ht-emr 0.7.24 → 0.7.25
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="canvas-editor-style",e.appendChild(document.createTextNode(`.ce-select-control-popup{max-width:160px;min-width:69px;max-height:225px;position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;overflow-y:auto}.ce-select-control-popup ul{list-style:none;padding:3px 0;margin:0;box-sizing:border-box}.ce-select-control-popup ul li{font-size:13px;padding:0 20px;position:relative;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#666;height:36px;line-height:36px;box-sizing:border-box;cursor:pointer}.ce-select-control-popup ul li:hover{background-color:#eef2fd}.ce-select-control-popup ul li.active{color:var(--COLOR-HOVER, #5175f4);font-weight:700}.ce-calculator{position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;padding:8px;width:200px}.ce-calculator-display{width:100%;height:40px;line-height:40px;text-align:right;padding:0 10px;margin-bottom:8px;border:1px solid #e4e7ed;border-radius:4px;background-color:#f5f7fa;font-size:16px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis}.ce-calculator-buttons{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ce-calculator-button{width:100%;height:36px;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;font-size:14px;cursor:pointer;transition:all .2s;box-sizing:border-box}.ce-calculator-button:hover{background-color:#eef2fd;border-color:#c6d1ff}.ce-calculator-button:active{background-color:#e1e8ff}.ce-calculator-button.operator{background-color:#f5f7fa}.ce-calculator-button.operator:hover{background-color:#eef2fd}.ce-calculator-button.equal{background-color:var(--COLOR-HOVER, #5175f4);color:#fff;border-color:var(--COLOR-HOVER, #5175f4)}.ce-calculator-button.equal:hover{background-color:var(--COLOR-HOVER, #6a84ff);border-color:var(--COLOR-HOVER, #6a84ff)}.ce-calculator-button.utility{background-color:#f0f2f5}.ce-calculator-button.utility:hover{background-color:#e6e8eb}.ce-date-container{display:none;width:300px;overflow:hidden;left:0;right:0;position:absolute;z-index:1;color:#606266;background:#fff;border-radius:4px;padding:10px;-webkit-user-select:none;user-select:none;border:1px solid #e4e7ed;box-shadow:0 2px 12px #0000001a}.ce-date-container.active{display:block}.ce-date-wrap{display:none}.ce-date-wrap.active{display:block}.ce-date-title{display:flex;justify-content:center;align-items:center;text-align:center;color:#606266;font-size:16px}.ce-date-title>span{display:inline-block}.ce-date-title>span:not(.ce-date-title__now){font-family:cursive;cursor:pointer}.ce-date-title>span:not(.ce-date-title__now):hover{color:#5175f4}.ce-date-title .ce-date-title__pre-year,.ce-date-title .ce-date-title__pre-month{width:15%}.ce-date-title .ce-date-title__now{width:40%}.ce-date-title .ce-date-title__next-year,.ce-date-title .ce-date-title__next-month{width:15%}.ce-date-week{width:100%;display:flex;justify-content:center;margin-top:15px;padding-bottom:5px;border-bottom:1px solid #e4e7ed}.ce-date-week>span{list-style:none;width:calc(100%/7);text-align:center;color:#606266;font-size:14px}.ce-date-day{width:100%;display:flex;flex-wrap:wrap;align-items:center;margin-top:5px}.ce-date-day>div{width:calc(100%/7);height:40px;text-align:center;color:#606266;font-size:14px;cursor:pointer;line-height:40px;border-radius:4px}.ce-date-day>div:hover{color:#5175f4;opacity:.8}.ce-date-day>div.active{color:#5175f4;font-weight:700}.ce-date-day>div.disable{color:#c0c4cc}.ce-date-day>div.select{color:#fff;background-color:#5175f4}.ce-time-wrap{display:none;padding:10px;height:286px}.ce-time-wrap ::-webkit-scrollbar{width:0}.ce-time-wrap.active{display:flex}.ce-time-wrap li{list-style:none}.ce-time-wrap>li{width:33.3%;height:100%;text-align:center}.ce-time-wrap>li>span{transform:translateY(-5px);display:inline-block}.ce-time-wrap>li>ol{height:calc(100% - 20px);overflow-y:auto;border:1px solid #e2e2e2;position:relative}.ce-time-wrap>li:first-child>ol{border-right:0}.ce-time-wrap>li:last-child>ol{border-left:0}.ce-time-wrap>li>ol>li{line-height:30px;cursor:pointer;transition:all .3s}.ce-time-wrap>li>ol>li:hover{background-color:#eaeaea}.ce-time-wrap>li>ol>li.active{color:#fff;background:#5175f4}.ce-date-menu{width:100%;height:28px;display:flex;justify-content:flex-end;align-items:center;padding-top:10px;position:relative;border-top:1px solid #e4e7ed}.ce-date-menu button{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#fff;border:1px solid #dcdfe6;color:#606266;appearance:none;text-align:center;box-sizing:border-box;outline:none;transition:.1s;font-weight:500;-webkit-user-select:none;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;inset: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,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M23.97%207l1.415%201.414-7.779%207.778%207.779%207.779-1.414%201.414-7.779-7.779-7.778%207.779L7%2023.97l7.778-7.779L7%208.414%208.414%207l7.778%207.778L23.971%207z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e") 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,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%2014v-4h2v4h4v2h-4v4h-2v-4h-4v-2h4zm8.749%2010.163A11.952%2011.952%200%200115%2027C8.373%2027%203%2021.627%203%2015S8.373%203%2015%203s12%205.373%2012%2012c0%202.954-1.067%205.658-2.837%207.749l4.908%204.908-1.414%201.414-4.908-4.908zM15%2025c5.523%200%2010-4.477%2010-10S20.523%205%2015%205%205%209.477%205%2015s4.477%2010%2010%2010z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.zoom-out{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M22.749%2024.163A11.952%2011.952%200%200115%2027C8.373%2027%203%2021.627%203%2015S8.373%203%2015%203s12%205.373%2012%2012c0%202.954-1.067%205.658-2.837%207.749l4.908%204.908-1.414%201.414-4.908-4.908zM15%2025c5.523%200%2010-4.477%2010-10S20.523%205%2015%205%205%209.477%205%2015s4.477%2010%2010%2010zm-5-11h10v2H10v-2z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.rotate{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M16%204c6.627%200%2012%205.373%2012%2012a11.97%2011.97%200%2001-4%208.944V23h-.86A9.968%209.968%200%200026%2016c0-5.523-4.477-10-10-10S6%2010.477%206%2016c0%205.185%203.947%209.449%209%209.95v2.009C8.84%2027.451%204%2022.291%204%2016%204%209.373%209.373%204%2016%204z'%20fill-rule='nonzero'/%3e%3cpath%20d='M19.879%2027.328l1.767-6.717%204.95%204.95z'/%3e%3c/g%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.original-size{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%204h24v24H4V4zm2%202v20h20V6H6zm4%205h2v10h-2V11zm5%202h2v2h-2v-2zm0%204h2v2h-2v-2zm5-6h2v10h-2V11z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.image-download{background-image:url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4.5%2015v3.5h15V15H21v5H3v-5h1.5zm8.232-11.226v9.196l4.05-4.05%201.06%201.06-5.834%205.834-5.833-5.833%201.06-1.06%203.998%203.996V3.774h1.5z'%20fill='%233D4757'/%3e%3c/svg%3e")}.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,%3csvg%20width='20'%20height='20'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.5%204.063L6.875%2010l5.625%205.938'%20stroke='%233D4757'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.image-next{background-image:url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.5%204.063L13.125%2010%207.5%2015.938'%20stroke='%233D4757'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e")}.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,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M0%200h16v16H0z'/%3e%3cg%20fill='%23767C85'%3e%3cpath%20d='M7%2012.243l-.707-.707%204.243-4.243.707.707z'/%3e%3cpath%20d='M6.293%204.464L7%203.757%2011.243%208l-.707.707z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e")}.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:#1937580a}.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,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M12%204h-1V2H5v2H4V2a1%201%200%20011-1h6a1%201%200%20011%201v2zm0%205v4a1%201%200%2001-1%201H5a1%201%200%2001-1-1V9h1v4h6V9h1z'/%3e%3cpath%20d='M12%2012v-1h2V5H2v6h2v1H2a1%201%200%2001-1-1V5a1%201%200%20011-1h12a1%201%200%20011%201v6a1%201%200%2001-1%201h-2z'/%3e%3cpath%20d='M3%208h10v1H3zm8-2h2v1h-2z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-image{background-image:url("data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_0-公共_x2F_02工具栏_x2F_插入图片-16px-'%3e%3cg%20id='Group-19'%20transform='translate(1%201)'%3e%3cpath%20id='Combined-Shape'%20class='st0'%20d='M1%200h12c.6%200%201%20.4%201%201v11c0%20.6-.4%201-1%201H1c-.6%200-1-.4-1-1V1c0-.6.4-1%201-1zm0%201v11h12V1H1z'/%3e%3ccircle%20id='椭圆形'%20class='st0'%20cx='10'%20cy='4'%20r='1'/%3e%3cpath%20id='Path'%20class='st0'%20d='M8.5%2011.2l-4-4.1L1%2010.7V9.2c1.7-1.6%202.7-2.5%203-2.8.4-.5.7-.4%201%200L8.5%2010%2011%207.3c.4-.5.6-.5%201-.1l2%202.8v1.5l-2.5-3.4-3%203.1z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-image-change{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cg%20transform='translate(2%204)'%20fill='%233D4757'%3e%3ccircle%20fill-rule='nonzero'%20cx='3'%20cy='1'%20r='1'/%3e%3cpath%20d='M7.473%208.223L3.47%204.107%200%207.667v-1.5C1.715%204.6%202.707%203.664%202.975%203.358c.402-.457.651-.39%201.042%200L7.473%207%209.96%204.349c.414-.462.62-.462%201.011-.071L13%207.06v1.5l-2.51-3.41-3.017%203.072z'/%3e%3c/g%3e%3cpath%20d='M6%201.5H1.5v12h13v-4V13a.5.5%200%2001-.5.5H2a.5.5%200%2001-.5-.5V2a.5.5%200%2001.5-.5h4zm8.5%208V6l-.5.5h1l-.5-.5v3.5zM6%201.5h4L9.5%201v1l.5-.5H6z'%20stroke='%233D4757'/%3e%3cpath%20d='M13.085%201.316l-3.814%204a1%201%200%20001.458%201.368l3.815-4a1%201%200%2010-1.459-1.368z'%20fill='%233D4757'%20fill-rule='nonzero'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-row-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%233D4757'%20d='M8.5%205.5h6v4h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M4%207v1h2V7zm-3%20.5L4%205v5zM1%201h12v1H1zm0%2012h12v1H1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-top-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M8%205H7v3h1zm-.5-3L10%205H5z'/%3e%3crect%20stroke='%233D4757'%20x='1.5'%20y='10.5'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-bottom-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M7%2011h1V8H7zm.5%203L5%2011h5z'/%3e%3crect%20stroke='%233D4757'%20x='1.5'%20y='2.5'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-left-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M11%207v1h3V7zm-3%20.5L11%205v5z'/%3e%3crect%20stroke='%233D4757'%20transform='rotate(90%204%207.5)'%20x='-2'%20y='6'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-right-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M5%208V7H2v1zm3-.5L5%2010V5z'/%3e%3crect%20stroke='%233D4757'%20transform='rotate(90%2012%207.5)'%20x='6'%20y='6'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-row-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M8.5%206.5h6v2h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M2%2012h11v1H2zM2%202h11v1H2zm.63%203L7%209.35l-.635.65L2%205.63z'/%3e%3cpath%20fill='%233D4757'%20d='M2%209.363L6.355%205%207%205.707%202.695%2010z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M8.5%205.5h6v4h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M1%2013h12v1H1zM1%201h12v1H1zm0%204h1v1H1zm1%201h1v1H2zm1%201h1v1H3zm1-1h1v1H4zm1-1h1v1H5zM4%208h1v1H4zM2%208h1v1H2zm3%201h1v1H5zM1%209h1v1H1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M5.5%207.5v-6h4v6z'/%3e%3cpath%20fill='%233D4757'%20d='M13%2015V3h1v12zM1%2015V3h1v12zm4%200v-1h1v1zm1-1v-1h1v1zm1-1v-1h1v1zm-1-1v-1h1v1zm-1-1v-1h1v1zm3%201v-1h1v1zm0%202v-1h1v1zm1-3v-1h1v1zm0%204v-1h1v1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-table{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M14%2013h-1v-3H2v3H1v-3a1%201%200%20011-1h11a1%201%200%20011%201v3z'%20fill-rule='nonzero'/%3e%3cpath%20d='M5.625%202L10%206.375%209.375%207%205%202.625z'/%3e%3cpath%20d='M5%206.375L9.375%202l.625.625L5.625%207z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-merge-cell{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M6%201v1H2v11h4v1H2a1%201%200%2001-1-1V2a1%201%200%20011-1h4zm3%200h4a1%201%200%20011%201v11a1%201%200%2001-1%201H9v-1h4V2H9V1z'/%3e%3cpath%20fill-rule='nonzero'%20d='M6%201h1v4H6zm2%200h1v4H8z'/%3e%3cpath%20d='M8%207.5L10%206v3zm-1%200L5%206v3z'/%3e%3cpath%20d='M9%207h3v1H9zM3%207h3v1H3z'/%3e%3cpath%20fill-rule='nonzero'%20d='M8%2010h1v4H8zm-2%200h1v4H6z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-merge-cancel-cell{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M6%201v1H2v11h4v1H2a1%201%200%2001-1-1V2a1%201%200%20011-1h4zm3%200h4a1%201%200%20011%201v11a1%201%200%2001-1%201H9v-1h4V2H9V1z'/%3e%3cpath%20fill-rule='nonzero'%20d='M6%201h1v4H6zm2%200h1v4H8z'/%3e%3cpath%20d='M3%207.5L5%206v3zm9%200L10%206v3z'/%3e%3cpath%20d='M4%207h3v1H4zm4%200h3v1H8z'/%3e%3cpath%20fill-rule='nonzero'%20d='M8%2010h1v4H8zm-2%200h1v4H6z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-vertical-align{background-image:url("data:image/svg+xml,%3csvg%20height='16'%20viewBox='0%200%2016%2016'%20width='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%2013h12v1H2zm0-3h8v1H2zm0-3h12v1H2zm0-6h12v1H2zm0%203h8v1H2z'%20fill='%233d4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-top{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8%208H7v6h1zm-.5-3L10%208H5zM2%203h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-middle{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8%2012H7v3h1zm-.5-3l2.5%203H5zM7%203h1V0H7zm.5%203L5%203h5zM2%207h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-bottom{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%209h1V3H7zm.5%203L5%209h5zM2%2013h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-border-all{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%233D4757'/%3e%3cpath%20fill='%233D4757'%20d='M3%208h11v1H3z'/%3e%3cpath%20fill='%233D4757'%20d='M9%203v11H8V3z'/%3e%3c/svg%3e")}.ce-contextmenu-border-empty{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13%203h-1V2h1a1%201%200%20011%201v1h-1V3zm-3-1v1H8.5v2h-1V3H6V2h4zM4%202v1H3v1H2V3a1%201%200%20011-1h1zM2%206h1v1.5h2v1H3V10H2V6zm0%206h1v1h1v1H3a1%201%200%2001-1-1v-1zm4%202v-1h1.5v-2h1v2H10v1H6zm6%200v-1h1v-1h1v1a1%201%200%2001-1%201h-1zm2-4h-1V8.5h-2v-1h2V6h1v4zM8.5%207.5v-1h-1v1h-1v1h1v1h1v-1h1v-1h-1z'%20fill='%23AAACB0'/%3e%3c/svg%3e")}.ce-contextmenu-border-dash{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13%203h-1V2h1a1%201%200%20011%201v1h-1V3zm-3-1v1H8.5v2h-1V3H6V2h4zM4%202v1H3v1H2V3a1%201%200%20011-1h1zM2%206h1v1.5h2v1H3V10H2V6zm0%206h1v1h1v1H3a1%201%200%2001-1-1v-1zm4%202v-1h1.5v-2h1v2H10v1H6zm6%200v-1h1v-1h1v1a1%201%200%2001-1%201h-1zm2-4h-1V8.5h-2v-1h2V6h1v4zM8.5%207.5v-1h-1v1h-1v1h1v1h1v-1h1v-1h-1z'%20fill='%23000000'/%3e%3c/svg%3e")}.ce-contextmenu-border-external{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%233D4757'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9%205V3H8v2h1zm0%209v-2H8v2h1zM5%208H3v1h2V8zm9%200h-2v1h2V8zM9%207v1h1v1H9v1H8V9H7V8h1V7h1z'%20fill='%23AAACB0'/%3e%3c/svg%3e")}.ce-contextmenu-border-internal{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9%205V3H8v2h1zm0%209v-2H8v2h1zM5%208H3v1h2V8zm9%200h-2v1h2V8zM9%207v1h1v1H9v1H8V9H7V8h1V7h1z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-contextmenu-border-td{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20d='M8.5%202.5%20v6%20h-6'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-top{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M2.5%203%20h12'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-left{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M3%203%20v11'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-bottom{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M2.5%2014%20h12'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-right{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M14%203%20v11'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-forward{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'%20/%3e%3cpath%20stroke='%233D4757'%20d='M14%203%20l-11%2011'%20/%3e%3c/svg%3e")}.ce-contextmenu-border-td-back{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'%20/%3e%3cpath%20stroke='%233D4757'%20d='M3%203%20l11%2011'%20/%3e%3c/svg%3e")}.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:#dae7fc;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;-webkit-user-select: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{min-width:60px!important;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;-webkit-user-select:none;user-select:none;caret-color:transparent;background-color:transparent;white-space:pre}.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}.ce-button-input-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;justify-content:center;align-items:center;z-index:2000}.ce-button-input-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:320px;max-width:480px;box-shadow:0 4px 20px #00000026}.ce-button-input-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.ce-button-input-modal__textarea{width:100%;min-height:100px;padding:10px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;line-height:1.5;resize:vertical;outline:none;box-sizing:border-box;font-family:inherit}.ce-button-input-modal__textarea:focus{border-color:#5175f4}.ce-button-input-modal__textarea::placeholder{color:#c0c4cc}.ce-button-input-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-button-input-modal__cancel,.ce-button-input-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-button-input-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-button-input-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-button-input-modal__confirm:hover{background:#409eff;border-color:#409eff}.ce-button-edit-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;justify-content:center;align-items:center;z-index:1000}.ce-button-edit-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:320px;max-width:480px;box-shadow:0 4px 20px #00000026}.ce-button-edit-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:16px}.ce-button-edit-modal__form{display:flex;flex-direction:column;gap:12px}.ce-button-edit-modal__field{display:flex;align-items:center;gap:8px}.ce-button-edit-modal__field label{min-width:80px;font-size:13px;color:#606266}.ce-button-edit-modal__field input{flex:1;padding:8px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;outline:none;box-sizing:border-box}.ce-button-edit-modal__field input:focus{border-color:#5175f4}.ce-button-edit-modal__field input::placeholder{color:#c0c4cc}.ce-button-edit-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-button-edit-modal__cancel,.ce-button-edit-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-button-edit-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-button-edit-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-button-edit-modal__confirm:hover{background:#409eff;border-color:#409eff}.ce-number-input-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;justify-content:center;align-items:center;z-index:2000}.ce-number-input-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:300px;max-width:400px;box-shadow:0 4px 20px #00000026}.ce-number-input-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.ce-number-input-modal__hint{font-size:12px;color:#909399;margin-bottom:12px}.ce-number-input-modal__input{width:100%;padding:10px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;outline:none;box-sizing:border-box}.ce-number-input-modal__input:focus{border-color:#5175f4}.ce-number-input-modal__input::placeholder{color:#c0c4cc}.ce-number-input-modal__error{font-size:12px;color:#f56c6c;margin-top:8px}.ce-number-input-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-number-input-modal__cancel,.ce-number-input-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-number-input-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-number-input-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-number-input-modal__confirm:hover{background:#409eff;border-color:#409eff}.tooth-position-edit-modal,.tooth-position-create-modal{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1000}.tooth-position-modal__container{position:relative;top:auto;left:auto;transform:none;background:#fff;border-radius:8px;box-shadow:0 4px 12px #00000026;min-width:400px;max-width:90vw;max-height:calc(100vh - 48px);display:flex;flex-direction:column;pointer-events:auto}.tooth-position-modal__header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #e8e8e8}.tooth-position-modal__header span{font-size:16px;font-weight:500;color:#333}.tooth-position-modal__close{font-size:20px;cursor:pointer;color:#999;line-height:1}.tooth-position-modal__close:hover{color:#333}.tooth-position-modal__content{padding:20px;max-height:60vh;overflow-y:auto}.tooth-section{margin-bottom:20px}.tooth-section:last-child{margin-bottom:0}.tooth-section-title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px;padding-left:8px;border-left:3px solid #1890ff}.tooth-row{display:flex;align-items:center;margin-bottom:8px}.tooth-row:last-child{margin-bottom:0}.tooth-row-label{width:30px;font-size:13px;color:#666}.tooth-buttons{display:flex;gap:8px;flex-wrap:wrap}.letter-buttons{margin-left:30px}.tooth-checkbox{display:flex;align-items:center;cursor:pointer}.tooth-checkbox input{display:none}.tooth-checkbox span{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid #d9d9d9;border-radius:4px;background:#f5f5f5;font-size:14px;color:#333;transition:all .2s}.tooth-checkbox input:checked+span{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-checkbox:hover span{border-color:#1890ff}.tooth-position-modal__footer{display:flex;justify-content:flex-end;gap:10px;padding:16px 20px;border-top:1px solid #e8e8e8}.tooth-position-modal__footer .btn-cancel,.tooth-position-modal__footer .btn-confirm{padding:8px 20px;font-size:14px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.tooth-position-modal__footer .btn-cancel:hover{color:#1890ff;border-color:#1890ff}.tooth-position-modal__footer .btn-confirm{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-position-modal__footer .btn-confirm:hover{background:#40a9ff;border-color:#40a9ff}.tooth-grid-container{display:flex;flex-direction:column;align-items:center;padding:15px 20px;background:#fafafa;border-radius:8px;margin-bottom:15px;position:relative}.tooth-quick-buttons{display:flex;gap:6px;margin-bottom:16px}.tooth-quick-buttons-left{display:flex;flex-direction:column;gap:6px;flex:1}.tooth-quick-buttons-row{display:flex;gap:6px}.tooth-quick-btn{padding:6px 12px;font-size:12px;border:1px solid #d9d9d9;border-radius:4px;cursor:pointer;background:#fff;color:#333;transition:all .2s;white-space:nowrap}.tooth-quick-btn:hover{border-color:#1890ff;color:#1890ff}.tooth-quick-btn.selected{background:#0ff;border-color:#0ff;color:#fff}.tooth-quick-btn--clear{background:#ff6b6b;border-color:#ff6b6b;color:#fff}.tooth-quick-btn--clear:hover{background:#ff5252;border-color:#ff5252;color:#fff}.tooth-grid-container:before{content:"";position:absolute;left:50%;top:20px;bottom:20px;width:2px;background:#000;transform:translate(-50%);z-index:1}.tooth-grid-container:after{content:"";position:absolute;left:20px;right:20px;top:50%;height:2px;background:#000;transform:translateY(-50%);z-index:1}.tooth-grid-letter-row,.tooth-grid-number-row{display:flex;align-items:center;justify-content:center;position:relative;z-index:2}.tooth-grid-half{display:flex;align-items:center;justify-content:center;gap:4px}.tooth-grid-half.left{justify-content:flex-end;padding-right:15px}.tooth-grid-half.right{justify-content:flex-start;padding-left:15px}.tooth-grid-divider-v,.tooth-grid-divider-h{display:none}.tooth-grid-number-item{width:34px;height:32px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:500;color:#333;cursor:pointer;background:#fff;transition:all .2s;box-sizing:border-box;border:1px solid #d9d9d9;border-radius:12px}.upper-number-row .tooth-grid-number-item{border-top:none;border-radius:0 0 12px 12px}.lower-number-row .tooth-grid-number-item{border-bottom:none;border-radius:12px 12px 0 0}.tooth-grid-number-item[data-value="1"],.tooth-grid-number-item[data-value="2"],.tooth-grid-number-item[data-value="3"]{border-radius:50px}.upper-number-row .tooth-grid-number-item[data-value="1"],.upper-number-row .tooth-grid-number-item[data-value="2"],.upper-number-row .tooth-grid-number-item[data-value="3"]{border-top:none!important;border-radius:0 0 50px 50px!important}.lower-number-row .tooth-grid-number-item[data-value="1"],.lower-number-row .tooth-grid-number-item[data-value="2"],.lower-number-row .tooth-grid-number-item[data-value="3"]{border-bottom:none!important;border-radius:50px 50px 0 0!important}.tooth-grid-number-item:hover{border-color:#1890ff;color:#1890ff}.tooth-grid-number-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-grid-letter-item{width:34px;height:32px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px solid #d9d9d9;transition:all .2s;box-sizing:border-box;border-radius:12px}.upper-letter-row .tooth-grid-letter-item{border-top:none;border-radius:0 0 12px 12px}.lower-letter-row .tooth-grid-letter-item{border-bottom:none;border-radius:12px 12px 0 0}.tooth-grid-letter-item[data-value=A],.tooth-grid-letter-item[data-value=B],.tooth-grid-letter-item[data-value=C]{border-radius:50px}.upper-letter-row .tooth-grid-letter-item[data-value=A],.upper-letter-row .tooth-grid-letter-item[data-value=B],.upper-letter-row .tooth-grid-letter-item[data-value=C]{border-top:none!important;border-radius:0 0 50px 50px!important}.lower-letter-row .tooth-grid-letter-item[data-value=A],.lower-letter-row .tooth-grid-letter-item[data-value=B],.lower-letter-row .tooth-grid-letter-item[data-value=C]{border-bottom:none!important;border-radius:50px 50px 0 0!important}.tooth-grid-letter-item:hover{border-color:#1890ff;color:#1890ff}.tooth-grid-letter-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-grid-letter-row.hidden,.tooth-grid-number-row.hidden{display:none}.tooth-grid-letter-row{margin-bottom:8px}.tooth-grid-number-row.upper-number-row{margin-bottom:15px}.tooth-grid-number-row.lower-number-row{margin-top:15px}.tooth-grid-letter-row.lower-letter-row{margin-top:8px}.tooth-preview-section{padding-top:10px;border-top:1px solid #e8e8e8}.tooth-preview-title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.tooth-preview-wrapper{display:flex;gap:15px}.tooth-preview-container{display:flex;justify-content:center;align-items:center;padding:10px;background:#fafafa;border-radius:8px;flex:1;min-height:60px}.tooth-preview-grid{display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;gap:0;width:100%;min-height:70px;position:relative}.tooth-preview-grid:before{content:"";position:absolute;left:50%;top:0;bottom:0;width:1px;background:#000;transform:translate(-50%)}.tooth-preview-grid:after{content:"";position:absolute;top:50%;left:0;right:0;height:1px;background:#000;transform:translateY(-50%)}.tooth-preview-quadrant{display:flex;align-items:center;padding:5px 10px;font-size:12px;flex-wrap:wrap;gap:4px;justify-content:center}.tooth-preview-upper-left{justify-content:flex-end}.tooth-preview-upper-right{justify-content:flex-start}.tooth-preview-lower-left{justify-content:flex-end}.tooth-preview-lower-right{justify-content:flex-start}.tooth-preview-tooth{position:relative;display:inline;margin:0 4px}.tooth-preview-tooth-value{font-size:12px}.tooth-preview-tooth-value--deciduous{font-size:10px}.tooth-preview-tooth-bracket{font-size:12px}.tooth-preview-supernumerary{font-size:9px;vertical-align:super;margin:0 1px}.tooth-preview-surface{font-size:9px;vertical-align:super;margin-left:1px}.tooth-extra-panel{width:100px;display:flex;flex-direction:column;gap:10px}.tooth-surface-panel{background:#fafafa;border-radius:8px;padding:10px 20px}.tooth-surface-title{font-size:12px;font-weight:500;color:#333;margin-bottom:8px;text-align:center}.tooth-surface-grid{display:flex;flex-direction:column;gap:4px;align-items:center}.tooth-surface-row{display:flex;gap:4px;justify-content:center}.tooth-surface-item{width:30px;height:30px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px dashed #d9d9d9;border-radius:5px;transition:all .2s;box-sizing:border-box}.tooth-surface-item--indent{margin-left:17px}.tooth-surface-item:hover{border-color:#1890ff;color:#1890ff}.tooth-surface-item.selected{background:#1890ff;border-color:#1890ff;border-style:solid;color:#fff}.tooth-supernumerary-panel{background:#fafafa;border-radius:8px;padding:10px 20px}.tooth-supernumerary-title{font-size:12px;font-weight:500;color:#333;margin-bottom:4px;text-align:center}.tooth-supernumerary-hint{font-size:10px;color:#999;font-weight:400}.tooth-supernumerary-grid{display:flex;gap:8px;justify-content:center;margin-top:8px}.tooth-supernumerary-item{width:30px;height:35px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px solid #d9d9d9;border-bottom:none;border-radius:50px;transition:all .2s;box-sizing:border-box}.tooth-supernumerary-item:hover{border-color:#1890ff;color:#1890ff}.tooth-supernumerary-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.ce-button-input-modal,.ce-button-edit-modal,.ce-number-input-modal,.tooth-position-edit-modal,.tooth-position-create-modal{inset:0;display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box;overflow:auto;background:transparent;pointer-events:none}.ce-button-input-modal__content,.ce-button-edit-modal__content,.ce-number-input-modal__content,.tooth-position-modal__container{pointer-events:auto}.ce-button-input-modal__content,.ce-button-edit-modal__content,.ce-number-input-modal__content{max-height:calc(100vh - 48px);overflow:auto}.tooth-position-modal__mask{display:none}.tooth-position-modal__container{position:relative;top:auto;left:auto;transform:none;display:flex;flex-direction:column;max-height:calc(100vh - 48px)}.ant-modal-mask{display:none!important}.ant-modal-wrap{position:fixed!important;inset:0!important;display:flex!important;align-items:center!important;justify-content:center!important;padding:24px!important;box-sizing:border-box!important;overflow:auto!important;pointer-events:none!important}.ant-modal{top:auto!important;margin:0!important;padding-bottom:0!important;max-width:calc(100vw - 48px)!important;max-height:calc(100vh - 48px)!important;pointer-events:auto!important}.ant-modal-content{max-height:calc(100vh - 48px)!important;overflow:auto!important}.dialog-mask{display:none}.dialog-container{position:fixed;inset:0;overflow:auto;z-index:999;margin:0;padding:24px;box-sizing:border-box;display:flex;justify-content:center;align-items:center;pointer-events:none}.dialog{position:relative;padding:0 30px 30px;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px;max-height:calc(100vh - 48px);overflow:auto;pointer-events:auto}.dialog-title{position:relative;border-bottom:1px solid #e2e6ed;margin-bottom:30px;height:60px;display:flex;align-items:center;justify-content:space-between}.dialog-title i{width:16px;height:16px;cursor:pointer;display:inline-block;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.9%208.192l4.242%204.243-.707.707L8.192%208.9%203.95%2013.142l-.707-.707%204.242-4.243L3.243%203.95l.707-.707%204.242%204.242%204.243-4.242.707.707L8.9%208.192z'%20fill='%236A6A6A'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.dialog-option__item{margin-bottom:18px;display:flex;align-items:center;justify-content:space-between}.dialog-option__item span{margin-right:12px;font-size:14px;color:#3d4757;position:relative}.dialog-option__item input,.dialog-option__item textarea,.dialog-option__item select{width:276px;height:30px;border-radius:2px;border:1px solid #d3d3d3;min-height:30px;padding:5px;box-sizing:border-box;outline:none;appearance:none;-webkit-user-select:none;user-select:none;font-family:inherit}.dialog-option__item input:focus,.dialog-option__item textarea:focus{border-color:#4991f2}.dialog-option__item--require:before{content:"*";color:#f56c6c;margin-right:4px;position:absolute;left:-8px}.dialog-menu{display:flex;align-items:center;justify-content:flex-end}.dialog-menu button{position:relative;display:inline-block;border:1px solid #e2e6ed;border-radius:2px;background:#fff;line-height:22px;padding:0 16px;white-space:nowrap;cursor:pointer}.dialog-menu button:hover{background:#1937580a}.dialog-menu__cancel{margin-right:16px}.dialog-menu button[type=submit]{color:#fff;background:#4991f2;border-color:#4991f2}.dialog-menu button[type=submit]:hover{background:#5b9cf3;border-color:#5b9cf3}.dialog-radio-group{display:flex;flex-direction:column;gap:8px}.dialog-radio-group--horizontal{flex-direction:row;gap:16px}.dialog-radio-item{display:flex;align-items:center;cursor:pointer;font-size:14px;color:#3d4757}.dialog-radio-item input[type=radio]{width:16px;height:16px;margin:0 6px 0 0;cursor:pointer;appearance:auto}.dialog-radio-item span{margin:0}`)),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
-
(function(s,Tn){typeof exports=="object"&&typeof module<"u"?Tn(exports):typeof define=="function"&&define.amd?define(["exports"],Tn):(s=typeof globalThis<"u"?globalThis:s||self,Tn(s["canvas-editor"]={}))})(this,(function(s){"use strict";const Tn="0.7.
|
|
2
|
+
(function(s,Tn){typeof exports=="object"&&typeof module<"u"?Tn(exports):typeof define=="function"&&define.amd?define(["exports"],Tn):(s=typeof globalThis<"u"?globalThis:s||self,Tn(s["canvas-editor"]={}))})(this,(function(s){"use strict";const Tn="0.7.25";s.MaxHeightRatio=void 0,(function(o){o.HALF="half",o.ONE_THIRD="one-third",o.QUARTER="quarter"})(s.MaxHeightRatio||(s.MaxHeightRatio={})),s.NumberType=void 0,(function(o){o.ARABIC="arabic",o.CHINESE="chinese"})(s.NumberType||(s.NumberType={})),s.ImageDisplay=void 0,(function(o){o.INLINE="inline",o.BLOCK="block",o.SURROUND="surround",o.FLOAT_TOP="float-top",o.FLOAT_BOTTOM="float-bottom"})(s.ImageDisplay||(s.ImageDisplay={})),s.LocationPosition=void 0,(function(o){o.BEFORE="before",o.AFTER="after",o.OUTER_BEFORE="outer-before",o.OUTER_AFTER="outer-after"})(s.LocationPosition||(s.LocationPosition={})),s.FlexDirection=void 0,(function(o){o.ROW="row",o.COLUMN="column"})(s.FlexDirection||(s.FlexDirection={}));const H="",ps=`
|
|
3
3
|
`,qo=" ",Cs=" ",Gl=["·","、",":",":",",",",",".","。",";",";","?","?","!","!"],Is={[s.MaxHeightRatio.HALF]:1/2,[s.MaxHeightRatio.ONE_THIRD]:1/3,[s.MaxHeightRatio.QUARTER]:1/4},ti={ENGLISH:"A-Za-z",NUMBER:"0-9.$¥",SPANISH:"A-Za-zÁÉÍÓÚáéíóúÑñÜü",FRENCH:"A-Za-zÀÂÇàâçÉéÈèÊêËëÎîÏïÔôÙùÛûŸÿ",GERMAN:"A-Za-zÄäÖöÜüß",RUSSIAN:"А-Яа-яЁё",PORTUGUESE:"A-Za-zÁÉÍÓÚáéíóúÃÕãõÇç",ITALIAN:"A-Za-zÀàÈèÉéÌìÍíÎîÓóÒòÙù",DUTCH:"A-Za-zÀàÁáÂâÄäÈèÉéÊêËëÌìÍíÎîÏïÓóÒòÔôÖöÙùÛûÜü",SWEDISH:"A-Za-zÅåÄäÖö",GREEK:"ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΛλΜμΝνΞξΟοΠπΡρΣσςΤτΥυΦφΧχΨψΩω"},xl="中";s.RowFlex=void 0,(function(o){o.LEFT="left",o.CENTER="center",o.RIGHT="right",o.ALIGNMENT="alignment",o.JUSTIFY="justify"})(s.RowFlex||(s.RowFlex={}));const ei=/[0-9.]/,Bl=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,Jl=/[#*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,$l=new RegExp(`${Jl.source}|${Bl.source}`,"g"),zl=/[、,。?!;:……「」“”‘’*()【】〔〕〖〗〘〙〚〛《》———﹝﹞–—\\/·.,!?;:`~<>()[\]{}'"|]/,ni=new RegExp(`^[${H}
|
|
4
4
|
]`),jl=/[^0-9\+\-\.eE,]/,ql=/\s/;function ta(o,t){let e;return function(...n){e&&window.clearTimeout(e),e=window.setTimeout(()=>{o.apply(this,n)},t)}}function ea(o,t){let e=0,n;return function(...i){const l=Date.now();l-e>=t?(window.clearTimeout(n),o.apply(this,i),e=l):(window.clearTimeout(n),n=window.setTimeout(()=>{o.apply(this,i),e=l},t))}}function oi(o,t){if(!o||typeof o!="object")return o;let e={};return Array.isArray(o)?e=o.map(n=>oi(n,t)):Object.keys(o).forEach(n=>{t.includes(n)||(e[n]=oi(o[n],t))}),e}function ht(o){if(typeof structuredClone=="function")return structuredClone(o);if(!o||typeof o!="object")return o;let t={};return Array.isArray(o)?t=o.map(e=>ht(e)):Object.keys(o).forEach(e=>{t[e]=ht(o[e])}),t}function ii(o){return o&&o.nodeType===1&&o.tagName.toLowerCase()==="body"}function Ls(o,t,e){if(o&&!ii(o))for(o=o;o;){if(!t||t(o)||ii(o))return t&&!t(o)&&ii(o)?null:o;o=o.parentNode}return null}function Tt(){function o(){return((1+Math.random())*65536|0).toString(16).substring(1)}return o()+o()+"-"+o()+"-"+o()+"-"+o()+"-"+o()+o()+o()}function Dt(o){const t=[];if(Intl.Segmenter){const n=new Intl.Segmenter().segment(o);for(const{segment:i}of n)t.push(i)}else{const e=new Map;for(const i of o.matchAll($l))e.set(i.index,i[0]);let n=0;for(;n<o.length;){const i=e.get(n);i?(t.push(i),n+=i.length):(t.push(o[n]),n++)}}return t}function Ps(o,t){const e=document.createElement("a");e.href=o,e.download=t,e.click()}function na(o,t){oa(3,o,t)}function oa(o,t,e){let n=0,i=0;const l=function(r){n=new Date().getTime()-i<300?n+1:0,i=new Date().getTime(),n>=o-1&&(e(r),n=0)};t.addEventListener("click",l)}function go(o){return Object.prototype.toString.call(o)==="[object Object]"}function si(o){return Array.isArray(o)}function ri(o){return Object.prototype.toString.call(o)==="[object Number]"}function ia(o){return Object.prototype.toString.call(o)==="[object String]"}function Es(o,t){if(go(o)&&go(t)){const e=t;for(const[n,i]of Object.entries(o))e[n]?e[n]=Es(i,e[n]):e[n]=i}else si(o)&&si(t)&&t.push(...o);return t}function li(o){if(typeof queueMicrotask=="function"){queueMicrotask(()=>{o()});return}if(typeof Promise<"u"){Promise.resolve().then(()=>{o()});return}setTimeout(()=>{o()},0)}function sa(o){const t=["零","一","二","三","四","五","六","七","八","九"],e=["","十","百","千","万","十","百","千","亿","十","百","千","万","十","百","千","亿"];if(!o||isNaN(o))return"零";const n=o.toString().split("");let i="";for(let l=0;l<n.length;l++){const r=n.length-1-l;i=`${e[l]}${i}`,i=`${t[Number(n[r])]}${i}`}return i=i.replace(/零(千|百|十)/g,"零").replace(/十零/g,"十"),i=i.replace(/零+/g,"零"),i=i.replace(/零亿/g,"亿").replace(/零万/g,"万"),i=i.replace(/亿万/g,"亿"),i=i.replace(/零+$/,""),i=i.replace(/^一十/g,"十"),i}function an(o,t,e){for(let n=0;n<o.length;n++){const i=o[n],l=t[i];l!==void 0?e[i]=l:delete e[i]}}function Ms(o,t){if(!(!t.length||!o.length))for(let e=o.length-1;e>=0;e--)t.includes(o[e])&&o.splice(e,1)}function ie(o,t){const e={};for(const n in o)t.includes(n)&&(e[n]=o[n]);return e}function Ce(o,t){const e={};for(const n in o)t.includes(n)||(e[n]=o[n]);return e}function ra(o){const e=new TextEncoder().encode(o),n=Array.from(e,l=>String.fromCharCode(l));return window.btoa(n.join(""))}function la(o){let t=o.parentElement;for(;t;){const n=window.getComputedStyle(t).getPropertyValue("overflow-y");if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"))return t;t=t.parentElement}return document.documentElement}function Os(o,t){return o.length!==t.length?!1:!o.some(e=>!t.includes(e))}function aa(o,t){if(!go(o)||!go(t))return!1;const e=Object.keys(o),n=Object.keys(t);return e.length!==n.length?!1:!e.some(i=>t[i]!==o[i])}function ca(o,t){const e=o.x,n=o.x+o.width,i=o.y,l=o.y+o.height,r=t.x,a=t.x+t.width,c=t.y,d=t.y+t.height;return!(e>a||n<r||i>d||l<c)}function Ss(o){return o==null}function To(o){return o.replace(/\r\n|\r/g,`
|
|
5
5
|
`)}function Xs(o,t,e=0){const n=Math.max(0,Math.floor(e));if(n>=o.length)return typeof t=="string"&&t===""?{index:o.length,length:0}:{index:-1,length:0};if(typeof t=="string"){if(t==="")return{index:n,length:0};const c=o.indexOf(t,n);return c===-1?{index:-1,length:0}:{index:c,length:t.length}}const i=t.flags,l=i.includes("g")?i:i+"g",r=new RegExp(t.source,l);r.lastIndex=n;const a=r.exec(o);return a?{index:a.index,length:a[0].length}:{index:-1,length:0}}function Ns(o,t){if(!t){o.scrollTop=0;return}const e=[];let n=t.offsetParent;for(;n&&o!==n&&o.contains(n);)e.push(n),n=n.offsetParent;const i=t.offsetTop+e.reduce((c,d)=>c+d.offsetTop,0),l=i+t.offsetHeight,r=o.scrollTop,a=r+o.clientHeight;i<r?o.scrollTop=i:l>a&&(o.scrollTop=l-o.clientHeight)}function se(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function da(o,t){return o.performance.enabled&&t>=o.performance.threshold}function ai(o,t,e,n=[],i){if(!da(o,e))return;const l={duration:Number(e.toFixed(2)),breakdown:n.map(r=>({label:r.label,duration:Number(r.duration.toFixed(2))})),...i};console.log(`[canvas-editor perf] ${t}`,l)}const ua=12,Ra={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},Ue="editor-component",tt="ce",Bn=`${tt}-clipboard`,fo={print:{imagePreviewerDisabled:!1,backgroundDisabled:!1},compare:{imagePreviewerDisabled:!1,backgroundDisabled:!1},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1,inputTraceEnabled:!0,deleteTraceEnabled:!0}};var Jt;(function(o){o.UP="top",o.DOWN="down",o.LEFT="left",o.RIGHT="right"})(Jt||(Jt={}));const fn=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),ha=typeof navigator<"u"&&/iPad|iPhone/.test(navigator.userAgent),ga=/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),Ta=typeof navigator<"u"&&/Firefox/.test(navigator.userAgent);s.ElementType=void 0,(function(o){o.TEXT="text",o.TEXTFIELD="TextField",o.BUTTON="button",o.IMAGE="image",o.TABLE="table",o.HYPERLINK="hyperlink",o.SUPERSCRIPT="superscript",o.SUBSCRIPT="subscript",o.SEPARATOR="separator",o.PAGE_BREAK="pageBreak",o.CONTROL="control",o.AREA="area",o.CHECKBOX="checkbox",o.RADIO="radio",o.LATEX="latex",o.TAB="tab",o.DATE="date",o.BLOCK="block",o.TITLE="title",o.LIST="list",o.SPLIT_TAG="splitTag",o.LABEL="label",o.MENSTRUAL_HISTORY="menstrualHistory",o.FETAL_HEART_POSITION="fetalHeartPosition",o.TOOTH_POSITION="toothPosition",o.SPECIAL_SYMBOLS="specialSymbols",o.MACRO="macro",o.CUSTOM_MACRO="customMacro",o.REUSABLE_ITEM="reusableItem",o.SUB_TEMPLATE="subTemplate"})(s.ElementType||(s.ElementType={}));const Ne=["bold","color","highlight","font","size","italic","underline","strikeout","textDecoration","deletePerson","newElEditPerson","deleteTime","newElEditTime"],Te=["rowFlex","rowMargin"],fa=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","url","areaId","hyperlinkId","dateId","dateFormat","groupIds","templateId","subTemplateContent","subTemplateRelation","subTemplateConditions","rowMargin","textDecoration","deletePerson","newElEditPerson","deleteTime","newElEditTime"],ma=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","rowMargin","dashArray","trList","tdPadding","tableToolDisabled","borderType","borderColor","borderWidth","borderExternalWidth","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","deletePerson","newElEditPerson","deleteTime","newElEditTime","dictCode","macroConfig","menstrualData","menstrualHistoryId","fetalHeartData","fetalHeartPositionId","toothPositionData","toothPositionId","reusableItemConfig","templateId","subTemplateContent","subTemplateRelation","subTemplateConditions","subTemplateExpanded"],pa=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],Sn=["tdId","trId","tableId"],ci=["level","titleId","title"],Jn=["listId","listType","listStyle"],di=["control","controlId","controlComponent"],ue=["font","size","bold","highlight","italic","strikeout","deletePerson","newElEditPerson","deleteTime","color","newElEditTime"],mn=["areaId","area"],ui=[...Sn,...ci,...Jn,...mn],Ie=[s.ElementType.TEXT,s.ElementType.HYPERLINK,s.ElementType.SUBSCRIPT,s.ElementType.SUPERSCRIPT,s.ElementType.CONTROL,s.ElementType.DATE],Ca=[s.ElementType.IMAGE,s.ElementType.LATEX],Ia=[s.ElementType.BLOCK,s.ElementType.PAGE_BREAK,s.ElementType.SEPARATOR,s.ElementType.TABLE],La=["HR","TABLE","UL","OL"],Pa=[s.ElementType.TITLE,s.ElementType.LIST];class Xn{static sandbox=["allow-scripts","allow-same-origin"];static allow=["fullscreen"];element;constructor(t){this.element=t}_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?.sandbox||Xn.sandbox),n.setAttribute("allow",[e?.allow||Xn.allow].join(" ")),n.style.border="none",n.style.width="100%",n.style.height="100%",e?.src?n.src=e.src:e?.srcdoc&&(n.srcdoc=e.srcdoc),t.append(n),this._defineIframeProperties(n.contentWindow)}}class Fs{draw;options;imageCache;container;floatImageContainer;floatImage;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer(),this.imageCache=new Map,this.floatImageContainer=null,this.floatImage=null}getOriginalMainImageList(){const t=[],e=n=>{for(const i of n)if(i.type===s.ElementType.TABLE){const l=i.trList;for(let r=0;r<l.length;r++){const a=l[r];for(let c=0;c<a.tdList.length;c++){const d=a.tdList[c];e(d.value)}}}else i.type===s.ElementType.IMAGE&&t.push(i)};return e(this.draw.getOriginalMainElementList()),t}_countImagesBeforeTarget(t,e){let n=0;for(const i of t){if(i===e)break;if(i.type===s.ElementType.TABLE){const l=i.trList;for(const r of l)for(const a of r.tdList)n+=this._countImagesBeforeTarget(a.value,e)}else i.type===s.ElementType.IMAGE&&n++}return n}createFloatImage(t){const{scale:e}=this.options;let n=this.floatImageContainer,i=this.floatImage;n||(n=document.createElement("div"),n.classList.add(`${tt}-float-image`),this.container.append(n),this.floatImageContainer=n),i||(i=document.createElement("img"),n.append(i),this.floatImage=i),n.style.display="none",i.style.width=`${t.width*e}px`,i.style.height=`${t.height*e}px`;const l=this.draw.getHeight(),r=this.draw.getPageGap(),a=this.draw.getPageNo()*(l+r),c=t.imgFloatPosition;n.style.left=`${c.x*e}px`,n.style.top=`${a+c.y*e}px`,i.src=t.value}dragFloatImage(t,e){if(!this.floatImageContainer)return;this.floatImageContainer.style.display="block";const n=parseFloat(this.floatImageContainer.style.left)+t,i=parseFloat(this.floatImageContainer.style.top)+e;this.floatImageContainer.style.left=`${n}px`,this.floatImageContainer.style.top=`${i}px`}destroyFloatImage(){this.floatImageContainer&&(this.floatImageContainer.style.display="none")}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const i=(t-Math.ceil(t/8)*8)/2,l=(e-Math.ceil(e/8)*8)/2,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
|
|
@@ -107,7 +107,7 @@ ${R||`${g+1}.`}${i(h)}${T?`
|
|
|
107
107
|
`)}}return r}return i(n)}function Ii(o){return oi(o,["metrics","style"])}function Vn(o){return!!o?.type&&(Ia.includes(o.type)||o.imgDisplay===s.ImageDisplay.INLINE)}function fc(o,t){const e=document.createElement(t);for(let n=0;n<o.attributes.length;n++){const i=o.attributes[n];e.setAttribute(i.name,i.value)}return e.innerHTML=o.innerHTML,e}function Li(o){const t=[];for(let e=0;e<o.length;e++){const n=o[e];n?.imgDisplay===s.ImageDisplay.SURROUND&&t.push(n)}return t}function mc(o,t){for(let e=o.length-1;e>=0;e--)o[e].imgFloatPosition?.pageNo===t&&o.splice(e,1)}function ae(o){return o?!!(o.hide||o.control?.hide||o.area?.hide):!0}function Wn(o,t,e=s.LocationPosition.BEFORE){if(!ae(o[t]))return t;let n=t;if(e===s.LocationPosition.BEFORE)for(n=t-1;n>0;){if(!ae(o[n]))return n;n--}else for(n=t+1;n<o.length;){if(!ae(o[n]))return n;n++}return n}const Gs=`${Bn}-control`;function xs(o){localStorage.setItem(Bn,JSON.stringify({text:o.text,elementList:o.elementList}))}function Bs(){const o=localStorage.getItem(Bn);return o?JSON.parse(o):null}function Js(){localStorage.removeItem(Bn)}function pc(o){localStorage.setItem(Gs,JSON.stringify(o))}function $s(){const o=localStorage.getItem(Gs);return o?JSON.parse(o):null}function Cc(){return!!$s()?.element}async function Ic(o,t,e){if(!o&&!t&&!e.length)return;const n=new Blob([o],{type:"text/plain"}),i=new Blob([t],{type:"text/html"});if(window.ClipboardItem){const l=new ClipboardItem({[n.type]:n,[i.type]:i});await window.navigator.clipboard.write([l])}else{const l=document.createElement("div");l.setAttribute("contenteditable","true"),l.innerHTML=t,document.body.append(l);const r=window.getSelection(),a=document.createRange(),c=document.createElement("span");c.innerText=`
|
|
108
108
|
`,l.append(c),a.selectNodeContents(l),r?.removeAllRanges(),r?.addRange(a),document.execCommand("copy"),l.remove()}xs({text:o,elementList:e})}async function Lc(o){if(!o)return;const t=[{value:o}],e=()=>{const n=document.createElement("textarea");n.value=o,n.style.position="fixed",n.style.opacity="0",document.body.append(n),n.select(),document.execCommand("copy"),n.remove()};if(window.navigator.clipboard?.writeText)try{await window.navigator.clipboard.writeText(o)}catch{e()}else e();xs({text:o,elementList:t})}async function zs(o,t){const e=bn(o,t);document.body.append(e);const n=e.innerText;e.remove();const i=e.innerHTML;!n&&!i&&!o.length||await Ic(n,i,Yt(o))}function Pc(o){let t=!1;for(let e=0;e<o.items.length;e++)if(o.items[e].kind==="file"){t=!0;break}return t}function Pi(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled()||e.getControl().getIsDisabledPasteControl())return;const n=e.getRange(),{startIndex:i}=n.getRange(),l=e.getElementList();if(~i&&!n.getIsSelectAll()){const r=l[i];if(r?.titleId||r?.listId){let a=0;for(;a<t.length;){const c=t[a];if(r.titleId&&/^\n/.test(c.value))break;if(Pa.includes(c.type)){if(t.splice(a,1),c.valueList)for(let d=0;d<c.valueList.length;d++){const u=c.valueList[d];u.value===H||u.value===`
|
|
109
109
|
`||(t.splice(a,0,u),a++)}a--}a++}}re(l,t,i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function js(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=Dn(t,{innerWidth:e.getOriginalInnerWidth()});Pi(o,n)}function Ei(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=e.getRange(),{startIndex:i}=n.getRange(),l=e.getElementList(),r=new FileReader;r.readAsDataURL(t),r.onload=()=>{const a=new Image,c=r.result;a.src=c,a.onload=()=>{const d={value:c,type:s.ElementType.IMAGE,width:a.width,height:a.height};~i&&re(l,[d],i,{editorOptions:e.getOptions()}),e.insertElementList([d])}}}function Ec(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=t.clipboardData;if(!n)return;const{paste:i}=e.getOverride();if(i&&i(t)?.preventDefault!==!1)return;if(!Pc(n)){const r=n.getData("text"),a=Bs();if(a&&To(r)===To(a.text)){Pi(o,a.elementList);return}}Js();let l=!1;for(let r=0;r<n.items.length;r++)if(n.items[r].type==="text/html"){l=!0;break}for(let r=0;r<n.items.length;r++){const a=n.items[r];if(a.kind==="string"){if(a.type==="text/plain"&&!l){a.getAsString(c=>{o.input(c)});break}if(a.type==="text/html"&&l){a.getAsString(c=>{js(o,c)});break}}else if(a.kind==="file"&&a.type.includes("image")){const c=a.getAsFile();c&&Ei(o,c)}}}async function Mc(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const{paste:n}=e.getOverride();if(n&&n()?.preventDefault!==!1)return;const i=await navigator.clipboard.readText(),l=Bs();if(l&&To(i)===To(l.text)){Pi(o,l.elementList);return}if(Js(),t?.isPlainText)i&&o.input(i);else{const r=await navigator.clipboard.read();let a=!1;for(const c of r)if(c.types.includes("text/html")){a=!0;break}for(const c of r)if(c.types.includes("text/plain")&&!a){const u=await(await c.getType("text/plain")).text();u&&o.input(u)}else if(c.types.includes("text/html")&&a){const u=await(await c.getType("text/html")).text();u&&js(o,u)}else if(c.types.some(d=>d.startsWith("image/"))){const d=c.types.find(R=>R.startsWith("image/")),u=await c.getType(d);Ei(o,u)}}}class Oc{draw;container;agentCursorDom;canvasEvent;eventBus;constructor(t,e){this.draw=t,this.container=t.getContainer(),this.canvasEvent=e,this.eventBus=t.getEventBus();const n=document.createElement("textarea");n.autocomplete="off",n.classList.add(`${tt}-inputarea`),n.innerText="",this.container.append(n),this.agentCursorDom=n,n.onkeydown=i=>this._keyDown(i),n.oninput=this._input.bind(this),n.onpaste=i=>this._paste(i),n.addEventListener("compositionstart",this._compositionstart.bind(this)),n.addEventListener("compositionupdate",this._compositionupdate.bind(this)),n.addEventListener("compositionend",this._compositionend.bind(this)),n.addEventListener("keydown",this._keydown.bind(this)),this.eventBus.on("rangeStyleChange",i=>{this.agentCursorDom.style.fontSize=Math.max(i.size,18)+"px"})}getAgentCursorDom(){return this.agentCursorDom}_keyDown(t){this.draw.isInteractionSuspended()||this.canvasEvent.keydown(t)}_input(t){if(this.draw.isInteractionSuspended())return;const e=t.data;e&&this.canvasEvent.input(e),this.eventBus.isSubscribe("input")&&this.eventBus.emit("input",t)}_paste(t){this.draw.isInteractionSuspended()||this.draw.isReadonly()||!t.clipboardData||(Ec(this.canvasEvent,t),t.preventDefault())}_compositionstart(){this.draw.isInteractionSuspended()||(this.agentCursorDom.style.zIndex="1000",this.agentCursorDom.style.width="0px",this.agentCursorDom.style.color="#000",this.agentCursorDom.style.background="#fff",this.canvasEvent.compositionstart())}_compositionupdate(){if(this.draw.isInteractionSuspended())return;this.agentCursorDom.style.width="9999px";let t=this.agentCursorDom.scrollWidth;const e=this.container.clientWidth,n=Math.max(e-this.agentCursorDom.offsetLeft,100);t>n&&(t=n),this.agentCursorDom.style.width=t+"px"}_compositionend(t){this.draw.isInteractionSuspended()||(this.agentCursorDom.style.zIndex="-1",this.agentCursorDom.style.width="0px",this.agentCursorDom.style.color="",this.agentCursorDom.style.background="",this.canvasEvent.compositionend(t))}_keydown(t){this.draw.isInteractionSuspended()||this.canvasEvent.isComposing&&t.code==="Escape"&&this.canvasEvent.compositionCancel()}}class Sc{ANIMATION_CLASS=`${tt}-cursor--animation`;draw;container;options;position;cursorDom;cursorAgent;blinkTimeout;hitLineStartIndex;constructor(t,e){this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${tt}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new Oc(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(ga&&this.draw.isReadonly())return;const t=this.cursorAgent.getAgentCursorDom();document.activeElement!==t&&(t.focus(),t.setSelectionRange(0,0))}drawCursor(t){let e=this.position.getCursorPosition();if(!e)return;const{scale:n,cursor:i}=this.options,{color:l,width:r,isShow:a=!0,isBlink:c=!0,isFocus:d=!0,hitLineStartIndex:u}={...i,...t},R=this.draw.getHeight(),h=this.draw.getPageGap();this.hitLineStartIndex=u,u&&(e=this.position.getPositionList()[u]);const{metrics:g,coordinate:{leftTop:T,rightTop:f},ascent:m,pageNo:C}=e,L=(this.draw.getZone().isMainActive()?C:this.draw.getPageNo())*(R+h),M=ua*n,O=Math.min(g.height/4,M),b=g.height+O*2,D=this.cursorAgent.getAgentCursorDom();d&&setTimeout(()=>{this.focus()});const W=g.boundingBoxDescent<0?0:g.boundingBoxDescent,V=T[1]+m+W-(b-O)+L,E=u?T[0]:f[0];if(D.style.left=`${E}px`,D.style.top=`${V+b-M}px`,!a){this.recoveryCursor();return}const y=this.cursorDom.style.top,F=this.draw.isReadonly();this.cursorDom.style.width=`${r*n}px`,this.cursorDom.style.backgroundColor=l,this.cursorDom.style.left=`${E}px`,this.cursorDom.style.top=`${V}px`,this.cursorDom.style.display=F?"none":"block",this.cursorDom.style.height=`${b}px`,c?this._setBlinkTimeout():this._clearBlinkTimeout(),li(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(y)>V?Jt.UP:Jt.DOWN})})}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:n}=t;if(!e||!n)return;const{pageNo:i,coordinate:{leftTop:l,leftBottom:r}}=e,a=la(this.container),c={left:0,right:0,top:0,bottom:0},d=a===document.documentElement;if(d)c.right=window.innerWidth,c.bottom=window.innerHeight;else{const{left:f,right:m,top:C,bottom:I}=a.getBoundingClientRect();c.left=f,c.right=m,c.top=C,c.bottom=I}const u=i*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,R=n===Jt.UP,h=r[0]+(d?0:c.left),g=R?l[1]+u:r[1]+u,{maskMargin:T}=this.options;if(c.top+=T[0],c.bottom-=T[2],!(h>=c.left&&h<=c.right&&g>=c.top&&g<=c.bottom)){const{scrollLeft:f,scrollTop:m}=a;R?a.scroll(f,m-(c.top-g)):a.scroll(f,m+g-c.bottom)}}}var In;(function(o){o[o.LEFT=0]="LEFT",o[o.CENTER=1]="CENTER",o[o.RIGHT=2]="RIGHT"})(In||(In={}));function He(o){return fn?o.metaKey:o.ctrlKey}s.KeyMap=void 0,(function(o){o.Delete="Delete",o.Backspace="Backspace",o.Enter="Enter",o.Left="ArrowLeft",o.Right="ArrowRight",o.Up="ArrowUp",o.Down="ArrowDown",o.ESC="Escape",o.TAB="Tab",o.META="Meta",o.LEFT_BRACKET="[",o.RIGHT_BRACKET="]",o.COMMA=",",o.PERIOD=".",o.LEFT_ANGLE_BRACKET="<",o.RIGHT_ANGLE_BRACKET=">",o.EQUAL="=",o.MINUS="-",o.PLUS="+",o.A="a",o.B="b",o.C="c",o.D="d",o.E="e",o.F="f",o.G="g",o.H="h",o.I="i",o.J="j",o.K="k",o.L="l",o.M="m",o.N="n",o.O="o",o.P="p",o.Q="q",o.R="r",o.S="s",o.T="t",o.U="u",o.V="v",o.W="w",o.X="x",o.Y="y",o.Z="z",o.A_UPPERCASE="A",o.B_UPPERCASE="B",o.C_UPPERCASE="C",o.D_UPPERCASE="D",o.E_UPPERCASE="E",o.F_UPPERCASE="F",o.G_UPPERCASE="G",o.H_UPPERCASE="H",o.I_UPPERCASE="I",o.J_UPPERCASE="J",o.K_UPPERCASE="K",o.L_UPPERCASE="L",o.M_UPPERCASE="M",o.N_UPPERCASE="N",o.O_UPPERCASE="O",o.P_UPPERCASE="P",o.Q_UPPERCASE="Q",o.R_UPPERCASE="R",o.S_UPPERCASE="S",o.T_UPPERCASE="T",o.U_UPPERCASE="U",o.V_UPPERCASE="V",o.W_UPPERCASE="W",o.X_UPPERCASE="X",o.Y_UPPERCASE="Y",o.Z_UPPERCASE="Z",o.ZERO="0",o.ONE="1",o.TWO="2",o.THREE="3",o.FOUR="4",o.FIVE="5",o.SIX="6",o.SEVEN="7",o.EIGHT="8",o.NINE="9"})(s.KeyMap||(s.KeyMap={}));class Oo{element;control;constructor(t,e){this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getCode(){return this.element.control?.code||null}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),n=t[e],i=[];let l=e;for(;l>0;){const a=t[l];if(a.controlId!==n.controlId||a.controlComponent===s.ControlComponent.PREFIX||a.controlComponent===s.ControlComponent.PRE_TEXT)break;a.controlComponent===s.ControlComponent.VALUE&&i.unshift(a),l--}let r=e+1;for(;r<t.length;){const a=t[r];if(a.controlId!==n.controlId||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT)break;a.controlComponent===s.ControlComponent.VALUE&&i.push(a),r++}return i}setValue(){return-1}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,l=e.elementList||this.control.getElementList(),{startIndex:r}=e.range||this.control.getRange(),a=l[r];let c=r;for(;c>0;){const u=l[c];if(u.controlId!==a.controlId||u.controlComponent===s.ControlComponent.PREFIX||u.controlComponent===s.ControlComponent.PRE_TEXT)break;if(u.controlComponent===s.ControlComponent.CHECKBOX){const R=u.checkbox;R.value=t.includes(R.code)}c--}let d=r+1;for(;d<l.length;){const u=l[d];if(u.controlId!==a.controlId||u.controlComponent===s.ControlComponent.POSTFIX||u.controlComponent===s.ControlComponent.POST_TEXT)break;if(u.controlComponent===s.ControlComponent.CHECKBOX){const R=u.checkbox;R.value=t.includes(R.code)}d++}i.code=t.join(","),this.control.repaintControl({curIndex:r,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:i}=e;return t.key===s.KeyMap.Backspace||t.key===s.KeyMap.Delete?this.control.removeControl(n):i}cut(){return-1}}class Mi extends Oo{setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,l=e.elementList||this.control.getElementList(),{startIndex:r}=e.range||this.control.getRange(),a=l[r];let c=r;for(;c>0;){const u=l[c];if(u.controlId!==a.controlId||u.controlComponent===s.ControlComponent.PREFIX||u.controlComponent===s.ControlComponent.PRE_TEXT)break;if(u.controlComponent===s.ControlComponent.RADIO){const R=u.radio;R.value=t.includes(R.code)}c--}let d=r+1;for(;d<l.length;){const u=l[d];if(u.controlId!==a.controlId||u.controlComponent===s.ControlComponent.POSTFIX||u.controlComponent===s.ControlComponent.POST_TEXT)break;if(u.controlComponent===s.ControlComponent.RADIO){const R=u.radio;R.value=t.includes(R.code)}d++}i.code=t.join(","),this.control.repaintControl({curIndex:r,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}}function qs(o){const t=o.getDraw(),e=t.getPosition(),n=t.getRange();o.isAllowDrag=!0,o.cacheRange=ht(n.getRange()),o.cacheElementList=t.getElementList(),o.cachePositionList=e.getPositionList(),o.cachePositionContext=e.getPositionContext()}function tr(o,t){const{checkbox:e,control:n}=o;if(!n)t.getCheckboxParticle().setSelect(o);else{const i=n?.code?n.code.split(","):[];if(e?.value){const r=i.findIndex(a=>a===e.code);i.splice(r,1)}else e?.code&&i.push(e.code);const l=t.getControl().getActiveControl();l instanceof Oo&&l.setSelect(i)}}function er(o,t){const{radio:e,control:n}=o;if(!n)t.getRadioParticle().setSelect(o);else{const i=e?.code?[e.code]:[],l=t.getControl().getActiveControl();l instanceof Mi&&l.setSelect(i)}}function Xc(o,t){const e=t.getDraw();let n=e.isReadonly();const i=e.isSelectionDisabled(),l=e.getRange(),r=e.getPosition(),a=l.getRange();if(o.button===In.RIGHT&&(a.isCrossRowCol||!l.getIsCollapsed()))return;const d=o.target.dataset.index;if(d&&e.setPageNo(Number(d)),!t.isAllowDrag&&!n&&a.startIndex!==a.endIndex&&l.getIsPointInRange(o.offsetX,o.offsetY,e.getPageNo())){qs(t);return}t.isAllowSelection=!i;const u=ht(r.getPositionContext()),R=r.getPositionByXY({x:o.offsetX,y:o.offsetY}),h=r.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!h)return;const{index:g,isDirectHit:T,isCheckbox:f,isRadio:m,isControl:C,isImage:I,isLabel:p,isMacro:L,isTable:M,tdValueIndex:O,hitLineStartIndex:b}=h;t.mouseDownStartPosition={...h,index:M?O:g,originalIndex:g,x:o.offsetX,y:o.offsetY};const D=e.getElementList(),W=r.getPositionList(),V=M?O:g;let E;M?E=e.getTd().value[O]:E=D[V];const y=M&&e.getTd()?.value||D,F=M&&e.getTd()?.positionList||W,S=!!(T&&I),N=!!(T&&f),P=!!(T&&m),Y=!!(T&&p),X=!!(T&&L),U=Z=>Z&&(Z.type===s.ElementType.MACRO||Z.type===s.ElementType.CUSTOM_MACRO||Z.type===s.ElementType.REUSABLE_ITEM||Z.type===s.ElementType.SUB_TEMPLATE||Z.type===s.ElementType.MENSTRUAL_HISTORY||Z.type===s.ElementType.FETAL_HEART_POSITION||Z.type===s.ElementType.TOOTH_POSITION||Z.type===s.ElementType.LIST||Z.type===s.ElementType.SPECIAL_SYMBOLS),Q=Z=>Z&&!!Z.originControlId&&!!Z.controlId,v=Z=>!!(Z&&Z.originControlId&&Z.controlId&&(Z.controlComponent===s.ControlComponent.POSTFIX||Z.controlComponent===s.ControlComponent.POSTTEXTFIX||Z.controlComponent===s.ControlComponent.POST_TEXT||Z.controlComponent===s.ControlComponent.PLACEHOLDER)),w=Z=>!!(Z&&Z.originControlId&&Z.controlId&&(Z.controlComponent===s.ControlComponent.PREFIX||Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||Z.controlComponent===s.ControlComponent.PLACEHOLDER)),j=Z=>{if(!Z)return null;const G=new Set;let q=Z,Rt=null;for(;q&&!G.has(q);){G.add(q);let pt;for(let At=0;At<D.length;At++){const vt=D[At];if(vt.controlId===q&&vt.control?.type&&(pt=vt,vt.controlComponent===s.ControlComponent.PREFIX||vt.controlComponent===s.ControlComponent.PRE_TEXT||vt.controlComponent===s.ControlComponent.PRETEXTFIX||vt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!pt)break;pt.control?.type===s.ControlType.TEXT&&(Rt=q),q=pt.originControlId||null}return Rt},J=e.getMode()===s.EditorMode.FORM,A=J&&E?.control?.type===s.ControlType.TEXT,x=J&&!A?e.getControl().getActiveTextControlLimit():null;let k=V;const lt=(Z,G)=>!!Z&&!!G&&Z.controlId===G,Ft=(Z,G,q)=>{if(q){for(let Rt=G;Rt>=0;Rt--){const pt=Z[Rt];if(lt(pt,q)&&!pt.originControlId&&pt.control?.type)return pt.control.type;if(pt.controlId&&pt.controlId!==q&&pt.originControlId!==q)break}for(let Rt=G+1;Rt<Z.length;Rt++){const pt=Z[Rt];if(lt(pt,q)&&!pt.originControlId&&pt.control?.type)return pt.control.type;if(pt.controlId&&pt.controlId!==q&&pt.originControlId!==q)break}}},Qt=(Z,G)=>!!(J&&Z?.controlId&&!Z.originControlId&&Ft(y,G,Z.controlId)===s.ControlType.TEXTFIELD),ge=(Z,G)=>!!(J&&Z?.controlId&&!Z.originControlId&&Ft(y,G,Z.controlId)===s.ControlType.TEXT),ee=F[V],K=y[V-1],$=y[V+1],_=6,rt=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],ct=(Z,G)=>!!(Z?.controlId&&Z.controlId===G?.controlId&&(Z.originControlId||null)===(G.originControlId||null)),nt=(Z,G)=>{if(Z?.control?.type)return Z.control.type;if(Z?.controlId){for(let q=G;q>=0;q--){const Rt=y[q];if(!ct(Z,Rt))break;if(Rt.control?.type)return Rt.control.type}for(let q=G+1;q<y.length;q++){const Rt=y[q];if(!ct(Z,Rt))break;if(Rt.control?.type)return Rt.control.type}}},ut=(Z,G)=>{const q=nt(Z,G);return!!(q&&rt.includes(q))},ft=Z=>!!(Z&&(Z.controlComponent===s.ControlComponent.POSTFIX||Z.controlComponent===s.ControlComponent.POST_TEXT||Z.controlComponent===s.ControlComponent.POSTTEXTFIX||Z.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)),It=Z=>!!(Z&&(Z.controlComponent===s.ControlComponent.PREFIX||Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)),wt=(Z,G)=>{if(!Z?.controlId)return-1;for(let q=G;q>=0;q--){const Rt=y[q];if(!ct(Z,Rt))break;if(Rt.controlComponent===s.ControlComponent.VALUE)return q}for(let q=G+1;q<y.length;q++){const Rt=y[q];if(!ct(Z,Rt))break;if(Rt.controlComponent===s.ControlComponent.VALUE)return q}return-1},Gt=(Z,G)=>{if(!Z)return!1;if(Z.controlComponent===s.ControlComponent.VALUE||Z.controlComponent===s.ControlComponent.PLACEHOLDER)return!0;const q=nt(Z,G),Rt=q===s.ControlType.SELECT||q===s.ControlType.DATE,pt=Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||Z.controlComponent===s.ControlComponent.TEXTFIXLABEL;return!!(Rt&&pt&&Z.value&&wt(Z,G)===-1)},Mt=Z=>{const G=F[Z];if(!G)return!1;const{coordinate:{leftTop:q,rightTop:Rt,leftBottom:pt}}=G;return o.offsetX>=q[0]&&o.offsetX<Rt[0]&&o.offsetY>=q[1]&&o.offsetY<=pt[1]},_t=(Z,G)=>{if(e.getMode()!==s.EditorMode.EDIT||!Z?.originControlId||Z.controlComponent!==s.ControlComponent.VALUE||nt(Z,G)!==s.ControlType.BUTTON||Z.control?.buttonText||Ft(y,G,Z.originControlId)!==s.ControlType.TEXTFIELD||!Mt(G))return!1;let q=-1;for(let Xe=G;Xe<y.length;Xe++){const ln=y[Xe];if(!ct(Z,ln))break;const Re=F[Xe];ln.controlComponent===s.ControlComponent.VALUE&&Re&&Re.coordinate.rightTop[0]>Re.coordinate.leftTop[0]&&(q=Xe)}if(q===-1)return!1;const Rt=F[q],{coordinate:{leftTop:pt,rightTop:At,leftBottom:vt}}=Rt;return o.offsetX>=pt[0]-2&&o.offsetX<=At[0]&&o.offsetY>=pt[1]&&o.offsetY<=vt[1]},$t=(Z,G)=>!(!T||!ut(Z,G)||!Mt(G)||_t(Z,G)||!Gt(Z,G)||ft(Z)||It(Z)&&!Z?.value),yt=()=>[R.isTable?R.tdValueIndex:R.index,V,V+1,V-1,V+2,V-2].filter((G,q,Rt)=>typeof G=="number"&&G>=0&&G<y.length&&Rt.indexOf(G)===q),St=()=>{if(!T)return null;for(const Z of yt()){const G=y[Z];if($t(G,Z))return{element:G,index:Z}}return null},Pt=()=>{if(!T)return-1;for(const Z of yt())if(_t(y[Z],Z))return Z;return-1},ne=Z=>{const G=y[Z];let q=Z;for(let Rt=Z+1;Rt<y.length&&ct(G,y[Rt]);Rt++)q=Rt;return q},Zt=yt().some(Z=>ut(y[Z],Z)),Xt=St(),Lt=Pt(),Et=Z=>(Z?.control?.type===s.ControlType.TEXTFIELD||Z?.control?.type===s.ControlType.TEXT)&&(Z.controlComponent===s.ControlComponent.POSTFIX||Z.controlComponent===s.ControlComponent.POST_TEXT||Z.controlComponent===s.ControlComponent.POSTTEXTFIX||Z.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT),bt=Z=>Z?.type===s.ElementType.CONTROL&&(Z.controlComponent===s.ControlComponent.POSTFIX||Z.controlComponent===s.ControlComponent.POST_TEXT||Z.controlComponent===s.ControlComponent.POSTTEXTFIX||Z.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT),pe=Z=>Z?.type===s.ElementType.CONTROL&&(Z.controlComponent===s.ControlComponent.PREFIX||Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT),Ct=(Z,G)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&Et(Z)&&G?.controlId===Z.originControlId&&!G.originControlId&&G.control?.type===s.ControlType.TEXTFIELD&&Et(G)),et=(Z,G)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&Et(Z)&&G?.controlId===Z.originControlId&&!G.originControlId&&G.control?.type===s.ControlType.TEXTFIELD&&G.controlComponent===s.ControlComponent.VALUE),Wt=(Z,G,q)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&q?.originControlId===Z.originControlId&&Z.controlId&&q.controlId&&Z.controlId!==q.controlId&&bt(Z)&&pe(q)&&Ft(y,G,Z.originControlId)===s.ControlType.TEXTFIELD),at=Ct(E,$),xt=et(E,$),B=Wt(E,V,$),ot=Wt(K,V-1,E),mt=!!(e.getMode()===s.EditorMode.EDIT&&C&&T&&Et(E)&&!at&&!xt&&!B&&K?.controlId===E.controlId&&(K.originControlId||null)===(E.originControlId||null)&&(K.controlComponent===s.ControlComponent.VALUE||K.controlComponent===s.ControlComponent.PLACEHOLDER)),it=(Z,G,q)=>!!(J&&v(Z)&&Ft(y,G,Z?.originControlId)===q&&(q===s.ControlType.TEXTFIELD?Qt(y[G+1],G+1):ge(y[G+1],G+1))),de=(Z,G,q)=>!!(J&&w(Z)&&Ft(y,G,Z?.originControlId)===q&&(q===s.ControlType.TEXTFIELD?Qt(y[G-1],G-1):ge(y[G-1],G-1))),kt=it(E,V,s.ControlType.TEXTFIELD),zt=!!(J&&ee&&Qt(E,V)&&it(K,V-1,s.ControlType.TEXTFIELD)&&o.offsetX<=ee.coordinate.leftTop[0]+_),xn=!!(J&&ee&&Qt(E,V)&&de($,V+1,s.ControlType.TEXTFIELD)&&o.offsetX>=ee.coordinate.rightTop[0]-_),gn=!!(J&&ee&&kt&&o.offsetX>ee.coordinate.rightTop[0]),Pe=!!(J&&ee&&w(E)&&Ft(y,V,E.originControlId)===s.ControlType.TEXTFIELD&&Qt(K,V-1)&&o.offsetX<ee.coordinate.leftTop[0]),We=Qt(E,V)||kt||zt||xn||gn||Pe,Af=it(E,V,s.ControlType.TEXT),Vl=Z=>{const G=y[Z],q=W[Z];if(!q||!ge(G,Z))return-1;const Rt=y[Z-1];return!it(Rt,Z-1,s.ControlType.TEXT)||o.offsetX>q.coordinate.leftTop[0]+_?-1:Z-1},fs=Vl(V),Wl=Vl(V-1),Yl=fs!==-1||Wl!==-1,Ul=!!(J&&ee&&w(E)&&Ft(y,V,E.originControlId)===s.ControlType.TEXT&&ge(K,V-1)&&o.offsetX<ee.coordinate.leftTop[0]),kf=!!(J&&ee&&ge(E,V)&&de($,V+1,s.ControlType.TEXT)&&o.offsetX>=ee.coordinate.rightTop[0]-_),Gf=Af||Yl||Ul||kf;at||xt||B?k=V:ot||mt?k=Math.max(V-1,0):Yl?k=fs!==-1?fs:Wl:Ul&&(k=Math.max(V-1,0)),Xt?(k=Xt.index,r.setPositionContext({...r.getPositionContext(),index:Xt.index,isControl:!0,isDirectHit:!0})):Lt!==-1?k=ne(Lt):ut(E,V)&&ee&&!Mt(V)&&o.offsetX>ee.coordinate.rightTop[0]&&(k=ne(V));let wl=!1;if(J&&x?.parentControlId&&E?.controlId===x.parentControlId&&!E?.originControlId)for(let Z=V;Z>=0;Z--){const G=D[Z];if(lt(G,x.parentControlId)){G.control?.type===s.ControlType.TEXTFIELD&&(wl=!0);break}if(G.controlId!==x.parentControlId)break}const Zl=!!(x&&(!E?.controlId||E.controlId===x.controlId&&(E.originControlId||null)===x.originControlId||x.parentControlId&&E.controlId===x.parentControlId&&!E.originControlId&&wl));if(J&&!A&&(E?.controlId||E?.originControlId)){let Z;const G=E.originControlId||E.controlId;for(let q=V;q>=0;q--){const Rt=D[q];if(lt(Rt,G)&&Rt.control?.type){Z=Rt.control.type;break}if(Rt.controlId!==E.controlId&&Rt.controlId!==G)break}if(Z!==s.ControlType.TEXT){if(Z===s.ControlType.TEXTFIELD){const q=E.controlComponent;if(!Q(E)){if(!(E.controlComponent===s.ControlComponent.VALUE&&U(E))){if(q===s.ControlComponent.PRETEXTFIX||q===s.ControlComponent.PRETEXTFIX_TEXT||q===s.ControlComponent.POSTTEXTFIX||q===s.ControlComponent.POSTTEXTFIX_TEXT||q===s.ControlComponent.TEXTFIXLABEL||q===s.ControlComponent.PREFIX||q===s.ControlComponent.POSTFIX||q===s.ControlComponent.PRE_TEXT||q===s.ControlComponent.POST_TEXT||q===s.ControlComponent.PLACEHOLDER)for(let Rt=V+1;Rt<D.length;Rt++){const pt=D[Rt];if(pt.controlId!==G&&pt.originControlId!==G)break;if(pt.controlComponent===s.ControlComponent.VALUE&&!U(pt)){k=Rt;break}if(pt.controlComponent===s.ControlComponent.POSTTEXTFIX||pt.controlComponent===s.ControlComponent.POSTFIX){for(let At=V-1;At>=0;At--){const vt=D[At];if(vt.controlId!==G&&vt.originControlId!==G)break;if(vt.controlComponent===s.ControlComponent.VALUE&&!U(vt)){k=At;break}}break}}else if(q===s.ControlComponent.VALUE&&V>0){const Rt=D[V-1];if(Rt&&(Rt.controlId===G||Rt.originControlId===G)&&Rt.controlComponent===s.ControlComponent.VALUE&&U(Rt)){let pt=!1;for(let At=V-2;At>=0;At--){const vt=D[At];if(vt.controlId!==G&&vt.originControlId!==G||vt.controlComponent!==s.ControlComponent.VALUE&&!vt.originControlId&&vt.controlId===G)break;if(!U(vt)){k=At+1,pt=!0;break}}if(!pt)for(let At=V;At<D.length;At++){const vt=D[At];if(vt.controlId!==G&&vt.originControlId!==G||(vt.controlComponent===s.ControlComponent.POSTTEXTFIX||vt.controlComponent===s.ControlComponent.POSTFIX)&&!vt.originControlId&&vt.controlId===G)break;if(!U(vt)){k=At,pt=!0;break}}}}}}}}}if(J&&E?.control?.type===s.ControlType.TEXT&&E?.originControlId&&E.controlComponent===s.ControlComponent.PLACEHOLDER&&j(E.originControlId)&&(k=V),~g&&We&&!Xt)t.isAllowSelection=!1,e.getControl().destroyControl({isEmitEvent:!1}),e.render({isCompute:!1,isSubmitHistory:!1,isSetCursor:!1});else if(~g&&!i){Zl&&(k=Math.min(Math.max(k,x.startIndex),x.endIndex));let Z=k,G=k;if(o.shiftKey){const{startIndex:pt}=l.getRange();~pt&&r.getPositionContext().tdId===u.tdId&&(V>pt?Z=pt:G=pt)}Zl&&(Z=Math.min(Math.max(Z,x.startIndex),x.endIndex),G=Math.min(Math.max(G,x.startIndex),x.endIndex),k=Math.min(Math.max(k,x.startIndex),x.endIndex));const q=e.getControl(),Rt=!!Xt;q.setPopupAwakeDisabled(o.button===In.RIGHT||Gf&&!Rt||Zt&&!Rt);try{l.setRange(Z,G)}finally{q.setPopupAwakeDisabled(!1)}if(r.setCursorPosition(W[k]),n=e.isReadonly(),N&&!n)tr(E,e);else if(P&&!n)er(E,e);else if(!n&&E.controlComponent===s.ControlComponent.VALUE&&(E.control?.type===s.ControlType.CHECKBOX||E.control?.type===s.ControlType.RADIO)){let pt=V;for(;pt>0;){const At=D[pt];if(At.controlComponent===s.ControlComponent.CHECKBOX){tr(At,e);break}else if(At.controlComponent===s.ControlComponent.RADIO){er(At,e);break}pt--}}else{const pt=!!(Xt&&nt(Xt.element,Xt.index)===s.ControlType.BUTTON&&!Xt.element.control?.buttonText);let At=!1;if(J&&E?.controlId&&E?.controlComponent===s.ControlComponent.VALUE&&!E.originControlId){let ln=!1;for(let Re=V;Re>=0;Re--){const Ye=D[Re];if(Ye.controlId!==E.controlId){if(Ye.originControlId===E.controlId){ln=!0;continue}break}if(Ye.control?.type===s.ControlType.TEXTFIELD){if(ln)break;At=!0;break}}if(!ln&&!At)for(let Re=V+1;Re<D.length;Re++){const Ye=D[Re];if(Ye.controlId!==E.controlId){if(Ye.originControlId===E.controlId){ln=!0;continue}break}}ln&&(At=!1)}const vt=At&&U(E),kl=X&&!vt?k+1:void 0;e.render({curIndex:X&&!vt?kl:k,isCompute:!1,isSubmitHistory:!1,isSetCursor:!S&&!N&&!P&&!(pt&&J)&&!vt});const Xe=D[k];if(!n&&Rt&&Xe?.controlId&&o.button===In.LEFT){const Re=e.getControl().getActiveControl(),Ye=Re?.getElement()?.control?.type;Re&&(Ye===s.ControlType.NUMBER||Ye===s.ControlType.SELECT||Ye===s.ControlType.DATE||Ye===s.ControlType.BUTTON)&&Re.getElement()?.controlId===Xe.controlId&&Xe.controlComponent!==s.ControlComponent.POSTFIX&&Xe.controlComponent!==s.ControlComponent.POSTTEXTFIX&&Xe.controlComponent!==s.ControlComponent.POSTTEXTFIX_TEXT&&Xe.controlComponent!==s.ControlComponent.POST_TEXT&&typeof Re.awake=="function"&&Re.awake()}}b&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:b})}const Be=e.getEventBus();if(Y&&Be.isSubscribe("labelMousedown")&&Be.emit("labelMousedown",{evt:o,element:E}),X&&(E.type===s.ElementType.MACRO||E.type===s.ElementType.CUSTOM_MACRO||E.type===s.ElementType.REUSABLE_ITEM)){const Z=e.getMode();if(Z===s.EditorMode.EDIT&&E.type===s.ElementType.CUSTOM_MACRO)Be.isSubscribe("macroClick")&&Be.emit("macroClick",{evt:o,element:E});else if(Z===s.EditorMode.FORM){let G=!1;E.type===s.ElementType.CUSTOM_MACRO&&o.button===In.LEFT&&!n&&(G=e.getMacroParticle().activateInlineEditor(E,V)),!G&&Be.isSubscribe("macroValueChange")&&Be.emit("macroValueChange",{evt:o,element:E})}}o.button===In.LEFT&&X&&E.type===s.ElementType.SUB_TEMPLATE&&e.getMode()===s.EditorMode.FORM&&Be.isSubscribe("subTemplateClick")&&Be.emit("subTemplateClick",{evt:o,element:E});const Ql=e.getPreviewer();if(Ql.clearResizer(),S){if(!e.isPrintLikeMode()){const Z={dragDisable:n||!E.controlId&&e.getMode()===s.EditorMode.FORM};E.type===s.ElementType.LATEX&&(Z.mime="svg",Z.srcKey="laTexSVG"),Ql.drawResizer(E,W[V],Z),e.getCursor().drawCursor({isShow:!1}),qs(t),(E.imgDisplay===s.ImageDisplay.SURROUND||E.imgDisplay===s.ImageDisplay.FLOAT_TOP||E.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(E)}Be.isSubscribe("imageMousedown")&&Be.emit("imageMousedown",{evt:o,element:E})}const vl=e.getTableTool();vl.dispose(),M&&!n&&e.getMode()!==s.EditorMode.FORM&&vl.render();const ms=e.getHyperlinkParticle();ms.clearHyperlinkPopup(),E.type===s.ElementType.HYPERLINK&&(He(o)?ms.openHyperlink(E):ms.drawHyperlinkPopup(E,W[V]));const Kl=e.getDateParticle();Kl.clearDatePicker(),E.type===s.ElementType.DATE&&!n&&Kl.renderDatePicker(E,W[V]);const Hl=e.getMenstrualHistoryParticle();Hl.clearMenstrualHistoryEditor(),E.type===s.ElementType.MENSTRUAL_HISTORY&&T&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&Hl.renderMenstrualHistoryEditor(E,W[V]);const _l=e.getFetalHeartPositionParticle();_l.clearFetalHeartPositionEditor(),E.type===s.ElementType.FETAL_HEART_POSITION&&T&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&_l.renderFetalHeartPositionEditor(E,W[V]);const Al=e.getToothPositionParticle();Al.clearToothPositionEditor(),E.type===s.ElementType.TOOTH_POSITION&&T&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&Al.renderToothPositionEditor(E,W[V])}function So(o){const t=Tt();return Reflect.set(o,"dragId",t),t}function Xo(o,t){return t.findIndex(e=>e.dragId===o)}function nr(o,t,e){const n=e.getDraw();if(o.imgDisplay===s.ImageDisplay.SURROUND||o.imgDisplay===s.ImageDisplay.FLOAT_TOP||o.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM){const i=t.offsetX-e.mouseDownStartPosition.x,l=t.offsetY-e.mouseDownStartPosition.y,r=o.imgFloatPosition;o.imgFloatPosition={x:r.x+i,y:r.y+l,pageNo:n.getPageNo()}}n.getImageParticle().destroyFloatImage()}function Nc(o,t){if(t.isAllowDrop){const e=t.getDraw();if(e.isReadonly()||e.isDisabled()){t.mousedown(o);return}const n=e.getPosition(),i=n.getPositionList(),l=n.getPositionContext(),r=e.getRange(),a=t.cacheRange,c=t.cacheElementList,d=t.cachePositionList,u=t.cachePositionContext,R=r.getRange(),h=a.startIndex===a.endIndex,g=h?a.startIndex-1:a.startIndex,T=a.endIndex;if(R.startIndex>=g&&R.endIndex<=T&&t.cachePositionContext?.tdId===l.tdId){e.clearSideEffect();let A=!1,x=!1;if(h){const k=c[T];if(k.type===s.ElementType.IMAGE||k.type===s.ElementType.LATEX){if(nr(k,o,t),k.imgDisplay===s.ImageDisplay.SURROUND||k.imgDisplay===s.ImageDisplay.FLOAT_TOP||k.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(k),A=!0;else{const lt=d[T];e.getPreviewer().drawResizer(k,lt)}x=k.imgDisplay===s.ImageDisplay.SURROUND}}r.replaceRange({...a}),e.render({isCompute:x,isSubmitHistory:A,isSetCursor:!1});return}const f=c.slice(g+1,T+1),m=f.find(A=>A.controlId);if(m){const A=c[g+1],x=c[T];if(!((!A.controlId||A.controlComponent===s.ControlComponent.PREFIX)&&(!x.controlId||x.controlComponent===s.ControlComponent.POSTFIX)||A.controlId===x.controlId&&A.controlComponent===s.ControlComponent.PREFIX&&x.controlComponent===s.ControlComponent.POSTFIX||A.control?.type===s.ControlType.TEXT&&A.controlComponent===s.ControlComponent.VALUE&&x.control?.type===s.ControlType.TEXT&&x.controlComponent===s.ControlComponent.VALUE)){e.render({curIndex:R.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const C=e.getControl(),I=e.getElementList(),p=!m||!!I[R.startIndex].controlId||!C.getIsElementListContainFullControl(f),L=e.getOptions(),M=f.map(A=>{if(!A.type||A.type===s.ElementType.TEXT){const x={value:A.value},k=Ne;return p||k.push(...di),k.forEach(lt=>{const Ft=A[lt];Ft!==void 0&&(x[lt]=Ft)}),x}else{let x=ht(A);return p&&(x=Ce(x,di)),jt([x],{isHandleFirstElement:!1,editorOptions:L}),x}});re(I,M,R.startIndex,{editorOptions:e.getOptions()});const O=c[g],b=d[g],D=So(c[g]),W=So(c[T]),V=M.length;let E=R.startIndex,y=E+V;const F=C.getActiveControl();if(F&&c[E].controlComponent!==s.ControlComponent.POSTFIX?(y=F.setValue(M),E=y-V):e.spliceElementList(I,E+1,0,M),!~y){e.render({isSetCursor:!1});return}const S=So(I[E]),N=So(I[y]),P=Xo(D,c),Y=Xo(W,c),X=c[Y];if(X.controlId&&X.controlComponent!==s.ControlComponent.POSTFIX)r.replaceRange({...a,startIndex:P,endIndex:Y}),C.getActiveControl()?.cut();else{let A=!0;if(u?.isTable){const{tableId:x,trIndex:k,tdIndex:lt}=u;A=!e.getOriginalElementList().some(Qt=>Qt.id===x&&Qt?.trList?.[k]?.tdList?.[lt]?.deletable===!1)}A&&e.spliceElementList(c,P+1,Y-P)}const U=I[R.startIndex],Q=i[R.startIndex];let v=l.index;v&&(U.tableId&&!O.tableId?b.index<v&&(v-=V):!U.tableId&&O.tableId&&Q.index<v&&(v+=V),n.setPositionContext({...l,index:v}));const w=Xo(S,I),j=Xo(N,I);r.setRange(h?j:w,j,R.tableId,R.startTdIndex,R.endTdIndex,R.startTrIndex,R.endTrIndex),e.clearSideEffect();let J=null;if(h){const x=e.getElementList()[j];(x.type===s.ElementType.IMAGE||x.type===s.ElementType.LATEX)&&(nr(x,o,t),J=x)}if(e.render({isSetCursor:!1}),F?C.emitControlContentChange():O.controlId&&C.emitControlContentChange({context:{range:a,elementList:c},controlElement:O}),J)if(J.imgDisplay===s.ImageDisplay.SURROUND||J.imgDisplay===s.ImageDisplay.FLOAT_TOP||J.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(J);else{const x=n.getPositionList()[j];e.getPreviewer().drawResizer(J,x)}}else t.isAllowDrag&&t.cacheRange?.startIndex!==t.cacheRange?.endIndex&&t.mousedown(o)}function Fc(o,t){const e=t.getDraw();if(!e.getOptions().pageOuterSelectionDisable)return;const n=e.getPageContainer(),{x:i,y:l,width:r,height:a}=n.getBoundingClientRect();o.x>=i&&o.x<=i+r&&o.y>=l&&o.y<=l+a||t.setIsAllowSelection(!1)}function yc(o,t){const e=t.getDraw(),n=e.getControl(),i=e.getPageList(),l=e.getPageNo(),r=i[l],a=e.getPosition(),c=a.getPositionByXY({x:o.offsetX,y:o.offsetY});if(~c.index){const N=c.isTable?e.getTdByPosition({...c,isTable:!0,index:c.index}):null,P=c.isTable&&N?.value||e.getElementList(),Y=c.isTable&&N?.positionList||a.getPositionList(),X=c.isTable?c.tdValueIndex:c.index,U=e.getMode(),Q=U===s.EditorMode.EDIT||U===s.EditorMode.FORM,v=[X,X+1,X-1,X+2,X-2].filter((A,x,k)=>A>=0&&A<P.length&&k.indexOf(A)===x),w=A=>{const x=Y[A];if(!x)return!1;const{coordinate:{leftTop:k,rightTop:lt,leftBottom:Ft}}=x;return lt[0]>k[0]&&o.offsetX>=k[0]&&o.offsetX<lt[0]&&o.offsetY>=k[1]&&o.offsetY<=Ft[1]},j=Q&&v.some(A=>{const k=P[A]?.control?.type;return k!==s.ControlType.NUMBER&&k!==s.ControlType.SELECT&&k!==s.ControlType.DATE?!1:w(A)}),J=v.some(A=>{const x=P[A];return!!(x?.control?.type===s.ControlType.BUTTON&&!x.control.buttonText&&(x.controlComponent===s.ControlComponent.VALUE||x.controlComponent===s.ControlComponent.PLACEHOLDER)&&w(A))});r&&(j||J)?r.style.cursor="pointer":r&&(r.style.cursor="text")}else r&&(r.style.cursor="text");if(t.isAllowDrag){if(e.isContentReadonly()){t.setIsAllowDrag(!1);return}const N=o.offsetX,P=o.offsetY,{startIndex:Y,endIndex:X}=t.cacheRange,U=t.cachePositionList;for(let v=Y+1;v<=X;v++){const{coordinate:{leftTop:w,rightBottom:j}}=U[v];if(N>=w[0]&&N<=j[0]&&P>=w[1]&&P<=j[1])return}const Q=t.cacheRange?.startIndex;if(Q){const v=t.cacheElementList[Q];v?.type===s.ElementType.IMAGE&&(v.imgDisplay===s.ImageDisplay.SURROUND||v.imgDisplay===s.ImageDisplay.FLOAT_TOP||v.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)&&(e.getPreviewer().clearResizer(),e.getImageParticle().dragFloatImage(o.movementX,o.movementY))}t.dragover(o),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const u=o.target.dataset.index;u&&e.setPageNo(Number(u));const R=e.getPosition(),h=R.getPositionByXY({x:o.offsetX,y:o.offsetY});if(!~h.index)return;const{index:g,isTable:T,tdValueIndex:f,tdIndex:m,trIndex:C,tableId:I,trId:p,tdId:L}=h;let M=T?f:g;if(h.isControl&&e.getMode()!==s.EditorMode.READONLY){const{newIndex:N}=n.moveCursor({index:g,isTable:T,trIndex:C,tdIndex:m,tdValueIndex:f});M=N}const{index:O,isTable:b,tdIndex:D,tdId:W,trIndex:V,tableId:E}=t.mouseDownStartPosition,y=M,F=e.getRange();let S;if(L!==W&&L&&W){const N=e.getTdByPosition({...t.mouseDownStartPosition,isTable:!!t.mouseDownStartPosition.tableId,index:t.mouseDownStartPosition.originalIndex??t.mouseDownStartPosition.index}),P=e.getTdByPosition({...h,isTable:!!h.tableId,index:h.index});if(e.isSplitTd(N,P)){const Y=(N.valueStartIndex??0)+O,X=(P.valueStartIndex??0)+f;S=[{index:Y,element:N.value[O],originalId:N.originalId,isCurrent:!1,length:N.value.length,startIndex:N.valueStartIndex??0},{index:X,element:P.value[f],originalId:P.originalId,isCurrent:!0,length:P.value.length,startIndex:P.valueStartIndex??0}]}}if(T&&b&&L!==W&&!S)F.setRange(y,y,I,D,m,V,C),R.setPositionContext({isTable:!!T,index:g,trIndex:C,tdIndex:m,tdId:L,trId:p,tableId:I});else{let N=~y?y:0;if((b||T)&&E!==I&&!S)return;R.setPositionContext({isTable:!!T,index:g,trIndex:C,tdIndex:m,tdId:L,trId:p,tableId:I});let P=O,Y,X;if(S)[{element:Y},{element:X}]=S;else{const v=e.getElementList();Y=v[P+1],X=v[N]}if(P===N||Y?.controlComponent===s.ControlComponent.PLACEHOLDER&&X?.controlComponent===s.ControlComponent.PLACEHOLDER&&Y.controlId===X.controlId)return;if(P>N&&([P,N]=[N,P]),e.getMode()===s.EditorMode.FORM){const w=n.getActiveControl()?.getElement()?.control?.type===s.ControlType.TEXT?null:n.getActiveTextControlLimit();w&&(P=Math.min(Math.max(P,w.startIndex),w.endIndex),N=Math.min(Math.max(N,w.startIndex),w.endIndex));const j=e.getElementList(),J=j[P],A=j[N];if(J?.control?.type===s.ControlType.TEXTFIELD||A?.control?.type===s.ControlType.TEXTFIELD){const x=J?.controlId||A?.controlId;if(x){let k=-1,lt=-1;for(let Ft=P;Ft>=0;Ft--){const Qt=j[Ft];if(Qt.controlId!==x)break;if(Qt.controlComponent===s.ControlComponent.PRETEXTFIX||Qt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||Qt.controlComponent===s.ControlComponent.TEXTFIXLABEL||Qt.controlComponent===s.ControlComponent.PREFIX||Qt.controlComponent===s.ControlComponent.PRE_TEXT){k=Ft+1;break}}for(let Ft=N;Ft<j.length;Ft++){const Qt=j[Ft];if(Qt.controlId!==x)break;if(Qt.controlComponent===s.ControlComponent.POSTTEXTFIX||Qt.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||Qt.controlComponent===s.ControlComponent.POSTFIX||Qt.controlComponent===s.ControlComponent.POST_TEXT){lt=Ft-1;break}}k!==-1&&P<k&&(P=k),lt!==-1&&N>lt&&(N=lt)}}}let Q;if(S){const[v,w]=S.sort((j,J)=>j.index-J.index);Q={originalId:S[0].originalId??S[1].originalId,startIndex:v.index,endIndex:w.index},v.isCurrent?(P=v.index,N=v.length-1):(P=0,N=Q.endIndex-w.startIndex)}F.setRange(P,N,void 0,void 0,void 0,void 0,void 0,Q)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function No(o,t){if(!t)return null;const e=new Set;let n=t,i=null;for(;n&&!e.has(n);){e.add(n);let l=null;for(let r=0;r<o.length;r++){const a=o[r];if(a.controlId===n&&a.control?.type&&(l=a,a.controlComponent===s.ControlComponent.PREFIX||a.controlComponent===s.ControlComponent.PRE_TEXT||a.controlComponent===s.ControlComponent.PRETEXTFIX||a.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!l)break;l.control?.type==="text"&&(i=n),n=l.originControlId||null}return i}function Oi(o,t){return!!o&&!!t&&o.controlId===t}function bc(o,t){const e=o[t];if(!e?.subTemplateParentId)return null;const n=e.subTemplateParentId;for(let i=t-1;i>=0;i--){const l=o[i];if(l.type===s.ElementType.SUB_TEMPLATE&&l.id===n)return{labelIndex:i,labelElement:l};if(l.type===s.ElementType.SUB_TEMPLATE&&l.id!==n)break}return null}function or(o,t,e){const n=o[t];n.subTemplateExpanded=!1,n.hide=!1;let i=t+1;for(;i<o.length&&o[i].subTemplateParentId===n.id;)i++;const l=i-t-1;return l>0&&e.spliceElementList(o,t+1,l),t}function Dc(o){const t=o.getDraw(),e=t.getRange(),n=e.getRange(),i=t.getElementList(),l=i[n.startIndex];if(!ae(l))return;let r=n.startIndex;for(;r>0;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE&&a.subTemplateExpanded){const u=or(i,r,t);n.startIndex=u,n.endIndex=u,e.replaceRange(n);const R=t.getPosition(),h=R.getPositionList();R.setCursorPosition(h[u]);return}let c=null;a.controlId?(c=t.getControl().removeControl(r),c!==null&&(r=c)):(t.spliceElementList(i,r,1),c=r-1,r--);const d=i[c];if(!d||!ae(d)){if(c){n.startIndex=c,n.endIndex=c,e.replaceRange(n);const u=t.getPosition(),R=u.getPositionList();u.setCursorPosition(R[c])}break}}}function Vc(o,t,e){if(e.originControlId){const n=No(o,e.originControlId);if(!n)return{isInParent:!1};for(let i=t;i<o.length;i++){const l=o[i];if(l.controlId===n)return l.controlComponent===s.ControlComponent.POSTFIX||l.controlComponent===s.ControlComponent.POSTTEXTFIX||l.controlComponent===s.ControlComponent.POST_TEXT?{isInParent:!1}:{isInParent:!0,parentControlId:n};if(l.controlId&&l.controlId!==n&&l.originControlId!==n)break}}if(!e.originControlId&&e.controlId){const n=o[t];if(n?.controlId&&n.controlId!==e.controlId&&(n.controlComponent===s.ControlComponent.PREFIX||n.controlComponent===s.ControlComponent.PRETEXTFIX))for(let i=t-1;i>=0;i--){const l=o[i];if(l.controlId===e.controlId&&(l.controlComponent===s.ControlComponent.PREFIX||l.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let r=i-1;r>=0;r--){const a=o[r],c=No(o,a.controlId);if(c&&c!==e.controlId&&(a.controlComponent===s.ControlComponent.PRETEXTFIX||a.controlComponent===s.ControlComponent.PREFIX))return{isInParent:!0,parentControlId:c};if(a.controlId&&a.controlId!==e.controlId&&(a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POSTTEXTFIX))return{isInParent:!1}}break}}if(n?.controlId&&n.controlId!==e.controlId&&!n.originControlId&&(n.controlComponent===s.ControlComponent.POSTFIX||n.controlComponent===s.ControlComponent.POSTTEXTFIX)){if(e.originControlId===n.controlId){const i=No(o,n.controlId);if(i)return{isInParent:!0,parentControlId:i}}return{isInParent:!1}}}return{isInParent:!1}}function Wc(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&Dc(t);const i=e.getControl(),{startIndex:l,endIndex:r,isCrossRowCol:a}=n.getRange();let c;const d=e.getElementList();if(n.getIsCollapsed()&&l>0){const R=d[l-1],h=d[l],g=h?.control?.type===s.ControlType.TEXT&&h.controlComponent===s.ControlComponent.PLACEHOLDER&&!i.getIsExistValueByElementListIndex(d,l);if(R?.subTemplateParentId){const F=bc(d,l-1);if(F){const S=or(d,F.labelIndex,e);e.getGlobalEvent().setCanvasEventAbility(),n.setRange(S,S),e.render({curIndex:S});return}}const f=e.getPosition().getPositionList(),m=f[l],C=f[l-1],I=m&&C&&m.rowIndex===C.rowIndex,p=R?.controlComponent===s.ControlComponent.PREFIX||R?.controlComponent===s.ControlComponent.PRETEXTFIX||R?.controlComponent===s.ControlComponent.PRE_TEXT||R?.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT,L=R?.controlComponent===s.ControlComponent.POSTFIX||R?.controlComponent===s.ControlComponent.POSTTEXTFIX||R?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||R?.controlComponent===s.ControlComponent.POST_TEXT,M=!!R?.controlId,O=h?.controlComponent===s.ControlComponent.PLACEHOLDER,b=h?.controlComponent===s.ControlComponent.POSTFIX||h?.controlComponent===s.ControlComponent.POSTTEXTFIX||h?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||h?.controlComponent===s.ControlComponent.POST_TEXT,D=h?.control?.type===s.ControlType.TEXT&&(h.controlComponent===s.ControlComponent.PREFIX||h.controlComponent===s.ControlComponent.PRE_TEXT),W=b&&R?.controlId===h?.controlId&&R?.originControlId===h?.originControlId&&R?.controlComponent===s.ControlComponent.VALUE,V=!!h&&!h.controlId&&!h.control;if(O&&p&&M&&I)return;const{isInParent:E,parentControlId:y}=Vc(d,l,R);if(L&&M&&I&&E&&!(h?.controlId===y&&!h?.originControlId&&(h?.controlComponent===s.ControlComponent.VALUE||h?.controlComponent===s.ControlComponent.PLACEHOLDER))){if(R.originControlId&&y)for(let S=l;S<d.length;S++){const N=d[S];if(Oi(N,y)){if(N.controlComponent===s.ControlComponent.VALUE){n.setRange(S,S),e.render({curIndex:S,isSubmitHistory:!1});return}if(N.controlComponent===s.ControlComponent.POSTFIX||N.controlComponent===s.ControlComponent.POSTTEXTFIX||N.controlComponent===s.ControlComponent.POST_TEXT)return}N.controlId!==y&&N.originControlId}return}if(L&&M&&I&&!E&&!(V&&!O&&!b)){if(D)return;if(g)return;{const F=l-1;c=i.removeControl(F),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(F,F),e.render({curIndex:F,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}}if(b&&h?.originControlId&&E&&y&&I){for(let F=l+1;F<d.length;F++){const S=d[F];if(Oi(S,y)){if(S.controlComponent===s.ControlComponent.VALUE||S.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(F,F),e.render({curIndex:F,isSubmitHistory:!1});return}break}if(S.controlId&&S.controlId!==y&&S.originControlId!==y)break}for(let F=l-1;F>=0;F--){const S=d[F];if(Oi(S,y)){if(S.controlComponent===s.ControlComponent.VALUE||S.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(F,F),e.render({curIndex:F,isSubmitHistory:!1});return}break}if(S.controlId&&S.controlId!==y&&S.originControlId!==y)break}return}if(e.getMode()===s.EditorMode.FORM&&b&&h?.originControlId&&I){const F=No(d,h.originControlId);if(!F)return;for(let S=l-1;S>=0;S--){const N=d[S];if(N.controlId===F&&!N.originControlId){if(N.controlComponent===s.ControlComponent.VALUE||N.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(S,S),e.render({curIndex:S,isSubmitHistory:!1});return}if(N.controlComponent===s.ControlComponent.PREFIX||N.controlComponent===s.ControlComponent.PRE_TEXT||N.controlComponent===s.ControlComponent.PRETEXTFIX||N.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)return}if(N.controlId&&N.controlId!==F&&N.originControlId!==F)break}return}if(b&&h?.controlId&&I&&!W){const F=l;c=i.removeControl(F),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(F,F),e.render({curIndex:F,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}}if(a){const R=e.getTableParticle().getRangeRowCol();if(!R)return;let h=!1;for(let g=0;g<R.length;g++){const T=R[g];for(let f=0;f<T.length;f++){const m=T[f];m.value.length>1&&(e.spliceElementList(m.value,1,m.value.length-1),h=!0)}}c=h?0:null}else if(i.getActiveControl()&&i.getIsRangeCanCaptureEvent())c=i.keydown(o),c!==null&&i.emitControlContentChange();else{const R=e.getPosition().getCursorPosition();if(!R)return;const{index:h}=R,g=n.getIsCollapsed(),T=e.getElementList();if(g&&h===0){const I=T[h];if(I.value===H){I.listId&&e.getListParticle().unsetList(),o.preventDefault();return}}const f=T[l];if(g&&f.rowFlex&&f.value===H){const I=n.getRangeRowElementList();if(I){const p=T[l-1];I.forEach(L=>{L.rowFlex=p?.rowFlex})}}const m=f.value===H?T[l-1]:f,C=T[r+1];if(m?.titleId&&C?.titleId&&m.level===C.level&&m.titleId!==C.titleId){const I=m.titleId,p=C.titleId;let L=r+1;for(;L<T.length&&T[L]?.titleId===p;)T[L].titleId=I,L++}g?e.spliceElementList(T,h,1):e.spliceElementList(T,l+1,r-l),c=g?h-1:l}e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(l,l),e.render({curIndex:l,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}))}function ir(o,t,e){const n=o[t];n.subTemplateExpanded=!1,n.hide=!1;let i=t+1;for(;i<o.length&&o[i].subTemplateParentId===n.id;)i++;const l=i-t-1;return l>0&&e.spliceElementList(o,t+1,l),t}function Yc(o){const t=o.getDraw(),n=t.getRange().getRange(),i=t.getElementList(),l=i[n.startIndex+1];if(!ae(l))return;const r=n.startIndex+1;for(;r<i.length;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE&&a.subTemplateExpanded){ir(i,r,t);return}let c=null;a.controlId?c=t.getControl().removeControl(r):(t.spliceElementList(i,r,1),c=r);const d=i[c];if(!d||!ae(d))break}}function Uc(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:l,isCrossRowCol:r,splitTdRange:a}=n.getRange(),c=e.getElementList(),d=e.getControl();n.getIsCollapsed()&&Yc(t);let u;if(r){const R=e.getTableParticle().getRangeRowCol();if(!R)return;let h=!1;for(let g=0;g<R.length;g++){const T=R[g];for(let f=0;f<T.length;f++){const m=T[f];m.value.length>1&&(e.spliceElementList(m.value,1,m.value.length-1),h=!0)}}u=h?0:null}else if(d.getActiveControl()&&d.getIsRangeWithinControl())u=d.keydown(o),u!==null&&d.emitControlContentChange();else if(c[l+1]?.controlId)u=d.removeControl(l+1);else if(n.getIsCollapsed()&&c[l+1]?.subTemplateParentId){const R=c[l+1].subTemplateParentId;let h=-1;for(let g=l;g>=0;g--){const T=c[g];if(T.type===s.ElementType.SUB_TEMPLATE&&T.id===R){h=g;break}}h!==-1?u=ir(c,h,e):u=null}else{e.removeSplitTdOtherRangeElements();const R=e.getPosition(),h=R.getCursorPosition();if(!h)return;const{index:g}=h,T=R.getPositionContext();if(T.isDirectHit&&T.isImage)e.spliceElementList(c,g,1),u=g-1;else{const f=n.getIsCollapsed();if(!f)e.spliceElementList(c,i+1,l-i);else if(c[g+1])e.spliceElementList(c,g+1,1);else{let m=!0;if(T.isTable){const C=e.getTd();if(C?.linkTdNextId){const I=e.getTdById(C.linkTdNextId);I&&(m=!1,e.spliceElementList(I.value,1,1))}}if(m)return}u=f?g:i,u===0&&a&&(u=e.fixPosition(!0)??u)}}e.getGlobalEvent().setCanvasEventAbility(),u===null?(n.setRange(i,i),e.render({curIndex:i,isSubmitHistory:!1})):(n.setRange(u,u),e.render({curIndex:u}))}function wc(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:l}=n.getRange(),r=n.getIsCollapsed(),a=e.getElementList(),c=a[i],d=a[l];if(r&&d.listId&&d.value===H&&a[l+1]?.listId!==d.listId){e.getListParticle().unsetList();return}let u={value:H};if(o.shiftKey&&c.listId&&(u.listWrap=!0),re(a,[u],i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),o.shiftKey&&d.areaId&&d.areaId!==a[l+1]?.areaId&&(u=Ce(u,mn)),!(a[i+1]?.titleId&&(!c.titleId||c.titleId!==a[i+1]?.titleId))&&!(d.titleId&&d.titleId!==a[l+1]?.titleId)){const m=n.getRangeAnchorStyle(a,l);if(m){const C=[...Te],I=m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||m.controlComponent===s.ControlComponent.POST_TEXT,p=m.control?.type===s.ControlType.BUTTON&&!m.control?.buttonText;!I&&!p&&C.push(...Ne),C.forEach(L=>{const M=m[L];M!==void 0&&(u[L]=M)})}}const R=e.getControl(),h=R.getActiveControl();let g;const T=h?.getElement();if(T?.control?.type===s.ControlType.BUTTON&&!T.control?.buttonText&&T?.controlId){const m=T.controlId;let C=l;for(;C+1<a.length&&a[C+1]?.controlId===m;)C++;e.spliceElementList(a,C+1,0,[u]),g=C+1}else if(h&&R.getIsRangeWithinControl())g=R.setValue([u]),R.emitControlContentChange();else{const C=e.getPosition().getCursorPosition();if(!C)return;const{index:I}=C;if(r){if(e.spliceElementList(a,I+1,0,[u]),d.titleId&&a[I+2]?.titleId===d.titleId){const p=Tt();let L=I+2;for(;L<a.length&&a[L]?.titleId===d.titleId;)a[L].titleId=p,L++}}else e.spliceElementList(a,i+1,l-i,[u]);g=I+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),o.preventDefault()}function sr(o){return o&&(o.type===s.ElementType.MACRO||o.type===s.ElementType.CUSTOM_MACRO||o.type===s.ElementType.REUSABLE_ITEM||o.type===s.ElementType.SUB_TEMPLATE||o.type===s.ElementType.MENSTRUAL_HISTORY||o.type===s.ElementType.FETAL_HEART_POSITION||o.type===s.ElementType.TOOTH_POSITION||o.type===s.ElementType.LIST||o.type===s.ElementType.SPECIAL_SYMBOLS)}function Zc(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),l=i.getCursorPosition();if(!l)return;const r=i.getPositionContext(),{index:a}=l;if(a<=0&&!r.isTable)return;const c=e.getRange(),{startIndex:d,endIndex:u}=c.getRange(),R=c.getIsCollapsed(),h=e.getElementList(),g=e.getControl(),T=e.getMode()===s.EditorMode.FORM,f=g.getActiveControl()?.getElement()?.control?.type,m=T&&f===s.ControlType.TEXT,C=T&&!m?g.getActiveTextControlLimit():null,I=h[a],p=I?.controlComponent===s.ControlComponent.PREFIX||I?.controlComponent===s.ControlComponent.PRETEXTFIX||I?.controlComponent===s.ControlComponent.PRE_TEXT;let L=!1;if(p&&I?.originControlId){const E=I.originControlId;for(let y=a-1;y>=0;y--){const F=h[y];if(F.controlId===E&&!F.originControlId){L=!0;break}if(F.controlId&&F.controlId!==E&&F.originControlId!==E)break}}if(T&&!m&&g.getActiveControl()&&p&&!C&&!L){g.initNextControl({direction:Jt.UP});return}let M=1;if(He(o)){const E=e.getLetterReg(),y=o.shiftKey&&!R&&d===l?.index?u:d;if(E.test(h[y]?.value)){let F=y-1;for(;F>0;){const S=h[F];if(!E.test(S.value))break;M++,F--}}}if(T&&!m){const E=h[d],y=E?.controlId;if(y&&E?.controlComponent===s.ControlComponent.VALUE){let F=!1;for(let S=d;S>=0;S--){const N=h[S];if(N.controlId!==y)break;if(N.control?.type===s.ControlType.TEXTFIELD){F=!0;break}}if(F){if(E.controlComponent===s.ControlComponent.VALUE&&sr(E))return;const S=d-M;if(S>=0){const N=h[S];if(N&&N.controlId===y&&N.controlComponent===s.ControlComponent.VALUE&&sr(N))return}}}}const O=C?Math.max(d-M,C.startIndex):d-M;let b=O,D=O;if(o.shiftKey&&l&&(d!==u?d===l.index?(b=d,D=u-M):(b=O,D=u):D=u),!o.shiftKey){const E=h[d];if(E.type===s.ElementType.TABLE){const y=E.trList,F=y.length-1,S=y[F],N=S.tdList.length-1,P=S.tdList[N];i.setPositionContext({isTable:!0,index:d,trIndex:F,tdIndex:N,tdId:P.id,trId:S.id,tableId:E.id}),b=P.value.length-1,D=b}else if(E.tableId&&d===0){const F=e.getOriginalElementList()[r.index],S=e.getTd();if(S?.linkTdPrevId){const N=e.getTdById(S.linkTdPrevId);N&&(i.setPositionContext({...r,isTable:!0,index:N.tableIndex,trIndex:N.trIndex,tdId:N.id,trId:N.trId,tableId:N.tableId}),b=N.value.length-1,D=b)}else{const N=F.trList;t:for(let P=0;P<N.length;P++){const Y=N[P];if(Y.id!==E.trId)continue;const X=Y.tdList;for(let U=0;U<X.length;U++)if(X[U].id===E.tdId){if(P===0&&U===0)i.setPositionContext({isTable:!1}),b=r.index-1,D=b,e.getTableTool().dispose();else{let v=P,w=U-1;w<0&&(v=P-1,w=N[v].tdList.length-1);const j=N[v],J=j.tdList[w];i.setPositionContext({isTable:!0,index:r.index,trIndex:v,tdIndex:w,tdId:J.id,trId:j.id,tableId:E.tableId}),b=J.value.length-1,D=b}break t}}}}}if(!~b||!~D)return;const W=e.getElementList();b=Wn(W,b),D=Wn(W,D),c.setRange(b,D);const V=b===D;e.updateTableTool(),e.render({curIndex:V?b:void 0,isSetCursor:V,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function rr(o){return o&&(o.type===s.ElementType.MACRO||o.type===s.ElementType.CUSTOM_MACRO||o.type===s.ElementType.REUSABLE_ITEM||o.type===s.ElementType.SUB_TEMPLATE||o.type===s.ElementType.MENSTRUAL_HISTORY||o.type===s.ElementType.FETAL_HEART_POSITION||o.type===s.ElementType.TOOTH_POSITION||o.type===s.ElementType.LIST||o.type===s.ElementType.SPECIAL_SYMBOLS)}function Qc(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),l=i.getCursorPosition();if(!l)return;const{index:r}=l,a=i.getPositionList(),c=i.getPositionContext();if(r>a.length-1&&!c.isTable)return;const d=e.getRange(),{startIndex:u,endIndex:R}=d.getRange(),h=d.getIsCollapsed();let g=e.getElementList();const T=e.getControl(),f=e.getMode()===s.EditorMode.FORM,m=T.getActiveControl()?.getElement()?.control?.type,C=f&&m===s.ControlType.TEXT,I=f&&!C?T.getActiveTextControlLimit():null,p=g[r],L=p?.controlComponent===s.ControlComponent.POSTFIX||p?.controlComponent===s.ControlComponent.POSTTEXTFIX||p?.controlComponent===s.ControlComponent.POST_TEXT;let M=!1;if(L&&p?.originControlId){const F=p.originControlId;for(let S=r+1;S<g.length;S++){const N=g[S];if(N.controlId===F&&!N.originControlId){M=!0;break}if(N.controlId&&N.controlId!==F&&N.originControlId!==F)break}}if(f&&!C&&T.getActiveControl()&&L&&!I&&!M){T.initNextControl({direction:Jt.DOWN});return}let O=1;if(He(o)){const F=e.getLetterReg(),S=o.shiftKey&&!h&&u===l?.index?R:u;if(F.test(g[S+1]?.value)){let N=S+2;for(;N<g.length;){const P=g[N];if(!F.test(P.value))break;O++,N++}}}if(f&&!C){const F=g[R],S=F?.controlId;if(S&&F?.controlComponent===s.ControlComponent.VALUE){let N=!1;for(let P=R;P>=0;P--){const Y=g[P];if(Y.controlId!==S)break;if(Y.control?.type===s.ControlType.TEXTFIELD){N=!0;break}}if(N){if(F.controlComponent===s.ControlComponent.VALUE&&rr(F))return;const P=R+O;if(P<g.length){const Y=g[P];if(Y&&Y.controlId===S&&Y.controlComponent===s.ControlComponent.VALUE&&rr(Y))return}}}}const b=I?Math.min(R+O,I.endIndex):R+O;let D=b,W=b;if(o.shiftKey&&l&&(u!==R?u===l.index?(D=u,W=b):(D=u+O,W=R):D=u),!o.shiftKey){const F=g[R],S=g[R+1];if(S?.type===s.ElementType.TABLE){const P=S.trList[0],Y=P.tdList[0];i.setPositionContext({isTable:!0,index:R+1,trIndex:0,tdIndex:0,tdId:Y.id,trId:P.id,tableId:S.id}),D=0,W=0}else if(F.tableId&&!S){const N=e.getTd(),P=N?.linkTdNextId?e.getTdById(N.linkTdNextId):void 0;if(P?.value.length)i.setPositionContext({...c,isTable:!0,index:P.tableIndex,trIndex:P.trIndex,tdId:P.id,trId:P.trId,tableId:P.tableId}),D=0,W=D;else{const X=e.getOriginalElementList()[c.index].trList;t:for(let U=0;U<X.length;U++){const Q=X[U];if(Q.id!==F.trId)continue;const v=Q.tdList;for(let w=0;w<v.length;w++)if(v[w].id===F.tdId){if(U===X.length-1&&w===v.length-1)i.setPositionContext({isTable:!1}),D=c.index,W=D,g=e.getElementList(),e.getTableTool().dispose();else{let J=U,A=w+1;A>v.length-1&&(J=U+1,A=0);const x=X[J],k=x.tdList[A];i.setPositionContext({isTable:!0,index:c.index,trIndex:J,tdIndex:A,tdId:k.id,trId:x.id,tableId:F.tableId}),D=0,W=D}break t}}}}}const V=g.length-1;if(D>V||W>V)return;const E=e.getElementList();D=Wn(E,D,s.LocationPosition.AFTER),W=Wn(E,W,s.LocationPosition.AFTER),d.setRange(D,W);const y=D===W;e.updateTableTool(),e.render({curIndex:y?D:void 0,isSetCursor:y,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function vc(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getMode()===s.EditorMode.FORM,l=e.getControl(),r=e.getRange(),a=e.getElementList(),{startIndex:c,endIndex:d}=r.getRange(),u=a[c],R=a[d],h=c>0?a[c-1]:null,g=l.getIsRangeWithinControl()||!!u?.controlId||!!R?.controlId||!!h?.controlId;let T=l.getActiveControl();if(i&&g&&(l.initControl(),T=l.getActiveControl()),i&&g)o.preventDefault(),l.initNextControl({direction:o.shiftKey?Jt.UP:Jt.DOWN});else if(T&&l.getIsRangeWithinControl())o.preventDefault(),l.initNextControl({direction:o.shiftKey?Jt.UP:Jt.DOWN});else{o.preventDefault();const f=r.getRangeAnchorStyle(a,d),C={...f?ie(f,Ne):null,type:s.ElementType.TAB,value:""};re(a,[C],c,{editorOptions:e.getOptions()}),e.insertElementList([C])}}function Si(o){const{positionList:t,index:e,isUp:n,rowNo:i,cursorX:l}=o;let r=-1;const a=[];if(n){let c=e-1;for(;c>=0;){const d=t[c];if(c--,d.rowNo!==i){if(a[0]&&a[0].rowNo!==d.rowNo)break;a.unshift(d)}}}else{let c=e+1;for(;c<t.length;){const d=t[c];if(c++,d.rowNo!==i){if(a[0]&&a[0].rowNo!==d.rowNo)break;a.push(d)}}}for(let c=0;c<a.length;c++){const d=a[c],{coordinate:{leftTop:[u],rightTop:[R]}}=d;if(c===a.length-1&&(r=d.index),!(l<u||l>R)){r=d.index;break}}return r}function Kc(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),l=i.getCursorPosition();if(!l)return;const r=e.getRange(),{startIndex:a,endIndex:c}=r.getRange();let d=i.getPositionList();const u=o.key===s.KeyMap.Up;let R=-1,h=-1;const g=i.getPositionContext();if(!o.shiftKey&&g.isTable&&(u&&l.rowIndex===0||!u&&l.rowIndex===e.getRowCount()-1)){const{index:f,trIndex:m,tdIndex:C,tableId:I}=g;if(u){const p=e.getOriginalElementList();if(m===0)if(p[f].originalId){const M=f-1,O=p[M];for(let b=O.trList.length-1;b>=0;b--){const D=O.trList[b].tdList.find(W=>W.tdIndex===C);if(D?.value.length){i.setPositionContext({isTable:!0,tableId:O.id,index:M,trIndex:b,tdIndex:C}),R=D.value.length-1,h=D.value.length-1;break}}}else i.setPositionContext({isTable:!1}),R=f-1,h=R,e.getTableTool().dispose();else{let L=-1,M=-1;const O=p[f].trList,b=O[m].tdList[C].colIndex;t:for(let V=m-1;V>=0;V--){const y=O[V].tdList;for(let F=0;F<y.length;F++){const S=y[F];if(S.colIndex===b||S.colIndex+S.colspan-1>=b&&S.colIndex<=b){L=V,M=F;break t}}}if(!~L||!~M)return;const D=O[L],W=D.tdList[M];i.setPositionContext({isTable:!0,index:f,trIndex:L,tdIndex:M,tdId:W.id,trId:D.id,tableId:I}),R=W.value.length-1,h=R}}else{const p=e.getOriginalElementList(),L=p[f],M=L.trList;if(m===M.length-1){const O=f+1,b=p[O];if(b&&[L.id,L.originalId].includes(b.originalId)){for(let W=C;W>=0;W--)if(b.trList[0].tdList[W].value.length){i.setPositionContext({isTable:!0,index:O,tableId:b.id,trIndex:0,tdIndex:W}),R=0,h=0;break}}else i.setPositionContext({isTable:!1}),R=f,h=R,e.getTableTool().dispose()}else{let O=-1,b=-1;const D=M[m].tdList[C].colIndex;t:for(let E=m+1;E<M.length;E++){const F=M[E].tdList;for(let S=0;S<F.length;S++){const N=F[S];if(N.colIndex===D||N.colIndex+N.colspan-1>=D&&N.colIndex<=D){O=E,b=S;break t}}}if(!~O||!~b)return;const W=M[O],V=W.tdList[b];i.setPositionContext({isTable:!0,index:f,trIndex:O,tdIndex:b,tdId:V.id,trId:W.id,tableId:I}),R=V.value.length-1,h=R}}}else{let f=l;o.shiftKey&&(a===l.index?f=d[c]:f=d[a]);const{index:m,rowNo:C,rowIndex:I,coordinate:{rightTop:[p]}}=f;if(u&&I===0||!u&&I===e.getRowCount()-1)return;const L=Si({positionList:d,index:m,rowNo:C,isUp:u,cursorX:p});if(L<0)return;R=L,h=L,o.shiftKey&&(a!==c?a===l.index?R=a:h=c:u?h=c:R=a);const O=e.getElementList()[L];if(O.type===s.ElementType.TABLE){const{scale:b}=e.getOptions(),D=e.getMargins(),W=O.trList;let V=-1,E=-1,y=-1;if(u)t:for(let F=W.length-1;F>=0;F--){const N=W[F].tdList;for(let P=0;P<N.length;P++){const Y=N[P],X=Y.x*b+D[3],U=Y.width*b;if(p>=X&&p<=X+U){const Q=Y.positionList,v=Q[Q.length-1],w=Si({positionList:Q,index:v.index+1,rowNo:v.rowNo-1,isUp:u,cursorX:p})||v.index;V=F,E=P,y=w;break t}}}else t:for(let F=0;F<W.length;F++){const N=W[F].tdList;for(let P=0;P<N.length;P++){const Y=N[P],X=Y.x*b+D[3],U=Y.width*b;if(p>=X&&p<=X+U){const Q=Y.positionList,v=Si({positionList:Q,index:-1,rowNo:-1,isUp:u,cursorX:p})||0;V=F,E=P,y=v;break t}}}if(~V&&~E&&~y){const F=W[V],S=F.tdList[E];i.setPositionContext({isTable:!0,index:L,trIndex:V,tdIndex:E,tdId:S.id,trId:F.id,tableId:O.id}),R=y,h=R,d=i.getPositionList()}}}if(!~R||!~h)return;R>h&&([R,h]=[h,R]),r.setRange(R,h);const T=R===h;e.render({curIndex:T?R:void 0,isSetCursor:T,isSubmitHistory:!1,isCompute:!1}),T||(e.getCursor().moveCursorToVisible({cursorPosition:d[u?R:h],direction:u?Jt.UP:Jt.DOWN}),e.updateTableTool())}function Hc(o){return o.key.length===1&&!o.ctrlKey&&!o.metaKey&&!o.altKey}function _c(o,t){const e=t.getDraw();if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return!1;const n=e.getRange();if(!n.getIsCanInput())return!1;const i=e.getControl();if(!i.getActiveControl()&&i.getIsRangeWithinControl()){i.setPopupAwakeDisabled(!0);try{i.initControl()}finally{i.setPopupAwakeDisabled(!1)}}const l=i.getActiveControl();if(l?.getElement()?.control?.type!==s.ControlType.DATE||!i.getIsRangeWithinControl())return!1;const{startIndex:r,endIndex:a}=n.getRange(),c=e.getElementList(),d=c[r],u=c[a],R=l.getElement(),h=C=>!!C?.controlId&&C.controlId===R.controlId&&(C.originControlId||null)===(R.originControlId||null),g=u?.controlComponent===s.ControlComponent.POSTFIX||u?.controlComponent===s.ControlComponent.POST_TEXT||u?.controlComponent===s.ControlComponent.POSTTEXTFIX||u?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT,T=c[a+1],f=!!(u?.originControlId&&u.controlComponent===s.ControlComponent.VALUE&&h(T)&&(T.controlComponent===s.ControlComponent.POSTFIX||T.controlComponent===s.ControlComponent.POST_TEXT||T.controlComponent===s.ControlComponent.POSTTEXTFIX||T.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT));return!h(d)||!h(u)||g||f?!1:(o.preventDefault(),l.awake?.(),!0)}function Ac(o,t){if(t.isComposing)return;const e=t.getDraw();if(o.key===s.KeyMap.Backspace)Wc(o,t);else if(o.key===s.KeyMap.Delete)Uc(o,t);else if(o.key===s.KeyMap.Enter)wc(o,t);else if(o.key===s.KeyMap.Left)Zc(o,t);else if(o.key===s.KeyMap.Right)Qc(o,t);else if(o.key===s.KeyMap.Up||o.key===s.KeyMap.Down)Kc(o,t);else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return;e.getHistoryManager().undo(),o.preventDefault()}else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return;e.getHistoryManager().redo(),o.preventDefault()}else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.C)t.copy(),o.preventDefault();else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.X)t.cut(),o.preventDefault();else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.A)t.selectAll(),o.preventDefault();else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.S){if(e.isReadonly())return;const n=e.getListener();n.saved&&n.saved(e.getValue());const i=e.getEventBus();i.isSubscribe("saved")&&i.emit("saved",e.getValue()),o.preventDefault()}else if(o.key===s.KeyMap.ESC){t.clearPainterStyle();const n=e.getZone();n.isMainActive()||n.setZone(s.EditorZone.MAIN),o.preventDefault()}else o.key===s.KeyMap.TAB?vc(o,t):Hc(o)&&_c(o,t)}function kc(o){return/[\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]/.test(o)}function Gc(o){return/[a-zA-Z]/.test(o)}function xc(o,t){return kc(o)?t:Gc(o)?"Times New Roman":t}function Fo(o){return o?.type===s.ElementType.CONTROL&&(o.controlComponent===s.ControlComponent.PREFIX||o.controlComponent===s.ControlComponent.PRE_TEXT||o.controlComponent===s.ControlComponent.PRETEXTFIX||o.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)}function Fe(o){return o?.type===s.ElementType.CONTROL&&(o.controlComponent===s.ControlComponent.POSTFIX||o.controlComponent===s.ControlComponent.POST_TEXT||o.controlComponent===s.ControlComponent.POSTTEXTFIX||o.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)}function Xi(o){return!!o?.originControlId&&Fo(o)}function zn(o){return!!o?.originControlId&&Fe(o)}function Bc(o,t){return!o||!t?!1:!!o.originControlId&&!!t.originControlId&&o.originControlId===t.originControlId&&o.controlId!==t.controlId}function dn(o,t,e){if(!t)return null;const n=new Set;let i=t,l=null;for(;i&&!n.has(i);){n.add(i);let r;for(let a=0;a<o.length;a++){const c=o[a];if(c.controlId===i&&c.control?.type&&(r=c,c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRE_TEXT||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!r)break;(r.control?.type===s.ControlType.TEXT||e===s.EditorMode.EDIT&&r.control?.type===s.ControlType.TEXTFIELD)&&(l=i),i=r.originControlId||null}return l}function Je(o,t){return!!o&&!!t&&o.controlId===t}function lr(o,t){if(t)return o.find(e=>e.controlId===t&&!e.originControlId&&!!e.control?.type)}function ar(o,t,e){if(!t?.originControlId||e?.originControlId!==t.originControlId||!t.controlId||!e.controlId||t.controlId===e.controlId||!Fe(t)||!Fo(e))return;const n=lr(o,t.originControlId);if(n?.control?.type===s.ControlType.TEXTFIELD)return n}function Ni(o,t,e){Ne.forEach(n=>{delete o[n]}),ue.forEach(n=>{const i=t?.[n];i!==void 0&&(o[n]=i)}),t?.type===s.ControlType.TEXT&&o.color?.toLowerCase()==="#87d068"?o.color=e:o.color||(o.color=e)}function Fi(o,t,e,n){o.controlId=t,o.control=e,o.controlComponent=s.ControlComponent.VALUE,delete o.originControlId,Ni(o,e,n)}function yi(o,t,e="input"){const n=se(),i=t.getDraw(),l=i.getControl(),r=i.getOptions(),a=i.getElementList(),u=i.getPosition().getCursorPosition()?.index;if(i.isReadonly()||i.isDisabled())return;const h=i.getPosition().getCursorPosition();if(!o||!h)return;const g=t.isComposing;if(g&&t.compositionInfo?.value===o)return;const T=i.getRange();if(!T.getIsCanInput())return;const f=Ct=>{l.setPopupAwakeDisabled(!0);try{return Ct()}finally{l.setPopupAwakeDisabled(!1)}},m=()=>{f(()=>l.initControl())},C=(Ct,et)=>{f(()=>{T.setRange(Ct,et)})};let I=l.getActiveControl();const p=i.getElementList()[T.getRange().endIndex],L=p?.control?.type===s.ControlType.TEXT&&!!p?.originControlId&&(p.controlComponent===s.ControlComponent.PREFIX||p.controlComponent===s.ControlComponent.PRE_TEXT||p.controlComponent===s.ControlComponent.PRETEXTFIX||p.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||p.controlComponent===s.ControlComponent.POSTFIX||p.controlComponent===s.ControlComponent.POST_TEXT||p.controlComponent===s.ControlComponent.POSTTEXTFIX||p.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||p.controlComponent===s.ControlComponent.PLACEHOLDER);if(!I&&(l.getIsRangeWithinControl()||L)&&(m(),I=l.getActiveControl()),I){const Ct=I.getElement(),et=i.getElementList()[T.getRange().endIndex],Wt=Ct?.controlId===et?.controlId&&(Ct?.originControlId||null)===(et?.originControlId||null),at=!!et&&et.controlComponent===s.ControlComponent.VALUE&&!!et.controlId&&!et.originControlId&&T.getRange().endIndex>0&&i.getElementList()[T.getRange().endIndex-1]?.originControlId===et.controlId;(!Wt||at)&&(m(),I=l.getActiveControl())}const{endIndex:M}=T.getRange(),O=i.getElementList(),b=O[M],D=O[M+1];if(b?.type===s.ElementType.SUB_TEMPLATE&&D?.type===s.ElementType.SUB_TEMPLATE)return;const W=i.getMode()===s.EditorMode.FORM;if(W){const Ct=T.getRange();if(!(i.getElementList()[Ct.endIndex]?.control?.type===s.ControlType.TEXT)){const at=l.getActiveTextControlLimit();if(!I||!l.getIsRangeWithinControl()&&!l.getIsRangeInPostfix())return;if(at){const mt=T.getRange();if(mt.startIndex<at.startIndex||mt.endIndex>at.endIndex){const it=Math.min(Math.max(mt.endIndex,at.startIndex),at.endIndex);f(()=>{T.setRange(it,it),i.render({curIndex:it,isSubmitHistory:!1})});return}}const{endIndex:xt}=T.getRange(),B=i.getElementList(),ot=B[xt];if(!ot?.originControlId){if(ot?.controlId&&ot?.controlComponent===s.ControlComponent.VALUE){let mt=!1;for(let it=xt;it>=0;it--){const de=B[it];if(de.controlId!==ot.controlId||de.originControlId)break;if(de.control?.type===s.ControlType.TEXTFIELD){mt=!0;break}}if(mt)return}}}}const V=T.getDefaultStyle()||t.compositionInfo?.defaultStyle||null,E=t.compositionInfo?.perfStartTime,y=$c(t,i.getElementList());g||i.getCursor().clearAgentDomValue();const{TEXT:F,HYPERLINK:S,SUBSCRIPT:N,SUPERSCRIPT:P,DATE:Y,TAB:X}=s.ElementType,U=o.replaceAll(`
|
|
110
|
-
`,H),{startIndex:Q,endIndex:v}=T.getRange(),w=T.getRangeAnchorStyle(y,Q);if(!w)return;const j=Q>0?y[Q-1]:null,J=!!(w.controlId||w.control),x={...!J&&j?j:w,...V},k=i.isDesignMode(),lt=y[v+1],Ft=dn(y,w.originControlId,i.getMode()),Qt=dn(y,lt?.originControlId,i.getMode()),ge=!w.originControlId&&!lt?.originControlId&&Fe(w)&&Fo(lt)&&!!w.controlId&&!!lt.controlId&&w.controlId!==lt.controlId,ee=zn(w)&&Xi(lt)&&!Ft&&!Qt,K=i.getMode()===s.EditorMode.EDIT?ar(y,w,lt):void 0,$=!!w.originControlId&&Fe(w)&<?.controlId===w.originControlId&&!lt.originControlId&<.control?.type===s.ControlType.TEXTFIELD&&Fe(lt),_=!!w.originControlId&&Fe(w)&<?.controlId===w.originControlId&&!lt.originControlId&<.control?.type===s.ControlType.TEXTFIELD&<.controlComponent===s.ControlComponent.VALUE,ct=!!Ft&&Ft===Qt&&!!w.controlId&&!!lt?.controlId&&w.controlId!==lt.controlId&&(zn(w)||Xi(lt))?Ft:null;if(W&&(ge||ee))return;const nt=Fo(lt)&&!lt?.originControlId,ut=Fe(w)&&!w.originControlId||w.type===s.ElementType.CONTROL&&w.controlComponent===s.ControlComponent.VALUE&<?.type!==s.ElementType.CONTROL&&!w.originControlId,ft=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],It=(Ct,et)=>!!(Ct?.controlId&&Ct.controlId===et?.controlId&&(Ct.originControlId||null)===(et.originControlId||null)),wt=(Ct,et)=>{if(Ct?.control?.type)return Ct.control.type;if(Ct?.controlId){for(let Wt=et;Wt>=0;Wt--){const at=y[Wt];if(!It(Ct,at))break;if(at.control?.type)return at.control.type}for(let Wt=et+1;Wt<y.length;Wt++){const at=y[Wt];if(!It(Ct,at))break;if(at.control?.type)return at.control.type}}},Gt=(Ct,et)=>{const Wt=wt(Ct,et);return!!(Wt&&ft.includes(Wt))},Mt=Ct=>{const et=y[Ct];let Wt=Ct;for(let at=Ct+1;at<y.length&&It(et,y[at]);at++)Wt=at;return Wt},_t=!!(Gt(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&!w.originControlId&&It(w,lt)&&Fe(lt)&&!lt?.value),yt=!!(Gt(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&w.originControlId&&It(w,lt)&&Fe(lt))?dn(y,w.originControlId,i.getMode()):null,St=lr(y,yt),Pt=nt||ut||_t,ne=Pt?{...w,type:void 0,control:void 0,controlId:void 0,controlComponent:void 0,originControlId:void 0,color:r.defaultColor,highlight:void 0}:w,Zt=Pt||J?ne:x,Xt=Dt(U).map(Ct=>{const et={value:Ct};if(k||!Zt.title?.disabled&&!Zt.control?.disabled){const Wt=y[v+1];(!Zt.type||Zt.type===F||Zt.type===S&&Wt?.type===S||Zt.type===Y&&Wt?.type===Y||Zt.type===N&&Wt?.type===N||Zt.type===P&&Wt?.type===P)&&fa.forEach(at=>{if(at==="groupIds"&&!Wt?.groupIds)return;const xt=Zt[at];xt!==void 0&&(et[at]=xt)}),(V||Zt.type===X)&&Ne.forEach(at=>{const xt=V?.[at]||Zt[at];xt!==void 0&&(et[at]=xt)}),g&&(et.underline=!0)}if(!Pt){const Wt=w.originControlId&&(w.controlComponent===s.ControlComponent.POSTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||w.controlComponent===s.ControlComponent.POST_TEXT);if($||_||K){const B=K||lt;et.controlId=B.controlId,et.control=B.control,et.controlComponent=s.ControlComponent.VALUE,delete et.originControlId,Ni(et,B.control,r.defaultColor)}const at=!w.originControlId&&w.controlId&&(w.controlComponent===s.ControlComponent.POSTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||w.controlComponent===s.ControlComponent.POST_TEXT)&<?.controlId&<.controlId!==w.controlId&&Bc(w,lt),xt=w.controlId&&w.originControlId&&(w.controlComponent===s.ControlComponent.VALUE||w.controlComponent===s.ControlComponent.PLACEHOLDER);if(!$&&!_&&!K&&Wt&&!et.controlId){const B=dn(y,w.originControlId,i.getMode());if(!B)return et;let ot=null;for(let mt=Q;mt>=0;mt--){const it=y[mt];if(Je(it,B)&&it.control){ot=it.control;break}}et.controlId=B,et.controlComponent=s.ControlComponent.VALUE,ot&&(et.control=ot),Ni(et,ot,r.defaultColor)}else if(at&&!et.controlId){if(lt?.controlId&<.controlId!==w.controlId)if(lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX)for(let B=Q;B>=0;B--){const ot=y[B];if(ot.controlId===w.controlId&&(ot.controlComponent===s.ControlComponent.PREFIX||ot.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let mt=B-1;mt>=0;mt--){const it=y[mt];if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.PRETEXTFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRE_TEXT)){et.controlId=it.controlId,et.controlComponent=s.ControlComponent.VALUE,it.control&&(et.control=it.control);break}if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}else(lt.controlComponent===s.ControlComponent.POSTFIX||lt.controlComponent===s.ControlComponent.POSTTEXTFIX)&&(et.controlId=lt.controlId,et.controlComponent=s.ControlComponent.VALUE,lt.control&&(et.control=lt.control));if(!et.controlId)for(let B=Q;B>=0;B--){const ot=y[B];if(ot.controlId===w.controlId&&(ot.controlComponent===s.ControlComponent.PREFIX||ot.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let mt=B-1;mt>=0;mt--){const it=y[mt];if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.PRETEXTFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRE_TEXT)){et.controlId=it.controlId,et.controlComponent=s.ControlComponent.VALUE,it.control&&(et.control=it.control);break}if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}}else if(xt&&!et.controlId){const B=w.controlId;let ot=w.control;if(!ot)for(let mt=Q;mt>=0;mt--){const it=y[mt];if(it.controlId===B&&it.control&&(ot=it.control,it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX))break}et.controlId=B,et.originControlId=w.originControlId,et.controlComponent=s.ControlComponent.VALUE,ot&&(et.control=ot)}else if(w.controlId){let B=w.control;if(!B)for(let ot=Q;ot>=0;ot--){const mt=y[ot];if(Je(mt,w.controlId)&&mt.control){B=mt.control;break}}et.controlId||(et.controlId=w.controlId),B&&!et.control&&(et.control=B),et.controlComponent||(et.controlComponent=s.ControlComponent.VALUE)}else if(!et.controlId&&!et.control&<?.originControlId&&(lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX)){const B=dn(y,lt.originControlId,i.getMode());if(!B)return et;let ot=null;for(let mt=v;mt>=0;mt--){const it=y[mt];if(Je(it,B)&&it.control){ot=it.control;break}}et.controlId=B,et.controlComponent=s.ControlComponent.VALUE,ot&&(et.control=ot)}}if(Ct&&Ct!==H){const Wt=xc(Ct,r.defaultFont);et.font=Wt}return et});let Lt;const Et=a[u],bt=a[u+1],pe=a[u-1];if(g)Lt=Q;else{const Ct=B=>{if(Xt?.length)for(let ot=0;ot<Xt.length;ot++)y.splice(B+ot,0,Xt[ot]);return B+Xt.length-1},et=Q+1,Wt=_t?Mt(Q)+1:et,at=()=>{let B=null,ot,mt=null;const it=i.getMode()===s.EditorMode.EDIT?ar(a,Et,bt):void 0;if(it?.controlId?(B=it.controlId,ot=it.control?.type):i.getMode()===s.EditorMode.EDIT&&zn(Et)&&bt?.controlId===Et.originControlId&&!bt.originControlId&&bt.control?.type===s.ControlType.TEXTFIELD&&(bt.controlComponent===s.ControlComponent.VALUE||Fe(bt))?(B=Et.originControlId,ot=s.ControlType.TEXTFIELD):zn(Et)?B=dn(a,Et.originControlId,i.getMode()):Xi(bt)?B=dn(a,bt.originControlId,i.getMode()):ct?B=ct:Et?.control?.type===s.ControlType.TEXT&&Et.controlId&&!Et.originControlId&&Fe(Et)&&pe?.originControlId===Et.controlId&&(B=Et.controlId,mt={startIndex:u-1,endIndex:u-1}),!B)return null;if(!ot)for(let kt=u;kt>=0;kt--){const zt=a[kt];if(Je(zt,B)&&zt.control?.type){ot=zt.control.type;break}if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}return ot!==s.ControlType.TEXT&&!(i.getMode()===s.EditorMode.EDIT&&ot===s.ControlType.TEXTFIELD)?null:{parentControlId:B,activationIndex:(()=>{for(let kt=u+1;kt<a.length;kt++){const zt=a[kt];if(Je(zt,B))return kt;if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}for(let kt=u;kt>=0;kt--){const zt=a[kt];if(Je(zt,B))return kt;if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}return u})(),boundaryRange:mt}};Q!==v&&(i.removeSplitTdOtherRangeElements(),i.spliceElementList(y,et,v-Q));const xt=at();if(yt&&St?.control){const B=Mt(Q);Xt.forEach(ot=>{Fi(ot,yt,St.control,r.defaultColor)}),re(y,Xt,B,{editorOptions:r}),i.spliceElementList(y,B+1,0,Xt),Lt=B+Xt.length}else if(xt){const{parentControlId:B,activationIndex:ot,boundaryRange:mt}=xt;C(ot,ot),m();const it=l.getActiveControl(),de=bt?.controlId===B&&!bt?.originControlId&&bt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,kt=!!(Et?.originControlId&&zn(Et)&&de!==-1),zt=mt||(kt?{startIndex:u,endIndex:u}:de!==-1?{startIndex:u,endIndex:de}:{startIndex:Q,endIndex:v});C(zt.startIndex,zt.endIndex),it&&it.getElement()?.controlId===B&&(it.getElement()?.control?.type===s.ControlType.TEXT||it.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Xt.forEach(xn=>{Fi(xn,B,it.getElement().control,r.defaultColor)}),Lt=it.setValue(Xt,{range:zt,elementList:y}),l.emitControlContentChange(),C(Lt,Lt),m()):Pt?Lt=Ct(Wt):(Lt=l.setValue(Xt),l.emitControlContentChange())}else if(Pt)Lt=Ct(Wt);else if(Et?.originControlId&&(Et.controlComponent===s.ControlComponent.POSTFIX||Et.controlComponent===s.ControlComponent.POST_TEXT||Et.controlComponent===s.ControlComponent.POSTTEXTFIX||Et.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))if(I?.getElement()?.control?.type===s.ControlType.TEXT&&I.getElement()?.controlId===Et.controlId&&(I.getElement()?.originControlId||null)===(Et.originControlId||null))Lt=l.setValue(Xt),l.emitControlContentChange();else{const ot=dn(a,Et.originControlId,i.getMode());if(!ot){Lt=Ct(et);return}let mt;for(let de=u;de>=0;de--){const kt=a[de];if(Je(kt,ot)&&kt.control?.type){mt=kt.control.type;break}if(kt.controlId&&kt.controlId!==ot&&kt.originControlId!==ot)break}if(mt===s.ControlType.TEXT||i.getMode()===s.EditorMode.EDIT&&mt===s.ControlType.TEXTFIELD){const de=()=>{for(let Pe=u+1;Pe<a.length;Pe++){const We=a[Pe];if(Je(We,ot))return Pe;if(We.controlId&&We.controlId!==ot&&We.originControlId!==ot)break}for(let Pe=u;Pe>=0;Pe--){const We=a[Pe];if(Je(We,ot))return Pe;if(We.controlId&&We.controlId!==ot&&We.originControlId!==ot)break}return u},kt=bt?.controlId===ot&&bt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,zt=kt!==-1?{startIndex:u,endIndex:kt}:{startIndex:u,endIndex:u},xn=de();C(xn,xn),m();const gn=l.getActiveControl();C(zt.startIndex,zt.endIndex),gn&&gn.getElement()?.controlId===ot&&(gn.getElement()?.control?.type===s.ControlType.TEXT||gn.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Xt.forEach(Pe=>{Fi(Pe,ot,gn.getElement().control,r.defaultColor)}),Lt=gn.setValue(Xt,{range:zt,elementList:y}),l.emitControlContentChange(),C(Lt,Lt),m()):Lt=Ct(et)}else Lt=Ct(et)}else if((Et?.control?.type===s.ControlType.NUMBER||bt?.control?.type===s.ControlType.NUMBER)&&I?.getElement()?.control?.type===s.ControlType.NUMBER&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),Lt=Q}else if((Et?.control?.type===s.ControlType.SELECT||bt?.control?.type===s.ControlType.SELECT)&&I?.getElement()?.control?.type===s.ControlType.SELECT&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),Lt=Q}else if(I?.getElement()?.control?.type===s.ControlType.DATE&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),Lt=Q}else Et?.control?.type==="button"||bt?.control?.type==="button"?Lt=Q:I&&l.getIsRangeWithinControl()?(Lt=l.setValue(Xt),l.emitControlContentChange()):(Et?.type==="control"||bt?.type==="control")&&!Pt?Lt=Ct(et):(re(y,Xt,Q,{editorOptions:r}),i.spliceElementList(y,et,0,Xt),Lt=Q+Xt.length)}if(~Lt&&!g){const Ct=se()-n,et=se();f(()=>{T.setRange(Lt,Lt),i.render({curIndex:Lt,isSubmitHistory:!g,traceLabel:`input:${e}`})}),ai(r,`input:${e}`,se()-n,[{label:"mutate",duration:Ct},{label:"renderCall",duration:se()-et}],{isComposing:g,textLength:Xt.length,compositionChainDuration:e==="compositionend"&&E!==void 0?Number((se()-E).toFixed(2)):void 0})}g&&(t.compositionInfo={value:U,startIndex:Lt,endIndex:v,defaultStyle:V,perfStartTime:n})}function Jc(o){o.compositionInfo&&(o.compositionInfo=null)}function $c(o,t){if(!o.compositionInfo||o.isComposing)return t;const{startIndex:e,endIndex:n}=o.compositionInfo;return e!==n&&(o.getDraw().removeSplitTdOtherRangeElements(),o.getDraw().spliceElementList(t,e+1,n-e),o.getDraw().getRange().setRange(e,e)),o.compositionInfo=null,t}async function zc(o){const t=o.getDraw(),e=t.getRange(),{startIndex:n,endIndex:i}=e.getRange();if(!~n&&!~n||t.isReadonly()||!e.getIsCanInput())return;const l=t.getElementList();let r=n,a=i;if(n===i){const h=t.getPosition().getPositionList(),g=h[n],T=g.rowNo,f=g.pageNo,m=[];for(let I=0;I<h.length;I++){const p=h[I];if(p.pageNo>f)break;p.pageNo===f&&p.rowNo===T&&m.push(I)}const C=m[0]-1;r=C<0?0:C,a=m[m.length-1]}const c=t.getOptions();await zs(l.slice(r+1,a+1),c);const d=t.getControl();let u;d.getActiveControl()&&d.getIsRangeWithinControl()?(u=d.cut(),d.emitControlContentChange()):(t.spliceElementList(l,r+1,a-r),u=r),e.setRange(u,u),t.render({curIndex:u})}function jc(o){return o.replace(/(?:\r\n|\r|\n)+$/,"")}async function qc(o,t){const e=o.getDraw(),n=e.getMode()===s.EditorMode.COMPARE,i=n||t?.isPlainText,{copy:l}=e.getOverride();if(l&&l()?.preventDefault!==!1)return;const r=e.getRange();let a=null;if(r.getRange().isCrossRowCol){const d=r.getRangeTableElement();if(!d)return;const u=e.getTableParticle().getRangeRowCol();if(!u)return;const R={type:s.ElementType.TABLE,value:"",colgroup:[],trList:[]},h=u[0],g=h[0].colIndex,T=h[h.length-1],f=T.colIndex+T.colspan-1;for(let m=g;m<=f;m++)R.colgroup.push(d.colgroup[m]);for(let m=0;m<u.length;m++){const C=u[m],I=d.trList[C[0].rowIndex],p={tdList:[],height:I.height,minHeight:I.minHeight};for(let L=0;L<C.length;L++)p.tdList.push(C[L]);R.trList.push(p)}a=n?[R]:Yt([R])}else a=r.getIsCollapsed()?r.getRangeRowElementList():r.getSelectionElementList();if(i&&a?.length){const d=Cn(a,e.getOptions());await Lc(n?jc(d):d);return}a?.length&&await zs(a,e.getOptions())}function td(o,t){const e=t.getDraw(),{drop:n}=e.getOverride();if(n&&n(o)?.preventDefault!==!1)return;o.preventDefault();const i=o.dataTransfer?.getData("text");if(i)t.input(i);else{const l=o.dataTransfer?.files;if(!l)return;for(let r=0;r<l.length;r++){const a=l[r];a.type.startsWith("image")&&Ei(t,a)}}}function cr(o){if(!Intl.Segmenter)return null;const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const i=t.getRange().getRangeParagraphInfo();if(!i)return null;const l=i?.elementList?.map(h=>!h.type||h.type!==s.ElementType.CONTROL&&Ie.includes(h.type)?h.value:H).join("")||"";if(!l)return null;const r=e.isFirstLetter||t.getCursor().getHitLineStartIndex()?e.index+1:e.index,a=i.startIndex,d=new Intl.Segmenter(void 0,{granularity:"word"}).segment(l);let u=-1,R=-1;for(const{segment:h,index:g,isWordLike:T}of d){const f=g+a;if(T&&r>=f&&r<f+h.length){u=f-1,R=u+h.length;break}}return~u&&~R?{startIndex:u,endIndex:R}:null}function ed(o){const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:n,index:i}=e,l=t.getLetterReg();let r=0,a=0;const c=ei.test(n);if(c||l.test(n)){const u=t.getElementList();let R=i-1;for(;R>0;){const g=u[R].value;if(c&&ei.test(g)||!c&&l.test(g))r++,R--;else break}let h=i+1;for(;h<u.length;){const g=u[h].value;if(c&&ei.test(g)||!c&&l.test(g))a++,h++;else break}}const d=i-r-1;return d<0?null:{startIndex:d,endIndex:i+a}}function nd(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(i.isImage&&i.isDirectHit){const a=e.getElementList(),c=e.getEventBus(),d=a[i.index];if(c.isSubscribe("imageDblclick")&&c.emit("imageDblclick",{evt:t,element:d}),d.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&e.getMode()===s.EditorMode.EDIT&&!~i.index&&i.zone){e.getZone().setZone(i.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((i.isCheckbox||i.isRadio)&&i.isDirectHit)return;const l=e.getRange(),r=cr(o)||ed(o);r&&(l.setRange(r.startIndex,r.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),l.setRangeStyle())}function od(o){const t=o.getDraw(),e=t.getControl();if(e.getActiveControl()&&e.selectValue())return;const i=t.getPosition().getCursorPosition();if(!i)return;const{index:l}=i,r=t.getElementList();let a=0,c=0,d=l-1;for(;d>0;){const T=r[d],f=r[d-1];if(T.value===H&&!T.listWrap||T.listId!==f?.listId||T.titleId!==f?.titleId)break;a++,d--}let u=l+1;for(;u<r.length;){const T=r[u],f=r[u+1];if(T.value===H&&!T.listWrap||T.listId!==f?.listId||T.titleId!==f?.titleId)break;c++,u++}const R=t.getRange();let h=l-a-1;if(r[h]?.value!==H&&(h-=1),h<0)return;let g=l+c+1;(r[g]?.value===H||g>r.length-1)&&(g-=1),R.setRange(h,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}const dr={dblclick:nd,threeClick:od};function id(o){o.isComposing=!0}function sd(o,t){const e=se();o.isComposing=!1;const n=o.getDraw(),i=n.getOptions();if(t.data)o.compositionInfo&&(o.compositionInfo.perfStartTime=e),Ta?setTimeout(()=>{o.compositionInfo&&yi(t.data,o,"compositionend")},1):o.compositionInfo&&yi(t.data,o,"compositionend");else{const r=o.compositionInfo?.cancel;if(Jc(o),!r){const a=n.getRange(),{endIndex:c}=a.getRange();n.render({curIndex:c,isSubmitHistory:!1,traceLabel:"compositionend:empty"})}}n.getCursor().clearAgentDomValue(),ai(i,"compositionend",se()-e,[],{hasData:!!t.data,dataLength:t.data?.length||0})}function rd(o){o.compositionInfo&&(o.compositionInfo.cancel=!0)}const bi={compositionstart:id,compositionend:sd,compositionCancel:rd};function ld(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!Ls(o.target,p=>p===i))return;const a=o.target.dataset.index;a&&e.setPageNo(Number(a));const c=e.getPosition(),d=c.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!d)return;const{isTable:u,tdValueIndex:R,index:h}=d,g=c.getPositionList(),T=u?R:h;~h&&(e.getRange().setRange(T,T),c.setCursorPosition(g[T]));const f=e.getCursor(),{cursor:{dragColor:m,dragWidth:C,dragFloatImageDisabled:I}}=e.getOptions();if(I){const p=t.cacheElementList?.[t.cacheRange.startIndex];if(p?.type===s.ElementType.IMAGE&&(p.imgDisplay===s.ImageDisplay.FLOAT_TOP||p.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM||p.imgDisplay===s.ImageDisplay.SURROUND))return}f.drawCursor({width:C,color:m,isBlink:!1,isFocus:!1})}const ad={dragover:ld};class cd{isAllowSelection;isComposing;compositionInfo;isAllowDrag;isAllowDrop;cacheRange;cacheElementList;cachePositionList;cachePositionContext;mouseDownStartPosition;draw;pageContainer;pageList;range;position;constructor(t){this.draw=t,this.pageContainer=t.getPageContainer(),this.pageList=t.getPageList(),this.range=this.draw.getRange(),this.position=this.draw.getPosition(),this.isAllowSelection=!1,this.isComposing=!1,this.compositionInfo=null,this.isAllowDrag=!1,this.isAllowDrop=!1,this.cacheRange=null,this.cacheElementList=null,this.cachePositionList=null,this.cachePositionContext=null,this.mouseDownStartPosition=null}getDraw(){return this.draw}register(){this.pageContainer.addEventListener("click",this.click.bind(this)),this.pageContainer.addEventListener("mousedown",this.mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this.mouseup.bind(this)),this.pageContainer.addEventListener("mouseleave",this.mouseleave.bind(this)),this.pageContainer.addEventListener("mousemove",this.mousemove.bind(this)),this.pageContainer.addEventListener("dblclick",this.dblclick.bind(this)),this.pageContainer.addEventListener("dragover",this.dragover.bind(this)),this.pageContainer.addEventListener("drop",this.drop.bind(this)),na(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 r=cr(this);r&&(n=this.draw.getElementList().slice(r.startIndex+1,r.endIndex+1))}if(!n)return;const i=Object.keys(t);n.forEach(r=>{i.forEach(a=>{const c=a;Reflect.set(r,c,t[c])})}),this.draw.render({isSetCursor:!1});const l=this.draw.getPainterOptions();(!l||!l.isDblclick)&&this.clearPainterStyle()}selectAll(){if(!this.draw.isSelectionDisabled())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){this.draw.isInteractionSuspended()||yc(t,this)}mousedown(t){this.draw.isInteractionSuspended()||Xc(t,this)}click(){this.draw.isInteractionSuspended()||ha&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){this.draw.isInteractionSuspended()||Nc(t,this)}mouseleave(t){this.draw.isInteractionSuspended()||Fc(t,this)}keydown(t){this.draw.isInteractionSuspended()||Ac(t,this)}dblclick(t){this.draw.isInteractionSuspended()||dr.dblclick(this,t)}threeClick(){this.draw.isInteractionSuspended()||dr.threeClick(this)}input(t,e="input"){this.draw.isInteractionSuspended()||yi(t,this,e)}async cut(){this.draw.isInteractionSuspended()||await zc(this)}async copy(t){this.draw.isInteractionSuspended()||await qc(this,t)}compositionstart(){this.draw.isInteractionSuspended()||bi.compositionstart(this)}compositionend(t){this.draw.isInteractionSuspended()||bi.compositionend(this,t)}compositionCancel(){this.draw.isInteractionSuspended()||bi.compositionCancel(this)}drop(t){this.draw.isInteractionSuspended()||td(t,this)}dragover(t){this.draw.isInteractionSuspended()||ad.dragover(t,this)}}const ur={PAGE_SCALE:"pageScale"};class dd{draw;options;cursor;canvasEvent;range;previewer;tableTool;hyperlinkParticle;control;dateParticle;imageParticle;dprMediaQueryList;constructor(t,e){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)}clearSideEffect=t=>{if(!this.cursor)return;if(this.draw.isInteractionSuspended()){this.resetSideEffect();return}const e=t?.composedPath?.()[0]||t.target;if(this.draw.isTargetInsideEditor(e)){this.watchCursorActive();return}this.resetSideEffect()};resetSideEffect=()=>{this.cursor&&(this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker(),this.imageParticle.destroyFloatImage())};setCanvasEventAbility=()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)};watchCursorActive(){this.range.getIsCollapsed()&&setTimeout(()=>{this.cursor?.getAgentIsActive()||this.cursor?.drawCursor({isFocus:!1,isBlink:!1})})}setPageScale=t=>{if(this.draw.isInteractionSuspended()||!this.draw.isTargetInsideEditor(t.target)||this.options.shortcutDisableKeys.includes(ur.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)}};_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})}};_handleDprChange=()=>{this.draw.setPageDevicePixel()}}class ud{undoStack=[];redoStack=[];maxRecordCount;constructor(t){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 Rd{cursorPosition;positionContext;positionList;floatPositionList;draw;eventBus;options;constructor(t){this.positionList=[],this.floatPositionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.eventBus=t.getEventBus(),this.options=t.getOptions()}getFloatPositionList(){return this.floatPositionList}getTablePositionList(t){const{index:e,trIndex:n,tdIndex:i}=this.positionContext;return t[e].trList[n].tdList[i].positionList||[]}getPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalElementList()):this.getOriginalPositionList()}getMainPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalMainElementList()):this.positionList}getOriginalPositionList(){const t=this.draw.getZone();return t.isHeaderActive()?this.draw.getHeader().getPositionList():t.isFooterActive()?this.draw.getFooter().getPositionList():this.positionList}getOriginalMainPositionList(){return this.positionList}getSelectionPositionList(){const{startIndex:t,endIndex:e}=this.draw.getRange().getRange();return t===e?null:this.getPositionList().slice(t+1,e+1)}setPositionList(t){this.positionList=t}setFloatPositionList(t){this.floatPositionList=t}computePageRowPosition(t){const{positionList:e,rowList:n,pageNo:i,startX:l,startY:r,startRowIndex:a,startIndex:c,innerWidth:d,zone:u}=t,{scale:R,table:{tdPadding:h}}=this.options;let g=l,T=r,f=c;for(let m=0;m<n.length;m++){const C=n[m];if(!C.isSurround){const L=C.width+(C.offsetX||0);C.rowFlex===s.RowFlex.CENTER?g+=(d-L)/2:C.rowFlex===s.RowFlex.RIGHT&&(g+=d-L)}g+=C.offsetX||0,T+=C.offsetY||0;const I=g,p=T;for(let L=0;L<C.elementList.length;L++){const M=C.elementList[L],O=M.metrics,b=!ae(M)&&(M.imgDisplay!==s.ImageDisplay.INLINE&&M.type===s.ElementType.IMAGE||M.type===s.ElementType.LATEX)?C.ascent-O.height:C.ascent;M.left&&(g+=M.left),M.translateX&&(g+=M.translateX*R);const D={pageNo:i,index:f,value:M.value,rowIndex:a+m,rowNo:m,metrics:O,left:M.left||0,ascent:b,lineHeight:C.height,isFirstLetter:L===0,isLastLetter:L===C.elementList.length-1,coordinate:{leftTop:[g,T],leftBottom:[g,T+C.height],rightTop:[g+O.width,T],rightBottom:[g+O.width,T+C.height]}};if(M.imgDisplay===s.ImageDisplay.SURROUND||M.imgDisplay===s.ImageDisplay.FLOAT_TOP||M.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM){const W=e[e.length-1];W&&(D.metrics=W.metrics,D.coordinate=W.coordinate),M.imgFloatPosition||(M.imgFloatPosition={x:g,y:T,pageNo:i}),this.floatPositionList.push({pageNo:i,element:M,position:D,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:f,zone:u})}if(e.push(D),f++,g+=O.width,M.type===s.ElementType.TABLE&&!ae(M)){const W=M.tdPadding||h,V=W[1]+W[3],E=W[0]+W[2];for(let y=0;y<M.trList.length;y++){const F=M.trList[y];for(let S=0;S<F.tdList.length;S++){const N=F.tdList[S];N.positionList=[];const P=N.rowList,Y=this.computePageRowPosition({positionList:N.positionList,rowList:P,pageNo:i,startRowIndex:0,startIndex:0,startX:(N.x+W[3])*R+I+(M.translateX||0)*R,startY:(N.y+W[0])*R+p,innerWidth:(N.width-V)*R,isTable:!0,index:f-1,tdIndex:S,trIndex:y,zone:u});if(N.verticalAlign===s.VerticalAlign.MIDDLE||N.verticalAlign===s.VerticalAlign.BOTTOM){const X=P.reduce((v,w)=>v+w.height,0),U=(N.height-E)*R-X,Q=N.verticalAlign===s.VerticalAlign.MIDDLE?U/2:U;Math.floor(Q)>0&&N.positionList.forEach(v=>{const{coordinate:{leftTop:w,leftBottom:j,rightBottom:J,rightTop:A}}=v;w[1]+=Q,j[1]+=Q,J[1]+=Q,A[1]+=Q})}g=Y.x,T=Y.y}}g=I,T=p}}g=l,T+=C.height}return{x:g,y:T,index:f}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),n=this.draw.getMargins(),i=n[3],r=this.draw.getHeader().getExtraHeight(),a=n[0]+r;let c=0;for(let d=0;d<e.length;d++){const u=e[d];if(!u?.length)continue;const R=u[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:u,pageNo:d,startRowIndex:c,startIndex:R,startX:i,startY:a,innerWidth:t}),c+=u.length}}computeRowPosition(t){const{row:e,innerWidth:n}=t,i=[];return this.computePageRowPosition({positionList:i,innerWidth:n,rowList:[ht(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),i}setCursorPosition(t){this.cursorPosition=t}getCursorPosition(){return this.cursorPosition}getPositionContext(){return this.positionContext}setPositionContext(t){this.eventBus.emit("positionContextChange",{value:t,oldValue:this.positionContext}),this.positionContext=t}getPositionByXY(t){const{x:e,y:n,isTable:i}=t;let{elementList:l,positionList:r}=t;l||(l=this.draw.getOriginalElementList()),r||(r=this.getOriginalPositionList());const a=this.draw.getZone(),c=t.pageNo??this.draw.getPageNo(),d=a.isMainActive(),u=d?c:0;if(!i){const f=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_TOP,s.ImageDisplay.SURROUND]});if(f)return f}for(let f=0;f<r.length;f++){const{index:m,pageNo:C,left:I,isFirstLetter:p,coordinate:{leftTop:L,rightTop:M,leftBottom:O}}=r[f];if(u===C){if(C>u)break;if(L[0]-I<=e&&M[0]>=e&&L[1]<=n&&O[1]>=n){let b=f;const D=l[f];if(D.type===s.ElementType.TABLE)for(let V=0;V<D.trList.length;V++){const E=D.trList[V];for(let y=0;y<E.tdList.length;y++){const F=E.tdList[y],S=this.getPositionByXY({x:e,y:n,td:F,pageNo:c,tablePosition:r[f],isTable:!0,elementList:F.value,positionList:F.positionList});if(~S.index){const{index:N,hitLineStartIndex:P}=S,Y=F.value[N];return{index:m,isCheckbox:S.isCheckbox||Y.type===s.ElementType.CHECKBOX||Y.controlComponent===s.ControlComponent.CHECKBOX,isRadio:Y.type===s.ElementType.RADIO||Y.controlComponent===s.ControlComponent.RADIO,isControl:!!Y.controlId,isImage:S.isImage,isLabel:S.isLabel,isMacro:S.isMacro,isDirectHit:S.isDirectHit,isTable:!0,tdIndex:y,trIndex:V,tdValueIndex:N,tdId:F.id,trId:E.id,tableId:D.id,hitLineStartIndex:P}}}}if(D.type===s.ElementType.IMAGE||D.type===s.ElementType.LATEX)return{index:b,isDirectHit:!0,isImage:!0};if(D.type===s.ElementType.MENSTRUAL_HISTORY)return{index:b,isDirectHit:!0};if(D.type===s.ElementType.FETAL_HEART_POSITION)return{index:b,isDirectHit:!0};if(D.type===s.ElementType.TOOTH_POSITION){const{scale:V}=this.options,E=D.width*V;return e>=L[0]&&e<=L[0]+E?{index:b,isDirectHit:!0}:{index:b}}if(D.type===s.ElementType.CHECKBOX||D.controlComponent===s.ControlComponent.CHECKBOX)return{index:b,isDirectHit:!0,isCheckbox:!0};if(D.type===s.ElementType.LABEL)return{index:b,isDirectHit:!0,isLabel:!0};if(D.type===s.ElementType.MACRO||D.type===s.ElementType.CUSTOM_MACRO||D.type===s.ElementType.REUSABLE_ITEM||D.type===s.ElementType.SUB_TEMPLATE)return{index:b,isDirectHit:!0,isMacro:!0};if(D.type===s.ElementType.TAB&&D.listStyle===s.ListStyle.CHECKBOX){let V=b-1;for(;V>0;){const E=l[V];if(E.value===H&&E.listStyle===s.ListStyle.CHECKBOX)break;V--}return{index:V,isDirectHit:!0,isCheckbox:!0}}if(D.type===s.ElementType.RADIO||D.controlComponent===s.ControlComponent.RADIO)return{index:b,isDirectHit:!0,isRadio:!0};let W;if(l[m].value!==H){const V=M[0]-L[0];e<L[0]+V/2&&(b=f-1,p&&(W=f))}return{isDirectHit:!0,hitLineStartIndex:W,index:b,isControl:!!D.controlId}}}}if(!i){const f=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_BOTTOM]});if(f)return f}let R=!1,h=-1,g;if(i){const{scale:f}=this.options,{td:m,tablePosition:C}=t;if(m&&C){const{leftTop:I}=C.coordinate,p=m.x*f+I[0],L=m.y*f+I[1],M=m.width*f,O=m.height*f;if(!(p<e&&e<p+M&&L<n&&n<L+O))return{index:h}}}const T=r.filter(f=>f.isLastLetter&&f.pageNo===u);for(let f=0;f<T.length;f++){const{index:m,rowNo:C,coordinate:{leftTop:I,leftBottom:p}}=T[f];if(n>I[1]&&n<=p[1]){const L=r.findIndex(D=>D.pageNo===u&&D.rowNo===C),M=l[L],O=r[L],b=M.listStyle===s.ListStyle.CHECKBOX?this.draw.getMargins()[3]:O.coordinate.leftTop[0];if(e<b)~L?O.value===H?h=L:(h=L-1,g=L):h=m;else{if(M.listStyle===s.ListStyle.CHECKBOX&&e<I[0])return{index:L,isDirectHit:!0,isCheckbox:!0};h=m}R=!0;break}}if(!R){if(this.draw.getIsPagingMode()){const m=this.draw.getHeader(),C=m.getHeight(),I=m.getHeaderTop()+C,p=this.draw.getFooter(),M=this.draw.getHeight()-(p.getFooterBottom()+p.getHeight());if(d){if(n<I)return{index:-1,zone:s.EditorZone.HEADER};if(n>M)return{index:-1,zone:s.EditorZone.FOOTER}}else if(n<=M&&n>=I)return{index:-1,zone:s.EditorZone.MAIN}}const f=this.draw.getMargins();if(n<=f[0])for(let m=0;m<r.length;m++){const C=r[m];if(C.pageNo!==u||C.rowNo!==0)continue;const{leftTop:I,rightTop:p}=C.coordinate;if(e<=f[3]||e>=I[0]&&e<=p[0]||r[m+1]?.rowNo!==0)return{index:C.index}}else{const m=T[T.length-1];if(m){const C=m.rowNo;for(let I=0;I<r.length;I++){const p=r[I];if(p.pageNo!==u||p.rowNo!==C)continue;const{leftTop:L,rightTop:M}=p.coordinate;if(e<=f[3]||e>=L[0]&&e<=M[0]||r[I+1]?.rowNo!==C)return{index:p.index}}}}return{index:T[T.length-1]?.index||r.length-1}}return{hitLineStartIndex:g,index:h,isControl:!!l[h]?.controlId}}getFloatPositionByXY(t){const{x:e,y:n}=t,i=t.pageNo??this.draw.getPageNo(),l=this.draw.getZone().getZone(),{scale:r}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:c,element:d,isTable:u,index:R,trIndex:h,tdIndex:g,tdValueIndex:T,zone:f,pageNo:m}=this.floatPositionList[a];if(i===m&&d.type===s.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!f||f===l)){const C=d.imgFloatPosition,I=C.x*r,p=C.y*r,L=d.width*r,M=d.height*r;if(e>=I&&e<=I+L&&n>=p&&n<=p+M)return u?{index:R,isDirectHit:!0,isImage:!0,isTable:u,trIndex:h,tdIndex:g,tdValueIndex:T,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()!==s.EditorMode.READONLY){const{index:m,isTable:C,trIndex:I,tdIndex:p,tdValueIndex:L}=e,M=this.draw.getControl(),{newIndex:O}=M.moveCursor({index:m,isTable:C,trIndex:I,tdIndex:p,tdValueIndex:L});C?e.tdValueIndex=O:e.index=O}const{index:n,isCheckbox:i,isRadio:l,isControl:r,isImage:a,isLabel:c,isDirectHit:d,isTable:u,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f}=e;return this.setPositionContext({isTable:u||!1,isCheckbox:i||!1,isRadio:l||!1,isControl:r||!1,isImage:a||!1,isLabel:c||!1,isDirectHit:d||!1,index:n,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f}),e}setSurroundPosition(t){const{scale:e}=this.options,{pageNo:n,row:i,rowElement:l,rowElementRect:r,surroundElementList:a,availableWidth:c}=t;let d=r.x,u=0;if(a.length&&!Vn(l)&&!l.control?.minWidth)for(let R=0;R<a.length;R++){const h=a[R],g=h.imgFloatPosition;if(g.pageNo!==n)continue;const T={...g,x:g.x*e,y:g.y*e,width:h.width*e,height:h.height*e};if(ca(r,T)){i.isSurround=!0;const f=T.width+T.x-r.x;if(l.left=f,i.width+=f,u+=f,d=T.x+T.width,i.width+l.metrics.width>c){l.left=0,i.width-=u;break}}}return{x:d,rowIncreaseWidth:u}}}class hd{draw;options;range;listener;eventBus;position;historyManager;defaultStyle;lastRangeStyle;constructor(t){this.draw=t,this.options=t.getOptions(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.range={startIndex:-1,endIndex:-1},this.defaultStyle=null,this.lastRangeStyle=null}_isSameRangeStyle(t,e){if(!t||!["type","undo","redo","painter","font","size","bold","italic","underline","strikeout","deletePerson","color","highlight","rowFlex","vertical","rowMargin","level","listType","listStyle","textDecoration","extension"].every(c=>t[c]===e[c])||!(t.dashArray.length===e.dashArray.length&&t.dashArray.every((c,d)=>c===e.dashArray[d])))return!1;const r=t.groupIds||[],a=e.groupIds||[];return r.length===a.length&&r.every((c,d)=>c===a[d])}_emitRangeStyle(t){this._isSameRangeStyle(this.lastRangeStyle,t)||(this.lastRangeStyle={...t,dashArray:[...t.dashArray],groupIds:t.groupIds?[...t.groupIds]:null},this.listener.rangeStyleChange?.(t),this.eventBus.isSubscribe("rangeStyleChange")&&this.eventBus.emit("rangeStyleChange",t))}getRange(){return this.range}clearRange(){this.setRange(-1,-1)}setDefaultStyle(t){t?this.defaultStyle={...this.defaultStyle,...t}:this.defaultStyle=null}getDefaultStyle(){return this.defaultStyle}getRangeAnchorStyle(t,e){const n=yn(t,e);return n?{...n,...this.defaultStyle}:null}getIsRangeChange(t,e,n,i,l,r,a){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==n||this.range.startTdIndex!==i||this.range.endTdIndex!==l||this.range.startTrIndex!==r||this.range.endTrIndex!==a}getIsCollapsed(){const{startIndex:t,endIndex:e}=this.range;return t===e}getIsSelection(){const{startIndex:t,endIndex:e}=this.range;return!~t&&!~e?!1:t!==e}getSelection(){const{startIndex:t,endIndex:e,splitTdRange:n}=this.range;if(t===e)return null;if(n)return this.draw.getSplitTdValues(n.originalId).slice(n.startIndex+1,n.endIndex+1);const i=this.draw.getElementList();return i.slice(i[t]?.value===H?t:t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let n=0;n<t.length;n++){const i=t[n];for(let l=0;l<i.length;l++){const r=i[l];e.push(...r.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||Ie.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Ie.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=new Map;for(let l=t;l<e+1;l++){const{pageNo:r,rowNo:a}=n[l],c=i.get(r);c?c.has(a)||c.add(a):i.set(r,new Set([a]))}return i}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:n}=this.range;if(!~t&&!~e)return null;if(n)return this.getSelectionElementList();const i=this.getRangeRow();if(!i)return null;const l=this.position.getPositionList(),r=this.draw.getElementList(),a=[];for(let c=0;c<l.length;c++){const d=l[c],u=i.get(d.pageNo);u&&u.has(d.rowNo)&&a.push(r[c])}return a}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=this.draw.getElementList(),l=new Map;let r=t;for(;r>=0;){const{pageNo:d,rowNo:u}=n[r];let R=l.get(d);R||(R=[],l.set(d,R)),R.includes(u)||R.unshift(u);const h=i[r],g=i[r-1];if(h.value===H&&!h.listWrap||h.listId!==g?.listId||h.titleId!==g?.titleId)break;r--}const a=t===e;if(!a){let d=t+1;for(;d<e;){const{pageNo:u,rowNo:R}=n[d];let h=l.get(u);h||(h=[],l.set(u,h)),h.includes(R)||h.push(R),d++}}let c=e;for(a&&i[t].value===H&&(c+=1);c<n.length;){const d=i[c],u=i[c+1];if(d.value===H&&!d.listWrap||d.listId!==u?.listId||d.titleId!==u?.titleId)break;const{pageNo:R,rowNo:h}=n[c];let g=l.get(R);g||(g=[],l.set(R,g)),g.includes(h)||g.push(h),c++}return l}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let n=-1;const i=[],l=this.getRangeParagraph();if(!l)return null;const r=this.draw.getElementList(),a=this.position.getPositionList();for(let c=0;c<a.length;c++){const d=a[c],u=l.get(d.pageNo);u&&u.includes(d.rowNo)&&(~n||(n=d.index),i.push(r[c]))}return i.length?{elementList:i,startIndex:n}:null}getRangeParagraphElementList(){return this.getRangeParagraphInfo()?.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,n){const{startIndex:i,endIndex:l}=this.range,r=this.position.getPositionList();for(let a=i+1;a<=l&&r[a];a++){const{coordinate:{leftTop:d,rightBottom:u},pageNo:R}=r[a];if(n===R&&t>=d[0]&&t<=u[0]&&e>=d[1]&&e<=u[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),n=new Map;for(const l of e){const r=n.get(l.groupId);if(r)r.endIndex+=1;else{const{type:a,groupId:c,tableId:d,index:u,tdIndex:R,trIndex:h}=l,g={startIndex:u,endIndex:u};a===Qe.TABLE&&(g.tableId=d,g.startTdIndex=R,g.endTdIndex=R,g.startTrIndex=h,g.endTrIndex=h),n.set(c,g)}}const i=[];return n.forEach(l=>{i.push(l)}),i}getIsCanInput(){const{range:{startIndex:t,endIndex:e},elementList:n}=this.getRangeElement(),i=n[t];if(!i)return!1;if(t===e)return(i.controlComponent!==s.ControlComponent.PRE_TEXT||n[t+1]?.controlComponent!==s.ControlComponent.PRE_TEXT)&&i.controlComponent!==s.ControlComponent.POST_TEXT;const l=n[e];return l?!i.controlId&&!l.controlId||(!i.controlId||i.controlComponent===s.ControlComponent.POSTFIX)&&(!l.controlId||l.controlComponent===s.ControlComponent.POSTFIX)||!!i.controlId&&l.controlId===i.controlId&&l.controlComponent!==s.ControlComponent.PRE_TEXT&&l.controlComponent!==s.ControlComponent.POST_TEXT&&l.controlComponent!==s.ControlComponent.POSTFIX:!1}setRange(t,e,n,i,l,r,a,c){this.getIsRangeChange(t,e,n,i,l,r,a)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=n,this.range.startTdIndex=i,this.range.endTdIndex=l,this.range.startTrIndex=r,this.range.endTrIndex=a,this.range.isCrossRowCol=!!(i||l||r||a),this.range.splitTdRange=c,this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const u=this.draw.getControl();if(~t&&~e&&!!this.draw.getElementList()[t]?.controlId&&!this.draw.isContentReadonly()){u.initControl();return}u.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}shrinkRange(){const{startIndex:t,endIndex:e}=this.range;t===e||!~t&&!~e||this.replaceRange({...this.range,startIndex:e})}setRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:i,isCrossRowCol:l}=this.range;if(!~n&&!~i)return;let r;if(l){const P=this.draw.getOriginalElementList(),Y=this.position.getPositionContext();r=P[Y.index]}else{const P=~i?i:0,Y=this.draw.getElementList();r=this.getRangeAnchorStyle(Y,P)}if(!r)return;const a=this.getSelection()||[r],c=r.type||s.ElementType.TEXT,d=r.font||this.options.defaultFont,u=r.size||this.options.defaultSize,R=!~a.findIndex(P=>!P.bold),h=!~a.findIndex(P=>!P.italic),g=!~a.findIndex(P=>!P.underline&&!P.control?.underline),T=!~a.findIndex(P=>!P.strikeout),f=r.color||null,m=r.highlight||null,C=r.rowFlex||null,I=r.vertical||null,p=r.rowMargin??this.options.defaultRowMargin,L=r.dashArray||[],M=r.level||null,O=r.listType||null,b=r.listStyle||null,D=g&&r.textDecoration||null,W=!!this.draw.getPainterStyle(),V=this.historyManager.isCanUndo(),E=this.historyManager.isCanRedo(),y=r.groupIds||null,F=r.extension??null,S=r.deletePerson??"",N={type:c,undo:V,redo:E,painter:W,font:d,size:u,bold:R,italic:h,underline:g,strikeout:T,deletePerson:S,color:f,highlight:m,rowFlex:C,vertical:I,rowMargin:p,dashArray:L,level:M,listType:O,listStyle:b,groupIds:y,textDecoration:D,extension:F};this._emitRangeStyle(N)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const n=this.options.defaultFont,i=this.options.defaultSize,l=this.options.defaultRowMargin,r=!!this.draw.getPainterStyle(),a=this.historyManager.isCanUndo(),c=this.historyManager.isCanRedo(),u={type:null,undo:a,redo:c,painter:r,font:n,size:i,bold:!1,italic:!1,underline:!1,strikeout:!1,deletePerson:"123",color:null,highlight:null,rowFlex:null,rowMargin:l,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,extension:null,vertical:null};this._emitRangeStyle(u)}shrinkBoundary(t={}){const{elementList:e,range:n}=this.getRangeElement(t),{startIndex:i,endIndex:l}=n;if(!~i&&!~l)return;const r=e[i],a=e[l];if(i===l){if(r.controlComponent===s.ControlComponent.PLACEHOLDER&&r.originControlId&&r.control?.type==="text")return;if(r.controlComponent===s.ControlComponent.PLACEHOLDER){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId===r.controlId&&(d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){n.startIndex=c,n.endIndex=c;break}if(d.controlId!==r.controlId&&!d.originControlId)break;c--}}if(r.controlComponent===s.ControlComponent.TEXTFIXLABEL){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===s.ControlComponent.VALUE||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;break}c--}}}else{if(r.controlComponent===s.ControlComponent.PLACEHOLDER||a.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.TEXTFIXLABEL||a.controlComponent===s.ControlComponent.TEXTFIXLABEL){let c=l-1;for(;c>0;){const d=e[c];if(d.controlId!==a.controlId||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;return}c--}}if(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PRETEXTFIX||r.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===s.ControlComponent.VALUE){n.startIndex=c-1;break}else if(d.controlComponent===s.ControlComponent.PLACEHOLDER){n.startIndex=c-1,n.endIndex=c-1;return}c++}}if(a.controlComponent!==s.ControlComponent.VALUE){let c=l-1;for(;c>0;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===s.ControlComponent.VALUE){n.endIndex=c;break}else if(d.controlComponent===s.ControlComponent.PLACEHOLDER){n.startIndex=c,n.endIndex=c;return}c--}}}}render(t,e,n,i,l){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,n,i,l),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(H,"g"),""):""}getRangeElement(t={}){const e=t.elementList||this.draw.getElementList(),n=t.range||this.getRange(),{splitTdRange:i}=n,l={elementList:e,range:n};return i&&(l.range=i,l.elementList=this.draw.getSplitTdValues(i.originalId)??[]),l}}class gd{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,n,i){t.save(),t.fillStyle=e,t.fillRect(0,0,n,i),t.restore()}_drawImage(t,e,n,i){const{background:l,scale:r}=this.options;if(l.size===s.BackgroundSize.CONTAIN){const a=e.width*r,c=e.height*r;if(!l.repeat||l.repeat===s.BackgroundRepeat.NO_REPEAT)t.drawImage(e,0,0,a,c);else{let d=0,u=0;const R=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_X?Math.ceil(n*r/a):1,h=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_Y?Math.ceil(i*r/c):1;for(let g=0;g<R;g++){for(let T=0;T<h;T++)t.drawImage(e,d,u,a,c),u+=c;u=0,d+=a}}}else t.drawImage(e,0,0,n*r,i*r)}_renderBackgroundImage(t,e,n){const{background:i}=this.options,l=this.imageCache.get(i.image);if(l)this._drawImage(t,l,e,n);else{const r=new Image;r.setAttribute("crossOrigin","Anonymous"),r.src=i.image,r.onload=()=>{this.imageCache.set(i.image,r),this._drawImage(t,r,e,n),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:n,color:i,applyPageNumbers:l}}=this.options;if(n&&(!l?.length||l.includes(e))){const{width:r,height:a}=this.options;this._renderBackgroundImage(t,r,a)}else{const r=this.draw.getCanvasWidth(e),a=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,i,r,a)}}}class Di{fillRect;fillColor;fillDecorationStyle;constructor(){this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillDecorationStyle=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,n,i,l,r,a){const c=!this.fillRect.width;if(!c&&(this.fillColor!==r||this.fillDecorationStyle!==a)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,n,i,l,r,a);return}c&&(this.fillRect.x=e,this.fillRect.y=n),l&&this.fillRect.height<l&&(this.fillRect.height=l),this.fillRect.width+=i,this.fillColor=r,this.fillDecorationStyle=a}}class Td extends Di{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:n,y:i,width:l,height:r}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(n,i,l,r),t.restore(),this.clearFillInfo()}}class fd{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:n,pageMode:i}=this.options,l=this.draw.getWidth(),r=i===s.PageMode.CONTINUITY?this.draw.getCanvasHeight(e)/this.draw.getPagePixelRatio():this.draw.getHeight(),a=this.draw.getMargins(),c=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=n,t.beginPath();const d=[a[3],a[0]],u=[l-a[1],a[0]],R=[a[3],r-a[2]],h=[l-a[1],r-a[2]];t.moveTo(d[0]-c,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]-c),t.moveTo(u[0]+c,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]-c),t.moveTo(R[0]-c,R[1]),t.lineTo(...R),t.lineTo(R[0],R[1]+c),t.moveTo(h[0]+c,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+c),t.stroke(),t.restore()}}class md{draw;options;position;range;searchKeyword;searchNavigateIndex;searchOptions;searchMatchList;constructor(t){this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.searchNavigateIndex=null,this.searchOptions=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t,e){this.searchKeyword=t,this.searchNavigateIndex=null,this.searchOptions=e||null}searchNavigatePre(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex-1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===n)return null;this.searchNavigateIndex=this.searchMatchList.length-1-(this.searchKeyword.length-1)}}return this.searchNavigateIndex}searchNavigateNext(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex+1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===n)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:n,rightTop:i},pageNo:l}=t,r=this.draw.getHeight(),a=this.draw.getPageGap(),c=l*(r+a),d=document.createElement("div");d.style.position="absolute";const u=50;d.style.width=`${i[0]-e[0]+u}px`,d.style.height=`${n[1]-e[1]+u}px`,d.style.left=`${e[0]}px`,d.style.top=`${e[1]+c}px`,this.draw.getContainer().append(d),d.scrollIntoView(!1),d.remove()}getSearchNavigateIndexList(){return this.searchNavigateIndex===null||!this.searchKeyword?[]:new Array(this.searchKeyword.length).fill(this.searchNavigateIndex).map((t,e)=>t+e)}getSearchMatchList(){return this.searchMatchList}getSearchNavigateInfo(){if(!this.searchKeyword||!this.searchMatchList.length)return null;const t=this.searchNavigateIndex!==null?this.searchNavigateIndex/this.searchKeyword.length+1:0;let e=0,n=null;for(let i=0;i<this.searchMatchList.length;i++){const l=this.searchMatchList[i];n!==l.groupId&&(n=l.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const{isRegEnable:n=!1,isIgnoreCase:i=!0}=this.searchOptions||{},l=i?t.toLocaleLowerCase():t,r=[],a=[],c=e.length,d=[];for(let g=0;g<c;g++)e[g].type===s.ElementType.TABLE&&d.push(g);let u=0,R=0;for(;R<c-1;){const g=d.length?d[u]:c,T=e.slice(R,g);T.length&&a.push({index:R,type:Qe.PAGE,elementList:T});const f=e[g];f&&a.push({index:g,type:Qe.TABLE,elementList:[f]}),R=g+1,u++}function h(g,T,f,m){if(!g)return;let C=f.map(O=>!O.type||Ie.includes(O.type)&&O.controlComponent!==s.ControlComponent.CHECKBOX&&O.controlComponent!==s.ControlComponent.RADIO&&!O.hide&&!O.control?.hide&&!O.area?.hide?O.value:H).filter(Boolean).join("");i&&(C=C.toLocaleLowerCase());const I=[],p=n?new RegExp(g):g;let{index:L,length:M}=Xs(C,p);for(;L!==-1&&M!==0;){I.push({index:L,length:M});const O=Xs(C,p,L+M);L=O.index,M=O.length}for(let O=0;O<I.length;O++){const{index:b,length:D}=I[O],W=Tt();for(let V=0;V<D;V++){const E=b+V+(m?.startIndex||0);r.push({type:T,index:E,groupId:W,...m})}}}for(let g=0;g<a.length;g++){const T=a[g];if(T.type===Qe.TABLE){const f=T.elementList[0];for(let m=0;m<f.trList.length;m++){const C=f.trList[m];for(let I=0;I<C.tdList.length;I++){const p=C.tdList[I],L={tableId:f.id,tableIndex:T.index,trIndex:m,tdIndex:I,tdId:p.id};h(l,T.type,p.value,L)}}}else h(l,T.type,T.elementList,{startIndex:T.index})}return r}compute(t){const e=this.searchOptions?.isLimitSelection&&!this.range.getIsCollapsed(),n=e?this.range.getSelectionElementList():this.draw.getOriginalElementList();if(!n?.length||(this.searchMatchList=this.getMatchList(t,n),!e||!this.searchMatchList.length))return;const{startIndex:i}=this.range.getRange(),l=i+1;for(const r of this.searchMatchList)r.type===Qe.TABLE?r.tableIndex+=l:r.index+=l}render(t,e){if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:n,searchMatchColor:i,searchNavigateMatchColor:l}=this.options,r=this.position.getOriginalPositionList(),a=this.draw.getOriginalElementList();t.save(),t.globalAlpha=n;for(let c=0;c<this.searchMatchList.length;c++){const d=this.searchMatchList[c];let u=null;if(d.type===Qe.TABLE){const{tableIndex:L,trIndex:M,tdIndex:O,index:b}=d;u=a[L]?.trList[M].tdList[O]?.positionList[b]}else u=r[d.index];if(!u)continue;const{coordinate:{leftTop:R,leftBottom:h,rightTop:g},pageNo:T}=u;if(T!==e)continue;if(this.getSearchNavigateIndexList().includes(c)){t.fillStyle=l;const L=this.searchMatchList[c-1];(!L||L.groupId!==d.groupId)&&this.searchNavigateScrollIntoView(u)}else t.fillStyle=i;const m=R[0],C=R[1],I=g[0]-R[0],p=h[1]-R[1];t.fillRect(m,C,I,p)}t.restore()}replace(t,e){if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const l=e?.index;if(ri(l)){const f=[];i.forEach(m=>{const C=f[f.length-1];!C||C[0].groupId!==m.groupId?f.push([m]):C.push(m)}),i=f[l]}if(!i?.length)return;const r=this.draw.isDesignMode();let a=0,c=0,d="",u="",R=-1;const h=this.draw.getOriginalElementList();for(let f=0;f<i.length;f++){const m=i[f];if(m.type===Qe.TABLE){const{tableIndex:C,trIndex:I,tdIndex:p,index:L,tdId:M}=m;u&&M!==u&&(c=0),u=M;const O=C+a,b=h[O].trList[I].tdList[p].value,D=L+c,W=b[D];if(!r&&(W?.control?.deletable===!1||W?.title?.deletable===!1))continue;if(t===""){this.draw.spliceElementList(b,D,1),c--,~R||(R=f);continue}if(d===m.groupId){this.draw.spliceElementList(b,D,1),c--;continue}~R||(R=f);for(let V=0;V<t.length;V++){const E=t[V];V===0?W.value=E:(this.draw.spliceElementList(b,D+V,0,[{...W,value:E}]),c++)}}else{const C=m.index+a,I=h[C];if(!r&&(I?.control?.deletable===!1||I?.title?.deletable===!1)||I.type===s.ElementType.CONTROL&&I.controlComponent!==s.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,C,1),a--,~R||(R=f);continue}if(~R||(R=f),d===m.groupId){this.draw.spliceElementList(h,C,1),a--;continue}for(let p=0;p<t.length;p++){const L=t[p];p===0?I.value=L:(this.draw.spliceElementList(h,C+p,0,[{...I,value:L}]),a++)}}d=m.groupId}if(!~R)return;const g=i[R],T=g.index+(t.length-1);if(g.type===Qe.TABLE){const{tableIndex:f,trIndex:m,tdIndex:C,index:I}=g,p=h[f].trList[m].tdList[C].value[I];this.position.setPositionContext({isTable:!0,index:f,trIndex:m,tdIndex:C,tdId:p.tdId,trId:p.trId,tableId:p.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(T,T),this.draw.render({curIndex:T})}}class pd extends Di{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{scale:e,strikeoutColor:n}=this.options,{x:i,y:l,width:r}=this.fillRect;t.save(),t.lineWidth=e,t.strokeStyle=n;const a=l-3;t.beginPath(),t.moveTo(i,a),t.lineTo(i+r,a),t.stroke(),t.beginPath(),t.moveTo(i,l+3.5),t.lineTo(i+r,l+3.5),t.stroke(),t.restore(),this.clearFillInfo()}}s.TextDecorationStyle=void 0,(function(o){o.SOLID="solid",o.DOUBLE="double",o.DASHED="dashed",o.DOTTED="dotted",o.WAVY="wavy"})(s.TextDecorationStyle||(s.TextDecorationStyle={}));var Yn;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(Yn||(Yn={}));class Cd extends Di{options;constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,l){const r=e+i;switch(t.beginPath(),l){case Yn.DASHED:t.setLineDash([3,1]);break;case Yn.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(r,n),t.stroke()}_drawDouble(t,e,n,i){const r=e+i,a=n+3*this.options.scale;this.options.mode===s.EditorMode.PRINT||this.options.mode===s.EditorMode.COMPARE?t.strokeStyle="transparent":t.strokeStyle="red",t.beginPath(),t.moveTo(e,n),t.lineTo(r,n),t.stroke(),t.beginPath(),t.moveTo(e,a),t.lineTo(r,a),t.stroke()}_drawWave(t,e,n,i){const{scale:l}=this.options,r=1.2*l,a=1/l,c=n+2*r;t.beginPath();for(let d=0;d<i;d++){const u=r*Math.sin(a*d);t.lineTo(e+d,c+u)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:i,y:l,width:r}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const a=Math.floor(l+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case s.TextDecorationStyle.WAVY:this._drawWave(t,i,a,r);break;case s.TextDecorationStyle.DOUBLE:this._drawDouble(t,i,a,r);break;case s.TextDecorationStyle.DASHED:this._drawLine(t,i,a,r,Yn.DASHED);break;case s.TextDecorationStyle.DOTTED:this._drawLine(t,i,a,r,Yn.DOTTED);break;default:this._drawLine(t,i,a,r);break}t.restore(),this.clearFillInfo()}}class Id{draw;options;ctx;curX;curY;text;curStyle;curColor;cacheMeasureText;constructor(t){this.draw=t,this.options=t.getOptions(),this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.cacheMeasureText=new Map}measureBasisWord(t,e){t.save(),t.font=e;const n=this.measureText(t,{value:xl});return t.restore(),n}measureWord(t,e,n){const i=this.draw.getLetterReg();let l=0,r=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==s.ElementType.TEXT||!i.test(c.value)){r=c;break}l+=this.measureText(t,c).width,a++}return{width:l,endElement:r}}buttonMeasureWord(t,e,n){const i=this.draw.getLetterReg();let l=0,r=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==s.ElementType.TEXT||!i.test(c.value)){r=c;break}l+=this.measureText(t,c).width,a++}return{width:l,endElement:r}}measurePunctuationWidth(t,e){return!e||!Gl.includes(e.value)?0:(t.font=this.draw.getElementFont(e),this.measureText(t,e).width)}measureText(t,e){if(e.width){const r=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:r.actualBoundingBoxAscent,actualBoundingBoxDescent:r.actualBoundingBoxDescent,actualBoundingBoxLeft:r.actualBoundingBoxLeft,actualBoundingBoxRight:r.actualBoundingBoxRight,fontBoundingBoxAscent:r.fontBoundingBoxAscent,fontBoundingBoxDescent:r.fontBoundingBoxDescent}}const n=`${e.value}${t.font}`,i=this.cacheMeasureText.get(n);if(i)return i;const l=t.measureText(e.value);return this.cacheMeasureText.set(n,l),l}getBasisWordBoundingBoxAscent(t,e){return this.measureBasisWord(t,e).actualBoundingBoxAscent}complete(){this._render(),this.text=""}record(t,e,n,i){if(this.ctx=t,this.options.renderMode===s.RenderMode.COMPATIBILITY){this._setCurXY(n,i),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(n,i),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(n,i)),this.text+=e.value,this.curStyle=e.style,this.curColor=e.color}_setCurXY(t,e){this.curX=t,this.curY=e}_render(){!this.text||!~this.curX||!~this.curX||(this.ctx.save(),this.ctx.font=this.curStyle,this.ctx.fillStyle=this.curColor||this.options.defaultColor,this.ctx.fillText(this.text,this.curX,this.curY),this.ctx.restore())}}class Un{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const l=i===s.NumberType.CHINESE?sa(e):`${e}`;return t.replace(n,l)}render(t,e){const{scale:n,pageNumber:{size:i,font:l,color:r,rowFlex:a,numberType:c,format:d,startPageNo:u,fromPageNo:R}}=this.options;if(e<R)return;let h=d;const g=new RegExp($n.PAGE_NO);g.test(h)&&(h=Un.formatNumberPlaceholder(h,e+u-R,g,c));const T=new RegExp($n.PAGE_COUNT);T.test(h)&&(h=Un.formatNumberPlaceholder(h,this.draw.getPageCount()-R,T,c));const f=this.draw.getWidth(),m=this.draw.getHeight(),C=this.draw.getPageNumberBottom(),I=m-C;t.save(),t.fillStyle=r,t.font=`${i*n}px ${l}`;let p=0;const L=this.draw.getMargins(),{width:M}=t.measureText(h);a===s.RowFlex.CENTER?p=(f-M)/2:a===s.RowFlex.RIGHT?p=f-M-L[1]:p=L[3],t.fillText(h,p,I),t.restore()}}class Ld{draw;options;scrollContainer;constructor(t){this.draw=t,this.options=t.getOptions(),this.scrollContainer=this.getScrollContainer(),setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}getScrollContainer(){return this.options.scrollContainerSelector&&document.querySelector(this.options.scrollContainerSelector)||document}_addEvent(){this.scrollContainer.addEventListener("scroll",this._observer)}removeEvent(){this.scrollContainer.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),n=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,i=Math.min(e.bottom,n)-Math.max(e.top,0);return{intersectionHeight:i>0?i:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let n=0,i=0;for(let l=0;l<t.length;l++){const r=t[l],{intersectionHeight:a}=this.getElementVisibleInfo(r);if(i&&!a)break;a&&e.push(l),a>i&&(i=a,n=l)}return{intersectionPageNo:n,visiblePageNoList:e}}_observer=ta(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150)}class Pd{draw;step=5;thresholdPoints=[70,40,10,20];selectionContainer;rangeManager;requestAnimationFrameId;isMousedown;isMoving;clientWidth;clientHeight;containerRect;constructor(t){this.draw=t,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)}_mousedown=t=>{if(this.draw.isInteractionSuspended()){this._mouseup();return}if(!this.draw.isTargetInsideEditor(t.target)){this._mouseup();return}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 e=this.selectionContainer.getBoundingClientRect();this.containerRect=e}};_mouseup=()=>{this.isMousedown=!1,this._stopMove()};_mousemove=t=>{if(this.draw.isInteractionSuspended()||!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(Jt.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove(Jt.DOWN):e<this.thresholdPoints[2]?this._startMove(Jt.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(Jt.RIGHT):this._stopMove()};_move(t){const e=this.selectionContainer instanceof Document?window:this.selectionContainer,n=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,i=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Jt.DOWN?e.scrollTo(n,i+this.step):t===Jt.UP?e.scrollTo(n,i-this.step):t===Jt.LEFT?e.scrollTo(n-this.step,i):e.scrollTo(n+this.step,i),this.requestAnimationFrameId=window.requestAnimationFrame(this._move.bind(this,t))}_startMove(t){this.isMoving||(this.isMoving=!0,this._move(t))}_stopMove(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=null,this.isMoving=!1)}}class Ed{draw;range;options;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=ht(t);for(let n=0;n<t.length;n++){const i=e[n];for(let l=i.tdList.length-1;l>=0;l--){const r=i.tdList[l],{rowspan:a,rowIndex:c,colIndex:d}=r,u=c+a-1;if(u!==l){const R=i.tdList.splice(l,1)[0];e[u]?.tdList.splice(d,0,R)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:l,startTdIndex:r,endTdIndex:a,startTrIndex:c,endTrIndex:d}=this.range.getRange(),h=this.draw.getOriginalElementList()[e].trList;if(!l)return[[h[n].tdList[i]]];let g=h[c].tdList[r],T=h[d].tdList[a];(g.x>T.x||g.y>T.y)&&([g,T]=[T,g]);const f=g.colIndex,m=T.colIndex+(T.colspan-1),C=g.rowIndex,I=T.rowIndex+(T.rowspan-1),p=[];for(let L=0;L<h.length;L++){const M=h[L],O=[];for(let b=0;b<M.tdList.length;b++){const D=M.tdList[b],W=D.colIndex,V=D.rowIndex;W>=f&&W<=m&&V>=C&&V<=I&&O.push(D)}O.length&&p.push(O)}return p.length?p:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:i,width:l,height:r,isDrawFullBorder:a,borderExternalWidth:c,skipTopBorderRanges:d=[]}=t,{scale:u}=this.options,R=this._mergeHorizontalBorderRanges(d,l),h=e.lineWidth;c&&(e.lineWidth=c*u),e.beginPath();const g=Math.round(n),T=Math.round(i);e.translate(.5,.5),a&&!R.length?e.rect(g,T,l,r):(a?(e.moveTo(g,T),e.lineTo(g,T+r),e.lineTo(g+l,T+r),e.lineTo(g+l,T)):(e.moveTo(g,T+r),e.lineTo(g,T)),this._drawHorizontalBorder(e,g,T,l,R)),e.stroke(),c&&(e.lineWidth=h),e.translate(-.5,-.5)}_drawHorizontalBorder(t,e,n,i,l){if(!l.length){t.lineTo(e+i,n);return}let r=0;l.forEach(([a,c])=>{r<a&&(t.moveTo(e+r,n),t.lineTo(e+a,n)),r=Math.max(r,c)}),r<i&&(t.moveTo(e+r,n),t.lineTo(e+i,n))}_mergeHorizontalBorderRanges(t,e){return t.map(([i,l])=>[Math.max(0,Math.min(i,e)),Math.max(0,Math.min(l,e))]).filter(([i,l])=>l>i).sort(([i],[l])=>i-l).reduce((i,l)=>{const r=i[i.length-1];return!r||l[0]>r[1]?i.push(l):l[1]>r[1]&&(r[1]=l[1]),i},[])}_getPagingContinuationTopBorderRanges(t,e){const{scale:n}=this.options,i=[];for(let l=0;l<t.length;l++){const r=t[l];for(let a=0;a<r.tdList.length;a++){const c=r.tdList[a];!c.linkTdPrevId||c.y!==0||i.push([c.x*n,(c.x+c.width)*n])}}return this._mergeHorizontalBorderRanges(i,e)}_drawSlash(t,e,n,i){const{scale:l}=this.options;t.save();const r=e.width*l,a=e.height*l,c=Math.round(e.x*l+n),d=Math.round(e.y*l+i);e.slashTypes?.includes(s.TdSlash.FORWARD)&&(t.moveTo(c+r,d),t.lineTo(c,d+a)),e.slashTypes?.includes(s.TdSlash.BACK)&&(t.moveTo(c,d),t.lineTo(c+r,d+a)),t.stroke(),t.restore()}_drawBorder(t,e,n,i){const{colgroup:l,trList:r,borderType:a,borderColor:c,borderWidth:d=1,borderExternalWidth:u}=e;if(!l||!r)return;const{scale:R,table:{defaultBorderColor:h}}=this.options,g=e.width*R,T=e.height*R,f=this._getPagingContinuationTopBorderRanges(r,g),m=a===s.TableBorder.EMPTY,C=a===s.TableBorder.EXTERNAL,I=a===s.TableBorder.INTERNAL;t.save(),a===s.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=d*R,t.strokeStyle=c||h,!m&&!I&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:T,borderExternalWidth:u,isDrawFullBorder:C,skipTopBorderRanges:f});for(let p=0;p<r.length;p++){const L=r[p];for(let M=0;M<L.tdList.length;M++){const O=L.tdList[M];if(O.slashTypes?.length&&this._drawSlash(t,O,n,i),!O.borderTypes?.length&&(m||C))continue;const b=O.width*R,D=O.height*R,W=Math.round(O.x*R+n+b),V=Math.round(O.y*R+i),E=!!O.linkTdPrevId,y=!!O.linkTdNextId;if(t.translate(.5,.5),t.beginPath(),!E&&O.borderTypes?.includes(s.TdBorder.TOP)&&(t.moveTo(W-b,V),t.lineTo(W,V),t.stroke()),O.borderTypes?.includes(s.TdBorder.RIGHT)&&(t.moveTo(W,V),t.lineTo(W,V+D),t.stroke()),O.borderTypes?.includes(s.TdBorder.BOTTOM)&&(t.moveTo(W,V+D),t.lineTo(W-b,V+D),t.stroke()),O.borderTypes?.includes(s.TdBorder.LEFT)&&(t.moveTo(W-b,V),t.lineTo(W-b,V+D),t.stroke()),!m&&!C){if((!I||O.colIndex+O.colspan<l.length)&&(t.moveTo(W,V),t.lineTo(W,V+D),u&&u!==d&&O.colIndex+O.colspan===l.length)){const F=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=F}if(y||!I||O.rowIndex+O.rowspan<r.length){const F=u&&u!==d&&O.rowIndex+O.rowspan===r.length;if(F&&(t.stroke(),t.beginPath()),t.moveTo(W,V+D),t.lineTo(W-b,V+D),F){const S=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=S}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,i){const{trList:l}=e;if(!l)return;const{scale:r}=this.options;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];if(!u.backgroundColor)continue;t.save();const R=u.width*r,h=u.height*r,g=Math.round(u.x*r+n),T=Math.round(u.y*r+i);t.fillStyle=u.backgroundColor,t.fillRect(g,T,R,h),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,n)=>e+n.width,0)}getTableHeight(t){const e=t.trList;return e?.length?this.getTdListByColIndex(e,0).reduce((n,i)=>n+i.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((n,i)=>n+i.rowspan,0)}getTdListByColIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const l=t[i].tdList;for(let r=0;r<l.length;r++){const a=l[r],c=a.colIndex,d=c+a.colspan-1;e>=c&&e<=d&&n.push(a)}}return n}getTdListByRowIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const l=t[i].tdList;for(let r=0;r<l.length;r++){const a=l[r],c=a.rowIndex,d=c+a.rowspan-1;e>=c&&e<=d&&n.push(a)}}return n}computeRowColInfo(t){const{colgroup:e,trList:n}=t;if(!e||!n)return;let i=0;for(let l=0;l<n.length;l++){const r=n[l],a=n.length-1===l;for(let c=0;c<r.tdList.length;c++){const d=r.tdList[c];let u=0;if(n.length>1&&l!==0){const C=r.tdList[c-1],I=C?C.colIndex+C.colspan:c;for(let p=I;p<e.length;p++)if(this.getRowCountByColIndex(n.slice(0,l),p)===l){u=p;let M=0;for(let O=0;O<p;O++)M+=e[O].width;i=M;break}}else{const C=r.tdList[c-1];C&&(u=C.colIndex+C.colspan)}let R=0;for(let C=0;C<d.colspan;C++)R+=e[C+u].width;let h=0;for(let C=0;C<d.rowspan;C++){const I=n[C+l]||n[l];h+=I.height}const g=r.tdList.length-1===c;let T=a;if(!T&&d.rowspan>1){const C=n.length-1-l;T=d.rowspan-1===C}const f=a&&g;d.isLastRowTd=g,d.isLastColTd=T,d.isLastTd=f,d.x=i;let m=0;for(let C=0;C<l;C++){const I=n[C].tdList;for(let p=0;p<I.length;p++){const L=I[p];if(u>=L.colIndex&&u<L.colIndex+L.colspan){m+=L.height;break}}}d.y=m,d.width=R,d.height=h,d.rowIndex=l,d.colIndex=u,d.trIndex=l,d.tdIndex=c,i+=R,g&&!f&&(i=0)}}}drawRange(t,e,n,i){const{scale:l,rangeAlpha:r,rangeColor:a}=this.options,{type:c,trList:d}=e;if(!d||c!==s.ElementType.TABLE)return;const{isCrossRowCol:u,startTdIndex:R,endTdIndex:h,startTrIndex:g,endTrIndex:T}=this.range.getRange();if(!u)return;let f=d[g].tdList[R],m=d[T].tdList[h];(f.x>m.x||f.y>m.y)&&([f,m]=[m,f]);const C=f.colIndex,I=m.colIndex+(m.colspan-1),p=f.rowIndex,L=m.rowIndex+(m.rowspan-1);t.save();for(let M=0;M<d.length;M++){const O=d[M];for(let b=0;b<O.tdList.length;b++){const D=O.tdList[b],W=D.colIndex,V=D.rowIndex;if(W>=C&&W<=I&&V>=p&&V<=L){const E=D.x*l,y=D.y*l,F=D.width*l,S=D.height*l;t.globalAlpha=r,t.fillStyle=a,t.fillRect(E+n,y+i,F,S)}}}t.restore()}render(t,e,n,i){this._drawBackgroundColor(t,e,n,i),this._drawBorder(t,e,n,i)}findPreRowSpanTd(t,e,n){for(let i=e;i>=0;i--){const l=t[i].tdList.find(r=>r.colIndex===n);if(l)return l}}computeTrHeight(t,e){const{scale:n,table:{tdPadding:i,defaultTrMinHeight:l}}=this.options,r=t.tdPadding||i,a=r[0]+r[2],c=t.trList;for(let R=0;R<c.length;R++){const h=c[R];h.height=h.minHeight||l,h.minHeight=h.height}this.computeRowColInfo(t);const d={},u={};for(let R=0;R<c.length;R++){const h=c[R];if(!h.tdList.length){h.height=0;continue}const g=[],T=[];for(let m=0;m<t.colgroup.length;m++){const C=h.tdList.find(I=>I.colIndex===m);if(C){const I=e?e(C):C.rowList,p=I.reduce((M,O)=>M+O.height,0);C.rowList=I;const L=p/n+a;C.mainHeight=L,C.rowspan>1?(u[C.colIndex]=C.id,d[C.id]={td:C,rowSpan:[R,R+C.rowspan-1],preHeight:0,preMinHeight:0,extraHeight:L},T.push(L)):C.height<L?(C.height=L,C.realHeight=L,g.push(L)):g.push(C.height)}else{const I=d[u[m]];I?.rowSpan[1]==R&&g.push(I.extraHeight)}}const f=Math.max(...g.length?g:T);Object.values(d).forEach(m=>{m.rowSpan[0]<=R&&m.rowSpan[1]>=R&&(m.extraHeight-=f,m.preHeight+=f,m.preMinHeight+=h.minHeight)}),h.height=f;for(let m=0;m<t.colgroup.length;m++){const C=h.tdList.find(I=>I.colIndex===m)??this.findPreRowSpanTd(c,R,m);if(C){const I=d[C.id]?.preHeight??0,p=d[C.id]?.preMinHeight??h.minHeight;C.height=f+I,C.realHeight=f+I,C.realMinHeight=p}}}this.computeRowColInfo(t)}}var _e;(function(o){o.ROW="row",o.COL="col"})(_e||(_e={}));class Md{MIN_TD_WIDTH=20;ROW_COL_OFFSET=18;ROW_COL_QUICK_WIDTH=16;ROW_COL_QUICK_OFFSET=5;ROW_COL_QUICK_POSITION=this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2;BORDER_VALUE=4;TABLE_SELECT_OFFSET=20;draw;canvas;options;position;range;container;toolRowContainer;toolRowAddBtn;toolColAddBtn;toolTableSelectBtn;toolColContainer;toolBorderContainer;anchorLine;mousedownX;mousedownY;constructor(t){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(){this.toolRowContainer?.remove(),this.toolRowAddBtn?.remove(),this.toolColAddBtn?.remove(),this.toolTableSelectBtn?.remove(),this.toolColContainer?.remove(),this.toolBorderContainer?.remove(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null}render(){if(this.draw.getMode()===s.EditorMode.FORM){this.dispose();return}const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.position.getPositionContext();if(!t)return;this.dispose();const l=this.draw.getOriginalElementList(),r=this.position.getOriginalPositionList(),a=l[e];if(a.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:c,table:{overflow:d}}=this.options,u=r[e],{colgroup:R,trList:h}=a,{coordinate:{leftTop:g}}=u,T=this.draw.getHeight(),f=this.draw.getPageGap(),m=this.draw.getPageNo()*(T+f),C=g[0],I=g[1]+m,p=a.trList[n].tdList[i],L=p.rowIndex,M=p.colIndex,O=a.height*c,b=a.width*c,D=document.createElement("div");D.classList.add(`${tt}-table-tool__select`),D.style.height=`${O*c}`,D.style.left=`${C}px`,D.style.top=`${I}px`,D.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*c}px, ${-this.TABLE_SELECT_OFFSET*c}px)`,D.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(D),this.toolTableSelectBtn=D;const W=h.map(P=>P.height),V=document.createElement("div");V.classList.add(`${tt}-table-tool__row`),V.style.transform=`translateX(-${this.ROW_COL_OFFSET*c}px)`;for(let P=0;P<W.length;P++){const Y=W[P]*c,X=document.createElement("div");X.classList.add(`${tt}-table-tool__row__item`),P===L&&X.classList.add("active"),X.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByRowIndex(h,P),v=Q[0],w=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:v.trIndex,tdIndex:v.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,v.tdIndex,w.tdIndex,v.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(V,P)};const U=document.createElement("div");U.classList.add(`${tt}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:P,order:_e.ROW})},X.append(U),X.style.height=`${Y}px`,V.append(X)}V.style.left=`${C}px`,V.style.top=`${I}px`,this.container.append(V),this.toolRowContainer=V;const E=document.createElement("div");E.classList.add(`${tt}-table-tool__quick__add`),E.style.height=`${O*c}`,E.style.left=`${C}px`,E.style.top=`${I+O}px`,E.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*c}px, ${this.ROW_COL_QUICK_OFFSET*c}px)`,E.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(E),this.toolRowAddBtn=E;const y=R.map(P=>P.width),F=document.createElement("div");F.classList.add(`${tt}-table-tool__col`),F.style.transform=`translateY(-${this.ROW_COL_OFFSET*c}px)`;for(let P=0;P<y.length;P++){const Y=y[P]*c,X=document.createElement("div");X.classList.add(`${tt}-table-tool__col__item`),P===M&&X.classList.add("active"),X.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByColIndex(h,P),v=Q[0],w=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:v.trIndex,tdIndex:v.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,v.tdIndex,w.tdIndex,v.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(F,P)};const U=document.createElement("div");U.classList.add(`${tt}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:P,order:_e.COL})},X.append(U),X.style.width=`${Y}px`,F.append(X)}F.style.left=`${C}px`,F.style.top=`${I}px`,this.container.append(F),this.toolColContainer=F;const S=document.createElement("div");S.classList.add(`${tt}-table-tool__quick__add`),S.style.height=`${O*c}`,S.style.left=`${C+b}px`,S.style.top=`${I}px`,S.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*c}px, -${this.ROW_COL_QUICK_POSITION*c}px)`,S.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(S),this.toolColAddBtn=S;const N=document.createElement("div");N.classList.add(`${tt}-table-tool__border`),N.style.height=`${O}px`,N.style.width=`${b}px`,N.style.left=`${C}px`,N.style.top=`${I}px`;for(let P=0;P<h.length;P++){const Y=h[P];for(let X=0;X<Y.tdList.length;X++){const U=Y.tdList[X],Q=document.createElement("div");Q.classList.add(`${tt}-table-tool__border__row`),Q.style.width=`${U.width*c}px`,Q.style.height=`${this.BORDER_VALUE}px`,Q.style.top=`${(U.y+U.height)*c-this.BORDER_VALUE/2}px`,Q.style.left=`${U.x*c}px`,Q.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.rowIndex+U.rowspan-1,order:_e.ROW})},N.appendChild(Q);const v=document.createElement("div");if(v.classList.add(`${tt}-table-tool__border__col`),v.style.width=`${this.BORDER_VALUE}px`,v.style.height=`${U.height*c}px`,v.style.top=`${U.y*c}px`,v.style.left=`${(U.x+U.width)*c-this.BORDER_VALUE/2}px`,v.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.colIndex+U.colspan-1,order:_e.COL})},N.appendChild(v),d&&U.colIndex===0){const w=document.createElement("div");w.classList.add(`${tt}-table-tool__border__col`),w.style.width=`${this.BORDER_VALUE}px`,w.style.height=`${U.height*c}px`,w.style.top=`${U.y*c}px`,w.style.left=`${U.x*c-this.BORDER_VALUE/2}px`,w.onmousedown=j=>{this._mousedown({evt:j,element:a,index:0,isLeftStartBorder:!0,order:_e.COL})},N.appendChild(w)}}}this.container.append(N),this.toolBorderContainer=N}_setAnchorActive(t,e){const n=t.children;for(let i=0;i<n.length;i++){const l=n[i];i===e?l.classList.add("active"):l.classList.remove("active")}}_mousedown(t){const{evt:e,index:n,order:i,element:l,isLeftStartBorder:r}=t;this.canvas=this.draw.getPage();const{scale:a,table:{overflow:c}}=this.options,d=this.draw.getWidth(),u=this.draw.getHeight(),R=this.draw.getPageGap(),h=this.draw.getPageNo()*(u+R),g=this.position.getPositionContext(),m=(this.position.getOriginalPositionList()[g.index]?.coordinate?.leftTop?.[0]||0)*a,C=this.draw.getMargins(),I=C[0],p=C[1],L=I,M=d-p;this.mousedownX=e.x,this.mousedownY=e.y;const O=e.target,b=this.canvas.getBoundingClientRect(),D=window.getComputedStyle(O).cursor;document.body.style.cursor=D,this.canvas.style.cursor=D;let W=0,V=0;const E=document.createElement("div");E.classList.add(`${tt}-table-anchor__line`),i===_e.ROW?(E.classList.add(`${tt}-table-anchor__line__row`),E.style.width=`${d}px`,W=0,V=h+this.mousedownY-b.top):(E.classList.add(`${tt}-table-anchor__line__col`),E.style.height=`${u}px`,W=this.mousedownX-b.left,V=h),E.style.left=`${W}px`,E.style.top=`${V}px`,this.container.append(E),this.anchorLine=E;let y=0,F=0;const S=N=>{const P=this._mousemove(N,i,W,V);P&&(y=P.dx,F=P.dy)};document.addEventListener("mousemove",S),document.addEventListener("mouseup",()=>{let N=!1;if(i===_e.ROW){const P=l.trList,Y=P[n]||P[n-1],{defaultTrMinHeight:X}=this.options.table;F<0&&Y.height+F<X&&(F=X-Y.height),F&&(Y.height+=F,Y.minHeight=Y.height,N=!0)}else{const{colgroup:P}=l;if(P&&y)if(c&&r){P[n].width-y/a<=this.MIN_TD_WIDTH&&(y=(P[n].width-this.MIN_TD_WIDTH)*a);const Y=m+(l.translateX||0)*a;Y+y<L&&(y=L-Y),P[n].width-=y/a,l.width-=y/a,l.translateX=(l.translateX||0)+y/a,N=!0}else{const Y=P[n].width;y<0&&Y*a+y<this.MIN_TD_WIDTH*a&&(y=this.MIN_TD_WIDTH*a-Y*a);const X=P[n+1]?.width;if(y>0&&X&&X*a-y<this.MIN_TD_WIDTH*a&&(y=X*a-this.MIN_TD_WIDTH*a),n===P.length-1){const Q=m+(l.translateX||0)*a+l.width*a;Q+y>M&&(y=M-Q)}y&&(P.length-1!==n&&(P[n+1].width-=y/a),P[n].width+=y/a,N=!0)}}N&&this.draw.render({isSetCursor:!1}),E.remove(),document.removeEventListener("mousemove",S),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,i){if(!this.anchorLine)return null;const l=t.x-this.mousedownX,r=t.y-this.mousedownY;return e===_e.ROW?this.anchorLine.style.top=`${i+r}px`:this.anchorLine.style.left=`${n+l}px`,t.preventDefault(),{dx:l,dy:r}}}class Od{draw;options;container;hyperlinkPopupContainer;hyperlinkDom;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:n}=this._createHyperlinkPopupDom();this.hyperlinkDom=n,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${tt}-hyperlink-popup`);const e=document.createElement("a");return e.target="_blank",e.rel="noopener",t.append(e),this.container.append(t),{hyperlinkPopupContainer:t,hyperlinkDom:e}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[n,i]},lineHeight:l}=e,r=this.draw.getHeight(),a=this.draw.getPageGap(),c=this.draw.getPageNo()*(r+a);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${i+c+l}px`;const d=t.url||"#";this.hyperlinkDom.href=d,this.hyperlinkDom.title=d,this.hyperlinkDom.innerText=d}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,i){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),t.fillText(e.value,n,i),t.restore()}}class Sd{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:l,label:{defaultBackgroundColor:r,defaultColor:a,defaultBorderRadius:c,defaultPadding:d}}=this.options,u=e.label?.backgroundColor||r,R=e.label?.color||a,h=e.label?.borderRadius||c,g=e.label?.padding||d;t.save(),t.font=e.style;const{width:T,height:f,boundingBoxAscent:m}=e.metrics;t.fillStyle=u,this._drawRoundedRect(t,n,i-m,T,f+(g[0]+g[3])*l,h*l),t.fill(),t.fillStyle=R,t.fillText(e.value,n+g[3]*l,i),t.restore()}_drawRoundedRect(t,e,n,i,l,r){t.beginPath(),t.moveTo(e+r,n),t.lineTo(e+i-r,n),t.quadraticCurveTo(e+i,n,e+i,n+r),t.lineTo(e+i,n+l-r),t.quadraticCurveTo(e+i,n+l,e+i-r,n+l),t.lineTo(e+r,n+l),t.quadraticCurveTo(e,n+l,e,n+l-r),t.lineTo(e,n+r),t.quadraticCurveTo(e,n,e+r,n),t.closePath()}}class Xd{options;draw;activeInlineEditor;constructor(t){this.draw=t,this.options=t.getOptions(),this.activeInlineEditor=null}render(t,e,n,i){const l=this.draw.getMode(),r=e.macroConfig;if(l===s.EditorMode.READONLY&&e.type!=="subTemplate"){this._renderPlainText(t,e,n,i,Po(e));return}if(l===s.EditorMode.EDIT){const c=e.label||e.value||"";this._renderEditMode(t,e,n,i,c);return}if(e.type==="macro"){const c=e.label||"",d=e.value||`获取 ${c}`;this._renderPlainText(t,e,n,i,d);return}if(e.type==="customMacro"){const c=r?.type||"text",d=r?.value||"",u=e.label||"";if(l===s.EditorMode.FORM)this.activeInlineEditor?.elementId===e.id&&this._syncInlineEditorPosition(),c==="select"?this._renderSelectControl(t,e,n,i,d):this._renderTextControl(t,e,n,i,d);else{const R=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,R)}return}if(e.type==="reusableItem"){const d=e.reusableItemConfig?.value||"",u=e.label||"";if(l===s.EditorMode.FORM)this._renderTextControl(t,e,n,i,d);else{const R=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,R)}return}if(e.type==="subTemplate"){const c=e.label||"子模板";l===s.EditorMode.FORM?e.subTemplateExpanded||this._renderEditMode(t,e,n,i,c):this._renderPlainText(t,e,n,i,c);return}const a=e.value||e.label||"";this._renderPlainText(t,e,n,i,a)}activateInlineEditor(t,e){if(this.draw.getMode()!==s.EditorMode.FORM||t.type!=="customMacro")return!1;const n=this._ensureMacroConfig(t),i=n.type||"text",l=this.activeInlineEditor;if(l&&l.elementId===t.id&&l.type===i)return l.input.focus(),l.input instanceof HTMLInputElement&&l.input.select(),!0;this.clearInlineEditor({isSubmitHistory:!1});const r=document.createElement("div");r.style.position="absolute",r.style.zIndex="1002",r.style.boxSizing="border-box",r.style.display="flex",r.style.alignItems="center";const a=this._getInlineEditorBaseStyle(t);let c;i==="select"?c=this._createSelectEditor(t,r):c=this._createTextEditor(t,r),c.style.boxSizing="border-box",c.style.width="100%",c.style.height="100%",c.style.border="none",c.style.outline="none",c.style.background="transparent",c.style.font=a.font,c.style.color=a.color,c.style.padding=a.padding,c.style.margin="0",r.append(c),r.addEventListener("mousedown",u=>u.stopPropagation()),r.addEventListener("click",u=>u.stopPropagation()),this.draw.getContainer().append(r),this.draw.setOverlayActive(!0);const d=u=>{const R=u.target;R instanceof Node&&r.contains(R)||this.clearInlineEditor()};return document.addEventListener("mousedown",d,!0),this.activeInlineEditor={elementId:t.id,index:e,type:i,wrapper:r,input:c,initialValue:n.value||"",initialCode:n.code,outsideHandler:d},this._syncInlineEditorPosition(),c.focus(),c instanceof HTMLInputElement?c.select():"showPicker"in c&&typeof c.showPicker=="function"?c.showPicker():c.click(),!0}clearInlineEditor(t={}){const e=this.activeInlineEditor;if(!e)return;const{isSubmitHistory:n=!0,isRestore:i=!1}=t;document.removeEventListener("mousedown",e.outsideHandler,!0);const l=this._getInlineEditorElement(e),r=l?.macroConfig,a=e.input.value||"",c=e.input instanceof HTMLSelectElement&&e.input.value||"";if(l&&r&&(i?(r.value=e.initialValue,e.type==="select"&&(r.code=e.initialCode)):e.type==="text"?r.value=a:(r.code=c||void 0,r.value=this._getSelectLabelByCode(r,c))),e.wrapper.remove(),this.activeInlineEditor=null,this.draw.setOverlayActive(!1),l&&!i){const d=this._ensureMacroConfig(l),u=d.value||"",R=d.code;u!==e.initialValue||R!==e.initialCode?this.draw.getCommand().setMacroValue({id:l.id,dictCode:l.dictCode,label:l.label,areaId:l.areaId,value:u,code:R,isSubmitHistory:n}):this.draw.render({isSubmitHistory:!1,isSetCursor:!1})}else this.draw.render({isSubmitHistory:!1,isSetCursor:!1})}_renderPlainText(t,e,n,i,l){t.save(),t.font=e.style,t.fillStyle=e.color||"#000000",t.textBaseline="alphabetic",t.fillText(l,n,i),t.restore()}_renderEditMode(t,e,n,i,l){const{scale:r}=this.options,a=e.type==="customMacro",c=e.type==="reusableItem",d=e.type==="subTemplate";let u,R;d?(u="#722ed1",R="#f9f0ff"):c?(u="#52c41a",R="#f6ffed"):a?(u="#fa8c16",R="#fff7e6"):(u="#1677ff",R="#e6f4ff"),t.save(),t.font=e.style;const h=t.measureText(l),g=h.actualBoundingBoxAscent+h.actualBoundingBoxDescent,T=8*r,f=4*r,m=4*r,C=h.width+T*2,I=g+f*2,p=e.metrics,L=n,M=i-p.boundingBoxAscent+(p.boundingBoxAscent+p.boundingBoxDescent-I)/2;t.fillStyle=R,this._drawRoundedRect(t,L,M,C,I,m),t.fill(),t.fillStyle=u,t.textBaseline="middle",t.fillText(l,n+T,M+I/2),t.restore()}_renderTextControl(t,e,n,i,l){const{scale:r,control:a,strikeoutColor:c}=this.options,{placeholderColor:d,bracketColor:u}=a;t.save(),t.font=e.style;const h=`请输入${e.label||""}`,g=l||h,f=t.measureText(g).width;t.fillStyle=u,t.textBaseline="alphabetic",t.fillText("[",n,i);const m=n+t.measureText("[").width;t.fillStyle=l?e.color||"#000000":d,t.fillText(g,m,i);const C=m+f;if(t.fillStyle=u,t.fillText("]",C,i),e.type==="reusableItem"){const I=t.measureText("[").width+f+t.measureText("]").width;if(t.lineWidth=r,this.draw.isPrintLikeMode()?t.strokeStyle="transparent":t.strokeStyle=c||"red",e.strikeout){const p=i-3*r,L=i+3.5*r;t.beginPath(),t.moveTo(n,p),t.lineTo(n+I,p),t.stroke(),t.beginPath(),t.moveTo(n,L),t.lineTo(n+I,L),t.stroke()}else if(e.underline&&e.textDecoration?.style==="double"){const p=Math.floor(i+2*r)+.5,L=3*r;t.beginPath(),t.moveTo(n,p),t.lineTo(n+I,p),t.stroke(),t.beginPath(),t.moveTo(n,p+L),t.lineTo(n+I,p+L),t.stroke()}}t.restore()}_renderSelectControl(t,e,n,i,l){const{scale:r,control:a}=this.options,{placeholderColor:c,bracketColor:d}=a;t.save(),t.font=e.style;const R=`请选择${e.label||""}`,h=l||R,g=t.measureText(h),T=g.actualBoundingBoxAscent+g.actualBoundingBoxDescent;t.fillStyle=d,t.textBaseline="alphabetic",t.fillText("[",n,i);const f=n+t.measureText("[").width;t.fillStyle=l?e.color||"#000000":c,t.fillText(h,f,i);const m=f+g.width+2*r,C=i-T/2;t.beginPath(),t.moveTo(m,C-2*r),t.lineTo(m+5*r,C-2*r),t.lineTo(m+2.5*r,C+2*r),t.closePath(),t.fillStyle="#666666",t.fill();const I=m+6*r;t.fillStyle=d,t.fillText("]",I,i),t.restore()}_drawRoundedRect(t,e,n,i,l,r){t.beginPath(),t.moveTo(e+r,n),t.lineTo(e+i-r,n),t.quadraticCurveTo(e+i,n,e+i,n+r),t.lineTo(e+i,n+l-r),t.quadraticCurveTo(e+i,n+l,e+i-r,n+l),t.lineTo(e+r,n+l),t.quadraticCurveTo(e,n+l,e,n+l-r),t.lineTo(e,n+r),t.quadraticCurveTo(e,n,e+r,n),t.closePath()}_createTextEditor(t,e){const n=document.createElement("input");return n.type="text",n.value=t.macroConfig?.value||"",n.placeholder=`请输入${t.label||""}`,n.style.minWidth="0",n.style.background="#ffffff",n.addEventListener("input",()=>{const i=this._ensureMacroConfig(t);i.value=n.value}),n.addEventListener("keydown",i=>{i.key==="Enter"?(i.preventDefault(),this.clearInlineEditor()):i.key==="Escape"&&(i.preventDefault(),this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0}))}),n.addEventListener("blur",()=>{this.activeInlineEditor?.input===n&&this.clearInlineEditor()}),e.style.background="#ffffff",e.style.border="1px solid #1677ff",e.style.borderRadius="4px",e.style.boxShadow="0 0 0 2px rgba(22, 119, 255, 0.12)",n}_createSelectEditor(t,e){const n=document.createElement("select"),i=this._ensureMacroConfig(t),l=document.createElement("option");return l.value="",l.textContent=`请选择${t.label||""}`,n.append(l),i.items?.forEach(r=>{const a=document.createElement("option");a.value=r.code,a.textContent=r.value,n.append(a)}),n.value=i.code||i.items?.find(r=>r.value===i.value)?.code||"",n.addEventListener("change",()=>{i.code=n.value||void 0,i.value=this._getSelectLabelByCode(i,n.value),this.clearInlineEditor()}),n.addEventListener("keydown",r=>{r.key==="Escape"?(r.preventDefault(),this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0})):r.key==="Enter"&&(r.preventDefault(),this.clearInlineEditor())}),n.addEventListener("blur",()=>{this.activeInlineEditor?.input===n&&this.clearInlineEditor()}),e.style.background="#ffffff",e.style.border="1px solid #1677ff",e.style.borderRadius="4px",e.style.boxShadow="0 0 0 2px rgba(22, 119, 255, 0.12)",n}_syncInlineEditorPosition(){const t=this.activeInlineEditor;if(!t)return;const e=this._getInlineEditorPosition(t);if(!e){this.clearInlineEditor({isSubmitHistory:!1});return}const n=e.pageNo*(this.draw.getHeight()+this.draw.getPageGap()),[i,l]=e.coordinate.leftTop,r=Math.max(e.lineHeight,e.metrics.height),a=Math.max(e.metrics.width,80*this.options.scale),c=Math.max(0,(e.lineHeight-r)/2);t.wrapper.style.left=`${i}px`,t.wrapper.style.top=`${l+n+c}px`,t.wrapper.style.width=`${a}px`,t.wrapper.style.height=`${r}px`}_getInlineEditorBaseStyle(t){return{font:this.draw.getElementFont(t),color:t.color||"#000000",padding:`0 ${6*this.options.scale}px`}}_getInlineEditorElement(t){const e=this.draw.getElementList()[t.index];return e?.id===t.elementId?e:t.elementId?this.draw.getElementList().find(n=>n.id===t.elementId)||null:e||null}_getInlineEditorPosition(t){return this.draw.getPosition().getPositionList()[t.index]||null}_ensureMacroConfig(t){return t.macroConfig||(t.macroConfig={type:"text"}),t.macroConfig}_getSelectLabelByCode(t,e){return e&&t.items?.find(n=>n.code===e)?.value||""}}class Nd{draw;position;zone;options;elementList;rowList;positionList;constructor(t,e){this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth(),e=this.draw.getMargins(),n=Li(this.elementList);this.rowList=this.draw.computeRowList({startX:e[3],startY:this.getHeaderTop(),innerWidth:t,elementList:this.elementList,surroundElementList:n})}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],l=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:l,innerWidth:e,zone:s.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*Is[t])}getHeight(){if(this.options.header.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getHeaderTop()+e-t[0];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),l=[];let r=0;for(let a=0;a<this.rowList.length;a++){const c=this.rowList[a];if(r+c.height>i)break;l.push(c),r+=c.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:l,pageNo:e,startIndex:0,innerWidth:n,zone:s.EditorZone.HEADER}),t.restore()}}class Fd{getOffsetY(t){return-t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class yd{getOffsetY(t){return t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class bd{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){t.save();const{scale:l,separator:{lineWidth:r,strokeStyle:a}}=this.options;t.lineWidth=(e.lineWidth||r)*l,t.strokeStyle=e.color||a,e.dashArray?.length&&t.setLineDash(e.dashArray);const c=Math.round(i);t.translate(0,t.lineWidth/2),t.beginPath(),t.moveTo(n,c),t.lineTo(n+e.width*l,c),t.stroke(),t.restore()}}class Dd{draw;options;i18n;constructor(t){this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,n,i){const{pageBreak:{font:l,fontSize:r,lineDash:a}}=this.options,c=this.i18n.t("pageBreak.displayName"),{scale:d,defaultRowMargin:u}=this.options,R=r*d,h=e.width*d,g=this.draw.getDefaultBasicRowMarginHeight()*u;t.save(),t.font=`${R}px ${l}`;const T=t.measureText(c),f=(h-T.width)/2;t.setLineDash(a),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,i),t.lineTo(n+f,i),t.moveTo(n+f+T.width,i),t.lineTo(n+h,i),t.stroke(),t.fillText(c,n+f,i+T.actualBoundingBoxAscent-R/2),t.restore()}}class Vd{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:n,opacity:i,font:l,size:r,color:a,repeat:c,gap:d,numberType:u},scale:R}=this.options,h=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=i,t.font=`${r*R}px ${l}`;let T=n;const f=new RegExp($n.PAGE_NO);f.test(T)&&(T=Un.formatNumberPlaceholder(T,e+1,f,u));const m=new RegExp($n.PAGE_COUNT);m.test(T)&&(T=Un.formatNumberPlaceholder(T,this.draw.getPageCount(),m,u));const C=t.measureText(T);if(c){const I=this.draw.getPagePixelRatio(),p=document.createElement("canvas"),L=p.getContext("2d"),M=C.width,O=C.actualBoundingBoxAscent+C.actualBoundingBoxDescent,b=Math.sqrt(Math.pow(M,2)+Math.pow(O,2)),D=b+2*d[0]*R,W=b+2*d[1]*R;p.width=D,p.height=W,p.style.width=`${D*I}px`,p.style.height=`${W*I}px`,L.translate(D/2,W/2),L.rotate(-45*Math.PI/180),L.translate(-D/2,-W/2),L.font=`${r*R}px ${l}`,L.fillStyle=a,L.fillText(T,(D-M)/2,(W-O)/2+C.actualBoundingBoxAscent);const V=t.createPattern(p,"repeat");V&&(t.fillStyle=V,t.fillRect(0,0,h,g))}else{const I=h/2,p=g/2;t.fillStyle=a,t.translate(I,p),t.rotate(-45*Math.PI/180),t.fillText(T,-C.width/2,C.actualBoundingBoxAscent-r*R/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:n,data:i,opacity:l,repeat:r,gap:a},scale:c}=this.options;if(!this.imageCache.has(i)){const g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=i,g.onload=()=>{this.imageCache.set(i,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const d=this.draw.getWidth(),u=this.draw.getHeight(),R=e*c,h=n*c;if(t.save(),t.globalAlpha=l,r){const g=this.draw.getPagePixelRatio(),T=document.createElement("canvas"),f=T.getContext("2d"),m=Math.sqrt(Math.pow(R,2)+Math.pow(h,2)),C=m+2*a[0]*c,I=m+2*a[1]*c;T.width=C,T.height=I,T.style.width=`${C*g}px`,T.style.height=`${I*g}px`,f.translate(C/2,I/2),f.rotate(-45*Math.PI/180),f.translate(-C/2,-I/2),f.drawImage(this.imageCache.get(i),(C-R)/2,(I-h)/2,R,h);const p=t.createPattern(T,"repeat");p&&(t.fillStyle=p,t.fillRect(0,0,d,u))}else{const g=d/2,T=u/2;t.translate(g,T),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(i),-R/2,-h/2,R,h)}t.restore()}render(t,e){this.options.watermark.type===s.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class Wd{draw;control;options;highlightList;highlightMatchResult;constructor(t){this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){const{control:{activeBackgroundColor:n,disabledBackgroundColor:i,existValueBackgroundColor:l,noValueBackgroundColor:r,inlineControlBackgroundColor:a}}=this.options,c=t[e],d=this.draw.isPrintLikeMode(),u=this.draw.getMode(),R=u===s.EditorMode.EDIT||u===s.EditorMode.FORM,h=this.control.getActiveControl()?.getElement(),g=this._getControlType(t,e);let T=!1,f=!1,m=!1,C=!1;c.highlight||(T=!d&&!!n&&!!h&&c.controlId===h.controlId&&!this.control.getIsRangeInPostfix()),T||(f=!d&&!!i&&!!c.control?.disabled),f||(m=!d&&!!l&&!!c.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),m||(C=!d&&!!r&&!!c.controlId&&!this.control.getIsExistValueByElementListIndex(t,e));const I=R&&!!a&&(g===s.ControlType.NUMBER||g===s.ControlType.SELECT||g===s.ControlType.DATE);return(T?n:"")||(f?i:"")||(m?l:"")||(C?r:"")||(I?a:"")}getIsInlineControlBackground(t,e){const n=this.draw.getMode(),i=this._getControlType(t,e);return!!((n===s.EditorMode.EDIT||n===s.EditorMode.FORM)&&this.options.control.inlineControlBackgroundColor&&(i===s.ControlType.NUMBER||i===s.ControlType.SELECT||i===s.ControlType.DATE))}_getControlType(t,e){const n=t[e];if(n.control?.type)return n.control.type;if(n.controlId){for(let i=e-1;i>=0;i--){const l=t[i];if(l.controlId!==n.controlId)break;if(l.control?.type)return l.control.type}for(let i=e+1;i<t.length;i++){const l=t[i];if(l.controlId!==n.controlId)break;if(l.control?.type)return l.control.type}}}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(n,i)=>{let l=0;for(;l<n.length;){const r=n[l];if(l++,r.type===s.ElementType.TABLE){const T=r.trList;for(let f=0;f<T.length;f++){const m=T[f];for(let C=0;C<m.tdList.length;C++){const I=m.tdList[C],p={tableId:r.id,tableIndex:l-1,trIndex:f,tdIndex:C,tdId:I.id};e(I.value,p)}}}const a=r?.control;if(!a)continue;const c=this.highlightList.findIndex(T=>T.id===r.controlId||a.conceptId&&a.conceptId===T.conceptId);if(!~c)continue;const d=l;let u=l;for(;u<n.length&&n[u].controlId===r.controlId;)u++;l=u;const R=n.slice(d,u).map(T=>T.controlComponent===s.ControlComponent.VALUE?T:{value:H}),h=this.highlightList[c],{ruleList:g}=h;for(let T=0;T<g.length;T++){const f=g[T],m=t.getMatchList(f.keyword,R);this.highlightMatchResult.push(...m.map(C=>({...C,...f,...i,index:C.index+d})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){if(!this.highlightMatchResult?.length)return;const{searchMatchAlpha:n,searchMatchColor:i}=this.options,l=this.draw.getPosition().getOriginalPositionList(),r=this.draw.getOriginalElementList();t.save();for(let a=0;a<this.highlightMatchResult.length;a++){const c=this.highlightMatchResult[a];let d=null;if(c.tableId){const{tableIndex:I,trIndex:p,tdIndex:L,index:M}=c;d=r[I]?.trList[p].tdList[L]?.positionList[M]}else d=l[c.index];if(!d)continue;const{coordinate:{leftTop:u,leftBottom:R,rightTop:h},pageNo:g}=d;if(g!==e)continue;t.fillStyle=c.backgroundColor||i,t.globalAlpha=c.alpha||n;const T=u[0],f=u[1],m=h[0]-u[0],C=R[1]-u[1];t.fillRect(T,f,m,C)}t.restore()}}const Rr={error:{borderColor:"#ff4d4f",backgroundColor:"rgba(255,77,79,0.08)"},warning:{borderColor:"#faad14",backgroundColor:"rgba(250,173,20,0.08)"},warn:{borderColor:"#faad14",backgroundColor:"rgba(250,173,20,0.08)"},info:{borderColor:"#1677ff",backgroundColor:"rgba(22,119,255,0.08)"}},Yd="#ff4d4f",Ud=5e3,Vi=4;class wd{draw;options;marks;underlineTimer;underlineVisible;constructor(t){this.draw=t,this.options=t.getOptions(),this.marks=[],this.underlineTimer=null,this.underlineVisible=!1}setMarks(t){this._clearUnderlineTimer(),this.marks=t.slice(),this.underlineVisible=this.marks.length>0,this.marks.length&&(this.underlineTimer=window.setTimeout(()=>{this.underlineVisible=!1,this.underlineTimer=null,this.draw.render({isSetCursor:!1,isSubmitHistory:!1})},Ud))}getMarks(){return this.marks}render(t,e,n,i,l,r,a){if(!this.marks.length||this.draw.isPrintLikeMode())return;const c=this._getRegions(e,n,i,l,r,a);if(c.length){t.save();for(let d=0;d<c.length;d++){const u=c[d],R=this._getStyle(u.mark),h=Math.max(1,this.options.scale),g=u.x-h,T=u.y-h,f=Math.max(1,u.width+h*2),m=Math.max(1,u.height+h*2),C=Math.max(2,this.options.scale*2);if(this.underlineVisible&&R.borderColor&&u.hasUnderline&&(t.lineWidth=C,t.strokeStyle=R.borderColor,t.beginPath(),t.moveTo(u.underlineX,u.underlineY),t.lineTo(u.underlineRight,u.underlineY),t.stroke()),u.drawRequired){this._renderRequiredMark(t,u,g);continue}if(R.borderColor){t.lineWidth=C;const I=Math.min(Math.max(8*this.options.scale,m*.3),m/2),p=g+f,L=T+m;t.beginPath(),u.drawLeft&&(t.moveTo(g+I,T),t.lineTo(g,T),t.lineTo(g,L)),u.drawRight&&(t.moveTo(p-I,L),t.lineTo(p,L),t.lineTo(p,T)),t.stroke()}}t.restore()}}_getRegions(t,e,n,i,l,r){const a=this._getParentMap(t),c=this.marks.map(h=>this._getTargetControlIds(t,h)),d=c.map(h=>this._getTitleTargets(t,h)),u=[];for(let h=0;h<n.length;h++){const g=n[h],T=new Map,f=e[g.startIndex],m=f?Math.min(f.coordinate.leftTop[0],f.coordinate.leftBottom[0])-(g.offsetX||0):0,C=f?m+(r||this.draw.getInnerWidth()):0;for(let I=0;I<g.elementList.length;I++){const p=g.elementList[I],L=g.startIndex+I,M=e[L];if(!M||l===s.EditorZone.MAIN&&M.pageNo!==i)continue;const O=this._getTargetIdsForElement(this._getQualityTargetId(p),c,a);for(let v=0;v<d.length;v++){const w=d[v].get(L);w&&w.forEach(j=>{O.some(J=>J.markIndex===v&&J.controlId===j)||O.push({markIndex:v,controlId:j})})}if(!O.length)continue;const b=M.coordinate.leftTop,D=M.coordinate.rightTop,W=M.coordinate.leftBottom,V=M.coordinate.rightBottom,E=Math.min(b[0],W[0]),y=Math.max(D[0],V[0]),F=Math.min(b[1],D[1]),S=Math.max(W[1],V[1]),N=M.metrics.boundingBoxAscent+M.metrics.boundingBoxDescent,P=F+M.ascent-M.metrics.boundingBoxAscent,Y=N>0?P:F,X=N>0?P+N:S,U=this._isButtonElement(p),Q=f?Math.max(E,Math.min(y,C)):y;for(let v=0;v<O.length;v++){const{markIndex:w,controlId:j}=O[v],J=`${w}:${j}:${g.startIndex}`,A=T.get(J),x={x:E,y:Y,right:y,bottom:X};if(A){const k=this._mergeBounds(A,x);A.x=k.x,A.y=k.y,A.width=Math.max(1,k.right-k.x),A.height=Math.max(1,k.bottom-k.y),U||(A.hasUnderline?(A.underlineX=Math.min(A.underlineX,E),A.underlineY=Math.max(A.underlineY,X+Vi),A.underlineRight=Math.max(A.underlineRight,Q)):(A.underlineX=E,A.underlineY=X+Vi,A.underlineRight=Q),A.hasUnderline=!0)}else T.set(J,{mark:this.marks[w],targetKey:`${w}:${j}`,x:E,y:Y,width:Math.max(1,y-E),height:Math.max(1,X-Y),baseline:F+M.ascent,font:p.style||this.draw.getElementFont(p,this.options.scale),underlineX:E,underlineY:X+Vi,underlineRight:Q,hasUnderline:!U,drawLeft:!1,drawRight:!1,drawRequired:!1})}}u.push(...T.values())}const R=new Map;for(let h=0;h<u.length;h++){const g=u[h],T=R.get(g.targetKey)||[];T.push(g),R.set(g.targetKey,T)}return R.forEach(h=>{this._isRequiredMark(h[0].mark)?h[0].drawRequired=!0:(h[0].drawLeft=!0,h[h.length-1].drawRight=!0)}),u}_renderRequiredMark(t,e,n){t.save(),t.font=e.font,t.fillStyle=e.mark.style?.borderColor||Yd,t.textBaseline="alphabetic";const i=t.measureText("*").width,l=Math.max(2,this.options.scale*2);t.fillText("*",n-i-l,e.baseline),t.restore()}_clearUnderlineTimer(){this.underlineTimer!==null&&(window.clearTimeout(this.underlineTimer),this.underlineTimer=null)}_mergeBounds(t,e){return{x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),right:Math.max(t.x+t.width,e.right),bottom:Math.max(t.y+t.height,e.bottom)}}_getParentMap(t){const e=new Map;for(let n=0;n<t.length;n++){const i=t[n],l=this._getQualityTargetId(i);l&&i.originControlId&&e.set(l,i.originControlId)}return e}_getTitleTargets(t,e){const n=new Map;return e.forEach(i=>{const l=t.findIndex(h=>this._getQualityTargetId(h)===i);if(l<0)return;const r=t[l],a=r.control,c=this._getTitleTextBefore(t,l);if(!c)return;const d=[a?.label,a?.placeholder].concat(this._isMacroElement(r)?[r.label]:[]).filter(Boolean).map(h=>this._normalizeTitleText(h)),u=this._normalizeTitleText(c);if(!d.some(h=>h===u||h.includes(u)||u.includes(h)))return;let R=l-1;for(;R>=0&&this._isTitleValueElement(t[R]);){let h=n.get(R);h||(h=new Set,n.set(R,h)),h.add(i),R--}}),n}_getTitleTextBefore(t,e){const n=t[e-1];if(n?.type===s.ElementType.TITLE)return n.valueList?.map(r=>r.value).join("")||"";if(!this._isTitleValueElement(n))return"";const i=n.titleId;let l=e-1;for(;l>=0&&this._isTitleValueElement(t[l])&&t[l].titleId===i;)l--;return t.slice(l+1,e).map(r=>r.value).join("")}_isTitleValueElement(t){return!!t?.titleId&&!!t.level}_normalizeTitleText(t){return t.replace(/\s/g,"").replace(/[::]+$/,"")}_getTargetControlIds(t,e){const n=new Set,i=e.id?"id":e.conceptId?"conceptId":e.code?"code":null;if(!i)return n;for(let l=0;l<t.length;l++){const r=t[l],a=this._getQualityTargetId(r);if(!a)continue;const c=r.control?.conceptId||r.conceptId,d=r.control?.code||r.macroConfig?.code||r.dictCode;(i==="id"&&a===e.id||i==="conceptId"&&c===e.conceptId||i==="code"&&d===e.code)&&n.add(a)}return n}_getQualityTargetId(t){if(t.controlId)return t.controlId;if(this._isMacroElement(t))return t.id}_isMacroElement(t){return[s.ElementType.MACRO,s.ElementType.CUSTOM_MACRO,s.ElementType.REUSABLE_ITEM].includes(t.type)}_getTargetIdsForElement(t,e,n){if(!t)return[];const i=[];for(let l=0;l<e.length;l++){const r=e[l];let a=t;const c=new Set;for(;a&&!c.has(a);){if(r.has(a)){i.push({markIndex:l,controlId:a});break}c.add(a),a=n.get(a)}}return i}_getStyle(t){return{...Rr[t.type?.toLowerCase()||"error"]||Rr.error,...t.style}}_isRequiredMark(t){return t.required===!0||["required","required-empty","required_empty"].includes(t.type?.toLowerCase()||"")}_isButtonElement(t){return t.type===s.ElementType.BUTTON||t.control?.type===s.ControlType.BUTTON&&!t.control.buttonText}}class Zd{borderRect;options;constructor(t){this.borderRect=this.clearBorderInfo(),this.options=t.getOptions()}clearBorderInfo(){return this.borderRect={x:0,y:0,width:0,height:0},this.borderRect}recordBorderInfo(t,e,n,i){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=i),this.borderRect.width+=n}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:n,borderColor:i}}=this.options,{x:l,y:r,width:a,height:c}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=n*e,t.strokeStyle=i,t.beginPath(),t.rect(l,r,a,c),t.stroke(),t.restore(),this.clearBorderInfo()}}class jn{draw;element;control;isPopup;selectDom;options;VALUE_DELIMITER=",";DEFAULT_MULTI_SELECT_DELIMITER=",";constructor(t,e){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(){return this.element?.control?.code?this.element.control.code.split(","):[]}getText(t){if(!this.element?.control)return null;const e=this.element.control;if(!e.valueSets?.length)return null;const n=e?.multiSelectDelimiter||this.DEFAULT_MULTI_SELECT_DELIMITER,i=e.valueSets,l=[];return t.forEach(r=>{const a=i.find(c=>c.code===r);a&&!Ss(a.value)&&l.push(a.value)}),l.join(n)||null}getValue(t={}){const{elementList:e,range:n}=this.control.mergeControl(t),{startIndex:i}=n,l=e[i],r=[];let a=i;for(;a>=0;){const d=e[a];if(!d||d.controlId!==l.controlId||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT)break;d.controlComponent===s.ControlComponent.VALUE&&r.unshift(d),a--}let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==l.controlId||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POST_TEXT)break;d.controlComponent===s.ControlComponent.VALUE&&r.push(d),c++}return r}setValue(t,e={},n={}){if(!this.element.control?.selectExclusiveOptions?.inputAble||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:r,endIndex:a}=l,c=this.control.getDraw();r!==a?c.spliceElementList(i,r+1,a-r):this.control.removePlaceholder(r,{elementList:i});const d=i[r],u=d.type&&!Ie.includes(d.type)||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT?ie(d,["control","controlId",...ue]):Ce(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};re(i,[g],r,{editorOptions:this.options}),c.spliceElementList(i,R+h,0,[g])}return R+t.length-1}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.element.control?.selectExclusiveOptions?.inputAble;if(t.key===s.KeyMap.Backspace)return i!==l?c?(this.draw.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect():r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1):this.clearSelect();if(t.key===s.KeyMap.Delete){if(i!==l)return c?(this.draw.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect();{const d=e[l+1];return(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT)&&d.controlComponent===s.ControlComponent.PLACEHOLDER||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect()}}return l}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();return t===e?t:this.clearSelect()}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const l=t.elementList||this.control.getElementList(),{startIndex:r}=t.range||this.control.getRange(),a=l[r];let c=-1,d=-1,u=r;for(;u>0;){const g=l[u];if(g.controlId!==a.controlId||g.controlComponent===s.ControlComponent.PREFIX||g.controlComponent===s.ControlComponent.PRE_TEXT){c=u;break}u--}let R=r+1;for(;R<l.length;){const g=l[R];if(g.controlId!==a.controlId||g.controlComponent===s.ControlComponent.POSTFIX||g.controlComponent===s.ControlComponent.POST_TEXT){d=R-1;break}R++}return!~c||!~d?-1:(this.control.getDraw().spliceElementList(l,c+1,d-c,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(u,t),this.control.setControlProperties({code:void 0},{elementList:l,range:{startIndex:u,endIndex:u}}),u)}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),r=this.element.control,a=t?.split(this.VALUE_DELIMITER)||[],c=r.code,d=r.code?.split(this.VALUE_DELIMITER)||[],u=r.isMultiSelect;if(!u&&t===c||u&&Os(d,a)){this.control.repaintControl({curIndex:l.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const R=r.valueSets;if(!Array.isArray(R)||!R.length)return;const h=this.getText(a);if(!h){if(c){const L=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~L&&(this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],T=g?ie(g,Ne):ie(i[l.startIndex],ue),f=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~f)return;c||this.control.removePlaceholder(f,e);const m=Ce(i[f],Ne),C=f+1,I=Dt(h),p=this.control.getDraw();for(let L=0;L<I.length;L++){const M={...T,...m,type:s.ElementType.TEXT,value:I[L],controlComponent:s.ControlComponent.VALUE};(M.color===this.options.control.bracketColor||M.color===this.options.control.placeholderColor)&&(M.color=this.options.defaultColor),re(i,[M],f,{editorOptions:this.options}),p.spliceElementList(i,C+L,0,[M])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:f,endIndex:f}}),!e.range){const L=C+I.length-1;this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({context:e}),u||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const n=this.control.getPosition();if(!n)return;const i=document.createElement("div");i.classList.add(`${tt}-select-control-popup`),i.setAttribute(Ue,s.EditorComponent.POPUP);const l=document.createElement("ul");let r=null;for(let h=0;h<e.length;h++){const g=e[h],T=document.createElement("li");let f=this.getCodes();f.includes(g.code)&&(T.classList.add("active"),r=T),T.onclick=()=>{const m=f.findIndex(C=>C===g.code);t.isMultiSelect?~m?f.splice(m,1):f.push(g.code):~m?f=[]:f=[g.code],this.setSelect(f.join(this.VALUE_DELIMITER))},T.append(document.createTextNode(g.value)),l.append(T)}i.append(l);const{coordinate:{leftTop:[a,c]},lineHeight:d}=n,u=this.control.getPreY();i.style.left=`${a}px`,i.style.top=`${c+u+d}px`,this.control.getContainer().append(i),this.selectDom=i,r&&Ns(i,r)}awake(){if(this.isPopup||this.control.getIsDisabledControl())return;const{startIndex:t}=this.control.getRange(),n=this.control.getElementList()[t];if(!n||n.controlId!==this.element.controlId||n.controlComponent===s.ControlComponent.POSTFIX||n.controlComponent===s.ControlComponent.POSTTEXTFIX||n.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||n.controlComponent===s.ControlComponent.POST_TEXT)return;const l=n.controlComponent===s.ControlComponent.PREFIX||n.controlComponent===s.ControlComponent.PRE_TEXT||n.controlComponent===s.ControlComponent.PLACEHOLDER;!this.control.getIsRangeWithinControl()&&!l||(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){this.isPopup&&(this.selectDom?.remove(),this.isPopup=!1)}}var hr;function st(){return hr.apply(null,arguments)}function Qd(o){hr=o}function ye(o){return o instanceof Array||Object.prototype.toString.call(o)==="[object Array]"}function Ln(o){return o!=null&&Object.prototype.toString.call(o)==="[object Object]"}function Kt(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function Wi(o){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(o).length===0;var t;for(t in o)if(Kt(o,t))return!1;return!0}function me(o){return o===void 0}function $e(o){return typeof o=="number"||Object.prototype.toString.call(o)==="[object Number]"}function qn(o){return o instanceof Date||Object.prototype.toString.call(o)==="[object Date]"}function gr(o,t){var e=[],n,i=o.length;for(n=0;n<i;++n)e.push(t(o[n],n));return e}function un(o,t){for(var e in t)Kt(t,e)&&(o[e]=t[e]);return Kt(t,"toString")&&(o.toString=t.toString),Kt(t,"valueOf")&&(o.valueOf=t.valueOf),o}function Ae(o,t,e,n){return Kr(o,t,e,n,!0).utc()}function vd(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function Ot(o){return o._pf==null&&(o._pf=vd()),o._pf}var Yi;Array.prototype.some?Yi=Array.prototype.some:Yi=function(o){var t=Object(this),e=t.length>>>0,n;for(n=0;n<e;n++)if(n in t&&o.call(this,t[n],n,t))return!0;return!1};function Ui(o){var t=null,e=!1,n=o._d&&!isNaN(o._d.getTime());if(n&&(t=Ot(o),e=Yi.call(t.parsedDateParts,function(i){return i!=null}),n=t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&e),o._strict&&(n=n&&t.charsLeftOver===0&&t.unusedTokens.length===0&&t.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(o))o._isValid=n;else return n;return o._isValid}function yo(o){var t=Ae(NaN);return o!=null?un(Ot(t),o):Ot(t).userInvalidated=!0,t}var Tr=st.momentProperties=[],wi=!1;function Zi(o,t){var e,n,i,l=Tr.length;if(me(t._isAMomentObject)||(o._isAMomentObject=t._isAMomentObject),me(t._i)||(o._i=t._i),me(t._f)||(o._f=t._f),me(t._l)||(o._l=t._l),me(t._strict)||(o._strict=t._strict),me(t._tzm)||(o._tzm=t._tzm),me(t._isUTC)||(o._isUTC=t._isUTC),me(t._offset)||(o._offset=t._offset),me(t._pf)||(o._pf=Ot(t)),me(t._locale)||(o._locale=t._locale),l>0)for(e=0;e<l;e++)n=Tr[e],i=t[n],me(i)||(o[n]=i);return o}function to(o){Zi(this,o),this._d=new Date(o._d!=null?o._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),wi===!1&&(wi=!0,st.updateOffset(this),wi=!1)}function be(o){return o instanceof to||o!=null&&o._isAMomentObject!=null}function fr(o){st.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+o)}function Me(o,t){var e=!0;return un(function(){if(st.deprecationHandler!=null&&st.deprecationHandler(null,o),e){var n=[],i,l,r,a=arguments.length;for(l=0;l<a;l++){if(i="",typeof arguments[l]=="object"){i+=`
|
|
110
|
+
`,H),{startIndex:Q,endIndex:v}=T.getRange(),w=T.getRangeAnchorStyle(y,Q);if(!w)return;const j=Q>0?y[Q-1]:null,J=!!(w.controlId||w.control),x={...!J&&j?j:w,...V},k=i.isDesignMode(),lt=y[v+1],Ft=dn(y,w.originControlId,i.getMode()),Qt=dn(y,lt?.originControlId,i.getMode()),ge=!w.originControlId&&!lt?.originControlId&&Fe(w)&&Fo(lt)&&!!w.controlId&&!!lt.controlId&&w.controlId!==lt.controlId,ee=zn(w)&&Xi(lt)&&!Ft&&!Qt,K=i.getMode()===s.EditorMode.EDIT?ar(y,w,lt):void 0,$=!!w.originControlId&&Fe(w)&<?.controlId===w.originControlId&&!lt.originControlId&<.control?.type===s.ControlType.TEXTFIELD&&Fe(lt),_=!!w.originControlId&&Fe(w)&<?.controlId===w.originControlId&&!lt.originControlId&<.control?.type===s.ControlType.TEXTFIELD&<.controlComponent===s.ControlComponent.VALUE,ct=!!Ft&&Ft===Qt&&!!w.controlId&&!!lt?.controlId&&w.controlId!==lt.controlId&&(zn(w)||Xi(lt))?Ft:null;if(W&&(ge||ee))return;const nt=Fo(lt)&&!lt?.originControlId,ut=Fe(w)&&!w.originControlId||w.type===s.ElementType.CONTROL&&w.controlComponent===s.ControlComponent.VALUE&<?.type!==s.ElementType.CONTROL&&!w.originControlId,ft=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],It=(Ct,et)=>!!(Ct?.controlId&&Ct.controlId===et?.controlId&&(Ct.originControlId||null)===(et.originControlId||null)),wt=(Ct,et)=>{if(Ct?.control?.type)return Ct.control.type;if(Ct?.controlId){for(let Wt=et;Wt>=0;Wt--){const at=y[Wt];if(!It(Ct,at))break;if(at.control?.type)return at.control.type}for(let Wt=et+1;Wt<y.length;Wt++){const at=y[Wt];if(!It(Ct,at))break;if(at.control?.type)return at.control.type}}},Gt=(Ct,et)=>{const Wt=wt(Ct,et);return!!(Wt&&ft.includes(Wt))},Mt=Ct=>{const et=y[Ct];let Wt=Ct;for(let at=Ct+1;at<y.length&&It(et,y[at]);at++)Wt=at;return Wt},_t=!!(Gt(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&!w.originControlId&&It(w,lt)&&Fe(lt)&&!lt?.value),yt=!!(Gt(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&w.originControlId&&It(w,lt)&&Fe(lt))?dn(y,w.originControlId,i.getMode()):null,St=lr(y,yt),Pt=nt||ut||_t,ne=Pt?{...w,type:void 0,control:void 0,controlId:void 0,controlComponent:void 0,originControlId:void 0,color:r.defaultColor,highlight:void 0}:w,Zt=Pt||J?ne:x,Xt=Dt(U).map(Ct=>{const et={value:Ct};if(k||!Zt.title?.disabled&&!Zt.control?.disabled){const Wt=y[v+1];(!Zt.type||Zt.type===F||Zt.type===S&&Wt?.type===S||Zt.type===Y&&Wt?.type===Y||Zt.type===N&&Wt?.type===N||Zt.type===P&&Wt?.type===P)&&fa.forEach(at=>{if(at==="groupIds"&&!Wt?.groupIds)return;const xt=Zt[at];xt!==void 0&&(et[at]=xt)}),(V||Zt.type===X)&&Ne.forEach(at=>{const xt=V?.[at]||Zt[at];xt!==void 0&&(et[at]=xt)}),g&&(et.underline=!0)}if(!Pt){const Wt=w.originControlId&&(w.controlComponent===s.ControlComponent.POSTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||w.controlComponent===s.ControlComponent.POST_TEXT);if($||_||K){const B=K||lt;et.controlId=B.controlId,et.control=B.control,et.controlComponent=s.ControlComponent.VALUE,delete et.originControlId,Ni(et,B.control,r.defaultColor)}const at=!w.originControlId&&w.controlId&&(w.controlComponent===s.ControlComponent.POSTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||w.controlComponent===s.ControlComponent.POST_TEXT)&<?.controlId&<.controlId!==w.controlId&&Bc(w,lt),xt=w.controlId&&w.originControlId&&(w.controlComponent===s.ControlComponent.VALUE||w.controlComponent===s.ControlComponent.PLACEHOLDER);if(!$&&!_&&!K&&Wt&&!et.controlId){const B=dn(y,w.originControlId,i.getMode());if(!B)return et;let ot=null;for(let mt=Q;mt>=0;mt--){const it=y[mt];if(Je(it,B)&&it.control){ot=it.control;break}}et.controlId=B,et.controlComponent=s.ControlComponent.VALUE,ot&&(et.control=ot),Ni(et,ot,r.defaultColor)}else if(at&&!et.controlId){if(lt?.controlId&<.controlId!==w.controlId)if(lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX)for(let B=Q;B>=0;B--){const ot=y[B];if(ot.controlId===w.controlId&&(ot.controlComponent===s.ControlComponent.PREFIX||ot.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let mt=B-1;mt>=0;mt--){const it=y[mt];if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.PRETEXTFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRE_TEXT)){et.controlId=it.controlId,et.controlComponent=s.ControlComponent.VALUE,it.control&&(et.control=it.control);break}if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}else(lt.controlComponent===s.ControlComponent.POSTFIX||lt.controlComponent===s.ControlComponent.POSTTEXTFIX)&&(et.controlId=lt.controlId,et.controlComponent=s.ControlComponent.VALUE,lt.control&&(et.control=lt.control));if(!et.controlId)for(let B=Q;B>=0;B--){const ot=y[B];if(ot.controlId===w.controlId&&(ot.controlComponent===s.ControlComponent.PREFIX||ot.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let mt=B-1;mt>=0;mt--){const it=y[mt];if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.PRETEXTFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRE_TEXT)){et.controlId=it.controlId,et.controlComponent=s.ControlComponent.VALUE,it.control&&(et.control=it.control);break}if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}}else if(xt&&!et.controlId){const B=w.controlId;let ot=w.control;if(!ot)for(let mt=Q;mt>=0;mt--){const it=y[mt];if(it.controlId===B&&it.control&&(ot=it.control,it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX))break}et.controlId=B,et.originControlId=w.originControlId,et.controlComponent=s.ControlComponent.VALUE,ot&&(et.control=ot)}else if(w.controlId){let B=w.control;if(!B)for(let ot=Q;ot>=0;ot--){const mt=y[ot];if(Je(mt,w.controlId)&&mt.control){B=mt.control;break}}et.controlId||(et.controlId=w.controlId),B&&!et.control&&(et.control=B),et.controlComponent||(et.controlComponent=s.ControlComponent.VALUE)}else if(!et.controlId&&!et.control&<?.originControlId&&(lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX)){const B=dn(y,lt.originControlId,i.getMode());if(!B)return et;let ot=null;for(let mt=v;mt>=0;mt--){const it=y[mt];if(Je(it,B)&&it.control){ot=it.control;break}}et.controlId=B,et.controlComponent=s.ControlComponent.VALUE,ot&&(et.control=ot)}}if(Ct&&Ct!==H){const Wt=xc(Ct,r.defaultFont);et.font=Wt}return et});let Lt;const Et=a[u],bt=a[u+1],pe=a[u-1];if(g)Lt=Q;else{const Ct=B=>{if(Xt?.length)for(let ot=0;ot<Xt.length;ot++)y.splice(B+ot,0,Xt[ot]);return B+Xt.length-1},et=Q+1,Wt=_t?Mt(Q)+1:et,at=()=>{let B=null,ot,mt=null;const it=i.getMode()===s.EditorMode.EDIT?ar(a,Et,bt):void 0;if(it?.controlId?(B=it.controlId,ot=it.control?.type):i.getMode()===s.EditorMode.EDIT&&zn(Et)&&bt?.controlId===Et.originControlId&&!bt.originControlId&&bt.control?.type===s.ControlType.TEXTFIELD&&(bt.controlComponent===s.ControlComponent.VALUE||Fe(bt))?(B=Et.originControlId,ot=s.ControlType.TEXTFIELD):zn(Et)?B=dn(a,Et.originControlId,i.getMode()):Xi(bt)?B=dn(a,bt.originControlId,i.getMode()):ct?B=ct:Et?.control?.type===s.ControlType.TEXT&&Et.controlId&&!Et.originControlId&&Fe(Et)&&pe?.originControlId===Et.controlId&&(B=Et.controlId,mt={startIndex:u-1,endIndex:u-1}),!B)return null;if(!ot)for(let kt=u;kt>=0;kt--){const zt=a[kt];if(Je(zt,B)&&zt.control?.type){ot=zt.control.type;break}if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}return ot!==s.ControlType.TEXT&&!(i.getMode()===s.EditorMode.EDIT&&ot===s.ControlType.TEXTFIELD)?null:{parentControlId:B,activationIndex:(()=>{for(let kt=u+1;kt<a.length;kt++){const zt=a[kt];if(Je(zt,B))return kt;if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}for(let kt=u;kt>=0;kt--){const zt=a[kt];if(Je(zt,B))return kt;if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}return u})(),boundaryRange:mt}};Q!==v&&(i.removeSplitTdOtherRangeElements(),i.spliceElementList(y,et,v-Q));const xt=at();if(yt&&St?.control){const B=Mt(Q);Xt.forEach(ot=>{Fi(ot,yt,St.control,r.defaultColor)}),re(y,Xt,B,{editorOptions:r}),i.spliceElementList(y,B+1,0,Xt),Lt=B+Xt.length}else if(xt){const{parentControlId:B,activationIndex:ot,boundaryRange:mt}=xt;C(ot,ot),m();const it=l.getActiveControl(),de=bt?.controlId===B&&!bt?.originControlId&&bt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,kt=!!(Et?.originControlId&&zn(Et)&&de!==-1),zt=mt||(kt?{startIndex:u,endIndex:u}:de!==-1?{startIndex:u,endIndex:de}:{startIndex:Q,endIndex:v});C(zt.startIndex,zt.endIndex),it&&it.getElement()?.controlId===B&&(it.getElement()?.control?.type===s.ControlType.TEXT||it.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Xt.forEach(xn=>{Fi(xn,B,it.getElement().control,r.defaultColor)}),Lt=it.setValue(Xt,{range:zt,elementList:y}),l.emitControlContentChange(),C(Lt,Lt),m()):Pt?Lt=Ct(Wt):(Lt=l.setValue(Xt),l.emitControlContentChange())}else if(Pt)Lt=Ct(Wt);else if(Et?.originControlId&&(Et.controlComponent===s.ControlComponent.POSTFIX||Et.controlComponent===s.ControlComponent.POST_TEXT||Et.controlComponent===s.ControlComponent.POSTTEXTFIX||Et.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))if(I?.getElement()?.control?.type===s.ControlType.TEXT&&I.getElement()?.controlId===Et.controlId&&(I.getElement()?.originControlId||null)===(Et.originControlId||null))Lt=l.setValue(Xt),l.emitControlContentChange();else{const ot=dn(a,Et.originControlId,i.getMode());if(!ot){Lt=Ct(et);return}let mt;for(let de=u;de>=0;de--){const kt=a[de];if(Je(kt,ot)&&kt.control?.type){mt=kt.control.type;break}if(kt.controlId&&kt.controlId!==ot&&kt.originControlId!==ot)break}if(mt===s.ControlType.TEXT||i.getMode()===s.EditorMode.EDIT&&mt===s.ControlType.TEXTFIELD){const de=()=>{for(let Pe=u+1;Pe<a.length;Pe++){const We=a[Pe];if(Je(We,ot))return Pe;if(We.controlId&&We.controlId!==ot&&We.originControlId!==ot)break}for(let Pe=u;Pe>=0;Pe--){const We=a[Pe];if(Je(We,ot))return Pe;if(We.controlId&&We.controlId!==ot&&We.originControlId!==ot)break}return u},kt=bt?.controlId===ot&&bt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,zt=kt!==-1?{startIndex:u,endIndex:kt}:{startIndex:u,endIndex:u},xn=de();C(xn,xn),m();const gn=l.getActiveControl();C(zt.startIndex,zt.endIndex),gn&&gn.getElement()?.controlId===ot&&(gn.getElement()?.control?.type===s.ControlType.TEXT||gn.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Xt.forEach(Pe=>{Fi(Pe,ot,gn.getElement().control,r.defaultColor)}),Lt=gn.setValue(Xt,{range:zt,elementList:y}),l.emitControlContentChange(),C(Lt,Lt),m()):Lt=Ct(et)}else Lt=Ct(et)}else if((Et?.control?.type===s.ControlType.NUMBER||bt?.control?.type===s.ControlType.NUMBER)&&I?.getElement()?.control?.type===s.ControlType.NUMBER&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),Lt=Q}else if((Et?.control?.type===s.ControlType.SELECT||bt?.control?.type===s.ControlType.SELECT)&&I?.getElement()?.control?.type===s.ControlType.SELECT&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),Lt=Q}else if(I?.getElement()?.control?.type===s.ControlType.DATE&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),Lt=Q}else Et?.control?.type==="button"||bt?.control?.type==="button"?Lt=Q:I&&l.getIsRangeWithinControl()?(Lt=l.setValue(Xt),l.emitControlContentChange()):(Et?.type==="control"||bt?.type==="control")&&!Pt?Lt=Ct(et):(re(y,Xt,Q,{editorOptions:r}),i.spliceElementList(y,et,0,Xt),Lt=Q+Xt.length)}if(~Lt&&!g){const Ct=se()-n,et=se();f(()=>{T.setRange(Lt,Lt),i.render({curIndex:Lt,isSubmitHistory:!g,traceLabel:`input:${e}`})}),ai(r,`input:${e}`,se()-n,[{label:"mutate",duration:Ct},{label:"renderCall",duration:se()-et}],{isComposing:g,textLength:Xt.length,compositionChainDuration:e==="compositionend"&&E!==void 0?Number((se()-E).toFixed(2)):void 0})}g&&(t.compositionInfo={value:U,startIndex:Lt,endIndex:v,defaultStyle:V,perfStartTime:n})}function Jc(o){o.compositionInfo&&(o.compositionInfo=null)}function $c(o,t){if(!o.compositionInfo||o.isComposing)return t;const{startIndex:e,endIndex:n}=o.compositionInfo;return e!==n&&(o.getDraw().removeSplitTdOtherRangeElements(),o.getDraw().spliceElementList(t,e+1,n-e),o.getDraw().getRange().setRange(e,e)),o.compositionInfo=null,t}async function zc(o){const t=o.getDraw(),e=t.getRange(),{startIndex:n,endIndex:i}=e.getRange();if(!~n&&!~n||t.isReadonly()||!e.getIsCanInput())return;const l=t.getElementList();let r=n,a=i;if(n===i){const h=t.getPosition().getPositionList(),g=h[n],T=g.rowNo,f=g.pageNo,m=[];for(let I=0;I<h.length;I++){const p=h[I];if(p.pageNo>f)break;p.pageNo===f&&p.rowNo===T&&m.push(I)}const C=m[0]-1;r=C<0?0:C,a=m[m.length-1]}const c=t.getOptions();await zs(l.slice(r+1,a+1),c);const d=t.getControl();let u;d.getActiveControl()&&d.getIsRangeWithinControl()?(u=d.cut(),d.emitControlContentChange()):(t.spliceElementList(l,r+1,a-r),u=r),e.setRange(u,u),t.render({curIndex:u})}function jc(o){return o.replace(/^(?:\r\n|\r|\n)+|(?:\r\n|\r|\n)+$/g,"")}async function qc(o,t){const e=o.getDraw(),n=e.getMode()===s.EditorMode.COMPARE,i=n||t?.isPlainText,{copy:l}=e.getOverride();if(l&&l()?.preventDefault!==!1)return;const r=e.getRange();let a=null;if(r.getRange().isCrossRowCol){const d=r.getRangeTableElement();if(!d)return;const u=e.getTableParticle().getRangeRowCol();if(!u)return;const R={type:s.ElementType.TABLE,value:"",colgroup:[],trList:[]},h=u[0],g=h[0].colIndex,T=h[h.length-1],f=T.colIndex+T.colspan-1;for(let m=g;m<=f;m++)R.colgroup.push(d.colgroup[m]);for(let m=0;m<u.length;m++){const C=u[m],I=d.trList[C[0].rowIndex],p={tdList:[],height:I.height,minHeight:I.minHeight};for(let L=0;L<C.length;L++)p.tdList.push(C[L]);R.trList.push(p)}a=n?[R]:Yt([R])}else a=r.getIsCollapsed()?r.getRangeRowElementList():r.getSelectionElementList();if(i&&a?.length){const d=Cn(a,e.getOptions());await Lc(n?jc(d):d);return}a?.length&&await zs(a,e.getOptions())}function td(o,t){const e=t.getDraw(),{drop:n}=e.getOverride();if(n&&n(o)?.preventDefault!==!1)return;o.preventDefault();const i=o.dataTransfer?.getData("text");if(i)t.input(i);else{const l=o.dataTransfer?.files;if(!l)return;for(let r=0;r<l.length;r++){const a=l[r];a.type.startsWith("image")&&Ei(t,a)}}}function cr(o){if(!Intl.Segmenter)return null;const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const i=t.getRange().getRangeParagraphInfo();if(!i)return null;const l=i?.elementList?.map(h=>!h.type||h.type!==s.ElementType.CONTROL&&Ie.includes(h.type)?h.value:H).join("")||"";if(!l)return null;const r=e.isFirstLetter||t.getCursor().getHitLineStartIndex()?e.index+1:e.index,a=i.startIndex,d=new Intl.Segmenter(void 0,{granularity:"word"}).segment(l);let u=-1,R=-1;for(const{segment:h,index:g,isWordLike:T}of d){const f=g+a;if(T&&r>=f&&r<f+h.length){u=f-1,R=u+h.length;break}}return~u&&~R?{startIndex:u,endIndex:R}:null}function ed(o){const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:n,index:i}=e,l=t.getLetterReg();let r=0,a=0;const c=ei.test(n);if(c||l.test(n)){const u=t.getElementList();let R=i-1;for(;R>0;){const g=u[R].value;if(c&&ei.test(g)||!c&&l.test(g))r++,R--;else break}let h=i+1;for(;h<u.length;){const g=u[h].value;if(c&&ei.test(g)||!c&&l.test(g))a++,h++;else break}}const d=i-r-1;return d<0?null:{startIndex:d,endIndex:i+a}}function nd(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(i.isImage&&i.isDirectHit){const a=e.getElementList(),c=e.getEventBus(),d=a[i.index];if(c.isSubscribe("imageDblclick")&&c.emit("imageDblclick",{evt:t,element:d}),d.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&e.getMode()===s.EditorMode.EDIT&&!~i.index&&i.zone){e.getZone().setZone(i.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((i.isCheckbox||i.isRadio)&&i.isDirectHit)return;const l=e.getRange(),r=cr(o)||ed(o);r&&(l.setRange(r.startIndex,r.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),l.setRangeStyle())}function od(o){const t=o.getDraw(),e=t.getControl();if(e.getActiveControl()&&e.selectValue())return;const i=t.getPosition().getCursorPosition();if(!i)return;const{index:l}=i,r=t.getElementList();let a=0,c=0,d=l-1;for(;d>0;){const T=r[d],f=r[d-1];if(T.value===H&&!T.listWrap||T.listId!==f?.listId||T.titleId!==f?.titleId)break;a++,d--}let u=l+1;for(;u<r.length;){const T=r[u],f=r[u+1];if(T.value===H&&!T.listWrap||T.listId!==f?.listId||T.titleId!==f?.titleId)break;c++,u++}const R=t.getRange();let h=l-a-1;if(r[h]?.value!==H&&(h-=1),h<0)return;let g=l+c+1;(r[g]?.value===H||g>r.length-1)&&(g-=1),R.setRange(h,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}const dr={dblclick:nd,threeClick:od};function id(o){o.isComposing=!0}function sd(o,t){const e=se();o.isComposing=!1;const n=o.getDraw(),i=n.getOptions();if(t.data)o.compositionInfo&&(o.compositionInfo.perfStartTime=e),Ta?setTimeout(()=>{o.compositionInfo&&yi(t.data,o,"compositionend")},1):o.compositionInfo&&yi(t.data,o,"compositionend");else{const r=o.compositionInfo?.cancel;if(Jc(o),!r){const a=n.getRange(),{endIndex:c}=a.getRange();n.render({curIndex:c,isSubmitHistory:!1,traceLabel:"compositionend:empty"})}}n.getCursor().clearAgentDomValue(),ai(i,"compositionend",se()-e,[],{hasData:!!t.data,dataLength:t.data?.length||0})}function rd(o){o.compositionInfo&&(o.compositionInfo.cancel=!0)}const bi={compositionstart:id,compositionend:sd,compositionCancel:rd};function ld(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!Ls(o.target,p=>p===i))return;const a=o.target.dataset.index;a&&e.setPageNo(Number(a));const c=e.getPosition(),d=c.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!d)return;const{isTable:u,tdValueIndex:R,index:h}=d,g=c.getPositionList(),T=u?R:h;~h&&(e.getRange().setRange(T,T),c.setCursorPosition(g[T]));const f=e.getCursor(),{cursor:{dragColor:m,dragWidth:C,dragFloatImageDisabled:I}}=e.getOptions();if(I){const p=t.cacheElementList?.[t.cacheRange.startIndex];if(p?.type===s.ElementType.IMAGE&&(p.imgDisplay===s.ImageDisplay.FLOAT_TOP||p.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM||p.imgDisplay===s.ImageDisplay.SURROUND))return}f.drawCursor({width:C,color:m,isBlink:!1,isFocus:!1})}const ad={dragover:ld};class cd{isAllowSelection;isComposing;compositionInfo;isAllowDrag;isAllowDrop;cacheRange;cacheElementList;cachePositionList;cachePositionContext;mouseDownStartPosition;draw;pageContainer;pageList;range;position;constructor(t){this.draw=t,this.pageContainer=t.getPageContainer(),this.pageList=t.getPageList(),this.range=this.draw.getRange(),this.position=this.draw.getPosition(),this.isAllowSelection=!1,this.isComposing=!1,this.compositionInfo=null,this.isAllowDrag=!1,this.isAllowDrop=!1,this.cacheRange=null,this.cacheElementList=null,this.cachePositionList=null,this.cachePositionContext=null,this.mouseDownStartPosition=null}getDraw(){return this.draw}register(){this.pageContainer.addEventListener("click",this.click.bind(this)),this.pageContainer.addEventListener("mousedown",this.mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this.mouseup.bind(this)),this.pageContainer.addEventListener("mouseleave",this.mouseleave.bind(this)),this.pageContainer.addEventListener("mousemove",this.mousemove.bind(this)),this.pageContainer.addEventListener("dblclick",this.dblclick.bind(this)),this.pageContainer.addEventListener("dragover",this.dragover.bind(this)),this.pageContainer.addEventListener("drop",this.drop.bind(this)),na(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 r=cr(this);r&&(n=this.draw.getElementList().slice(r.startIndex+1,r.endIndex+1))}if(!n)return;const i=Object.keys(t);n.forEach(r=>{i.forEach(a=>{const c=a;Reflect.set(r,c,t[c])})}),this.draw.render({isSetCursor:!1});const l=this.draw.getPainterOptions();(!l||!l.isDblclick)&&this.clearPainterStyle()}selectAll(){if(!this.draw.isSelectionDisabled())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){this.draw.isInteractionSuspended()||yc(t,this)}mousedown(t){this.draw.isInteractionSuspended()||Xc(t,this)}click(){this.draw.isInteractionSuspended()||ha&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){this.draw.isInteractionSuspended()||Nc(t,this)}mouseleave(t){this.draw.isInteractionSuspended()||Fc(t,this)}keydown(t){this.draw.isInteractionSuspended()||Ac(t,this)}dblclick(t){this.draw.isInteractionSuspended()||dr.dblclick(this,t)}threeClick(){this.draw.isInteractionSuspended()||dr.threeClick(this)}input(t,e="input"){this.draw.isInteractionSuspended()||yi(t,this,e)}async cut(){this.draw.isInteractionSuspended()||await zc(this)}async copy(t){this.draw.isInteractionSuspended()||await qc(this,t)}compositionstart(){this.draw.isInteractionSuspended()||bi.compositionstart(this)}compositionend(t){this.draw.isInteractionSuspended()||bi.compositionend(this,t)}compositionCancel(){this.draw.isInteractionSuspended()||bi.compositionCancel(this)}drop(t){this.draw.isInteractionSuspended()||td(t,this)}dragover(t){this.draw.isInteractionSuspended()||ad.dragover(t,this)}}const ur={PAGE_SCALE:"pageScale"};class dd{draw;options;cursor;canvasEvent;range;previewer;tableTool;hyperlinkParticle;control;dateParticle;imageParticle;dprMediaQueryList;constructor(t,e){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)}clearSideEffect=t=>{if(!this.cursor)return;if(this.draw.isInteractionSuspended()){this.resetSideEffect();return}const e=t?.composedPath?.()[0]||t.target;if(this.draw.isTargetInsideEditor(e)){this.watchCursorActive();return}this.resetSideEffect()};resetSideEffect=()=>{this.cursor&&(this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker(),this.imageParticle.destroyFloatImage())};setCanvasEventAbility=()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)};watchCursorActive(){this.range.getIsCollapsed()&&setTimeout(()=>{this.cursor?.getAgentIsActive()||this.cursor?.drawCursor({isFocus:!1,isBlink:!1})})}setPageScale=t=>{if(this.draw.isInteractionSuspended()||!this.draw.isTargetInsideEditor(t.target)||this.options.shortcutDisableKeys.includes(ur.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)}};_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})}};_handleDprChange=()=>{this.draw.setPageDevicePixel()}}class ud{undoStack=[];redoStack=[];maxRecordCount;constructor(t){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 Rd{cursorPosition;positionContext;positionList;floatPositionList;draw;eventBus;options;constructor(t){this.positionList=[],this.floatPositionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.eventBus=t.getEventBus(),this.options=t.getOptions()}getFloatPositionList(){return this.floatPositionList}getTablePositionList(t){const{index:e,trIndex:n,tdIndex:i}=this.positionContext;return t[e].trList[n].tdList[i].positionList||[]}getPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalElementList()):this.getOriginalPositionList()}getMainPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalMainElementList()):this.positionList}getOriginalPositionList(){const t=this.draw.getZone();return t.isHeaderActive()?this.draw.getHeader().getPositionList():t.isFooterActive()?this.draw.getFooter().getPositionList():this.positionList}getOriginalMainPositionList(){return this.positionList}getSelectionPositionList(){const{startIndex:t,endIndex:e}=this.draw.getRange().getRange();return t===e?null:this.getPositionList().slice(t+1,e+1)}setPositionList(t){this.positionList=t}setFloatPositionList(t){this.floatPositionList=t}computePageRowPosition(t){const{positionList:e,rowList:n,pageNo:i,startX:l,startY:r,startRowIndex:a,startIndex:c,innerWidth:d,zone:u}=t,{scale:R,table:{tdPadding:h}}=this.options;let g=l,T=r,f=c;for(let m=0;m<n.length;m++){const C=n[m];if(!C.isSurround){const L=C.width+(C.offsetX||0);C.rowFlex===s.RowFlex.CENTER?g+=(d-L)/2:C.rowFlex===s.RowFlex.RIGHT&&(g+=d-L)}g+=C.offsetX||0,T+=C.offsetY||0;const I=g,p=T;for(let L=0;L<C.elementList.length;L++){const M=C.elementList[L],O=M.metrics,b=!ae(M)&&(M.imgDisplay!==s.ImageDisplay.INLINE&&M.type===s.ElementType.IMAGE||M.type===s.ElementType.LATEX)?C.ascent-O.height:C.ascent;M.left&&(g+=M.left),M.translateX&&(g+=M.translateX*R);const D={pageNo:i,index:f,value:M.value,rowIndex:a+m,rowNo:m,metrics:O,left:M.left||0,ascent:b,lineHeight:C.height,isFirstLetter:L===0,isLastLetter:L===C.elementList.length-1,coordinate:{leftTop:[g,T],leftBottom:[g,T+C.height],rightTop:[g+O.width,T],rightBottom:[g+O.width,T+C.height]}};if(M.imgDisplay===s.ImageDisplay.SURROUND||M.imgDisplay===s.ImageDisplay.FLOAT_TOP||M.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM){const W=e[e.length-1];W&&(D.metrics=W.metrics,D.coordinate=W.coordinate),M.imgFloatPosition||(M.imgFloatPosition={x:g,y:T,pageNo:i}),this.floatPositionList.push({pageNo:i,element:M,position:D,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:f,zone:u})}if(e.push(D),f++,g+=O.width,M.type===s.ElementType.TABLE&&!ae(M)){const W=M.tdPadding||h,V=W[1]+W[3],E=W[0]+W[2];for(let y=0;y<M.trList.length;y++){const F=M.trList[y];for(let S=0;S<F.tdList.length;S++){const N=F.tdList[S];N.positionList=[];const P=N.rowList,Y=this.computePageRowPosition({positionList:N.positionList,rowList:P,pageNo:i,startRowIndex:0,startIndex:0,startX:(N.x+W[3])*R+I+(M.translateX||0)*R,startY:(N.y+W[0])*R+p,innerWidth:(N.width-V)*R,isTable:!0,index:f-1,tdIndex:S,trIndex:y,zone:u});if(N.verticalAlign===s.VerticalAlign.MIDDLE||N.verticalAlign===s.VerticalAlign.BOTTOM){const X=P.reduce((v,w)=>v+w.height,0),U=(N.height-E)*R-X,Q=N.verticalAlign===s.VerticalAlign.MIDDLE?U/2:U;Math.floor(Q)>0&&N.positionList.forEach(v=>{const{coordinate:{leftTop:w,leftBottom:j,rightBottom:J,rightTop:A}}=v;w[1]+=Q,j[1]+=Q,J[1]+=Q,A[1]+=Q})}g=Y.x,T=Y.y}}g=I,T=p}}g=l,T+=C.height}return{x:g,y:T,index:f}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),n=this.draw.getMargins(),i=n[3],r=this.draw.getHeader().getExtraHeight(),a=n[0]+r;let c=0;for(let d=0;d<e.length;d++){const u=e[d];if(!u?.length)continue;const R=u[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:u,pageNo:d,startRowIndex:c,startIndex:R,startX:i,startY:a,innerWidth:t}),c+=u.length}}computeRowPosition(t){const{row:e,innerWidth:n}=t,i=[];return this.computePageRowPosition({positionList:i,innerWidth:n,rowList:[ht(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),i}setCursorPosition(t){this.cursorPosition=t}getCursorPosition(){return this.cursorPosition}getPositionContext(){return this.positionContext}setPositionContext(t){this.eventBus.emit("positionContextChange",{value:t,oldValue:this.positionContext}),this.positionContext=t}getPositionByXY(t){const{x:e,y:n,isTable:i}=t;let{elementList:l,positionList:r}=t;l||(l=this.draw.getOriginalElementList()),r||(r=this.getOriginalPositionList());const a=this.draw.getZone(),c=t.pageNo??this.draw.getPageNo(),d=a.isMainActive(),u=d?c:0;if(!i){const f=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_TOP,s.ImageDisplay.SURROUND]});if(f)return f}for(let f=0;f<r.length;f++){const{index:m,pageNo:C,left:I,isFirstLetter:p,coordinate:{leftTop:L,rightTop:M,leftBottom:O}}=r[f];if(u===C){if(C>u)break;if(L[0]-I<=e&&M[0]>=e&&L[1]<=n&&O[1]>=n){let b=f;const D=l[f];if(D.type===s.ElementType.TABLE)for(let V=0;V<D.trList.length;V++){const E=D.trList[V];for(let y=0;y<E.tdList.length;y++){const F=E.tdList[y],S=this.getPositionByXY({x:e,y:n,td:F,pageNo:c,tablePosition:r[f],isTable:!0,elementList:F.value,positionList:F.positionList});if(~S.index){const{index:N,hitLineStartIndex:P}=S,Y=F.value[N];return{index:m,isCheckbox:S.isCheckbox||Y.type===s.ElementType.CHECKBOX||Y.controlComponent===s.ControlComponent.CHECKBOX,isRadio:Y.type===s.ElementType.RADIO||Y.controlComponent===s.ControlComponent.RADIO,isControl:!!Y.controlId,isImage:S.isImage,isLabel:S.isLabel,isMacro:S.isMacro,isDirectHit:S.isDirectHit,isTable:!0,tdIndex:y,trIndex:V,tdValueIndex:N,tdId:F.id,trId:E.id,tableId:D.id,hitLineStartIndex:P}}}}if(D.type===s.ElementType.IMAGE||D.type===s.ElementType.LATEX)return{index:b,isDirectHit:!0,isImage:!0};if(D.type===s.ElementType.MENSTRUAL_HISTORY)return{index:b,isDirectHit:!0};if(D.type===s.ElementType.FETAL_HEART_POSITION)return{index:b,isDirectHit:!0};if(D.type===s.ElementType.TOOTH_POSITION){const{scale:V}=this.options,E=D.width*V;return e>=L[0]&&e<=L[0]+E?{index:b,isDirectHit:!0}:{index:b}}if(D.type===s.ElementType.CHECKBOX||D.controlComponent===s.ControlComponent.CHECKBOX)return{index:b,isDirectHit:!0,isCheckbox:!0};if(D.type===s.ElementType.LABEL)return{index:b,isDirectHit:!0,isLabel:!0};if(D.type===s.ElementType.MACRO||D.type===s.ElementType.CUSTOM_MACRO||D.type===s.ElementType.REUSABLE_ITEM||D.type===s.ElementType.SUB_TEMPLATE)return{index:b,isDirectHit:!0,isMacro:!0};if(D.type===s.ElementType.TAB&&D.listStyle===s.ListStyle.CHECKBOX){let V=b-1;for(;V>0;){const E=l[V];if(E.value===H&&E.listStyle===s.ListStyle.CHECKBOX)break;V--}return{index:V,isDirectHit:!0,isCheckbox:!0}}if(D.type===s.ElementType.RADIO||D.controlComponent===s.ControlComponent.RADIO)return{index:b,isDirectHit:!0,isRadio:!0};let W;if(l[m].value!==H){const V=M[0]-L[0];e<L[0]+V/2&&(b=f-1,p&&(W=f))}return{isDirectHit:!0,hitLineStartIndex:W,index:b,isControl:!!D.controlId}}}}if(!i){const f=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_BOTTOM]});if(f)return f}let R=!1,h=-1,g;if(i){const{scale:f}=this.options,{td:m,tablePosition:C}=t;if(m&&C){const{leftTop:I}=C.coordinate,p=m.x*f+I[0],L=m.y*f+I[1],M=m.width*f,O=m.height*f;if(!(p<e&&e<p+M&&L<n&&n<L+O))return{index:h}}}const T=r.filter(f=>f.isLastLetter&&f.pageNo===u);for(let f=0;f<T.length;f++){const{index:m,rowNo:C,coordinate:{leftTop:I,leftBottom:p}}=T[f];if(n>I[1]&&n<=p[1]){const L=r.findIndex(D=>D.pageNo===u&&D.rowNo===C),M=l[L],O=r[L],b=M.listStyle===s.ListStyle.CHECKBOX?this.draw.getMargins()[3]:O.coordinate.leftTop[0];if(e<b)~L?O.value===H?h=L:(h=L-1,g=L):h=m;else{if(M.listStyle===s.ListStyle.CHECKBOX&&e<I[0])return{index:L,isDirectHit:!0,isCheckbox:!0};h=m}R=!0;break}}if(!R){if(this.draw.getIsPagingMode()){const m=this.draw.getHeader(),C=m.getHeight(),I=m.getHeaderTop()+C,p=this.draw.getFooter(),M=this.draw.getHeight()-(p.getFooterBottom()+p.getHeight());if(d){if(n<I)return{index:-1,zone:s.EditorZone.HEADER};if(n>M)return{index:-1,zone:s.EditorZone.FOOTER}}else if(n<=M&&n>=I)return{index:-1,zone:s.EditorZone.MAIN}}const f=this.draw.getMargins();if(n<=f[0])for(let m=0;m<r.length;m++){const C=r[m];if(C.pageNo!==u||C.rowNo!==0)continue;const{leftTop:I,rightTop:p}=C.coordinate;if(e<=f[3]||e>=I[0]&&e<=p[0]||r[m+1]?.rowNo!==0)return{index:C.index}}else{const m=T[T.length-1];if(m){const C=m.rowNo;for(let I=0;I<r.length;I++){const p=r[I];if(p.pageNo!==u||p.rowNo!==C)continue;const{leftTop:L,rightTop:M}=p.coordinate;if(e<=f[3]||e>=L[0]&&e<=M[0]||r[I+1]?.rowNo!==C)return{index:p.index}}}}return{index:T[T.length-1]?.index||r.length-1}}return{hitLineStartIndex:g,index:h,isControl:!!l[h]?.controlId}}getFloatPositionByXY(t){const{x:e,y:n}=t,i=t.pageNo??this.draw.getPageNo(),l=this.draw.getZone().getZone(),{scale:r}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:c,element:d,isTable:u,index:R,trIndex:h,tdIndex:g,tdValueIndex:T,zone:f,pageNo:m}=this.floatPositionList[a];if(i===m&&d.type===s.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!f||f===l)){const C=d.imgFloatPosition,I=C.x*r,p=C.y*r,L=d.width*r,M=d.height*r;if(e>=I&&e<=I+L&&n>=p&&n<=p+M)return u?{index:R,isDirectHit:!0,isImage:!0,isTable:u,trIndex:h,tdIndex:g,tdValueIndex:T,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()!==s.EditorMode.READONLY){const{index:m,isTable:C,trIndex:I,tdIndex:p,tdValueIndex:L}=e,M=this.draw.getControl(),{newIndex:O}=M.moveCursor({index:m,isTable:C,trIndex:I,tdIndex:p,tdValueIndex:L});C?e.tdValueIndex=O:e.index=O}const{index:n,isCheckbox:i,isRadio:l,isControl:r,isImage:a,isLabel:c,isDirectHit:d,isTable:u,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f}=e;return this.setPositionContext({isTable:u||!1,isCheckbox:i||!1,isRadio:l||!1,isControl:r||!1,isImage:a||!1,isLabel:c||!1,isDirectHit:d||!1,index:n,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f}),e}setSurroundPosition(t){const{scale:e}=this.options,{pageNo:n,row:i,rowElement:l,rowElementRect:r,surroundElementList:a,availableWidth:c}=t;let d=r.x,u=0;if(a.length&&!Vn(l)&&!l.control?.minWidth)for(let R=0;R<a.length;R++){const h=a[R],g=h.imgFloatPosition;if(g.pageNo!==n)continue;const T={...g,x:g.x*e,y:g.y*e,width:h.width*e,height:h.height*e};if(ca(r,T)){i.isSurround=!0;const f=T.width+T.x-r.x;if(l.left=f,i.width+=f,u+=f,d=T.x+T.width,i.width+l.metrics.width>c){l.left=0,i.width-=u;break}}}return{x:d,rowIncreaseWidth:u}}}class hd{draw;options;range;listener;eventBus;position;historyManager;defaultStyle;lastRangeStyle;constructor(t){this.draw=t,this.options=t.getOptions(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.range={startIndex:-1,endIndex:-1},this.defaultStyle=null,this.lastRangeStyle=null}_isSameRangeStyle(t,e){if(!t||!["type","undo","redo","painter","font","size","bold","italic","underline","strikeout","deletePerson","color","highlight","rowFlex","vertical","rowMargin","level","listType","listStyle","textDecoration","extension"].every(c=>t[c]===e[c])||!(t.dashArray.length===e.dashArray.length&&t.dashArray.every((c,d)=>c===e.dashArray[d])))return!1;const r=t.groupIds||[],a=e.groupIds||[];return r.length===a.length&&r.every((c,d)=>c===a[d])}_emitRangeStyle(t){this._isSameRangeStyle(this.lastRangeStyle,t)||(this.lastRangeStyle={...t,dashArray:[...t.dashArray],groupIds:t.groupIds?[...t.groupIds]:null},this.listener.rangeStyleChange?.(t),this.eventBus.isSubscribe("rangeStyleChange")&&this.eventBus.emit("rangeStyleChange",t))}getRange(){return this.range}clearRange(){this.setRange(-1,-1)}setDefaultStyle(t){t?this.defaultStyle={...this.defaultStyle,...t}:this.defaultStyle=null}getDefaultStyle(){return this.defaultStyle}getRangeAnchorStyle(t,e){const n=yn(t,e);return n?{...n,...this.defaultStyle}:null}getIsRangeChange(t,e,n,i,l,r,a){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==n||this.range.startTdIndex!==i||this.range.endTdIndex!==l||this.range.startTrIndex!==r||this.range.endTrIndex!==a}getIsCollapsed(){const{startIndex:t,endIndex:e}=this.range;return t===e}getIsSelection(){const{startIndex:t,endIndex:e}=this.range;return!~t&&!~e?!1:t!==e}getSelection(){const{startIndex:t,endIndex:e,splitTdRange:n}=this.range;if(t===e)return null;if(n)return this.draw.getSplitTdValues(n.originalId).slice(n.startIndex+1,n.endIndex+1);const i=this.draw.getElementList();return i.slice(i[t]?.value===H?t:t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let n=0;n<t.length;n++){const i=t[n];for(let l=0;l<i.length;l++){const r=i[l];e.push(...r.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||Ie.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Ie.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=new Map;for(let l=t;l<e+1;l++){const{pageNo:r,rowNo:a}=n[l],c=i.get(r);c?c.has(a)||c.add(a):i.set(r,new Set([a]))}return i}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:n}=this.range;if(!~t&&!~e)return null;if(n)return this.getSelectionElementList();const i=this.getRangeRow();if(!i)return null;const l=this.position.getPositionList(),r=this.draw.getElementList(),a=[];for(let c=0;c<l.length;c++){const d=l[c],u=i.get(d.pageNo);u&&u.has(d.rowNo)&&a.push(r[c])}return a}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=this.draw.getElementList(),l=new Map;let r=t;for(;r>=0;){const{pageNo:d,rowNo:u}=n[r];let R=l.get(d);R||(R=[],l.set(d,R)),R.includes(u)||R.unshift(u);const h=i[r],g=i[r-1];if(h.value===H&&!h.listWrap||h.listId!==g?.listId||h.titleId!==g?.titleId)break;r--}const a=t===e;if(!a){let d=t+1;for(;d<e;){const{pageNo:u,rowNo:R}=n[d];let h=l.get(u);h||(h=[],l.set(u,h)),h.includes(R)||h.push(R),d++}}let c=e;for(a&&i[t].value===H&&(c+=1);c<n.length;){const d=i[c],u=i[c+1];if(d.value===H&&!d.listWrap||d.listId!==u?.listId||d.titleId!==u?.titleId)break;const{pageNo:R,rowNo:h}=n[c];let g=l.get(R);g||(g=[],l.set(R,g)),g.includes(h)||g.push(h),c++}return l}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let n=-1;const i=[],l=this.getRangeParagraph();if(!l)return null;const r=this.draw.getElementList(),a=this.position.getPositionList();for(let c=0;c<a.length;c++){const d=a[c],u=l.get(d.pageNo);u&&u.includes(d.rowNo)&&(~n||(n=d.index),i.push(r[c]))}return i.length?{elementList:i,startIndex:n}:null}getRangeParagraphElementList(){return this.getRangeParagraphInfo()?.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,n){const{startIndex:i,endIndex:l}=this.range,r=this.position.getPositionList();for(let a=i+1;a<=l&&r[a];a++){const{coordinate:{leftTop:d,rightBottom:u},pageNo:R}=r[a];if(n===R&&t>=d[0]&&t<=u[0]&&e>=d[1]&&e<=u[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),n=new Map;for(const l of e){const r=n.get(l.groupId);if(r)r.endIndex+=1;else{const{type:a,groupId:c,tableId:d,index:u,tdIndex:R,trIndex:h}=l,g={startIndex:u,endIndex:u};a===Qe.TABLE&&(g.tableId=d,g.startTdIndex=R,g.endTdIndex=R,g.startTrIndex=h,g.endTrIndex=h),n.set(c,g)}}const i=[];return n.forEach(l=>{i.push(l)}),i}getIsCanInput(){const{range:{startIndex:t,endIndex:e},elementList:n}=this.getRangeElement(),i=n[t];if(!i)return!1;if(t===e)return(i.controlComponent!==s.ControlComponent.PRE_TEXT||n[t+1]?.controlComponent!==s.ControlComponent.PRE_TEXT)&&i.controlComponent!==s.ControlComponent.POST_TEXT;const l=n[e];return l?!i.controlId&&!l.controlId||(!i.controlId||i.controlComponent===s.ControlComponent.POSTFIX)&&(!l.controlId||l.controlComponent===s.ControlComponent.POSTFIX)||!!i.controlId&&l.controlId===i.controlId&&l.controlComponent!==s.ControlComponent.PRE_TEXT&&l.controlComponent!==s.ControlComponent.POST_TEXT&&l.controlComponent!==s.ControlComponent.POSTFIX:!1}setRange(t,e,n,i,l,r,a,c){this.getIsRangeChange(t,e,n,i,l,r,a)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=n,this.range.startTdIndex=i,this.range.endTdIndex=l,this.range.startTrIndex=r,this.range.endTrIndex=a,this.range.isCrossRowCol=!!(i||l||r||a),this.range.splitTdRange=c,this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const u=this.draw.getControl();if(~t&&~e&&!!this.draw.getElementList()[t]?.controlId&&!this.draw.isContentReadonly()){u.initControl();return}u.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}shrinkRange(){const{startIndex:t,endIndex:e}=this.range;t===e||!~t&&!~e||this.replaceRange({...this.range,startIndex:e})}setRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:i,isCrossRowCol:l}=this.range;if(!~n&&!~i)return;let r;if(l){const P=this.draw.getOriginalElementList(),Y=this.position.getPositionContext();r=P[Y.index]}else{const P=~i?i:0,Y=this.draw.getElementList();r=this.getRangeAnchorStyle(Y,P)}if(!r)return;const a=this.getSelection()||[r],c=r.type||s.ElementType.TEXT,d=r.font||this.options.defaultFont,u=r.size||this.options.defaultSize,R=!~a.findIndex(P=>!P.bold),h=!~a.findIndex(P=>!P.italic),g=!~a.findIndex(P=>!P.underline&&!P.control?.underline),T=!~a.findIndex(P=>!P.strikeout),f=r.color||null,m=r.highlight||null,C=r.rowFlex||null,I=r.vertical||null,p=r.rowMargin??this.options.defaultRowMargin,L=r.dashArray||[],M=r.level||null,O=r.listType||null,b=r.listStyle||null,D=g&&r.textDecoration||null,W=!!this.draw.getPainterStyle(),V=this.historyManager.isCanUndo(),E=this.historyManager.isCanRedo(),y=r.groupIds||null,F=r.extension??null,S=r.deletePerson??"",N={type:c,undo:V,redo:E,painter:W,font:d,size:u,bold:R,italic:h,underline:g,strikeout:T,deletePerson:S,color:f,highlight:m,rowFlex:C,vertical:I,rowMargin:p,dashArray:L,level:M,listType:O,listStyle:b,groupIds:y,textDecoration:D,extension:F};this._emitRangeStyle(N)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const n=this.options.defaultFont,i=this.options.defaultSize,l=this.options.defaultRowMargin,r=!!this.draw.getPainterStyle(),a=this.historyManager.isCanUndo(),c=this.historyManager.isCanRedo(),u={type:null,undo:a,redo:c,painter:r,font:n,size:i,bold:!1,italic:!1,underline:!1,strikeout:!1,deletePerson:"123",color:null,highlight:null,rowFlex:null,rowMargin:l,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,extension:null,vertical:null};this._emitRangeStyle(u)}shrinkBoundary(t={}){const{elementList:e,range:n}=this.getRangeElement(t),{startIndex:i,endIndex:l}=n;if(!~i&&!~l)return;const r=e[i],a=e[l];if(i===l){if(r.controlComponent===s.ControlComponent.PLACEHOLDER&&r.originControlId&&r.control?.type==="text")return;if(r.controlComponent===s.ControlComponent.PLACEHOLDER){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId===r.controlId&&(d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){n.startIndex=c,n.endIndex=c;break}if(d.controlId!==r.controlId&&!d.originControlId)break;c--}}if(r.controlComponent===s.ControlComponent.TEXTFIXLABEL){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===s.ControlComponent.VALUE||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;break}c--}}}else{if(r.controlComponent===s.ControlComponent.PLACEHOLDER||a.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.TEXTFIXLABEL||a.controlComponent===s.ControlComponent.TEXTFIXLABEL){let c=l-1;for(;c>0;){const d=e[c];if(d.controlId!==a.controlId||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;return}c--}}if(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PRETEXTFIX||r.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===s.ControlComponent.VALUE){n.startIndex=c-1;break}else if(d.controlComponent===s.ControlComponent.PLACEHOLDER){n.startIndex=c-1,n.endIndex=c-1;return}c++}}if(a.controlComponent!==s.ControlComponent.VALUE){let c=l-1;for(;c>0;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===s.ControlComponent.VALUE){n.endIndex=c;break}else if(d.controlComponent===s.ControlComponent.PLACEHOLDER){n.startIndex=c,n.endIndex=c;return}c--}}}}render(t,e,n,i,l){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,n,i,l),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(H,"g"),""):""}getRangeElement(t={}){const e=t.elementList||this.draw.getElementList(),n=t.range||this.getRange(),{splitTdRange:i}=n,l={elementList:e,range:n};return i&&(l.range=i,l.elementList=this.draw.getSplitTdValues(i.originalId)??[]),l}}class gd{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,n,i){t.save(),t.fillStyle=e,t.fillRect(0,0,n,i),t.restore()}_drawImage(t,e,n,i){const{background:l,scale:r}=this.options;if(l.size===s.BackgroundSize.CONTAIN){const a=e.width*r,c=e.height*r;if(!l.repeat||l.repeat===s.BackgroundRepeat.NO_REPEAT)t.drawImage(e,0,0,a,c);else{let d=0,u=0;const R=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_X?Math.ceil(n*r/a):1,h=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_Y?Math.ceil(i*r/c):1;for(let g=0;g<R;g++){for(let T=0;T<h;T++)t.drawImage(e,d,u,a,c),u+=c;u=0,d+=a}}}else t.drawImage(e,0,0,n*r,i*r)}_renderBackgroundImage(t,e,n){const{background:i}=this.options,l=this.imageCache.get(i.image);if(l)this._drawImage(t,l,e,n);else{const r=new Image;r.setAttribute("crossOrigin","Anonymous"),r.src=i.image,r.onload=()=>{this.imageCache.set(i.image,r),this._drawImage(t,r,e,n),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:n,color:i,applyPageNumbers:l}}=this.options;if(n&&(!l?.length||l.includes(e))){const{width:r,height:a}=this.options;this._renderBackgroundImage(t,r,a)}else{const r=this.draw.getCanvasWidth(e),a=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,i,r,a)}}}class Di{fillRect;fillColor;fillDecorationStyle;constructor(){this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillDecorationStyle=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,n,i,l,r,a){const c=!this.fillRect.width;if(!c&&(this.fillColor!==r||this.fillDecorationStyle!==a)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,n,i,l,r,a);return}c&&(this.fillRect.x=e,this.fillRect.y=n),l&&this.fillRect.height<l&&(this.fillRect.height=l),this.fillRect.width+=i,this.fillColor=r,this.fillDecorationStyle=a}}class Td extends Di{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:n,y:i,width:l,height:r}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(n,i,l,r),t.restore(),this.clearFillInfo()}}class fd{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:n,pageMode:i}=this.options,l=this.draw.getWidth(),r=i===s.PageMode.CONTINUITY?this.draw.getCanvasHeight(e)/this.draw.getPagePixelRatio():this.draw.getHeight(),a=this.draw.getMargins(),c=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=n,t.beginPath();const d=[a[3],a[0]],u=[l-a[1],a[0]],R=[a[3],r-a[2]],h=[l-a[1],r-a[2]];t.moveTo(d[0]-c,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]-c),t.moveTo(u[0]+c,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]-c),t.moveTo(R[0]-c,R[1]),t.lineTo(...R),t.lineTo(R[0],R[1]+c),t.moveTo(h[0]+c,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+c),t.stroke(),t.restore()}}class md{draw;options;position;range;searchKeyword;searchNavigateIndex;searchOptions;searchMatchList;constructor(t){this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.searchNavigateIndex=null,this.searchOptions=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t,e){this.searchKeyword=t,this.searchNavigateIndex=null,this.searchOptions=e||null}searchNavigatePre(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex-1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===n)return null;this.searchNavigateIndex=this.searchMatchList.length-1-(this.searchKeyword.length-1)}}return this.searchNavigateIndex}searchNavigateNext(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex+1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===n)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:n,rightTop:i},pageNo:l}=t,r=this.draw.getHeight(),a=this.draw.getPageGap(),c=l*(r+a),d=document.createElement("div");d.style.position="absolute";const u=50;d.style.width=`${i[0]-e[0]+u}px`,d.style.height=`${n[1]-e[1]+u}px`,d.style.left=`${e[0]}px`,d.style.top=`${e[1]+c}px`,this.draw.getContainer().append(d),d.scrollIntoView(!1),d.remove()}getSearchNavigateIndexList(){return this.searchNavigateIndex===null||!this.searchKeyword?[]:new Array(this.searchKeyword.length).fill(this.searchNavigateIndex).map((t,e)=>t+e)}getSearchMatchList(){return this.searchMatchList}getSearchNavigateInfo(){if(!this.searchKeyword||!this.searchMatchList.length)return null;const t=this.searchNavigateIndex!==null?this.searchNavigateIndex/this.searchKeyword.length+1:0;let e=0,n=null;for(let i=0;i<this.searchMatchList.length;i++){const l=this.searchMatchList[i];n!==l.groupId&&(n=l.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const{isRegEnable:n=!1,isIgnoreCase:i=!0}=this.searchOptions||{},l=i?t.toLocaleLowerCase():t,r=[],a=[],c=e.length,d=[];for(let g=0;g<c;g++)e[g].type===s.ElementType.TABLE&&d.push(g);let u=0,R=0;for(;R<c-1;){const g=d.length?d[u]:c,T=e.slice(R,g);T.length&&a.push({index:R,type:Qe.PAGE,elementList:T});const f=e[g];f&&a.push({index:g,type:Qe.TABLE,elementList:[f]}),R=g+1,u++}function h(g,T,f,m){if(!g)return;let C=f.map(O=>!O.type||Ie.includes(O.type)&&O.controlComponent!==s.ControlComponent.CHECKBOX&&O.controlComponent!==s.ControlComponent.RADIO&&!O.hide&&!O.control?.hide&&!O.area?.hide?O.value:H).filter(Boolean).join("");i&&(C=C.toLocaleLowerCase());const I=[],p=n?new RegExp(g):g;let{index:L,length:M}=Xs(C,p);for(;L!==-1&&M!==0;){I.push({index:L,length:M});const O=Xs(C,p,L+M);L=O.index,M=O.length}for(let O=0;O<I.length;O++){const{index:b,length:D}=I[O],W=Tt();for(let V=0;V<D;V++){const E=b+V+(m?.startIndex||0);r.push({type:T,index:E,groupId:W,...m})}}}for(let g=0;g<a.length;g++){const T=a[g];if(T.type===Qe.TABLE){const f=T.elementList[0];for(let m=0;m<f.trList.length;m++){const C=f.trList[m];for(let I=0;I<C.tdList.length;I++){const p=C.tdList[I],L={tableId:f.id,tableIndex:T.index,trIndex:m,tdIndex:I,tdId:p.id};h(l,T.type,p.value,L)}}}else h(l,T.type,T.elementList,{startIndex:T.index})}return r}compute(t){const e=this.searchOptions?.isLimitSelection&&!this.range.getIsCollapsed(),n=e?this.range.getSelectionElementList():this.draw.getOriginalElementList();if(!n?.length||(this.searchMatchList=this.getMatchList(t,n),!e||!this.searchMatchList.length))return;const{startIndex:i}=this.range.getRange(),l=i+1;for(const r of this.searchMatchList)r.type===Qe.TABLE?r.tableIndex+=l:r.index+=l}render(t,e){if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:n,searchMatchColor:i,searchNavigateMatchColor:l}=this.options,r=this.position.getOriginalPositionList(),a=this.draw.getOriginalElementList();t.save(),t.globalAlpha=n;for(let c=0;c<this.searchMatchList.length;c++){const d=this.searchMatchList[c];let u=null;if(d.type===Qe.TABLE){const{tableIndex:L,trIndex:M,tdIndex:O,index:b}=d;u=a[L]?.trList[M].tdList[O]?.positionList[b]}else u=r[d.index];if(!u)continue;const{coordinate:{leftTop:R,leftBottom:h,rightTop:g},pageNo:T}=u;if(T!==e)continue;if(this.getSearchNavigateIndexList().includes(c)){t.fillStyle=l;const L=this.searchMatchList[c-1];(!L||L.groupId!==d.groupId)&&this.searchNavigateScrollIntoView(u)}else t.fillStyle=i;const m=R[0],C=R[1],I=g[0]-R[0],p=h[1]-R[1];t.fillRect(m,C,I,p)}t.restore()}replace(t,e){if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const l=e?.index;if(ri(l)){const f=[];i.forEach(m=>{const C=f[f.length-1];!C||C[0].groupId!==m.groupId?f.push([m]):C.push(m)}),i=f[l]}if(!i?.length)return;const r=this.draw.isDesignMode();let a=0,c=0,d="",u="",R=-1;const h=this.draw.getOriginalElementList();for(let f=0;f<i.length;f++){const m=i[f];if(m.type===Qe.TABLE){const{tableIndex:C,trIndex:I,tdIndex:p,index:L,tdId:M}=m;u&&M!==u&&(c=0),u=M;const O=C+a,b=h[O].trList[I].tdList[p].value,D=L+c,W=b[D];if(!r&&(W?.control?.deletable===!1||W?.title?.deletable===!1))continue;if(t===""){this.draw.spliceElementList(b,D,1),c--,~R||(R=f);continue}if(d===m.groupId){this.draw.spliceElementList(b,D,1),c--;continue}~R||(R=f);for(let V=0;V<t.length;V++){const E=t[V];V===0?W.value=E:(this.draw.spliceElementList(b,D+V,0,[{...W,value:E}]),c++)}}else{const C=m.index+a,I=h[C];if(!r&&(I?.control?.deletable===!1||I?.title?.deletable===!1)||I.type===s.ElementType.CONTROL&&I.controlComponent!==s.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,C,1),a--,~R||(R=f);continue}if(~R||(R=f),d===m.groupId){this.draw.spliceElementList(h,C,1),a--;continue}for(let p=0;p<t.length;p++){const L=t[p];p===0?I.value=L:(this.draw.spliceElementList(h,C+p,0,[{...I,value:L}]),a++)}}d=m.groupId}if(!~R)return;const g=i[R],T=g.index+(t.length-1);if(g.type===Qe.TABLE){const{tableIndex:f,trIndex:m,tdIndex:C,index:I}=g,p=h[f].trList[m].tdList[C].value[I];this.position.setPositionContext({isTable:!0,index:f,trIndex:m,tdIndex:C,tdId:p.tdId,trId:p.trId,tableId:p.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(T,T),this.draw.render({curIndex:T})}}class pd extends Di{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{scale:e,strikeoutColor:n}=this.options,{x:i,y:l,width:r}=this.fillRect;t.save(),t.lineWidth=e,t.strokeStyle=n;const a=l-3;t.beginPath(),t.moveTo(i,a),t.lineTo(i+r,a),t.stroke(),t.beginPath(),t.moveTo(i,l+3.5),t.lineTo(i+r,l+3.5),t.stroke(),t.restore(),this.clearFillInfo()}}s.TextDecorationStyle=void 0,(function(o){o.SOLID="solid",o.DOUBLE="double",o.DASHED="dashed",o.DOTTED="dotted",o.WAVY="wavy"})(s.TextDecorationStyle||(s.TextDecorationStyle={}));var Yn;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(Yn||(Yn={}));class Cd extends Di{options;constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,l){const r=e+i;switch(t.beginPath(),l){case Yn.DASHED:t.setLineDash([3,1]);break;case Yn.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(r,n),t.stroke()}_drawDouble(t,e,n,i){const r=e+i,a=n+3*this.options.scale;this.options.mode===s.EditorMode.PRINT||this.options.mode===s.EditorMode.COMPARE?t.strokeStyle="transparent":t.strokeStyle="red",t.beginPath(),t.moveTo(e,n),t.lineTo(r,n),t.stroke(),t.beginPath(),t.moveTo(e,a),t.lineTo(r,a),t.stroke()}_drawWave(t,e,n,i){const{scale:l}=this.options,r=1.2*l,a=1/l,c=n+2*r;t.beginPath();for(let d=0;d<i;d++){const u=r*Math.sin(a*d);t.lineTo(e+d,c+u)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:i,y:l,width:r}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const a=Math.floor(l+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case s.TextDecorationStyle.WAVY:this._drawWave(t,i,a,r);break;case s.TextDecorationStyle.DOUBLE:this._drawDouble(t,i,a,r);break;case s.TextDecorationStyle.DASHED:this._drawLine(t,i,a,r,Yn.DASHED);break;case s.TextDecorationStyle.DOTTED:this._drawLine(t,i,a,r,Yn.DOTTED);break;default:this._drawLine(t,i,a,r);break}t.restore(),this.clearFillInfo()}}class Id{draw;options;ctx;curX;curY;text;curStyle;curColor;cacheMeasureText;constructor(t){this.draw=t,this.options=t.getOptions(),this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.cacheMeasureText=new Map}measureBasisWord(t,e){t.save(),t.font=e;const n=this.measureText(t,{value:xl});return t.restore(),n}measureWord(t,e,n){const i=this.draw.getLetterReg();let l=0,r=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==s.ElementType.TEXT||!i.test(c.value)){r=c;break}l+=this.measureText(t,c).width,a++}return{width:l,endElement:r}}buttonMeasureWord(t,e,n){const i=this.draw.getLetterReg();let l=0,r=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==s.ElementType.TEXT||!i.test(c.value)){r=c;break}l+=this.measureText(t,c).width,a++}return{width:l,endElement:r}}measurePunctuationWidth(t,e){return!e||!Gl.includes(e.value)?0:(t.font=this.draw.getElementFont(e),this.measureText(t,e).width)}measureText(t,e){if(e.width){const r=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:r.actualBoundingBoxAscent,actualBoundingBoxDescent:r.actualBoundingBoxDescent,actualBoundingBoxLeft:r.actualBoundingBoxLeft,actualBoundingBoxRight:r.actualBoundingBoxRight,fontBoundingBoxAscent:r.fontBoundingBoxAscent,fontBoundingBoxDescent:r.fontBoundingBoxDescent}}const n=`${e.value}${t.font}`,i=this.cacheMeasureText.get(n);if(i)return i;const l=t.measureText(e.value);return this.cacheMeasureText.set(n,l),l}getBasisWordBoundingBoxAscent(t,e){return this.measureBasisWord(t,e).actualBoundingBoxAscent}complete(){this._render(),this.text=""}record(t,e,n,i){if(this.ctx=t,this.options.renderMode===s.RenderMode.COMPATIBILITY){this._setCurXY(n,i),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(n,i),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(n,i)),this.text+=e.value,this.curStyle=e.style,this.curColor=e.color}_setCurXY(t,e){this.curX=t,this.curY=e}_render(){!this.text||!~this.curX||!~this.curX||(this.ctx.save(),this.ctx.font=this.curStyle,this.ctx.fillStyle=this.curColor||this.options.defaultColor,this.ctx.fillText(this.text,this.curX,this.curY),this.ctx.restore())}}class Un{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const l=i===s.NumberType.CHINESE?sa(e):`${e}`;return t.replace(n,l)}render(t,e){const{scale:n,pageNumber:{size:i,font:l,color:r,rowFlex:a,numberType:c,format:d,startPageNo:u,fromPageNo:R}}=this.options;if(e<R)return;let h=d;const g=new RegExp($n.PAGE_NO);g.test(h)&&(h=Un.formatNumberPlaceholder(h,e+u-R,g,c));const T=new RegExp($n.PAGE_COUNT);T.test(h)&&(h=Un.formatNumberPlaceholder(h,this.draw.getPageCount()-R,T,c));const f=this.draw.getWidth(),m=this.draw.getHeight(),C=this.draw.getPageNumberBottom(),I=m-C;t.save(),t.fillStyle=r,t.font=`${i*n}px ${l}`;let p=0;const L=this.draw.getMargins(),{width:M}=t.measureText(h);a===s.RowFlex.CENTER?p=(f-M)/2:a===s.RowFlex.RIGHT?p=f-M-L[1]:p=L[3],t.fillText(h,p,I),t.restore()}}class Ld{draw;options;scrollContainer;constructor(t){this.draw=t,this.options=t.getOptions(),this.scrollContainer=this.getScrollContainer(),setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}getScrollContainer(){return this.options.scrollContainerSelector&&document.querySelector(this.options.scrollContainerSelector)||document}_addEvent(){this.scrollContainer.addEventListener("scroll",this._observer)}removeEvent(){this.scrollContainer.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),n=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,i=Math.min(e.bottom,n)-Math.max(e.top,0);return{intersectionHeight:i>0?i:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let n=0,i=0;for(let l=0;l<t.length;l++){const r=t[l],{intersectionHeight:a}=this.getElementVisibleInfo(r);if(i&&!a)break;a&&e.push(l),a>i&&(i=a,n=l)}return{intersectionPageNo:n,visiblePageNoList:e}}_observer=ta(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150)}class Pd{draw;step=5;thresholdPoints=[70,40,10,20];selectionContainer;rangeManager;requestAnimationFrameId;isMousedown;isMoving;clientWidth;clientHeight;containerRect;constructor(t){this.draw=t,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)}_mousedown=t=>{if(this.draw.isInteractionSuspended()){this._mouseup();return}if(!this.draw.isTargetInsideEditor(t.target)){this._mouseup();return}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 e=this.selectionContainer.getBoundingClientRect();this.containerRect=e}};_mouseup=()=>{this.isMousedown=!1,this._stopMove()};_mousemove=t=>{if(this.draw.isInteractionSuspended()||!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(Jt.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove(Jt.DOWN):e<this.thresholdPoints[2]?this._startMove(Jt.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(Jt.RIGHT):this._stopMove()};_move(t){const e=this.selectionContainer instanceof Document?window:this.selectionContainer,n=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,i=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Jt.DOWN?e.scrollTo(n,i+this.step):t===Jt.UP?e.scrollTo(n,i-this.step):t===Jt.LEFT?e.scrollTo(n-this.step,i):e.scrollTo(n+this.step,i),this.requestAnimationFrameId=window.requestAnimationFrame(this._move.bind(this,t))}_startMove(t){this.isMoving||(this.isMoving=!0,this._move(t))}_stopMove(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=null,this.isMoving=!1)}}class Ed{draw;range;options;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=ht(t);for(let n=0;n<t.length;n++){const i=e[n];for(let l=i.tdList.length-1;l>=0;l--){const r=i.tdList[l],{rowspan:a,rowIndex:c,colIndex:d}=r,u=c+a-1;if(u!==l){const R=i.tdList.splice(l,1)[0];e[u]?.tdList.splice(d,0,R)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:l,startTdIndex:r,endTdIndex:a,startTrIndex:c,endTrIndex:d}=this.range.getRange(),h=this.draw.getOriginalElementList()[e].trList;if(!l)return[[h[n].tdList[i]]];let g=h[c].tdList[r],T=h[d].tdList[a];(g.x>T.x||g.y>T.y)&&([g,T]=[T,g]);const f=g.colIndex,m=T.colIndex+(T.colspan-1),C=g.rowIndex,I=T.rowIndex+(T.rowspan-1),p=[];for(let L=0;L<h.length;L++){const M=h[L],O=[];for(let b=0;b<M.tdList.length;b++){const D=M.tdList[b],W=D.colIndex,V=D.rowIndex;W>=f&&W<=m&&V>=C&&V<=I&&O.push(D)}O.length&&p.push(O)}return p.length?p:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:i,width:l,height:r,isDrawFullBorder:a,borderExternalWidth:c,skipTopBorderRanges:d=[]}=t,{scale:u}=this.options,R=this._mergeHorizontalBorderRanges(d,l),h=e.lineWidth;c&&(e.lineWidth=c*u),e.beginPath();const g=Math.round(n),T=Math.round(i);e.translate(.5,.5),a&&!R.length?e.rect(g,T,l,r):(a?(e.moveTo(g,T),e.lineTo(g,T+r),e.lineTo(g+l,T+r),e.lineTo(g+l,T)):(e.moveTo(g,T+r),e.lineTo(g,T)),this._drawHorizontalBorder(e,g,T,l,R)),e.stroke(),c&&(e.lineWidth=h),e.translate(-.5,-.5)}_drawHorizontalBorder(t,e,n,i,l){if(!l.length){t.lineTo(e+i,n);return}let r=0;l.forEach(([a,c])=>{r<a&&(t.moveTo(e+r,n),t.lineTo(e+a,n)),r=Math.max(r,c)}),r<i&&(t.moveTo(e+r,n),t.lineTo(e+i,n))}_mergeHorizontalBorderRanges(t,e){return t.map(([i,l])=>[Math.max(0,Math.min(i,e)),Math.max(0,Math.min(l,e))]).filter(([i,l])=>l>i).sort(([i],[l])=>i-l).reduce((i,l)=>{const r=i[i.length-1];return!r||l[0]>r[1]?i.push(l):l[1]>r[1]&&(r[1]=l[1]),i},[])}_getPagingContinuationTopBorderRanges(t,e){const{scale:n}=this.options,i=[];for(let l=0;l<t.length;l++){const r=t[l];for(let a=0;a<r.tdList.length;a++){const c=r.tdList[a];!c.linkTdPrevId||c.y!==0||i.push([c.x*n,(c.x+c.width)*n])}}return this._mergeHorizontalBorderRanges(i,e)}_drawSlash(t,e,n,i){const{scale:l}=this.options;t.save();const r=e.width*l,a=e.height*l,c=Math.round(e.x*l+n),d=Math.round(e.y*l+i);e.slashTypes?.includes(s.TdSlash.FORWARD)&&(t.moveTo(c+r,d),t.lineTo(c,d+a)),e.slashTypes?.includes(s.TdSlash.BACK)&&(t.moveTo(c,d),t.lineTo(c+r,d+a)),t.stroke(),t.restore()}_drawBorder(t,e,n,i){const{colgroup:l,trList:r,borderType:a,borderColor:c,borderWidth:d=1,borderExternalWidth:u}=e;if(!l||!r)return;const{scale:R,table:{defaultBorderColor:h}}=this.options,g=e.width*R,T=e.height*R,f=this._getPagingContinuationTopBorderRanges(r,g),m=a===s.TableBorder.EMPTY,C=a===s.TableBorder.EXTERNAL,I=a===s.TableBorder.INTERNAL;t.save(),a===s.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=d*R,t.strokeStyle=c||h,!m&&!I&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:T,borderExternalWidth:u,isDrawFullBorder:C,skipTopBorderRanges:f});for(let p=0;p<r.length;p++){const L=r[p];for(let M=0;M<L.tdList.length;M++){const O=L.tdList[M];if(O.slashTypes?.length&&this._drawSlash(t,O,n,i),!O.borderTypes?.length&&(m||C))continue;const b=O.width*R,D=O.height*R,W=Math.round(O.x*R+n+b),V=Math.round(O.y*R+i),E=!!O.linkTdPrevId,y=!!O.linkTdNextId;if(t.translate(.5,.5),t.beginPath(),!E&&O.borderTypes?.includes(s.TdBorder.TOP)&&(t.moveTo(W-b,V),t.lineTo(W,V),t.stroke()),O.borderTypes?.includes(s.TdBorder.RIGHT)&&(t.moveTo(W,V),t.lineTo(W,V+D),t.stroke()),O.borderTypes?.includes(s.TdBorder.BOTTOM)&&(t.moveTo(W,V+D),t.lineTo(W-b,V+D),t.stroke()),O.borderTypes?.includes(s.TdBorder.LEFT)&&(t.moveTo(W-b,V),t.lineTo(W-b,V+D),t.stroke()),!m&&!C){if((!I||O.colIndex+O.colspan<l.length)&&(t.moveTo(W,V),t.lineTo(W,V+D),u&&u!==d&&O.colIndex+O.colspan===l.length)){const F=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=F}if(y||!I||O.rowIndex+O.rowspan<r.length){const F=u&&u!==d&&O.rowIndex+O.rowspan===r.length;if(F&&(t.stroke(),t.beginPath()),t.moveTo(W,V+D),t.lineTo(W-b,V+D),F){const S=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=S}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,i){const{trList:l}=e;if(!l)return;const{scale:r}=this.options;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];if(!u.backgroundColor)continue;t.save();const R=u.width*r,h=u.height*r,g=Math.round(u.x*r+n),T=Math.round(u.y*r+i);t.fillStyle=u.backgroundColor,t.fillRect(g,T,R,h),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,n)=>e+n.width,0)}getTableHeight(t){const e=t.trList;return e?.length?this.getTdListByColIndex(e,0).reduce((n,i)=>n+i.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((n,i)=>n+i.rowspan,0)}getTdListByColIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const l=t[i].tdList;for(let r=0;r<l.length;r++){const a=l[r],c=a.colIndex,d=c+a.colspan-1;e>=c&&e<=d&&n.push(a)}}return n}getTdListByRowIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const l=t[i].tdList;for(let r=0;r<l.length;r++){const a=l[r],c=a.rowIndex,d=c+a.rowspan-1;e>=c&&e<=d&&n.push(a)}}return n}computeRowColInfo(t){const{colgroup:e,trList:n}=t;if(!e||!n)return;let i=0;for(let l=0;l<n.length;l++){const r=n[l],a=n.length-1===l;for(let c=0;c<r.tdList.length;c++){const d=r.tdList[c];let u=0;if(n.length>1&&l!==0){const C=r.tdList[c-1],I=C?C.colIndex+C.colspan:c;for(let p=I;p<e.length;p++)if(this.getRowCountByColIndex(n.slice(0,l),p)===l){u=p;let M=0;for(let O=0;O<p;O++)M+=e[O].width;i=M;break}}else{const C=r.tdList[c-1];C&&(u=C.colIndex+C.colspan)}let R=0;for(let C=0;C<d.colspan;C++)R+=e[C+u].width;let h=0;for(let C=0;C<d.rowspan;C++){const I=n[C+l]||n[l];h+=I.height}const g=r.tdList.length-1===c;let T=a;if(!T&&d.rowspan>1){const C=n.length-1-l;T=d.rowspan-1===C}const f=a&&g;d.isLastRowTd=g,d.isLastColTd=T,d.isLastTd=f,d.x=i;let m=0;for(let C=0;C<l;C++){const I=n[C].tdList;for(let p=0;p<I.length;p++){const L=I[p];if(u>=L.colIndex&&u<L.colIndex+L.colspan){m+=L.height;break}}}d.y=m,d.width=R,d.height=h,d.rowIndex=l,d.colIndex=u,d.trIndex=l,d.tdIndex=c,i+=R,g&&!f&&(i=0)}}}drawRange(t,e,n,i){const{scale:l,rangeAlpha:r,rangeColor:a}=this.options,{type:c,trList:d}=e;if(!d||c!==s.ElementType.TABLE)return;const{isCrossRowCol:u,startTdIndex:R,endTdIndex:h,startTrIndex:g,endTrIndex:T}=this.range.getRange();if(!u)return;let f=d[g].tdList[R],m=d[T].tdList[h];(f.x>m.x||f.y>m.y)&&([f,m]=[m,f]);const C=f.colIndex,I=m.colIndex+(m.colspan-1),p=f.rowIndex,L=m.rowIndex+(m.rowspan-1);t.save();for(let M=0;M<d.length;M++){const O=d[M];for(let b=0;b<O.tdList.length;b++){const D=O.tdList[b],W=D.colIndex,V=D.rowIndex;if(W>=C&&W<=I&&V>=p&&V<=L){const E=D.x*l,y=D.y*l,F=D.width*l,S=D.height*l;t.globalAlpha=r,t.fillStyle=a,t.fillRect(E+n,y+i,F,S)}}}t.restore()}render(t,e,n,i){this._drawBackgroundColor(t,e,n,i),this._drawBorder(t,e,n,i)}findPreRowSpanTd(t,e,n){for(let i=e;i>=0;i--){const l=t[i].tdList.find(r=>r.colIndex===n);if(l)return l}}computeTrHeight(t,e){const{scale:n,table:{tdPadding:i,defaultTrMinHeight:l}}=this.options,r=t.tdPadding||i,a=r[0]+r[2],c=t.trList;for(let R=0;R<c.length;R++){const h=c[R];h.height=h.minHeight||l,h.minHeight=h.height}this.computeRowColInfo(t);const d={},u={};for(let R=0;R<c.length;R++){const h=c[R];if(!h.tdList.length){h.height=0;continue}const g=[],T=[];for(let m=0;m<t.colgroup.length;m++){const C=h.tdList.find(I=>I.colIndex===m);if(C){const I=e?e(C):C.rowList,p=I.reduce((M,O)=>M+O.height,0);C.rowList=I;const L=p/n+a;C.mainHeight=L,C.rowspan>1?(u[C.colIndex]=C.id,d[C.id]={td:C,rowSpan:[R,R+C.rowspan-1],preHeight:0,preMinHeight:0,extraHeight:L},T.push(L)):C.height<L?(C.height=L,C.realHeight=L,g.push(L)):g.push(C.height)}else{const I=d[u[m]];I?.rowSpan[1]==R&&g.push(I.extraHeight)}}const f=Math.max(...g.length?g:T);Object.values(d).forEach(m=>{m.rowSpan[0]<=R&&m.rowSpan[1]>=R&&(m.extraHeight-=f,m.preHeight+=f,m.preMinHeight+=h.minHeight)}),h.height=f;for(let m=0;m<t.colgroup.length;m++){const C=h.tdList.find(I=>I.colIndex===m)??this.findPreRowSpanTd(c,R,m);if(C){const I=d[C.id]?.preHeight??0,p=d[C.id]?.preMinHeight??h.minHeight;C.height=f+I,C.realHeight=f+I,C.realMinHeight=p}}}this.computeRowColInfo(t)}}var _e;(function(o){o.ROW="row",o.COL="col"})(_e||(_e={}));class Md{MIN_TD_WIDTH=20;ROW_COL_OFFSET=18;ROW_COL_QUICK_WIDTH=16;ROW_COL_QUICK_OFFSET=5;ROW_COL_QUICK_POSITION=this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2;BORDER_VALUE=4;TABLE_SELECT_OFFSET=20;draw;canvas;options;position;range;container;toolRowContainer;toolRowAddBtn;toolColAddBtn;toolTableSelectBtn;toolColContainer;toolBorderContainer;anchorLine;mousedownX;mousedownY;constructor(t){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(){this.toolRowContainer?.remove(),this.toolRowAddBtn?.remove(),this.toolColAddBtn?.remove(),this.toolTableSelectBtn?.remove(),this.toolColContainer?.remove(),this.toolBorderContainer?.remove(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null}render(){if(this.draw.getMode()===s.EditorMode.FORM){this.dispose();return}const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.position.getPositionContext();if(!t)return;this.dispose();const l=this.draw.getOriginalElementList(),r=this.position.getOriginalPositionList(),a=l[e];if(a.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:c,table:{overflow:d}}=this.options,u=r[e],{colgroup:R,trList:h}=a,{coordinate:{leftTop:g}}=u,T=this.draw.getHeight(),f=this.draw.getPageGap(),m=this.draw.getPageNo()*(T+f),C=g[0],I=g[1]+m,p=a.trList[n].tdList[i],L=p.rowIndex,M=p.colIndex,O=a.height*c,b=a.width*c,D=document.createElement("div");D.classList.add(`${tt}-table-tool__select`),D.style.height=`${O*c}`,D.style.left=`${C}px`,D.style.top=`${I}px`,D.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*c}px, ${-this.TABLE_SELECT_OFFSET*c}px)`,D.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(D),this.toolTableSelectBtn=D;const W=h.map(P=>P.height),V=document.createElement("div");V.classList.add(`${tt}-table-tool__row`),V.style.transform=`translateX(-${this.ROW_COL_OFFSET*c}px)`;for(let P=0;P<W.length;P++){const Y=W[P]*c,X=document.createElement("div");X.classList.add(`${tt}-table-tool__row__item`),P===L&&X.classList.add("active"),X.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByRowIndex(h,P),v=Q[0],w=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:v.trIndex,tdIndex:v.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,v.tdIndex,w.tdIndex,v.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(V,P)};const U=document.createElement("div");U.classList.add(`${tt}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:P,order:_e.ROW})},X.append(U),X.style.height=`${Y}px`,V.append(X)}V.style.left=`${C}px`,V.style.top=`${I}px`,this.container.append(V),this.toolRowContainer=V;const E=document.createElement("div");E.classList.add(`${tt}-table-tool__quick__add`),E.style.height=`${O*c}`,E.style.left=`${C}px`,E.style.top=`${I+O}px`,E.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*c}px, ${this.ROW_COL_QUICK_OFFSET*c}px)`,E.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(E),this.toolRowAddBtn=E;const y=R.map(P=>P.width),F=document.createElement("div");F.classList.add(`${tt}-table-tool__col`),F.style.transform=`translateY(-${this.ROW_COL_OFFSET*c}px)`;for(let P=0;P<y.length;P++){const Y=y[P]*c,X=document.createElement("div");X.classList.add(`${tt}-table-tool__col__item`),P===M&&X.classList.add("active"),X.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByColIndex(h,P),v=Q[0],w=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:v.trIndex,tdIndex:v.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,v.tdIndex,w.tdIndex,v.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(F,P)};const U=document.createElement("div");U.classList.add(`${tt}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:P,order:_e.COL})},X.append(U),X.style.width=`${Y}px`,F.append(X)}F.style.left=`${C}px`,F.style.top=`${I}px`,this.container.append(F),this.toolColContainer=F;const S=document.createElement("div");S.classList.add(`${tt}-table-tool__quick__add`),S.style.height=`${O*c}`,S.style.left=`${C+b}px`,S.style.top=`${I}px`,S.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*c}px, -${this.ROW_COL_QUICK_POSITION*c}px)`,S.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(S),this.toolColAddBtn=S;const N=document.createElement("div");N.classList.add(`${tt}-table-tool__border`),N.style.height=`${O}px`,N.style.width=`${b}px`,N.style.left=`${C}px`,N.style.top=`${I}px`;for(let P=0;P<h.length;P++){const Y=h[P];for(let X=0;X<Y.tdList.length;X++){const U=Y.tdList[X],Q=document.createElement("div");Q.classList.add(`${tt}-table-tool__border__row`),Q.style.width=`${U.width*c}px`,Q.style.height=`${this.BORDER_VALUE}px`,Q.style.top=`${(U.y+U.height)*c-this.BORDER_VALUE/2}px`,Q.style.left=`${U.x*c}px`,Q.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.rowIndex+U.rowspan-1,order:_e.ROW})},N.appendChild(Q);const v=document.createElement("div");if(v.classList.add(`${tt}-table-tool__border__col`),v.style.width=`${this.BORDER_VALUE}px`,v.style.height=`${U.height*c}px`,v.style.top=`${U.y*c}px`,v.style.left=`${(U.x+U.width)*c-this.BORDER_VALUE/2}px`,v.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.colIndex+U.colspan-1,order:_e.COL})},N.appendChild(v),d&&U.colIndex===0){const w=document.createElement("div");w.classList.add(`${tt}-table-tool__border__col`),w.style.width=`${this.BORDER_VALUE}px`,w.style.height=`${U.height*c}px`,w.style.top=`${U.y*c}px`,w.style.left=`${U.x*c-this.BORDER_VALUE/2}px`,w.onmousedown=j=>{this._mousedown({evt:j,element:a,index:0,isLeftStartBorder:!0,order:_e.COL})},N.appendChild(w)}}}this.container.append(N),this.toolBorderContainer=N}_setAnchorActive(t,e){const n=t.children;for(let i=0;i<n.length;i++){const l=n[i];i===e?l.classList.add("active"):l.classList.remove("active")}}_mousedown(t){const{evt:e,index:n,order:i,element:l,isLeftStartBorder:r}=t;this.canvas=this.draw.getPage();const{scale:a,table:{overflow:c}}=this.options,d=this.draw.getWidth(),u=this.draw.getHeight(),R=this.draw.getPageGap(),h=this.draw.getPageNo()*(u+R),g=this.position.getPositionContext(),m=(this.position.getOriginalPositionList()[g.index]?.coordinate?.leftTop?.[0]||0)*a,C=this.draw.getMargins(),I=C[0],p=C[1],L=I,M=d-p;this.mousedownX=e.x,this.mousedownY=e.y;const O=e.target,b=this.canvas.getBoundingClientRect(),D=window.getComputedStyle(O).cursor;document.body.style.cursor=D,this.canvas.style.cursor=D;let W=0,V=0;const E=document.createElement("div");E.classList.add(`${tt}-table-anchor__line`),i===_e.ROW?(E.classList.add(`${tt}-table-anchor__line__row`),E.style.width=`${d}px`,W=0,V=h+this.mousedownY-b.top):(E.classList.add(`${tt}-table-anchor__line__col`),E.style.height=`${u}px`,W=this.mousedownX-b.left,V=h),E.style.left=`${W}px`,E.style.top=`${V}px`,this.container.append(E),this.anchorLine=E;let y=0,F=0;const S=N=>{const P=this._mousemove(N,i,W,V);P&&(y=P.dx,F=P.dy)};document.addEventListener("mousemove",S),document.addEventListener("mouseup",()=>{let N=!1;if(i===_e.ROW){const P=l.trList,Y=P[n]||P[n-1],{defaultTrMinHeight:X}=this.options.table;F<0&&Y.height+F<X&&(F=X-Y.height),F&&(Y.height+=F,Y.minHeight=Y.height,N=!0)}else{const{colgroup:P}=l;if(P&&y)if(c&&r){P[n].width-y/a<=this.MIN_TD_WIDTH&&(y=(P[n].width-this.MIN_TD_WIDTH)*a);const Y=m+(l.translateX||0)*a;Y+y<L&&(y=L-Y),P[n].width-=y/a,l.width-=y/a,l.translateX=(l.translateX||0)+y/a,N=!0}else{const Y=P[n].width;y<0&&Y*a+y<this.MIN_TD_WIDTH*a&&(y=this.MIN_TD_WIDTH*a-Y*a);const X=P[n+1]?.width;if(y>0&&X&&X*a-y<this.MIN_TD_WIDTH*a&&(y=X*a-this.MIN_TD_WIDTH*a),n===P.length-1){const Q=m+(l.translateX||0)*a+l.width*a;Q+y>M&&(y=M-Q)}y&&(P.length-1!==n&&(P[n+1].width-=y/a),P[n].width+=y/a,N=!0)}}N&&this.draw.render({isSetCursor:!1}),E.remove(),document.removeEventListener("mousemove",S),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,i){if(!this.anchorLine)return null;const l=t.x-this.mousedownX,r=t.y-this.mousedownY;return e===_e.ROW?this.anchorLine.style.top=`${i+r}px`:this.anchorLine.style.left=`${n+l}px`,t.preventDefault(),{dx:l,dy:r}}}class Od{draw;options;container;hyperlinkPopupContainer;hyperlinkDom;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:n}=this._createHyperlinkPopupDom();this.hyperlinkDom=n,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${tt}-hyperlink-popup`);const e=document.createElement("a");return e.target="_blank",e.rel="noopener",t.append(e),this.container.append(t),{hyperlinkPopupContainer:t,hyperlinkDom:e}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[n,i]},lineHeight:l}=e,r=this.draw.getHeight(),a=this.draw.getPageGap(),c=this.draw.getPageNo()*(r+a);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${i+c+l}px`;const d=t.url||"#";this.hyperlinkDom.href=d,this.hyperlinkDom.title=d,this.hyperlinkDom.innerText=d}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,i){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),t.fillText(e.value,n,i),t.restore()}}class Sd{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:l,label:{defaultBackgroundColor:r,defaultColor:a,defaultBorderRadius:c,defaultPadding:d}}=this.options,u=e.label?.backgroundColor||r,R=e.label?.color||a,h=e.label?.borderRadius||c,g=e.label?.padding||d;t.save(),t.font=e.style;const{width:T,height:f,boundingBoxAscent:m}=e.metrics;t.fillStyle=u,this._drawRoundedRect(t,n,i-m,T,f+(g[0]+g[3])*l,h*l),t.fill(),t.fillStyle=R,t.fillText(e.value,n+g[3]*l,i),t.restore()}_drawRoundedRect(t,e,n,i,l,r){t.beginPath(),t.moveTo(e+r,n),t.lineTo(e+i-r,n),t.quadraticCurveTo(e+i,n,e+i,n+r),t.lineTo(e+i,n+l-r),t.quadraticCurveTo(e+i,n+l,e+i-r,n+l),t.lineTo(e+r,n+l),t.quadraticCurveTo(e,n+l,e,n+l-r),t.lineTo(e,n+r),t.quadraticCurveTo(e,n,e+r,n),t.closePath()}}class Xd{options;draw;activeInlineEditor;constructor(t){this.draw=t,this.options=t.getOptions(),this.activeInlineEditor=null}render(t,e,n,i){const l=this.draw.getMode(),r=e.macroConfig;if(l===s.EditorMode.READONLY&&e.type!=="subTemplate"){this._renderPlainText(t,e,n,i,Po(e));return}if(l===s.EditorMode.EDIT){const c=e.label||e.value||"";this._renderEditMode(t,e,n,i,c);return}if(e.type==="macro"){const c=e.label||"",d=e.value||`获取 ${c}`;this._renderPlainText(t,e,n,i,d);return}if(e.type==="customMacro"){const c=r?.type||"text",d=r?.value||"",u=e.label||"";if(l===s.EditorMode.FORM)this.activeInlineEditor?.elementId===e.id&&this._syncInlineEditorPosition(),c==="select"?this._renderSelectControl(t,e,n,i,d):this._renderTextControl(t,e,n,i,d);else{const R=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,R)}return}if(e.type==="reusableItem"){const d=e.reusableItemConfig?.value||"",u=e.label||"";if(l===s.EditorMode.FORM)this._renderTextControl(t,e,n,i,d);else{const R=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,R)}return}if(e.type==="subTemplate"){const c=e.label||"子模板";l===s.EditorMode.FORM?e.subTemplateExpanded||this._renderEditMode(t,e,n,i,c):this._renderPlainText(t,e,n,i,c);return}const a=e.value||e.label||"";this._renderPlainText(t,e,n,i,a)}activateInlineEditor(t,e){if(this.draw.getMode()!==s.EditorMode.FORM||t.type!=="customMacro")return!1;const n=this._ensureMacroConfig(t),i=n.type||"text",l=this.activeInlineEditor;if(l&&l.elementId===t.id&&l.type===i)return l.input.focus(),l.input instanceof HTMLInputElement&&l.input.select(),!0;this.clearInlineEditor({isSubmitHistory:!1});const r=document.createElement("div");r.style.position="absolute",r.style.zIndex="1002",r.style.boxSizing="border-box",r.style.display="flex",r.style.alignItems="center";const a=this._getInlineEditorBaseStyle(t);let c;i==="select"?c=this._createSelectEditor(t,r):c=this._createTextEditor(t,r),c.style.boxSizing="border-box",c.style.width="100%",c.style.height="100%",c.style.border="none",c.style.outline="none",c.style.background="transparent",c.style.font=a.font,c.style.color=a.color,c.style.padding=a.padding,c.style.margin="0",r.append(c),r.addEventListener("mousedown",u=>u.stopPropagation()),r.addEventListener("click",u=>u.stopPropagation()),this.draw.getContainer().append(r),this.draw.setOverlayActive(!0);const d=u=>{const R=u.target;R instanceof Node&&r.contains(R)||this.clearInlineEditor()};return document.addEventListener("mousedown",d,!0),this.activeInlineEditor={elementId:t.id,index:e,type:i,wrapper:r,input:c,initialValue:n.value||"",initialCode:n.code,outsideHandler:d},this._syncInlineEditorPosition(),c.focus(),c instanceof HTMLInputElement?c.select():"showPicker"in c&&typeof c.showPicker=="function"?c.showPicker():c.click(),!0}clearInlineEditor(t={}){const e=this.activeInlineEditor;if(!e)return;const{isSubmitHistory:n=!0,isRestore:i=!1}=t;document.removeEventListener("mousedown",e.outsideHandler,!0);const l=this._getInlineEditorElement(e),r=l?.macroConfig,a=e.input.value||"",c=e.input instanceof HTMLSelectElement&&e.input.value||"";if(l&&r&&(i?(r.value=e.initialValue,e.type==="select"&&(r.code=e.initialCode)):e.type==="text"?r.value=a:(r.code=c||void 0,r.value=this._getSelectLabelByCode(r,c))),e.wrapper.remove(),this.activeInlineEditor=null,this.draw.setOverlayActive(!1),l&&!i){const d=this._ensureMacroConfig(l),u=d.value||"",R=d.code;u!==e.initialValue||R!==e.initialCode?this.draw.getCommand().setMacroValue({id:l.id,dictCode:l.dictCode,label:l.label,areaId:l.areaId,value:u,code:R,isSubmitHistory:n}):this.draw.render({isSubmitHistory:!1,isSetCursor:!1})}else this.draw.render({isSubmitHistory:!1,isSetCursor:!1})}_renderPlainText(t,e,n,i,l){t.save(),t.font=e.style,t.fillStyle=e.color||"#000000",t.textBaseline="alphabetic",t.fillText(l,n,i),t.restore()}_renderEditMode(t,e,n,i,l){const{scale:r}=this.options,a=e.type==="customMacro",c=e.type==="reusableItem",d=e.type==="subTemplate";let u,R;d?(u="#722ed1",R="#f9f0ff"):c?(u="#52c41a",R="#f6ffed"):a?(u="#fa8c16",R="#fff7e6"):(u="#1677ff",R="#e6f4ff"),t.save(),t.font=e.style;const h=t.measureText(l),g=h.actualBoundingBoxAscent+h.actualBoundingBoxDescent,T=8*r,f=4*r,m=4*r,C=h.width+T*2,I=g+f*2,p=e.metrics,L=n,M=i-p.boundingBoxAscent+(p.boundingBoxAscent+p.boundingBoxDescent-I)/2;t.fillStyle=R,this._drawRoundedRect(t,L,M,C,I,m),t.fill(),t.fillStyle=u,t.textBaseline="middle",t.fillText(l,n+T,M+I/2),t.restore()}_renderTextControl(t,e,n,i,l){const{scale:r,control:a,strikeoutColor:c}=this.options,{placeholderColor:d,bracketColor:u}=a;t.save(),t.font=e.style;const h=`请输入${e.label||""}`,g=l||h,f=t.measureText(g).width;t.fillStyle=u,t.textBaseline="alphabetic",t.fillText("[",n,i);const m=n+t.measureText("[").width;t.fillStyle=l?e.color||"#000000":d,t.fillText(g,m,i);const C=m+f;if(t.fillStyle=u,t.fillText("]",C,i),e.type==="reusableItem"){const I=t.measureText("[").width+f+t.measureText("]").width;if(t.lineWidth=r,this.draw.isPrintLikeMode()?t.strokeStyle="transparent":t.strokeStyle=c||"red",e.strikeout){const p=i-3*r,L=i+3.5*r;t.beginPath(),t.moveTo(n,p),t.lineTo(n+I,p),t.stroke(),t.beginPath(),t.moveTo(n,L),t.lineTo(n+I,L),t.stroke()}else if(e.underline&&e.textDecoration?.style==="double"){const p=Math.floor(i+2*r)+.5,L=3*r;t.beginPath(),t.moveTo(n,p),t.lineTo(n+I,p),t.stroke(),t.beginPath(),t.moveTo(n,p+L),t.lineTo(n+I,p+L),t.stroke()}}t.restore()}_renderSelectControl(t,e,n,i,l){const{scale:r,control:a}=this.options,{placeholderColor:c,bracketColor:d}=a;t.save(),t.font=e.style;const R=`请选择${e.label||""}`,h=l||R,g=t.measureText(h),T=g.actualBoundingBoxAscent+g.actualBoundingBoxDescent;t.fillStyle=d,t.textBaseline="alphabetic",t.fillText("[",n,i);const f=n+t.measureText("[").width;t.fillStyle=l?e.color||"#000000":c,t.fillText(h,f,i);const m=f+g.width+2*r,C=i-T/2;t.beginPath(),t.moveTo(m,C-2*r),t.lineTo(m+5*r,C-2*r),t.lineTo(m+2.5*r,C+2*r),t.closePath(),t.fillStyle="#666666",t.fill();const I=m+6*r;t.fillStyle=d,t.fillText("]",I,i),t.restore()}_drawRoundedRect(t,e,n,i,l,r){t.beginPath(),t.moveTo(e+r,n),t.lineTo(e+i-r,n),t.quadraticCurveTo(e+i,n,e+i,n+r),t.lineTo(e+i,n+l-r),t.quadraticCurveTo(e+i,n+l,e+i-r,n+l),t.lineTo(e+r,n+l),t.quadraticCurveTo(e,n+l,e,n+l-r),t.lineTo(e,n+r),t.quadraticCurveTo(e,n,e+r,n),t.closePath()}_createTextEditor(t,e){const n=document.createElement("input");return n.type="text",n.value=t.macroConfig?.value||"",n.placeholder=`请输入${t.label||""}`,n.style.minWidth="0",n.style.background="#ffffff",n.addEventListener("input",()=>{const i=this._ensureMacroConfig(t);i.value=n.value}),n.addEventListener("keydown",i=>{i.key==="Enter"?(i.preventDefault(),this.clearInlineEditor()):i.key==="Escape"&&(i.preventDefault(),this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0}))}),n.addEventListener("blur",()=>{this.activeInlineEditor?.input===n&&this.clearInlineEditor()}),e.style.background="#ffffff",e.style.border="1px solid #1677ff",e.style.borderRadius="4px",e.style.boxShadow="0 0 0 2px rgba(22, 119, 255, 0.12)",n}_createSelectEditor(t,e){const n=document.createElement("select"),i=this._ensureMacroConfig(t),l=document.createElement("option");return l.value="",l.textContent=`请选择${t.label||""}`,n.append(l),i.items?.forEach(r=>{const a=document.createElement("option");a.value=r.code,a.textContent=r.value,n.append(a)}),n.value=i.code||i.items?.find(r=>r.value===i.value)?.code||"",n.addEventListener("change",()=>{i.code=n.value||void 0,i.value=this._getSelectLabelByCode(i,n.value),this.clearInlineEditor()}),n.addEventListener("keydown",r=>{r.key==="Escape"?(r.preventDefault(),this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0})):r.key==="Enter"&&(r.preventDefault(),this.clearInlineEditor())}),n.addEventListener("blur",()=>{this.activeInlineEditor?.input===n&&this.clearInlineEditor()}),e.style.background="#ffffff",e.style.border="1px solid #1677ff",e.style.borderRadius="4px",e.style.boxShadow="0 0 0 2px rgba(22, 119, 255, 0.12)",n}_syncInlineEditorPosition(){const t=this.activeInlineEditor;if(!t)return;const e=this._getInlineEditorPosition(t);if(!e){this.clearInlineEditor({isSubmitHistory:!1});return}const n=e.pageNo*(this.draw.getHeight()+this.draw.getPageGap()),[i,l]=e.coordinate.leftTop,r=Math.max(e.lineHeight,e.metrics.height),a=Math.max(e.metrics.width,80*this.options.scale),c=Math.max(0,(e.lineHeight-r)/2);t.wrapper.style.left=`${i}px`,t.wrapper.style.top=`${l+n+c}px`,t.wrapper.style.width=`${a}px`,t.wrapper.style.height=`${r}px`}_getInlineEditorBaseStyle(t){return{font:this.draw.getElementFont(t),color:t.color||"#000000",padding:`0 ${6*this.options.scale}px`}}_getInlineEditorElement(t){const e=this.draw.getElementList()[t.index];return e?.id===t.elementId?e:t.elementId?this.draw.getElementList().find(n=>n.id===t.elementId)||null:e||null}_getInlineEditorPosition(t){return this.draw.getPosition().getPositionList()[t.index]||null}_ensureMacroConfig(t){return t.macroConfig||(t.macroConfig={type:"text"}),t.macroConfig}_getSelectLabelByCode(t,e){return e&&t.items?.find(n=>n.code===e)?.value||""}}class Nd{draw;position;zone;options;elementList;rowList;positionList;constructor(t,e){this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth(),e=this.draw.getMargins(),n=Li(this.elementList);this.rowList=this.draw.computeRowList({startX:e[3],startY:this.getHeaderTop(),innerWidth:t,elementList:this.elementList,surroundElementList:n})}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],l=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:l,innerWidth:e,zone:s.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*Is[t])}getHeight(){if(this.options.header.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getHeaderTop()+e-t[0];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),l=[];let r=0;for(let a=0;a<this.rowList.length;a++){const c=this.rowList[a];if(r+c.height>i)break;l.push(c),r+=c.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:l,pageNo:e,startIndex:0,innerWidth:n,zone:s.EditorZone.HEADER}),t.restore()}}class Fd{getOffsetY(t){return-t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class yd{getOffsetY(t){return t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class bd{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){t.save();const{scale:l,separator:{lineWidth:r,strokeStyle:a}}=this.options;t.lineWidth=(e.lineWidth||r)*l,t.strokeStyle=e.color||a,e.dashArray?.length&&t.setLineDash(e.dashArray);const c=Math.round(i);t.translate(0,t.lineWidth/2),t.beginPath(),t.moveTo(n,c),t.lineTo(n+e.width*l,c),t.stroke(),t.restore()}}class Dd{draw;options;i18n;constructor(t){this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,n,i){const{pageBreak:{font:l,fontSize:r,lineDash:a}}=this.options,c=this.i18n.t("pageBreak.displayName"),{scale:d,defaultRowMargin:u}=this.options,R=r*d,h=e.width*d,g=this.draw.getDefaultBasicRowMarginHeight()*u;t.save(),t.font=`${R}px ${l}`;const T=t.measureText(c),f=(h-T.width)/2;t.setLineDash(a),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,i),t.lineTo(n+f,i),t.moveTo(n+f+T.width,i),t.lineTo(n+h,i),t.stroke(),t.fillText(c,n+f,i+T.actualBoundingBoxAscent-R/2),t.restore()}}class Vd{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:n,opacity:i,font:l,size:r,color:a,repeat:c,gap:d,numberType:u},scale:R}=this.options,h=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=i,t.font=`${r*R}px ${l}`;let T=n;const f=new RegExp($n.PAGE_NO);f.test(T)&&(T=Un.formatNumberPlaceholder(T,e+1,f,u));const m=new RegExp($n.PAGE_COUNT);m.test(T)&&(T=Un.formatNumberPlaceholder(T,this.draw.getPageCount(),m,u));const C=t.measureText(T);if(c){const I=this.draw.getPagePixelRatio(),p=document.createElement("canvas"),L=p.getContext("2d"),M=C.width,O=C.actualBoundingBoxAscent+C.actualBoundingBoxDescent,b=Math.sqrt(Math.pow(M,2)+Math.pow(O,2)),D=b+2*d[0]*R,W=b+2*d[1]*R;p.width=D,p.height=W,p.style.width=`${D*I}px`,p.style.height=`${W*I}px`,L.translate(D/2,W/2),L.rotate(-45*Math.PI/180),L.translate(-D/2,-W/2),L.font=`${r*R}px ${l}`,L.fillStyle=a,L.fillText(T,(D-M)/2,(W-O)/2+C.actualBoundingBoxAscent);const V=t.createPattern(p,"repeat");V&&(t.fillStyle=V,t.fillRect(0,0,h,g))}else{const I=h/2,p=g/2;t.fillStyle=a,t.translate(I,p),t.rotate(-45*Math.PI/180),t.fillText(T,-C.width/2,C.actualBoundingBoxAscent-r*R/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:n,data:i,opacity:l,repeat:r,gap:a},scale:c}=this.options;if(!this.imageCache.has(i)){const g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=i,g.onload=()=>{this.imageCache.set(i,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const d=this.draw.getWidth(),u=this.draw.getHeight(),R=e*c,h=n*c;if(t.save(),t.globalAlpha=l,r){const g=this.draw.getPagePixelRatio(),T=document.createElement("canvas"),f=T.getContext("2d"),m=Math.sqrt(Math.pow(R,2)+Math.pow(h,2)),C=m+2*a[0]*c,I=m+2*a[1]*c;T.width=C,T.height=I,T.style.width=`${C*g}px`,T.style.height=`${I*g}px`,f.translate(C/2,I/2),f.rotate(-45*Math.PI/180),f.translate(-C/2,-I/2),f.drawImage(this.imageCache.get(i),(C-R)/2,(I-h)/2,R,h);const p=t.createPattern(T,"repeat");p&&(t.fillStyle=p,t.fillRect(0,0,d,u))}else{const g=d/2,T=u/2;t.translate(g,T),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(i),-R/2,-h/2,R,h)}t.restore()}render(t,e){this.options.watermark.type===s.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class Wd{draw;control;options;highlightList;highlightMatchResult;constructor(t){this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){const{control:{activeBackgroundColor:n,disabledBackgroundColor:i,existValueBackgroundColor:l,noValueBackgroundColor:r,inlineControlBackgroundColor:a}}=this.options,c=t[e],d=this.draw.isPrintLikeMode(),u=this.draw.getMode(),R=u===s.EditorMode.EDIT||u===s.EditorMode.FORM,h=this.control.getActiveControl()?.getElement(),g=this._getControlType(t,e);let T=!1,f=!1,m=!1,C=!1;c.highlight||(T=!d&&!!n&&!!h&&c.controlId===h.controlId&&!this.control.getIsRangeInPostfix()),T||(f=!d&&!!i&&!!c.control?.disabled),f||(m=!d&&!!l&&!!c.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),m||(C=!d&&!!r&&!!c.controlId&&!this.control.getIsExistValueByElementListIndex(t,e));const I=R&&!!a&&(g===s.ControlType.NUMBER||g===s.ControlType.SELECT||g===s.ControlType.DATE);return(T?n:"")||(f?i:"")||(m?l:"")||(C?r:"")||(I?a:"")}getIsInlineControlBackground(t,e){const n=this.draw.getMode(),i=this._getControlType(t,e);return!!((n===s.EditorMode.EDIT||n===s.EditorMode.FORM)&&this.options.control.inlineControlBackgroundColor&&(i===s.ControlType.NUMBER||i===s.ControlType.SELECT||i===s.ControlType.DATE))}_getControlType(t,e){const n=t[e];if(n.control?.type)return n.control.type;if(n.controlId){for(let i=e-1;i>=0;i--){const l=t[i];if(l.controlId!==n.controlId)break;if(l.control?.type)return l.control.type}for(let i=e+1;i<t.length;i++){const l=t[i];if(l.controlId!==n.controlId)break;if(l.control?.type)return l.control.type}}}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(n,i)=>{let l=0;for(;l<n.length;){const r=n[l];if(l++,r.type===s.ElementType.TABLE){const T=r.trList;for(let f=0;f<T.length;f++){const m=T[f];for(let C=0;C<m.tdList.length;C++){const I=m.tdList[C],p={tableId:r.id,tableIndex:l-1,trIndex:f,tdIndex:C,tdId:I.id};e(I.value,p)}}}const a=r?.control;if(!a)continue;const c=this.highlightList.findIndex(T=>T.id===r.controlId||a.conceptId&&a.conceptId===T.conceptId);if(!~c)continue;const d=l;let u=l;for(;u<n.length&&n[u].controlId===r.controlId;)u++;l=u;const R=n.slice(d,u).map(T=>T.controlComponent===s.ControlComponent.VALUE?T:{value:H}),h=this.highlightList[c],{ruleList:g}=h;for(let T=0;T<g.length;T++){const f=g[T],m=t.getMatchList(f.keyword,R);this.highlightMatchResult.push(...m.map(C=>({...C,...f,...i,index:C.index+d})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){if(!this.highlightMatchResult?.length)return;const{searchMatchAlpha:n,searchMatchColor:i}=this.options,l=this.draw.getPosition().getOriginalPositionList(),r=this.draw.getOriginalElementList();t.save();for(let a=0;a<this.highlightMatchResult.length;a++){const c=this.highlightMatchResult[a];let d=null;if(c.tableId){const{tableIndex:I,trIndex:p,tdIndex:L,index:M}=c;d=r[I]?.trList[p].tdList[L]?.positionList[M]}else d=l[c.index];if(!d)continue;const{coordinate:{leftTop:u,leftBottom:R,rightTop:h},pageNo:g}=d;if(g!==e)continue;t.fillStyle=c.backgroundColor||i,t.globalAlpha=c.alpha||n;const T=u[0],f=u[1],m=h[0]-u[0],C=R[1]-u[1];t.fillRect(T,f,m,C)}t.restore()}}const Rr={error:{borderColor:"#ff4d4f",backgroundColor:"rgba(255,77,79,0.08)"},warning:{borderColor:"#faad14",backgroundColor:"rgba(250,173,20,0.08)"},warn:{borderColor:"#faad14",backgroundColor:"rgba(250,173,20,0.08)"},info:{borderColor:"#1677ff",backgroundColor:"rgba(22,119,255,0.08)"}},Yd="#ff4d4f",Ud=5e3,Vi=4;class wd{draw;options;marks;underlineTimer;underlineVisible;constructor(t){this.draw=t,this.options=t.getOptions(),this.marks=[],this.underlineTimer=null,this.underlineVisible=!1}setMarks(t){this._clearUnderlineTimer(),this.marks=t.slice(),this.underlineVisible=this.marks.length>0,this.marks.length&&(this.underlineTimer=window.setTimeout(()=>{this.underlineVisible=!1,this.underlineTimer=null,this.draw.render({isSetCursor:!1,isSubmitHistory:!1})},Ud))}getMarks(){return this.marks}render(t,e,n,i,l,r,a){if(!this.marks.length||this.draw.isPrintLikeMode())return;const c=this._getRegions(e,n,i,l,r,a);if(c.length){t.save();for(let d=0;d<c.length;d++){const u=c[d],R=this._getStyle(u.mark),h=Math.max(1,this.options.scale),g=u.x-h,T=u.y-h,f=Math.max(1,u.width+h*2),m=Math.max(1,u.height+h*2),C=Math.max(2,this.options.scale*2);if(this.underlineVisible&&R.borderColor&&u.hasUnderline&&(t.lineWidth=C,t.strokeStyle=R.borderColor,t.beginPath(),t.moveTo(u.underlineX,u.underlineY),t.lineTo(u.underlineRight,u.underlineY),t.stroke()),u.drawRequired){this._renderRequiredMark(t,u,g);continue}if(R.borderColor){t.lineWidth=C;const I=Math.min(Math.max(8*this.options.scale,m*.3),m/2),p=g+f,L=T+m;t.beginPath(),u.drawLeft&&(t.moveTo(g+I,T),t.lineTo(g,T),t.lineTo(g,L)),u.drawRight&&(t.moveTo(p-I,L),t.lineTo(p,L),t.lineTo(p,T)),t.stroke()}}t.restore()}}_getRegions(t,e,n,i,l,r){const a=this._getParentMap(t),c=this.marks.map(h=>this._getTargetControlIds(t,h)),d=c.map(h=>this._getTitleTargets(t,h)),u=[];for(let h=0;h<n.length;h++){const g=n[h],T=new Map,f=e[g.startIndex],m=f?Math.min(f.coordinate.leftTop[0],f.coordinate.leftBottom[0])-(g.offsetX||0):0,C=f?m+(r||this.draw.getInnerWidth()):0;for(let I=0;I<g.elementList.length;I++){const p=g.elementList[I],L=g.startIndex+I,M=e[L];if(!M||l===s.EditorZone.MAIN&&M.pageNo!==i)continue;const O=this._getTargetIdsForElement(this._getQualityTargetId(p),c,a);for(let v=0;v<d.length;v++){const w=d[v].get(L);w&&w.forEach(j=>{O.some(J=>J.markIndex===v&&J.controlId===j)||O.push({markIndex:v,controlId:j})})}if(!O.length)continue;const b=M.coordinate.leftTop,D=M.coordinate.rightTop,W=M.coordinate.leftBottom,V=M.coordinate.rightBottom,E=Math.min(b[0],W[0]),y=Math.max(D[0],V[0]),F=Math.min(b[1],D[1]),S=Math.max(W[1],V[1]),N=M.metrics.boundingBoxAscent+M.metrics.boundingBoxDescent,P=F+M.ascent-M.metrics.boundingBoxAscent,Y=N>0?P:F,X=N>0?P+N:S,U=this._isButtonElement(p),Q=f?Math.max(E,Math.min(y,C)):y;for(let v=0;v<O.length;v++){const{markIndex:w,controlId:j}=O[v],J=`${w}:${j}:${g.startIndex}`,A=T.get(J),x={x:E,y:Y,right:y,bottom:X};if(A){const k=this._mergeBounds(A,x);A.x=k.x,A.y=k.y,A.width=Math.max(1,k.right-k.x),A.height=Math.max(1,k.bottom-k.y),U||(A.hasUnderline?(A.underlineX=Math.min(A.underlineX,E),A.underlineY=Math.max(A.underlineY,X+Vi),A.underlineRight=Math.max(A.underlineRight,Q)):(A.underlineX=E,A.underlineY=X+Vi,A.underlineRight=Q),A.hasUnderline=!0)}else T.set(J,{mark:this.marks[w],targetKey:`${w}:${j}`,x:E,y:Y,width:Math.max(1,y-E),height:Math.max(1,X-Y),baseline:F+M.ascent,font:p.style||this.draw.getElementFont(p,this.options.scale),underlineX:E,underlineY:X+Vi,underlineRight:Q,hasUnderline:!U,drawLeft:!1,drawRight:!1,drawRequired:!1})}}u.push(...T.values())}const R=new Map;for(let h=0;h<u.length;h++){const g=u[h],T=R.get(g.targetKey)||[];T.push(g),R.set(g.targetKey,T)}return R.forEach(h=>{this._isRequiredMark(h[0].mark)?h[0].drawRequired=!0:(h[0].drawLeft=!0,h[h.length-1].drawRight=!0)}),u}_renderRequiredMark(t,e,n){t.save(),t.font=e.font,t.fillStyle=e.mark.style?.borderColor||Yd,t.textBaseline="alphabetic";const i=t.measureText("*").width,l=Math.max(2,this.options.scale*2);t.fillText("*",n-i-l,e.baseline),t.restore()}_clearUnderlineTimer(){this.underlineTimer!==null&&(window.clearTimeout(this.underlineTimer),this.underlineTimer=null)}_mergeBounds(t,e){return{x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),right:Math.max(t.x+t.width,e.right),bottom:Math.max(t.y+t.height,e.bottom)}}_getParentMap(t){const e=new Map;for(let n=0;n<t.length;n++){const i=t[n],l=this._getQualityTargetId(i);l&&i.originControlId&&e.set(l,i.originControlId)}return e}_getTitleTargets(t,e){const n=new Map;return e.forEach(i=>{const l=t.findIndex(h=>this._getQualityTargetId(h)===i);if(l<0)return;const r=t[l],a=r.control,c=this._getTitleTextBefore(t,l);if(!c)return;const d=[a?.label,a?.placeholder].concat(this._isMacroElement(r)?[r.label]:[]).filter(Boolean).map(h=>this._normalizeTitleText(h)),u=this._normalizeTitleText(c);if(!d.some(h=>h===u||h.includes(u)||u.includes(h)))return;let R=l-1;for(;R>=0&&this._isTitleValueElement(t[R]);){let h=n.get(R);h||(h=new Set,n.set(R,h)),h.add(i),R--}}),n}_getTitleTextBefore(t,e){const n=t[e-1];if(n?.type===s.ElementType.TITLE)return n.valueList?.map(r=>r.value).join("")||"";if(!this._isTitleValueElement(n))return"";const i=n.titleId;let l=e-1;for(;l>=0&&this._isTitleValueElement(t[l])&&t[l].titleId===i;)l--;return t.slice(l+1,e).map(r=>r.value).join("")}_isTitleValueElement(t){return!!t?.titleId&&!!t.level}_normalizeTitleText(t){return t.replace(/\s/g,"").replace(/[::]+$/,"")}_getTargetControlIds(t,e){const n=new Set,i=e.id?"id":e.conceptId?"conceptId":e.code?"code":null;if(!i)return n;for(let l=0;l<t.length;l++){const r=t[l],a=this._getQualityTargetId(r);if(!a)continue;const c=r.control?.conceptId||r.conceptId,d=r.control?.code||r.macroConfig?.code||r.dictCode;(i==="id"&&a===e.id||i==="conceptId"&&c===e.conceptId||i==="code"&&d===e.code)&&n.add(a)}return n}_getQualityTargetId(t){if(t.controlId)return t.controlId;if(this._isMacroElement(t))return t.id}_isMacroElement(t){return[s.ElementType.MACRO,s.ElementType.CUSTOM_MACRO,s.ElementType.REUSABLE_ITEM].includes(t.type)}_getTargetIdsForElement(t,e,n){if(!t)return[];const i=[];for(let l=0;l<e.length;l++){const r=e[l];let a=t;const c=new Set;for(;a&&!c.has(a);){if(r.has(a)){i.push({markIndex:l,controlId:a});break}c.add(a),a=n.get(a)}}return i}_getStyle(t){return{...Rr[t.type?.toLowerCase()||"error"]||Rr.error,...t.style}}_isRequiredMark(t){return t.required===!0||["required","required-empty","required_empty"].includes(t.type?.toLowerCase()||"")}_isButtonElement(t){return t.type===s.ElementType.BUTTON||t.control?.type===s.ControlType.BUTTON&&!t.control.buttonText}}class Zd{borderRect;options;constructor(t){this.borderRect=this.clearBorderInfo(),this.options=t.getOptions()}clearBorderInfo(){return this.borderRect={x:0,y:0,width:0,height:0},this.borderRect}recordBorderInfo(t,e,n,i){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=i),this.borderRect.width+=n}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:n,borderColor:i}}=this.options,{x:l,y:r,width:a,height:c}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=n*e,t.strokeStyle=i,t.beginPath(),t.rect(l,r,a,c),t.stroke(),t.restore(),this.clearBorderInfo()}}class jn{draw;element;control;isPopup;selectDom;options;VALUE_DELIMITER=",";DEFAULT_MULTI_SELECT_DELIMITER=",";constructor(t,e){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(){return this.element?.control?.code?this.element.control.code.split(","):[]}getText(t){if(!this.element?.control)return null;const e=this.element.control;if(!e.valueSets?.length)return null;const n=e?.multiSelectDelimiter||this.DEFAULT_MULTI_SELECT_DELIMITER,i=e.valueSets,l=[];return t.forEach(r=>{const a=i.find(c=>c.code===r);a&&!Ss(a.value)&&l.push(a.value)}),l.join(n)||null}getValue(t={}){const{elementList:e,range:n}=this.control.mergeControl(t),{startIndex:i}=n,l=e[i],r=[];let a=i;for(;a>=0;){const d=e[a];if(!d||d.controlId!==l.controlId||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT)break;d.controlComponent===s.ControlComponent.VALUE&&r.unshift(d),a--}let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==l.controlId||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POST_TEXT)break;d.controlComponent===s.ControlComponent.VALUE&&r.push(d),c++}return r}setValue(t,e={},n={}){if(!this.element.control?.selectExclusiveOptions?.inputAble||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:r,endIndex:a}=l,c=this.control.getDraw();r!==a?c.spliceElementList(i,r+1,a-r):this.control.removePlaceholder(r,{elementList:i});const d=i[r],u=d.type&&!Ie.includes(d.type)||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT?ie(d,["control","controlId",...ue]):Ce(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};re(i,[g],r,{editorOptions:this.options}),c.spliceElementList(i,R+h,0,[g])}return R+t.length-1}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.element.control?.selectExclusiveOptions?.inputAble;if(t.key===s.KeyMap.Backspace)return i!==l?c?(this.draw.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect():r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1):this.clearSelect();if(t.key===s.KeyMap.Delete){if(i!==l)return c?(this.draw.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect();{const d=e[l+1];return(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT)&&d.controlComponent===s.ControlComponent.PLACEHOLDER||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect()}}return l}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();return t===e?t:this.clearSelect()}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const l=t.elementList||this.control.getElementList(),{startIndex:r}=t.range||this.control.getRange(),a=l[r];let c=-1,d=-1,u=r;for(;u>0;){const g=l[u];if(g.controlId!==a.controlId||g.controlComponent===s.ControlComponent.PREFIX||g.controlComponent===s.ControlComponent.PRE_TEXT){c=u;break}u--}let R=r+1;for(;R<l.length;){const g=l[R];if(g.controlId!==a.controlId||g.controlComponent===s.ControlComponent.POSTFIX||g.controlComponent===s.ControlComponent.POST_TEXT){d=R-1;break}R++}return!~c||!~d?-1:(this.control.getDraw().spliceElementList(l,c+1,d-c,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(u,t),this.control.setControlProperties({code:void 0},{elementList:l,range:{startIndex:u,endIndex:u}}),u)}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),r=this.element.control,a=t?.split(this.VALUE_DELIMITER)||[],c=r.code,d=r.code?.split(this.VALUE_DELIMITER)||[],u=r.isMultiSelect;if(!u&&t===c||u&&Os(d,a)){this.control.repaintControl({curIndex:l.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const R=r.valueSets;if(!Array.isArray(R)||!R.length)return;const h=this.getText(a);if(!h){if(c){const L=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~L&&(this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],T=g?ie(g,Ne):ie(i[l.startIndex],ue),f=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~f)return;c||this.control.removePlaceholder(f,e);const m=Ce(i[f],Ne),C=f+1,I=Dt(h),p=this.control.getDraw();for(let L=0;L<I.length;L++){const M={...T,...m,type:s.ElementType.TEXT,value:I[L],controlComponent:s.ControlComponent.VALUE};(M.color===this.options.control.bracketColor||M.color===this.options.control.placeholderColor)&&(M.color=this.options.defaultColor),re(i,[M],f,{editorOptions:this.options}),p.spliceElementList(i,C+L,0,[M])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:f,endIndex:f}}),!e.range){const L=C+I.length-1;this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({context:e}),u||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const n=this.control.getPosition();if(!n)return;const i=document.createElement("div");i.classList.add(`${tt}-select-control-popup`),i.setAttribute(Ue,s.EditorComponent.POPUP);const l=document.createElement("ul");let r=null;for(let h=0;h<e.length;h++){const g=e[h],T=document.createElement("li");let f=this.getCodes();f.includes(g.code)&&(T.classList.add("active"),r=T),T.onclick=()=>{const m=f.findIndex(C=>C===g.code);t.isMultiSelect?~m?f.splice(m,1):f.push(g.code):~m?f=[]:f=[g.code],this.setSelect(f.join(this.VALUE_DELIMITER))},T.append(document.createTextNode(g.value)),l.append(T)}i.append(l);const{coordinate:{leftTop:[a,c]},lineHeight:d}=n,u=this.control.getPreY();i.style.left=`${a}px`,i.style.top=`${c+u+d}px`,this.control.getContainer().append(i),this.selectDom=i,r&&Ns(i,r)}awake(){if(this.isPopup||this.control.getIsDisabledControl())return;const{startIndex:t}=this.control.getRange(),n=this.control.getElementList()[t];if(!n||n.controlId!==this.element.controlId||n.controlComponent===s.ControlComponent.POSTFIX||n.controlComponent===s.ControlComponent.POSTTEXTFIX||n.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||n.controlComponent===s.ControlComponent.POST_TEXT)return;const l=n.controlComponent===s.ControlComponent.PREFIX||n.controlComponent===s.ControlComponent.PRE_TEXT||n.controlComponent===s.ControlComponent.PLACEHOLDER;!this.control.getIsRangeWithinControl()&&!l||(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){this.isPopup&&(this.selectDom?.remove(),this.isPopup=!1)}}var hr;function st(){return hr.apply(null,arguments)}function Qd(o){hr=o}function ye(o){return o instanceof Array||Object.prototype.toString.call(o)==="[object Array]"}function Ln(o){return o!=null&&Object.prototype.toString.call(o)==="[object Object]"}function Kt(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function Wi(o){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(o).length===0;var t;for(t in o)if(Kt(o,t))return!1;return!0}function me(o){return o===void 0}function $e(o){return typeof o=="number"||Object.prototype.toString.call(o)==="[object Number]"}function qn(o){return o instanceof Date||Object.prototype.toString.call(o)==="[object Date]"}function gr(o,t){var e=[],n,i=o.length;for(n=0;n<i;++n)e.push(t(o[n],n));return e}function un(o,t){for(var e in t)Kt(t,e)&&(o[e]=t[e]);return Kt(t,"toString")&&(o.toString=t.toString),Kt(t,"valueOf")&&(o.valueOf=t.valueOf),o}function Ae(o,t,e,n){return Kr(o,t,e,n,!0).utc()}function vd(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function Ot(o){return o._pf==null&&(o._pf=vd()),o._pf}var Yi;Array.prototype.some?Yi=Array.prototype.some:Yi=function(o){var t=Object(this),e=t.length>>>0,n;for(n=0;n<e;n++)if(n in t&&o.call(this,t[n],n,t))return!0;return!1};function Ui(o){var t=null,e=!1,n=o._d&&!isNaN(o._d.getTime());if(n&&(t=Ot(o),e=Yi.call(t.parsedDateParts,function(i){return i!=null}),n=t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&e),o._strict&&(n=n&&t.charsLeftOver===0&&t.unusedTokens.length===0&&t.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(o))o._isValid=n;else return n;return o._isValid}function yo(o){var t=Ae(NaN);return o!=null?un(Ot(t),o):Ot(t).userInvalidated=!0,t}var Tr=st.momentProperties=[],wi=!1;function Zi(o,t){var e,n,i,l=Tr.length;if(me(t._isAMomentObject)||(o._isAMomentObject=t._isAMomentObject),me(t._i)||(o._i=t._i),me(t._f)||(o._f=t._f),me(t._l)||(o._l=t._l),me(t._strict)||(o._strict=t._strict),me(t._tzm)||(o._tzm=t._tzm),me(t._isUTC)||(o._isUTC=t._isUTC),me(t._offset)||(o._offset=t._offset),me(t._pf)||(o._pf=Ot(t)),me(t._locale)||(o._locale=t._locale),l>0)for(e=0;e<l;e++)n=Tr[e],i=t[n],me(i)||(o[n]=i);return o}function to(o){Zi(this,o),this._d=new Date(o._d!=null?o._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),wi===!1&&(wi=!0,st.updateOffset(this),wi=!1)}function be(o){return o instanceof to||o!=null&&o._isAMomentObject!=null}function fr(o){st.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+o)}function Me(o,t){var e=!0;return un(function(){if(st.deprecationHandler!=null&&st.deprecationHandler(null,o),e){var n=[],i,l,r,a=arguments.length;for(l=0;l<a;l++){if(i="",typeof arguments[l]=="object"){i+=`
|
|
111
111
|
[`+l+"] ";for(r in arguments[0])Kt(arguments[0],r)&&(i+=r+": "+arguments[0][r]+", ");i=i.slice(0,-2)}else i=arguments[l];n.push(i)}fr(o+`
|
|
112
112
|
Arguments: `+Array.prototype.slice.call(n).join("")+`
|
|
113
113
|
`+new Error().stack),e=!1}return t.apply(this,arguments)},t)}var mr={};function pr(o,t){st.deprecationHandler!=null&&st.deprecationHandler(o,t),mr[o]||(fr(t),mr[o]=!0)}st.suppressDeprecationWarnings=!1,st.deprecationHandler=null;function ke(o){return typeof Function<"u"&&o instanceof Function||Object.prototype.toString.call(o)==="[object Function]"}function Kd(o){var t,e;for(e in o)Kt(o,e)&&(t=o[e],ke(t)?this[e]=t:this["_"+e]=t);this._config=o,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function Qi(o,t){var e=un({},o),n;for(n in t)Kt(t,n)&&(Ln(o[n])&&Ln(t[n])?(e[n]={},un(e[n],o[n]),un(e[n],t[n])):t[n]!=null?e[n]=t[n]:delete e[n]);for(n in o)Kt(o,n)&&!Kt(t,n)&&Ln(o[n])&&(e[n]=un({},e[n]));return e}function vi(o){o!=null&&this.set(o)}var Ki;Object.keys?Ki=Object.keys:Ki=function(o){var t,e=[];for(t in o)Kt(o,t)&&e.push(t);return e};var Hd={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function _d(o,t,e){var n=this._calendar[o]||this._calendar.sameElse;return ke(n)?n.call(t,e):n}function Ge(o,t,e){var n=""+Math.abs(o),i=t-n.length,l=o>=0;return(l?e?"+":"":"-")+Math.pow(10,Math.max(0,i)).toString().substr(1)+n}var Hi=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,bo=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,_i={},wn={};function gt(o,t,e,n){var i=n;typeof n=="string"&&(i=function(){return this[n]()}),o&&(wn[o]=i),t&&(wn[t[0]]=function(){return Ge(i.apply(this,arguments),t[1],t[2])}),e&&(wn[e]=function(){return this.localeData().ordinal(i.apply(this,arguments),o)})}function Ad(o){return o.match(/\[[\s\S]/)?o.replace(/^\[|\]$/g,""):o.replace(/\\/g,"")}function kd(o){var t=o.match(Hi),e,n;for(e=0,n=t.length;e<n;e++)wn[t[e]]?t[e]=wn[t[e]]:t[e]=Ad(t[e]);return function(i){var l="",r;for(r=0;r<n;r++)l+=ke(t[r])?t[r].call(i,o):t[r];return l}}function Do(o,t){return o.isValid()?(t=Cr(t,o.localeData()),_i[t]=_i[t]||kd(t),_i[t](o)):o.localeData().invalidDate()}function Cr(o,t){var e=5;function n(i){return t.longDateFormat(i)||i}for(bo.lastIndex=0;e>=0&&bo.test(o);)o=o.replace(bo,n),bo.lastIndex=0,e-=1;return o}var Gd={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function xd(o){var t=this._longDateFormat[o],e=this._longDateFormat[o.toUpperCase()];return t||!e?t:(this._longDateFormat[o]=e.match(Hi).map(function(n){return n==="MMMM"||n==="MM"||n==="DD"||n==="dddd"?n.slice(1):n}).join(""),this._longDateFormat[o])}var Bd="Invalid date";function Jd(){return this._invalidDate}var $d="%d",zd=/\d{1,2}/;function jd(o){return this._ordinal.replace("%d",o)}var qd={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function tu(o,t,e,n){var i=this._relativeTime[e];return ke(i)?i(o,t,e,n):i.replace(/%d/i,o)}function eu(o,t){var e=this._relativeTime[o>0?"future":"past"];return ke(e)?e(t):e.replace(/%s/i,t)}var Ir={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function Oe(o){return typeof o=="string"?Ir[o]||Ir[o.toLowerCase()]:void 0}function Ai(o){var t={},e,n;for(n in o)Kt(o,n)&&(e=Oe(n),e&&(t[e]=o[n]));return t}var nu={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function ou(o){var t=[],e;for(e in o)Kt(o,e)&&t.push({unit:e,priority:nu[e]});return t.sort(function(n,i){return n.priority-i.priority}),t}var Lr=/\d/,Le=/\d\d/,Pr=/\d{3}/,ki=/\d{4}/,Vo=/[+-]?\d{6}/,qt=/\d\d?/,Er=/\d\d\d\d?/,Mr=/\d\d\d\d\d\d?/,Wo=/\d{1,3}/,Gi=/\d{1,4}/,Yo=/[+-]?\d{1,6}/,Zn=/\d+/,Uo=/[+-]?\d+/,iu=/Z|[+-]\d\d:?\d\d/gi,wo=/Z|[+-]\d\d(?::?\d\d)?/gi,su=/[+-]?\d+(\.\d{1,3})?/,eo=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,Qn=/^[1-9]\d?/,xi=/^([1-9]\d|\d)/,Zo;Zo={};function dt(o,t,e){Zo[o]=ke(t)?t:function(n,i){return n&&e?e:t}}function ru(o,t){return Kt(Zo,o)?Zo[o](t._strict,t._locale):new RegExp(lu(o))}function lu(o){return ze(o.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,i,l){return e||n||i||l}))}function ze(o){return o.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Se(o){return o<0?Math.ceil(o)||0:Math.floor(o)}function Vt(o){var t=+o,e=0;return t!==0&&isFinite(t)&&(e=Se(t)),e}var Bi={};function Bt(o,t){var e,n=t,i;for(typeof o=="string"&&(o=[o]),$e(t)&&(n=function(l,r){r[t]=Vt(l)}),i=o.length,e=0;e<i;e++)Bi[o[e]]=n}function no(o,t){Bt(o,function(e,n,i,l){i._w=i._w||{},t(e,i._w,i,l)})}function au(o,t,e){t!=null&&Kt(Bi,o)&&Bi[o](t,e._a,e,o)}function Qo(o){return o%4===0&&o%100!==0||o%400===0}var he=0,je=1,xe=2,ce=3,De=4,qe=5,Pn=6,cu=7,du=8;gt("Y",0,0,function(){var o=this.year();return o<=9999?Ge(o,4):"+"+o}),gt(0,["YY",2],0,function(){return this.year()%100}),gt(0,["YYYY",4],0,"year"),gt(0,["YYYYY",5],0,"year"),gt(0,["YYYYYY",6,!0],0,"year"),dt("Y",Uo),dt("YY",qt,Le),dt("YYYY",Gi,ki),dt("YYYYY",Yo,Vo),dt("YYYYYY",Yo,Vo),Bt(["YYYYY","YYYYYY"],he),Bt("YYYY",function(o,t){t[he]=o.length===2?st.parseTwoDigitYear(o):Vt(o)}),Bt("YY",function(o,t){t[he]=st.parseTwoDigitYear(o)}),Bt("Y",function(o,t){t[he]=parseInt(o,10)});function oo(o){return Qo(o)?366:365}st.parseTwoDigitYear=function(o){return Vt(o)+(Vt(o)>68?1900:2e3)};var Or=vn("FullYear",!0);function uu(){return Qo(this.year())}function vn(o,t){return function(e){return e!=null?(Sr(this,o,e),st.updateOffset(this,t),this):io(this,o)}}function io(o,t){if(!o.isValid())return NaN;var e=o._d,n=o._isUTC;switch(t){case"Milliseconds":return n?e.getUTCMilliseconds():e.getMilliseconds();case"Seconds":return n?e.getUTCSeconds():e.getSeconds();case"Minutes":return n?e.getUTCMinutes():e.getMinutes();case"Hours":return n?e.getUTCHours():e.getHours();case"Date":return n?e.getUTCDate():e.getDate();case"Day":return n?e.getUTCDay():e.getDay();case"Month":return n?e.getUTCMonth():e.getMonth();case"FullYear":return n?e.getUTCFullYear():e.getFullYear();default:return NaN}}function Sr(o,t,e){var n,i,l,r,a;if(!(!o.isValid()||isNaN(e))){switch(n=o._d,i=o._isUTC,t){case"Milliseconds":return void(i?n.setUTCMilliseconds(e):n.setMilliseconds(e));case"Seconds":return void(i?n.setUTCSeconds(e):n.setSeconds(e));case"Minutes":return void(i?n.setUTCMinutes(e):n.setMinutes(e));case"Hours":return void(i?n.setUTCHours(e):n.setHours(e));case"Date":return void(i?n.setUTCDate(e):n.setDate(e));case"FullYear":break;default:return}l=e,r=o.month(),a=o.date(),a=a===29&&r===1&&!Qo(l)?28:a,i?n.setUTCFullYear(l,r,a):n.setFullYear(l,r,a)}}function Ru(o){return o=Oe(o),ke(this[o])?this[o]():this}function hu(o,t){if(typeof o=="object"){o=Ai(o);var e=ou(o),n,i=e.length;for(n=0;n<i;n++)this[e[n].unit](o[e[n].unit])}else if(o=Oe(o),ke(this[o]))return this[o](t);return this}function gu(o,t){return(o%t+t)%t}var le;Array.prototype.indexOf?le=Array.prototype.indexOf:le=function(o){var t;for(t=0;t<this.length;++t)if(this[t]===o)return t;return-1};function Ji(o,t){if(isNaN(o)||isNaN(t))return NaN;var e=gu(t,12);return o+=(t-e)/12,e===1?Qo(o)?29:28:31-e%7%2}gt("M",["MM",2],"Mo",function(){return this.month()+1}),gt("MMM",0,0,function(o){return this.localeData().monthsShort(this,o)}),gt("MMMM",0,0,function(o){return this.localeData().months(this,o)}),dt("M",qt,Qn),dt("MM",qt,Le),dt("MMM",function(o,t){return t.monthsShortRegex(o)}),dt("MMMM",function(o,t){return t.monthsRegex(o)}),Bt(["M","MM"],function(o,t){t[je]=Vt(o)-1}),Bt(["MMM","MMMM"],function(o,t,e,n){var i=e._locale.monthsParse(o,n,e._strict);i!=null?t[je]=i:Ot(e).invalidMonth=o});var Tu="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Xr="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Nr=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,fu=eo,mu=eo;function pu(o,t){return o?ye(this._months)?this._months[o.month()]:this._months[(this._months.isFormat||Nr).test(t)?"format":"standalone"][o.month()]:ye(this._months)?this._months:this._months.standalone}function Cu(o,t){return o?ye(this._monthsShort)?this._monthsShort[o.month()]:this._monthsShort[Nr.test(t)?"format":"standalone"][o.month()]:ye(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Iu(o,t,e){var n,i,l,r=o.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],n=0;n<12;++n)l=Ae([2e3,n]),this._shortMonthsParse[n]=this.monthsShort(l,"").toLocaleLowerCase(),this._longMonthsParse[n]=this.months(l,"").toLocaleLowerCase();return e?t==="MMM"?(i=le.call(this._shortMonthsParse,r),i!==-1?i:null):(i=le.call(this._longMonthsParse,r),i!==-1?i:null):t==="MMM"?(i=le.call(this._shortMonthsParse,r),i!==-1?i:(i=le.call(this._longMonthsParse,r),i!==-1?i:null)):(i=le.call(this._longMonthsParse,r),i!==-1?i:(i=le.call(this._shortMonthsParse,r),i!==-1?i:null))}function Lu(o,t,e){var n,i,l;if(this._monthsParseExact)return Iu.call(this,o,t,e);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(i=Ae([2e3,n]),e&&!this._longMonthsParse[n]&&(this._longMonthsParse[n]=new RegExp("^"+this.months(i,"").replace(".","")+"$","i"),this._shortMonthsParse[n]=new RegExp("^"+this.monthsShort(i,"").replace(".","")+"$","i")),!e&&!this._monthsParse[n]&&(l="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[n]=new RegExp(l.replace(".",""),"i")),e&&t==="MMMM"&&this._longMonthsParse[n].test(o))return n;if(e&&t==="MMM"&&this._shortMonthsParse[n].test(o))return n;if(!e&&this._monthsParse[n].test(o))return n}}function Fr(o,t){if(!o.isValid())return o;if(typeof t=="string"){if(/^\d+$/.test(t))t=Vt(t);else if(t=o.localeData().monthsParse(t),!$e(t))return o}var e=t,n=o.date();return n=n<29?n:Math.min(n,Ji(o.year(),e)),o._isUTC?o._d.setUTCMonth(e,n):o._d.setMonth(e,n),o}function yr(o){return o!=null?(Fr(this,o),st.updateOffset(this,!0),this):io(this,"Month")}function Pu(){return Ji(this.year(),this.month())}function Eu(o){return this._monthsParseExact?(Kt(this,"_monthsRegex")||br.call(this),o?this._monthsShortStrictRegex:this._monthsShortRegex):(Kt(this,"_monthsShortRegex")||(this._monthsShortRegex=fu),this._monthsShortStrictRegex&&o?this._monthsShortStrictRegex:this._monthsShortRegex)}function Mu(o){return this._monthsParseExact?(Kt(this,"_monthsRegex")||br.call(this),o?this._monthsStrictRegex:this._monthsRegex):(Kt(this,"_monthsRegex")||(this._monthsRegex=mu),this._monthsStrictRegex&&o?this._monthsStrictRegex:this._monthsRegex)}function br(){function o(c,d){return d.length-c.length}var t=[],e=[],n=[],i,l,r,a;for(i=0;i<12;i++)l=Ae([2e3,i]),r=ze(this.monthsShort(l,"")),a=ze(this.months(l,"")),t.push(r),e.push(a),n.push(a),n.push(r);t.sort(o),e.sort(o),n.sort(o),this._monthsRegex=new RegExp("^("+n.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+t.join("|")+")","i")}function Ou(o,t,e,n,i,l,r){var a;return o<100&&o>=0?(a=new Date(o+400,t,e,n,i,l,r),isFinite(a.getFullYear())&&a.setFullYear(o)):a=new Date(o,t,e,n,i,l,r),a}function so(o){var t,e;return o<100&&o>=0?(e=Array.prototype.slice.call(arguments),e[0]=o+400,t=new Date(Date.UTC.apply(null,e)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(o)):t=new Date(Date.UTC.apply(null,arguments)),t}function vo(o,t,e){var n=7+t-e,i=(7+so(o,0,n).getUTCDay()-t)%7;return-i+n-1}function Dr(o,t,e,n,i){var l=(7+e-n)%7,r=vo(o,n,i),a=1+7*(t-1)+l+r,c,d;return a<=0?(c=o-1,d=oo(c)+a):a>oo(o)?(c=o+1,d=a-oo(o)):(c=o,d=a),{year:c,dayOfYear:d}}function ro(o,t,e){var n=vo(o.year(),t,e),i=Math.floor((o.dayOfYear()-n-1)/7)+1,l,r;return i<1?(r=o.year()-1,l=i+tn(r,t,e)):i>tn(o.year(),t,e)?(l=i-tn(o.year(),t,e),r=o.year()+1):(r=o.year(),l=i),{week:l,year:r}}function tn(o,t,e){var n=vo(o,t,e),i=vo(o+1,t,e);return(oo(o)-n+i)/7}gt("w",["ww",2],"wo","week"),gt("W",["WW",2],"Wo","isoWeek"),dt("w",qt,Qn),dt("ww",qt,Le),dt("W",qt,Qn),dt("WW",qt,Le),no(["w","ww","W","WW"],function(o,t,e,n){t[n.substr(0,1)]=Vt(o)});function Su(o){return ro(o,this._week.dow,this._week.doy).week}var Xu={dow:0,doy:6};function Nu(){return this._week.dow}function Fu(){return this._week.doy}function yu(o){var t=this.localeData().week(this);return o==null?t:this.add((o-t)*7,"d")}function bu(o){var t=ro(this,1,4).week;return o==null?t:this.add((o-t)*7,"d")}gt("d",0,"do","day"),gt("dd",0,0,function(o){return this.localeData().weekdaysMin(this,o)}),gt("ddd",0,0,function(o){return this.localeData().weekdaysShort(this,o)}),gt("dddd",0,0,function(o){return this.localeData().weekdays(this,o)}),gt("e",0,0,"weekday"),gt("E",0,0,"isoWeekday"),dt("d",qt),dt("e",qt),dt("E",qt),dt("dd",function(o,t){return t.weekdaysMinRegex(o)}),dt("ddd",function(o,t){return t.weekdaysShortRegex(o)}),dt("dddd",function(o,t){return t.weekdaysRegex(o)}),no(["dd","ddd","dddd"],function(o,t,e,n){var i=e._locale.weekdaysParse(o,n,e._strict);i!=null?t.d=i:Ot(e).invalidWeekday=o}),no(["d","e","E"],function(o,t,e,n){t[n]=Vt(o)});function Du(o,t){return typeof o!="string"?o:isNaN(o)?(o=t.weekdaysParse(o),typeof o=="number"?o:null):parseInt(o,10)}function Vu(o,t){return typeof o=="string"?t.weekdaysParse(o)%7||7:isNaN(o)?null:o}function $i(o,t){return o.slice(t,7).concat(o.slice(0,t))}var Wu="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Vr="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Yu="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Uu=eo,wu=eo,Zu=eo;function Qu(o,t){var e=ye(this._weekdays)?this._weekdays:this._weekdays[o&&o!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return o===!0?$i(e,this._week.dow):o?e[o.day()]:e}function vu(o){return o===!0?$i(this._weekdaysShort,this._week.dow):o?this._weekdaysShort[o.day()]:this._weekdaysShort}function Ku(o){return o===!0?$i(this._weekdaysMin,this._week.dow):o?this._weekdaysMin[o.day()]:this._weekdaysMin}function Hu(o,t,e){var n,i,l,r=o.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],n=0;n<7;++n)l=Ae([2e3,1]).day(n),this._minWeekdaysParse[n]=this.weekdaysMin(l,"").toLocaleLowerCase(),this._shortWeekdaysParse[n]=this.weekdaysShort(l,"").toLocaleLowerCase(),this._weekdaysParse[n]=this.weekdays(l,"").toLocaleLowerCase();return e?t==="dddd"?(i=le.call(this._weekdaysParse,r),i!==-1?i:null):t==="ddd"?(i=le.call(this._shortWeekdaysParse,r),i!==-1?i:null):(i=le.call(this._minWeekdaysParse,r),i!==-1?i:null):t==="dddd"?(i=le.call(this._weekdaysParse,r),i!==-1||(i=le.call(this._shortWeekdaysParse,r),i!==-1)?i:(i=le.call(this._minWeekdaysParse,r),i!==-1?i:null)):t==="ddd"?(i=le.call(this._shortWeekdaysParse,r),i!==-1||(i=le.call(this._weekdaysParse,r),i!==-1)?i:(i=le.call(this._minWeekdaysParse,r),i!==-1?i:null)):(i=le.call(this._minWeekdaysParse,r),i!==-1||(i=le.call(this._weekdaysParse,r),i!==-1)?i:(i=le.call(this._shortWeekdaysParse,r),i!==-1?i:null))}function _u(o,t,e){var n,i,l;if(this._weekdaysParseExact)return Hu.call(this,o,t,e);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(i=Ae([2e3,1]).day(n),e&&!this._fullWeekdaysParse[n]&&(this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(i,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(i,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(i,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[n]||(l="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[n]=new RegExp(l.replace(".",""),"i")),e&&t==="dddd"&&this._fullWeekdaysParse[n].test(o))return n;if(e&&t==="ddd"&&this._shortWeekdaysParse[n].test(o))return n;if(e&&t==="dd"&&this._minWeekdaysParse[n].test(o))return n;if(!e&&this._weekdaysParse[n].test(o))return n}}function Au(o){if(!this.isValid())return o!=null?this:NaN;var t=io(this,"Day");return o!=null?(o=Du(o,this.localeData()),this.add(o-t,"d")):t}function ku(o){if(!this.isValid())return o!=null?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return o==null?t:this.add(o-t,"d")}function Gu(o){if(!this.isValid())return o!=null?this:NaN;if(o!=null){var t=Vu(o,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function xu(o){return this._weekdaysParseExact?(Kt(this,"_weekdaysRegex")||zi.call(this),o?this._weekdaysStrictRegex:this._weekdaysRegex):(Kt(this,"_weekdaysRegex")||(this._weekdaysRegex=Uu),this._weekdaysStrictRegex&&o?this._weekdaysStrictRegex:this._weekdaysRegex)}function Bu(o){return this._weekdaysParseExact?(Kt(this,"_weekdaysRegex")||zi.call(this),o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(Kt(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=wu),this._weekdaysShortStrictRegex&&o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Ju(o){return this._weekdaysParseExact?(Kt(this,"_weekdaysRegex")||zi.call(this),o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(Kt(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=Zu),this._weekdaysMinStrictRegex&&o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function zi(){function o(u,R){return R.length-u.length}var t=[],e=[],n=[],i=[],l,r,a,c,d;for(l=0;l<7;l++)r=Ae([2e3,1]).day(l),a=ze(this.weekdaysMin(r,"")),c=ze(this.weekdaysShort(r,"")),d=ze(this.weekdays(r,"")),t.push(a),e.push(c),n.push(d),i.push(a),i.push(c),i.push(d);t.sort(o),e.sort(o),n.sort(o),i.sort(o),this._weekdaysRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+t.join("|")+")","i")}function ji(){return this.hours()%12||12}function $u(){return this.hours()||24}gt("H",["HH",2],0,"hour"),gt("h",["hh",2],0,ji),gt("k",["kk",2],0,$u),gt("hmm",0,0,function(){return""+ji.apply(this)+Ge(this.minutes(),2)}),gt("hmmss",0,0,function(){return""+ji.apply(this)+Ge(this.minutes(),2)+Ge(this.seconds(),2)}),gt("Hmm",0,0,function(){return""+this.hours()+Ge(this.minutes(),2)}),gt("Hmmss",0,0,function(){return""+this.hours()+Ge(this.minutes(),2)+Ge(this.seconds(),2)});function Wr(o,t){gt(o,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}Wr("a",!0),Wr("A",!1);function Yr(o,t){return t._meridiemParse}dt("a",Yr),dt("A",Yr),dt("H",qt,xi),dt("h",qt,Qn),dt("k",qt,Qn),dt("HH",qt,Le),dt("hh",qt,Le),dt("kk",qt,Le),dt("hmm",Er),dt("hmmss",Mr),dt("Hmm",Er),dt("Hmmss",Mr),Bt(["H","HH"],ce),Bt(["k","kk"],function(o,t,e){var n=Vt(o);t[ce]=n===24?0:n}),Bt(["a","A"],function(o,t,e){e._isPm=e._locale.isPM(o),e._meridiem=o}),Bt(["h","hh"],function(o,t,e){t[ce]=Vt(o),Ot(e).bigHour=!0}),Bt("hmm",function(o,t,e){var n=o.length-2;t[ce]=Vt(o.substr(0,n)),t[De]=Vt(o.substr(n)),Ot(e).bigHour=!0}),Bt("hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[ce]=Vt(o.substr(0,n)),t[De]=Vt(o.substr(n,2)),t[qe]=Vt(o.substr(i)),Ot(e).bigHour=!0}),Bt("Hmm",function(o,t,e){var n=o.length-2;t[ce]=Vt(o.substr(0,n)),t[De]=Vt(o.substr(n))}),Bt("Hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[ce]=Vt(o.substr(0,n)),t[De]=Vt(o.substr(n,2)),t[qe]=Vt(o.substr(i))});function zu(o){return(o+"").toLowerCase().charAt(0)==="p"}var ju=/[ap]\.?m?\.?/i,qu=vn("Hours",!0);function tR(o,t,e){return o>11?e?"pm":"PM":e?"am":"AM"}var Ur={calendar:Hd,longDateFormat:Gd,invalidDate:Bd,ordinal:$d,dayOfMonthOrdinalParse:zd,relativeTime:qd,months:Tu,monthsShort:Xr,week:Xu,weekdays:Wu,weekdaysMin:Yu,weekdaysShort:Vr,meridiemParse:ju},oe={},lo={},ao;function eR(o,t){var e,n=Math.min(o.length,t.length);for(e=0;e<n;e+=1)if(o[e]!==t[e])return e;return n}function wr(o){return o&&o.toLowerCase().replace("_","-")}function nR(o){for(var t=0,e,n,i,l;t<o.length;){for(l=wr(o[t]).split("-"),e=l.length,n=wr(o[t+1]),n=n?n.split("-"):null;e>0;){if(i=Ko(l.slice(0,e).join("-")),i)return i;if(n&&n.length>=e&&eR(l,n)>=e-1)break;e--}t++}return ao}function oR(o){return!!(o&&o.match("^[^/\\\\]*$"))}function Ko(o){var t=null,e;if(oe[o]===void 0&&typeof module<"u"&&module&&module.exports&&oR(o))try{t=ao._abbr,e=require,e("./locale/"+o),Rn(t)}catch{oe[o]=null}return oe[o]}function Rn(o,t){var e;return o&&(me(t)?e=en(o):e=qi(o,t),e?ao=e:typeof console<"u"&&console.warn&&console.warn("Locale "+o+" not found. Did you forget to load it?")),ao._abbr}function qi(o,t){if(t!==null){var e,n=Ur;if(t.abbr=o,oe[o]!=null)pr("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=oe[o]._config;else if(t.parentLocale!=null)if(oe[t.parentLocale]!=null)n=oe[t.parentLocale]._config;else if(e=Ko(t.parentLocale),e!=null)n=e._config;else return lo[t.parentLocale]||(lo[t.parentLocale]=[]),lo[t.parentLocale].push({name:o,config:t}),null;return oe[o]=new vi(Qi(n,t)),lo[o]&&lo[o].forEach(function(i){qi(i.name,i.config)}),Rn(o),oe[o]}else return delete oe[o],null}function iR(o,t){if(t!=null){var e,n,i=Ur;oe[o]!=null&&oe[o].parentLocale!=null?oe[o].set(Qi(oe[o]._config,t)):(n=Ko(o),n!=null&&(i=n._config),t=Qi(i,t),n==null&&(t.abbr=o),e=new vi(t),e.parentLocale=oe[o],oe[o]=e),Rn(o)}else oe[o]!=null&&(oe[o].parentLocale!=null?(oe[o]=oe[o].parentLocale,o===Rn()&&Rn(o)):oe[o]!=null&&delete oe[o]);return oe[o]}function en(o){var t;if(o&&o._locale&&o._locale._abbr&&(o=o._locale._abbr),!o)return ao;if(!ye(o)){if(t=Ko(o),t)return t;o=[o]}return nR(o)}function sR(){return Ki(oe)}function ts(o){var t,e=o._a;return e&&Ot(o).overflow===-2&&(t=e[je]<0||e[je]>11?je:e[xe]<1||e[xe]>Ji(e[he],e[je])?xe:e[ce]<0||e[ce]>24||e[ce]===24&&(e[De]!==0||e[qe]!==0||e[Pn]!==0)?ce:e[De]<0||e[De]>59?De:e[qe]<0||e[qe]>59?qe:e[Pn]<0||e[Pn]>999?Pn:-1,Ot(o)._overflowDayOfYear&&(t<he||t>xe)&&(t=xe),Ot(o)._overflowWeeks&&t===-1&&(t=cu),Ot(o)._overflowWeekday&&t===-1&&(t=du),Ot(o).overflow=t),o}var rR=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,lR=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,aR=/Z|[+-]\d\d(?::?\d\d)?/,Ho=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],es=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],cR=/^\/?Date\((-?\d+)/i,dR=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,uR={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Zr(o){var t,e,n=o._i,i=rR.exec(n)||lR.exec(n),l,r,a,c,d=Ho.length,u=es.length;if(i){for(Ot(o).iso=!0,t=0,e=d;t<e;t++)if(Ho[t][1].exec(i[1])){r=Ho[t][0],l=Ho[t][2]!==!1;break}if(r==null){o._isValid=!1;return}if(i[3]){for(t=0,e=u;t<e;t++)if(es[t][1].exec(i[3])){a=(i[2]||" ")+es[t][0];break}if(a==null){o._isValid=!1;return}}if(!l&&a!=null){o._isValid=!1;return}if(i[4])if(aR.exec(i[4]))c="Z";else{o._isValid=!1;return}o._f=r+(a||"")+(c||""),os(o)}else o._isValid=!1}function RR(o,t,e,n,i,l){var r=[hR(o),Xr.indexOf(t),parseInt(e,10),parseInt(n,10),parseInt(i,10)];return l&&r.push(parseInt(l,10)),r}function hR(o){var t=parseInt(o,10);return t<=49?2e3+t:t<=999?1900+t:t}function gR(o){return o.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function TR(o,t,e){if(o){var n=Vr.indexOf(o),i=new Date(t[0],t[1],t[2]).getDay();if(n!==i)return Ot(e).weekdayMismatch=!0,e._isValid=!1,!1}return!0}function fR(o,t,e){if(o)return uR[o];if(t)return 0;var n=parseInt(e,10),i=n%100,l=(n-i)/100;return l*60+i}function Qr(o){var t=dR.exec(gR(o._i)),e;if(t){if(e=RR(t[4],t[3],t[2],t[5],t[6],t[7]),!TR(t[1],e,o))return;o._a=e,o._tzm=fR(t[8],t[9],t[10]),o._d=so.apply(null,o._a),o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),Ot(o).rfc2822=!0}else o._isValid=!1}function mR(o){var t=cR.exec(o._i);if(t!==null){o._d=new Date(+t[1]);return}if(Zr(o),o._isValid===!1)delete o._isValid;else return;if(Qr(o),o._isValid===!1)delete o._isValid;else return;o._strict?o._isValid=!1:st.createFromInputFallback(o)}st.createFromInputFallback=Me("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(o){o._d=new Date(o._i+(o._useUTC?" UTC":""))});function Kn(o,t,e){return o??t??e}function pR(o){var t=new Date(st.now());return o._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function ns(o){var t,e,n=[],i,l,r;if(!o._d){for(i=pR(o),o._w&&o._a[xe]==null&&o._a[je]==null&&CR(o),o._dayOfYear!=null&&(r=Kn(o._a[he],i[he]),(o._dayOfYear>oo(r)||o._dayOfYear===0)&&(Ot(o)._overflowDayOfYear=!0),e=so(r,0,o._dayOfYear),o._a[je]=e.getUTCMonth(),o._a[xe]=e.getUTCDate()),t=0;t<3&&o._a[t]==null;++t)o._a[t]=n[t]=i[t];for(;t<7;t++)o._a[t]=n[t]=o._a[t]==null?t===2?1:0:o._a[t];o._a[ce]===24&&o._a[De]===0&&o._a[qe]===0&&o._a[Pn]===0&&(o._nextDay=!0,o._a[ce]=0),o._d=(o._useUTC?so:Ou).apply(null,n),l=o._useUTC?o._d.getUTCDay():o._d.getDay(),o._tzm!=null&&o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),o._nextDay&&(o._a[ce]=24),o._w&&typeof o._w.d<"u"&&o._w.d!==l&&(Ot(o).weekdayMismatch=!0)}}function CR(o){var t,e,n,i,l,r,a,c,d;t=o._w,t.GG!=null||t.W!=null||t.E!=null?(l=1,r=4,e=Kn(t.GG,o._a[he],ro(te(),1,4).year),n=Kn(t.W,1),i=Kn(t.E,1),(i<1||i>7)&&(c=!0)):(l=o._locale._week.dow,r=o._locale._week.doy,d=ro(te(),l,r),e=Kn(t.gg,o._a[he],d.year),n=Kn(t.w,d.week),t.d!=null?(i=t.d,(i<0||i>6)&&(c=!0)):t.e!=null?(i=t.e+l,(t.e<0||t.e>6)&&(c=!0)):i=l),n<1||n>tn(e,l,r)?Ot(o)._overflowWeeks=!0:c!=null?Ot(o)._overflowWeekday=!0:(a=Dr(e,n,i,l,r),o._a[he]=a.year,o._dayOfYear=a.dayOfYear)}st.ISO_8601=function(){},st.RFC_2822=function(){};function os(o){if(o._f===st.ISO_8601){Zr(o);return}if(o._f===st.RFC_2822){Qr(o);return}o._a=[],Ot(o).empty=!0;var t=""+o._i,e,n,i,l,r,a=t.length,c=0,d,u;for(i=Cr(o._f,o._locale).match(Hi)||[],u=i.length,e=0;e<u;e++)l=i[e],n=(t.match(ru(l,o))||[])[0],n&&(r=t.substr(0,t.indexOf(n)),r.length>0&&Ot(o).unusedInput.push(r),t=t.slice(t.indexOf(n)+n.length),c+=n.length),wn[l]?(n?Ot(o).empty=!1:Ot(o).unusedTokens.push(l),au(l,n,o)):o._strict&&!n&&Ot(o).unusedTokens.push(l);Ot(o).charsLeftOver=a-c,t.length>0&&Ot(o).unusedInput.push(t),o._a[ce]<=12&&Ot(o).bigHour===!0&&o._a[ce]>0&&(Ot(o).bigHour=void 0),Ot(o).parsedDateParts=o._a.slice(0),Ot(o).meridiem=o._meridiem,o._a[ce]=IR(o._locale,o._a[ce],o._meridiem),d=Ot(o).era,d!==null&&(o._a[he]=o._locale.erasConvertYear(d,o._a[he])),ns(o),ts(o)}function IR(o,t,e){var n;return e==null?t:o.meridiemHour!=null?o.meridiemHour(t,e):(o.isPM!=null&&(n=o.isPM(e),n&&t<12&&(t+=12),!n&&t===12&&(t=0)),t)}function LR(o){var t,e,n,i,l,r,a=!1,c=o._f.length;if(c===0){Ot(o).invalidFormat=!0,o._d=new Date(NaN);return}for(i=0;i<c;i++)l=0,r=!1,t=Zi({},o),o._useUTC!=null&&(t._useUTC=o._useUTC),t._f=o._f[i],os(t),Ui(t)&&(r=!0),l+=Ot(t).charsLeftOver,l+=Ot(t).unusedTokens.length*10,Ot(t).score=l,a?l<n&&(n=l,e=t):(n==null||l<n||r)&&(n=l,e=t,r&&(a=!0));un(o,e||t)}function PR(o){if(!o._d){var t=Ai(o._i),e=t.day===void 0?t.date:t.day;o._a=gr([t.year,t.month,e,t.hour,t.minute,t.second,t.millisecond],function(n){return n&&parseInt(n,10)}),ns(o)}}function ER(o){var t=new to(ts(vr(o)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function vr(o){var t=o._i,e=o._f;return o._locale=o._locale||en(o._l),t===null||e===void 0&&t===""?yo({nullInput:!0}):(typeof t=="string"&&(o._i=t=o._locale.preparse(t)),be(t)?new to(ts(t)):(qn(t)?o._d=t:ye(e)?LR(o):e?os(o):MR(o),Ui(o)||(o._d=null),o))}function MR(o){var t=o._i;me(t)?o._d=new Date(st.now()):qn(t)?o._d=new Date(t.valueOf()):typeof t=="string"?mR(o):ye(t)?(o._a=gr(t.slice(0),function(e){return parseInt(e,10)}),ns(o)):Ln(t)?PR(o):$e(t)?o._d=new Date(t):st.createFromInputFallback(o)}function Kr(o,t,e,n,i){var l={};return(t===!0||t===!1)&&(n=t,t=void 0),(e===!0||e===!1)&&(n=e,e=void 0),(Ln(o)&&Wi(o)||ye(o)&&o.length===0)&&(o=void 0),l._isAMomentObject=!0,l._useUTC=l._isUTC=i,l._l=e,l._i=o,l._f=t,l._strict=n,ER(l)}function te(o,t,e,n){return Kr(o,t,e,n,!1)}var OR=Me("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=te.apply(null,arguments);return this.isValid()&&o.isValid()?o<this?this:o:yo()}),SR=Me("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=te.apply(null,arguments);return this.isValid()&&o.isValid()?o>this?this:o:yo()});function Hr(o,t){var e,n;if(t.length===1&&ye(t[0])&&(t=t[0]),!t.length)return te();for(e=t[0],n=1;n<t.length;++n)(!t[n].isValid()||t[n][o](e))&&(e=t[n]);return e}function XR(){var o=[].slice.call(arguments,0);return Hr("isBefore",o)}function NR(){var o=[].slice.call(arguments,0);return Hr("isAfter",o)}var FR=function(){return Date.now?Date.now():+new Date},co=["year","quarter","month","week","day","hour","minute","second","millisecond"];function yR(o){var t,e=!1,n,i=co.length;for(t in o)if(Kt(o,t)&&!(le.call(co,t)!==-1&&(o[t]==null||!isNaN(o[t]))))return!1;for(n=0;n<i;++n)if(o[co[n]]){if(e)return!1;parseFloat(o[co[n]])!==Vt(o[co[n]])&&(e=!0)}return!0}function bR(){return this._isValid}function DR(){return Ve(NaN)}function _o(o){var t=Ai(o),e=t.year||0,n=t.quarter||0,i=t.month||0,l=t.week||t.isoWeek||0,r=t.day||0,a=t.hour||0,c=t.minute||0,d=t.second||0,u=t.millisecond||0;this._isValid=yR(t),this._milliseconds=+u+d*1e3+c*6e4+a*1e3*60*60,this._days=+r+l*7,this._months=+i+n*3+e*12,this._data={},this._locale=en(),this._bubble()}function Ao(o){return o instanceof _o}function is(o){return o<0?Math.round(-1*o)*-1:Math.round(o)}function VR(o,t,e){var n=Math.min(o.length,t.length),i=Math.abs(o.length-t.length),l=0,r;for(r=0;r<n;r++)Vt(o[r])!==Vt(t[r])&&l++;return l+i}function _r(o,t){gt(o,0,0,function(){var e=this.utcOffset(),n="+";return e<0&&(e=-e,n="-"),n+Ge(~~(e/60),2)+t+Ge(~~e%60,2)})}_r("Z",":"),_r("ZZ",""),dt("Z",wo),dt("ZZ",wo),Bt(["Z","ZZ"],function(o,t,e){e._useUTC=!0,e._tzm=ss(wo,o)});var WR=/([\+\-]|\d\d)/gi;function ss(o,t){var e=(t||"").match(o),n,i,l;return e===null?null:(n=e[e.length-1]||[],i=(n+"").match(WR)||["-",0,0],l=+(i[1]*60)+Vt(i[2]),l===0?0:i[0]==="+"?l:-l)}function rs(o,t){var e,n;return t._isUTC?(e=t.clone(),n=(be(o)||qn(o)?o.valueOf():te(o).valueOf())-e.valueOf(),e._d.setTime(e._d.valueOf()+n),st.updateOffset(e,!1),e):te(o).local()}function ls(o){return-Math.round(o._d.getTimezoneOffset())}st.updateOffset=function(){};function YR(o,t,e){var n=this._offset||0,i;if(!this.isValid())return o!=null?this:NaN;if(o!=null){if(typeof o=="string"){if(o=ss(wo,o),o===null)return this}else Math.abs(o)<16&&!e&&(o=o*60);return!this._isUTC&&t&&(i=ls(this)),this._offset=o,this._isUTC=!0,i!=null&&this.add(i,"m"),n!==o&&(!t||this._changeInProgress?xr(this,Ve(o-n,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,st.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?n:ls(this)}function UR(o,t){return o!=null?(typeof o!="string"&&(o=-o),this.utcOffset(o,t),this):-this.utcOffset()}function wR(o){return this.utcOffset(0,o)}function ZR(o){return this._isUTC&&(this.utcOffset(0,o),this._isUTC=!1,o&&this.subtract(ls(this),"m")),this}function QR(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var o=ss(iu,this._i);o!=null?this.utcOffset(o):this.utcOffset(0,!0)}return this}function vR(o){return this.isValid()?(o=o?te(o).utcOffset():0,(this.utcOffset()-o)%60===0):!1}function KR(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function HR(){if(!me(this._isDSTShifted))return this._isDSTShifted;var o={},t;return Zi(o,this),o=vr(o),o._a?(t=o._isUTC?Ae(o._a):te(o._a),this._isDSTShifted=this.isValid()&&VR(o._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function _R(){return this.isValid()?!this._isUTC:!1}function AR(){return this.isValid()?this._isUTC:!1}function Ar(){return this.isValid()?this._isUTC&&this._offset===0:!1}var kR=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,GR=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Ve(o,t){var e=o,n=null,i,l,r;return Ao(o)?e={ms:o._milliseconds,d:o._days,M:o._months}:$e(o)||!isNaN(+o)?(e={},t?e[t]=+o:e.milliseconds=+o):(n=kR.exec(o))?(i=n[1]==="-"?-1:1,e={y:0,d:Vt(n[xe])*i,h:Vt(n[ce])*i,m:Vt(n[De])*i,s:Vt(n[qe])*i,ms:Vt(is(n[Pn]*1e3))*i}):(n=GR.exec(o))?(i=n[1]==="-"?-1:1,e={y:En(n[2],i),M:En(n[3],i),w:En(n[4],i),d:En(n[5],i),h:En(n[6],i),m:En(n[7],i),s:En(n[8],i)}):e==null?e={}:typeof e=="object"&&("from"in e||"to"in e)&&(r=xR(te(e.from),te(e.to)),e={},e.ms=r.milliseconds,e.M=r.months),l=new _o(e),Ao(o)&&Kt(o,"_locale")&&(l._locale=o._locale),Ao(o)&&Kt(o,"_isValid")&&(l._isValid=o._isValid),l}Ve.fn=_o.prototype,Ve.invalid=DR;function En(o,t){var e=o&&parseFloat(o.replace(",","."));return(isNaN(e)?0:e)*t}function kr(o,t){var e={};return e.months=t.month()-o.month()+(t.year()-o.year())*12,o.clone().add(e.months,"M").isAfter(t)&&--e.months,e.milliseconds=+t-+o.clone().add(e.months,"M"),e}function xR(o,t){var e;return o.isValid()&&t.isValid()?(t=rs(t,o),o.isBefore(t)?e=kr(o,t):(e=kr(t,o),e.milliseconds=-e.milliseconds,e.months=-e.months),e):{milliseconds:0,months:0}}function Gr(o,t){return function(e,n){var i,l;return n!==null&&!isNaN(+n)&&(pr(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),l=e,e=n,n=l),i=Ve(e,n),xr(this,i,o),this}}function xr(o,t,e,n){var i=t._milliseconds,l=is(t._days),r=is(t._months);o.isValid()&&(n=n??!0,r&&Fr(o,io(o,"Month")+r*e),l&&Sr(o,"Date",io(o,"Date")+l*e),i&&o._d.setTime(o._d.valueOf()+i*e),n&&st.updateOffset(o,l||r))}var BR=Gr(1,"add"),JR=Gr(-1,"subtract");function Br(o){return typeof o=="string"||o instanceof String}function $R(o){return be(o)||qn(o)||Br(o)||$e(o)||jR(o)||zR(o)||o===null||o===void 0}function zR(o){var t=Ln(o)&&!Wi(o),e=!1,n=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],i,l,r=n.length;for(i=0;i<r;i+=1)l=n[i],e=e||Kt(o,l);return t&&e}function jR(o){var t=ye(o),e=!1;return t&&(e=o.filter(function(n){return!$e(n)&&Br(o)}).length===0),t&&e}function qR(o){var t=Ln(o)&&!Wi(o),e=!1,n=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],i,l;for(i=0;i<n.length;i+=1)l=n[i],e=e||Kt(o,l);return t&&e}function th(o,t){var e=o.diff(t,"days",!0);return e<-6?"sameElse":e<-1?"lastWeek":e<0?"lastDay":e<1?"sameDay":e<2?"nextDay":e<7?"nextWeek":"sameElse"}function eh(o,t){arguments.length===1&&(arguments[0]?$R(arguments[0])?(o=arguments[0],t=void 0):qR(arguments[0])&&(t=arguments[0],o=void 0):(o=void 0,t=void 0));var e=o||te(),n=rs(e,this).startOf("day"),i=st.calendarFormat(this,n)||"sameElse",l=t&&(ke(t[i])?t[i].call(this,e):t[i]);return this.format(l||this.localeData().calendar(i,this,te(e)))}function nh(){return new to(this)}function oh(o,t){var e=be(o)?o:te(o);return this.isValid()&&e.isValid()?(t=Oe(t)||"millisecond",t==="millisecond"?this.valueOf()>e.valueOf():e.valueOf()<this.clone().startOf(t).valueOf()):!1}function ih(o,t){var e=be(o)?o:te(o);return this.isValid()&&e.isValid()?(t=Oe(t)||"millisecond",t==="millisecond"?this.valueOf()<e.valueOf():this.clone().endOf(t).valueOf()<e.valueOf()):!1}function sh(o,t,e,n){var i=be(o)?o:te(o),l=be(t)?t:te(t);return this.isValid()&&i.isValid()&&l.isValid()?(n=n||"()",(n[0]==="("?this.isAfter(i,e):!this.isBefore(i,e))&&(n[1]===")"?this.isBefore(l,e):!this.isAfter(l,e))):!1}function rh(o,t){var e=be(o)?o:te(o),n;return this.isValid()&&e.isValid()?(t=Oe(t)||"millisecond",t==="millisecond"?this.valueOf()===e.valueOf():(n=e.valueOf(),this.clone().startOf(t).valueOf()<=n&&n<=this.clone().endOf(t).valueOf())):!1}function lh(o,t){return this.isSame(o,t)||this.isAfter(o,t)}function ah(o,t){return this.isSame(o,t)||this.isBefore(o,t)}function ch(o,t,e){var n,i,l;if(!this.isValid())return NaN;if(n=rs(o,this),!n.isValid())return NaN;switch(i=(n.utcOffset()-this.utcOffset())*6e4,t=Oe(t),t){case"year":l=ko(this,n)/12;break;case"month":l=ko(this,n);break;case"quarter":l=ko(this,n)/3;break;case"second":l=(this-n)/1e3;break;case"minute":l=(this-n)/6e4;break;case"hour":l=(this-n)/36e5;break;case"day":l=(this-n-i)/864e5;break;case"week":l=(this-n-i)/6048e5;break;default:l=this-n}return e?l:Se(l)}function ko(o,t){if(o.date()<t.date())return-ko(t,o);var e=(t.year()-o.year())*12+(t.month()-o.month()),n=o.clone().add(e,"months"),i,l;return t-n<0?(i=o.clone().add(e-1,"months"),l=(t-n)/(n-i)):(i=o.clone().add(e+1,"months"),l=(t-n)/(i-n)),-(e+l)||0}st.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",st.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function dh(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function uh(o){if(!this.isValid())return null;var t=o!==!0,e=t?this.clone().utc():this;return e.year()<0||e.year()>9999?Do(e,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):ke(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",Do(e,"Z")):Do(e,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function Rh(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var o="moment",t="",e,n,i,l;return this.isLocal()||(o=this.utcOffset()===0?"moment.utc":"moment.parseZone",t="Z"),e="["+o+'("]',n=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i="-MM-DD[T]HH:mm:ss.SSS",l=t+'[")]',this.format(e+n+i+l)}function hh(o){o||(o=this.isUtc()?st.defaultFormatUtc:st.defaultFormat);var t=Do(this,o);return this.localeData().postformat(t)}function gh(o,t){return this.isValid()&&(be(o)&&o.isValid()||te(o).isValid())?Ve({to:this,from:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Th(o){return this.from(te(),o)}function fh(o,t){return this.isValid()&&(be(o)&&o.isValid()||te(o).isValid())?Ve({from:this,to:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function mh(o){return this.to(te(),o)}function Jr(o){var t;return o===void 0?this._locale._abbr:(t=en(o),t!=null&&(this._locale=t),this)}var $r=Me("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(o){return o===void 0?this.localeData():this.locale(o)});function zr(){return this._locale}var Go=1e3,Hn=60*Go,xo=60*Hn,jr=(365*400+97)*24*xo;function _n(o,t){return(o%t+t)%t}function qr(o,t,e){return o<100&&o>=0?new Date(o+400,t,e)-jr:new Date(o,t,e).valueOf()}function tl(o,t,e){return o<100&&o>=0?Date.UTC(o+400,t,e)-jr:Date.UTC(o,t,e)}function ph(o){var t,e;if(o=Oe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?tl:qr,o){case"year":t=e(this.year(),0,1);break;case"quarter":t=e(this.year(),this.month()-this.month()%3,1);break;case"month":t=e(this.year(),this.month(),1);break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":t=e(this.year(),this.month(),this.date());break;case"hour":t=this._d.valueOf(),t-=_n(t+(this._isUTC?0:this.utcOffset()*Hn),xo);break;case"minute":t=this._d.valueOf(),t-=_n(t,Hn);break;case"second":t=this._d.valueOf(),t-=_n(t,Go);break}return this._d.setTime(t),st.updateOffset(this,!0),this}function Ch(o){var t,e;if(o=Oe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?tl:qr,o){case"year":t=e(this.year()+1,0,1)-1;break;case"quarter":t=e(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":t=e(this.year(),this.month()+1,1)-1;break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":t=e(this.year(),this.month(),this.date()+1)-1;break;case"hour":t=this._d.valueOf(),t+=xo-_n(t+(this._isUTC?0:this.utcOffset()*Hn),xo)-1;break;case"minute":t=this._d.valueOf(),t+=Hn-_n(t,Hn)-1;break;case"second":t=this._d.valueOf(),t+=Go-_n(t,Go)-1;break}return this._d.setTime(t),st.updateOffset(this,!0),this}function Ih(){return this._d.valueOf()-(this._offset||0)*6e4}function Lh(){return Math.floor(this.valueOf()/1e3)}function Ph(){return new Date(this.valueOf())}function Eh(){var o=this;return[o.year(),o.month(),o.date(),o.hour(),o.minute(),o.second(),o.millisecond()]}function Mh(){var o=this;return{years:o.year(),months:o.month(),date:o.date(),hours:o.hours(),minutes:o.minutes(),seconds:o.seconds(),milliseconds:o.milliseconds()}}function Oh(){return this.isValid()?this.toISOString():null}function Sh(){return Ui(this)}function Xh(){return un({},Ot(this))}function Nh(){return Ot(this).overflow}function Fh(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}gt("N",0,0,"eraAbbr"),gt("NN",0,0,"eraAbbr"),gt("NNN",0,0,"eraAbbr"),gt("NNNN",0,0,"eraName"),gt("NNNNN",0,0,"eraNarrow"),gt("y",["y",1],"yo","eraYear"),gt("y",["yy",2],0,"eraYear"),gt("y",["yyy",3],0,"eraYear"),gt("y",["yyyy",4],0,"eraYear"),dt("N",as),dt("NN",as),dt("NNN",as),dt("NNNN",vh),dt("NNNNN",Kh),Bt(["N","NN","NNN","NNNN","NNNNN"],function(o,t,e,n){var i=e._locale.erasParse(o,n,e._strict);i?Ot(e).era=i:Ot(e).invalidEra=o}),dt("y",Zn),dt("yy",Zn),dt("yyy",Zn),dt("yyyy",Zn),dt("yo",Hh),Bt(["y","yy","yyy","yyyy"],he),Bt(["yo"],function(o,t,e,n){var i;e._locale._eraYearOrdinalRegex&&(i=o.match(e._locale._eraYearOrdinalRegex)),e._locale.eraYearOrdinalParse?t[he]=e._locale.eraYearOrdinalParse(o,i):t[he]=parseInt(o,10)});function yh(o,t){var e,n,i,l=this._eras||en("en")._eras;for(e=0,n=l.length;e<n;++e)switch(typeof l[e].since==="string"&&(i=st(l[e].since).startOf("day"),l[e].since=i.valueOf()),typeof l[e].until){case"undefined":l[e].until=1/0;break;case"string":i=st(l[e].until).startOf("day").valueOf(),l[e].until=i.valueOf();break}return l}function bh(o,t,e){var n,i,l=this.eras(),r,a,c;for(o=o.toUpperCase(),n=0,i=l.length;n<i;++n)if(r=l[n].name.toUpperCase(),a=l[n].abbr.toUpperCase(),c=l[n].narrow.toUpperCase(),e)switch(t){case"N":case"NN":case"NNN":if(a===o)return l[n];break;case"NNNN":if(r===o)return l[n];break;case"NNNNN":if(c===o)return l[n];break}else if([r,a,c].indexOf(o)>=0)return l[n]}function Dh(o,t){var e=o.since<=o.until?1:-1;return t===void 0?st(o.since).year():st(o.since).year()+(t-o.offset)*e}function Vh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].name;return""}function Wh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].narrow;return""}function Yh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].abbr;return""}function Uh(){var o,t,e,n,i=this.localeData().eras();for(o=0,t=i.length;o<t;++o)if(e=i[o].since<=i[o].until?1:-1,n=this.clone().startOf("day").valueOf(),i[o].since<=n&&n<=i[o].until||i[o].until<=n&&n<=i[o].since)return(this.year()-st(i[o].since).year())*e+i[o].offset;return this.year()}function wh(o){return Kt(this,"_erasNameRegex")||cs.call(this),o?this._erasNameRegex:this._erasRegex}function Zh(o){return Kt(this,"_erasAbbrRegex")||cs.call(this),o?this._erasAbbrRegex:this._erasRegex}function Qh(o){return Kt(this,"_erasNarrowRegex")||cs.call(this),o?this._erasNarrowRegex:this._erasRegex}function as(o,t){return t.erasAbbrRegex(o)}function vh(o,t){return t.erasNameRegex(o)}function Kh(o,t){return t.erasNarrowRegex(o)}function Hh(o,t){return t._eraYearOrdinalRegex||Zn}function cs(){var o=[],t=[],e=[],n=[],i,l,r,a,c,d=this.eras();for(i=0,l=d.length;i<l;++i)r=ze(d[i].name),a=ze(d[i].abbr),c=ze(d[i].narrow),t.push(r),o.push(a),e.push(c),n.push(r),n.push(a),n.push(c);this._erasRegex=new RegExp("^("+n.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+t.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+o.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+e.join("|")+")","i")}gt(0,["gg",2],0,function(){return this.weekYear()%100}),gt(0,["GG",2],0,function(){return this.isoWeekYear()%100});function Bo(o,t){gt(0,[o,o.length],0,t)}Bo("gggg","weekYear"),Bo("ggggg","weekYear"),Bo("GGGG","isoWeekYear"),Bo("GGGGG","isoWeekYear"),dt("G",Uo),dt("g",Uo),dt("GG",qt,Le),dt("gg",qt,Le),dt("GGGG",Gi,ki),dt("gggg",Gi,ki),dt("GGGGG",Yo,Vo),dt("ggggg",Yo,Vo),no(["gggg","ggggg","GGGG","GGGGG"],function(o,t,e,n){t[n.substr(0,2)]=Vt(o)}),no(["gg","GG"],function(o,t,e,n){t[n]=st.parseTwoDigitYear(o)});function _h(o){return el.call(this,o,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function Ah(o){return el.call(this,o,this.isoWeek(),this.isoWeekday(),1,4)}function kh(){return tn(this.year(),1,4)}function Gh(){return tn(this.isoWeekYear(),1,4)}function xh(){var o=this.localeData()._week;return tn(this.year(),o.dow,o.doy)}function Bh(){var o=this.localeData()._week;return tn(this.weekYear(),o.dow,o.doy)}function el(o,t,e,n,i){var l;return o==null?ro(this,n,i).year:(l=tn(o,n,i),t>l&&(t=l),Jh.call(this,o,t,e,n,i))}function Jh(o,t,e,n,i){var l=Dr(o,t,e,n,i),r=so(l.year,0,l.dayOfYear);return this.year(r.getUTCFullYear()),this.month(r.getUTCMonth()),this.date(r.getUTCDate()),this}gt("Q",0,"Qo","quarter"),dt("Q",Lr),Bt("Q",function(o,t){t[je]=(Vt(o)-1)*3});function $h(o){return o==null?Math.ceil((this.month()+1)/3):this.month((o-1)*3+this.month()%3)}gt("D",["DD",2],"Do","date"),dt("D",qt,Qn),dt("DD",qt,Le),dt("Do",function(o,t){return o?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Bt(["D","DD"],xe),Bt("Do",function(o,t){t[xe]=Vt(o.match(qt)[0])});var nl=vn("Date",!0);gt("DDD",["DDDD",3],"DDDo","dayOfYear"),dt("DDD",Wo),dt("DDDD",Pr),Bt(["DDD","DDDD"],function(o,t,e){e._dayOfYear=Vt(o)});function zh(o){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return o==null?t:this.add(o-t,"d")}gt("m",["mm",2],0,"minute"),dt("m",qt,xi),dt("mm",qt,Le),Bt(["m","mm"],De);var jh=vn("Minutes",!1);gt("s",["ss",2],0,"second"),dt("s",qt,xi),dt("ss",qt,Le),Bt(["s","ss"],qe);var qh=vn("Seconds",!1);gt("S",0,0,function(){return~~(this.millisecond()/100)}),gt(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),gt(0,["SSS",3],0,"millisecond"),gt(0,["SSSS",4],0,function(){return this.millisecond()*10}),gt(0,["SSSSS",5],0,function(){return this.millisecond()*100}),gt(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),gt(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),gt(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),gt(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),dt("S",Wo,Lr),dt("SS",Wo,Le),dt("SSS",Wo,Pr);var hn,ol;for(hn="SSSS";hn.length<=9;hn+="S")dt(hn,Zn);function tg(o,t){t[Pn]=Vt(("0."+o)*1e3)}for(hn="S";hn.length<=9;hn+="S")Bt(hn,tg);ol=vn("Milliseconds",!1),gt("z",0,0,"zoneAbbr"),gt("zz",0,0,"zoneName");function eg(){return this._isUTC?"UTC":""}function ng(){return this._isUTC?"Coordinated Universal Time":""}var z=to.prototype;z.add=BR,z.calendar=eh,z.clone=nh,z.diff=ch,z.endOf=Ch,z.format=hh,z.from=gh,z.fromNow=Th,z.to=fh,z.toNow=mh,z.get=Ru,z.invalidAt=Nh,z.isAfter=oh,z.isBefore=ih,z.isBetween=sh,z.isSame=rh,z.isSameOrAfter=lh,z.isSameOrBefore=ah,z.isValid=Sh,z.lang=$r,z.locale=Jr,z.localeData=zr,z.max=SR,z.min=OR,z.parsingFlags=Xh,z.set=hu,z.startOf=ph,z.subtract=JR,z.toArray=Eh,z.toObject=Mh,z.toDate=Ph,z.toISOString=uh,z.inspect=Rh,typeof Symbol<"u"&&Symbol.for!=null&&(z[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),z.toJSON=Oh,z.toString=dh,z.unix=Lh,z.valueOf=Ih,z.creationData=Fh,z.eraName=Vh,z.eraNarrow=Wh,z.eraAbbr=Yh,z.eraYear=Uh,z.year=Or,z.isLeapYear=uu,z.weekYear=_h,z.isoWeekYear=Ah,z.quarter=z.quarters=$h,z.month=yr,z.daysInMonth=Pu,z.week=z.weeks=yu,z.isoWeek=z.isoWeeks=bu,z.weeksInYear=xh,z.weeksInWeekYear=Bh,z.isoWeeksInYear=kh,z.isoWeeksInISOWeekYear=Gh,z.date=nl,z.day=z.days=Au,z.weekday=ku,z.isoWeekday=Gu,z.dayOfYear=zh,z.hour=z.hours=qu,z.minute=z.minutes=jh,z.second=z.seconds=qh,z.millisecond=z.milliseconds=ol,z.utcOffset=YR,z.utc=wR,z.local=ZR,z.parseZone=QR,z.hasAlignedHourOffset=vR,z.isDST=KR,z.isLocal=_R,z.isUtcOffset=AR,z.isUtc=Ar,z.isUTC=Ar,z.zoneAbbr=eg,z.zoneName=ng,z.dates=Me("dates accessor is deprecated. Use date instead.",nl),z.months=Me("months accessor is deprecated. Use month instead",yr),z.years=Me("years accessor is deprecated. Use year instead",Or),z.zone=Me("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",UR),z.isDSTShifted=Me("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",HR);function og(o){return te(o*1e3)}function ig(){return te.apply(null,arguments).parseZone()}function il(o){return o}var Ht=vi.prototype;Ht.calendar=_d,Ht.longDateFormat=xd,Ht.invalidDate=Jd,Ht.ordinal=jd,Ht.preparse=il,Ht.postformat=il,Ht.relativeTime=tu,Ht.pastFuture=eu,Ht.set=Kd,Ht.eras=yh,Ht.erasParse=bh,Ht.erasConvertYear=Dh,Ht.erasAbbrRegex=Zh,Ht.erasNameRegex=wh,Ht.erasNarrowRegex=Qh,Ht.months=pu,Ht.monthsShort=Cu,Ht.monthsParse=Lu,Ht.monthsRegex=Mu,Ht.monthsShortRegex=Eu,Ht.week=Su,Ht.firstDayOfYear=Fu,Ht.firstDayOfWeek=Nu,Ht.weekdays=Qu,Ht.weekdaysMin=Ku,Ht.weekdaysShort=vu,Ht.weekdaysParse=_u,Ht.weekdaysRegex=xu,Ht.weekdaysShortRegex=Bu,Ht.weekdaysMinRegex=Ju,Ht.isPM=zu,Ht.meridiem=tR;function Jo(o,t,e,n){var i=en(),l=Ae().set(n,t);return i[e](l,o)}function sl(o,t,e){if($e(o)&&(t=o,o=void 0),o=o||"",t!=null)return Jo(o,t,e,"month");var n,i=[];for(n=0;n<12;n++)i[n]=Jo(o,n,e,"month");return i}function ds(o,t,e,n){typeof o=="boolean"?($e(t)&&(e=t,t=void 0),t=t||""):(t=o,e=t,o=!1,$e(t)&&(e=t,t=void 0),t=t||"");var i=en(),l=o?i._week.dow:0,r,a=[];if(e!=null)return Jo(t,(e+l)%7,n,"day");for(r=0;r<7;r++)a[r]=Jo(t,(r+l)%7,n,"day");return a}function sg(o,t){return sl(o,t,"months")}function rg(o,t){return sl(o,t,"monthsShort")}function lg(o,t,e){return ds(o,t,e,"weekdays")}function ag(o,t,e){return ds(o,t,e,"weekdaysShort")}function cg(o,t,e){return ds(o,t,e,"weekdaysMin")}Rn("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(o){var t=o%10,e=Vt(o%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return o+e}}),st.lang=Me("moment.lang is deprecated. Use moment.locale instead.",Rn),st.langData=Me("moment.langData is deprecated. Use moment.localeData instead.",en);var nn=Math.abs;function dg(){var o=this._data;return this._milliseconds=nn(this._milliseconds),this._days=nn(this._days),this._months=nn(this._months),o.milliseconds=nn(o.milliseconds),o.seconds=nn(o.seconds),o.minutes=nn(o.minutes),o.hours=nn(o.hours),o.months=nn(o.months),o.years=nn(o.years),this}function rl(o,t,e,n){var i=Ve(t,e);return o._milliseconds+=n*i._milliseconds,o._days+=n*i._days,o._months+=n*i._months,o._bubble()}function ug(o,t){return rl(this,o,t,1)}function Rg(o,t){return rl(this,o,t,-1)}function ll(o){return o<0?Math.floor(o):Math.ceil(o)}function hg(){var o=this._milliseconds,t=this._days,e=this._months,n=this._data,i,l,r,a,c;return o>=0&&t>=0&&e>=0||o<=0&&t<=0&&e<=0||(o+=ll(us(e)+t)*864e5,t=0,e=0),n.milliseconds=o%1e3,i=Se(o/1e3),n.seconds=i%60,l=Se(i/60),n.minutes=l%60,r=Se(l/60),n.hours=r%24,t+=Se(r/24),c=Se(al(t)),e+=c,t-=ll(us(c)),a=Se(e/12),e%=12,n.days=t,n.months=e,n.years=a,this}function al(o){return o*4800/146097}function us(o){return o*146097/4800}function gg(o){if(!this.isValid())return NaN;var t,e,n=this._milliseconds;if(o=Oe(o),o==="month"||o==="quarter"||o==="year")switch(t=this._days+n/864e5,e=this._months+al(t),o){case"month":return e;case"quarter":return e/3;case"year":return e/12}else switch(t=this._days+Math.round(us(this._months)),o){case"week":return t/7+n/6048e5;case"day":return t+n/864e5;case"hour":return t*24+n/36e5;case"minute":return t*1440+n/6e4;case"second":return t*86400+n/1e3;case"millisecond":return Math.floor(t*864e5)+n;default:throw new Error("Unknown unit "+o)}}function on(o){return function(){return this.as(o)}}var cl=on("ms"),Tg=on("s"),fg=on("m"),mg=on("h"),pg=on("d"),Cg=on("w"),Ig=on("M"),Lg=on("Q"),Pg=on("y"),Eg=cl;function Mg(){return Ve(this)}function Og(o){return o=Oe(o),this.isValid()?this[o+"s"]():NaN}function Mn(o){return function(){return this.isValid()?this._data[o]:NaN}}var Sg=Mn("milliseconds"),Xg=Mn("seconds"),Ng=Mn("minutes"),Fg=Mn("hours"),yg=Mn("days"),bg=Mn("months"),Dg=Mn("years");function Vg(){return Se(this.days()/7)}var sn=Math.round,An={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Wg(o,t,e,n,i){return i.relativeTime(t||1,!!e,o,n)}function Yg(o,t,e,n){var i=Ve(o).abs(),l=sn(i.as("s")),r=sn(i.as("m")),a=sn(i.as("h")),c=sn(i.as("d")),d=sn(i.as("M")),u=sn(i.as("w")),R=sn(i.as("y")),h=l<=e.ss&&["s",l]||l<e.s&&["ss",l]||r<=1&&["m"]||r<e.m&&["mm",r]||a<=1&&["h"]||a<e.h&&["hh",a]||c<=1&&["d"]||c<e.d&&["dd",c];return e.w!=null&&(h=h||u<=1&&["w"]||u<e.w&&["ww",u]),h=h||d<=1&&["M"]||d<e.M&&["MM",d]||R<=1&&["y"]||["yy",R],h[2]=t,h[3]=+o>0,h[4]=n,Wg.apply(null,h)}function Ug(o){return o===void 0?sn:typeof o=="function"?(sn=o,!0):!1}function wg(o,t){return An[o]===void 0?!1:t===void 0?An[o]:(An[o]=t,o==="s"&&(An.ss=t-1),!0)}function Zg(o,t){if(!this.isValid())return this.localeData().invalidDate();var e=!1,n=An,i,l;return typeof o=="object"&&(t=o,o=!1),typeof o=="boolean"&&(e=o),typeof t=="object"&&(n=Object.assign({},An,t),t.s!=null&&t.ss==null&&(n.ss=t.s-1)),i=this.localeData(),l=Yg(this,!e,n,i),e&&(l=i.pastFuture(+this,l)),i.postformat(l)}var Rs=Math.abs;function kn(o){return(o>0)-(o<0)||+o}function $o(){if(!this.isValid())return this.localeData().invalidDate();var o=Rs(this._milliseconds)/1e3,t=Rs(this._days),e=Rs(this._months),n,i,l,r,a=this.asSeconds(),c,d,u,R;return a?(n=Se(o/60),i=Se(n/60),o%=60,n%=60,l=Se(e/12),e%=12,r=o?o.toFixed(3).replace(/\.?0+$/,""):"",c=a<0?"-":"",d=kn(this._months)!==kn(a)?"-":"",u=kn(this._days)!==kn(a)?"-":"",R=kn(this._milliseconds)!==kn(a)?"-":"",c+"P"+(l?d+l+"Y":"")+(e?d+e+"M":"")+(t?u+t+"D":"")+(i||n||o?"T":"")+(i?R+i+"H":"")+(n?R+n+"M":"")+(o?R+r+"S":"")):"P0D"}var Ut=_o.prototype;Ut.isValid=bR,Ut.abs=dg,Ut.add=ug,Ut.subtract=Rg,Ut.as=gg,Ut.asMilliseconds=cl,Ut.asSeconds=Tg,Ut.asMinutes=fg,Ut.asHours=mg,Ut.asDays=pg,Ut.asWeeks=Cg,Ut.asMonths=Ig,Ut.asQuarters=Lg,Ut.asYears=Pg,Ut.valueOf=Eg,Ut._bubble=hg,Ut.clone=Mg,Ut.get=Og,Ut.milliseconds=Sg,Ut.seconds=Xg,Ut.minutes=Ng,Ut.hours=Fg,Ut.days=yg,Ut.weeks=Vg,Ut.months=bg,Ut.years=Dg,Ut.humanize=Zg,Ut.toISOString=$o,Ut.toString=$o,Ut.toJSON=$o,Ut.locale=Jr,Ut.localeData=zr,Ut.toIsoString=Me("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",$o),Ut.lang=$r,gt("X",0,0,"unix"),gt("x",0,0,"valueOf"),dt("x",Uo),dt("X",su),Bt("X",function(o,t,e){e._d=new Date(parseFloat(o)*1e3)}),Bt("x",function(o,t,e){e._d=new Date(Vt(o))});st.version="2.30.1",Qd(te),st.fn=z,st.min=XR,st.max=NR,st.now=FR,st.utc=Ae,st.unix=og,st.months=sg,st.isDate=qn,st.locale=Rn,st.invalid=yo,st.duration=Ve,st.isMoment=be,st.weekdays=lg,st.parseZone=ig,st.localeData=en,st.isDuration=Ao,st.monthsShort=rg,st.weekdaysMin=cg,st.defineLocale=qi,st.updateLocale=iR,st.locales=sR,st.weekdaysShort=ag,st.normalizeUnits=Oe,st.relativeTimeRounding=Ug,st.relativeTimeThreshold=wg,st.calendarFormat=th,st.prototype=z,st.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};class hs{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),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();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),l=t?null:i.getTd();n>=e.length&&(n=e.length-1);const r=e[n],a=[];let c=l,d=e,u=n;for(;;){if(u<0&&c?.linkTdPrevId){const f=i.getTdById(c.linkTdPrevId);if(f){d=f.value,u=d.length-1,c=f;continue}}if(u<0)break;const T=d[u];if(T.controlId!==r.controlId||T.controlComponent===s.ControlComponent.PREFIX||T.controlComponent===s.ControlComponent.PRE_TEXT)break;T.controlComponent===s.ControlComponent.VALUE&&a.unshift(T),u--}c=l;let R=e,h=n+1;for(;;){if(h>=R.length&&c?.linkTdNextId){const f=i.getTdById(c.linkTdNextId);if(f){R=f.value,h=0,c=f;continue}}const T=R[h];if(!T||T.controlId!==r.controlId||T.controlComponent===s.ControlComponent.POSTFIX||T.controlComponent===s.ControlComponent.POST_TEXT)break;T.controlComponent===s.ControlComponent.VALUE&&a.push(T),h++}return a.filter(T=>T.type!==s.ElementType.SPLIT_TAG)}removeNextControlElement(t,e){const n=this.control.getDraw();if(e=e??n.getTd()?.linkTdNextId,e){const i=n.getTdById(e);if(i){if(i.value.length){if(i.value[1].controlId===t)return n.spliceElementList(i.value,1,1),i.value[1]}else if(i.linkTdNextId)return this.removeNextControlElement(t,i.linkTdNextId)}}}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const i=e.range||this.control.getRange(),l=e.elementList||this.control.getElementList(),r=l[i.startIndex],a=l[i.startIndex+1],c=V=>!!(V&&(V.controlComponent===s.ControlComponent.POSTFIX||V.controlComponent===s.ControlComponent.POST_TEXT||V.controlComponent===s.ControlComponent.POSTTEXTFIX||V.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)),d=!!(r?.originControlId&&c(r)&&a?.controlId===r.originControlId&&!a.originControlId&&a.control?.type===s.ControlType.TEXTFIELD&&c(a));let u=this.element.controlId||r?.controlId,R=this.element.originControlId||(this.element.controlId===r?.controlId?r?.originControlId:void 0),h=this.element.control||r.control;const g=!!(r?.controlId&&r.controlId!==this.element.controlId&&!r.originControlId&&r.control?.type===s.ControlType.TEXTFIELD);d?(u=r.originControlId,R=void 0,h=a.control):g&&(u=r.controlId,R=void 0,h=r.control);const T=!!u&&r?.controlId!==u&&this._findNearestTextAncestorId(l,r?.originControlId)===u;!T&&!d&&!g&&(this.control.mergeControl(e),this.control.shrinkBoundary(e));const{startIndex:f,endIndex:m}=i,C=this.control.getDraw();f!==m?C.spliceElementList(l,f+1,m-f,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):T||d||g?this._removePlaceholdersByControl(l,u,R||null):this.control.removePlaceholder(f,{elementList:l});const I=l[f];T||d||g?this._removePlaceholdersByControl(l,u,R||null):this._removeControlPlaceholders(l,f);const p=I.type&&!Ie.includes(I.type)||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRE_TEXT?ie(I,["control","controlId","originControlId",...ue]):Ce(I,["type"]),L=T||d||g,M=V=>{ue.forEach(E=>{delete V[E];const y=h?.[E];y!==void 0&&(V[E]=y)}),delete V.underline,delete V.textDecoration,h?.type===s.ControlType.TEXT&&V.color?.toLowerCase()==="#87d068"?V.color=this.options.defaultColor:V.color||(V.color=this.options.defaultColor)};L&&M(p),p.controlId=u,h&&(p.control=h),R?p.originControlId=R:delete p.originControlId;const O=this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.inputTraceEnabled,b=i.startIndex+1,D=[],W=V=>{const E=D.length?D:l,y=D.length?D.length-1:d?i.startIndex+1:i.startIndex;re(E,[V],y,{editorOptions:this.options}),D.push(V)};for(let V=0;V<t.length;V++){const E=t[V];if(E.type===s.ElementType.CONTROL&&E.control){const y=E,F=y.controlId||Tt(),S=y.control?.value||[],N=y.control?.type===s.ControlType.TEXTFIELD,Y={...Ce(p,["underline","textDecoration"]),controlId:F,type:s.ElementType.CONTROL,control:y.control,originControlId:u},X=N?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,U=N?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,Q=N?y.control?.preTextFix||this.options.control.preTextFix:y.control?.prefix||this.options.control.prefix;for(let w=0;w<Q.length;w++){const j={...Y,value:Q[w],controlComponent:X};W(j)}for(let w=0;w<S.length;w++){const j=S[w],J={...Y,...j,controlComponent:s.ControlComponent.VALUE};(J.color===this.options.control.bracketColor||J.color===this.options.control.placeholderColor)&&(J.color=this.options.defaultColor),W(J)}if(S.length===0){const w=y.control?.placeholder||"";for(let j=0;j<w.length;j++){const J={...Y,value:w[j],controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};W(J)}}const v=N?y.control?.postTextFix||this.options.control.postTextFix:y.control?.postfix||this.options.control.postfix;for(let w=0;w<v.length;w++){const j={...Y,value:v[w],controlComponent:U};W(j)}}else if(E.type||E.value){(I.controlComponent===s.ControlComponent.PRE_TEXT||I.controlComponent===s.ControlComponent.POST_TEXT||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.POSTFIX)&&(p.color=this.options.defaultColor);const F=Ce(E,["control","controlId","controlComponent","originControlId"]),S={...p,...F,controlComponent:s.ControlComponent.VALUE};L&&M(S),(S.color===this.options.control.bracketColor||S.color===this.options.control.placeholderColor||S.color===this.options.control.textFixColor)&&(S.color=this.options.defaultColor),S.strikeout&&delete S.strikeout,O&&(S.textDecoration={style:s.TextDecorationStyle.DOUBLE},S.underline=!0),W(S)}}return D.length&&C.spliceElementList(l,b,0,D),i.startIndex+D.length}_removeControlPlaceholders(t,e){const n=t[e];if(!n?.controlId)return;const i=a=>!!a&&a.controlId===n.controlId&&a.originControlId===n.originControlId;let l=e;for(;l>=0&&i(t[l]);)l--;let r=e+1;for(;r<t.length&&i(t[r]);)r++;for(let a=r-1;a>l;a--)t[a].controlComponent===s.ControlComponent.PLACEHOLDER&&t.splice(a,1)}_removePlaceholdersByControl(t,e,n){if(e)for(let i=t.length-1;i>=0;i--){const l=t[i];l.controlId===e&&(l.originControlId||null)===n&&l.controlComponent===s.ControlComponent.PLACEHOLDER&&t.splice(i,1)}}_findNearestTextAncestorId(t,e){if(!e)return null;const n=new Set;let i=e,l=null;for(;i&&!n.has(i);){n.add(i);let r;for(let a=0;a<t.length;a++){const c=t[a];if(c.controlId===i&&c.control?.type&&(r=c,c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRE_TEXT||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!r)break;(r.control?.type===s.ControlType.TEXT||this.options.mode===s.EditorMode.EDIT&&r.control?.type===s.ControlType.TEXTFIELD)&&(l=i),i=r.originControlId||null}return l}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange();this.control.shrinkBoundary(t);const{startIndex:l,endIndex:r}=i;return this.control.getDraw().spliceElementList(n,l+1,r-l,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),e.isAddPlaceholder!==!1&&(this.getValue(t).length||this.control.addPlaceholder(l,t)),l}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.control.getDraw(),d=this.options.mode===s.EditorMode.FORM,u=this.element.controlId||r.controlId,R=this.element.originControlId||r.originControlId||null,h=P=>{if(!P)return null;const Y=new Set;let X=P,U=null;for(;X&&!Y.has(X);){Y.add(X);let Q;for(let v=0;v<e.length;v++){const w=e[v];if(w.controlId===X&&w.control?.type&&(Q=w,w.controlComponent===s.ControlComponent.PREFIX||w.controlComponent===s.ControlComponent.PRE_TEXT||w.controlComponent===s.ControlComponent.PRETEXTFIX||w.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!Q)break;(Q.control?.type===s.ControlType.TEXT||this.options.mode===s.EditorMode.EDIT&&Q.control?.type===s.ControlType.TEXTFIELD)&&(U=X),X=Q.originControlId||null}return U},g=h(R),T=!!g,f=r.controlId===u&&(r.originControlId||null)===R,m=r.controlComponent===s.ControlComponent.VALUE,C=P=>{for(let Y=i-1;Y>=0;Y--){const X=e[Y];if(X.controlId===P&&!X.originControlId){if(X.controlComponent===s.ControlComponent.VALUE||X.controlComponent===s.ControlComponent.PLACEHOLDER)return Y;if(X.controlComponent===s.ControlComponent.PREFIX||X.controlComponent===s.ControlComponent.PRE_TEXT||X.controlComponent===s.ControlComponent.PRETEXTFIX||X.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)break}if(X.controlId&&X.controlId!==P&&X.originControlId!==P)break}return-1},I=(P,Y)=>{for(let X=P;X>=0;X--){const U=e[X];if(U.controlId===Y&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.PREFIX||U.controlComponent===s.ControlComponent.PRE_TEXT||U.controlComponent===s.ControlComponent.PRETEXTFIX||U.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))return X;if(U.controlId&&U.controlId!==Y&&U.originControlId!==Y)break}for(let X=P+1;X<e.length;X++){const U=e[X];if(U.controlId===Y&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.POSTFIX||U.controlComponent===s.ControlComponent.POST_TEXT||U.controlComponent===s.ControlComponent.POSTTEXTFIX||U.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return X;if(U.controlId&&U.controlId!==Y&&U.originControlId!==Y)break}return P},L=T&&f&&(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PRETEXTFIX||r.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.TEXTFIXLABEL),M=e[l+1],O=!!M?.originControlId&&!!M?.controlId&&M.originControlId!==M.controlId&&(M.controlComponent===s.ControlComponent.PREFIX||M.controlComponent===s.ControlComponent.PRE_TEXT||M.controlComponent===s.ControlComponent.PRETEXTFIX||M.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||M.controlComponent===s.ControlComponent.PLACEHOLDER||M.controlComponent===s.ControlComponent.TEXTFIXLABEL),b=!!M?.originControlId&&!!M?.controlId&&M.originControlId!==M.controlId&&(M.controlComponent===s.ControlComponent.PREFIX||M.controlComponent===s.ControlComponent.PRE_TEXT||M.controlComponent===s.ControlComponent.PRETEXTFIX||M.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||M.controlComponent===s.ControlComponent.POSTFIX||M.controlComponent===s.ControlComponent.POST_TEXT||M.controlComponent===s.ControlComponent.POSTTEXTFIX||M.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||M.controlComponent===s.ControlComponent.PLACEHOLDER||M.controlComponent===s.ControlComponent.TEXTFIXLABEL),D=P=>this.options.mode===s.EditorMode.FORM?i:this.control.removeControl(P),W=r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId&&!!M?.originControlId&&!!u&&h(M.originControlId)===u,V=P=>!!P&&P.controlId===r.controlId&&(P.originControlId||null)===(r.originControlId||null),E=P=>P?.controlComponent===s.ControlComponent.POSTFIX||P?.controlComponent===s.ControlComponent.POST_TEXT||P?.controlComponent===s.ControlComponent.POSTTEXTFIX||P?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT,y=()=>{const P=r.controlId,Y=r.originControlId||null;return c.spliceElementList(e,i,1),e.some(U=>U.controlId===P&&(U.originControlId||null)===Y&&U.controlComponent===s.ControlComponent.VALUE)||this.control.addPlaceholder(i-1),Math.max(i-1,0)},F=r.controlComponent===s.ControlComponent.VALUE&&!!r.originControlId&&V(M)&&E(M),S=!!u&&!this.control.getIsExistValueByElementListIndex(e,i),N=()=>{if(r.controlComponent!==s.ControlComponent.VALUE)return null;let P=i;for(let U=i;U>=0;U--){const Q=e[U];if(!(Q.controlId===r.controlId&&(Q.originControlId||null)===(r.originControlId||null))||Q.controlComponent!==s.ControlComponent.VALUE)break;if(!Q.strikeout){P=U;break}}const Y=e[P];if(!Y||Y.strikeout)return null;Y.strikeout=!0,Y.deletePerson="SWJ",Y.deleteTime=st(new Date).format("YYYY-MM-DD HH:mm:ss");let X=Math.max(P-1,0);for(let U=P-1;U>=0;U--){const Q=e[U];if(!(Q.controlId===Y.controlId&&(Q.originControlId||null)===(Y.originControlId||null))){X=U;break}if(Q.controlComponent!==s.ControlComponent.VALUE){X=U;break}if(!Q.strikeout){X=U;break}X=Math.max(U-1,0)}return this.draws.render({curIndex:X,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),queueMicrotask(()=>{this.ranges.setRange(X,X),this.draws.setCursor(X)}),X};if(t.key===s.KeyMap.Backspace){if(i===l&&S&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return i;if(d&&i===l&&g&&!f&&(r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)){const Y=C(g);return Y>=0?Y:i}if(i===l&&L&&!(d&&r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId))return D(i);if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!T||m)){if(i===l&&r.controlComponent===s.ControlComponent.VALUE){const Y=N();if(Y!==null)return Y}return r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?i:this.strikeout()}else{if(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER)return i;if(i!==l){c.spliceElementList(e,i+1,l-i);const Y=e[i+1];return(Y?.controlComponent===s.ControlComponent.POSTFIX||Y?.controlComponent===s.ControlComponent.POST_TEXT||Y?.controlComponent===s.ControlComponent.POSTTEXTFIX||Y?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(i),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i}else{const Y=e[i-1],X=e[i+1];return!r.originControlId&&Y?.controlId===r.controlId&&Y?.originControlId===r.originControlId&&Y?.controlComponent===s.ControlComponent.VALUE&&(r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.options.mode!==s.EditorMode.FORM?(c.spliceElementList(e,i-1,1),this.getValue().length||this.control.addPlaceholder(i-2),i-2):E(X)?X.originControlId?F?y():W?(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):D(i):(c.spliceElementList(e,i,1),this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):(c.spliceElementList(e,i,1),i===1&&e[0].type===s.ElementType.SPLIT_TAG||i===0?c.fixPosition(!0)??i-1:I(Math.max(i-1,0),r.controlId))}}}else if(t.key===s.KeyMap.Delete){if(i===l&&S&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return l;if(i===l&&(O||b)){if(W){const U=e[l+1];if(U?.controlComponent===s.ControlComponent.VALUE&&U.controlId===r.controlId&&!U.originControlId)return c.spliceElementList(e,l+1,1),this.getValue().length||this.control.addPlaceholder(i),i}return D(l+1)}const P=e[l+1],Y=!!r.originControlId;if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!Y||r.controlComponent===s.ControlComponent.VALUE))return a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||a.controlComponent===s.ControlComponent.POSTTEXTFIX||a.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?l:P?.controlComponent===s.ControlComponent.POSTFIX||P?.controlComponent===s.ControlComponent.POST_TEXT||P?.controlComponent===s.ControlComponent.POSTTEXTFIX||P?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?P.originControlId?W?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):D(i+1):(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):this.strikeout();{const U=e[l+1];return r.controlComponent===s.ControlComponent.PLACEHOLDER?l:U?.controlComponent===s.ControlComponent.POSTFIX||U?.controlComponent===s.ControlComponent.POST_TEXT||U?.controlComponent===s.ControlComponent.POSTTEXTFIX||U?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?U.originControlId?W?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):D(i+1):(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):i!==l?(c.spliceElementList(e,i+1,l-i),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):U?(c.spliceElementList(e,i+1,1),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):(c.getTd()?.linkTdNextId&&r.controlId&&this.removeNextControlElement(r.controlId),l)}}return l}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();n.spliceElementList(i,t+1,e-t);const l=i[t+1];return(l?.controlComponent===s.ControlComponent.POSTFIX||l?.controlComponent===s.ControlComponent.POST_TEXT||l?.controlComponent===s.ControlComponent.POSTTEXTFIX||l?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(t),t}strikeout(t){const e=this.control.getRange(),{endIndex:n}=e,{isIgnoreDisabledRule:i=!1}=t||{};if(!i&&(this.draws.isReadonly()||this.draws.isDisabled()))return null;const r=this.ranges.getSelectionElementList(),a=this.position.getCursorPosition(),c=st(new Date).format("YYYY-MM-DD HH:mm:ss"),d=h=>{queueMicrotask(()=>{this.ranges.setRange(h,h),this.draws.setCursor(h),this.options.mode===s.EditorMode.FORM&&console.log("[text-sync-trace-cursor]",{index:h,range:this.ranges.getRange(),cursorIndex:this.position.getCursorPosition()?.index})})},u=h=>{const g=this.control.getElementList(),T=g[h],f=T?.controlId,m=T?.originControlId||null;let C=-1;for(let I=h-1;I>=0;I--){const p=g[I];if(p.controlId===f&&(p.originControlId||null)===m&&p.controlComponent===s.ControlComponent.VALUE)return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:I,reason:"prev-value"}),I;if(m){if(p.controlId&&p.controlId!==f&&p.originControlId!==m)break}else{if(p.controlId===f&&(p.controlComponent===s.ControlComponent.PREFIX||p.controlComponent===s.ControlComponent.PRE_TEXT||p.controlComponent===s.ControlComponent.PRETEXTFIX||p.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){C=I;break}if(p.controlId&&p.controlId!==f&&!p.originControlId)break;if(p.originControlId===f&&(p.controlComponent===s.ControlComponent.POSTFIX||p.controlComponent===s.ControlComponent.POST_TEXT||p.controlComponent===s.ControlComponent.POSTTEXTFIX||p.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:I,reason:"nested-postfix"}),I}}if(C>=0){const I=C+1,p=g[I];return p?.controlId===f&&(p.controlComponent===s.ControlComponent.PLACEHOLDER||p.controlComponent===s.ControlComponent.VALUE)?(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:I,reason:"prefix-next-editable"}),I):(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:C,reason:"prefix"}),C)}return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:h,reason:"self"}),h},R=h=>{const g=this.control.getElementList(),T=g[h];if(!T?.controlId||T.controlComponent===s.ControlComponent.VALUE&&(T.metrics?.width??0)>0)return h;for(let f=h+1;f<g.length;f++){const m=g[f];if(m.controlId!==T.controlId||(m.originControlId||null)!==(T.originControlId||null))break;if(m.controlComponent===s.ControlComponent.VALUE&&(m.metrics?.width??0)>0)return f}for(let f=h-1;f>=0;f--){const m=g[f];if(m.controlId!==T.controlId||(m.originControlId||null)!==(T.originControlId||null))break;if(m.controlComponent===s.ControlComponent.VALUE&&(m.metrics?.width??0)>0)return f}return h};if(r?.length){if(!this.element.strikeout){const h=r.findIndex(g=>!g.strikeout);return r.forEach(g=>{g.deletePerson="SWJ",g.deleteTime=c,g.strikeout=!!~h}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),this.control.getRange().endIndex??null}}else{const h=R(a.index),g=this.control.getElementList()[h],T=this.control.getElementList();if(this.options.mode===s.EditorMode.FORM&&console.log("[text-strikeout]",{cursorIndex:a.index,targetIndex:h,targetValue:g?.value,targetComponent:g?.controlComponent,targetControlId:g?.controlId,targetOriginControlId:g?.originControlId||null}),!this.control.getElementList()[h].strikeout&&g?.metrics.width>0){this.control.getElementList()[h].strikeout=!0,this.control.getElementList()[h].deletePerson="SWJ",this.control.getElementList()[h].deleteTime=c;const f=u(h);return this.options.mode===s.EditorMode.FORM&&console.log("[text-strikeout:after]",{targetIndex:h,newIndex:f}),this.ranges.setRange(f,f),this.draws.render({curIndex:f,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),d(f),f??null}else if(n>=0&&n<T.length&&T[n]?.metrics?.width!==void 0&&T[n].metrics.width<=0&&!T[n]?.strikeout){T.splice(n,1);const f=n-1;return this.ranges.setRange(f,f),this.draws.render({curIndex:f,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),d(f),f??null}}return n??null}strikeoute(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draws.isReadonly()||this.draws.isDisabled()))return;if(!this.ranges.getSelectionElementList()?.length){const{endIndex:l}=this.ranges.getRange(),a=this.draws.getElementList()[l];this.ranges.setDefaultStyle({strikeout:a.strikeout?!1:!this.ranges.getDefaultStyle()?.strikeout})}}}class dl{draw;options;now;dom;renderOptions;isDatePicker;pickDate;lang;constructor(t,e={}){this.draw=t,this.options=e,this.lang=this._getLang(),this.now=new Date,this.dom=this._createDom(),this.renderOptions=null,this.isDatePicker=!0,this.pickDate=null,this._bindEvent()}_createDom(){const t=document.createElement("div");t.classList.add(`${tt}-date-container`),t.setAttribute(Ue,s.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${tt}-date-wrap`);const n=document.createElement("div");n.classList.add(`${tt}-date-title`);const i=document.createElement("span");i.classList.add(`${tt}-date-title__pre-year`),i.innerText="<<";const l=document.createElement("span");l.classList.add(`${tt}-date-title__pre-month`),l.innerText="<";const r=document.createElement("span");r.classList.add(`${tt}-date-title__now`);const a=document.createElement("span");a.classList.add(`${tt}-date-title__next-month`),a.innerText=">";const c=document.createElement("span");c.classList.add(`${tt}-date-title__next-year`),c.innerText=">>",n.append(i),n.append(l),n.append(r),n.append(a),n.append(c);const d=document.createElement("div");d.classList.add(`${tt}-date-week`);const{weeks:{sun:u,mon:R,tue:h,wed:g,thu:T,fri:f,sat:m}}=this.lang;[u,R,h,g,T,f,m].forEach(y=>{const F=document.createElement("span");F.innerText=`${y}`,d.append(F)});const I=document.createElement("div");I.classList.add(`${tt}-date-day`),e.append(n),e.append(d),e.append(I);const p=document.createElement("ul");p.classList.add(`${tt}-time-wrap`);let L,M,O;[this.lang.hour,this.lang.minute,this.lang.second].forEach((y,F)=>{const S=document.createElement("li"),N=document.createElement("span");N.innerText=y,S.append(N);const P=document.createElement("ol"),Y=F===0,X=F===1,U=Y?24:60;for(let Q=0;Q<U;Q++){const v=document.createElement("li");v.innerText=`${String(Q).padStart(2,"0")}`,v.setAttribute("data-id",`${Q}`),P.append(v)}Y?L=P:X?M=P:O=P,S.append(P),p.append(S)});const D=document.createElement("div");D.classList.add(`${tt}-date-menu`);const W=document.createElement("button");W.classList.add(`${tt}-date-menu__time`),W.innerText=this.lang.timeSelect;const V=document.createElement("button");V.classList.add(`${tt}-date-menu__now`),V.innerText=this.lang.now;const E=document.createElement("button");return E.classList.add(`${tt}-date-menu__submit`),E.innerText=this.lang.confirm,D.append(W),D.append(V),D.append(E),t.append(e),t.append(p),t.append(D),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:d,timeWrap:p,title:{preYear:i,preMonth:l,now:r,nextMonth:a,nextYear:c},day:I,time:{hour:L,minute:M,second:O},menu:{time:W,now:V,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:i}}=this.renderOptions,l=this.draw.getHeight(),r=this.draw.getPageGap(),c=(i??this.draw.getPageNo())*(l+r);this.dom.container.style.left=`${t}px`,this.dom.container.style.top=`${e+c+n}px`}isInvalidDate(t){return t.toDateString()==="Invalid Date"}_setValue(){const t=this.renderOptions?.value;if(t){const e=new Date(t);this.now=this.isInvalidDate(e)?new Date:e}else this.now=new Date;this.pickDate=new Date(this.now)}_getLang(){const t=this.draw.getI18n(),e=t.t.bind(t);return{now:e("datePicker.now"),confirm:e("datePicker.confirm"),return:e("datePicker.return"),timeSelect:e("datePicker.timeSelect"),weeks:{sun:e("datePicker.weeks.sun"),mon:e("datePicker.weeks.mon"),tue:e("datePicker.weeks.tue"),wed:e("datePicker.weeks.wed"),thu:e("datePicker.weeks.thu"),fri:e("datePicker.weeks.fri"),sat:e("datePicker.weeks.sat")},year:e("datePicker.year"),month:e("datePicker.month"),hour:e("datePicker.hour"),minute:e("datePicker.minute"),second:e("datePicker.second")}}_setLangChange(){this.dom.menu.time.innerText=this.lang.timeSelect,this.dom.menu.now.innerText=this.lang.now,this.dom.menu.submit.innerText=this.lang.confirm;const{weeks:{sun:t,mon:e,tue:n,wed:i,thu:l,fri:r,sat:a}}=this.lang,c=[t,e,n,i,l,r,a];this.dom.datePickerWeek.childNodes.forEach((h,g)=>{const T=h;T.innerText=c[g]});const d=this.dom.time.hour.previousElementSibling;d.innerText=this.lang.hour;const u=this.dom.time.minute.previousElementSibling;u.innerText=this.lang.minute;const R=this.dom.time.second.previousElementSibling;R.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),n=t.getMonth()+1,i=t.getDate();let l=null,r=null,a=null;this.pickDate&&(l=this.pickDate.getFullYear(),r=this.pickDate.getMonth()+1,a=this.pickDate.getDate());const c=this.now.getFullYear(),d=this.now.getMonth()+1;this.dom.title.now.innerText=`${c}${this.lang.year} ${String(d).padStart(2,"0")}${this.lang.month}`;const R=new Date(c,d,0).getDate();let h=new Date(c,d-1,1).getDay();h===0&&(h=7);const g=new Date(c,d-1,0).getDate();this.dom.day.innerHTML="";const T=g-h+1;for(let m=T;m<=g;m++){const C=document.createElement("div");C.classList.add("disable"),C.innerText=`${m}`,C.onclick=()=>{const I=d-2;this.now=new Date(c,I,m),this._setDatePick(c,I,m)},this.dom.day.append(C)}for(let m=1;m<=R;m++){const C=document.createElement("div");e===c&&n===d&&i===m&&C.classList.add("active"),this.pickDate&&l===c&&r===d&&a===m&&C.classList.add("select"),C.innerText=`${m}`,C.onclick=I=>{const p=d-1;this.now=new Date(c,p,m),this._setDatePick(c,p,m),I.stopPropagation()},this.dom.day.append(C)}const f=42-h-R;for(let m=1;m<=f;m++){const C=document.createElement("div");C.classList.add("disable"),C.innerText=`${m}`,C.onclick=()=>{this.now=new Date(c,d,m),this._setDatePick(c,d,m)},this.dom.day.append(C)}}_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){this.now=new Date(t,e,n),this.pickDate?.setFullYear(t),this.pickDate?.setMonth(e),this.pickDate?.setDate(n),this._update()}_setTimePick(t=!0){const e=this.pickDate?.getHours()||0,n=this.pickDate?.getMinutes()||0,i=this.pickDate?.getSeconds()||0,{hour:l,minute:r,second:a}=this.dom.time;[l,r,a].forEach(u=>{u.querySelectorAll("li").forEach(R=>R.classList.remove("active"))}),[[l,e],[r,n],[a,i]].forEach(([u,R])=>{const h=u.querySelector(`[data-id='${R}']`);h.classList.add("active"),t&&Ns(u,h)})}_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(){if(this.options.onSubmit&&this.pickDate){const t=this.renderOptions?.dateFormat,e=this.formatDate(this.pickDate,t);this.options.onSubmit(e)}}formatDate(t,e="YYYY-MM-DD HH:mm:ss"){let n=e;const i=t.getFullYear().toString(),l=(t.getMonth()+1).toString(),r=t.getDate().toString(),a=t.getHours(),c=a%12===0?12:a%12,d=t.getMinutes().toString(),u=t.getSeconds().toString(),R=t.getMilliseconds().toString(),h={"y+":i,"Y+":i,"M+":l,"d+":r,"D+":r,"h+":c.toString(),"H+":a.toString(),"m+":d,"s+":u,"S+":R};for(const g in h){const T=new RegExp("("+g+")").exec(e),f=g;T&&(n=n.replace(T[1],T[1].length===1?h[f]:h[f].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 uo{draw;element;control;isPopup;datePicker;options;constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:l,endIndex:r}=n;for(let a=l;a<=r;a++){const c=e[a];c.controlComponent===s.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:r,endIndex:a}=l,c=this.control.getDraw();r!==a?c.spliceElementList(i,r+1,a-r):this.control.removePlaceholder(r,{elementList:i});const d=i[r],u=d.type&&!Ie.includes(d.type)||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT?ie(d,["control","controlId",...ue]):Ce(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};re(i,[g],r,{editorOptions:this.options}),c.spliceElementList(i,R+h,0,[g])}return R+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const l=this.control.getValueRange(t);if(!l)return-1;const{startIndex:r,endIndex:a}=l;if(!~r||!~a)return-1;const c=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(c,r+1,a-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(r,t),r}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),r=this.getValue(e)[0],a=r?ie(r,Ne):ie(i[l.startIndex],ue),c=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~c)return;const d=Ce(i[c],Ne),u=c+1,R=this.control.getDraw();for(let h=0;h<t.length;h++){const g={...a,...d,type:s.ElementType.TEXT,value:t[h],controlComponent:s.ControlComponent.VALUE};(g.color===this.options.control.bracketColor||g.color===this.options.control.placeholderColor)&&(g.color=this.options.defaultColor),re(i,[g],c,{editorOptions:this.options}),R.spliceElementList(i,u+h,0,[g])}if(!e.range){const h=u+t.length-1;this.control.repaintControl({curIndex:h}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.control.getDraw();if(t.key===s.KeyMap.Backspace)return i!==l?(c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key===s.KeyMap.Delete){if(i!==l)return c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i;{const d=e[l+1];return(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT)&&d.controlComponent===s.ControlComponent.PLACEHOLDER||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}}return l}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){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(e[n+1]?.controlId!==this.element.controlId)return;this.datePicker=new dl(this.draw,{onSubmit:this._setDate.bind(this)});const i=this.getValue().map(r=>r.value).join("")||"",l=this.element.control?.dateFormat;this.datePicker.render({value:i,position:t,dateFormat:l}),this.isPopup=!0}destroy(){this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}_setDate(t){t?this.setSelect(t):this.clearSelect(),this.destroy()}}class Ro extends hs{isPopup;inputPopup;constructor(t,e){super(t,e),this.isPopup=!1,this.inputPopup=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(L=>!Rc(L)||jl.test(L.value)))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange();this.control.shrinkBoundary(e);const r=ht(t),{startIndex:a,endIndex:c}=l,d=i[a];let u=null;for(let L=a;L>=0;L--)if(i[L].controlComponent===s.ControlComponent.PREFIX){u=i[L];break}const R=u?.control||this.element.control;if(this.control.getIsExistValueByElementListIndex(i,a)){let L=a;for(;L>0;){const O=i[L];if(O.controlId!==d.controlId||O.controlComponent===s.ControlComponent.PREFIX||O.controlComponent===s.ControlComponent.PRE_TEXT)break;r.unshift(O),L--}let M=c+1;for(;M<i.length;){const O=i[M];if(O.controlId!==d.controlId||O.controlComponent===s.ControlComponent.POSTFIX||O.controlComponent===s.ControlComponent.POST_TEXT)break;r.push(O),M++}}const h=As(r);if(Number.isNaN(Number(h))||!Number.isFinite(Number(h)))return-1;const g=R?.numberExclusiveOptions,T=g?.maxLength??null,f=g?.decimalPlaces??null,m=h.replace(/[.-]/g,"").length;if(T!=null&&m>T||f!=null&&(h.split(".")[1]||"").length>f)return-1;const C=Number(h),I=g?.minValue,p=g?.maxValue;return I!=null&&C<I||p!=null&&C>p?-1:super.setValue(t,e,n)}_setNumberValue(t){const e=this.control.getElementList(),n=this.control.getRange(),{startIndex:i}=n;let l=null;for(let b=i;b>=0;b--)if(e[b].controlComponent===s.ControlComponent.PREFIX){l=e[b];break}const a=(l?.control||this.element.control)?.numberExclusiveOptions,c=a?.minValue,d=a?.maxValue,u=a?.minLength,R=a?.maxLength,h=t.trim(),g=h.replace(/[.-]/g,"").length,T=Number(h);if(u!=null&&g<u||R!=null&&g>R||c!=null&&T<c||d!=null&&T>d)return!1;let f=i;for(let b=i;b>=0;b--)if(e[b].controlComponent===s.ControlComponent.PREFIX){f=b;break}let m=f+1;for(let b=f+1;b<e.length;b++)if(e[b].controlComponent===s.ControlComponent.POSTFIX){m=b;break}const C=this.options.mode===s.EditorMode.FORM,I=C&&this.options.modeRule.form.inputTraceEnabled,p=C&&this.options.modeRule.form.deleteTraceEnabled,L=st(new Date).format("YYYY-MM-DD HH:mm:ss");if(p)for(let b=f+1;b<m;b++){const D=e[b];D.controlComponent===s.ControlComponent.VALUE&&!D.strikeout&&D.value&&(D.strikeout=!0,D.deletePerson="SYSTEM",D.deleteTime=L),D.controlComponent===s.ControlComponent.PLACEHOLDER&&(this.control.getDraw().spliceElementList(e,b,1),m--,b--)}else{const b=f+1,D=m-b;D>0&&this.control.getDraw().spliceElementList(e,b,D),m=f+1}m=f+1;for(let b=f+1;b<e.length;b++)if(e[b].controlComponent===s.ControlComponent.POSTFIX){m=b;break}const M=[];for(let b=0;b<h.length;b++){const D={type:s.ElementType.TEXT,value:h[b],controlComponent:s.ControlComponent.VALUE,controlId:e[f].controlId,originControlId:e[f].originControlId,control:e[f].control};I&&(D.textDecoration={style:s.TextDecorationStyle.DOUBLE},D.underline=!0),M.push(D)}for(let b=0;b<M.length;b++)this.control.getDraw().spliceElementList(e,m+b,0,[M[b]]);const O=m+M.length-1;return this.control.getDraw().getRange().setRange(O,O),this.control.emitControlContentChange(),this.control.repaintControl({curIndex:O}),!0}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e,i=t[n];if(!i||i.controlId!==this.element.controlId)return;let l=null;for(let T=n;T>=0;T--)if(t[T].controlComponent===s.ControlComponent.PREFIX){l=t[T];break}const r=l?.control||this.element.control,c=this.getValue().filter(T=>!T.strikeout),d=c.length>0?As(c):"",u=r?.numberExclusiveOptions,R=u?.minValue,h=u?.maxValue,g=u?.decimalPlaces;this.inputPopup=new Qg({control:this.control,currentValue:d,minValue:R,maxValue:h,decimalPlaces:g,onConfirm:T=>{if(!T||T.trim()==="")return this._clearNumberValue(),!0;const f=Number(T);return Number.isNaN(f)||!Number.isFinite(f)?!1:this._setNumberValue(T)},onTab:T=>{this.destroy(),setTimeout(()=>{this.control.initNextControl({direction:T})})},onClose:()=>{this.destroy()}}),this.inputPopup.create(),this.isPopup=!0}_clearNumberValue(){const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e;let i=n;for(let c=n;c>=0;c--)if(t[c].controlComponent===s.ControlComponent.PREFIX){i=c;break}let l=i+1;for(let c=i+1;c<t.length;c++)if(t[c].controlComponent===s.ControlComponent.POSTFIX){l=c;break}const r=i+1,a=l-r;a>0&&this.control.getDraw().spliceElementList(t,r,a),this.control.addPlaceholder(i),this.control.getDraw().getRange().setRange(i,i),this.control.emitControlContentChange(),this.control.repaintControl({curIndex:i})}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.control.getDraw();if(t.key==="Backspace")return r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT?i:i!==l?(c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key==="Delete"){const u=e[l+1];return r.controlComponent===s.ControlComponent.PLACEHOLDER||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT?this.control.removeControl(i):r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||u?.controlComponent===s.ControlComponent.POSTFIX||u?.controlComponent===s.ControlComponent.POST_TEXT?l:i!==l?(c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}return t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey?(t.preventDefault(),this.awake(),null):l}destroy(){this.inputPopup&&(this.inputPopup.destroy(),this.inputPopup=null),this.isPopup=!1}}class Qg{options;popupDom;constructor(t){this.options=t,this.popupDom=null}create(){const{currentValue:t,minValue:e,maxValue:n,decimalPlaces:i,onConfirm:l,onTab:r,onClose:a}=this.options,c=document.createElement("div");c.classList.add(`${tt}-number-input-modal`),c.setAttribute(Ue,s.EditorComponent.POPUP);const d=p=>{if(p.type==="mouseup"){const L=this.options.control.getDraw().getCanvasEvent();L.setIsAllowDrag(!1),L.setIsAllowSelection(!1)}p.stopPropagation()};c.addEventListener("mousedown",d),c.addEventListener("mouseup",d),c.addEventListener("click",d),c.addEventListener("keydown",d),c.addEventListener("input",d);const u=document.createElement("div");u.classList.add(`${tt}-number-input-modal__content`);const R=document.createElement("div");if(R.classList.add(`${tt}-number-input-modal__title`),R.textContent="请输入数值",u.appendChild(R),e!==void 0||n!==void 0){const p=document.createElement("div");p.classList.add(`${tt}-number-input-modal__hint`);let L="有效范围:";e!==void 0&&n!==void 0?L+=`${e} ~ ${n}`:e!==void 0?L+=`≥ ${e}`:L+=`≤ ${n}`,i!=null&&(L+=`,保留${i}位小数`),p.textContent=L,u.appendChild(p)}const h=document.createElement("input");h.classList.add(`${tt}-number-input-modal__input`),h.type="number",h.value=t,h.placeholder="请输入数值",e!==void 0&&(h.min=String(e)),n!==void 0&&(h.max=String(n)),i!=null&&(h.step=(1/Math.pow(10,i)).toString()),setTimeout(()=>{h.focus(),h.select()},100),u.appendChild(h);const g=document.createElement("div");g.classList.add(`${tt}-number-input-modal__error`),g.style.display="none",u.appendChild(g);const T=document.createElement("div");T.classList.add(`${tt}-number-input-modal__buttons`);const f=document.createElement("button");f.classList.add(`${tt}-number-input-modal__cancel`),f.textContent="取消",f.onclick=()=>{a()},T.appendChild(f);const m=document.createElement("button");m.classList.add(`${tt}-number-input-modal__confirm`),m.textContent="确定";const C=()=>{const p=h.value.trim();if(!p)return l("");const L=parseFloat(p);return Number.isNaN(L)||!Number.isFinite(L)?(g.textContent="请输入有效的数值",g.style.display="block",!1):i!=null&&(p.split(".")[1]||"").length>i?(g.textContent=`小数位数不能超过${i}位`,g.style.display="block",!1):e!==void 0&&L<e?(g.textContent=`数值不能小于 ${e}`,g.style.display="block",!1):n!==void 0&&L>n?(g.textContent=`数值不能大于 ${n}`,g.style.display="block",!1):(g.style.display="none",l(p))};m.onclick=()=>{C()&&a()},T.appendChild(m),u.appendChild(T),c.appendChild(u),h.onkeydown=p=>{p.key==="Enter"?m.click():p.key==="Tab"?(p.preventDefault(),C()&&(a(),r(p.shiftKey?Jt.UP:Jt.DOWN))):p.key==="Escape"&&a()},this.options.control.getContainer().appendChild(c),this.popupDom=c}destroy(){this.popupDom&&(this.popupDom.remove(),this.popupDom=null)}}class vg{options;mask;container;inputList;optionItemContainers;data;constructor(t){this.options=t,this.mask=null,this.container=null,this.inputList=[],this.optionItemContainers=[],this.data=t.data,this._render()}_getFieldValue(t){const e=this.inputList.filter(n=>n.name===t);if(e.length!==0){for(const n of e)if(n instanceof HTMLInputElement&&n.type==="radio"&&n.checked)return n.value;return e[0].value}}_updateFieldVisibility(){this.data.forEach((t,e)=>{if(t.visibleWhen){const{field:n,value:i}=t.visibleWhen,l=this._getFieldValue(n),r=this.optionItemContainers[e];if(r){const a=l===i;r.style.display=a?"":"none"}}})}_render(){const{title:t,onClose:e,onCancel:n,onConfirm:i}=this.options,l=document.createElement("div");l.classList.add("dialog-mask"),l.setAttribute(Ue,s.EditorComponent.COMPONENT),document.body.append(l);const r=document.createElement("div");r.classList.add("dialog-container"),r.setAttribute(Ue,s.EditorComponent.COMPONENT);const a=document.createElement("div");a.classList.add("dialog"),r.append(a);const c=document.createElement("div");c.classList.add("dialog-title");const d=document.createElement("span");d.append(document.createTextNode(t));const u=document.createElement("i");u.onclick=()=>{e&&e(),this._dispose()},c.append(d),c.append(u),a.append(c);const R=document.createElement("div");R.classList.add("dialog-option");for(let f=0;f<this.data.length;f++){const m=this.data[f],C=document.createElement("div");if(C.classList.add("dialog-option__item"),m.visible===!1&&(C.style.display="none"),m.label){const I=document.createElement("span");I.append(document.createTextNode(m.label)),C.append(I),m.required&&I.classList.add("dialog-option__item--require")}if(m.type==="radio"){const I=document.createElement("div");I.classList.add("dialog-radio-group"),m.horizontal&&I.classList.add("dialog-radio-group--horizontal"),m.options?.forEach(p=>{const L=document.createElement("label");L.classList.add("dialog-radio-item");const M=document.createElement("input");M.type="radio",M.name=m.name,M.value=p.value,p.value===(m.value||"")&&(M.checked=!0);const O=document.createElement("span");O.textContent=p.label,L.append(M),L.append(O),I.append(L),M.addEventListener("change",()=>{this._updateFieldVisibility()}),this.inputList.push(M)}),C.append(I)}else if(m.type==="select"){const I=document.createElement("select"),p=m.value||"";m.options?.forEach(L=>{const M=document.createElement("option");M.value=L.value,M.label=L.label,L.value===p&&(M.selected=!0),I.append(M)}),I.name=m.name,I.value=p,I.addEventListener("change",()=>{this._updateFieldVisibility()}),m.width&&(I.style.width=`${m.width}px`),C.append(I),this.inputList.push(I)}else if(m.type==="textarea"){const I=document.createElement("textarea");I.name=m.name,I.value=m.value||"",I.placeholder=m.placeholder||"",m.width&&(I.style.width=`${m.width}px`),m.height&&(I.style.height=`${m.height}px`),C.append(I),this.inputList.push(I)}else{const I=document.createElement("input");I.type=m.type,I.name=m.name,I.value=m.value||"",I.placeholder=m.placeholder||"",m.width&&(I.style.width=`${m.width}px`),m.height&&(I.style.height=`${m.height}px`),C.append(I),this.inputList.push(I)}R.append(C),this.optionItemContainers.push(C)}a.append(R);const h=document.createElement("div");h.classList.add("dialog-menu");const g=document.createElement("button");g.classList.add("dialog-menu__cancel"),g.append(document.createTextNode("取消")),g.type="button",g.onclick=()=>{n&&n(),this._dispose()},h.append(g);const T=document.createElement("button");T.append(document.createTextNode("确定")),T.type="submit",T.onclick=()=>{if(i){const f=new Set,m=[];for(const C of this.inputList)if(!f.has(C.name))if(C instanceof HTMLInputElement&&C.type==="radio"){const I=this.inputList.find(p=>p.name===C.name&&p instanceof HTMLInputElement&&p.checked);I&&(m.push({name:C.name,value:I.value}),f.add(C.name))}else m.push({name:C.name,value:C.value}),f.add(C.name);i(m)}this._dispose()},h.append(T),a.append(h),document.body.append(r),this.container=r,this.mask=l,this._updateFieldVisibility()}_dispose(){this.mask?.remove(),this.container?.remove()}}class On{draw;element;control;isPopup;datePicker;options;range;static isDeleting=!1;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.range=n.getRange(),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(){return[]}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e),r=this.control.getDraw(),{startIndex:a}=l,d=i[a].controlId;let u=a;for(let C=a;C>=0;C--){const I=i[C];if(I.controlId!==d)break;if(I.controlComponent===s.ControlComponent.PREFIX){u=C;break}}let R=a;for(let C=a;C<i.length;C++){const I=i[C];if(I.controlId!==d){R=C;break}if(I.controlComponent===s.ControlComponent.POSTFIX){R=C;break}}const h=u+1,g=R-1;g>=h&&r.spliceElementList(i,h,g-h+1);const T=i[u],f=ie(T,["control","controlId",...ue]),m=u+1;for(let C=0;C<t.length;C++){const I={...f,...t[C],controlComponent:s.ControlComponent.VALUE};I.color="#fff",I.highlight="#1677FF",re(i,[I],u,{editorOptions:this.options}),r.spliceElementList(i,m+C,0,[I])}return m+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const l=this.control.getValueRange(t);if(!l)return-1;const{startIndex:r,endIndex:a}=l;if(!~r||!~a)return-1;const c=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(c,r+1,a-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(r,t),r}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{endIndex:i}=n,l=e[i];return!!l?.originControlId&&!!l?.controlId&&l.originControlId!==l.controlId&&l.control?.type===s.ControlType.BUTTON&&!l.control?.buttonText&&(t.key===s.KeyMap.Backspace||t.key===s.KeyMap.Delete)?this.control.removeControl(i):l?.controlComponent==="value"&&l.control?.type==="button"&&l.control?.buttonText?t.key===s.KeyMap.Backspace||t.key===s.KeyMap.Delete?(l.controlId&&this.removeByValue(e,l.controlId),i):null:(t.key===s.KeyMap.Backspace&&l?.controlComponent==="value"&&l.control?.type==="button"&&!l.control?.buttonText,null)}removeByValue(t,e){return On.isDeleting=!0,new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text")&&t[c].controlId===e&&t.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),setTimeout(()=>{On.isDeleting=!1},300),n(!0)})}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl()||On.isDeleting||!this.control.getPosition())return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(e[n]?.controlId!==this.element?.controlId)return;const i=this.control.getDraw().getPosition().getPositionContext();if(!i.isDirectHit||i.index!==n||e[i.index]?.controlId!==this.element?.controlId)return;const l=e[n]?.controlId,r=e[n]?.control;if(!(l?.endsWith("_text")||r?.buttonText)){if(this.options.mode=="form"){const a=e[n].controlId;if(!a)return;const c=e.filter(d=>d.controlId==a);c[0].control.buttonText||this.showInputModal(c)}else if(this.options.mode=="edit"){const a=e[n].controlId,c=e.filter(d=>d.controlId==a);this.showEditModal(c)}}}showInputModal(t){if(this.inputModal){this.closeInputModal();return}this.isPopup=!0,this.inputModal=document.createElement("div"),this.inputModal.classList.add(`${tt}-button-input-modal`),this.inputModal.setAttribute(Ue,s.EditorComponent.POPUP);const e=d=>{if(d.type==="mouseup"){const u=this.control.getDraw().getCanvasEvent();u.setIsAllowDrag(!1),u.setIsAllowSelection(!1)}d.stopPropagation()};this.inputModal.addEventListener("mousedown",e),this.inputModal.addEventListener("mouseup",e),this.inputModal.addEventListener("click",e),this.inputModal.addEventListener("keydown",e),this.inputModal.addEventListener("input",e),this.inputModal.oncontextmenu=d=>{d.preventDefault(),d.stopPropagation()};const n=document.createElement("div");n.classList.add(`${tt}-button-input-modal__content`),n.oncontextmenu=d=>{d.preventDefault(),d.stopPropagation()};const i=document.createElement("div");i.classList.add(`${tt}-button-input-modal__title`),i.innerText="请输入按钮展开文字(用逗号分隔)";const l=document.createElement("textarea");l.classList.add(`${tt}-button-input-modal__textarea`),l.placeholder="例如:选项1,选项2,选项3",l.rows=5;const r=document.createElement("div");r.classList.add(`${tt}-button-input-modal__buttons`);const a=document.createElement("button");a.classList.add(`${tt}-button-input-modal__cancel`),a.innerText="取消",a.onclick=()=>this.closeInputModal();const c=document.createElement("button");c.classList.add(`${tt}-button-input-modal__confirm`),c.innerText="确认",c.onclick=()=>{const d=l.value.trim();if(d){const u=d.split(/[,,]/).map((R,h)=>({value:R.trim(),code:String(h+1)})).filter(R=>R.value);if(u.length>0&&t[0]?.controlId){const R={controlId:t[0].controlId,element:[{...t[0],newButtonValue:u}]};this.draw.getCommand().executeButton(R)}}this.closeInputModal()},r.appendChild(a),r.appendChild(c),n.appendChild(i),n.appendChild(l),n.appendChild(r),this.inputModal.appendChild(n),this.draw.getContainer().appendChild(this.inputModal),setTimeout(()=>l.focus(),100),this.inputModal.onclick=d=>{d.target===this.inputModal&&this.closeInputModal()}}closeInputModal(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}showEditModal(t){const e=t[0]?.control||{},n=e.buttonLabel||e.label||"按钮",i=e.code||"";this.isPopup=!0,new vg({title:"修改按钮属性",data:[{type:"text",label:"按钮标签",name:"buttonLabel",required:!0,placeholder:"请输入按钮标签",value:n},{type:"text",label:"按钮代码",name:"code",placeholder:"请输入按钮代码",value:i}],onClose:()=>{this.isPopup=!1},onCancel:()=>{this.isPopup=!1},onConfirm:l=>{const r=l.find(h=>h.name==="buttonLabel")?.value?.trim()||"按钮",a=l.find(h=>h.name==="code")?.value?.trim()||"",c=this.control.getElementList(),d=t[0]?.controlId;if(d)for(let h=0;h<c.length;h++){const g=c[h];g.controlId===d&&g.control&&(g.control.buttonLabel=r,g.control.label=r,g.control.code=a)}const u=[];for(let h=0;h<r.length;h++)u.push({value:r[h],controlComponent:s.ControlComponent.VALUE});const R=this.setValue(u);R!==-1&&this.control.repaintControl({curIndex:R}),this.isPopup=!1}})}destroy(){this.inputModal&&this.closeInputModal(),this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}}class ul{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),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();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),l=t?null:i.getTd();n>=e.length&&(n=e.length-1);const r=e[n],a=[];let c=l;if(r.controlComponent===s.ControlComponent.PRETEXTFIX||r.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){let T=n+1;for(;T<e.length;){const f=e[T];if(f.controlId!==r.controlId||f.controlComponent!==s.ControlComponent.PRETEXTFIX&&f.controlComponent!==s.ControlComponent.PRETEXTFIX_TEXT){n=T-1;break}T++}}let d=e,u=n;for(;;){if(u<0&&c?.linkTdPrevId){const f=i.getTdById(c.linkTdPrevId);if(f){d=f.value,u=d.length-1,c=f;continue}}if(u<0)break;const T=d[u];if(T.controlId!==r.controlId||T.controlComponent===s.ControlComponent.PRETEXTFIX||T.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||T.controlComponent===s.ControlComponent.TEXTFIXLABEL)break;T.controlComponent===s.ControlComponent.VALUE&&a.unshift(T),u--}c=l;let R=e,h=n+1;for(;;){if(h>=R.length&&c?.linkTdNextId){const f=i.getTdById(c.linkTdNextId);if(f){R=f.value,h=0,c=f;continue}}const T=R[h];if(!T||T.controlId!==r.controlId||T.controlComponent===s.ControlComponent.POSTTEXTFIX||T.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||T.controlComponent===s.ControlComponent.TEXTFIXLABEL)break;T.controlComponent===s.ControlComponent.VALUE&&a.push(T),h++}return a.filter(T=>T.type!==s.ElementType.SPLIT_TAG)}removeNextControlElement(t,e){const n=this.control.getDraw();if(e=e??n.getTd()?.linkTdNextId,e){const i=n.getTdById(e);if(i){if(i.value.length){if(i.value[1].controlId===t)return n.spliceElementList(i.value,1,1),i.value[1]}else if(i.linkTdNextId)return this.removeNextControlElement(t,i.linkTdNextId)}}}setValue(t,e={},n={}){if(this.options.mode===s.EditorMode.FORM||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:r,endIndex:a}=l,c=this.control.getDraw();r!==a?c.spliceElementList(i,r+1,a-r,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(r,{elementList:i});const d=i[r],u=i[r+1];let R=d.originControlId||d.controlId,h=d.originControlId&&(d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===s.ControlComponent.POST_TEXT);if(!h&&d.controlId&&(d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===s.ControlComponent.POST_TEXT)&&u?.controlId&&u.controlId!==d.controlId)if(u.controlComponent===s.ControlComponent.PREFIX||u.controlComponent===s.ControlComponent.PRETEXTFIX)for(let C=r;C>=0;C--){const I=i[C];if(I.controlId===d.controlId&&(I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let p=C-1;p>=0;p--){const L=i[p];if(L.controlId&&L.controlId!==d.controlId&&(L.controlComponent===s.ControlComponent.PRETEXTFIX||L.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||L.controlComponent===s.ControlComponent.PREFIX||L.controlComponent===s.ControlComponent.PRE_TEXT)){R=L.controlId,h=!0;break}if(L.controlId&&L.controlId!==d.controlId&&(L.controlComponent===s.ControlComponent.POSTFIX||L.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}else(u.controlComponent===s.ControlComponent.POSTFIX||u.controlComponent===s.ControlComponent.POSTTEXTFIX)&&(R=u.controlId,h=!0);if(!h&&d.controlId&&(d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===s.ControlComponent.POST_TEXT))for(let C=r;C>=0;C--){const I=i[C];if(I.controlId===d.controlId&&(I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let p=C-1;p>=0;p--){const L=i[p];if(L.controlId&&L.controlId!==d.controlId&&(L.controlComponent===s.ControlComponent.PRETEXTFIX||L.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||L.controlComponent===s.ControlComponent.PREFIX||L.controlComponent===s.ControlComponent.PRE_TEXT)){R=L.controlId,h=!0;break}if(L.controlId&&L.controlId!==d.controlId&&(L.controlComponent===s.ControlComponent.POSTFIX||L.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}const g=d.type&&!Ie.includes(d.type)||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT?ie(d,["control","controlId",...ue]):Ce(d,["type"]);h&&(g.controlId=R,delete g.originControlId);const T=l.startIndex+1,f=[],m=C=>{const I=f.length?f:i,p=f.length?f.length-1:l.startIndex;re(I,[C],p,{editorOptions:this.options}),f.push(C)};for(let C=0;C<t.length;C++){const I=t[C];if(I.type===s.ElementType.CONTROL&&I.control){const p=I,L=p.controlId||Tt(),M=p.control?.value||[],O=p.control?.type===s.ControlType.TEXTFIELD,b={...g,controlId:L,type:s.ElementType.CONTROL,control:p.control,originControlId:R},D=O?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,W=O?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,V=O?p.control?.preTextFix||this.options.control.preTextFix:p.control?.prefix||this.options.control.prefix;for(let y=0;y<V.length;y++){const F={...b,value:V[y],controlComponent:D};m(F)}for(let y=0;y<M.length;y++){const F=M[y],S={...b,...F,controlComponent:s.ControlComponent.VALUE,type:F.type};(S.color===this.options.control.textFixColor||S.color===this.options.control.placeholderColor)&&(S.color=this.options.defaultColor),m(S)}if(M.length===0){const y=p.control?.placeholder||"";for(let F=0;F<y.length;F++){const S={...b,value:y[F],controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};m(S)}}const E=O?p.control?.postTextFix||this.options.control.postTextFix:p.control?.postfix||this.options.control.postfix;for(let y=0;y<E.length;y++){const F={...b,value:E[y],controlComponent:W};m(F)}}else if(I.type||I.value){g.color=this.options.defaultColor;const p={...g,...I,controlComponent:s.ControlComponent.VALUE};h&&(p.color=this.element.control?.color??this.options.defaultColor,this.element.control?.highlight?p.highlight=this.element.control.highlight:delete p.highlight),(p.color===this.options.control.textFixColor||p.color===this.options.control.placeholderColor)&&(p.color=this.options.defaultColor),m(p)}}return f.length&&c.spliceElementList(i,T,0,f),l.startIndex+f.length}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange();this.control.shrinkBoundary(t);const{startIndex:l,endIndex:r}=i;return this.control.getDraw().spliceElementList(n,l+1,r-l,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),e.isAddPlaceholder!==!1&&(this.getValue(t).length||this.control.addPlaceholder(l,t)),l}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange(),i=n.startIndex,l=n.endIndex;if(t.key===s.KeyMap.Backspace&&i===l&&i>0){const m=e[i-1],C=m?.controlComponent===s.ControlComponent.POSTFIX||m?.controlComponent===s.ControlComponent.POSTTEXTFIX,I=m?.controlComponent===s.ControlComponent.PLACEHOLDER,p=!!m?.controlId,M=this.draws.getPosition().getPositionList(),O=M[i],b=M[i-1],D=O&&b&&O.rowIndex===b.rowIndex;if((C||I)&&p&&D)return this.control.removeControl(i-1)}this.control.shrinkBoundary();const{startIndex:r,endIndex:a}=n,c=e[r],d=this.control.getDraw(),u=e[a+1],R=!!c?.originControlId&&!!c?.controlId&&c.originControlId!==c.controlId,h=R&&(c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRE_TEXT||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.POSTFIX||c.controlComponent===s.ControlComponent.POST_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PLACEHOLDER||c.controlComponent===s.ControlComponent.TEXTFIXLABEL),g=R&&c.control?.type===s.ControlType.BUTTON&&c.controlComponent===s.ControlComponent.VALUE,T=!!u?.originControlId&&!!u?.controlId&&u.originControlId!==u.controlId&&(u.controlComponent===s.ControlComponent.PREFIX||u.controlComponent===s.ControlComponent.PRE_TEXT||u.controlComponent===s.ControlComponent.PRETEXTFIX||u.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||u.controlComponent===s.ControlComponent.PLACEHOLDER||u.controlComponent===s.ControlComponent.TEXTFIXLABEL),f=!!u?.originControlId&&!!u?.controlId&&u.originControlId!==u.controlId&&u.control?.type===s.ControlType.BUTTON;if(t.key===s.KeyMap.Backspace){if(r===a&&(g||h&&c.controlComponent!==s.ControlComponent.POSTFIX&&c.controlComponent!==s.ControlComponent.POST_TEXT&&c.controlComponent!==s.ControlComponent.POSTTEXTFIX&&c.controlComponent!==s.ControlComponent.POSTTEXTFIX_TEXT))return this.control.removeControl(r);if(this.options.mode===s.EditorMode.FORM)this.strikeout();else{if(r!==a)return e.slice(r,a+1).some(I=>I.controlComponent===s.ControlComponent.POSTTEXTFIX||I.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)?r:(d.spliceElementList(e,r+1,a-r),this.getValue().length||this.control.addPlaceholder(r),r===0&&e[0].type===s.ElementType.SPLIT_TAG?d.fixPosition(!0)??r:r);{const m=e[r-1];return m?.controlId===c.controlId&&m?.originControlId===c.originControlId&&m?.controlComponent===s.ControlComponent.VALUE&&(c.controlComponent===s.ControlComponent.POSTFIX||c.controlComponent===s.ControlComponent.POST_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)?(d.spliceElementList(e,r-1,1),this.getValue().length||this.control.addPlaceholder(r-2),r-2):c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===s.ControlComponent.TEXTFIXLABEL||c.controlComponent===s.ControlComponent.PLACEHOLDER?r:(d.spliceElementList(e,r,1),this.getValue().length||this.control.addPlaceholder(r-1),r===1&&e[0].type===s.ElementType.SPLIT_TAG||r===0?d.fixPosition(!0)??r-1:r-1)}}}else if(t.key===s.KeyMap.Delete){if(r===a&&(h||g))return this.control.removeControl(r);if(r===a&&(T||f))return this.control.removeControl(a+1);if(this.options.mode===s.EditorMode.FORM)this.strikeout();else return r!==a?(d.spliceElementList(e,r+1,a-r),this.getValue().length||this.control.addPlaceholder(r),r===0&&e[0].type===s.ElementType.SPLIT_TAG?d.fixPosition(!0)??r:r):(u||d.getTd()?.linkTdNextId&&c.controlId&&this.removeNextControlElement(c.controlId),u&&((c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&(u.controlComponent===s.ControlComponent.PLACEHOLDER||u.controlComponent===s.ControlComponent.TEXTFIXLABEL)||u.controlComponent===s.ControlComponent.POSTTEXTFIX||u.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PLACEHOLDER||c.controlComponent===s.ControlComponent.TEXTFIXLABEL)?r:(d.spliceElementList(e,r+1,1),this.getValue().length||this.control.addPlaceholder(r),r===0&&e[0].type===s.ElementType.SPLIT_TAG?d.fixPosition(!0)??r:r))}return a}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}strikeout(t,e={},n={}){const{isIgnoreDisabledRule:i=!1}=t||{};if(!i&&(this.draws.isReadonly()||this.draws.isDisabled()))return;const r=this.ranges.getSelectionElementList(),a=this.position.getCursorPosition(),c=st(new Date).format("YYYY-MM-DD HH:mm:ss");if(r?.length){if(!this.element.strikeout){const d=r.findIndex(u=>!u.strikeout);r.forEach(u=>{u.deletePerson="SWJ",u.deleteTime=c,u.strikeout=!!~d}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),setTimeout(()=>{this.strikeoute()},100)}}else{const d=this.control.getElementList()[a.index];if(!this.control.getElementList()[a.index].strikeout&&d?.metrics.width>0){this.control.getElementList()[a.index].strikeout=!0,this.control.getElementList()[a.index].deletePerson="SWJ",this.control.getElementList()[a.index].deleteTime=c;const u=--a.index;setTimeout(()=>{this.strikeoute()},100),setTimeout(()=>{const h=u;this.draws.render({curIndex:h,isSetCursor:!0}),a.index=u,this.position.setCursorPosition(a),this.ranges.setRange(u,u)},100)}else{const{elementList:u,range:R}=this.control.mergeControl(n),h=R.startIndex;if(h>=0&&h<u.length&&u[h]?.metrics?.width!==void 0&&u[h].metrics.width<=0&&!u[h]?.strikeout){this.draws.spliceElementList(u,R.startIndex,1,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule});const g=!0,T=R.startIndex-1;this.draws.render({curIndex:T,isSetCursor:g}),a.index=T,delete a.value,this.position.setCursorPosition(a),this.ranges.setRange(T,T)}}}}strikeoute(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draws.isReadonly()||this.draws.isDisabled()))return;if(!this.ranges.getSelectionElementList()?.length){const{endIndex:l}=this.ranges.getRange(),a=this.draws.getElementList()[l];this.ranges.setDefaultStyle({strikeout:a.strikeout?!1:!this.ranges.getDefaultStyle()?.strikeout})}}}const Kg={indent:" ",divider:"────────────────"};class Rl{draw;element;control;options;isPopup;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:l,endIndex:r}=n;for(let a=l;a<=r;a++){const c=e[a];c.controlComponent===s.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e),r=this.control.getDraw(),{startIndex:a}=l,d=i[a].controlId;let u=a;for(let C=a;C>=0;C--){const I=i[C];if(I.controlId!==d)break;if(I.controlComponent===s.ControlComponent.PREFIX){u=C;break}}let R=a;for(let C=a;C<i.length;C++){const I=i[C];if(I.controlId!==d){R=C;break}if(I.controlComponent===s.ControlComponent.POSTFIX){R=C;break}}const h=u+1,g=R-1;g>=h&&r.spliceElementList(i,h,g-h+1);const T=i[u],f=ie(T,["control","controlId",...ue]),m=u+1;for(let C=0;C<t.length;C++){const I={...f,...t[C],value:t[C].value===`
|