@hufe921/canvas-editor 0.9.131 → 0.9.132
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/CHANGELOG.md +25 -0
- package/dist/canvas-editor.es.js +184 -30
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +21 -21
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/draw/Draw.d.ts +3 -0
- package/dist/src/editor/core/draw/interactive/Magnifier.d.ts +19 -0
- package/dist/src/editor/core/event/GlobalEvent.d.ts +1 -0
- package/dist/src/editor/core/observer/SelectionObserver.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Magnifier.d.ts +2 -0
- package/dist/src/editor/dataset/enum/KeyMap.d.ts +1 -0
- package/dist/src/editor/interface/Editor.d.ts +2 -0
- package/dist/src/editor/interface/Magnifier.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
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:14.28571%;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:14.28571%;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}')),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();})();
|
|
2
|
-
var
|
|
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:14.28571%;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:14.28571%;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-magnifier{position:fixed;pointer-events:none;z-index:9999;display:none;border-radius:50%;box-shadow:0 4px 12px #00000040}.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}')),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();})();
|
|
2
|
+
var Hl=Object.defineProperty,Gl=Object.defineProperties;var xl=Object.getOwnPropertyDescriptors;var mi=Object.getOwnPropertySymbols;var Jl=Object.prototype.hasOwnProperty,vl=Object.prototype.propertyIsEnumerable;var Mn=(R,ut,Xt)=>ut in R?Hl(R,ut,{enumerable:!0,configurable:!0,writable:!0,value:Xt}):R[ut]=Xt,Y=(R,ut)=>{for(var Xt in ut||(ut={}))Jl.call(ut,Xt)&&Mn(R,Xt,ut[Xt]);if(mi)for(var Xt of mi(ut))vl.call(ut,Xt)&&Mn(R,Xt,ut[Xt]);return R},B=(R,ut)=>Gl(R,xl(ut));var L=(R,ut,Xt)=>(Mn(R,typeof ut!="symbol"?ut+"":ut,Xt),Xt);(function(R,ut){typeof exports=="object"&&typeof module!="undefined"?ut(exports):typeof define=="function"&&define.amd?define(["exports"],ut):(R=typeof globalThis!="undefined"?globalThis:R||self,ut(R["canvas-editor"]={}))})(this,function(R){"use strict";var ut="";const Xt="0.9.132";R.MaxHeightRatio=void 0,function(r){r.HALF="half",r.ONE_THIRD="one-third",r.QUARTER="quarter"}(R.MaxHeightRatio||(R.MaxHeightRatio={})),R.NumberType=void 0,function(r){r.ARABIC="arabic",r.CHINESE="chinese"}(R.NumberType||(R.NumberType={})),R.ImageDisplay=void 0,function(r){r.INLINE="inline",r.BLOCK="block",r.SURROUND="surround",r.FLOAT_TOP="float-top",r.FLOAT_BOTTOM="float-bottom"}(R.ImageDisplay||(R.ImageDisplay={})),R.LocationPosition=void 0,function(r){r.BEFORE="before",r.AFTER="after",r.OUTER_BEFORE="outer-before",r.OUTER_AFTER="outer-after"}(R.LocationPosition||(R.LocationPosition={})),R.FlexDirection=void 0,function(r){r.ROW="row",r.COLUMN="column"}(R.FlexDirection||(R.FlexDirection={}));const y="\u200B",On=`
|
|
3
3
|
`,we=" ",Sn=" ",Fi=["\xB7","\u3001",":","\uFF1A",",","\uFF0C",".","\u3002",";","\uFF1B","?","\uFF1F","!","\uFF01"],Xn={[R.MaxHeightRatio.HALF]:1/2,[R.MaxHeightRatio.ONE_THIRD]:1/3,[R.MaxHeightRatio.QUARTER]:1/4},In={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"},Wi="\u4E2D";R.RowFlex=void 0,function(r){r.LEFT="left",r.CENTER="center",r.RIGHT="right",r.ALIGNMENT="alignment",r.JUSTIFY="justify"}(R.RowFlex||(R.RowFlex={}));const He=/[0-9.]/,Vi=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,pi=/[#*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,Zi=new RegExp(`${pi.source}|${Vi.source}`,"g"),Ui=/[、,。?!;:……「」“”‘’*()【】〔〕〖〗〘〙〚〛《》———﹝﹞–—\\/·.,!?;:`~<>()[\]{}'"|]/,Te=new RegExp(`^[${y}
|
|
4
|
-
]`),Yi=/[^0-9\+\-\.eE,]/,Qi=/\s/;function Ci(r,t){let e;return function(...n){e&&window.clearTimeout(e),e=window.setTimeout(()=>{r.apply(this,n)},t)}}function Ei(r,t){let e=0,n;return function(...o){const s=Date.now();s-e>=t?(window.clearTimeout(n),r.apply(this,o),e=s):(window.clearTimeout(n),n=window.setTimeout(()=>{r.apply(this,o),e=s},t))}}function Ge(r,t){if(!r||typeof r!="object")return r;let e={};return Array.isArray(r)?e=r.map(n=>Ge(n,t)):Object.keys(r).forEach(n=>{t.includes(n)||(e[n]=Ge(r[n],t))}),e}function $(r){if(typeof structuredClone=="function")return structuredClone(r);if(!r||typeof r!="object")return r;let t={};return Array.isArray(r)?t=r.map(e=>$(e)):Object.keys(r).forEach(e=>{t[e]=$(r[e])}),t}function xe(r){return r&&r.nodeType===1&&r.tagName.toLowerCase()==="body"}function me(r,t,e){if(r&&!xe(r))for(r=e?r:r.parentNode;r;){if(!t||t(r)||xe(r))return t&&!t(r)&&xe(r)?null:r;r=r.parentNode}return null}function j(){function r(){return((1+Math.random())*65536|0).toString(16).substring(1)}return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}function Qt(r){const t=[];if(Intl.Segmenter){const n=new Intl.Segmenter().segment(r);for(const{segment:o}of n)t.push(o)}else{const e=new Map;for(const o of r.matchAll(Zi))e.set(o.index,o[0]);let n=0;for(;n<r.length;){const o=e.get(n);o?(t.push(o),n+=o.length):(t.push(r[n]),n++)}}return t}function Nn(r,t){const e=document.createElement("a");e.href=r,e.download=t,e.click()}function Di(r,t){bi(3,r,t)}function bi(r,t,e){let n=0,o=0;const s=function(i){n=new Date().getTime()-o<300?n+1:0,o=new Date().getTime(),n>=r-1&&(e(i),n=0)};t.addEventListener("click",s)}function Fe(r){return Object.prototype.toString.call(r)==="[object Object]"}function Je(r){return Array.isArray(r)}function ve(r){return Object.prototype.toString.call(r)==="[object Number]"}function Ki(r){return Object.prototype.toString.call(r)==="[object String]"}function fn(r,t){if(Fe(r)&&Fe(t)){const e=t;for(const[n,o]of Object.entries(r))e[n]?e[n]=fn(o,e[n]):e[n]=o}else Je(r)&&Je(t)&&t.push(...r);return t}function Be(r){setTimeout(()=>{r()},0)}function yi(r){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(!r||isNaN(r))return"\u96F6";const n=r.toString().split("");let o="";for(let s=0;s<n.length;s++){const i=n.length-1-s;o=`${e[s]}${o}`,o=`${t[Number(n[i])]}${o}`}return o=o.replace(/零(千|百|十)/g,"\u96F6").replace(/十零/g,"\u5341"),o=o.replace(/零+/g,"\u96F6"),o=o.replace(/零亿/g,"\u4EBF").replace(/零万/g,"\u4E07"),o=o.replace(/亿万/g,"\u4EBF"),o=o.replace(/零+$/,""),o=o.replace(/^一十/g,"\u5341"),o}function
|
|
5
|
-
`)}function Vn(r,t,e=0){const n=Math.max(0,Math.floor(e));if(n>=r.length)return typeof t=="string"&&t===""?{index:r.length,length:0}:{index:-1,length:0};if(typeof t=="string"){if(t==="")return{index:n,length:0};const a=r.indexOf(t,n);return a===-1?{index:-1,length:0}:{index:a,length:t.length}}const o=t.flags,s=o.includes("g")?o:o+"g",i=new RegExp(t.source,s);i.lastIndex=n;const l=i.exec(r);return l?{index:l.index,length:l[0].length}:{index:-1,length:0}}function pn(r,t){if(!t){r.scrollTop=0;return}const e=[];let n=t.offsetParent;for(;n&&r!==n&&r.contains(n);)e.push(n),n=n.offsetParent;const o=t.offsetTop+e.reduce((a,c)=>a+c.offsetTop,0),s=o+t.offsetHeight,i=r.scrollTop,l=i+r.clientHeight;o<i?r.scrollTop=o:s>l&&(r.scrollTop=s-r.clientHeight)}const vi=12,Bi={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},_t="editor-component",v="ce",Ve=`${v}-clipboard`,ke={print:{imagePreviewerDisabled:!1,backgroundDisabled:!1,filterEmptyControl:!0},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1}};var Lt;(function(r){r.UP="top",r.DOWN="down",r.LEFT="left",r.RIGHT="right"})(Lt||(Lt={}));const
|
|
4
|
+
]`),Yi=/[^0-9\+\-\.eE,]/,Qi=/\s/;function Ci(r,t){let e;return function(...n){e&&window.clearTimeout(e),e=window.setTimeout(()=>{r.apply(this,n)},t)}}function Ei(r,t){let e=0,n;return function(...o){const s=Date.now();s-e>=t?(window.clearTimeout(n),r.apply(this,o),e=s):(window.clearTimeout(n),n=window.setTimeout(()=>{r.apply(this,o),e=s},t))}}function Ge(r,t){if(!r||typeof r!="object")return r;let e={};return Array.isArray(r)?e=r.map(n=>Ge(n,t)):Object.keys(r).forEach(n=>{t.includes(n)||(e[n]=Ge(r[n],t))}),e}function $(r){if(typeof structuredClone=="function")return structuredClone(r);if(!r||typeof r!="object")return r;let t={};return Array.isArray(r)?t=r.map(e=>$(e)):Object.keys(r).forEach(e=>{t[e]=$(r[e])}),t}function xe(r){return r&&r.nodeType===1&&r.tagName.toLowerCase()==="body"}function me(r,t,e){if(r&&!xe(r))for(r=e?r:r.parentNode;r;){if(!t||t(r)||xe(r))return t&&!t(r)&&xe(r)?null:r;r=r.parentNode}return null}function j(){function r(){return((1+Math.random())*65536|0).toString(16).substring(1)}return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}function Qt(r){const t=[];if(Intl.Segmenter){const n=new Intl.Segmenter().segment(r);for(const{segment:o}of n)t.push(o)}else{const e=new Map;for(const o of r.matchAll(Zi))e.set(o.index,o[0]);let n=0;for(;n<r.length;){const o=e.get(n);o?(t.push(o),n+=o.length):(t.push(r[n]),n++)}}return t}function Nn(r,t){const e=document.createElement("a");e.href=r,e.download=t,e.click()}function Di(r,t){bi(3,r,t)}function bi(r,t,e){let n=0,o=0;const s=function(i){n=new Date().getTime()-o<300?n+1:0,o=new Date().getTime(),n>=r-1&&(e(i),n=0)};t.addEventListener("click",s)}function Fe(r){return Object.prototype.toString.call(r)==="[object Object]"}function Je(r){return Array.isArray(r)}function ve(r){return Object.prototype.toString.call(r)==="[object Number]"}function Ki(r){return Object.prototype.toString.call(r)==="[object String]"}function fn(r,t){if(Fe(r)&&Fe(t)){const e=t;for(const[n,o]of Object.entries(r))e[n]?e[n]=fn(o,e[n]):e[n]=o}else Je(r)&&Je(t)&&t.push(...r);return t}function Be(r){setTimeout(()=>{r()},0)}function yi(r){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(!r||isNaN(r))return"\u96F6";const n=r.toString().split("");let o="";for(let s=0;s<n.length;s++){const i=n.length-1-s;o=`${e[s]}${o}`,o=`${t[Number(n[i])]}${o}`}return o=o.replace(/零(千|百|十)/g,"\u96F6").replace(/十零/g,"\u5341"),o=o.replace(/零+/g,"\u96F6"),o=o.replace(/零亿/g,"\u4EBF").replace(/零万/g,"\u4E07"),o=o.replace(/亿万/g,"\u4EBF"),o=o.replace(/零+$/,""),o=o.replace(/^一十/g,"\u5341"),o}function qt(r,t,e){for(let n=0;n<r.length;n++){const o=r[n],s=t[o];s!==void 0?e[o]=s:delete e[o]}}function mn(r,t){if(!(!t.length||!r.length))for(let e=r.length-1;e>=0;e--)t.includes(r[e])&&r.splice(e,1)}function pt(r,t){const e={};for(const n in r)t.includes(n)&&(e[n]=r[n]);return e}function Ht(r,t){const e={};for(const n in r)t.includes(n)||(e[n]=r[n]);return e}function wi(r){const e=new TextEncoder().encode(r),n=Array.from(e,s=>String.fromCharCode(s));return window.btoa(n.join(""))}function Hi(r){let t=r.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 Fn(r,t){return r.length!==t.length?!1:!r.some(e=>!t.includes(e))}function Gi(r,t){if(!Fe(r)||!Fe(t))return!1;const e=Object.keys(r),n=Object.keys(t);return e.length!==n.length?!1:!e.some(o=>t[o]!==r[o])}function xi(r,t){const e=r.x,n=r.x+r.width,o=r.y,s=r.y+r.height,i=t.x,l=t.x+t.width,a=t.y,c=t.y+t.height;return!(e>l||n<i||o>c||s<a)}function Wn(r){return r==null}function Ji(r){return new Promise((t,e)=>{const n=new Image;n.onload=()=>t(n),n.onerror=e,n.src=r})}function We(r){return r.replace(/\r\n|\r/g,`
|
|
5
|
+
`)}function Vn(r,t,e=0){const n=Math.max(0,Math.floor(e));if(n>=r.length)return typeof t=="string"&&t===""?{index:r.length,length:0}:{index:-1,length:0};if(typeof t=="string"){if(t==="")return{index:n,length:0};const a=r.indexOf(t,n);return a===-1?{index:-1,length:0}:{index:a,length:t.length}}const o=t.flags,s=o.includes("g")?o:o+"g",i=new RegExp(t.source,s);i.lastIndex=n;const l=i.exec(r);return l?{index:l.index,length:l[0].length}:{index:-1,length:0}}function pn(r,t){if(!t){r.scrollTop=0;return}const e=[];let n=t.offsetParent;for(;n&&r!==n&&r.contains(n);)e.push(n),n=n.offsetParent;const o=t.offsetTop+e.reduce((a,c)=>a+c.offsetTop,0),s=o+t.offsetHeight,i=r.scrollTop,l=i+r.clientHeight;o<i?r.scrollTop=o:s>l&&(r.scrollTop=s-r.clientHeight)}const vi=12,Bi={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},_t="editor-component",v="ce",Ve=`${v}-clipboard`,ke={print:{imagePreviewerDisabled:!1,backgroundDisabled:!1,filterEmptyControl:!0},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1}};var Lt;(function(r){r.UP="top",r.DOWN="down",r.LEFT="left",r.RIGHT="right"})(Lt||(Lt={}));const Gt=typeof navigator!="undefined"&&/Mac OS X/.test(navigator.userAgent),ki=typeof navigator!="undefined"&&/iPad|iPhone/.test(navigator.userAgent),Ai=/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),_i=typeof navigator!="undefined"&&/Firefox/.test(navigator.userAgent);R.ElementType=void 0,function(r){r.TEXT="text",r.IMAGE="image",r.TABLE="table",r.HYPERLINK="hyperlink",r.SUPERSCRIPT="superscript",r.SUBSCRIPT="subscript",r.SEPARATOR="separator",r.PAGE_BREAK="pageBreak",r.CONTROL="control",r.AREA="area",r.CHECKBOX="checkbox",r.RADIO="radio",r.LATEX="latex",r.TAB="tab",r.DATE="date",r.BLOCK="block",r.TITLE="title",r.LIST="list",r.LABEL="label"}(R.ElementType||(R.ElementType={}));const Dt=["bold","color","highlight","font","size","italic","underline","strikeout","textDecoration"],te=["rowFlex","rowMargin"],zi=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","url","areaId","hyperlinkId","dateId","dateFormat","groupIds","rowMargin","textDecoration"],$i=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","rowMargin","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"],ji=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],Pe=["tdId","trId","tableId"],Ae=["level","titleId","title"],pe=["listId","listType","listStyle"],_e=["control","controlId","controlComponent"],xt=["font","size","bold","highlight","italic","strikeout"],se=["areaId","area"],Zn=[...Pe,...Ae,...pe,...se],bt=[R.ElementType.TEXT,R.ElementType.HYPERLINK,R.ElementType.SUBSCRIPT,R.ElementType.SUPERSCRIPT,R.ElementType.CONTROL,R.ElementType.DATE],qi=[R.ElementType.IMAGE,R.ElementType.LATEX],to=[R.ElementType.BLOCK,R.ElementType.PAGE_BREAK,R.ElementType.SEPARATOR,R.ElementType.TABLE],eo=["HR","TABLE","UL","OL"],no=[R.ElementType.TITLE,R.ElementType.LIST],be=class{constructor(t){L(this,"element");L(this,"iframe",null);L(this,"isReadonly");this.element=t,this.isReadonly=!1}getIframe(){return this.iframe}_defineIframeProperties(t){Object.defineProperties(t,{parent:{get:()=>null},__POWERED_BY_CANVAS_EDITOR__:{get:()=>!0}})}render(t){const{iframeBlock:e}=this.element.block||{},n=document.createElement("iframe");n.setAttribute("data-id",this.element.id),n.sandbox.add(...(e==null?void 0:e.sandbox)||be.sandbox),n.setAttribute("allow",[(e==null?void 0:e.allow)||be.allow].join(" ")),n.style.border="none",n.style.width="100%",n.style.height="100%",(e==null?void 0:e.src)?n.src=e.src:(e==null?void 0:e.srcdoc)&&(n.srcdoc=e.srcdoc),t.append(n),this._defineIframeProperties(n.contentWindow),this.iframe=n}setReadonly(t){!this.iframe||this.isReadonly===t||(this.isReadonly=t,t?(this.iframe.style.pointerEvents="none",this.iframe.setAttribute("tabindex","-1")):(this.iframe.style.pointerEvents="",this.iframe.removeAttribute("tabindex")))}};let zt=be;L(zt,"sandbox",["allow-scripts","allow-same-origin"]),L(zt,"allow",["fullscreen"]);class Un{constructor(t){L(this,"draw");L(this,"options");L(this,"imageCache");L(this,"container");L(this,"floatImageContainer");L(this,"floatImage");this.draw=t,this.options=t.getOptions(),this.container=t.getContainer(),this.imageCache=new Map,this.floatImageContainer=null,this.floatImage=null}getOriginalMainImageList(){const t=[],e=n=>{for(const o of n)if(o.type===R.ElementType.TABLE){const s=o.trList;for(let i=0;i<s.length;i++){const l=s[i];for(let a=0;a<l.tdList.length;a++){const c=l.tdList[a];e(c.value)}}}else o.type===R.ElementType.IMAGE&&t.push(o)};return e(this.draw.getOriginalMainElementList()),t}_countImagesBeforeTarget(t,e){let n=0;for(const o of t){if(o===e)break;if(o.type===R.ElementType.TABLE){const s=o.trList;for(const i of s)for(const l of i.tdList)n+=this._countImagesBeforeTarget(l.value,e)}else o.type===R.ElementType.IMAGE&&n++}return n}createFloatImage(t){const{scale:e}=this.options;let n=this.floatImageContainer,o=this.floatImage;n||(n=document.createElement("div"),n.classList.add(`${v}-float-image`),this.container.append(n),this.floatImageContainer=n),o||(o=document.createElement("img"),n.append(o),this.floatImage=o),n.style.display="none",o.style.width=`${t.width*e}px`,o.style.height=`${t.height*e}px`;const s=this.draw.getHeight(),i=this.draw.getPageGap(),l=this.draw.getPageNo()*(s+i),a=t.imgFloatPosition;n.style.left=`${a.x*e}px`,n.style.top=`${l+a.y*e}px`,o.src=t.value}dragFloatImage(t,e){if(!this.floatImageContainer)return;this.floatImageContainer.style.display="block";const n=parseFloat(this.floatImageContainer.style.left)+t,o=parseFloat(this.floatImageContainer.style.top)+e;this.floatImageContainer.style.left=`${n}px`,this.floatImageContainer.style.top=`${o}px`}destroyFloatImage(){this.floatImageContainer&&(this.floatImageContainer.style.display="none")}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const n=8,o=(t-Math.ceil(t/n)*n)/2,s=(e-Math.ceil(e/n)*n)/2,i=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
|
|
6
6
|
<rect width="${t}" height="${e}" fill="url(#mosaic)" />
|
|
7
7
|
<defs>
|
|
8
8
|
<pattern id="mosaic" x="${o}" y="${s}" width="${n*2}" height="${n*2}" patternUnits="userSpaceOnUse">
|
|
@@ -58,19 +58,19 @@ trailer
|
|
|
58
58
|
>>startxref
|
|
59
59
|
|
|
60
60
|
%%EOF
|
|
61
|
-
`,a+c}boxes(t){t||(t={});const[e,n,o,s]=this.resolveScale(t),i=[];for(let l=0;l<this._tree.chld.length;l++){const{x:a,y:c,w:d,h}=this._tree.chld[l].bbox;i.push({x:e+a*o,y:n+c*s,w:d*o,h:h*s})}return i}box(t){t||(t={});const[e,n,o,s]=this.resolveScale(t);return{x:e+this._tree.bbox.x*o,y:n+this._tree.bbox.y*s,w:this._tree.bbox.w*o,h:this._tree.bbox.h*s}}}class Cn extends Un{static convertLaTextToSVG(t){return new ho(t).svg({SCALE_X:10,SCALE_Y:10,MARGIN_X:0,MARGIN_Y:0})}render(t,e,n,o){const{scale:s}=this.options,i=e.width*s,l=e.height*s;if(this.imageCache.has(e.value)){const a=this.imageCache.get(e.value);t.drawImage(a,n,o,i,l)}else{const a=new Promise((c,d)=>{const h=new Image;h.src=e.laTexSVG,h.onload=()=>{t.drawImage(h,n,o,i,l),this.imageCache.set(e.value,h),c(e)},h.onerror=u=>{d(u)}});this.addImageObserver(a)}}}R.ListType=void 0,function(r){r.UL="ul",r.OL="ol"}(R.ListType||(R.ListType={}));var ee;(function(r){r.DISC="disc",r.CIRCLE="circle",r.SQUARE="square",r.CHECKBOX="checkbox"})(ee||(ee={}));var En;(function(r){r.DECIMAL="decimal"})(En||(En={})),R.ListStyle=void 0,function(r){r.DISC="disc",r.CIRCLE="circle",r.SQUARE="square",r.DECIMAL="decimal",r.CHECKBOX="checkbox"}(R.ListStyle||(R.ListStyle={}));const uo={inheritStyle:!1},je={[ee.DISC]:"\u2022",[ee.CIRCLE]:"\u25E6",[ee.SQUARE]:"\u25AB\uFE0E",[ee.CHECKBOX]:"\u2611\uFE0F"},go={[R.ListType.OL]:"ol",[R.ListType.UL]:"ul"},Lo={[R.ListStyle.DISC]:"disc",[R.ListStyle.CIRCLE]:"circle",[R.ListStyle.SQUARE]:"square",[R.ListStyle.DECIMAL]:"decimal",[R.ListStyle.CHECKBOX]:"checkbox"};R.TitleLevel=void 0,function(r){r.FIRST="first",r.SECOND="second",r.THIRD="third",r.FOURTH="fourth",r.FIFTH="fifth",r.SIXTH="sixth"}(R.TitleLevel||(R.TitleLevel={}));const To={defaultFirstSize:26,defaultSecondSize:24,defaultThirdSize:22,defaultFourthSize:20,defaultFifthSize:18,defaultSixthSize:16},Dn={[R.TitleLevel.FIRST]:"defaultFirstSize",[R.TitleLevel.SECOND]:"defaultSecondSize",[R.TitleLevel.THIRD]:"defaultThirdSize",[R.TitleLevel.FOURTH]:"defaultFourthSize",[R.TitleLevel.FIFTH]:"defaultFifthSize",[R.TitleLevel.SIXTH]:"defaultSixthSize"},qe={[R.TitleLevel.FIRST]:1,[R.TitleLevel.SECOND]:2,[R.TitleLevel.THIRD]:3,[R.TitleLevel.FOURTH]:4,[R.TitleLevel.FIFTH]:5,[R.TitleLevel.SIXTH]:6},Po={H1:R.TitleLevel.FIRST,H2:R.TitleLevel.SECOND,H3:R.TitleLevel.THIRD,H4:R.TitleLevel.FOURTH,H5:R.TitleLevel.FIFTH,H6:R.TitleLevel.SIXTH};R.BlockType=void 0,function(r){r.IFRAME="iframe",r.VIDEO="video"}(R.BlockType||(R.BlockType={})),R.ControlType=void 0,function(r){r.TEXT="text",r.SELECT="select",r.CHECKBOX="checkbox",r.RADIO="radio",r.DATE="date",r.NUMBER="number"}(R.ControlType||(R.ControlType={})),R.ControlComponent=void 0,function(r){r.PREFIX="prefix",r.POSTFIX="postfix",r.PRE_TEXT="preText",r.POST_TEXT="postText",r.PLACEHOLDER="placeholder",r.VALUE="value",r.CHECKBOX="checkbox",r.RADIO="radio"}(R.ControlComponent||(R.ControlComponent={})),R.ControlIndentation=void 0,function(r){r.ROW_START="rowStart",r.VALUE_START="valueStart"}(R.ControlIndentation||(R.ControlIndentation={})),R.ControlState=void 0,function(r){r.ACTIVE="active",r.INACTIVE="inactive"}(R.ControlState||(R.ControlState={}));var at;(function(r){r.NUMBER="number",r.OPERATOR="operator",r.UTILITY="utility",r.EQUAL="equal"})(at||(at={})),R.EditorComponent=void 0,function(r){r.COMPONENT="component",r.MENU="menu",r.MAIN="main",r.FOOTER="footer",r.CONTEXTMENU="contextmenu",r.POPUP="popup",r.CATALOG="catalog",r.COMMENT="comment"}(R.EditorComponent||(R.EditorComponent={}));var Bt;(function(r){r.PAGE="page",r.TABLE="table"})(Bt||(Bt={})),R.EditorMode=void 0,function(r){r.EDIT="edit",r.CLEAN="clean",r.READONLY="readonly",r.FORM="form",r.PRINT="print",r.DESIGN="design",r.GRAFFITI="graffiti"}(R.EditorMode||(R.EditorMode={})),R.EditorZone=void 0,function(r){r.HEADER="header",r.MAIN="main",r.FOOTER="footer"}(R.EditorZone||(R.EditorZone={})),R.PageMode=void 0,function(r){r.PAGING="paging",r.CONTINUITY="continuity"}(R.PageMode||(R.PageMode={})),R.PaperDirection=void 0,function(r){r.VERTICAL="vertical",r.HORIZONTAL="horizontal"}(R.PaperDirection||(R.PaperDirection={})),R.WordBreak=void 0,function(r){r.BREAK_ALL="break-all",r.BREAK_WORD="break-word"}(R.WordBreak||(R.WordBreak={})),R.RenderMode=void 0,function(r){r.SPEED="speed",r.COMPATIBILITY="compatibility"}(R.RenderMode||(R.RenderMode={})),R.TableBorder=void 0,function(r){r.ALL="all",r.EMPTY="empty",r.EXTERNAL="external",r.INTERNAL="internal",r.DASH="dash"}(R.TableBorder||(R.TableBorder={})),R.TdBorder=void 0,function(r){r.TOP="top",r.RIGHT="right",r.BOTTOM="bottom",r.LEFT="left"}(R.TdBorder||(R.TdBorder={})),R.TdSlash=void 0,function(r){r.FORWARD="forward",r.BACK="back"}(R.TdSlash||(R.TdSlash={})),R.BackgroundSize=void 0,function(r){r.CONTAIN="contain",r.COVER="cover"}(R.BackgroundSize||(R.BackgroundSize={})),R.BackgroundRepeat=void 0,function(r){r.REPEAT="repeat",r.NO_REPEAT="no-repeat",r.REPEAT_X="repeat-x",r.REPEAT_Y="repeat-y"}(R.BackgroundRepeat||(R.BackgroundRepeat={}));const Mo={color:"#FFFFFF",image:"",size:R.BackgroundSize.COVER,repeat:R.BackgroundRepeat.NO_REPEAT,applyPageNumbers:[]};R.VerticalAlign=void 0,function(r){r.TOP="top",r.MIDDLE="middle",r.BOTTOM="bottom"}(R.VerticalAlign||(R.VerticalAlign={}));const Oo={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#ffffff",strokeStyle:"#000000",checkFillStyle:"#5175f4",checkStrokeStyle:"#5175f4",checkMarkColor:"#ffffff",verticalAlign:R.VerticalAlign.BOTTOM},So={placeholderColor:"#9c9b9b",bracketColor:"#000000",prefix:"{",postfix:"}",borderWidth:1,borderColor:"#000000",activeBackgroundColor:"",disabledBackgroundColor:"",existValueBackgroundColor:"",noValueBackgroundColor:""},Xo={bottom:30,inactiveAlpha:1,maxHeightRadio:R.MaxHeightRatio.HALF,disabled:!1,editable:!0},Io={opacity:.1,backgroundColor:"#E99D00",activeOpacity:.5,activeBackgroundColor:"#E99D00",disabled:!1,deletable:!0},No={top:30,inactiveAlpha:1,maxHeightRadio:R.MaxHeightRatio.HALF,disabled:!1,editable:!0},fo={defaultColor:"#1976d2",defaultBackgroundColor:"#e3f2fd",defaultBorderRadius:4,defaultPadding:[4,4,4,4]},mo={color:"#666666",font:"Microsoft YaHei",size:12,top:5},Fo={disabled:!0,color:"#CCCCCC",lineWidth:1.5},Wo={font:"Microsoft YaHei",fontSize:12,lineDash:[3,1]},Me={PAGE_NO:"{pageNo}",PAGE_COUNT:"{pageCount}"},Vo={bottom:60,size:12,font:"Microsoft YaHei",color:"#000000",rowFlex:R.RowFlex.CENTER,format:Me.PAGE_NO,numberType:R.NumberType.ARABIC,disabled:!1,startPageNo:1,fromPageNo:0,maxPageNo:null},bn={data:"",color:"#DCDFE6",opacity:1,size:16,font:"Microsoft YaHei"},po={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#000000",verticalAlign:R.VerticalAlign.BOTTOM},Zo={lineWidth:1,strokeStyle:"#000000"},Uo={tdPadding:[0,5,5,5],defaultTrMinHeight:42,defaultColMinWidth:40,defaultBorderColor:"#000000",overflow:!0};R.WatermarkType=void 0,function(r){r.TEXT="text",r.IMAGE="image"}(R.WatermarkType||(R.WatermarkType={})),R.WatermarkLayer=void 0,function(r){r.BOTTOM="bottom",r.TOP="top"}(R.WatermarkLayer||(R.WatermarkLayer={}));const tn={data:"",type:R.WatermarkType.TEXT,width:0,height:0,color:"#AEB5C0",opacity:.3,size:200,font:"Microsoft YaHei",repeat:!1,gap:[10,10],numberType:R.NumberType.ARABIC,layer:R.WatermarkLayer.BOTTOM},Yo={tipDisabled:!0};R.LineNumberType=void 0,function(r){r.PAGE="page",r.CONTINUITY="continuity"}(R.LineNumberType||(R.LineNumberType={}));const Qo={size:12,font:"Microsoft YaHei",color:"#000000",disabled:!0,right:20,type:R.LineNumberType.CONTINUITY},Co={color:"#000000",lineWidth:1,padding:[0,5,0,5],disabled:!0},Eo={top:0,left:5},Do={defaultLineColor:"#000000",defaultLineWidth:2},bo={disabled:!0,color:"#CCCCCC",radius:1};function en(r={}){var C,D,W;const t=Y(Y({},Uo),r.table),e=Y(Y({},No),r.header),n=Y(Y({},Xo),r.footer),o=Y(Y({},Vo),r.pageNumber),s=Y(Y({},tn),r.watermark),i=Y(Y({},So),r.control),l=Y(Y({},Oo),r.checkbox),a=Y(Y({},po),r.radio),c=Y(Y({},Bi),r.cursor),d=Y(Y({},To),r.title),h=Y(Y({},bn),r.placeholder),u=Y(Y({},Io),r.group),g=Y(Y({},Wo),r.pageBreak),T=Y(Y({},Yo),r.zone),P=Y(Y({},Mo),r.background),O=Y(Y({},Fo),r.lineBreak),M=Y(Y({},bo),r.whiteSpace),S=Y(Y({},Zo),r.separator),X=Y(Y({},Qo),r.lineNumber),N=Y(Y({},Co),r.pageBorder),m=Y(Y({},Eo),r.badge),I=Y(Y({},Do),r.graffiti),f=Y(Y({},fo),r.label),F=Y(Y({},mo),r.imgCaption),V=Y(Y({},uo),r.list),Z={print:Y(Y({},ke.print),(C=r.modeRule)==null?void 0:C.print),readonly:Y(Y({},ke.readonly),(D=r.modeRule)==null?void 0:D.readonly),form:Y(Y({},ke.form),(W=r.modeRule)==null?void 0:W.form)};return B(Y({mode:R.EditorMode.EDIT,locale:"zhCN",defaultType:"TEXT",defaultColor:"#000000",defaultFont:"Microsoft YaHei",defaultSize:16,minSize:5,maxSize:72,defaultRowMargin:1,defaultBasicRowMarginHeight:8,defaultTabWidth:32,width:794,height:1123,scale:1,pageGap:20,underlineColor:"#000000",strikeoutColor:"#FF0000",rangeAlpha:.6,rangeColor:"#AECBFA",rangeMinWidth:5,searchMatchAlpha:.6,searchMatchColor:"#FFFF00",searchNavigateMatchColor:"#AAD280",highlightAlpha:.6,highlightMarginHeight:8,resizerColor:"#4182D9",resizerSize:5,marginIndicatorSize:35,marginIndicatorColor:"#BABABA",margins:[100,120,100,120],pageMode:R.PageMode.PAGING,renderMode:R.RenderMode.SPEED,defaultHyperlinkColor:"#0000FF",paperDirection:R.PaperDirection.VERTICAL,inactiveAlpha:.6,historyMaxRecordCount:100,wordBreak:R.WordBreak.BREAK_WORD,printPixelRatio:3,maskMargin:[0,0,0,0],letterClass:[In.ENGLISH],contextMenuDisableKeys:[],shortcutDisableKeys:[],scrollContainerSelector:"",pageOuterSelectionDisable:!1},r),{table:t,header:e,footer:n,pageNumber:o,watermark:s,control:i,checkbox:l,radio:a,cursor:c,title:d,placeholder:h,group:u,pageBreak:g,zone:T,background:P,lineBreak:O,whiteSpace:M,separator:S,lineNumber:X,pageBorder:N,badge:m,modeRule:Z,graffiti:I,label:f,imgCaption:F,list:V})}function Kn(r){const t=[];for(let e=0;e<r.length;e++){const n=r[e],o=Qt(n.value);for(let s=0;s<o.length;s++)t.push(B(Y({},n),{value:o[s]}))}return t}function Pt(r,t){var l,a,c;const{isHandleFirstElement:e=!0,isForceCompensation:n=!1,editorOptions:o}=t,s=r[0];(s==null?void 0:s.type)!==R.ElementType.LIST&&(n||e&&((s==null?void 0:s.type)&&s.type!==R.ElementType.TEXT||!Te.test(s==null?void 0:s.value)))&&r.unshift({value:y});let i=0;for(;i<r.length;){let d=r[i];if(d.type===R.ElementType.TITLE){r.splice(i,1);const h=d.valueList||[];if(Pt(h,B(Y({},t),{isHandleFirstElement:!1,isForceCompensation:!1})),h.length){const u=d.titleId||j(),g=o.title;for(let T=0;T<h.length;T++){const P=h[T];P.title=d.title,d.level&&(P.titleId=u,P.level=d.level),Ye(P)&&(P.size||(P.size=g[Dn[P.level]]),P.bold===void 0&&(P.bold=!0)),r.splice(i,0,P),i++}}i--}else if(d.type===R.ElementType.LIST){r.splice(i,1);const h=d.valueList||[];if(Pt(h,B(Y({},t),{isHandleFirstElement:!0,isForceCompensation:!1})),h.length){const u=j();for(let g=0;g<h.length;g++){const T=h[g];T.listId=u,T.listType=d.listType,T.listStyle=d.listStyle,r.splice(i,0,T),i++}r[i]&&(((l=r[i].valueList)==null?void 0:l.length)?!Te.test(r[i].valueList[0].value):!Te.test(r[i].value))&&(r.splice(i,0,{value:y}),i++)}i--}else if(d.type===R.ElementType.AREA){r.splice(i,1);const h=(d==null?void 0:d.valueList)||[];if(Pt(h,B(Y({},t),{isHandleFirstElement:!0,isForceCompensation:!0})),h.length){const u=j();for(let g=0;g<h.length;g++){const T=h[g];if(T.areaId=d.areaId||u,T.area=d.area,T.areaIndex=g,T.type===R.ElementType.TABLE){const P=T.trList;for(let O=0;O<P.length;O++){const M=P[O];for(let S=0;S<M.tdList.length;S++){const N=M.tdList[S].value;for(let m=0;m<N.length;m++){const I=N[m];I.areaId=d.areaId||u,I.area=d.area}}}}r.splice(i,0,T),i++}}i--}else if(d.type===R.ElementType.TABLE){const h=d.id||j();if(d.id=h,d.trList){const{defaultTrMinHeight:u}=o.table;for(let g=0;g<d.trList.length;g++){const T=d.trList[g],P=T.id||j();T.id=P,(!T.minHeight||T.minHeight<u)&&(T.minHeight=u),T.height<T.minHeight&&(T.height=T.minHeight);for(let O=0;O<T.tdList.length;O++){const M=T.tdList[O],S=M.id||j();M.id=S,Pt(M.value,B(Y({},t),{isHandleFirstElement:!0,isForceCompensation:!0})),!M.value[0].size&&((a=M.value[1])==null?void 0:a.size)&&Ye(M.value[1])&&(M.value[0].size=M.value[1].size);for(let X=0;X<M.value.length;X++){const N=M.value[X];N.tdId=S,N.trId=P,N.tableId=h}}}}}else if(d.type===R.ElementType.HYPERLINK){r.splice(i,1);const h=Kn(d.valueList||[]);if(h.length){const u=j();for(let g=0;g<h.length;g++){const T=h[g];T.type=d.type,T.url=d.url,T.hyperlinkId=u,r.splice(i,0,T),i++}}i--}else if(d.type===R.ElementType.DATE){r.splice(i,1);const h=Kn(d.valueList||[]);if(h.length){const u=j();for(let g=0;g<h.length;g++){const T=h[g];T.type=d.type,T.dateFormat=d.dateFormat,T.dateId=u,r.splice(i,0,T),i++}}i--}else if(d.type===R.ElementType.CONTROL){if(!d.control){i++;continue}const{prefix:h,postfix:u,preText:g,postText:T,value:P,placeholder:O,code:M,type:S,valueSets:X}=d.control,{editorOptions:{control:N,checkbox:m,radio:I}}=t,f=d.controlId||j();r.splice(i,1);const F=pt(d,[...Zn,...te]),V=pt(d.control,xt),Z=B(Y({},V),{color:o.control.bracketColor}),C=Qt(h||N.prefix);for(let W=0;W<C.length;W++){const E=C[W];r.splice(i,0,B(Y(Y({},F),Z),{controlId:f,value:E,type:d.type,control:d.control,controlComponent:R.ControlComponent.PREFIX})),i++}if(g){const W=Qt(g);for(let E=0;E<W.length;E++){const U=W[E];r.splice(i,0,B(Y(Y({},F),V),{controlId:f,value:U,type:d.type,control:d.control,controlComponent:R.ControlComponent.PRE_TEXT})),i++}}if(P&&P.length||S===R.ControlType.CHECKBOX||S===R.ControlType.RADIO||S===R.ControlType.SELECT&&M&&(!P||!P.length)){let W=P?$(P):[];if(S===R.ControlType.CHECKBOX){const E=M?M.split(","):[];if(Array.isArray(X)&&X.length){const U=W.reduce((w,K)=>w.concat(K.value.split("").map(p=>B(Y({},K),{value:p}))),[]);let Q=0;for(let w=0;w<X.length;w++){const K=X[w];r.splice(i,0,B(Y(Y({},F),V),{controlId:f,value:"",type:d.type,control:d.control,controlComponent:R.ControlComponent.CHECKBOX,checkbox:{code:K.code,value:E.includes(K.code)}})),i++;const p=Qt(K.value);for(let G=0;G<p.length;G++){const H=p[G],x=G===p.length-1;r.splice(i,0,B(Y(Y(Y({},F),V),U[Q]),{controlId:f,value:H===`
|
|
62
|
-
`?y:H,letterSpacing:x?m.gap:0,control:d.control,controlComponent:R.ControlComponent.VALUE})),Q++,i++}}}}else if(S===R.ControlType.RADIO){if(Array.isArray(X)&&X.length){const
|
|
63
|
-
`?y:G,letterSpacing:H?I.gap:0,control:d.control,controlComponent:R.ControlComponent.VALUE})),U++,i++}}}}else{if((!P||!P.length)&&Array.isArray(X)&&X.length){const
|
|
64
|
-
`?y:Q,type:U.type||R.ElementType.TEXT,control:d.control,controlComponent:R.ControlComponent.VALUE})),i++}}}else if(O){const W=B(Y({},V),{color:o.control.placeholderColor}),
|
|
65
|
-
`?y:Q,type:d.type,control:d.control,controlComponent:R.ControlComponent.PLACEHOLDER})),i++}}if(T){const W=Qt(T);for(let
|
|
61
|
+
`,a+c}boxes(t){t||(t={});const[e,n,o,s]=this.resolveScale(t),i=[];for(let l=0;l<this._tree.chld.length;l++){const{x:a,y:c,w:d,h}=this._tree.chld[l].bbox;i.push({x:e+a*o,y:n+c*s,w:d*o,h:h*s})}return i}box(t){t||(t={});const[e,n,o,s]=this.resolveScale(t);return{x:e+this._tree.bbox.x*o,y:n+this._tree.bbox.y*s,w:this._tree.bbox.w*o,h:this._tree.bbox.h*s}}}class Cn extends Un{static convertLaTextToSVG(t){return new ho(t).svg({SCALE_X:10,SCALE_Y:10,MARGIN_X:0,MARGIN_Y:0})}render(t,e,n,o){const{scale:s}=this.options,i=e.width*s,l=e.height*s;if(this.imageCache.has(e.value)){const a=this.imageCache.get(e.value);t.drawImage(a,n,o,i,l)}else{const a=new Promise((c,d)=>{const h=new Image;h.src=e.laTexSVG,h.onload=()=>{t.drawImage(h,n,o,i,l),this.imageCache.set(e.value,h),c(e)},h.onerror=u=>{d(u)}});this.addImageObserver(a)}}}R.ListType=void 0,function(r){r.UL="ul",r.OL="ol"}(R.ListType||(R.ListType={}));var ee;(function(r){r.DISC="disc",r.CIRCLE="circle",r.SQUARE="square",r.CHECKBOX="checkbox"})(ee||(ee={}));var En;(function(r){r.DECIMAL="decimal"})(En||(En={})),R.ListStyle=void 0,function(r){r.DISC="disc",r.CIRCLE="circle",r.SQUARE="square",r.DECIMAL="decimal",r.CHECKBOX="checkbox"}(R.ListStyle||(R.ListStyle={}));const uo={inheritStyle:!1},je={[ee.DISC]:"\u2022",[ee.CIRCLE]:"\u25E6",[ee.SQUARE]:"\u25AB\uFE0E",[ee.CHECKBOX]:"\u2611\uFE0F"},go={[R.ListType.OL]:"ol",[R.ListType.UL]:"ul"},Lo={[R.ListStyle.DISC]:"disc",[R.ListStyle.CIRCLE]:"circle",[R.ListStyle.SQUARE]:"square",[R.ListStyle.DECIMAL]:"decimal",[R.ListStyle.CHECKBOX]:"checkbox"};R.TitleLevel=void 0,function(r){r.FIRST="first",r.SECOND="second",r.THIRD="third",r.FOURTH="fourth",r.FIFTH="fifth",r.SIXTH="sixth"}(R.TitleLevel||(R.TitleLevel={}));const To={defaultFirstSize:26,defaultSecondSize:24,defaultThirdSize:22,defaultFourthSize:20,defaultFifthSize:18,defaultSixthSize:16},Dn={[R.TitleLevel.FIRST]:"defaultFirstSize",[R.TitleLevel.SECOND]:"defaultSecondSize",[R.TitleLevel.THIRD]:"defaultThirdSize",[R.TitleLevel.FOURTH]:"defaultFourthSize",[R.TitleLevel.FIFTH]:"defaultFifthSize",[R.TitleLevel.SIXTH]:"defaultSixthSize"},qe={[R.TitleLevel.FIRST]:1,[R.TitleLevel.SECOND]:2,[R.TitleLevel.THIRD]:3,[R.TitleLevel.FOURTH]:4,[R.TitleLevel.FIFTH]:5,[R.TitleLevel.SIXTH]:6},Po={H1:R.TitleLevel.FIRST,H2:R.TitleLevel.SECOND,H3:R.TitleLevel.THIRD,H4:R.TitleLevel.FOURTH,H5:R.TitleLevel.FIFTH,H6:R.TitleLevel.SIXTH};R.BlockType=void 0,function(r){r.IFRAME="iframe",r.VIDEO="video"}(R.BlockType||(R.BlockType={})),R.ControlType=void 0,function(r){r.TEXT="text",r.SELECT="select",r.CHECKBOX="checkbox",r.RADIO="radio",r.DATE="date",r.NUMBER="number"}(R.ControlType||(R.ControlType={})),R.ControlComponent=void 0,function(r){r.PREFIX="prefix",r.POSTFIX="postfix",r.PRE_TEXT="preText",r.POST_TEXT="postText",r.PLACEHOLDER="placeholder",r.VALUE="value",r.CHECKBOX="checkbox",r.RADIO="radio"}(R.ControlComponent||(R.ControlComponent={})),R.ControlIndentation=void 0,function(r){r.ROW_START="rowStart",r.VALUE_START="valueStart"}(R.ControlIndentation||(R.ControlIndentation={})),R.ControlState=void 0,function(r){r.ACTIVE="active",r.INACTIVE="inactive"}(R.ControlState||(R.ControlState={}));var at;(function(r){r.NUMBER="number",r.OPERATOR="operator",r.UTILITY="utility",r.EQUAL="equal"})(at||(at={})),R.EditorComponent=void 0,function(r){r.COMPONENT="component",r.MENU="menu",r.MAIN="main",r.FOOTER="footer",r.CONTEXTMENU="contextmenu",r.POPUP="popup",r.CATALOG="catalog",r.COMMENT="comment"}(R.EditorComponent||(R.EditorComponent={}));var Bt;(function(r){r.PAGE="page",r.TABLE="table"})(Bt||(Bt={})),R.EditorMode=void 0,function(r){r.EDIT="edit",r.CLEAN="clean",r.READONLY="readonly",r.FORM="form",r.PRINT="print",r.DESIGN="design",r.GRAFFITI="graffiti"}(R.EditorMode||(R.EditorMode={})),R.EditorZone=void 0,function(r){r.HEADER="header",r.MAIN="main",r.FOOTER="footer"}(R.EditorZone||(R.EditorZone={})),R.PageMode=void 0,function(r){r.PAGING="paging",r.CONTINUITY="continuity"}(R.PageMode||(R.PageMode={})),R.PaperDirection=void 0,function(r){r.VERTICAL="vertical",r.HORIZONTAL="horizontal"}(R.PaperDirection||(R.PaperDirection={})),R.WordBreak=void 0,function(r){r.BREAK_ALL="break-all",r.BREAK_WORD="break-word"}(R.WordBreak||(R.WordBreak={})),R.RenderMode=void 0,function(r){r.SPEED="speed",r.COMPATIBILITY="compatibility"}(R.RenderMode||(R.RenderMode={})),R.TableBorder=void 0,function(r){r.ALL="all",r.EMPTY="empty",r.EXTERNAL="external",r.INTERNAL="internal",r.DASH="dash"}(R.TableBorder||(R.TableBorder={})),R.TdBorder=void 0,function(r){r.TOP="top",r.RIGHT="right",r.BOTTOM="bottom",r.LEFT="left"}(R.TdBorder||(R.TdBorder={})),R.TdSlash=void 0,function(r){r.FORWARD="forward",r.BACK="back"}(R.TdSlash||(R.TdSlash={})),R.BackgroundSize=void 0,function(r){r.CONTAIN="contain",r.COVER="cover"}(R.BackgroundSize||(R.BackgroundSize={})),R.BackgroundRepeat=void 0,function(r){r.REPEAT="repeat",r.NO_REPEAT="no-repeat",r.REPEAT_X="repeat-x",r.REPEAT_Y="repeat-y"}(R.BackgroundRepeat||(R.BackgroundRepeat={}));const Mo={color:"#FFFFFF",image:"",size:R.BackgroundSize.COVER,repeat:R.BackgroundRepeat.NO_REPEAT,applyPageNumbers:[]};R.VerticalAlign=void 0,function(r){r.TOP="top",r.MIDDLE="middle",r.BOTTOM="bottom"}(R.VerticalAlign||(R.VerticalAlign={}));const Oo={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#ffffff",strokeStyle:"#000000",checkFillStyle:"#5175f4",checkStrokeStyle:"#5175f4",checkMarkColor:"#ffffff",verticalAlign:R.VerticalAlign.BOTTOM},So={placeholderColor:"#9c9b9b",bracketColor:"#000000",prefix:"{",postfix:"}",borderWidth:1,borderColor:"#000000",activeBackgroundColor:"",disabledBackgroundColor:"",existValueBackgroundColor:"",noValueBackgroundColor:""},Xo={bottom:30,inactiveAlpha:1,maxHeightRadio:R.MaxHeightRatio.HALF,disabled:!1,editable:!0},Io={opacity:.1,backgroundColor:"#E99D00",activeOpacity:.5,activeBackgroundColor:"#E99D00",disabled:!1,deletable:!0},No={top:30,inactiveAlpha:1,maxHeightRadio:R.MaxHeightRatio.HALF,disabled:!1,editable:!0},fo={defaultColor:"#1976d2",defaultBackgroundColor:"#e3f2fd",defaultBorderRadius:4,defaultPadding:[4,4,4,4]},mo={color:"#666666",font:"Microsoft YaHei",size:12,top:5},Fo={disabled:!0,color:"#CCCCCC",lineWidth:1.5},Wo={font:"Microsoft YaHei",fontSize:12,lineDash:[3,1]},Me={PAGE_NO:"{pageNo}",PAGE_COUNT:"{pageCount}"},Vo={bottom:60,size:12,font:"Microsoft YaHei",color:"#000000",rowFlex:R.RowFlex.CENTER,format:Me.PAGE_NO,numberType:R.NumberType.ARABIC,disabled:!1,startPageNo:1,fromPageNo:0,maxPageNo:null},bn={data:"",color:"#DCDFE6",opacity:1,size:16,font:"Microsoft YaHei"},po={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#000000",verticalAlign:R.VerticalAlign.BOTTOM},Zo={lineWidth:1,strokeStyle:"#000000"},Uo={tdPadding:[0,5,5,5],defaultTrMinHeight:42,defaultColMinWidth:40,defaultBorderColor:"#000000",overflow:!0};R.WatermarkType=void 0,function(r){r.TEXT="text",r.IMAGE="image"}(R.WatermarkType||(R.WatermarkType={})),R.WatermarkLayer=void 0,function(r){r.BOTTOM="bottom",r.TOP="top"}(R.WatermarkLayer||(R.WatermarkLayer={}));const tn={data:"",type:R.WatermarkType.TEXT,width:0,height:0,color:"#AEB5C0",opacity:.3,size:200,font:"Microsoft YaHei",repeat:!1,gap:[10,10],numberType:R.NumberType.ARABIC,layer:R.WatermarkLayer.BOTTOM},Yo={tipDisabled:!0};R.LineNumberType=void 0,function(r){r.PAGE="page",r.CONTINUITY="continuity"}(R.LineNumberType||(R.LineNumberType={}));const Qo={size:12,font:"Microsoft YaHei",color:"#000000",disabled:!0,right:20,type:R.LineNumberType.CONTINUITY},Co={disabled:!0,size:120,zoom:2,borderColor:"#efefef"},Eo={color:"#000000",lineWidth:1,padding:[0,5,0,5],disabled:!0},Do={top:0,left:5},bo={defaultLineColor:"#000000",defaultLineWidth:2},Ko={disabled:!0,color:"#CCCCCC",radius:1};function en(r={}){var D,W,C;const t=Y(Y({},Uo),r.table),e=Y(Y({},No),r.header),n=Y(Y({},Xo),r.footer),o=Y(Y({},Vo),r.pageNumber),s=Y(Y({},tn),r.watermark),i=Y(Y({},So),r.control),l=Y(Y({},Oo),r.checkbox),a=Y(Y({},po),r.radio),c=Y(Y({},Bi),r.cursor),d=Y(Y({},To),r.title),h=Y(Y({},bn),r.placeholder),u=Y(Y({},Io),r.group),g=Y(Y({},Wo),r.pageBreak),T=Y(Y({},Yo),r.zone),P=Y(Y({},Mo),r.background),O=Y(Y({},Fo),r.lineBreak),M=Y(Y({},Ko),r.whiteSpace),S=Y(Y({},Zo),r.separator),X=Y(Y({},Qo),r.lineNumber),N=Y(Y({},Eo),r.pageBorder),m=Y(Y({},Do),r.badge),I=Y(Y({},bo),r.graffiti),f=Y(Y({},fo),r.label),F=Y(Y({},mo),r.imgCaption),V=Y(Y({},uo),r.list),Z=Y(Y({},Co),r.magnifier),E={print:Y(Y({},ke.print),(D=r.modeRule)==null?void 0:D.print),readonly:Y(Y({},ke.readonly),(W=r.modeRule)==null?void 0:W.readonly),form:Y(Y({},ke.form),(C=r.modeRule)==null?void 0:C.form)};return B(Y({mode:R.EditorMode.EDIT,locale:"zhCN",defaultType:"TEXT",defaultColor:"#000000",defaultFont:"Microsoft YaHei",defaultSize:16,minSize:5,maxSize:72,defaultRowMargin:1,defaultBasicRowMarginHeight:8,defaultTabWidth:32,width:794,height:1123,scale:1,pageGap:20,underlineColor:"#000000",strikeoutColor:"#FF0000",rangeAlpha:.6,rangeColor:"#AECBFA",rangeMinWidth:5,searchMatchAlpha:.6,searchMatchColor:"#FFFF00",searchNavigateMatchColor:"#AAD280",highlightAlpha:.6,highlightMarginHeight:8,resizerColor:"#4182D9",resizerSize:5,marginIndicatorSize:35,marginIndicatorColor:"#BABABA",margins:[100,120,100,120],pageMode:R.PageMode.PAGING,renderMode:R.RenderMode.SPEED,defaultHyperlinkColor:"#0000FF",paperDirection:R.PaperDirection.VERTICAL,inactiveAlpha:.6,historyMaxRecordCount:100,wordBreak:R.WordBreak.BREAK_WORD,printPixelRatio:3,maskMargin:[0,0,0,0],letterClass:[In.ENGLISH],contextMenuDisableKeys:[],shortcutDisableKeys:[],scrollContainerSelector:"",pageOuterSelectionDisable:!1},r),{table:t,header:e,footer:n,pageNumber:o,watermark:s,control:i,checkbox:l,radio:a,cursor:c,title:d,placeholder:h,group:u,pageBreak:g,zone:T,background:P,lineBreak:O,whiteSpace:M,separator:S,lineNumber:X,pageBorder:N,badge:m,modeRule:E,graffiti:I,label:f,imgCaption:F,list:V,magnifier:Z})}function Kn(r){const t=[];for(let e=0;e<r.length;e++){const n=r[e],o=Qt(n.value);for(let s=0;s<o.length;s++)t.push(B(Y({},n),{value:o[s]}))}return t}function Pt(r,t){var l,a,c;const{isHandleFirstElement:e=!0,isForceCompensation:n=!1,editorOptions:o}=t,s=r[0];(s==null?void 0:s.type)!==R.ElementType.LIST&&(n||e&&((s==null?void 0:s.type)&&s.type!==R.ElementType.TEXT||!Te.test(s==null?void 0:s.value)))&&r.unshift({value:y});let i=0;for(;i<r.length;){let d=r[i];if(d.type===R.ElementType.TITLE){r.splice(i,1);const h=d.valueList||[];if(Pt(h,B(Y({},t),{isHandleFirstElement:!1,isForceCompensation:!1})),h.length){const u=d.titleId||j(),g=o.title;for(let T=0;T<h.length;T++){const P=h[T];P.title=d.title,d.level&&(P.titleId=u,P.level=d.level),Ye(P)&&(P.size||(P.size=g[Dn[P.level]]),P.bold===void 0&&(P.bold=!0)),r.splice(i,0,P),i++}}i--}else if(d.type===R.ElementType.LIST){r.splice(i,1);const h=d.valueList||[];if(Pt(h,B(Y({},t),{isHandleFirstElement:!0,isForceCompensation:!1})),h.length){const u=d.listId||j();for(let g=0;g<h.length;g++){const T=h[g];T.listId=u,T.listType=d.listType,T.listStyle=d.listStyle,r.splice(i,0,T),i++}r[i]&&(((l=r[i].valueList)==null?void 0:l.length)?!Te.test(r[i].valueList[0].value):!Te.test(r[i].value))&&(r.splice(i,0,{value:y}),i++)}i--}else if(d.type===R.ElementType.AREA){r.splice(i,1);const h=(d==null?void 0:d.valueList)||[];if(Pt(h,B(Y({},t),{isHandleFirstElement:!0,isForceCompensation:!0})),h.length){const u=j();for(let g=0;g<h.length;g++){const T=h[g];if(T.areaId=d.areaId||u,T.area=d.area,T.areaIndex=g,T.type===R.ElementType.TABLE){const P=T.trList;for(let O=0;O<P.length;O++){const M=P[O];for(let S=0;S<M.tdList.length;S++){const N=M.tdList[S].value;for(let m=0;m<N.length;m++){const I=N[m];I.areaId=d.areaId||u,I.area=d.area}}}}r.splice(i,0,T),i++}}i--}else if(d.type===R.ElementType.TABLE){const h=d.id||j();if(d.id=h,d.trList){const{defaultTrMinHeight:u}=o.table;for(let g=0;g<d.trList.length;g++){const T=d.trList[g],P=T.id||j();T.id=P,(!T.minHeight||T.minHeight<u)&&(T.minHeight=u),T.height<T.minHeight&&(T.height=T.minHeight);for(let O=0;O<T.tdList.length;O++){const M=T.tdList[O],S=M.id||j();M.id=S,Pt(M.value,B(Y({},t),{isHandleFirstElement:!0,isForceCompensation:!0})),!M.value[0].size&&((a=M.value[1])==null?void 0:a.size)&&Ye(M.value[1])&&(M.value[0].size=M.value[1].size);for(let X=0;X<M.value.length;X++){const N=M.value[X];N.tdId=S,N.trId=P,N.tableId=h}}}}}else if(d.type===R.ElementType.HYPERLINK){r.splice(i,1);const h=Kn(d.valueList||[]);if(h.length){const u=j();for(let g=0;g<h.length;g++){const T=h[g];T.type=d.type,T.url=d.url,T.hyperlinkId=u,r.splice(i,0,T),i++}}i--}else if(d.type===R.ElementType.DATE){r.splice(i,1);const h=Kn(d.valueList||[]);if(h.length){const u=j();for(let g=0;g<h.length;g++){const T=h[g];T.type=d.type,T.dateFormat=d.dateFormat,T.dateId=u,r.splice(i,0,T),i++}}i--}else if(d.type===R.ElementType.CONTROL){if(!d.control){i++;continue}const{prefix:h,postfix:u,preText:g,postText:T,value:P,placeholder:O,code:M,type:S,valueSets:X}=d.control,{editorOptions:{control:N,checkbox:m,radio:I}}=t,f=d.controlId||j();r.splice(i,1);const F=pt(d,[...Zn,...te]),V=pt(d.control,xt),Z=B(Y({},V),{color:o.control.bracketColor}),E=Qt(h||N.prefix);for(let W=0;W<E.length;W++){const C=E[W];r.splice(i,0,B(Y(Y({},F),Z),{controlId:f,value:C,type:d.type,control:d.control,controlComponent:R.ControlComponent.PREFIX})),i++}if(g){const W=Qt(g);for(let C=0;C<W.length;C++){const U=W[C];r.splice(i,0,B(Y(Y({},F),V),{controlId:f,value:U,type:d.type,control:d.control,controlComponent:R.ControlComponent.PRE_TEXT})),i++}}if(P&&P.length||S===R.ControlType.CHECKBOX||S===R.ControlType.RADIO||S===R.ControlType.SELECT&&M&&(!P||!P.length)){let W=P?$(P):[];if(S===R.ControlType.CHECKBOX){const C=M?M.split(","):[];if(Array.isArray(X)&&X.length){const U=W.reduce((w,K)=>w.concat(K.value.split("").map(p=>B(Y({},K),{value:p}))),[]);let Q=0;for(let w=0;w<X.length;w++){const K=X[w];r.splice(i,0,B(Y(Y({},F),V),{controlId:f,value:"",type:d.type,control:d.control,controlComponent:R.ControlComponent.CHECKBOX,checkbox:{code:K.code,value:C.includes(K.code)}})),i++;const p=Qt(K.value);for(let G=0;G<p.length;G++){const H=p[G],x=G===p.length-1;r.splice(i,0,B(Y(Y(Y({},F),V),U[Q]),{controlId:f,value:H===`
|
|
62
|
+
`?y:H,letterSpacing:x?m.gap:0,control:d.control,controlComponent:R.ControlComponent.VALUE})),Q++,i++}}}}else if(S===R.ControlType.RADIO){if(Array.isArray(X)&&X.length){const C=W.reduce((Q,w)=>Q.concat(w.value.split("").map(K=>B(Y({},w),{value:K}))),[]);let U=0;for(let Q=0;Q<X.length;Q++){const w=X[Q];r.splice(i,0,B(Y(Y({},F),V),{controlId:f,value:"",type:d.type,control:d.control,controlComponent:R.ControlComponent.RADIO,radio:{code:w.code,value:M===w.code}})),i++;const K=Qt(w.value);for(let p=0;p<K.length;p++){const G=K[p],H=p===K.length-1;r.splice(i,0,B(Y(Y(Y({},F),V),C[U]),{controlId:f,value:G===`
|
|
63
|
+
`?y:G,letterSpacing:H?I.gap:0,control:d.control,controlComponent:R.ControlComponent.VALUE})),U++,i++}}}}else{if((!P||!P.length)&&Array.isArray(X)&&X.length){const C=X.find(U=>U.code===M);C&&(W=[{value:C.value}])}Pt(W,B(Y({},t),{isHandleFirstElement:!1,isForceCompensation:!1}));for(let C=0;C<W.length;C++){const U=W[C],Q=U.value;r.splice(i,0,B(Y(Y(Y({},F),V),U),{controlId:f,value:Q===`
|
|
64
|
+
`?y:Q,type:U.type||R.ElementType.TEXT,control:d.control,controlComponent:R.ControlComponent.VALUE})),i++}}}else if(O){const W=B(Y({},V),{color:o.control.placeholderColor}),C=Qt(O);for(let U=0;U<C.length;U++){const Q=C[U];r.splice(i,0,B(Y(Y({},F),W),{controlId:f,value:Q===`
|
|
65
|
+
`?y:Q,type:d.type,control:d.control,controlComponent:R.ControlComponent.PLACEHOLDER})),i++}}if(T){const W=Qt(T);for(let C=0;C<W.length;C++){const U=W[C];r.splice(i,0,B(Y(Y({},F),V),{controlId:f,value:U,type:d.type,control:d.control,controlComponent:R.ControlComponent.POST_TEXT})),i++}}const D=Qt(u||N.postfix);for(let W=0;W<D.length;W++){const C=D[W];r.splice(i,0,B(Y(Y({},F),Z),{controlId:f,value:C,type:d.type,control:d.control,controlComponent:R.ControlComponent.POSTFIX})),i++}i--}else if((!d.type||bt.includes(d.type))&&((c=d.value)==null?void 0:c.length)>1){r.splice(i,1);const h=Qt(d.value);for(let u=0;u<h.length;u++)r.splice(i+u,0,B(Y({},d),{value:h[u]}));d=r[i]}if((d.value===`
|
|
66
66
|
`||d.value==`\r
|
|
67
|
-
`)&&(d.value=y),(d.type===R.ElementType.IMAGE||d.type===R.ElementType.BLOCK)&&(d.id=d.id||j()),d.type===R.ElementType.LATEX){const{svg:h,width:u,height:g}=Cn.convertLaTextToSVG(d.value);d.width=d.width||u,d.height=d.height||g,d.laTexSVG=h,d.id=d.id||j()}i++}}function
|
|
68
|
-
`:r.value};return n.forEach(s=>{const i=r[s];i!==void 0&&(o[s]=i)}),o}function st(r,t={}){const{extraPickAttrs:e,isClassifyArea:n=!1,isClone:o=!0}=t,s=o?$(r):r,i=[];let l=0;for(;l<s.length;){let a=s[l];if(l===0&&a.value===y&&!a.listId&&(!a.type||a.type===R.ElementType.TEXT)){l++;continue}if(a.areaId){const d=a.areaId,h=a.area,u=[];for(;l<s.length;){const T=s[l];if(d!==T.areaId){l--;break}delete T.area,delete T.areaId,u.push(T),l++}const g=st(u,t);if(n){const T={type:R.ElementType.AREA,value:"",areaId:d,area:h};T.valueList=g,a=T}else{i.splice(l,0,...g);continue}}else if(a.titleId&&a.level){const d=a.titleId;if(d){const h=a.level,u={type:R.ElementType.TITLE,title:a.title,titleId:d,value:"",level:h},g=[];for(;l<s.length;){const T=s[l];if(d!==T.titleId){l--;break}delete T.level,delete T.title,g.push(T),l++}u.valueList=st(g,t),a=u}}else if(a.listId&&a.listType){const d=a.listId;if(d){const h=a.listType,u=a.listStyle,g={type:R.ElementType.LIST,value:"",listId:d,listType:h,listStyle:u},T=[];for(;l<s.length;){const P=s[l];if(d!==P.listId){l--;break}delete P.listType,delete P.listStyle,T.push(P),l++}g.valueList=st(T,t),a=g}}else if(a.type===R.ElementType.TABLE){if(a.pagingId){let d=l+1,h=0;for(;d<s.length;){const u=s[d];if(u.pagingId===a.pagingId)a.height+=u.height,a.trList.push(...u.trList),d++,h++;else break}l+=h}if(a.trList)for(let d=0;d<a.trList.length;d++){const h=a.trList[d];delete h.id;for(let u=0;u<h.tdList.length;u++){const g=h.tdList[u],T={colspan:g.colspan,rowspan:g.rowspan,value:st(g.value,B(Y({},t),{isClassifyArea:!1}))};ji.forEach(P=>{const O=g[P];O!==void 0&&(T[P]=O)}),h.tdList[u]=T}}}else if(a.type===R.ElementType.HYPERLINK){const d=a.hyperlinkId;if(d){const h={type:R.ElementType.HYPERLINK,value:"",url:a.url},u=[];for(;l<s.length;){const g=s[l];if(d!==g.hyperlinkId){l--;break}delete g.type,delete g.url,u.push(g),l++}h.valueList=st(u,t),a=h}}else if(a.type===R.ElementType.DATE){const d=a.dateId;if(d){const h={type:R.ElementType.DATE,value:"",dateFormat:a.dateFormat},u=[];for(;l<s.length;){const g=s[l];if(d!==g.dateId){l--;break}delete g.type,delete g.dateFormat,u.push(g),l++}h.valueList=st(u,t),a=h}}else if(a.controlId){const d=a.controlId;if(a.controlComponent===R.ControlComponent.PREFIX){const h=[];let u=!1,g=l;for(;g<s.length;){const T=s[g];if(d!==T.controlId)break;T.controlComponent===R.ControlComponent.VALUE&&(delete T.control,delete T.controlId,h.push(T)),T.controlComponent===R.ControlComponent.POSTFIX&&(u=!0),g++}if(u){const T=pt(a,xt),P=Y(Y({},a.control),T),O=B(Y({},pt(a,te)),{type:R.ElementType.CONTROL,value:"",control:P,controlId:d});O.control.value=st(h,t),a=le(O,{extraPickAttrs:e}),l+=g-l-1}}if(a.controlComponent&&(delete a.control,delete a.controlId,a.controlComponent!==R.ControlComponent.VALUE&&a.controlComponent!==R.ControlComponent.PRE_TEXT&&a.controlComponent!==R.ControlComponent.POST_TEXT)){l++;continue}}const c=le(a,{extraPickAttrs:e});if(!a.type||a.type===R.ElementType.TEXT||a.type===R.ElementType.SUBSCRIPT||a.type===R.ElementType.SUPERSCRIPT)for(;l<s.length;){const d=s[l+1];if(l++,d&&
|
|
69
|
-
`:d.value;c.value+=h}else break}else l++;i.push(c)}return i}function yn(r){switch(window.getComputedStyle(r).textAlign){case"left":case"start":return R.RowFlex.LEFT;case"center":return R.RowFlex.CENTER;case"right":case"end":return R.RowFlex.RIGHT;case"justify":return R.RowFlex.ALIGNMENT;case"justify-all":return R.RowFlex.JUSTIFY;default:return R.RowFlex.LEFT}}function wn(r){return r===R.RowFlex.ALIGNMENT?"justify":r}function
|
|
67
|
+
`)&&(d.value=y),(d.type===R.ElementType.IMAGE||d.type===R.ElementType.BLOCK)&&(d.id=d.id||j()),d.type===R.ElementType.LATEX){const{svg:h,width:u,height:g}=Cn.convertLaTextToSVG(d.value);d.width=d.width||u,d.height=d.height||g,d.laTexSVG=h,d.id=d.id||j()}i++}}function yo(r,t){const e=Object.keys(r),n=Object.keys(t);if(e.length!==n.length)return!1;for(let o=0;o<e.length;o++){const s=e[o];if(s!=="value"&&!(s==="groupIds"&&Array.isArray(r[s])&&Array.isArray(t[s])&&Fn(r[s],t[s]))&&r[s]!==t[s])return!1}return!0}function le(r,t={}){const{extraPickAttrs:e}=t,n=[...$i];e&&n.push(...e);const o={value:r.value===y?`
|
|
68
|
+
`:r.value};return n.forEach(s=>{const i=r[s];i!==void 0&&(o[s]=i)}),o}function st(r,t={}){const{extraPickAttrs:e,isClassifyArea:n=!1,isClone:o=!0}=t,s=o?$(r):r,i=[];let l=0;for(;l<s.length;){let a=s[l];if(l===0&&a.value===y&&!a.listId&&(!a.type||a.type===R.ElementType.TEXT)){l++;continue}if(a.areaId){const d=a.areaId,h=a.area,u=[];for(;l<s.length;){const T=s[l];if(d!==T.areaId){l--;break}delete T.area,delete T.areaId,u.push(T),l++}const g=st(u,t);if(n){const T={type:R.ElementType.AREA,value:"",areaId:d,area:h};T.valueList=g,a=T}else{i.splice(l,0,...g);continue}}else if(a.titleId&&a.level){const d=a.titleId;if(d){const h=a.level,u={type:R.ElementType.TITLE,title:a.title,titleId:d,value:"",level:h},g=[];for(;l<s.length;){const T=s[l];if(d!==T.titleId){l--;break}delete T.level,delete T.title,g.push(T),l++}u.valueList=st(g,t),a=u}}else if(a.listId&&a.listType){const d=a.listId;if(d){const h=a.listType,u=a.listStyle,g={type:R.ElementType.LIST,value:"",listId:d,listType:h,listStyle:u},T=[];for(;l<s.length;){const P=s[l];if(d!==P.listId){l--;break}delete P.listType,delete P.listStyle,T.push(P),l++}g.valueList=st(T,t),a=g}}else if(a.type===R.ElementType.TABLE){if(a.pagingId){let d=l+1,h=0;for(;d<s.length;){const u=s[d];if(u.pagingId===a.pagingId)a.height+=u.height,a.trList.push(...u.trList),d++,h++;else break}l+=h}if(a.trList)for(let d=0;d<a.trList.length;d++){const h=a.trList[d];delete h.id;for(let u=0;u<h.tdList.length;u++){const g=h.tdList[u],T={colspan:g.colspan,rowspan:g.rowspan,value:st(g.value,B(Y({},t),{isClassifyArea:!1}))};ji.forEach(P=>{const O=g[P];O!==void 0&&(T[P]=O)}),h.tdList[u]=T}}}else if(a.type===R.ElementType.HYPERLINK){const d=a.hyperlinkId;if(d){const h={type:R.ElementType.HYPERLINK,value:"",url:a.url},u=[];for(;l<s.length;){const g=s[l];if(d!==g.hyperlinkId){l--;break}delete g.type,delete g.url,u.push(g),l++}h.valueList=st(u,t),a=h}}else if(a.type===R.ElementType.DATE){const d=a.dateId;if(d){const h={type:R.ElementType.DATE,value:"",dateFormat:a.dateFormat},u=[];for(;l<s.length;){const g=s[l];if(d!==g.dateId){l--;break}delete g.type,delete g.dateFormat,u.push(g),l++}h.valueList=st(u,t),a=h}}else if(a.controlId){const d=a.controlId;if(a.controlComponent===R.ControlComponent.PREFIX){const h=[];let u=!1,g=l;for(;g<s.length;){const T=s[g];if(d!==T.controlId)break;T.controlComponent===R.ControlComponent.VALUE&&(delete T.control,delete T.controlId,h.push(T)),T.controlComponent===R.ControlComponent.POSTFIX&&(u=!0),g++}if(u){const T=pt(a,xt),P=Y(Y({},a.control),T),O=B(Y({},pt(a,te)),{type:R.ElementType.CONTROL,value:"",control:P,controlId:d});O.control.value=st(h,t),a=le(O,{extraPickAttrs:e}),l+=g-l-1}}if(a.controlComponent&&(delete a.control,delete a.controlId,a.controlComponent!==R.ControlComponent.VALUE&&a.controlComponent!==R.ControlComponent.PRE_TEXT&&a.controlComponent!==R.ControlComponent.POST_TEXT)){l++;continue}}const c=le(a,{extraPickAttrs:e});if(!a.type||a.type===R.ElementType.TEXT||a.type===R.ElementType.SUBSCRIPT||a.type===R.ElementType.SUPERSCRIPT)for(;l<s.length;){const d=s[l+1];if(l++,d&&yo(c,le(d,{extraPickAttrs:e}))){const h=d.value===y?`
|
|
69
|
+
`:d.value;c.value+=h}else break}else l++;i.push(c)}return i}function yn(r){switch(window.getComputedStyle(r).textAlign){case"left":case"start":return R.RowFlex.LEFT;case"center":return R.RowFlex.CENTER;case"right":case"end":return R.RowFlex.RIGHT;case"justify":return R.RowFlex.ALIGNMENT;case"justify-all":return R.RowFlex.JUSTIFY;default:return R.RowFlex.LEFT}}function wn(r){return r===R.RowFlex.ALIGNMENT?"justify":r}function wo(r){switch(r){case R.RowFlex.LEFT:return"flex-start";case R.RowFlex.CENTER:return"center";case R.RowFlex.RIGHT:return"flex-end";case R.RowFlex.ALIGNMENT:case R.RowFlex.JUSTIFY:return"space-between";default:return"flex-start"}}function Ye(r){return!r.type||bt.includes(r.type)}function Ho(r){return!r.type||r.type===R.ElementType.TEXT}function Go(r){return r.filter(t=>Ye(t)).map(t=>t.value).join("").replace(new RegExp(y,"g"),"")}function Qe(r,t){const e=r[t];if(!e)return null;const n=r[t+1];return!e.listId&&e.value===y&&n&&n.value!==y&&e.areaId===n.areaId?n:e}function It(r,t,e,n){var d,h,u;let o=Qe(r,e);if(!o)return;const{isBreakWhenWrap:s=!1,editorOptions:i,ignoreContextKeys:l=[]}=n||{},{mode:a}=i||{};a!==R.EditorMode.DESIGN&&((d=o.title)==null?void 0:d.disabled)&&(o=Ht(o,Ae));let c=!1;for(let g=0;g<t.length;g++){const T=t[g];if(s&&!o.listId&&Te.test(T.value)&&(c=!0),c||!o.listId&&T.type===R.ElementType.LIST){const O=[...Pe,...te,...se];mn(O,l),qt(O,o,T),(h=T.valueList)==null||h.forEach(M=>{qt(O,o,M)});continue}((u=T.valueList)==null?void 0:u.length)&&It(r,T.valueList,e,n);const P=[...Zn];$t(T)||P.push(...te),mn(P,l),qt(P,o,T)}}function xo(r,t){var o,s;let e="span";r.type===R.ElementType.SUPERSCRIPT?e="sup":r.type===R.ElementType.SUBSCRIPT&&(e="sub");const n=document.createElement(e);return n.style.fontFamily=r.font||t.defaultFont,r.rowFlex&&(n.style.textAlign=wn(r.rowFlex)),r.color&&(n.style.color=r.color),r.bold&&(n.style.fontWeight="600"),r.italic&&(n.style.fontStyle="italic"),n.style.fontSize=`${r.size||t.defaultSize}px`,r.highlight&&(n.style.backgroundColor=r.highlight),r.underline&&(n.style.textDecoration="underline",n.style.textDecorationStyle=((o=r.textDecoration)==null?void 0:o.style)||"solid"),r.strikeout&&(n.style.textDecoration+=" line-through"),r.type&&n.setAttribute("data-type",r.type),r.rowMargin&&(n.style.lineHeight=((s=r.rowMargin)!=null?s:t.defaultRowMargin).toString()),n.innerText=r.value.replace(new RegExp(`${y}`,"g"),`
|
|
70
70
|
`),n}function Hn(r){let t=0;const e=new Map;for(let n=0;n<r.length;n++){const o=r[n];if(n===0){if(o.checkbox)continue;o.value=o.value.replace(Te,"")}if(o.listWrap){const s=e.get(t)||[];s.push(o),e.set(t,s)}else{const s=o.value.split(`
|
|
71
|
-
`);for(let i=0;i<s.length;i++){i>0&&(t+=1);const l=s[i],a=e.get(t)||[];a.push(B(Y({},o),{value:l})),e.set(t,a)}}}return e}function
|
|
72
|
-
`),l.append(F)}}return l}const o=document.createElement("div"),s=
|
|
73
|
-
`});else if(u.nodeName==="A"){const g=u,T=g.innerText;T&&e.push({type:R.ElementType.HYPERLINK,value:"",valueList:[{value:T}],url:g.href})}else if(/H[1-6]/.test(u.nodeName)){const T=Re(
|
|
71
|
+
`);for(let i=0;i<s.length;i++){i>0&&(t+=1);const l=s[i],a=e.get(t)||[];a.push(B(Y({},o),{value:l})),e.set(t,a)}}}return e}function Jo(r){var n;const t=[];if(!r.length)return t;let e=((n=r[0])==null?void 0:n.rowFlex)||null;t.push({rowFlex:e,data:[r[0]]});for(let o=1;o<r.length;o++){const s=r[o],i=s.rowFlex||null;e===i&&!$t(s)&&!$t(r[o-1])?t[t.length-1].data.push(s):(t.push({rowFlex:i,data:[s]}),e=i)}for(let o=0;o<t.length;o++){const s=t[o];s.data=st(s.data)}return t}function ae(r,t){const e=en(t);function n(i){var a,c,d,h,u,g,T,P,O,M,S,X,N;const l=document.createElement("div");for(let m=0;m<i.length;m++){const I=i[m];if(I.type===R.ElementType.TABLE){const f=document.createElement("table");f.setAttribute("cellSpacing","0"),f.setAttribute("cellpadding","0"),f.setAttribute("border","0");const F="1px solid #000000";!I.borderType||I.borderType===R.TableBorder.ALL?(f.style.borderTop=F,f.style.borderLeft=F):I.borderType===R.TableBorder.EXTERNAL&&(f.style.border=F),f.style.width=`${I.width}px`;const V=document.createElement("colgroup");for(let E=0;E<I.colgroup.length;E++){const D=I.colgroup[E],W=document.createElement("col");W.setAttribute("width",`${D.width}`),V.append(W)}f.append(V);const Z=I.trList;for(let E=0;E<Z.length;E++){const D=document.createElement("tr"),W=Z[E];D.style.height=`${W.height}px`;for(let C=0;C<W.tdList.length;C++){const U=document.createElement("td");(!I.borderType||I.borderType===R.TableBorder.ALL)&&(U.style.borderBottom=U.style.borderRight="1px solid");const Q=W.tdList[C];U.colSpan=Q.colspan,U.rowSpan=Q.rowspan,U.style.verticalAlign=Q.verticalAlign||"top",((a=Q.borderTypes)==null?void 0:a.includes(R.TdBorder.TOP))&&(U.style.borderTop=F),((c=Q.borderTypes)==null?void 0:c.includes(R.TdBorder.RIGHT))&&(U.style.borderRight=F),((d=Q.borderTypes)==null?void 0:d.includes(R.TdBorder.BOTTOM))&&(U.style.borderBottom=F),((h=Q.borderTypes)==null?void 0:h.includes(R.TdBorder.LEFT))&&(U.style.borderLeft=F);const w=ae(Q.value,t);U.innerHTML=w.innerHTML,Q.backgroundColor&&(U.style.backgroundColor=Q.backgroundColor),D.append(U)}f.append(D)}l.append(f)}else if(I.type===R.ElementType.HYPERLINK){const f=document.createElement("a");f.innerText=I.valueList.map(F=>F.value).join(""),I.url&&(f.href=I.url),l.append(f)}else if(I.type===R.ElementType.TITLE){const f=document.createElement(`h${qe[I.level]}`),F=n(I.valueList);f.innerHTML=F.innerHTML,l.append(f)}else if(I.type===R.ElementType.LIST){const f=document.createElement(go[I.listType]);I.listStyle&&(f.style.listStyleType=Lo[I.listStyle]);const F=st(I.valueList);Hn(F).forEach(Z=>{const E=document.createElement("li"),D=n(Z);E.innerHTML=D.innerHTML,f.append(E)}),l.append(f)}else if(I.type===R.ElementType.IMAGE){const f=document.createElement("img");I.value&&(f.src=I.value,f.width=I.width,f.height=I.height),l.append(f)}else if(I.type===R.ElementType.BLOCK){if(((u=I.block)==null?void 0:u.type)===R.BlockType.VIDEO){const f=(g=I.block.videoBlock)==null?void 0:g.src;if(f){const F=document.createElement("video");F.style.display="block",F.controls=!0,F.src=f,F.width=I.width||(t==null?void 0:t.width)||window.innerWidth,F.height=I.height,l.append(F)}}else if(((T=I.block)==null?void 0:T.type)===R.BlockType.IFRAME){const{src:f,srcdoc:F,sandbox:V,allow:Z}=I.block.iframeBlock||{};if(f||F){const E=document.createElement("iframe");E.sandbox.add(...V||zt.sandbox),E.setAttribute("allow",[Z||zt.allow].join(" ")),E.style.display="block",E.style.border="none",f?E.src=f:F&&(E.srcdoc=F),E.width=`${I.width||(t==null?void 0:t.width)||window.innerWidth}`,E.height=`${I.height}`,l.append(E)}}}else if(I.type===R.ElementType.SEPARATOR){const f=document.createElement("hr");((P=I.dashArray)==null?void 0:P.length)&&f.setAttribute("data-dash-array",I.dashArray.join(",")),l.append(f)}else if(I.type===R.ElementType.CHECKBOX){const f=document.createElement("input");f.type="checkbox",((O=I.checkbox)==null?void 0:O.value)&&f.setAttribute("checked","true"),l.append(f)}else if(I.type===R.ElementType.RADIO){const f=document.createElement("input");f.type="radio",((M=I.radio)==null?void 0:M.value)&&f.setAttribute("checked","true"),l.append(f)}else if(I.type===R.ElementType.TAB){const f=document.createElement("span");f.innerHTML=`${Sn}${Sn}`,l.append(f)}else if(I.type===R.ElementType.CONTROL){const f=document.createElement("span"),F=n(((S=I.control)==null?void 0:S.value)||[]);f.innerHTML=F.innerHTML,l.append(f)}else if(I.type===R.ElementType.PAGE_BREAK){const f=document.createElement("div");f.style.breakAfter="page",l.append(f)}else if(!I.type||I.type===R.ElementType.LATEX||bt.includes(I.type)){let f="";if(I.type===R.ElementType.DATE?f=((X=I.valueList)==null?void 0:X.map(V=>V.value).join(""))||"":f=I.value,!f)continue;const F=xo(I,e);((N=i[m-1])==null?void 0:N.type)===R.ElementType.TITLE&&(f=f.replace(/^\n/,"")),F.innerText=f.replace(new RegExp(`${y}`,"g"),`
|
|
72
|
+
`),l.append(F)}}return l}const o=document.createElement("div"),s=Jo(r);for(let i=0;i<s.length;i++){const l=s[i],a=!l.rowFlex||l.rowFlex===R.RowFlex.LEFT,c=document.createElement("div");if(!a){const d=l.data[0];$t(d)?(c.style.display="flex",c.style.justifyContent=wo(d.rowFlex)):(c.style.textAlign=wn(l.rowFlex),l.rowFlex==="justify"&&(c.style.textAlignLast="justify"))}c.innerHTML=n(l.data).innerHTML,a?c.childNodes.forEach(d=>{o.append(d.cloneNode(!0))}):o.append(c)}return o}function vo(r){if(!r||r.nodeType!==3)return null;const t=r.parentNode,e=t.nodeName==="FONT"?t.parentNode:t,n=yn(e),o=r.textContent,s=window.getComputedStyle(e);if(!o||e.nodeName==="STYLE")return null;const i={value:o,color:s.color,bold:Number(s.fontWeight)>500,italic:s.fontStyle.includes("italic"),size:Math.floor(parseFloat(s.fontSize))};return e.nodeName==="SUB"||s.verticalAlign==="sub"?i.type=R.ElementType.SUBSCRIPT:(e.nodeName==="SUP"||s.verticalAlign==="super")&&(i.type=R.ElementType.SUPERSCRIPT),n!==R.RowFlex.LEFT&&(i.rowFlex=n),s.backgroundColor!=="rgba(0, 0, 0, 0)"&&(i.highlight=s.backgroundColor),s.textDecorationLine.includes("underline")&&(i.underline=!0),s.textDecorationLine.includes("line-through")&&(i.strikeout=!0),i}function Re(r,t){const e=[];function n(a){var c;if(a.nodeType===3){const d=vo(a);d&&e.push(d)}else if(a.nodeType===1){const d=a.childNodes;for(let h=0;h<d.length;h++){const u=d[h];if(u.nodeName==="BR")e.push({value:`
|
|
73
|
+
`});else if(u.nodeName==="A"){const g=u,T=g.innerText;T&&e.push({type:R.ElementType.HYPERLINK,value:"",valueList:[{value:T}],url:g.href})}else if(/H[1-6]/.test(u.nodeName)){const T=Re(Bo(u,"div").outerHTML,t);e.push({value:"",type:R.ElementType.TITLE,level:Po[u.nodeName],valueList:T}),u.nextSibling&&!eo.includes(u.nextSibling.nodeName)&&e.push({value:`
|
|
74
74
|
`})}else if(u.nodeName==="UL"||u.nodeName==="OL"){const g=u,T={value:"",type:R.ElementType.LIST,valueList:[]};u.nodeName==="OL"?T.listType=R.ListType.OL:(T.listType=R.ListType.UL,T.listStyle=g.style.listStyleType),g.querySelectorAll("li").forEach(P=>{const O=Re(P.innerHTML,t);O.forEach(M=>{M.value===`
|
|
75
75
|
`&&(M.listWrap=!0)}),O.unshift({value:`
|
|
76
76
|
`}),T.valueList.push(...O)}),e.push(T)}else if(u.nodeName==="HR")e.push({value:`
|
|
@@ -81,11 +81,11 @@ trailer
|
|
|
81
81
|
`:""}`}}}else if(u.type===R.ElementType.TAB)n+=" ";else if(u.type===R.ElementType.HYPERLINK)n+=u.valueList.map(g=>g.value).join("");else if(u.type===R.ElementType.TITLE)n+=`${t(st(u.valueList))}`;else if(u.type===R.ElementType.LIST){const g=st(u.valueList),T=Hn(g);let P="";u.listType===R.ListType.UL&&(P=je[u.listStyle]),T.forEach((O,M)=>{const S=T.size-1===M;n+=`
|
|
82
82
|
${P||`${M+1}.`}${t(O)}${S?`
|
|
83
83
|
`:""}`})}else if(u.type===R.ElementType.CHECKBOX)n+=((o=u.checkbox)==null?void 0:o.value)?"\u2611":"\u25A1";else if(u.type===R.ElementType.RADIO)n+=((s=u.radio)==null?void 0:s.value)?"\u2609":"\u25CB";else if(!u.type||u.type===R.ElementType.LATEX||bt.includes(u.type)){let g="";if(u.type===R.ElementType.CONTROL){const T=((l=(i=u.control.value)==null?void 0:i[0])==null?void 0:l.value)||"";g=T?`${((a=u.control)==null?void 0:a.preText)||""}${T}${((c=u.control)==null?void 0:c.postText)||""}`:""}else u.type===R.ElementType.DATE?g=((d=u.valueList)==null?void 0:d.map(T=>T.value).join(""))||"":g=u.value;n+=g.replace(new RegExp(`${y}`,"g"),`
|
|
84
|
-
`)}}return n}return t(st(r))}function nn(r){return Ge(r,["metrics","style"])}function $t(r){return!!(r==null?void 0:r.type)&&(to.includes(r.type)||r.imgDisplay===R.ImageDisplay.INLINE)}function
|
|
85
|
-
`,s.append(a),l.selectNodeContents(s),i==null||i.removeAllRanges(),i==null||i.addRange(l),document.execCommand("copy"),s.remove()}
|
|
86
|
-
`||(t.splice(l,0,d),l++)}l--}l++}}It(s,t,o,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function vn(r,t){const e=r.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=Re(t,{innerWidth:e.getOriginalInnerWidth()});sn(r,n)}function rn(r,t){const e=r.getDraw();if(e.isReadonly()||e.isDisabled())return;const{pasteImage:n}=e.getOverride();if(n){const a=n(t);if((a==null?void 0:a.preventDefault)!==!1)return}const o=e.getRange(),{startIndex:s}=o.getRange(),i=e.getElementList(),l=new FileReader;l.readAsDataURL(t),l.onload=()=>{const a=new Image,c=l.result;a.src=c,a.onload=()=>{const d={value:c,type:R.ElementType.IMAGE,width:a.width,height:a.height};~s&&It(i,[d],s,{editorOptions:e.getOptions()}),e.insertElementList([d])}}}function zo(r,t){const e=r.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=t.clipboardData;if(!n)return;const{paste:o}=e.getOverride();if(o){const i=o(t);if((i==null?void 0:i.preventDefault)!==!1)return}if(!_o(n)){const i=n.getData("text"),l=Gn();if(l&&We(i)===We(l.text)){sn(r,l.elementList);return}}xn();let s=!1;for(let i=0;i<n.items.length;i++)if(n.items[i].type==="text/html"){s=!0;break}for(let i=0;i<n.items.length;i++){const l=n.items[i];if(l.kind==="string"){if(l.type==="text/plain"&&!s){l.getAsString(a=>{r.input(a)});break}if(l.type==="text/html"&&s){l.getAsString(a=>{vn(r,a)});break}}else if(l.kind==="file"&&l.type.includes("image")){const a=l.getAsFile();a&&rn(r,a)}}}async function $o(r,t){const e=r.getDraw();if(e.isReadonly()||e.isDisabled())return;const{paste:n}=e.getOverride();if(n){const i=n();if((i==null?void 0:i.preventDefault)!==!1)return}const o=await navigator.clipboard.readText(),s=Gn();if(s&&We(o)===We(s.text)){sn(r,s.elementList);return}if(xn(),t==null?void 0:t.isPlainText)o&&r.input(o);else{const i=await navigator.clipboard.read();let l=!1;for(const a of i)if(a.types.includes("text/html")){l=!0;break}for(const a of i)if(a.types.includes("text/plain")&&!l){const d=await(await a.getType("text/plain")).text();d&&r.input(d)}else if(a.types.includes("text/html")&&l){const d=await(await a.getType("text/html")).text();d&&vn(r,d)}else if(a.types.some(c=>c.startsWith("image/"))){const c=a.types.find(h=>h.startsWith("image/")),d=await a.getType(c);rn(r,d)}}}class jo{constructor(t,e){L(this,"draw");L(this,"container");L(this,"agentCursorDom");L(this,"canvasEvent");L(this,"eventBus");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(`${v}-inputarea`),n.innerText="",this.container.append(n),this.agentCursorDom=n,n.onkeydown=o=>this._keyDown(o),n.oninput=this._input.bind(this),n.onpaste=o=>this._paste(o),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||(zo(this.canvasEvent,t),t.preventDefault())}_compositionstart(){this.canvasEvent.compositionstart()}_compositionend(t){this.canvasEvent.compositionend(t)}}class qo{constructor(t,e){L(this,"ANIMATION_CLASS",`${v}-cursor--animation`);L(this,"draw");L(this,"container");L(this,"options");L(this,"position");L(this,"cursorDom");L(this,"cursorAgent");L(this,"blinkTimeout");L(this,"hitLineStartIndex");this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${v}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new jo(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(Ai&&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:o}=this.options,{color:s,width:i,isShow:l=!0,isBlink:a=!0,isFocus:c=!0,hitLineStartIndex:d}=Y(Y({},o),t),h=this.draw.getHeight(),u=this.draw.getPageGap();this.hitLineStartIndex=d,d&&(e=this.position.getPositionList()[d]);const{metrics:g,coordinate:{leftTop:T,rightTop:P},ascent:O,pageNo:M}=e,N=(this.draw.getZone().isMainActive()?M:this.draw.getPageNo())*(h+u),m=vi*n,I=Math.min(g.height/4,m),f=g.height+I*2,F=this.cursorAgent.getAgentCursorDom();c&&setTimeout(()=>{this.focus()});const V=g.boundingBoxDescent<0?0:g.boundingBoxDescent,Z=T[1]+O+V-(f-I)+N,C=d?T[0]:P[0];if(F.style.left=`${C}px`,F.style.top=`${Z+f-m}px`,!l){this.recoveryCursor();return}const D=this.cursorDom.style.top,W=this.draw.isReadonly();this.cursorDom.style.width=`${i*n}px`,this.cursorDom.style.backgroundColor=s,this.cursorDom.style.left=`${C}px`,this.cursorDom.style.top=`${Z}px`,this.cursorDom.style.display=W?"none":"block",this.cursorDom.style.height=`${f}px`,a?this._setBlinkTimeout():this._clearBlinkTimeout(),c&&Be(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(D)>Z?Lt.UP:Lt.DOWN})})}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:n}=t;if(!e||!n)return;const{pageNo:o,coordinate:{leftTop:s,leftBottom:i}}=e,l=Hi(this.container),a={left:0,right:0,top:0,bottom:0},c=l===document.documentElement;if(c)a.right=window.innerWidth,a.bottom=window.innerHeight;else{const{left:P,right:O,top:M,bottom:S}=l.getBoundingClientRect();a.left=P,a.right=O,a.top=M,a.bottom=S}const d=o*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,h=n===Lt.UP,u=i[0]+(c?0:a.left),g=h?s[1]+d:i[1]+d,{maskMargin:T}=this.options;if(a.top+=T[0],a.bottom-=T[2],!(u>=a.left&&u<=a.right&&g>=a.top&&g<=a.bottom)){const{scrollLeft:P,scrollTop:O}=l;h?l.scroll(P,O-(a.top-g)):l.scroll(P,O+g-a.bottom)}}}var ln;(function(r){r[r.LEFT=0]="LEFT",r[r.CENTER=1]="CENTER",r[r.RIGHT=2]="RIGHT"})(ln||(ln={}));function yt(r){return qt?r.metaKey:r.ctrlKey}R.KeyMap=void 0,function(r){r.Delete="Delete",r.Backspace="Backspace",r.Enter="Enter",r.Left="ArrowLeft",r.Right="ArrowRight",r.Up="ArrowUp",r.Down="ArrowDown",r.Home="Home",r.End="End",r.ESC="Escape",r.TAB="Tab",r.META="Meta",r.LEFT_BRACKET="[",r.RIGHT_BRACKET="]",r.COMMA=",",r.PERIOD=".",r.LEFT_ANGLE_BRACKET="<",r.RIGHT_ANGLE_BRACKET=">",r.EQUAL="=",r.MINUS="-",r.PLUS="+",r.A="a",r.B="b",r.C="c",r.D="d",r.E="e",r.F="f",r.G="g",r.H="h",r.I="i",r.J="j",r.K="k",r.L="l",r.M="m",r.N="n",r.O="o",r.P="p",r.Q="q",r.R="r",r.S="s",r.T="t",r.U="u",r.V="v",r.W="w",r.X="x",r.Y="y",r.Z="z",r.A_UPPERCASE="A",r.B_UPPERCASE="B",r.C_UPPERCASE="C",r.D_UPPERCASE="D",r.E_UPPERCASE="E",r.F_UPPERCASE="F",r.G_UPPERCASE="G",r.H_UPPERCASE="H",r.I_UPPERCASE="I",r.J_UPPERCASE="J",r.K_UPPERCASE="K",r.L_UPPERCASE="L",r.M_UPPERCASE="M",r.N_UPPERCASE="N",r.O_UPPERCASE="O",r.P_UPPERCASE="P",r.Q_UPPERCASE="Q",r.R_UPPERCASE="R",r.S_UPPERCASE="S",r.T_UPPERCASE="T",r.U_UPPERCASE="U",r.V_UPPERCASE="V",r.W_UPPERCASE="W",r.X_UPPERCASE="X",r.Y_UPPERCASE="Y",r.Z_UPPERCASE="Z",r.ZERO="0",r.ONE="1",r.TWO="2",r.THREE="3",r.FOUR="4",r.FIVE="5",r.SIX="6",r.SEVEN="7",r.EIGHT="8",r.NINE="9"}(R.KeyMap||(R.KeyMap={}));class Ce{constructor(t,e){L(this,"element");L(this,"control");this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getCode(){var t;return((t=this.element.control)==null?void 0:t.code)||null}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),n=t[e],o=[];let s=e;for(;s>0;){const l=t[s];if(l.controlId!==n.controlId||l.controlComponent===R.ControlComponent.PREFIX||l.controlComponent===R.ControlComponent.PRE_TEXT)break;l.controlComponent===R.ControlComponent.VALUE&&o.unshift(l),s--}let i=e+1;for(;i<t.length;){const l=t[i];if(l.controlId!==n.controlId||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT)break;l.controlComponent===R.ControlComponent.VALUE&&o.push(l),i++}return o}setValue(){return-1}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:o}=this.element,s=e.elementList||this.control.getElementList(),{startIndex:i}=e.range||this.control.getRange(),l=s[i];let a=i;for(;a>0;){const d=s[a];if(d.controlId!==l.controlId||d.controlComponent===R.ControlComponent.PREFIX||d.controlComponent===R.ControlComponent.PRE_TEXT)break;if(d.controlComponent===R.ControlComponent.CHECKBOX){const h=d.checkbox;h.value=t.includes(h.code)}a--}let c=i+1;for(;c<s.length;){const d=s[c];if(d.controlId!==l.controlId||d.controlComponent===R.ControlComponent.POSTFIX||d.controlComponent===R.ControlComponent.POST_TEXT)break;if(d.controlComponent===R.ControlComponent.CHECKBOX){const h=d.checkbox;h.value=t.includes(h.code)}c++}o.code=t.join(","),this.control.repaintControl({curIndex:i,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:o}=e;return t.key===R.KeyMap.Backspace||t.key===R.KeyMap.Delete?this.control.removeControl(n):o}cut(){return-1}}class an extends Ce{setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:o}=this.element,s=e.elementList||this.control.getElementList(),{startIndex:i}=e.range||this.control.getRange(),l=s[i];let a=i;for(;a>0;){const d=s[a];if(d.controlId!==l.controlId||d.controlComponent===R.ControlComponent.PREFIX||d.controlComponent===R.ControlComponent.PRE_TEXT)break;if(d.controlComponent===R.ControlComponent.RADIO){const h=d.radio;h.value=t.includes(h.code)}a--}let c=i+1;for(;c<s.length;){const d=s[c];if(d.controlId!==l.controlId||d.controlComponent===R.ControlComponent.POSTFIX||d.controlComponent===R.ControlComponent.POST_TEXT)break;if(d.controlComponent===R.ControlComponent.RADIO){const h=d.radio;h.value=t.includes(h.code)}c++}o.code=t.join(","),this.control.repaintControl({curIndex:i,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}}function Bn(r){const t=r.getDraw(),e=t.getPosition(),n=t.getRange();r.isAllowDrag=!0,r.cacheRange=$(n.getRange()),r.cacheElementList=t.getElementList(),r.cachePositionList=e.getPositionList(),r.cachePositionContext=e.getPositionContext()}function kn(r,t){const{checkbox:e,control:n}=r;if(!n)t.getCheckboxParticle().setSelect(r);else{const o=(n==null?void 0:n.code)?n.code.split(","):[];if(e==null?void 0:e.value){const i=o.findIndex(l=>l===e.code);o.splice(i,1)}else(e==null?void 0:e.code)&&o.push(e.code);const s=t.getControl().getActiveControl();s instanceof Ce&&s.setSelect(o)}}function An(r,t){const{radio:e,control:n}=r;if(!n)t.getRadioParticle().setSelect(r);else{const o=(e==null?void 0:e.code)?[e.code]:[],s=t.getControl().getActiveControl();s instanceof an&&s.setSelect(o)}}function ts(r,t){var w,K;const e=t.getDraw();let n=e.isReadonly();const o=e.getRange(),s=e.getPosition(),i=o.getRange();if(r.button===ln.RIGHT&&(i.isCrossRowCol||!o.getIsCollapsed()))return;if(!t.isAllowDrag&&!n&&i.startIndex!==i.endIndex&&o.getIsPointInRange(r.offsetX,r.offsetY)){Bn(t);return}const a=r.target.dataset.index;a&&e.setPageNo(Number(a)),t.isAllowSelection=!0;const c=$(s.getPositionContext()),d=s.adjustPositionContext({x:r.offsetX,y:r.offsetY});if(!d)return;const{index:h,isDirectHit:u,isCheckbox:g,isRadio:T,isImage:P,isLabel:O,isTable:M,tdValueIndex:S,hitLineStartIndex:X}=d;t.mouseDownStartPosition=B(Y({},d),{index:M?S:h,x:r.offsetX,y:r.offsetY});const N=e.getElementList(),m=s.getPositionList(),I=M?S:h,f=N[I],F=!!(u&&P),V=!!(u&&g),Z=!!(u&&T),C=!!(u&&O);if(~h){let p=I,G=I;if(r.shiftKey){const{startIndex:H}=o.getRange();~H&&s.getPositionContext().tdId===c.tdId&&(I>H?p=H:G=H)}if(o.setRange(p,G),s.setCursorPosition(m[I]),n=e.isReadonly(),V&&!n)kn(f,e);else if(Z&&!n)An(f,e);else if(f.controlComponent===R.ControlComponent.VALUE&&(((w=f.control)==null?void 0:w.type)===R.ControlType.CHECKBOX||((K=f.control)==null?void 0:K.type)===R.ControlType.RADIO)){let H=I;for(;H>0;){const x=N[H];if(x.controlComponent===R.ControlComponent.CHECKBOX){kn(x,e);break}else if(x.controlComponent===R.ControlComponent.RADIO){An(x,e);break}H--}}else e.render({curIndex:I,isCompute:!1,isSubmitHistory:!1,isSetCursor:!F&&!V&&!Z});X&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:X})}const D=e.getEventBus();C&&D.isSubscribe("labelMousedown")&&D.emit("labelMousedown",{evt:r,element:f});const W=e.getPreviewer();if(W.clearResizer(),F){const p={dragDisable:n||!f.controlId&&e.getMode()===R.EditorMode.FORM};f.type===R.ElementType.LATEX&&(p.mime="svg",p.srcKey="laTexSVG"),W.drawResizer(f,m[I],p),e.getCursor().drawCursor({isShow:!1}),Bn(t),(f.imgDisplay===R.ImageDisplay.SURROUND||f.imgDisplay===R.ImageDisplay.FLOAT_TOP||f.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(f),D.isSubscribe("imageMousedown")&&D.emit("imageMousedown",{evt:r,element:f})}const E=e.getTableTool();E.dispose(),M&&!n&&e.getMode()!==R.EditorMode.FORM&&E.render();const U=e.getHyperlinkParticle();U.clearHyperlinkPopup(),f.type===R.ElementType.HYPERLINK&&(yt(r)?U.openHyperlink(f):U.drawHyperlinkPopup(f,m[I]));const Q=e.getDateParticle();Q.clearDatePicker(),f.type===R.ElementType.DATE&&!n&&Q.renderDatePicker(f,m[I])}function Ee(r){const t=j();return Reflect.set(r,"dragId",t),t}function De(r,t){return t.findIndex(e=>e.dragId===r)}function _n(r,t,e){const n=e.getDraw();if(r.imgDisplay===R.ImageDisplay.SURROUND||r.imgDisplay===R.ImageDisplay.FLOAT_TOP||r.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM){const o=t.offsetX-e.mouseDownStartPosition.x,s=t.offsetY-e.mouseDownStartPosition.y,i=r.imgFloatPosition;r.imgFloatPosition={x:i.x+o,y:i.y+s,pageNo:n.getPageNo()}}n.getImageParticle().destroyFloatImage()}function es(r,t){var e,n,o,s,i,l;if(t.isAllowDrop){const a=t.getDraw();if(a.isReadonly()||a.isDisabled()){t.mousedown(r);return}const c=a.getPosition(),d=c.getPositionList(),h=c.getPositionContext(),u=a.getRange(),g=t.cacheRange,T=t.cacheElementList,P=t.cachePositionList,O=t.cachePositionContext,M=u.getRange(),S=g.startIndex===g.endIndex,X=S?g.startIndex-1:g.startIndex,N=g.endIndex;if(M.startIndex>=X&&M.endIndex<=N&&((e=t.cachePositionContext)==null?void 0:e.tdId)===h.tdId){a.clearSideEffect();let it=!1,et=!1;if(S){const q=T[N];if(q.type===R.ElementType.IMAGE||q.type===R.ElementType.LATEX){if(_n(q,r,t),q.imgDisplay===R.ImageDisplay.SURROUND||q.imgDisplay===R.ImageDisplay.FLOAT_TOP||q.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)a.getPreviewer().drawResizer(q),it=!0;else{const nt=P[N];a.getPreviewer().drawResizer(q,nt)}et=q.imgDisplay===R.ImageDisplay.SURROUND}}u.replaceRange(Y({},g)),a.render({isCompute:et,isSubmitHistory:it,isSetCursor:!1});return}const m=T.slice(X+1,N+1),I=m.find(it=>it.controlId);if(I){const it=T[X+1],et=T[N];if(!((!it.controlId||it.controlComponent===R.ControlComponent.PREFIX)&&(!et.controlId||et.controlComponent===R.ControlComponent.POSTFIX)||it.controlId===et.controlId&&it.controlComponent===R.ControlComponent.PREFIX&&et.controlComponent===R.ControlComponent.POSTFIX||((n=it.control)==null?void 0:n.type)===R.ControlType.TEXT&&it.controlComponent===R.ControlComponent.VALUE&&((o=et.control)==null?void 0:o.type)===R.ControlType.TEXT&&et.controlComponent===R.ControlComponent.VALUE)){a.render({curIndex:M.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const f=a.getControl(),F=a.getElementList(),V=!I||!!F[M.startIndex].controlId||!f.getIsElementListContainFullControl(m),Z=a.getOptions(),C=m.map(it=>{if(!it.type||it.type===R.ElementType.TEXT){const et={value:it.value},q=Dt;return V||q.push(..._e),q.forEach(nt=>{const b=it[nt];b!==void 0&&(et[nt]=b)}),et}else{let et=$(it);return V&&(et=Gt(et,_e)),Pt([et],{isHandleFirstElement:!1,editorOptions:Z}),et}});It(F,C,M.startIndex,{editorOptions:a.getOptions()});const D=T[X],W=P[X],E=Ee(T[X]),U=Ee(T[N]),Q=C.length;let w=M.startIndex,K=w+Q;const p=f.getActiveControl();if(p&&T[w].controlComponent!==R.ControlComponent.POSTFIX?(K=p.setValue(C),w=K-Q):a.spliceElementList(F,w+1,0,C),!~K){a.render({isSetCursor:!1});return}const G=Ee(F[w]),H=Ee(F[K]),x=De(E,T),k=De(U,T),A=T[k];if(A.controlId&&A.controlComponent!==R.ControlComponent.POSTFIX)u.replaceRange(B(Y({},g),{startIndex:x,endIndex:k})),(s=f.getActiveControl())==null||s.cut();else{let it=!0;if(O==null?void 0:O.isTable){const{tableId:et,trIndex:q,tdIndex:nt}=O;it=!a.getOriginalElementList().some(Zt=>{var J,Ne,Tt,fe;return Zt.id===et&&((fe=(Tt=(Ne=(J=Zt==null?void 0:Zt.trList)==null?void 0:J[q])==null?void 0:Ne.tdList)==null?void 0:Tt[nt])==null?void 0:fe.deletable)===!1})}it&&a.spliceElementList(T,x+1,k-x)}const Nt=F[M.startIndex],Vt=d[M.startIndex];let ft=h.index;ft&&(Nt.tableId&&!D.tableId?W.index<ft&&(ft-=Q):!Nt.tableId&&D.tableId&&Vt.index<ft&&(ft+=Q),c.setPositionContext(B(Y({},h),{index:ft})));const gt=De(G,F),rt=De(H,F);u.setRange(S?rt:gt,rt,M.tableId,M.startTdIndex,M.endTdIndex,M.startTrIndex,M.endTrIndex),a.clearSideEffect();let Mt=null;if(S){const et=a.getElementList()[rt];(et.type===R.ElementType.IMAGE||et.type===R.ElementType.LATEX)&&(_n(et,r,t),Mt=et)}if(a.render({isSetCursor:!1}),p?f.emitControlContentChange():D.controlId&&f.emitControlContentChange({context:{range:g,elementList:T},controlElement:D}),Mt)if(Mt.imgDisplay===R.ImageDisplay.SURROUND||Mt.imgDisplay===R.ImageDisplay.FLOAT_TOP||Mt.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)a.getPreviewer().drawResizer(Mt);else{const et=c.getPositionList()[rt];a.getPreviewer().drawResizer(Mt,et)}}else t.isAllowDrag&&((i=t.cacheRange)==null?void 0:i.startIndex)!==((l=t.cacheRange)==null?void 0:l.endIndex)&&t.mousedown(r)}function ns(r,t){const e=t.getDraw();if(!e.getOptions().pageOuterSelectionDisable)return;const n=e.getPageContainer(),{x:o,y:s,width:i,height:l}=n.getBoundingClientRect();r.x>=o&&r.x<=o+i&&r.y>=s&&r.y<=s+l||t.setIsAllowSelection(!1)}function is(r,t){var I;const e=t.getDraw();if(t.isAllowDrag){const f=r.offsetX,F=r.offsetY,{startIndex:V,endIndex:Z}=t.cacheRange,C=t.cachePositionList;for(let W=V+1;W<=Z;W++){const{coordinate:{leftTop:E,rightBottom:U}}=C[W];if(f>=E[0]&&f<=U[0]&&F>=E[1]&&F<=U[1])return}const D=(I=t.cacheRange)==null?void 0:I.startIndex;if(D){const W=t.cacheElementList[D];(W==null?void 0:W.type)===R.ElementType.IMAGE&&(W.imgDisplay===R.ImageDisplay.SURROUND||W.imgDisplay===R.ImageDisplay.FLOAT_TOP||W.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)&&(e.getPreviewer().clearResizer(),e.getImageParticle().dragFloatImage(r.movementX,r.movementY))}t.dragover(r),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const o=r.target.dataset.index;o&&e.setPageNo(Number(o));const s=e.getPosition(),i=s.getPositionByXY({x:r.offsetX,y:r.offsetY});if(!~i.index)return;const{index:l,isTable:a,tdValueIndex:c,tdIndex:d,trIndex:h,tableId:u,trId:g,tdId:T}=i,{index:P,isTable:O,tdIndex:M,trIndex:S,tableId:X}=t.mouseDownStartPosition,N=a?c:l,m=e.getRange();if(a&&O&&(d!==M||h!==S))m.setRange(N,N,u,M,d,S,h),s.setPositionContext({isTable:a,index:l,trIndex:h,tdIndex:d,tdId:T,trId:g,tableId:u});else{let f=~N?N:0;if((O||a)&&X!==u)return;let F=P;if(F>f&&([F,f]=[f,F]),F===f)return;const V=e.getElementList(),Z=V[F+1],C=V[f];if((Z==null?void 0:Z.controlComponent)===R.ControlComponent.PLACEHOLDER&&(C==null?void 0:C.controlComponent)===R.ControlComponent.PLACEHOLDER&&Z.controlId===C.controlId)return;m.setRange(F,f)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function os(r){var l,a,c,d;const t=r.getDraw(),e=t.getRange(),n=e.getRange(),o=t.getElementList(),s=o[n.startIndex];if(!s.hide&&!((l=s.control)==null?void 0:l.hide)&&!((a=s.area)==null?void 0:a.hide))return;let i=n.startIndex;for(;i>0;){const h=o[i];let u=null;h.controlId?(u=t.getControl().removeControl(i),u!==null&&(i=u)):(t.spliceElementList(o,i,1),u=i-1,i--);const g=o[u];if(!g||!g.hide&&!((c=g.control)==null?void 0:c.hide)&&!((d=g.area)==null?void 0:d.hide)){if(u){n.startIndex=u,n.endIndex=u,e.replaceRange(n);const T=t.getPosition(),P=T.getPositionList();T.setCursorPosition(P[u])}break}}}function ss(r,t){var c;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&os(t);const o=e.getControl(),{startIndex:s,endIndex:i,isCrossRowCol:l}=n.getRange();let a;if(l){const d=e.getTableParticle().getRangeRowCol();if(!d)return;let h=!1;for(let u=0;u<d.length;u++){const g=d[u];for(let T=0;T<g.length;T++){const P=g[T];P.value.length>1&&(e.spliceElementList(P.value,1,P.value.length-1),h=!0)}}a=h?0:null}else if(o.getActiveControl()&&o.getIsRangeCanCaptureEvent())a=o.keydown(r),a&&o.emitControlContentChange();else{const d=e.getPosition().getCursorPosition();if(!d)return;const{index:h}=d,u=n.getIsCollapsed(),g=e.getElementList();if(u&&h===0){const M=g[h];if(M.value===y){M.listId&&e.getListParticle().unsetList(),r.preventDefault();return}}const T=g[s];if(u&&T.rowFlex&&T.value===y){const M=n.getRangeRowElementList();if(M){const S=g[s-1];M.forEach(X=>{X.rowFlex=S==null?void 0:S.rowFlex})}}const P=T.value===y?g[s-1]:T,O=g[i+1];if((P==null?void 0:P.titleId)&&(O==null?void 0:O.titleId)&&P.level===O.level&&P.titleId!==O.titleId){const M=P.titleId,S=O.titleId;let X=i+1;for(;X<g.length&&((c=g[X])==null?void 0:c.titleId)===S;)g[X].titleId=M,X++}u?e.spliceElementList(g,h,1):e.spliceElementList(g,s+1,i-s),a=u?h-1:s}e.getGlobalEvent().setCanvasEventAbility(),a===null?(n.setRange(s,s),e.render({curIndex:s,isSubmitHistory:!1})):(n.setRange(a,a),e.render({curIndex:a}))}function rs(r){var l,a,c,d;const t=r.getDraw(),n=t.getRange().getRange(),o=t.getElementList(),s=o[n.startIndex+1];if(!s.hide&&!((l=s.control)==null?void 0:l.hide)&&!((a=s.area)==null?void 0:a.hide))return;const i=n.startIndex+1;for(;i<o.length;){const h=o[i];let u=null;h.controlId?u=t.getControl().removeControl(i):(t.spliceElementList(o,i,1),u=i);const g=o[u];if(!g||!g.hide&&!((c=g.control)==null?void 0:c.hide)&&!((d=g.area)==null?void 0:d.hide))break}}function ls(r,t){var d;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:o,endIndex:s,isCrossRowCol:i}=n.getRange(),l=e.getElementList(),a=e.getControl();n.getIsCollapsed()&&rs(t);let c;if(i){const h=e.getTableParticle().getRangeRowCol();if(!h)return;let u=!1;for(let g=0;g<h.length;g++){const T=h[g];for(let P=0;P<T.length;P++){const O=T[P];O.value.length>1&&(e.spliceElementList(O.value,1,O.value.length-1),u=!0)}}c=u?0:null}else if(a.getActiveControl()&&a.getIsRangeWithinControl())c=a.keydown(r),c&&a.emitControlContentChange();else if((d=l[s+1])==null?void 0:d.controlId)c=a.removeControl(s+1);else{const h=e.getPosition(),u=h.getCursorPosition();if(!u)return;const{index:g}=u,T=h.getPositionContext();if(T.isDirectHit&&T.isImage)e.spliceElementList(l,g,1),c=g-1;else{const P=n.getIsCollapsed();if(!P)e.spliceElementList(l,o+1,s-o);else{if(!l[g+1])return;e.spliceElementList(l,g+1,1)}c=P?g:o}}e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(o,o),e.render({curIndex:o,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}))}function as(r,t){var T,P,O,M,S,X,N;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:o,endIndex:s}=n.getRange(),i=n.getIsCollapsed(),l=e.getElementList(),a=l[o],c=l[s];if(i&&c.listId&&c.value===y&&((T=l[s+1])==null?void 0:T.listId)!==c.listId){e.getListParticle().unsetList();return}let d={value:y};if(r.shiftKey&&a.listId&&(d.listWrap=!0),It(l,[d],o,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),r.shiftKey&&c.areaId&&c.areaId!==((P=l[s+1])==null?void 0:P.areaId)&&(d=Gt(d,se)),!(((O=l[o+1])==null?void 0:O.titleId)&&(!a.titleId||a.titleId!==((M=l[o+1])==null?void 0:M.titleId)))&&!(c.titleId&&c.titleId!==((S=l[s+1])==null?void 0:S.titleId))){const m=n.getRangeAnchorStyle(l,s);if(m){const I=[...te];m.controlComponent!==R.ControlComponent.POSTFIX&&I.push(...Dt),I.forEach(f=>{const F=m[f];F!==void 0&&(d[f]=F)})}}const h=e.getControl(),u=h.getActiveControl();let g;if(u&&h.getIsRangeWithinControl())g=h.setValue([d]),h.emitControlContentChange();else{const I=e.getPosition().getCursorPosition();if(!I)return;const{index:f}=I;if(i){if(e.spliceElementList(l,f+1,0,[d]),c.titleId&&((X=l[f+2])==null?void 0:X.titleId)===c.titleId){const F=j();let V=f+2;for(;V<l.length&&((N=l[V])==null?void 0:N.titleId)===c.titleId;)l[V].titleId=F,V++}}else e.spliceElementList(l,o+1,s-o,[d]);g=f+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),r.preventDefault()}function Rs(r,t){var N,m,I;const e=t.getDraw();if(e.isReadonly())return;const o=e.getPosition(),s=o.getCursorPosition();if(!s)return;const i=o.getPositionContext(),{index:l}=s;if(l<=0&&!i.isTable)return;const a=e.getRange(),{startIndex:c,endIndex:d}=a.getRange(),h=a.getIsCollapsed(),u=e.getElementList(),g=e.getControl();if(e.getMode()===R.EditorMode.FORM&&g.getActiveControl()&&(((N=u[l])==null?void 0:N.controlComponent)===R.ControlComponent.PREFIX||((m=u[l])==null?void 0:m.controlComponent)===R.ControlComponent.PRE_TEXT)){g.initNextControl({direction:Lt.UP});return}let T=1;if(yt(r)){const f=e.getLetterReg(),F=r.shiftKey&&!h&&c===(s==null?void 0:s.index)?d:c;if(f.test((I=u[F])==null?void 0:I.value)){let V=F-1;for(;V>0;){const Z=u[V];if(!f.test(Z.value))break;T++,V--}}}const P=c-T;let O=P,M=P;if(r.shiftKey&&s&&(c!==d?c===s.index?(O=c,M=d-T):(O=P,M=d):M=d),!r.shiftKey){const f=u[c];if(f.type===R.ElementType.TABLE){const F=f.trList,V=F.length-1,Z=F[V],C=Z.tdList.length-1,D=Z.tdList[C];o.setPositionContext({isTable:!0,index:c,trIndex:V,tdIndex:C,tdId:D.id,trId:Z.id,tableId:f.id}),O=D.value.length-1,M=O,e.getTableTool().render()}else if(f.tableId&&c===0){const V=e.getOriginalElementList()[i.index].trList;t:for(let Z=0;Z<V.length;Z++){const C=V[Z];if(C.id!==f.trId)continue;const D=C.tdList;for(let W=0;W<D.length;W++)if(D[W].id===f.tdId){if(Z===0&&W===0)o.setPositionContext({isTable:!1}),O=i.index-1,M=O,e.getTableTool().dispose();else{let U=Z,Q=W-1;Q<0&&(U=Z-1,Q=V[U].tdList.length-1);const w=V[U],K=w.tdList[Q];o.setPositionContext({isTable:!0,index:i.index,trIndex:U,tdIndex:Q,tdId:K.id,trId:w.id,tableId:f.tableId}),O=K.value.length-1,M=O,e.getTableTool().render()}break t}}}}if(!~O||!~M)return;const S=e.getElementList();O=Oe(S,O),M=Oe(S,M),a.setRange(O,M);const X=O===M;if(e.render({curIndex:X?O:void 0,isSetCursor:X,isSubmitHistory:!1,isCompute:!1}),X){const f=o.getPositionList(),F=f[O];if((F==null?void 0:F.isLastLetter)&&F.value!==y&&O+1<f.length){const V=f[O+1],Z=S[O],C=S[O+1];V.value!==y&&!$t(C)&&Z.listId===C.listId&&e.getCursor().drawCursor({hitLineStartIndex:O+1})}}r.preventDefault()}function cs(r,t){var I,f,F;const e=t.getDraw();if(e.isReadonly())return;const o=e.getPosition(),s=o.getCursorPosition();if(!s)return;const{index:i}=s,l=o.getPositionList(),a=o.getPositionContext();if(i>l.length-1&&!a.isTable)return;const c=e.getRange(),{startIndex:d,endIndex:h}=c.getRange(),u=c.getIsCollapsed();let g=e.getElementList();const T=e.getControl();if(e.getMode()===R.EditorMode.FORM&&T.getActiveControl()&&(((I=g[i+1])==null?void 0:I.controlComponent)===R.ControlComponent.POSTFIX||((f=g[i+1])==null?void 0:f.controlComponent)===R.ControlComponent.POST_TEXT)){T.initNextControl({direction:Lt.DOWN});return}let P=1;if(yt(r)){const V=e.getLetterReg(),Z=r.shiftKey&&!u&&d===(s==null?void 0:s.index)?h:d;if(V.test((F=g[Z+1])==null?void 0:F.value)){let C=Z+2;for(;C<g.length;){const D=g[C];if(!V.test(D.value))break;P++,C++}}}const O=h+P;let M=O,S=O;if(r.shiftKey&&s&&(d!==h?d===s.index?(M=d,S=O):(M=d+P,S=h):M=d),!r.shiftKey){const V=g[h],Z=g[h+1];if((Z==null?void 0:Z.type)===R.ElementType.TABLE){const D=Z.trList[0],W=D.tdList[0];o.setPositionContext({isTable:!0,index:h+1,trIndex:0,tdIndex:0,tdId:W.id,trId:D.id,tableId:Z.id}),M=0,S=0,e.getTableTool().render()}else if(V.tableId&&!Z){const D=e.getOriginalElementList()[a.index].trList;t:for(let W=0;W<D.length;W++){const E=D[W];if(E.id!==V.trId)continue;const U=E.tdList;for(let Q=0;Q<U.length;Q++)if(U[Q].id===V.tdId){if(W===D.length-1&&Q===U.length-1)o.setPositionContext({isTable:!1}),M=a.index,S=M,g=e.getElementList(),e.getTableTool().dispose();else{let K=W,p=Q+1;p>U.length-1&&(K=W+1,p=0);const G=D[K],H=G.tdList[p];o.setPositionContext({isTable:!0,index:a.index,trIndex:K,tdIndex:p,tdId:H.id,trId:G.id,tableId:V.tableId}),M=0,S=M,e.getTableTool().render()}break t}}}}const X=g.length-1;if(M>X||S>X)return;const N=e.getElementList();M=Oe(N,M,R.LocationPosition.AFTER),S=Oe(N,S,R.LocationPosition.AFTER),c.setRange(M,S);const m=M===S;if(e.render({curIndex:m?M:void 0,isSetCursor:m,isSubmitHistory:!1,isCompute:!1}),m){const V=l[M];if((V==null?void 0:V.isLastLetter)&&V.value!==y&&M+1<l.length){const Z=l[M+1],C=g[M],D=g[M+1];Z.value!==y&&!$t(D)&&C.listId===D.listId&&e.getCursor().drawCursor({hitLineStartIndex:M+1})}}r.preventDefault()}function ds(r,t){const e=t.getDraw();if(e.isReadonly())return;r.preventDefault();const o=e.getControl();if(o.getActiveControl()&&o.getIsRangeWithinControl())o.initNextControl({direction:r.shiftKey?Lt.UP:Lt.DOWN});else{const i=e.getRange(),l=e.getElementList(),{startIndex:a,endIndex:c}=i.getRange(),d=i.getRangeAnchorStyle(l,c),h=d?pt(d,Dt):null,u=B(Y({},h),{type:R.ElementType.TAB,value:""});It(l,[u],a,{editorOptions:e.getOptions()}),e.insertElementList([u])}}function Rn(r){const{positionList:t,index:e,isUp:n,rowNo:o,cursorX:s}=r;let i=-1;const l=[];if(n){let a=e-1;for(;a>=0;){const c=t[a];if(a--,c.rowNo!==o){if(l[0]&&l[0].rowNo!==c.rowNo)break;l.unshift(c)}}}else{let a=e+1;for(;a<t.length;){const c=t[a];if(a++,c.rowNo!==o){if(l[0]&&l[0].rowNo!==c.rowNo)break;l.push(c)}}}for(let a=0;a<l.length;a++){const c=l[a],{coordinate:{leftTop:[d],rightTop:[h]}}=c;if(a===l.length-1&&(i=c.index),!(s<d||s>h)){i=c.index;break}}return i}function hs(r,t){const e=t.getDraw();if(e.isReadonly())return;const o=e.getPosition(),s=o.getCursorPosition();if(!s)return;const i=e.getRange(),{startIndex:l,endIndex:a}=i.getRange();let c=o.getPositionList();const d=r.key===R.KeyMap.Up;let h=-1,u=-1;const g=o.getPositionContext();if(!r.shiftKey&&g.isTable&&(d&&s.rowIndex===0||!d&&s.rowIndex===e.getRowCount()-1)){const{index:P,trIndex:O,tdIndex:M,tableId:S}=g;if(d)if(O===0)o.setPositionContext({isTable:!1}),h=P-1,u=h,e.getTableTool().dispose();else{let X=-1,N=-1;const I=e.getOriginalElementList()[P].trList,f=I[O].tdList[M].colIndex;t:for(let Z=O-1;Z>=0;Z--){const D=I[Z].tdList;for(let W=0;W<D.length;W++){const E=D[W];if(E.colIndex===f||E.colIndex+E.colspan-1>=f&&E.colIndex<=f){X=Z,N=W;break t}}}if(!~X||!~N)return;const F=I[X],V=F.tdList[N];o.setPositionContext({isTable:!0,index:P,trIndex:X,tdIndex:N,tdId:V.id,trId:F.id,tableId:S}),h=V.value.length-1,u=h,e.getTableTool().render()}else{const N=e.getOriginalElementList()[P].trList;if(O===N.length-1)o.setPositionContext({isTable:!1}),h=P,u=h,e.getTableTool().dispose();else{let m=-1,I=-1;const f=N[O].tdList[M].colIndex;t:for(let Z=O+1;Z<N.length;Z++){const D=N[Z].tdList;for(let W=0;W<D.length;W++){const E=D[W];if(E.colIndex===f||E.colIndex+E.colspan-1>=f&&E.colIndex<=f){m=Z,I=W;break t}}}if(!~m||!~I)return;const F=N[m],V=F.tdList[I];o.setPositionContext({isTable:!0,index:P,trIndex:m,tdIndex:I,tdId:V.id,trId:F.id,tableId:S}),h=V.value.length-1,u=h,e.getTableTool().render()}}}else{let P=s;r.shiftKey&&(l===s.index?P=c[a]:P=c[l]);const{index:O,rowNo:M,rowIndex:S,coordinate:{rightTop:[X]}}=P;if(d&&S===0||!d&&S===e.getRowCount()-1)return;const N=Rn({positionList:c,index:O,rowNo:M,isUp:d,cursorX:X});if(N<0)return;h=N,u=N,r.shiftKey&&(l!==a?l===s.index?h=l:u=a:d?u=a:h=l);const I=e.getElementList()[N];if(I.type===R.ElementType.TABLE){const{scale:f}=e.getOptions(),F=e.getMargins(),V=I.trList;let Z=-1,C=-1,D=-1;if(d){t:for(let W=V.length-1;W>=0;W--){const U=V[W].tdList;for(let Q=0;Q<U.length;Q++){const w=U[Q],K=w.x*f+F[3],p=w.width*f;if(X>=K&&X<=K+p){const G=w.positionList,H=G[G.length-1],x=Rn({positionList:G,index:H.index+1,rowNo:H.rowNo-1,isUp:d,cursorX:X})||H.index;Z=W,C=Q,D=x;break t}}}}else{t:for(let W=0;W<V.length;W++){const U=V[W].tdList;for(let Q=0;Q<U.length;Q++){const w=U[Q],K=w.x*f+F[3],p=w.width*f;if(X>=K&&X<=K+p){const G=w.positionList,H=Rn({positionList:G,index:-1,rowNo:-1,isUp:d,cursorX:X})||0;Z=W,C=Q,D=H;break t}}}}if(~Z&&~C&&~D){const W=V[Z],E=W.tdList[C];o.setPositionContext({isTable:!0,index:N,trIndex:Z,tdIndex:C,tdId:E.id,trId:W.id,tableId:I.id}),h=D,u=h,c=o.getPositionList(),e.getTableTool().render()}}}if(!~h||!~u)return;h>u&&([h,u]=[u,h]),i.setRange(h,u);const T=h===u;e.render({curIndex:T?h:void 0,isSetCursor:T,isSubmitHistory:!1,isCompute:!1}),T||e.getCursor().moveCursorToVisible({cursorPosition:c[d?h:u],direction:d?Lt.UP:Lt.DOWN})}function zn(r,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getPosition(),o=n.getCursorPosition();if(!o)return;const s=e.getRange(),{startIndex:i,endIndex:l}=s.getRange(),a=n.getPositionList();let c=o;r.shiftKey&&i!==l&&(i===o.index?c=a[l]:c=a[i]);const{rowNo:d}=c;let h=c.index;for(let O=c.index-1;O>=0&&a[O].rowNo===d;O--)h=O;const u=a[h].value!==y;u&&h--;let g=h,T=h;r.shiftKey&&(i!==l?i===o.index?(g=i,T=h):(g=h,T=l):(g=h,T=i)),g>T&&([g,T]=[T,g]),s.setRange(g,T);const P=g===T;e.render({curIndex:P?g:void 0,isSetCursor:P,isSubmitHistory:!1,isCompute:!1}),u&&e.getCursor().drawCursor({hitLineStartIndex:h+1}),r.preventDefault()}function $n(r,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getPosition(),o=n.getCursorPosition();if(!o)return;const s=e.getRange(),{startIndex:i,endIndex:l}=s.getRange(),a=n.getPositionList();let c=o;r.shiftKey&&i!==l&&(i===o.index?c=a[l]:c=a[i]);let{rowNo:d}=c;e.getCursor().getHitLineStartIndex()!==void 0&&d++;let u=c.index;for(let O=c.index+1;O<a.length&&a[O].rowNo===d;O++)u=O;let g=u,T=u;r.shiftKey&&(i!==l?i===o.index?(g=i,T=u):(g=u,T=l):(g=i,T=u)),g>T&&([g,T]=[T,g]),s.setRange(g,T);const P=g===T;e.render({curIndex:P?g:void 0,isSetCursor:P,isSubmitHistory:!1,isCompute:!1}),r.preventDefault()}function us(r,t){if(t.isComposing)return;const e=t.getDraw();if(r.key===R.KeyMap.Backspace)ss(r,t);else if(r.key===R.KeyMap.Delete)ls(r,t);else if(r.key===R.KeyMap.Enter)as(r,t);else if(r.key===R.KeyMap.Left)yt(r)?zn(r,t):Rs(r,t);else if(r.key===R.KeyMap.Right)yt(r)?$n(r,t):cs(r,t);else if(r.key===R.KeyMap.Up||r.key===R.KeyMap.Down)hs(r,t);else if(r.key===R.KeyMap.Home)zn(r,t);else if(r.key===R.KeyMap.End)$n(r,t);else if(yt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==R.EditorMode.FORM)return;e.getHistoryManager().undo(),r.preventDefault()}else if(yt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==R.EditorMode.FORM)return;e.getHistoryManager().redo(),r.preventDefault()}else if(yt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.C)t.copy(),r.preventDefault();else if(yt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.X)t.cut(),r.preventDefault();else if(yt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.A)t.selectAll(),r.preventDefault();else if(yt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.S){if(e.isReadonly())return;const n=e.getListener();n.saved&&n.saved(e.getValue());const o=e.getEventBus();o.isSubscribe("saved")&&o.emit("saved",e.getValue()),r.preventDefault()}else if(r.key===R.KeyMap.ESC){t.clearPainterStyle();const n=e.getZone();n.isMainActive()||n.setZone(R.EditorZone.MAIN),r.preventDefault()}else r.key===R.KeyMap.TAB&&ds(r,t)}function cn(r,t){var f,F;const e=t.getDraw();if(e.isReadonly()||e.isDisabled())return;const o=e.getPosition().getCursorPosition();if(!r||!o)return;const s=t.isComposing;if(s&&((f=t.compositionInfo)==null?void 0:f.value)===r)return;const i=e.getRange();if(!i.getIsCanInput())return;const l=i.getDefaultStyle()||((F=t.compositionInfo)==null?void 0:F.defaultStyle)||null;jn(t),s||e.getCursor().clearAgentDomValue();const{TEXT:a,HYPERLINK:c,SUBSCRIPT:d,SUPERSCRIPT:h,DATE:u,TAB:g}=R.ElementType,T=r.replaceAll(`
|
|
87
|
-
`,y),{startIndex:P,endIndex:O}=i.getRange(),M=e.getElementList(),S=i.getRangeAnchorStyle(M,O);if(!S)return;const X=e.isDesignMode(),N=Qt(T).map(V=>{var C,D;const Z={value:V};if(X||!((C=S.title)==null?void 0:C.disabled)&&!((D=S.control)==null?void 0:D.disabled)){const W=M[O+1];(!S.type||S.type===a||S.type===c&&(W==null?void 0:W.type)===c||S.type===u&&(W==null?void 0:W.type)===u||S.type===d&&(W==null?void 0:W.type)===d||S.type===h&&(W==null?void 0:W.type)===h)&&zi.forEach(E=>{if(E==="groupIds"&&!(W==null?void 0:W.groupIds))return;const U=S[E];U!==void 0&&(Z[E]=U)}),(l||S.type===g)&&Dt.forEach(E=>{const U=(l==null?void 0:l[E])||S[E];U!==void 0&&(Z[E]=U)}),s&&(Z.underline=!0)}return Z}),m=e.getControl();let I;if(m.getActiveControl()&&m.getIsRangeWithinControl())I=m.setValue(N),s||m.emitControlContentChange();else{const V=P+1;P!==O&&e.spliceElementList(M,V,O-P),It(M,N,P,{editorOptions:e.getOptions()}),e.spliceElementList(M,V,0,N),I=P+N.length}~I&&(i.setRange(I,I),e.render({curIndex:I,isSubmitHistory:!s})),s&&~I&&(t.compositionInfo={elementList:M,value:T,startIndex:I-N.length,endIndex:I,defaultStyle:l})}function jn(r){if(!r.compositionInfo)return;const{elementList:t,startIndex:e,endIndex:n}=r.compositionInfo;t.splice(e+1,n-e),r.getDraw().getRange().setRange(e,e),r.compositionInfo=null}async function gs(r){const t=r.getDraw(),e=t.getRange(),{startIndex:n,endIndex:o}=e.getRange();if(!~n&&!~n||t.isReadonly()||!e.getIsCanInput())return;const s=t.getElementList();let i=n,l=o;if(n===o){const u=t.getPosition().getPositionList(),g=u[n],T=g.rowNo,P=g.pageNo,O=[];for(let S=0;S<u.length;S++){const X=u[S];if(X.pageNo>P)break;X.pageNo===P&&X.rowNo===T&&O.push(S)}const M=O[0]-1;i=M<0?0:M,l=O[O.length-1]}const a=t.getOptions();await Jn(s.slice(i+1,l+1),a);const c=t.getControl();let d;c.getActiveControl()&&c.getIsRangeWithinControl()?(d=c.cut(),c.emitControlContentChange()):(t.spliceElementList(s,i+1,l-i),d=i),e.setRange(d,d),t.render({curIndex:d})}async function Ls(r,t){const e=r.getDraw(),{copy:n}=e.getOverride();if(n){const l=n();if((l==null?void 0:l.preventDefault)!==!1)return}const o=e.getRange();let s=null;if(o.getRange().isCrossRowCol){const l=o.getRangeTableElement();if(!l)return;const a=e.getTableParticle().getRangeRowCol();if(!a)return;const c={type:R.ElementType.TABLE,value:"",colgroup:[],trList:[]},d=a[0],h=d[0].colIndex,u=d[d.length-1],g=u.colIndex+u.colspan-1;for(let T=h;T<=g;T++)c.colgroup.push(l.colgroup[T]);for(let T=0;T<a.length;T++){const P=a[T],O=l.trList[P[0].rowIndex],M={tdList:[],height:O.height,minHeight:O.minHeight};for(let S=0;S<P.length;S++)M.tdList.push(P[S]);c.trList.push(M)}s=st([c])}else s=o.getIsCollapsed()?o.getRangeRowElementList():o.getSelectionElementList();(t==null?void 0:t.isPlainText)&&(s==null?void 0:s.length)&&(s=[{value:ce(s)}]),!!(s==null?void 0:s.length)&&await Jn(s,e.getOptions())}function Ts(r,t){var s,i;const e=t.getDraw(),{drop:n}=e.getOverride();if(n){const l=n(r);if((l==null?void 0:l.preventDefault)!==!1)return}r.preventDefault();const o=(s=r.dataTransfer)==null?void 0:s.getData("text");if(o)t.input(o);else{const l=(i=r.dataTransfer)==null?void 0:i.files;if(!l)return;for(let a=0;a<l.length;a++){const c=l[a];c.type.startsWith("image")&&rn(t,c)}}}function qn(r){var u;if(!Intl.Segmenter)return null;const t=r.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const o=t.getRange().getRangeParagraphInfo();if(!o)return null;const s=((u=o==null?void 0:o.elementList)==null?void 0:u.map(g=>!g.type||g.type!==R.ElementType.CONTROL&&bt.includes(g.type)?g.value:y).join(""))||"";if(!s)return null;const i=e.isFirstLetter||t.getCursor().getHitLineStartIndex()?e.index+1:e.index,l=o.startIndex,c=new Intl.Segmenter(void 0,{granularity:"word"}).segment(s);let d=-1,h=-1;for(const{segment:g,index:T,isWordLike:P}of c){const O=T+l;if(P&&i>=O&&i<O+g.length){d=O-1,h=d+g.length;break}}return~d&&~h?{startIndex:d,endIndex:h}:null}function Ps(r){const t=r.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:n,index:o}=e,s=t.getLetterReg();let i=0,l=0;const a=He.test(n);if(a||s.test(n)){const d=t.getElementList();let h=o-1;for(;h>0;){const g=d[h].value;if(a&&He.test(g)||!a&&s.test(g))i++,h--;else break}let u=o+1;for(;u<d.length;){const g=d[u].value;if(a&&He.test(g)||!a&&s.test(g))l++,u++;else break}}const c=o-i-1;return c<0?null:{startIndex:c,endIndex:o+l}}function Ms(r,t){const e=r.getDraw(),n=e.getPosition(),o=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(o.isImage&&o.isDirectHit){const l=e.getElementList(),a=e.getEventBus(),c=l[o.index];if(a.isSubscribe("imageDblclick")&&a.emit("imageDblclick",{evt:t,element:c}),c.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&!~o.index&&o.zone){e.getZone().setZone(o.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((o.isCheckbox||o.isRadio)&&o.isDirectHit)return;const s=e.getRange(),i=qn(r)||Ps(r);!i||(s.setRange(i.startIndex,i.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),s.setRangeStyle())}function Os(r){var T,P;const t=r.getDraw(),e=t.getControl();if(e.getActiveControl()&&e.selectValue())return;const o=t.getPosition().getCursorPosition();if(!o)return;const{index:s}=o,i=t.getElementList();let l=0,a=0,c=s-1;for(;c>0;){const O=i[c],M=i[c-1];if(O.value===y&&!O.listWrap||O.listId!==(M==null?void 0:M.listId)||O.titleId!==(M==null?void 0:M.titleId))break;l++,c--}let d=s+1;for(;d<i.length;){const O=i[d],M=i[d+1];if(O.value===y&&!O.listWrap||O.listId!==(M==null?void 0:M.listId)||O.titleId!==(M==null?void 0:M.titleId))break;a++,d++}const h=t.getRange();let u=s-l-1;if(((T=i[u])==null?void 0:T.value)!==y&&(u-=1),u<0)return;let g=s+a+1;(((P=i[g])==null?void 0:P.value)===y||g>i.length-1)&&(g-=1),h.setRange(u,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}var ti={dblclick:Ms,threeClick:Os};function Ss(r){r.isComposing=!0}function Xs(r,t){r.isComposing=!1;const e=r.getDraw();if(t.data)_i?setTimeout(()=>{r.compositionInfo&&cn(t.data,r)},1):r.compositionInfo&&cn(t.data,r);else{jn(r);const o=e.getRange(),{endIndex:s}=o.getRange();e.render({curIndex:s,isSubmitHistory:!1})}e.getCursor().clearAgentDomValue()}var ei={compositionstart:Ss,compositionend:Xs};function Is(r,t){var X;const e=t.getDraw();if(e.isReadonly())return;r.preventDefault();const o=e.getPageContainer();if(!me(r.target,N=>N===o,!0))return;const l=r.target.dataset.index;l&&e.setPageNo(Number(l));const a=e.getPosition(),c=a.adjustPositionContext({x:r.offsetX,y:r.offsetY});if(!c)return;const{isTable:d,tdValueIndex:h,index:u}=c,g=a.getPositionList(),T=d?h:u;~u&&(e.getRange().setRange(T,T),a.setCursorPosition(g[T]));const P=e.getCursor(),{cursor:{dragColor:O,dragWidth:M,dragFloatImageDisabled:S}}=e.getOptions();if(S){const N=(X=t.cacheElementList)==null?void 0:X[t.cacheRange.startIndex];if((N==null?void 0:N.type)===R.ElementType.IMAGE&&(N.imgDisplay===R.ImageDisplay.FLOAT_TOP||N.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM||N.imgDisplay===R.ImageDisplay.SURROUND))return}P.drawCursor({width:M,color:O,isBlink:!1,isFocus:!1})}var Ns={dragover:Is};class fs{constructor(t){L(this,"isAllowSelection");L(this,"isComposing");L(this,"compositionInfo");L(this,"isAllowDrag");L(this,"isAllowDrop");L(this,"cacheRange");L(this,"cacheElementList");L(this,"cachePositionList");L(this,"cachePositionContext");L(this,"mouseDownStartPosition");L(this,"draw");L(this,"pageContainer");L(this,"pageList");L(this,"range");L(this,"position");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)),Di(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 i=qn(this);i&&(n=this.draw.getElementList().slice(i.startIndex+1,i.endIndex+1))}if(!n)return;const o=Object.keys(t);n.forEach(i=>{o.forEach(l=>{const a=l;Reflect.set(i,a,t[a])})}),this.draw.render({isSetCursor:!1});const s=this.draw.getPainterOptions();(!s||!s.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){is(t,this)}mousedown(t){ts(t,this)}click(){ki&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){es(t,this)}mouseleave(t){ns(t,this)}keydown(t){us(t,this)}dblclick(t){ti.dblclick(this,t)}threeClick(){ti.threeClick(this)}input(t){cn(t,this)}async cut(){await gs(this)}async copy(t){await Ls(this,t)}compositionstart(){ei.compositionstart(this)}compositionend(t){ei.compositionend(this,t)}drop(t){Ts(t,this)}dragover(t){Ns.dragover(t,this)}}const ni={PAGE_SCALE:"pageScale"};class ms{constructor(t,e){L(this,"draw");L(this,"options");L(this,"cursor");L(this,"canvasEvent");L(this,"range");L(this,"previewer");L(this,"tableTool");L(this,"hyperlinkParticle");L(this,"control");L(this,"dateParticle");L(this,"imageParticle");L(this,"dprMediaQueryList");L(this,"clearSideEffect",t=>{if(!this.cursor)return;const e=(t==null?void 0:t.composedPath()[0])||t.target,n=this.draw.getPageList();if(me(e,i=>n.includes(i),!0))return;if(me(e,i=>!!i&&i.nodeType===1&&!!i.getAttribute(_t),!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()});L(this,"setCanvasEventAbility",()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)});L(this,"setPageScale",t=>{if(this.options.shortcutDisableKeys.includes(ni.PAGE_SCALE)||!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const n=e*10+1;n<=30&&this.draw.setPageScale(n/10)}else{const n=e*10-1;n>=5&&this.draw.setPageScale(n/10)}});L(this,"_handleVisibilityChange",()=>{if(document.visibilityState==="visible"){const t=this.range.getRange(),e=!!~t.startIndex&&!!~t.endIndex&&t.startIndex===t.endIndex;this.range.replaceRange(t),this.draw.render({isSetCursor:e,isCompute:!1,isSubmitHistory:!1,curIndex:t.startIndex})}});L(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?void 0:t.getAgentIsActive())||(e=this.cursor)==null||e.drawCursor({isFocus:!1,isBlink:!1})})}}class Fs{constructor(t){L(this,"undoStack",[]);L(this,"redoStack",[]);L(this,"maxRecordCount");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 Ws{constructor(t){L(this,"cursorPosition");L(this,"positionContext");L(this,"positionList");L(this,"floatPositionList");L(this,"draw");L(this,"eventBus");L(this,"options");this.positionList=[],this.floatPositionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.eventBus=t.getEventBus(),this.options=t.getOptions()}getFloatPositionList(){return this.floatPositionList}getTablePositionList(t){const{index:e,trIndex:n,tdIndex:o}=this.positionContext;return t[e].trList[n].tdList[o].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:o,startX:s,startY:i,startRowIndex:l,startIndex:a,innerWidth:c,zone:d}=t,{scale:h,table:{tdPadding:u}}=this.options;let g=s,T=i,P=a;for(let O=0;O<n.length;O++){const M=n[O];if(!M.isSurround){const N=M.width+(M.offsetX||0);M.rowFlex===R.RowFlex.CENTER?g+=(c-N)/2:M.rowFlex===R.RowFlex.RIGHT&&(g+=c-N)}g+=M.offsetX||0,T+=M.offsetY||0;const S=g,X=T;for(let N=0;N<M.elementList.length;N++){const m=M.elementList[N],I=m.metrics,f=!m.hide&&(m.imgDisplay!==R.ImageDisplay.INLINE&&m.type===R.ElementType.IMAGE||m.type===R.ElementType.LATEX)?M.ascent-I.height:M.ascent;m.left&&(g+=m.left),m.translateX&&(g+=m.translateX*h);const F={pageNo:o,index:P,value:m.value,rowIndex:l+O,rowNo:O,metrics:I,left:m.left||0,ascent:f,lineHeight:M.height,isFirstLetter:N===0,isLastLetter:N===M.elementList.length-1,coordinate:{leftTop:[g,T],leftBottom:[g,T+M.height],rightTop:[g+I.width,T],rightBottom:[g+I.width,T+M.height]}};if(m.imgDisplay===R.ImageDisplay.SURROUND||m.imgDisplay===R.ImageDisplay.FLOAT_TOP||m.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM){const V=e[e.length-1];V&&(F.metrics=V.metrics,F.coordinate=V.coordinate),m.imgFloatPosition||(m.imgFloatPosition={x:g,y:T,pageNo:o}),this.floatPositionList.push({pageNo:o,element:m,position:F,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:P,zone:d})}if(e.push(F),P++,g+=I.width,m.type===R.ElementType.TABLE&&!m.hide){const V=u[1]+u[3],Z=u[0]+u[2];for(let C=0;C<m.trList.length;C++){const D=m.trList[C];for(let W=0;W<D.tdList.length;W++){const E=D.tdList[W];E.positionList=[];const U=E.rowList,Q=this.computePageRowPosition({positionList:E.positionList,rowList:U,pageNo:o,startRowIndex:0,startIndex:0,startX:(E.x+u[3])*h+S+(m.translateX||0)*h,startY:(E.y+u[0])*h+X,innerWidth:(E.width-V)*h,isTable:!0,index:P-1,tdIndex:W,trIndex:C,zone:d});if(E.verticalAlign===R.VerticalAlign.MIDDLE||E.verticalAlign===R.VerticalAlign.BOTTOM){const w=U.reduce((G,H)=>G+H.height,0),K=(E.height-Z)*h-w,p=E.verticalAlign===R.VerticalAlign.MIDDLE?K/2:K;Math.floor(p)>0&&E.positionList.forEach(G=>{const{coordinate:{leftTop:H,leftBottom:x,rightBottom:k,rightTop:A}}=G;H[1]+=p,x[1]+=p,k[1]+=p,A[1]+=p})}g=Q.x,T=Q.y}}g=S,T=X}}g=s,T+=M.height}return{x:g,y:T,index:P}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),n=this.draw.getMargins(),o=n[3],i=this.draw.getHeader().getExtraHeight(),l=n[0]+i;let a=0;for(let c=0;c<e.length;c++){const d=e[c];if(!(d==null?void 0:d.length))continue;const h=d[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:d,pageNo:c,startRowIndex:a,startIndex:h,startX:o,startY:l,innerWidth:t}),a+=d.length}}computeRowPosition(t){const{row:e,innerWidth:n}=t,o=[];return this.computePageRowPosition({positionList:o,innerWidth:n,rowList:[$(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),o}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 P,O,M,S,X;const{x:e,y:n,isTable:o}=t;let{elementList:s,positionList:i}=t;s||(s=this.draw.getOriginalElementList()),i||(i=this.getOriginalPositionList());const l=this.draw.getZone(),a=(P=t.pageNo)!=null?P:this.draw.getPageNo(),c=l.isMainActive(),d=c?a:0;if(!o){const N=this.getFloatPositionByXY(B(Y({},t),{imgDisplays:[R.ImageDisplay.FLOAT_TOP,R.ImageDisplay.SURROUND]}));if(N)return N}for(let N=0;N<i.length;N++){const{index:m,pageNo:I,left:f,isFirstLetter:F,coordinate:{leftTop:V,rightTop:Z,leftBottom:C}}=i[N];if(d===I){if(I>d)break;if(V[0]-f<=e&&Z[0]>=e&&V[1]<=n&&C[1]>=n){let D=N;const W=s[N];if(W.type===R.ElementType.TABLE)for(let U=0;U<W.trList.length;U++){const Q=W.trList[U];for(let w=0;w<Q.tdList.length;w++){const K=Q.tdList[w],p=this.getPositionByXY({x:e,y:n,td:K,pageNo:a,tablePosition:i[N],isTable:!0,elementList:K.value,positionList:K.positionList});if(~p.index){const{index:G,hitLineStartIndex:H}=p,x=K.value[G];return{index:m,isCheckbox:p.isCheckbox||x.type===R.ElementType.CHECKBOX||x.controlComponent===R.ControlComponent.CHECKBOX,isRadio:x.type===R.ElementType.RADIO||x.controlComponent===R.ControlComponent.RADIO,isControl:!!x.controlId,isImage:p.isImage,isDirectHit:p.isDirectHit,isTable:!0,tdIndex:w,trIndex:U,tdValueIndex:G,tdId:K.id,trId:Q.id,tableId:W.id,hitLineStartIndex:H}}}}if(W.type===R.ElementType.IMAGE||W.type===R.ElementType.LATEX)return{index:D,isDirectHit:!0,isImage:!0};if(W.type===R.ElementType.CHECKBOX||W.controlComponent===R.ControlComponent.CHECKBOX)return{index:D,isDirectHit:!0,isCheckbox:!0};if(W.type===R.ElementType.LABEL)return{index:D,isDirectHit:!0,isLabel:!0};if(W.type===R.ElementType.TAB&&W.listStyle===R.ListStyle.CHECKBOX){let U=D-1;for(;U>0;){const Q=s[U];if(Q.value===y&&Q.listStyle===R.ListStyle.CHECKBOX)break;U--}return{index:U,isDirectHit:!0,isCheckbox:!0}}if(W.type===R.ElementType.RADIO||W.controlComponent===R.ControlComponent.RADIO)return{index:D,isDirectHit:!0,isRadio:!0};let E;if(s[m].value!==y){const U=Z[0]-V[0];e<V[0]+U/2&&(D=N-1,F&&(E=N))}return{isDirectHit:!0,hitLineStartIndex:E,index:D,isControl:!!W.controlId}}}}if(!o){const N=this.getFloatPositionByXY(B(Y({},t),{imgDisplays:[R.ImageDisplay.FLOAT_BOTTOM]}));if(N)return N}let h=!1,u=-1,g;if(o){const{scale:N}=this.options,{td:m,tablePosition:I}=t;if(m&&I){const{leftTop:f}=I.coordinate,F=m.x*N+f[0],V=m.y*N+f[1],Z=m.width*N,C=m.height*N;if(!(F<e&&e<F+Z&&V<n&&n<V+C))return{index:u}}}const T=i.filter(N=>N.isLastLetter&&N.pageNo===d);for(let N=0;N<T.length;N++){const{index:m,rowNo:I,coordinate:{leftTop:f,leftBottom:F}}=T[N];if(n>f[1]&&n<=F[1]){const V=i.findIndex(W=>W.pageNo===d&&W.rowNo===I),Z=s[V],C=i[V],D=Z.listStyle===R.ListStyle.CHECKBOX?this.draw.getMargins()[3]:C.coordinate.leftTop[0];if(e<D)~V?C.value===y?u=V:(u=V-1,g=V):u=m;else{if(Z.listStyle===R.ListStyle.CHECKBOX&&e<f[0])return{index:V,isDirectHit:!0,isCheckbox:!0};u=m}h=!0;break}}if(!h){if(this.draw.getIsPagingMode()){const m=this.draw.getHeader(),I=m.getHeight(),f=m.getHeaderTop()+I,F=this.draw.getFooter(),Z=this.draw.getHeight()-(F.getFooterBottom()+F.getHeight());if(c){if(n<f)return{index:-1,zone:R.EditorZone.HEADER};if(n>Z)return{index:-1,zone:R.EditorZone.FOOTER}}else if(n<=Z&&n>=f)return{index:-1,zone:R.EditorZone.MAIN}}const N=this.draw.getMargins();if(n<=N[0])for(let m=0;m<i.length;m++){const I=i[m];if(I.pageNo!==d||I.rowNo!==0)continue;const{leftTop:f,rightTop:F}=I.coordinate;if(e<=N[3]||e>=f[0]&&e<=F[0]||((O=i[m+1])==null?void 0:O.rowNo)!==0)return{index:I.index}}else{const m=T[T.length-1];if(m){const I=m.rowNo;for(let f=0;f<i.length;f++){const F=i[f];if(F.pageNo!==d||F.rowNo!==I)continue;const{leftTop:V,rightTop:Z}=F.coordinate;if(e<=N[3]||e>=V[0]&&e<=Z[0]||((M=i[f+1])==null?void 0:M.rowNo)!==I)return{index:F.index}}}}return{index:((S=T[T.length-1])==null?void 0:S.index)||i.length-1}}return{hitLineStartIndex:g,index:u,isControl:!!((X=s[u])==null?void 0:X.controlId)}}getFloatPositionByXY(t){var l;const{x:e,y:n}=t,o=(l=t.pageNo)!=null?l:this.draw.getPageNo(),s=this.draw.getZone().getZone(),{scale:i}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:c,element:d,isTable:h,index:u,trIndex:g,tdIndex:T,tdValueIndex:P,zone:O,pageNo:M}=this.floatPositionList[a];if(o===M&&d.type===R.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!O||O===s)){const S=d.imgFloatPosition,X=S.x*i,N=S.y*i,m=d.width*i,I=d.height*i;if(e>=X&&e<=X+m&&n>=N&&n<=N+I)return h?{index:u,isDirectHit:!0,isImage:!0,isTable:h,trIndex:g,tdIndex:T,tdValueIndex:P,tdId:d.tdId,trId:d.trId,tableId:d.tableId}:{index:c.index,isDirectHit:!0,isImage:!0}}}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==R.EditorMode.READONLY){const{index:O,isTable:M,trIndex:S,tdIndex:X,tdValueIndex:N}=e,m=this.draw.getControl(),{newIndex:I}=m.moveCursor({index:O,isTable:M,trIndex:S,tdIndex:X,tdValueIndex:N});M?e.tdValueIndex=I:e.index=I}const{index:n,isCheckbox:o,isRadio:s,isControl:i,isImage:l,isLabel:a,isDirectHit:c,isTable:d,trIndex:h,tdIndex:u,tdId:g,trId:T,tableId:P}=e;return this.setPositionContext({isTable:d||!1,isCheckbox:o||!1,isRadio:s||!1,isControl:i||!1,isImage:l||!1,isLabel:a||!1,isDirectHit:c||!1,index:n,trIndex:h,tdIndex:u,tdId:g,trId:T,tableId:P}),e}setSurroundPosition(t){var h;const{scale:e}=this.options,{pageNo:n,row:o,rowElement:s,rowElementRect:i,surroundElementList:l,availableWidth:a}=t;let c=i.x,d=0;if(l.length&&!$t(s)&&!((h=s.control)==null?void 0:h.minWidth))for(let u=0;u<l.length;u++){const g=l[u],T=g.imgFloatPosition;if(T.pageNo!==n)continue;const P=B(Y({},T),{x:T.x*e,y:T.y*e,width:g.width*e,height:g.height*e});if(xi(i,P)){o.isSurround=!0;const O=P.width+P.x-i.x;if(s.left=O,o.width+=O,d+=O,c=P.x+P.width,o.width+s.metrics.width>a){s.left=0,o.width-=d;break}}}return{x:c,rowIncreaseWidth:d}}}class Vs{constructor(t){L(this,"draw");L(this,"options");L(this,"range");L(this,"listener");L(this,"eventBus");L(this,"position");L(this,"historyManager");L(this,"defaultStyle");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=Y(Y({},this.defaultStyle),t):this.defaultStyle=null}getDefaultStyle(){return this.defaultStyle}getRangeAnchorStyle(t,e){const n=Qe(t,e);return n?Y(Y({},n),this.defaultStyle):null}getIsRangeChange(t,e,n,o,s,i,l){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==n||this.range.startTdIndex!==o||this.range.endTdIndex!==s||this.range.startTrIndex!==i||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 o;const{startIndex:t,endIndex:e}=this.range;if(t===e)return null;const n=this.draw.getElementList();return n.slice(((o=n[t])==null?void 0:o.value)===y?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 o=t[n];for(let s=0;s<o.length;s++){const i=o[s];e.push(...i.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||bt.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||bt.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),o=new Map;for(let s=t;s<e+1;s++){const{pageNo:i,rowNo:l}=n[s],a=o.get(i);a?a.has(l)||a.add(l):o.set(i,new Set([l]))}return o}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:n}=this.range;if(!~t&&!~e)return null;if(n)return this.getSelectionElementList();const o=this.getRangeRow();if(!o)return null;const s=this.position.getPositionList(),i=this.draw.getElementList(),l=[];for(let a=0;a<s.length;a++){const c=s[a],d=o.get(c.pageNo);!d||d.has(c.rowNo)&&l.push(i[a])}return l}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),o=this.draw.getElementList(),s=new Map;let i=t;for(;i>=0;){const{pageNo:c,rowNo:d}=n[i];let h=s.get(c);h||(h=[],s.set(c,h)),h.includes(d)||h.unshift(d);const u=o[i],g=o[i-1];if(u.value===y&&!u.listWrap||u.listId!==(g==null?void 0:g.listId)||u.titleId!==(g==null?void 0:g.titleId))break;i--}const l=t===e;if(!l){let c=t+1;for(;c<e;){const{pageNo:d,rowNo:h}=n[c];let u=s.get(d);u||(u=[],s.set(d,u)),u.includes(h)||u.push(h),c++}}let a=e;for(l&&o[t].value===y&&(a+=1);a<n.length;){const c=o[a],d=o[a+1];if(c.value===y&&!c.listWrap||c.listId!==(d==null?void 0:d.listId)||c.titleId!==(d==null?void 0:d.titleId))break;const{pageNo:h,rowNo:u}=n[a];let g=s.get(h);g||(g=[],s.set(h,g)),g.includes(u)||g.push(u),a++}return s}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let n=-1;const o=[],s=this.getRangeParagraph();if(!s)return null;const i=this.draw.getElementList(),l=this.position.getPositionList();for(let a=0;a<l.length;a++){const c=l[a],d=s.get(c.pageNo);!d||d.includes(c.rowNo)&&(~n||(n=c.index),o.push(i[a]))}return o.length?{elementList:o,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:o}=this.range,s=this.position.getPositionList();for(let i=n+1;i<=o&&s[i];i++){const{coordinate:{leftTop:a,rightBottom:c}}=s[i];if(t>=a[0]&&t<=c[0]&&e>=a[1]&&e<=c[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),n=new Map;for(const s of e){const i=n.get(s.groupId);if(i)i.endIndex+=1;else{const{type:l,groupId:a,tableId:c,index:d,tdIndex:h,trIndex:u}=s,g={startIndex:d,endIndex:d};l===Bt.TABLE&&(g.tableId=c,g.startTdIndex=h,g.endTdIndex=h,g.startTrIndex=u,g.endTrIndex=u),n.set(a,g)}}const o=[];return n.forEach(s=>{o.push(s)}),o}getIsCanInput(){var i;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.draw.getElementList(),o=n[t];if(t===e)return(o.controlComponent!==R.ControlComponent.PRE_TEXT||((i=n[t+1])==null?void 0:i.controlComponent)!==R.ControlComponent.PRE_TEXT)&&o.controlComponent!==R.ControlComponent.POST_TEXT;const s=n[e];return!o.controlId&&!s.controlId||(!o.controlId||o.controlComponent===R.ControlComponent.POSTFIX)&&(!s.controlId||s.controlComponent===R.ControlComponent.POSTFIX)||!!o.controlId&&s.controlId===o.controlId&&s.controlComponent!==R.ControlComponent.PRE_TEXT&&s.controlComponent!==R.ControlComponent.POST_TEXT&&s.controlComponent!==R.ControlComponent.POSTFIX}setRange(t,e,n,o,s,i,l){this.getIsRangeChange(t,e,n,o,s,i,l)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=n,this.range.startTdIndex=o,this.range.endTdIndex=s,this.range.startTrIndex=i,this.range.endTrIndex=l,this.range.isCrossRowCol=!!(o||s||i||l),this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const c=this.draw.getControl();if(~t&&~e){const h=this.draw.getElementList()[t];if(h==null?void 0:h.controlId){c.initControl();return}}c.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(B(Y({},this.range),{startIndex:e}))}setRangeStyle(){var E,U;const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:o,isCrossRowCol:s}=this.range;if(!~n&&!~o)return;let i;if(s){const Q=this.draw.getOriginalElementList(),w=this.position.getPositionContext();i=Q[w.index]}else{const Q=~o?o:0,w=this.draw.getElementList();i=this.getRangeAnchorStyle(w,Q)}if(!i)return;const l=this.getSelection()||[i],a=i.type||R.ElementType.TEXT,c=i.font||this.options.defaultFont,d=i.size||this.options.defaultSize,h=!~l.findIndex(Q=>!Q.bold),u=!~l.findIndex(Q=>!Q.italic),g=!~l.findIndex(Q=>{var w;return!Q.underline&&!((w=Q.control)==null?void 0:w.underline)}),T=!~l.findIndex(Q=>!Q.strikeout),P=i.color||null,O=i.highlight||null,M=i.rowFlex||null,S=(E=i.rowMargin)!=null?E:this.options.defaultRowMargin,X=i.dashArray||[],N=i.level||null,m=i.listType||null,I=i.listStyle||null,f=g&&i.textDecoration||null,F=!!this.draw.getPainterStyle(),V=this.historyManager.isCanUndo(),Z=this.historyManager.isCanRedo(),C=i.groupIds||null,D=(U=i.extension)!=null?U:null,W={type:a,undo:V,redo:Z,painter:F,font:c,size:d,bold:h,italic:u,underline:g,strikeout:T,color:P,highlight:O,rowFlex:M,rowMargin:S,dashArray:X,level:N,listType:m,listStyle:I,groupIds:C,textDecoration:f,extension:D};t&&t(W),e&&this.eventBus.emit("rangeStyleChange",W)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const n=this.options.defaultFont,o=this.options.defaultSize,s=this.options.defaultRowMargin,i=!!this.draw.getPainterStyle(),l=this.historyManager.isCanUndo(),a=this.historyManager.isCanRedo(),c={type:null,undo:l,redo:a,painter:i,font:n,size:o,bold:!1,italic:!1,underline:!1,strikeout:!1,color:null,highlight:null,rowFlex:null,rowMargin:s,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,extension:null};t&&t(c),e&&this.eventBus.emit("rangeStyleChange",c)}shrinkBoundary(t={}){const e=t.elementList||this.draw.getElementList(),n=t.range||this.getRange(),{startIndex:o,endIndex:s}=n;if(!~o&&!~s)return;const i=e[o],l=e[s];if(o===s){if(i.controlComponent===R.ControlComponent.PLACEHOLDER){let a=o-1;for(;a>0;){const c=e[a];if(c.controlId!==i.controlId||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT){n.startIndex=a,n.endIndex=a;break}a--}}}else{if(i.controlComponent===R.ControlComponent.PLACEHOLDER||l.controlComponent===R.ControlComponent.PLACEHOLDER){let a=s-1;for(;a>0;){const c=e[a];if(c.controlId!==l.controlId||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT){n.startIndex=a,n.endIndex=a;return}a--}}if(i.controlComponent===R.ControlComponent.PREFIX){let a=o+1;for(;a<e.length;){const c=e[a];if(c.controlId!==i.controlId||c.controlComponent===R.ControlComponent.VALUE){n.startIndex=a-1;break}else if(c.controlComponent===R.ControlComponent.PLACEHOLDER){n.startIndex=a-1,n.endIndex=a-1;return}a++}}if(l.controlComponent!==R.ControlComponent.VALUE){let a=o-1;for(;a>0;){const c=e[a];if(c.controlId!==i.controlId||c.controlComponent===R.ControlComponent.VALUE){n.startIndex=a;break}else if(c.controlComponent===R.ControlComponent.PLACEHOLDER){n.startIndex=a,n.endIndex=a;return}a--}}}}render(t,e,n,o,s){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,n,o,s),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(y,"g"),""):""}}class ps{constructor(t){L(this,"draw");L(this,"options");L(this,"imageCache");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,n,o){t.save(),t.fillStyle=e,t.fillRect(0,0,n,o),t.restore()}_drawImage(t,e,n,o){const{background:s,scale:i}=this.options;if(s.size===R.BackgroundSize.CONTAIN){const l=e.width*i,a=e.height*i;if(!s.repeat||s.repeat===R.BackgroundRepeat.NO_REPEAT)t.drawImage(e,0,0,l,a);else{let c=0,d=0;const h=s.repeat===R.BackgroundRepeat.REPEAT||s.repeat===R.BackgroundRepeat.REPEAT_X?Math.ceil(n*i/l):1,u=s.repeat===R.BackgroundRepeat.REPEAT||s.repeat===R.BackgroundRepeat.REPEAT_Y?Math.ceil(o*i/a):1;for(let g=0;g<h;g++){for(let T=0;T<u;T++)t.drawImage(e,c,d,l,a),d+=a;d=0,c+=l}}}else t.drawImage(e,0,0,n*i,o*i)}_renderBackgroundImage(t,e,n){const{background:o}=this.options,s=this.imageCache.get(o.image);if(s)this._drawImage(t,s,e,n);else{const i=new Image;i.setAttribute("crossOrigin","Anonymous"),i.src=o.image,i.onload=()=>{this.imageCache.set(o.image,i),this._drawImage(t,i,e,n),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:n,color:o,applyPageNumbers:s}}=this.options;if(n&&(!(s==null?void 0:s.length)||s.includes(e))){const{width:i,height:l}=this.options;this._renderBackgroundImage(t,i,l)}else{const i=this.draw.getCanvasWidth(e),l=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,o,i,l)}}}class dn{constructor(){L(this,"fillRect");L(this,"fillColor");L(this,"fillDecorationStyle");this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillDecorationStyle=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,n,o,s,i,l){const a=!this.fillRect.width;if(!a&&(this.fillColor!==i||this.fillDecorationStyle!==l)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,n,o,s,i,l);return}a&&(this.fillRect.x=e,this.fillRect.y=n),s&&this.fillRect.height<s&&(this.fillRect.height=s),this.fillRect.width+=o,this.fillColor=i,this.fillDecorationStyle=l}}class Zs extends dn{constructor(t){super();L(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:n,y:o,width:s,height:i}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(n,o,s,i),t.restore(),this.clearFillInfo()}}class Us{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:n,pageMode:o}=this.options,s=this.draw.getWidth(),i=o===R.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 c=[l[3],l[0]],d=[s-l[1],l[0]],h=[l[3],i-l[2]],u=[s-l[1],i-l[2]];t.moveTo(c[0]-a,c[1]),t.lineTo(...c),t.lineTo(c[0],c[1]-a),t.moveTo(d[0]+a,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]-a),t.moveTo(h[0]-a,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+a),t.moveTo(u[0]+a,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]+a),t.stroke(),t.restore()}}class Ys{constructor(t){L(this,"draw");L(this,"options");L(this,"position");L(this,"range");L(this,"searchKeyword");L(this,"searchNavigateIndex");L(this,"searchOptions");L(this,"searchMatchList");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 o=this.searchMatchList[t];if(n!==o.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 o=this.searchMatchList[t];if(n!==o.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:o},pageNo:s}=t,i=this.draw.getHeight(),l=this.draw.getPageGap(),a=s*(i+l),c=document.createElement("div");c.style.position="absolute";const d=50;c.style.width=`${o[0]-e[0]+d}px`,c.style.height=`${n[1]-e[1]+d}px`,c.style.left=`${e[0]}px`,c.style.top=`${e[1]+a}px`,this.draw.getContainer().append(c),c.scrollIntoView(!1),c.remove()}getSearchNavigateIndexList(){return this.searchNavigateIndex===null||!this.searchKeyword?[]:new Array(this.searchKeyword.length).fill(this.searchNavigateIndex).map((t,e)=>t+e)}getSearchMatchList(){return this.searchMatchList}getSearchNavigateInfo(){if(!this.searchKeyword||!this.searchMatchList.length)return null;const t=this.searchNavigateIndex!==null?this.searchNavigateIndex/this.searchKeyword.length+1:0;let e=0,n=null;for(let o=0;o<this.searchMatchList.length;o++){const s=this.searchMatchList[o];n!==s.groupId&&(n=s.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const{isRegEnable:n=!1,isIgnoreCase:o=!0}=this.searchOptions||{},s=o?t.toLocaleLowerCase():t,i=[],l=[],a=e.length,c=[];for(let g=0;g<a;g++)e[g].type===R.ElementType.TABLE&&c.push(g);let d=0,h=0;for(;h<a-1;){const g=c.length?c[d]:a,T=e.slice(h,g);T.length&&l.push({index:h,type:Bt.PAGE,elementList:T});const P=e[g];P&&l.push({index:g,type:Bt.TABLE,elementList:[P]}),h=g+1,d++}function u(g,T,P,O){if(!g)return;let M=P.map(I=>{var f,F;return!I.type||bt.includes(I.type)&&I.controlComponent!==R.ControlComponent.CHECKBOX&&I.controlComponent!==R.ControlComponent.RADIO&&!I.hide&&!((f=I.control)==null?void 0:f.hide)&&!((F=I.area)==null?void 0:F.hide)?I.value:y}).filter(Boolean).join("");o&&(M=M.toLocaleLowerCase());const S=[],X=n?new RegExp(g):g;let{index:N,length:m}=Vn(M,X);for(;N!==-1&&m!==0;){S.push({index:N,length:m});const I=Vn(M,X,N+m);N=I.index,m=I.length}for(let I=0;I<S.length;I++){const{index:f,length:F}=S[I],V=j();for(let Z=0;Z<F;Z++){const C=f+Z+((O==null?void 0:O.startIndex)||0);i.push(Y({type:T,index:C,groupId:V},O))}}}for(let g=0;g<l.length;g++){const T=l[g];if(T.type===Bt.TABLE){const P=T.elementList[0];for(let O=0;O<P.trList.length;O++){const M=P.trList[O];for(let S=0;S<M.tdList.length;S++){const X=M.tdList[S],N={tableId:P.id,tableIndex:T.index,trIndex:O,tdIndex:S,tdId:X.id};u(s,T.type,X.value,N)}}}else u(s,T.type,T.elementList,{startIndex:T.index})}return i}compute(t){var i;const e=((i=this.searchOptions)==null?void 0:i.isLimitSelection)&&!this.range.getIsCollapsed(),n=e?this.range.getSelectionElementList():this.draw.getOriginalElementList();if(!(n==null?void 0:n.length)||(this.searchMatchList=this.getMatchList(t,n),!e||!this.searchMatchList.length))return;const{startIndex:o}=this.range.getRange(),s=o+1;for(const l of this.searchMatchList)l.type===Bt.TABLE?l.tableIndex+=s:l.index+=s}render(t,e){var a,c;if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:n,searchMatchColor:o,searchNavigateMatchColor:s}=this.options,i=this.position.getOriginalPositionList(),l=this.draw.getOriginalElementList();t.save(),t.globalAlpha=n;for(let d=0;d<this.searchMatchList.length;d++){const h=this.searchMatchList[d];let u=null;if(h.type===Bt.TABLE){const{tableIndex:I,trIndex:f,tdIndex:F,index:V}=h;u=(c=(a=l[I])==null?void 0:a.trList[f].tdList[F])==null?void 0:c.positionList[V]}else u=i[h.index];if(!u)continue;const{coordinate:{leftTop:g,leftBottom:T,rightTop:P},pageNo:O}=u;if(O!==e)continue;if(this.getSearchNavigateIndexList().includes(d)){t.fillStyle=s;const I=this.searchMatchList[d-1];(!I||I.groupId!==h.groupId)&&this.searchNavigateScrollIntoView(u)}else t.fillStyle=o;const S=g[0],X=g[1],N=P[0]-g[0],m=T[1]-g[1];t.fillRect(S,X,N,m)}t.restore()}replace(t,e){var P,O,M,S;if(this.draw.isReadonly()||t==null)return;let o=this.getSearchMatchList();const s=e==null?void 0:e.index;if(ve(s)){const X=[];o.forEach(N=>{const m=X[X.length-1];!m||m[0].groupId!==N.groupId?X.push([N]):m.push(N)}),o=X[s]}if(!(o==null?void 0:o.length))return;const i=this.draw.isDesignMode();let l=0,a=0,c="",d="",h=-1;const u=this.draw.getOriginalElementList();for(let X=0;X<o.length;X++){const N=o[X];if(N.type===Bt.TABLE){const{tableIndex:m,trIndex:I,tdIndex:f,index:F,tdId:V}=N;d&&V!==d&&(a=0),d=V;const Z=m+l,C=u[Z].trList[I].tdList[f].value,D=F+a,W=C[D];if(!i&&(((P=W==null?void 0:W.control)==null?void 0:P.deletable)===!1||((O=W==null?void 0:W.title)==null?void 0:O.deletable)===!1))continue;if(t===""){this.draw.spliceElementList(C,D,1),a--,~h||(h=X);continue}if(c===N.groupId){this.draw.spliceElementList(C,D,1),a--;continue}~h||(h=X);for(let E=0;E<t.length;E++){const U=t[E];E===0?W.value=U:(this.draw.spliceElementList(C,D+E,0,[B(Y({},W),{value:U})]),a++)}}else{const m=N.index+l,I=u[m];if(!i&&(((M=I==null?void 0:I.control)==null?void 0:M.deletable)===!1||((S=I==null?void 0:I.title)==null?void 0:S.deletable)===!1)||I.type===R.ElementType.CONTROL&&I.controlComponent!==R.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(u,m,1),l--,~h||(h=X);continue}if(~h||(h=X),c===N.groupId){this.draw.spliceElementList(u,m,1),l--;continue}for(let f=0;f<t.length;f++){const F=t[f];f===0?I.value=F:(this.draw.spliceElementList(u,m+f,0,[B(Y({},I),{value:F})]),l++)}}c=N.groupId}if(!~h)return;const g=o[h],T=g.index+(t.length-1);if(g.type===Bt.TABLE){const{tableIndex:X,trIndex:N,tdIndex:m,index:I}=g,f=u[X].trList[N].tdList[m].value[I];this.position.setPositionContext({isTable:!0,index:X,trIndex:N,tdIndex:m,tdId:f.tdId,trId:f.trId,tableId:f.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(T,T),this.draw.render({curIndex:T})}}class Qs extends dn{constructor(t){super();L(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{scale:e,strikeoutColor:n}=this.options,{x:o,y:s,width:i}=this.fillRect;t.save(),t.lineWidth=e,t.strokeStyle=n;const l=s+.5;t.beginPath(),t.moveTo(o,l),t.lineTo(o+i,l),t.stroke(),t.restore(),this.clearFillInfo()}}R.TextDecorationStyle=void 0,function(r){r.SOLID="solid",r.DOUBLE="double",r.DASHED="dashed",r.DOTTED="dotted",r.WAVY="wavy"}(R.TextDecorationStyle||(R.TextDecorationStyle={}));var de;(function(r){r.SOLID="solid",r.DASHED="dashed",r.DOTTED="dotted"})(de||(de={}));class Cs extends dn{constructor(t){super();L(this,"options");this.options=t.getOptions()}_drawLine(t,e,n,o,s){const i=e+o;switch(t.beginPath(),s){case de.DASHED:t.setLineDash([3,1]);break;case de.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(i,n),t.stroke()}_drawDouble(t,e,n,o){const s=3,i=e+o,l=n+s*this.options.scale;t.beginPath(),t.moveTo(e,n),t.lineTo(i,n),t.stroke(),t.beginPath(),t.moveTo(e,l),t.lineTo(i,l),t.stroke()}_drawWave(t,e,n,o){const{scale:s}=this.options,i=1.2*s,l=1/s,a=n+2*i;t.beginPath();for(let c=0;c<o;c++){const d=i*Math.sin(l*c);t.lineTo(e+c,a+d)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:o,y:s,width:i}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const l=Math.floor(s+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case R.TextDecorationStyle.WAVY:this._drawWave(t,o,l,i);break;case R.TextDecorationStyle.DOUBLE:this._drawDouble(t,o,l,i);break;case R.TextDecorationStyle.DASHED:this._drawLine(t,o,l,i,de.DASHED);break;case R.TextDecorationStyle.DOTTED:this._drawLine(t,o,l,i,de.DOTTED);break;default:this._drawLine(t,o,l,i);break}t.restore(),this.clearFillInfo()}}class Es{constructor(t){L(this,"draw");L(this,"options");L(this,"ctx");L(this,"curX");L(this,"curY");L(this,"text");L(this,"curStyle");L(this,"curColor");L(this,"cacheMeasureText");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:Wi});return t.restore(),n}measureWord(t,e,n){const o=this.draw.getLetterReg();let s=0,i=null,l=n;for(;l<e.length;){const a=e[l];if(a.type&&a.type!==R.ElementType.TEXT||!o.test(a.value)){i=a;break}s+=this.measureText(t,a).width,l++}return{width:s,endElement:i}}measurePunctuationWidth(t,e){return!e||!Fi.includes(e.value)?0:(t.font=this.draw.getElementFont(e),this.measureText(t,e).width)}measureText(t,e){if(e.width){const i=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:i.actualBoundingBoxAscent,actualBoundingBoxDescent:i.actualBoundingBoxDescent,actualBoundingBoxLeft:i.actualBoundingBoxLeft,actualBoundingBoxRight:i.actualBoundingBoxRight,fontBoundingBoxAscent:i.fontBoundingBoxAscent,fontBoundingBoxDescent:i.fontBoundingBoxDescent}}const n=`${e.value}${t.font}`,o=this.cacheMeasureText.get(n);if(o)return o;const s=t.measureText(e.value);return this.cacheMeasureText.set(n,s),s}getBasisWordBoundingBoxAscent(t,e){return this.measureBasisWord(t,e).actualBoundingBoxAscent}complete(){this._render(),this.text=""}record(t,e,n,o){if(this.ctx=t,this.options.renderMode===R.RenderMode.COMPATIBILITY){this._setCurXY(n,o),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(n,o),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(n,o)),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.curY||(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 he{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,o){const s=o===R.NumberType.CHINESE?yi(e):`${e}`;return t.replace(n,s)}render(t,e){const{scale:n,pageNumber:{size:o,font:s,color:i,rowFlex:l,numberType:a,format:c,startPageNo:d,fromPageNo:h}}=this.options;if(e<h)return;let u=c;const g=new RegExp(Me.PAGE_NO);g.test(u)&&(u=he.formatNumberPlaceholder(u,e+d-h,g,a));const T=new RegExp(Me.PAGE_COUNT);T.test(u)&&(u=he.formatNumberPlaceholder(u,this.draw.getPageCount()-h,T,a));const P=this.draw.getWidth(),O=this.draw.getHeight(),M=this.draw.getPageNumberBottom(),S=O-M;t.save(),t.fillStyle=i,t.font=`${o*n}px ${s}`;let X=0;const N=this.draw.getMargins(),{width:m}=t.measureText(u);l===R.RowFlex.CENTER?X=(P-m)/2:l===R.RowFlex.RIGHT?X=P-m-N[1]:X=N[3],t.fillText(u,X,S),t.restore()}}class Ds{constructor(t){L(this,"draw");L(this,"options");L(this,"scrollContainer");L(this,"_observer",Ci(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150));this.draw=t,this.options=t.getOptions(),this.scrollContainer=this.getScrollContainer(),setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}getScrollContainer(){return this.options.scrollContainerSelector&&document.querySelector(this.options.scrollContainerSelector)||document}_addEvent(){this.scrollContainer.addEventListener("scroll",this._observer)}removeEvent(){this.scrollContainer.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),n=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,o=Math.min(e.bottom,n)-Math.max(e.top,0);return{intersectionHeight:o>0?o:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let n=0,o=0;for(let s=0;s<t.length;s++){const i=t[s],{intersectionHeight:l}=this.getElementVisibleInfo(i);if(o&&!l)break;l&&e.push(s),l>o&&(o=l,n=s)}return{intersectionPageNo:n,visiblePageNoList:e}}}class bs{constructor(t){L(this,"step",5);L(this,"thresholdPoints",[70,40,10,20]);L(this,"selectionContainer");L(this,"rangeManager");L(this,"requestAnimationFrameId");L(this,"isMousedown");L(this,"isMoving");L(this,"clientWidth");L(this,"clientHeight");L(this,"containerRect");L(this,"_mousedown",()=>{if(this.isMousedown=!0,this.clientWidth=this.selectionContainer instanceof Document?document.documentElement.clientWidth:this.selectionContainer.clientWidth,this.clientHeight=this.selectionContainer instanceof Document?document.documentElement.clientHeight:this.selectionContainer.clientHeight,!(this.selectionContainer instanceof Document)){const t=this.selectionContainer.getBoundingClientRect();this.containerRect=t}});L(this,"_mouseup",()=>{this.isMousedown=!1,this._stopMove()});L(this,"_mousemove",t=>{if(!this.isMousedown||this.rangeManager.getIsCollapsed())return;let{x:e,y:n}=t;this.containerRect&&(e=e-this.containerRect.x,n=n-this.containerRect.y),n<this.thresholdPoints[0]?this._startMove(Lt.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove(Lt.DOWN):e<this.thresholdPoints[2]?this._startMove(Lt.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(Lt.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,o=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Lt.DOWN?e.scrollTo(n,o+this.step):t===Lt.UP?e.scrollTo(n,o-this.step):t===Lt.LEFT?e.scrollTo(n-this.step,o):e.scrollTo(n+this.step,o),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 Ks{constructor(t){L(this,"draw");L(this,"range");L(this,"options");this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){var n;const e=$(t);for(let o=0;o<t.length;o++){const s=e[o];for(let i=s.tdList.length-1;i>=0;i--){const l=s.tdList[i],{rowspan:a,rowIndex:c,colIndex:d}=l,h=c+a-1;if(h!==i){const u=s.tdList.splice(i,1)[0];(n=e[h])==null||n.tdList.splice(d,0,u)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:n,tdIndex:o}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:s,startTdIndex:i,endTdIndex:l,startTrIndex:a,endTrIndex:c}=this.range.getRange(),u=this.draw.getOriginalElementList()[e].trList;if(!s)return[[u[n].tdList[o]]];let g=u[a].tdList[i],T=u[c].tdList[l];(g.x>T.x||g.y>T.y)&&([g,T]=[T,g]);const P=g.colIndex,O=T.colIndex+(T.colspan-1),M=g.rowIndex,S=T.rowIndex+(T.rowspan-1),X=[];for(let N=0;N<u.length;N++){const m=u[N],I=[];for(let f=0;f<m.tdList.length;f++){const F=m.tdList[f],V=F.colIndex,Z=F.rowIndex;V>=P&&V<=O&&Z>=M&&Z<=S&&I.push(F)}I.length&&X.push(I)}return X.length?X:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:o,width:s,height:i,isDrawFullBorder:l,borderExternalWidth:a}=t,{scale:c}=this.options,d=e.lineWidth;a&&(e.lineWidth=a*c),e.beginPath();const h=Math.round(n),u=Math.round(o);e.translate(.5,.5),l?e.rect(h,u,s,i):(e.moveTo(h,u+i),e.lineTo(h,u),e.lineTo(h+s,u)),e.stroke(),a&&(e.lineWidth=d),e.translate(-.5,-.5)}_drawSlash(t,e,n,o){var d,h;const{scale:s}=this.options;t.save();const i=e.width*s,l=e.height*s,a=Math.round(e.x*s+n),c=Math.round(e.y*s+o);((d=e.slashTypes)==null?void 0:d.includes(R.TdSlash.FORWARD))&&(t.moveTo(a+i,c),t.lineTo(a,c+l)),((h=e.slashTypes)==null?void 0:h.includes(R.TdSlash.BACK))&&(t.moveTo(a,c),t.lineTo(a+i,c+l)),t.stroke(),t.restore()}_drawBorder(t,e,n,o){var S,X,N,m,I,f;const{colgroup:s,trList:i,borderType:l,borderColor:a,borderWidth:c=1,borderExternalWidth:d}=e;if(!s||!i)return;const{scale:h,table:{defaultBorderColor:u}}=this.options,g=e.width*h,T=e.height*h,P=l===R.TableBorder.EMPTY,O=l===R.TableBorder.EXTERNAL,M=l===R.TableBorder.INTERNAL;t.save(),l===R.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=c*h,t.strokeStyle=a||u,!P&&!M&&this._drawOuterBorder({ctx:t,startX:n,startY:o,width:g,height:T,borderExternalWidth:d,isDrawFullBorder:O});for(let F=0;F<i.length;F++){const V=i[F];for(let Z=0;Z<V.tdList.length;Z++){const C=V.tdList[Z];if(((S=C.slashTypes)==null?void 0:S.length)&&this._drawSlash(t,C,n,o),!((X=C.borderTypes)==null?void 0:X.length)&&(P||O))continue;const D=C.width*h,W=C.height*h,E=Math.round(C.x*h+n+D),U=Math.round(C.y*h+o);if(t.translate(.5,.5),t.beginPath(),((N=C.borderTypes)==null?void 0:N.includes(R.TdBorder.TOP))&&(t.moveTo(E-D,U),t.lineTo(E,U),t.stroke()),((m=C.borderTypes)==null?void 0:m.includes(R.TdBorder.RIGHT))&&(t.moveTo(E,U),t.lineTo(E,U+W),t.stroke()),((I=C.borderTypes)==null?void 0:I.includes(R.TdBorder.BOTTOM))&&(t.moveTo(E,U+W),t.lineTo(E-D,U+W),t.stroke()),((f=C.borderTypes)==null?void 0:f.includes(R.TdBorder.LEFT))&&(t.moveTo(E-D,U),t.lineTo(E-D,U+W),t.stroke()),!P&&!O){if((!M||C.colIndex+C.colspan<s.length)&&(t.moveTo(E,U),t.lineTo(E,U+W),d&&d!==c&&C.colIndex+C.colspan===s.length)){const Q=t.lineWidth;t.lineWidth=d*h,t.stroke(),t.beginPath(),t.lineWidth=Q}if(!M||C.rowIndex+C.rowspan<i.length){const Q=d&&d!==c&&C.rowIndex+C.rowspan===i.length;if(Q&&(t.stroke(),t.beginPath()),t.moveTo(E,U+W),t.lineTo(E-D,U+W),Q){const w=t.lineWidth;t.lineWidth=d*h,t.stroke(),t.beginPath(),t.lineWidth=w}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,o){const{trList:s}=e;if(!s)return;const{scale:i}=this.options;for(let l=0;l<s.length;l++){const a=s[l];for(let c=0;c<a.tdList.length;c++){const d=a.tdList[c];if(!d.backgroundColor)continue;t.save();const h=d.width*i,u=d.height*i,g=Math.round(d.x*i+n),T=Math.round(d.y*i+o);t.fillStyle=d.backgroundColor,t.fillRect(g,T,h,u),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,n)=>e+n.width,0)}getTableHeight(t){const e=t.trList;return(e==null?void 0:e.length)?this.getTdListByColIndex(e,0).reduce((n,o)=>n+o.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((n,o)=>n+o.rowspan,0)}getTdListByColIndex(t,e){const n=[];for(let o=0;o<t.length;o++){const s=t[o].tdList;for(let i=0;i<s.length;i++){const l=s[i],a=l.colIndex,c=a+l.colspan-1;e>=a&&e<=c&&n.push(l)}}return n}getTdListByRowIndex(t,e){const n=[];for(let o=0;o<t.length;o++){const s=t[o].tdList;for(let i=0;i<s.length;i++){const l=s[i],a=l.rowIndex,c=a+l.rowspan-1;e>=a&&e<=c&&n.push(l)}}return n}computeRowColInfo(t){const{colgroup:e,trList:n}=t;if(!e||!n)return;let o=0;for(let s=0;s<n.length;s++){const i=n[s],l=n.length-1===s;for(let a=0;a<i.tdList.length;a++){const c=i.tdList[a];let d=0;if(n.length>1&&s!==0){const M=i.tdList[a-1],S=M?M.colIndex+M.colspan:a;for(let X=S;X<e.length;X++)if(this.getRowCountByColIndex(n.slice(0,s),X)===s){d=X;let m=0;for(let I=0;I<X;I++)m+=e[I].width;o=m;break}}else{const M=i.tdList[a-1];M&&(d=M.colIndex+M.colspan)}let h=0;for(let M=0;M<c.colspan;M++)h+=e[M+d].width;let u=0;for(let M=0;M<c.rowspan;M++)u+=(n[M+s]||n[s]).height;const g=i.tdList.length-1===a;let T=l;if(!T&&c.rowspan>1){const M=n.length-1-s;T=c.rowspan-1===M}const P=l&&g;c.isLastRowTd=g,c.isLastColTd=T,c.isLastTd=P,c.x=o;let O=0;for(let M=0;M<s;M++){const S=n[M].tdList;for(let X=0;X<S.length;X++){const N=S[X];if(d>=N.colIndex&&d<N.colIndex+N.colspan){O+=N.height;break}}}c.y=O,c.width=h,c.height=u,c.rowIndex=s,c.colIndex=d,c.trIndex=s,c.tdIndex=a,o+=h,g&&!P&&(o=0)}}}drawRange(t,e,n,o){const{scale:s,rangeAlpha:i,rangeColor:l}=this.options,{type:a,trList:c}=e;if(!c||a!==R.ElementType.TABLE)return;const{isCrossRowCol:d,startTdIndex:h,endTdIndex:u,startTrIndex:g,endTrIndex:T}=this.range.getRange();if(!d)return;let P=c[g].tdList[h],O=c[T].tdList[u];(P.x>O.x||P.y>O.y)&&([P,O]=[O,P]);const M=P.colIndex,S=O.colIndex+(O.colspan-1),X=P.rowIndex,N=O.rowIndex+(O.rowspan-1);t.save();for(let m=0;m<c.length;m++){const I=c[m];for(let f=0;f<I.tdList.length;f++){const F=I.tdList[f],V=F.colIndex,Z=F.rowIndex;if(V>=M&&V<=S&&Z>=X&&Z<=N){const C=F.x*s,D=F.y*s,W=F.width*s,E=F.height*s;t.globalAlpha=i,t.fillStyle=l,t.fillRect(C+n,D+o,W,E)}}}t.restore()}render(t,e,n,o){this._drawBackgroundColor(t,e,n,o),this._drawBorder(t,e,n,o)}}var kt;(function(r){r.ROW="row",r.COL="col"})(kt||(kt={}));class ys{constructor(t){L(this,"MIN_TD_WIDTH",20);L(this,"ROW_COL_OFFSET",18);L(this,"ROW_COL_QUICK_WIDTH",16);L(this,"ROW_COL_QUICK_OFFSET",5);L(this,"ROW_COL_QUICK_POSITION",this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2);L(this,"BORDER_VALUE",4);L(this,"TABLE_SELECT_OFFSET",20);L(this,"draw");L(this,"canvas");L(this,"options");L(this,"position");L(this,"range");L(this,"container");L(this,"toolRowContainer");L(this,"toolRowAddBtn");L(this,"toolColAddBtn");L(this,"toolTableSelectBtn");L(this,"toolColContainer");L(this,"toolBorderContainer");L(this,"anchorLine");L(this,"mousedownX");L(this,"mousedownY");this.draw=t,this.canvas=t.getPage(),this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.container=t.getContainer(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null,this.anchorLine=null,this.mousedownX=0,this.mousedownY=0}dispose(){var t,e,n,o,s,i;(t=this.toolRowContainer)==null||t.remove(),(e=this.toolRowAddBtn)==null||e.remove(),(n=this.toolColAddBtn)==null||n.remove(),(o=this.toolTableSelectBtn)==null||o.remove(),(s=this.toolColContainer)==null||s.remove(),(i=this.toolBorderContainer)==null||i.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:o}=this.position.getPositionContext();if(!t)return;this.dispose();const s=this.draw.getOriginalElementList(),i=this.position.getOriginalPositionList(),l=s[e];if(l.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:a,table:{overflow:c}}=this.options,d=i[e],{colgroup:h,trList:u}=l,{coordinate:{leftTop:g}}=d,T=this.draw.getHeight(),P=this.draw.getPageGap(),O=this.draw.getPageNo()*(T+P),M=g[0],S=g[1]+O,X=l.trList[n].tdList[o],N=X.rowIndex,m=X.colIndex,I=l.height*a,f=l.width*a,F=document.createElement("div");F.classList.add(`${v}-table-tool__select`),F.style.height=`${I*a}`,F.style.left=`${M}px`,F.style.top=`${S}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 V=u.map(Q=>Q.height),Z=document.createElement("div");Z.classList.add(`${v}-table-tool__row`),Z.style.transform=`translateX(-${this.ROW_COL_OFFSET*a}px)`;for(let Q=0;Q<V.length;Q++){const w=V[Q]*a,K=document.createElement("div");K.classList.add(`${v}-table-tool__row__item`),Q===N&&K.classList.add("active"),K.onclick=()=>{const G=this.draw.getTableParticle().getTdListByRowIndex(u,Q),H=G[0],x=G[G.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:H.trIndex,tdIndex:H.tdIndex,tableId:l.id}),this.range.setRange(0,0,l.id,H.tdIndex,x.tdIndex,H.trIndex,x.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(Z,Q)};const p=document.createElement("div");p.classList.add(`${v}-table-tool__anchor`),p.onmousedown=G=>{this._mousedown({evt:G,element:l,index:Q,order:kt.ROW})},K.append(p),K.style.height=`${w}px`,Z.append(K)}Z.style.left=`${M}px`,Z.style.top=`${S}px`,this.container.append(Z),this.toolRowContainer=Z;const C=document.createElement("div");C.classList.add(`${v}-table-tool__quick__add`),C.style.height=`${I*a}`,C.style.left=`${M}px`,C.style.top=`${S+I}px`,C.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*a}px, ${this.ROW_COL_QUICK_OFFSET*a}px)`,C.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:u.length-1,tdIndex:0,tableId:l.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(C),this.toolRowAddBtn=C;const D=h.map(Q=>Q.width),W=document.createElement("div");W.classList.add(`${v}-table-tool__col`),W.style.transform=`translateY(-${this.ROW_COL_OFFSET*a}px)`;for(let Q=0;Q<D.length;Q++){const w=D[Q]*a,K=document.createElement("div");K.classList.add(`${v}-table-tool__col__item`),Q===m&&K.classList.add("active"),K.onclick=()=>{const G=this.draw.getTableParticle().getTdListByColIndex(u,Q),H=G[0],x=G[G.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:H.trIndex,tdIndex:H.tdIndex,tableId:l.id}),this.range.setRange(0,0,l.id,H.tdIndex,x.tdIndex,H.trIndex,x.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(W,Q)};const p=document.createElement("div");p.classList.add(`${v}-table-tool__anchor`),p.onmousedown=G=>{this._mousedown({evt:G,element:l,index:Q,order:kt.COL})},K.append(p),K.style.width=`${w}px`,W.append(K)}W.style.left=`${M}px`,W.style.top=`${S}px`,this.container.append(W),this.toolColContainer=W;const E=document.createElement("div");E.classList.add(`${v}-table-tool__quick__add`),E.style.height=`${I*a}`,E.style.left=`${M+f}px`,E.style.top=`${S}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:u[0].tdList.length-1||0,tableId:l.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(E),this.toolColAddBtn=E;const U=document.createElement("div");U.classList.add(`${v}-table-tool__border`),U.style.height=`${I}px`,U.style.width=`${f}px`,U.style.left=`${M}px`,U.style.top=`${S}px`;for(let Q=0;Q<u.length;Q++){const w=u[Q];for(let K=0;K<w.tdList.length;K++){const p=w.tdList[K],G=document.createElement("div");G.classList.add(`${v}-table-tool__border__row`),G.style.width=`${p.width*a}px`,G.style.height=`${this.BORDER_VALUE}px`,G.style.top=`${(p.y+p.height)*a-this.BORDER_VALUE/2}px`,G.style.left=`${p.x*a}px`,G.onmousedown=x=>{this._mousedown({evt:x,element:l,index:p.rowIndex+p.rowspan-1,order:kt.ROW})},U.appendChild(G);const H=document.createElement("div");if(H.classList.add(`${v}-table-tool__border__col`),H.style.width=`${this.BORDER_VALUE}px`,H.style.height=`${p.height*a}px`,H.style.top=`${p.y*a}px`,H.style.left=`${(p.x+p.width)*a-this.BORDER_VALUE/2}px`,H.onmousedown=x=>{this._mousedown({evt:x,element:l,index:p.colIndex+p.colspan-1,order:kt.COL})},U.appendChild(H),c&&p.colIndex===0){const x=document.createElement("div");x.classList.add(`${v}-table-tool__border__col`),x.style.width=`${this.BORDER_VALUE}px`,x.style.height=`${p.height*a}px`,x.style.top=`${p.y*a}px`,x.style.left=`${p.x*a-this.BORDER_VALUE/2}px`,x.onmousedown=k=>{this._mousedown({evt:k,element:l,index:0,isLeftStartBorder:!0,order:kt.COL})},U.appendChild(x)}}}this.container.append(U),this.toolBorderContainer=U}_setAnchorActive(t,e){const n=t.children;for(let o=0;o<n.length;o++){const s=n[o];o===e?s.classList.add("active"):s.classList.remove("active")}}_mousedown(t){const{evt:e,index:n,order:o,element:s,isLeftStartBorder:i}=t;this.canvas=this.draw.getPage();const{scale:l,table:{overflow:a}}=this.options,c=this.draw.getWidth(),d=this.draw.getHeight(),h=this.draw.getPageGap(),u=this.draw.getPageNo()*(d+h);this.mousedownX=e.x,this.mousedownY=e.y;const g=e.target,T=this.canvas.getBoundingClientRect(),P=window.getComputedStyle(g).cursor;document.body.style.cursor=P,this.canvas.style.cursor=P;let O=0,M=0;const S=document.createElement("div");S.classList.add(`${v}-table-anchor__line`),o===kt.ROW?(S.classList.add(`${v}-table-anchor__line__row`),S.style.width=`${c}px`,O=0,M=u+this.mousedownY-T.top):(S.classList.add(`${v}-table-anchor__line__col`),S.style.height=`${d}px`,O=this.mousedownX-T.left,M=u),S.style.left=`${O}px`,S.style.top=`${M}px`,this.container.append(S),this.anchorLine=S;let X=0,N=0;const m=I=>{const f=this._mousemove(I,o,O,M);f&&(X=f.dx,N=f.dy)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",()=>{var f;let I=!1;if(o===kt.ROW){const F=s.trList,V=F[n]||F[n-1],{defaultTrMinHeight:Z}=this.options.table;N<0&&V.height+N<Z&&(N=Z-V.height),N&&(V.height+=N,V.minHeight=V.height,I=!0)}else{const{colgroup:F}=s;if(F&&X)if(a&&i)F[n].width-X/l<=this.MIN_TD_WIDTH&&(X=(F[n].width-this.MIN_TD_WIDTH)*l),F[n].width-=X/l,s.width-=X/l,s.translateX=(s.translateX||0)+X/l,I=!0;else{const V=this.draw.getInnerWidth(),Z=F[n].width;X<0&&Z+X<this.MIN_TD_WIDTH&&(X=this.MIN_TD_WIDTH-Z);const C=(f=F[n+1])==null?void 0:f.width;X>0&&C&&C-X<this.MIN_TD_WIDTH&&(X=C-this.MIN_TD_WIDTH);const D=Z+X;if(!a&&n===F.length-1){let W=0;for(let E=0;E<F.length;E++){const U=F[E];E===n+1&&(W-=X),E===n&&(W+=D),E!==n&&(W+=U.width)}if(W>V){const E=s.width;X=V-E}}X&&(F.length-1!==n&&(F[n+1].width-=X/l),F[n].width+=X/l,I=!0)}}I&&this.draw.render({isSetCursor:!1}),S.remove(),document.removeEventListener("mousemove",m),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,o){if(!this.anchorLine)return null;const s=t.x-this.mousedownX,i=t.y-this.mousedownY;return e===kt.ROW?this.anchorLine.style.top=`${o+i}px`:this.anchorLine.style.left=`${n+s}px`,t.preventDefault(),{dx:s,dy:i}}}class ws{constructor(t){L(this,"draw");L(this,"options");L(this,"container");L(this,"hyperlinkPopupContainer");L(this,"hyperlinkDom");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(`${v}-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,o]},lineHeight:s}=e,i=this.draw.getHeight(),l=this.draw.getPageGap(),a=this.draw.getPageNo()*(i+l);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${o+a+s}px`;const c=t.url||"#";this.hyperlinkDom.href=c,this.hyperlinkDom.title=c,this.hyperlinkDom.innerText=c}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,o){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,o),t.restore()}}class Hs{constructor(t){L(this,"options");this.options=t.getOptions()}render(t,e,n,o){var M,S,X,N;const{scale:s,label:{defaultBackgroundColor:i,defaultColor:l,defaultBorderRadius:a,defaultPadding:c}}=this.options,d=((M=e.label)==null?void 0:M.backgroundColor)||i,h=((S=e.label)==null?void 0:S.color)||l,u=((X=e.label)==null?void 0:X.borderRadius)||a,g=((N=e.label)==null?void 0:N.padding)||c;t.save(),t.font=e.style;const{width:T,height:P,boundingBoxAscent:O}=e.metrics;t.fillStyle=d,this._drawRoundedRect(t,n,o-O,T,P+(g[0]+g[3])*s,u*s),t.fill(),t.fillStyle=h,t.fillText(e.value,n+g[3]*s,o),t.restore()}_drawRoundedRect(t,e,n,o,s,i){t.beginPath(),t.moveTo(e+i,n),t.lineTo(e+o-i,n),t.quadraticCurveTo(e+o,n,e+o,n+i),t.lineTo(e+o,n+s-i),t.quadraticCurveTo(e+o,n+s,e+o-i,n+s),t.lineTo(e+i,n+s),t.quadraticCurveTo(e,n+s,e,n+s-i),t.lineTo(e,n+i),t.quadraticCurveTo(e,n,e+i,n),t.closePath()}}class Gs{constructor(t,e){L(this,"draw");L(this,"position");L(this,"zone");L(this,"options");L(this,"elementList");L(this,"rowList");L(this,"positionList");this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth(),e=this.draw.getMargins(),n=on(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(),o=this.draw.getMargins()[3],s=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:o,startY:s,innerWidth:e,zone:R.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*Xn[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(),o=this.getHeaderTop()+e-t[0];return o<=0?0:o}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const n=this.draw.getInnerWidth(),o=this.getMaxHeight(),s=[];let i=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(i+a.height>o)break;s.push(a),i+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:s,pageNo:e,startIndex:0,innerWidth:n,zone:R.EditorZone.HEADER}),t.restore()}}class xs{getOffsetY(t){return-t.metrics.height/2}render(t,e,n,o){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,o+this.getOffsetY(e)),t.restore()}}class Js{getOffsetY(t){return t.metrics.height/2}render(t,e,n,o){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,o+this.getOffsetY(e)),t.restore()}}class vs{constructor(t){L(this,"options");this.options=t.getOptions()}render(t,e,n,o){var c;t.save();const{scale:s,separator:{lineWidth:i,strokeStyle:l}}=this.options;t.lineWidth=(e.lineWidth||i)*s,t.strokeStyle=e.color||l,((c=e.dashArray)==null?void 0:c.length)&&t.setLineDash(e.dashArray);const a=Math.round(o);t.translate(0,t.lineWidth/2),t.beginPath(),t.moveTo(n,a),t.lineTo(n+e.width*s,a),t.stroke(),t.restore()}}class Bs{constructor(t){L(this,"draw");L(this,"options");L(this,"i18n");this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,n,o){const{pageBreak:{font:s,fontSize:i,lineDash:l}}=this.options,a=this.i18n.t("pageBreak.displayName"),{scale:c,defaultRowMargin:d}=this.options,h=i*c,u=e.width*c,g=this.draw.getDefaultBasicRowMarginHeight()*d;t.save(),t.font=`${h}px ${s}`;const T=t.measureText(a),P=(u-T.width)/2;t.setLineDash(l),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,o),t.lineTo(n+P,o),t.moveTo(n+P+T.width,o),t.lineTo(n+u,o),t.stroke(),t.fillText(a,n+P,o+T.actualBoundingBoxAscent-h/2),t.restore()}}class ks{constructor(t){L(this,"draw");L(this,"options");L(this,"imageCache");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:n,opacity:o,font:s,size:i,color:l,repeat:a,gap:c,numberType:d},scale:h}=this.options,u=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=o,t.font=`${i*h}px ${s}`;let T=n;const P=new RegExp(Me.PAGE_NO);P.test(T)&&(T=he.formatNumberPlaceholder(T,e+1,P,d));const O=new RegExp(Me.PAGE_COUNT);O.test(T)&&(T=he.formatNumberPlaceholder(T,this.draw.getPageCount(),O,d));const M=t.measureText(T);if(a){const S=this.draw.getPagePixelRatio(),X=document.createElement("canvas"),N=X.getContext("2d"),m=M.width,I=M.actualBoundingBoxAscent+M.actualBoundingBoxDescent,f=Math.sqrt(Math.pow(m,2)+Math.pow(I,2)),F=f+2*c[0]*h,V=f+2*c[1]*h;X.width=F,X.height=V,X.style.width=`${F*S}px`,X.style.height=`${V*S}px`,N.translate(F/2,V/2),N.rotate(-45*Math.PI/180),N.translate(-F/2,-V/2),N.font=`${i*h}px ${s}`,N.fillStyle=l,N.fillText(T,(F-m)/2,(V-I)/2+M.actualBoundingBoxAscent);const Z=t.createPattern(X,"repeat");Z&&(t.fillStyle=Z,t.fillRect(0,0,u,g))}else{const S=u/2,X=g/2;t.fillStyle=l,t.translate(S,X),t.rotate(-45*Math.PI/180),t.fillText(T,-M.width/2,M.actualBoundingBoxAscent-i*h/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:n,data:o,opacity:s,repeat:i,gap:l},scale:a}=this.options;if(!this.imageCache.has(o)){const g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=o,g.onload=()=>{this.imageCache.set(o,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const c=this.draw.getWidth(),d=this.draw.getHeight(),h=e*a,u=n*a;if(t.save(),t.globalAlpha=s,i){const g=this.draw.getPagePixelRatio(),T=document.createElement("canvas"),P=T.getContext("2d"),O=Math.sqrt(Math.pow(h,2)+Math.pow(u,2)),M=O+2*l[0]*a,S=O+2*l[1]*a;T.width=M,T.height=S,T.style.width=`${M*g}px`,T.style.height=`${S*g}px`,P.translate(M/2,S/2),P.rotate(-45*Math.PI/180),P.translate(-M/2,-S/2),P.drawImage(this.imageCache.get(o),(M-h)/2,(S-u)/2,h,u);const X=t.createPattern(T,"repeat");X&&(t.fillStyle=X,t.fillRect(0,0,c,d))}else{const g=c/2,T=d/2;t.translate(g,T),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(o),-h/2,-u/2,h,u)}t.restore()}render(t,e){this.options.watermark.type===R.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class As{constructor(t){L(this,"draw");L(this,"control");L(this,"options");L(this,"highlightList");L(this,"highlightMatchResult");this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){var T,P;const{control:{activeBackgroundColor:n,disabledBackgroundColor:o,existValueBackgroundColor:s,noValueBackgroundColor:i}}=this.options,l=t[e],a=this.draw.isPrintMode(),c=(T=this.control.getActiveControl())==null?void 0:T.getElement();let d=!1,h=!1,u=!1,g=!1;return l.highlight||(d=!a&&!!n&&!!c&&l.controlId===c.controlId&&!this.control.getIsRangeInPostfix()),d||(h=!a&&!!o&&!!((P=l.control)==null?void 0:P.disabled)),h||(u=!a&&!!s&&!!l.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),u||(g=!a&&!!i&&!!l.controlId&&!this.control.getIsExistValueByElementListIndex(t,e)),(d?n:"")||(h?o:"")||(u?s:"")||(g?i:"")}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(n,o)=>{let s=0;for(;s<n.length;){const i=n[s];if(s++,i.type===R.ElementType.TABLE){const T=i.trList;for(let P=0;P<T.length;P++){const O=T[P];for(let M=0;M<O.tdList.length;M++){const S=O.tdList[M],X={tableId:i.id,tableIndex:s-1,trIndex:P,tdIndex:M,tdId:S.id};e(S.value,X)}}}const l=i==null?void 0:i.control;if(!l)continue;const a=this.highlightList.findIndex(T=>T.id===i.controlId||l.conceptId&&l.conceptId===T.conceptId);if(!~a)continue;const c=s;let d=s;for(;d<n.length&&n[d].controlId===i.controlId;)d++;s=d;const h=n.slice(c,d).map(T=>T.controlComponent===R.ControlComponent.VALUE?T:{value:y}),u=this.highlightList[a],{ruleList:g}=u;for(let T=0;T<g.length;T++){const P=g[T],O=t.getMatchList(P.keyword,h);this.highlightMatchResult.push(...O.map(M=>B(Y(Y(Y({},M),P),o),{index:M.index+c})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){var l,a,c;if(!((l=this.highlightMatchResult)==null?void 0:l.length))return;const{searchMatchAlpha:n,searchMatchColor:o}=this.options,s=this.draw.getPosition().getOriginalPositionList(),i=this.draw.getOriginalElementList();t.save();for(let d=0;d<this.highlightMatchResult.length;d++){const h=this.highlightMatchResult[d];let u=null;if(h.tableId){const{tableIndex:m,trIndex:I,tdIndex:f,index:F}=h;u=(c=(a=i[m])==null?void 0:a.trList[I].tdList[f])==null?void 0:c.positionList[F]}else u=s[h.index];if(!u)continue;const{coordinate:{leftTop:g,leftBottom:T,rightTop:P},pageNo:O}=u;if(O!==e)continue;t.fillStyle=h.backgroundColor||o,t.globalAlpha=h.alpha||n;const M=g[0],S=g[1],X=P[0]-g[0],N=T[1]-g[1];t.fillRect(M,S,X,N)}t.restore()}}class _s{constructor(t){L(this,"borderRect");L(this,"options");this.borderRect=this.clearBorderInfo(),this.options=t.getOptions()}clearBorderInfo(){return this.borderRect={x:0,y:0,width:0,height:0},this.borderRect}recordBorderInfo(t,e,n,o){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=o),this.borderRect.width+=n}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:n,borderColor:o}}=this.options,{x:s,y:i,width:l,height:a}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=n*e,t.strokeStyle=o,t.beginPath(),t.rect(s,i,l,a),t.stroke(),t.restore(),this.clearBorderInfo()}}class Se{constructor(t,e){L(this,"draw");L(this,"element");L(this,"control");L(this,"isPopup");L(this,"selectDom");L(this,"options");L(this,"VALUE_DELIMITER",",");L(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?void 0:e.code)?this.element.control.code.split(","):[]}getText(t){var i,l;if(!((i=this.element)==null?void 0:i.control))return null;const e=this.element.control;if(!((l=e.valueSets)==null?void 0:l.length))return null;const n=(e==null?void 0:e.multiSelectDelimiter)||this.DEFAULT_MULTI_SELECT_DELIMITER,o=e.valueSets,s=[];return t.forEach(a=>{const c=o.find(d=>d.code===a);c&&!Wn(c.value)&&s.push(c.value)}),s.join(n)||null}getValue(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:n}=t.range||this.control.getRange(),o=e[n],s=[];let i=n;for(;i>0;){const a=e[i];if(a.controlId!==o.controlId||a.controlComponent===R.ControlComponent.PREFIX||a.controlComponent===R.ControlComponent.PRE_TEXT)break;a.controlComponent===R.ControlComponent.VALUE&&s.unshift(a),i--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==o.controlId||a.controlComponent===R.ControlComponent.POSTFIX||a.controlComponent===R.ControlComponent.POST_TEXT)break;a.controlComponent===R.ControlComponent.VALUE&&s.push(a),l++}return s}setValue(t,e={},n={}){var u,g;if(!((g=(u=this.element.control)==null?void 0:u.selectExclusiveOptions)==null?void 0:g.inputAble)||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:i,endIndex:l}=s,a=this.control.getDraw();i!==l?a.spliceElementList(o,i+1,l-i):this.control.removePlaceholder(i,e);const c=o[i],d=c.type&&!bt.includes(c.type)||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT?pt(c,["control","controlId",...xt]):Gt(c,["type"]),h=s.startIndex+1;for(let T=0;T<t.length;T++){const P=B(Y(Y({},d),t[T]),{controlComponent:R.ControlComponent.VALUE});It(o,[P],i,{editorOptions:this.options}),a.spliceElementList(o,h+T,0,[P])}return h+t.length-1}keydown(t){var c,d;if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:o,endIndex:s}=n,i=e[o],l=e[s],a=(d=(c=this.element.control)==null?void 0:c.selectExclusiveOptions)==null?void 0:d.inputAble;if(t.key===R.KeyMap.Backspace)return o!==s?a?(this.draw.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o):this.clearSelect():i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):a?(this.draw.spliceElementList(e,o,1),this.getValue().length||this.control.addPlaceholder(o-1),o-1):this.clearSelect();if(t.key===R.KeyMap.Delete){if(o!==s)return a?(this.draw.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o):this.clearSelect();{const h=e[s+1];return(i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT)&&h.controlComponent===R.ControlComponent.PLACEHOLDER||h.controlComponent===R.ControlComponent.POSTFIX||h.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):a?(this.draw.spliceElementList(e,o+1,1),this.getValue().length||this.control.addPlaceholder(o),o):this.clearSelect()}}return s}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:o=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const s=t.elementList||this.control.getElementList(),{startIndex:i}=t.range||this.control.getRange(),l=s[i];let a=-1,c=-1,d=i;for(;d>0;){const g=s[d];if(g.controlId!==l.controlId||g.controlComponent===R.ControlComponent.PREFIX||g.controlComponent===R.ControlComponent.PRE_TEXT){a=d;break}d--}let h=i+1;for(;h<s.length;){const g=s[h];if(g.controlId!==l.controlId||g.controlComponent===R.ControlComponent.POSTFIX||g.controlComponent===R.ControlComponent.POST_TEXT){c=h-1;break}h++}return!~a||!~c?-1:(this.control.getDraw().spliceElementList(s,a+1,c-a,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),o&&this.control.addPlaceholder(d,t),this.control.setControlProperties({code:null},{elementList:s,range:{startIndex:d,endIndex:d}}),d)}setSelect(t,e={},n={}){var N;if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange(),i=this.element.control,l=(t==null?void 0:t.split(this.VALUE_DELIMITER))||[],a=i.code,c=((N=i.code)==null?void 0:N.split(this.VALUE_DELIMITER))||[],d=i.isMultiSelect;if(!d&&t===a||d&&Fn(c,l)){this.control.repaintControl({curIndex:s.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const h=i.valueSets;if(!Array.isArray(h)||!h.length)return;const u=this.getText(l);if(!u){if(a){const m=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~m&&(this.control.repaintControl({curIndex:m}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],T=g?pt(g,Dt):pt(o[s.startIndex],xt),P=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~P)return;a||this.control.removePlaceholder(P,e);const O=Gt(o[P],Dt),M=P+1,S=Qt(u),X=this.control.getDraw();for(let m=0;m<S.length;m++){const I=B(Y(Y({},T),O),{type:R.ElementType.TEXT,value:S[m],controlComponent:R.ControlComponent.VALUE});It(o,[I],P,{editorOptions:this.options}),X.spliceElementList(o,M+m,0,[I])}if(this.control.setControlProperties({code:t},{elementList:o,range:{startIndex:P,endIndex:P}}),!e.range){const m=M+S.length-1;this.control.repaintControl({curIndex:m}),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 o=document.createElement("div");o.classList.add(`${v}-select-control-popup`),o.setAttribute(_t,R.EditorComponent.POPUP);const s=document.createElement("ul");let i=null;for(let u=0;u<e.length;u++){const g=e[u],T=document.createElement("li");let P=this.getCodes();P.includes(g.code)&&(T.classList.add("active"),i=T),T.onclick=()=>{const O=P.findIndex(M=>M===g.code);t.isMultiSelect?~O?P.splice(O,1):P.push(g.code):~O?P=[]:P=[g.code],this.setSelect(P.join(this.VALUE_DELIMITER))},T.append(document.createTextNode(g.value)),s.append(T)}o.append(s);const{coordinate:{leftTop:[l,a]},lineHeight:c}=n,d=this.control.getPreY();o.style.left=`${l}px`,o.style.top=`${a+d+c}px`,this.control.getContainer().append(o),this.selectDom=o,i&&pn(o,i)}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 hn{constructor(t,e){L(this,"element");L(this,"control");L(this,"options");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(),o=e[n],s=[];let i=n;for(;i>0;){const a=e[i];if(a.controlId!==o.controlId||a.controlComponent===R.ControlComponent.PREFIX||a.controlComponent===R.ControlComponent.PRE_TEXT)break;a.controlComponent===R.ControlComponent.VALUE&&s.unshift(a),i--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==o.controlId||a.controlComponent===R.ControlComponent.POSTFIX||a.controlComponent===R.ControlComponent.POST_TEXT)break;a.controlComponent===R.ControlComponent.VALUE&&s.push(a),l++}return s}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:i,endIndex:l}=s,a=this.control.getDraw();i!==l?a.spliceElementList(o,i+1,l-i,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(i,e);const c=o[i],d=c.type&&!bt.includes(c.type)||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT?pt(c,["control","controlId",...xt]):Gt(c,["type"]),h=s.startIndex+1;for(let u=0;u<t.length;u++){const g=B(Y(Y({},d),t[u]),{controlComponent:R.ControlComponent.VALUE});It(o,[g],i,{editorOptions:this.options}),a.spliceElementList(o,h+u,0,[g])}return h+t.length-1}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),o=t.range||this.control.getValueRange()||this.control.getRange(),{startIndex:s,endIndex:i}=o;return this.control.getDraw().spliceElementList(n,s+1,i-s,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),this.getValue({range:o,elementList:n}).length||this.control.addPlaceholder(s,t),s}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:o,endIndex:s}=n,i=e[o],l=e[s],a=this.control.getDraw();if(t.key===R.KeyMap.Backspace)return o!==s?(a.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o):i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):(a.spliceElementList(e,o,1),this.getValue().length||this.control.addPlaceholder(o-1),o-1);if(t.key===R.KeyMap.Delete){if(o!==s)return a.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o;{const c=e[s+1];return(i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT)&&c.controlComponent===R.ControlComponent.PLACEHOLDER||c.controlComponent===R.ControlComponent.POSTFIX||c.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):(a.spliceElementList(e,o+1,1),this.getValue().length||this.control.addPlaceholder(o),o)}}return s}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(),o=this.control.getElementList();return n.spliceElementList(o,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}}class ii{constructor(t,e={}){L(this,"draw");L(this,"options");L(this,"now");L(this,"dom");L(this,"renderOptions");L(this,"isDatePicker");L(this,"pickDate");L(this,"lang");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(`${v}-date-container`),t.setAttribute(_t,R.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${v}-date-wrap`);const n=document.createElement("div");n.classList.add(`${v}-date-title`);const o=document.createElement("span");o.classList.add(`${v}-date-title__pre-year`),o.innerText="<<";const s=document.createElement("span");s.classList.add(`${v}-date-title__pre-month`),s.innerText="<";const i=document.createElement("span");i.classList.add(`${v}-date-title__now`);const l=document.createElement("span");l.classList.add(`${v}-date-title__next-month`),l.innerText=">";const a=document.createElement("span");a.classList.add(`${v}-date-title__next-year`),a.innerText=">>",n.append(o),n.append(s),n.append(i),n.append(l),n.append(a);const c=document.createElement("div");c.classList.add(`${v}-date-week`);const{weeks:{sun:d,mon:h,tue:u,wed:g,thu:T,fri:P,sat:O}}=this.lang;[d,h,u,g,T,P,O].forEach(D=>{const W=document.createElement("span");W.innerText=`${D}`,c.append(W)});const S=document.createElement("div");S.classList.add(`${v}-date-day`),e.append(n),e.append(c),e.append(S);const X=document.createElement("ul");X.classList.add(`${v}-time-wrap`);let N,m,I;[this.lang.hour,this.lang.minute,this.lang.second].forEach((D,W)=>{const E=document.createElement("li"),U=document.createElement("span");U.innerText=D,E.append(U);const Q=document.createElement("ol"),w=W===0,K=W===1,p=w?24:60;for(let G=0;G<p;G++){const H=document.createElement("li");H.innerText=`${String(G).padStart(2,"0")}`,H.setAttribute("data-id",`${G}`),Q.append(H)}w?N=Q:K?m=Q:I=Q,E.append(Q),X.append(E)});const F=document.createElement("div");F.classList.add(`${v}-date-menu`);const V=document.createElement("button");V.classList.add(`${v}-date-menu__time`),V.innerText=this.lang.timeSelect;const Z=document.createElement("button");Z.classList.add(`${v}-date-menu__now`),Z.innerText=this.lang.now;const C=document.createElement("button");return C.classList.add(`${v}-date-menu__submit`),C.innerText=this.lang.confirm,F.append(V),F.append(Z),F.append(C),t.append(e),t.append(X),t.append(F),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:c,timeWrap:X,title:{preYear:o,preMonth:s,now:i,nextMonth:l,nextYear:a},day:S,time:{hour:N,minute:m,second:I},menu:{time:V,now:Z,submit:C}}}_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:o}}=this.renderOptions,s=this.draw.getHeight(),i=this.draw.getPageGap(),a=(o!=null?o:this.draw.getPageNo())*(s+i);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:o,thu:s,fri:i,sat:l}}=this.lang,a=[t,e,n,o,s,i,l];this.dom.datePickerWeek.childNodes.forEach((u,g)=>{const T=u;T.innerText=a[g]});const c=this.dom.time.hour.previousElementSibling;c.innerText=this.lang.hour;const d=this.dom.time.minute.previousElementSibling;d.innerText=this.lang.minute;const h=this.dom.time.second.previousElementSibling;h.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),n=t.getMonth()+1,o=t.getDate();let s=null,i=null,l=null;this.pickDate&&(s=this.pickDate.getFullYear(),i=this.pickDate.getMonth()+1,l=this.pickDate.getDate());const a=this.now.getFullYear(),c=this.now.getMonth()+1;this.dom.title.now.innerText=`${a}${this.lang.year} ${String(c).padStart(2,"0")}${this.lang.month}`;const h=new Date(a,c,0).getDate();let u=new Date(a,c-1,1).getDay();u===0&&(u=7);const g=new Date(a,c-1,0).getDate();this.dom.day.innerHTML="";const T=g-u+1;for(let O=T;O<=g;O++){const M=document.createElement("div");M.classList.add("disable"),M.innerText=`${O}`,M.onclick=()=>{const S=c-2;this.now=new Date(a,S,O),this._setDatePick(a,S,O)},this.dom.day.append(M)}for(let O=1;O<=h;O++){const M=document.createElement("div");e===a&&n===c&&o===O&&M.classList.add("active"),this.pickDate&&s===a&&i===c&&l===O&&M.classList.add("select"),M.innerText=`${O}`,M.onclick=S=>{const X=c-1;this.now=new Date(a,X,O),this._setDatePick(a,X,O),S.stopPropagation()},this.dom.day.append(M)}const P=6*7-u-h;for(let O=1;O<=P;O++){const M=document.createElement("div");M.classList.add("disable"),M.innerText=`${O}`,M.onclick=()=>{this.now=new Date(a,c,O),this._setDatePick(a,c,O)},this.dom.day.append(M)}}_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 o,s,i;this.now=new Date(t,e,n),(o=this.pickDate)==null||o.setFullYear(t),(s=this.pickDate)==null||s.setMonth(e),(i=this.pickDate)==null||i.setDate(n),this._update()}_setTimePick(t=!0){var d,h,u;const e=((d=this.pickDate)==null?void 0:d.getHours())||0,n=((h=this.pickDate)==null?void 0:h.getMinutes())||0,o=((u=this.pickDate)==null?void 0:u.getSeconds())||0,{hour:s,minute:i,second:l}=this.dom.time;[s,i,l].forEach(g=>{g.querySelectorAll("li").forEach(T=>T.classList.remove("active"))}),[[s,e],[i,n],[l,o]].forEach(([g,T])=>{const P=g.querySelector(`[data-id='${T}']`);P.classList.add("active"),t&&pn(g,P)})}_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 o=t.getFullYear().toString(),s=(t.getMonth()+1).toString(),i=t.getDate().toString(),l=t.getHours(),a=l%12==0?12:l%12,c=t.getMinutes().toString(),d=t.getSeconds().toString(),h=t.getMilliseconds().toString(),u={"y+":o,"Y+":o,"M+":s,"d+":i,"D+":i,"h+":a.toString(),"H+":l.toString(),"m+":c,"s+":d,"S+":h};for(const g in u){const T=new RegExp("("+g+")").exec(e),P=g;T&&(n=n.replace(T[1],T[1].length===1?u[P]:u[P].padStart(T[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 Xe{constructor(t,e){L(this,"draw");L(this,"element");L(this,"control");L(this,"isPopup");L(this,"datePicker");L(this,"options");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 o=[],{startIndex:s,endIndex:i}=n;for(let l=s;l<=i;l++){const a=e[l];a.controlComponent===R.ControlComponent.VALUE&&o.push(a)}return o}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:i,endIndex:l}=s,a=this.control.getDraw();i!==l?a.spliceElementList(o,i+1,l-i):this.control.removePlaceholder(i,e);const c=o[i],d=c.type&&!bt.includes(c.type)||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT?pt(c,["control","controlId",...xt]):Gt(c,["type"]),h=s.startIndex+1;for(let u=0;u<t.length;u++){const g=B(Y(Y({},d),t[u]),{controlComponent:R.ControlComponent.VALUE});It(o,[g],i,{editorOptions:this.options}),a.spliceElementList(o,h+u,0,[g])}return h+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:o=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const s=this.control.getValueRange(t);if(!s)return-1;const{startIndex:i,endIndex:l}=s;if(!~i||!~l)return-1;const a=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(a,i+1,l-i,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),o&&this.control.addPlaceholder(i,t),i}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange(),i=this.getValue(e)[0],l=i?pt(i,Dt):pt(o[s.startIndex],xt),a=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~a)return;const c=Gt(o[a],Dt),d=a+1,h=this.control.getDraw();for(let u=0;u<t.length;u++){const g=B(Y(Y({},l),c),{type:R.ElementType.TEXT,value:t[u],controlComponent:R.ControlComponent.VALUE});It(o,[g],a,{editorOptions:this.options}),h.spliceElementList(o,d+u,0,[g])}if(!e.range){const u=d+t.length-1;this.control.repaintControl({curIndex:u}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:o,endIndex:s}=n,i=e[o],l=e[s],a=this.control.getDraw();if(t.key===R.KeyMap.Backspace)return o!==s?(a.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o):i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):(a.spliceElementList(e,o,1),this.getValue().length||this.control.addPlaceholder(o-1),o-1);if(t.key===R.KeyMap.Delete){if(o!==s)return a.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o;{const c=e[s+1];return(i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT)&&c.controlComponent===R.ControlComponent.PLACEHOLDER||c.controlComponent===R.ControlComponent.POSTFIX||c.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):(a.spliceElementList(e,o+1,1),this.getValue().length||this.control.addPlaceholder(o),o)}}return s}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(),o=this.control.getElementList();return n.spliceElementList(o,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){var i,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(((i=e[n+1])==null?void 0:i.controlId)!==this.element.controlId)return;this.datePicker=new ii(this.draw,{onSubmit:this._setDate.bind(this)});const o=this.getValue().map(a=>a.value).join("")||"",s=(l=this.element.control)==null?void 0:l.dateFormat;this.datePicker.render({value:o,position:t,dateFormat:s}),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 zs{constructor(t){L(this,"control");L(this,"calculatorDom");L(this,"onCalculate");L(this,"currentExpression");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(`${v}-calculator`),e.setAttribute(_t,R.EditorComponent.POPUP);const n=document.createElement("div");n.classList.add(`${v}-calculator-display`),n.textContent="0";const o=document.createElement("div");o.classList.add(`${v}-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(h=>{h.forEach(u=>{const g=document.createElement("button");g.classList.add(`${v}-calculator-button`),u.type===at.OPERATOR?g.classList.add("operator"):u.type===at.EQUAL?g.classList.add("equal"):u.type===at.UTILITY&&g.classList.add("utility"),g.textContent=u.text,g.onclick=()=>{const T=u.text;if(T==="C")this.currentExpression="",n.textContent="0";else if(T==="\u2190")this.currentExpression=this.currentExpression.slice(0,-1),n.textContent=this.currentExpression||"0";else if(T==="="){const P=this.calculate(this.currentExpression);Number.isFinite(P)?(n.textContent=P.toString(),this.currentExpression=P.toString(),this.onCalculate(P)):(n.textContent="Error",this.currentExpression="")}else this.currentExpression+=T,n.textContent=this.currentExpression},u.span&&(g.style.gridColumn=`span ${u.span}`),o.appendChild(g)})}),e.appendChild(n),e.appendChild(o);const{coordinate:{leftTop:[i,l]},lineHeight:a}=t,c=this.control.getPreY();e.style.left=`${i}px`,e.style.top=`${l+c+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 Ie extends hn{constructor(t,e){super(t,e);L(this,"isPopup");L(this,"calculator");this.isPopup=!1,this.calculator=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(h=>!wo(h)||Yi.test(h.value)))return-1;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange();this.control.shrinkBoundary(e);const i=$(t),{startIndex:l,endIndex:a}=s,c=o[l];if(this.control.getIsExistValueByElementListIndex(o,l)){let h=l;for(;h>0;){const g=o[h];if(g.controlId!==c.controlId||g.controlComponent===R.ControlComponent.PREFIX||g.controlComponent===R.ControlComponent.PRE_TEXT)break;i.unshift(g),h--}let u=a+1;for(;u<o.length;){const g=o[u];if(g.controlId!==c.controlId||g.controlComponent===R.ControlComponent.POSTFIX||g.controlComponent===R.ControlComponent.POST_TEXT)break;i.push(g),u++}}const d=Ho(i);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(),o=this.control.getRange(),s=this.getValue()[0],i=s?pt(s,Dt):pt(n[o.startIndex],xt),l=Gt(n[e],Dt),a=t.toString(),c=[];for(let d=0;d<a.length;d++){const h=B(Y(Y({},i),l),{type:R.ElementType.TEXT,value:a[d],controlComponent:R.ControlComponent.VALUE});c.push(h)}this.setValue(c),this.control.repaintControl({curIndex:e+c.length}),this.control.emitControlContentChange(),this.destroy()}awake(){var o,s,i;const t=((s=(o=this.element.control)==null?void 0:o.numberExclusiveOptions)==null?void 0:s.calculatorDisabled)===!1;if(this.isPopup||!t||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const{startIndex:e}=this.control.getRange();((i=this.control.getElementList()[e+1])==null?void 0:i.controlId)===this.element.controlId&&(this.calculator=new zs({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 $s{constructor(t){L(this,"controlBorder");L(this,"draw");L(this,"range");L(this,"listener");L(this,"eventBus");L(this,"controlSearch");L(this,"options");L(this,"controlOptions");L(this,"activeControl");L(this,"activeControlValue");L(this,"preElement");this.controlBorder=new _s(t),this.draw=t,this.range=t.getRange(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.controlSearch=new As(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){const{filterEmptyControl:e}=this.options.modeRule[R.EditorMode.PRINT];return t.filter((n,o)=>{var s,i,l;if(n.type===R.ElementType.TABLE){const a=n.trList;for(let c=0;c<a.length;c++){const d=a[c];for(let h=0;h<d.tdList.length;h++){const u=d.tdList[h];u.value=this.filterAssistElement(u.value)}}}if(!n.controlId)return!0;if((s=n.control)==null?void 0:s.minWidth){if(n.controlComponent===R.ControlComponent.PREFIX||n.controlComponent===R.ControlComponent.POSTFIX)return n.value="",!0}else{if(((i=n.control)==null?void 0:i.preText)&&n.controlComponent===R.ControlComponent.PRE_TEXT){let a=!1,c=o+1;for(;c<t.length;){const d=t[c];if(n.controlId!==d.controlId)break;if(d.controlComponent===R.ControlComponent.VALUE){a=!0;break}c++}return a}if(((l=n.control)==null?void 0:l.postText)&&n.controlComponent===R.ControlComponent.POST_TEXT){let a=!1,c=o-1;for(;c<t.length;){const d=t[c];if(n.controlId!==d.controlId)break;if(d.controlComponent===R.ControlComponent.VALUE){a=!0;break}c--}return a}}return n.controlComponent!==R.ControlComponent.PREFIX&&n.controlComponent!==R.ControlComponent.POSTFIX&&(!e||n.controlComponent!==R.ControlComponent.PLACEHOLDER)})}getIsRangeCanCaptureEvent(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),o=n[t];if(t===e&&o.controlComponent===R.ControlComponent.POSTFIX)return!0;const s=n[e];return!!(o.controlId&&o.controlId===s.controlId&&s.controlComponent!==R.ControlComponent.POSTFIX)}getIsRangeInPostfix(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();return t!==e?!1:this.getElementList()[t].controlComponent===R.ControlComponent.POSTFIX}getIsRangeWithinControl(){const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),o=n[t],s=n[e];return!!((o==null?void 0:o.controlId)&&o.controlId===s.controlId&&s.controlComponent!==R.ControlComponent.POSTFIX)}getIsElementListContainFullControl(t){if(!t.some(o=>o.controlId))return!1;let e=0,n=0;for(let o=0;o<t.length;o++){const s=t[o];s.controlComponent===R.ControlComponent.PREFIX?e++:s.controlComponent===R.ControlComponent.POSTFIX&&n++}return!e||!n?!1:e===n}getIsDisabledControl(t={}){var o,s;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===R.ControlComponent.POSTFIX?!1:!!((s=(o=this.activeControl.getElement())==null?void 0:o.control)==null?void 0:s.disabled)}getIsDisabledPasteControl(t={}){var o,s;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===R.ControlComponent.POSTFIX?!1:!!((s=(o=this.activeControl.getElement())==null?void 0:o.control)==null?void 0:s.pasteDisabled)}getIsExistValueByElementListIndex(t,e){var o,s,i;const n=t[e];if(!n.controlId)return!1;if(((o=n.control)==null?void 0:o.type)===R.ControlType.CHECKBOX||((s=n.control)==null?void 0:s.type)===R.ControlType.RADIO)return!!((i=n.control)==null?void 0:i.code);if(n.controlComponent===R.ControlComponent.VALUE)return!0;if(n.controlComponent===R.ControlComponent.PLACEHOLDER)return!1;if(n.controlComponent===R.ControlComponent.PREFIX||n.controlComponent===R.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===R.ControlComponent.VALUE)return!0;if(a.controlComponent===R.ControlComponent.PLACEHOLDER)return!1;l++}}if(n.controlComponent===R.ControlComponent.POSTFIX||n.controlComponent===R.ControlComponent.POST_TEXT){let l=e-1;for(;l>=0;){const a=t[l];if(a.controlId!==n.controlId)return!1;if(a.controlComponent===R.ControlComponent.VALUE)return!0;if(a.controlComponent===R.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 o,s;const t=this.draw.getHeight(),e=this.draw.getPageGap();return((s=(o=this.getPosition())==null?void 0:o.pageNo)!=null?s:this.draw.getPageNo())*(t+e)}getRange(){return this.range.getRange()}getValueRange(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),o=e[n];let s=n;for(;s>0;){const l=e[s];if(l.controlId!==o.controlId||l.controlComponent===R.ControlComponent.PREFIX||l.controlComponent===R.ControlComponent.PRE_TEXT)break;s--}let i=n+1;for(;i<e.length;){const l=e[i];if(l.controlId!==o.controlId||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT)break;i++}return s===i?null:{startIndex:s,endIndex:i-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(),o=e[n];if(!(o==null?void 0:o.controlId))return[];const s=[];let i=n;for(;i>0;){const a=e[i];if(a.controlId!==o.controlId)break;s.unshift(a),i--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==o.controlId)break;s.push(a),l++}return s}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 o=this.activeControlValue,s=this.activeControl.getElement();(o==null?void 0:o.length)?n=st(o)[0].control:(n=le($(s)).control,n.value=[]);const i={state:t,control:n,controlId:s.controlId};(a=(l=this.listener).controlChange)==null||a.call(l,i),e&&this.eventBus.emit("controlChange",i)}initControl(){var i,l;const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];if(this.activeControl){(this.activeControl instanceof Se||this.activeControl instanceof Xe||this.activeControl instanceof Ie)&&(n.controlComponent===R.ControlComponent.POSTFIX?this.activeControl.destroy():this.activeControl.awake()),((i=this.preElement)==null?void 0:i.controlId)===n.controlId&&(n.controlComponent===R.ControlComponent.POSTFIX?this.emitControlChange(R.ControlState.INACTIVE):((l=this.preElement)==null?void 0:l.controlComponent)===R.ControlComponent.POSTFIX&&this.emitControlChange(R.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 s=n.control;if(s.type===R.ControlType.TEXT)this.activeControl=new hn(n,this);else if(s.type===R.ControlType.SELECT){const a=new Se(n,this);this.activeControl=a,a.awake()}else if(s.type===R.ControlType.CHECKBOX)this.activeControl=new Ce(n,this);else if(s.type===R.ControlType.RADIO)this.activeControl=new an(n,this);else if(s.type===R.ControlType.DATE){const a=new Xe(n,this);this.activeControl=a,a.awake()}else if(s.type===R.ControlType.NUMBER){const a=new Ie(n,this);this.activeControl=a,a.awake()}this.updateActiveControlValue(),this.preElement=n,n.controlComponent!==R.ControlComponent.POSTFIX&&this.emitControlChange(R.ControlState.ACTIVE)}destroyControl(t={}){var n;if(!this.activeControl)return;const{isEmitEvent:e=!0}=t;(this.activeControl instanceof Se||this.activeControl instanceof Xe||this.activeControl instanceof Ie)&&this.activeControl.destroy(),e&&((n=this.preElement)==null?void 0:n.controlComponent)!==R.ControlComponent.POSTFIX&&this.emitControlChange(R.ControlState.INACTIVE),this.preElement=null,this.activeControl=null,this.activeControlValue=[]}repaintControl(t={}){const{curIndex:e,isCompute:n=!0,isSubmitHistory:o=!0,isSetCursor:s=!0}=t;e===void 0?(this.range.clearRange(),this.draw.render({isCompute:n,isSubmitHistory:o,isSetCursor:!1})):(this.range.setRange(e,e),this.draw.render({curIndex:e,isCompute:n,isSetCursor:s,isSubmitHistory:o}))}emitControlContentChange(t){var c,d,h,u,g,T;const e=this.eventBus.isSubscribe("controlContentChange");if(!e&&!this.listener.controlContentChange)return;const n=(t==null?void 0:t.controlElement)||((c=this.activeControl)==null?void 0:c.getElement());if(!n)return;const o=((d=t==null?void 0:t.context)==null?void 0:d.elementList)||this.getElementList(),{startIndex:s}=((h=t==null?void 0:t.context)==null?void 0:h.range)||this.getRange();if(!((u=o[s])==null?void 0:u.controlId))return;const i=(t==null?void 0:t.controlValue)||this.getControlElementList(t==null?void 0:t.context);let l;if((i==null?void 0:i.length)?l=st(i)[0].control:(l=n.control,l.value=[]),!l)return;const a={control:l,controlId:n.controlId};(T=(g=this.listener).controlContentChange)==null||T.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 Xe||this.activeControl instanceof Se||this.activeControl instanceof Ie)&&this.activeControl.getIsPopup()&&(this.activeControl.destroy(),this.activeControl.awake())}selectValue(){var i;const t=this.getElementList(),{startIndex:e}=this.getRange(),n=t[e];if(!(n==null?void 0:n.controlId)||n.controlComponent!==R.ControlComponent.VALUE&&((i=t[e+1])==null?void 0:i.controlComponent)===R.ControlComponent.VALUE)return!1;let o=e;for(;o>0&&t[o].controlComponent===R.ControlComponent.VALUE;)o--;let s=e+1;for(;s<t.length;){if(t[s].controlComponent!==R.ControlComponent.VALUE){s--;break}s++}if(o!==s){const l=this.range.getRange();return this.range.replaceRange(B(Y({},l),{startIndex:o,endIndex:s})),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),!0}return!1}moveCursor(t){var c,d;const{index:e,trIndex:n,tdIndex:o,tdValueIndex:s}=t;let i=this.draw.getOriginalElementList(),l;const a=t.isTable?s:e;if(t.isTable?(i=i[e].trList[n].tdList[o].value,l=i[s]):l=i[e],l.hide||((c=l.control)==null?void 0:c.hide)||((d=l.area)==null?void 0:d.hide)){const h=Oe(i,a);return{newIndex:h,newElement:i[h]}}if(l.controlComponent===R.ControlComponent.VALUE)return{newIndex:a,newElement:l};if(l.controlComponent===R.ControlComponent.POSTFIX){let h=a+1;for(;h<i.length;){if(i[h].controlId!==l.controlId)return{newIndex:h-1,newElement:i[h-1]};if(h===i.length-1)return{newIndex:h,newElement:i[h]};h++}}else if(l.controlComponent===R.ControlComponent.PREFIX||l.controlComponent===R.ControlComponent.PRE_TEXT){let h=a+1;for(;h<i.length;){const u=i[h];if(u.controlId!==l.controlId||u.controlComponent!==R.ControlComponent.PREFIX&&u.controlComponent!==R.ControlComponent.PRE_TEXT)return{newIndex:h-1,newElement:i[h-1]};h++}}else if(l.controlComponent===R.ControlComponent.PLACEHOLDER||l.controlComponent===R.ControlComponent.POST_TEXT){let h=a-1;for(;h>0;){const u=i[h];if(u.controlId!==l.controlId||u.controlComponent===R.ControlComponent.VALUE||u.controlComponent===R.ControlComponent.PREFIX||u.controlComponent===R.ControlComponent.PRE_TEXT)return{newIndex:h,newElement:i[h]};h--}}return{newIndex:a,newElement:l}}removeControl(t,e={}){var c,d;const n=e.elementList||this.getElementList(),o=n[t];if(!this.draw.isDesignMode()&&!(o==null?void 0:o.hide)&&!((c=o==null?void 0:o.control)==null?void 0:c.hide)&&!((d=o==null?void 0:o.area)==null?void 0:d.hide)){const{deletable:h=!0}=o.control;if(!h)return null;const u=this.draw.getMode();if(u===R.EditorMode.FORM&&this.options.modeRule[u].controlDeletableDisabled)return null}let s=-1,i=-1,l=t;for(;l>0;){if(n[l].controlId!==o.controlId){s=l;break}l--}let a=t+1;for(;a<n.length;){if(n[a].controlId!==o.controlId){i=a-1;break}a++}return a===n.length&&(i=a-1),!~s&&!~i?t:(s=~s?s:0,this.draw.spliceElementList(n,s+1,i-s),s)}removePlaceholder(t,e={}){const n=e.elementList||this.getElementList(),o=n[t],s=n[t+1];if(o.controlComponent===R.ControlComponent.PLACEHOLDER||s.controlComponent===R.ControlComponent.PLACEHOLDER){let i=!1,l=t;for(;l<n.length;){const a=n[l];if(a.controlId!==o.controlId)break;a.controlComponent===R.ControlComponent.PLACEHOLDER?(i||(i=!0,this.draw.getHistoryManager().popUndo(),this.draw.submitHistory(t)),n.splice(l,1)):l++}}}addPlaceholder(t,e={}){const n=e.elementList||this.getElementList(),o=n[t],s=o.control;if(!s.placeholder)return;const i=Qt(s.placeholder),l=pt(o,xt);for(let a=0;a<i.length;a++){const c=i[a],d=B(Y({},l),{value:c===`
|
|
88
|
-
`?y:c,controlId:o.controlId,type:R.ElementType.CONTROL,control:o.control,controlComponent:R.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:o}=e.range||this.getRange(),s=n[o];let i=o;for(;i>0;){const a=n[i];if(a.controlId!==s.controlId)break;a.control=Y(Y({},a.control),t),i--}let l=o+1;for(;l<n.length;){const a=n[l];if(a.controlId!==s.controlId)break;a.control=Y(Y({},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:o,areaId:s}=t,i=[];if(!e&&!o&&!n)return i;const l=(c,d)=>{let h=0;for(;h<c.length;){const u=c[h];if(h++,u.type===R.ElementType.TABLE){const X=u.trList;for(let N=0;N<X.length;N++){const m=X[N];for(let I=0;I<m.tdList.length;I++){const f=m.tdList[I];l(f.value,d)}}}if(!u.control||n&&u.control.groupId!==n||e&&u.controlId!==e||o&&u.control.conceptId!==o||s&&u.areaId!==s)continue;const{type:g,code:T,valueSets:P}=u.control;let O=h,M="";const S=[];for(;O<c.length;){const X=c[O];if(X.controlId!==u.controlId)break;(g===R.ControlType.TEXT||g===R.ControlType.DATE||g===R.ControlType.NUMBER)&&X.controlComponent===R.ControlComponent.VALUE&&(M+=X.value,S.push(Gt(X,_e))),O++}if(g===R.ControlType.TEXT||g===R.ControlType.DATE||g===R.ControlType.NUMBER)i.push(B(Y({},u.control),{zone:d,value:M||null,innerText:M||null,elementList:st(S)}));else if(g===R.ControlType.SELECT||g===R.ControlType.CHECKBOX||g===R.ControlType.RADIO){const X=T==null?void 0:T.split(",").map(N=>{var m;return(m=P==null?void 0:P.find(I=>I.code===N))==null?void 0:m.value}).filter(Boolean).join("");i.push(B(Y({},u.control),{zone:d,value:T||null,innerText:X||null}))}h=O}},a=[{zone:R.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:R.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:R.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:c,elementList:d}of a)l(d,c);return i}setValueListById(t){if(!t.length)return;let e=!1,n=!1;const o=i=>{let l=0;for(;l<i.length;){const a=i[l];if(l++,a.type===R.ElementType.TABLE){const S=a.trList;for(let X=0;X<S.length;X++){const N=S[X];for(let m=0;m<N.tdList.length;m++){const I=N.tdList[m];o(I.value)}}}if(!a.control)continue;const c=t.find(S=>{var X;return(!S.groupId||S.groupId===((X=a.control)==null?void 0:X.groupId))&&(S.id&&a.controlId===S.id||S.conceptId&&a.control.conceptId===S.conceptId||S.areaId&&a.areaId===S.areaId)});if(!c)continue;const{value:d,isSubmitHistory:h=!0}=c;e=!0,h&&(n=!0);const{type:u}=a.control;let g=l;for(;g<i.length&&i[g].controlId===a.controlId;)g++;const P={range:{startIndex:l-1,endIndex:g-2},elementList:i},O={isIgnoreDisabledRule:!0,isIgnoreDeletedRule:!0};if(u===R.ControlType.TEXT){const S=Array.isArray(d)?d:d?[{value:d}]:[];S.length&&Pt(S,{isHandleFirstElement:!1,editorOptions:this.options});const X=new hn(a,this);this.activeControl=X,S.length?X.setValue(S,P,O):X.clearValue(P,O)}else if(u===R.ControlType.SELECT){if(Array.isArray(d))continue;const S=new Se(a,this);this.activeControl=S,d?S.setSelect(d,P,O):S.clearSelect(P,O)}else if(u===R.ControlType.CHECKBOX){if(Array.isArray(d))continue;const S=new Ce(a,this);this.activeControl=S;const X=d?d.split(","):[];S.setSelect(X,P,O)}else if(u===R.ControlType.RADIO){if(Array.isArray(d))continue;const S=new an(a,this);this.activeControl=S;const X=d?[d]:[];S.setSelect(X,P,O)}else if(u===R.ControlType.DATE){const S=new Xe(a,this);this.activeControl=S,Je(d)?(d.length&&Pt(d,{isHandleFirstElement:!1,editorOptions:this.options}),S.setValue(d,P,O)):Ki(d)?S.setSelect(d,P,O):S.clearSelect(P,O)}else if(u===R.ControlType.NUMBER){const S=Array.isArray(d)?d:d?[{value:d}]:[];S.length&&Pt(S,{isHandleFirstElement:!1,editorOptions:this.options});const X=new Ie(a,this);this.activeControl=X,S.length?X.setValue(S,P,O):X.clearValue(P,O)}this.emitControlContentChange({context:P}),this.activeControl=null;let M=l;for(;M<i.length&&i[M].controlId===a.controlId;)M++;l=M}};this.destroyControl({isEmitEvent:!1});const s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of s)o(i);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}setExtensionListById(t){if(!t.length)return;const e=o=>{let s=0;for(;s<o.length;){const i=o[s];if(s++,i.type===R.ElementType.TABLE){const d=i.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];e(T.value)}}}if(!i.control)continue;const l=t.find(d=>{var h;return(!d.groupId||d.groupId===((h=i.control)==null?void 0:h.groupId))&&(d.id&&i.controlId===d.id||d.conceptId&&i.control.conceptId===d.conceptId||d.areaId&&i.areaId===d.areaId)});if(!l)continue;const{extension:a}=l;this.setControlProperties({extension:a},{elementList:o,range:{startIndex:s,endIndex:s}});let c=s;for(;c<o.length&&o[c].controlId===i.controlId;)c++;s=c}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const o of n)e(o)}setPropertiesListById(t){if(!t.length)return;let e=!1,n=!1;const o=i=>{let l=0;for(;l<i.length;){const a=i[l];if(l++,a.type===R.ElementType.TABLE){const g=a.trList;for(let T=0;T<g.length;T++){const P=g[T];for(let O=0;O<P.tdList.length;O++){const M=P.tdList[O];o(M.value)}}}if(!a.control)continue;const c=t.find(g=>{var T;return(!g.groupId||g.groupId===((T=a.control)==null?void 0:T.groupId))&&(g.id&&a.controlId===g.id||g.conceptId&&a.control.conceptId===g.conceptId||g.areaId&&a.areaId===g.areaId)});if(!c)continue;const{properties:d,isSubmitHistory:h=!0}=c;e=!0,h&&(n=!0),this.setControlProperties(B(Y(Y({},a.control),d),{value:a.control.value}),{elementList:i,range:{startIndex:l,endIndex:l}}),xt.forEach(g=>{const T=d[g];T&&Reflect.set(a,g,T)});let u=l;for(;u<i.length&&i[u].controlId===a.controlId;)u++;l=u}},s={header:this.draw.getHeaderElementList(),main:this.draw.getOriginalMainElementList(),footer:this.draw.getFooterElementList()};for(const i in s){const l=s[i];o(l)}if(!!e){for(const i in s){const l=i,a=st(s[l],{isClassifyArea:!0,extraPickAttrs:["id"]});s[l]=a,Pt(a,{editorOptions:this.options,isForceCompensation:!0})}this.draw.setEditorData(s),n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1})}}getList(){const t=[];function e(o){for(let s=0;s<o.length;s++){const i=o[s];if(i.type===R.ElementType.TABLE){const l=i.trList;for(let a=0;a<l.length;a++){const c=l[a];for(let d=0;d<c.tdList.length;d++){const u=c.tdList[d].value;e(u)}}}if(i.controlId){const l=Gt(i,[...Ae,...pe]);t.push(l)}}}const n=[this.draw.getHeader().getElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooter().getElementList()];for(const o of n)e(o);return st(t,{extraPickAttrs:["controlId"]})}recordBorderInfo(t,e,n,o){this.controlBorder.recordBorderInfo(t,e,n,o)}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 o(a,c){for(let d=c;d>0;d--){const h=a[d];if(h.type===R.ElementType.TABLE){const g=h.trList||[];for(let T=g.length-1;T>=0;T--){const P=g[T],O=P.tdList;for(let M=O.length-1;M>=0;M--){const S=O[M],X=o(S.value,S.value.length-1);if(X)return{positionContext:{isTable:!0,index:d,trIndex:T,tdIndex:M,tdId:S.id,trId:P.id,tableId:h.id},nextIndex:X.nextIndex}}}}if(!h.controlId||h.controlId===n.controlId)continue;let u=d;for(;u>0;){const g=a[u];if(g.controlComponent===R.ControlComponent.VALUE||g.controlComponent===R.ControlComponent.PREFIX||g.controlComponent===R.ControlComponent.PRE_TEXT)break;u--}return{positionContext:{isTable:!1},nextIndex:u}}return null}const{startIndex:s}=this.range.getRange(),i=this.getElementList(),l=o(i,s);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:c,trIndex:d,tdIndex:h}=e,u=a[c].trList;for(let T=d;T>=0;T--){const P=u[T],O=P.tdList;for(let M=O.length-1;M>=0;M--){if(d===T&&M>=h)continue;const S=O[M],X=o(S.value,S.value.length-1);if(X)return{positionContext:{isTable:!0,index:e.index,trIndex:T,tdIndex:M,tdId:S.id,trId:P.id,tableId:n.tableId},nextIndex:X.nextIndex}}}const g=o(a,c-1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}getNextControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function o(a,c){var d,h;for(let u=c;u<a.length;u++){const g=a[u];if(g.type===R.ElementType.TABLE){const T=g.trList||[];for(let P=0;P<T.length;P++){const O=T[P],M=O.tdList;for(let S=0;S<M.length;S++){const X=M[S],N=o(X.value,0);if(N)return{positionContext:{isTable:!0,index:u,trIndex:P,tdIndex:S,tdId:X.id,trId:O.id,tableId:g.id},nextIndex:N.nextIndex}}}}if(!(!g.controlId||g.controlId===n.controlId||((d=a[u+1])==null?void 0:d.controlComponent)===R.ControlComponent.PREFIX||((h=a[u+1])==null?void 0:h.controlComponent)===R.ControlComponent.PRE_TEXT))return{positionContext:{isTable:!1},nextIndex:u}}return null}const{endIndex:s}=this.range.getRange(),i=this.getElementList(),l=o(i,s);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:c,trIndex:d,tdIndex:h}=e,u=a[c].trList;for(let T=d;T<u.length;T++){const P=u[T],O=P.tdList;for(let M=0;M<O.length;M++){if(d===T&&M<=h)continue;const S=O[M],X=o(S.value,0);if(X)return{positionContext:{isTable:!0,index:e.index,trIndex:T,tdIndex:M,tdId:S.id,trId:P.id,tableId:n.tableId},nextIndex:X.nextIndex}}}const g=o(a,c+1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}initNextControl(t={}){const{direction:e=Lt.DOWN}=t;let n=null;if(e===Lt.UP?n=this.getPreControlContext():n=this.getNextControlContext(),!n)return;const{nextIndex:o,positionContext:s}=n;this.draw.getPosition().setPositionContext(s),this.draw.getRange().replaceRange({startIndex:o,endIndex:o}),this.draw.render({curIndex:o,isCompute:!1,isSetCursor:!0,isSubmitHistory:!1})}setMinWidthControlInfo(t){var d,h,u,g,T;const{row:e,rowElement:n,controlRealWidth:o,availableWidth:s}=t;if(!((d=n.control)==null?void 0:d.minWidth))return;const{scale:i}=this.options,l=n.control.minWidth*i;let a=null;if(((h=n.control)==null?void 0:h.minWidth)&&(((u=n.control)==null?void 0:u.rowFlex)===R.RowFlex.CENTER||((g=n.control)==null?void 0:g.rowFlex)===R.RowFlex.RIGHT)){let P=n.metrics.width,O=e.elementList.length-1;for(;O>=0;){const M=e.elementList[O];if(P+=M.metrics.width,((T=e.elementList[O-1])==null?void 0:T.controlComponent)===R.ControlComponent.PREFIX){a=M;break}O--}a&&P<l&&(n.control.rowFlex===R.RowFlex.CENTER?a.left=(l-P)/2:n.control.rowFlex===R.RowFlex.RIGHT&&(a.left=l-P-n.metrics.width))}const c=l-o;if(c>0){const P=(a==null?void 0:a.left)||0,O=s-e.width-n.metrics.width,M=Math.min(O,c);n.left=M-P,e.width+=M-P}}}class js{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}setSelect(t){const{checkbox:e}=t;e?e.value=!e.value:t.checkbox={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:o,row:s}=t;let{y:i}=t;const{checkbox:{gap:l,lineWidth:a,fillStyle:c,strokeStyle:d,checkFillStyle:h,checkStrokeStyle:u,checkMarkColor:g,verticalAlign:T},scale:P}=this.options,{metrics:O,checkbox:M}=s.elementList[o];if(T===R.VerticalAlign.TOP||T===R.VerticalAlign.MIDDLE){let I=o+1,f=null;for(;I<s.elementList.length&&(f=s.elementList[I],!(f.value!==y&&f.value!==we));)I++;if(f){const{metrics:{boundingBoxAscent:F,boundingBoxDescent:V}}=f,Z=F+V;Z>O.height&&(T===R.VerticalAlign.TOP?i-=F-O.height:T===R.VerticalAlign.MIDDLE&&(i-=(Z-O.height)/2))}}const S=Math.round(n+l*P),X=Math.round(i-O.height+a),N=O.width-l*2*P,m=O.height;e.save(),e.beginPath(),e.translate(.5,.5),(M==null?void 0:M.value)?(e.fillStyle=h,e.fillRect(S,X,N,m),e.beginPath(),e.lineWidth=a,e.strokeStyle=u,e.rect(S,X,N,m),e.stroke(),e.beginPath(),e.strokeStyle=g,e.lineWidth=a*2*P,e.moveTo(S+2*P,X+m/2),e.lineTo(S+N/2,X+m-3*P),e.lineTo(S+N-2*P,X+3*P),e.stroke()):(e.fillStyle=c,e.fillRect(S,X,N,m),e.beginPath(),e.lineWidth=a,e.strokeStyle=d,e.rect(S,X,N,m),e.stroke()),e.closePath(),e.restore()}}class qs{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}setSelect(t){const{radio:e}=t;e?e.value=!e.value:t.radio={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:o,row:s}=t;let{y:i}=t;const{radio:{gap:l,lineWidth:a,fillStyle:c,strokeStyle:d,verticalAlign:h},scale:u}=this.options,{metrics:g,radio:T}=s.elementList[o];if(h===R.VerticalAlign.TOP||h===R.VerticalAlign.MIDDLE){let X=o+1,N=null;for(;X<s.elementList.length&&(N=s.elementList[X],!(N.value!==y&&N.value!==we));)X++;if(N){const{metrics:{boundingBoxAscent:m,boundingBoxDescent:I}}=N,f=m+I;f>g.height&&(h===R.VerticalAlign.TOP?i-=m-g.height:h===R.VerticalAlign.MIDDLE&&(i-=(f-g.height)/2))}}const P=Math.round(n+l*u),O=Math.round(i-g.height+a),M=g.width-l*2*u,S=g.height;e.save(),e.beginPath(),e.translate(.5,.5),e.strokeStyle=(T==null?void 0:T.value)?c:d,e.lineWidth=a,e.arc(P+M/2,O+S/2,M/2,0,Math.PI*2),e.stroke(),(T==null?void 0:T.value)&&(e.beginPath(),e.fillStyle=c,e.arc(P+M/2,O+S/2,M/3,0,Math.PI*2),e.fill()),e.closePath(),e.restore()}}const oi="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciB1OyhmdW5jdGlvbihuKXtuLlRFWFQ9InRleHQiLG4uVEFCTEU9InRhYmxlIixuLkhZUEVSTElOSz0iaHlwZXJsaW5rIixuLkNPTlRST0w9ImNvbnRyb2wiLG4uTEFURVg9ImxhdGV4In0pKHV8fCh1PXt9KSk7dmFyIGg7KGZ1bmN0aW9uKG4pe24uVkFMVUU9InZhbHVlIn0pKGh8fChoPXt9KSk7Y29uc3QgcD0iXHUyMDBCIixnPWAKYDtmdW5jdGlvbiBjKG4pe3ZhciBsLGY7bGV0IHM9IiIscj0wO2Zvcig7cjxuLmxlbmd0aDspe2NvbnN0IGU9bltyXTtpZihlLnR5cGU9PT11LlRBQkxFKXtpZihlLnRyTGlzdClmb3IobGV0IG89MDtvPGUudHJMaXN0Lmxlbmd0aDtvKyspe2NvbnN0IGk9ZS50ckxpc3Rbb107Zm9yKGxldCB0PTA7dDxpLnRkTGlzdC5sZW5ndGg7dCsrKXtjb25zdCBhPWkudGRMaXN0W3RdO3MrPWMoYS52YWx1ZSl9fX1lbHNlIGlmKGUudHlwZT09PXUuSFlQRVJMSU5LKXtjb25zdCBvPWUuaHlwZXJsaW5rSWQsaT1bXTtmb3IoO3I8bi5sZW5ndGg7KXtjb25zdCB0PW5bcl07aWYobyE9PXQuaHlwZXJsaW5rSWQpe3ItLTticmVha31kZWxldGUgdC50eXBlLGkucHVzaCh0KSxyKyt9cys9YyhpKX1lbHNlIGlmKGUudHlwZT09PXUuTEFURVgpcys9ZS52YWx1ZTtlbHNlIGlmKGUuY29udHJvbElkKXtpZighKChsPWUuY29udHJvbCk9PW51bGw/dm9pZCAwOmwuaGlkZSkpe2NvbnN0IG89ZS5jb250cm9sSWQsaT1bXTtmb3IoO3I8bi5sZW5ndGg7KXtjb25zdCB0PW5bcl07aWYobyE9PXQuY29udHJvbElkKXtyLS07YnJlYWt9dC5jb250cm9sQ29tcG9uZW50PT09aC5WQUxVRSYmKGRlbGV0ZSB0LmNvbnRyb2xJZCxpLnB1c2godCkpLHIrK31zKz1jKGkpfX1lbHNlKCFlLnR5cGV8fGUudHlwZT09PXUuVEVYVCkmJiEoKGY9ZS5hcmVhKT09bnVsbD92b2lkIDA6Zi5oaWRlKSYmKHMrPWUudmFsdWUpO3IrK31yZXR1cm4gc31mdW5jdGlvbiBMKG4pe2NvbnN0IHM9W107bGV0IHI9IiI7Y29uc3QgbD0oKT0+e3ImJihzLnB1c2gocikscj0iIil9LGY9dD0+dDw9MzJ8fHQ9PT0xNjB8fHQ+PTgxOTImJnQ8PTgyMDJ8fHQ9PT04MjM5fHx0PT09MTIyODh8fHQ+PTgyMDMmJnQ8PTgyMDd8fHQ+PTgyMzQmJnQ8PTgyMzh8fHQ9PT04Mjg4fHx0PT09NjUyNzksZT10PT50Pj00OCYmdDw9NTd8fHQ+PTY1JiZ0PD05MHx8dD49OTcmJnQ8PTEyMixvPXQ9PnQ+PTMzJiZ0PD00N3x8dD49NTgmJnQ8PTY0fHx0Pj05MSYmdDw9OTZ8fHQ+PTEyMyYmdDw9MTI2LGk9dD0+dD09PTEyM3x8dD09PTEyNTtmb3IoY29uc3QgdCBvZiBuKXtjb25zdCBhPXQuY2hhckNvZGVBdCgwKTtpZihmKGEpKXtsKCk7Y29udGludWV9aWYoZShhKXx8aShhKXx8byhhKSl7cis9dDtjb250aW51ZX1sKCkscy5wdXNoKHQpfXJldHVybiBsKCksc31vbm1lc3NhZ2U9bj0+e2NvbnN0IHM9bi5kYXRhLGw9YyhzKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke3B9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChwLCJnIiksZyksZj1MKGwpO3Bvc3RNZXNzYWdlKGYubGVuZ3RoKX19KSgpO30pKCk7Cg==",si=typeof window!="undefined"&&window.Blob&&new Blob([atob(oi)],{type:"text/javascript;charset=utf-8"});function tr(){const r=si&&(window.URL||window.webkitURL).createObjectURL(si);try{return r?new Worker(r):new Worker("data:application/javascript;base64,"+oi,{type:"module"})}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}const ri="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBhOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuSU1BR0U9ImltYWdlIix0LlRBQkxFPSJ0YWJsZSIsdC5IWVBFUkxJTks9Imh5cGVybGluayIsdC5TVVBFUlNDUklQVD0ic3VwZXJzY3JpcHQiLHQuU1VCU0NSSVBUPSJzdWJzY3JpcHQiLHQuU0VQQVJBVE9SPSJzZXBhcmF0b3IiLHQuUEFHRV9CUkVBSz0icGFnZUJyZWFrIix0LkNPTlRST0w9ImNvbnRyb2wiLHQuQ0hFQ0tCT1g9ImNoZWNrYm94Iix0LlJBRElPPSJyYWRpbyIsdC5MQVRFWD0ibGF0ZXgiLHQuVEFCPSJ0YWIiLHQuREFURT0iZGF0ZSIsdC5CTE9DSz0iYmxvY2siLHQuVElUTEU9InRpdGxlIix0LkFSRUE9ImFyZWEiLHQuTElTVD0ibGlzdCIsdC5MQUJFTD0ibGFiZWwifSkoYXx8KGE9e30pKTt2YXIgYzsoZnVuY3Rpb24odCl7dC5GSVJTVD0iZmlyc3QiLHQuU0VDT05EPSJzZWNvbmQiLHQuVEhJUkQ9InRoaXJkIix0LkZPVVJUSD0iZm91cnRoIix0LkZJRlRIPSJmaWZ0aCIsdC5TSVhUSD0ic2l4dGgifSkoY3x8KGM9e30pKTtjb25zdCBkPXtbYy5GSVJTVF06MSxbYy5TRUNPTkRdOjIsW2MuVEhJUkRdOjMsW2MuRk9VUlRIXTo0LFtjLkZJRlRIXTo1LFtjLlNJWFRIXTo2fSxDPVthLlRFWFQsYS5IWVBFUkxJTkssYS5TVUJTQ1JJUFQsYS5TVVBFUlNDUklQVCxhLkNPTlRST0wsYS5EQVRFLGEuTEFCRUxdLFM9Ilx1MjAwQiI7ZnVuY3Rpb24gVCh0KXtyZXR1cm4hdC50eXBlfHxDLmluY2x1ZGVzKHQudHlwZSl9ZnVuY3Rpb24gTih0KXt2YXIgRTtjb25zdHtlbGVtZW50TGlzdDpMLHBvc2l0aW9uTGlzdDpmfT10LGg9W107bGV0IGc9MDtmb3IoO2c8TC5sZW5ndGg7KXtjb25zdCBzPUxbZ10sbD0oZSxvLG4pPT57Y29uc3QgST1lLnRpdGxlSWQsQT1lLmxldmVsLHI9e3R5cGU6YS5USVRMRSx2YWx1ZToiIixsZXZlbDpBLHRpdGxlSWQ6SSxwYWdlTm86ZltnXS5wYWdlTm99LGk9W107Zm9yKDtuPG8ubGVuZ3RoOyl7Y29uc3QgdT1vW25dO2lmKEkhPT11LnRpdGxlSWQpe24tLTticmVha31pLnB1c2godSksbisrfXJldHVybiByLnZhbHVlPWkuZmlsdGVyKHU9PlQodSkpLm1hcCh1PT51LnZhbHVlKS5qb2luKCIiKS5yZXBsYWNlKG5ldyBSZWdFeHAoUywiZyIpLCIiKSx7cG9zaXRpb246bix0aXRsZUVsZW1lbnQ6cn19O2lmKHMudGl0bGVJZCl7Y29uc3R7cG9zaXRpb246ZSx0aXRsZUVsZW1lbnQ6b309bChzLEwsZyk7Zz1lLGgucHVzaChvKX1pZihzLnR5cGU9PT1hLlRBQkxFKXtjb25zdCBlPXMudHJMaXN0O2ZvcihsZXQgbz0wO288ZS5sZW5ndGg7bysrKXtjb25zdCBuPWVbb107Zm9yKGxldCBJPTA7STxuLnRkTGlzdC5sZW5ndGg7SSsrKXtjb25zdCByPW4udGRMaXN0W0ldLnZhbHVlO2lmKHIubGVuZ3RoPjEpe2xldCBpPTE7Zm9yKDtpPHIubGVuZ3RoOyl7aWYoKEU9cltpXSk9PW51bGw/dm9pZCAwOkUudGl0bGVJZCl7Y29uc3R7dGl0bGVFbGVtZW50OnUscG9zaXRpb246T309bChyW2ldLHIsaSk7aC5wdXNoKHUpLGk9T31pKyt9fX19fWcrK31pZighaC5sZW5ndGgpcmV0dXJuIG51bGw7Y29uc3Qgdj0ocyxsKT0+e2NvbnN0IGU9bC5zdWJDYXRhbG9nW2wuc3ViQ2F0YWxvZy5sZW5ndGgtMV0sbz1kW2U9PW51bGw/dm9pZCAwOmUubGV2ZWxdLG49ZFtzLmxldmVsXTtlJiZuPm8/dihzLGUpOmwuc3ViQ2F0YWxvZy5wdXNoKHtpZDpzLnRpdGxlSWQsbmFtZTpzLnZhbHVlLGxldmVsOnMubGV2ZWwscGFnZU5vOnMucGFnZU5vLHN1YkNhdGFsb2c6W119KX0sUj1bXTtmb3IobGV0IHM9MDtzPGgubGVuZ3RoO3MrKyl7Y29uc3QgbD1oW3NdLGU9UltSLmxlbmd0aC0xXSxvPWRbZT09bnVsbD92b2lkIDA6ZS5sZXZlbF0sbj1kW2wubGV2ZWxdO2UmJm4+bz92KGwsZSk6Ui5wdXNoKHtpZDpsLnRpdGxlSWQsbmFtZTpsLnZhbHVlLGxldmVsOmwubGV2ZWwscGFnZU5vOmwucGFnZU5vLHN1YkNhdGFsb2c6W119KX1yZXR1cm4gUn1vbm1lc3NhZ2U9dD0+e2NvbnN0IEw9dC5kYXRhLGY9TihMKTtwb3N0TWVzc2FnZShmKX19KSgpO30pKCk7Cg==",li=typeof window!="undefined"&&window.Blob&&new Blob([atob(ri)],{type:"text/javascript;charset=utf-8"});function er(){const r=li&&(window.URL||window.webkitURL).createObjectURL(li);try{return r?new Worker(r):new Worker("data:application/javascript;base64,"+ri,{type:"module"})}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}const ai="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBuOyhmdW5jdGlvbihvKXtvLlRBQkxFPSJ0YWJsZSJ9KShufHwobj17fSkpO2Z1bmN0aW9uIGMobyl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBvKXtpZihzLnR5cGU9PT1uLlRBQkxFKXtjb25zdCBlPXMudHJMaXN0O2ZvcihsZXQgcj0wO3I8ZS5sZW5ndGg7cisrKXtjb25zdCBpPWVbcl07Zm9yKGxldCB1PTA7dTxpLnRkTGlzdC5sZW5ndGg7dSsrKXtjb25zdCBkPWkudGRMaXN0W3VdO3QucHVzaCguLi5jKGQudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgZSBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMoZSl8fHQucHVzaChlKX1yZXR1cm4gdH1vbm1lc3NhZ2U9bz0+e2NvbnN0IHQ9by5kYXRhLHM9Yyh0KTtwb3N0TWVzc2FnZShzKX19KSgpO30pKCk7Cg==",Ri=typeof window!="undefined"&&window.Blob&&new Blob([atob(ai)],{type:"text/javascript;charset=utf-8"});function nr(){const r=Ri&&(window.URL||window.webkitURL).createObjectURL(Ri);try{return r?new Worker(r):new Worker("data:application/javascript;base64,"+ai,{type:"module"})}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}const ci="KCgpPT57dmFyIEllPU9iamVjdC5kZWZpbmVQcm9wZXJ0eSxBZT1PYmplY3QuZGVmaW5lUHJvcGVydGllczt2YXIgZGU9T2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnM7dmFyIG5lPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHM7dmFyIFJlPU9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHksT2U9T2JqZWN0LnByb3RvdHlwZS5wcm9wZXJ0eUlzRW51bWVyYWJsZTt2YXIgcmU9KFQsSSxkKT0+SSBpbiBUP0llKFQsSSx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6ZH0pOlRbSV09ZCxnPShULEkpPT57Zm9yKHZhciBkIGluIEl8fChJPXt9KSlSZS5jYWxsKEksZCkmJnJlKFQsZCxJW2RdKTtpZihuZSlmb3IodmFyIGQgb2YgbmUoSSkpT2UuY2FsbChJLGQpJiZyZShULGQsSVtkXSk7cmV0dXJuIFR9LFg9KFQsSSk9PkFlKFQsZGUoSSkpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgVDsoZnVuY3Rpb24oZSl7ZS5IQUxGPSJoYWxmIixlLk9ORV9USElSRD0ib25lLXRoaXJkIixlLlFVQVJURVI9InF1YXJ0ZXIifSkoVHx8KFQ9e30pKTt2YXIgSTsoZnVuY3Rpb24oZSl7ZS5BUkFCSUM9ImFyYWJpYyIsZS5DSElORVNFPSJjaGluZXNlIn0pKEl8fChJPXt9KSk7dmFyIGQ7KGZ1bmN0aW9uKGUpe2UuSU5MSU5FPSJpbmxpbmUiLGUuQkxPQ0s9ImJsb2NrIixlLlNVUlJPVU5EPSJzdXJyb3VuZCIsZS5GTE9BVF9UT1A9ImZsb2F0LXRvcCIsZS5GTE9BVF9CT1RUT009ImZsb2F0LWJvdHRvbSJ9KShkfHwoZD17fSkpO3ZhciBfOyhmdW5jdGlvbihlKXtlLkJFRk9SRT0iYmVmb3JlIixlLkFGVEVSPSJhZnRlciIsZS5PVVRFUl9CRUZPUkU9Im91dGVyLWJlZm9yZSIsZS5PVVRFUl9BRlRFUj0ib3V0ZXItYWZ0ZXIifSkoX3x8KF89e30pKTt2YXIgdzsoZnVuY3Rpb24oZSl7ZS5ST1c9InJvdyIsZS5DT0xVTU49ImNvbHVtbiJ9KSh3fHwodz17fSkpO2NvbnN0IFA9Ilx1MjAwQiI7VC5IQUxGKyIiLDEvMixULk9ORV9USElSRCsiIiwxLzMsVC5RVUFSVEVSKyIiLDEvNDtmdW5jdGlvbiBiKGUpe2lmKHR5cGVvZiBzdHJ1Y3R1cmVkQ2xvbmU9PSJmdW5jdGlvbiIpcmV0dXJuIHN0cnVjdHVyZWRDbG9uZShlKTtpZighZXx8dHlwZW9mIGUhPSJvYmplY3QiKXJldHVybiBlO2xldCBjPXt9O3JldHVybiBBcnJheS5pc0FycmF5KGUpP2M9ZS5tYXAoRT0+YihFKSk6T2JqZWN0LmtleXMoZSkuZm9yRWFjaChFPT57Y1tFXT1iKGVbRV0pfSksY31mdW5jdGlvbiBLKGUsYyl7Y29uc3QgRT17fTtmb3IoY29uc3QgQSBpbiBlKWMuaW5jbHVkZXMoQSkmJihFW0FdPWVbQV0pO3JldHVybiBFfWZ1bmN0aW9uIG9lKGUsYyl7cmV0dXJuIGUubGVuZ3RoIT09Yy5sZW5ndGg/ITE6IWUuc29tZShFPT4hYy5pbmNsdWRlcyhFKSl9dmFyIG47KGZ1bmN0aW9uKGUpe2UuVEVYVD0idGV4dCIsZS5JTUFHRT0iaW1hZ2UiLGUuVEFCTEU9InRhYmxlIixlLkhZUEVSTElOSz0iaHlwZXJsaW5rIixlLlNVUEVSU0NSSVBUPSJzdXBlcnNjcmlwdCIsZS5TVUJTQ1JJUFQ9InN1YnNjcmlwdCIsZS5TRVBBUkFUT1I9InNlcGFyYXRvciIsZS5QQUdFX0JSRUFLPSJwYWdlQnJlYWsiLGUuQ09OVFJPTD0iY29udHJvbCIsZS5BUkVBPSJhcmVhIixlLkNIRUNLQk9YPSJjaGVja2JveCIsZS5SQURJTz0icmFkaW8iLGUuTEFURVg9ImxhdGV4IixlLlRBQj0idGFiIixlLkRBVEU9ImRhdGUiLGUuQkxPQ0s9ImJsb2NrIixlLlRJVExFPSJ0aXRsZSIsZS5MSVNUPSJsaXN0IixlLkxBQkVMPSJsYWJlbCJ9KShufHwobj17fSkpO2NvbnN0IGNlPVsicm93RmxleCIsInJvd01hcmdpbiJdLHNlPVsidHlwZSIsImZvbnQiLCJzaXplIiwiYm9sZCIsImNvbG9yIiwiaXRhbGljIiwiaGlnaGxpZ2h0IiwidW5kZXJsaW5lIiwic3RyaWtlb3V0Iiwicm93RmxleCIsInJvd01hcmdpbiIsImRhc2hBcnJheSIsInRyTGlzdCIsInRhYmxlVG9vbERpc2FibGVkIiwiYm9yZGVyVHlwZSIsImJvcmRlckNvbG9yIiwidHJhbnNsYXRlWCIsIndpZHRoIiwiaGVpZ2h0IiwidXJsIiwiY29sZ3JvdXAiLCJ2YWx1ZUxpc3QiLCJjb250cm9sIiwiY2hlY2tib3giLCJyYWRpbyIsImRhdGVGb3JtYXQiLCJibG9jayIsImxldmVsIiwidGl0bGUiLCJsaXN0VHlwZSIsImxpc3RTdHlsZSIsImxpc3RXcmFwIiwiZ3JvdXBJZHMiLCJjb25jZXB0SWQiLCJpbWdEaXNwbGF5IiwiaW1nRmxvYXRQb3NpdGlvbiIsImltZ1Rvb2xEaXNhYmxlZCIsImltZ1ByZXZpZXdEaXNhYmxlZCIsImltZ0Nyb3AiLCJpbWdDYXB0aW9uIiwidGV4dERlY29yYXRpb24iLCJleHRlbnNpb24iLCJleHRlcm5hbElkIiwiYXJlYUlkIiwiYXJlYSIsImhpZGUiLCJsYWJlbCIsImxhYmVsSWQiLCJsaW5lV2lkdGgiXSxmZT1bImNvbmNlcHRJZCIsImV4dGVuc2lvbiIsImV4dGVybmFsSWQiLCJ2ZXJ0aWNhbEFsaWduIiwiYmFja2dyb3VuZENvbG9yIiwiYm9yZGVyVHlwZXMiLCJzbGFzaFR5cGVzIiwiZGlzYWJsZWQiLCJkZWxldGFibGUiXSxFZT1bImZvbnQiLCJzaXplIiwiYm9sZCIsImhpZ2hsaWdodCIsIml0YWxpYyIsInN0cmlrZW91dCJdO24uVEVYVCxuLkhZUEVSTElOSyxuLlNVQlNDUklQVCxuLlNVUEVSU0NSSVBULG4uQ09OVFJPTCxuLkRBVEUsbi5JTUFHRSxuLkxBVEVYLG4uQkxPQ0ssbi5QQUdFX0JSRUFLLG4uU0VQQVJBVE9SLG4uVEFCTEUsbi5USVRMRSxuLkxJU1Q7dmFyIE47KGZ1bmN0aW9uKGUpe2UuVUw9InVsIixlLk9MPSJvbCJ9KShOfHwoTj17fSkpO3ZhciBPOyhmdW5jdGlvbihlKXtlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuQ0hFQ0tCT1g9ImNoZWNrYm94In0pKE98fChPPXt9KSk7dmFyIEg7KGZ1bmN0aW9uKGUpe2UuREVDSU1BTD0iZGVjaW1hbCJ9KShIfHwoSD17fSkpO3ZhciB2OyhmdW5jdGlvbihlKXtlW2UuRElTQz1PLkRJU0NdPSJESVNDIixlW2UuQ0lSQ0xFPU8uQ0lSQ0xFXT0iQ0lSQ0xFIixlW2UuU1FVQVJFPU8uU1FVQVJFXT0iU1FVQVJFIixlW2UuREVDSU1BTD1ILkRFQ0lNQUxdPSJERUNJTUFMIixlW2UuQ0hFQ0tCT1g9Ty5DSEVDS0JPWF09IkNIRUNLQk9YIn0pKHZ8fCh2PXt9KSksTy5ESVNDKyIiLE8uQ0lSQ0xFKyIiLE8uU1FVQVJFKyIiLE8uQ0hFQ0tCT1grIiIsTi5PTCsiIixOLlVMKyIiLHYuRElTQysiIix2LkNJUkNMRSsiIix2LlNRVUFSRSsiIix2LkRFQ0lNQUwrIiIsdi5DSEVDS0JPWCsiIjt2YXIgdTsoZnVuY3Rpb24oZSl7ZS5GSVJTVD0iZmlyc3QiLGUuU0VDT05EPSJzZWNvbmQiLGUuVEhJUkQ9InRoaXJkIixlLkZPVVJUSD0iZm91cnRoIixlLkZJRlRIPSJmaWZ0aCIsZS5TSVhUSD0ic2l4dGgifSkodXx8KHU9e30pKSx1LkZJUlNUKyIiLHUuU0VDT05EKyIiLHUuVEhJUkQrIiIsdS5GT1VSVEgrIiIsdS5GSUZUSCsiIix1LlNJWFRIKyIiLHUuRklSU1QrIiIsdS5TRUNPTkQrIiIsdS5USElSRCsiIix1LkZPVVJUSCsiIix1LkZJRlRIKyIiLHUuU0lYVEgrIiIsdS5GSVJTVCx1LlNFQ09ORCx1LlRISVJELHUuRk9VUlRILHUuRklGVEgsdS5TSVhUSDt2YXIgRzsoZnVuY3Rpb24oZSl7ZS5JRlJBTUU9ImlmcmFtZSIsZS5WSURFTz0idmlkZW8ifSkoR3x8KEc9e30pKTt2YXIgejsoZnVuY3Rpb24oZSl7ZS5URVhUPSJ0ZXh0IixlLlNFTEVDVD0ic2VsZWN0IixlLkNIRUNLQk9YPSJjaGVja2JveCIsZS5SQURJTz0icmFkaW8iLGUuREFURT0iZGF0ZSIsZS5OVU1CRVI9Im51bWJlciJ9KSh6fHwoej17fSkpO3ZhciBDOyhmdW5jdGlvbihlKXtlLlBSRUZJWD0icHJlZml4IixlLlBPU1RGSVg9InBvc3RmaXgiLGUuUFJFX1RFWFQ9InByZVRleHQiLGUuUE9TVF9URVhUPSJwb3N0VGV4dCIsZS5QTEFDRUhPTERFUj0icGxhY2Vob2xkZXIiLGUuVkFMVUU9InZhbHVlIixlLkNIRUNLQk9YPSJjaGVja2JveCIsZS5SQURJTz0icmFkaW8ifSkoQ3x8KEM9e30pKTt2YXIgWTsoZnVuY3Rpb24oZSl7ZS5ST1dfU1RBUlQ9InJvd1N0YXJ0IixlLlZBTFVFX1NUQVJUPSJ2YWx1ZVN0YXJ0In0pKFl8fChZPXt9KSk7dmFyIFY7KGZ1bmN0aW9uKGUpe2UuQUNUSVZFPSJhY3RpdmUiLGUuSU5BQ1RJVkU9ImluYWN0aXZlIn0pKFZ8fChWPXt9KSk7dmFyIFE7KGZ1bmN0aW9uKGUpe2UuTlVNQkVSPSJudW1iZXIiLGUuT1BFUkFUT1I9Im9wZXJhdG9yIixlLlVUSUxJVFk9InV0aWxpdHkiLGUuRVFVQUw9ImVxdWFsIn0pKFF8fChRPXt9KSk7dmFyIFc7KGZ1bmN0aW9uKGUpe2UuQ09NUE9ORU5UPSJjb21wb25lbnQiLGUuTUVOVT0ibWVudSIsZS5NQUlOPSJtYWluIixlLkZPT1RFUj0iZm9vdGVyIixlLkNPTlRFWFRNRU5VPSJjb250ZXh0bWVudSIsZS5QT1BVUD0icG9wdXAiLGUuQ0FUQUxPRz0iY2F0YWxvZyIsZS5DT01NRU5UPSJjb21tZW50In0pKFd8fChXPXt9KSk7dmFyIHE7KGZ1bmN0aW9uKGUpe2UuUEFHRT0icGFnZSIsZS5UQUJMRT0idGFibGUifSkocXx8KHE9e30pKTt2YXIgWjsoZnVuY3Rpb24oZSl7ZS5FRElUPSJlZGl0IixlLkNMRUFOPSJjbGVhbiIsZS5SRUFET05MWT0icmVhZG9ubHkiLGUuRk9STT0iZm9ybSIsZS5QUklOVD0icHJpbnQiLGUuREVTSUdOPSJkZXNpZ24iLGUuR1JBRkZJVEk9ImdyYWZmaXRpIn0pKFp8fChaPXt9KSk7dmFyIEo7KGZ1bmN0aW9uKGUpe2UuSEVBREVSPSJoZWFkZXIiLGUuTUFJTj0ibWFpbiIsZS5GT09URVI9ImZvb3RlciJ9KShKfHwoSj17fSkpO3ZhciBqOyhmdW5jdGlvbihlKXtlLlBBR0lORz0icGFnaW5nIixlLkNPTlRJTlVJVFk9ImNvbnRpbnVpdHkifSkoanx8KGo9e30pKTt2YXIgJDsoZnVuY3Rpb24oZSl7ZS5WRVJUSUNBTD0idmVydGljYWwiLGUuSE9SSVpPTlRBTD0iaG9yaXpvbnRhbCJ9KSgkfHwoJD17fSkpO3ZhciBlZTsoZnVuY3Rpb24oZSl7ZS5CUkVBS19BTEw9ImJyZWFrLWFsbCIsZS5CUkVBS19XT1JEPSJicmVhay13b3JkIn0pKGVlfHwoZWU9e30pKTt2YXIgdGU7KGZ1bmN0aW9uKGUpe2UuU1BFRUQ9InNwZWVkIixlLkNPTVBBVElCSUxJVFk9ImNvbXBhdGliaWxpdHkifSkodGV8fCh0ZT17fSkpO3ZhciBEOyhmdW5jdGlvbihlKXtlLkxFRlQ9ImxlZnQiLGUuQ0VOVEVSPSJjZW50ZXIiLGUuUklHSFQ9InJpZ2h0IixlLkFMSUdOTUVOVD0iYWxpZ25tZW50IixlLkpVU1RJRlk9Imp1c3RpZnkifSkoRHx8KEQ9e30pKTt2YXIgaWU7KGZ1bmN0aW9uKGUpe2UuQUxMPSJhbGwiLGUuRU1QVFk9ImVtcHR5IixlLkVYVEVSTkFMPSJleHRlcm5hbCIsZS5JTlRFUk5BTD0iaW50ZXJuYWwiLGUuREFTSD0iZGFzaCJ9KShpZXx8KGllPXt9KSk7dmFyIGFlOyhmdW5jdGlvbihlKXtlLlRPUD0idG9wIixlLlJJR0hUPSJyaWdodCIsZS5CT1RUT009ImJvdHRvbSIsZS5MRUZUPSJsZWZ0In0pKGFlfHwoYWU9e30pKTt2YXIgbGU7KGZ1bmN0aW9uKGUpe2UuRk9SV0FSRD0iZm9yd2FyZCIsZS5CQUNLPSJiYWNrIn0pKGxlfHwobGU9e30pKTt2YXIgazsoZnVuY3Rpb24oZSl7ZS5DT05UQUlOPSJjb250YWluIixlLkNPVkVSPSJjb3ZlciJ9KShrfHwoaz17fSkpO3ZhciBtOyhmdW5jdGlvbihlKXtlLlJFUEVBVD0icmVwZWF0IixlLk5PX1JFUEVBVD0ibm8tcmVwZWF0IixlLlJFUEVBVF9YPSJyZXBlYXQteCIsZS5SRVBFQVRfWT0icmVwZWF0LXkifSkobXx8KG09e30pKSxrLkNPVkVSLG0uTk9fUkVQRUFUO3ZhciBGOyhmdW5jdGlvbihlKXtlLlRPUD0idG9wIixlLk1JRERMRT0ibWlkZGxlIixlLkJPVFRPTT0iYm90dG9tIn0pKEZ8fChGPXt9KSksRi5CT1RUT00sVC5IQUxGLFQuSEFMRjtjb25zdCB1ZT17UEFHRV9OTzoie3BhZ2VOb30iLFBBR0VfQ09VTlQ6IntwYWdlQ291bnR9In07RC5DRU5URVIsdWUuUEFHRV9OTyxJLkFSQUJJQyxGLkJPVFRPTTt2YXIgeTsoZnVuY3Rpb24oZSl7ZS5URVhUPSJ0ZXh0IixlLklNQUdFPSJpbWFnZSJ9KSh5fHwoeT17fSkpO3ZhciBVOyhmdW5jdGlvbihlKXtlLkJPVFRPTT0iYm90dG9tIixlLlRPUD0idG9wIn0pKFV8fChVPXt9KSkseS5URVhULEkuQVJBQklDLFUuQk9UVE9NO3ZhciBCOyhmdW5jdGlvbihlKXtlLlBBR0U9InBhZ2UiLGUuQ09OVElOVUlUWT0iY29udGludWl0eSJ9KShCfHwoQj17fSkpLEIuQ09OVElOVUlUWTtmdW5jdGlvbiBUZShlLGMpe2NvbnN0IEU9T2JqZWN0LmtleXMoZSksQT1PYmplY3Qua2V5cyhjKTtpZihFLmxlbmd0aCE9PUEubGVuZ3RoKXJldHVybiExO2ZvcihsZXQgUj0wO1I8RS5sZW5ndGg7UisrKXtjb25zdCBhPUVbUl07aWYoYSE9PSJ2YWx1ZSImJiEoYT09PSJncm91cElkcyImJkFycmF5LmlzQXJyYXkoZVthXSkmJkFycmF5LmlzQXJyYXkoY1thXSkmJm9lKGVbYV0sY1thXSkpJiZlW2FdIT09Y1thXSlyZXR1cm4hMX1yZXR1cm4hMH1mdW5jdGlvbiB4KGUsYz17fSl7Y29uc3R7ZXh0cmFQaWNrQXR0cnM6RX09YyxBPVsuLi5zZV07RSYmQS5wdXNoKC4uLkUpO2NvbnN0IFI9e3ZhbHVlOmUudmFsdWU9PT1QP2AKYDplLnZhbHVlfTtyZXR1cm4gQS5mb3JFYWNoKGE9Pntjb25zdCBwPWVbYV07cCE9PXZvaWQgMCYmKFJbYV09cCl9KSxSfWZ1bmN0aW9uIGgoZSxjPXt9KXtjb25zdHtleHRyYVBpY2tBdHRyczpFLGlzQ2xhc3NpZnlBcmVhOkE9ITEsaXNDbG9uZTpSPSEwfT1jLGE9Uj9iKGUpOmUscD1bXTtsZXQgaT0wO2Zvcig7aTxhLmxlbmd0aDspe2xldCB0PWFbaV07aWYoaT09PTAmJnQudmFsdWU9PT1QJiYhdC5saXN0SWQmJighdC50eXBlfHx0LnR5cGU9PT1uLlRFWFQpKXtpKys7Y29udGludWV9aWYodC5hcmVhSWQpe2NvbnN0IGw9dC5hcmVhSWQsZj10LmFyZWEscz1bXTtmb3IoO2k8YS5sZW5ndGg7KXtjb25zdCBvPWFbaV07aWYobCE9PW8uYXJlYUlkKXtpLS07YnJlYWt9ZGVsZXRlIG8uYXJlYSxkZWxldGUgby5hcmVhSWQscy5wdXNoKG8pLGkrK31jb25zdCByPWgocyxjKTtpZihBKXtjb25zdCBvPXt0eXBlOm4uQVJFQSx2YWx1ZToiIixhcmVhSWQ6bCxhcmVhOmZ9O28udmFsdWVMaXN0PXIsdD1vfWVsc2V7cC5zcGxpY2UoaSwwLC4uLnIpO2NvbnRpbnVlfX1lbHNlIGlmKHQudGl0bGVJZCYmdC5sZXZlbCl7Y29uc3QgbD10LnRpdGxlSWQ7aWYobCl7Y29uc3QgZj10LmxldmVsLHM9e3R5cGU6bi5USVRMRSx0aXRsZTp0LnRpdGxlLHRpdGxlSWQ6bCx2YWx1ZToiIixsZXZlbDpmfSxyPVtdO2Zvcig7aTxhLmxlbmd0aDspe2NvbnN0IG89YVtpXTtpZihsIT09by50aXRsZUlkKXtpLS07YnJlYWt9ZGVsZXRlIG8ubGV2ZWwsZGVsZXRlIG8udGl0bGUsci5wdXNoKG8pLGkrK31zLnZhbHVlTGlzdD1oKHIsYyksdD1zfX1lbHNlIGlmKHQubGlzdElkJiZ0Lmxpc3RUeXBlKXtjb25zdCBsPXQubGlzdElkO2lmKGwpe2NvbnN0IGY9dC5saXN0VHlwZSxzPXQubGlzdFN0eWxlLHI9e3R5cGU6bi5MSVNULHZhbHVlOiIiLGxpc3RJZDpsLGxpc3RUeXBlOmYsbGlzdFN0eWxlOnN9LG89W107Zm9yKDtpPGEubGVuZ3RoOyl7Y29uc3QgTD1hW2ldO2lmKGwhPT1MLmxpc3RJZCl7aS0tO2JyZWFrfWRlbGV0ZSBMLmxpc3RUeXBlLGRlbGV0ZSBMLmxpc3RTdHlsZSxvLnB1c2goTCksaSsrfXIudmFsdWVMaXN0PWgobyxjKSx0PXJ9fWVsc2UgaWYodC50eXBlPT09bi5UQUJMRSl7aWYodC5wYWdpbmdJZCl7bGV0IGw9aSsxLGY9MDtmb3IoO2w8YS5sZW5ndGg7KXtjb25zdCBzPWFbbF07aWYocy5wYWdpbmdJZD09PXQucGFnaW5nSWQpdC5oZWlnaHQrPXMuaGVpZ2h0LHQudHJMaXN0LnB1c2goLi4ucy50ckxpc3QpLGwrKyxmKys7ZWxzZSBicmVha31pKz1mfWlmKHQudHJMaXN0KWZvcihsZXQgbD0wO2w8dC50ckxpc3QubGVuZ3RoO2wrKyl7Y29uc3QgZj10LnRyTGlzdFtsXTtkZWxldGUgZi5pZDtmb3IobGV0IHM9MDtzPGYudGRMaXN0Lmxlbmd0aDtzKyspe2NvbnN0IHI9Zi50ZExpc3Rbc10sbz17Y29sc3BhbjpyLmNvbHNwYW4scm93c3BhbjpyLnJvd3NwYW4sdmFsdWU6aChyLnZhbHVlLFgoZyh7fSxjKSx7aXNDbGFzc2lmeUFyZWE6ITF9KSl9O2ZlLmZvckVhY2goTD0+e2NvbnN0IFM9cltMXTtTIT09dm9pZCAwJiYob1tMXT1TKX0pLGYudGRMaXN0W3NdPW99fX1lbHNlIGlmKHQudHlwZT09PW4uSFlQRVJMSU5LKXtjb25zdCBsPXQuaHlwZXJsaW5rSWQ7aWYobCl7Y29uc3QgZj17dHlwZTpuLkhZUEVSTElOSyx2YWx1ZToiIix1cmw6dC51cmx9LHM9W107Zm9yKDtpPGEubGVuZ3RoOyl7Y29uc3Qgcj1hW2ldO2lmKGwhPT1yLmh5cGVybGlua0lkKXtpLS07YnJlYWt9ZGVsZXRlIHIudHlwZSxkZWxldGUgci51cmwscy5wdXNoKHIpLGkrK31mLnZhbHVlTGlzdD1oKHMsYyksdD1mfX1lbHNlIGlmKHQudHlwZT09PW4uREFURSl7Y29uc3QgbD10LmRhdGVJZDtpZihsKXtjb25zdCBmPXt0eXBlOm4uREFURSx2YWx1ZToiIixkYXRlRm9ybWF0OnQuZGF0ZUZvcm1hdH0scz1bXTtmb3IoO2k8YS5sZW5ndGg7KXtjb25zdCByPWFbaV07aWYobCE9PXIuZGF0ZUlkKXtpLS07YnJlYWt9ZGVsZXRlIHIudHlwZSxkZWxldGUgci5kYXRlRm9ybWF0LHMucHVzaChyKSxpKyt9Zi52YWx1ZUxpc3Q9aChzLGMpLHQ9Zn19ZWxzZSBpZih0LmNvbnRyb2xJZCl7Y29uc3QgbD10LmNvbnRyb2xJZDtpZih0LmNvbnRyb2xDb21wb25lbnQ9PT1DLlBSRUZJWCl7Y29uc3QgZj1bXTtsZXQgcz0hMSxyPWk7Zm9yKDtyPGEubGVuZ3RoOyl7Y29uc3Qgbz1hW3JdO2lmKGwhPT1vLmNvbnRyb2xJZClicmVhaztvLmNvbnRyb2xDb21wb25lbnQ9PT1DLlZBTFVFJiYoZGVsZXRlIG8uY29udHJvbCxkZWxldGUgby5jb250cm9sSWQsZi5wdXNoKG8pKSxvLmNvbnRyb2xDb21wb25lbnQ9PT1DLlBPU1RGSVgmJihzPSEwKSxyKyt9aWYocyl7Y29uc3Qgbz1LKHQsRWUpLEw9ZyhnKHt9LHQuY29udHJvbCksbyksUz1YKGcoe30sSyh0LGNlKSkse3R5cGU6bi5DT05UUk9MLHZhbHVlOiIiLGNvbnRyb2w6TCxjb250cm9sSWQ6bH0pO1MuY29udHJvbC52YWx1ZT1oKGYsYyksdD14KFMse2V4dHJhUGlja0F0dHJzOkV9KSxpKz1yLWktMX19aWYodC5jb250cm9sQ29tcG9uZW50JiYoZGVsZXRlIHQuY29udHJvbCxkZWxldGUgdC5jb250cm9sSWQsdC5jb250cm9sQ29tcG9uZW50IT09Qy5WQUxVRSYmdC5jb250cm9sQ29tcG9uZW50IT09Qy5QUkVfVEVYVCYmdC5jb250cm9sQ29tcG9uZW50IT09Qy5QT1NUX1RFWFQpKXtpKys7Y29udGludWV9fWNvbnN0IE09eCh0LHtleHRyYVBpY2tBdHRyczpFfSk7aWYoIXQudHlwZXx8dC50eXBlPT09bi5URVhUfHx0LnR5cGU9PT1uLlNVQlNDUklQVHx8dC50eXBlPT09bi5TVVBFUlNDUklQVClmb3IoO2k8YS5sZW5ndGg7KXtjb25zdCBsPWFbaSsxXTtpZihpKyssbCYmVGUoTSx4KGwse2V4dHJhUGlja0F0dHJzOkV9KSkpe2NvbnN0IGY9bC52YWx1ZT09PVA/YApgOmwudmFsdWU7TS52YWx1ZSs9Zn1lbHNlIGJyZWFrfWVsc2UgaSsrO3AucHVzaChNKX1yZXR1cm4gcH1vbm1lc3NhZ2U9ZT0+e2NvbnN0IGM9ZS5kYXRhLHtvcHRpb25zOkUsZGF0YTpBfT1jLHtleHRyYVBpY2tBdHRyczpSPVtdfT1FfHx7fSxhPXtoZWFkZXI6aChBLmhlYWRlcix7ZXh0cmFQaWNrQXR0cnM6Uixpc0Nsb25lOiExfSksbWFpbjpoKEEubWFpbix7ZXh0cmFQaWNrQXR0cnM6Uixpc0NsYXNzaWZ5QXJlYTohMCxpc0Nsb25lOiExfSksZm9vdGVyOmgoQS5mb290ZXIse2V4dHJhUGlja0F0dHJzOlIsaXNDbG9uZTohMX0pfTtwb3N0TWVzc2FnZShhKX19KSgpO30pKCk7Cg==",di=typeof window!="undefined"&&window.Blob&&new Blob([atob(ci)],{type:"text/javascript;charset=utf-8"});function ir(){const r=di&&(window.URL||window.webkitURL).createObjectURL(di);try{return r?new Worker(r):new Worker("data:application/javascript;base64,"+ci,{type:"module"})}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}class or{constructor(t){L(this,"draw");L(this,"wordCountWorker");L(this,"catalogWorker");L(this,"groupWorker");L(this,"valueWorker");this.draw=t,this.wordCountWorker=new tr,this.catalogWorker=new er,this.groupWorker=new nr,this.valueWorker=new ir}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=o=>{t(o.data)},this.wordCountWorker.onerror=o=>{e(o)};const n=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(n)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=s=>{t(s.data)},this.catalogWorker.onerror=s=>{e(s)};const n=this.draw.getOriginalMainElementList(),o=this.draw.getPosition().getOriginalMainPositionList();this.catalogWorker.postMessage({elementList:n,positionList:o})})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=o=>{t(o.data)},this.groupWorker.onerror=o=>{e(o)};const n=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(n)})}getValue(t){return new Promise((e,n)=>{this.valueWorker.onmessage=o=>{e({version:Xt,data:o.data,options:$(this.draw.getOptions())})},this.valueWorker.onerror=o=>{n(o)},this.valueWorker.postMessage({data:this.draw.getOriginValue(t),options:t})})}destroy(){this.wordCountWorker.terminate(),this.catalogWorker.terminate(),this.groupWorker.terminate(),this.valueWorker.terminate()}}class sr{constructor(t){L(this,"container");L(this,"canvas");L(this,"draw");L(this,"options");L(this,"curElement");L(this,"curElementSrc");L(this,"previewerDrawOption");L(this,"curPosition");L(this,"eventBus");L(this,"imageList");L(this,"curShowElement");L(this,"imageCount");L(this,"imagePre");L(this,"imageNext");L(this,"resizerSelection");L(this,"resizerHandleList");L(this,"resizerImageContainer");L(this,"resizerImage");L(this,"resizerSize");L(this,"width");L(this,"height");L(this,"mousedownX");L(this,"mousedownY");L(this,"curHandleIndex");L(this,"previewerContainer");L(this,"previewerImage");L(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:o,resizerImage:s,resizerSize:i}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=n,this.resizerImageContainer=o,this.resizerImage=s,this.resizerSize=i,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 o=0,s=0;const i=this.draw.getHeight(),l=this.draw.getPageGap(),c=((d=e==null?void 0:e.pageNo)!=null?d:this.draw.getPageNo())*(i+l);if(t.imgFloatPosition)o=t.imgFloatPosition.x*n,s=t.imgFloatPosition.y*n+c;else if(e){const{coordinate:{leftTop:[h,u]},ascent:g}=e;o=h,s=u+c+g}return{x:o,y:s}}_createResizerDom(){const{scale:t}=this.options,e=document.createElement("div");e.classList.add(`${v}-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 c=document.createElement("div");c.style.background=this.options.resizerColor,c.classList.add("resizer-handle"),c.classList.add(`handle-${a}`),c.setAttribute("data-index",String(a)),c.onmousedown=this._mousedown.bind(this),e.append(c),n.push(c)}this.container.append(e);const o=document.createElement("div");o.classList.add(`${v}-resizer-size-view`);const s=document.createElement("span");o.append(s),e.append(o);const i=document.createElement("div");i.classList.add(`${v}-resizer-image`),i.style.display="none";const l=document.createElement("img");return i.append(l),this.container.append(i),{resizerSelection:e,resizerHandleList:n,resizerImageContainer:i,resizerImage:l,resizerSize:s}}_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 o=window.getComputedStyle(n).cursor;document.body.style.cursor=o,this.canvas.style.cursor=o,this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{x:s,y:i}=this._getElementPosition(this.curElement,this.curPosition);this.resizerImageContainer.style.left=`${s}px`,this.resizerImageContainer.style.top=`${i}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.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,o=0;switch(this.curHandleIndex){case 0:{const c=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(c**3+d**3),o=this.curElement.height*n/this.curElement.width}break;case 1:o=this.mousedownY-t.y;break;case 2:{const c=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(c**3+d**3),o=this.curElement.height*n/this.curElement.width}break;case 4:{const c=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(c**3+d**3),o=this.curElement.height*n/this.curElement.width}break;case 3:n=t.x-this.mousedownX;break;case 5:o=t.y-this.mousedownY;break;case 6:{const c=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(c**3+d**3),o=this.curElement.height*n/this.curElement.width}break;case 7:n=this.mousedownX-t.x;break}const s=this.curElement.width+n/e,i=this.curElement.height+o/e;if(s<=0||i<=0)return;this.width=s,this.height=i;const l=s*e,a=i*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(`${v}-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(`${v}-image-container`);const o=document.createElement("img");o.src=this.curElementSrc,o.draggable=!1,n.append(o),this.previewerImage=o,t.append(n);let s=0,i=0,l=1,a=0;const c=document.createElement("div");c.classList.add(`${v}-image-menu`);const d=document.createElement("div");d.classList.add("image-navigate");const h=document.createElement("i");h.classList.add("image-pre"),h.onclick=()=>{const I=this.imageList.findIndex(f=>{var F;return f.id===((F=this.curShowElement)==null?void 0:F.id)});I<=0||(this.curShowElement=this.imageList[I-1],o.src=this.curShowElement.value,this._updateImageNavigate())},d.append(h),this.imagePre=h;const u=document.createElement("span");u.classList.add("image-count"),this.imageCount=u,d.append(u);const g=document.createElement("i");g.classList.add("image-next"),g.onclick=()=>{const I=this.imageList.findIndex(f=>{var F;return f.id===((F=this.curShowElement)==null?void 0:F.id)});I>=this.imageList.length-1||(this.curShowElement=this.imageList[I+1],o.src=this.curShowElement.value,this._updateImageNavigate())},this.imageNext=g,d.append(g),c.append(d);const T=document.createElement("i");T.classList.add("zoom-in"),T.onclick=()=>{l+=.1,this._setPreviewerTransform(l,a,s,i)},c.append(T);const P=document.createElement("i");P.onclick=()=>{l-.1<=.1||(l-=.1,this._setPreviewerTransform(l,a,s,i))},P.classList.add("zoom-out"),c.append(P);const O=document.createElement("i");O.classList.add("rotate"),O.onclick=()=>{a+=1,this._setPreviewerTransform(l,a,s,i)},c.append(O);const M=document.createElement("i");M.classList.add("original-size"),M.onclick=()=>{s=0,i=0,l=1,a=0,this._setPreviewerTransform(l,a,s,i)},c.append(M);const S=document.createElement("i");S.classList.add("image-download"),S.onclick=()=>{var f;const{mime:I}=this.previewerDrawOption;Nn(o.src,`${(f=this.curElement)==null?void 0:f.id}.${I||"png"}`)},c.append(S),t.append(c),this.previewerContainer=t,document.body.append(t);let X=0,N=0,m=!1;o.onmousedown=I=>{m=!0,X=I.x,N=I.y,t.style.cursor="move"},t.onmousemove=I=>{!m||(s+=I.x-X,i+=I.y-N,X=I.x,N=I.y,this._setPreviewerTransform(l,a,s,i))},t.onmouseup=()=>{m=!1,t.style.cursor="auto"},t.onwheel=I=>{if(I.preventDefault(),I.stopPropagation(),I.deltaY<0)l+=.1;else{if(l-.1<=.1)return;l-=.1}this._setPreviewerTransform(l,a,s,i)},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,o){!this.previewerImage||(this.previewerImage.style.left=`${n}px`,this.previewerImage.style.top=`${o}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:o}=this.options,s=this.draw.isReadonly();this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let i=0;i<8;i++){const l=i===0||i===6||i===7?-n:i===1||i===5?t/2:t-n,a=i===0||i===1||i===2?-n:i===3||i===7?e/2-n:e-n;this.resizerHandleList[i].style.transform=`scale(${o})`,this.resizerHandleList[i].style.left=`${l}px`,this.resizerHandleList[i].style.top=`${a}px`,this.resizerHandleList[i].style.display=s?"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===R.EditorMode.PRINT&&((e=this.options.modeRule[R.EditorMode.PRINT])==null?void 0:e.imagePreviewerDisabled)||t===R.EditorMode.READONLY&&((n=this.options.modeRule[R.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 s,i;const o=this.draw.getMode();t.imgToolDisabled&&!this.draw.isDesignMode()||o===R.EditorMode.PRINT&&((s=this.options.modeRule[R.EditorMode.PRINT])==null?void 0:s.imagePreviewerDisabled)||o===R.EditorMode.READONLY&&((i=this.options.modeRule[R.EditorMode.READONLY])==null?void 0:i.imagePreviewerDisabled)||(this.previewerDrawOption=n,this.curElementSrc=t[n.srcKey||"value"]||"",this.updateResizer(t,e),document.addEventListener("keydown",this._keydown))}updateResizer(t,e=null){const{scale:n}=this.options,o=t.width*n,s=t.height*n;this._updateResizerSizeView(o,s);const{x:i,y:l}=this._getElementPosition(t,e);this.resizerSelection.style.left=`${i}px`,this.resizerSelection.style.top=`${l}px`,this.resizerSelection.style.borderWidth=`${n}px`,this._updateResizerRect(o,s),this.resizerSelection.style.display="block",this.curElement=t,this.curPosition=e,this.width=o,this.height=s}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}class rr{constructor(t){L(this,"draw");L(this,"range");L(this,"datePicker");L(this,"options");this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.datePicker=new ii(t,{onSubmit:this._setValue.bind(this)})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[n,o]=e,s=this.draw.getElementList(),i=s[n+1];this.draw.spliceElementList(s,n+1,o-n),this.range.setRange(n,n);const l={type:R.ElementType.DATE,value:"",dateFormat:i.dateFormat,valueList:[{value:t}]};It(s,[l],n,{editorOptions:this.options}),this.draw.insertElementList([l])}getDateElementRange(){let t=-1,e=-1;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return null;const s=this.draw.getElementList(),i=s[n];if(i.type!==R.ElementType.DATE)return null;let l=n;for(;l>=0;){if(s[l].dateId!==i.dateId){t=l;break}l--}let a=n+1;for(;a<s.length;){if(s[a].dateId!==i.dateId){e=a-1;break}a++}return a===s.length&&(e=a-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const n=this.draw.getElementList(),o=this.getDateElementRange(),s=o?n.slice(o[0]+1,o[1]+1).map(i=>i.value).join(""):"";this.datePicker.render({value:s,position:e,dateFormat:t.dateFormat})}}class hi{constructor(t){L(this,"element");L(this,"videoCache");this.element=t,this.videoCache=new Map}snapshot(t,e,n){return new Promise((o,s)=>{var l,a;const i=((a=(l=this.element.block)==null?void 0:l.videoBlock)==null?void 0:a.src)||"";if(this.videoCache.has(i)){const c=this.videoCache.get(i);t.drawImage(c,e,n,this.element.metrics.width,this.element.metrics.height),o(this.element)}else{const c=document.createElement("video");c.src=i,c.muted=!0,c.crossOrigin="anonymous",c.onloadeddata=()=>{t.drawImage(c,e,n,this.element.metrics.width,this.element.metrics.height),this.videoCache.set(i,c),o(this.element)},c.onerror=d=>{s(d)},c.play().then(()=>{c.pause()})}})}render(t){var o;const e=this.element.block,n=document.createElement("video");n.style.width="100%",n.style.height="100%",n.style.objectFit="contain",n.src=((o=e.videoBlock)==null?void 0:o.src)||"",n.controls=!0,t.append(n)}}class lr{constructor(t,e){L(this,"draw");L(this,"options");L(this,"element");L(this,"block");L(this,"blockContainer");L(this,"blockItem");L(this,"positionInfo",null);L(this,"blockCache");L(this,"resizerMask");L(this,"resizerSelection");L(this,"resizerHandleList");L(this,"width");L(this,"height");L(this,"mousedownX");L(this,"mousedownY");L(this,"curHandleIndex");L(this,"isAllowResize");this.draw=t.getDraw(),this.options=this.draw.getOptions(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null;const{blockItem:n,resizerMask:o,resizerSelection:s,resizerHandleList:i}=this._createBlockItem();this.blockItem=n,this.blockContainer.append(this.blockItem),this.blockCache=new Map,this.resizerMask=o,this.resizerSelection=s,this.resizerHandleList=i,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}getIFrameBlock(){return this.block instanceof zt?this.block:null}getPositionInfo(){return this.positionInfo}_createBlockItem(){const{scale:t,resizerColor:e}=this.options,n=document.createElement("div");n.classList.add(`${v}-block-item`);const o=document.createElement("div");o.style.display="none",o.classList.add(`${v}-resizer-selection`),o.style.borderColor=e,o.style.borderWidth=`${t}px`;const s=[];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),o.append(a),s.push(a)}const i=document.createElement("div");return i.classList.add(`${v}-resizer-mask`),i.style.display="none",n.append(i),n.onmouseenter=()=>{if(this.draw.isReadonly())return;const{width:a,height:c}=this.element.metrics;this._updateResizerRect(a,c),o.style.display="block"},n.onmouseleave=()=>{this.isAllowResize||(o.style.display="none")},n.append(o),{blockItem:n,resizerMask:i,resizerSelection:o,resizerHandleList:s}}_updateResizerRect(t,e){const{resizerSize:n,scale:o}=this.options;this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let s=0;s<8;s++){const i=s===0||s===6||s===7?-n:s===1||s===5?t/2:t-n,l=s===0||s===1||s===2?-n:s===3||s===7?e/2-n:e-n;this.resizerHandleList[s].style.transform=`scale(${o})`,this.resizerHandleList[s].style.left=`${i}px`,this.resizerHandleList[s].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 o=window.getComputedStyle(n).cursor;document.body.style.cursor=o,e.style.cursor=o;const s=this._mousemove.bind(this);document.addEventListener("mousemove",s),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",s),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,o=0;switch(this.curHandleIndex){case 0:{const c=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(c**3+d**3),o=this.element.height*n/this.getBlockWidth()}break;case 1:o=this.mousedownY-t.y;break;case 2:{const c=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(c**3+d**3),o=this.element.height*n/this.getBlockWidth()}break;case 4:{const c=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(c**3+d**3),o=this.element.height*n/this.getBlockWidth()}break;case 3:n=t.x-this.mousedownX;break;case 5:o=t.y-this.mousedownY;break;case 6:{const c=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(c**3+d**3),o=this.element.height*n/this.getBlockWidth()}break;case 7:n=this.mousedownX-t.x;break}const s=this.getBlockWidth()+n/e,i=this.element.height+o/e;if(s<=0||i<=0)return;this.width=s,this.height=i;const l=s*e,a=i*e;this._updateResizerRect(l,a),this.blockItem.style.width=`${l}px`,this.blockItem.style.height=`${a}px`,t.preventDefault()}snapshot(t,e,n,o){const s=this.element.block;if(s.type===R.BlockType.VIDEO)if(this.blockItem.style.display="none",this.blockCache.has(this.element.id))this.blockCache.get(this.element.id).snapshot(t,n,o);else{this.block=new hi(this.element);const i=this.block.snapshot(t,n,o);this.draw.getImageObserver().add(i),this.blockCache.set(this.element.id,this.block)}else s.type===R.BlockType.IFRAME&&this.setClientRects(e,n,o)}render(){const t=this.element.block;t.type===R.BlockType.IFRAME?(this.block=new zt(this.element),this.block.render(this.blockItem)):t.type===R.BlockType.VIDEO&&(this.block=new hi(this.element),this.block.render(this.blockItem))}setClientRects(t,e,n){const o=this.draw.getHeight(),s=this.draw.getPageGap(),i=t*(o+s),{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=`${i+n}px`,this.positionInfo={pageNo:t,x:e,y:n}}setStatus(){this.block instanceof zt&&this.block.setReadonly(this.draw.isReadonly())}remove(){this.blockItem.remove()}}class ar{constructor(t){L(this,"draw");L(this,"options");L(this,"container");L(this,"blockContainer");L(this,"blockMap");this.draw=t,this.options=t.getOptions(),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(`${v}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,n,o,s){const i=n.id;let l=this.blockMap.get(i);l||(l=new lr(this,n),l.render(),this.blockMap.set(i,l)),this.draw.isPrintMode()?l.snapshot(t,e,o,s):l.setClientRects(e,o,s),l.setStatus()}clear(){if(!this.blockMap.size)return;const t=this.draw.getOriginalMainElementList(),e=[];for(let n=0;n<t.length;n++){const o=t[n];o.type===R.ElementType.BLOCK&&e.push(o.id)}this.blockMap.forEach(n=>{const o=n.getBlockElement().id;e.includes(o)||(n.remove(),this.blockMap.delete(o))})}update(){this.blockMap.forEach(t=>{var n,o,s,i,l;const e=t.getBlockElement();if(((n=e.block)==null?void 0:n.type)===R.BlockType.IFRAME&&((o=e.block.iframeBlock)==null?void 0:o.srcdoc)){const a=(l=(i=(s=t.getIFrameBlock)==null?void 0:s.call(t))==null?void 0:i.getIframe)==null?void 0:l.call(i);(a==null?void 0:a.contentDocument)&&(e.block.iframeBlock.srcdoc=a.contentDocument.documentElement.outerHTML)}})}async drawIframeToPage(t,e){const n=[];this.blockMap.forEach(o=>{var g,T,P;if(((g=o.getBlockElement().block)==null?void 0:g.type)!==R.BlockType.IFRAME)return;const s=o.getPositionInfo();if(!s)return;const i=(T=o.getIFrameBlock())==null?void 0:T.getIframe();if(!i)return;const{pageNo:l,x:a,y:c}=s,d=(P=t[l])==null?void 0:P.getContext("2d");if(!d)return;const{width:h,height:u}=o.getBlockElement().metrics;n.push(e(i).then(O=>Ji(O)).then(O=>d.drawImage(O,a,c,h,u)))}),await Promise.allSettled(n)}pickIframeInfo(){const t=[],{scale:e}=this.options;return this.blockMap.forEach(n=>{var c;const o=n.getBlockElement();if(!((c=o.block)==null?void 0:c.iframeBlock)||o.block.type!==R.BlockType.IFRAME)return;const s=n.getPositionInfo();if(!s)return;const{pageNo:i,x:l,y:a}=s;t[i]||(t[i]=[]),t[i].push({x:l,y:a,width:o.metrics.width/e,height:o.metrics.height/e,src:o.block.iframeBlock.src,srcdoc:o.block.iframeBlock.srcdoc})}),t}}var un={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"}},Rr={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 cr{constructor(t){L(this,"currentLocale");L(this,"langMap",new Map([["zhCN",un],["en",Rr]]));this.currentLocale=t}registerLangMap(t,e){const n=this.langMap.get(t);this.langMap.set(t,fn(n||un,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||un}t(t){const e=t.split(".");let n="",o=this.getLang();for(let s=0;s<e.length;s++){const i=e[s],l=Reflect.get(o,i);if(l)n=o=l;else return""}return n}}class dr{constructor(){L(this,"promiseList");this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class hr{constructor(t,e){L(this,"draw");L(this,"zone");L(this,"i18n");L(this,"container");L(this,"pageContainer");L(this,"isDisableMouseMove");L(this,"tipContainer");L(this,"tipContent");L(this,"currentMoveZone");this.draw=t,this.zone=e,this.i18n=t.getI18n(),this.container=t.getContainer(),this.pageContainer=t.getPageContainer();const{tipContainer:n,tipContent:o}=this._drawZoneTip();this.tipContainer=n,this.tipContent=o,this.isDisableMouseMove=!0,this.currentMoveZone=R.EditorZone.MAIN;const s=[],{header:i,footer:l}=t.getOptions();i.disabled||s.push(R.EditorZone.HEADER),l.disabled||s.push(R.EditorZone.FOOTER),s.length&&this._watchMouseMoveZoneChange(s)}_watchMouseMoveZoneChange(t){this.pageContainer.addEventListener("mousemove",Ei(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()===R.EditorZone.MAIN&&(n===R.EditorZone.HEADER||n===R.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(`${v}-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===R.EditorZone.HEADER?"headerTip":"footerTip"}`)):this.tipContainer.classList.remove("show")}}class ur{constructor(t){L(this,"INDICATOR_PADDING",2);L(this,"INDICATOR_TITLE_TRANSLATE",[20,5]);L(this,"draw");L(this,"options");L(this,"i18n");L(this,"container");L(this,"currentZone");L(this,"indicatorContainer");this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=R.EditorZone.MAIN,this.indicatorContainer=null,this.options.zone.tipDisabled||new hr(t,this)}isHeaderActive(){return this.getZone()===R.EditorZone.HEADER}isMainActive(){return this.getZone()===R.EditorZone.MAIN}isFooterActive(){return this.getZone()===R.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){const{header:e,footer:n}=this.options;!e.editable&&t===R.EditorZone.HEADER||!n.editable&&t===R.EditorZone.FOOTER||this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),Be(()=>{const o=this.draw.getListener();o.zoneChange&&o.zoneChange(t);const s=this.draw.getEventBus();s.isSubscribe("zoneChange")&&s.emit("zoneChange",t)}))}getZoneByY(t){const e=this.draw.getHeader(),n=e.getHeaderTop()+e.getHeight(),o=this.draw.getFooter(),i=this.draw.getHeight()-(o.getFooterBottom()+o.getHeight());return t<n?R.EditorZone.HEADER:t>i?R.EditorZone.FOOTER:R.EditorZone.MAIN}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[n,o]=this.INDICATOR_TITLE_TRANSLATE,s=this.draw.getPageList(),i=this.draw.getMargins(),l=this.draw.getInnerWidth(),a=this.draw.getHeight(),c=this.draw.getPageGap(),d=a+c;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${v}-zone-indicator`);const h=this.draw.getHeader(),u=this.draw.getFooter(),g=e?h.getHeight():u.getHeight(),T=e?h.getHeaderTop():a-u.getFooterBottom()-g;for(let P=0;P<s.length;P++){const O=d*P+T,M=i[3]-this.INDICATOR_PADDING,S=i[3]+l+this.INDICATOR_PADDING,X=e?O-this.INDICATOR_PADDING:O+g+this.INDICATOR_PADDING,N=e?O+g+this.INDICATOR_PADDING:O-this.INDICATOR_PADDING,m=document.createElement("div");m.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),m.style.top=`${N}px`,m.style.transform=`translate(${n*t}px, ${o*t}px) scale(${t})`,this.indicatorContainer.append(m);const I=document.createElement("span");I.classList.add(`${v}-zone-indicator-border__top`),I.style.top=`${X}px`,I.style.width=`${l}px`,I.style.marginLeft=`${i[3]}px`,this.indicatorContainer.append(I);const f=document.createElement("span");f.classList.add(`${v}-zone-indicator-border__left`),f.style.top=`${O}px`,f.style.height=`${g}px`,f.style.left=`${M}px`,this.indicatorContainer.append(f);const F=document.createElement("span");F.classList.add(`${v}-zone-indicator-border__bottom`),F.style.top=`${N}px`,this.indicatorContainer.append(F);const V=document.createElement("span");V.classList.add(`${v}-zone-indicator-border__right`),V.style.top=`${O}px`,V.style.height=`${g}px`,V.style.left=`${S}px`,this.indicatorContainer.append(V)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){var t;(t=this.indicatorContainer)==null||t.remove(),this.indicatorContainer=null}}class gr{constructor(t,e){L(this,"draw");L(this,"position");L(this,"zone");L(this,"options");L(this,"elementList");L(this,"rowList");L(this,"positionList");this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(){const t=this.getFooterBottom(),e=this.draw.getInnerWidth(),o=this.draw.getMargins()[3],s=this.draw.getHeight(),i=this.getHeight(),l=s-t-i;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:o,startY:l,innerWidth:e,zone:R.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*Xn[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(),o=this.getFooterBottom()+e-t[2];return o<=0?0:o}render(t,e){t.save(),t.globalAlpha=this.zone.isFooterActive()?1:this.options.footer.inactiveAlpha;const n=this.draw.getInnerWidth(),o=this.getMaxHeight(),s=[];let i=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(i+a.height>o)break;s.push(a),i+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:s,pageNo:e,startIndex:0,innerWidth:n,zone:R.EditorZone.FOOTER}),t.restore()}}class Lr{constructor(t){L(this,"draw");L(this,"range");L(this,"options");L(this,"UN_COUNT_STYLE_WIDTH",20);L(this,"MEASURE_BASE_TEXT","0");L(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:o,endIndex:s}=this.range.getRange();if(!~o&&!~s)return;const i=this.range.getRangeParagraphElementList();if(!i||!i.length)return;if(i.find(h=>h.listType===t&&h.listStyle===e)||!t){this.unsetList();return}const a=j();i.forEach(h=>{h.listId=a,h.listType=t,h.listStyle=e});const c=o===s,d=c?s:o;this.draw.render({curIndex:d,isSetCursor:c})}unsetList(){var c;if(this.draw.isReadonly())return;const{startIndex:e,endIndex:n}=this.range.getRange();if(!~e&&!~n)return;const o=(c=this.range.getRangeParagraphElementList())==null?void 0:c.filter(d=>d.listId);if(!o||!o.length)return;const s=this.draw.getElementList(),i=s[n];if(i.listId){let d=n+1;for(;d<s.length;){const h=s[d];if(h.value===y&&!h.listWrap)break;if(h.listId!==i.listId){this.draw.spliceElementList(s,d,0,[{value:y}]);break}d++}}o.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 o=0,s=e[o].listId,i=[];const l=e.length;for(;o<l;){const a=e[o];if(s&&s===a.listId)i.push(a);else if(a.listId&&a.listId!==s){if(i.length){const c=this.getListStyleWidth(t,i);n.set(s,c)}s=a.listId,i=s?[a]:[]}o++}if(i.length){const a=this.getListStyleWidth(t,i);n.set(s,a)}return n}findStyledElement(t){let e=t[0];for(let n=1;n<t.length;n++){const o=t[n];if(o.font||o.size||o.bold||o.italic){e=o;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:o}=this.options;return`${o*e}px ${n}`}}getListStyleWidth(t,e){const{scale:n,checkbox:o}=this.options,s=e[0];if(s.listStyle&&s.listStyle!==R.ListStyle.DECIMAL)return s.listStyle===R.ListStyle.CHECKBOX?(o.width+this.LIST_GAP)*n:this.UN_COUNT_STYLE_WIDTH*n;const i=e.reduce((c,d)=>(d.value===y&&(c+=1),c),0);if(!i)return 0;t.save(),t.font=this.getListFontStyle(e,n);const l=`${this.MEASURE_BASE_TEXT.repeat(String(i).length)}${R.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:o,offsetX:s,listIndex:i,ascent:l}=e,a=o[0];if(a.value!==y||a.listWrap)return;let c=0;const{defaultTabWidth:d,scale:h}=this.options;for(let M=1;M<o.length;M++){const S=o[M];if((S==null?void 0:S.type)!==R.ElementType.TAB)break;c+=d*h}const{coordinate:{leftTop:[u,g]}}=n,T=u-s+c,P=g+l;if(a.listStyle===R.ListStyle.CHECKBOX){const{width:M,height:S,gap:X}=this.options.checkbox,N=B(Y({},a),{checkbox:{value:!!((O=a.checkbox)==null?void 0:O.value)},metrics:B(Y({},a.metrics),{width:(M+X*2)*h,height:S*h})});this.draw.getCheckboxParticle().render({ctx:t,x:T-X*h,y:P,index:0,row:B(Y({},e),{elementList:[N,...e.elementList]})})}else{let M="";if(a.listType===R.ListType.UL?M=je[a.listStyle]||je[ee.DISC]:M=`${i+1}${R.KeyMap.PERIOD}`,!M)return;t.save(),t.font=this.getListFontStyle(o,h),t.fillText(M,T,P),t.restore()}}}const gn=class{constructor(t){L(this,"options");this.options=t.getOptions()}render(t,e,n,o){const{scale:s,lineBreak:{color:i,lineWidth:l}}=this.options;t.save(),t.beginPath();const a=o-gn.HEIGHT*s/2,c=n+e.metrics.width;t.translate(c,a),t.scale(s,s),t.strokeStyle=i,t.lineWidth=l,t.lineCap="round",t.lineJoin="round",t.beginPath(),t.moveTo(8,0),t.lineTo(12,0),t.lineTo(12,6),t.lineTo(3,6),t.moveTo(3,6),t.lineTo(6,3),t.moveTo(3,6),t.lineTo(6,9),t.stroke(),t.closePath(),t.restore()}};let ne=gn;L(ne,"WIDTH",12),L(ne,"HEIGHT",9),L(ne,"GAP",3);class ui{constructor(t){L(this,"draw");L(this,"position");L(this,"options");L(this,"elementList");L(this,"rowList");L(this,"positionList");this.draw=t,this.position=t.getPosition(),this.options=t.getOptions(),this.elementList=[],this.rowList=[],this.positionList=[]}_recovery(){this.elementList=[],this.rowList=[],this.positionList=[]}_compute(t){this._computeRowList(),this._computePositionList(t)}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(t){const{lineBreak:e,scale:n}=this.options,o=this.draw.getHeader().getExtraHeight(),s=this.draw.getInnerWidth(),i=this.draw.getMargins();let l=i[3];e.disabled||(l+=(ne.WIDTH+ne.GAP)*n);const a=(t==null?void 0:t.startY)||i[0]+o;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:l,startY:a,innerWidth:s})}render(t,e){const{placeholder:n=this.options.placeholder}=e||{},{data:o,font:s,size:i,color:l,opacity:a}=n;this._recovery(),this.elementList=[{value:o,font:s,size:i,color:l}],Pt(this.elementList,{editorOptions:this.options,isForceCompensation:!0}),this._compute(e);const c=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:c,isDrawLineBreak:!1}),t.restore()}}class Tr{constructor(t){L(this,"draw");L(this,"options");L(this,"range");L(this,"fillRectMap");this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==R.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=j();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 o,s;const n=[];for(let i=0;i<t.length;i++){const l=t[i];if(l.type===R.ElementType.TABLE){const a=l.trList;for(let c=0;c<a.length;c++){const d=a[c];for(let h=0;h<d.tdList.length;h++){const u=d.tdList[h],g=this.getElementListByGroupId(u.value,e);if(g.length)return n.push(...g),n}}}if((o=l==null?void 0:l.groupIds)==null?void 0:o.includes(e)){n.push(l);const a=t[i+1];if(!((s=a==null?void 0:a.groupIds)==null?void 0:s.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 o=0;o<n.length;o++){const s=n[o],i=s.groupIds,l=i.findIndex(a=>a===t);i.splice(l,1),i.length||delete s.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){var n,o;for(let s=0;s<t.length;s++){const i=t[s];if(i.type===R.ElementType.TABLE){const a=i.trList;for(let c=0;c<a.length;c++){const d=a[c];for(let h=0;h<d.tdList.length;h++){const u=d.tdList[h],g=this.getContextByGroupId(u.value,e);if(g)return B(Y({},g),{isTable:!0,index:s,trIndex:c,tdIndex:h,tdId:u.id,trId:d.id,tableId:i.tableId})}}}const l=t[s+1];if(((n=i.groupIds)==null?void 0:n.includes(e))&&!((o=l==null?void 0:l.groupIds)==null?void 0:o.includes(e)))return{isTable:!1,startIndex:s,endIndex:s}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,n,o,s){const i=t.groupIds;if(!!i)for(const l of i){const a=this.fillRectMap.get(l);a?a.width+=o:this.fillRectMap.set(l,{x:e,y:n,width:o,height:s})}}render(t){var c;if(!this.fillRectMap.size)return;const e=this.range.getRange(),o=(c=this.draw.getElementList()[e.endIndex])==null?void 0:c.groupIds,{group:{backgroundColor:s,opacity:i,activeOpacity:l,activeBackgroundColor:a}}=this.options;t.save(),this.fillRectMap.forEach((d,h)=>{const{x:u,y:g,width:T,height:P}=d;(o==null?void 0:o.includes(h))?(t.globalAlpha=l,t.fillStyle=a):(t.globalAlpha=i,t.fillStyle=s),t.fillRect(u,g,T,P)}),t.restore(),this.clearFillInfo()}}class Pr{constructor(t){L(this,"options");this.options=t.getOptions()}render(t,e,n,o){const{scale:s,whiteSpace:{color:i,radius:l}}=this.options,a=e.metrics;t.save(),t.fillStyle=i,t.beginPath(),t.arc(n+a.width/2,o,l*s,0,Math.PI*2),t.fill(),t.closePath(),t.restore()}}class Mr{constructor(t){L(this,"draw");L(this,"eventBus");L(this,"pageContainer");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 Or{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:n,lineNumber:{color:o,size:s,font:i,right:l,type:a}}=this.options,c=this.draw.getTextParticle(),d=this.draw.getMargins(),h=this.draw.getPosition().getOriginalMainPositionList(),g=this.draw.getPageRowList()[e];t.save(),t.fillStyle=o,t.font=`${s*n}px ${i}`;for(let T=0;T<g.length;T++){const P=g[T],{coordinate:{leftBottom:O}}=h[P.startIndex],M=a===R.LineNumberType.PAGE?T+1:P.rowIndex+1,S=c.measureText(t,{value:`${M}`}),X=d[3]-(S.width+l)*n,N=O[1]-S.actualBoundingBoxAscent*n;t.fillText(`${M}`,X,N)}t.restore()}}class Sr{constructor(t){L(this,"draw");L(this,"header");L(this,"footer");L(this,"options");this.draw=t,this.header=t.getHeader(),this.footer=t.getFooter(),this.options=t.getOptions()}render(t){const{scale:e,pageBorder:{color:n,lineWidth:o,padding:s}}=this.options;t.save(),t.translate(.5,.5),t.strokeStyle=n,t.lineWidth=o*e;const i=this.draw.getMargins(),l=i[3]-s[3]*e,a=i[0]+this.header.getExtraHeight()-s[0]*e,c=this.draw.getInnerWidth()+(s[1]+s[3])*e,d=this.draw.getHeight()-a-this.footer.getExtraHeight()-i[2]+s[2]*e;t.rect(l,a,c,d),t.stroke(),t.restore()}}function Xr(r,t){const{value:e,oldValue:n}=t;n.isTable&&!e.isTable&&r.getTableTool().dispose()}class Ir{constructor(t){L(this,"draw");L(this,"eventBus");this.draw=t,this.eventBus=t.getEventBus(),this.execute()}execute(){this.eventBus.on("positionContextChange",t=>{Xr(this.draw,t)})}}class Nr{constructor(t){L(this,"draw");L(this,"range");L(this,"position");L(this,"tableTool");L(this,"tableParticle");L(this,"options");this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.tableTool=t.getTableTool(),this.tableParticle=t.getTableParticle(),this.options=t.getOptions()}insertTable(t,e){var T;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const{defaultTrMinHeight:s}=this.options.table,i=this.draw.getElementList();let l=0;if((T=i[n])==null?void 0:T.listId){const P=this.position.getPositionList(),{rowIndex:O}=P[n],S=this.draw.getRowList()[O];l=(S==null?void 0:S.offsetX)||0}const a=this.draw.getContextInnerWidth()-l,c=[],d=a/e;for(let P=0;P<e;P++)c.push({width:d});const h=[];for(let P=0;P<t;P++){const O=[],M={height:s,tdList:O};for(let S=0;S<e;S++)O.push({colspan:1,rowspan:1,value:[]});h.push(M)}const u={type:R.ElementType.TABLE,value:"",colgroup:c,trList:h};Pt([u],{editorOptions:this.options}),It(i,[u],n,{editorOptions:this.options});const g=n+1;this.draw.spliceElementList(i,g,n===o?0:o-n,[u]),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:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=l[n];if(a.tdList.length<i.colgroup.length){const h=a.tdList[0].rowIndex;for(let u=0;u<n;u++){const g=l[u];for(let T=0;T<g.tdList.length;T++){const P=g.tdList[T];P.rowspan>1&&P.rowIndex+P.rowspan>=h+1&&(P.rowspan+=1)}}}const c=j(),d={height:a.height,id:c,tdList:[]};for(let h=0;h<a.tdList.length;h++){const u=a.tdList[h],g=j();d.tdList.push({id:g,rowspan:1,colspan:u.colspan,value:[{value:y,size:16,tableId:o,trId:c,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:o}),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:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=l[n],c=l.length-1===n?a:l[n+1];if(c.tdList.length<i.colgroup.length){const u=c.tdList[0].rowIndex;for(let g=0;g<n+1;g++){const T=l[g];for(let P=0;P<T.tdList.length;P++){const O=T.tdList[P];O.rowspan>1&&O.rowIndex+O.rowspan>=u+1&&(O.rowspan+=1)}}}const d=j(),h={height:c.height,id:d,tdList:[]};for(let u=0;u<c.tdList.length;u++){const g=c.tdList[u],T=j();h.tdList.push({id:T,rowspan:1,colspan:g.colspan,value:[{value:y,size:16,tableId:o,trId:d,tdId:T}]})}l.splice(n+1,0,h),this.position.setPositionContext({isTable:!0,index:e,trIndex:n+1,tdIndex:0,tdId:h.tdList[0].id,trId:h.id,tableId:i.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}adjustColWidth(t){if(t.type!==R.ElementType.TABLE)return;const{defaultColMinWidth:e}=this.options.table,n=t.colgroup,o=n.reduce((i,l)=>i+l.width,0),s=this.draw.getOriginalInnerWidth();if(o>s){const i=n.filter(a=>a.width>e),l=(o-s)/i.length;for(let a=0;a<n.length;a++){const c=n[a];c.width-l>=e&&(c.width-=l)}}}insertTableLeftCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=n;for(let h=0;h<l.length;h++){const u=l[h],g=j();u.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:o,trId:u.id,tdId:g}]})}const{defaultColMinWidth:c}=this.options.table;i.colgroup.splice(a,0,{width:c}),this.adjustColWidth(i),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:o}),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:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=n+1;for(let h=0;h<l.length;h++){const u=l[h],g=j();u.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:o,trId:u.id,tdId:g}]})}const{defaultColMinWidth:c}=this.options.table;i.colgroup.splice(a,0,{width:c}),this.adjustColWidth(i),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:i.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:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=l[n],c=a.tdList[o].rowIndex;if(l.length<=1&&i.pagingIndex===0){this.deleteTable();return}for(let d=0;d<c;d++){const u=l[d].tdList;for(let g=0;g<u.length;g++){const T=u[g];T.rowIndex+T.rowspan>c&&T.rowspan--}}for(let d=0;d<a.tdList.length;d++){const h=a.tdList[d];if(h.rowspan>1){const u=j(),g=l[n+1];g.tdList.splice(d,0,{id:u,rowspan:h.rowspan-1,colspan:h.colspan,value:[{value:y,size:16,tableId:i.id,trId:g.id,tdId:u}]})}}l.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.clearRange(),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTableCol(){var h;const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,c=l[o].tdList[n].colIndex;if(!l.find(u=>u.tdList.length>1)){this.deleteTable();return}for(let u=0;u<l.length;u++){const g=l[u];for(let T=0;T<g.tdList.length;T++){const P=g.tdList[T];P.colIndex<=c&&P.colIndex+P.colspan>c&&(P.colspan>1?P.colspan--:g.tdList.splice(T,1))}}(h=i.colgroup)==null||h.splice(c,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTable(){const t=this.position.getPositionContext();if(!t.isTable)return;const e=this.draw.getOriginalElementList(),n=e[t.index];let o=1,s=t.index;if(n.pagingId){s=t.index-n.pagingIndex;for(let l=s+1;l<e.length&&e[l].pagingId===n.pagingId;l++)o++}e.splice(s,o);const i=s-1;this.position.setPositionContext({isTable:!1,index:i}),this.range.setRange(i,i),this.draw.render({curIndex:i}),this.tableTool.dispose()}mergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{isCrossRowCol:e,startTdIndex:n,endTdIndex:o,startTrIndex:s,endTrIndex:i}=this.range.getRange();if(!e)return;const{index:l}=t,d=this.draw.getOriginalElementList()[l].trList;let h=d[s].tdList[n],u=d[i].tdList[o];(h.x>u.x||h.y>u.y)&&([h,u]=[u,h]);const g=h.colIndex,T=u.colIndex+(u.colspan-1),P=h.rowIndex,O=u.rowIndex+(u.rowspan-1),M=[];for(let W=0;W<d.length;W++){const E=d[W],U=[];for(let Q=0;Q<E.tdList.length;Q++){const w=E.tdList[Q],K=w.colIndex,p=w.rowIndex;K>=g&&K<=T&&p>=P&&p<=O&&U.push(w)}U.length&&M.push(U)}if(!M.length)return;const S=M[M.length-1],X=M[0][0],N=S[S.length-1],m=X.x,I=X.y,f=N.x+N.width,F=N.y+N.height;for(let W=0;W<M.length;W++){const E=M[W];for(let U=0;U<E.length;U++){const Q=E[U],w=Q.x,K=Q.y,p=w+Q.width,G=K+Q.height;if(m>w||I>K||f<p||F<G)return}}const V=[],Z=M[0][0],C=Z.value[0];for(let W=0;W<M.length;W++){const E=M[W];for(let U=0;U<E.length;U++){const Q=E[U];if(!(W===0&&U===0)){V.push(Q.id);const K=Q.value.length>1?0:1;for(let p=K;p<Q.value.length;p++){const G=Q.value[p];jt(Pe,C,G),Z.value.push(G)}}W===0&&U!==0&&(Z.colspan+=Q.colspan),W!==0&&Z.colIndex===Q.colIndex&&(Z.rowspan+=Q.rowspan)}}for(let W=0;W<d.length;W++){const E=d[W];let U=0;for(;U<E.tdList.length;){const Q=E.tdList[U];V.includes(Q.id)&&(E.tdList.splice(U,1),U--),U++}}this.position.setPositionContext(B(Y({},t),{trIndex:Z.trIndex,tdIndex:Z.tdIndex}));const D=Z.value.length-1;this.range.setRange(D,D),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=l[o],c=a.tdList[n];if(c.rowspan===1&&c.colspan===1)return;const d=c.colspan;if(c.colspan>1){for(let u=1;u<c.colspan;u++){const g=j();a.tdList.splice(n+u,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:i.id,trId:a.id,tdId:g}]})}c.colspan=1}if(c.rowspan>1){for(let u=1;u<c.rowspan;u++){const g=l[o+u];for(let T=0;T<d;T++){const P=j();g.tdList.splice(c.colIndex,0,{id:P,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:i.id,trId:g.id,tdId:P}]})}}c.rowspan=1}const h=c.value.length-1;this.range.setRange(h,h),this.draw.render(),this.tableTool.render()}splitVerticalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:o,trIndex:s}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,c=a[s],d=c.tdList[o];l.colgroup.splice(o+1,0,{width:this.options.table.defaultColMinWidth});for(let h=0;h<a.length;h++){const u=a[h];let g=0;for(;g<u.tdList.length;){const T=u.tdList[g];if(T.rowIndex!==d.rowIndex)T.colIndex<=d.colIndex&&T.colIndex+T.colspan>d.colIndex&&T.colspan++;else if(T.id===d.id){const P=j();c.tdList.splice(g+d.colspan,0,{id:P,rowspan:d.rowspan,colspan:1,value:[{value:y,size:16,tableId:l.id,trId:u.id,tdId:P}]}),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:o,trIndex:s}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,d=a[s].tdList[o];let h=-1,u=0;for(;u<a.length;){if(u===h){u++;continue}const g=a[u];let T=0;for(;T<g.tdList.length;){const P=g.tdList[T];if(P.id===d.id){const O=j(),M=j();a.splice(u+d.rowspan,0,{id:O,height:this.options.table.defaultTrMinHeight,tdList:[{id:M,rowspan:1,colspan:d.colspan,value:[{value:y,size:16,tableId:l.id,trId:O,tdId:M}]}]}),h=u+d.rowspan}else P.rowIndex>=d.rowIndex&&P.rowIndex<d.rowIndex+d.rowspan&&P.rowIndex+P.rowspan>=d.rowIndex+d.rowspan&&P.rowspan++;T++}u++}this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let o=0;o<e.length;o++){const s=e[o];for(let i=0;i<s.length;i++){const l=s[i];!l||l.verticalAlign===t||!l.verticalAlign&&t===R.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,s=this.draw.getOriginalElementList()[n];if(!s.borderType&&t===R.TableBorder.ALL||s.borderType===t)return;s.borderType=t;const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i})}tableBorderColor(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,s=this.draw.getOriginalElementList()[n];if(!s.borderColor&&t===this.options.table.defaultBorderColor||s.borderColor===t)return;s.borderColor=t;const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isCompute:!1})}tableTdBorderType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),o=n.some(i=>{var l;return!((l=i.borderTypes)==null?void 0:l.includes(t))});n.forEach(i=>{i.borderTypes||(i.borderTypes=[]);const l=i.borderTypes.findIndex(a=>a===t);o?~l||i.borderTypes.push(t):~l&&i.borderTypes.splice(l,1),i.borderTypes.length||delete i.borderTypes});const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s})}tableTdSlashType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),o=n.some(i=>{var l;return!((l=i.slashTypes)==null?void 0:l.includes(t))});n.forEach(i=>{i.slashTypes||(i.slashTypes=[]);const l=i.slashTypes.findIndex(a=>a===t);o?~l||i.slashTypes.push(t):~l&&i.slashTypes.splice(l,1),i.slashTypes.length||delete i.slashTypes});const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s})}tableTdBackgroundColor(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let o=0;o<e.length;o++){const s=e[o];for(let i=0;i<s.length;i++){const l=s[i];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:o}=t;if(!o||!n)return;const{startIndex:s,endIndex:i}=this.range.getRange(),a=this.draw.getOriginalElementList()[e].trList,c=a.length-1,d=a[c].tdList.length-1;this.range.replaceRange({startIndex:s,endIndex:i,tableId:n,startTdIndex:0,endTdIndex:d,startTrIndex:0,endTrIndex:c}),this.draw.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1})}}R.AreaMode=void 0,function(r){r.EDIT="edit",r.READONLY="readonly",r.FORM="form"}(R.AreaMode||(R.AreaMode={}));class fr{constructor(t){L(this,"draw");L(this,"zone");L(this,"range");L(this,"position");L(this,"options");L(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?void 0:t.area))return!1;switch(t.area.mode){case R.AreaMode.EDIT:return!1;case R.AreaMode.READONLY:return!0;case R.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:o,position:s,range:i}=t;if(this.zone.getZone()!==R.EditorZone.MAIN&&this.zone.setZone(R.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),i&&!this.getActiveAreaId()){const{startIndex:a,endIndex:c}=i,d=this.draw.getOriginalMainElementList();if(!d[a]||!d[c])return null;this.range.setRange(i.startIndex,i.endIndex)}else if(s===R.LocationPosition.BEFORE)this.range.setRange(0,0);else{const c=this.draw.getOriginalMainElementList().length-1;this.range.setRange(c,c)}const l=e||j();return this.draw.insertElementList([{type:R.ElementType.AREA,value:"",areaId:l,valueList:n,area:$(o)}]),l}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),o=this.draw.getInnerWidth();for(const s of this.areaInfoMap){const{area:i,positionList:l}=s[1];if((i==null?void 0:i.hide)||!(i==null?void 0:i.backgroundColor)&&!(i==null?void 0:i.borderColor)&&!(i==null?void 0:i.placeholder))continue;const a=l.filter(T=>T.pageNo===e);if(!a.length)continue;t.translate(.5,.5);const c=a[0],d=a[a.length-1],h=n[3],u=Math.ceil(c.coordinate.leftTop[1]),g=Math.ceil(d.coordinate.rightBottom[1]-u);i.backgroundColor&&(t.fillStyle=i.backgroundColor,t.fillRect(h,u,o,g)),i.borderColor&&(t.strokeStyle=i.borderColor,t.strokeRect(h,u,o,g)),i.placeholder&&l.length<=1&&new ui(this.draw).render(t,{placeholder:Y(Y({},bn),i.placeholder),startY:c.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const o=t[n],s=o.areaId;if(s){const i=this.areaInfoMap.get(s);i?(i.elementList.push(o),i.positionList.push(e[n])):this.areaInfoMap.set(s,{id:s,area:o.area,elementList:[o],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:st(n.elementList)}:null}getContextByAreaId(t,e){var o,s,i;const n=this.draw.getOriginalMainElementList();for(let l=0;l<n.length;l++){const a=n[l];if((e==null?void 0:e.position)===R.LocationPosition.OUTER_BEFORE){if(((o=n[l+1])==null?void 0:o.areaId)!==t)continue}else if((e==null?void 0:e.position)===R.LocationPosition.AFTER){if(!(a.areaId===t&&((s=n[l+1])==null?void 0:s.areaId)!==t))continue}else if((e==null?void 0:e.position)===R.LocationPosition.OUTER_AFTER){if(!(a.areaId!==t&&((i=n[l-1])==null?void 0:i.areaId)===t))continue}else if(a.areaId!==t)continue;const c=this.position.getOriginalMainPositionList();return{range:{startIndex:l,endIndex:l},elementPosition:c[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 o=!1;const s=["top","hide"];Object.entries(t.properties).forEach(([i,l])=>{if(Wn(l))return;const a=i;n.area[a]=l,s.includes(a)&&(o=!0)}),this.draw.render({isCompute:o,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:o}=n,s=this.draw.getOriginalMainElementList(),i=t.value;Pt([{type:R.ElementType.AREA,value:"",valueList:i,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(s,o[0].index,o.length,i,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}deleteArea(t={}){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:o}=n,s=this.draw.getOriginalMainElementList();this.draw.spliceElementList(s,o[0].index,o.length,[],{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class mr{constructor(t){L(this,"draw");L(this,"options");L(this,"imageCache");L(this,"mainBadge");L(this,"areaBadgeMap");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,o,s,i){if(this.imageCache.has(i)){const l=this.imageCache.get(i);t.drawImage(l,e,n,o,s)}else{const l=new Image;l.setAttribute("crossOrigin","Anonymous"),l.src=i,l.onload=()=>{this.imageCache.set(i,l),t.drawImage(l,e,n,o,s)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:o}=this.options,{left:s,top:i,width:l,height:a,value:c}=this.mainBadge,d=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),h=(s||o.left)*n,u=(i||o.top)*n+d;this._drawImage(t,h,u,l*n,a*n,c)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:o,badge:s}=this.options;for(const i of n){const{positionList:l}=i[1],a=l[0];if(a.pageNo!==e)continue;const c=this.areaBadgeMap.get(i[0]);if(!c)continue;const{left:d,top:h,width:u,height:g,value:T}=c,P=(d||s.left)*o,O=(h||s.top)*o+a.coordinate.leftTop[1];this._drawImage(t,P,O,u*o,g*o,T)}}}}}class Fr{constructor(t,e){L(this,"draw");L(this,"options");L(this,"data");L(this,"pageContainer");L(this,"isDrawing",!1);L(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 c;if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,o=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<o&&Math.abs(this.startStroke.points[1]-n)<o)return;const s=this.draw.getPageNo();let i=this.data.find(d=>d.pageNo===s);if(this.startStroke&&(i||(i={pageNo:s,strokes:[]},this.data.push(i)),i.strokes.push(this.startStroke),this.startStroke=null),!((c=i==null?void 0:i.strokes)==null?void 0:c.length))return;const{scale:l}=this.options;i.strokes[i.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?void 0:n.length))return;const{graffiti:{defaultLineColor:o,defaultLineWidth:s},scale:i}=this.options;t.save();for(let a=0;a<n.length;a++){const c=n[a];t.beginPath(),t.strokeStyle=c.lineColor||o,t.lineWidth=(c.lineWidth||s)*i,t.moveTo(c.points[0]*i,c.points[1]*i);for(let d=2;d<c.points.length;d+=2)t.lineTo(c.points[d]*i,c.points[d+1]*i);t.stroke()}t.restore()}}class Wr{constructor(t,e,n,o,s,i){L(this,"container");L(this,"pageContainer");L(this,"pageList");L(this,"ctxList");L(this,"pageNo");L(this,"renderCount");L(this,"pagePixelRatio");L(this,"mode");L(this,"options");L(this,"position");L(this,"zone");L(this,"elementList");L(this,"listener");L(this,"eventBus");L(this,"override");L(this,"i18n");L(this,"canvasEvent");L(this,"globalEvent");L(this,"cursor");L(this,"range");L(this,"margin");L(this,"background");L(this,"badge");L(this,"search");L(this,"group");L(this,"area");L(this,"underline");L(this,"strikeout");L(this,"highlight");L(this,"historyManager");L(this,"previewer");L(this,"imageParticle");L(this,"laTexParticle");L(this,"textParticle");L(this,"tableParticle");L(this,"tableTool");L(this,"tableOperate");L(this,"pageNumber");L(this,"lineNumber");L(this,"waterMark");L(this,"placeholder");L(this,"header");L(this,"footer");L(this,"hyperlinkParticle");L(this,"labelParticle");L(this,"dateParticle");L(this,"separatorParticle");L(this,"pageBreakParticle");L(this,"superscriptParticle");L(this,"subscriptParticle");L(this,"checkboxParticle");L(this,"radioParticle");L(this,"blockParticle");L(this,"listParticle");L(this,"lineBreakParticle");L(this,"whiteSpaceParticle");L(this,"control");L(this,"pageBorder");L(this,"workerManager");L(this,"scrollObserver");L(this,"selectionObserver");L(this,"imageObserver");L(this,"graffiti");L(this,"LETTER_REG");L(this,"WORD_LIKE_REG");L(this,"rowList");L(this,"pageRowList");L(this,"painterStyle");L(this,"painterOptions");L(this,"visiblePageNoList");L(this,"intersectionPageNo");L(this,"lazyRenderIntersectionObserver");L(this,"printModeData");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=o,this.eventBus=s,this.override=i,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new cr(e.locale),this.historyManager=new Fs(this),this.position=new Ws(this),this.zone=new ur(this),this.range=new Vs(this),this.margin=new Us(this),this.background=new ps(this),this.badge=new mr(this),this.search=new Ys(this),this.group=new Tr(this),this.area=new fr(this),this.underline=new Cs(this),this.strikeout=new Qs(this),this.highlight=new Zs(this),this.previewer=new sr(this),this.imageParticle=new Un(this),this.laTexParticle=new Cn(this),this.textParticle=new Es(this),this.tableParticle=new Ks(this),this.tableTool=new ys(this),this.tableOperate=new Nr(this),this.pageNumber=new he(this),this.lineNumber=new Or(this),this.waterMark=new ks(this),this.placeholder=new ui(this),this.header=new Gs(this,n.header),this.footer=new gr(this,n.footer),this.hyperlinkParticle=new ws(this),this.labelParticle=new Hs(this),this.dateParticle=new rr(this),this.separatorParticle=new vs(this),this.pageBreakParticle=new Bs(this),this.superscriptParticle=new xs,this.subscriptParticle=new Js,this.checkboxParticle=new js(this),this.radioParticle=new qs(this),this.blockParticle=new ar(this),this.listParticle=new Lr(this),this.lineBreakParticle=new ne(this),this.whiteSpaceParticle=new Pr(this),this.control=new $s(this),this.pageBorder=new Sr(this),this.graffiti=new Fr(this,n.graffiti),this.scrollObserver=new Ds(this),this.selectionObserver=new bs(this),this.imageObserver=new dr,new Mr(this),this.canvasEvent=new fs(this),this.cursor=new qo(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new ms(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new or(this),new Ir(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===R.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=$(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===R.EditorMode.PRINT&&this.setPrintData(),this.mode===R.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?void 0:e.mode)return this.area.isReadonly();switch(this.mode){case R.EditorMode.DESIGN:return!1;case R.EditorMode.READONLY:case R.EditorMode.PRINT:case R.EditorMode.GRAFFITI:return!0;case R.EditorMode.FORM:return!this.control.getIsRangeWithinControl();default:return!1}}isDisabled(){var s,i,l,a,c;if(this.mode===R.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if((s=this.getTd())==null?void 0:s.disabled)return!0;if(t===e){const d=n[t],h=n[t+1];return!!(((i=d==null?void 0:d.title)==null?void 0:i.disabled)&&((l=h==null?void 0:h.title)==null?void 0:l.disabled)&&d.titleId===h.titleId||((a=d==null?void 0:d.control)==null?void 0:a.disabled)&&((c=h==null?void 0:h.control)==null?void 0:c.disabled)&&d.controlId===h.controlId)}return n.slice(t+1,e+1).some(d=>{var h,u;return((h=d.title)==null?void 0:h.disabled)||((u=d.control)==null?void 0:u.disabled)})}isDesignMode(){return this.mode===R.EditorMode.DESIGN}isPrintMode(){return this.mode===R.EditorMode.PRINT}isGraffitiMode(){return this.mode===R.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===R.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===R.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:o}=t,i=this.getOriginalElementList()[e].trList[n].tdList[o],l=this.getTdPadding();return i.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===R.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:o,tdIndex:s}=e;return t[n].trList[o].tdList[s].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 i;const e=this.position.getPositionContext(),{index:n,trIndex:o,tdIndex:s}=e;return((i=t[n].trList)==null?void 0:i[o].tdList[s].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:o,isTable:s}=t;return s?this.getOriginalElementList()[e].trList[n].tdList[o]:null}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const{isSubmitHistory:s=!0}=e;Pt(t,{isHandleFirstElement:!1,editorOptions:this.options});let i=-1,l=this.control.getActiveControl();if(!l&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),l=this.control.getActiveControl()),l&&this.control.getIsRangeWithinControl())i=l.setValue(t,void 0,{isIgnoreDisabledRule:!0}),this.control.emitControlContentChange();else{const a=this.getElementList(),c=n===o,d=n+1;c||this.spliceElementList(a,d,o-n),this.spliceElementList(a,d,0,t),i=n+t.length;const h=a[d-1];t[0].listId&&h&&!h.listId&&(h==null?void 0:h.value)===y&&(!h.type||h.type===R.ElementType.TEXT)&&(a.splice(n,1),i-=1)}~i&&(this.range.setRange(i,i),this.render({curIndex:i,isSubmitHistory:s}))}appendElementList(t,e={}){if(!t.length)return;Pt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:o,isSubmitHistory:s=!0}=e;o?(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:s})}spliceElementList(t,e,n,o,s){var c,d,h,u,g,T,P,O;const{isIgnoreDeletedRule:i=!1}=s||{},{group:l,modeRule:a}=this.options;if(n>0){const M=e+n,S=t[M],X=S==null?void 0:S.listId;if(X&&((c=t[e-1])==null?void 0:c.listId)!==X){let N=M;for(;N<t.length;){const m=t[N];if(m.listId!==X||m.value===y)break;delete m.listId,delete m.listType,delete m.listStyle,N++}}if(!i&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const N=(d=this.getTd())==null?void 0:d.deletable;let m=M-1;for(;m>=e;){const I=t[m];((I==null?void 0:I.hide)||((h=I==null?void 0:I.control)==null?void 0:h.hide)||((u=I==null?void 0:I.area)==null?void 0:u.hide)||N!==!1&&((g=I==null?void 0:I.control)==null?void 0:g.deletable)!==!1&&(!I.controlId||this.mode!==R.EditorMode.FORM||!a[this.mode].controlDeletableDisabled)&&((T=I==null?void 0:I.title)==null?void 0:T.deletable)!==!1&&(l.deletable!==!1||!((P=I.groupIds)==null?void 0:P.length))&&(((O=I==null?void 0:I.area)==null?void 0:O.deletable)!==!1||(I==null?void 0:I.areaIndex)!==0))&&t.splice(m,1),m--}}else t.splice(e,n)}if(o==null?void 0:o.length)for(let M=0;M<o.length;M++)t.splice(e+M,0,o[M])}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}getBlockParticle(){return this.blockParticle}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,snapDomFunction:o}=t;e&&this.setPagePixelRatio(e);const s=this.mode,i=!!n&&s!==n;i&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled(),o&&await this.blockParticle.drawIframeToPage(this.pageList,o);const l=this.pageList.map(a=>a.toDataURL());return e&&this.setPagePixelRatio(null),i&&this.setMode(s),l}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===R.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===R.PageMode.PAGING){const{height:o}=this.options,s=this.getPagePixelRatio(),i=this.pageList[0];i.style.height=`${o}px`,i.height=o*s,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(R.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(),o=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((i,l)=>{i.width=n*e,i.height=o*e,i.style.width=`${n}px`,i.style.height=`${o}px`,i.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[l])});const s=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!s,curIndex:s==null?void 0:s.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((o,s)=>{o.width=e*t,o.height=n*t,this._initPageContext(this.ctxList[s])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),o=this.getWidth(),s=this.getHeight();this.container.style.width=`${o}px`,this.pageList.forEach((i,l)=>{i.width=o*n,i.height=s*n,i.style.width=`${o}px`,i.style.height=`${s}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(),o=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((s,i)=>{s.width=n*e,s.height=o*e,s.style.width=`${n}px`,s.style.height=`${o}px`,this._initPageContext(this.ctxList[i])}),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(s=>s.elementList)),this.blockParticle.update(),{header:this.getHeaderElementList(),main:n,footer:this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t),{extraPickAttrs:n}=t,o={header:st(e.header,{extraPickAttrs:n}),main:st(e.main,{extraPickAttrs:n,isClassifyArea:!0}),footer:st(e.footer,{extraPickAttrs:n}),graffiti:e.graffiti};return{version:Xt,data:o,options:$(this.options)}}setValue(t,e){const{header:n,main:o,footer:s}=$(t);if(!n&&!o&&!s)return;const{isSetCursor:i=!1}=e||{};[n,o,s].forEach(c=>{!c||Pt(c,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:o,footer:s}),this.historyManager.recovery();const a=i?(o==null?void 0:o.length)?o.length-1:0:void 0;a!==void 0&&this.range.setRange(a,a),this.render({curIndex:a,isSetCursor:i,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:o}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),o&&this.footer.setElementList(o)}_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(_t,R.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${v}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),o=document.createElement("canvas");o.style.width=`${e}px`,o.style.height=`${n}px`,o.style.display="block",o.style.backgroundColor="#ffffff",o.style.marginBottom=`${this.getPageGap()}px`,o.setAttribute("data-index",String(t)),this.pageContainer.append(o);const s=this.getPagePixelRatio();o.width=e*s,o.height=n*s,o.style.cursor="text";const i=o.getContext("2d");this._initPageContext(i),this.pageList.push(o),this.ctxList.push(i)}_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:o}=this.options,s=t.font||o,i=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${i*e}px ${s}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){var a;const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:o,scale:s}=this.options,i=t.size||e;let l=1;return i<12?l=i/12:i>30&&(l=1+(i-30)/30),n*l*((a=t.rowMargin)!=null?a:o)*s}computeRowList(t){var C,D,W,E,U,Q,w,K,p,G,H,x,k,A,Nt,Vt,ft,gt,rt,Mt,it,et;const{innerWidth:e,elementList:n,isPagingMode:o=!1,isFromTable:s=!1,startX:i=0,startY:l=0,pageHeight:a=0,mainOuterHeight:c=0,surroundElementList:d=[]}=t,{defaultSize:h,scale:u,imgCaption:g,table:{tdPadding:T},defaultTabWidth:P}=this.options,O=this.getDefaultBasicRowMarginHeight(),S=document.createElement("canvas").getContext("2d"),X=this.listParticle.computeListStyle(S,n),N=[];n.length&&N.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:((C=n==null?void 0:n[0])==null?void 0:C.rowFlex)||((D=n==null?void 0:n[1])==null?void 0:D.rowFlex)});let m=i,I=l,f=0,F,V=0,Z=0;for(let q=0;q<n.length;q++){const nt=N[N.length-1],b=n[q],Zt=this.getElementRowMargin(b),J={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},Ne=nt.offsetX||b.listId&&X.get(b.listId)||0,Tt=e-Ne,fe=nt.elementList.length===1;if(m+=fe?Ne:0,I+=fe&&nt.offsetY||0,(b.hide||((W=b.control)==null?void 0:W.hide)||((E=b.area)==null?void 0:E.hide))&&!this.isDesignMode()){const _=nt.elementList[nt.elementList.length-1];J.height=(_==null?void 0:_.metrics.height)||this.options.defaultSize*u,J.boundingBoxAscent=(_==null?void 0:_.metrics.boundingBoxAscent)||0,J.boundingBoxDescent=(_==null?void 0:_.metrics.boundingBoxDescent)||0}else if(b.type===R.ElementType.IMAGE||b.type===R.ElementType.LATEX)if(b.imgDisplay===R.ImageDisplay.SURROUND||b.imgDisplay===R.ImageDisplay.FLOAT_TOP||b.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)J.width=0,J.height=0,J.boundingBoxDescent=0;else{const _=b.width*u,lt=b.height*u;if(_>Tt){const tt=lt*Tt/_;b.width=Tt/u,b.height=tt/u,J.width=Tt,J.height=tt,J.boundingBoxDescent=tt}else J.width=_,J.height=lt,J.boundingBoxDescent=lt;if((U=b.imgCaption)==null?void 0:U.value){const tt=b.imgCaption.size||g.size,mt=(Q=b.imgCaption.top)!=null?Q:g.top,ie=(tt+mt)*u;J.boundingBoxAscent+=ie}}else if(b.type===R.ElementType.TABLE){const _=T[1]+T[3],lt=T[0]+T[2];if(b.pagingId){let Rt=q+1,St=0;for(;Rt<n.length;){const ct=n[Rt];if(ct.pagingId===b.pagingId){const dt=ct.trList.filter(Ct=>!Ct.pagingRepeat);b.trList.push(...dt),b.height+=ct.height,Rt++,St++}else break}St&&n.splice(q+1,St)}b.pagingIndex=(w=b.pagingIndex)!=null?w:0;const tt=b.trList,mt=lt+h+Zt*2/u;for(let Rt=0;Rt<tt.length;Rt++){const St=tt[Rt];St.height=Math.max(mt,St.minHeight||0),St.minHeight=St.height}this.tableParticle.computeRowColInfo(b);for(let Rt=0;Rt<tt.length;Rt++){const St=tt[Rt];for(let ct=0;ct<St.tdList.length;ct++){const dt=St.tdList[ct],Ct=this.computeRowList({innerWidth:(dt.width-_)*u,elementList:dt.value,isFromTable:!0,isPagingMode:o}),ht=Ct.reduce((Wt,Ht)=>Wt+Ht.height,0);dt.rowList=Ct;const Ot=ht/u+lt;if(dt.height<Ot){const Wt=Ot-dt.height,Ht=tt[Rt+dt.rowspan-1];Ht.height+=Wt,Ht.tdList.forEach(At=>{At.height+=Wt,At.realHeight?At.realHeight+=Wt:At.realHeight=At.height})}let Ft=0,Et=0,Ut=0;for(;Ut<dt.rowspan;){const Wt=tt[Ut+Rt]||tt[Rt];Ft+=Wt.minHeight,Et+=Wt.height,Ut++}dt.realMinHeight=Ft,dt.realHeight=Et,dt.mainHeight=Ot}}const ie=this.tableParticle.getTrListGroupByCol(tt);for(let Rt=0;Rt<ie.length;Rt++){const St=ie[Rt];let ct=-1;for(let dt=0;dt<St.tdList.length;dt++){const Ct=St.tdList[dt],ht=Ct.realHeight,Ot=Ct.mainHeight,Ft=Ct.realMinHeight,Et=Ot<Ft?ht-Ft:ht-Ot;(!~ct||Et<ct)&&(ct=Et)}if(ct>0){const dt=tt[Rt];dt.height-=ct,dt.tdList.forEach(Ct=>{Ct.height-=ct,Ct.realHeight-=ct})}}this.tableParticle.computeRowColInfo(b);const Ni=this.tableParticle.getTableHeight(b),fi=this.tableParticle.getTableWidth(b);b.width=fi,b.height=Ni;const Kl=fi*u,Tn=Ni*u;if(J.width=Kl,J.height=Tn,J.boundingBoxDescent=Tn,J.boundingBoxAscent=-Zt,((K=n[q+1])==null?void 0:K.type)===R.ElementType.TABLE&&(J.boundingBoxAscent-=Zt),o){const Rt=this.getHeight(),St=this.getMainOuterHeight();let ct=St;for(let ht=0;ht<N.length;ht++){const Ot=N[ht],Ft=Ot.offsetY||0;Ot.height+ct+Ft>Rt||((p=N[ht-1])==null?void 0:p.isPageBreak)?ct=St+Ot.height+Ft:ct+=Ot.height+Ft}const dt=Zt*2*u,Ct=b.trList[0].height*u;if((ct+Ct+dt>Rt||b.pagingIndex!==0&&b.trList[0].pagingRepeat||((G=n[q-1])==null?void 0:G.type)===R.ElementType.PAGE_BREAK)&&(ct=St),ct+dt+Tn>Rt){const ht=b.trList;let Ot=0,Ft=0,Et=0;if(ht.length>1)for(let Ut=0;Ut<ht.length;Ut++){const Wt=ht[Ut],Ht=Wt.height*u;if(ct+dt+Et+Ht>Rt){const At=Wt.tdList.reduce((oe,ye)=>oe+ye.colspan,0);((H=b.colgroup)==null?void 0:H.length)!==At&&(Ft=0);break}else Ot=Ut+1,Ft=ht.length-Ot,Et+=Ht}if(Ft){const Ut=ht.splice(Ot,Ft),Wt=Ut.reduce((Le,Pn)=>Le+Pn.height,0),Ht=Wt*u,At=b.pagingId||j();b.pagingId=At,b.height-=Wt,J.height-=Ht,J.boundingBoxDescent-=Ht;const oe=$(b);oe.pagingId=At,oe.pagingIndex=b.pagingIndex+1;const ye=ht.filter(Le=>Le.pagingRepeat);if(ye.length){const Le=$(ye);Le.forEach(Pn=>Pn.id=j()),Ut.unshift(...Le)}oe.trList=Ut,oe.id=j(),this.spliceElementList(n,q+1,0,[oe])}}if(b.pagingId){const ht=this.position.getPositionContext();if(ht.isTable){let Ot=-1,Ft=-1,Et=q;for(;Et<n.length;){const Ut=n[Et];if(Ut.pagingId!==b.pagingId)break;const Wt=Ut.trList.findIndex(Ht=>Ht.id===ht.trId);if(~Wt){Ot=Et,Ft=Wt;break}Et++}~Ot&&(ht.index=Ot,ht.trIndex=Ft,this.position.setPositionContext(ht))}}}}else if(b.type===R.ElementType.SEPARATOR){const{separator:{lineWidth:_}}=this.options,lt=b.lineWidth||_;b.width=Tt/u,J.width=Tt,J.height=lt*u,J.boundingBoxAscent=-Zt,J.boundingBoxDescent=-Zt+J.height}else if(b.type===R.ElementType.PAGE_BREAK)b.width=Tt/u,J.width=Tt,J.height=h;else if(b.type===R.ElementType.RADIO||b.controlComponent===R.ControlComponent.RADIO){const{width:_,height:lt,gap:tt}=this.options.radio,mt=_+tt*2;b.width=mt,J.width=mt*u,J.height=lt*u}else if(b.type===R.ElementType.CHECKBOX||b.controlComponent===R.ControlComponent.CHECKBOX){const{width:_,height:lt,gap:tt}=this.options.checkbox,mt=_+tt*2;b.width=mt,J.width=mt*u,J.height=lt*u}else if(b.type===R.ElementType.TAB)J.width=P*u,J.height=h*u,J.boundingBoxDescent=0,J.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(S,S.font);else if(b.type===R.ElementType.BLOCK){if(!b.width)J.width=Tt;else{const _=b.width*u;J.width=Math.min(_,Tt)}J.height=b.height*u,J.boundingBoxDescent=J.height,J.boundingBoxAscent=0}else if(b.type===R.ElementType.LABEL){const{defaultSize:_,label:{defaultPadding:lt}}=this.options;S.font=this.getElementFont(b);const tt=this.textParticle.measureText(S,b);J.width=(tt.width+lt[1]+lt[3])*u,J.height=(b.size||_)*u,J.boundingBoxDescent=0,J.boundingBoxAscent=(lt[0]+tt.actualBoundingBoxAscent)*u}else{const _=b.size||h;(b.type===R.ElementType.SUPERSCRIPT||b.type===R.ElementType.SUBSCRIPT)&&(b.actualSize=Math.ceil(_*.6)),J.height=(b.actualSize||_)*u,S.font=this.getElementFont(b);const lt=this.textParticle.measureText(S,b);J.width=lt.width*u,b.letterSpacing&&(J.width+=b.letterSpacing*u);const tt=this.textParticle.measureBasisWord(S,b.font);J.boundingBoxAscent=tt.actualBoundingBoxAscent*u,J.boundingBoxDescent=tt.actualBoundingBoxDescent*u,b.type===R.ElementType.SUPERSCRIPT?J.boundingBoxAscent+=J.height/2:b.type===R.ElementType.SUBSCRIPT&&(J.boundingBoxDescent+=J.height/2)}const Mi=!b.hide&&(b.imgDisplay!==R.ImageDisplay.INLINE&&b.type===R.ElementType.IMAGE||b.type===R.ElementType.LATEX)?J.height+Zt:J.boundingBoxAscent+Zt,ge=Zt+J.boundingBoxAscent+J.boundingBoxDescent+Zt,wt=Object.assign(b,{metrics:J,left:0,style:this.getElementFont(b,u)});((x=wt.control)==null?void 0:x.minWidth)&&(wt.controlComponent&&(Z+=J.width),wt.controlComponent===R.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:nt,rowElement:wt,availableWidth:Tt,controlRealWidth:Z}),Z=0));const ot=n[q-1];let Oi=n[q+1],Ke=nt.width+J.width;if(this.options.wordBreak===R.WordBreak.BREAK_WORD&&(!(ot==null?void 0:ot.type)||(ot==null?void 0:ot.type)===R.ElementType.TEXT)&&(!b.type||b.type===R.ElementType.TEXT)){const _=`${(ot==null?void 0:ot.value)||""}${b.value}`;if(this.WORD_LIKE_REG.test(_)){const{width:tt,endElement:mt}=this.textParticle.measureWord(S,n,q),ie=tt*u;mt&&ie<=Tt&&(Ke+=ie,Oi=mt)}Ke+=this.textParticle.measurePunctuationWidth(S,Oi)*u}b.listId&&(b.listId!==F?V=0:b.value===y&&!b.listWrap&&V++),F=b.listId;const Si=this.position.setSurroundPosition({pageNo:f,rowElement:wt,row:nt,rowElementRect:{x:m,y:I,height:ge,width:J.width},availableWidth:Tt,surroundElementList:d});m=Si.x,Ke+=Si.rowIncreaseWidth,m+=J.width;const Xi=b.type===R.ElementType.SEPARATOR||b.type===R.ElementType.TABLE||(ot==null?void 0:ot.type)===R.ElementType.TABLE||(ot==null?void 0:ot.type)===R.ElementType.BLOCK||b.type===R.ElementType.BLOCK||(ot==null?void 0:ot.imgDisplay)===R.ImageDisplay.INLINE||b.imgDisplay===R.ImageDisplay.INLINE||(ot==null?void 0:ot.listId)!==b.listId||(ot==null?void 0:ot.areaId)!==b.areaId&&!((k=b.area)==null?void 0:k.hide)||((A=b.control)==null?void 0:A.flexDirection)===R.FlexDirection.COLUMN&&(b.controlComponent===R.ControlComponent.CHECKBOX||b.controlComponent===R.ControlComponent.RADIO)&&(ot==null?void 0:ot.controlComponent)===R.ControlComponent.VALUE||q!==0&&b.value===y&&!((Nt=b.area)==null?void 0:Nt.hide),Ii=Ke>Tt,Ln=Xi||Ii;if(Ln){const _={width:J.width,height:ge,startIndex:q,elementList:[wt],ascent:Mi,rowIndex:nt.rowIndex+1,rowFlex:((Vt=n[q])==null?void 0:Vt.rowFlex)||((ft=n[q+1])==null?void 0:ft.rowFlex),isPageBreak:b.type===R.ElementType.PAGE_BREAK};if(wt.controlComponent!==R.ControlComponent.PREFIX&&((gt=wt.control)==null?void 0:gt.indentation)===R.ControlIndentation.VALUE_START){const lt=nt.elementList.findIndex(tt=>tt.controlId===wt.controlId&&tt.controlComponent!==R.ControlComponent.PREFIX);if(~lt){const mt=this.position.computeRowPosition({row:nt,innerWidth:this.getInnerWidth()})[lt];mt&&(_.offsetX=mt.coordinate.leftTop[0])}}b.listId&&(_.isList=!0,_.offsetX=X.get(b.listId),_.listIndex=V),_.offsetY=!s&&((rt=b.area)==null?void 0:rt.top)&&b.areaId!==((Mt=n[q-1])==null?void 0:Mt.areaId)?b.area.top*u:0,N.push(_)}else nt.width+=J.width,q===0&&($t(n[1])||!!((it=n[1])==null?void 0:it.areaId))?(nt.height=O,nt.ascent=O):nt.height<ge&&(nt.height=ge,nt.ascent=Mi),nt.elementList.push(wt);if((Ln||q===n.length-1)&&(nt.isWidthNotEnough=Ii&&!Xi,!nt.isSurround&&((ot==null?void 0:ot.rowFlex)===R.RowFlex.JUSTIFY||(ot==null?void 0:ot.rowFlex)===R.RowFlex.ALIGNMENT&&nt.isWidthNotEnough))){const _=((et=nt.elementList[0])==null?void 0:et.value)===y?nt.elementList.slice(1):nt.elementList,lt=(Tt-nt.width)/(_.length-1);for(let tt=0;tt<_.length-1;tt++){const mt=_[tt];mt.metrics.width+=lt}nt.width=Tt}if(Ln){m=i,I+=nt.height,o&&!s&&a&&(I-l+c+ge>a||b.type===R.ElementType.PAGE_BREAK)&&(I=l,Bo(d,f),f+=1),wt.left=0;const _=N[N.length-1];m=this.position.setSurroundPosition({pageNo:f,rowElement:wt,row:_,rowElementRect:{x:m,y:I,height:ge,width:J.width},availableWidth:Tt,surroundElementList:d}).x,m+=J.width}}return N}_computePageList(){var a;const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,o=this.getHeight(),s=this.getMainOuterHeight();let i=s,l=0;if(e===R.PageMode.CONTINUITY){t[0]=this.rowList,i+=this.rowList.reduce((u,g)=>u+g.height+(g.offsetY||0),0);const c=this.getPagePixelRatio(),d=this.pageList[0],h=Number(d.style.height.replace("px",""));if(i>h)d.style.height=`${i}px`,d.height=i*c;else{const u=i<o?o:i;d.style.height=`${u}px`,d.height=u*c}this._initPageContext(this.ctxList[0])}else for(let c=0;c<this.rowList.length;c++){const d=this.rowList[c],h=d.offsetY||0;if(d.height+h+i>o||((a=this.rowList[c-1])==null?void 0:a.isPageBreak)){if(Number.isInteger(n)&&l>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}i=s+d.height+h,t.push([d]),l++}else i+=d.height+h,t[l].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:o,elementList:s}=e,i=this.getDefaultBasicRowMarginHeight(),l=this.getHighlightMarginHeight();for(let a=0;a<n.length;a++){const c=n[a];for(let d=0;d<c.elementList.length;d++){const h=c.elementList[d],u=c.elementList[d-1],g=h.highlight||this.control.getControlHighlight(s,c.startIndex+d);if(g){u&&u.highlight&&u.highlight!==h.highlight&&this.highlight.render(t);const{coordinate:{leftTop:[T,P]}}=o[c.startIndex+d],O=h.left||0;this.highlight.recordFillInfo(t,T-O,P+i-l,h.metrics.width+O,c.height-2*i+2*l,g)}else(u==null?void 0:u.highlight)&&this.highlight.render(t)}this.highlight.render(t)}}drawRow(t,e){var m,I,f,F,V,Z,C,D,W;this._drawHighlight(t,e);const{scale:n,table:{tdPadding:o},group:s,lineBreak:i,whiteSpace:l}=this.options,{rowList:a,pageNo:c,elementList:d,positionList:h,startIndex:u,zone:g,isDrawLineBreak:T=!i.disabled,isDrawWhiteSpace:P=!l.disabled}=e,O=this.isPrintMode(),M=this.isGraffitiMode(),{isCrossRowCol:S,tableId:X}=this.range.getRange();let N=u;for(let E=0;E<a.length;E++){const U=a[E],Q={x:0,y:0,width:0,height:0};let w=null;for(let K=0;K<U.elementList.length;K++){const p=U.elementList[K],G=p.metrics,{ascent:H,coordinate:{leftTop:[x,k]}}=h[U.startIndex+K],A=U.elementList[K-1];if((p.hide||((m=p.control)==null?void 0:m.hide)||((I=p.area)==null?void 0:I.hide))&&!this.isDesignMode())this.textParticle.complete();else if(p.type===R.ElementType.IMAGE)this.textParticle.complete(),p.imgDisplay!==R.ImageDisplay.SURROUND&&p.imgDisplay!==R.ImageDisplay.FLOAT_TOP&&p.imgDisplay!==R.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,p,x,k+H);else if(p.type===R.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,p,x,k+H);else if(p.type===R.ElementType.TABLE)S&&(Q.x=x,Q.y=k,w=p),this.tableParticle.render(t,p,x,k);else if(p.type===R.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,p,x,k+H);else if(p.type===R.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,p,x,k+H);else if(p.type===R.ElementType.DATE){const gt=U.elementList[K+1];(!A||A.dateId!==p.dateId)&&this.textParticle.complete(),this.textParticle.record(t,p,x,k+H),(!gt||gt.dateId!==p.dateId)&&this.textParticle.complete()}else p.type===R.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,p,x,k+H)):p.type===R.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,p,x,k+H)):p.type===R.ElementType.SEPARATOR?this.separatorParticle.render(t,p,x,k):p.type===R.ElementType.PAGE_BREAK?this.mode!==R.EditorMode.CLEAN&&!O&&this.pageBreakParticle.render(t,p,x,k):p.type===R.ElementType.CHECKBOX||p.controlComponent===R.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x,y:k+H,index:K,row:U})):p.type===R.ElementType.RADIO||p.controlComponent===R.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x,y:k+H,index:K,row:U})):p.type===R.ElementType.TAB?this.textParticle.complete():p.rowFlex===R.RowFlex.ALIGNMENT||p.rowFlex===R.RowFlex.JUSTIFY?(this.textParticle.record(t,p,x,k+H),this.textParticle.complete()):p.type===R.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,c,p,x,k+H)):(p.left&&this.textParticle.complete(),this.textParticle.record(t,p,x,k+H),(p.width||p.letterSpacing||Ui.test(p.value))&&this.textParticle.complete());if(T&&!O&&this.mode!==R.EditorMode.CLEAN&&!U.isWidthNotEnough&&K===U.elementList.length-1&&this.lineBreakParticle.render(t,p,x,k+U.height/2),P&&Qi.test(p.value)&&this.whiteSpaceParticle.render(t,p,x,k+U.height/2),(f=p.control)==null?void 0:f.border){((F=A==null?void 0:A.control)==null?void 0:F.border)&&A.controlId!==p.controlId&&this.control.drawBorder(t);const gt=this.getElementRowMargin(p);this.control.recordBorderInfo(x,k+gt,p.metrics.width,U.height-2*gt)}else((V=A==null?void 0:A.control)==null?void 0:V.border)&&this.control.drawBorder(t);if(p.underline||((Z=p.control)==null?void 0:Z.underline)){(A==null?void 0:A.type)===R.ElementType.SUBSCRIPT&&p.type!==R.ElementType.SUBSCRIPT&&this.underline.render(t);const gt=this.getElementRowMargin(p),rt=p.left||0;let Mt=0;p.type===R.ElementType.SUBSCRIPT&&(Mt=this.subscriptParticle.getOffsetY(p));const it=((C=p.control)==null?void 0:C.underline)?this.options.underlineColor:p.color;this.underline.recordFillInfo(t,x-rt,k+U.height-gt+Mt,G.width+rt,0,it,(D=p.textDecoration)==null?void 0:D.style)}else((A==null?void 0:A.underline)||((W=A==null?void 0:A.control)==null?void 0:W.underline))&&this.underline.render(t);if(p.strikeout){if(!p.type||bt.includes(p.type)){A&&(A.type===R.ElementType.SUBSCRIPT&&p.type!==R.ElementType.SUBSCRIPT||A.type===R.ElementType.SUPERSCRIPT&&p.type!==R.ElementType.SUPERSCRIPT||this.getElementSize(A)!==this.getElementSize(p))&&this.strikeout.render(t);const gt=this.textParticle.measureBasisWord(t,this.getElementFont(p));let rt=k+H+gt.actualBoundingBoxDescent*n-G.height/2;p.type===R.ElementType.SUBSCRIPT?rt+=this.subscriptParticle.getOffsetY(p):p.type===R.ElementType.SUPERSCRIPT&&(rt+=this.superscriptParticle.getOffsetY(p)),this.strikeout.recordFillInfo(t,x,rt,G.width)}}else(A==null?void 0:A.strikeout)&&this.strikeout.render(t);const{zone:Nt,startIndex:Vt,endIndex:ft}=this.range.getRange();if(Nt===g&&Vt!==ft&&Vt<=N&&N<=ft){const gt=this.position.getPositionContext();if(!gt.isTable&&!p.tdId||gt.tdId===p.tdId)if(Vt===N){const rt=d[Vt+1];rt&&rt.value===y&&(Q.x=x+G.width,Q.y=k,Q.height=U.height,Q.width+=this.options.rangeMinWidth)}else{let rt=G.width;rt===0&&U.elementList.length===1&&(rt=this.options.rangeMinWidth),Q.width||(Q.x=x,Q.y=k,Q.height=U.height),Q.width+=rt}}if(!s.disabled&&p.groupIds&&this.group.recordFillInfo(p,x,k,G.width,U.height),N++,p.type===R.ElementType.TABLE&&!p.hide){const gt=o[1]+o[3];for(let rt=0;rt<p.trList.length;rt++){const Mt=p.trList[rt];for(let it=0;it<Mt.tdList.length;it++){const et=Mt.tdList[it];this.drawRow(t,{elementList:et.value,positionList:et.positionList,rowList:et.rowList,pageNo:c,startIndex:0,innerWidth:(et.width-gt)*n,zone:g,isDrawLineBreak:T})}}}}if(U.isList&&this.listParticle.drawListStyle(t,U,h[U.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!O&&!M){if(Q.width&&Q.height){const{x:K,y:p,width:G,height:H}=Q;this.range.render(t,K,p,G,H)}if(S&&w&&w.id===X){const{coordinate:{leftTop:[K,p]}}=h[U.startIndex];this.tableParticle.drawRange(t,w,K,p)}}}}_drawFloat(t,e){const{scale:n}=this.options,o=this.position.getFloatPositionList(),{imgDisplays:s,pageNo:i}=e;for(let l=0;l<o.length;l++){const a=o[l],c=a.element;if((i===a.pageNo||a.zone===R.EditorZone.HEADER||a.zone==R.EditorZone.FOOTER)&&c.imgDisplay&&s.includes(c.imgDisplay)&&c.type===R.ElementType.IMAGE){const d=c.imgFloatPosition;this.imageParticle.render(t,c,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 S,X,N;const{elementList:e,positionList:n,rowList:o,pageNo:s}=t,{inactiveAlpha:i,pageMode:l,header:a,footer:c,pageNumber:d,lineNumber:h,pageBorder:u}=this.options,g=this.mode===R.EditorMode.PRINT,T=l===R.PageMode.CONTINUITY,P=this.getInnerWidth(),O=this.ctxList[s];O.globalAlpha=this.zone.isMainActive()?1:i,this._clearPage(s),(!g||!((S=this.options.modeRule[R.EditorMode.PRINT])==null?void 0:S.backgroundDisabled))&&this.background.render(O,s),g||this.area.render(O,s),!T&&this.options.watermark.data&&this.options.watermark.layer===R.WatermarkLayer.BOTTOM&&this.waterMark.render(O,s),g||this.margin.render(O,s),this._drawFloat(O,{pageNo:s,imgDisplays:[R.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(O,s);const M=(X=o[0])==null?void 0:X.startIndex;this.drawRow(O,{elementList:e,positionList:n,rowList:o,pageNo:s,startIndex:M,innerWidth:P,zone:R.EditorZone.MAIN}),this.getIsPagingMode()&&(a.disabled||this.header.render(O,s),d.disabled||this.pageNumber.render(O,s),c.disabled||this.footer.render(O,s)),this._drawFloat(O,{pageNo:s,imgDisplays:[R.ImageDisplay.FLOAT_TOP,R.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(O,s),this.elementList.length<=1&&!((N=this.elementList[0])==null?void 0:N.listId)&&this.placeholder.render(O),h.disabled||this.lineNumber.render(O,s),u.disabled||this.pageBorder.render(O),this.badge.render(O,s),this.isGraffitiMode()&&this.graffiti.render(O,s),!T&&this.options.watermark.data&&this.options.watermark.layer===R.WatermarkLayer.TOP&&this.waterMark.render(O,s)}_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(o=>{if(o.isIntersecting){const s=Number(o.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[s],pageNo:s})}})}),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:o=!0,isSetCursor:s=!0,isCompute:i=!0,isLazy:l=!0,isInit:a=!1,isSourceHistory:c=!1,isFirstRender:d=!1}=t||{};let{curIndex:h}=t||{};const u=this.getInnerWidth(),g=this.getIsPagingMode(),T=this.pageRowList.length;if(i){this.position.setFloatPositionList([]),g&&(e.disabled||this.header.compute(),n.disabled||this.footer.compute());const M=this.getMargins(),S=this.getHeight(),X=this.header.getExtraHeight(),N=this.getMainOuterHeight(),m=M[3],I=M[0]+X,f=on(this.elementList);if(this.rowList=this.computeRowList({startX:m,startY:I,pageHeight:S,mainOuterHeight:N,isPagingMode:g,innerWidth:u,surroundElementList:f,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 M=0;M<this.pageRowList.length;M++)this.pageList[M]||this._createPage(M);const P=this.pageRowList.length,O=this.pageList.length;if(O>P){const M=O-P;this.ctxList.splice(P,M),this.pageList.splice(P,M).forEach(S=>S.remove())}l&&g?this._lazyRender():this._immediateRender(),s?h=this.setCursor(h):this.range.getIsSelection()&&this.cursor.focus(),(o&&!d||h!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(h),Be(()=>{this.range.setRangeStyle(),i&&this.control.getActiveControl()&&this.control.reAwakeControl(),i&&!this.isReadonly()&&this.position.getPositionContext().isTable&&this.tableTool.render(),i&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),T!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(o||c)&&!a&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"))})}setCursor(t){var s;const e=this.position.getPositionContext(),n=this.position.getPositionList();if(e.isTable){const{index:i,trIndex:l,tdIndex:a}=e,d=(s=this.getOriginalElementList()[i].trList)==null?void 0:s[l].tdList[a].positionList;t===void 0&&d&&(t=d.length-1);const h=d==null?void 0:d[t];this.position.setCursorPosition(h||null)}else this.position.setCursorPosition(t!==void 0?n[t]:null);let o=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const l=this.getElementList()[t];if(qi.includes(l.type)){o=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(l,a)}}return this.cursor.drawCursor({isShow:o}),t}submitHistory(t){const e=this.position.getPositionContext(),n=nn(this.elementList),o=nn(this.header.getElementList()),s=nn(this.footer.getElementList()),i=$(this.range.getRange()),l=this.pageNo,a=$(e),c=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(c),this.setPageNo(l),this.position.setPositionContext($(a)),this.header.setElementList($(o)),this.footer.setElementList($(s)),this.elementList=$(n),this.range.replaceRange($(i)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){var t;this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent(),this.workerManager.destroy(),(t=this.lazyRenderIntersectionObserver)==null||t.disconnect()}clearSideEffect(){this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}}class gi{constructor(t){L(this,"executeMode");L(this,"executeCut");L(this,"executeCopy");L(this,"executePaste");L(this,"executeSelectAll");L(this,"executeBackspace");L(this,"executeSetRange");L(this,"executeReplaceRange");L(this,"executeSetPositionContext");L(this,"executeForceUpdate");L(this,"executeBlur");L(this,"executeHideCursor");L(this,"executeUndo");L(this,"executeRedo");L(this,"executePainter");L(this,"executeApplyPainterStyle");L(this,"executeFormat");L(this,"executeFont");L(this,"executeSize");L(this,"executeSizeAdd");L(this,"executeSizeMinus");L(this,"executeBold");L(this,"executeItalic");L(this,"executeUnderline");L(this,"executeStrikeout");L(this,"executeSuperscript");L(this,"executeSubscript");L(this,"executeColor");L(this,"executeHighlight");L(this,"executeTitle");L(this,"executeList");L(this,"executeRowFlex");L(this,"executeRowMargin");L(this,"executeInsertTable");L(this,"executeInsertTableTopRow");L(this,"executeInsertTableBottomRow");L(this,"executeInsertTableLeftCol");L(this,"executeInsertTableRightCol");L(this,"executeDeleteTableRow");L(this,"executeDeleteTableCol");L(this,"executeDeleteTable");L(this,"executeMergeTableCell");L(this,"executeCancelMergeTableCell");L(this,"executeSplitVerticalTableCell");L(this,"executeSplitHorizontalTableCell");L(this,"executeTableTdVerticalAlign");L(this,"executeTableBorderType");L(this,"executeTableBorderColor");L(this,"executeTableTdBorderType");L(this,"executeTableTdSlashType");L(this,"executeTableTdBackgroundColor");L(this,"executeTableSelectAll");L(this,"executeImage");L(this,"executeHyperlink");L(this,"executeDeleteHyperlink");L(this,"executeCancelHyperlink");L(this,"executeEditHyperlink");L(this,"executeSeparator");L(this,"executePageBreak");L(this,"executeAddWatermark");L(this,"executeDeleteWatermark");L(this,"executeSearch");L(this,"executeSearchNavigatePre");L(this,"executeSearchNavigateNext");L(this,"executeReplace");L(this,"executePrint");L(this,"executeReplaceImageElement");L(this,"executeSaveAsImageElement");L(this,"executeSetImageCrop");L(this,"executeSetImageCaption");L(this,"executeChangeImageDisplay");L(this,"executePageMode");L(this,"executePageScale");L(this,"executePageScaleRecovery");L(this,"executePageScaleMinus");L(this,"executePageScaleAdd");L(this,"executePaperSize");L(this,"executePaperDirection");L(this,"executeSetPaperMargin");L(this,"executeSetMainBadge");L(this,"executeSetAreaBadge");L(this,"executeInsertElementList");L(this,"executeInsertArea");L(this,"executeSetAreaValue");L(this,"executeSetAreaProperties");L(this,"executeDeleteArea");L(this,"executeLocationArea");L(this,"executeClearGraffiti");L(this,"executeAppendElementList");L(this,"executeUpdateElementById");L(this,"executeDeleteElementById");L(this,"executeSetValue");L(this,"executeRemoveControl");L(this,"executeTranslate");L(this,"executeSetLocale");L(this,"executeLocationCatalog");L(this,"executeWordTool");L(this,"executeSetHTML");L(this,"executeSetGroup");L(this,"executeDeleteGroup");L(this,"executeLocationGroup");L(this,"executeSetZone");L(this,"executeSetControlValue");L(this,"executeSetControlValueList");L(this,"executeSetControlExtension");L(this,"executeSetControlExtensionList");L(this,"executeSetControlProperties");L(this,"executeSetControlPropertiesList");L(this,"executeSetControlHighlight");L(this,"executeLocationControl");L(this,"executeInsertControl");L(this,"executeJumpControl");L(this,"executeUpdateOptions");L(this,"executeInsertTitle");L(this,"executeFocus");L(this,"executeComputeElementListHeight");L(this,"getCatalog");L(this,"getImage");L(this,"getOptions");L(this,"getValue");L(this,"getValueAsync");L(this,"getAreaValue");L(this,"getHTML");L(this,"getText");L(this,"getWordCount");L(this,"getCursorPosition");L(this,"getRemainingContentHeight");L(this,"getRange");L(this,"getRangeText");L(this,"getRangeContext");L(this,"getRangeRow");L(this,"getRangeParagraph");L(this,"getKeywordRangeList");L(this,"getKeywordContext");L(this,"getPaperMargin");L(this,"getSearchNavigateInfo");L(this,"getLocale");L(this,"getGroupIds");L(this,"getControlValue");L(this,"getControlList");L(this,"getContainer");L(this,"getTitleValue");L(this,"getPositionContextByEvent");L(this,"getElementById");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.executeDeleteArea=t.deleteArea.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.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 Li(r,t){let e=0;for(let n=1;n<t;n++){const o=r[n],s=r[n-1];(o.value===y&&!o.listWrap&&!o.listId||o.listId!==(s==null?void 0:s.listId)&&s.value!==y||o.titleId!==(s==null?void 0:s.titleId)&&s.value!==y)&&e++}return e}function Vr(r,t){return r===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:r===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:r===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${r}px`,height:`${t}px`}}async function pr(r,t){const{width:e,height:n,direction:o=R.PaperDirection.VERTICAL,iframeInfoList:s=[]}=t,i=document.createElement("iframe");i.style.visibility="hidden",i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.width="0",i.style.height="0",i.style.border="none",document.body.append(i);const l=i.contentWindow,a=l.document;a.open();const c=document.createElement("div"),d=Vr(e,n);r.forEach((g,T)=>{const P=document.createElement("div");P.style.position="relative",P.style.width=o===R.PaperDirection.HORIZONTAL?d.height:d.width,P.style.height=o===R.PaperDirection.HORIZONTAL?d.width:d.height;const O=document.createElement("img");O.style.width="100%",O.style.height="100%",O.style.position="absolute",O.style.left="0",O.style.top="0",O.src=g,P.append(O),(s[T]||[]).forEach(S=>{const X=document.createElement("iframe");if(X.style.position="absolute",X.style.left=`${S.x}px`,X.style.top=`${S.y}px`,X.style.width=`${S.width}px`,X.style.height=`${S.height}px`,X.style.border="none",S.src)X.src=S.src;else if(S.srcdoc){const N=`
|
|
84
|
+
`)}}return n}return t(st(r))}function nn(r){return Ge(r,["metrics","style"])}function $t(r){return!!(r==null?void 0:r.type)&&(to.includes(r.type)||r.imgDisplay===R.ImageDisplay.INLINE)}function Bo(r,t){const e=document.createElement(t);for(let n=0;n<r.attributes.length;n++){const o=r.attributes[n];e.setAttribute(o.name,o.value)}return e.innerHTML=r.innerHTML,e}function on(r){const t=[];for(let e=0;e<r.length;e++){const n=r[e];n.imgDisplay===R.ImageDisplay.SURROUND&&t.push(n)}return t}function ko(r,t){var e;for(let n=r.length-1;n>=0;n--)((e=r[n].imgFloatPosition)==null?void 0:e.pageNo)===t&&r.splice(n,1)}function Oe(r,t,e=R.LocationPosition.BEFORE){var o,s,i,l,a,c,d,h,u,g,T,P,O,M,S;if(!((o=r[t])==null?void 0:o.hide)&&!((i=(s=r[t])==null?void 0:s.control)==null?void 0:i.hide)&&!((a=(l=r[t])==null?void 0:l.area)==null?void 0:a.hide))return t;let n=t;if(e===R.LocationPosition.BEFORE)for(n=t-1;n>0;){if(!((c=r[n])==null?void 0:c.hide)&&!((h=(d=r[n])==null?void 0:d.control)==null?void 0:h.hide)&&!((g=(u=r[n])==null?void 0:u.area)==null?void 0:g.hide))return n;n--}else for(n=t+1;n<r.length;){if(!((T=r[n])==null?void 0:T.hide)&&!((O=(P=r[n])==null?void 0:P.control)==null?void 0:O.hide)&&!((S=(M=r[n])==null?void 0:M.area)==null?void 0:S.hide))return n;n++}return n}function Ao(r){localStorage.setItem(Ve,JSON.stringify({text:r.text,elementList:r.elementList}))}function Gn(){const r=localStorage.getItem(Ve);return r?JSON.parse(r):null}function xn(){localStorage.removeItem(Ve)}async function _o(r,t,e){if(!r&&!t&&!e.length)return;const n=new Blob([r],{type:"text/plain"}),o=new Blob([t],{type:"text/html"});if(window.ClipboardItem){const s=new ClipboardItem({[n.type]:n,[o.type]:o});await window.navigator.clipboard.write([s])}else{const s=document.createElement("div");s.setAttribute("contenteditable","true"),s.innerHTML=t,document.body.append(s);const i=window.getSelection(),l=document.createRange(),a=document.createElement("span");a.innerText=`
|
|
85
|
+
`,s.append(a),l.selectNodeContents(s),i==null||i.removeAllRanges(),i==null||i.addRange(l),document.execCommand("copy"),s.remove()}Ao({text:r,elementList:e})}async function Jn(r,t){const e=ae(r,t);document.body.append(e);const n=e.innerText;e.remove();const o=e.innerHTML;!n&&!o&&!r.length||await _o(n,o,st(r))}function zo(r){let t=!1;for(let e=0;e<r.items.length;e++)if(r.items[e].kind==="file"){t=!0;break}return t}function sn(r,t){const e=r.getDraw();if(e.isReadonly()||e.isDisabled()||e.getControl().getIsDisabledPasteControl())return;const n=e.getRange(),{startIndex:o}=n.getRange(),s=e.getElementList();if(~o&&!n.getIsSelectAll()){const i=s[o];if((i==null?void 0:i.titleId)||(i==null?void 0:i.listId)){let l=0;for(;l<t.length;){const a=t[l];if(i.titleId&&/^\n/.test(a.value))break;if(no.includes(a.type)){if(t.splice(l,1),a.valueList)for(let c=0;c<a.valueList.length;c++){const d=a.valueList[c];d.value===y||d.value===`
|
|
86
|
+
`||(t.splice(l,0,d),l++)}l--}l++}}It(s,t,o,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function vn(r,t){const e=r.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=Re(t,{innerWidth:e.getOriginalInnerWidth()});sn(r,n)}function rn(r,t){const e=r.getDraw();if(e.isReadonly()||e.isDisabled())return;const{pasteImage:n}=e.getOverride();if(n){const a=n(t);if((a==null?void 0:a.preventDefault)!==!1)return}const o=e.getRange(),{startIndex:s}=o.getRange(),i=e.getElementList(),l=new FileReader;l.readAsDataURL(t),l.onload=()=>{const a=new Image,c=l.result;a.src=c,a.onload=()=>{const d={value:c,type:R.ElementType.IMAGE,width:a.width,height:a.height};~s&&It(i,[d],s,{editorOptions:e.getOptions()}),e.insertElementList([d])}}}function $o(r,t){const e=r.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=t.clipboardData;if(!n)return;const{paste:o}=e.getOverride();if(o){const i=o(t);if((i==null?void 0:i.preventDefault)!==!1)return}if(!zo(n)){const i=n.getData("text"),l=Gn();if(l&&We(i)===We(l.text)){sn(r,l.elementList);return}}xn();let s=!1;for(let i=0;i<n.items.length;i++)if(n.items[i].type==="text/html"){s=!0;break}for(let i=0;i<n.items.length;i++){const l=n.items[i];if(l.kind==="string"){if(l.type==="text/plain"&&!s){l.getAsString(a=>{r.input(a)});break}if(l.type==="text/html"&&s){l.getAsString(a=>{vn(r,a)});break}}else if(l.kind==="file"&&l.type.includes("image")){const a=l.getAsFile();a&&rn(r,a)}}}async function jo(r,t){const e=r.getDraw();if(e.isReadonly()||e.isDisabled())return;const{paste:n}=e.getOverride();if(n){const i=n();if((i==null?void 0:i.preventDefault)!==!1)return}const o=await navigator.clipboard.readText(),s=Gn();if(s&&We(o)===We(s.text)){sn(r,s.elementList);return}if(xn(),t==null?void 0:t.isPlainText)o&&r.input(o);else{const i=await navigator.clipboard.read();let l=!1;for(const a of i)if(a.types.includes("text/html")){l=!0;break}for(const a of i)if(a.types.includes("text/plain")&&!l){const d=await(await a.getType("text/plain")).text();d&&r.input(d)}else if(a.types.includes("text/html")&&l){const d=await(await a.getType("text/html")).text();d&&vn(r,d)}else if(a.types.some(c=>c.startsWith("image/"))){const c=a.types.find(h=>h.startsWith("image/")),d=await a.getType(c);rn(r,d)}}}class qo{constructor(t,e){L(this,"draw");L(this,"container");L(this,"agentCursorDom");L(this,"canvasEvent");L(this,"eventBus");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(`${v}-inputarea`),n.innerText="",this.container.append(n),this.agentCursorDom=n,n.onkeydown=o=>this._keyDown(o),n.oninput=this._input.bind(this),n.onpaste=o=>this._paste(o),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||($o(this.canvasEvent,t),t.preventDefault())}_compositionstart(){this.canvasEvent.compositionstart()}_compositionend(t){this.canvasEvent.compositionend(t)}}class ts{constructor(t,e){L(this,"ANIMATION_CLASS",`${v}-cursor--animation`);L(this,"draw");L(this,"container");L(this,"options");L(this,"position");L(this,"cursorDom");L(this,"cursorAgent");L(this,"blinkTimeout");L(this,"hitLineStartIndex");this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${v}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new qo(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(Ai&&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:o}=this.options,{color:s,width:i,isShow:l=!0,isBlink:a=!0,isFocus:c=!0,hitLineStartIndex:d}=Y(Y({},o),t),h=this.draw.getHeight(),u=this.draw.getPageGap();this.hitLineStartIndex=d,d&&(e=this.position.getPositionList()[d]);const{metrics:g,coordinate:{leftTop:T,rightTop:P},ascent:O,pageNo:M}=e,N=(this.draw.getZone().isMainActive()?M:this.draw.getPageNo())*(h+u),m=vi*n,I=Math.min(g.height/4,m),f=g.height+I*2,F=this.cursorAgent.getAgentCursorDom();c&&setTimeout(()=>{this.focus()});const V=g.boundingBoxDescent<0?0:g.boundingBoxDescent,Z=T[1]+O+V-(f-I)+N,E=d?T[0]:P[0];if(F.style.left=`${E}px`,F.style.top=`${Z+f-m}px`,!l){this.recoveryCursor();return}const D=this.cursorDom.style.top,W=this.draw.isReadonly();this.cursorDom.style.width=`${i*n}px`,this.cursorDom.style.backgroundColor=s,this.cursorDom.style.left=`${E}px`,this.cursorDom.style.top=`${Z}px`,this.cursorDom.style.display=W?"none":"block",this.cursorDom.style.height=`${f}px`,a?this._setBlinkTimeout():this._clearBlinkTimeout(),c&&Be(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(D)>Z?Lt.UP:Lt.DOWN})})}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:n}=t;if(!e||!n)return;const{pageNo:o,coordinate:{leftTop:s,leftBottom:i}}=e,l=Hi(this.container),a={left:0,right:0,top:0,bottom:0},c=l===document.documentElement;if(c)a.right=window.innerWidth,a.bottom=window.innerHeight;else{const{left:P,right:O,top:M,bottom:S}=l.getBoundingClientRect();a.left=P,a.right=O,a.top=M,a.bottom=S}const d=o*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,h=n===Lt.UP,u=i[0]+(c?0:a.left),g=h?s[1]+d:i[1]+d,{maskMargin:T}=this.options;if(a.top+=T[0],a.bottom-=T[2],!(u>=a.left&&u<=a.right&&g>=a.top&&g<=a.bottom)){const{scrollLeft:P,scrollTop:O}=l;h?l.scroll(P,O-(a.top-g)):l.scroll(P,O+g-a.bottom)}}}var ln;(function(r){r[r.LEFT=0]="LEFT",r[r.CENTER=1]="CENTER",r[r.RIGHT=2]="RIGHT"})(ln||(ln={}));function jt(r){return Gt?r.metaKey:r.ctrlKey}R.KeyMap=void 0,function(r){r.Delete="Delete",r.Backspace="Backspace",r.ALT="Alt",r.Enter="Enter",r.Left="ArrowLeft",r.Right="ArrowRight",r.Up="ArrowUp",r.Down="ArrowDown",r.Home="Home",r.End="End",r.ESC="Escape",r.TAB="Tab",r.META="Meta",r.LEFT_BRACKET="[",r.RIGHT_BRACKET="]",r.COMMA=",",r.PERIOD=".",r.LEFT_ANGLE_BRACKET="<",r.RIGHT_ANGLE_BRACKET=">",r.EQUAL="=",r.MINUS="-",r.PLUS="+",r.A="a",r.B="b",r.C="c",r.D="d",r.E="e",r.F="f",r.G="g",r.H="h",r.I="i",r.J="j",r.K="k",r.L="l",r.M="m",r.N="n",r.O="o",r.P="p",r.Q="q",r.R="r",r.S="s",r.T="t",r.U="u",r.V="v",r.W="w",r.X="x",r.Y="y",r.Z="z",r.A_UPPERCASE="A",r.B_UPPERCASE="B",r.C_UPPERCASE="C",r.D_UPPERCASE="D",r.E_UPPERCASE="E",r.F_UPPERCASE="F",r.G_UPPERCASE="G",r.H_UPPERCASE="H",r.I_UPPERCASE="I",r.J_UPPERCASE="J",r.K_UPPERCASE="K",r.L_UPPERCASE="L",r.M_UPPERCASE="M",r.N_UPPERCASE="N",r.O_UPPERCASE="O",r.P_UPPERCASE="P",r.Q_UPPERCASE="Q",r.R_UPPERCASE="R",r.S_UPPERCASE="S",r.T_UPPERCASE="T",r.U_UPPERCASE="U",r.V_UPPERCASE="V",r.W_UPPERCASE="W",r.X_UPPERCASE="X",r.Y_UPPERCASE="Y",r.Z_UPPERCASE="Z",r.ZERO="0",r.ONE="1",r.TWO="2",r.THREE="3",r.FOUR="4",r.FIVE="5",r.SIX="6",r.SEVEN="7",r.EIGHT="8",r.NINE="9"}(R.KeyMap||(R.KeyMap={}));class Ce{constructor(t,e){L(this,"element");L(this,"control");this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getCode(){var t;return((t=this.element.control)==null?void 0:t.code)||null}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),n=t[e],o=[];let s=e;for(;s>0;){const l=t[s];if(l.controlId!==n.controlId||l.controlComponent===R.ControlComponent.PREFIX||l.controlComponent===R.ControlComponent.PRE_TEXT)break;l.controlComponent===R.ControlComponent.VALUE&&o.unshift(l),s--}let i=e+1;for(;i<t.length;){const l=t[i];if(l.controlId!==n.controlId||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT)break;l.controlComponent===R.ControlComponent.VALUE&&o.push(l),i++}return o}setValue(){return-1}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:o}=this.element,s=e.elementList||this.control.getElementList(),{startIndex:i}=e.range||this.control.getRange(),l=s[i];let a=i;for(;a>0;){const d=s[a];if(d.controlId!==l.controlId||d.controlComponent===R.ControlComponent.PREFIX||d.controlComponent===R.ControlComponent.PRE_TEXT)break;if(d.controlComponent===R.ControlComponent.CHECKBOX){const h=d.checkbox;h.value=t.includes(h.code)}a--}let c=i+1;for(;c<s.length;){const d=s[c];if(d.controlId!==l.controlId||d.controlComponent===R.ControlComponent.POSTFIX||d.controlComponent===R.ControlComponent.POST_TEXT)break;if(d.controlComponent===R.ControlComponent.CHECKBOX){const h=d.checkbox;h.value=t.includes(h.code)}c++}o.code=t.join(","),this.control.repaintControl({curIndex:i,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:o}=e;return t.key===R.KeyMap.Backspace||t.key===R.KeyMap.Delete?this.control.removeControl(n):o}cut(){return-1}}class an extends Ce{setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:o}=this.element,s=e.elementList||this.control.getElementList(),{startIndex:i}=e.range||this.control.getRange(),l=s[i];let a=i;for(;a>0;){const d=s[a];if(d.controlId!==l.controlId||d.controlComponent===R.ControlComponent.PREFIX||d.controlComponent===R.ControlComponent.PRE_TEXT)break;if(d.controlComponent===R.ControlComponent.RADIO){const h=d.radio;h.value=t.includes(h.code)}a--}let c=i+1;for(;c<s.length;){const d=s[c];if(d.controlId!==l.controlId||d.controlComponent===R.ControlComponent.POSTFIX||d.controlComponent===R.ControlComponent.POST_TEXT)break;if(d.controlComponent===R.ControlComponent.RADIO){const h=d.radio;h.value=t.includes(h.code)}c++}o.code=t.join(","),this.control.repaintControl({curIndex:i,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}}function Bn(r){const t=r.getDraw(),e=t.getPosition(),n=t.getRange();r.isAllowDrag=!0,r.cacheRange=$(n.getRange()),r.cacheElementList=t.getElementList(),r.cachePositionList=e.getPositionList(),r.cachePositionContext=e.getPositionContext()}function kn(r,t){const{checkbox:e,control:n}=r;if(!n)t.getCheckboxParticle().setSelect(r);else{const o=(n==null?void 0:n.code)?n.code.split(","):[];if(e==null?void 0:e.value){const i=o.findIndex(l=>l===e.code);o.splice(i,1)}else(e==null?void 0:e.code)&&o.push(e.code);const s=t.getControl().getActiveControl();s instanceof Ce&&s.setSelect(o)}}function An(r,t){const{radio:e,control:n}=r;if(!n)t.getRadioParticle().setSelect(r);else{const o=(e==null?void 0:e.code)?[e.code]:[],s=t.getControl().getActiveControl();s instanceof an&&s.setSelect(o)}}function es(r,t){var w,K;const e=t.getDraw();let n=e.isReadonly();const o=e.getRange(),s=e.getPosition(),i=o.getRange();if(r.button===ln.RIGHT&&(i.isCrossRowCol||!o.getIsCollapsed()))return;if(!t.isAllowDrag&&!n&&i.startIndex!==i.endIndex&&o.getIsPointInRange(r.offsetX,r.offsetY)){Bn(t);return}const a=r.target.dataset.index;a&&e.setPageNo(Number(a)),t.isAllowSelection=!0;const c=$(s.getPositionContext()),d=s.adjustPositionContext({x:r.offsetX,y:r.offsetY});if(!d)return;const{index:h,isDirectHit:u,isCheckbox:g,isRadio:T,isImage:P,isLabel:O,isTable:M,tdValueIndex:S,hitLineStartIndex:X}=d;t.mouseDownStartPosition=B(Y({},d),{index:M?S:h,x:r.offsetX,y:r.offsetY});const N=e.getElementList(),m=s.getPositionList(),I=M?S:h,f=N[I],F=!!(u&&P),V=!!(u&&g),Z=!!(u&&T),E=!!(u&&O);if(~h){let p=I,G=I;if(r.shiftKey){const{startIndex:H}=o.getRange();~H&&s.getPositionContext().tdId===c.tdId&&(I>H?p=H:G=H)}if(o.setRange(p,G),s.setCursorPosition(m[I]),n=e.isReadonly(),V&&!n)kn(f,e);else if(Z&&!n)An(f,e);else if(f.controlComponent===R.ControlComponent.VALUE&&(((w=f.control)==null?void 0:w.type)===R.ControlType.CHECKBOX||((K=f.control)==null?void 0:K.type)===R.ControlType.RADIO)){let H=I;for(;H>0;){const x=N[H];if(x.controlComponent===R.ControlComponent.CHECKBOX){kn(x,e);break}else if(x.controlComponent===R.ControlComponent.RADIO){An(x,e);break}H--}}else e.render({curIndex:I,isCompute:!1,isSubmitHistory:!1,isSetCursor:!F&&!V&&!Z});X&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:X})}const D=e.getEventBus();E&&D.isSubscribe("labelMousedown")&&D.emit("labelMousedown",{evt:r,element:f});const W=e.getPreviewer();if(W.clearResizer(),F){const p={dragDisable:n||!f.controlId&&e.getMode()===R.EditorMode.FORM};f.type===R.ElementType.LATEX&&(p.mime="svg",p.srcKey="laTexSVG"),W.drawResizer(f,m[I],p),e.getCursor().drawCursor({isShow:!1}),Bn(t),(f.imgDisplay===R.ImageDisplay.SURROUND||f.imgDisplay===R.ImageDisplay.FLOAT_TOP||f.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(f),D.isSubscribe("imageMousedown")&&D.emit("imageMousedown",{evt:r,element:f})}const C=e.getTableTool();C.dispose(),M&&!n&&e.getMode()!==R.EditorMode.FORM&&C.render();const U=e.getHyperlinkParticle();U.clearHyperlinkPopup(),f.type===R.ElementType.HYPERLINK&&(jt(r)?U.openHyperlink(f):U.drawHyperlinkPopup(f,m[I]));const Q=e.getDateParticle();Q.clearDatePicker(),f.type===R.ElementType.DATE&&!n&&Q.renderDatePicker(f,m[I])}function Ee(r){const t=j();return Reflect.set(r,"dragId",t),t}function De(r,t){return t.findIndex(e=>e.dragId===r)}function _n(r,t,e){const n=e.getDraw();if(r.imgDisplay===R.ImageDisplay.SURROUND||r.imgDisplay===R.ImageDisplay.FLOAT_TOP||r.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM){const o=t.offsetX-e.mouseDownStartPosition.x,s=t.offsetY-e.mouseDownStartPosition.y,i=r.imgFloatPosition;r.imgFloatPosition={x:i.x+o,y:i.y+s,pageNo:n.getPageNo()}}n.getImageParticle().destroyFloatImage()}function ns(r,t){var e,n,o,s,i,l;if(t.isAllowDrop){const a=t.getDraw();if(a.isReadonly()||a.isDisabled()){t.mousedown(r);return}const c=a.getPosition(),d=c.getPositionList(),h=c.getPositionContext(),u=a.getRange(),g=t.cacheRange,T=t.cacheElementList,P=t.cachePositionList,O=t.cachePositionContext,M=u.getRange(),S=g.startIndex===g.endIndex,X=S?g.startIndex-1:g.startIndex,N=g.endIndex;if(M.startIndex>=X&&M.endIndex<=N&&((e=t.cachePositionContext)==null?void 0:e.tdId)===h.tdId){a.clearSideEffect();let it=!1,et=!1;if(S){const q=T[N];if(q.type===R.ElementType.IMAGE||q.type===R.ElementType.LATEX){if(_n(q,r,t),q.imgDisplay===R.ImageDisplay.SURROUND||q.imgDisplay===R.ImageDisplay.FLOAT_TOP||q.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)a.getPreviewer().drawResizer(q),it=!0;else{const nt=P[N];a.getPreviewer().drawResizer(q,nt)}et=q.imgDisplay===R.ImageDisplay.SURROUND}}u.replaceRange(Y({},g)),a.render({isCompute:et,isSubmitHistory:it,isSetCursor:!1});return}const m=T.slice(X+1,N+1),I=m.find(it=>it.controlId);if(I){const it=T[X+1],et=T[N];if(!((!it.controlId||it.controlComponent===R.ControlComponent.PREFIX)&&(!et.controlId||et.controlComponent===R.ControlComponent.POSTFIX)||it.controlId===et.controlId&&it.controlComponent===R.ControlComponent.PREFIX&&et.controlComponent===R.ControlComponent.POSTFIX||((n=it.control)==null?void 0:n.type)===R.ControlType.TEXT&&it.controlComponent===R.ControlComponent.VALUE&&((o=et.control)==null?void 0:o.type)===R.ControlType.TEXT&&et.controlComponent===R.ControlComponent.VALUE)){a.render({curIndex:M.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const f=a.getControl(),F=a.getElementList(),V=!I||!!F[M.startIndex].controlId||!f.getIsElementListContainFullControl(m),Z=a.getOptions(),E=m.map(it=>{if(!it.type||it.type===R.ElementType.TEXT){const et={value:it.value},q=[...Dt];return V||q.push(..._e),q.forEach(nt=>{const b=it[nt];b!==void 0&&(et[nt]=b)}),et}else{let et=$(it);return V&&(et=Ht(et,_e)),Pt([et],{isHandleFirstElement:!1,editorOptions:Z}),et}});It(F,E,M.startIndex,{editorOptions:a.getOptions()});const D=T[X],W=P[X],C=Ee(T[X]),U=Ee(T[N]),Q=E.length;let w=M.startIndex,K=w+Q;const p=f.getActiveControl();if(p&&T[w].controlComponent!==R.ControlComponent.POSTFIX?(K=p.setValue(E),w=K-Q):a.spliceElementList(F,w+1,0,E),!~K){a.render({isSetCursor:!1});return}const G=Ee(F[w]),H=Ee(F[K]),x=De(C,T),k=De(U,T),A=T[k];if(A.controlId&&A.controlComponent!==R.ControlComponent.POSTFIX)u.replaceRange(B(Y({},g),{startIndex:x,endIndex:k})),(s=f.getActiveControl())==null||s.cut();else{let it=!0;if(O==null?void 0:O.isTable){const{tableId:et,trIndex:q,tdIndex:nt}=O;it=!a.getOriginalElementList().some(Zt=>{var J,Ne,Tt,fe;return Zt.id===et&&((fe=(Tt=(Ne=(J=Zt==null?void 0:Zt.trList)==null?void 0:J[q])==null?void 0:Ne.tdList)==null?void 0:Tt[nt])==null?void 0:fe.deletable)===!1})}it&&a.spliceElementList(T,x+1,k-x)}const Nt=F[M.startIndex],Vt=d[M.startIndex];let ft=h.index;ft&&(Nt.tableId&&!D.tableId?W.index<ft&&(ft-=Q):!Nt.tableId&&D.tableId&&Vt.index<ft&&(ft+=Q),c.setPositionContext(B(Y({},h),{index:ft})));const gt=De(G,F),rt=De(H,F);u.setRange(S?rt:gt,rt,M.tableId,M.startTdIndex,M.endTdIndex,M.startTrIndex,M.endTrIndex),a.clearSideEffect();let Mt=null;if(S){const et=a.getElementList()[rt];(et.type===R.ElementType.IMAGE||et.type===R.ElementType.LATEX)&&(_n(et,r,t),Mt=et)}if(a.render({isSetCursor:!1}),p?f.emitControlContentChange():D.controlId&&f.emitControlContentChange({context:{range:g,elementList:T},controlElement:D}),Mt)if(Mt.imgDisplay===R.ImageDisplay.SURROUND||Mt.imgDisplay===R.ImageDisplay.FLOAT_TOP||Mt.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)a.getPreviewer().drawResizer(Mt);else{const et=c.getPositionList()[rt];a.getPreviewer().drawResizer(Mt,et)}}else t.isAllowDrag&&((i=t.cacheRange)==null?void 0:i.startIndex)!==((l=t.cacheRange)==null?void 0:l.endIndex)&&t.mousedown(r)}function is(r,t){const e=t.getDraw();if(!e.getOptions().pageOuterSelectionDisable)return;const n=e.getPageContainer(),{x:o,y:s,width:i,height:l}=n.getBoundingClientRect();r.x>=o&&r.x<=o+i&&r.y>=s&&r.y<=s+l||t.setIsAllowSelection(!1)}function os(r,t){var I;const e=t.getDraw();if(t.isAllowDrag){const f=r.offsetX,F=r.offsetY,{startIndex:V,endIndex:Z}=t.cacheRange,E=t.cachePositionList;for(let W=V+1;W<=Z;W++){const{coordinate:{leftTop:C,rightBottom:U}}=E[W];if(f>=C[0]&&f<=U[0]&&F>=C[1]&&F<=U[1])return}const D=(I=t.cacheRange)==null?void 0:I.startIndex;if(D){const W=t.cacheElementList[D];(W==null?void 0:W.type)===R.ElementType.IMAGE&&(W.imgDisplay===R.ImageDisplay.SURROUND||W.imgDisplay===R.ImageDisplay.FLOAT_TOP||W.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)&&(e.getPreviewer().clearResizer(),e.getImageParticle().dragFloatImage(r.movementX,r.movementY))}t.dragover(r),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const o=r.target.dataset.index;o&&e.setPageNo(Number(o));const s=e.getPosition(),i=s.getPositionByXY({x:r.offsetX,y:r.offsetY});if(!~i.index)return;const{index:l,isTable:a,tdValueIndex:c,tdIndex:d,trIndex:h,tableId:u,trId:g,tdId:T}=i,{index:P,isTable:O,tdIndex:M,trIndex:S,tableId:X}=t.mouseDownStartPosition,N=a?c:l,m=e.getRange();if(a&&O&&(d!==M||h!==S))m.setRange(N,N,u,M,d,S,h),s.setPositionContext({isTable:a,index:l,trIndex:h,tdIndex:d,tdId:T,trId:g,tableId:u});else{let f=~N?N:0;if((O||a)&&X!==u)return;let F=P;if(F>f&&([F,f]=[f,F]),F===f)return;const V=e.getElementList(),Z=V[F+1],E=V[f];if((Z==null?void 0:Z.controlComponent)===R.ControlComponent.PLACEHOLDER&&(E==null?void 0:E.controlComponent)===R.ControlComponent.PLACEHOLDER&&Z.controlId===E.controlId)return;m.setRange(F,f)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function ss(r){var l,a,c,d;const t=r.getDraw(),e=t.getRange(),n=e.getRange(),o=t.getElementList(),s=o[n.startIndex];if(!s.hide&&!((l=s.control)==null?void 0:l.hide)&&!((a=s.area)==null?void 0:a.hide))return;let i=n.startIndex;for(;i>0;){const h=o[i];let u=null;h.controlId?(u=t.getControl().removeControl(i),u!==null&&(i=u)):(t.spliceElementList(o,i,1),u=i-1,i--);const g=o[u];if(!g||!g.hide&&!((c=g.control)==null?void 0:c.hide)&&!((d=g.area)==null?void 0:d.hide)){if(u){n.startIndex=u,n.endIndex=u,e.replaceRange(n);const T=t.getPosition(),P=T.getPositionList();T.setCursorPosition(P[u])}break}}}function rs(r,t){var c;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&ss(t);const o=e.getControl(),{startIndex:s,endIndex:i,isCrossRowCol:l}=n.getRange();let a;if(l){const d=e.getTableParticle().getRangeRowCol();if(!d)return;let h=!1;for(let u=0;u<d.length;u++){const g=d[u];for(let T=0;T<g.length;T++){const P=g[T];P.value.length>1&&(e.spliceElementList(P.value,1,P.value.length-1),h=!0)}}a=h?0:null}else if(o.getActiveControl()&&o.getIsRangeCanCaptureEvent())a=o.keydown(r),a&&o.emitControlContentChange();else{const d=e.getPosition().getCursorPosition();if(!d)return;const{index:h}=d,u=n.getIsCollapsed(),g=e.getElementList();if(u&&h===0){const M=g[h];if(M.value===y){M.listId&&e.getListParticle().unsetList(),r.preventDefault();return}}const T=g[s];if(u&&T.rowFlex&&T.value===y){const M=n.getRangeRowElementList();if(M){const S=g[s-1];M.forEach(X=>{X.rowFlex=S==null?void 0:S.rowFlex})}}const P=T.value===y?g[s-1]:T,O=g[i+1];if((P==null?void 0:P.titleId)&&(O==null?void 0:O.titleId)&&P.level===O.level&&P.titleId!==O.titleId){const M=P.titleId,S=O.titleId;let X=i+1;for(;X<g.length&&((c=g[X])==null?void 0:c.titleId)===S;)g[X].titleId=M,X++}u?e.spliceElementList(g,h,1):e.spliceElementList(g,s+1,i-s),a=u?h-1:s}e.getGlobalEvent().setCanvasEventAbility(),a===null?(n.setRange(s,s),e.render({curIndex:s,isSubmitHistory:!1})):(n.setRange(a,a),e.render({curIndex:a}))}function ls(r){var l,a,c,d;const t=r.getDraw(),n=t.getRange().getRange(),o=t.getElementList(),s=o[n.startIndex+1];if(!s.hide&&!((l=s.control)==null?void 0:l.hide)&&!((a=s.area)==null?void 0:a.hide))return;const i=n.startIndex+1;for(;i<o.length;){const h=o[i];let u=null;h.controlId?u=t.getControl().removeControl(i):(t.spliceElementList(o,i,1),u=i);const g=o[u];if(!g||!g.hide&&!((c=g.control)==null?void 0:c.hide)&&!((d=g.area)==null?void 0:d.hide))break}}function as(r,t){var d;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:o,endIndex:s,isCrossRowCol:i}=n.getRange(),l=e.getElementList(),a=e.getControl();n.getIsCollapsed()&&ls(t);let c;if(i){const h=e.getTableParticle().getRangeRowCol();if(!h)return;let u=!1;for(let g=0;g<h.length;g++){const T=h[g];for(let P=0;P<T.length;P++){const O=T[P];O.value.length>1&&(e.spliceElementList(O.value,1,O.value.length-1),u=!0)}}c=u?0:null}else if(a.getActiveControl()&&a.getIsRangeWithinControl())c=a.keydown(r),c&&a.emitControlContentChange();else if((d=l[s+1])==null?void 0:d.controlId)c=a.removeControl(s+1);else{const h=e.getPosition(),u=h.getCursorPosition();if(!u)return;const{index:g}=u,T=h.getPositionContext();if(T.isDirectHit&&T.isImage)e.spliceElementList(l,g,1),c=g-1;else{const P=n.getIsCollapsed();if(!P)e.spliceElementList(l,o+1,s-o);else{if(!l[g+1])return;e.spliceElementList(l,g+1,1)}c=P?g:o}}e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(o,o),e.render({curIndex:o,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}))}function Rs(r,t){var T,P,O,M,S,X,N;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:o,endIndex:s}=n.getRange(),i=n.getIsCollapsed(),l=e.getElementList(),a=l[o],c=l[s];if(i&&c.listId&&c.value===y&&((T=l[s+1])==null?void 0:T.listId)!==c.listId){e.getListParticle().unsetList();return}let d={value:y};if(r.shiftKey&&a.listId&&(d.listWrap=!0),It(l,[d],o,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),r.shiftKey&&c.areaId&&c.areaId!==((P=l[s+1])==null?void 0:P.areaId)&&(d=Ht(d,se)),!(((O=l[o+1])==null?void 0:O.titleId)&&(!a.titleId||a.titleId!==((M=l[o+1])==null?void 0:M.titleId)))&&!(c.titleId&&c.titleId!==((S=l[s+1])==null?void 0:S.titleId))){const m=n.getRangeAnchorStyle(l,s);if(m){const I=[...te];m.controlComponent!==R.ControlComponent.POSTFIX&&I.push(...Dt),I.forEach(f=>{const F=m[f];F!==void 0&&(d[f]=F)})}}const h=e.getControl(),u=h.getActiveControl();let g;if(u&&h.getIsRangeWithinControl())g=h.setValue([d]),h.emitControlContentChange();else{const I=e.getPosition().getCursorPosition();if(!I)return;const{index:f}=I;if(i){if(e.spliceElementList(l,f+1,0,[d]),c.titleId&&((X=l[f+2])==null?void 0:X.titleId)===c.titleId){const F=j();let V=f+2;for(;V<l.length&&((N=l[V])==null?void 0:N.titleId)===c.titleId;)l[V].titleId=F,V++}}else e.spliceElementList(l,o+1,s-o,[d]);g=f+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),r.preventDefault()}function cs(r,t){var N,m,I;const e=t.getDraw();if(e.isReadonly())return;const o=e.getPosition(),s=o.getCursorPosition();if(!s)return;const i=o.getPositionContext(),{index:l}=s;if(l<=0&&!i.isTable)return;const a=e.getRange(),{startIndex:c,endIndex:d}=a.getRange(),h=a.getIsCollapsed(),u=e.getElementList(),g=e.getControl();if(e.getMode()===R.EditorMode.FORM&&g.getActiveControl()&&(((N=u[l])==null?void 0:N.controlComponent)===R.ControlComponent.PREFIX||((m=u[l])==null?void 0:m.controlComponent)===R.ControlComponent.PRE_TEXT)){g.initNextControl({direction:Lt.UP});return}let T=1;if(Gt?r.altKey:r.ctrlKey){const f=e.getLetterReg(),F=r.shiftKey&&!h&&c===(s==null?void 0:s.index)?d:c;if(f.test((I=u[F])==null?void 0:I.value)){let V=F-1;for(;V>0;){const Z=u[V];if(!f.test(Z.value))break;T++,V--}}}const P=c-T;let O=P,M=P;if(r.shiftKey&&s&&(c!==d?c===s.index?(O=c,M=d-T):(O=P,M=d):M=d),!r.shiftKey){const f=u[c];if(f.type===R.ElementType.TABLE){const F=f.trList,V=F.length-1,Z=F[V],E=Z.tdList.length-1,D=Z.tdList[E];o.setPositionContext({isTable:!0,index:c,trIndex:V,tdIndex:E,tdId:D.id,trId:Z.id,tableId:f.id}),O=D.value.length-1,M=O,e.getTableTool().render()}else if(f.tableId&&c===0){const V=e.getOriginalElementList()[i.index].trList;t:for(let Z=0;Z<V.length;Z++){const E=V[Z];if(E.id!==f.trId)continue;const D=E.tdList;for(let W=0;W<D.length;W++)if(D[W].id===f.tdId){if(Z===0&&W===0)o.setPositionContext({isTable:!1}),O=i.index-1,M=O,e.getTableTool().dispose();else{let U=Z,Q=W-1;Q<0&&(U=Z-1,Q=V[U].tdList.length-1);const w=V[U],K=w.tdList[Q];o.setPositionContext({isTable:!0,index:i.index,trIndex:U,tdIndex:Q,tdId:K.id,trId:w.id,tableId:f.tableId}),O=K.value.length-1,M=O,e.getTableTool().render()}break t}}}}if(!~O||!~M)return;const S=e.getElementList();O=Oe(S,O),M=Oe(S,M),a.setRange(O,M);const X=O===M;if(e.render({curIndex:X?O:void 0,isSetCursor:X,isSubmitHistory:!1,isCompute:!1}),X){const f=o.getPositionList(),F=f[O];if((F==null?void 0:F.isLastLetter)&&F.value!==y&&O+1<f.length){const V=f[O+1],Z=S[O],E=S[O+1];V.value!==y&&!$t(E)&&Z.listId===E.listId&&e.getCursor().drawCursor({hitLineStartIndex:O+1})}}r.preventDefault()}function ds(r,t){var I,f,F;const e=t.getDraw();if(e.isReadonly())return;const o=e.getPosition(),s=o.getCursorPosition();if(!s)return;const{index:i}=s,l=o.getPositionList(),a=o.getPositionContext();if(i>l.length-1&&!a.isTable)return;const c=e.getRange(),{startIndex:d,endIndex:h}=c.getRange(),u=c.getIsCollapsed();let g=e.getElementList();const T=e.getControl();if(e.getMode()===R.EditorMode.FORM&&T.getActiveControl()&&(((I=g[i+1])==null?void 0:I.controlComponent)===R.ControlComponent.POSTFIX||((f=g[i+1])==null?void 0:f.controlComponent)===R.ControlComponent.POST_TEXT)){T.initNextControl({direction:Lt.DOWN});return}let P=1;if(Gt?r.altKey:r.ctrlKey){const V=e.getLetterReg(),Z=r.shiftKey&&!u&&d===(s==null?void 0:s.index)?h:d;if(V.test((F=g[Z+1])==null?void 0:F.value)){let E=Z+2;for(;E<g.length;){const D=g[E];if(!V.test(D.value))break;P++,E++}}}const O=h+P;let M=O,S=O;if(r.shiftKey&&s&&(d!==h?d===s.index?(M=d,S=O):(M=d+P,S=h):M=d),!r.shiftKey){const V=g[h],Z=g[h+1];if((Z==null?void 0:Z.type)===R.ElementType.TABLE){const D=Z.trList[0],W=D.tdList[0];o.setPositionContext({isTable:!0,index:h+1,trIndex:0,tdIndex:0,tdId:W.id,trId:D.id,tableId:Z.id}),M=0,S=0,e.getTableTool().render()}else if(V.tableId&&!Z){const D=e.getOriginalElementList()[a.index].trList;t:for(let W=0;W<D.length;W++){const C=D[W];if(C.id!==V.trId)continue;const U=C.tdList;for(let Q=0;Q<U.length;Q++)if(U[Q].id===V.tdId){if(W===D.length-1&&Q===U.length-1)o.setPositionContext({isTable:!1}),M=a.index,S=M,g=e.getElementList(),e.getTableTool().dispose();else{let K=W,p=Q+1;p>U.length-1&&(K=W+1,p=0);const G=D[K],H=G.tdList[p];o.setPositionContext({isTable:!0,index:a.index,trIndex:K,tdIndex:p,tdId:H.id,trId:G.id,tableId:V.tableId}),M=0,S=M,e.getTableTool().render()}break t}}}}const X=g.length-1;if(M>X||S>X)return;const N=e.getElementList();M=Oe(N,M,R.LocationPosition.AFTER),S=Oe(N,S,R.LocationPosition.AFTER),c.setRange(M,S);const m=M===S;if(e.render({curIndex:m?M:void 0,isSetCursor:m,isSubmitHistory:!1,isCompute:!1}),m){const V=l[M];if((V==null?void 0:V.isLastLetter)&&V.value!==y&&M+1<l.length){const Z=l[M+1],E=g[M],D=g[M+1];Z.value!==y&&!$t(D)&&E.listId===D.listId&&e.getCursor().drawCursor({hitLineStartIndex:M+1})}}r.preventDefault()}function hs(r,t){const e=t.getDraw();if(e.isReadonly())return;r.preventDefault();const o=e.getControl();if(o.getActiveControl()&&o.getIsRangeWithinControl())o.initNextControl({direction:r.shiftKey?Lt.UP:Lt.DOWN});else{const i=e.getRange(),l=e.getElementList(),{startIndex:a,endIndex:c}=i.getRange(),d=i.getRangeAnchorStyle(l,c),h=d?pt(d,Dt):null,u=B(Y({},h),{type:R.ElementType.TAB,value:""});It(l,[u],a,{editorOptions:e.getOptions()}),e.insertElementList([u])}}function Rn(r){const{positionList:t,index:e,isUp:n,rowNo:o,cursorX:s}=r;let i=-1;const l=[];if(n){let a=e-1;for(;a>=0;){const c=t[a];if(a--,c.rowNo!==o){if(l[0]&&l[0].rowNo!==c.rowNo)break;l.unshift(c)}}}else{let a=e+1;for(;a<t.length;){const c=t[a];if(a++,c.rowNo!==o){if(l[0]&&l[0].rowNo!==c.rowNo)break;l.push(c)}}}for(let a=0;a<l.length;a++){const c=l[a],{coordinate:{leftTop:[d],rightTop:[h]}}=c;if(a===l.length-1&&(i=c.index),!(s<d||s>h)){i=c.index;break}}return i}function us(r,t){const e=t.getDraw();if(e.isReadonly())return;const o=e.getPosition(),s=o.getCursorPosition();if(!s)return;const i=e.getRange(),{startIndex:l,endIndex:a}=i.getRange();let c=o.getPositionList();const d=r.key===R.KeyMap.Up;let h=-1,u=-1;const g=o.getPositionContext();if(!r.shiftKey&&g.isTable&&(d&&s.rowIndex===0||!d&&s.rowIndex===e.getRowCount()-1)){const{index:P,trIndex:O,tdIndex:M,tableId:S}=g;if(d)if(O===0)o.setPositionContext({isTable:!1}),h=P-1,u=h,e.getTableTool().dispose();else{let X=-1,N=-1;const I=e.getOriginalElementList()[P].trList,f=I[O].tdList[M].colIndex;t:for(let Z=O-1;Z>=0;Z--){const D=I[Z].tdList;for(let W=0;W<D.length;W++){const C=D[W];if(C.colIndex===f||C.colIndex+C.colspan-1>=f&&C.colIndex<=f){X=Z,N=W;break t}}}if(!~X||!~N)return;const F=I[X],V=F.tdList[N];o.setPositionContext({isTable:!0,index:P,trIndex:X,tdIndex:N,tdId:V.id,trId:F.id,tableId:S}),h=V.value.length-1,u=h,e.getTableTool().render()}else{const N=e.getOriginalElementList()[P].trList;if(O===N.length-1)o.setPositionContext({isTable:!1}),h=P,u=h,e.getTableTool().dispose();else{let m=-1,I=-1;const f=N[O].tdList[M].colIndex;t:for(let Z=O+1;Z<N.length;Z++){const D=N[Z].tdList;for(let W=0;W<D.length;W++){const C=D[W];if(C.colIndex===f||C.colIndex+C.colspan-1>=f&&C.colIndex<=f){m=Z,I=W;break t}}}if(!~m||!~I)return;const F=N[m],V=F.tdList[I];o.setPositionContext({isTable:!0,index:P,trIndex:m,tdIndex:I,tdId:V.id,trId:F.id,tableId:S}),h=V.value.length-1,u=h,e.getTableTool().render()}}}else{let P=s;r.shiftKey&&(l===s.index?P=c[a]:P=c[l]);const{index:O,rowNo:M,rowIndex:S,coordinate:{rightTop:[X]}}=P;if(d&&S===0||!d&&S===e.getRowCount()-1)return;const N=Rn({positionList:c,index:O,rowNo:M,isUp:d,cursorX:X});if(N<0)return;h=N,u=N,r.shiftKey&&(l!==a?l===s.index?h=l:u=a:d?u=a:h=l);const I=e.getElementList()[N];if(I.type===R.ElementType.TABLE){const{scale:f}=e.getOptions(),F=e.getMargins(),V=I.trList;let Z=-1,E=-1,D=-1;if(d){t:for(let W=V.length-1;W>=0;W--){const U=V[W].tdList;for(let Q=0;Q<U.length;Q++){const w=U[Q],K=w.x*f+F[3],p=w.width*f;if(X>=K&&X<=K+p){const G=w.positionList,H=G[G.length-1],x=Rn({positionList:G,index:H.index+1,rowNo:H.rowNo-1,isUp:d,cursorX:X})||H.index;Z=W,E=Q,D=x;break t}}}}else{t:for(let W=0;W<V.length;W++){const U=V[W].tdList;for(let Q=0;Q<U.length;Q++){const w=U[Q],K=w.x*f+F[3],p=w.width*f;if(X>=K&&X<=K+p){const G=w.positionList,H=Rn({positionList:G,index:-1,rowNo:-1,isUp:d,cursorX:X})||0;Z=W,E=Q,D=H;break t}}}}if(~Z&&~E&&~D){const W=V[Z],C=W.tdList[E];o.setPositionContext({isTable:!0,index:N,trIndex:Z,tdIndex:E,tdId:C.id,trId:W.id,tableId:I.id}),h=D,u=h,c=o.getPositionList(),e.getTableTool().render()}}}if(!~h||!~u)return;h>u&&([h,u]=[u,h]),i.setRange(h,u);const T=h===u;e.render({curIndex:T?h:void 0,isSetCursor:T,isSubmitHistory:!1,isCompute:!1}),T||e.getCursor().moveCursorToVisible({cursorPosition:c[d?h:u],direction:d?Lt.UP:Lt.DOWN})}function zn(r,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getPosition(),o=n.getCursorPosition();if(!o)return;const s=e.getRange(),{startIndex:i,endIndex:l}=s.getRange(),a=n.getPositionList();let c=o;r.shiftKey&&i!==l&&(i===o.index?c=a[l]:c=a[i]);const{rowNo:d}=c;let h=c.index;for(let O=c.index-1;O>=0&&a[O].rowNo===d;O--)h=O;const u=a[h].value!==y;u&&h--;let g=h,T=h;r.shiftKey&&(i!==l?i===o.index?(g=i,T=h):(g=h,T=l):(g=h,T=i)),g>T&&([g,T]=[T,g]),s.setRange(g,T);const P=g===T;e.render({curIndex:P?g:void 0,isSetCursor:P,isSubmitHistory:!1,isCompute:!1}),u&&e.getCursor().drawCursor({hitLineStartIndex:h+1}),r.preventDefault()}function $n(r,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getPosition(),o=n.getCursorPosition();if(!o)return;const s=e.getRange(),{startIndex:i,endIndex:l}=s.getRange(),a=n.getPositionList();let c=o;r.shiftKey&&i!==l&&(i===o.index?c=a[l]:c=a[i]);let{rowNo:d}=c;e.getCursor().getHitLineStartIndex()!==void 0&&d++;let u=c.index;for(let O=c.index+1;O<a.length&&a[O].rowNo===d;O++)u=O;let g=u,T=u;r.shiftKey&&(i!==l?i===o.index?(g=i,T=u):(g=u,T=l):(g=i,T=u)),g>T&&([g,T]=[T,g]),s.setRange(g,T);const P=g===T;e.render({curIndex:P?g:void 0,isSetCursor:P,isSubmitHistory:!1,isCompute:!1}),r.preventDefault()}function gs(r,t){if(t.isComposing)return;const e=t.getDraw();if(r.key===R.KeyMap.Backspace)rs(r,t);else if(r.key===R.KeyMap.Delete)as(r,t);else if(r.key===R.KeyMap.Enter)Rs(r,t);else if(r.key===R.KeyMap.Left)Gt&&r.metaKey?zn(r,t):cs(r,t);else if(r.key===R.KeyMap.Right)Gt&&r.metaKey?$n(r,t):ds(r,t);else if(r.key===R.KeyMap.Up||r.key===R.KeyMap.Down)us(r,t);else if(r.key===R.KeyMap.Home)zn(r,t);else if(r.key===R.KeyMap.End)$n(r,t);else if(jt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==R.EditorMode.FORM)return;e.getHistoryManager().undo(),r.preventDefault()}else if(jt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==R.EditorMode.FORM)return;e.getHistoryManager().redo(),r.preventDefault()}else if(jt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.C)t.copy(),r.preventDefault();else if(jt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.X)t.cut(),r.preventDefault();else if(jt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.A)t.selectAll(),r.preventDefault();else if(jt(r)&&r.key.toLocaleLowerCase()===R.KeyMap.S){if(e.isReadonly())return;const n=e.getListener();n.saved&&n.saved(e.getValue());const o=e.getEventBus();o.isSubscribe("saved")&&o.emit("saved",e.getValue()),r.preventDefault()}else if(r.key===R.KeyMap.ESC){t.clearPainterStyle();const n=e.getZone();n.isMainActive()||n.setZone(R.EditorZone.MAIN),r.preventDefault()}else r.key===R.KeyMap.TAB&&hs(r,t)}function cn(r,t){var f,F;const e=t.getDraw();if(e.isReadonly()||e.isDisabled())return;const o=e.getPosition().getCursorPosition();if(!r||!o)return;const s=t.isComposing;if(s&&((f=t.compositionInfo)==null?void 0:f.value)===r)return;const i=e.getRange();if(!i.getIsCanInput())return;const l=i.getDefaultStyle()||((F=t.compositionInfo)==null?void 0:F.defaultStyle)||null;jn(t),s||e.getCursor().clearAgentDomValue();const{TEXT:a,HYPERLINK:c,SUBSCRIPT:d,SUPERSCRIPT:h,DATE:u,TAB:g}=R.ElementType,T=r.replaceAll(`
|
|
87
|
+
`,y),{startIndex:P,endIndex:O}=i.getRange(),M=e.getElementList(),S=i.getRangeAnchorStyle(M,O);if(!S)return;const X=e.isDesignMode(),N=Qt(T).map(V=>{var E,D;const Z={value:V};if(X||!((E=S.title)==null?void 0:E.disabled)&&!((D=S.control)==null?void 0:D.disabled)){const W=M[O+1];(!S.type||S.type===a||S.type===c&&(W==null?void 0:W.type)===c||S.type===u&&(W==null?void 0:W.type)===u||S.type===d&&(W==null?void 0:W.type)===d||S.type===h&&(W==null?void 0:W.type)===h)&&zi.forEach(C=>{if(C==="groupIds"&&!(W==null?void 0:W.groupIds))return;const U=S[C];U!==void 0&&(Z[C]=U)}),(l||S.type===g)&&Dt.forEach(C=>{const U=(l==null?void 0:l[C])||S[C];U!==void 0&&(Z[C]=U)}),s&&(Z.underline=!0)}return Z}),m=e.getControl();let I;if(m.getActiveControl()&&m.getIsRangeWithinControl())I=m.setValue(N),s||m.emitControlContentChange();else{const V=P+1;P!==O&&e.spliceElementList(M,V,O-P),It(M,N,P,{editorOptions:e.getOptions()}),e.spliceElementList(M,V,0,N),I=P+N.length}~I&&(i.setRange(I,I),e.render({curIndex:I,isSubmitHistory:!s})),s&&~I&&(t.compositionInfo={elementList:M,value:T,startIndex:I-N.length,endIndex:I,defaultStyle:l})}function jn(r){if(!r.compositionInfo)return;const{elementList:t,startIndex:e,endIndex:n}=r.compositionInfo;t.splice(e+1,n-e),r.getDraw().getRange().setRange(e,e),r.compositionInfo=null}async function Ls(r){const t=r.getDraw(),e=t.getRange(),{startIndex:n,endIndex:o}=e.getRange();if(!~n&&!~o||t.isReadonly()||!e.getIsCanInput())return;const s=t.getElementList();let i=n,l=o;if(n===o){const u=t.getPosition().getPositionList(),g=u[n],T=g.rowNo,P=g.pageNo,O=[];for(let S=0;S<u.length;S++){const X=u[S];if(X.pageNo>P)break;X.pageNo===P&&X.rowNo===T&&O.push(S)}const M=O[0]-1;i=M<0?0:M,l=O[O.length-1]}const a=t.getOptions();await Jn(s.slice(i+1,l+1),a);const c=t.getControl();let d;c.getActiveControl()&&c.getIsRangeWithinControl()?(d=c.cut(),c.emitControlContentChange()):(t.spliceElementList(s,i+1,l-i),d=i),e.setRange(d,d),t.render({curIndex:d})}async function Ts(r,t){const e=r.getDraw(),{copy:n}=e.getOverride();if(n){const l=n();if((l==null?void 0:l.preventDefault)!==!1)return}const o=e.getRange();let s=null;if(o.getRange().isCrossRowCol){const l=o.getRangeTableElement();if(!l)return;const a=e.getTableParticle().getRangeRowCol();if(!a)return;const c={type:R.ElementType.TABLE,value:"",colgroup:[],trList:[]},d=a[0],h=d[0].colIndex,u=d[d.length-1],g=u.colIndex+u.colspan-1;for(let T=h;T<=g;T++)c.colgroup.push(l.colgroup[T]);for(let T=0;T<a.length;T++){const P=a[T],O=l.trList[P[0].rowIndex],M={tdList:[],height:O.height,minHeight:O.minHeight};for(let S=0;S<P.length;S++)M.tdList.push(P[S]);c.trList.push(M)}s=st([c])}else s=o.getIsCollapsed()?o.getRangeRowElementList():o.getSelectionElementList();(t==null?void 0:t.isPlainText)&&(s==null?void 0:s.length)&&(s=[{value:ce(s)}]),!!(s==null?void 0:s.length)&&await Jn(s,e.getOptions())}function Ps(r,t){var s,i;const e=t.getDraw(),{drop:n}=e.getOverride();if(n){const l=n(r);if((l==null?void 0:l.preventDefault)!==!1)return}r.preventDefault();const o=(s=r.dataTransfer)==null?void 0:s.getData("text");if(o)t.input(o);else{const l=(i=r.dataTransfer)==null?void 0:i.files;if(!l)return;for(let a=0;a<l.length;a++){const c=l[a];c.type.startsWith("image")&&rn(t,c)}}}function qn(r){var u;if(!Intl.Segmenter)return null;const t=r.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const o=t.getRange().getRangeParagraphInfo();if(!o)return null;const s=((u=o==null?void 0:o.elementList)==null?void 0:u.map(g=>!g.type||g.type!==R.ElementType.CONTROL&&bt.includes(g.type)?g.value:y).join(""))||"";if(!s)return null;const i=e.isFirstLetter||t.getCursor().getHitLineStartIndex()?e.index+1:e.index,l=o.startIndex,c=new Intl.Segmenter(void 0,{granularity:"word"}).segment(s);let d=-1,h=-1;for(const{segment:g,index:T,isWordLike:P}of c){const O=T+l;if(P&&i>=O&&i<O+g.length){d=O-1,h=d+g.length;break}}return~d&&~h?{startIndex:d,endIndex:h}:null}function Ms(r){const t=r.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:n,index:o}=e,s=t.getLetterReg();let i=0,l=0;const a=He.test(n);if(a||s.test(n)){const d=t.getElementList();let h=o-1;for(;h>0;){const g=d[h].value;if(a&&He.test(g)||!a&&s.test(g))i++,h--;else break}let u=o+1;for(;u<d.length;){const g=d[u].value;if(a&&He.test(g)||!a&&s.test(g))l++,u++;else break}}const c=o-i-1;return c<0?null:{startIndex:c,endIndex:o+l}}function Os(r,t){const e=r.getDraw(),n=e.getPosition(),o=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(o.isImage&&o.isDirectHit){const l=e.getElementList(),a=e.getEventBus(),c=l[o.index];if(a.isSubscribe("imageDblclick")&&a.emit("imageDblclick",{evt:t,element:c}),c.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&!~o.index&&o.zone){e.getZone().setZone(o.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((o.isCheckbox||o.isRadio)&&o.isDirectHit)return;const s=e.getRange(),i=qn(r)||Ms(r);!i||(s.setRange(i.startIndex,i.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),s.setRangeStyle())}function Ss(r){var T,P;const t=r.getDraw(),e=t.getControl();if(e.getActiveControl()&&e.selectValue())return;const o=t.getPosition().getCursorPosition();if(!o)return;const{index:s}=o,i=t.getElementList();let l=0,a=0,c=s-1;for(;c>0;){const O=i[c],M=i[c-1];if(O.value===y&&!O.listWrap||O.listId!==(M==null?void 0:M.listId)||O.titleId!==(M==null?void 0:M.titleId))break;l++,c--}let d=s+1;for(;d<i.length;){const O=i[d],M=i[d+1];if(O.value===y&&!O.listWrap||O.listId!==(M==null?void 0:M.listId)||O.titleId!==(M==null?void 0:M.titleId))break;a++,d++}const h=t.getRange();let u=s-l-1;if(((T=i[u])==null?void 0:T.value)!==y&&(u-=1),u<0)return;let g=s+a+1;(((P=i[g])==null?void 0:P.value)===y||g>i.length-1)&&(g-=1),h.setRange(u,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}var ti={dblclick:Os,threeClick:Ss};function Xs(r){r.isComposing=!0}function Is(r,t){r.isComposing=!1;const e=r.getDraw();if(t.data)_i?setTimeout(()=>{r.compositionInfo&&cn(t.data,r)},1):r.compositionInfo&&cn(t.data,r);else{jn(r);const o=e.getRange(),{endIndex:s}=o.getRange();e.render({curIndex:s,isSubmitHistory:!1})}e.getCursor().clearAgentDomValue()}var ei={compositionstart:Xs,compositionend:Is};function Ns(r,t){var X;const e=t.getDraw();if(e.isReadonly())return;r.preventDefault();const o=e.getPageContainer();if(!me(r.target,N=>N===o,!0))return;const l=r.target.dataset.index;l&&e.setPageNo(Number(l));const a=e.getPosition(),c=a.adjustPositionContext({x:r.offsetX,y:r.offsetY});if(!c)return;const{isTable:d,tdValueIndex:h,index:u}=c,g=a.getPositionList(),T=d?h:u;~u&&(e.getRange().setRange(T,T),a.setCursorPosition(g[T]));const P=e.getCursor(),{cursor:{dragColor:O,dragWidth:M,dragFloatImageDisabled:S}}=e.getOptions();if(S){const N=(X=t.cacheElementList)==null?void 0:X[t.cacheRange.startIndex];if((N==null?void 0:N.type)===R.ElementType.IMAGE&&(N.imgDisplay===R.ImageDisplay.FLOAT_TOP||N.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM||N.imgDisplay===R.ImageDisplay.SURROUND))return}P.drawCursor({width:M,color:O,isBlink:!1,isFocus:!1})}var fs={dragover:Ns};class ms{constructor(t){L(this,"isAllowSelection");L(this,"isComposing");L(this,"compositionInfo");L(this,"isAllowDrag");L(this,"isAllowDrop");L(this,"cacheRange");L(this,"cacheElementList");L(this,"cachePositionList");L(this,"cachePositionContext");L(this,"mouseDownStartPosition");L(this,"draw");L(this,"pageContainer");L(this,"pageList");L(this,"range");L(this,"position");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)),Di(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 i=qn(this);i&&(n=this.draw.getElementList().slice(i.startIndex+1,i.endIndex+1))}if(!n)return;const o=Object.keys(t);n.forEach(i=>{o.forEach(l=>{const a=l;Reflect.set(i,a,t[a])})}),this.draw.render({isSetCursor:!1});const s=this.draw.getPainterOptions();(!s||!s.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){os(t,this)}mousedown(t){es(t,this)}click(){ki&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){ns(t,this)}mouseleave(t){is(t,this)}keydown(t){gs(t,this)}dblclick(t){ti.dblclick(this,t)}threeClick(){ti.threeClick(this)}input(t){cn(t,this)}async cut(){await Ls(this)}async copy(t){await Ts(this,t)}compositionstart(){ei.compositionstart(this)}compositionend(t){ei.compositionend(this,t)}drop(t){Ps(t,this)}dragover(t){fs.dragover(t,this)}}const ni={PAGE_SCALE:"pageScale"};class Fs{constructor(t,e){L(this,"draw");L(this,"options");L(this,"cursor");L(this,"canvasEvent");L(this,"range");L(this,"previewer");L(this,"tableTool");L(this,"hyperlinkParticle");L(this,"control");L(this,"magnifier");L(this,"dateParticle");L(this,"imageParticle");L(this,"dprMediaQueryList");L(this,"clearSideEffect",t=>{if(!this.cursor)return;const e=(t==null?void 0:t.composedPath()[0])||t.target,n=this.draw.getPageList();if(me(e,i=>n.includes(i),!0))return;if(me(e,i=>!!i&&i.nodeType===1&&!!i.getAttribute(_t),!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.magnifier.hide()});L(this,"setCanvasEventAbility",()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)});L(this,"setPageScale",t=>{if(this.options.shortcutDisableKeys.includes(ni.PAGE_SCALE)||!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const n=e*10+1;n<=30&&this.draw.setPageScale(n/10)}else{const n=e*10-1;n>=5&&this.draw.setPageScale(n/10)}});L(this,"_handleVisibilityChange",()=>{if(document.visibilityState==="visible"){const t=this.range.getRange(),e=!!~t.startIndex&&!!~t.endIndex&&t.startIndex===t.endIndex;this.range.replaceRange(t),this.draw.render({isSetCursor:e,isCompute:!1,isSubmitHistory:!1,curIndex:t.startIndex})}});L(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.magnifier=t.getMagnifier(),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?void 0:t.getAgentIsActive())||(e=this.cursor)==null||e.drawCursor({isFocus:!1,isBlink:!1})})}}class Ws{constructor(t){L(this,"undoStack",[]);L(this,"redoStack",[]);L(this,"maxRecordCount");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 Vs{constructor(t){L(this,"cursorPosition");L(this,"positionContext");L(this,"positionList");L(this,"floatPositionList");L(this,"draw");L(this,"eventBus");L(this,"options");this.positionList=[],this.floatPositionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.eventBus=t.getEventBus(),this.options=t.getOptions()}getFloatPositionList(){return this.floatPositionList}getTablePositionList(t){const{index:e,trIndex:n,tdIndex:o}=this.positionContext;return t[e].trList[n].tdList[o].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:o,startX:s,startY:i,startRowIndex:l,startIndex:a,innerWidth:c,zone:d}=t,{scale:h,table:{tdPadding:u}}=this.options;let g=s,T=i,P=a;for(let O=0;O<n.length;O++){const M=n[O];if(!M.isSurround){const N=M.width+(M.offsetX||0);M.rowFlex===R.RowFlex.CENTER?g+=(c-N)/2:M.rowFlex===R.RowFlex.RIGHT&&(g+=c-N)}g+=M.offsetX||0,T+=M.offsetY||0;const S=g,X=T;for(let N=0;N<M.elementList.length;N++){const m=M.elementList[N],I=m.metrics,f=!m.hide&&(m.imgDisplay!==R.ImageDisplay.INLINE&&m.type===R.ElementType.IMAGE||m.type===R.ElementType.LATEX)?M.ascent-I.height:M.ascent;m.left&&(g+=m.left),m.translateX&&(g+=m.translateX*h);const F={pageNo:o,index:P,value:m.value,rowIndex:l+O,rowNo:O,metrics:I,left:m.left||0,ascent:f,lineHeight:M.height,isFirstLetter:N===0,isLastLetter:N===M.elementList.length-1,coordinate:{leftTop:[g,T],leftBottom:[g,T+M.height],rightTop:[g+I.width,T],rightBottom:[g+I.width,T+M.height]}};if(m.imgDisplay===R.ImageDisplay.SURROUND||m.imgDisplay===R.ImageDisplay.FLOAT_TOP||m.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM){const V=e[e.length-1];V&&(F.metrics=V.metrics,F.coordinate=V.coordinate),m.imgFloatPosition||(m.imgFloatPosition={x:g,y:T,pageNo:o}),this.floatPositionList.push({pageNo:o,element:m,position:F,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:P,zone:d})}if(e.push(F),P++,g+=I.width,m.type===R.ElementType.TABLE&&!m.hide){const V=u[1]+u[3],Z=u[0]+u[2];for(let E=0;E<m.trList.length;E++){const D=m.trList[E];for(let W=0;W<D.tdList.length;W++){const C=D.tdList[W];C.positionList=[];const U=C.rowList,Q=this.computePageRowPosition({positionList:C.positionList,rowList:U,pageNo:o,startRowIndex:0,startIndex:0,startX:(C.x+u[3])*h+S+(m.translateX||0)*h,startY:(C.y+u[0])*h+X,innerWidth:(C.width-V)*h,isTable:!0,index:P-1,tdIndex:W,trIndex:E,zone:d});if(C.verticalAlign===R.VerticalAlign.MIDDLE||C.verticalAlign===R.VerticalAlign.BOTTOM){const w=U.reduce((G,H)=>G+H.height,0),K=(C.height-Z)*h-w,p=C.verticalAlign===R.VerticalAlign.MIDDLE?K/2:K;Math.floor(p)>0&&C.positionList.forEach(G=>{const{coordinate:{leftTop:H,leftBottom:x,rightBottom:k,rightTop:A}}=G;H[1]+=p,x[1]+=p,k[1]+=p,A[1]+=p})}g=Q.x,T=Q.y}}g=S,T=X}}g=s,T+=M.height}return{x:g,y:T,index:P}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),n=this.draw.getMargins(),o=n[3],i=this.draw.getHeader().getExtraHeight(),l=n[0]+i;let a=0;for(let c=0;c<e.length;c++){const d=e[c];if(!(d==null?void 0:d.length))continue;const h=d[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:d,pageNo:c,startRowIndex:a,startIndex:h,startX:o,startY:l,innerWidth:t}),a+=d.length}}computeRowPosition(t){const{row:e,innerWidth:n}=t,o=[];return this.computePageRowPosition({positionList:o,innerWidth:n,rowList:[$(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),o}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 P,O,M,S,X;const{x:e,y:n,isTable:o}=t;let{elementList:s,positionList:i}=t;s||(s=this.draw.getOriginalElementList()),i||(i=this.getOriginalPositionList());const l=this.draw.getZone(),a=(P=t.pageNo)!=null?P:this.draw.getPageNo(),c=l.isMainActive(),d=c?a:0;if(!o){const N=this.getFloatPositionByXY(B(Y({},t),{imgDisplays:[R.ImageDisplay.FLOAT_TOP,R.ImageDisplay.SURROUND]}));if(N)return N}for(let N=0;N<i.length;N++){const{index:m,pageNo:I,left:f,isFirstLetter:F,coordinate:{leftTop:V,rightTop:Z,leftBottom:E}}=i[N];if(d===I){if(I>d)break;if(V[0]-f<=e&&Z[0]>=e&&V[1]<=n&&E[1]>=n){let D=N;const W=s[N];if(W.type===R.ElementType.TABLE)for(let U=0;U<W.trList.length;U++){const Q=W.trList[U];for(let w=0;w<Q.tdList.length;w++){const K=Q.tdList[w],p=this.getPositionByXY({x:e,y:n,td:K,pageNo:a,tablePosition:i[N],isTable:!0,elementList:K.value,positionList:K.positionList});if(~p.index){const{index:G,hitLineStartIndex:H}=p,x=K.value[G];return{index:m,isCheckbox:p.isCheckbox||x.type===R.ElementType.CHECKBOX||x.controlComponent===R.ControlComponent.CHECKBOX,isRadio:x.type===R.ElementType.RADIO||x.controlComponent===R.ControlComponent.RADIO,isControl:!!x.controlId,isImage:p.isImage,isDirectHit:p.isDirectHit,isTable:!0,tdIndex:w,trIndex:U,tdValueIndex:G,tdId:K.id,trId:Q.id,tableId:W.id,hitLineStartIndex:H}}}}if(W.type===R.ElementType.IMAGE||W.type===R.ElementType.LATEX)return{index:D,isDirectHit:!0,isImage:!0};if(W.type===R.ElementType.CHECKBOX||W.controlComponent===R.ControlComponent.CHECKBOX)return{index:D,isDirectHit:!0,isCheckbox:!0};if(W.type===R.ElementType.LABEL)return{index:D,isDirectHit:!0,isLabel:!0};if(W.type===R.ElementType.TAB&&W.listStyle===R.ListStyle.CHECKBOX){let U=D-1;for(;U>0;){const Q=s[U];if(Q.value===y&&Q.listStyle===R.ListStyle.CHECKBOX)break;U--}return{index:U,isDirectHit:!0,isCheckbox:!0}}if(W.type===R.ElementType.RADIO||W.controlComponent===R.ControlComponent.RADIO)return{index:D,isDirectHit:!0,isRadio:!0};let C;if(s[m].value!==y){const U=Z[0]-V[0];e<V[0]+U/2&&(D=N-1,F&&(C=N))}return{isDirectHit:!0,hitLineStartIndex:C,index:D,isControl:!!W.controlId}}}}if(!o){const N=this.getFloatPositionByXY(B(Y({},t),{imgDisplays:[R.ImageDisplay.FLOAT_BOTTOM]}));if(N)return N}let h=!1,u=-1,g;if(o){const{scale:N}=this.options,{td:m,tablePosition:I}=t;if(m&&I){const{leftTop:f}=I.coordinate,F=m.x*N+f[0],V=m.y*N+f[1],Z=m.width*N,E=m.height*N;if(!(F<e&&e<F+Z&&V<n&&n<V+E))return{index:u}}}const T=i.filter(N=>N.isLastLetter&&N.pageNo===d);for(let N=0;N<T.length;N++){const{index:m,rowNo:I,coordinate:{leftTop:f,leftBottom:F}}=T[N];if(n>f[1]&&n<=F[1]){const V=i.findIndex(W=>W.pageNo===d&&W.rowNo===I),Z=s[V],E=i[V],D=Z.listStyle===R.ListStyle.CHECKBOX?this.draw.getMargins()[3]:E.coordinate.leftTop[0];if(e<D)~V?E.value===y?u=V:(u=V-1,g=V):u=m;else{if(Z.listStyle===R.ListStyle.CHECKBOX&&e<f[0])return{index:V,isDirectHit:!0,isCheckbox:!0};u=m}h=!0;break}}if(!h){if(this.draw.getIsPagingMode()){const m=this.draw.getHeader(),I=m.getHeight(),f=m.getHeaderTop()+I,F=this.draw.getFooter(),Z=this.draw.getHeight()-(F.getFooterBottom()+F.getHeight());if(c){if(n<f)return{index:-1,zone:R.EditorZone.HEADER};if(n>Z)return{index:-1,zone:R.EditorZone.FOOTER}}else if(n<=Z&&n>=f)return{index:-1,zone:R.EditorZone.MAIN}}const N=this.draw.getMargins();if(n<=N[0])for(let m=0;m<i.length;m++){const I=i[m];if(I.pageNo!==d||I.rowNo!==0)continue;const{leftTop:f,rightTop:F}=I.coordinate;if(e<=N[3]||e>=f[0]&&e<=F[0]||((O=i[m+1])==null?void 0:O.rowNo)!==0)return{index:I.index}}else{const m=T[T.length-1];if(m){const I=m.rowNo;for(let f=0;f<i.length;f++){const F=i[f];if(F.pageNo!==d||F.rowNo!==I)continue;const{leftTop:V,rightTop:Z}=F.coordinate;if(e<=N[3]||e>=V[0]&&e<=Z[0]||((M=i[f+1])==null?void 0:M.rowNo)!==I)return{index:F.index}}}}return{index:((S=T[T.length-1])==null?void 0:S.index)||i.length-1}}return{hitLineStartIndex:g,index:u,isControl:!!((X=s[u])==null?void 0:X.controlId)}}getFloatPositionByXY(t){var l;const{x:e,y:n}=t,o=(l=t.pageNo)!=null?l:this.draw.getPageNo(),s=this.draw.getZone().getZone(),{scale:i}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:c,element:d,isTable:h,index:u,trIndex:g,tdIndex:T,tdValueIndex:P,zone:O,pageNo:M}=this.floatPositionList[a];if(o===M&&d.type===R.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!O||O===s)){const S=d.imgFloatPosition,X=S.x*i,N=S.y*i,m=d.width*i,I=d.height*i;if(e>=X&&e<=X+m&&n>=N&&n<=N+I)return h?{index:u,isDirectHit:!0,isImage:!0,isTable:h,trIndex:g,tdIndex:T,tdValueIndex:P,tdId:d.tdId,trId:d.trId,tableId:d.tableId}:{index:c.index,isDirectHit:!0,isImage:!0}}}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==R.EditorMode.READONLY){const{index:O,isTable:M,trIndex:S,tdIndex:X,tdValueIndex:N}=e,m=this.draw.getControl(),{newIndex:I}=m.moveCursor({index:O,isTable:M,trIndex:S,tdIndex:X,tdValueIndex:N});M?e.tdValueIndex=I:e.index=I}const{index:n,isCheckbox:o,isRadio:s,isControl:i,isImage:l,isLabel:a,isDirectHit:c,isTable:d,trIndex:h,tdIndex:u,tdId:g,trId:T,tableId:P}=e;return this.setPositionContext({isTable:d||!1,isCheckbox:o||!1,isRadio:s||!1,isControl:i||!1,isImage:l||!1,isLabel:a||!1,isDirectHit:c||!1,index:n,trIndex:h,tdIndex:u,tdId:g,trId:T,tableId:P}),e}setSurroundPosition(t){var h;const{scale:e}=this.options,{pageNo:n,row:o,rowElement:s,rowElementRect:i,surroundElementList:l,availableWidth:a}=t;let c=i.x,d=0;if(l.length&&!$t(s)&&!((h=s.control)==null?void 0:h.minWidth))for(let u=0;u<l.length;u++){const g=l[u],T=g.imgFloatPosition;if(T.pageNo!==n)continue;const P=B(Y({},T),{x:T.x*e,y:T.y*e,width:g.width*e,height:g.height*e});if(xi(i,P)){o.isSurround=!0;const O=P.width+P.x-i.x;if(s.left=O,o.width+=O,d+=O,c=P.x+P.width,o.width+s.metrics.width>a){s.left=0,o.width-=d;break}}}return{x:c,rowIncreaseWidth:d}}}class ps{constructor(t){L(this,"draw");L(this,"options");L(this,"range");L(this,"listener");L(this,"eventBus");L(this,"position");L(this,"historyManager");L(this,"defaultStyle");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=Y(Y({},this.defaultStyle),t):this.defaultStyle=null}getDefaultStyle(){return this.defaultStyle}getRangeAnchorStyle(t,e){const n=Qe(t,e);return n?Y(Y({},n),this.defaultStyle):null}getIsRangeChange(t,e,n,o,s,i,l){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==n||this.range.startTdIndex!==o||this.range.endTdIndex!==s||this.range.startTrIndex!==i||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 o;const{startIndex:t,endIndex:e}=this.range;if(t===e)return null;const n=this.draw.getElementList();return n.slice(((o=n[t])==null?void 0:o.value)===y?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 o=t[n];for(let s=0;s<o.length;s++){const i=o[s];e.push(...i.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||bt.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||bt.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),o=new Map;for(let s=t;s<e+1;s++){const{pageNo:i,rowNo:l}=n[s],a=o.get(i);a?a.has(l)||a.add(l):o.set(i,new Set([l]))}return o}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:n}=this.range;if(!~t&&!~e)return null;if(n)return this.getSelectionElementList();const o=this.getRangeRow();if(!o)return null;const s=this.position.getPositionList(),i=this.draw.getElementList(),l=[];for(let a=0;a<s.length;a++){const c=s[a],d=o.get(c.pageNo);!d||d.has(c.rowNo)&&l.push(i[a])}return l}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),o=this.draw.getElementList(),s=new Map;let i=t;for(;i>=0;){const{pageNo:c,rowNo:d}=n[i];let h=s.get(c);h||(h=[],s.set(c,h)),h.includes(d)||h.unshift(d);const u=o[i],g=o[i-1];if(u.value===y&&!u.listWrap||u.listId!==(g==null?void 0:g.listId)||u.titleId!==(g==null?void 0:g.titleId))break;i--}const l=t===e;if(!l){let c=t+1;for(;c<e;){const{pageNo:d,rowNo:h}=n[c];let u=s.get(d);u||(u=[],s.set(d,u)),u.includes(h)||u.push(h),c++}}let a=e;for(l&&o[t].value===y&&(a+=1);a<n.length;){const c=o[a],d=o[a+1];if(c.value===y&&!c.listWrap||c.listId!==(d==null?void 0:d.listId)||c.titleId!==(d==null?void 0:d.titleId))break;const{pageNo:h,rowNo:u}=n[a];let g=s.get(h);g||(g=[],s.set(h,g)),g.includes(u)||g.push(u),a++}return s}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let n=-1;const o=[],s=this.getRangeParagraph();if(!s)return null;const i=this.draw.getElementList(),l=this.position.getPositionList();for(let a=0;a<l.length;a++){const c=l[a],d=s.get(c.pageNo);!d||d.includes(c.rowNo)&&(~n||(n=c.index),o.push(i[a]))}return o.length?{elementList:o,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:o}=this.range,s=this.position.getPositionList();for(let i=n+1;i<=o&&s[i];i++){const{coordinate:{leftTop:a,rightBottom:c}}=s[i];if(t>=a[0]&&t<=c[0]&&e>=a[1]&&e<=c[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),n=new Map;for(const s of e){const i=n.get(s.groupId);if(i)i.endIndex+=1;else{const{type:l,groupId:a,tableId:c,index:d,tdIndex:h,trIndex:u}=s,g={startIndex:d,endIndex:d};l===Bt.TABLE&&(g.tableId=c,g.startTdIndex=h,g.endTdIndex=h,g.startTrIndex=u,g.endTrIndex=u),n.set(a,g)}}const o=[];return n.forEach(s=>{o.push(s)}),o}getIsCanInput(){var i;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.draw.getElementList(),o=n[t];if(t===e)return(o.controlComponent!==R.ControlComponent.PRE_TEXT||((i=n[t+1])==null?void 0:i.controlComponent)!==R.ControlComponent.PRE_TEXT)&&o.controlComponent!==R.ControlComponent.POST_TEXT;const s=n[e];return!o.controlId&&!s.controlId||(!o.controlId||o.controlComponent===R.ControlComponent.POSTFIX)&&(!s.controlId||s.controlComponent===R.ControlComponent.POSTFIX)||!!o.controlId&&s.controlId===o.controlId&&s.controlComponent!==R.ControlComponent.PRE_TEXT&&s.controlComponent!==R.ControlComponent.POST_TEXT&&s.controlComponent!==R.ControlComponent.POSTFIX}setRange(t,e,n,o,s,i,l){this.getIsRangeChange(t,e,n,o,s,i,l)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=n,this.range.startTdIndex=o,this.range.endTdIndex=s,this.range.startTrIndex=i,this.range.endTrIndex=l,this.range.isCrossRowCol=!!(o||s||i||l),this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const c=this.draw.getControl();if(~t&&~e){const h=this.draw.getElementList()[t];if(h==null?void 0:h.controlId){c.initControl();return}}c.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(B(Y({},this.range),{startIndex:e}))}setRangeStyle(){var C,U;const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:o,isCrossRowCol:s}=this.range;if(!~n&&!~o)return;let i;if(s){const Q=this.draw.getOriginalElementList(),w=this.position.getPositionContext();i=Q[w.index]}else{const Q=~o?o:0,w=this.draw.getElementList();i=this.getRangeAnchorStyle(w,Q)}if(!i)return;const l=this.getSelection()||[i],a=i.type||R.ElementType.TEXT,c=i.font||this.options.defaultFont,d=i.size||this.options.defaultSize,h=!~l.findIndex(Q=>!Q.bold),u=!~l.findIndex(Q=>!Q.italic),g=!~l.findIndex(Q=>{var w;return!Q.underline&&!((w=Q.control)==null?void 0:w.underline)}),T=!~l.findIndex(Q=>!Q.strikeout),P=i.color||null,O=i.highlight||null,M=i.rowFlex||null,S=(C=i.rowMargin)!=null?C:this.options.defaultRowMargin,X=i.dashArray||[],N=i.level||null,m=i.listType||null,I=i.listStyle||null,f=g&&i.textDecoration||null,F=!!this.draw.getPainterStyle(),V=this.historyManager.isCanUndo(),Z=this.historyManager.isCanRedo(),E=i.groupIds||null,D=(U=i.extension)!=null?U:null,W={type:a,undo:V,redo:Z,painter:F,font:c,size:d,bold:h,italic:u,underline:g,strikeout:T,color:P,highlight:O,rowFlex:M,rowMargin:S,dashArray:X,level:N,listType:m,listStyle:I,groupIds:E,textDecoration:f,extension:D};t&&t(W),e&&this.eventBus.emit("rangeStyleChange",W)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const n=this.options.defaultFont,o=this.options.defaultSize,s=this.options.defaultRowMargin,i=!!this.draw.getPainterStyle(),l=this.historyManager.isCanUndo(),a=this.historyManager.isCanRedo(),c={type:null,undo:l,redo:a,painter:i,font:n,size:o,bold:!1,italic:!1,underline:!1,strikeout:!1,color:null,highlight:null,rowFlex:null,rowMargin:s,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,extension:null};t&&t(c),e&&this.eventBus.emit("rangeStyleChange",c)}shrinkBoundary(t={}){const e=t.elementList||this.draw.getElementList(),n=t.range||this.getRange(),{startIndex:o,endIndex:s}=n;if(!~o&&!~s)return;const i=e[o],l=e[s];if(o===s){if(i.controlComponent===R.ControlComponent.PLACEHOLDER){let a=o-1;for(;a>0;){const c=e[a];if(c.controlId!==i.controlId||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT){n.startIndex=a,n.endIndex=a;break}a--}}}else{if(i.controlComponent===R.ControlComponent.PLACEHOLDER||l.controlComponent===R.ControlComponent.PLACEHOLDER){let a=s-1;for(;a>0;){const c=e[a];if(c.controlId!==l.controlId||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT){n.startIndex=a,n.endIndex=a;return}a--}}if(i.controlComponent===R.ControlComponent.PREFIX){let a=o+1;for(;a<e.length;){const c=e[a];if(c.controlId!==i.controlId||c.controlComponent===R.ControlComponent.VALUE){n.startIndex=a-1;break}else if(c.controlComponent===R.ControlComponent.PLACEHOLDER){n.startIndex=a-1,n.endIndex=a-1;return}a++}}if(l.controlComponent!==R.ControlComponent.VALUE){let a=o-1;for(;a>0;){const c=e[a];if(c.controlId!==i.controlId||c.controlComponent===R.ControlComponent.VALUE){n.startIndex=a;break}else if(c.controlComponent===R.ControlComponent.PLACEHOLDER){n.startIndex=a,n.endIndex=a;return}a--}}}}render(t,e,n,o,s){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,n,o,s),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(y,"g"),""):""}}class Zs{constructor(t){L(this,"draw");L(this,"options");L(this,"imageCache");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,n,o){t.save(),t.fillStyle=e,t.fillRect(0,0,n,o),t.restore()}_drawImage(t,e,n,o){const{background:s,scale:i}=this.options;if(s.size===R.BackgroundSize.CONTAIN){const l=e.width*i,a=e.height*i;if(!s.repeat||s.repeat===R.BackgroundRepeat.NO_REPEAT)t.drawImage(e,0,0,l,a);else{let c=0,d=0;const h=s.repeat===R.BackgroundRepeat.REPEAT||s.repeat===R.BackgroundRepeat.REPEAT_X?Math.ceil(n*i/l):1,u=s.repeat===R.BackgroundRepeat.REPEAT||s.repeat===R.BackgroundRepeat.REPEAT_Y?Math.ceil(o*i/a):1;for(let g=0;g<h;g++){for(let T=0;T<u;T++)t.drawImage(e,c,d,l,a),d+=a;d=0,c+=l}}}else t.drawImage(e,0,0,n*i,o*i)}_renderBackgroundImage(t,e,n){const{background:o}=this.options,s=this.imageCache.get(o.image);if(s)this._drawImage(t,s,e,n);else{const i=new Image;i.setAttribute("crossOrigin","Anonymous"),i.src=o.image,i.onload=()=>{this.imageCache.set(o.image,i),this._drawImage(t,i,e,n),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:n,color:o,applyPageNumbers:s}}=this.options;if(n&&(!(s==null?void 0:s.length)||s.includes(e))){const{width:i,height:l}=this.options;this._renderBackgroundImage(t,i,l)}else{const i=this.draw.getCanvasWidth(e),l=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,o,i,l)}}}class dn{constructor(){L(this,"fillRect");L(this,"fillColor");L(this,"fillDecorationStyle");this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillDecorationStyle=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,n,o,s,i,l){const a=!this.fillRect.width;if(!a&&(this.fillColor!==i||this.fillDecorationStyle!==l)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,n,o,s,i,l);return}a&&(this.fillRect.x=e,this.fillRect.y=n),s&&this.fillRect.height<s&&(this.fillRect.height=s),this.fillRect.width+=o,this.fillColor=i,this.fillDecorationStyle=l}}class Us extends dn{constructor(t){super();L(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:n,y:o,width:s,height:i}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(n,o,s,i),t.restore(),this.clearFillInfo()}}class Ys{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:n,pageMode:o}=this.options,s=this.draw.getWidth(),i=o===R.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 c=[l[3],l[0]],d=[s-l[1],l[0]],h=[l[3],i-l[2]],u=[s-l[1],i-l[2]];t.moveTo(c[0]-a,c[1]),t.lineTo(...c),t.lineTo(c[0],c[1]-a),t.moveTo(d[0]+a,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]-a),t.moveTo(h[0]-a,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+a),t.moveTo(u[0]+a,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]+a),t.stroke(),t.restore()}}class Qs{constructor(t){L(this,"draw");L(this,"options");L(this,"position");L(this,"range");L(this,"searchKeyword");L(this,"searchNavigateIndex");L(this,"searchOptions");L(this,"searchMatchList");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 o=this.searchMatchList[t];if(n!==o.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 o=this.searchMatchList[t];if(n!==o.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:o},pageNo:s}=t,i=this.draw.getHeight(),l=this.draw.getPageGap(),a=s*(i+l),c=document.createElement("div");c.style.position="absolute";const d=50;c.style.width=`${o[0]-e[0]+d}px`,c.style.height=`${n[1]-e[1]+d}px`,c.style.left=`${e[0]}px`,c.style.top=`${e[1]+a}px`,this.draw.getContainer().append(c),c.scrollIntoView(!1),c.remove()}getSearchNavigateIndexList(){return this.searchNavigateIndex===null||!this.searchKeyword?[]:new Array(this.searchKeyword.length).fill(this.searchNavigateIndex).map((t,e)=>t+e)}getSearchMatchList(){return this.searchMatchList}getSearchNavigateInfo(){if(!this.searchKeyword||!this.searchMatchList.length)return null;const t=this.searchNavigateIndex!==null?this.searchNavigateIndex/this.searchKeyword.length+1:0;let e=0,n=null;for(let o=0;o<this.searchMatchList.length;o++){const s=this.searchMatchList[o];n!==s.groupId&&(n=s.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const{isRegEnable:n=!1,isIgnoreCase:o=!0}=this.searchOptions||{},s=o?t.toLocaleLowerCase():t,i=[],l=[],a=e.length,c=[];for(let g=0;g<a;g++)e[g].type===R.ElementType.TABLE&&c.push(g);let d=0,h=0;for(;h<a-1;){const g=c.length?c[d]:a,T=e.slice(h,g);T.length&&l.push({index:h,type:Bt.PAGE,elementList:T});const P=e[g];P&&l.push({index:g,type:Bt.TABLE,elementList:[P]}),h=g+1,d++}function u(g,T,P,O){if(!g)return;let M=P.map(I=>{var f,F;return!I.type||bt.includes(I.type)&&I.controlComponent!==R.ControlComponent.CHECKBOX&&I.controlComponent!==R.ControlComponent.RADIO&&!I.hide&&!((f=I.control)==null?void 0:f.hide)&&!((F=I.area)==null?void 0:F.hide)?I.value:y}).filter(Boolean).join("");o&&(M=M.toLocaleLowerCase());const S=[],X=n?new RegExp(g):g;let{index:N,length:m}=Vn(M,X);for(;N!==-1&&m!==0;){S.push({index:N,length:m});const I=Vn(M,X,N+m);N=I.index,m=I.length}for(let I=0;I<S.length;I++){const{index:f,length:F}=S[I],V=j();for(let Z=0;Z<F;Z++){const E=f+Z+((O==null?void 0:O.startIndex)||0);i.push(Y({type:T,index:E,groupId:V},O))}}}for(let g=0;g<l.length;g++){const T=l[g];if(T.type===Bt.TABLE){const P=T.elementList[0];for(let O=0;O<P.trList.length;O++){const M=P.trList[O];for(let S=0;S<M.tdList.length;S++){const X=M.tdList[S],N={tableId:P.id,tableIndex:T.index,trIndex:O,tdIndex:S,tdId:X.id};u(s,T.type,X.value,N)}}}else u(s,T.type,T.elementList,{startIndex:T.index})}return i}compute(t){var i;const e=((i=this.searchOptions)==null?void 0:i.isLimitSelection)&&!this.range.getIsCollapsed(),n=e?this.range.getSelectionElementList():this.draw.getOriginalElementList();if(!(n==null?void 0:n.length)||(this.searchMatchList=this.getMatchList(t,n),!e||!this.searchMatchList.length))return;const{startIndex:o}=this.range.getRange(),s=o+1;for(const l of this.searchMatchList)l.type===Bt.TABLE?l.tableIndex+=s:l.index+=s}render(t,e){var a,c;if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:n,searchMatchColor:o,searchNavigateMatchColor:s}=this.options,i=this.position.getOriginalPositionList(),l=this.draw.getOriginalElementList();t.save(),t.globalAlpha=n;for(let d=0;d<this.searchMatchList.length;d++){const h=this.searchMatchList[d];let u=null;if(h.type===Bt.TABLE){const{tableIndex:I,trIndex:f,tdIndex:F,index:V}=h;u=(c=(a=l[I])==null?void 0:a.trList[f].tdList[F])==null?void 0:c.positionList[V]}else u=i[h.index];if(!u)continue;const{coordinate:{leftTop:g,leftBottom:T,rightTop:P},pageNo:O}=u;if(O!==e)continue;if(this.getSearchNavigateIndexList().includes(d)){t.fillStyle=s;const I=this.searchMatchList[d-1];(!I||I.groupId!==h.groupId)&&this.searchNavigateScrollIntoView(u)}else t.fillStyle=o;const S=g[0],X=g[1],N=P[0]-g[0],m=T[1]-g[1];t.fillRect(S,X,N,m)}t.restore()}replace(t,e){var P,O,M,S;if(this.draw.isReadonly()||t==null)return;let o=this.getSearchMatchList();const s=e==null?void 0:e.index;if(ve(s)){const X=[];o.forEach(N=>{const m=X[X.length-1];!m||m[0].groupId!==N.groupId?X.push([N]):m.push(N)}),o=X[s]}if(!(o==null?void 0:o.length))return;const i=this.draw.isDesignMode();let l=0,a=0,c="",d="",h=-1;const u=this.draw.getOriginalElementList();for(let X=0;X<o.length;X++){const N=o[X];if(N.type===Bt.TABLE){const{tableIndex:m,trIndex:I,tdIndex:f,index:F,tdId:V}=N;d&&V!==d&&(a=0),d=V;const Z=m+l,E=u[Z].trList[I].tdList[f].value,D=F+a,W=E[D];if(!i&&(((P=W==null?void 0:W.control)==null?void 0:P.deletable)===!1||((O=W==null?void 0:W.title)==null?void 0:O.deletable)===!1))continue;if(t===""){this.draw.spliceElementList(E,D,1),a--,~h||(h=X);continue}if(c===N.groupId){this.draw.spliceElementList(E,D,1),a--;continue}~h||(h=X);for(let C=0;C<t.length;C++){const U=t[C];C===0?W.value=U:(this.draw.spliceElementList(E,D+C,0,[B(Y({},W),{value:U})]),a++)}}else{const m=N.index+l,I=u[m];if(!i&&(((M=I==null?void 0:I.control)==null?void 0:M.deletable)===!1||((S=I==null?void 0:I.title)==null?void 0:S.deletable)===!1)||I.type===R.ElementType.CONTROL&&I.controlComponent!==R.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(u,m,1),l--,~h||(h=X);continue}if(~h||(h=X),c===N.groupId){this.draw.spliceElementList(u,m,1),l--;continue}for(let f=0;f<t.length;f++){const F=t[f];f===0?I.value=F:(this.draw.spliceElementList(u,m+f,0,[B(Y({},I),{value:F})]),l++)}}c=N.groupId}if(!~h)return;const g=o[h],T=g.index+(t.length-1);if(g.type===Bt.TABLE){const{tableIndex:X,trIndex:N,tdIndex:m,index:I}=g,f=u[X].trList[N].tdList[m].value[I];this.position.setPositionContext({isTable:!0,index:X,trIndex:N,tdIndex:m,tdId:f.tdId,trId:f.trId,tableId:f.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(T,T),this.draw.render({curIndex:T})}}class Cs extends dn{constructor(t){super();L(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{scale:e,strikeoutColor:n}=this.options,{x:o,y:s,width:i}=this.fillRect;t.save(),t.lineWidth=e,t.strokeStyle=n;const l=s+.5;t.beginPath(),t.moveTo(o,l),t.lineTo(o+i,l),t.stroke(),t.restore(),this.clearFillInfo()}}R.TextDecorationStyle=void 0,function(r){r.SOLID="solid",r.DOUBLE="double",r.DASHED="dashed",r.DOTTED="dotted",r.WAVY="wavy"}(R.TextDecorationStyle||(R.TextDecorationStyle={}));var de;(function(r){r.SOLID="solid",r.DASHED="dashed",r.DOTTED="dotted"})(de||(de={}));class Es extends dn{constructor(t){super();L(this,"options");this.options=t.getOptions()}_drawLine(t,e,n,o,s){const i=e+o;switch(t.beginPath(),s){case de.DASHED:t.setLineDash([3,1]);break;case de.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(i,n),t.stroke()}_drawDouble(t,e,n,o){const s=3,i=e+o,l=n+s*this.options.scale;t.beginPath(),t.moveTo(e,n),t.lineTo(i,n),t.stroke(),t.beginPath(),t.moveTo(e,l),t.lineTo(i,l),t.stroke()}_drawWave(t,e,n,o){const{scale:s}=this.options,i=1.2*s,l=1/s,a=n+2*i;t.beginPath();for(let c=0;c<o;c++){const d=i*Math.sin(l*c);t.lineTo(e+c,a+d)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:o,y:s,width:i}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const l=Math.floor(s+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case R.TextDecorationStyle.WAVY:this._drawWave(t,o,l,i);break;case R.TextDecorationStyle.DOUBLE:this._drawDouble(t,o,l,i);break;case R.TextDecorationStyle.DASHED:this._drawLine(t,o,l,i,de.DASHED);break;case R.TextDecorationStyle.DOTTED:this._drawLine(t,o,l,i,de.DOTTED);break;default:this._drawLine(t,o,l,i);break}t.restore(),this.clearFillInfo()}}class Ds{constructor(t){L(this,"draw");L(this,"options");L(this,"ctx");L(this,"curX");L(this,"curY");L(this,"text");L(this,"curStyle");L(this,"curColor");L(this,"cacheMeasureText");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:Wi});return t.restore(),n}measureWord(t,e,n){const o=this.draw.getLetterReg();let s=0,i=null,l=n;for(;l<e.length;){const a=e[l];if(a.type&&a.type!==R.ElementType.TEXT||!o.test(a.value)){i=a;break}s+=this.measureText(t,a).width,l++}return{width:s,endElement:i}}measurePunctuationWidth(t,e){return!e||!Fi.includes(e.value)?0:(t.font=this.draw.getElementFont(e),this.measureText(t,e).width)}measureText(t,e){if(e.width){const i=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:i.actualBoundingBoxAscent,actualBoundingBoxDescent:i.actualBoundingBoxDescent,actualBoundingBoxLeft:i.actualBoundingBoxLeft,actualBoundingBoxRight:i.actualBoundingBoxRight,fontBoundingBoxAscent:i.fontBoundingBoxAscent,fontBoundingBoxDescent:i.fontBoundingBoxDescent}}const n=`${e.value}${t.font}`,o=this.cacheMeasureText.get(n);if(o)return o;const s=t.measureText(e.value);return this.cacheMeasureText.set(n,s),s}getBasisWordBoundingBoxAscent(t,e){return this.measureBasisWord(t,e).actualBoundingBoxAscent}complete(){this._render(),this.text=""}record(t,e,n,o){if(this.ctx=t,this.options.renderMode===R.RenderMode.COMPATIBILITY){this._setCurXY(n,o),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(n,o),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(n,o)),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.curY||(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 he{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,o){const s=o===R.NumberType.CHINESE?yi(e):`${e}`;return t.replace(n,s)}render(t,e){const{scale:n,pageNumber:{size:o,font:s,color:i,rowFlex:l,numberType:a,format:c,startPageNo:d,fromPageNo:h}}=this.options;if(e<h)return;let u=c;const g=new RegExp(Me.PAGE_NO);g.test(u)&&(u=he.formatNumberPlaceholder(u,e+d-h,g,a));const T=new RegExp(Me.PAGE_COUNT);T.test(u)&&(u=he.formatNumberPlaceholder(u,this.draw.getPageCount()-h,T,a));const P=this.draw.getWidth(),O=this.draw.getHeight(),M=this.draw.getPageNumberBottom(),S=O-M;t.save(),t.fillStyle=i,t.font=`${o*n}px ${s}`;let X=0;const N=this.draw.getMargins(),{width:m}=t.measureText(u);l===R.RowFlex.CENTER?X=(P-m)/2:l===R.RowFlex.RIGHT?X=P-m-N[1]:X=N[3],t.fillText(u,X,S),t.restore()}}class bs{constructor(t){L(this,"draw");L(this,"options");L(this,"scrollContainer");L(this,"_observer",Ci(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150));this.draw=t,this.options=t.getOptions(),this.scrollContainer=this.getScrollContainer(),setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}getScrollContainer(){return this.options.scrollContainerSelector&&document.querySelector(this.options.scrollContainerSelector)||document}_addEvent(){this.scrollContainer.addEventListener("scroll",this._observer)}removeEvent(){this.scrollContainer.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),n=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,o=Math.min(e.bottom,n)-Math.max(e.top,0);return{intersectionHeight:o>0?o:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let n=0,o=0;for(let s=0;s<t.length;s++){const i=t[s],{intersectionHeight:l}=this.getElementVisibleInfo(i);if(o&&!l)break;l&&e.push(s),l>o&&(o=l,n=s)}return{intersectionPageNo:n,visiblePageNoList:e}}}class Ks{constructor(t){L(this,"step",5);L(this,"thresholdPoints",[70,40,10,20]);L(this,"selectionContainer");L(this,"rangeManager");L(this,"requestAnimationFrameId");L(this,"isMousedown");L(this,"isMoving");L(this,"clientWidth");L(this,"clientHeight");L(this,"containerRect");L(this,"pageContainer");L(this,"_mousedown",()=>{if(this.isMousedown=!0,this.clientWidth=this.selectionContainer instanceof Document?document.documentElement.clientWidth:this.selectionContainer.clientWidth,this.clientHeight=this.selectionContainer instanceof Document?document.documentElement.clientHeight:this.selectionContainer.clientHeight,!(this.selectionContainer instanceof Document)){const t=this.selectionContainer.getBoundingClientRect();this.containerRect=t}});L(this,"_mouseup",()=>{this.isMousedown=!1,this._stopMove()});L(this,"_mousemove",t=>{if(!this.isMousedown||this.rangeManager.getIsCollapsed()||!this.pageContainer.contains(t.target))return;let{x:e,y:n}=t;this.containerRect&&(e=e-this.containerRect.x,n=n-this.containerRect.y),n<this.thresholdPoints[0]?this._startMove(Lt.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove(Lt.DOWN):e<this.thresholdPoints[2]?this._startMove(Lt.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(Lt.RIGHT):this._stopMove()});this.rangeManager=t.getRange(),this.pageContainer=t.getPageContainer();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,o=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Lt.DOWN?e.scrollTo(n,o+this.step):t===Lt.UP?e.scrollTo(n,o-this.step):t===Lt.LEFT?e.scrollTo(n-this.step,o):e.scrollTo(n+this.step,o),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 ys{constructor(t){L(this,"draw");L(this,"range");L(this,"options");this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){var n;const e=$(t);for(let o=0;o<t.length;o++){const s=e[o];for(let i=s.tdList.length-1;i>=0;i--){const l=s.tdList[i],{rowspan:a,rowIndex:c,colIndex:d}=l,h=c+a-1;if(h!==i){const u=s.tdList.splice(i,1)[0];(n=e[h])==null||n.tdList.splice(d,0,u)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:n,tdIndex:o}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:s,startTdIndex:i,endTdIndex:l,startTrIndex:a,endTrIndex:c}=this.range.getRange(),u=this.draw.getOriginalElementList()[e].trList;if(!s)return[[u[n].tdList[o]]];let g=u[a].tdList[i],T=u[c].tdList[l];(g.x>T.x||g.y>T.y)&&([g,T]=[T,g]);const P=g.colIndex,O=T.colIndex+(T.colspan-1),M=g.rowIndex,S=T.rowIndex+(T.rowspan-1),X=[];for(let N=0;N<u.length;N++){const m=u[N],I=[];for(let f=0;f<m.tdList.length;f++){const F=m.tdList[f],V=F.colIndex,Z=F.rowIndex;V>=P&&V<=O&&Z>=M&&Z<=S&&I.push(F)}I.length&&X.push(I)}return X.length?X:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:o,width:s,height:i,isDrawFullBorder:l,borderExternalWidth:a}=t,{scale:c}=this.options,d=e.lineWidth;a&&(e.lineWidth=a*c),e.beginPath();const h=Math.round(n),u=Math.round(o);e.translate(.5,.5),l?e.rect(h,u,s,i):(e.moveTo(h,u+i),e.lineTo(h,u),e.lineTo(h+s,u)),e.stroke(),a&&(e.lineWidth=d),e.translate(-.5,-.5)}_drawSlash(t,e,n,o){var d,h;const{scale:s}=this.options;t.save();const i=e.width*s,l=e.height*s,a=Math.round(e.x*s+n),c=Math.round(e.y*s+o);((d=e.slashTypes)==null?void 0:d.includes(R.TdSlash.FORWARD))&&(t.moveTo(a+i,c),t.lineTo(a,c+l)),((h=e.slashTypes)==null?void 0:h.includes(R.TdSlash.BACK))&&(t.moveTo(a,c),t.lineTo(a+i,c+l)),t.stroke(),t.restore()}_drawBorder(t,e,n,o){var S,X,N,m,I,f;const{colgroup:s,trList:i,borderType:l,borderColor:a,borderWidth:c=1,borderExternalWidth:d}=e;if(!s||!i)return;const{scale:h,table:{defaultBorderColor:u}}=this.options,g=e.width*h,T=e.height*h,P=l===R.TableBorder.EMPTY,O=l===R.TableBorder.EXTERNAL,M=l===R.TableBorder.INTERNAL;t.save(),l===R.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=c*h,t.strokeStyle=a||u,!P&&!M&&this._drawOuterBorder({ctx:t,startX:n,startY:o,width:g,height:T,borderExternalWidth:d,isDrawFullBorder:O});for(let F=0;F<i.length;F++){const V=i[F];for(let Z=0;Z<V.tdList.length;Z++){const E=V.tdList[Z];if(((S=E.slashTypes)==null?void 0:S.length)&&this._drawSlash(t,E,n,o),!((X=E.borderTypes)==null?void 0:X.length)&&(P||O))continue;const D=E.width*h,W=E.height*h,C=Math.round(E.x*h+n+D),U=Math.round(E.y*h+o);if(t.translate(.5,.5),t.beginPath(),((N=E.borderTypes)==null?void 0:N.includes(R.TdBorder.TOP))&&(t.moveTo(C-D,U),t.lineTo(C,U),t.stroke()),((m=E.borderTypes)==null?void 0:m.includes(R.TdBorder.RIGHT))&&(t.moveTo(C,U),t.lineTo(C,U+W),t.stroke()),((I=E.borderTypes)==null?void 0:I.includes(R.TdBorder.BOTTOM))&&(t.moveTo(C,U+W),t.lineTo(C-D,U+W),t.stroke()),((f=E.borderTypes)==null?void 0:f.includes(R.TdBorder.LEFT))&&(t.moveTo(C-D,U),t.lineTo(C-D,U+W),t.stroke()),!P&&!O){if((!M||E.colIndex+E.colspan<s.length)&&(t.moveTo(C,U),t.lineTo(C,U+W),d&&d!==c&&E.colIndex+E.colspan===s.length)){const Q=t.lineWidth;t.lineWidth=d*h,t.stroke(),t.beginPath(),t.lineWidth=Q}if(!M||E.rowIndex+E.rowspan<i.length){const Q=d&&d!==c&&E.rowIndex+E.rowspan===i.length;if(Q&&(t.stroke(),t.beginPath()),t.moveTo(C,U+W),t.lineTo(C-D,U+W),Q){const w=t.lineWidth;t.lineWidth=d*h,t.stroke(),t.beginPath(),t.lineWidth=w}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,o){const{trList:s}=e;if(!s)return;const{scale:i}=this.options;for(let l=0;l<s.length;l++){const a=s[l];for(let c=0;c<a.tdList.length;c++){const d=a.tdList[c];if(!d.backgroundColor)continue;t.save();const h=d.width*i,u=d.height*i,g=Math.round(d.x*i+n),T=Math.round(d.y*i+o);t.fillStyle=d.backgroundColor,t.fillRect(g,T,h,u),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,n)=>e+n.width,0)}getTableHeight(t){const e=t.trList;return(e==null?void 0:e.length)?this.getTdListByColIndex(e,0).reduce((n,o)=>n+o.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((n,o)=>n+o.rowspan,0)}getTdListByColIndex(t,e){const n=[];for(let o=0;o<t.length;o++){const s=t[o].tdList;for(let i=0;i<s.length;i++){const l=s[i],a=l.colIndex,c=a+l.colspan-1;e>=a&&e<=c&&n.push(l)}}return n}getTdListByRowIndex(t,e){const n=[];for(let o=0;o<t.length;o++){const s=t[o].tdList;for(let i=0;i<s.length;i++){const l=s[i],a=l.rowIndex,c=a+l.rowspan-1;e>=a&&e<=c&&n.push(l)}}return n}computeRowColInfo(t){const{colgroup:e,trList:n}=t;if(!e||!n)return;let o=0;for(let s=0;s<n.length;s++){const i=n[s],l=n.length-1===s;for(let a=0;a<i.tdList.length;a++){const c=i.tdList[a];let d=0;if(n.length>1&&s!==0){const M=i.tdList[a-1],S=M?M.colIndex+M.colspan:a;for(let X=S;X<e.length;X++)if(this.getRowCountByColIndex(n.slice(0,s),X)===s){d=X;let m=0;for(let I=0;I<X;I++)m+=e[I].width;o=m;break}}else{const M=i.tdList[a-1];M&&(d=M.colIndex+M.colspan)}let h=0;for(let M=0;M<c.colspan;M++)h+=e[M+d].width;let u=0;for(let M=0;M<c.rowspan;M++)u+=(n[M+s]||n[s]).height;const g=i.tdList.length-1===a;let T=l;if(!T&&c.rowspan>1){const M=n.length-1-s;T=c.rowspan-1===M}const P=l&&g;c.isLastRowTd=g,c.isLastColTd=T,c.isLastTd=P,c.x=o;let O=0;for(let M=0;M<s;M++){const S=n[M].tdList;for(let X=0;X<S.length;X++){const N=S[X];if(d>=N.colIndex&&d<N.colIndex+N.colspan){O+=N.height;break}}}c.y=O,c.width=h,c.height=u,c.rowIndex=s,c.colIndex=d,c.trIndex=s,c.tdIndex=a,o+=h,g&&!P&&(o=0)}}}drawRange(t,e,n,o){const{scale:s,rangeAlpha:i,rangeColor:l}=this.options,{type:a,trList:c}=e;if(!c||a!==R.ElementType.TABLE)return;const{isCrossRowCol:d,startTdIndex:h,endTdIndex:u,startTrIndex:g,endTrIndex:T}=this.range.getRange();if(!d)return;let P=c[g].tdList[h],O=c[T].tdList[u];(P.x>O.x||P.y>O.y)&&([P,O]=[O,P]);const M=P.colIndex,S=O.colIndex+(O.colspan-1),X=P.rowIndex,N=O.rowIndex+(O.rowspan-1);t.save();for(let m=0;m<c.length;m++){const I=c[m];for(let f=0;f<I.tdList.length;f++){const F=I.tdList[f],V=F.colIndex,Z=F.rowIndex;if(V>=M&&V<=S&&Z>=X&&Z<=N){const E=F.x*s,D=F.y*s,W=F.width*s,C=F.height*s;t.globalAlpha=i,t.fillStyle=l,t.fillRect(E+n,D+o,W,C)}}}t.restore()}render(t,e,n,o){this._drawBackgroundColor(t,e,n,o),this._drawBorder(t,e,n,o)}}var kt;(function(r){r.ROW="row",r.COL="col"})(kt||(kt={}));class ws{constructor(t){L(this,"MIN_TD_WIDTH",20);L(this,"ROW_COL_OFFSET",18);L(this,"ROW_COL_QUICK_WIDTH",16);L(this,"ROW_COL_QUICK_OFFSET",5);L(this,"ROW_COL_QUICK_POSITION",this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2);L(this,"BORDER_VALUE",4);L(this,"TABLE_SELECT_OFFSET",20);L(this,"draw");L(this,"canvas");L(this,"options");L(this,"position");L(this,"range");L(this,"container");L(this,"toolRowContainer");L(this,"toolRowAddBtn");L(this,"toolColAddBtn");L(this,"toolTableSelectBtn");L(this,"toolColContainer");L(this,"toolBorderContainer");L(this,"anchorLine");L(this,"mousedownX");L(this,"mousedownY");this.draw=t,this.canvas=t.getPage(),this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.container=t.getContainer(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null,this.anchorLine=null,this.mousedownX=0,this.mousedownY=0}dispose(){var t,e,n,o,s,i;(t=this.toolRowContainer)==null||t.remove(),(e=this.toolRowAddBtn)==null||e.remove(),(n=this.toolColAddBtn)==null||n.remove(),(o=this.toolTableSelectBtn)==null||o.remove(),(s=this.toolColContainer)==null||s.remove(),(i=this.toolBorderContainer)==null||i.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:o}=this.position.getPositionContext();if(!t)return;this.dispose();const s=this.draw.getOriginalElementList(),i=this.position.getOriginalPositionList(),l=s[e];if(l.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:a,table:{overflow:c}}=this.options,d=i[e],{colgroup:h,trList:u}=l,{coordinate:{leftTop:g}}=d,T=this.draw.getHeight(),P=this.draw.getPageGap(),O=this.draw.getPageNo()*(T+P),M=g[0],S=g[1]+O,X=l.trList[n].tdList[o],N=X.rowIndex,m=X.colIndex,I=l.height*a,f=l.width*a,F=document.createElement("div");F.classList.add(`${v}-table-tool__select`),F.style.height=`${I*a}`,F.style.left=`${M}px`,F.style.top=`${S}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 V=u.map(Q=>Q.height),Z=document.createElement("div");Z.classList.add(`${v}-table-tool__row`),Z.style.transform=`translateX(-${this.ROW_COL_OFFSET*a}px)`;for(let Q=0;Q<V.length;Q++){const w=V[Q]*a,K=document.createElement("div");K.classList.add(`${v}-table-tool__row__item`),Q===N&&K.classList.add("active"),K.onclick=()=>{const G=this.draw.getTableParticle().getTdListByRowIndex(u,Q),H=G[0],x=G[G.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:H.trIndex,tdIndex:H.tdIndex,tableId:l.id}),this.range.setRange(0,0,l.id,H.tdIndex,x.tdIndex,H.trIndex,x.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(Z,Q)};const p=document.createElement("div");p.classList.add(`${v}-table-tool__anchor`),p.onmousedown=G=>{this._mousedown({evt:G,element:l,index:Q,order:kt.ROW})},K.append(p),K.style.height=`${w}px`,Z.append(K)}Z.style.left=`${M}px`,Z.style.top=`${S}px`,this.container.append(Z),this.toolRowContainer=Z;const E=document.createElement("div");E.classList.add(`${v}-table-tool__quick__add`),E.style.height=`${I*a}`,E.style.left=`${M}px`,E.style.top=`${S+I}px`,E.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*a}px, ${this.ROW_COL_QUICK_OFFSET*a}px)`,E.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:u.length-1,tdIndex:0,tableId:l.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(E),this.toolRowAddBtn=E;const D=h.map(Q=>Q.width),W=document.createElement("div");W.classList.add(`${v}-table-tool__col`),W.style.transform=`translateY(-${this.ROW_COL_OFFSET*a}px)`;for(let Q=0;Q<D.length;Q++){const w=D[Q]*a,K=document.createElement("div");K.classList.add(`${v}-table-tool__col__item`),Q===m&&K.classList.add("active"),K.onclick=()=>{const G=this.draw.getTableParticle().getTdListByColIndex(u,Q),H=G[0],x=G[G.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:H.trIndex,tdIndex:H.tdIndex,tableId:l.id}),this.range.setRange(0,0,l.id,H.tdIndex,x.tdIndex,H.trIndex,x.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(W,Q)};const p=document.createElement("div");p.classList.add(`${v}-table-tool__anchor`),p.onmousedown=G=>{this._mousedown({evt:G,element:l,index:Q,order:kt.COL})},K.append(p),K.style.width=`${w}px`,W.append(K)}W.style.left=`${M}px`,W.style.top=`${S}px`,this.container.append(W),this.toolColContainer=W;const C=document.createElement("div");C.classList.add(`${v}-table-tool__quick__add`),C.style.height=`${I*a}`,C.style.left=`${M+f}px`,C.style.top=`${S}px`,C.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*a}px, -${this.ROW_COL_QUICK_POSITION*a}px)`,C.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:u[0].tdList.length-1||0,tableId:l.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(C),this.toolColAddBtn=C;const U=document.createElement("div");U.classList.add(`${v}-table-tool__border`),U.style.height=`${I}px`,U.style.width=`${f}px`,U.style.left=`${M}px`,U.style.top=`${S}px`;for(let Q=0;Q<u.length;Q++){const w=u[Q];for(let K=0;K<w.tdList.length;K++){const p=w.tdList[K],G=document.createElement("div");G.classList.add(`${v}-table-tool__border__row`),G.style.width=`${p.width*a}px`,G.style.height=`${this.BORDER_VALUE}px`,G.style.top=`${(p.y+p.height)*a-this.BORDER_VALUE/2}px`,G.style.left=`${p.x*a}px`,G.onmousedown=x=>{this._mousedown({evt:x,element:l,index:p.rowIndex+p.rowspan-1,order:kt.ROW})},U.appendChild(G);const H=document.createElement("div");if(H.classList.add(`${v}-table-tool__border__col`),H.style.width=`${this.BORDER_VALUE}px`,H.style.height=`${p.height*a}px`,H.style.top=`${p.y*a}px`,H.style.left=`${(p.x+p.width)*a-this.BORDER_VALUE/2}px`,H.onmousedown=x=>{this._mousedown({evt:x,element:l,index:p.colIndex+p.colspan-1,order:kt.COL})},U.appendChild(H),c&&p.colIndex===0){const x=document.createElement("div");x.classList.add(`${v}-table-tool__border__col`),x.style.width=`${this.BORDER_VALUE}px`,x.style.height=`${p.height*a}px`,x.style.top=`${p.y*a}px`,x.style.left=`${p.x*a-this.BORDER_VALUE/2}px`,x.onmousedown=k=>{this._mousedown({evt:k,element:l,index:0,isLeftStartBorder:!0,order:kt.COL})},U.appendChild(x)}}}this.container.append(U),this.toolBorderContainer=U}_setAnchorActive(t,e){const n=t.children;for(let o=0;o<n.length;o++){const s=n[o];o===e?s.classList.add("active"):s.classList.remove("active")}}_mousedown(t){const{evt:e,index:n,order:o,element:s,isLeftStartBorder:i}=t;this.canvas=this.draw.getPage();const{scale:l,table:{overflow:a}}=this.options,c=this.draw.getWidth(),d=this.draw.getHeight(),h=this.draw.getPageGap(),u=this.draw.getPageNo()*(d+h);this.mousedownX=e.x,this.mousedownY=e.y;const g=e.target,T=this.canvas.getBoundingClientRect(),P=window.getComputedStyle(g).cursor;document.body.style.cursor=P,this.canvas.style.cursor=P;let O=0,M=0;const S=document.createElement("div");S.classList.add(`${v}-table-anchor__line`),o===kt.ROW?(S.classList.add(`${v}-table-anchor__line__row`),S.style.width=`${c}px`,O=0,M=u+this.mousedownY-T.top):(S.classList.add(`${v}-table-anchor__line__col`),S.style.height=`${d}px`,O=this.mousedownX-T.left,M=u),S.style.left=`${O}px`,S.style.top=`${M}px`,this.container.append(S),this.anchorLine=S;let X=0,N=0;const m=I=>{const f=this._mousemove(I,o,O,M);f&&(X=f.dx,N=f.dy)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",()=>{var f;let I=!1;if(o===kt.ROW){const F=s.trList,V=F[n]||F[n-1],{defaultTrMinHeight:Z}=this.options.table;N<0&&V.height+N<Z&&(N=Z-V.height),N&&(V.height+=N,V.minHeight=V.height,I=!0)}else{const{colgroup:F}=s;if(F&&X)if(a&&i)F[n].width-X/l<=this.MIN_TD_WIDTH&&(X=(F[n].width-this.MIN_TD_WIDTH)*l),F[n].width-=X/l,s.width-=X/l,s.translateX=(s.translateX||0)+X/l,I=!0;else{const V=this.draw.getInnerWidth(),Z=F[n].width;X<0&&Z+X<this.MIN_TD_WIDTH&&(X=this.MIN_TD_WIDTH-Z);const E=(f=F[n+1])==null?void 0:f.width;X>0&&E&&E-X<this.MIN_TD_WIDTH&&(X=E-this.MIN_TD_WIDTH);const D=Z+X;if(!a&&n===F.length-1){let W=0;for(let C=0;C<F.length;C++){const U=F[C];C===n+1&&(W-=X),C===n&&(W+=D),C!==n&&(W+=U.width)}if(W>V){const C=s.width;X=V-C}}X&&(F.length-1!==n&&(F[n+1].width-=X/l),F[n].width+=X/l,I=!0)}}I&&this.draw.render({isSetCursor:!1}),S.remove(),document.removeEventListener("mousemove",m),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,o){if(!this.anchorLine)return null;const s=t.x-this.mousedownX,i=t.y-this.mousedownY;return e===kt.ROW?this.anchorLine.style.top=`${o+i}px`:this.anchorLine.style.left=`${n+s}px`,t.preventDefault(),{dx:s,dy:i}}}class Hs{constructor(t){L(this,"draw");L(this,"options");L(this,"container");L(this,"hyperlinkPopupContainer");L(this,"hyperlinkDom");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(`${v}-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,o]},lineHeight:s}=e,i=this.draw.getHeight(),l=this.draw.getPageGap(),a=this.draw.getPageNo()*(i+l);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${o+a+s}px`;const c=t.url||"#";this.hyperlinkDom.href=c,this.hyperlinkDom.title=c,this.hyperlinkDom.innerText=c}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,o){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,o),t.restore()}}class Gs{constructor(t){L(this,"options");this.options=t.getOptions()}render(t,e,n,o){var M,S,X,N;const{scale:s,label:{defaultBackgroundColor:i,defaultColor:l,defaultBorderRadius:a,defaultPadding:c}}=this.options,d=((M=e.label)==null?void 0:M.backgroundColor)||i,h=((S=e.label)==null?void 0:S.color)||l,u=((X=e.label)==null?void 0:X.borderRadius)||a,g=((N=e.label)==null?void 0:N.padding)||c;t.save(),t.font=e.style;const{width:T,height:P,boundingBoxAscent:O}=e.metrics;t.fillStyle=d,this._drawRoundedRect(t,n,o-O,T,P+(g[0]+g[3])*s,u*s),t.fill(),t.fillStyle=h,t.fillText(e.value,n+g[3]*s,o),t.restore()}_drawRoundedRect(t,e,n,o,s,i){t.beginPath(),t.moveTo(e+i,n),t.lineTo(e+o-i,n),t.quadraticCurveTo(e+o,n,e+o,n+i),t.lineTo(e+o,n+s-i),t.quadraticCurveTo(e+o,n+s,e+o-i,n+s),t.lineTo(e+i,n+s),t.quadraticCurveTo(e,n+s,e,n+s-i),t.lineTo(e,n+i),t.quadraticCurveTo(e,n,e+i,n),t.closePath()}}class xs{constructor(t,e){L(this,"draw");L(this,"position");L(this,"zone");L(this,"options");L(this,"elementList");L(this,"rowList");L(this,"positionList");this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth(),e=this.draw.getMargins(),n=on(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(),o=this.draw.getMargins()[3],s=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:o,startY:s,innerWidth:e,zone:R.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*Xn[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(),o=this.getHeaderTop()+e-t[0];return o<=0?0:o}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const n=this.draw.getInnerWidth(),o=this.getMaxHeight(),s=[];let i=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(i+a.height>o)break;s.push(a),i+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:s,pageNo:e,startIndex:0,innerWidth:n,zone:R.EditorZone.HEADER}),t.restore()}}class Js{getOffsetY(t){return-t.metrics.height/2}render(t,e,n,o){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,o+this.getOffsetY(e)),t.restore()}}class vs{getOffsetY(t){return t.metrics.height/2}render(t,e,n,o){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,o+this.getOffsetY(e)),t.restore()}}class Bs{constructor(t){L(this,"options");this.options=t.getOptions()}render(t,e,n,o){var c;t.save();const{scale:s,separator:{lineWidth:i,strokeStyle:l}}=this.options;t.lineWidth=(e.lineWidth||i)*s,t.strokeStyle=e.color||l,((c=e.dashArray)==null?void 0:c.length)&&t.setLineDash(e.dashArray);const a=Math.round(o);t.translate(0,t.lineWidth/2),t.beginPath(),t.moveTo(n,a),t.lineTo(n+e.width*s,a),t.stroke(),t.restore()}}class ks{constructor(t){L(this,"draw");L(this,"options");L(this,"i18n");this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,n,o){const{pageBreak:{font:s,fontSize:i,lineDash:l}}=this.options,a=this.i18n.t("pageBreak.displayName"),{scale:c,defaultRowMargin:d}=this.options,h=i*c,u=e.width*c,g=this.draw.getDefaultBasicRowMarginHeight()*d;t.save(),t.font=`${h}px ${s}`;const T=t.measureText(a),P=(u-T.width)/2;t.setLineDash(l),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,o),t.lineTo(n+P,o),t.moveTo(n+P+T.width,o),t.lineTo(n+u,o),t.stroke(),t.fillText(a,n+P,o+T.actualBoundingBoxAscent-h/2),t.restore()}}class As{constructor(t){L(this,"draw");L(this,"options");L(this,"imageCache");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:n,opacity:o,font:s,size:i,color:l,repeat:a,gap:c,numberType:d},scale:h}=this.options,u=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=o,t.font=`${i*h}px ${s}`;let T=n;const P=new RegExp(Me.PAGE_NO);P.test(T)&&(T=he.formatNumberPlaceholder(T,e+1,P,d));const O=new RegExp(Me.PAGE_COUNT);O.test(T)&&(T=he.formatNumberPlaceholder(T,this.draw.getPageCount(),O,d));const M=t.measureText(T);if(a){const S=this.draw.getPagePixelRatio(),X=document.createElement("canvas"),N=X.getContext("2d"),m=M.width,I=M.actualBoundingBoxAscent+M.actualBoundingBoxDescent,f=Math.sqrt(Math.pow(m,2)+Math.pow(I,2)),F=f+2*c[0]*h,V=f+2*c[1]*h;X.width=F,X.height=V,X.style.width=`${F*S}px`,X.style.height=`${V*S}px`,N.translate(F/2,V/2),N.rotate(-45*Math.PI/180),N.translate(-F/2,-V/2),N.font=`${i*h}px ${s}`,N.fillStyle=l,N.fillText(T,(F-m)/2,(V-I)/2+M.actualBoundingBoxAscent);const Z=t.createPattern(X,"repeat");Z&&(t.fillStyle=Z,t.fillRect(0,0,u,g))}else{const S=u/2,X=g/2;t.fillStyle=l,t.translate(S,X),t.rotate(-45*Math.PI/180),t.fillText(T,-M.width/2,M.actualBoundingBoxAscent-i*h/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:n,data:o,opacity:s,repeat:i,gap:l},scale:a}=this.options;if(!this.imageCache.has(o)){const g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=o,g.onload=()=>{this.imageCache.set(o,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const c=this.draw.getWidth(),d=this.draw.getHeight(),h=e*a,u=n*a;if(t.save(),t.globalAlpha=s,i){const g=this.draw.getPagePixelRatio(),T=document.createElement("canvas"),P=T.getContext("2d"),O=Math.sqrt(Math.pow(h,2)+Math.pow(u,2)),M=O+2*l[0]*a,S=O+2*l[1]*a;T.width=M,T.height=S,T.style.width=`${M*g}px`,T.style.height=`${S*g}px`,P.translate(M/2,S/2),P.rotate(-45*Math.PI/180),P.translate(-M/2,-S/2),P.drawImage(this.imageCache.get(o),(M-h)/2,(S-u)/2,h,u);const X=t.createPattern(T,"repeat");X&&(t.fillStyle=X,t.fillRect(0,0,c,d))}else{const g=c/2,T=d/2;t.translate(g,T),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(o),-h/2,-u/2,h,u)}t.restore()}render(t,e){this.options.watermark.type===R.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class _s{constructor(t){L(this,"draw");L(this,"control");L(this,"options");L(this,"highlightList");L(this,"highlightMatchResult");this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){var T,P;const{control:{activeBackgroundColor:n,disabledBackgroundColor:o,existValueBackgroundColor:s,noValueBackgroundColor:i}}=this.options,l=t[e],a=this.draw.isPrintMode(),c=(T=this.control.getActiveControl())==null?void 0:T.getElement();let d=!1,h=!1,u=!1,g=!1;return l.highlight||(d=!a&&!!n&&!!c&&l.controlId===c.controlId&&!this.control.getIsRangeInPostfix()),d||(h=!a&&!!o&&!!((P=l.control)==null?void 0:P.disabled)),h||(u=!a&&!!s&&!!l.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),u||(g=!a&&!!i&&!!l.controlId&&!this.control.getIsExistValueByElementListIndex(t,e)),(d?n:"")||(h?o:"")||(u?s:"")||(g?i:"")}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(n,o)=>{let s=0;for(;s<n.length;){const i=n[s];if(s++,i.type===R.ElementType.TABLE){const T=i.trList;for(let P=0;P<T.length;P++){const O=T[P];for(let M=0;M<O.tdList.length;M++){const S=O.tdList[M],X={tableId:i.id,tableIndex:s-1,trIndex:P,tdIndex:M,tdId:S.id};e(S.value,X)}}}const l=i==null?void 0:i.control;if(!l)continue;const a=this.highlightList.findIndex(T=>T.id===i.controlId||l.conceptId&&l.conceptId===T.conceptId);if(!~a)continue;const c=s;let d=s;for(;d<n.length&&n[d].controlId===i.controlId;)d++;s=d;const h=n.slice(c,d).map(T=>T.controlComponent===R.ControlComponent.VALUE?T:{value:y}),u=this.highlightList[a],{ruleList:g}=u;for(let T=0;T<g.length;T++){const P=g[T],O=t.getMatchList(P.keyword,h);this.highlightMatchResult.push(...O.map(M=>B(Y(Y(Y({},M),P),o),{index:M.index+c})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){var l,a,c;if(!((l=this.highlightMatchResult)==null?void 0:l.length))return;const{searchMatchAlpha:n,searchMatchColor:o}=this.options,s=this.draw.getPosition().getOriginalPositionList(),i=this.draw.getOriginalElementList();t.save();for(let d=0;d<this.highlightMatchResult.length;d++){const h=this.highlightMatchResult[d];let u=null;if(h.tableId){const{tableIndex:m,trIndex:I,tdIndex:f,index:F}=h;u=(c=(a=i[m])==null?void 0:a.trList[I].tdList[f])==null?void 0:c.positionList[F]}else u=s[h.index];if(!u)continue;const{coordinate:{leftTop:g,leftBottom:T,rightTop:P},pageNo:O}=u;if(O!==e)continue;t.fillStyle=h.backgroundColor||o,t.globalAlpha=h.alpha||n;const M=g[0],S=g[1],X=P[0]-g[0],N=T[1]-g[1];t.fillRect(M,S,X,N)}t.restore()}}class zs{constructor(t){L(this,"borderRect");L(this,"options");this.borderRect=this.clearBorderInfo(),this.options=t.getOptions()}clearBorderInfo(){return this.borderRect={x:0,y:0,width:0,height:0},this.borderRect}recordBorderInfo(t,e,n,o){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=o),this.borderRect.width+=n}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:n,borderColor:o}}=this.options,{x:s,y:i,width:l,height:a}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=n*e,t.strokeStyle=o,t.beginPath(),t.rect(s,i,l,a),t.stroke(),t.restore(),this.clearBorderInfo()}}class Se{constructor(t,e){L(this,"draw");L(this,"element");L(this,"control");L(this,"isPopup");L(this,"selectDom");L(this,"options");L(this,"VALUE_DELIMITER",",");L(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?void 0:e.code)?this.element.control.code.split(","):[]}getText(t){var i,l;if(!((i=this.element)==null?void 0:i.control))return null;const e=this.element.control;if(!((l=e.valueSets)==null?void 0:l.length))return null;const n=(e==null?void 0:e.multiSelectDelimiter)||this.DEFAULT_MULTI_SELECT_DELIMITER,o=e.valueSets,s=[];return t.forEach(a=>{const c=o.find(d=>d.code===a);c&&!Wn(c.value)&&s.push(c.value)}),s.join(n)||null}getValue(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:n}=t.range||this.control.getRange(),o=e[n],s=[];let i=n;for(;i>0;){const a=e[i];if(a.controlId!==o.controlId||a.controlComponent===R.ControlComponent.PREFIX||a.controlComponent===R.ControlComponent.PRE_TEXT)break;a.controlComponent===R.ControlComponent.VALUE&&s.unshift(a),i--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==o.controlId||a.controlComponent===R.ControlComponent.POSTFIX||a.controlComponent===R.ControlComponent.POST_TEXT)break;a.controlComponent===R.ControlComponent.VALUE&&s.push(a),l++}return s}setValue(t,e={},n={}){var u,g;if(!((g=(u=this.element.control)==null?void 0:u.selectExclusiveOptions)==null?void 0:g.inputAble)||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:i,endIndex:l}=s,a=this.control.getDraw();i!==l?a.spliceElementList(o,i+1,l-i):this.control.removePlaceholder(i,e);const c=o[i],d=c.type&&!bt.includes(c.type)||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT?pt(c,["control","controlId",...xt]):Ht(c,["type"]),h=s.startIndex+1;for(let T=0;T<t.length;T++){const P=B(Y(Y({},d),t[T]),{controlComponent:R.ControlComponent.VALUE});It(o,[P],i,{editorOptions:this.options}),a.spliceElementList(o,h+T,0,[P])}return h+t.length-1}keydown(t){var c,d;if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:o,endIndex:s}=n,i=e[o],l=e[s],a=(d=(c=this.element.control)==null?void 0:c.selectExclusiveOptions)==null?void 0:d.inputAble;if(t.key===R.KeyMap.Backspace)return o!==s?a?(this.draw.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o):this.clearSelect():i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):a?(this.draw.spliceElementList(e,o,1),this.getValue().length||this.control.addPlaceholder(o-1),o-1):this.clearSelect();if(t.key===R.KeyMap.Delete){if(o!==s)return a?(this.draw.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o):this.clearSelect();{const h=e[s+1];return(i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT)&&h.controlComponent===R.ControlComponent.PLACEHOLDER||h.controlComponent===R.ControlComponent.POSTFIX||h.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):a?(this.draw.spliceElementList(e,o+1,1),this.getValue().length||this.control.addPlaceholder(o),o):this.clearSelect()}}return s}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:o=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const s=t.elementList||this.control.getElementList(),{startIndex:i}=t.range||this.control.getRange(),l=s[i];let a=-1,c=-1,d=i;for(;d>0;){const g=s[d];if(g.controlId!==l.controlId||g.controlComponent===R.ControlComponent.PREFIX||g.controlComponent===R.ControlComponent.PRE_TEXT){a=d;break}d--}let h=i+1;for(;h<s.length;){const g=s[h];if(g.controlId!==l.controlId||g.controlComponent===R.ControlComponent.POSTFIX||g.controlComponent===R.ControlComponent.POST_TEXT){c=h-1;break}h++}return!~a||!~c?-1:(this.control.getDraw().spliceElementList(s,a+1,c-a,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),o&&this.control.addPlaceholder(d,t),this.control.setControlProperties({code:null},{elementList:s,range:{startIndex:d,endIndex:d}}),d)}setSelect(t,e={},n={}){var N;if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange(),i=this.element.control,l=(t==null?void 0:t.split(this.VALUE_DELIMITER))||[],a=i.code,c=((N=i.code)==null?void 0:N.split(this.VALUE_DELIMITER))||[],d=i.isMultiSelect;if(!d&&t===a||d&&Fn(c,l)){this.control.repaintControl({curIndex:s.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const h=i.valueSets;if(!Array.isArray(h)||!h.length)return;const u=this.getText(l);if(!u){if(a){const m=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~m&&(this.control.repaintControl({curIndex:m}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],T=g?pt(g,Dt):pt(o[s.startIndex],xt),P=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~P)return;a||this.control.removePlaceholder(P,e);const O=Ht(o[P],Dt),M=P+1,S=Qt(u),X=this.control.getDraw();for(let m=0;m<S.length;m++){const I=B(Y(Y({},T),O),{type:R.ElementType.TEXT,value:S[m],controlComponent:R.ControlComponent.VALUE});It(o,[I],P,{editorOptions:this.options}),X.spliceElementList(o,M+m,0,[I])}if(this.control.setControlProperties({code:t},{elementList:o,range:{startIndex:P,endIndex:P}}),!e.range){const m=M+S.length-1;this.control.repaintControl({curIndex:m}),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 o=document.createElement("div");o.classList.add(`${v}-select-control-popup`),o.setAttribute(_t,R.EditorComponent.POPUP);const s=document.createElement("ul");let i=null;for(let u=0;u<e.length;u++){const g=e[u],T=document.createElement("li");let P=this.getCodes();P.includes(g.code)&&(T.classList.add("active"),i=T),T.onclick=()=>{const O=P.findIndex(M=>M===g.code);t.isMultiSelect?~O?P.splice(O,1):P.push(g.code):~O?P=[]:P=[g.code],this.setSelect(P.join(this.VALUE_DELIMITER))},T.append(document.createTextNode(g.value)),s.append(T)}o.append(s);const{coordinate:{leftTop:[l,a]},lineHeight:c}=n,d=this.control.getPreY();o.style.left=`${l}px`,o.style.top=`${a+d+c}px`,this.control.getContainer().append(o),this.selectDom=o,i&&pn(o,i)}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 hn{constructor(t,e){L(this,"element");L(this,"control");L(this,"options");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(),o=e[n],s=[];let i=n;for(;i>0;){const a=e[i];if(a.controlId!==o.controlId||a.controlComponent===R.ControlComponent.PREFIX||a.controlComponent===R.ControlComponent.PRE_TEXT)break;a.controlComponent===R.ControlComponent.VALUE&&s.unshift(a),i--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==o.controlId||a.controlComponent===R.ControlComponent.POSTFIX||a.controlComponent===R.ControlComponent.POST_TEXT)break;a.controlComponent===R.ControlComponent.VALUE&&s.push(a),l++}return s}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:i,endIndex:l}=s,a=this.control.getDraw();i!==l?a.spliceElementList(o,i+1,l-i,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(i,e);const c=o[i],d=c.type&&!bt.includes(c.type)||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT?pt(c,["control","controlId",...xt]):Ht(c,["type"]),h=s.startIndex+1;for(let u=0;u<t.length;u++){const g=B(Y(Y({},d),t[u]),{controlComponent:R.ControlComponent.VALUE});It(o,[g],i,{editorOptions:this.options}),a.spliceElementList(o,h+u,0,[g])}return h+t.length-1}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),o=t.range||this.control.getValueRange()||this.control.getRange(),{startIndex:s,endIndex:i}=o;return this.control.getDraw().spliceElementList(n,s+1,i-s,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),this.getValue({range:o,elementList:n}).length||this.control.addPlaceholder(s,t),s}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:o,endIndex:s}=n,i=e[o],l=e[s],a=this.control.getDraw();if(t.key===R.KeyMap.Backspace)return o!==s?(a.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o):i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):(a.spliceElementList(e,o,1),this.getValue().length||this.control.addPlaceholder(o-1),o-1);if(t.key===R.KeyMap.Delete){if(o!==s)return a.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o;{const c=e[s+1];return(i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT)&&c.controlComponent===R.ControlComponent.PLACEHOLDER||c.controlComponent===R.ControlComponent.POSTFIX||c.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):(a.spliceElementList(e,o+1,1),this.getValue().length||this.control.addPlaceholder(o),o)}}return s}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(),o=this.control.getElementList();return n.spliceElementList(o,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}}class ii{constructor(t,e={}){L(this,"draw");L(this,"options");L(this,"now");L(this,"dom");L(this,"renderOptions");L(this,"isDatePicker");L(this,"pickDate");L(this,"lang");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(`${v}-date-container`),t.setAttribute(_t,R.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${v}-date-wrap`);const n=document.createElement("div");n.classList.add(`${v}-date-title`);const o=document.createElement("span");o.classList.add(`${v}-date-title__pre-year`),o.innerText="<<";const s=document.createElement("span");s.classList.add(`${v}-date-title__pre-month`),s.innerText="<";const i=document.createElement("span");i.classList.add(`${v}-date-title__now`);const l=document.createElement("span");l.classList.add(`${v}-date-title__next-month`),l.innerText=">";const a=document.createElement("span");a.classList.add(`${v}-date-title__next-year`),a.innerText=">>",n.append(o),n.append(s),n.append(i),n.append(l),n.append(a);const c=document.createElement("div");c.classList.add(`${v}-date-week`);const{weeks:{sun:d,mon:h,tue:u,wed:g,thu:T,fri:P,sat:O}}=this.lang;[d,h,u,g,T,P,O].forEach(D=>{const W=document.createElement("span");W.innerText=`${D}`,c.append(W)});const S=document.createElement("div");S.classList.add(`${v}-date-day`),e.append(n),e.append(c),e.append(S);const X=document.createElement("ul");X.classList.add(`${v}-time-wrap`);let N,m,I;[this.lang.hour,this.lang.minute,this.lang.second].forEach((D,W)=>{const C=document.createElement("li"),U=document.createElement("span");U.innerText=D,C.append(U);const Q=document.createElement("ol"),w=W===0,K=W===1,p=w?24:60;for(let G=0;G<p;G++){const H=document.createElement("li");H.innerText=`${String(G).padStart(2,"0")}`,H.setAttribute("data-id",`${G}`),Q.append(H)}w?N=Q:K?m=Q:I=Q,C.append(Q),X.append(C)});const F=document.createElement("div");F.classList.add(`${v}-date-menu`);const V=document.createElement("button");V.classList.add(`${v}-date-menu__time`),V.innerText=this.lang.timeSelect;const Z=document.createElement("button");Z.classList.add(`${v}-date-menu__now`),Z.innerText=this.lang.now;const E=document.createElement("button");return E.classList.add(`${v}-date-menu__submit`),E.innerText=this.lang.confirm,F.append(V),F.append(Z),F.append(E),t.append(e),t.append(X),t.append(F),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:c,timeWrap:X,title:{preYear:o,preMonth:s,now:i,nextMonth:l,nextYear:a},day:S,time:{hour:N,minute:m,second:I},menu:{time:V,now:Z,submit:E}}}_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:o}}=this.renderOptions,s=this.draw.getHeight(),i=this.draw.getPageGap(),a=(o!=null?o:this.draw.getPageNo())*(s+i);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:o,thu:s,fri:i,sat:l}}=this.lang,a=[t,e,n,o,s,i,l];this.dom.datePickerWeek.childNodes.forEach((u,g)=>{const T=u;T.innerText=a[g]});const c=this.dom.time.hour.previousElementSibling;c.innerText=this.lang.hour;const d=this.dom.time.minute.previousElementSibling;d.innerText=this.lang.minute;const h=this.dom.time.second.previousElementSibling;h.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),n=t.getMonth()+1,o=t.getDate();let s=null,i=null,l=null;this.pickDate&&(s=this.pickDate.getFullYear(),i=this.pickDate.getMonth()+1,l=this.pickDate.getDate());const a=this.now.getFullYear(),c=this.now.getMonth()+1;this.dom.title.now.innerText=`${a}${this.lang.year} ${String(c).padStart(2,"0")}${this.lang.month}`;const h=new Date(a,c,0).getDate();let u=new Date(a,c-1,1).getDay();u===0&&(u=7);const g=new Date(a,c-1,0).getDate();this.dom.day.innerHTML="";const T=g-u+1;for(let O=T;O<=g;O++){const M=document.createElement("div");M.classList.add("disable"),M.innerText=`${O}`,M.onclick=()=>{const S=c-2;this.now=new Date(a,S,O),this._setDatePick(a,S,O)},this.dom.day.append(M)}for(let O=1;O<=h;O++){const M=document.createElement("div");e===a&&n===c&&o===O&&M.classList.add("active"),this.pickDate&&s===a&&i===c&&l===O&&M.classList.add("select"),M.innerText=`${O}`,M.onclick=S=>{const X=c-1;this.now=new Date(a,X,O),this._setDatePick(a,X,O),S.stopPropagation()},this.dom.day.append(M)}const P=6*7-u-h;for(let O=1;O<=P;O++){const M=document.createElement("div");M.classList.add("disable"),M.innerText=`${O}`,M.onclick=()=>{this.now=new Date(a,c,O),this._setDatePick(a,c,O)},this.dom.day.append(M)}}_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 o,s,i;this.now=new Date(t,e,n),(o=this.pickDate)==null||o.setFullYear(t),(s=this.pickDate)==null||s.setMonth(e),(i=this.pickDate)==null||i.setDate(n),this._update()}_setTimePick(t=!0){var d,h,u;const e=((d=this.pickDate)==null?void 0:d.getHours())||0,n=((h=this.pickDate)==null?void 0:h.getMinutes())||0,o=((u=this.pickDate)==null?void 0:u.getSeconds())||0,{hour:s,minute:i,second:l}=this.dom.time;[s,i,l].forEach(g=>{g.querySelectorAll("li").forEach(T=>T.classList.remove("active"))}),[[s,e],[i,n],[l,o]].forEach(([g,T])=>{const P=g.querySelector(`[data-id='${T}']`);P.classList.add("active"),t&&pn(g,P)})}_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 o=t.getFullYear().toString(),s=(t.getMonth()+1).toString(),i=t.getDate().toString(),l=t.getHours(),a=l%12==0?12:l%12,c=t.getMinutes().toString(),d=t.getSeconds().toString(),h=t.getMilliseconds().toString(),u={"y+":o,"Y+":o,"M+":s,"d+":i,"D+":i,"h+":a.toString(),"H+":l.toString(),"m+":c,"s+":d,"S+":h};for(const g in u){const T=new RegExp("("+g+")").exec(e),P=g;T&&(n=n.replace(T[1],T[1].length===1?u[P]:u[P].padStart(T[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 Xe{constructor(t,e){L(this,"draw");L(this,"element");L(this,"control");L(this,"isPopup");L(this,"datePicker");L(this,"options");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 o=[],{startIndex:s,endIndex:i}=n;for(let l=s;l<=i;l++){const a=e[l];a.controlComponent===R.ControlComponent.VALUE&&o.push(a)}return o}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:i,endIndex:l}=s,a=this.control.getDraw();i!==l?a.spliceElementList(o,i+1,l-i):this.control.removePlaceholder(i,e);const c=o[i],d=c.type&&!bt.includes(c.type)||c.controlComponent===R.ControlComponent.PREFIX||c.controlComponent===R.ControlComponent.PRE_TEXT?pt(c,["control","controlId",...xt]):Ht(c,["type"]),h=s.startIndex+1;for(let u=0;u<t.length;u++){const g=B(Y(Y({},d),t[u]),{controlComponent:R.ControlComponent.VALUE});It(o,[g],i,{editorOptions:this.options}),a.spliceElementList(o,h+u,0,[g])}return h+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:o=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const s=this.control.getValueRange(t);if(!s)return-1;const{startIndex:i,endIndex:l}=s;if(!~i||!~l)return-1;const a=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(a,i+1,l-i,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),o&&this.control.addPlaceholder(i,t),i}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange(),i=this.getValue(e)[0],l=i?pt(i,Dt):pt(o[s.startIndex],xt),a=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~a)return;const c=Ht(o[a],Dt),d=a+1,h=this.control.getDraw();for(let u=0;u<t.length;u++){const g=B(Y(Y({},l),c),{type:R.ElementType.TEXT,value:t[u],controlComponent:R.ControlComponent.VALUE});It(o,[g],a,{editorOptions:this.options}),h.spliceElementList(o,d+u,0,[g])}if(!e.range){const u=d+t.length-1;this.control.repaintControl({curIndex:u}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:o,endIndex:s}=n,i=e[o],l=e[s],a=this.control.getDraw();if(t.key===R.KeyMap.Backspace)return o!==s?(a.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o):i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):(a.spliceElementList(e,o,1),this.getValue().length||this.control.addPlaceholder(o-1),o-1);if(t.key===R.KeyMap.Delete){if(o!==s)return a.spliceElementList(e,o+1,s-o),this.getValue().length||this.control.addPlaceholder(o),o;{const c=e[s+1];return(i.controlComponent===R.ControlComponent.PREFIX||i.controlComponent===R.ControlComponent.PRE_TEXT)&&c.controlComponent===R.ControlComponent.PLACEHOLDER||c.controlComponent===R.ControlComponent.POSTFIX||c.controlComponent===R.ControlComponent.POST_TEXT||i.controlComponent===R.ControlComponent.PLACEHOLDER?this.control.removeControl(o):(a.spliceElementList(e,o+1,1),this.getValue().length||this.control.addPlaceholder(o),o)}}return s}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(),o=this.control.getElementList();return n.spliceElementList(o,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){var i,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(((i=e[n+1])==null?void 0:i.controlId)!==this.element.controlId)return;this.datePicker=new ii(this.draw,{onSubmit:this._setDate.bind(this)});const o=this.getValue().map(a=>a.value).join("")||"",s=(l=this.element.control)==null?void 0:l.dateFormat;this.datePicker.render({value:o,position:t,dateFormat:s}),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 $s{constructor(t){L(this,"control");L(this,"calculatorDom");L(this,"onCalculate");L(this,"currentExpression");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(`${v}-calculator`),e.setAttribute(_t,R.EditorComponent.POPUP);const n=document.createElement("div");n.classList.add(`${v}-calculator-display`),n.textContent="0";const o=document.createElement("div");o.classList.add(`${v}-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(h=>{h.forEach(u=>{const g=document.createElement("button");g.classList.add(`${v}-calculator-button`),u.type===at.OPERATOR?g.classList.add("operator"):u.type===at.EQUAL?g.classList.add("equal"):u.type===at.UTILITY&&g.classList.add("utility"),g.textContent=u.text,g.onclick=()=>{const T=u.text;if(T==="C")this.currentExpression="",n.textContent="0";else if(T==="\u2190")this.currentExpression=this.currentExpression.slice(0,-1),n.textContent=this.currentExpression||"0";else if(T==="="){const P=this.calculate(this.currentExpression);Number.isFinite(P)?(n.textContent=P.toString(),this.currentExpression=P.toString(),this.onCalculate(P)):(n.textContent="Error",this.currentExpression="")}else this.currentExpression+=T,n.textContent=this.currentExpression},u.span&&(g.style.gridColumn=`span ${u.span}`),o.appendChild(g)})}),e.appendChild(n),e.appendChild(o);const{coordinate:{leftTop:[i,l]},lineHeight:a}=t,c=this.control.getPreY();e.style.left=`${i}px`,e.style.top=`${l+c+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 Ie extends hn{constructor(t,e){super(t,e);L(this,"isPopup");L(this,"calculator");this.isPopup=!1,this.calculator=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(h=>!Ho(h)||Yi.test(h.value)))return-1;const o=e.elementList||this.control.getElementList(),s=e.range||this.control.getRange();this.control.shrinkBoundary(e);const i=$(t),{startIndex:l,endIndex:a}=s,c=o[l];if(this.control.getIsExistValueByElementListIndex(o,l)){let h=l;for(;h>0;){const g=o[h];if(g.controlId!==c.controlId||g.controlComponent===R.ControlComponent.PREFIX||g.controlComponent===R.ControlComponent.PRE_TEXT)break;i.unshift(g),h--}let u=a+1;for(;u<o.length;){const g=o[u];if(g.controlId!==c.controlId||g.controlComponent===R.ControlComponent.POSTFIX||g.controlComponent===R.ControlComponent.POST_TEXT)break;i.push(g),u++}}const d=Go(i);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(),o=this.control.getRange(),s=this.getValue()[0],i=s?pt(s,Dt):pt(n[o.startIndex],xt),l=Ht(n[e],Dt),a=t.toString(),c=[];for(let d=0;d<a.length;d++){const h=B(Y(Y({},i),l),{type:R.ElementType.TEXT,value:a[d],controlComponent:R.ControlComponent.VALUE});c.push(h)}this.setValue(c),this.control.repaintControl({curIndex:e+c.length}),this.control.emitControlContentChange(),this.destroy()}awake(){var o,s,i;const t=((s=(o=this.element.control)==null?void 0:o.numberExclusiveOptions)==null?void 0:s.calculatorDisabled)===!1;if(this.isPopup||!t||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const{startIndex:e}=this.control.getRange();((i=this.control.getElementList()[e+1])==null?void 0:i.controlId)===this.element.controlId&&(this.calculator=new $s({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 js{constructor(t){L(this,"controlBorder");L(this,"draw");L(this,"range");L(this,"listener");L(this,"eventBus");L(this,"controlSearch");L(this,"options");L(this,"controlOptions");L(this,"activeControl");L(this,"activeControlValue");L(this,"preElement");this.controlBorder=new zs(t),this.draw=t,this.range=t.getRange(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.controlSearch=new _s(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){const{filterEmptyControl:e}=this.options.modeRule[R.EditorMode.PRINT];return t.filter((n,o)=>{var s,i,l;if(n.type===R.ElementType.TABLE){const a=n.trList;for(let c=0;c<a.length;c++){const d=a[c];for(let h=0;h<d.tdList.length;h++){const u=d.tdList[h];u.value=this.filterAssistElement(u.value)}}}if(!n.controlId)return!0;if((s=n.control)==null?void 0:s.minWidth){if(n.controlComponent===R.ControlComponent.PREFIX||n.controlComponent===R.ControlComponent.POSTFIX)return n.value="",!0}else{if(((i=n.control)==null?void 0:i.preText)&&n.controlComponent===R.ControlComponent.PRE_TEXT){let a=!1,c=o+1;for(;c<t.length;){const d=t[c];if(n.controlId!==d.controlId)break;if(d.controlComponent===R.ControlComponent.VALUE){a=!0;break}c++}return a}if(((l=n.control)==null?void 0:l.postText)&&n.controlComponent===R.ControlComponent.POST_TEXT){let a=!1,c=o-1;for(;c>=0;){const d=t[c];if(n.controlId!==d.controlId)break;if(d.controlComponent===R.ControlComponent.VALUE){a=!0;break}c--}return a}}return n.controlComponent!==R.ControlComponent.PREFIX&&n.controlComponent!==R.ControlComponent.POSTFIX&&(!e||n.controlComponent!==R.ControlComponent.PLACEHOLDER)})}getIsRangeCanCaptureEvent(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),o=n[t];if(t===e&&o.controlComponent===R.ControlComponent.POSTFIX)return!0;const s=n[e];return!!(o.controlId&&o.controlId===s.controlId&&s.controlComponent!==R.ControlComponent.POSTFIX)}getIsRangeInPostfix(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();return t!==e?!1:this.getElementList()[t].controlComponent===R.ControlComponent.POSTFIX}getIsRangeWithinControl(){const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),o=n[t],s=n[e];return!!((o==null?void 0:o.controlId)&&o.controlId===s.controlId&&s.controlComponent!==R.ControlComponent.POSTFIX)}getIsElementListContainFullControl(t){if(!t.some(o=>o.controlId))return!1;let e=0,n=0;for(let o=0;o<t.length;o++){const s=t[o];s.controlComponent===R.ControlComponent.PREFIX?e++:s.controlComponent===R.ControlComponent.POSTFIX&&n++}return!e||!n?!1:e===n}getIsDisabledControl(t={}){var o,s;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===R.ControlComponent.POSTFIX?!1:!!((s=(o=this.activeControl.getElement())==null?void 0:o.control)==null?void 0:s.disabled)}getIsDisabledPasteControl(t={}){var o,s;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===R.ControlComponent.POSTFIX?!1:!!((s=(o=this.activeControl.getElement())==null?void 0:o.control)==null?void 0:s.pasteDisabled)}getIsExistValueByElementListIndex(t,e){var o,s,i;const n=t[e];if(!n.controlId)return!1;if(((o=n.control)==null?void 0:o.type)===R.ControlType.CHECKBOX||((s=n.control)==null?void 0:s.type)===R.ControlType.RADIO)return!!((i=n.control)==null?void 0:i.code);if(n.controlComponent===R.ControlComponent.VALUE)return!0;if(n.controlComponent===R.ControlComponent.PLACEHOLDER)return!1;if(n.controlComponent===R.ControlComponent.PREFIX||n.controlComponent===R.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===R.ControlComponent.VALUE)return!0;if(a.controlComponent===R.ControlComponent.PLACEHOLDER)return!1;l++}}if(n.controlComponent===R.ControlComponent.POSTFIX||n.controlComponent===R.ControlComponent.POST_TEXT){let l=e-1;for(;l>=0;){const a=t[l];if(a.controlId!==n.controlId)return!1;if(a.controlComponent===R.ControlComponent.VALUE)return!0;if(a.controlComponent===R.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 o,s;const t=this.draw.getHeight(),e=this.draw.getPageGap();return((s=(o=this.getPosition())==null?void 0:o.pageNo)!=null?s:this.draw.getPageNo())*(t+e)}getRange(){return this.range.getRange()}getValueRange(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),o=e[n];let s=n;for(;s>0;){const l=e[s];if(l.controlId!==o.controlId||l.controlComponent===R.ControlComponent.PREFIX||l.controlComponent===R.ControlComponent.PRE_TEXT)break;s--}let i=n+1;for(;i<e.length;){const l=e[i];if(l.controlId!==o.controlId||l.controlComponent===R.ControlComponent.POSTFIX||l.controlComponent===R.ControlComponent.POST_TEXT)break;i++}return s===i?null:{startIndex:s,endIndex:i-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(),o=e[n];if(!(o==null?void 0:o.controlId))return[];const s=[];let i=n;for(;i>0;){const a=e[i];if(a.controlId!==o.controlId)break;s.unshift(a),i--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==o.controlId)break;s.push(a),l++}return s}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 o=this.activeControlValue,s=this.activeControl.getElement();(o==null?void 0:o.length)?n=st(o)[0].control:(n=le($(s)).control,n.value=[]);const i={state:t,control:n,controlId:s.controlId};(a=(l=this.listener).controlChange)==null||a.call(l,i),e&&this.eventBus.emit("controlChange",i)}initControl(){var i,l;const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];if(this.activeControl){(this.activeControl instanceof Se||this.activeControl instanceof Xe||this.activeControl instanceof Ie)&&(n.controlComponent===R.ControlComponent.POSTFIX?this.activeControl.destroy():this.activeControl.awake()),((i=this.preElement)==null?void 0:i.controlId)===n.controlId&&(n.controlComponent===R.ControlComponent.POSTFIX?this.emitControlChange(R.ControlState.INACTIVE):((l=this.preElement)==null?void 0:l.controlComponent)===R.ControlComponent.POSTFIX&&this.emitControlChange(R.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 s=n.control;if(s.type===R.ControlType.TEXT)this.activeControl=new hn(n,this);else if(s.type===R.ControlType.SELECT){const a=new Se(n,this);this.activeControl=a,a.awake()}else if(s.type===R.ControlType.CHECKBOX)this.activeControl=new Ce(n,this);else if(s.type===R.ControlType.RADIO)this.activeControl=new an(n,this);else if(s.type===R.ControlType.DATE){const a=new Xe(n,this);this.activeControl=a,a.awake()}else if(s.type===R.ControlType.NUMBER){const a=new Ie(n,this);this.activeControl=a,a.awake()}this.updateActiveControlValue(),this.preElement=n,n.controlComponent!==R.ControlComponent.POSTFIX&&this.emitControlChange(R.ControlState.ACTIVE)}destroyControl(t={}){var n;if(!this.activeControl)return;const{isEmitEvent:e=!0}=t;(this.activeControl instanceof Se||this.activeControl instanceof Xe||this.activeControl instanceof Ie)&&this.activeControl.destroy(),e&&((n=this.preElement)==null?void 0:n.controlComponent)!==R.ControlComponent.POSTFIX&&this.emitControlChange(R.ControlState.INACTIVE),this.preElement=null,this.activeControl=null,this.activeControlValue=[]}repaintControl(t={}){const{curIndex:e,isCompute:n=!0,isSubmitHistory:o=!0,isSetCursor:s=!0}=t;e===void 0?(this.range.clearRange(),this.draw.render({isCompute:n,isSubmitHistory:o,isSetCursor:!1})):(this.range.setRange(e,e),this.draw.render({curIndex:e,isCompute:n,isSetCursor:s,isSubmitHistory:o}))}emitControlContentChange(t){var c,d,h,u,g,T;const e=this.eventBus.isSubscribe("controlContentChange");if(!e&&!this.listener.controlContentChange)return;const n=(t==null?void 0:t.controlElement)||((c=this.activeControl)==null?void 0:c.getElement());if(!n)return;const o=((d=t==null?void 0:t.context)==null?void 0:d.elementList)||this.getElementList(),{startIndex:s}=((h=t==null?void 0:t.context)==null?void 0:h.range)||this.getRange();if(!((u=o[s])==null?void 0:u.controlId))return;const i=(t==null?void 0:t.controlValue)||this.getControlElementList(t==null?void 0:t.context);let l;if((i==null?void 0:i.length)?l=st(i)[0].control:(l=n.control,l.value=[]),!l)return;const a={control:l,controlId:n.controlId};(T=(g=this.listener).controlContentChange)==null||T.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 Xe||this.activeControl instanceof Se||this.activeControl instanceof Ie)&&this.activeControl.getIsPopup()&&(this.activeControl.destroy(),this.activeControl.awake())}selectValue(){var i;const t=this.getElementList(),{startIndex:e}=this.getRange(),n=t[e];if(!(n==null?void 0:n.controlId)||n.controlComponent!==R.ControlComponent.VALUE&&((i=t[e+1])==null?void 0:i.controlComponent)===R.ControlComponent.VALUE)return!1;let o=e;for(;o>0&&t[o].controlComponent===R.ControlComponent.VALUE;)o--;let s=e+1;for(;s<t.length;){if(t[s].controlComponent!==R.ControlComponent.VALUE){s--;break}s++}if(o!==s){const l=this.range.getRange();return this.range.replaceRange(B(Y({},l),{startIndex:o,endIndex:s})),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),!0}return!1}moveCursor(t){var c,d;const{index:e,trIndex:n,tdIndex:o,tdValueIndex:s}=t;let i=this.draw.getOriginalElementList(),l;const a=t.isTable?s:e;if(t.isTable?(i=i[e].trList[n].tdList[o].value,l=i[s]):l=i[e],l.hide||((c=l.control)==null?void 0:c.hide)||((d=l.area)==null?void 0:d.hide)){const h=Oe(i,a);return{newIndex:h,newElement:i[h]}}if(l.controlComponent===R.ControlComponent.VALUE)return{newIndex:a,newElement:l};if(l.controlComponent===R.ControlComponent.POSTFIX){let h=a+1;for(;h<i.length;){if(i[h].controlId!==l.controlId)return{newIndex:h-1,newElement:i[h-1]};if(h===i.length-1)return{newIndex:h,newElement:i[h]};h++}}else if(l.controlComponent===R.ControlComponent.PREFIX||l.controlComponent===R.ControlComponent.PRE_TEXT){let h=a+1;for(;h<i.length;){const u=i[h];if(u.controlId!==l.controlId||u.controlComponent!==R.ControlComponent.PREFIX&&u.controlComponent!==R.ControlComponent.PRE_TEXT)return{newIndex:h-1,newElement:i[h-1]};h++}}else if(l.controlComponent===R.ControlComponent.PLACEHOLDER||l.controlComponent===R.ControlComponent.POST_TEXT){let h=a-1;for(;h>0;){const u=i[h];if(u.controlId!==l.controlId||u.controlComponent===R.ControlComponent.VALUE||u.controlComponent===R.ControlComponent.PREFIX||u.controlComponent===R.ControlComponent.PRE_TEXT)return{newIndex:h,newElement:i[h]};h--}}return{newIndex:a,newElement:l}}removeControl(t,e={}){var c,d;const n=e.elementList||this.getElementList(),o=n[t];if(!this.draw.isDesignMode()&&!(o==null?void 0:o.hide)&&!((c=o==null?void 0:o.control)==null?void 0:c.hide)&&!((d=o==null?void 0:o.area)==null?void 0:d.hide)){const{deletable:h=!0}=o.control;if(!h)return null;const u=this.draw.getMode();if(u===R.EditorMode.FORM&&this.options.modeRule[u].controlDeletableDisabled)return null}let s=-1,i=-1,l=t;for(;l>0;){if(n[l].controlId!==o.controlId){s=l;break}l--}let a=t+1;for(;a<n.length;){if(n[a].controlId!==o.controlId){i=a-1;break}a++}return a===n.length&&(i=a-1),!~s&&!~i?t:(s=~s?s:0,this.draw.spliceElementList(n,s+1,i-s),s)}removePlaceholder(t,e={}){const n=e.elementList||this.getElementList(),o=n[t],s=n[t+1];if(o.controlComponent===R.ControlComponent.PLACEHOLDER||s.controlComponent===R.ControlComponent.PLACEHOLDER){let i=!1,l=t;for(;l<n.length;){const a=n[l];if(a.controlId!==o.controlId)break;a.controlComponent===R.ControlComponent.PLACEHOLDER?(i||(i=!0,this.draw.getHistoryManager().popUndo(),this.draw.submitHistory(t)),n.splice(l,1)):l++}}}addPlaceholder(t,e={}){const n=e.elementList||this.getElementList(),o=n[t],s=o.control;if(!s.placeholder)return;const i=Qt(s.placeholder),l=pt(o,xt);for(let a=0;a<i.length;a++){const c=i[a],d=B(Y({},l),{value:c===`
|
|
88
|
+
`?y:c,controlId:o.controlId,type:R.ElementType.CONTROL,control:o.control,controlComponent:R.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:o}=e.range||this.getRange(),s=n[o];let i=o;for(;i>0;){const a=n[i];if(a.controlId!==s.controlId)break;a.control=Y(Y({},a.control),t),i--}let l=o+1;for(;l<n.length;){const a=n[l];if(a.controlId!==s.controlId)break;a.control=Y(Y({},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:o,areaId:s}=t,i=[];if(!e&&!o&&!n)return i;const l=(c,d)=>{let h=0;for(;h<c.length;){const u=c[h];if(h++,u.type===R.ElementType.TABLE){const X=u.trList;for(let N=0;N<X.length;N++){const m=X[N];for(let I=0;I<m.tdList.length;I++){const f=m.tdList[I];l(f.value,d)}}}if(!u.control||n&&u.control.groupId!==n||e&&u.controlId!==e||o&&u.control.conceptId!==o||s&&u.areaId!==s)continue;const{type:g,code:T,valueSets:P}=u.control;let O=h,M="";const S=[];for(;O<c.length;){const X=c[O];if(X.controlId!==u.controlId)break;(g===R.ControlType.TEXT||g===R.ControlType.DATE||g===R.ControlType.NUMBER)&&X.controlComponent===R.ControlComponent.VALUE&&(M+=X.value,S.push(Ht(X,_e))),O++}if(g===R.ControlType.TEXT||g===R.ControlType.DATE||g===R.ControlType.NUMBER)i.push(B(Y({},u.control),{zone:d,value:M||null,innerText:M||null,elementList:st(S)}));else if(g===R.ControlType.SELECT||g===R.ControlType.CHECKBOX||g===R.ControlType.RADIO){const X=T==null?void 0:T.split(",").map(N=>{var m;return(m=P==null?void 0:P.find(I=>I.code===N))==null?void 0:m.value}).filter(Boolean).join("");i.push(B(Y({},u.control),{zone:d,value:T||null,innerText:X||null}))}h=O}},a=[{zone:R.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:R.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:R.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:c,elementList:d}of a)l(d,c);return i}setValueListById(t){if(!t.length)return;let e=!1,n=!1;const o=i=>{let l=0;for(;l<i.length;){const a=i[l];if(l++,a.type===R.ElementType.TABLE){const S=a.trList;for(let X=0;X<S.length;X++){const N=S[X];for(let m=0;m<N.tdList.length;m++){const I=N.tdList[m];o(I.value)}}}if(!a.control)continue;const c=t.find(S=>{var X;return(!S.groupId||S.groupId===((X=a.control)==null?void 0:X.groupId))&&(S.id&&a.controlId===S.id||S.conceptId&&a.control.conceptId===S.conceptId||S.areaId&&a.areaId===S.areaId)});if(!c)continue;const{value:d,isSubmitHistory:h=!0}=c;e=!0,h&&(n=!0);const{type:u}=a.control;let g=l;for(;g<i.length&&i[g].controlId===a.controlId;)g++;const P={range:{startIndex:l-1,endIndex:g-2},elementList:i},O={isIgnoreDisabledRule:!0,isIgnoreDeletedRule:!0};if(u===R.ControlType.TEXT){const S=Array.isArray(d)?d:d?[{value:d}]:[];S.length&&Pt(S,{isHandleFirstElement:!1,editorOptions:this.options});const X=new hn(a,this);this.activeControl=X,S.length?X.setValue(S,P,O):X.clearValue(P,O)}else if(u===R.ControlType.SELECT){if(Array.isArray(d))continue;const S=new Se(a,this);this.activeControl=S,d?S.setSelect(d,P,O):S.clearSelect(P,O)}else if(u===R.ControlType.CHECKBOX){if(Array.isArray(d))continue;const S=new Ce(a,this);this.activeControl=S;const X=d?d.split(","):[];S.setSelect(X,P,O)}else if(u===R.ControlType.RADIO){if(Array.isArray(d))continue;const S=new an(a,this);this.activeControl=S;const X=d?[d]:[];S.setSelect(X,P,O)}else if(u===R.ControlType.DATE){const S=new Xe(a,this);this.activeControl=S,Je(d)?(d.length&&Pt(d,{isHandleFirstElement:!1,editorOptions:this.options}),S.setValue(d,P,O)):Ki(d)?S.setSelect(d,P,O):S.clearSelect(P,O)}else if(u===R.ControlType.NUMBER){const S=Array.isArray(d)?d:d?[{value:d}]:[];S.length&&Pt(S,{isHandleFirstElement:!1,editorOptions:this.options});const X=new Ie(a,this);this.activeControl=X,S.length?X.setValue(S,P,O):X.clearValue(P,O)}this.emitControlContentChange({context:P}),this.activeControl=null;let M=l;for(;M<i.length&&i[M].controlId===a.controlId;)M++;l=M}};this.destroyControl({isEmitEvent:!1});const s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of s)o(i);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}setExtensionListById(t){if(!t.length)return;const e=o=>{let s=0;for(;s<o.length;){const i=o[s];if(s++,i.type===R.ElementType.TABLE){const d=i.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];e(T.value)}}}if(!i.control)continue;const l=t.find(d=>{var h;return(!d.groupId||d.groupId===((h=i.control)==null?void 0:h.groupId))&&(d.id&&i.controlId===d.id||d.conceptId&&i.control.conceptId===d.conceptId||d.areaId&&i.areaId===d.areaId)});if(!l)continue;const{extension:a}=l;this.setControlProperties({extension:a},{elementList:o,range:{startIndex:s,endIndex:s}});let c=s;for(;c<o.length&&o[c].controlId===i.controlId;)c++;s=c}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const o of n)e(o)}setPropertiesListById(t){if(!t.length)return;let e=!1,n=!1;const o=i=>{let l=0;for(;l<i.length;){const a=i[l];if(l++,a.type===R.ElementType.TABLE){const g=a.trList;for(let T=0;T<g.length;T++){const P=g[T];for(let O=0;O<P.tdList.length;O++){const M=P.tdList[O];o(M.value)}}}if(!a.control)continue;const c=t.find(g=>{var T;return(!g.groupId||g.groupId===((T=a.control)==null?void 0:T.groupId))&&(g.id&&a.controlId===g.id||g.conceptId&&a.control.conceptId===g.conceptId||g.areaId&&a.areaId===g.areaId)});if(!c)continue;const{properties:d,isSubmitHistory:h=!0}=c;e=!0,h&&(n=!0),this.setControlProperties(B(Y(Y({},a.control),d),{value:a.control.value}),{elementList:i,range:{startIndex:l,endIndex:l}}),xt.forEach(g=>{const T=d[g];T&&Reflect.set(a,g,T)});let u=l;for(;u<i.length&&i[u].controlId===a.controlId;)u++;l=u}},s={header:this.draw.getHeaderElementList(),main:this.draw.getOriginalMainElementList(),footer:this.draw.getFooterElementList()};for(const i in s){const l=s[i];o(l)}if(!!e){for(const i in s){const l=i,a=st(s[l],{isClassifyArea:!0,extraPickAttrs:["id"]});s[l]=a,Pt(a,{editorOptions:this.options,isForceCompensation:!0})}this.draw.setEditorData(s),n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1})}}getList(){const t=[];function e(o){for(let s=0;s<o.length;s++){const i=o[s];if(i.type===R.ElementType.TABLE){const l=i.trList;for(let a=0;a<l.length;a++){const c=l[a];for(let d=0;d<c.tdList.length;d++){const u=c.tdList[d].value;e(u)}}}if(i.controlId){const l=Ht(i,[...Ae,...pe]);t.push(l)}}}const n=[this.draw.getHeader().getElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooter().getElementList()];for(const o of n)e(o);return st(t,{extraPickAttrs:["controlId"]})}recordBorderInfo(t,e,n,o){this.controlBorder.recordBorderInfo(t,e,n,o)}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 o(a,c){for(let d=c;d>0;d--){const h=a[d];if(h.type===R.ElementType.TABLE){const g=h.trList||[];for(let T=g.length-1;T>=0;T--){const P=g[T],O=P.tdList;for(let M=O.length-1;M>=0;M--){const S=O[M],X=o(S.value,S.value.length-1);if(X)return{positionContext:{isTable:!0,index:d,trIndex:T,tdIndex:M,tdId:S.id,trId:P.id,tableId:h.id},nextIndex:X.nextIndex}}}}if(!h.controlId||h.controlId===n.controlId)continue;let u=d;for(;u>0;){const g=a[u];if(g.controlComponent===R.ControlComponent.VALUE||g.controlComponent===R.ControlComponent.PREFIX||g.controlComponent===R.ControlComponent.PRE_TEXT)break;u--}return{positionContext:{isTable:!1},nextIndex:u}}return null}const{startIndex:s}=this.range.getRange(),i=this.getElementList(),l=o(i,s);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:c,trIndex:d,tdIndex:h}=e,u=a[c].trList;for(let T=d;T>=0;T--){const P=u[T],O=P.tdList;for(let M=O.length-1;M>=0;M--){if(d===T&&M>=h)continue;const S=O[M],X=o(S.value,S.value.length-1);if(X)return{positionContext:{isTable:!0,index:e.index,trIndex:T,tdIndex:M,tdId:S.id,trId:P.id,tableId:n.tableId},nextIndex:X.nextIndex}}}const g=o(a,c-1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}getNextControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function o(a,c){var d,h;for(let u=c;u<a.length;u++){const g=a[u];if(g.type===R.ElementType.TABLE){const T=g.trList||[];for(let P=0;P<T.length;P++){const O=T[P],M=O.tdList;for(let S=0;S<M.length;S++){const X=M[S],N=o(X.value,0);if(N)return{positionContext:{isTable:!0,index:u,trIndex:P,tdIndex:S,tdId:X.id,trId:O.id,tableId:g.id},nextIndex:N.nextIndex}}}}if(!(!g.controlId||g.controlId===n.controlId||((d=a[u+1])==null?void 0:d.controlComponent)===R.ControlComponent.PREFIX||((h=a[u+1])==null?void 0:h.controlComponent)===R.ControlComponent.PRE_TEXT))return{positionContext:{isTable:!1},nextIndex:u}}return null}const{endIndex:s}=this.range.getRange(),i=this.getElementList(),l=o(i,s);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:c,trIndex:d,tdIndex:h}=e,u=a[c].trList;for(let T=d;T<u.length;T++){const P=u[T],O=P.tdList;for(let M=0;M<O.length;M++){if(d===T&&M<=h)continue;const S=O[M],X=o(S.value,0);if(X)return{positionContext:{isTable:!0,index:e.index,trIndex:T,tdIndex:M,tdId:S.id,trId:P.id,tableId:n.tableId},nextIndex:X.nextIndex}}}const g=o(a,c+1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}initNextControl(t={}){const{direction:e=Lt.DOWN}=t;let n=null;if(e===Lt.UP?n=this.getPreControlContext():n=this.getNextControlContext(),!n)return;const{nextIndex:o,positionContext:s}=n;this.draw.getPosition().setPositionContext(s),this.draw.getRange().replaceRange({startIndex:o,endIndex:o}),this.draw.render({curIndex:o,isCompute:!1,isSetCursor:!0,isSubmitHistory:!1})}setMinWidthControlInfo(t){var d,h,u,g,T;const{row:e,rowElement:n,controlRealWidth:o,availableWidth:s}=t;if(!((d=n.control)==null?void 0:d.minWidth))return;const{scale:i}=this.options,l=n.control.minWidth*i;let a=null;if(((h=n.control)==null?void 0:h.minWidth)&&(((u=n.control)==null?void 0:u.rowFlex)===R.RowFlex.CENTER||((g=n.control)==null?void 0:g.rowFlex)===R.RowFlex.RIGHT)){let P=n.metrics.width,O=e.elementList.length-1;for(;O>=0;){const M=e.elementList[O];if(P+=M.metrics.width,((T=e.elementList[O-1])==null?void 0:T.controlComponent)===R.ControlComponent.PREFIX){a=M;break}O--}a&&P<l&&(n.control.rowFlex===R.RowFlex.CENTER?a.left=(l-P)/2:n.control.rowFlex===R.RowFlex.RIGHT&&(a.left=l-P-n.metrics.width))}const c=l-o;if(c>0){const P=(a==null?void 0:a.left)||0,O=s-e.width-n.metrics.width,M=Math.min(O,c);n.left=M-P,e.width+=M-P}}}class qs{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}setSelect(t){const{checkbox:e}=t;e?e.value=!e.value:t.checkbox={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:o,row:s}=t;let{y:i}=t;const{checkbox:{gap:l,lineWidth:a,fillStyle:c,strokeStyle:d,checkFillStyle:h,checkStrokeStyle:u,checkMarkColor:g,verticalAlign:T},scale:P}=this.options,{metrics:O,checkbox:M}=s.elementList[o];if(T===R.VerticalAlign.TOP||T===R.VerticalAlign.MIDDLE){let I=o+1,f=null;for(;I<s.elementList.length&&(f=s.elementList[I],!(f.value!==y&&f.value!==we));)I++;if(f){const{metrics:{boundingBoxAscent:F,boundingBoxDescent:V}}=f,Z=F+V;Z>O.height&&(T===R.VerticalAlign.TOP?i-=F-O.height:T===R.VerticalAlign.MIDDLE&&(i-=(Z-O.height)/2))}}const S=Math.round(n+l*P),X=Math.round(i-O.height+a),N=O.width-l*2*P,m=O.height;e.save(),e.beginPath(),e.translate(.5,.5),(M==null?void 0:M.value)?(e.fillStyle=h,e.fillRect(S,X,N,m),e.beginPath(),e.lineWidth=a,e.strokeStyle=u,e.rect(S,X,N,m),e.stroke(),e.beginPath(),e.strokeStyle=g,e.lineWidth=a*2*P,e.moveTo(S+2*P,X+m/2),e.lineTo(S+N/2,X+m-3*P),e.lineTo(S+N-2*P,X+3*P),e.stroke()):(e.fillStyle=c,e.fillRect(S,X,N,m),e.beginPath(),e.lineWidth=a,e.strokeStyle=d,e.rect(S,X,N,m),e.stroke()),e.closePath(),e.restore()}}class tr{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}setSelect(t){const{radio:e}=t;e?e.value=!e.value:t.radio={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:o,row:s}=t;let{y:i}=t;const{radio:{gap:l,lineWidth:a,fillStyle:c,strokeStyle:d,verticalAlign:h},scale:u}=this.options,{metrics:g,radio:T}=s.elementList[o];if(h===R.VerticalAlign.TOP||h===R.VerticalAlign.MIDDLE){let X=o+1,N=null;for(;X<s.elementList.length&&(N=s.elementList[X],!(N.value!==y&&N.value!==we));)X++;if(N){const{metrics:{boundingBoxAscent:m,boundingBoxDescent:I}}=N,f=m+I;f>g.height&&(h===R.VerticalAlign.TOP?i-=m-g.height:h===R.VerticalAlign.MIDDLE&&(i-=(f-g.height)/2))}}const P=Math.round(n+l*u),O=Math.round(i-g.height+a),M=g.width-l*2*u,S=g.height;e.save(),e.beginPath(),e.translate(.5,.5),e.strokeStyle=(T==null?void 0:T.value)?c:d,e.lineWidth=a,e.arc(P+M/2,O+S/2,M/2,0,Math.PI*2),e.stroke(),(T==null?void 0:T.value)&&(e.beginPath(),e.fillStyle=c,e.arc(P+M/2,O+S/2,M/3,0,Math.PI*2),e.fill()),e.closePath(),e.restore()}}const oi="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciB1OyhmdW5jdGlvbihuKXtuLlRFWFQ9InRleHQiLG4uVEFCTEU9InRhYmxlIixuLkhZUEVSTElOSz0iaHlwZXJsaW5rIixuLkNPTlRST0w9ImNvbnRyb2wiLG4uTEFURVg9ImxhdGV4In0pKHV8fCh1PXt9KSk7dmFyIGg7KGZ1bmN0aW9uKG4pe24uVkFMVUU9InZhbHVlIn0pKGh8fChoPXt9KSk7Y29uc3QgcD0iXHUyMDBCIixnPWAKYDtmdW5jdGlvbiBjKG4pe3ZhciBsLGY7bGV0IHM9IiIscj0wO2Zvcig7cjxuLmxlbmd0aDspe2NvbnN0IGU9bltyXTtpZihlLnR5cGU9PT11LlRBQkxFKXtpZihlLnRyTGlzdClmb3IobGV0IG89MDtvPGUudHJMaXN0Lmxlbmd0aDtvKyspe2NvbnN0IGk9ZS50ckxpc3Rbb107Zm9yKGxldCB0PTA7dDxpLnRkTGlzdC5sZW5ndGg7dCsrKXtjb25zdCBhPWkudGRMaXN0W3RdO3MrPWMoYS52YWx1ZSl9fX1lbHNlIGlmKGUudHlwZT09PXUuSFlQRVJMSU5LKXtjb25zdCBvPWUuaHlwZXJsaW5rSWQsaT1bXTtmb3IoO3I8bi5sZW5ndGg7KXtjb25zdCB0PW5bcl07aWYobyE9PXQuaHlwZXJsaW5rSWQpe3ItLTticmVha31kZWxldGUgdC50eXBlLGkucHVzaCh0KSxyKyt9cys9YyhpKX1lbHNlIGlmKGUudHlwZT09PXUuTEFURVgpcys9ZS52YWx1ZTtlbHNlIGlmKGUuY29udHJvbElkKXtpZighKChsPWUuY29udHJvbCk9PW51bGw/dm9pZCAwOmwuaGlkZSkpe2NvbnN0IG89ZS5jb250cm9sSWQsaT1bXTtmb3IoO3I8bi5sZW5ndGg7KXtjb25zdCB0PW5bcl07aWYobyE9PXQuY29udHJvbElkKXtyLS07YnJlYWt9dC5jb250cm9sQ29tcG9uZW50PT09aC5WQUxVRSYmKGRlbGV0ZSB0LmNvbnRyb2xJZCxpLnB1c2godCkpLHIrK31zKz1jKGkpfX1lbHNlKCFlLnR5cGV8fGUudHlwZT09PXUuVEVYVCkmJiEoKGY9ZS5hcmVhKT09bnVsbD92b2lkIDA6Zi5oaWRlKSYmKHMrPWUudmFsdWUpO3IrK31yZXR1cm4gc31mdW5jdGlvbiBMKG4pe2NvbnN0IHM9W107bGV0IHI9IiI7Y29uc3QgbD0oKT0+e3ImJihzLnB1c2gocikscj0iIil9LGY9dD0+dDw9MzJ8fHQ9PT0xNjB8fHQ+PTgxOTImJnQ8PTgyMDJ8fHQ9PT04MjM5fHx0PT09MTIyODh8fHQ+PTgyMDMmJnQ8PTgyMDd8fHQ+PTgyMzQmJnQ8PTgyMzh8fHQ9PT04Mjg4fHx0PT09NjUyNzksZT10PT50Pj00OCYmdDw9NTd8fHQ+PTY1JiZ0PD05MHx8dD49OTcmJnQ8PTEyMixvPXQ9PnQ+PTMzJiZ0PD00N3x8dD49NTgmJnQ8PTY0fHx0Pj05MSYmdDw9OTZ8fHQ+PTEyMyYmdDw9MTI2LGk9dD0+dD09PTEyM3x8dD09PTEyNTtmb3IoY29uc3QgdCBvZiBuKXtjb25zdCBhPXQuY2hhckNvZGVBdCgwKTtpZihmKGEpKXtsKCk7Y29udGludWV9aWYoZShhKXx8aShhKXx8byhhKSl7cis9dDtjb250aW51ZX1sKCkscy5wdXNoKHQpfXJldHVybiBsKCksc31vbm1lc3NhZ2U9bj0+e2NvbnN0IHM9bi5kYXRhLGw9YyhzKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke3B9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChwLCJnIiksZyksZj1MKGwpO3Bvc3RNZXNzYWdlKGYubGVuZ3RoKX19KSgpO30pKCk7Cg==",si=typeof window!="undefined"&&window.Blob&&new Blob([atob(oi)],{type:"text/javascript;charset=utf-8"});function er(){const r=si&&(window.URL||window.webkitURL).createObjectURL(si);try{return r?new Worker(r):new Worker("data:application/javascript;base64,"+oi,{type:"module"})}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}const ri="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBhOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuSU1BR0U9ImltYWdlIix0LlRBQkxFPSJ0YWJsZSIsdC5IWVBFUkxJTks9Imh5cGVybGluayIsdC5TVVBFUlNDUklQVD0ic3VwZXJzY3JpcHQiLHQuU1VCU0NSSVBUPSJzdWJzY3JpcHQiLHQuU0VQQVJBVE9SPSJzZXBhcmF0b3IiLHQuUEFHRV9CUkVBSz0icGFnZUJyZWFrIix0LkNPTlRST0w9ImNvbnRyb2wiLHQuQ0hFQ0tCT1g9ImNoZWNrYm94Iix0LlJBRElPPSJyYWRpbyIsdC5MQVRFWD0ibGF0ZXgiLHQuVEFCPSJ0YWIiLHQuREFURT0iZGF0ZSIsdC5CTE9DSz0iYmxvY2siLHQuVElUTEU9InRpdGxlIix0LkFSRUE9ImFyZWEiLHQuTElTVD0ibGlzdCIsdC5MQUJFTD0ibGFiZWwifSkoYXx8KGE9e30pKTt2YXIgYzsoZnVuY3Rpb24odCl7dC5GSVJTVD0iZmlyc3QiLHQuU0VDT05EPSJzZWNvbmQiLHQuVEhJUkQ9InRoaXJkIix0LkZPVVJUSD0iZm91cnRoIix0LkZJRlRIPSJmaWZ0aCIsdC5TSVhUSD0ic2l4dGgifSkoY3x8KGM9e30pKTtjb25zdCBkPXtbYy5GSVJTVF06MSxbYy5TRUNPTkRdOjIsW2MuVEhJUkRdOjMsW2MuRk9VUlRIXTo0LFtjLkZJRlRIXTo1LFtjLlNJWFRIXTo2fSxDPVthLlRFWFQsYS5IWVBFUkxJTkssYS5TVUJTQ1JJUFQsYS5TVVBFUlNDUklQVCxhLkNPTlRST0wsYS5EQVRFLGEuTEFCRUxdLFM9Ilx1MjAwQiI7ZnVuY3Rpb24gVCh0KXtyZXR1cm4hdC50eXBlfHxDLmluY2x1ZGVzKHQudHlwZSl9ZnVuY3Rpb24gTih0KXt2YXIgRTtjb25zdHtlbGVtZW50TGlzdDpMLHBvc2l0aW9uTGlzdDpmfT10LGg9W107bGV0IGc9MDtmb3IoO2c8TC5sZW5ndGg7KXtjb25zdCBzPUxbZ10sbD0oZSxvLG4pPT57Y29uc3QgST1lLnRpdGxlSWQsQT1lLmxldmVsLHI9e3R5cGU6YS5USVRMRSx2YWx1ZToiIixsZXZlbDpBLHRpdGxlSWQ6SSxwYWdlTm86ZltnXS5wYWdlTm99LGk9W107Zm9yKDtuPG8ubGVuZ3RoOyl7Y29uc3QgdT1vW25dO2lmKEkhPT11LnRpdGxlSWQpe24tLTticmVha31pLnB1c2godSksbisrfXJldHVybiByLnZhbHVlPWkuZmlsdGVyKHU9PlQodSkpLm1hcCh1PT51LnZhbHVlKS5qb2luKCIiKS5yZXBsYWNlKG5ldyBSZWdFeHAoUywiZyIpLCIiKSx7cG9zaXRpb246bix0aXRsZUVsZW1lbnQ6cn19O2lmKHMudGl0bGVJZCl7Y29uc3R7cG9zaXRpb246ZSx0aXRsZUVsZW1lbnQ6b309bChzLEwsZyk7Zz1lLGgucHVzaChvKX1pZihzLnR5cGU9PT1hLlRBQkxFKXtjb25zdCBlPXMudHJMaXN0O2ZvcihsZXQgbz0wO288ZS5sZW5ndGg7bysrKXtjb25zdCBuPWVbb107Zm9yKGxldCBJPTA7STxuLnRkTGlzdC5sZW5ndGg7SSsrKXtjb25zdCByPW4udGRMaXN0W0ldLnZhbHVlO2lmKHIubGVuZ3RoPjEpe2xldCBpPTE7Zm9yKDtpPHIubGVuZ3RoOyl7aWYoKEU9cltpXSk9PW51bGw/dm9pZCAwOkUudGl0bGVJZCl7Y29uc3R7dGl0bGVFbGVtZW50OnUscG9zaXRpb246T309bChyW2ldLHIsaSk7aC5wdXNoKHUpLGk9T31pKyt9fX19fWcrK31pZighaC5sZW5ndGgpcmV0dXJuIG51bGw7Y29uc3Qgdj0ocyxsKT0+e2NvbnN0IGU9bC5zdWJDYXRhbG9nW2wuc3ViQ2F0YWxvZy5sZW5ndGgtMV0sbz1kW2U9PW51bGw/dm9pZCAwOmUubGV2ZWxdLG49ZFtzLmxldmVsXTtlJiZuPm8/dihzLGUpOmwuc3ViQ2F0YWxvZy5wdXNoKHtpZDpzLnRpdGxlSWQsbmFtZTpzLnZhbHVlLGxldmVsOnMubGV2ZWwscGFnZU5vOnMucGFnZU5vLHN1YkNhdGFsb2c6W119KX0sUj1bXTtmb3IobGV0IHM9MDtzPGgubGVuZ3RoO3MrKyl7Y29uc3QgbD1oW3NdLGU9UltSLmxlbmd0aC0xXSxvPWRbZT09bnVsbD92b2lkIDA6ZS5sZXZlbF0sbj1kW2wubGV2ZWxdO2UmJm4+bz92KGwsZSk6Ui5wdXNoKHtpZDpsLnRpdGxlSWQsbmFtZTpsLnZhbHVlLGxldmVsOmwubGV2ZWwscGFnZU5vOmwucGFnZU5vLHN1YkNhdGFsb2c6W119KX1yZXR1cm4gUn1vbm1lc3NhZ2U9dD0+e2NvbnN0IEw9dC5kYXRhLGY9TihMKTtwb3N0TWVzc2FnZShmKX19KSgpO30pKCk7Cg==",li=typeof window!="undefined"&&window.Blob&&new Blob([atob(ri)],{type:"text/javascript;charset=utf-8"});function nr(){const r=li&&(window.URL||window.webkitURL).createObjectURL(li);try{return r?new Worker(r):new Worker("data:application/javascript;base64,"+ri,{type:"module"})}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}const ai="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBuOyhmdW5jdGlvbihvKXtvLlRBQkxFPSJ0YWJsZSJ9KShufHwobj17fSkpO2Z1bmN0aW9uIGMobyl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBvKXtpZihzLnR5cGU9PT1uLlRBQkxFKXtjb25zdCBlPXMudHJMaXN0O2ZvcihsZXQgcj0wO3I8ZS5sZW5ndGg7cisrKXtjb25zdCBpPWVbcl07Zm9yKGxldCB1PTA7dTxpLnRkTGlzdC5sZW5ndGg7dSsrKXtjb25zdCBkPWkudGRMaXN0W3VdO3QucHVzaCguLi5jKGQudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgZSBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMoZSl8fHQucHVzaChlKX1yZXR1cm4gdH1vbm1lc3NhZ2U9bz0+e2NvbnN0IHQ9by5kYXRhLHM9Yyh0KTtwb3N0TWVzc2FnZShzKX19KSgpO30pKCk7Cg==",Ri=typeof window!="undefined"&&window.Blob&&new Blob([atob(ai)],{type:"text/javascript;charset=utf-8"});function ir(){const r=Ri&&(window.URL||window.webkitURL).createObjectURL(Ri);try{return r?new Worker(r):new Worker("data:application/javascript;base64,"+ai,{type:"module"})}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}const ci="KCgpPT57dmFyIEllPU9iamVjdC5kZWZpbmVQcm9wZXJ0eSxBZT1PYmplY3QuZGVmaW5lUHJvcGVydGllczt2YXIgZGU9T2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnM7dmFyIG5lPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHM7dmFyIFJlPU9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHksT2U9T2JqZWN0LnByb3RvdHlwZS5wcm9wZXJ0eUlzRW51bWVyYWJsZTt2YXIgcmU9KFQsSSxkKT0+SSBpbiBUP0llKFQsSSx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6ZH0pOlRbSV09ZCxnPShULEkpPT57Zm9yKHZhciBkIGluIEl8fChJPXt9KSlSZS5jYWxsKEksZCkmJnJlKFQsZCxJW2RdKTtpZihuZSlmb3IodmFyIGQgb2YgbmUoSSkpT2UuY2FsbChJLGQpJiZyZShULGQsSVtkXSk7cmV0dXJuIFR9LFg9KFQsSSk9PkFlKFQsZGUoSSkpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgVDsoZnVuY3Rpb24oZSl7ZS5IQUxGPSJoYWxmIixlLk9ORV9USElSRD0ib25lLXRoaXJkIixlLlFVQVJURVI9InF1YXJ0ZXIifSkoVHx8KFQ9e30pKTt2YXIgSTsoZnVuY3Rpb24oZSl7ZS5BUkFCSUM9ImFyYWJpYyIsZS5DSElORVNFPSJjaGluZXNlIn0pKEl8fChJPXt9KSk7dmFyIGQ7KGZ1bmN0aW9uKGUpe2UuSU5MSU5FPSJpbmxpbmUiLGUuQkxPQ0s9ImJsb2NrIixlLlNVUlJPVU5EPSJzdXJyb3VuZCIsZS5GTE9BVF9UT1A9ImZsb2F0LXRvcCIsZS5GTE9BVF9CT1RUT009ImZsb2F0LWJvdHRvbSJ9KShkfHwoZD17fSkpO3ZhciBfOyhmdW5jdGlvbihlKXtlLkJFRk9SRT0iYmVmb3JlIixlLkFGVEVSPSJhZnRlciIsZS5PVVRFUl9CRUZPUkU9Im91dGVyLWJlZm9yZSIsZS5PVVRFUl9BRlRFUj0ib3V0ZXItYWZ0ZXIifSkoX3x8KF89e30pKTt2YXIgdzsoZnVuY3Rpb24oZSl7ZS5ST1c9InJvdyIsZS5DT0xVTU49ImNvbHVtbiJ9KSh3fHwodz17fSkpO2NvbnN0IFA9Ilx1MjAwQiI7VC5IQUxGKyIiLDEvMixULk9ORV9USElSRCsiIiwxLzMsVC5RVUFSVEVSKyIiLDEvNDtmdW5jdGlvbiBiKGUpe2lmKHR5cGVvZiBzdHJ1Y3R1cmVkQ2xvbmU9PSJmdW5jdGlvbiIpcmV0dXJuIHN0cnVjdHVyZWRDbG9uZShlKTtpZighZXx8dHlwZW9mIGUhPSJvYmplY3QiKXJldHVybiBlO2xldCBjPXt9O3JldHVybiBBcnJheS5pc0FycmF5KGUpP2M9ZS5tYXAoRT0+YihFKSk6T2JqZWN0LmtleXMoZSkuZm9yRWFjaChFPT57Y1tFXT1iKGVbRV0pfSksY31mdW5jdGlvbiBLKGUsYyl7Y29uc3QgRT17fTtmb3IoY29uc3QgQSBpbiBlKWMuaW5jbHVkZXMoQSkmJihFW0FdPWVbQV0pO3JldHVybiBFfWZ1bmN0aW9uIG9lKGUsYyl7cmV0dXJuIGUubGVuZ3RoIT09Yy5sZW5ndGg/ITE6IWUuc29tZShFPT4hYy5pbmNsdWRlcyhFKSl9dmFyIG47KGZ1bmN0aW9uKGUpe2UuVEVYVD0idGV4dCIsZS5JTUFHRT0iaW1hZ2UiLGUuVEFCTEU9InRhYmxlIixlLkhZUEVSTElOSz0iaHlwZXJsaW5rIixlLlNVUEVSU0NSSVBUPSJzdXBlcnNjcmlwdCIsZS5TVUJTQ1JJUFQ9InN1YnNjcmlwdCIsZS5TRVBBUkFUT1I9InNlcGFyYXRvciIsZS5QQUdFX0JSRUFLPSJwYWdlQnJlYWsiLGUuQ09OVFJPTD0iY29udHJvbCIsZS5BUkVBPSJhcmVhIixlLkNIRUNLQk9YPSJjaGVja2JveCIsZS5SQURJTz0icmFkaW8iLGUuTEFURVg9ImxhdGV4IixlLlRBQj0idGFiIixlLkRBVEU9ImRhdGUiLGUuQkxPQ0s9ImJsb2NrIixlLlRJVExFPSJ0aXRsZSIsZS5MSVNUPSJsaXN0IixlLkxBQkVMPSJsYWJlbCJ9KShufHwobj17fSkpO2NvbnN0IGNlPVsicm93RmxleCIsInJvd01hcmdpbiJdLHNlPVsidHlwZSIsImZvbnQiLCJzaXplIiwiYm9sZCIsImNvbG9yIiwiaXRhbGljIiwiaGlnaGxpZ2h0IiwidW5kZXJsaW5lIiwic3RyaWtlb3V0Iiwicm93RmxleCIsInJvd01hcmdpbiIsImRhc2hBcnJheSIsInRyTGlzdCIsInRhYmxlVG9vbERpc2FibGVkIiwiYm9yZGVyVHlwZSIsImJvcmRlckNvbG9yIiwidHJhbnNsYXRlWCIsIndpZHRoIiwiaGVpZ2h0IiwidXJsIiwiY29sZ3JvdXAiLCJ2YWx1ZUxpc3QiLCJjb250cm9sIiwiY2hlY2tib3giLCJyYWRpbyIsImRhdGVGb3JtYXQiLCJibG9jayIsImxldmVsIiwidGl0bGUiLCJsaXN0VHlwZSIsImxpc3RTdHlsZSIsImxpc3RXcmFwIiwiZ3JvdXBJZHMiLCJjb25jZXB0SWQiLCJpbWdEaXNwbGF5IiwiaW1nRmxvYXRQb3NpdGlvbiIsImltZ1Rvb2xEaXNhYmxlZCIsImltZ1ByZXZpZXdEaXNhYmxlZCIsImltZ0Nyb3AiLCJpbWdDYXB0aW9uIiwidGV4dERlY29yYXRpb24iLCJleHRlbnNpb24iLCJleHRlcm5hbElkIiwiYXJlYUlkIiwiYXJlYSIsImhpZGUiLCJsYWJlbCIsImxhYmVsSWQiLCJsaW5lV2lkdGgiXSxmZT1bImNvbmNlcHRJZCIsImV4dGVuc2lvbiIsImV4dGVybmFsSWQiLCJ2ZXJ0aWNhbEFsaWduIiwiYmFja2dyb3VuZENvbG9yIiwiYm9yZGVyVHlwZXMiLCJzbGFzaFR5cGVzIiwiZGlzYWJsZWQiLCJkZWxldGFibGUiXSxFZT1bImZvbnQiLCJzaXplIiwiYm9sZCIsImhpZ2hsaWdodCIsIml0YWxpYyIsInN0cmlrZW91dCJdO24uVEVYVCxuLkhZUEVSTElOSyxuLlNVQlNDUklQVCxuLlNVUEVSU0NSSVBULG4uQ09OVFJPTCxuLkRBVEUsbi5JTUFHRSxuLkxBVEVYLG4uQkxPQ0ssbi5QQUdFX0JSRUFLLG4uU0VQQVJBVE9SLG4uVEFCTEUsbi5USVRMRSxuLkxJU1Q7dmFyIE47KGZ1bmN0aW9uKGUpe2UuVUw9InVsIixlLk9MPSJvbCJ9KShOfHwoTj17fSkpO3ZhciBPOyhmdW5jdGlvbihlKXtlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuQ0hFQ0tCT1g9ImNoZWNrYm94In0pKE98fChPPXt9KSk7dmFyIEg7KGZ1bmN0aW9uKGUpe2UuREVDSU1BTD0iZGVjaW1hbCJ9KShIfHwoSD17fSkpO3ZhciB2OyhmdW5jdGlvbihlKXtlW2UuRElTQz1PLkRJU0NdPSJESVNDIixlW2UuQ0lSQ0xFPU8uQ0lSQ0xFXT0iQ0lSQ0xFIixlW2UuU1FVQVJFPU8uU1FVQVJFXT0iU1FVQVJFIixlW2UuREVDSU1BTD1ILkRFQ0lNQUxdPSJERUNJTUFMIixlW2UuQ0hFQ0tCT1g9Ty5DSEVDS0JPWF09IkNIRUNLQk9YIn0pKHZ8fCh2PXt9KSksTy5ESVNDKyIiLE8uQ0lSQ0xFKyIiLE8uU1FVQVJFKyIiLE8uQ0hFQ0tCT1grIiIsTi5PTCsiIixOLlVMKyIiLHYuRElTQysiIix2LkNJUkNMRSsiIix2LlNRVUFSRSsiIix2LkRFQ0lNQUwrIiIsdi5DSEVDS0JPWCsiIjt2YXIgdTsoZnVuY3Rpb24oZSl7ZS5GSVJTVD0iZmlyc3QiLGUuU0VDT05EPSJzZWNvbmQiLGUuVEhJUkQ9InRoaXJkIixlLkZPVVJUSD0iZm91cnRoIixlLkZJRlRIPSJmaWZ0aCIsZS5TSVhUSD0ic2l4dGgifSkodXx8KHU9e30pKSx1LkZJUlNUKyIiLHUuU0VDT05EKyIiLHUuVEhJUkQrIiIsdS5GT1VSVEgrIiIsdS5GSUZUSCsiIix1LlNJWFRIKyIiLHUuRklSU1QrIiIsdS5TRUNPTkQrIiIsdS5USElSRCsiIix1LkZPVVJUSCsiIix1LkZJRlRIKyIiLHUuU0lYVEgrIiIsdS5GSVJTVCx1LlNFQ09ORCx1LlRISVJELHUuRk9VUlRILHUuRklGVEgsdS5TSVhUSDt2YXIgRzsoZnVuY3Rpb24oZSl7ZS5JRlJBTUU9ImlmcmFtZSIsZS5WSURFTz0idmlkZW8ifSkoR3x8KEc9e30pKTt2YXIgejsoZnVuY3Rpb24oZSl7ZS5URVhUPSJ0ZXh0IixlLlNFTEVDVD0ic2VsZWN0IixlLkNIRUNLQk9YPSJjaGVja2JveCIsZS5SQURJTz0icmFkaW8iLGUuREFURT0iZGF0ZSIsZS5OVU1CRVI9Im51bWJlciJ9KSh6fHwoej17fSkpO3ZhciBDOyhmdW5jdGlvbihlKXtlLlBSRUZJWD0icHJlZml4IixlLlBPU1RGSVg9InBvc3RmaXgiLGUuUFJFX1RFWFQ9InByZVRleHQiLGUuUE9TVF9URVhUPSJwb3N0VGV4dCIsZS5QTEFDRUhPTERFUj0icGxhY2Vob2xkZXIiLGUuVkFMVUU9InZhbHVlIixlLkNIRUNLQk9YPSJjaGVja2JveCIsZS5SQURJTz0icmFkaW8ifSkoQ3x8KEM9e30pKTt2YXIgWTsoZnVuY3Rpb24oZSl7ZS5ST1dfU1RBUlQ9InJvd1N0YXJ0IixlLlZBTFVFX1NUQVJUPSJ2YWx1ZVN0YXJ0In0pKFl8fChZPXt9KSk7dmFyIFY7KGZ1bmN0aW9uKGUpe2UuQUNUSVZFPSJhY3RpdmUiLGUuSU5BQ1RJVkU9ImluYWN0aXZlIn0pKFZ8fChWPXt9KSk7dmFyIFE7KGZ1bmN0aW9uKGUpe2UuTlVNQkVSPSJudW1iZXIiLGUuT1BFUkFUT1I9Im9wZXJhdG9yIixlLlVUSUxJVFk9InV0aWxpdHkiLGUuRVFVQUw9ImVxdWFsIn0pKFF8fChRPXt9KSk7dmFyIFc7KGZ1bmN0aW9uKGUpe2UuQ09NUE9ORU5UPSJjb21wb25lbnQiLGUuTUVOVT0ibWVudSIsZS5NQUlOPSJtYWluIixlLkZPT1RFUj0iZm9vdGVyIixlLkNPTlRFWFRNRU5VPSJjb250ZXh0bWVudSIsZS5QT1BVUD0icG9wdXAiLGUuQ0FUQUxPRz0iY2F0YWxvZyIsZS5DT01NRU5UPSJjb21tZW50In0pKFd8fChXPXt9KSk7dmFyIHE7KGZ1bmN0aW9uKGUpe2UuUEFHRT0icGFnZSIsZS5UQUJMRT0idGFibGUifSkocXx8KHE9e30pKTt2YXIgWjsoZnVuY3Rpb24oZSl7ZS5FRElUPSJlZGl0IixlLkNMRUFOPSJjbGVhbiIsZS5SRUFET05MWT0icmVhZG9ubHkiLGUuRk9STT0iZm9ybSIsZS5QUklOVD0icHJpbnQiLGUuREVTSUdOPSJkZXNpZ24iLGUuR1JBRkZJVEk9ImdyYWZmaXRpIn0pKFp8fChaPXt9KSk7dmFyIEo7KGZ1bmN0aW9uKGUpe2UuSEVBREVSPSJoZWFkZXIiLGUuTUFJTj0ibWFpbiIsZS5GT09URVI9ImZvb3RlciJ9KShKfHwoSj17fSkpO3ZhciBqOyhmdW5jdGlvbihlKXtlLlBBR0lORz0icGFnaW5nIixlLkNPTlRJTlVJVFk9ImNvbnRpbnVpdHkifSkoanx8KGo9e30pKTt2YXIgJDsoZnVuY3Rpb24oZSl7ZS5WRVJUSUNBTD0idmVydGljYWwiLGUuSE9SSVpPTlRBTD0iaG9yaXpvbnRhbCJ9KSgkfHwoJD17fSkpO3ZhciBlZTsoZnVuY3Rpb24oZSl7ZS5CUkVBS19BTEw9ImJyZWFrLWFsbCIsZS5CUkVBS19XT1JEPSJicmVhay13b3JkIn0pKGVlfHwoZWU9e30pKTt2YXIgdGU7KGZ1bmN0aW9uKGUpe2UuU1BFRUQ9InNwZWVkIixlLkNPTVBBVElCSUxJVFk9ImNvbXBhdGliaWxpdHkifSkodGV8fCh0ZT17fSkpO3ZhciBEOyhmdW5jdGlvbihlKXtlLkxFRlQ9ImxlZnQiLGUuQ0VOVEVSPSJjZW50ZXIiLGUuUklHSFQ9InJpZ2h0IixlLkFMSUdOTUVOVD0iYWxpZ25tZW50IixlLkpVU1RJRlk9Imp1c3RpZnkifSkoRHx8KEQ9e30pKTt2YXIgaWU7KGZ1bmN0aW9uKGUpe2UuQUxMPSJhbGwiLGUuRU1QVFk9ImVtcHR5IixlLkVYVEVSTkFMPSJleHRlcm5hbCIsZS5JTlRFUk5BTD0iaW50ZXJuYWwiLGUuREFTSD0iZGFzaCJ9KShpZXx8KGllPXt9KSk7dmFyIGFlOyhmdW5jdGlvbihlKXtlLlRPUD0idG9wIixlLlJJR0hUPSJyaWdodCIsZS5CT1RUT009ImJvdHRvbSIsZS5MRUZUPSJsZWZ0In0pKGFlfHwoYWU9e30pKTt2YXIgbGU7KGZ1bmN0aW9uKGUpe2UuRk9SV0FSRD0iZm9yd2FyZCIsZS5CQUNLPSJiYWNrIn0pKGxlfHwobGU9e30pKTt2YXIgazsoZnVuY3Rpb24oZSl7ZS5DT05UQUlOPSJjb250YWluIixlLkNPVkVSPSJjb3ZlciJ9KShrfHwoaz17fSkpO3ZhciBtOyhmdW5jdGlvbihlKXtlLlJFUEVBVD0icmVwZWF0IixlLk5PX1JFUEVBVD0ibm8tcmVwZWF0IixlLlJFUEVBVF9YPSJyZXBlYXQteCIsZS5SRVBFQVRfWT0icmVwZWF0LXkifSkobXx8KG09e30pKSxrLkNPVkVSLG0uTk9fUkVQRUFUO3ZhciBGOyhmdW5jdGlvbihlKXtlLlRPUD0idG9wIixlLk1JRERMRT0ibWlkZGxlIixlLkJPVFRPTT0iYm90dG9tIn0pKEZ8fChGPXt9KSksRi5CT1RUT00sVC5IQUxGLFQuSEFMRjtjb25zdCB1ZT17UEFHRV9OTzoie3BhZ2VOb30iLFBBR0VfQ09VTlQ6IntwYWdlQ291bnR9In07RC5DRU5URVIsdWUuUEFHRV9OTyxJLkFSQUJJQyxGLkJPVFRPTTt2YXIgeTsoZnVuY3Rpb24oZSl7ZS5URVhUPSJ0ZXh0IixlLklNQUdFPSJpbWFnZSJ9KSh5fHwoeT17fSkpO3ZhciBVOyhmdW5jdGlvbihlKXtlLkJPVFRPTT0iYm90dG9tIixlLlRPUD0idG9wIn0pKFV8fChVPXt9KSkseS5URVhULEkuQVJBQklDLFUuQk9UVE9NO3ZhciBCOyhmdW5jdGlvbihlKXtlLlBBR0U9InBhZ2UiLGUuQ09OVElOVUlUWT0iY29udGludWl0eSJ9KShCfHwoQj17fSkpLEIuQ09OVElOVUlUWTtmdW5jdGlvbiBUZShlLGMpe2NvbnN0IEU9T2JqZWN0LmtleXMoZSksQT1PYmplY3Qua2V5cyhjKTtpZihFLmxlbmd0aCE9PUEubGVuZ3RoKXJldHVybiExO2ZvcihsZXQgUj0wO1I8RS5sZW5ndGg7UisrKXtjb25zdCBhPUVbUl07aWYoYSE9PSJ2YWx1ZSImJiEoYT09PSJncm91cElkcyImJkFycmF5LmlzQXJyYXkoZVthXSkmJkFycmF5LmlzQXJyYXkoY1thXSkmJm9lKGVbYV0sY1thXSkpJiZlW2FdIT09Y1thXSlyZXR1cm4hMX1yZXR1cm4hMH1mdW5jdGlvbiB4KGUsYz17fSl7Y29uc3R7ZXh0cmFQaWNrQXR0cnM6RX09YyxBPVsuLi5zZV07RSYmQS5wdXNoKC4uLkUpO2NvbnN0IFI9e3ZhbHVlOmUudmFsdWU9PT1QP2AKYDplLnZhbHVlfTtyZXR1cm4gQS5mb3JFYWNoKGE9Pntjb25zdCBwPWVbYV07cCE9PXZvaWQgMCYmKFJbYV09cCl9KSxSfWZ1bmN0aW9uIGgoZSxjPXt9KXtjb25zdHtleHRyYVBpY2tBdHRyczpFLGlzQ2xhc3NpZnlBcmVhOkE9ITEsaXNDbG9uZTpSPSEwfT1jLGE9Uj9iKGUpOmUscD1bXTtsZXQgaT0wO2Zvcig7aTxhLmxlbmd0aDspe2xldCB0PWFbaV07aWYoaT09PTAmJnQudmFsdWU9PT1QJiYhdC5saXN0SWQmJighdC50eXBlfHx0LnR5cGU9PT1uLlRFWFQpKXtpKys7Y29udGludWV9aWYodC5hcmVhSWQpe2NvbnN0IGw9dC5hcmVhSWQsZj10LmFyZWEscz1bXTtmb3IoO2k8YS5sZW5ndGg7KXtjb25zdCBvPWFbaV07aWYobCE9PW8uYXJlYUlkKXtpLS07YnJlYWt9ZGVsZXRlIG8uYXJlYSxkZWxldGUgby5hcmVhSWQscy5wdXNoKG8pLGkrK31jb25zdCByPWgocyxjKTtpZihBKXtjb25zdCBvPXt0eXBlOm4uQVJFQSx2YWx1ZToiIixhcmVhSWQ6bCxhcmVhOmZ9O28udmFsdWVMaXN0PXIsdD1vfWVsc2V7cC5zcGxpY2UoaSwwLC4uLnIpO2NvbnRpbnVlfX1lbHNlIGlmKHQudGl0bGVJZCYmdC5sZXZlbCl7Y29uc3QgbD10LnRpdGxlSWQ7aWYobCl7Y29uc3QgZj10LmxldmVsLHM9e3R5cGU6bi5USVRMRSx0aXRsZTp0LnRpdGxlLHRpdGxlSWQ6bCx2YWx1ZToiIixsZXZlbDpmfSxyPVtdO2Zvcig7aTxhLmxlbmd0aDspe2NvbnN0IG89YVtpXTtpZihsIT09by50aXRsZUlkKXtpLS07YnJlYWt9ZGVsZXRlIG8ubGV2ZWwsZGVsZXRlIG8udGl0bGUsci5wdXNoKG8pLGkrK31zLnZhbHVlTGlzdD1oKHIsYyksdD1zfX1lbHNlIGlmKHQubGlzdElkJiZ0Lmxpc3RUeXBlKXtjb25zdCBsPXQubGlzdElkO2lmKGwpe2NvbnN0IGY9dC5saXN0VHlwZSxzPXQubGlzdFN0eWxlLHI9e3R5cGU6bi5MSVNULHZhbHVlOiIiLGxpc3RJZDpsLGxpc3RUeXBlOmYsbGlzdFN0eWxlOnN9LG89W107Zm9yKDtpPGEubGVuZ3RoOyl7Y29uc3QgTD1hW2ldO2lmKGwhPT1MLmxpc3RJZCl7aS0tO2JyZWFrfWRlbGV0ZSBMLmxpc3RUeXBlLGRlbGV0ZSBMLmxpc3RTdHlsZSxvLnB1c2goTCksaSsrfXIudmFsdWVMaXN0PWgobyxjKSx0PXJ9fWVsc2UgaWYodC50eXBlPT09bi5UQUJMRSl7aWYodC5wYWdpbmdJZCl7bGV0IGw9aSsxLGY9MDtmb3IoO2w8YS5sZW5ndGg7KXtjb25zdCBzPWFbbF07aWYocy5wYWdpbmdJZD09PXQucGFnaW5nSWQpdC5oZWlnaHQrPXMuaGVpZ2h0LHQudHJMaXN0LnB1c2goLi4ucy50ckxpc3QpLGwrKyxmKys7ZWxzZSBicmVha31pKz1mfWlmKHQudHJMaXN0KWZvcihsZXQgbD0wO2w8dC50ckxpc3QubGVuZ3RoO2wrKyl7Y29uc3QgZj10LnRyTGlzdFtsXTtkZWxldGUgZi5pZDtmb3IobGV0IHM9MDtzPGYudGRMaXN0Lmxlbmd0aDtzKyspe2NvbnN0IHI9Zi50ZExpc3Rbc10sbz17Y29sc3BhbjpyLmNvbHNwYW4scm93c3BhbjpyLnJvd3NwYW4sdmFsdWU6aChyLnZhbHVlLFgoZyh7fSxjKSx7aXNDbGFzc2lmeUFyZWE6ITF9KSl9O2ZlLmZvckVhY2goTD0+e2NvbnN0IFM9cltMXTtTIT09dm9pZCAwJiYob1tMXT1TKX0pLGYudGRMaXN0W3NdPW99fX1lbHNlIGlmKHQudHlwZT09PW4uSFlQRVJMSU5LKXtjb25zdCBsPXQuaHlwZXJsaW5rSWQ7aWYobCl7Y29uc3QgZj17dHlwZTpuLkhZUEVSTElOSyx2YWx1ZToiIix1cmw6dC51cmx9LHM9W107Zm9yKDtpPGEubGVuZ3RoOyl7Y29uc3Qgcj1hW2ldO2lmKGwhPT1yLmh5cGVybGlua0lkKXtpLS07YnJlYWt9ZGVsZXRlIHIudHlwZSxkZWxldGUgci51cmwscy5wdXNoKHIpLGkrK31mLnZhbHVlTGlzdD1oKHMsYyksdD1mfX1lbHNlIGlmKHQudHlwZT09PW4uREFURSl7Y29uc3QgbD10LmRhdGVJZDtpZihsKXtjb25zdCBmPXt0eXBlOm4uREFURSx2YWx1ZToiIixkYXRlRm9ybWF0OnQuZGF0ZUZvcm1hdH0scz1bXTtmb3IoO2k8YS5sZW5ndGg7KXtjb25zdCByPWFbaV07aWYobCE9PXIuZGF0ZUlkKXtpLS07YnJlYWt9ZGVsZXRlIHIudHlwZSxkZWxldGUgci5kYXRlRm9ybWF0LHMucHVzaChyKSxpKyt9Zi52YWx1ZUxpc3Q9aChzLGMpLHQ9Zn19ZWxzZSBpZih0LmNvbnRyb2xJZCl7Y29uc3QgbD10LmNvbnRyb2xJZDtpZih0LmNvbnRyb2xDb21wb25lbnQ9PT1DLlBSRUZJWCl7Y29uc3QgZj1bXTtsZXQgcz0hMSxyPWk7Zm9yKDtyPGEubGVuZ3RoOyl7Y29uc3Qgbz1hW3JdO2lmKGwhPT1vLmNvbnRyb2xJZClicmVhaztvLmNvbnRyb2xDb21wb25lbnQ9PT1DLlZBTFVFJiYoZGVsZXRlIG8uY29udHJvbCxkZWxldGUgby5jb250cm9sSWQsZi5wdXNoKG8pKSxvLmNvbnRyb2xDb21wb25lbnQ9PT1DLlBPU1RGSVgmJihzPSEwKSxyKyt9aWYocyl7Y29uc3Qgbz1LKHQsRWUpLEw9ZyhnKHt9LHQuY29udHJvbCksbyksUz1YKGcoe30sSyh0LGNlKSkse3R5cGU6bi5DT05UUk9MLHZhbHVlOiIiLGNvbnRyb2w6TCxjb250cm9sSWQ6bH0pO1MuY29udHJvbC52YWx1ZT1oKGYsYyksdD14KFMse2V4dHJhUGlja0F0dHJzOkV9KSxpKz1yLWktMX19aWYodC5jb250cm9sQ29tcG9uZW50JiYoZGVsZXRlIHQuY29udHJvbCxkZWxldGUgdC5jb250cm9sSWQsdC5jb250cm9sQ29tcG9uZW50IT09Qy5WQUxVRSYmdC5jb250cm9sQ29tcG9uZW50IT09Qy5QUkVfVEVYVCYmdC5jb250cm9sQ29tcG9uZW50IT09Qy5QT1NUX1RFWFQpKXtpKys7Y29udGludWV9fWNvbnN0IE09eCh0LHtleHRyYVBpY2tBdHRyczpFfSk7aWYoIXQudHlwZXx8dC50eXBlPT09bi5URVhUfHx0LnR5cGU9PT1uLlNVQlNDUklQVHx8dC50eXBlPT09bi5TVVBFUlNDUklQVClmb3IoO2k8YS5sZW5ndGg7KXtjb25zdCBsPWFbaSsxXTtpZihpKyssbCYmVGUoTSx4KGwse2V4dHJhUGlja0F0dHJzOkV9KSkpe2NvbnN0IGY9bC52YWx1ZT09PVA/YApgOmwudmFsdWU7TS52YWx1ZSs9Zn1lbHNlIGJyZWFrfWVsc2UgaSsrO3AucHVzaChNKX1yZXR1cm4gcH1vbm1lc3NhZ2U9ZT0+e2NvbnN0IGM9ZS5kYXRhLHtvcHRpb25zOkUsZGF0YTpBfT1jLHtleHRyYVBpY2tBdHRyczpSPVtdfT1FfHx7fSxhPXtoZWFkZXI6aChBLmhlYWRlcix7ZXh0cmFQaWNrQXR0cnM6Uixpc0Nsb25lOiExfSksbWFpbjpoKEEubWFpbix7ZXh0cmFQaWNrQXR0cnM6Uixpc0NsYXNzaWZ5QXJlYTohMCxpc0Nsb25lOiExfSksZm9vdGVyOmgoQS5mb290ZXIse2V4dHJhUGlja0F0dHJzOlIsaXNDbG9uZTohMX0pfTtwb3N0TWVzc2FnZShhKX19KSgpO30pKCk7Cg==",di=typeof window!="undefined"&&window.Blob&&new Blob([atob(ci)],{type:"text/javascript;charset=utf-8"});function or(){const r=di&&(window.URL||window.webkitURL).createObjectURL(di);try{return r?new Worker(r):new Worker("data:application/javascript;base64,"+ci,{type:"module"})}finally{r&&(window.URL||window.webkitURL).revokeObjectURL(r)}}class sr{constructor(t){L(this,"draw");L(this,"wordCountWorker");L(this,"catalogWorker");L(this,"groupWorker");L(this,"valueWorker");this.draw=t,this.wordCountWorker=new er,this.catalogWorker=new nr,this.groupWorker=new ir,this.valueWorker=new or}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=o=>{t(o.data)},this.wordCountWorker.onerror=o=>{e(o)};const n=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(n)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=s=>{t(s.data)},this.catalogWorker.onerror=s=>{e(s)};const n=this.draw.getOriginalMainElementList(),o=this.draw.getPosition().getOriginalMainPositionList();this.catalogWorker.postMessage({elementList:n,positionList:o})})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=o=>{t(o.data)},this.groupWorker.onerror=o=>{e(o)};const n=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(n)})}getValue(t){return new Promise((e,n)=>{this.valueWorker.onmessage=o=>{e({version:Xt,data:o.data,options:$(this.draw.getOptions())})},this.valueWorker.onerror=o=>{n(o)},this.valueWorker.postMessage({data:this.draw.getOriginValue(t),options:t})})}destroy(){this.wordCountWorker.terminate(),this.catalogWorker.terminate(),this.groupWorker.terminate(),this.valueWorker.terminate()}}class rr{constructor(t){L(this,"container");L(this,"canvas");L(this,"draw");L(this,"options");L(this,"curElement");L(this,"curElementSrc");L(this,"previewerDrawOption");L(this,"curPosition");L(this,"eventBus");L(this,"imageList");L(this,"curShowElement");L(this,"imageCount");L(this,"imagePre");L(this,"imageNext");L(this,"resizerSelection");L(this,"resizerHandleList");L(this,"resizerImageContainer");L(this,"resizerImage");L(this,"resizerSize");L(this,"width");L(this,"height");L(this,"mousedownX");L(this,"mousedownY");L(this,"curHandleIndex");L(this,"previewerContainer");L(this,"previewerImage");L(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:o,resizerImage:s,resizerSize:i}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=n,this.resizerImageContainer=o,this.resizerImage=s,this.resizerSize=i,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 o=0,s=0;const i=this.draw.getHeight(),l=this.draw.getPageGap(),c=((d=e==null?void 0:e.pageNo)!=null?d:this.draw.getPageNo())*(i+l);if(t.imgFloatPosition)o=t.imgFloatPosition.x*n,s=t.imgFloatPosition.y*n+c;else if(e){const{coordinate:{leftTop:[h,u]},ascent:g}=e;o=h,s=u+c+g}return{x:o,y:s}}_createResizerDom(){const{scale:t}=this.options,e=document.createElement("div");e.classList.add(`${v}-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 c=document.createElement("div");c.style.background=this.options.resizerColor,c.classList.add("resizer-handle"),c.classList.add(`handle-${a}`),c.setAttribute("data-index",String(a)),c.onmousedown=this._mousedown.bind(this),e.append(c),n.push(c)}this.container.append(e);const o=document.createElement("div");o.classList.add(`${v}-resizer-size-view`);const s=document.createElement("span");o.append(s),e.append(o);const i=document.createElement("div");i.classList.add(`${v}-resizer-image`),i.style.display="none";const l=document.createElement("img");return i.append(l),this.container.append(i),{resizerSelection:e,resizerHandleList:n,resizerImageContainer:i,resizerImage:l,resizerSize:s}}_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 o=window.getComputedStyle(n).cursor;document.body.style.cursor=o,this.canvas.style.cursor=o,this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{x:s,y:i}=this._getElementPosition(this.curElement,this.curPosition);this.resizerImageContainer.style.left=`${s}px`,this.resizerImageContainer.style.top=`${i}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.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,o=0;switch(this.curHandleIndex){case 0:{const c=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(c**3+d**3),o=this.curElement.height*n/this.curElement.width}break;case 1:o=this.mousedownY-t.y;break;case 2:{const c=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(c**3+d**3),o=this.curElement.height*n/this.curElement.width}break;case 4:{const c=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(c**3+d**3),o=this.curElement.height*n/this.curElement.width}break;case 3:n=t.x-this.mousedownX;break;case 5:o=t.y-this.mousedownY;break;case 6:{const c=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(c**3+d**3),o=this.curElement.height*n/this.curElement.width}break;case 7:n=this.mousedownX-t.x;break}const s=this.curElement.width+n/e,i=this.curElement.height+o/e;if(s<=0||i<=0)return;this.width=s,this.height=i;const l=s*e,a=i*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(`${v}-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(`${v}-image-container`);const o=document.createElement("img");o.src=this.curElementSrc,o.draggable=!1,n.append(o),this.previewerImage=o,t.append(n);let s=0,i=0,l=1,a=0;const c=document.createElement("div");c.classList.add(`${v}-image-menu`);const d=document.createElement("div");d.classList.add("image-navigate");const h=document.createElement("i");h.classList.add("image-pre"),h.onclick=()=>{const I=this.imageList.findIndex(f=>{var F;return f.id===((F=this.curShowElement)==null?void 0:F.id)});I<=0||(this.curShowElement=this.imageList[I-1],o.src=this.curShowElement.value,this._updateImageNavigate())},d.append(h),this.imagePre=h;const u=document.createElement("span");u.classList.add("image-count"),this.imageCount=u,d.append(u);const g=document.createElement("i");g.classList.add("image-next"),g.onclick=()=>{const I=this.imageList.findIndex(f=>{var F;return f.id===((F=this.curShowElement)==null?void 0:F.id)});I>=this.imageList.length-1||(this.curShowElement=this.imageList[I+1],o.src=this.curShowElement.value,this._updateImageNavigate())},this.imageNext=g,d.append(g),c.append(d);const T=document.createElement("i");T.classList.add("zoom-in"),T.onclick=()=>{l+=.1,this._setPreviewerTransform(l,a,s,i)},c.append(T);const P=document.createElement("i");P.onclick=()=>{l-.1<=.1||(l-=.1,this._setPreviewerTransform(l,a,s,i))},P.classList.add("zoom-out"),c.append(P);const O=document.createElement("i");O.classList.add("rotate"),O.onclick=()=>{a+=1,this._setPreviewerTransform(l,a,s,i)},c.append(O);const M=document.createElement("i");M.classList.add("original-size"),M.onclick=()=>{s=0,i=0,l=1,a=0,this._setPreviewerTransform(l,a,s,i)},c.append(M);const S=document.createElement("i");S.classList.add("image-download"),S.onclick=()=>{var f;const{mime:I}=this.previewerDrawOption;Nn(o.src,`${(f=this.curElement)==null?void 0:f.id}.${I||"png"}`)},c.append(S),t.append(c),this.previewerContainer=t,document.body.append(t);let X=0,N=0,m=!1;o.onmousedown=I=>{m=!0,X=I.x,N=I.y,t.style.cursor="move"},t.onmousemove=I=>{!m||(s+=I.x-X,i+=I.y-N,X=I.x,N=I.y,this._setPreviewerTransform(l,a,s,i))},t.onmouseup=()=>{m=!1,t.style.cursor="auto"},t.onwheel=I=>{if(I.preventDefault(),I.stopPropagation(),I.deltaY<0)l+=.1;else{if(l-.1<=.1)return;l-=.1}this._setPreviewerTransform(l,a,s,i)},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,o){!this.previewerImage||(this.previewerImage.style.left=`${n}px`,this.previewerImage.style.top=`${o}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:o}=this.options,s=this.draw.isReadonly();this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let i=0;i<8;i++){const l=i===0||i===6||i===7?-n:i===1||i===5?t/2:t-n,a=i===0||i===1||i===2?-n:i===3||i===7?e/2-n:e-n;this.resizerHandleList[i].style.transform=`scale(${o})`,this.resizerHandleList[i].style.left=`${l}px`,this.resizerHandleList[i].style.top=`${a}px`,this.resizerHandleList[i].style.display=s?"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===R.EditorMode.PRINT&&((e=this.options.modeRule[R.EditorMode.PRINT])==null?void 0:e.imagePreviewerDisabled)||t===R.EditorMode.READONLY&&((n=this.options.modeRule[R.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 s,i;const o=this.draw.getMode();t.imgToolDisabled&&!this.draw.isDesignMode()||o===R.EditorMode.PRINT&&((s=this.options.modeRule[R.EditorMode.PRINT])==null?void 0:s.imagePreviewerDisabled)||o===R.EditorMode.READONLY&&((i=this.options.modeRule[R.EditorMode.READONLY])==null?void 0:i.imagePreviewerDisabled)||(this.previewerDrawOption=n,this.curElementSrc=t[n.srcKey||"value"]||"",this.updateResizer(t,e),document.addEventListener("keydown",this._keydown))}updateResizer(t,e=null){const{scale:n}=this.options,o=t.width*n,s=t.height*n;this._updateResizerSizeView(o,s);const{x:i,y:l}=this._getElementPosition(t,e);this.resizerSelection.style.left=`${i}px`,this.resizerSelection.style.top=`${l}px`,this.resizerSelection.style.borderWidth=`${n}px`,this._updateResizerRect(o,s),this.resizerSelection.style.display="block",this.curElement=t,this.curPosition=e,this.width=o,this.height=s}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}class lr{constructor(t){L(this,"draw");L(this,"range");L(this,"datePicker");L(this,"options");this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.datePicker=new ii(t,{onSubmit:this._setValue.bind(this)})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[n,o]=e,s=this.draw.getElementList(),i=s[n+1];this.draw.spliceElementList(s,n+1,o-n),this.range.setRange(n,n);const l={type:R.ElementType.DATE,value:"",dateFormat:i.dateFormat,valueList:[{value:t}]};It(s,[l],n,{editorOptions:this.options}),this.draw.insertElementList([l])}getDateElementRange(){let t=-1,e=-1;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return null;const s=this.draw.getElementList(),i=s[n];if(i.type!==R.ElementType.DATE)return null;let l=n;for(;l>=0;){if(s[l].dateId!==i.dateId){t=l;break}l--}let a=n+1;for(;a<s.length;){if(s[a].dateId!==i.dateId){e=a-1;break}a++}return a===s.length&&(e=a-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const n=this.draw.getElementList(),o=this.getDateElementRange(),s=o?n.slice(o[0]+1,o[1]+1).map(i=>i.value).join(""):"";this.datePicker.render({value:s,position:e,dateFormat:t.dateFormat})}}class hi{constructor(t){L(this,"element");L(this,"videoCache");this.element=t,this.videoCache=new Map}snapshot(t,e,n){return new Promise((o,s)=>{var l,a;const i=((a=(l=this.element.block)==null?void 0:l.videoBlock)==null?void 0:a.src)||"";if(this.videoCache.has(i)){const c=this.videoCache.get(i);t.drawImage(c,e,n,this.element.metrics.width,this.element.metrics.height),o(this.element)}else{const c=document.createElement("video");c.src=i,c.muted=!0,c.crossOrigin="anonymous",c.onloadeddata=()=>{t.drawImage(c,e,n,this.element.metrics.width,this.element.metrics.height),this.videoCache.set(i,c),o(this.element)},c.onerror=d=>{s(d)},c.play().then(()=>{c.pause()})}})}render(t){var o;const e=this.element.block,n=document.createElement("video");n.style.width="100%",n.style.height="100%",n.style.objectFit="contain",n.src=((o=e.videoBlock)==null?void 0:o.src)||"",n.controls=!0,t.append(n)}}class ar{constructor(t,e){L(this,"draw");L(this,"options");L(this,"element");L(this,"block");L(this,"blockContainer");L(this,"blockItem");L(this,"positionInfo",null);L(this,"blockCache");L(this,"resizerMask");L(this,"resizerSelection");L(this,"resizerHandleList");L(this,"width");L(this,"height");L(this,"mousedownX");L(this,"mousedownY");L(this,"curHandleIndex");L(this,"isAllowResize");this.draw=t.getDraw(),this.options=this.draw.getOptions(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null;const{blockItem:n,resizerMask:o,resizerSelection:s,resizerHandleList:i}=this._createBlockItem();this.blockItem=n,this.blockContainer.append(this.blockItem),this.blockCache=new Map,this.resizerMask=o,this.resizerSelection=s,this.resizerHandleList=i,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}getIFrameBlock(){return this.block instanceof zt?this.block:null}getPositionInfo(){return this.positionInfo}_createBlockItem(){const{scale:t,resizerColor:e}=this.options,n=document.createElement("div");n.classList.add(`${v}-block-item`);const o=document.createElement("div");o.style.display="none",o.classList.add(`${v}-resizer-selection`),o.style.borderColor=e,o.style.borderWidth=`${t}px`;const s=[];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),o.append(a),s.push(a)}const i=document.createElement("div");return i.classList.add(`${v}-resizer-mask`),i.style.display="none",n.append(i),n.onmouseenter=()=>{if(this.draw.isReadonly())return;const{width:a,height:c}=this.element.metrics;this._updateResizerRect(a,c),o.style.display="block"},n.onmouseleave=()=>{this.isAllowResize||(o.style.display="none")},n.append(o),{blockItem:n,resizerMask:i,resizerSelection:o,resizerHandleList:s}}_updateResizerRect(t,e){const{resizerSize:n,scale:o}=this.options;this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let s=0;s<8;s++){const i=s===0||s===6||s===7?-n:s===1||s===5?t/2:t-n,l=s===0||s===1||s===2?-n:s===3||s===7?e/2-n:e-n;this.resizerHandleList[s].style.transform=`scale(${o})`,this.resizerHandleList[s].style.left=`${i}px`,this.resizerHandleList[s].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 o=window.getComputedStyle(n).cursor;document.body.style.cursor=o,e.style.cursor=o;const s=this._mousemove.bind(this);document.addEventListener("mousemove",s),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",s),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,o=0;switch(this.curHandleIndex){case 0:{const c=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(c**3+d**3),o=this.element.height*n/this.getBlockWidth()}break;case 1:o=this.mousedownY-t.y;break;case 2:{const c=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(c**3+d**3),o=this.element.height*n/this.getBlockWidth()}break;case 4:{const c=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(c**3+d**3),o=this.element.height*n/this.getBlockWidth()}break;case 3:n=t.x-this.mousedownX;break;case 5:o=t.y-this.mousedownY;break;case 6:{const c=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(c**3+d**3),o=this.element.height*n/this.getBlockWidth()}break;case 7:n=this.mousedownX-t.x;break}const s=this.getBlockWidth()+n/e,i=this.element.height+o/e;if(s<=0||i<=0)return;this.width=s,this.height=i;const l=s*e,a=i*e;this._updateResizerRect(l,a),this.blockItem.style.width=`${l}px`,this.blockItem.style.height=`${a}px`,t.preventDefault()}snapshot(t,e,n,o){const s=this.element.block;if(s.type===R.BlockType.VIDEO)if(this.blockItem.style.display="none",this.blockCache.has(this.element.id))this.blockCache.get(this.element.id).snapshot(t,n,o);else{this.block=new hi(this.element);const i=this.block.snapshot(t,n,o);this.draw.getImageObserver().add(i),this.blockCache.set(this.element.id,this.block)}else s.type===R.BlockType.IFRAME&&this.setClientRects(e,n,o)}render(){const t=this.element.block;t.type===R.BlockType.IFRAME?(this.block=new zt(this.element),this.block.render(this.blockItem)):t.type===R.BlockType.VIDEO&&(this.block=new hi(this.element),this.block.render(this.blockItem))}setClientRects(t,e,n){const o=this.draw.getHeight(),s=this.draw.getPageGap(),i=t*(o+s),{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=`${i+n}px`,this.positionInfo={pageNo:t,x:e,y:n}}setStatus(){this.block instanceof zt&&this.block.setReadonly(this.draw.isReadonly())}remove(){this.blockItem.remove()}}class Rr{constructor(t){L(this,"draw");L(this,"options");L(this,"container");L(this,"blockContainer");L(this,"blockMap");this.draw=t,this.options=t.getOptions(),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(`${v}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,n,o,s){const i=n.id;let l=this.blockMap.get(i);l||(l=new ar(this,n),l.render(),this.blockMap.set(i,l)),this.draw.isPrintMode()?l.snapshot(t,e,o,s):l.setClientRects(e,o,s),l.setStatus()}clear(){if(!this.blockMap.size)return;const t=this.draw.getOriginalMainElementList(),e=[];for(let n=0;n<t.length;n++){const o=t[n];o.type===R.ElementType.BLOCK&&e.push(o.id)}this.blockMap.forEach(n=>{const o=n.getBlockElement().id;e.includes(o)||(n.remove(),this.blockMap.delete(o))})}update(){this.blockMap.forEach(t=>{var n,o,s,i,l;const e=t.getBlockElement();if(((n=e.block)==null?void 0:n.type)===R.BlockType.IFRAME&&((o=e.block.iframeBlock)==null?void 0:o.srcdoc)){const a=(l=(i=(s=t.getIFrameBlock)==null?void 0:s.call(t))==null?void 0:i.getIframe)==null?void 0:l.call(i);(a==null?void 0:a.contentDocument)&&(e.block.iframeBlock.srcdoc=a.contentDocument.documentElement.outerHTML)}})}async drawIframeToPage(t,e){const n=[];this.blockMap.forEach(o=>{var g,T,P;if(((g=o.getBlockElement().block)==null?void 0:g.type)!==R.BlockType.IFRAME)return;const s=o.getPositionInfo();if(!s)return;const i=(T=o.getIFrameBlock())==null?void 0:T.getIframe();if(!i)return;const{pageNo:l,x:a,y:c}=s,d=(P=t[l])==null?void 0:P.getContext("2d");if(!d)return;const{width:h,height:u}=o.getBlockElement().metrics;n.push(e(i).then(O=>Ji(O)).then(O=>d.drawImage(O,a,c,h,u)))}),await Promise.allSettled(n)}pickIframeInfo(){const t=[],{scale:e}=this.options;return this.blockMap.forEach(n=>{var c;const o=n.getBlockElement();if(!((c=o.block)==null?void 0:c.iframeBlock)||o.block.type!==R.BlockType.IFRAME)return;const s=n.getPositionInfo();if(!s)return;const{pageNo:i,x:l,y:a}=s;t[i]||(t[i]=[]),t[i].push({x:l,y:a,width:o.metrics.width/e,height:o.metrics.height/e,src:o.block.iframeBlock.src,srcdoc:o.block.iframeBlock.srcdoc})}),t}}var un={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"}},cr={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 dr{constructor(t){L(this,"currentLocale");L(this,"langMap",new Map([["zhCN",un],["en",cr]]));this.currentLocale=t}registerLangMap(t,e){const n=this.langMap.get(t);this.langMap.set(t,fn(n||un,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||un}t(t){const e=t.split(".");let n="",o=this.getLang();for(let s=0;s<e.length;s++){const i=e[s],l=Reflect.get(o,i);if(l)n=o=l;else return""}return n}}class hr{constructor(){L(this,"promiseList");this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class ur{constructor(t,e){L(this,"draw");L(this,"zone");L(this,"i18n");L(this,"container");L(this,"pageContainer");L(this,"isDisableMouseMove");L(this,"tipContainer");L(this,"tipContent");L(this,"currentMoveZone");this.draw=t,this.zone=e,this.i18n=t.getI18n(),this.container=t.getContainer(),this.pageContainer=t.getPageContainer();const{tipContainer:n,tipContent:o}=this._drawZoneTip();this.tipContainer=n,this.tipContent=o,this.isDisableMouseMove=!0,this.currentMoveZone=R.EditorZone.MAIN;const s=[],{header:i,footer:l}=t.getOptions();i.disabled||s.push(R.EditorZone.HEADER),l.disabled||s.push(R.EditorZone.FOOTER),s.length&&this._watchMouseMoveZoneChange(s)}_watchMouseMoveZoneChange(t){this.pageContainer.addEventListener("mousemove",Ei(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()===R.EditorZone.MAIN&&(n===R.EditorZone.HEADER||n===R.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(`${v}-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===R.EditorZone.HEADER?"headerTip":"footerTip"}`)):this.tipContainer.classList.remove("show")}}class gr{constructor(t){L(this,"INDICATOR_PADDING",2);L(this,"INDICATOR_TITLE_TRANSLATE",[20,5]);L(this,"draw");L(this,"options");L(this,"i18n");L(this,"container");L(this,"currentZone");L(this,"indicatorContainer");this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=R.EditorZone.MAIN,this.indicatorContainer=null,this.options.zone.tipDisabled||new ur(t,this)}isHeaderActive(){return this.getZone()===R.EditorZone.HEADER}isMainActive(){return this.getZone()===R.EditorZone.MAIN}isFooterActive(){return this.getZone()===R.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){const{header:e,footer:n}=this.options;!e.editable&&t===R.EditorZone.HEADER||!n.editable&&t===R.EditorZone.FOOTER||this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),Be(()=>{const o=this.draw.getListener();o.zoneChange&&o.zoneChange(t);const s=this.draw.getEventBus();s.isSubscribe("zoneChange")&&s.emit("zoneChange",t)}))}getZoneByY(t){const e=this.draw.getHeader(),n=e.getHeaderTop()+e.getHeight(),o=this.draw.getFooter(),i=this.draw.getHeight()-(o.getFooterBottom()+o.getHeight());return t<n?R.EditorZone.HEADER:t>i?R.EditorZone.FOOTER:R.EditorZone.MAIN}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[n,o]=this.INDICATOR_TITLE_TRANSLATE,s=this.draw.getPageList(),i=this.draw.getMargins(),l=this.draw.getInnerWidth(),a=this.draw.getHeight(),c=this.draw.getPageGap(),d=a+c;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${v}-zone-indicator`);const h=this.draw.getHeader(),u=this.draw.getFooter(),g=e?h.getHeight():u.getHeight(),T=e?h.getHeaderTop():a-u.getFooterBottom()-g;for(let P=0;P<s.length;P++){const O=d*P+T,M=i[3]-this.INDICATOR_PADDING,S=i[3]+l+this.INDICATOR_PADDING,X=e?O-this.INDICATOR_PADDING:O+g+this.INDICATOR_PADDING,N=e?O+g+this.INDICATOR_PADDING:O-this.INDICATOR_PADDING,m=document.createElement("div");m.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),m.style.top=`${N}px`,m.style.transform=`translate(${n*t}px, ${o*t}px) scale(${t})`,this.indicatorContainer.append(m);const I=document.createElement("span");I.classList.add(`${v}-zone-indicator-border__top`),I.style.top=`${X}px`,I.style.width=`${l}px`,I.style.marginLeft=`${i[3]}px`,this.indicatorContainer.append(I);const f=document.createElement("span");f.classList.add(`${v}-zone-indicator-border__left`),f.style.top=`${O}px`,f.style.height=`${g}px`,f.style.left=`${M}px`,this.indicatorContainer.append(f);const F=document.createElement("span");F.classList.add(`${v}-zone-indicator-border__bottom`),F.style.top=`${N}px`,this.indicatorContainer.append(F);const V=document.createElement("span");V.classList.add(`${v}-zone-indicator-border__right`),V.style.top=`${O}px`,V.style.height=`${g}px`,V.style.left=`${S}px`,this.indicatorContainer.append(V)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){var t;(t=this.indicatorContainer)==null||t.remove(),this.indicatorContainer=null}}class Lr{constructor(t,e){L(this,"draw");L(this,"position");L(this,"zone");L(this,"options");L(this,"elementList");L(this,"rowList");L(this,"positionList");this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(){const t=this.getFooterBottom(),e=this.draw.getInnerWidth(),o=this.draw.getMargins()[3],s=this.draw.getHeight(),i=this.getHeight(),l=s-t-i;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:o,startY:l,innerWidth:e,zone:R.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*Xn[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(),o=this.getFooterBottom()+e-t[2];return o<=0?0:o}render(t,e){t.save(),t.globalAlpha=this.zone.isFooterActive()?1:this.options.footer.inactiveAlpha;const n=this.draw.getInnerWidth(),o=this.getMaxHeight(),s=[];let i=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(i+a.height>o)break;s.push(a),i+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:s,pageNo:e,startIndex:0,innerWidth:n,zone:R.EditorZone.FOOTER}),t.restore()}}class Tr{constructor(t){L(this,"draw");L(this,"range");L(this,"options");L(this,"UN_COUNT_STYLE_WIDTH",20);L(this,"MEASURE_BASE_TEXT","0");L(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:o,endIndex:s}=this.range.getRange();if(!~o&&!~s)return;const i=this.range.getRangeParagraphElementList();if(!i||!i.length)return;if(i.find(h=>h.listType===t&&h.listStyle===e)||!t){this.unsetList();return}const a=j();i.forEach(h=>{h.listId=a,h.listType=t,h.listStyle=e});const c=o===s,d=c?s:o;this.draw.render({curIndex:d,isSetCursor:c})}unsetList(){var c;if(this.draw.isReadonly())return;const{startIndex:e,endIndex:n}=this.range.getRange();if(!~e&&!~n)return;const o=(c=this.range.getRangeParagraphElementList())==null?void 0:c.filter(d=>d.listId);if(!o||!o.length)return;const s=this.draw.getElementList(),i=s[n];if(i.listId){let d=n+1;for(;d<s.length;){const h=s[d];if(h.value===y&&!h.listWrap)break;if(h.listId!==i.listId){this.draw.spliceElementList(s,d,0,[{value:y}]);break}d++}}o.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 o=0,s=e[o].listId,i=[];const l=e.length;for(;o<l;){const a=e[o];if(s&&s===a.listId)i.push(a);else if(a.listId&&a.listId!==s){if(i.length){const c=this.getListStyleWidth(t,i);n.set(s,c)}s=a.listId,i=s?[a]:[]}o++}if(i.length){const a=this.getListStyleWidth(t,i);n.set(s,a)}return n}findStyledElement(t){let e=t[0];for(let n=1;n<t.length;n++){const o=t[n];if(o.font||o.size||o.bold||o.italic){e=o;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:o}=this.options;return`${o*e}px ${n}`}}getListStyleWidth(t,e){const{scale:n,checkbox:o}=this.options,s=e[0];if(s.listStyle&&s.listStyle!==R.ListStyle.DECIMAL)return s.listStyle===R.ListStyle.CHECKBOX?(o.width+this.LIST_GAP)*n:this.UN_COUNT_STYLE_WIDTH*n;const i=e.reduce((c,d)=>(d.value===y&&(c+=1),c),0);if(!i)return 0;t.save(),t.font=this.getListFontStyle(e,n);const l=`${this.MEASURE_BASE_TEXT.repeat(String(i).length-1||1)}${R.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:o,offsetX:s,listIndex:i,ascent:l}=e,a=o[0];if(a.value!==y||a.listWrap)return;let c=0;const{defaultTabWidth:d,scale:h}=this.options;for(let M=1;M<o.length;M++){const S=o[M];if((S==null?void 0:S.type)!==R.ElementType.TAB)break;c+=d*h}const{coordinate:{leftTop:[u,g]}}=n,T=u-s+c,P=g+l;if(a.listStyle===R.ListStyle.CHECKBOX){const{width:M,height:S,gap:X}=this.options.checkbox,N=B(Y({},a),{checkbox:{value:!!((O=a.checkbox)==null?void 0:O.value)},metrics:B(Y({},a.metrics),{width:(M+X*2)*h,height:S*h})});this.draw.getCheckboxParticle().render({ctx:t,x:T-X*h,y:P,index:0,row:B(Y({},e),{elementList:[N,...e.elementList]})})}else{let M="";if(a.listType===R.ListType.UL?M=je[a.listStyle]||je[ee.DISC]:M=`${i+1}${R.KeyMap.PERIOD}`,!M)return;t.save(),t.font=this.getListFontStyle(o,h),t.fillText(M,T,P),t.restore()}}}const gn=class{constructor(t){L(this,"options");this.options=t.getOptions()}render(t,e,n,o){const{scale:s,lineBreak:{color:i,lineWidth:l}}=this.options;t.save(),t.beginPath();const a=o-gn.HEIGHT*s/2,c=n+e.metrics.width;t.translate(c,a),t.scale(s,s),t.strokeStyle=i,t.lineWidth=l,t.lineCap="round",t.lineJoin="round",t.beginPath(),t.moveTo(8,0),t.lineTo(12,0),t.lineTo(12,6),t.lineTo(3,6),t.moveTo(3,6),t.lineTo(6,3),t.moveTo(3,6),t.lineTo(6,9),t.stroke(),t.closePath(),t.restore()}};let ne=gn;L(ne,"WIDTH",12),L(ne,"HEIGHT",9),L(ne,"GAP",3);class ui{constructor(t){L(this,"draw");L(this,"position");L(this,"options");L(this,"elementList");L(this,"rowList");L(this,"positionList");this.draw=t,this.position=t.getPosition(),this.options=t.getOptions(),this.elementList=[],this.rowList=[],this.positionList=[]}_recovery(){this.elementList=[],this.rowList=[],this.positionList=[]}_compute(t){this._computeRowList(),this._computePositionList(t)}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(t){const{lineBreak:e,scale:n}=this.options,o=this.draw.getHeader().getExtraHeight(),s=this.draw.getInnerWidth(),i=this.draw.getMargins();let l=i[3];e.disabled||(l+=(ne.WIDTH+ne.GAP)*n);const a=(t==null?void 0:t.startY)||i[0]+o;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:l,startY:a,innerWidth:s})}render(t,e){const{placeholder:n=this.options.placeholder}=e||{},{data:o,font:s,size:i,color:l,opacity:a}=n;this._recovery(),this.elementList=[{value:o,font:s,size:i,color:l}],Pt(this.elementList,{editorOptions:this.options,isForceCompensation:!0}),this._compute(e);const c=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:c,isDrawLineBreak:!1}),t.restore()}}class Pr{constructor(t){L(this,"draw");L(this,"options");L(this,"range");L(this,"fillRectMap");this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==R.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=j();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 o,s;const n=[];for(let i=0;i<t.length;i++){const l=t[i];if(l.type===R.ElementType.TABLE){const a=l.trList;for(let c=0;c<a.length;c++){const d=a[c];for(let h=0;h<d.tdList.length;h++){const u=d.tdList[h],g=this.getElementListByGroupId(u.value,e);if(g.length)return n.push(...g),n}}}if((o=l==null?void 0:l.groupIds)==null?void 0:o.includes(e)){n.push(l);const a=t[i+1];if(!((s=a==null?void 0:a.groupIds)==null?void 0:s.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 o=0;o<n.length;o++){const s=n[o],i=s.groupIds,l=i.findIndex(a=>a===t);i.splice(l,1),i.length||delete s.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){var n,o;for(let s=0;s<t.length;s++){const i=t[s];if(i.type===R.ElementType.TABLE){const a=i.trList;for(let c=0;c<a.length;c++){const d=a[c];for(let h=0;h<d.tdList.length;h++){const u=d.tdList[h],g=this.getContextByGroupId(u.value,e);if(g)return B(Y({},g),{isTable:!0,index:s,trIndex:c,tdIndex:h,tdId:u.id,trId:d.id,tableId:i.tableId})}}}const l=t[s+1];if(((n=i.groupIds)==null?void 0:n.includes(e))&&!((o=l==null?void 0:l.groupIds)==null?void 0:o.includes(e)))return{isTable:!1,startIndex:s,endIndex:s}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,n,o,s){const i=t.groupIds;if(!!i)for(const l of i){const a=this.fillRectMap.get(l);a?a.width+=o:this.fillRectMap.set(l,{x:e,y:n,width:o,height:s})}}render(t){var c;if(!this.fillRectMap.size)return;const e=this.range.getRange(),o=(c=this.draw.getElementList()[e.endIndex])==null?void 0:c.groupIds,{group:{backgroundColor:s,opacity:i,activeOpacity:l,activeBackgroundColor:a}}=this.options;t.save(),this.fillRectMap.forEach((d,h)=>{const{x:u,y:g,width:T,height:P}=d;(o==null?void 0:o.includes(h))?(t.globalAlpha=l,t.fillStyle=a):(t.globalAlpha=i,t.fillStyle=s),t.fillRect(u,g,T,P)}),t.restore(),this.clearFillInfo()}}class Mr{constructor(t){L(this,"options");this.options=t.getOptions()}render(t,e,n,o){const{scale:s,whiteSpace:{color:i,radius:l}}=this.options,a=e.metrics;t.save(),t.fillStyle=i,t.beginPath(),t.arc(n+a.width/2,o,l*s,0,Math.PI*2),t.fill(),t.closePath(),t.restore()}}class Or{constructor(t){L(this,"draw");L(this,"eventBus");L(this,"pageContainer");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 Sr{constructor(t){L(this,"draw");L(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:n,lineNumber:{color:o,size:s,font:i,right:l,type:a}}=this.options,c=this.draw.getTextParticle(),d=this.draw.getMargins(),h=this.draw.getPosition().getOriginalMainPositionList(),g=this.draw.getPageRowList()[e];t.save(),t.fillStyle=o,t.font=`${s*n}px ${i}`;for(let T=0;T<g.length;T++){const P=g[T],{coordinate:{leftBottom:O}}=h[P.startIndex],M=a===R.LineNumberType.PAGE?T+1:P.rowIndex+1,S=c.measureText(t,{value:`${M}`}),X=d[3]-(S.width+l)*n,N=O[1]-S.actualBoundingBoxAscent*n;t.fillText(`${M}`,X,N)}t.restore()}}class Xr{constructor(t){L(this,"draw");L(this,"header");L(this,"footer");L(this,"options");this.draw=t,this.header=t.getHeader(),this.footer=t.getFooter(),this.options=t.getOptions()}render(t){const{scale:e,pageBorder:{color:n,lineWidth:o,padding:s}}=this.options;t.save(),t.translate(.5,.5),t.strokeStyle=n,t.lineWidth=o*e;const i=this.draw.getMargins(),l=i[3]-s[3]*e,a=i[0]+this.header.getExtraHeight()-s[0]*e,c=this.draw.getInnerWidth()+(s[1]+s[3])*e,d=this.draw.getHeight()-a-this.footer.getExtraHeight()-i[2]+s[2]*e;t.rect(l,a,c,d),t.stroke(),t.restore()}}function Ir(r,t){const{value:e,oldValue:n}=t;n.isTable&&!e.isTable&&r.getTableTool().dispose()}class Nr{constructor(t){L(this,"draw");L(this,"eventBus");this.draw=t,this.eventBus=t.getEventBus(),this.execute()}execute(){this.eventBus.on("positionContextChange",t=>{Ir(this.draw,t)})}}class fr{constructor(t){L(this,"draw");L(this,"range");L(this,"position");L(this,"tableTool");L(this,"tableParticle");L(this,"options");this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.tableTool=t.getTableTool(),this.tableParticle=t.getTableParticle(),this.options=t.getOptions()}insertTable(t,e){var T;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const{defaultTrMinHeight:s}=this.options.table,i=this.draw.getElementList();let l=0;if((T=i[n])==null?void 0:T.listId){const P=this.position.getPositionList(),{rowIndex:O}=P[n],S=this.draw.getRowList()[O];l=(S==null?void 0:S.offsetX)||0}const a=this.draw.getContextInnerWidth()-l,c=[],d=a/e;for(let P=0;P<e;P++)c.push({width:d});const h=[];for(let P=0;P<t;P++){const O=[],M={height:s,tdList:O};for(let S=0;S<e;S++)O.push({colspan:1,rowspan:1,value:[]});h.push(M)}const u={type:R.ElementType.TABLE,value:"",colgroup:c,trList:h};Pt([u],{editorOptions:this.options}),It(i,[u],n,{editorOptions:this.options});const g=n+1;this.draw.spliceElementList(i,g,n===o?0:o-n,[u]),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:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=l[n];if(a.tdList.length<i.colgroup.length){const h=a.tdList[0].rowIndex;for(let u=0;u<n;u++){const g=l[u];for(let T=0;T<g.tdList.length;T++){const P=g.tdList[T];P.rowspan>1&&P.rowIndex+P.rowspan>=h+1&&(P.rowspan+=1)}}}const c=j(),d={height:a.height,id:c,tdList:[]};for(let h=0;h<a.tdList.length;h++){const u=a.tdList[h],g=j();d.tdList.push({id:g,rowspan:1,colspan:u.colspan,value:[{value:y,size:16,tableId:o,trId:c,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:o}),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:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=l[n],c=l.length-1===n?a:l[n+1];if(c.tdList.length<i.colgroup.length){const u=c.tdList[0].rowIndex;for(let g=0;g<n+1;g++){const T=l[g];for(let P=0;P<T.tdList.length;P++){const O=T.tdList[P];O.rowspan>1&&O.rowIndex+O.rowspan>=u+1&&(O.rowspan+=1)}}}const d=j(),h={height:c.height,id:d,tdList:[]};for(let u=0;u<c.tdList.length;u++){const g=c.tdList[u],T=j();h.tdList.push({id:T,rowspan:1,colspan:g.colspan,value:[{value:y,size:16,tableId:o,trId:d,tdId:T}]})}l.splice(n+1,0,h),this.position.setPositionContext({isTable:!0,index:e,trIndex:n+1,tdIndex:0,tdId:h.tdList[0].id,trId:h.id,tableId:i.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}adjustColWidth(t){if(t.type!==R.ElementType.TABLE)return;const{defaultColMinWidth:e}=this.options.table,n=t.colgroup,o=n.reduce((i,l)=>i+l.width,0),s=this.draw.getOriginalInnerWidth();if(o>s){const i=n.filter(a=>a.width>e),l=(o-s)/i.length;for(let a=0;a<n.length;a++){const c=n[a];c.width-l>=e&&(c.width-=l)}}}insertTableLeftCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=n;for(let h=0;h<l.length;h++){const u=l[h],g=j();u.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:o,trId:u.id,tdId:g}]})}const{defaultColMinWidth:c}=this.options.table;i.colgroup.splice(a,0,{width:c}),this.adjustColWidth(i),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:o}),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:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=n+1;for(let h=0;h<l.length;h++){const u=l[h],g=j();u.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:o,trId:u.id,tdId:g}]})}const{defaultColMinWidth:c}=this.options.table;i.colgroup.splice(a,0,{width:c}),this.adjustColWidth(i),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:i.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:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=l[n],c=a.tdList[o].rowIndex;if(l.length<=1&&i.pagingIndex===0){this.deleteTable();return}for(let d=0;d<c;d++){const u=l[d].tdList;for(let g=0;g<u.length;g++){const T=u[g];T.rowIndex+T.rowspan>c&&T.rowspan--}}for(let d=0;d<a.tdList.length;d++){const h=a.tdList[d];if(h.rowspan>1){const u=j(),g=l[n+1];g.tdList.splice(d,0,{id:u,rowspan:h.rowspan-1,colspan:h.colspan,value:[{value:y,size:16,tableId:i.id,trId:g.id,tdId:u}]})}}l.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.clearRange(),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTableCol(){var h;const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,c=l[o].tdList[n].colIndex;if(!l.find(u=>u.tdList.length>1)){this.deleteTable();return}for(let u=0;u<l.length;u++){const g=l[u];for(let T=0;T<g.tdList.length;T++){const P=g.tdList[T];P.colIndex<=c&&P.colIndex+P.colspan>c&&(P.colspan>1?P.colspan--:g.tdList.splice(T,1))}}(h=i.colgroup)==null||h.splice(c,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTable(){const t=this.position.getPositionContext();if(!t.isTable)return;const e=this.draw.getOriginalElementList(),n=e[t.index];let o=1,s=t.index;if(n.pagingId){s=t.index-n.pagingIndex;for(let l=s+1;l<e.length&&e[l].pagingId===n.pagingId;l++)o++}e.splice(s,o);const i=s-1;this.position.setPositionContext({isTable:!1,index:i}),this.range.setRange(i,i),this.draw.render({curIndex:i}),this.tableTool.dispose()}mergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{isCrossRowCol:e,startTdIndex:n,endTdIndex:o,startTrIndex:s,endTrIndex:i}=this.range.getRange();if(!e)return;const{index:l}=t,d=this.draw.getOriginalElementList()[l].trList;let h=d[s].tdList[n],u=d[i].tdList[o];(h.x>u.x||h.y>u.y)&&([h,u]=[u,h]);const g=h.colIndex,T=u.colIndex+(u.colspan-1),P=h.rowIndex,O=u.rowIndex+(u.rowspan-1),M=[];for(let W=0;W<d.length;W++){const C=d[W],U=[];for(let Q=0;Q<C.tdList.length;Q++){const w=C.tdList[Q],K=w.colIndex,p=w.rowIndex;K>=g&&K<=T&&p>=P&&p<=O&&U.push(w)}U.length&&M.push(U)}if(!M.length)return;const S=M[M.length-1],X=M[0][0],N=S[S.length-1],m=X.x,I=X.y,f=N.x+N.width,F=N.y+N.height;for(let W=0;W<M.length;W++){const C=M[W];for(let U=0;U<C.length;U++){const Q=C[U],w=Q.x,K=Q.y,p=w+Q.width,G=K+Q.height;if(m>w||I>K||f<p||F<G)return}}const V=[],Z=M[0][0],E=Z.value[0];for(let W=0;W<M.length;W++){const C=M[W];for(let U=0;U<C.length;U++){const Q=C[U];if(!(W===0&&U===0)){V.push(Q.id);const K=Q.value.length>1?0:1;for(let p=K;p<Q.value.length;p++){const G=Q.value[p];qt(Pe,E,G),Z.value.push(G)}}W===0&&U!==0&&(Z.colspan+=Q.colspan),W!==0&&Z.colIndex===Q.colIndex&&(Z.rowspan+=Q.rowspan)}}for(let W=0;W<d.length;W++){const C=d[W];let U=0;for(;U<C.tdList.length;){const Q=C.tdList[U];V.includes(Q.id)&&(C.tdList.splice(U,1),U--),U++}}this.position.setPositionContext(B(Y({},t),{trIndex:Z.trIndex,tdIndex:Z.tdIndex}));const D=Z.value.length-1;this.range.setRange(D,D),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:o}=t,i=this.draw.getOriginalElementList()[e],l=i.trList,a=l[o],c=a.tdList[n];if(c.rowspan===1&&c.colspan===1)return;const d=c.colspan;if(c.colspan>1){for(let u=1;u<c.colspan;u++){const g=j();a.tdList.splice(n+u,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:i.id,trId:a.id,tdId:g}]})}c.colspan=1}if(c.rowspan>1){for(let u=1;u<c.rowspan;u++){const g=l[o+u];for(let T=0;T<d;T++){const P=j();g.tdList.splice(c.colIndex,0,{id:P,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:i.id,trId:g.id,tdId:P}]})}}c.rowspan=1}const h=c.value.length-1;this.range.setRange(h,h),this.draw.render(),this.tableTool.render()}splitVerticalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:o,trIndex:s}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,c=a[s],d=c.tdList[o];l.colgroup.splice(o+1,0,{width:this.options.table.defaultColMinWidth});for(let h=0;h<a.length;h++){const u=a[h];let g=0;for(;g<u.tdList.length;){const T=u.tdList[g];if(T.rowIndex!==d.rowIndex)T.colIndex<=d.colIndex&&T.colIndex+T.colspan>d.colIndex&&T.colspan++;else if(T.id===d.id){const P=j();c.tdList.splice(g+d.colspan,0,{id:P,rowspan:d.rowspan,colspan:1,value:[{value:y,size:16,tableId:l.id,trId:u.id,tdId:P}]}),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:o,trIndex:s}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,d=a[s].tdList[o];let h=-1,u=0;for(;u<a.length;){if(u===h){u++;continue}const g=a[u];let T=0;for(;T<g.tdList.length;){const P=g.tdList[T];if(P.id===d.id){const O=j(),M=j();a.splice(u+d.rowspan,0,{id:O,height:this.options.table.defaultTrMinHeight,tdList:[{id:M,rowspan:1,colspan:d.colspan,value:[{value:y,size:16,tableId:l.id,trId:O,tdId:M}]}]}),h=u+d.rowspan}else P.rowIndex>=d.rowIndex&&P.rowIndex<d.rowIndex+d.rowspan&&P.rowIndex+P.rowspan>=d.rowIndex+d.rowspan&&P.rowspan++;T++}u++}this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let o=0;o<e.length;o++){const s=e[o];for(let i=0;i<s.length;i++){const l=s[i];!l||l.verticalAlign===t||!l.verticalAlign&&t===R.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,s=this.draw.getOriginalElementList()[n];if(!s.borderType&&t===R.TableBorder.ALL||s.borderType===t)return;s.borderType=t;const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i})}tableBorderColor(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,s=this.draw.getOriginalElementList()[n];if(!s.borderColor&&t===this.options.table.defaultBorderColor||s.borderColor===t)return;s.borderColor=t;const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isCompute:!1})}tableTdBorderType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),o=n.some(i=>{var l;return!((l=i.borderTypes)==null?void 0:l.includes(t))});n.forEach(i=>{i.borderTypes||(i.borderTypes=[]);const l=i.borderTypes.findIndex(a=>a===t);o?~l||i.borderTypes.push(t):~l&&i.borderTypes.splice(l,1),i.borderTypes.length||delete i.borderTypes});const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s})}tableTdSlashType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),o=n.some(i=>{var l;return!((l=i.slashTypes)==null?void 0:l.includes(t))});n.forEach(i=>{i.slashTypes||(i.slashTypes=[]);const l=i.slashTypes.findIndex(a=>a===t);o?~l||i.slashTypes.push(t):~l&&i.slashTypes.splice(l,1),i.slashTypes.length||delete i.slashTypes});const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s})}tableTdBackgroundColor(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let o=0;o<e.length;o++){const s=e[o];for(let i=0;i<s.length;i++){const l=s[i];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:o}=t;if(!o||!n)return;const{startIndex:s,endIndex:i}=this.range.getRange(),a=this.draw.getOriginalElementList()[e].trList,c=a.length-1,d=a[c].tdList.length-1;this.range.replaceRange({startIndex:s,endIndex:i,tableId:n,startTdIndex:0,endTdIndex:d,startTrIndex:0,endTrIndex:c}),this.draw.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1})}}R.AreaMode=void 0,function(r){r.EDIT="edit",r.READONLY="readonly",r.FORM="form"}(R.AreaMode||(R.AreaMode={}));class mr{constructor(t){L(this,"draw");L(this,"zone");L(this,"range");L(this,"position");L(this,"options");L(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?void 0:t.area))return!1;switch(t.area.mode){case R.AreaMode.EDIT:return!1;case R.AreaMode.READONLY:return!0;case R.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:o,position:s,range:i}=t;if(this.zone.getZone()!==R.EditorZone.MAIN&&this.zone.setZone(R.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),i&&!this.getActiveAreaId()){const{startIndex:a,endIndex:c}=i,d=this.draw.getOriginalMainElementList();if(!d[a]||!d[c])return null;this.range.setRange(i.startIndex,i.endIndex)}else if(s===R.LocationPosition.BEFORE)this.range.setRange(0,0);else{const c=this.draw.getOriginalMainElementList().length-1;this.range.setRange(c,c)}const l=e||j();return this.draw.insertElementList([{type:R.ElementType.AREA,value:"",areaId:l,valueList:n,area:$(o)}]),l}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),o=this.draw.getInnerWidth();for(const s of this.areaInfoMap){const{area:i,positionList:l}=s[1];if((i==null?void 0:i.hide)||!(i==null?void 0:i.backgroundColor)&&!(i==null?void 0:i.borderColor)&&!(i==null?void 0:i.placeholder))continue;const a=l.filter(T=>T.pageNo===e);if(!a.length)continue;t.translate(.5,.5);const c=a[0],d=a[a.length-1],h=n[3],u=Math.ceil(c.coordinate.leftTop[1]),g=Math.ceil(d.coordinate.rightBottom[1]-u);i.backgroundColor&&(t.fillStyle=i.backgroundColor,t.fillRect(h,u,o,g)),i.borderColor&&(t.strokeStyle=i.borderColor,t.strokeRect(h,u,o,g)),i.placeholder&&l.length<=1&&new ui(this.draw).render(t,{placeholder:Y(Y({},bn),i.placeholder),startY:c.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const o=t[n],s=o.areaId;if(s){const i=this.areaInfoMap.get(s);i?(i.elementList.push(o),i.positionList.push(e[n])):this.areaInfoMap.set(s,{id:s,area:o.area,elementList:[o],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:st(n.elementList)}:null}getContextByAreaId(t,e){var o,s,i;const n=this.draw.getOriginalMainElementList();for(let l=0;l<n.length;l++){const a=n[l];if((e==null?void 0:e.position)===R.LocationPosition.OUTER_BEFORE){if(((o=n[l+1])==null?void 0:o.areaId)!==t)continue}else if((e==null?void 0:e.position)===R.LocationPosition.AFTER){if(!(a.areaId===t&&((s=n[l+1])==null?void 0:s.areaId)!==t))continue}else if((e==null?void 0:e.position)===R.LocationPosition.OUTER_AFTER){if(!(a.areaId!==t&&((i=n[l-1])==null?void 0:i.areaId)===t))continue}else if(a.areaId!==t)continue;const c=this.position.getOriginalMainPositionList();return{range:{startIndex:l,endIndex:l},elementPosition:c[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 o=!1;const s=["top","hide"];Object.entries(t.properties).forEach(([i,l])=>{if(Wn(l))return;const a=i;n.area[a]=l,s.includes(a)&&(o=!0)}),this.draw.render({isCompute:o,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:o}=n,s=this.draw.getOriginalMainElementList(),i=t.value;Pt([{type:R.ElementType.AREA,value:"",valueList:i,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(s,o[0].index,o.length,i,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}deleteArea(t={}){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:o}=n,s=this.draw.getOriginalMainElementList();this.draw.spliceElementList(s,o[0].index,o.length,[],{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class Fr{constructor(t){L(this,"draw");L(this,"options");L(this,"imageCache");L(this,"mainBadge");L(this,"areaBadgeMap");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,o,s,i){if(this.imageCache.has(i)){const l=this.imageCache.get(i);t.drawImage(l,e,n,o,s)}else{const l=new Image;l.setAttribute("crossOrigin","Anonymous"),l.src=i,l.onload=()=>{this.imageCache.set(i,l),t.drawImage(l,e,n,o,s)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:o}=this.options,{left:s,top:i,width:l,height:a,value:c}=this.mainBadge,d=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),h=(s||o.left)*n,u=(i||o.top)*n+d;this._drawImage(t,h,u,l*n,a*n,c)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:o,badge:s}=this.options;for(const i of n){const{positionList:l}=i[1],a=l[0];if(a.pageNo!==e)continue;const c=this.areaBadgeMap.get(i[0]);if(!c)continue;const{left:d,top:h,width:u,height:g,value:T}=c,P=(d||s.left)*o,O=(h||s.top)*o+a.coordinate.leftTop[1];this._drawImage(t,P,O,u*o,g*o,T)}}}}}class Wr{constructor(t,e){L(this,"draw");L(this,"options");L(this,"data");L(this,"pageContainer");L(this,"isDrawing",!1);L(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 c;if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,o=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<o&&Math.abs(this.startStroke.points[1]-n)<o)return;const s=this.draw.getPageNo();let i=this.data.find(d=>d.pageNo===s);if(this.startStroke&&(i||(i={pageNo:s,strokes:[]},this.data.push(i)),i.strokes.push(this.startStroke),this.startStroke=null),!((c=i==null?void 0:i.strokes)==null?void 0:c.length))return;const{scale:l}=this.options;i.strokes[i.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?void 0:n.length))return;const{graffiti:{defaultLineColor:o,defaultLineWidth:s},scale:i}=this.options;t.save();for(let a=0;a<n.length;a++){const c=n[a];t.beginPath(),t.strokeStyle=c.lineColor||o,t.lineWidth=(c.lineWidth||s)*i,t.moveTo(c.points[0]*i,c.points[1]*i);for(let d=2;d<c.points.length;d+=2)t.lineTo(c.points[d]*i,c.points[d+1]*i);t.stroke()}t.restore()}}class Vr{constructor(t){L(this,"draw");L(this,"options");L(this,"canvas");L(this,"isActive");L(this,"container");L(this,"_handleKeyDown",t=>{t.key===R.KeyMap.ALT&&this.show()});L(this,"_handleKeyUp",t=>{t.key===R.KeyMap.ALT&&this.hide()});L(this,"_mousemove",t=>{this.isActive&&this._update(t)});this.draw=t,this.options=t.getOptions(),this.container=t.getContainer(),this.isActive=!1;const e=this._createMagnifierCanvas();this.container.appendChild(e),this.canvas=e,this._addEvent()}_createMagnifierCanvas(){const{magnifier:t}=this.options,e=document.createElement("canvas");return e.classList.add(`${v}-magnifier`),e.width=t.size,e.height=t.size,e.style.width=`${t.size}px`,e.style.height=`${t.size}px`,e}_addEvent(){this.container.addEventListener("mousemove",this._mousemove),document.addEventListener("keydown",this._handleKeyDown),document.addEventListener("keyup",this._handleKeyUp)}_removeEvent(){this.container.removeEventListener("mousemove",this._mousemove),document.removeEventListener("keydown",this._handleKeyDown),document.removeEventListener("keyup",this._handleKeyUp)}show(){this.options.magnifier.disabled||(this.isActive=!0,this.canvas.style.display="block")}hide(){this.options.magnifier.disabled||(this.isActive=!1,this.canvas.style.display="none")}_update(t){if(!this.isActive)return;const e=this.canvas.getContext("2d"),{magnifier:{size:n,zoom:o,borderColor:s}}=this.options,i=n/2,l=n/o;this.canvas.style.left=`${t.clientX-i}px`,this.canvas.style.top=`${t.clientY-i}px`;const a=this.draw.getPageList();let c=null,d=0,h=0;for(let u=0;u<a.length;u++){const g=a[u],T=g.getBoundingClientRect();if(t.clientX>=T.left&&t.clientX<=T.right&&t.clientY>=T.top&&t.clientY<=T.bottom){c=g;const P=c.width/T.width;d=(t.clientX-T.left)*P-l/2,h=(t.clientY-T.top)*P-l/2;break}}e.clearRect(0,0,n,n),!!c&&(e.save(),e.beginPath(),e.arc(i,i,i-1,0,Math.PI*2),e.closePath(),e.clip(),e.drawImage(c,Math.max(0,d),Math.max(0,h),l,l,0,0,n,n),e.restore(),e.beginPath(),e.arc(i,i,i-1,0,Math.PI*2),e.strokeStyle=s,e.lineWidth=2,e.stroke())}destroy(){this.canvas.remove(),this._removeEvent()}}class pr{constructor(t,e,n,o,s,i){L(this,"container");L(this,"pageContainer");L(this,"pageList");L(this,"ctxList");L(this,"pageNo");L(this,"renderCount");L(this,"pagePixelRatio");L(this,"mode");L(this,"options");L(this,"position");L(this,"zone");L(this,"elementList");L(this,"listener");L(this,"eventBus");L(this,"override");L(this,"i18n");L(this,"canvasEvent");L(this,"globalEvent");L(this,"cursor");L(this,"range");L(this,"margin");L(this,"background");L(this,"badge");L(this,"magnifier");L(this,"search");L(this,"group");L(this,"area");L(this,"underline");L(this,"strikeout");L(this,"highlight");L(this,"historyManager");L(this,"previewer");L(this,"imageParticle");L(this,"laTexParticle");L(this,"textParticle");L(this,"tableParticle");L(this,"tableTool");L(this,"tableOperate");L(this,"pageNumber");L(this,"lineNumber");L(this,"waterMark");L(this,"placeholder");L(this,"header");L(this,"footer");L(this,"hyperlinkParticle");L(this,"labelParticle");L(this,"dateParticle");L(this,"separatorParticle");L(this,"pageBreakParticle");L(this,"superscriptParticle");L(this,"subscriptParticle");L(this,"checkboxParticle");L(this,"radioParticle");L(this,"blockParticle");L(this,"listParticle");L(this,"lineBreakParticle");L(this,"whiteSpaceParticle");L(this,"control");L(this,"pageBorder");L(this,"workerManager");L(this,"scrollObserver");L(this,"selectionObserver");L(this,"imageObserver");L(this,"graffiti");L(this,"LETTER_REG");L(this,"WORD_LIKE_REG");L(this,"rowList");L(this,"pageRowList");L(this,"painterStyle");L(this,"painterOptions");L(this,"visiblePageNoList");L(this,"intersectionPageNo");L(this,"lazyRenderIntersectionObserver");L(this,"printModeData");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=o,this.eventBus=s,this.override=i,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new dr(e.locale),this.historyManager=new Ws(this),this.position=new Vs(this),this.zone=new gr(this),this.range=new ps(this),this.margin=new Ys(this),this.background=new Zs(this),this.badge=new Fr(this),this.magnifier=new Vr(this),this.search=new Qs(this),this.group=new Pr(this),this.area=new mr(this),this.underline=new Es(this),this.strikeout=new Cs(this),this.highlight=new Us(this),this.previewer=new rr(this),this.imageParticle=new Un(this),this.laTexParticle=new Cn(this),this.textParticle=new Ds(this),this.tableParticle=new ys(this),this.tableTool=new ws(this),this.tableOperate=new fr(this),this.pageNumber=new he(this),this.lineNumber=new Sr(this),this.waterMark=new As(this),this.placeholder=new ui(this),this.header=new xs(this,n.header),this.footer=new Lr(this,n.footer),this.hyperlinkParticle=new Hs(this),this.labelParticle=new Gs(this),this.dateParticle=new lr(this),this.separatorParticle=new Bs(this),this.pageBreakParticle=new ks(this),this.superscriptParticle=new Js,this.subscriptParticle=new vs,this.checkboxParticle=new qs(this),this.radioParticle=new tr(this),this.blockParticle=new Rr(this),this.listParticle=new Tr(this),this.lineBreakParticle=new ne(this),this.whiteSpaceParticle=new Mr(this),this.control=new js(this),this.pageBorder=new Xr(this),this.graffiti=new Wr(this,n.graffiti),this.scrollObserver=new bs(this),this.selectionObserver=new Ks(this),this.imageObserver=new hr,new Or(this),this.canvasEvent=new ms(this),this.cursor=new ts(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new Fs(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new sr(this),new Nr(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===R.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=$(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===R.EditorMode.PRINT&&this.setPrintData(),this.mode===R.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?void 0:e.mode)return this.area.isReadonly();switch(this.mode){case R.EditorMode.DESIGN:return!1;case R.EditorMode.READONLY:case R.EditorMode.PRINT:case R.EditorMode.GRAFFITI:return!0;case R.EditorMode.FORM:return!this.control.getIsRangeWithinControl();default:return!1}}isDisabled(){var s,i,l,a,c;if(this.mode===R.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if((s=this.getTd())==null?void 0:s.disabled)return!0;if(t===e){const d=n[t],h=n[t+1];return!!(((i=d==null?void 0:d.title)==null?void 0:i.disabled)&&((l=h==null?void 0:h.title)==null?void 0:l.disabled)&&d.titleId===h.titleId||((a=d==null?void 0:d.control)==null?void 0:a.disabled)&&((c=h==null?void 0:h.control)==null?void 0:c.disabled)&&d.controlId===h.controlId)}return n.slice(t+1,e+1).some(d=>{var h,u;return((h=d.title)==null?void 0:h.disabled)||((u=d.control)==null?void 0:u.disabled)})}isDesignMode(){return this.mode===R.EditorMode.DESIGN}isPrintMode(){return this.mode===R.EditorMode.PRINT}isGraffitiMode(){return this.mode===R.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===R.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===R.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:o}=t,i=this.getOriginalElementList()[e].trList[n].tdList[o],l=this.getTdPadding();return i.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===R.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:o,tdIndex:s}=e;return t[n].trList[o].tdList[s].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}getMagnifier(){return this.magnifier}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 i;const e=this.position.getPositionContext(),{index:n,trIndex:o,tdIndex:s}=e;return((i=t[n].trList)==null?void 0:i[o].tdList[s].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:o,isTable:s}=t;return s?this.getOriginalElementList()[e].trList[n].tdList[o]:null}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const{isSubmitHistory:s=!0}=e;Pt(t,{isHandleFirstElement:!1,editorOptions:this.options});let i=-1,l=this.control.getActiveControl();if(!l&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),l=this.control.getActiveControl()),l&&this.control.getIsRangeWithinControl())i=l.setValue(t,void 0,{isIgnoreDisabledRule:!0}),this.control.emitControlContentChange();else{const a=this.getElementList(),c=n===o,d=n+1;c||this.spliceElementList(a,d,o-n),this.spliceElementList(a,d,0,t),i=n+t.length;const h=a[d-1];t[0].listId&&h&&!h.listId&&(h==null?void 0:h.value)===y&&(!h.type||h.type===R.ElementType.TEXT)&&(a.splice(n,1),i-=1)}~i&&(this.range.setRange(i,i),this.render({curIndex:i,isSubmitHistory:s}))}appendElementList(t,e={}){if(!t.length)return;Pt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:o,isSubmitHistory:s=!0}=e;o?(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:s})}spliceElementList(t,e,n,o,s){var c,d,h,u,g,T,P,O;const{isIgnoreDeletedRule:i=!1}=s||{},{group:l,modeRule:a}=this.options;if(n>0){const M=e+n,S=t[M],X=S==null?void 0:S.listId;if(X&&((c=t[e-1])==null?void 0:c.listId)!==X){let N=M;for(;N<t.length;){const m=t[N];if(m.listId!==X||m.value===y)break;delete m.listId,delete m.listType,delete m.listStyle,N++}}if(!i&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const N=(d=this.getTd())==null?void 0:d.deletable;let m=M-1;for(;m>=e;){const I=t[m];((I==null?void 0:I.hide)||((h=I==null?void 0:I.control)==null?void 0:h.hide)||((u=I==null?void 0:I.area)==null?void 0:u.hide)||N!==!1&&((g=I==null?void 0:I.control)==null?void 0:g.deletable)!==!1&&(!I.controlId||this.mode!==R.EditorMode.FORM||!a[this.mode].controlDeletableDisabled)&&((T=I==null?void 0:I.title)==null?void 0:T.deletable)!==!1&&(l.deletable!==!1||!((P=I.groupIds)==null?void 0:P.length))&&(((O=I==null?void 0:I.area)==null?void 0:O.deletable)!==!1||(I==null?void 0:I.areaIndex)!==0))&&t.splice(m,1),m--}}else t.splice(e,n)}if(o==null?void 0:o.length)for(let M=0;M<o.length;M++)t.splice(e+M,0,o[M])}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}getBlockParticle(){return this.blockParticle}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,snapDomFunction:o}=t;e&&this.setPagePixelRatio(e);const s=this.mode,i=!!n&&s!==n;i&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled(),o&&await this.blockParticle.drawIframeToPage(this.pageList,o);const l=this.pageList.map(a=>a.toDataURL());return e&&this.setPagePixelRatio(null),i&&this.setMode(s),l}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===R.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===R.PageMode.PAGING){const{height:o}=this.options,s=this.getPagePixelRatio(),i=this.pageList[0];i.style.height=`${o}px`,i.height=o*s,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(R.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(),o=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((i,l)=>{i.width=n*e,i.height=o*e,i.style.width=`${n}px`,i.style.height=`${o}px`,i.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[l])});const s=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!s,curIndex:s==null?void 0:s.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((o,s)=>{o.width=e*t,o.height=n*t,this._initPageContext(this.ctxList[s])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),o=this.getWidth(),s=this.getHeight();this.container.style.width=`${o}px`,this.pageList.forEach((i,l)=>{i.width=o*n,i.height=s*n,i.style.width=`${o}px`,i.style.height=`${s}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(),o=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((s,i)=>{s.width=n*e,s.height=o*e,s.style.width=`${n}px`,s.style.height=`${o}px`,this._initPageContext(this.ctxList[i])}),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(s=>s.elementList)),this.blockParticle.update(),{header:this.getHeaderElementList(),main:n,footer:this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t),{extraPickAttrs:n}=t,o={header:st(e.header,{extraPickAttrs:n}),main:st(e.main,{extraPickAttrs:n,isClassifyArea:!0}),footer:st(e.footer,{extraPickAttrs:n}),graffiti:e.graffiti};return{version:Xt,data:o,options:$(this.options)}}setValue(t,e){const{header:n,main:o,footer:s}=$(t);if(!n&&!o&&!s)return;const{isSetCursor:i=!1}=e||{};[n,o,s].forEach(c=>{!c||Pt(c,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:o,footer:s}),this.historyManager.recovery();const a=i?(o==null?void 0:o.length)?o.length-1:0:void 0;a!==void 0&&this.range.setRange(a,a),this.render({curIndex:a,isSetCursor:i,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:o}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),o&&this.footer.setElementList(o)}_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(_t,R.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${v}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),o=document.createElement("canvas");o.style.width=`${e}px`,o.style.height=`${n}px`,o.style.display="block",o.style.backgroundColor="#ffffff",o.style.marginBottom=`${this.getPageGap()}px`,o.setAttribute("data-index",String(t)),this.pageContainer.append(o);const s=this.getPagePixelRatio();o.width=e*s,o.height=n*s,o.style.cursor="text";const i=o.getContext("2d");this._initPageContext(i),this.pageList.push(o),this.ctxList.push(i)}_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:o}=this.options,s=t.font||o,i=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${i*e}px ${s}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){var a;const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:o,scale:s}=this.options,i=t.size||e;let l=1;return i<12?l=i/12:i>30&&(l=1+(i-30)/30),n*l*((a=t.rowMargin)!=null?a:o)*s}computeRowList(t){var E,D,W,C,U,Q,w,K,p,G,H,x,k,A,Nt,Vt,ft,gt,rt,Mt,it,et;const{innerWidth:e,elementList:n,isPagingMode:o=!1,isFromTable:s=!1,startX:i=0,startY:l=0,pageHeight:a=0,mainOuterHeight:c=0,surroundElementList:d=[]}=t,{defaultSize:h,scale:u,imgCaption:g,table:{tdPadding:T},defaultTabWidth:P}=this.options,O=this.getDefaultBasicRowMarginHeight(),S=document.createElement("canvas").getContext("2d"),X=this.listParticle.computeListStyle(S,n),N=[];n.length&&N.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:((E=n==null?void 0:n[0])==null?void 0:E.rowFlex)||((D=n==null?void 0:n[1])==null?void 0:D.rowFlex)});let m=i,I=l,f=0,F,V=0,Z=0;for(let q=0;q<n.length;q++){const nt=N[N.length-1],b=n[q],Zt=this.getElementRowMargin(b),J={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},Ne=nt.offsetX||b.listId&&X.get(b.listId)||0,Tt=e-Ne,fe=nt.elementList.length===1;if(m+=fe?Ne:0,I+=fe&&nt.offsetY||0,(b.hide||((W=b.control)==null?void 0:W.hide)||((C=b.area)==null?void 0:C.hide))&&!this.isDesignMode()){const _=nt.elementList[nt.elementList.length-1];J.height=(_==null?void 0:_.metrics.height)||this.options.defaultSize*u,J.boundingBoxAscent=(_==null?void 0:_.metrics.boundingBoxAscent)||0,J.boundingBoxDescent=(_==null?void 0:_.metrics.boundingBoxDescent)||0}else if(b.type===R.ElementType.IMAGE||b.type===R.ElementType.LATEX)if(b.imgDisplay===R.ImageDisplay.SURROUND||b.imgDisplay===R.ImageDisplay.FLOAT_TOP||b.imgDisplay===R.ImageDisplay.FLOAT_BOTTOM)J.width=0,J.height=0,J.boundingBoxDescent=0;else{const _=b.width*u,lt=b.height*u;if(_>Tt){const tt=lt*Tt/_;b.width=Tt/u,b.height=tt/u,J.width=Tt,J.height=tt,J.boundingBoxDescent=tt}else J.width=_,J.height=lt,J.boundingBoxDescent=lt;if((U=b.imgCaption)==null?void 0:U.value){const tt=b.imgCaption.size||g.size,mt=(Q=b.imgCaption.top)!=null?Q:g.top,ie=(tt+mt)*u;J.boundingBoxAscent+=ie}}else if(b.type===R.ElementType.TABLE){const _=T[1]+T[3],lt=T[0]+T[2];if(b.pagingId){let Rt=q+1,St=0;for(;Rt<n.length;){const ct=n[Rt];if(ct.pagingId===b.pagingId){const dt=ct.trList.filter(Ct=>!Ct.pagingRepeat);b.trList.push(...dt),b.height+=ct.height,Rt++,St++}else break}St&&n.splice(q+1,St)}b.pagingIndex=(w=b.pagingIndex)!=null?w:0;const tt=b.trList,mt=lt+h+Zt*2/u;for(let Rt=0;Rt<tt.length;Rt++){const St=tt[Rt];St.height=Math.max(mt,St.minHeight||0),St.minHeight=St.height}this.tableParticle.computeRowColInfo(b);for(let Rt=0;Rt<tt.length;Rt++){const St=tt[Rt];for(let ct=0;ct<St.tdList.length;ct++){const dt=St.tdList[ct],Ct=this.computeRowList({innerWidth:(dt.width-_)*u,elementList:dt.value,isFromTable:!0,isPagingMode:o}),ht=Ct.reduce((Wt,wt)=>Wt+wt.height,0);dt.rowList=Ct;const Ot=ht/u+lt;if(dt.height<Ot){const Wt=Ot-dt.height,wt=tt[Rt+dt.rowspan-1];wt.height+=Wt,wt.tdList.forEach(At=>{At.height+=Wt,At.realHeight?At.realHeight+=Wt:At.realHeight=At.height})}let Ft=0,Et=0,Ut=0;for(;Ut<dt.rowspan;){const Wt=tt[Ut+Rt]||tt[Rt];Ft+=Wt.minHeight,Et+=Wt.height,Ut++}dt.realMinHeight=Ft,dt.realHeight=Et,dt.mainHeight=Ot}}const ie=this.tableParticle.getTrListGroupByCol(tt);for(let Rt=0;Rt<ie.length;Rt++){const St=ie[Rt];let ct=-1;for(let dt=0;dt<St.tdList.length;dt++){const Ct=St.tdList[dt],ht=Ct.realHeight,Ot=Ct.mainHeight,Ft=Ct.realMinHeight,Et=Ot<Ft?ht-Ft:ht-Ot;(!~ct||Et<ct)&&(ct=Et)}if(ct>0){const dt=tt[Rt];dt.height-=ct,dt.tdList.forEach(Ct=>{Ct.height-=ct,Ct.realHeight-=ct})}}this.tableParticle.computeRowColInfo(b);const Ni=this.tableParticle.getTableHeight(b),fi=this.tableParticle.getTableWidth(b);b.width=fi,b.height=Ni;const wl=fi*u,Tn=Ni*u;if(J.width=wl,J.height=Tn,J.boundingBoxDescent=Tn,J.boundingBoxAscent=-Zt,((K=n[q+1])==null?void 0:K.type)===R.ElementType.TABLE&&(J.boundingBoxAscent-=Zt),o){const Rt=this.getHeight(),St=this.getMainOuterHeight();let ct=St;for(let ht=0;ht<N.length;ht++){const Ot=N[ht],Ft=Ot.offsetY||0;Ot.height+ct+Ft>Rt||((p=N[ht-1])==null?void 0:p.isPageBreak)?ct=St+Ot.height+Ft:ct+=Ot.height+Ft}const dt=Zt*2*u,Ct=b.trList[0].height*u;if((ct+Ct+dt>Rt||b.pagingIndex!==0&&b.trList[0].pagingRepeat||((G=n[q-1])==null?void 0:G.type)===R.ElementType.PAGE_BREAK)&&(ct=St),ct+dt+Tn>Rt){const ht=b.trList;let Ot=0,Ft=0,Et=0;if(ht.length>1)for(let Ut=0;Ut<ht.length;Ut++){const Wt=ht[Ut],wt=Wt.height*u;if(ct+dt+Et+wt>Rt){const At=Wt.tdList.reduce((oe,ye)=>oe+ye.colspan,0);((H=b.colgroup)==null?void 0:H.length)!==At&&(Ft=0);break}else Ot=Ut+1,Ft=ht.length-Ot,Et+=wt}if(Ft){const Ut=ht.splice(Ot,Ft),Wt=Ut.reduce((Le,Pn)=>Le+Pn.height,0),wt=Wt*u,At=b.pagingId||j();b.pagingId=At,b.height-=Wt,J.height-=wt,J.boundingBoxDescent-=wt;const oe=$(b);oe.pagingId=At,oe.pagingIndex=b.pagingIndex+1;const ye=ht.filter(Le=>Le.pagingRepeat);if(ye.length){const Le=$(ye);Le.forEach(Pn=>Pn.id=j()),Ut.unshift(...Le)}oe.trList=Ut,oe.id=j(),this.spliceElementList(n,q+1,0,[oe])}}if(b.pagingId){const ht=this.position.getPositionContext();if(ht.isTable){let Ot=-1,Ft=-1,Et=q;for(;Et<n.length;){const Ut=n[Et];if(Ut.pagingId!==b.pagingId)break;const Wt=Ut.trList.findIndex(wt=>wt.id===ht.trId);if(~Wt){Ot=Et,Ft=Wt;break}Et++}~Ot&&(ht.index=Ot,ht.trIndex=Ft,this.position.setPositionContext(ht))}}}}else if(b.type===R.ElementType.SEPARATOR){const{separator:{lineWidth:_}}=this.options,lt=b.lineWidth||_;b.width=Tt/u,J.width=Tt,J.height=lt*u,J.boundingBoxAscent=-Zt,J.boundingBoxDescent=-Zt+J.height}else if(b.type===R.ElementType.PAGE_BREAK)b.width=Tt/u,J.width=Tt,J.height=h;else if(b.type===R.ElementType.RADIO||b.controlComponent===R.ControlComponent.RADIO){const{width:_,height:lt,gap:tt}=this.options.radio,mt=_+tt*2;b.width=mt,J.width=mt*u,J.height=lt*u}else if(b.type===R.ElementType.CHECKBOX||b.controlComponent===R.ControlComponent.CHECKBOX){const{width:_,height:lt,gap:tt}=this.options.checkbox,mt=_+tt*2;b.width=mt,J.width=mt*u,J.height=lt*u}else if(b.type===R.ElementType.TAB)J.width=P*u,J.height=h*u,J.boundingBoxDescent=0,J.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(S,S.font);else if(b.type===R.ElementType.BLOCK){if(!b.width)J.width=Tt;else{const _=b.width*u;J.width=Math.min(_,Tt)}J.height=b.height*u,J.boundingBoxDescent=J.height,J.boundingBoxAscent=0}else if(b.type===R.ElementType.LABEL){const{defaultSize:_,label:{defaultPadding:lt}}=this.options;S.font=this.getElementFont(b);const tt=this.textParticle.measureText(S,b);J.width=(tt.width+lt[1]+lt[3])*u,J.height=(b.size||_)*u,J.boundingBoxDescent=0,J.boundingBoxAscent=(lt[0]+tt.actualBoundingBoxAscent)*u}else{const _=b.size||h;(b.type===R.ElementType.SUPERSCRIPT||b.type===R.ElementType.SUBSCRIPT)&&(b.actualSize=Math.ceil(_*.6)),J.height=(b.actualSize||_)*u,S.font=this.getElementFont(b);const lt=this.textParticle.measureText(S,b);J.width=lt.width*u,b.letterSpacing&&(J.width+=b.letterSpacing*u);const tt=this.textParticle.measureBasisWord(S,b.font);J.boundingBoxAscent=tt.actualBoundingBoxAscent*u,J.boundingBoxDescent=tt.actualBoundingBoxDescent*u,b.type===R.ElementType.SUPERSCRIPT?J.boundingBoxAscent+=J.height/2:b.type===R.ElementType.SUBSCRIPT&&(J.boundingBoxDescent+=J.height/2)}const Mi=!b.hide&&(b.imgDisplay!==R.ImageDisplay.INLINE&&b.type===R.ElementType.IMAGE||b.type===R.ElementType.LATEX)?J.height+Zt:J.boundingBoxAscent+Zt,ge=Zt+J.boundingBoxAscent+J.boundingBoxDescent+Zt,yt=Object.assign(b,{metrics:J,left:0,style:this.getElementFont(b,u)});((x=yt.control)==null?void 0:x.minWidth)&&(yt.controlComponent&&(Z+=J.width),yt.controlComponent===R.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:nt,rowElement:yt,availableWidth:Tt,controlRealWidth:Z}),Z=0));const ot=n[q-1];let Oi=n[q+1],Ke=nt.width+J.width;if(this.options.wordBreak===R.WordBreak.BREAK_WORD&&(!(ot==null?void 0:ot.type)||(ot==null?void 0:ot.type)===R.ElementType.TEXT)&&(!b.type||b.type===R.ElementType.TEXT)){const _=`${(ot==null?void 0:ot.value)||""}${b.value}`;if(this.WORD_LIKE_REG.test(_)){const{width:tt,endElement:mt}=this.textParticle.measureWord(S,n,q),ie=tt*u;mt&&ie<=Tt&&(Ke+=ie,Oi=mt)}Ke+=this.textParticle.measurePunctuationWidth(S,Oi)*u}b.listId&&(b.listId!==F?V=0:b.value===y&&!b.listWrap&&V++),F=b.listId;const Si=this.position.setSurroundPosition({pageNo:f,rowElement:yt,row:nt,rowElementRect:{x:m,y:I,height:ge,width:J.width},availableWidth:Tt,surroundElementList:d});m=Si.x,Ke+=Si.rowIncreaseWidth,m+=J.width;const Xi=b.type===R.ElementType.SEPARATOR||b.type===R.ElementType.TABLE||(ot==null?void 0:ot.type)===R.ElementType.TABLE||(ot==null?void 0:ot.type)===R.ElementType.BLOCK||b.type===R.ElementType.BLOCK||(ot==null?void 0:ot.imgDisplay)===R.ImageDisplay.INLINE||b.imgDisplay===R.ImageDisplay.INLINE||(ot==null?void 0:ot.listId)!==b.listId||(ot==null?void 0:ot.areaId)!==b.areaId&&!((k=b.area)==null?void 0:k.hide)||((A=b.control)==null?void 0:A.flexDirection)===R.FlexDirection.COLUMN&&(b.controlComponent===R.ControlComponent.CHECKBOX||b.controlComponent===R.ControlComponent.RADIO)&&(ot==null?void 0:ot.controlComponent)===R.ControlComponent.VALUE||q!==0&&b.value===y&&!((Nt=b.area)==null?void 0:Nt.hide),Ii=Ke>Tt,Ln=Xi||Ii;if(Ln){const _={width:J.width,height:ge,startIndex:q,elementList:[yt],ascent:Mi,rowIndex:nt.rowIndex+1,rowFlex:((Vt=n[q])==null?void 0:Vt.rowFlex)||((ft=n[q+1])==null?void 0:ft.rowFlex),isPageBreak:b.type===R.ElementType.PAGE_BREAK};if(yt.controlComponent!==R.ControlComponent.PREFIX&&((gt=yt.control)==null?void 0:gt.indentation)===R.ControlIndentation.VALUE_START){const lt=nt.elementList.findIndex(tt=>tt.controlId===yt.controlId&&tt.controlComponent!==R.ControlComponent.PREFIX);if(~lt){const mt=this.position.computeRowPosition({row:nt,innerWidth:this.getInnerWidth()})[lt];mt&&(_.offsetX=mt.coordinate.leftTop[0])}}b.listId&&(_.isList=!0,_.offsetX=X.get(b.listId),_.listIndex=V),_.offsetY=!s&&((rt=b.area)==null?void 0:rt.top)&&b.areaId!==((Mt=n[q-1])==null?void 0:Mt.areaId)?b.area.top*u:0,N.push(_)}else nt.width+=J.width,q===0&&($t(n[1])||!!((it=n[1])==null?void 0:it.areaId))?(nt.height=O,nt.ascent=O):nt.height<ge&&(nt.height=ge,nt.ascent=Mi),nt.elementList.push(yt);if((Ln||q===n.length-1)&&(nt.isWidthNotEnough=Ii&&!Xi,!nt.isSurround&&((ot==null?void 0:ot.rowFlex)===R.RowFlex.JUSTIFY||(ot==null?void 0:ot.rowFlex)===R.RowFlex.ALIGNMENT&&nt.isWidthNotEnough))){const _=((et=nt.elementList[0])==null?void 0:et.value)===y?nt.elementList.slice(1):nt.elementList,lt=(Tt-nt.width)/(_.length-1);for(let tt=0;tt<_.length-1;tt++){const mt=_[tt];mt.metrics.width+=lt}nt.width=Tt}if(Ln){m=i,I+=nt.height,o&&!s&&a&&(I-l+c+ge>a||b.type===R.ElementType.PAGE_BREAK)&&(I=l,ko(d,f),f+=1),yt.left=0;const _=N[N.length-1];m=this.position.setSurroundPosition({pageNo:f,rowElement:yt,row:_,rowElementRect:{x:m,y:I,height:ge,width:J.width},availableWidth:Tt,surroundElementList:d}).x,m+=J.width}}return N}_computePageList(){var a;const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,o=this.getHeight(),s=this.getMainOuterHeight();let i=s,l=0;if(e===R.PageMode.CONTINUITY){t[0]=this.rowList,i+=this.rowList.reduce((u,g)=>u+g.height+(g.offsetY||0),0);const c=this.getPagePixelRatio(),d=this.pageList[0],h=Number(d.style.height.replace("px",""));if(i>h)d.style.height=`${i}px`,d.height=i*c;else{const u=i<o?o:i;d.style.height=`${u}px`,d.height=u*c}this._initPageContext(this.ctxList[0])}else for(let c=0;c<this.rowList.length;c++){const d=this.rowList[c],h=d.offsetY||0;if(d.height+h+i>o||((a=this.rowList[c-1])==null?void 0:a.isPageBreak)){if(Number.isInteger(n)&&l>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}i=s+d.height+h,t.push([d]),l++}else i+=d.height+h,t[l].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:o,elementList:s}=e,i=this.getDefaultBasicRowMarginHeight(),l=this.getHighlightMarginHeight();for(let a=0;a<n.length;a++){const c=n[a];for(let d=0;d<c.elementList.length;d++){const h=c.elementList[d],u=c.elementList[d-1],g=h.highlight||this.control.getControlHighlight(s,c.startIndex+d);if(g){u&&u.highlight&&u.highlight!==h.highlight&&this.highlight.render(t);const{coordinate:{leftTop:[T,P]}}=o[c.startIndex+d],O=h.left||0;this.highlight.recordFillInfo(t,T-O,P+i-l,h.metrics.width+O,c.height-2*i+2*l,g)}else(u==null?void 0:u.highlight)&&this.highlight.render(t)}this.highlight.render(t)}}drawRow(t,e){var m,I,f,F,V,Z,E,D,W;this._drawHighlight(t,e);const{scale:n,table:{tdPadding:o},group:s,lineBreak:i,whiteSpace:l}=this.options,{rowList:a,pageNo:c,elementList:d,positionList:h,startIndex:u,zone:g,isDrawLineBreak:T=!i.disabled,isDrawWhiteSpace:P=!l.disabled}=e,O=this.isPrintMode(),M=this.isGraffitiMode(),{isCrossRowCol:S,tableId:X}=this.range.getRange();let N=u;for(let C=0;C<a.length;C++){const U=a[C],Q={x:0,y:0,width:0,height:0};let w=null;for(let K=0;K<U.elementList.length;K++){const p=U.elementList[K],G=p.metrics,{ascent:H,coordinate:{leftTop:[x,k]}}=h[U.startIndex+K],A=U.elementList[K-1];if((p.hide||((m=p.control)==null?void 0:m.hide)||((I=p.area)==null?void 0:I.hide))&&!this.isDesignMode())this.textParticle.complete();else if(p.type===R.ElementType.IMAGE)this.textParticle.complete(),p.imgDisplay!==R.ImageDisplay.SURROUND&&p.imgDisplay!==R.ImageDisplay.FLOAT_TOP&&p.imgDisplay!==R.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,p,x,k+H);else if(p.type===R.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,p,x,k+H);else if(p.type===R.ElementType.TABLE)S&&(Q.x=x,Q.y=k,w=p),this.tableParticle.render(t,p,x,k);else if(p.type===R.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,p,x,k+H);else if(p.type===R.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,p,x,k+H);else if(p.type===R.ElementType.DATE){const gt=U.elementList[K+1];(!A||A.dateId!==p.dateId)&&this.textParticle.complete(),this.textParticle.record(t,p,x,k+H),(!gt||gt.dateId!==p.dateId)&&this.textParticle.complete()}else p.type===R.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,p,x,k+H)):p.type===R.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,p,x,k+H)):p.type===R.ElementType.SEPARATOR?this.separatorParticle.render(t,p,x,k):p.type===R.ElementType.PAGE_BREAK?this.mode!==R.EditorMode.CLEAN&&!O&&this.pageBreakParticle.render(t,p,x,k):p.type===R.ElementType.CHECKBOX||p.controlComponent===R.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x,y:k+H,index:K,row:U})):p.type===R.ElementType.RADIO||p.controlComponent===R.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x,y:k+H,index:K,row:U})):p.type===R.ElementType.TAB?this.textParticle.complete():p.rowFlex===R.RowFlex.ALIGNMENT||p.rowFlex===R.RowFlex.JUSTIFY?(this.textParticle.record(t,p,x,k+H),this.textParticle.complete()):p.type===R.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,c,p,x,k+H)):(p.left&&this.textParticle.complete(),this.textParticle.record(t,p,x,k+H),(p.width||p.letterSpacing||Ui.test(p.value))&&this.textParticle.complete());if(T&&!O&&this.mode!==R.EditorMode.CLEAN&&!U.isWidthNotEnough&&K===U.elementList.length-1&&this.lineBreakParticle.render(t,p,x,k+U.height/2),P&&Qi.test(p.value)&&this.whiteSpaceParticle.render(t,p,x,k+U.height/2),(f=p.control)==null?void 0:f.border){((F=A==null?void 0:A.control)==null?void 0:F.border)&&A.controlId!==p.controlId&&this.control.drawBorder(t);const gt=this.getElementRowMargin(p);this.control.recordBorderInfo(x,k+gt,p.metrics.width,U.height-2*gt)}else((V=A==null?void 0:A.control)==null?void 0:V.border)&&this.control.drawBorder(t);if(p.underline||((Z=p.control)==null?void 0:Z.underline)){(A==null?void 0:A.type)===R.ElementType.SUBSCRIPT&&p.type!==R.ElementType.SUBSCRIPT&&this.underline.render(t);const gt=this.getElementRowMargin(p),rt=p.left||0;let Mt=0;p.type===R.ElementType.SUBSCRIPT&&(Mt=this.subscriptParticle.getOffsetY(p));const it=((E=p.control)==null?void 0:E.underline)?this.options.underlineColor:p.color;this.underline.recordFillInfo(t,x-rt,k+U.height-gt+Mt,G.width+rt,0,it,(D=p.textDecoration)==null?void 0:D.style)}else((A==null?void 0:A.underline)||((W=A==null?void 0:A.control)==null?void 0:W.underline))&&this.underline.render(t);if(p.strikeout){if(!p.type||bt.includes(p.type)){A&&(A.type===R.ElementType.SUBSCRIPT&&p.type!==R.ElementType.SUBSCRIPT||A.type===R.ElementType.SUPERSCRIPT&&p.type!==R.ElementType.SUPERSCRIPT||this.getElementSize(A)!==this.getElementSize(p))&&this.strikeout.render(t);const gt=this.textParticle.measureBasisWord(t,this.getElementFont(p));let rt=k+H+gt.actualBoundingBoxDescent*n-G.height/2;p.type===R.ElementType.SUBSCRIPT?rt+=this.subscriptParticle.getOffsetY(p):p.type===R.ElementType.SUPERSCRIPT&&(rt+=this.superscriptParticle.getOffsetY(p)),this.strikeout.recordFillInfo(t,x,rt,G.width)}}else(A==null?void 0:A.strikeout)&&this.strikeout.render(t);const{zone:Nt,startIndex:Vt,endIndex:ft}=this.range.getRange();if(Nt===g&&Vt!==ft&&Vt<=N&&N<=ft){const gt=this.position.getPositionContext();if(!gt.isTable&&!p.tdId||gt.tdId===p.tdId)if(Vt===N){const rt=d[Vt+1];rt&&rt.value===y&&(Q.x=x+G.width,Q.y=k,Q.height=U.height,Q.width+=this.options.rangeMinWidth)}else{let rt=G.width;rt===0&&U.elementList.length===1&&(rt=this.options.rangeMinWidth),Q.width||(Q.x=x,Q.y=k,Q.height=U.height),Q.width+=rt}}if(!s.disabled&&p.groupIds&&this.group.recordFillInfo(p,x,k,G.width,U.height),N++,p.type===R.ElementType.TABLE&&!p.hide){const gt=o[1]+o[3];for(let rt=0;rt<p.trList.length;rt++){const Mt=p.trList[rt];for(let it=0;it<Mt.tdList.length;it++){const et=Mt.tdList[it];this.drawRow(t,{elementList:et.value,positionList:et.positionList,rowList:et.rowList,pageNo:c,startIndex:0,innerWidth:(et.width-gt)*n,zone:g,isDrawLineBreak:T})}}}}if(U.isList&&this.listParticle.drawListStyle(t,U,h[U.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!O&&!M){if(Q.width&&Q.height){const{x:K,y:p,width:G,height:H}=Q;this.range.render(t,K,p,G,H)}if(S&&w&&w.id===X){const{coordinate:{leftTop:[K,p]}}=h[U.startIndex];this.tableParticle.drawRange(t,w,K,p)}}}}_drawFloat(t,e){const{scale:n}=this.options,o=this.position.getFloatPositionList(),{imgDisplays:s,pageNo:i}=e;for(let l=0;l<o.length;l++){const a=o[l],c=a.element;if((i===a.pageNo||a.zone===R.EditorZone.HEADER||a.zone==R.EditorZone.FOOTER)&&c.imgDisplay&&s.includes(c.imgDisplay)&&c.type===R.ElementType.IMAGE){const d=c.imgFloatPosition;this.imageParticle.render(t,c,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 S,X,N;const{elementList:e,positionList:n,rowList:o,pageNo:s}=t,{inactiveAlpha:i,pageMode:l,header:a,footer:c,pageNumber:d,lineNumber:h,pageBorder:u}=this.options,g=this.mode===R.EditorMode.PRINT,T=l===R.PageMode.CONTINUITY,P=this.getInnerWidth(),O=this.ctxList[s];O.globalAlpha=this.zone.isMainActive()?1:i,this._clearPage(s),(!g||!((S=this.options.modeRule[R.EditorMode.PRINT])==null?void 0:S.backgroundDisabled))&&this.background.render(O,s),g||this.area.render(O,s),!T&&this.options.watermark.data&&this.options.watermark.layer===R.WatermarkLayer.BOTTOM&&this.waterMark.render(O,s),g||this.margin.render(O,s),this._drawFloat(O,{pageNo:s,imgDisplays:[R.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(O,s);const M=(X=o[0])==null?void 0:X.startIndex;this.drawRow(O,{elementList:e,positionList:n,rowList:o,pageNo:s,startIndex:M,innerWidth:P,zone:R.EditorZone.MAIN}),this.getIsPagingMode()&&(a.disabled||this.header.render(O,s),d.disabled||this.pageNumber.render(O,s),c.disabled||this.footer.render(O,s)),this._drawFloat(O,{pageNo:s,imgDisplays:[R.ImageDisplay.FLOAT_TOP,R.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(O,s),this.elementList.length<=1&&!((N=this.elementList[0])==null?void 0:N.listId)&&this.placeholder.render(O),h.disabled||this.lineNumber.render(O,s),u.disabled||this.pageBorder.render(O),this.badge.render(O,s),this.isGraffitiMode()&&this.graffiti.render(O,s),!T&&this.options.watermark.data&&this.options.watermark.layer===R.WatermarkLayer.TOP&&this.waterMark.render(O,s)}_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(o=>{if(o.isIntersecting){const s=Number(o.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[s],pageNo:s})}})}),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:o=!0,isSetCursor:s=!0,isCompute:i=!0,isLazy:l=!0,isInit:a=!1,isSourceHistory:c=!1,isFirstRender:d=!1}=t||{};let{curIndex:h}=t||{};const u=this.getInnerWidth(),g=this.getIsPagingMode(),T=this.pageRowList.length;if(i){this.position.setFloatPositionList([]),g&&(e.disabled||this.header.compute(),n.disabled||this.footer.compute());const M=this.getMargins(),S=this.getHeight(),X=this.header.getExtraHeight(),N=this.getMainOuterHeight(),m=M[3],I=M[0]+X,f=on(this.elementList);if(this.rowList=this.computeRowList({startX:m,startY:I,pageHeight:S,mainOuterHeight:N,isPagingMode:g,innerWidth:u,surroundElementList:f,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 M=0;M<this.pageRowList.length;M++)this.pageList[M]||this._createPage(M);const P=this.pageRowList.length,O=this.pageList.length;if(O>P){const M=O-P;this.ctxList.splice(P,M),this.pageList.splice(P,M).forEach(S=>S.remove())}l&&g?this._lazyRender():this._immediateRender(),s?h=this.setCursor(h):this.range.getIsSelection()&&this.cursor.focus(),(o&&!d||h!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(h),Be(()=>{this.range.setRangeStyle(),i&&this.control.getActiveControl()&&this.control.reAwakeControl(),i&&!this.isReadonly()&&this.position.getPositionContext().isTable&&this.tableTool.render(),i&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),T!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(o||c)&&!a&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"))})}setCursor(t){var s;const e=this.position.getPositionContext(),n=this.position.getPositionList();if(e.isTable){const{index:i,trIndex:l,tdIndex:a}=e,d=(s=this.getOriginalElementList()[i].trList)==null?void 0:s[l].tdList[a].positionList;t===void 0&&d&&(t=d.length-1);const h=d==null?void 0:d[t];this.position.setCursorPosition(h||null)}else this.position.setCursorPosition(t!==void 0?n[t]:null);let o=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const l=this.getElementList()[t];if(qi.includes(l.type)){o=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(l,a)}}return this.cursor.drawCursor({isShow:o}),t}submitHistory(t){const e=this.position.getPositionContext(),n=nn(this.elementList),o=nn(this.header.getElementList()),s=nn(this.footer.getElementList()),i=$(this.range.getRange()),l=this.pageNo,a=$(e),c=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(c),this.setPageNo(l),this.position.setPositionContext($(a)),this.header.setElementList($(o)),this.footer.setElementList($(s)),this.elementList=$(n),this.range.replaceRange($(i)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){var t;this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent(),this.workerManager.destroy(),this.magnifier.destroy(),(t=this.lazyRenderIntersectionObserver)==null||t.disconnect()}clearSideEffect(){this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}}class gi{constructor(t){L(this,"executeMode");L(this,"executeCut");L(this,"executeCopy");L(this,"executePaste");L(this,"executeSelectAll");L(this,"executeBackspace");L(this,"executeSetRange");L(this,"executeReplaceRange");L(this,"executeSetPositionContext");L(this,"executeForceUpdate");L(this,"executeBlur");L(this,"executeHideCursor");L(this,"executeUndo");L(this,"executeRedo");L(this,"executePainter");L(this,"executeApplyPainterStyle");L(this,"executeFormat");L(this,"executeFont");L(this,"executeSize");L(this,"executeSizeAdd");L(this,"executeSizeMinus");L(this,"executeBold");L(this,"executeItalic");L(this,"executeUnderline");L(this,"executeStrikeout");L(this,"executeSuperscript");L(this,"executeSubscript");L(this,"executeColor");L(this,"executeHighlight");L(this,"executeTitle");L(this,"executeList");L(this,"executeRowFlex");L(this,"executeRowMargin");L(this,"executeInsertTable");L(this,"executeInsertTableTopRow");L(this,"executeInsertTableBottomRow");L(this,"executeInsertTableLeftCol");L(this,"executeInsertTableRightCol");L(this,"executeDeleteTableRow");L(this,"executeDeleteTableCol");L(this,"executeDeleteTable");L(this,"executeMergeTableCell");L(this,"executeCancelMergeTableCell");L(this,"executeSplitVerticalTableCell");L(this,"executeSplitHorizontalTableCell");L(this,"executeTableTdVerticalAlign");L(this,"executeTableBorderType");L(this,"executeTableBorderColor");L(this,"executeTableTdBorderType");L(this,"executeTableTdSlashType");L(this,"executeTableTdBackgroundColor");L(this,"executeTableSelectAll");L(this,"executeImage");L(this,"executeHyperlink");L(this,"executeDeleteHyperlink");L(this,"executeCancelHyperlink");L(this,"executeEditHyperlink");L(this,"executeSeparator");L(this,"executePageBreak");L(this,"executeAddWatermark");L(this,"executeDeleteWatermark");L(this,"executeSearch");L(this,"executeSearchNavigatePre");L(this,"executeSearchNavigateNext");L(this,"executeReplace");L(this,"executePrint");L(this,"executeReplaceImageElement");L(this,"executeSaveAsImageElement");L(this,"executeSetImageCrop");L(this,"executeSetImageCaption");L(this,"executeChangeImageDisplay");L(this,"executePageMode");L(this,"executePageScale");L(this,"executePageScaleRecovery");L(this,"executePageScaleMinus");L(this,"executePageScaleAdd");L(this,"executePaperSize");L(this,"executePaperDirection");L(this,"executeSetPaperMargin");L(this,"executeSetMainBadge");L(this,"executeSetAreaBadge");L(this,"executeInsertElementList");L(this,"executeInsertArea");L(this,"executeSetAreaValue");L(this,"executeSetAreaProperties");L(this,"executeDeleteArea");L(this,"executeLocationArea");L(this,"executeClearGraffiti");L(this,"executeAppendElementList");L(this,"executeUpdateElementById");L(this,"executeDeleteElementById");L(this,"executeSetValue");L(this,"executeRemoveControl");L(this,"executeTranslate");L(this,"executeSetLocale");L(this,"executeLocationCatalog");L(this,"executeWordTool");L(this,"executeSetHTML");L(this,"executeSetGroup");L(this,"executeDeleteGroup");L(this,"executeLocationGroup");L(this,"executeSetZone");L(this,"executeSetControlValue");L(this,"executeSetControlValueList");L(this,"executeSetControlExtension");L(this,"executeSetControlExtensionList");L(this,"executeSetControlProperties");L(this,"executeSetControlPropertiesList");L(this,"executeSetControlHighlight");L(this,"executeLocationControl");L(this,"executeInsertControl");L(this,"executeJumpControl");L(this,"executeUpdateOptions");L(this,"executeInsertTitle");L(this,"executeFocus");L(this,"executeComputeElementListHeight");L(this,"getCatalog");L(this,"getImage");L(this,"getOptions");L(this,"getValue");L(this,"getValueAsync");L(this,"getAreaValue");L(this,"getHTML");L(this,"getText");L(this,"getWordCount");L(this,"getCursorPosition");L(this,"getRemainingContentHeight");L(this,"getRange");L(this,"getRangeText");L(this,"getRangeContext");L(this,"getRangeRow");L(this,"getRangeParagraph");L(this,"getKeywordRangeList");L(this,"getKeywordContext");L(this,"getPaperMargin");L(this,"getSearchNavigateInfo");L(this,"getLocale");L(this,"getGroupIds");L(this,"getControlValue");L(this,"getControlList");L(this,"getContainer");L(this,"getTitleValue");L(this,"getPositionContextByEvent");L(this,"getElementById");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.executeDeleteArea=t.deleteArea.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.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 Li(r,t){let e=0;for(let n=1;n<t;n++){const o=r[n],s=r[n-1];(o.value===y&&!o.listWrap&&!o.listId||o.listId!==(s==null?void 0:s.listId)&&s.value!==y||o.titleId!==(s==null?void 0:s.titleId)&&s.value!==y)&&e++}return e}function Zr(r,t){return r===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:r===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:r===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${r}px`,height:`${t}px`}}async function Ur(r,t){const{width:e,height:n,direction:o=R.PaperDirection.VERTICAL,iframeInfoList:s=[]}=t,i=document.createElement("iframe");i.style.visibility="hidden",i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.width="0",i.style.height="0",i.style.border="none",document.body.append(i);const l=i.contentWindow,a=l.document;a.open();const c=document.createElement("div"),d=Zr(e,n);r.forEach((g,T)=>{const P=document.createElement("div");P.style.position="relative",P.style.width=o===R.PaperDirection.HORIZONTAL?d.height:d.width,P.style.height=o===R.PaperDirection.HORIZONTAL?d.width:d.height;const O=document.createElement("img");O.style.width="100%",O.style.height="100%",O.style.position="absolute",O.style.left="0",O.style.top="0",O.src=g,P.append(O),(s[T]||[]).forEach(S=>{const X=document.createElement("iframe");if(X.style.position="absolute",X.style.left=`${S.x}px`,X.style.top=`${S.y}px`,X.style.width=`${S.width}px`,X.style.height=`${S.height}px`,X.style.border="none",S.src)X.src=S.src;else if(S.srcdoc){const N=`
|
|
89
89
|
<script>
|
|
90
90
|
if (!window.__CUSTOM_CANVAS_EDITOR_LOAD_HOOK__) {
|
|
91
91
|
window.postMessage({ type: '__LOADED_TO_CANVAS_EDITOR__' }, '*')
|
|
@@ -98,5 +98,5 @@ ${P||`${M+1}.`}${t(O)}${S?`
|
|
|
98
98
|
@page {
|
|
99
99
|
margin: 0;
|
|
100
100
|
size: ${d.size} ${o===R.PaperDirection.HORIZONTAL?"landscape":"portrait"};
|
|
101
|
-
}`;h.append(document.createTextNode(u)),a.write(`${h.outerHTML}${c.innerHTML}`),s.length&&await Zr(a),setTimeout(async()=>{l.print(),a.close(),window.addEventListener("mouseover",()=>{i==null||i.remove()},{once:!0})})}async function Zr(r){const e=Array.from(r.querySelectorAll("iframe")).map(n=>new Promise(s=>{var i;n.srcdoc?(i=n.contentWindow)==null||i.addEventListener("message",l=>{l.data.type==="__LOADED_TO_CANVAS_EDITOR__"&&s(!0)}):s(!0)}));await Promise.allSettled(e)}class Ur{constructor(t){L(this,"draw");L(this,"range");L(this,"position");L(this,"historyManager");L(this,"canvasEvent");L(this,"options");L(this,"control");L(this,"workerManager");L(this,"searchManager");L(this,"i18n");L(this,"zone");L(this,"tableOperate");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()||$o(this.canvasEvent,t)}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.draw.getElementList(),{startIndex:n,endIndex:o}=this.range.getRange(),s=n===o;if(s&&e[n].value===y&&n===0)return;s?this.draw.spliceElementList(e,n,1):this.draw.spliceElementList(e,n+1,o-n);const i=s?n-1:n;this.range.setRange(i,i),this.draw.render({curIndex:i})}setRange(t,e,n,o,s,i,l){if(t<0||e<0||e<t)return;this.range.setRange(t,e,n,o,s,i,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:o}=t,s=this.draw.getOriginalElementList();if(e){const i=s.findIndex(d=>d.id===e);if(!~i)return;const a=s[i].trList[n],c=a.tdList[o];this.position.setPositionContext({isTable:!0,index:i,trIndex:n,tdIndex:o,tdId:c.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(o=>{Dt.forEach(i=>{const l=i;n[l]===void 0&&Reflect.set(n,l,o[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 o=this.range.getSelectionElementList();let s={},i=[];if(o==null?void 0:o.length)i=o,s={isSetCursor:!1};else{const{endIndex:l}=this.range.getRange(),c=this.draw.getElementList()[l];(c==null?void 0:c.value)===y&&(i.push(c),s={curIndex:l})}!i.length||(i.forEach(l=>{Dt.forEach(a=>{delete l[a]})}),this.draw.render(s))}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const s=this.range.getSelectionElementList();if(s==null?void 0:s.length)s.forEach(i=>{i.font=t}),this.draw.render({isSetCursor:!1});else{let i=!0;const{endIndex:l}=this.range.getRange(),c=this.draw.getElementList()[l];this.range.setDefaultStyle({font:t}),(c==null?void 0:c.value)===y?c.font=t:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:s,maxSize:i,defaultSize:l}=this.options;if(t<s||t>i)return;let a={},c=[];const d=this.range.getTextLikeSelectionElementList();if(d==null?void 0:d.length)c=d,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange(),T=this.draw.getElementList()[u];this.range.setDefaultStyle({size:t}),(T==null?void 0:T.value)===y?(c.push(T),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let h=!1;c.forEach(u=>{!u.size&&t===l||u.size&&u.size===t||(u.size=t,h=!0)}),h&&this.draw.render(a)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:o,maxSize:s}=this.options,i=this.range.getTextLikeSelectionElementList();let l={},a=[];if(i==null?void 0:i.length)a=i,l={isSetCursor:!1};else{const{endIndex:d}=this.range.getRange(),u=this.draw.getElementList()[d],g=this.range.getDefaultStyle(),T=(g==null?void 0:g.size)||u.size||o;this.range.setDefaultStyle({size:T+2>s?s:T+2}),(u==null?void 0:u.value)===y?(a.push(u),l={curIndex:d}):this.draw.render({curIndex:d,isCompute:!1,isSubmitHistory:!1})}if(!a.length)return;let c=!1;a.forEach(d=>{d.size||(d.size=o),!(d.size>=s)&&(d.size+2>s?d.size=s:d.size+=2,c=!0)}),c&&this.draw.render(l)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:o,minSize:s}=this.options,i=this.range.getTextLikeSelectionElementList();let l={},a=[];if(i==null?void 0:i.length)a=i,l={isSetCursor:!1};else{const{endIndex:d}=this.range.getRange(),u=this.draw.getElementList()[d],g=this.range.getDefaultStyle(),T=(g==null?void 0:g.size)||u.size||o;this.range.setDefaultStyle({size:T-2<s?s:T-2}),(u==null?void 0:u.value)===y?(a.push(u),l={curIndex:d}):this.draw.render({curIndex:d,isCompute:!1,isSubmitHistory:!1})}if(!a.length)return;let c=!1;a.forEach(d=>{d.size||(d.size=o),!(d.size<=s)&&(d.size-2<s?d.size=s:d.size-=2,c=!0)}),c&&this.draw.render(l)}bold(t){var s;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(o==null?void 0:o.length){const i=o.findIndex(l=>!l.bold);o.forEach(l=>{l.bold=!!~i}),this.draw.render({isSetCursor:!1})}else{let i=!0;const{endIndex:l}=this.range.getRange(),c=this.draw.getElementList()[l];this.range.setDefaultStyle({bold:c.bold?!1:!((s=this.range.getDefaultStyle())==null?void 0:s.bold)}),(c==null?void 0:c.value)===y?c.bold=!c.bold:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}italic(t){var s;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(o==null?void 0:o.length){const i=o.findIndex(l=>!l.italic);o.forEach(l=>{l.italic=!!~i}),this.draw.render({isSetCursor:!1})}else{let i=!0;const{endIndex:l}=this.range.getRange(),c=this.draw.getElementList()[l];this.range.setDefaultStyle({italic:c.italic?!1:!((s=this.range.getDefaultStyle())==null?void 0:s.italic)}),(c==null?void 0:c.value)===y?c.italic=!c.italic:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}underline(t,e){var i;const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const s=this.range.getSelectionElementList();if(s==null?void 0:s.length){const l=s.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!Gi(a.textDecoration,t));s.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?void 0:d.underline)?!1:!((i=this.range.getDefaultStyle())==null?void 0:i.underline)}),(d==null?void 0:d.value)===y?d.underline=!d.underline:l=!1,this.draw.render({isSubmitHistory:l,curIndex:a,isCompute:!1})}}strikeout(t){var s;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(o==null?void 0:o.length){const i=o.findIndex(l=>!l.strikeout);o.forEach(l=>{l.strikeout=!!~i}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let i=!0;const{endIndex:l}=this.range.getRange(),c=this.draw.getElementList()[l];this.range.setDefaultStyle({strikeout:c.strikeout?!1:!((s=this.range.getDefaultStyle())==null?void 0:s.strikeout)}),(c==null?void 0:c.value)===y?c.strikeout=!c.strikeout:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(!o)return;const s=o.findIndex(i=>i.type===R.ElementType.SUPERSCRIPT);o.forEach(i=>{~s?i.type===R.ElementType.SUPERSCRIPT&&(i.type=R.ElementType.TEXT,delete i.actualSize):(!i.type||i.type===R.ElementType.TEXT||i.type===R.ElementType.SUBSCRIPT)&&(i.type=R.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(!o)return;const s=o.findIndex(i=>i.type===R.ElementType.SUBSCRIPT);o.forEach(i=>{~s?i.type===R.ElementType.SUBSCRIPT&&(i.type=R.ElementType.TEXT,delete i.actualSize):(!i.type||i.type===R.ElementType.TEXT||i.type===R.ElementType.SUPERSCRIPT)&&(i.type=R.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 s=this.range.getSelectionElementList();if(s==null?void 0:s.length)s.forEach(i=>{t?i.color=t:delete i.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let i=!0;const{endIndex:l}=this.range.getRange(),c=this.draw.getElementList()[l];this.range.setDefaultStyle({color:t||void 0}),(c==null?void 0:c.value)===y?t?c.color=t:delete c.color:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const s=this.range.getSelectionElementList();if(s==null?void 0:s.length)s.forEach(i=>{t?i.highlight=t:delete i.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let i=!0;const{endIndex:l}=this.range.getRange(),c=this.draw.getElementList()[l];this.range.setDefaultStyle({highlight:t||void 0}),(c==null?void 0:c.value)===y?t?c.highlight=t:delete c.highlight:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const s=this.draw.getElementList(),i=n===o?this.range.getRangeParagraphElementList():s.slice(n+1,o+1);if(!i||!i.length)return;const l=j(),a=this.draw.getOptions().title;i.forEach(h=>{!h.type&&h.value===y||(t?(h.level=t,h.titleId=l,Ye(h)&&(h.size=a[Dn[t]],h.bold=!0)):h.titleId&&(delete h.titleId,delete h.title,delete h.level,delete h.size,delete h.bold))});const c=n===o,d=c?o:n;this.draw.render({curIndex:d,isSetCursor:c})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const s=this.range.getRangeRowElementList();if(!s)return;s.forEach(a=>{a.rowFlex=t});const i=n===o,l=i?o:n;this.draw.render({curIndex:l,isSetCursor:i})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const s=this.range.getRangeRowElementList();if(!s)return;s.forEach(a=>{a.rowMargin=t});const i=n===o,l=i?o:n;this.draw.render({curIndex:l,isSetCursor:i})}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:o}=t;if(!n||!(e==null?void 0: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:R.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:o||j()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return null;const s=this.draw.getElementList(),i=s[n];if(i.type!==R.ElementType.HYPERLINK)return null;let l=n;for(;l>0;){if(s[l].hyperlinkId!==i.hyperlinkId){t=l+1;break}l--}let a=n+1;for(;a<s.length;){if(s[a].hyperlinkId!==i.hyperlinkId){e=a-1;break}a++}return a===s.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(),[o,s]=e;this.draw.spliceElementList(n,o,s-o+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const i=o-1;this.range.setRange(i,i),this.draw.render({curIndex:i})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[o,s]=e;for(let l=o;l<=s;l++){const a=n[l];delete a.type,delete a.url,delete a.hyperlinkId,delete a.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const o=this.draw.getElementList(),[s,i]=n;for(let a=s;a<=i;a++){const c=o[a];c.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:s,endIndex:i}=this.range.getRange();if(!~s&&!~i)return;const l=this.draw.getElementList();let a=-1;const c=l[i+1];if(c&&c.type===R.ElementType.SEPARATOR){if(c.dashArray&&c.dashArray.join()===t.join())return;a=i,Object.assign(c,Y({dashArray:t},e))}else{const d=Y({value:On,type:R.ElementType.SEPARATOR,dashArray:t},e);It(l,[d],s,{editorOptions:this.options}),s!==0&&l[s].value===y?(this.draw.spliceElementList(l,s,1,[d]),a=s-1):(this.draw.spliceElementList(l,s+1,0,[d]),a=s)}this.range.setRange(a,a),this.draw.render({curIndex:a})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:R.ElementType.PAGE_BREAK,value:On}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:o,size:s,opacity:i,font:l,gap:a,layer:c}=tn;n.watermark.data=t.data,n.watermark.type=t.type||R.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||o,n.watermark.opacity=t.opacity||i,n.watermark.size=t.size||s,n.watermark.font=t.font||l,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||a,n.watermark.layer=t.layer||c,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=Y({},tn),this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return null;const s=t.id||j();return this.insertElementList([B(Y({},t),{id:s,type:R.ElementType.IMAGE})]),s}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:o,height:s}=this.options;t!==1&&this.draw.setPageScale(1);const i=await this.draw.getDataURL({pixelRatio:e,mode:R.EditorMode.PRINT});await pr(i,{width:o,height:s,direction:n,iframeInfoList:this.draw.getBlockParticle().pickIframeInfo()}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),o=this.draw.getElementList()[e];!o||o.type!==R.ElementType.IMAGE||(o.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==R.ElementType.IMAGE||Nn(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),o=this.draw.getElementList()[e];!o||o.type!==R.ElementType.IMAGE||(o.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),o=this.draw.getElementList()[e];(o==null?void 0:o.type)===R.ElementType.IMAGE&&(o.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:o}=this.range.getRange();if(e===R.ImageDisplay.SURROUND||e===R.ImageDisplay.FLOAT_TOP||e===R.ImageDisplay.FLOAT_BOTTOM){const s=this.position.getPositionList(),{pageNo:i,coordinate:{leftTop:l}}=s[n];t.imgFloatPosition={pageNo:i,x:l[0],y:l[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:o})}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(),o=this.draw.getFooterElementList();return{header:ae(e,t).innerHTML,main:ae(n,t).innerHTML,footer:ae(o,t).innerHTML}}getText(){const t=this.draw.getHeaderElementList(),e=this.draw.getOriginalMainElementList(),n=this.draw.getFooterElementList();return{header:ce(t),main:ce(e),footer:ce(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,o=(t[e]||[]).reduce((a,c)=>a+c.height+(c.offsetY||0),0),s=this.draw.getHeight(),i=this.draw.getMainOuterHeight(),l=s-(i+o);return l>0?l:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=$(t);Pt(n,{isHandleFirstElement:!1,editorOptions:this.options});const o=on(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:o}).reduce((i,l)=>i+l.height+(l.offsetY||0),0)}getRange(){return $(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){var H,x;const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const o=e===n,s=this.range.toString(),i=st(this.range.getSelectionElementList()||[]),l=this.draw.getElementList(),a=le(l[o?e:e+1],{extraPickAttrs:["id","controlComponent"]}),c=le(l[n],{extraPickAttrs:["id","controlComponent"]}),d=this.draw.getRowList(),h=this.position.getPositionList(),u=h[e],g=h[n],T=u.pageNo,P=g.pageNo,O=u.rowIndex,M=g.rowIndex,S=d[O],X=d[M];let N=0,m=0;this.draw.getCursor().getHitLineStartIndex()||(N=((H=S.elementList[0])==null?void 0:H.value)===y?u.index-S.startIndex:u.index-S.startIndex+1),u===g?m=N:m=((x=X.elementList[0])==null?void 0:x.value)===y?g.index-X.startIndex:g.index-X.startIndex+1;const I=[],f=this.draw.getOriginalHeight(),F=this.draw.getOriginalPageGap(),V=this.position.getSelectionPositionList();if(V){let k=null,A=0,Nt=null;for(let Vt=0;Vt<V.length;Vt++){const{rowNo:ft,pageNo:gt,coordinate:{leftTop:rt,rightTop:Mt},lineHeight:it}=V[Vt];k===null||k!==ft?(Nt&&I.push(Nt),Nt={x:rt[0],y:rt[1]+gt*(f+F),width:Mt[0]-rt[0],height:it},k=ft,A=rt[0]):Nt.width=Mt[0]-A,Vt===V.length-1&&Nt&&I.push(Nt)}}else{const A=this.position.getPositionList()[n],{coordinate:{rightTop:Nt},pageNo:Vt,lineHeight:ft}=A;I.push({x:Nt[0],y:Nt[1]+Vt*(f+F),width:0,height:ft})}const Z=this.draw.getZone().getZone(),{isTable:C,trIndex:D,tdIndex:W,index:E}=this.position.getPositionContext();let U=null;if(C){const A=this.draw.getOriginalElementList()[E]||null;A&&(U=st([A])[0])}let Q=null,w=null,K=e-1;for(;K>0;){const k=l[K],A=l[K-1];if(k.titleId&&k.titleId!==(A==null?void 0:A.titleId)){Q=k.titleId,w=h[K].pageNo;break}K--}const p=Li(l,e),G=e===n?p:Li(l,n);return $({isCollapsed:o,startElement:a,endElement:c,startPageNo:T,endPageNo:P,startRowNo:O,endRowNo:M,startColNo:N,endColNo:m,rangeRects:I,zone:Z,isTable:C,trIndex:D!=null?D:null,tdIndex:W!=null?W:null,tableElement:U,selectionText:s,selectionElementList:i,titleId:Q,titleStartPageNo:w,startParagraphNo:p,endParagraphNo:G})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?st(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?st(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){var i,l,a,c;const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],o=this.position.getOriginalMainPositionList(),s=this.draw.getOriginalMainElementList();for(let d=0;d<e.length;d++){const h=e[d],{startIndex:u,endIndex:g,tableId:T,startTrIndex:P,startTdIndex:O}=h;let M=o;if(h.tableId){const N=s.find(m=>m.id===T);N&&(M=((c=(a=(l=(i=N.trList)==null?void 0:i[P])==null?void 0:l.tdList)==null?void 0:a[O])==null?void 0:c.positionList)||[])}const S=$(M[u]),X=$(M[g]);n.push({range:h,startPosition:S,endPosition:X})}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:o=!0,ignoreContextKeys:s}=e;o||this.range.shrinkRange();const i=$(t),{startIndex:l}=this.range.getRange(),a=this.draw.getElementList();It(a,i,l,{ignoreContextKeys:s,isBreakWhenWrap:!0,editorOptions:this.options}),this.draw.insertElementList(i,e)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList($(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const o=[];function s(l){let a=0;for(;a<l.length;){const c=l[a];if(a++,c.type===R.ElementType.TABLE){const d=c.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];s(T.value)}}}(e&&c.id===e||n&&c.conceptId===n)&&o.push({elementList:l,index:a-1})}}const i=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const l of i)s(l);if(!!o.length){for(let l=0;l<o.length;l++){const{elementList:a,index:c}=o[l],d=a[c],h=st([Y(Y({},d),t.properties)],{extraPickAttrs:["id"]});jt(se,d,h[0]),Pt(h,{isHandleFirstElement:!1,editorOptions:this.options}),a[c]=h[0]}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let o=!1;function s(l){let a=0;for(;a<l.length;){const c=l[a];if(c.type===R.ElementType.TABLE){const d=c.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];s(T.value)}}}(e&&c.id===e||n&&c.conceptId===n)&&(o=!0,l.splice(a,1),a--),a++}}const i=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const l of i)s(l);!o||this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,o=[];if(!e&&!n)return o;const s=l=>{let a=0;for(;a<l.length;){const c=l[a];if(a++,c.type===R.ElementType.TABLE){const d=c.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];s(T.value)}}}e&&c.id!==e||n&&c.conceptId!==n||o.push(c)}},i=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const l of i)s(l);return st(o,{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 o=!1;const s=l=>{let a=l.length-1;for(;a>=0;){const c=l[a];if(c.type===R.ElementType.TABLE){const d=c.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];s(T.value)}}}a--,!(!c.control||e&&c.controlId!==e||n&&c.control.conceptId!==n)&&(o=!0,l.splice(a+1,1))}},i=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const l of i)s(l);o&&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(M,S){var X;for(let N=0;N<M.length;N++){const m=M[N];if(m.type===R.ElementType.TABLE){const I=m.trList;for(let f=0;f<I.length;f++){const F=I[f];for(let V=0;V<F.tdList.length;V++){const Z=F.tdList[V],C=n(Z.value,S);if(C)return B(Y({},C),{isTable:!0,index:N,trIndex:f,tdIndex:V,tdId:Z.id,trId:F.id,tableId:m.id})}}}if(m.titleId===S){let I=N;for(;I<M.length;){if(((X=M[I+1])==null?void 0:X.titleId)!==S)return{isTable:!1,startIndex:I,endIndex:I};I++}}}return null}const o=n(e,t);if(!o)return;const{isTable:s,index:i,startTdIndex:l,endTdIndex:a,startTrIndex:c,endTrIndex:d,trIndex:h,tdIndex:u,tdId:g,trId:T,tableId:P,endIndex:O}=o;this.position.setPositionContext({isTable:s,index:i,trIndex:h,tdIndex:u,tdId:g,trId:T,tableId:P}),this.range.setRange(O,O,P,l,a,c,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===y)for(;n+1<t.length;){const s=t[n+1];if(s.value!==y&&s.value!==we)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:o}=t,s=this.draw.getOriginalInnerWidth(),i=l=>l!==void 0?Re(l,{innerWidth:s}):void 0;this.setValue({header:i(e),main:i(n),footer:i(o)})}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:o,index:s,trIndex:i,tdIndex:l,tdId:a,trId:c,tableId:d,endIndex:h}=n;this.position.setPositionContext({isTable:o,index:s,trIndex:i,tdIndex:l,tdId:a,trId:c,tableId:d}),this.range.setRange(h,h),this.draw.render({curIndex:h,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=en(t);Object.entries(e).forEach(([n,o])=>{Reflect.set(this.options,n,o)}),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){function n(s,i){var a,c,d;let l=0;for(;l<s.length;){const h=s[l];if(l++,h.type===R.ElementType.TABLE){const g=h.trList;for(let T=0;T<g.length;T++){const P=g[T];for(let O=0;O<P.tdList.length;O++){const M=P.tdList[O],S=n(M.value,i);if(S)return B(Y({},S),{positionContext:{isTable:!0,index:l-1,trIndex:T,tdIndex:O,tdId:h.tdId,trId:h.trId,tableId:h.tableId}})}}}if((h==null?void 0:h.controlId)!==t)continue;let u=l-1;if((e==null?void 0:e.position)===R.LocationPosition.OUTER_AFTER){if(!(h.controlComponent===R.ControlComponent.POSTFIX&&((a=s[l+1])==null?void 0:a.controlComponent)!==R.ControlComponent.POST_TEXT))continue}else if((e==null?void 0:e.position)===R.LocationPosition.OUTER_BEFORE)u-=1;else if((e==null?void 0:e.position)===R.LocationPosition.AFTER){if(u-=1,h.controlComponent!==R.ControlComponent.PLACEHOLDER&&h.controlComponent!==R.ControlComponent.POSTFIX&&h.controlComponent!==R.ControlComponent.POST_TEXT)continue}else if(h.controlComponent!==R.ControlComponent.PREFIX&&h.controlComponent!==R.ControlComponent.PRE_TEXT||((c=s[l])==null?void 0:c.controlComponent)===R.ControlComponent.PREFIX||((d=s[l])==null?void 0:d.controlComponent)===R.ControlComponent.PRE_TEXT)continue;return{zone:i,range:{startIndex:u,endIndex:u},positionContext:{isTable:!1}}}return null}const o=[{zone:R.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:R.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:R.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const s of o){const i=n(s.elementList,s.zone);if(i){this.setZone(i.zone),this.position.setPositionContext(i.positionContext),this.range.replaceRange(i.range),this.draw.render({curIndex:i.range.startIndex,isCompute:!1,isSubmitHistory:!1});break}}}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=$(t),{startIndex:o}=this.range.getRange(),s=this.draw.getElementList(),i=Qe(s,o);if(!i)return;const l=[...Pe,...te,...pe,...se];jt(l,i,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=[],o=(i,l)=>{var c;let a=0;for(;a<i.length;){const d=i[a];if(a++,d.type===R.ElementType.TABLE){const g=d.trList;for(let T=0;T<g.length;T++){const P=g[T];for(let O=0;O<P.tdList.length;O++){const M=P.tdList[O];o(M.value,l)}}}if(((c=d==null?void 0:d.title)==null?void 0:c.conceptId)!==e)continue;const h=[];let u=a;for(;u<i.length;){const g=i[u];if(u++,d.titleId!==g.titleId){if(g.level&&qe[g.level]<=qe[d.level])break;h.push(g)}}n.push(B(Y({},d.title),{value:ce(h),elementList:st(h),zone:l})),a=u}},s=[{zone:R.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:R.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:R.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:i,elementList:l}of s)o(l,i);return n}getPositionContextByEvent(t,e={}){var N,m,I;const n=(N=t.target)==null?void 0:N.dataset.index;if(!n)return null;const{isMustDirectHit:o=!0}=e,s=Number(n),i=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:s}),{isDirectHit:l,isTable:a,index:c,trIndex:d,tdIndex:h,tdValueIndex:u,zone:g}=i;if(o&&!l||g&&g!==this.zone.getZone())return null;let T=null,P=null;const O=this.draw.getOriginalElementList();let M=null;const S=this.position.getOriginalPositionList();if(a){const f=(m=O[c].trList)==null?void 0:m[d].tdList[h];P=(f==null?void 0:f.value[u])||null,M=((I=f==null?void 0:f.positionList)==null?void 0:I[u])||null,T={element:O[c],trIndex:d,tdIndex:h}}else P=O[c]||null,M=S[c]||null;let X=null;if(M){const{pageNo:f,coordinate:{leftTop:F,rightTop:V},lineHeight:Z}=M,C=this.draw.getOriginalHeight(),D=this.draw.getOriginalPageGap();X={x:F[0],y:F[1]+f*(C+D),width:V[0]-F[0],height:Z}}return{pageNo:s,element:P,rangeRect:X,tableInfo:T}}insertTitle(t){var a;if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=$(t),{startIndex:o}=this.range.getRange(),s=this.draw.getElementList(),i=Qe(s,o);if(!i)return;const l=[...Pe,...te,...pe,...se];(a=n.valueList)==null||a.forEach(c=>{jt(l,i,c)}),this.draw.insertElementList([n])}focus(t){var a,c;const{position:e=R.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:o,range:s}=t||{};let i=-1;if(s)this.range.replaceRange(s),i=e===R.LocationPosition.BEFORE?s.startIndex:s.endIndex;else if(ve(o)){const d=this.draw.getOriginalRowList();if(i=e===R.LocationPosition.BEFORE?(a=d[o])==null?void 0:a.startIndex:((c=d[o+1])==null?void 0:c.startIndex)-1,!ve(i))return;this.range.setRange(i,i)}else i=e===R.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(i,i);const l={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~i&&this.range.getIsCollapsed()&&(l.curIndex=i,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)}deleteArea(t){this.draw.getArea().deleteArea(t)}locationArea(t,e){if((e==null?void 0:e.isAppendLastLineBreak)&&(e==null?void 0:e.position)===R.LocationPosition.OUTER_AFTER){const s=this.draw.getOriginalMainElementList();s[s.length-1].areaId===t&&this.draw.appendElementList([{value:y}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:o}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(o,o),this.draw.render({curIndex:o,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}}class Yr{constructor(){L(this,"rangeStyleChange");L(this,"visiblePageNoListChange");L(this,"intersectionPageNoChange");L(this,"pageSizeChange");L(this,"pageScaleChange");L(this,"saved");L(this,"contentChange");L(this,"controlChange");L(this,"controlContentChange");L(this,"pageModeChange");L(this,"zoneChange");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 Qr{constructor(t){L(this,"contextMenuList");L(this,"getContextMenuList");L(this,"shortcutList");L(this,"langMap");const{contextMenu:e,shortcut:n,i18n:o}=t;this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=o.registerLangMap.bind(o)}}const Ti={SELECTED_TEXT:"%s"},ue={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:Cr}}=ue,Er=[{key:Cr,i18nPath:"contextmenu.control.delete",when:r=>{var t;return!r.isReadonly&&!r.editorHasSelection&&!!((t=r.startElement)==null?void 0:t.controlId)&&r.options.mode!==R.EditorMode.FORM},callback:r=>{r.executeRemoveControl()}}],{GLOBAL:{CUT:Dr,COPY:br,PASTE:Kr,SELECT_ALL:yr,PRINT:wr}}=ue,Hr=[{key:Dr,i18nPath:"contextmenu.global.cut",shortCut:`${qt?"\u2318":"Ctrl"} + X`,when:r=>!r.isReadonly,callback:r=>{r.executeCut()}},{key:br,i18nPath:"contextmenu.global.copy",shortCut:`${qt?"\u2318":"Ctrl"} + C`,when:r=>r.editorHasSelection||r.isCrossRowCol,callback:r=>{r.executeCopy()}},{key:Kr,i18nPath:"contextmenu.global.paste",shortCut:`${qt?"\u2318":"Ctrl"} + V`,when:r=>!r.isReadonly&&r.editorTextFocus,callback:r=>{r.executePaste()}},{key:yr,i18nPath:"contextmenu.global.selectAll",shortCut:`${qt?"\u2318":"Ctrl"} + A`,when:r=>r.editorTextFocus,callback:r=>{r.executeSelectAll()}},{isDivider:!0},{key:wr,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:r=>{r.executePrint()}}],{HYPERLINK:{DELETE:Gr,CANCEL:xr,EDIT:Jr}}=ue,vr=[{key:Gr,i18nPath:"contextmenu.hyperlink.delete",when:r=>{var t;return!r.isReadonly&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.HYPERLINK},callback:r=>{r.executeDeleteHyperlink()}},{key:xr,i18nPath:"contextmenu.hyperlink.cancel",when:r=>{var t;return!r.isReadonly&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.HYPERLINK},callback:r=>{r.executeCancelHyperlink()}},{key:Jr,i18nPath:"contextmenu.hyperlink.edit",when:r=>{var t;return!r.isReadonly&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.HYPERLINK},callback:(r,t)=>{var n;const e=window.prompt(r.executeTranslate("contextmenu.hyperlink.edit"),(n=t.startElement)==null?void 0:n.url);e&&r.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:Br,SAVE_AS:kr,TEXT_WRAP:Ar,TEXT_WRAP_EMBED:_r,TEXT_WRAP_UP_DOWN:zr,TEXT_WRAP_SURROUND:$r,TEXT_WRAP_FLOAT_TOP:jr,TEXT_WRAP_FLOAT_BOTTOM:qr}}=ue,tl=[{key:Br,i18nPath:"contextmenu.image.change",icon:"image-change",when:r=>{var t;return!r.isReadonly&&!r.editorHasSelection&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.IMAGE},callback:r=>{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 o=n.result;r.executeReplaceImageElement(o)}},t.click()}},{key:kr,i18nPath:"contextmenu.image.saveAs",icon:"image",when:r=>{var t;return!r.editorHasSelection&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.IMAGE},callback:r=>{r.executeSaveAsImageElement()}},{key:Ar,i18nPath:"contextmenu.image.textWrap",when:r=>{var t;return!r.isReadonly&&!r.editorHasSelection&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.IMAGE},childMenus:[{key:_r,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.BLOCK)}},{key:zr,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.INLINE)}},{key:$r,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.SURROUND)}},{key:jr,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.FLOAT_TOP)}},{key:qr,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:el,BORDER_ALL:nl,BORDER_EMPTY:il,BORDER_DASH:ol,BORDER_EXTERNAL:sl,BORDER_INTERNAL:rl,BORDER_TD:ll,BORDER_TD_TOP:al,BORDER_TD_LEFT:Rl,BORDER_TD_BOTTOM:cl,BORDER_TD_RIGHT:dl,BORDER_TD_BACK:hl,BORDER_TD_FORWARD:ul,VERTICAL_ALIGN:gl,VERTICAL_ALIGN_TOP:Ll,VERTICAL_ALIGN_MIDDLE:Tl,VERTICAL_ALIGN_BOTTOM:Pl,INSERT_ROW_COL:Ml,INSERT_TOP_ROW:Ol,INSERT_BOTTOM_ROW:Sl,INSERT_LEFT_COL:Xl,INSERT_RIGHT_COL:Il,DELETE_ROW_COL:Nl,DELETE_ROW:fl,DELETE_COL:ml,DELETE_TABLE:Fl,MERGE_CELL:Wl,CANCEL_MERGE_CELL:Vl}}=ue,pl=[{isDivider:!0},{key:el,i18nPath:"contextmenu.table.border",icon:"border-all",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,childMenus:[{key:nl,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.ALL)}},{key:il,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.EMPTY)}},{key:ol,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.DASH)}},{key:sl,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.EXTERNAL)}},{key:rl,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.INTERNAL)}},{key:ll,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:al,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:r=>{r.executeTableTdBorderType(R.TdBorder.TOP)}},{key:dl,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:r=>{r.executeTableTdBorderType(R.TdBorder.RIGHT)}},{key:cl,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:r=>{r.executeTableTdBorderType(R.TdBorder.BOTTOM)}},{key:Rl,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:r=>{r.executeTableTdBorderType(R.TdBorder.LEFT)}},{key:ul,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:r=>{r.executeTableTdSlashType(R.TdSlash.FORWARD)}},{key:hl,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:r=>{r.executeTableTdSlashType(R.TdSlash.BACK)}}]}]},{key:gl,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,childMenus:[{key:Ll,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:r=>{r.executeTableTdVerticalAlign(R.VerticalAlign.TOP)}},{key:Tl,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:r=>{r.executeTableTdVerticalAlign(R.VerticalAlign.MIDDLE)}},{key:Pl,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:r=>{r.executeTableTdVerticalAlign(R.VerticalAlign.BOTTOM)}}]},{key:Ml,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,childMenus:[{key:Ol,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:r=>{r.executeInsertTableTopRow()}},{key:Sl,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:r=>{r.executeInsertTableBottomRow()}},{key:Xl,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:r=>{r.executeInsertTableLeftCol()}},{key:Il,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:r=>{r.executeInsertTableRightCol()}}]},{key:Nl,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,childMenus:[{key:fl,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:r=>{r.executeDeleteTableRow()}},{key:ml,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:r=>{r.executeDeleteTableCol()}},{key:Fl,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:r=>{r.executeDeleteTable()}}]},{key:Wl,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:r=>!r.isReadonly&&r.isCrossRowCol&&r.options.mode!==R.EditorMode.FORM,callback:r=>{r.executeMergeTableCell()}},{key:Vl,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,callback:r=>{r.executeCancelMergeTableCell()}}];class Zl{constructor(t,e){L(this,"options");L(this,"draw");L(this,"command");L(this,"range");L(this,"position");L(this,"i18n");L(this,"container");L(this,"contextMenuList");L(this,"contextMenuContainerList");L(this,"contextMenuRelationShip");L(this,"context");L(this,"_proxyContextMenuEvent",t=>{this.context=this._getContext();const e=this._filterMenuList(this.contextMenuList);e.some(o=>!o.isDivider)&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()});L(this,"_handleSideEffect",t=>{if(this.contextMenuContainerList.length){const e=(t==null?void 0:t.composedPath()[0])||t.target;me(e,o=>!!o&&o.nodeType===1&&o.getAttribute(_t)===R.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=[...Hr,...pl,...tl,...Er,...vr],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 o;const{contextMenuDisableKeys:e}=this.options,n=[];for(let s=0;s<t.length;s++){const i=t[s];i.disable||i.key&&e.includes(i.key)||(i.isDivider||((o=i.when)==null?void 0:o.call(i,this.context)))&&n.push(i)}return n}_getContext(){const t=this.draw.isReadonly(),{isCrossRowCol:e,startIndex:n,endIndex:o}=this.range.getRange(),s=!!(~n||~o),i=s&&n!==o,{isTable:l,trIndex:a,tdIndex:c,index:d}=this.position.getPositionContext();let h=null;if(l){const S=this.draw.getOriginalElementList()[d]||null;S&&(h=st([S],{extraPickAttrs:["id"]})[0])}const u=l&&!!e,g=this.draw.getElementList(),T=g[n]||null,P=g[o]||null,O=this.draw.getZone().getZone();return{startElement:T,endElement:P,isReadonly:t,editorHasSelection:i,editorTextFocus:s,isCrossRowCol:u,zone:O,isInTable:l,trIndex:a!=null?a:null,tdIndex:c!=null?c:null,tableElement:h,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${v}-contextmenu-container`),t.setAttribute(_t,R.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){var O;const{contextMenuList:e,left:n,top:o,parentMenuContainer:s}=t,i=this._createContextMenuContainer(),l=document.createElement("div");l.classList.add(`${v}-contextmenu-content`);let a=null;s&&this.contextMenuRelationShip.set(s,i);for(let M=0;M<e.length;M++){const S=e[M];if(S.isDivider){if(M!==0&&M!==e.length-1&&!((O=e[M-1])==null?void 0:O.isDivider)){const X=document.createElement("div");X.classList.add(`${v}-contextmenu-divider`),l.append(X)}}else{const X=document.createElement("div");if(X.classList.add(`${v}-contextmenu-item`),S.childMenus){const f=this._filterMenuList(S.childMenus);f.some(V=>!V.isDivider)&&(X.classList.add(`${v}-contextmenu-sub-item`),X.onmouseenter=()=>{this._setHoverStatus(X,!0),this._removeSubMenu(i);const V=X.getBoundingClientRect(),Z=V.left+V.width,C=V.top;a=this._render({contextMenuList:f,left:Z,top:C,parentMenuContainer:i})},X.onmouseleave=V=>{(!a||!a.contains(V.relatedTarget))&&this._setHoverStatus(X,!1)})}else X.onmouseenter=()=>{this._setHoverStatus(X,!0),this._removeSubMenu(i)},X.onmouseleave=()=>{this._setHoverStatus(X,!1)},X.onclick=()=>{S.callback&&this.context&&S.callback(this.command,this.context),this.dispose()};const N=document.createElement("i");X.append(N),S.icon&&N.classList.add(`${v}-contextmenu-${S.icon}`);const m=document.createElement("span"),I=S.i18nPath?this._formatName(this.i18n.t(S.i18nPath)):this._formatName(S.name||"");if(m.append(document.createTextNode(I)),X.append(m),S.shortCut){const f=document.createElement("span");f.classList.add(`${v}-shortcut`),f.append(document.createTextNode(S.shortCut)),X.append(f)}l.append(X)}}i.append(l),i.style.display="block";const c=window.innerWidth,d=i.getBoundingClientRect(),h=d.width,u=n+h>c?n-h:n;i.style.left=`${u}px`;const g=window.innerHeight,T=d.height,P=o+T>g?o-T:o;return i.style.top=`${P}px`,this.contextMenuContainerList.push(i),i}_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(`${v}-contextmenu-item`).forEach(o=>o.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(Ti),n=new RegExp(`${e.join("|")}`);let o=t;if(n.test(o)){const s=new RegExp(Ti.SELECTED_TEXT,"g");if(s.test(o)){const i=this.range.toString();o=o.replace(s,i)}}return o}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const Ul=[{key:R.KeyMap.X,ctrl:!0,shift:!0,callback:r=>{r.executeStrikeout()}},{key:R.KeyMap.LEFT_BRACKET,mod:!0,callback:r=>{r.executeSizeAdd()}},{key:R.KeyMap.RIGHT_BRACKET,mod:!0,callback:r=>{r.executeSizeMinus()}},{key:R.KeyMap.B,mod:!0,callback:r=>{r.executeBold()}},{key:R.KeyMap.I,mod:!0,callback:r=>{r.executeItalic()}},{key:R.KeyMap.U,mod:!0,callback:r=>{r.executeUnderline()}},{key:qt?R.KeyMap.COMMA:R.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:r=>{r.executeSuperscript()}},{key:qt?R.KeyMap.PERIOD:R.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:r=>{r.executeSubscript()}},{key:R.KeyMap.L,mod:!0,callback:r=>{r.executeRowFlex(R.RowFlex.LEFT)}},{key:R.KeyMap.E,mod:!0,callback:r=>{r.executeRowFlex(R.RowFlex.CENTER)}},{key:R.KeyMap.R,mod:!0,callback:r=>{r.executeRowFlex(R.RowFlex.RIGHT)}},{key:R.KeyMap.J,mod:!0,callback:r=>{r.executeRowFlex(R.RowFlex.ALIGNMENT)}},{key:R.KeyMap.J,mod:!0,shift:!0,callback:r=>{r.executeRowFlex(R.RowFlex.JUSTIFY)}}],Yl=[{key:R.KeyMap.ZERO,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(null)}},{key:R.KeyMap.ONE,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.FIRST)}},{key:R.KeyMap.TWO,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.SECOND)}},{key:R.KeyMap.THREE,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.THIRD)}},{key:R.KeyMap.FOUR,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.FOURTH)}},{key:R.KeyMap.FIVE,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.FIFTH)}},{key:R.KeyMap.SIX,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.SIXTH)}}],Ql=[{key:R.KeyMap.I,shift:!0,mod:!0,callback:r=>{r.executeList(R.ListType.UL,R.ListStyle.DISC)}},{key:R.KeyMap.U,shift:!0,mod:!0,callback:r=>{r.executeList(R.ListType.OL)}}];class Cl{constructor(t,e){L(this,"command");L(this,"globalShortcutList");L(this,"agentShortcutList");L(this,"_globalKeydown",t=>{!this.globalShortcutList.length||this._execute(t,this.globalShortcutList)});this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...Ul,...Yl,...Ql]),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 o=0;o<e.length;o++){const s=e[o];if((s.mod?yt(t)===!!s.mod:t.ctrlKey===!!s.ctrl&&t.metaKey===!!s.meta)&&t.shiftKey===!!s.shift&&t.altKey===!!s.alt&&t.key.toLowerCase()===s.key.toLowerCase()){s.disable||((n=s==null?void 0:s.callback)==null||n.call(s,this.command),t.preventDefault());break}}}}class El{constructor(t){L(this,"editor");this.editor=t}use(t,e){t(this.editor,e)}}class Dl{constructor(){L(this,"eventHub");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(o=>o(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 bl{constructor(){L(this,"paste");L(this,"pasteImage");L(this,"copy");L(this,"drop")}}class Pi{constructor(t,e,n={}){L(this,"command");L(this,"version");L(this,"listener");L(this,"eventBus");L(this,"override");L(this,"register");L(this,"destroy");L(this,"use");const o=en(n);e=$(e);let s=[],i=[],l=[],a=[];Array.isArray(e)?i=e:(s=e.header||[],i=e.main,l=e.footer||[],a=e.graffiti||[]),[s,i,l].forEach(T=>{Pt(T,{editorOptions:o,isForceCompensation:!0})}),this.version=Xt,this.listener=new Yr,this.eventBus=new Dl,this.override=new bl;const d=new Wr(t,o,{header:s,main:i,footer:l,graffiti:a},this.listener,this.eventBus,this.override);this.command=new gi(new Ur(d));const h=new Zl(d,this.command),u=new Cl(d,this.command);this.register=new Qr({contextMenu:h,shortcut:u,i18n:d.getI18n()}),this.destroy=()=>{d.destroy(),u.removeEvent(),h.removeEvent(),this.eventBus.dangerouslyClearAll()};const g=new El(this);this.use=g.use.bind(g)}}R.Command=gi,R.EDITOR_CLIPBOARD=Ve,R.EDITOR_COMPONENT=_t,R.Editor=Pi,R.INTERNAL_CONTEXT_MENU_KEY=ue,R.INTERNAL_SHORTCUT_KEY=ni,R.LETTER_CLASS=In,R.createDomFromElementList=ae,R.default=Pi,R.getElementListByHTML=Re,R.getTextFromElementList=ce,R.splitText=Qt,Object.defineProperty(R,"__esModule",{value:!0}),R[Symbol.toStringTag]="Module"});
|
|
101
|
+
}`;h.append(document.createTextNode(u)),a.write(`${h.outerHTML}${c.innerHTML}`),s.length&&await Yr(a),setTimeout(async()=>{l.print(),a.close(),window.addEventListener("mouseover",()=>{i==null||i.remove()},{once:!0})})}async function Yr(r){const e=Array.from(r.querySelectorAll("iframe")).map(n=>new Promise(s=>{var i;n.srcdoc?(i=n.contentWindow)==null||i.addEventListener("message",l=>{l.data.type==="__LOADED_TO_CANVAS_EDITOR__"&&s(!0)}):s(!0)}));await Promise.allSettled(e)}class Qr{constructor(t){L(this,"draw");L(this,"range");L(this,"position");L(this,"historyManager");L(this,"canvasEvent");L(this,"options");L(this,"control");L(this,"workerManager");L(this,"searchManager");L(this,"i18n");L(this,"zone");L(this,"tableOperate");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()||jo(this.canvasEvent,t)}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.draw.getElementList(),{startIndex:n,endIndex:o}=this.range.getRange(),s=n===o;if(s&&e[n].value===y&&n===0)return;s?this.draw.spliceElementList(e,n,1):this.draw.spliceElementList(e,n+1,o-n);const i=s?n-1:n;this.range.setRange(i,i),this.draw.render({curIndex:i})}setRange(t,e,n,o,s,i,l){if(t<0||e<0||e<t)return;this.range.setRange(t,e,n,o,s,i,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:o}=t,s=this.draw.getOriginalElementList();if(e){const i=s.findIndex(d=>d.id===e);if(!~i)return;const a=s[i].trList[n],c=a.tdList[o];this.position.setPositionContext({isTable:!0,index:i,trIndex:n,tdIndex:o,tdId:c.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(o=>{Dt.forEach(i=>{const l=i;n[l]===void 0&&Reflect.set(n,l,o[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 o=this.range.getSelectionElementList();let s={},i=[];if(o==null?void 0:o.length)i=o,s={isSetCursor:!1};else{const{endIndex:l}=this.range.getRange();if(!~l)return;const c=this.draw.getElementList()[l];(c==null?void 0:c.value)===y&&(i.push(c),s={curIndex:l})}!i.length||(i.forEach(l=>{Dt.forEach(a=>{delete l[a]})}),this.draw.render(s))}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const s=this.range.getSelectionElementList();if(s==null?void 0:s.length)s.forEach(i=>{i.font=t}),this.draw.render({isSetCursor:!1});else{let i=!0;const{endIndex:l}=this.range.getRange();if(!~l)return;const c=this.draw.getElementList()[l];this.range.setDefaultStyle({font:t}),(c==null?void 0:c.value)===y?c.font=t:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:s,maxSize:i,defaultSize:l}=this.options;if(t<s||t>i)return;let a={},c=[];const d=this.range.getTextLikeSelectionElementList();if(d==null?void 0:d.length)c=d,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange();if(!~u)return;const T=this.draw.getElementList()[u];this.range.setDefaultStyle({size:t}),(T==null?void 0:T.value)===y?(c.push(T),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let h=!1;c.forEach(u=>{!u.size&&t===l||u.size&&u.size===t||(u.size=t,h=!0)}),h&&this.draw.render(a)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:o,maxSize:s}=this.options,i=this.range.getTextLikeSelectionElementList();let l={},a=[];if(i==null?void 0:i.length)a=i,l={isSetCursor:!1};else{const{endIndex:d}=this.range.getRange();if(!~d)return;const u=this.draw.getElementList()[d],g=this.range.getDefaultStyle(),T=(g==null?void 0:g.size)||u.size||o;this.range.setDefaultStyle({size:T+2>s?s:T+2}),(u==null?void 0:u.value)===y?(a.push(u),l={curIndex:d}):this.draw.render({curIndex:d,isCompute:!1,isSubmitHistory:!1})}if(!a.length)return;let c=!1;a.forEach(d=>{d.size||(d.size=o),!(d.size>=s)&&(d.size+2>s?d.size=s:d.size+=2,c=!0)}),c&&this.draw.render(l)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:o,minSize:s}=this.options,i=this.range.getTextLikeSelectionElementList();let l={},a=[];if(i==null?void 0:i.length)a=i,l={isSetCursor:!1};else{const{endIndex:d}=this.range.getRange();if(!~d)return;const u=this.draw.getElementList()[d],g=this.range.getDefaultStyle(),T=(g==null?void 0:g.size)||u.size||o;this.range.setDefaultStyle({size:T-2<s?s:T-2}),(u==null?void 0:u.value)===y?(a.push(u),l={curIndex:d}):this.draw.render({curIndex:d,isCompute:!1,isSubmitHistory:!1})}if(!a.length)return;let c=!1;a.forEach(d=>{d.size||(d.size=o),!(d.size<=s)&&(d.size-2<s?d.size=s:d.size-=2,c=!0)}),c&&this.draw.render(l)}bold(t){var s;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(o==null?void 0:o.length){const i=o.findIndex(l=>!l.bold);o.forEach(l=>{l.bold=!!~i}),this.draw.render({isSetCursor:!1})}else{let i=!0;const{endIndex:l}=this.range.getRange();if(!~l)return;const c=this.draw.getElementList()[l];this.range.setDefaultStyle({bold:c.bold?!1:!((s=this.range.getDefaultStyle())==null?void 0:s.bold)}),(c==null?void 0:c.value)===y?c.bold=!c.bold:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}italic(t){var s;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(o==null?void 0:o.length){const i=o.findIndex(l=>!l.italic);o.forEach(l=>{l.italic=!!~i}),this.draw.render({isSetCursor:!1})}else{let i=!0;const{endIndex:l}=this.range.getRange();if(!~l)return;const c=this.draw.getElementList()[l];this.range.setDefaultStyle({italic:c.italic?!1:!((s=this.range.getDefaultStyle())==null?void 0:s.italic)}),(c==null?void 0:c.value)===y?c.italic=!c.italic:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}underline(t,e){var i;const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const s=this.range.getSelectionElementList();if(s==null?void 0:s.length){const l=s.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!Gi(a.textDecoration,t));s.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();if(!~a)return;const d=this.draw.getElementList()[a];this.range.setDefaultStyle({underline:(d==null?void 0:d.underline)?!1:!((i=this.range.getDefaultStyle())==null?void 0:i.underline)}),(d==null?void 0:d.value)===y?d.underline=!d.underline:l=!1,this.draw.render({isSubmitHistory:l,curIndex:a,isCompute:!1})}}strikeout(t){var s;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(o==null?void 0:o.length){const i=o.findIndex(l=>!l.strikeout);o.forEach(l=>{l.strikeout=!!~i}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let i=!0;const{endIndex:l}=this.range.getRange();if(!~l)return;const c=this.draw.getElementList()[l];this.range.setDefaultStyle({strikeout:c.strikeout?!1:!((s=this.range.getDefaultStyle())==null?void 0:s.strikeout)}),(c==null?void 0:c.value)===y?c.strikeout=!c.strikeout:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(!o)return;const s=o.findIndex(i=>i.type===R.ElementType.SUPERSCRIPT);o.forEach(i=>{~s?i.type===R.ElementType.SUPERSCRIPT&&(i.type=R.ElementType.TEXT,delete i.actualSize):(!i.type||i.type===R.ElementType.TEXT||i.type===R.ElementType.SUBSCRIPT)&&(i.type=R.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const o=this.range.getSelectionElementList();if(!o)return;const s=o.findIndex(i=>i.type===R.ElementType.SUBSCRIPT);o.forEach(i=>{~s?i.type===R.ElementType.SUBSCRIPT&&(i.type=R.ElementType.TEXT,delete i.actualSize):(!i.type||i.type===R.ElementType.TEXT||i.type===R.ElementType.SUPERSCRIPT)&&(i.type=R.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 s=this.range.getSelectionElementList();if(s==null?void 0:s.length)s.forEach(i=>{t?i.color=t:delete i.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let i=!0;const{endIndex:l}=this.range.getRange();if(!~l)return;const c=this.draw.getElementList()[l];this.range.setDefaultStyle({color:t||void 0}),(c==null?void 0:c.value)===y?t?c.color=t:delete c.color:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const s=this.range.getSelectionElementList();if(s==null?void 0:s.length)s.forEach(i=>{t?i.highlight=t:delete i.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let i=!0;const{endIndex:l}=this.range.getRange();if(!~l)return;const c=this.draw.getElementList()[l];this.range.setDefaultStyle({highlight:t||void 0}),(c==null?void 0:c.value)===y?t?c.highlight=t:delete c.highlight:i=!1,this.draw.render({isSubmitHistory:i,curIndex:l,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const s=this.draw.getElementList(),i=n===o?this.range.getRangeParagraphElementList():s.slice(n+1,o+1);if(!i||!i.length)return;const l=j(),a=this.draw.getOptions().title;i.forEach(h=>{!h.type&&h.value===y||(t?(h.level=t,h.titleId=l,Ye(h)&&(h.size=a[Dn[t]],h.bold=!0)):h.titleId&&(delete h.titleId,delete h.title,delete h.level,delete h.size,delete h.bold))});const c=n===o,d=c?o:n;this.draw.render({curIndex:d,isSetCursor:c})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const s=this.range.getRangeRowElementList();if(!s)return;s.forEach(a=>{a.rowFlex=t});const i=n===o,l=i?o:n;this.draw.render({curIndex:l,isSetCursor:i})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return;const s=this.range.getRangeRowElementList();if(!s)return;s.forEach(a=>{a.rowMargin=t});const i=n===o,l=i?o:n;this.draw.render({curIndex:l,isSetCursor:i})}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:o}=t;if(!n||!(e==null?void 0: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:R.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:o||j()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return null;const s=this.draw.getElementList(),i=s[n];if(i.type!==R.ElementType.HYPERLINK)return null;let l=n;for(;l>=0;){if(s[l].hyperlinkId!==i.hyperlinkId){t=l+1;break}l--}let a=n+1;for(;a<=s.length;){const c=s[a];if((c==null?void 0:c.hyperlinkId)!==i.hyperlinkId){e=a-1;break}a++}return!~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(),[o,s]=e;this.draw.spliceElementList(n,o,s-o+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const i=o-1;this.range.setRange(i,i),this.draw.render({curIndex:i})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[o,s]=e;for(let l=o;l<=s;l++){const a=n[l];delete a.type,delete a.url,delete a.hyperlinkId,delete a.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const o=this.draw.getElementList(),[s,i]=n;for(let a=s;a<=i;a++){const c=o[a];c.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:s,endIndex:i}=this.range.getRange();if(!~s&&!~i)return;const l=this.draw.getElementList();let a=-1;const c=l[i+1];if(c&&c.type===R.ElementType.SEPARATOR){if(c.dashArray&&c.dashArray.join()===t.join())return;a=i,Object.assign(c,Y({dashArray:t},e))}else{const d=Y({value:On,type:R.ElementType.SEPARATOR,dashArray:t},e);It(l,[d],s,{editorOptions:this.options}),s!==0&&l[s].value===y?(this.draw.spliceElementList(l,s,1,[d]),a=s-1):(this.draw.spliceElementList(l,s+1,0,[d]),a=s)}this.range.setRange(a,a),this.draw.render({curIndex:a})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:R.ElementType.PAGE_BREAK,value:On}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:o,size:s,opacity:i,font:l,gap:a,layer:c}=tn;n.watermark.data=t.data,n.watermark.type=t.type||R.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||o,n.watermark.opacity=t.opacity||i,n.watermark.size=t.size||s,n.watermark.font=t.font||l,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||a,n.watermark.layer=t.layer||c,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=Y({},tn),this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:o}=this.range.getRange();if(!~n&&!~o)return null;const s=t.id||j();return this.insertElementList([B(Y({},t),{id:s,type:R.ElementType.IMAGE})]),s}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:o,height:s}=this.options;t!==1&&this.draw.setPageScale(1);const i=await this.draw.getDataURL({pixelRatio:e,mode:R.EditorMode.PRINT});await Ur(i,{width:o,height:s,direction:n,iframeInfoList:this.draw.getBlockParticle().pickIframeInfo()}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),o=this.draw.getElementList()[e];!o||o.type!==R.ElementType.IMAGE||(o.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==R.ElementType.IMAGE||Nn(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),o=this.draw.getElementList()[e];!o||o.type!==R.ElementType.IMAGE||(o.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),o=this.draw.getElementList()[e];(o==null?void 0:o.type)===R.ElementType.IMAGE&&(o.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:o}=this.range.getRange();if(e===R.ImageDisplay.SURROUND||e===R.ImageDisplay.FLOAT_TOP||e===R.ImageDisplay.FLOAT_BOTTOM){const s=this.position.getPositionList(),{pageNo:i,coordinate:{leftTop:l}}=s[n];t.imgFloatPosition={pageNo:i,x:l[0],y:l[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:o})}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(),o=this.draw.getFooterElementList();return{header:ae(e,t).innerHTML,main:ae(n,t).innerHTML,footer:ae(o,t).innerHTML}}getText(){const t=this.draw.getHeaderElementList(),e=this.draw.getOriginalMainElementList(),n=this.draw.getFooterElementList();return{header:ce(t),main:ce(e),footer:ce(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,o=(t[e]||[]).reduce((a,c)=>a+c.height+(c.offsetY||0),0),s=this.draw.getHeight(),i=this.draw.getMainOuterHeight(),l=s-(i+o);return l>0?l:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=$(t);Pt(n,{isHandleFirstElement:!1,editorOptions:this.options});const o=on(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:o}).reduce((i,l)=>i+l.height+(l.offsetY||0),0)}getRange(){return $(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){var H,x;const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const o=e===n,s=this.range.toString(),i=st(this.range.getSelectionElementList()||[]),l=this.draw.getElementList(),a=le(l[o?e:e+1],{extraPickAttrs:["id","controlComponent"]}),c=le(l[n],{extraPickAttrs:["id","controlComponent"]}),d=this.draw.getRowList(),h=this.position.getPositionList(),u=h[e],g=h[n],T=u.pageNo,P=g.pageNo,O=u.rowIndex,M=g.rowIndex,S=d[O],X=d[M];let N=0,m=0;this.draw.getCursor().getHitLineStartIndex()||(N=((H=S.elementList[0])==null?void 0:H.value)===y?u.index-S.startIndex:u.index-S.startIndex+1),u===g?m=N:m=((x=X.elementList[0])==null?void 0:x.value)===y?g.index-X.startIndex:g.index-X.startIndex+1;const I=[],f=this.draw.getOriginalHeight(),F=this.draw.getOriginalPageGap(),V=this.position.getSelectionPositionList();if(V){let k=null,A=0,Nt=null;for(let Vt=0;Vt<V.length;Vt++){const{rowNo:ft,pageNo:gt,coordinate:{leftTop:rt,rightTop:Mt},lineHeight:it}=V[Vt];k===null||k!==ft?(Nt&&I.push(Nt),Nt={x:rt[0],y:rt[1]+gt*(f+F),width:Mt[0]-rt[0],height:it},k=ft,A=rt[0]):Nt.width=Mt[0]-A,Vt===V.length-1&&Nt&&I.push(Nt)}}else{const A=this.position.getPositionList()[n],{coordinate:{rightTop:Nt},pageNo:Vt,lineHeight:ft}=A;I.push({x:Nt[0],y:Nt[1]+Vt*(f+F),width:0,height:ft})}const Z=this.draw.getZone().getZone(),{isTable:E,trIndex:D,tdIndex:W,index:C}=this.position.getPositionContext();let U=null;if(E){const A=this.draw.getOriginalElementList()[C]||null;A&&(U=st([A])[0])}let Q=null,w=null,K=e-1;for(;K>0;){const k=l[K],A=l[K-1];if(k.titleId&&k.titleId!==(A==null?void 0:A.titleId)){Q=k.titleId,w=h[K].pageNo;break}K--}const p=Li(l,e),G=e===n?p:Li(l,n);return $({isCollapsed:o,startElement:a,endElement:c,startPageNo:T,endPageNo:P,startRowNo:O,endRowNo:M,startColNo:N,endColNo:m,rangeRects:I,zone:Z,isTable:E,trIndex:D!=null?D:null,tdIndex:W!=null?W:null,tableElement:U,selectionText:s,selectionElementList:i,titleId:Q,titleStartPageNo:w,startParagraphNo:p,endParagraphNo:G})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?st(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?st(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){var i,l,a,c;const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],o=this.position.getOriginalMainPositionList(),s=this.draw.getOriginalMainElementList();for(let d=0;d<e.length;d++){const h=e[d],{startIndex:u,endIndex:g,tableId:T,startTrIndex:P,startTdIndex:O}=h;let M=o;if(h.tableId){const N=s.find(m=>m.id===T);N&&(M=((c=(a=(l=(i=N.trList)==null?void 0:i[P])==null?void 0:l.tdList)==null?void 0:a[O])==null?void 0:c.positionList)||[])}const S=$(M[u]),X=$(M[g]);n.push({range:h,startPosition:S,endPosition:X})}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:o=!0,ignoreContextKeys:s}=e;o||this.range.shrinkRange();const i=$(t),{startIndex:l}=this.range.getRange(),a=this.draw.getElementList();It(a,i,l,{ignoreContextKeys:s,isBreakWhenWrap:!0,editorOptions:this.options}),this.draw.insertElementList(i,e)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList($(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const o=[];function s(l){let a=0;for(;a<l.length;){const c=l[a];if(a++,c.type===R.ElementType.TABLE){const d=c.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];s(T.value)}}}(e&&c.id===e||n&&c.conceptId===n)&&o.push({elementList:l,index:a-1})}}const i=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const l of i)s(l);if(!!o.length){for(let l=0;l<o.length;l++){const{elementList:a,index:c}=o[l],d=a[c];if(d.type===R.ElementType.BLOCK||d.type===R.ElementType.IMAGE||d.type===R.ElementType.LATEX)a[c]=B(Y(Y({},d),t.properties),{type:d.type});else{const h=st([Y(Y({},d),t.properties)],{extraPickAttrs:["id"]});qt(se,d,h[0]),Pt(h,{isHandleFirstElement:!1,editorOptions:this.options}),a[c]=h[0]}}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let o=!1;function s(l){let a=0;for(;a<l.length;){const c=l[a];if(c.type===R.ElementType.TABLE){const d=c.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];s(T.value)}}}(e&&c.id===e||n&&c.conceptId===n)&&(o=!0,l.splice(a,1),a--),a++}}const i=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const l of i)s(l);!o||this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,o=[];if(!e&&!n)return o;const s=l=>{let a=0;for(;a<l.length;){const c=l[a];if(a++,c.type===R.ElementType.TABLE){const d=c.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];s(T.value)}}}e&&c.id!==e||n&&c.conceptId!==n||o.push(c)}},i=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const l of i)s(l);return st(o,{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 o=!1;const s=l=>{let a=l.length-1;for(;a>=0;){const c=l[a];if(c.type===R.ElementType.TABLE){const d=c.trList;for(let h=0;h<d.length;h++){const u=d[h];for(let g=0;g<u.tdList.length;g++){const T=u.tdList[g];s(T.value)}}}a--,!(!c.control||e&&c.controlId!==e||n&&c.control.conceptId!==n)&&(o=!0,l.splice(a+1,1))}},i=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const l of i)s(l);o&&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(M,S){var X;for(let N=0;N<M.length;N++){const m=M[N];if(m.type===R.ElementType.TABLE){const I=m.trList;for(let f=0;f<I.length;f++){const F=I[f];for(let V=0;V<F.tdList.length;V++){const Z=F.tdList[V],E=n(Z.value,S);if(E)return B(Y({},E),{isTable:!0,index:N,trIndex:f,tdIndex:V,tdId:Z.id,trId:F.id,tableId:m.id})}}}if(m.titleId===S){let I=N;for(;I<M.length;){if(((X=M[I+1])==null?void 0:X.titleId)!==S)return{isTable:!1,startIndex:I,endIndex:I};I++}}}return null}const o=n(e,t);if(!o)return;const{isTable:s,index:i,startTdIndex:l,endTdIndex:a,startTrIndex:c,endTrIndex:d,trIndex:h,tdIndex:u,tdId:g,trId:T,tableId:P,endIndex:O}=o;this.position.setPositionContext({isTable:s,index:i,trIndex:h,tdIndex:u,tdId:g,trId:T,tableId:P}),this.range.setRange(O,O,P,l,a,c,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===y)for(;n+1<t.length;){const s=t[n+1];if(s.value!==y&&s.value!==we)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:o}=t,s=this.draw.getOriginalInnerWidth(),i=l=>l!==void 0?Re(l,{innerWidth:s}):void 0;this.setValue({header:i(e),main:i(n),footer:i(o)})}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:o,index:s,trIndex:i,tdIndex:l,tdId:a,trId:c,tableId:d,endIndex:h}=n;this.position.setPositionContext({isTable:o,index:s,trIndex:i,tdIndex:l,tdId:a,trId:c,tableId:d}),this.range.setRange(h,h),this.draw.render({curIndex:h,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=en(t);Object.entries(e).forEach(([n,o])=>{Reflect.set(this.options,n,o)}),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){function n(s,i){var a,c,d;let l=0;for(;l<s.length;){const h=s[l];if(l++,h.type===R.ElementType.TABLE){const g=h.trList;for(let T=0;T<g.length;T++){const P=g[T];for(let O=0;O<P.tdList.length;O++){const M=P.tdList[O],S=n(M.value,i);if(S)return B(Y({},S),{positionContext:{isTable:!0,index:l-1,trIndex:T,tdIndex:O,tdId:h.tdId,trId:h.trId,tableId:h.tableId}})}}}if((h==null?void 0:h.controlId)!==t)continue;let u=l-1;if((e==null?void 0:e.position)===R.LocationPosition.OUTER_AFTER){if(!(h.controlComponent===R.ControlComponent.POSTFIX&&((a=s[l+1])==null?void 0:a.controlComponent)!==R.ControlComponent.POST_TEXT))continue}else if((e==null?void 0:e.position)===R.LocationPosition.OUTER_BEFORE)u-=1;else if((e==null?void 0:e.position)===R.LocationPosition.AFTER){if(u-=1,h.controlComponent!==R.ControlComponent.PLACEHOLDER&&h.controlComponent!==R.ControlComponent.POSTFIX&&h.controlComponent!==R.ControlComponent.POST_TEXT)continue}else if(h.controlComponent!==R.ControlComponent.PREFIX&&h.controlComponent!==R.ControlComponent.PRE_TEXT||((c=s[l])==null?void 0:c.controlComponent)===R.ControlComponent.PREFIX||((d=s[l])==null?void 0:d.controlComponent)===R.ControlComponent.PRE_TEXT)continue;return{zone:i,range:{startIndex:u,endIndex:u},positionContext:{isTable:!1}}}return null}const o=[{zone:R.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:R.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:R.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const s of o){const i=n(s.elementList,s.zone);if(i){this.setZone(i.zone),this.position.setPositionContext(i.positionContext),this.range.replaceRange(i.range),this.draw.render({curIndex:i.range.startIndex,isCompute:!1,isSubmitHistory:!1});break}}}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=$(t),{startIndex:o}=this.range.getRange(),s=this.draw.getElementList(),i=Qe(s,o);if(!i)return;const l=[...Pe,...te,...pe,...se];qt(l,i,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=[],o=(i,l)=>{var c;let a=0;for(;a<i.length;){const d=i[a];if(a++,d.type===R.ElementType.TABLE){const g=d.trList;for(let T=0;T<g.length;T++){const P=g[T];for(let O=0;O<P.tdList.length;O++){const M=P.tdList[O];o(M.value,l)}}}if(((c=d==null?void 0:d.title)==null?void 0:c.conceptId)!==e)continue;const h=[];let u=a;for(;u<i.length;){const g=i[u];if(u++,d.titleId!==g.titleId){if(g.level&&qe[g.level]<=qe[d.level])break;h.push(g)}}n.push(B(Y({},d.title),{value:ce(h),elementList:st(h),zone:l})),a=u}},s=[{zone:R.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:R.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:R.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:i,elementList:l}of s)o(l,i);return n}getPositionContextByEvent(t,e={}){var N,m,I;const n=(N=t.target)==null?void 0:N.dataset.index;if(!n)return null;const{isMustDirectHit:o=!0}=e,s=Number(n),i=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:s}),{isDirectHit:l,isTable:a,index:c,trIndex:d,tdIndex:h,tdValueIndex:u,zone:g}=i;if(o&&!l||g&&g!==this.zone.getZone())return null;let T=null,P=null;const O=this.draw.getOriginalElementList();let M=null;const S=this.position.getOriginalPositionList();if(a){const f=(m=O[c].trList)==null?void 0:m[d].tdList[h];P=(f==null?void 0:f.value[u])||null,M=((I=f==null?void 0:f.positionList)==null?void 0:I[u])||null,T={element:O[c],trIndex:d,tdIndex:h}}else P=O[c]||null,M=S[c]||null;let X=null;if(M){const{pageNo:f,coordinate:{leftTop:F,rightTop:V},lineHeight:Z}=M,E=this.draw.getOriginalHeight(),D=this.draw.getOriginalPageGap();X={x:F[0],y:F[1]+f*(E+D),width:V[0]-F[0],height:Z}}return{pageNo:s,element:P,rangeRect:X,tableInfo:T}}insertTitle(t){var a;if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=$(t),{startIndex:o}=this.range.getRange(),s=this.draw.getElementList(),i=Qe(s,o);if(!i)return;const l=[...Pe,...te,...pe,...se];(a=n.valueList)==null||a.forEach(c=>{qt(l,i,c)}),this.draw.insertElementList([n])}focus(t){var a,c;const{position:e=R.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:o,range:s}=t||{};let i=-1;if(s)this.range.replaceRange(s),i=e===R.LocationPosition.BEFORE?s.startIndex:s.endIndex;else if(ve(o)){const d=this.draw.getOriginalRowList();if(i=e===R.LocationPosition.BEFORE?(a=d[o])==null?void 0:a.startIndex:((c=d[o+1])==null?void 0:c.startIndex)-1,!ve(i))return;this.range.setRange(i,i)}else i=e===R.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(i,i);const l={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~i&&this.range.getIsCollapsed()&&(l.curIndex=i,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)}deleteArea(t){this.draw.getArea().deleteArea(t)}locationArea(t,e){if((e==null?void 0:e.isAppendLastLineBreak)&&(e==null?void 0:e.position)===R.LocationPosition.OUTER_AFTER){const s=this.draw.getOriginalMainElementList();s[s.length-1].areaId===t&&this.draw.appendElementList([{value:y}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:o}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(o,o),this.draw.render({curIndex:o,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}}class Cr{constructor(){L(this,"rangeStyleChange");L(this,"visiblePageNoListChange");L(this,"intersectionPageNoChange");L(this,"pageSizeChange");L(this,"pageScaleChange");L(this,"saved");L(this,"contentChange");L(this,"controlChange");L(this,"controlContentChange");L(this,"pageModeChange");L(this,"zoneChange");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 Er{constructor(t){L(this,"contextMenuList");L(this,"getContextMenuList");L(this,"shortcutList");L(this,"langMap");const{contextMenu:e,shortcut:n,i18n:o}=t;this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=o.registerLangMap.bind(o)}}const Ti={SELECTED_TEXT:"%s"},ue={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:Dr}}=ue,br=[{key:Dr,i18nPath:"contextmenu.control.delete",when:r=>{var t;return!r.isReadonly&&!r.editorHasSelection&&!!((t=r.startElement)==null?void 0:t.controlId)&&r.options.mode!==R.EditorMode.FORM},callback:r=>{r.executeRemoveControl()}}],{GLOBAL:{CUT:Kr,COPY:yr,PASTE:wr,SELECT_ALL:Hr,PRINT:Gr}}=ue,xr=[{key:Kr,i18nPath:"contextmenu.global.cut",shortCut:`${Gt?"\u2318":"Ctrl"} + X`,when:r=>!r.isReadonly,callback:r=>{r.executeCut()}},{key:yr,i18nPath:"contextmenu.global.copy",shortCut:`${Gt?"\u2318":"Ctrl"} + C`,when:r=>r.editorHasSelection||r.isCrossRowCol,callback:r=>{r.executeCopy()}},{key:wr,i18nPath:"contextmenu.global.paste",shortCut:`${Gt?"\u2318":"Ctrl"} + V`,when:r=>!r.isReadonly&&r.editorTextFocus,callback:r=>{r.executePaste()}},{key:Hr,i18nPath:"contextmenu.global.selectAll",shortCut:`${Gt?"\u2318":"Ctrl"} + A`,when:r=>r.editorTextFocus,callback:r=>{r.executeSelectAll()}},{isDivider:!0},{key:Gr,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:r=>{r.executePrint()}}],{HYPERLINK:{DELETE:Jr,CANCEL:vr,EDIT:Br}}=ue,kr=[{key:Jr,i18nPath:"contextmenu.hyperlink.delete",when:r=>{var t;return!r.isReadonly&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.HYPERLINK},callback:r=>{r.executeDeleteHyperlink()}},{key:vr,i18nPath:"contextmenu.hyperlink.cancel",when:r=>{var t;return!r.isReadonly&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.HYPERLINK},callback:r=>{r.executeCancelHyperlink()}},{key:Br,i18nPath:"contextmenu.hyperlink.edit",when:r=>{var t;return!r.isReadonly&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.HYPERLINK},callback:(r,t)=>{var n;const e=window.prompt(r.executeTranslate("contextmenu.hyperlink.edit"),(n=t.startElement)==null?void 0:n.url);e&&r.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:Ar,SAVE_AS:_r,TEXT_WRAP:zr,TEXT_WRAP_EMBED:$r,TEXT_WRAP_UP_DOWN:jr,TEXT_WRAP_SURROUND:qr,TEXT_WRAP_FLOAT_TOP:tl,TEXT_WRAP_FLOAT_BOTTOM:el}}=ue,nl=[{key:Ar,i18nPath:"contextmenu.image.change",icon:"image-change",when:r=>{var t;return!r.isReadonly&&!r.editorHasSelection&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.IMAGE},callback:r=>{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 o=n.result;r.executeReplaceImageElement(o)}},t.click()}},{key:_r,i18nPath:"contextmenu.image.saveAs",icon:"image",when:r=>{var t;return!r.editorHasSelection&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.IMAGE},callback:r=>{r.executeSaveAsImageElement()}},{key:zr,i18nPath:"contextmenu.image.textWrap",when:r=>{var t;return!r.isReadonly&&!r.editorHasSelection&&((t=r.startElement)==null?void 0:t.type)===R.ElementType.IMAGE},childMenus:[{key:$r,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.BLOCK)}},{key:jr,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.INLINE)}},{key:qr,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.SURROUND)}},{key:tl,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.FLOAT_TOP)}},{key:el,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(r,t)=>{r.executeChangeImageDisplay(t.startElement,R.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:il,BORDER_ALL:ol,BORDER_EMPTY:sl,BORDER_DASH:rl,BORDER_EXTERNAL:ll,BORDER_INTERNAL:al,BORDER_TD:Rl,BORDER_TD_TOP:cl,BORDER_TD_LEFT:dl,BORDER_TD_BOTTOM:hl,BORDER_TD_RIGHT:ul,BORDER_TD_BACK:gl,BORDER_TD_FORWARD:Ll,VERTICAL_ALIGN:Tl,VERTICAL_ALIGN_TOP:Pl,VERTICAL_ALIGN_MIDDLE:Ml,VERTICAL_ALIGN_BOTTOM:Ol,INSERT_ROW_COL:Sl,INSERT_TOP_ROW:Xl,INSERT_BOTTOM_ROW:Il,INSERT_LEFT_COL:Nl,INSERT_RIGHT_COL:fl,DELETE_ROW_COL:ml,DELETE_ROW:Fl,DELETE_COL:Wl,DELETE_TABLE:Vl,MERGE_CELL:pl,CANCEL_MERGE_CELL:Zl}}=ue,Ul=[{isDivider:!0},{key:il,i18nPath:"contextmenu.table.border",icon:"border-all",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,childMenus:[{key:ol,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.ALL)}},{key:sl,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.EMPTY)}},{key:rl,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.DASH)}},{key:ll,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.EXTERNAL)}},{key:al,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:r=>{r.executeTableBorderType(R.TableBorder.INTERNAL)}},{key:Rl,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:cl,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:r=>{r.executeTableTdBorderType(R.TdBorder.TOP)}},{key:ul,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:r=>{r.executeTableTdBorderType(R.TdBorder.RIGHT)}},{key:hl,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:r=>{r.executeTableTdBorderType(R.TdBorder.BOTTOM)}},{key:dl,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:r=>{r.executeTableTdBorderType(R.TdBorder.LEFT)}},{key:Ll,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:r=>{r.executeTableTdSlashType(R.TdSlash.FORWARD)}},{key:gl,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:r=>{r.executeTableTdSlashType(R.TdSlash.BACK)}}]}]},{key:Tl,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,childMenus:[{key:Pl,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:r=>{r.executeTableTdVerticalAlign(R.VerticalAlign.TOP)}},{key:Ml,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:r=>{r.executeTableTdVerticalAlign(R.VerticalAlign.MIDDLE)}},{key:Ol,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:r=>{r.executeTableTdVerticalAlign(R.VerticalAlign.BOTTOM)}}]},{key:Sl,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,childMenus:[{key:Xl,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:r=>{r.executeInsertTableTopRow()}},{key:Il,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:r=>{r.executeInsertTableBottomRow()}},{key:Nl,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:r=>{r.executeInsertTableLeftCol()}},{key:fl,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:r=>{r.executeInsertTableRightCol()}}]},{key:ml,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,childMenus:[{key:Fl,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:r=>{r.executeDeleteTableRow()}},{key:Wl,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:r=>{r.executeDeleteTableCol()}},{key:Vl,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:r=>{r.executeDeleteTable()}}]},{key:pl,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:r=>!r.isReadonly&&r.isCrossRowCol&&r.options.mode!==R.EditorMode.FORM,callback:r=>{r.executeMergeTableCell()}},{key:Zl,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:r=>!r.isReadonly&&r.isInTable&&r.options.mode!==R.EditorMode.FORM,callback:r=>{r.executeCancelMergeTableCell()}}];class Yl{constructor(t,e){L(this,"options");L(this,"draw");L(this,"command");L(this,"range");L(this,"position");L(this,"i18n");L(this,"container");L(this,"contextMenuList");L(this,"contextMenuContainerList");L(this,"contextMenuRelationShip");L(this,"context");L(this,"_proxyContextMenuEvent",t=>{this.context=this._getContext();const e=this._filterMenuList(this.contextMenuList);e.some(o=>!o.isDivider)&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()});L(this,"_handleSideEffect",t=>{if(this.contextMenuContainerList.length){const e=(t==null?void 0:t.composedPath()[0])||t.target;me(e,o=>!!o&&o.nodeType===1&&o.getAttribute(_t)===R.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=[...xr,...Ul,...nl,...br,...kr],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 o;const{contextMenuDisableKeys:e}=this.options,n=[];for(let s=0;s<t.length;s++){const i=t[s];i.disable||i.key&&e.includes(i.key)||(i.isDivider||((o=i.when)==null?void 0:o.call(i,this.context)))&&n.push(i)}return n}_getContext(){const t=this.draw.isReadonly(),{isCrossRowCol:e,startIndex:n,endIndex:o}=this.range.getRange(),s=!!(~n||~o),i=s&&n!==o,{isTable:l,trIndex:a,tdIndex:c,index:d}=this.position.getPositionContext();let h=null;if(l){const S=this.draw.getOriginalElementList()[d]||null;S&&(h=st([S],{extraPickAttrs:["id"]})[0])}const u=l&&!!e,g=this.draw.getElementList(),T=g[n]||null,P=g[o]||null,O=this.draw.getZone().getZone();return{startElement:T,endElement:P,isReadonly:t,editorHasSelection:i,editorTextFocus:s,isCrossRowCol:u,zone:O,isInTable:l,trIndex:a!=null?a:null,tdIndex:c!=null?c:null,tableElement:h,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${v}-contextmenu-container`),t.setAttribute(_t,R.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){var O;const{contextMenuList:e,left:n,top:o,parentMenuContainer:s}=t,i=this._createContextMenuContainer(),l=document.createElement("div");l.classList.add(`${v}-contextmenu-content`);let a=null;s&&this.contextMenuRelationShip.set(s,i);for(let M=0;M<e.length;M++){const S=e[M];if(S.isDivider){if(M!==0&&M!==e.length-1&&!((O=e[M-1])==null?void 0:O.isDivider)){const X=document.createElement("div");X.classList.add(`${v}-contextmenu-divider`),l.append(X)}}else{const X=document.createElement("div");if(X.classList.add(`${v}-contextmenu-item`),S.childMenus){const f=this._filterMenuList(S.childMenus);f.some(V=>!V.isDivider)&&(X.classList.add(`${v}-contextmenu-sub-item`),X.onmouseenter=()=>{this._setHoverStatus(X,!0),this._removeSubMenu(i);const V=X.getBoundingClientRect(),Z=V.left+V.width,E=V.top;a=this._render({contextMenuList:f,left:Z,top:E,parentMenuContainer:i})},X.onmouseleave=V=>{(!a||!a.contains(V.relatedTarget))&&this._setHoverStatus(X,!1)})}else X.onmouseenter=()=>{this._setHoverStatus(X,!0),this._removeSubMenu(i)},X.onmouseleave=()=>{this._setHoverStatus(X,!1)},X.onclick=()=>{S.callback&&this.context&&S.callback(this.command,this.context),this.dispose()};const N=document.createElement("i");X.append(N),S.icon&&N.classList.add(`${v}-contextmenu-${S.icon}`);const m=document.createElement("span"),I=S.i18nPath?this._formatName(this.i18n.t(S.i18nPath)):this._formatName(S.name||"");if(m.append(document.createTextNode(I)),X.append(m),S.shortCut){const f=document.createElement("span");f.classList.add(`${v}-shortcut`),f.append(document.createTextNode(S.shortCut)),X.append(f)}l.append(X)}}i.append(l),i.style.display="block";const c=window.innerWidth,d=i.getBoundingClientRect(),h=d.width,u=n+h>c?n-h:n;i.style.left=`${u}px`;const g=window.innerHeight,T=d.height,P=o+T>g?o-T:o;return i.style.top=`${P}px`,this.contextMenuContainerList.push(i),i}_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(`${v}-contextmenu-item`).forEach(o=>o.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(Ti),n=new RegExp(`${e.join("|")}`);let o=t;if(n.test(o)){const s=new RegExp(Ti.SELECTED_TEXT,"g");if(s.test(o)){const i=this.range.toString();o=o.replace(s,i)}}return o}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const Ql=[{key:R.KeyMap.X,ctrl:!0,shift:!0,callback:r=>{r.executeStrikeout()}},{key:R.KeyMap.LEFT_BRACKET,mod:!0,callback:r=>{r.executeSizeAdd()}},{key:R.KeyMap.RIGHT_BRACKET,mod:!0,callback:r=>{r.executeSizeMinus()}},{key:R.KeyMap.B,mod:!0,callback:r=>{r.executeBold()}},{key:R.KeyMap.I,mod:!0,callback:r=>{r.executeItalic()}},{key:R.KeyMap.U,mod:!0,callback:r=>{r.executeUnderline()}},{key:Gt?R.KeyMap.COMMA:R.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:r=>{r.executeSuperscript()}},{key:Gt?R.KeyMap.PERIOD:R.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:r=>{r.executeSubscript()}},{key:R.KeyMap.L,mod:!0,callback:r=>{r.executeRowFlex(R.RowFlex.LEFT)}},{key:R.KeyMap.E,mod:!0,callback:r=>{r.executeRowFlex(R.RowFlex.CENTER)}},{key:R.KeyMap.R,mod:!0,callback:r=>{r.executeRowFlex(R.RowFlex.RIGHT)}},{key:R.KeyMap.J,mod:!0,callback:r=>{r.executeRowFlex(R.RowFlex.ALIGNMENT)}},{key:R.KeyMap.J,mod:!0,shift:!0,callback:r=>{r.executeRowFlex(R.RowFlex.JUSTIFY)}}],Cl=[{key:R.KeyMap.ZERO,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(null)}},{key:R.KeyMap.ONE,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.FIRST)}},{key:R.KeyMap.TWO,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.SECOND)}},{key:R.KeyMap.THREE,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.THIRD)}},{key:R.KeyMap.FOUR,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.FOURTH)}},{key:R.KeyMap.FIVE,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.FIFTH)}},{key:R.KeyMap.SIX,alt:!0,ctrl:!0,callback:r=>{r.executeTitle(R.TitleLevel.SIXTH)}}],El=[{key:R.KeyMap.I,shift:!0,mod:!0,callback:r=>{r.executeList(R.ListType.UL,R.ListStyle.DISC)}},{key:R.KeyMap.U,shift:!0,mod:!0,callback:r=>{r.executeList(R.ListType.OL)}}];class Dl{constructor(t,e){L(this,"command");L(this,"globalShortcutList");L(this,"agentShortcutList");L(this,"_globalKeydown",t=>{!this.globalShortcutList.length||this._execute(t,this.globalShortcutList)});this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...Ql,...Cl,...El]),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 o=0;o<e.length;o++){const s=e[o];if((s.mod?jt(t)===!!s.mod:t.ctrlKey===!!s.ctrl&&t.metaKey===!!s.meta)&&t.shiftKey===!!s.shift&&t.altKey===!!s.alt&&t.key.toLowerCase()===s.key.toLowerCase()){s.disable||((n=s==null?void 0:s.callback)==null||n.call(s,this.command),t.preventDefault());break}}}}class bl{constructor(t){L(this,"editor");this.editor=t}use(t,e){t(this.editor,e)}}class Kl{constructor(){L(this,"eventHub");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(o=>o(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 yl{constructor(){L(this,"paste");L(this,"pasteImage");L(this,"copy");L(this,"drop")}}class Pi{constructor(t,e,n={}){L(this,"command");L(this,"version");L(this,"listener");L(this,"eventBus");L(this,"override");L(this,"register");L(this,"destroy");L(this,"use");const o=en(n);e=$(e);let s=[],i=[],l=[],a=[];Array.isArray(e)?i=e:(s=e.header||[],i=e.main,l=e.footer||[],a=e.graffiti||[]),[s,i,l].forEach(T=>{Pt(T,{editorOptions:o,isForceCompensation:!0})}),this.version=Xt,this.listener=new Cr,this.eventBus=new Kl,this.override=new yl;const d=new pr(t,o,{header:s,main:i,footer:l,graffiti:a},this.listener,this.eventBus,this.override);this.command=new gi(new Qr(d));const h=new Yl(d,this.command),u=new Dl(d,this.command);this.register=new Er({contextMenu:h,shortcut:u,i18n:d.getI18n()}),this.destroy=()=>{d.destroy(),u.removeEvent(),h.removeEvent(),this.eventBus.dangerouslyClearAll()};const g=new bl(this);this.use=g.use.bind(g)}}R.Command=gi,R.EDITOR_CLIPBOARD=Ve,R.EDITOR_COMPONENT=_t,R.Editor=Pi,R.INTERNAL_CONTEXT_MENU_KEY=ue,R.INTERNAL_SHORTCUT_KEY=ni,R.LETTER_CLASS=In,R.createDomFromElementList=ae,R.default=Pi,R.getElementListByHTML=Re,R.getTextFromElementList=ce,R.splitText=Qt,Object.defineProperty(R,"__esModule",{value:!0}),R[Symbol.toStringTag]="Module"});
|
|
102
102
|
//# sourceMappingURL=canvas-editor.umd.js.map
|