(()=>{var V6=Object.create;var $w=Object.defineProperty;var s_=Object.getOwnPropertyDescriptor;var H6=Object.getOwnPropertyNames;var j6=Object.getPrototypeOf,z6=Object.prototype.hasOwnProperty;var xo=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var $c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var X6=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of H6(t))!z6.call(e,n)&&n!==i&&$w(e,n,{get:()=>t[n],enumerable:!(r=s_(t,n))||r.enumerable});return e};var oy=(e,t,i)=>(i=e!=null?V6(j6(e)):{},X6(t||!e||!e.__esModule?$w(i,"default",{value:e,enumerable:!0}):i,e));var Ws=(e,t,i,r)=>{for(var n=r>1?void 0:r?s_(t,i):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(n=(r?a(t,i,n):a(n))||n);return r&&n&&$w(t,i,n),n};var l_=$c((Jte,o_)=>{var db=[];db.push("g.selected>.primitive-text{fill:var(--selectColor)}g.highlight>.primitive-text{fill:var(--highlight)}#selectBox1,.cross-path{stroke:var(--selectColor)}.cross-path-content{fill:var(--selectColor)}.control-dot:hover,.handle-dot:hover{fill:var(--highlight)}.control-dot.selected,.handle-dot.selected{fill:var(--selectColor)}.dimensionAngle text,.dimensionLength text,.dimensionRadius text{fill:var(--normalDimensionColor)}.dimensionAngle line,.dimensionAngle path,.dimensionAngle polyline,.dimensionLength line,.dimensionLength path,.dimensionLength polyline,.dimensionRadius line,.dimensionRadius path,.dimensionRadius polyline{stroke:var(--normalDimensionColor)}.dimensionAngle.selected .key-point,.dimensionLength.selected .key-point,.dimensionRadius.selected .key-point{display:inline;display:initial}.dimensionAngle .key-point,.dimensionLength .key-point,.dimensionRadius .key-point{display:none}.dimensionAngle.highlight text,.dimensionLength.highlight text,.dimensionRadius.highlight text{fill:var(--highlight);stroke:none}.dimensionAngle.highlight line,.dimensionAngle.highlight path,.dimensionAngle.highlight polyline,.dimensionLength.highlight line,.dimensionLength.highlight path,.dimensionLength.highlight polyline,.dimensionRadius.highlight line,.dimensionRadius.highlight path,.dimensionRadius.highlight polyline{stroke:var(--highlight)}.dimensionAngle.selected text,.dimensionLength.selected text,.dimensionRadius.selected text{fill:var(--selectColor);stroke:none}.dimensionAngle.selected line,.dimensionAngle.selected path,.dimensionAngle.selected polyline,.dimensionLength.selected line,.dimensionLength.selected path,.dimensionLength.selected polyline,.dimensionRadius.selected line,.dimensionRadius.selected path,.dimensionRadius.selected polyline{stroke:var(--selectColor)}[c_partid=dimension][category=Constraint] text{fill:var(--dimensionConstraintColor);stroke:none}[c_partid=dimension][category=Constraint] line,[c_partid=dimension][category=Constraint] polyline{stroke:var(--dimensionConstraintColor)}[c_partid=dimension][category=Annotation] text{fill:var(--dimensionLabelColor);stroke:none}[c_partid=dimension][category=Annotation] line,[c_partid=dimension][category=Annotation] polyline{stroke:var(--dimensionLabelColor)}[c_partid=dimension].highlight text{fill:var(--highlight);stroke:none}[c_partid=dimension].highlight line,[c_partid=dimension].highlight polyline{stroke:var(--highlight)}[c_partid=dimension].selected text{fill:var(--selectColor);stroke:none}[c_partid=dimension].selected line,[c_partid=dimension].selected polyline{stroke:var(--selectColor)}#gridCell [type=dot]{fill:var(--gridColor)}#gridCell [type=line]{stroke:var(--gridColor)}");db=db.join("");function a_(){let e=document.createElement("style");e.innerHTML=db,document.head.appendChild(e)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",a_):a_();o_.exports={selected:"selected","primitive-text":"primitive-text",highlight:"highlight",selectBox1:"selectBox1","cross-path":"cross-path","cross-path-content":"cross-path-content","control-dot":"control-dot","handle-dot":"handle-dot",dimensionAngle:"dimensionAngle",dimensionLength:"dimensionLength",dimensionRadius:"dimensionRadius","key-point":"key-point",gridCell:"gridCell"}});var u_=$c((Kte,c_)=>{var pb=[];pb.push(`<!-- \u9762\u677F\u5E93\u9884\u89C8\u8981\u590D\u7528\u8FD9\u4E2A\u6587\u4EF6\uFF0C\u62BD\u53D6\u51FA\u6765 -->
<style type="text/css" id="layer-css-container">
	html,
	body {
		padding: 0px;
		margin: 0px;
		border: none;
		/* \u68CB\u76D8\u683C\u80CC\u666F\u56FE\u7247 */
		background-image: url(data:image/gif;base64,R0lGODlhEAAQAIAAAP///9/f3yH5BAAHAP8ALAAAAAAQABAAAAIfjG+gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);
	}

	body > #root {
		position: absolute;
		left: 0px;
		top: 0px;
		margin: 0;
	}
	.panel-mark,
	rect.panel-border {
		pointer-events: none;
		stroke-width: 1;
		vector-effect: non-scaling-stroke;
	}
	[layer='2']:not([stroke='none']) /* \u900F\u660E\u63A7\u5236\u5C42 */ {
		stroke: #999;
		stroke-width: 1;
		vector-effect: non-scaling-stroke;
	}
	[layer='2'], [layer='2'] path:not([fill='none']):not(.hitbox) /* \u900F\u660E\u63A7\u5236\u5C42 */ {
		fill: url(#slashPattern);
	}
	[layer='2'][c_partid="part_text"] path:not([fill='none']):not(.hitbox) /* \u900F\u660E\u63A7\u5236\u5C42\u7684\u6587\u672C */ {
		stroke-width: 0.5px;
	}

	/* \u677F\u6846\u6316\u7A7A\u5C42 */
	[layer='4'] {
		fill: url(#transparent-pattern);
		stroke-width: 1;
		vector-effect: non-scaling-stroke;
		stroke: #000;
	}

	/* \u80CC\u80F6\u6316\u7A7A\u5C42 */
	[layer='5'] {
		stroke-width: 1;
		vector-effect: non-scaling-stroke;
		fill: url(#grid-45-degree);
		stroke: #ccc;
	}
	/* \u9F13\u5305\u5C42 */
	[layer='7'] {
		fill: transparent;
		stroke: #ff00ff;
		stroke-width: 1;
		stroke-dasharray: 12 4 2 4;
		vector-effect: non-scaling-stroke;
	}

	/* \u677F\u6846\u5C42 */
	[layer='3'] {
		stroke-width: 1;
		stroke: black;
		vector-effect: non-scaling-stroke;
		fill: none;
	}
	[layer='3'][stroke='none'] {
		stroke: #000;
	}
	/* svg g\u6807\u7B7E\u8F83\u4E3A\u7279\u6B8A\uFF0C\u5B58\u5728\u5B50\u5143\u7D20\u65E0\u6CD5\u7EE7\u627F\u5176\u5C5E\u6027\u60C5\u51B5 */
	*[hide='1']:not([stroke='none']),
	g[hide='1'] > *:not([stroke='none']) {
		stroke: #ffff00 !important;
		stroke-opacity: 0.2 !important;
		opacity: 1 !important;
	}
	*[hide='1']:not([fill='none']),
	g[hide='1'] > *:not([fill='none']) {
		fill: #ffff00 !important;
		fill-opacity: 0.2 !important;
		opacity: 1 !important;
	}
	/* \u4E0D\u900F\u660E\u5EA6\u503C\u592A\u5C0F\u4E86\u770B\u4E0D\u89C1\u4E0D\u65B9\u4FBF\u8BC6\u522B\uFF0C\u8FDB\u884C\u4E00\u4E0B\u589E\u5F3A */
	#g1 [opacity='0'],
	#g1 [opacity^='0.0'] {
		opacity: 0.1;
	}

	.key-point {
		display: none;
	}

	/* \u8F85\u52A9\u7EBF start */
	[c_partid='auxiliaryLine']:not([stroke]) {
		stroke: var(--auxiliaryLineColor);
	}
	[c_partid='auxiliaryLine']:not([stroke-dasharray]) {
		stroke-dasharray: var(--auxiliaryLineDashArray);
	}
	[c_partid='auxiliaryLine'].selected {
		stroke: var(--selectColor);
	}
	[c_partid='auxiliaryLine'].highlight {
		stroke: var(--highlight);
	}
	/* \u8F85\u52A9\u7EBF end */

	/* \u8F85\u52A9\u70B9 start */
	[c_partid='auxiliaryPoint']:not([fill]) {
		fill: var(--auxiliaryPointFillColor);
	}
	[c_partid='auxiliaryPoint'].selected {
		fill: var(--selectColor);
	}
	[c_partid='auxiliaryPoint'].highlight {
		fill: var(--highlight);
	}
	/* \u8F85\u52A9\u70B9 end */

	`);pb.push(l_());pb.push(`
</style>
`);c_.exports=pb.join("")});var p_=$c(($te,d_)=>{var Hh=[];Hh.push("body,html{border:none;height:100%;margin:0;overflow:hidden;padding:0}body::-webkit-scrollbar{height:12px;width:12px}body::-webkit-scrollbar-track{border-radius:10px;-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3)}body::-webkit-scrollbar-thumb{background:rgba(205,227,255,.8);border:1px solid #62b0ff;border-radius:10px;-webkit-box-shadow:inset 0 0 6px rgba(98,176,255,.5)}body::-webkit-scrollbar-thumb:window-inactive{background:rgba(205,227,255,.4)}input:not([type])::-ms-clear,input[type=text]::-ms-clear{display:none}svg,text{-webkit-user-select:none;-moz-user-select:none;-o-user-select:none;user-select:none}svg{overflow:hidden}svg rect.hitbox{fill:none;pointer-events:all;stroke:none}[c_partid=auxiliaryLine]{stroke-width:1;vector-effect:non-scaling-stroke!important}[c_partid=auxiliaryPoint]{stroke-width:0;vector-effect:non-scaling-stroke!important}.highlight[stroke=none],.selected [stroke=none]{stroke-width:1;vector-effect:non-scaling-stroke}.hidetext g text,.hidetext text,text.hidetext{display:none}#gControlDots rect{shape-rendering:auto}#gControlDots circle{shape-rendering:auto;vector-effect:non-scaling-stroke}#gControlDots circle.light{fill:#aea}#gControlLines line,#gControlLines rect,#gControlRects line,#gControlRects rect{fill:none;shape-rendering:auto;vector-effect:non-scaling-stroke}#gControlLines line:not([stroke-dasharray]),#gControlLines rect:not([stroke-dasharray]),#gControlRects line:not([stroke-dasharray]),#gControlRects rect:not([stroke-dasharray]),#selectBox1{stroke-dasharray:3,3}#selectBox1{fill:none;shape-rendering:crispEdges}.bw-chrome.cursor-cross-red{cursor:none,crosshair}.cursor-grab{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.cursor-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.cursor-crosshair{cursor:crosshair}.cursor-row-resize{cursor:row-resize}.cursor-col-resize{cursor:col-resize}.cursor-zoom-in{cursor:-moz-zoom-in;cursor:-webkit-zoom-in;cursor:zoom-in}.cursor-zoom-out{cursor:-moz-zoom-out;cursor:-webkit-zoom-out;cursor:zoom-out}[data-cursor=ns-resize]{cursor:ns-resize}[data-cursor=ew-resize]{cursor:ew-resize}[data-cursor=nesw-resize]{cursor:nesw-resize}[data-cursor=nwse-resize]{cursor:nwse-resize}[data-cursor=move]{cursor:move}[data-cursor=rotate-left-bottom],[data-cursor=rotate-left-top],[data-cursor=rotate-right-bottom],[data-cursor=rotate-right-top]{cursor:");Hh.push("url(");Hh.push('"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48cGF0aCBkPSJNMCAwaDE2djE2SDB6IiBzdHlsZT0iZmlsbDpub25lIi8+PHBhdGggZD0iTTAgMGgxNnYxNkgweiIgc3R5bGU9ImZpbGw6bm9uZSIvPjxwYXRoIGQ9Ik0xNS4xNSA4LjVhLjUuNSAwIDAgMC0uNDkxLjQ0MiA2LjY3IDYuNjcgMCAwIDEtMS45MTMgMy44MjhjLTEuMjcgMS4yOC0yLjk3IDEuOTgtNC43NyAxLjk4cy0zLjUtLjctNC43Ny0xLjk4YTYuNjggNi42OCAwIDAgMS0xLjk2LTQuMjdjLS4wMS0uMTctLjAyLS4zMy0uMDItLjVzLjAxLS4zMy4wMi0uNWMuMTItMS42MS44LTMuMTIgMS45Ni00LjI3QzQuODU0IDEuNTY5IDcuMjI2Ljg4NSA5LjYwMiAxLjQzOWMxLjIzNC4yODggMi4zMzQuOTU3IDMuMjE4IDEuODY1LjIxMy4yMi40MTQuNDU0LjU3Ni42OTZoLTEuOTJjLS4yOCAwLS41LjIyLS41LjVzLjIyLjUuNS41aDNhLjQ5NS40OTUgMCAwIDAgLjUtLjV2LTNjMC0uMjgtLjIyLS41LS41LS41cy0uNS4yMi0uNS41djEuNmMtLjE2LS4yLS4zMy0uMzktLjUyLS41OC0xLjUxLTEuNTEtMy41LTIuMjctNS40OC0yLjI3cy0zLjk3Ljc2LTUuNDggMi4yN0E3LjYyIDcuNjIgMCAwIDAgLjI1NiA3LjVjLS4wNC4zMy0uMDQuNjcgMCAxIC4xIDEuODEuODUgMy41OSAyLjI0IDQuOTggMS41MSAxLjUxIDMuNSAyLjI3IDUuNDggMi4yN3MzLjk3LS43NiA1LjQ4LTIuMjdhNy42MyA3LjYzIDAgMCAwIDIuMTg3LTQuNDEyLjUuNSAwIDAgMC0uNDkzLS41NjgiIHN0eWxlPSJ0cmFuc2Zvcm06bWF0cml4KC0xLDAsMCwxLDE2LDApIi8+PC9zdmc+"');Hh.push(")");Hh.push(" 8 0,auto}#gCurParts *,#gridOH,#gridOV{shape-rendering:crispEdges}#gCurParts circle.pindot{fill:silver;fill-opacity:.6;stroke:none}#g1 circle.pindot{fill:none;pointer-events:fill;stroke:none}#g1 .selected circle.pindot{fill:silver;fill-opacity:.6;stroke:none}#g1 circle,#g1 ellipse,#g1 line,#g1 path,#g1 polygon,#g1 polyline,#g1 rect{shape-rendering:auto}#g1 path[d*=A],#g1 path[d*=C]{shape-rendering:initial}#g1 g[c_partid=sheet]{pointer-events:none}#g1>g[c_partid=sheet]>.editing{pointer-events:all}#g1 .object-unselectable:not([c_partid=part]):not([c_partid=block_symbol]):not([c_partid=short_symbol]):not([c_partid=noneElec_symbol]):not([c_partid=netport]):not([c_partid=netflag]):not([c_partid=part_pin]){pointer-events:none}#g1 .object-unselectable:not([c_partid=part]):not([c_partid=block_symbol]):not([c_partid=short_symbol]):not([c_partid=noneElec_symbol]):not([c_partid=netport]):not([c_partid=netflag]):not([c_partid=part_pin])>*{pointer-events:inherit}#g1 .none-events *{pointer-events:none!important}#g1 .hidden,#g1 .invisible-part-object{display:none}#g1 rect.to-be-updated-symbol{pointer-events:none}circle,ellipse,line,path,polygon,polyline,rect{stroke-linecap:round;stroke-linejoin:round}#textBoxContainer{background-color:var(--bg-color-input);-o-box-shadow:0 0 10px 5px #666;box-shadow:0 0 10px 5px #666;font-size:12px;overflow:auto;padding:2px;position:absolute;resize:both}#textBoxContainer div.tip{color:#978e8e;margin-left:1px}#bodyPlaceholder{height:100px;margin:0;width:100px}.fixed-center{left:50%;position:fixed;top:-1000px;-moz-transform:translate(-50%);-webkit-transform:translate(-50%);transform:translate(-50%)}.one-time-tip{background-color:rgba(0,0,0,.5);color:#fff;font-family:Arial;padding:10px;top:10px}.one-time-tip .content{max-width:700px;white-space:nowrap}.one-time-tip .content+.content{margin-top:6px}.one-time-tip em{color:#ff0}.one-time-tip .btns{text-align:right}text{cursor:default}.events-all{pointer-events:all}.cursor-none{cursor:none}.hide{display:none}#cross-text{background:#fff;font-size:12px;padding:5px 10px;pointer-events:none;position:absolute}#gridCell *{vector-effect:non-scaling-stroke}#gridCell [type=line]{stroke-width:.5}");Hh=Hh.join("");function h_(){let e=document.createElement("style");e.innerHTML=Hh,document.head.appendChild(e)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",h_):h_();d_.exports={hitbox:"hitbox",highlight:"highlight",selected:"selected",hidetext:"hidetext",gControlDots:"gControlDots",light:"light",gControlLines:"gControlLines",gControlRects:"gControlRects",selectBox1:"selectBox1","bw-chrome":"bw-chrome","cursor-cross-red":"cursor-cross-red","cursor-grab":"cursor-grab","cursor-grabbing":"cursor-grabbing","cursor-crosshair":"cursor-crosshair","cursor-row-resize":"cursor-row-resize","cursor-col-resize":"cursor-col-resize","cursor-zoom-in":"cursor-zoom-in","cursor-zoom-out":"cursor-zoom-out",gCurParts:"gCurParts",gridOH:"gridOH",gridOV:"gridOV",pindot:"pindot",g1:"g1",editing:"editing","object-unselectable":"object-unselectable","none-events":"none-events",hidden:"hidden","invisible-part-object":"invisible-part-object","to-be-updated-symbol":"to-be-updated-symbol",textBoxContainer:"textBoxContainer",tip:"tip",bodyPlaceholder:"bodyPlaceholder","fixed-center":"fixed-center","one-time-tip":"one-time-tip",content:"content",btns:"btns","events-all":"events-all","cursor-none":"cursor-none",hide:"hide","cross-text":"cross-text",gridCell:"gridCell"}});var g_=$c((Zte,m_)=>{var f_=[];f_.push(`<defs id="patterns">
	<pattern id="gridPattern" x="0" y="0" width="5" height="5" patternUnits="userSpaceOnUse">
		<g id="gridCell"></g>
		<!-- <rect id="gridCell" x="0" y="0" width="1" height="1" fill="#CCCCCC" stroke="none" fill-opacity="0.8" type="dot"></rect> -->
	</pattern>
	<pattern id="chessPattern" x="0" y="0" width="16" height="16" patternUnits="userSpaceOnUse">
		<rect x="0" y="0" width="16" height="16" fill="#fff"></rect>
		<polyline points="0,8 8,0, 16,8 8,16" stroke="none" fill="#999"></polyline>
	</pattern>

	<pattern id="transparent-pattern" x="0" y="0" width="16" height="16" patternUnits="userSpaceOnUse">
		<rect x="0" y="0" width="16" height="16" fill="#fff" stroke="none"></rect>
		<rect x="0" y="0" width="8" height="8" fill="#dfdfdf" stroke="none"></rect>
		<rect x="8" y="8" width="8" height="8" fill="#dfdfdf" stroke="none"></rect>
	</pattern>

	<filter id="inset-shadow" x="-50%" y="-50%" width="200%" height="200%">
		<feComponentTransfer in="SourceAlpha">
			<feFuncA type="table" tableValues="1 0"></feFuncA>
		</feComponentTransfer>

		<feGaussianBlur stdDeviation="10"></feGaussianBlur>

		<feOffset dx="0" dy="0" result="offsetblur"></feOffset>

		<feFlood flood-color="#eee" result="color"></feFlood>

		<feComposite in2="offsetblur" operator="in"></feComposite>
		<feComposite in2="SourceAlpha" operator="in"></feComposite>

		<feMerge>
			<feMergeNode in="SourceGraphic"></feMergeNode>
			<feMergeNode></feMergeNode>
			<feMergeNode></feMergeNode>
			<feMergeNode></feMergeNode>
			<feMergeNode></feMergeNode>
		</feMerge>
	</filter>

	<pattern id="grid-45-degree" x="0" y="0" width="8" height="8" patternUnits="userSpaceOnUse">
		<rect x="0" y="0" width="8" height="8" fill="#fff"></rect>
		<line x1="0" y1="0" x2="8" y2="8" stroke="#ccc" fill="none"></line>
		<line x1="8" y1="0" x2="0" y2="8" stroke="#ccc" fill="none"></line>
	</pattern>

	<pattern id="slashPattern" x="0" y="0" width="16" height="16" patternUnits="userSpaceOnUse">
		<rect x="0" y="0" width="16" height="16" fill="#ccc" stroke="none"></rect>
		<path d="M 8 0 L 16 0 0 16 0 8 Z M 8 16 L 16 8 16 16 Z" fill="#999" stroke="none"></path>
	</pattern>

	<svg id="icon-lock" viewBox="0 0 20 20" height="20" width="20">
		<path
			stroke="#F0F"
			stroke-width="2"
			style="cursor:pointer;fill-opacity:0.001;fill:#fff;"
			d="M 5 7 C 5 -1 15 -1 15 7L1 7 1 19 19 19 19 7 15 7"
		></path>
	</svg>
</defs>
`);m_.exports=f_.join("")});var y_=$c((Qte,W6)=>{W6.exports="data:image/gif;base64,R0lGODlhXwBfAIAAAP////8AACH5BAEHAAAALAAAAABfAF8AAALshI+py23hopy02gOv3nznDobiM5am9Z3qiqTsa7rwDMr0fdn4Lun8v/ABhySiUSE88pJKHLNJe0Jh0imralVhszHucOsVgcM18tK8G6M16jXKHYXP2vJe/UW/N/L6YF/7d8IXiEFYMmiISKgYyPjn2AepJ3lHWWcphwmn2RPg+QkaKjpKWgphipqqyhnBiuZqBksmG0brZcuFm6VrxTvlCwXcJKxEfGRshEyk/GU4wgwE/SN95hxCnWZ9rV3GzYHt5P0t7kHOZp6D/qZOAX7jHsc+AT8nP29vh+9AT6W/778HIAN+eAT6MZgAWAEAOw=="});var b_=$c((eie,q6)=>{q6.exports="data:image/gif;base64,R0lGODlhEAAQAJEAAP////Ly8gAAAP///yH5BAEHAAMALAAAAAAQABAAAAI1nD8iyLkCgFoMSotrVHsnhHWXdISS+AiBFbXY28Yuy8pkYtsUnrtl7wEBdz9dw1ALNpK3QQEAOw=="});var x_=$c((tie,J6)=>{J6.exports="data:image/gif;base64,R0lGODlhEAAQAJEAAP///wAAAP///wAAACH5BAEHAAIALAAAAAAQABAAAAIrlI+py+0PVQhiVioBCJpvfHjauG2JSHbIlJIg2poGnIJzrJ6xvbZ86DsUAAA7"});var S_=$c((iie,E_)=>{var Eo=[];Eo.push(`<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title></title>

		`);Eo.push(u_());Eo.push(`

		<style type="text/css" id="themeStyle"></style>
		<link href="`);Eo.push(p_());Eo.push(`" rel="stylesheet" />
	</head>

	<body>
		<div id="bodyPlaceholder"></div>
		<svg
			id="root"
			width="1200"
			height="1200"
			style="left:0px;top:0px;"
			viewBox="0 0 1200 1200"
			preserveAspectRatio="xMinYMin"
			xmlns="http://www.w3.org/2000/svg"
			xmlns:xlink="http://www.w3.org/1999/xlink"
		>
			`);Eo.push(g_());Eo.push(`

			<defs>
				<filter id="feColorMatrixRed" x="0" y="0" width="100%" height="100%">
					<feColorMatrix
						type="matrix"
						in="SourceGraphic"
						values="0 0 0 2 0 0 0
											0 0 0 0 0 0 0 0 0 0 0 1 0"
					/>
				</filter>
				<filter id="feColorInvert" x="0" y="0" width="100%" height="100%">
					<feColorMatrix
						type="matrix"
						in="SourceGraphic"
						values="-1 0 0 0 1 0
												-1 0 0 1 0 0 -1 0 1 0 0 0 1 0"
					/>
				</filter>
				<filter id="feGaussianBlur">
					<feGaussianBlur in="SourceAlpha" stdDeviation="2" />
					<feOffset dx="0" dy="0"></feOffset>
					<feMerge>
						<feMergeNode></feMergeNode>
						<feMergeNode in="SourceGraphic"></feMergeNode>
					</feMerge>
				</filter>
			</defs>

			<!-- grid -->
			<rect id="gridBg" pointer-events="none" x="0" y="0" width="100%" height="100%" fill="none" stroke="none" />

			<!-- centra cross -->
			<line id="gridOH" pointer-events="none" x1="0" y1="-300" x2="100%" y2="-300" stroke="#666666" stroke-width="1" stroke-opacity=".3" />
			<line id="gridOV" pointer-events="none" x1="-400" y1="0" x2="-400" y2="100%" stroke="#666666" stroke-width="1" stroke-opacity=".3" />
			<!-- begin canvas -->
			<g id="g1" class="shapeBox"></g>
			<!-- end canvas -->

			<polygon
				points=""
				fill="none"
				stroke-dasharray="3, 3"
				vector-effect="non-scaling-stroke"
				stroke-width="1px"
				id="selection-polygon"
				display="none"
			></polygon>

			<polyline
				points=""
				fill="none"
				stroke-dasharray="3, 3"
				vector-effect="non-scaling-stroke"
				stroke-width="1px"
				id="selection-polyline"
				display="none"
				style="stroke: var(--selectColor);"
			></polyline>

			<!-- \u63D0\u5347\u7EC4\u5408\u91CC\u56FE\u5143\u7684\u5BB9\u5668 -->
			<g id="combination-container" pointer-events="none" style="pointer-events: none;"></g>

			<rect
				id="selectBox1"
				x="0"
				y="0"
				width="30"
				height="30"
				fill="none"
				stroke="blue"
				stroke-width="1"
				vector-effect="non-scaling-stroke"
				shape-rendering="crispEdges"
				pointer-events="none"
				display="none"
			/>

			<!-- \u63A7\u5236\u6846\u8FB9\u754C\u7EBF\u4E13\u7528 -->
			<polyline
				points=""
				fill="none"
				stroke-dasharray="3, 3"
				vector-effect="non-scaling-stroke"
				stroke-width="1px"
				id="ctrl-polyline"
				display="none"
				style="stroke: var(--selectColor);pointer-events: none;"
			></polyline>

			<!-- \u9009\u62E9\u5BF9\u8C61 -> \u77E9\u5F62 -->
			<rect
				x="0"
				y="0"
				width="0"
				height="0"
				fill="none"
				stroke-dasharray="3, 3"
				vector-effect="non-scaling-stroke"
				stroke-width="1px"
				id="selection-rect"
				display="none"
				style="stroke: var(--selectColor);pointer-events: none;"
			></rect>

			<g id="container-for-create-stroke" style="pointer-events: none;"></g>

			<g id="gCursors" pointer-events="none">
				<image
					id="cross-red"
					transform="translate(-48,-48)"
					xlink:href="`);Eo.push(y_());Eo.push(`"
					height="95"
					width="95"
					x="0"
					y="0"
					display="none"
				/>
				<image
					id="cursor-hand"
					transform="translate(-3,-6)"
					xlink:href="`);Eo.push(b_());Eo.push(`"
					height="16"
					width="16"
					x="0"
					y="0"
					display="none"
				/>
				<image
					id="cursor-grab"
					transform="translate(-3,-6)"
					xlink:href="`);Eo.push(x_());Eo.push(`"
					height="16"
					width="16"
					x="0"
					y="0"
					display="none"
				/>
			</g>

			<g id="gControlLocks">
				<g id="clock0" display="none">
					<use x="100" y="80" width="20" height="20" xlink:href="#icon-lock" />
					<rect
						x="100"
						y="100"
						width="100"
						height="100"
						fill="none"
						stroke="#F0F"
						stroke-width="1"
						stroke-dasharray="3,3"
						pointer-events="none"
						vector-effect="non-scaling-stroke"
					/>
				</g>
			</g>
			<g id="gControlRects" pointer-events="none">
				<rect
					id="crect0"
					x="0"
					y="0"
					width="1"
					height="1"
					stroke-width="1"
					stroke-dasharray="3,3"
					stroke="#0000CC"
					fill="none"
					visibility="hidden"
				/>
			</g>
			<g id="gControlLines" pointer-events="none">
				<line id="cline0" x1="0" y1="0" x2="1" y2="1" stroke-width="1" stroke-dasharray="3,3" stroke="#0000CC" visibility="hidden" />
			</g>
			<g id="gControlDots" class="hide"></g>

			<g id="gCurParts" pointer-events="none"></g>

			<circle id="gMarkError" cx="360" cy="350" r="2.5" fill="none" stroke="#FF0000" visibility="hidden" />
			<path
				id="cross-x"
				class="cross-path"
				d="M0 0 v0"
				stroke-dasharray="2,2"
				fill="none"
				stroke="red"
				stroke-width="1"
				vector-effect="non-scaling-stroke"
				shape-rendering="crispEdges"
				pointer-events="none"
			/>
			<path
				id="cross-y"
				class="cross-path"
				d="M0 0 h0"
				stroke-dasharray="2,2"
				fill="none"
				stroke="red"
				stroke-width="1"
				vector-effect="non-scaling-stroke"
				shape-rendering="crispEdges"
				pointer-events="none"
			/>
		</svg>
		<input type="hidden" id="mouse-x-for-test" />
		<input type="hidden" id="mouse-y-for-test" />
		<div id="cross-text" class="i18n hide"></div>
	</body>
</html>
`);E_.exports=Eo.join("")});var gb=$c((aie,L_)=>{"use strict";var iv=Object.defineProperty,K6=Object.getOwnPropertyDescriptor,$6=Object.getOwnPropertyNames,Z6=Object.prototype.hasOwnProperty,Q6=(e,t)=>{for(var i in t)iv(e,i,{get:t[i],enumerable:!0})},e8=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $6(t))!Z6.call(e,n)&&n!==i&&iv(e,n,{get:()=>t[n],enumerable:!(r=K6(t,n))||r.enumerable});return e},t8=e=>e8(iv({},"__esModule",{value:!0}),e),v_={};Q6(v_,{BroadcastChannelMessageBus:()=>b8,MessageBus:()=>p8,MessageBus2:()=>g8,MessageBusTask:()=>ev,MessageBusTask2:()=>ly,WindowMessageBridge:()=>d8,WorkerMessageBridge:()=>h8,createBroadcastP2PStream:()=>__,createBufferedByteBufferStream:()=>D_,createBufferedStream:()=>sv,createBufferedStringStream:()=>C_,dropP2PStream:()=>x8,flowRead:()=>S8,flowWrite:()=>E8});L_.exports=t8(v_);var fb=class{constructor(e=1.5){this.growthFactor=e,this.capacity=10,this.buffer=new Array(this.capacity),this.head=0,this.tail=0,this.count=0}enqueue(e){if(this.count===this.capacity){let t=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,t);let i=new Array(t);for(let r=0;r<this.count;r++)i[r]=this.buffer[(this.head+r)%this.capacity];this.buffer=i,this.head=0,this.tail=this.count,this.capacity=t}this.buffer[this.tail]=e,this.tail=(this.tail+1)%this.capacity,this.count++}dequeue(){if(this.isEmpty())return;let e=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,e}peek(){return this.buffer[this.head]}isEmpty(){return this.count===0}clear(){this.buffer.length=0,this.head=0,this.tail=0,this.count=0}},rv=new ArrayBuffer(8),rie=new Float64Array(rv),nie=new Uint32Array(rv),sie=new Uint16Array(rv),Qw=ArrayBuffer;try{Qw=self.HTMLImageElement||Qw}catch{}var i8=typeof SharedArrayBuffer<"u";function mb(e){if(typeof e!="object"||e===null||e instanceof Date||e instanceof ArrayBuffer||i8&&e instanceof SharedArrayBuffer||e instanceof Blob||e instanceof FormData||e instanceof Function||e instanceof Uint8ClampedArray||e instanceof Qw)return e;if(Array.isArray(e))return e.map(mb);{let t={};for(let i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=mb(e[i]));return t}}function Zw(e,t){return r8(e,t,()=>[])}function r8(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var n8=class{constructor(e){this.maxResources=e,this.idle=new fb,this.isClosed=!1,this.resources=e}acquire(e){this.isClosed?Promise.resolve(!1).then(e):this.resources>0?(this.resources--,Promise.resolve(!0).then(e)):this.idle.enqueue(e)}acquireSync(){return new Promise(e=>{this.acquire(e)})}release(){if(!this.isClosed){let e=this.idle.dequeue();e?Promise.resolve(!0).then(e):this.resources++}}close(){if(!this.isClosed)for(this.isClosed=!0;!this.idle.isEmpty();){let e=this.idle.dequeue();Promise.resolve(!1).then(e)}}};function s8(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global}function a8(e,t){let i=0,r=e.length;for(let n=0;n<r;n++)e[n]===t&&(e.splice(n,1),n--,r--,i++);return i}var o8=s8(),l8=o8.WeakRef||(e=>e);function sp(e){if(e!=null){if(typeof e=="object")return new l8(e);console.error(e,e instanceof Object,typeof e);return}}function jh(e){return e==null?void 0:e.deref()}var c8="_MSG_BUS_RPC_",nv=300*1e3,u8=(e=>(e.PUBLISH="publish",e.SUBSCRIBE="subscribe",e.PUSH="push",e.PULL="pull",e))(u8||{}),T_=class{constructor(e){this.bus=e}processRemoteMessage(e,t){let i=sp(t),r=e.topic,n=e.type,s=e.message;switch(n){case"pull":this.bus.pull(r,a=>{this.push(r,a,jh(i))});break;case"subscribe":this.bus.subscribe(r,a=>{this.publish(r,a,jh(i))});break;case"publish":this.bus.publish(r,s,this,jh(i));break;case"push":this.bus.push(r,s,this,jh(i));break;default:console.debug("unknown message type "+n)}}rpcCall(e,t,i,r=nv){let n=sp(i),s=new Promise(a=>{let o=this.bus.uniqueRpcTopic(e);this.publish(e,{message:t,reply:o},jh(n)),this.bus.pull(o,(l,c,u)=>{a({message:l,bridge:c,source:sp(u)})})});return r>0?Promise.race([s,new Promise((a,o)=>{setTimeout(o,r)})]):s}},h8=class extends T_{constructor(e,t){super(e),this.worker=t,t.onmessage=i=>{this.processRemoteMessage(i.data,void 0)}}publish(e,t){this.postMessage(e,"publish",t)}subscribe(e){this.postMessage(e,"subscribe",null)}push(e,t){this.postMessage(e,"push",t)}pull(e){this.postMessage(e,"pull",null)}rpcCall(e,t,i=nv){return super.rpcCall(e,t,void 0,i)}postMessage(e,t,i){let r={topic:e,type:t,message:i};this.worker.postMessage(r)}discard(){this.worker.terminate()}},d8=class extends T_{constructor(e){super(e),window.addEventListener("message",t=>{this.processRemoteMessage(t.data,t.source)},!1)}publish(e,t,i){this.postMessage(e,"publish",t,i)}subscribe(e,t){if(t===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(e,"subscribe",null,t)}push(e,t,i){this.postMessage(e,"push",t,i)}pull(e,t){if(t===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(e,"pull",null,t)}postMessage(e,t,i,r){let n={topic:e,type:t,message:i};r&&r.postMessage(n,"*")}},ev=class{constructor(e){this.isRunning=!0,this.callback=e}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}execute(e,t,i,r){try{e=r?e:mb(e),this.callback(e,t,i)}catch(n){console.error(n)}}},p8=class{constructor(e=!1){this.subscribed={},this.pulled={},this.pushed={},this.uuid=crypto.randomUUID().replace(/-/g,""),this.rpcTicket=0,this.unsafe=e}uniqueRpcTopic(e){return`${c8}-${e}-${this.uuid}-${this.rpcTicket++}`}publish(e,t,i,r){let n=this.subscribed[e];if(n){let s;for(let a of n)a.running()?a.execute(t,i,r,this.unsafe):(s=s||new Array,s.push(a));if(s)for(let a of s)a8(n,a)}else console.debug("no sub on topic: "+e)}subscribe(e,t){let i=new ev(t);return Zw(this.subscribed,e).push(i),i}push(e,t,i,r){let n=!1,s=this.pulled[e];if(s){for(;s.length>0;){let a=s.shift();if(a.running()){a.execute(t,i,r,this.unsafe),n=!0;break}}s.length===0&&delete this.pulled[e]}n||Zw(this.pushed,e).push({message:t,bridge:i,source:sp(r)})}pull(e,t){let i=new ev(t),r=this.pushed[e];if(r){let n=r.shift();i.execute(n.message,n.bridge,jh(n.source),this.unsafe),r.length===0&&delete this.pushed[e]}else Zw(this.pulled,e).push(i);return i}pullA(e){return new Promise(t=>{this.pull(e,(i,r,n)=>{t({message:i,bridge:r,source:sp(n)})})})}rpcService(e,t){this.subscribe(e,(i,r,n)=>{let{message:s,reply:a}=i;try{let o=t(s);if(o instanceof Promise){let l=sp(n);o.then(c=>{this.rpcReply(c,a,r,jh(l))},c=>{console.error(c),this.rpcReply(void 0,a,r,jh(l))})}else this.rpcReply(o,a,r,n)}catch(o){console.error(o),this.rpcReply(void 0,a,r,n)}})}rpcCall(e,t,i=nv){let r=new Promise(n=>{let s=this.uniqueRpcTopic(e);this.publish(e,{message:t,reply:s}),this.pull(s,(a,o,l)=>{n({message:a,bridge:o,source:sp(l)})})});return i>0?Promise.race([r,new Promise((n,s)=>{setTimeout(s,i)})]):r}rpcReply(e,t,i,r){i?i.push(t,e,r):this.push(t,e)}},f8="_MSG_BUS_RPC_";function tv(e,t){let i=0,r=e.length;for(let n=0;n<r;n++)e[n]===t&&(e.splice(n,1),n--,r--,i++);return i}function If(e,t){return m8(e,t,()=>[])}function m8(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var ly=class{constructor(e,t){this.callback=e,this.unsafe=t,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(e){try{e=this.unsafe?e:mb(e),this.callback(e)}catch(t){console.error(t)}}},I_=class{constructor(e=crypto.randomUUID()){this.uuid=e,this.rpcTicket=0}subscribeOnce(e,t){let i=this.subscribe(e,r=>{i.cancel(),t(r)});return i}pullA(e){return new Promise(t=>{this.pull(e,t)})}rpcService(e,t){let i=r=>{try{let{message:n,replyTopic:s}=r;try{let a=t(n);a instanceof Promise?a.then(o=>{this.publish(s,{success:!0,result:o})}).catch(o=>{console.error(o),this.publish(s,{success:!1,err:String(o)})}):this.publish(s,{success:!0,result:a})}catch(a){this.publish(s,{success:!1,err:String(a)})}}finally{this.pull(e,i)}};this.pull(e,i)}rpcCall(e,t,i=0){let r=new Promise((n,s)=>{let a=`${f8}-${e}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(a,o=>{o.success?n(o.result):s(new Error(o.err))}),this.push(e,{message:t,replyTopic:a})});return i>0?Promise.race([r,new Promise((n,s)=>{setTimeout(s,i)})]):r}},g8=class extends I_{constructor(e=!1){super(),this.unsafe=e,this.subscribed={},this.pulled={},this.pushed={}}publish(e,t){let i=this.subscribed[e];if(i){let r;for(let n of i)n.running()?n.execute(t):(r=r||new Array,r.push(n));if(r)for(let n of r)tv(i,n)}}subscribe(e,t){let i=new ly(t,this.unsafe);return If(this.subscribed,e).push(i),i}push(e,t){let i=!1,r=this.pulled[e];if(r){for(;r.length>0;){let n=r.shift();if(n&&n.running()){n.execute(t),i=!0;break}}r.length===0&&delete this.pulled[e]}i||If(this.pushed,e).push(t)}pull(e,t){let i=new ly(t,this.unsafe);return this.repull(e,i),i}repull(e,t){let i=this.pushed[e];if(i){let r=i.shift();r&&(t.execute(r),i.length===0&&delete this.pushed[e])}else If(this.pulled,e).push(t)}},y8=class extends I_{constructor(e=crypto.randomUUID()){super(e),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(e,t){console.debug("BC",this.uuid,"PUBLISH",e,t),this.broadcastPublish(e,t)}subscribe(e,t){console.debug("BC",this.uuid,"SUBSCRIBE",e);let i=new ly(t,!0);return If(this.subscribed,e).push(i),i}push(e,t){let i=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",e,`(${i})`,t),If(this.pushed,e).push({id:i,message:t}),this.broadcastPushedHeadMessage(e)}pull(e,t){console.debug("BC",this.uuid,"PULL",e);let i=new ly(t,!0);return If(this.pulled,e).push(i),this.broadcastWhoHas(e),i}broadcastPushedHeadMessage(e){let t=this.pushed[e];t&&t[0]&&this.broadcastIHave(e,t[0].id)}onReceivedPublish(e,t,i){console.debug("BCMSG(",this.uuid,")","from",e,"PUBLISH",t,"message",i);let r=this.subscribed[t];if(r){let n;for(let s of r)s.running()?s.execute(i):(n=n||new Array,n.push(s));if(n)for(let s of n)tv(r,s);r.length===0&&delete this.subscribed[t]}}onReceivedWhoHas(e,t){console.debug("BCMSG(",this.uuid,")","from",e,"WHOHAS",t),this.broadcastPushedHeadMessage(t)}onReceivedIHave(e,t,i){console.debug("BCMSG(",this.uuid,")","from",e,"IHAVE",t,"id",i);let r=this.pulled[t];if(r){let n;for(let s of r)if(s.running()){this.broadcastINeed(t,e,i);break}else n=n||new Array,n.push(s);if(n)for(let s of n)tv(r,s);r.length===0&&delete this.pulled[t]}}onReceivedINeed(e,t,i,r){if(console.debug("BCMSG(",this.uuid,")","from",e,"INEED",t,"source",i,"id",r),this.uuid===i){let n=this.pushed[t];if(n&&n[0]&&n[0].id===r){let{message:s}=n.shift();this.broadcastIGive(t,r,e,s),this.broadcastPushedHeadMessage(t),n.length===0&&delete this.pushed[t]}}}onReceivedIGive(e,t,i,r,n){console.debug("BCMSG(",this.uuid,")","from",e,"IGIVE",t,"id",i,"target",r,"message",n);let s=this.pulled[t];if(s&&this.uuid===r){let a=!1;for(;s.length>0;){let o=s.shift();if(o.running()){o.execute(n),a=!0;break}}a||this.push(t,n),s.length===0&&delete this.pulled[t]}}},b8=class extends y8{constructor(e,t=crypto.randomUUID()){super(t),this.bc=new BroadcastChannel(e),this.bc.onmessage=i=>{this.onMessage(i.data)}}onMessage(e){let{type:t,uuid:i,topic:r}=e;switch(t){case"PUBLISH":{let{message:n}=e;this.onReceivedPublish(i,r,n);break}case"WHOHAS":{this.onReceivedWhoHas(i,r);break}case"IHAVE":{let{id:n}=e;this.onReceivedIHave(i,r,n);break}case"INEED":{let{source:n,id:s}=e;this.onReceivedINeed(i,r,n,s);break}case"IGIVE":{let{target:n,id:s,message:a}=e;this.onReceivedIGive(i,r,s,n,a);break}default:console.warn("unsupported",e)}}broadcastPublish(e,t){this.post({type:"PUBLISH",uuid:this.uuid,topic:e,message:t})}broadcastWhoHas(e){this.post({type:"WHOHAS",uuid:this.uuid,topic:e})}broadcastIHave(e,t){this.post({type:"IHAVE",uuid:this.uuid,topic:e,id:t})}broadcastINeed(e,t,i){this.post({type:"INEED",uuid:this.uuid,topic:e,source:t,id:i})}broadcastIGive(e,t,i,r){this.post({type:"IGIVE",uuid:this.uuid,topic:e,id:t,target:i,message:r})}post(e){this.bc.postMessage(e),Promise.resolve().then(()=>{this.onMessage(e)})}},Af=Symbol("BLOCKING_QUEUE_RESET"),A_=class{constructor(e,t=()=>1){if(this.maxSize=e,this.itemSizeOf=t,this.queue=new fb,this.waitingConsumers=new fb,this.waitingProducers=new fb,this.queueSize=0,this.closePromise=null,this.closeResolve=null,e<=0)throw new Error("Max size must be greater than 0")}enqueue(e){return this.closePromise?!1:this.isFull()?(async()=>{console.debug("queue is full",this.queueSize,this.maxSize);let t=await new Promise(i=>{this.waitingProducers.enqueue(i)});return console.debug("queue is not full",this.size(),t),t?(this.innerEnqueue(e),!0):!1})():(this.innerEnqueue(e),!0)}innerEnqueue(e){if(this.waitingConsumers.isEmpty())this.queue.enqueue(e),this.queueSize+=this.itemSizeOf(e),console.debug("queue pushed",e,"size",this.queueSize);else{let t=this.waitingConsumers.dequeue();Promise.resolve(e).then(t),console.debug("queue direct",e,"size",this.queueSize)}}dequeue(){if(this.queue.isEmpty())if(this.closePromise){for(;!this.waitingConsumers.isEmpty();){let e=this.waitingConsumers.dequeue();Promise.resolve(Af).then(e)}return setTimeout(()=>this.closeResolve(),0),Af}else return new Promise(e=>{this.waitingConsumers.enqueue(e)});else{let e=this.queue.dequeue();if(this.queueSize-=this.itemSizeOf(e),!this.waitingProducers.isEmpty()){let t=this.waitingProducers.dequeue();Promise.resolve(!0).then(t)}return e}}size(){return this.queueSize}isEmpty(){return this.queueSize===0}isFull(){return this.queueSize>=this.maxSize}close(){return this.closePromise||(this.closePromise=new Promise(e=>{for(this.closeResolve=e;!this.waitingProducers.isEmpty();){let t=this.waitingProducers.dequeue();Promise.resolve(!1).then(t)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let t=this.waitingConsumers.dequeue();Promise.resolve(Af).then(t)}e()}})),this.closePromise}};function sv(e,t,i=Number.MAX_SAFE_INTEGER){let r=new A_(i,t),n=new ReadableStream({pull(a){let o=!0,l=(async()=>{let c=new Array;do{let u=r.dequeue();if(u instanceof Promise){o=!1;let h=await u;h===Af?a.close():c.push(h)}else{let h=u;h===Af?a.close():c.push(h)}}while(r.size()>0);if(c.length>0){let u=e(c);a.enqueue(u)}})();if(!o)return console.debug("read stream stucked --------------------------------------"),l},async cancel(){console.debug("buffered readable cancel"),await r.close()}}),s=new WritableStream({write(a,o){let l=!0,c=(async()=>{let u=r.enqueue(a);typeof u=="boolean"?u||o.error(new Error("Write stream closed")):(l=!1,await u||o.error(new Error("Write stream closed")))})();if(!l)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),c},async close(){console.debug("buffered writable closing",r.size()),await r.close(),console.debug("buffered writable closed",r.size())},async abort(){console.debug("buffered writable aborting",r.size()),await r.close(),console.debug("buffered writable aborted",r.size())}});return{readable:n,writable:s}}function C_(e=Number.MAX_SAFE_INTEGER){return sv(t=>t.join(""),t=>t.length,e)}function D_(e=Number.MAX_SAFE_INTEGER){return sv(t=>{let i=new Uint8Array(t.reduce((n,s)=>n+s.byteLength,0)),r=0;return t.forEach(n=>{i.set(n,r),r+=n.byteLength}),i},t=>t.byteLength,e)}function __(e){return new Promise((t,i)=>{let r=new BroadcastChannel(e),n=new A_(1),s=new n8(1),a=null,o=!1,l=!1,c=!1;r.onmessage=u=>{let h=u.data,{type:d}=h;if(console.debug("p2p",e,"type",d,"data",d==="DATA"&&h.data),d==="DATA")n.enqueue(h.data);else if(d==="HI"){if(!a){r.postMessage({type:"HI"});let g=0;a={rs:new ReadableStream({async pull(b){let y=await n.dequeue();y===Af?(await f(),b.close()):(b.enqueue(y),r.postMessage({type:"ACK"}))},cancel(){return f()}}),ws:new WritableStream({async write(b,y){await s.acquireSync()?r.postMessage({type:"DATA",id:g++,data:b}):(p(),y.error(new Error("Write stream closed")))},close(){p()},abort(){p()}})},t(a)}}else d==="REND"?a?s.close():m("REND1"):d==="WEND"?a?n.close():m("WEND1"):d==="ACK"&&s.release();function p(){o||(o=!0,console.debug(e,"p2p write stream closed"),s.close(),r.postMessage({type:"WEND"}),l&&(console.debug(e,"p2p channel closed on ws"),r.close()))}async function f(){l||(l=!0,console.debug(e,"p2p read stream closed"),r.postMessage({type:"REND"}),await n.close(),o&&(console.debug(e,"p2p channel closed on rs"),r.close()))}async function m(g){c||(c=!0,console.debug(e,"p2p channel connection released on",g),s.close(),n.close(),a?(a.rs.locked||(console.debug(e,"p2p unlocked read stream direct cancel"),a.rs.cancel()),a.ws.locked||(console.debug(e,"p2p unlocked write stream direct close"),a.ws.close())):(r.postMessage({type:"HI"}),r.close()),i(new Error("p2p channel connection released")))}},r.postMessage({type:"HI"})})}function x8(e){return new Promise(t=>{let i=new BroadcastChannel(e);i.onmessage=r=>{let n=r.data,{type:s}=n;s==="HI"&&(i.postMessage({type:"REND"}),i.close(),t())},i.postMessage({type:"REND"})})}async function P_(e){try{return await __(e)}catch(t){t.message!=="p2p channel connection released"&&console.error(t)}}async function E8(e,t,i=10*1024*1024,r=!0){let n=await P_(e);if(!n)return!1;let s=!1;try{let a,o=l=>{if(!a)if(!r)a=n.ws.getWriter();else if(typeof l=="string"){let c=C_(i);c.readable.pipeTo(n.ws),a=c.writable.getWriter()}else{let c=D_(i);c.readable.pipeTo(n.ws),a=c.writable.getWriter()}return a.write(l)};if(Array.isArray(t))for(let l of t)await o(l);else await t({write:o,get desiredSize(){return((a==null?void 0:a.desiredSize)||0)+10}});a&&await a.close(),s=!0}catch(a){console.error(a)}finally{return n.rs.cancel(),s}}async function S8(e,t){var r,n;let i=await P_(e);if(i)try{let s=i.rs.getReader();for((r=t.start)==null?void 0:r.call(t);;){let{value:a,done:o}=await s.read();if(a!==void 0){let l;if(t.update instanceof Promise?l=await t.update(a):l=t.update(a),l){await s.cancel();break}}if(o){(n=t.end)==null||n.call(t);break}}}catch(s){console.error(s)}finally{i.ws.close()}}});var CB=$c((AB,cS)=>{(function(e,t){"use strict";typeof cS=="object"&&typeof cS.exports=="object"?cS.exports=e.document?t(e,!0):function(i){if(!i.document)throw new Error("jQuery requires a window with a document");return t(i)}:t(e)})(typeof window<"u"?window:AB,function(e,t){"use strict";var i=[],r=Object.getPrototypeOf,n=i.slice,s=i.flat?function(v){return i.flat.call(v)}:function(v){return i.concat.apply([],v)},a=i.push,o=i.indexOf,l={},c=l.toString,u=l.hasOwnProperty,h=u.toString,d=h.call(Object),p={},f=function(_){return typeof _=="function"&&typeof _.nodeType!="number"&&typeof _.item!="function"},m=function(_){return _!=null&&_===_.window},g=e.document,b={type:!0,src:!0,nonce:!0,noModule:!0};function y(v,_,Y){Y=Y||g;var W,Z,Q=Y.createElement("script");if(Q.text=v,_)for(W in b)Z=_[W]||_.getAttribute&&_.getAttribute(W),Z&&Q.setAttribute(W,Z);Y.head.appendChild(Q).parentNode.removeChild(Q)}function E(v){return v==null?v+"":typeof v=="object"||typeof v=="function"?l[c.call(v)]||"object":typeof v}var S="3.7.1",w=/HTML$/i,x=function(v,_){return new x.fn.init(v,_)};x.fn=x.prototype={jquery:S,constructor:x,length:0,toArray:function(){return n.call(this)},get:function(v){return v==null?n.call(this):v<0?this[v+this.length]:this[v]},pushStack:function(v){var _=x.merge(this.constructor(),v);return _.prevObject=this,_},each:function(v){return x.each(this,v)},map:function(v){return this.pushStack(x.map(this,function(_,Y){return v.call(_,Y,_)}))},slice:function(){return this.pushStack(n.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(x.grep(this,function(v,_){return(_+1)%2}))},odd:function(){return this.pushStack(x.grep(this,function(v,_){return _%2}))},eq:function(v){var _=this.length,Y=+v+(v<0?_:0);return this.pushStack(Y>=0&&Y<_?[this[Y]]:[])},end:function(){return this.prevObject||this.constructor()},push:a,sort:i.sort,splice:i.splice},x.extend=x.fn.extend=function(){var v,_,Y,W,Z,Q,re=arguments[0]||{},Ee=1,be=arguments.length,De=!1;for(typeof re=="boolean"&&(De=re,re=arguments[Ee]||{},Ee++),typeof re!="object"&&!f(re)&&(re={}),Ee===be&&(re=this,Ee--);Ee<be;Ee++)if((v=arguments[Ee])!=null)for(_ in v)W=v[_],!(_==="__proto__"||re===W)&&(De&&W&&(x.isPlainObject(W)||(Z=Array.isArray(W)))?(Y=re[_],Z&&!Array.isArray(Y)?Q=[]:!Z&&!x.isPlainObject(Y)?Q={}:Q=Y,Z=!1,re[_]=x.extend(De,Q,W)):W!==void 0&&(re[_]=W));return re},x.extend({expando:"jQuery"+(S+Math.random()).replace(/\D/g,""),isReady:!0,error:function(v){throw new Error(v)},noop:function(){},isPlainObject:function(v){var _,Y;return!v||c.call(v)!=="[object Object]"?!1:(_=r(v),_?(Y=u.call(_,"constructor")&&_.constructor,typeof Y=="function"&&h.call(Y)===d):!0)},isEmptyObject:function(v){var _;for(_ in v)return!1;return!0},globalEval:function(v,_,Y){y(v,{nonce:_&&_.nonce},Y)},each:function(v,_){var Y,W=0;if(I(v))for(Y=v.length;W<Y&&_.call(v[W],W,v[W])!==!1;W++);else for(W in v)if(_.call(v[W],W,v[W])===!1)break;return v},text:function(v){var _,Y="",W=0,Z=v.nodeType;if(!Z)for(;_=v[W++];)Y+=x.text(_);return Z===1||Z===11?v.textContent:Z===9?v.documentElement.textContent:Z===3||Z===4?v.nodeValue:Y},makeArray:function(v,_){var Y=_||[];return v!=null&&(I(Object(v))?x.merge(Y,typeof v=="string"?[v]:v):a.call(Y,v)),Y},inArray:function(v,_,Y){return _==null?-1:o.call(_,v,Y)},isXMLDoc:function(v){var _=v&&v.namespaceURI,Y=v&&(v.ownerDocument||v).documentElement;return!w.test(_||Y&&Y.nodeName||"HTML")},merge:function(v,_){for(var Y=+_.length,W=0,Z=v.length;W<Y;W++)v[Z++]=_[W];return v.length=Z,v},grep:function(v,_,Y){for(var W,Z=[],Q=0,re=v.length,Ee=!Y;Q<re;Q++)W=!_(v[Q],Q),W!==Ee&&Z.push(v[Q]);return Z},map:function(v,_,Y){var W,Z,Q=0,re=[];if(I(v))for(W=v.length;Q<W;Q++)Z=_(v[Q],Q,Y),Z!=null&&re.push(Z);else for(Q in v)Z=_(v[Q],Q,Y),Z!=null&&re.push(Z);return s(re)},guid:1,support:p}),typeof Symbol=="function"&&(x.fn[Symbol.iterator]=i[Symbol.iterator]),x.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(v,_){l["[object "+_+"]"]=_.toLowerCase()});function I(v){var _=!!v&&"length"in v&&v.length,Y=E(v);return f(v)||m(v)?!1:Y==="array"||_===0||typeof _=="number"&&_>0&&_-1 in v}function A(v,_){return v.nodeName&&v.nodeName.toLowerCase()===_.toLowerCase()}var O=i.pop,R=i.sort,M=i.splice,F="[\\x20\\t\\r\\n\\f]",G=new RegExp("^"+F+"+|((?:^|[^\\\\])(?:\\\\.)*)"+F+"+$","g");x.contains=function(v,_){var Y=_&&_.parentNode;return v===Y||!!(Y&&Y.nodeType===1&&(v.contains?v.contains(Y):v.compareDocumentPosition&&v.compareDocumentPosition(Y)&16))};var V=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function q(v,_){return _?v==="\0"?"\uFFFD":v.slice(0,-1)+"\\"+v.charCodeAt(v.length-1).toString(16)+" ":"\\"+v}x.escapeSelector=function(v){return(v+"").replace(V,q)};var C=g,N=a;(function(){var v,_,Y,W,Z,Q=N,re,Ee,be,De,He,qe=x.expando,ke=0,at=0,Si=lb(),Sr=lb(),ki=lb(),da=lb(),Ms=function(ue,Te){return ue===Te&&(Z=!0),0},Xc="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",Wc="(?:\\\\[\\da-fA-F]{1,6}"+F+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",ur="\\["+F+"*("+Wc+")(?:"+F+"*([*^$|!~]?=)"+F+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+Wc+"))|)"+F+"*\\]",rp=":("+Wc+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+ur+")*)|.*)\\)|)",Cr=new RegExp(F+"+","g"),ss=new RegExp("^"+F+"*,"+F+"*"),ny=new RegExp("^"+F+"*([>+~]|"+F+")"+F+"*"),jw=new RegExp(F+"|>"),qc=new RegExp(rp),sy=new RegExp("^"+Wc+"$"),Jc={ID:new RegExp("^#("+Wc+")"),CLASS:new RegExp("^\\.("+Wc+")"),TAG:new RegExp("^("+Wc+"|[*])"),ATTR:new RegExp("^"+ur),PSEUDO:new RegExp("^"+rp),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+F+"*(even|odd|(([+-]|)(\\d*)n|)"+F+"*(?:([+-]|)"+F+"*(\\d+)|))"+F+"*\\)|)","i"),bool:new RegExp("^(?:"+Xc+")$","i"),needsContext:new RegExp("^"+F+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+F+"*((?:-\\d)?\\d*)"+F+"*\\)|)(?=[^-]|$)","i")},Uh=/^(?:input|select|textarea|button)$/i,Yh=/^h\d$/i,Sl=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,zw=/[+~]/,Vu=new RegExp("\\\\[\\da-fA-F]{1,6}"+F+"?|\\\\([^\\r\\n\\f])","g"),Hu=function(ue,Te){var Me="0x"+ue.slice(1)-65536;return Te||(Me<0?String.fromCharCode(Me+65536):String.fromCharCode(Me>>10|55296,Me&1023|56320))},M6=function(){Vh()},B6=ub(function(ue){return ue.disabled===!0&&A(ue,"fieldset")},{dir:"parentNode",next:"legend"});function k6(){try{return re.activeElement}catch{}}try{Q.apply(i=n.call(C.childNodes),C.childNodes),i[C.childNodes.length].nodeType}catch{Q={apply:function(Te,Me){N.apply(Te,n.call(Me))},call:function(Te){N.apply(Te,n.call(arguments,1))}}}function en(ue,Te,Me,Ue){var We,yt,Dt,Kt,_t,Ki,bi,Ai=Te&&Te.ownerDocument,$i=Te?Te.nodeType:9;if(Me=Me||[],typeof ue!="string"||!ue||$i!==1&&$i!==9&&$i!==11)return Me;if(!Ue&&(Vh(Te),Te=Te||re,be)){if($i!==11&&(_t=Sl.exec(ue)))if(We=_t[1]){if($i===9)if(Dt=Te.getElementById(We)){if(Dt.id===We)return Q.call(Me,Dt),Me}else return Me;else if(Ai&&(Dt=Ai.getElementById(We))&&en.contains(Te,Dt)&&Dt.id===We)return Q.call(Me,Dt),Me}else{if(_t[2])return Q.apply(Me,Te.getElementsByTagName(ue)),Me;if((We=_t[3])&&Te.getElementsByClassName)return Q.apply(Me,Te.getElementsByClassName(We)),Me}if(!da[ue+" "]&&(!De||!De.test(ue))){if(bi=ue,Ai=Te,$i===1&&(jw.test(ue)||ny.test(ue))){for(Ai=zw.test(ue)&&Xw(Te.parentNode)||Te,(Ai!=Te||!p.scope)&&((Kt=Te.getAttribute("id"))?Kt=x.escapeSelector(Kt):Te.setAttribute("id",Kt=qe)),Ki=ay(ue),yt=Ki.length;yt--;)Ki[yt]=(Kt?"#"+Kt:":scope")+" "+cb(Ki[yt]);bi=Ki.join(",")}try{return Q.apply(Me,Ai.querySelectorAll(bi)),Me}catch{da(ue,!0)}finally{Kt===qe&&Te.removeAttribute("id")}}}return n_(ue.replace(G,"$1"),Te,Me,Ue)}function lb(){var ue=[];function Te(Me,Ue){return ue.push(Me+" ")>_.cacheLength&&delete Te[ue.shift()],Te[Me+" "]=Ue}return Te}function lc(ue){return ue[qe]=!0,ue}function vf(ue){var Te=re.createElement("fieldset");try{return!!ue(Te)}catch{return!1}finally{Te.parentNode&&Te.parentNode.removeChild(Te),Te=null}}function F6(ue){return function(Te){return A(Te,"input")&&Te.type===ue}}function G6(ue){return function(Te){return(A(Te,"input")||A(Te,"button"))&&Te.type===ue}}function i_(ue){return function(Te){return"form"in Te?Te.parentNode&&Te.disabled===!1?"label"in Te?"label"in Te.parentNode?Te.parentNode.disabled===ue:Te.disabled===ue:Te.isDisabled===ue||Te.isDisabled!==!ue&&B6(Te)===ue:Te.disabled===ue:"label"in Te?Te.disabled===ue:!1}}function np(ue){return lc(function(Te){return Te=+Te,lc(function(Me,Ue){for(var We,yt=ue([],Me.length,Te),Dt=yt.length;Dt--;)Me[We=yt[Dt]]&&(Me[We]=!(Ue[We]=Me[We]))})})}function Xw(ue){return ue&&typeof ue.getElementsByTagName<"u"&&ue}function Vh(ue){var Te,Me=ue?ue.ownerDocument||ue:C;return Me==re||Me.nodeType!==9||!Me.documentElement||(re=Me,Ee=re.documentElement,be=!x.isXMLDoc(re),He=Ee.matches||Ee.webkitMatchesSelector||Ee.msMatchesSelector,Ee.msMatchesSelector&&C!=re&&(Te=re.defaultView)&&Te.top!==Te&&Te.addEventListener("unload",M6),p.getById=vf(function(Ue){return Ee.appendChild(Ue).id=x.expando,!re.getElementsByName||!re.getElementsByName(x.expando).length}),p.disconnectedMatch=vf(function(Ue){return He.call(Ue,"*")}),p.scope=vf(function(){return re.querySelectorAll(":scope")}),p.cssHas=vf(function(){try{return re.querySelector(":has(*,:jqfake)"),!1}catch{return!0}}),p.getById?(_.filter.ID=function(Ue){var We=Ue.replace(Vu,Hu);return function(yt){return yt.getAttribute("id")===We}},_.find.ID=function(Ue,We){if(typeof We.getElementById<"u"&&be){var yt=We.getElementById(Ue);return yt?[yt]:[]}}):(_.filter.ID=function(Ue){var We=Ue.replace(Vu,Hu);return function(yt){var Dt=typeof yt.getAttributeNode<"u"&&yt.getAttributeNode("id");return Dt&&Dt.value===We}},_.find.ID=function(Ue,We){if(typeof We.getElementById<"u"&&be){var yt,Dt,Kt,_t=We.getElementById(Ue);if(_t){if(yt=_t.getAttributeNode("id"),yt&&yt.value===Ue)return[_t];for(Kt=We.getElementsByName(Ue),Dt=0;_t=Kt[Dt++];)if(yt=_t.getAttributeNode("id"),yt&&yt.value===Ue)return[_t]}return[]}}),_.find.TAG=function(Ue,We){return typeof We.getElementsByTagName<"u"?We.getElementsByTagName(Ue):We.querySelectorAll(Ue)},_.find.CLASS=function(Ue,We){if(typeof We.getElementsByClassName<"u"&&be)return We.getElementsByClassName(Ue)},De=[],vf(function(Ue){var We;Ee.appendChild(Ue).innerHTML="<a id='"+qe+"' href='' disabled='disabled'></a><select id='"+qe+"-\r\\' disabled='disabled'><option selected=''></option></select>",Ue.querySelectorAll("[selected]").length||De.push("\\["+F+"*(?:value|"+Xc+")"),Ue.querySelectorAll("[id~="+qe+"-]").length||De.push("~="),Ue.querySelectorAll("a#"+qe+"+*").length||De.push(".#.+[+~]"),Ue.querySelectorAll(":checked").length||De.push(":checked"),We=re.createElement("input"),We.setAttribute("type","hidden"),Ue.appendChild(We).setAttribute("name","D"),Ee.appendChild(Ue).disabled=!0,Ue.querySelectorAll(":disabled").length!==2&&De.push(":enabled",":disabled"),We=re.createElement("input"),We.setAttribute("name",""),Ue.appendChild(We),Ue.querySelectorAll("[name='']").length||De.push("\\["+F+"*name"+F+"*="+F+`*(?:''|"")`)}),p.cssHas||De.push(":has"),De=De.length&&new RegExp(De.join("|")),Ms=function(Ue,We){if(Ue===We)return Z=!0,0;var yt=!Ue.compareDocumentPosition-!We.compareDocumentPosition;return yt||(yt=(Ue.ownerDocument||Ue)==(We.ownerDocument||We)?Ue.compareDocumentPosition(We):1,yt&1||!p.sortDetached&&We.compareDocumentPosition(Ue)===yt?Ue===re||Ue.ownerDocument==C&&en.contains(C,Ue)?-1:We===re||We.ownerDocument==C&&en.contains(C,We)?1:W?o.call(W,Ue)-o.call(W,We):0:yt&4?-1:1)}),re}en.matches=function(ue,Te){return en(ue,null,null,Te)},en.matchesSelector=function(ue,Te){if(Vh(ue),be&&!da[Te+" "]&&(!De||!De.test(Te)))try{var Me=He.call(ue,Te);if(Me||p.disconnectedMatch||ue.document&&ue.document.nodeType!==11)return Me}catch{da(Te,!0)}return en(Te,re,null,[ue]).length>0},en.contains=function(ue,Te){return(ue.ownerDocument||ue)!=re&&Vh(ue),x.contains(ue,Te)},en.attr=function(ue,Te){(ue.ownerDocument||ue)!=re&&Vh(ue);var Me=_.attrHandle[Te.toLowerCase()],Ue=Me&&u.call(_.attrHandle,Te.toLowerCase())?Me(ue,Te,!be):void 0;return Ue!==void 0?Ue:ue.getAttribute(Te)},en.error=function(ue){throw new Error("Syntax error, unrecognized expression: "+ue)},x.uniqueSort=function(ue){var Te,Me=[],Ue=0,We=0;if(Z=!p.sortStable,W=!p.sortStable&&n.call(ue,0),R.call(ue,Ms),Z){for(;Te=ue[We++];)Te===ue[We]&&(Ue=Me.push(We));for(;Ue--;)M.call(ue,Me[Ue],1)}return W=null,ue},x.fn.uniqueSort=function(){return this.pushStack(x.uniqueSort(n.apply(this)))},_=x.expr={cacheLength:50,createPseudo:lc,match:Jc,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(ue){return ue[1]=ue[1].replace(Vu,Hu),ue[3]=(ue[3]||ue[4]||ue[5]||"").replace(Vu,Hu),ue[2]==="~="&&(ue[3]=" "+ue[3]+" "),ue.slice(0,4)},CHILD:function(ue){return ue[1]=ue[1].toLowerCase(),ue[1].slice(0,3)==="nth"?(ue[3]||en.error(ue[0]),ue[4]=+(ue[4]?ue[5]+(ue[6]||1):2*(ue[3]==="even"||ue[3]==="odd")),ue[5]=+(ue[7]+ue[8]||ue[3]==="odd")):ue[3]&&en.error(ue[0]),ue},PSEUDO:function(ue){var Te,Me=!ue[6]&&ue[2];return Jc.CHILD.test(ue[0])?null:(ue[3]?ue[2]=ue[4]||ue[5]||"":Me&&qc.test(Me)&&(Te=ay(Me,!0))&&(Te=Me.indexOf(")",Me.length-Te)-Me.length)&&(ue[0]=ue[0].slice(0,Te),ue[2]=Me.slice(0,Te)),ue.slice(0,3))}},filter:{TAG:function(ue){var Te=ue.replace(Vu,Hu).toLowerCase();return ue==="*"?function(){return!0}:function(Me){return A(Me,Te)}},CLASS:function(ue){var Te=Si[ue+" "];return Te||(Te=new RegExp("(^|"+F+")"+ue+"("+F+"|$)"))&&Si(ue,function(Me){return Te.test(typeof Me.className=="string"&&Me.className||typeof Me.getAttribute<"u"&&Me.getAttribute("class")||"")})},ATTR:function(ue,Te,Me){return function(Ue){var We=en.attr(Ue,ue);return We==null?Te==="!=":Te?(We+="",Te==="="?We===Me:Te==="!="?We!==Me:Te==="^="?Me&&We.indexOf(Me)===0:Te==="*="?Me&&We.indexOf(Me)>-1:Te==="$="?Me&&We.slice(-Me.length)===Me:Te==="~="?(" "+We.replace(Cr," ")+" ").indexOf(Me)>-1:Te==="|="?We===Me||We.slice(0,Me.length+1)===Me+"-":!1):!0}},CHILD:function(ue,Te,Me,Ue,We){var yt=ue.slice(0,3)!=="nth",Dt=ue.slice(-4)!=="last",Kt=Te==="of-type";return Ue===1&&We===0?function(_t){return!!_t.parentNode}:function(_t,Ki,bi){var Ai,$i,hi,Tn,bo,Ma=yt!==Dt?"nextSibling":"previousSibling",wl=_t.parentNode,Kc=Kt&&_t.nodeName.toLowerCase(),Tf=!bi&&!Kt,Qa=!1;if(wl){if(yt){for(;Ma;){for(hi=_t;hi=hi[Ma];)if(Kt?A(hi,Kc):hi.nodeType===1)return!1;bo=Ma=ue==="only"&&!bo&&"nextSibling"}return!0}if(bo=[Dt?wl.firstChild:wl.lastChild],Dt&&Tf){for($i=wl[qe]||(wl[qe]={}),Ai=$i[ue]||[],Tn=Ai[0]===ke&&Ai[1],Qa=Tn&&Ai[2],hi=Tn&&wl.childNodes[Tn];hi=++Tn&&hi&&hi[Ma]||(Qa=Tn=0)||bo.pop();)if(hi.nodeType===1&&++Qa&&hi===_t){$i[ue]=[ke,Tn,Qa];break}}else if(Tf&&($i=_t[qe]||(_t[qe]={}),Ai=$i[ue]||[],Tn=Ai[0]===ke&&Ai[1],Qa=Tn),Qa===!1)for(;(hi=++Tn&&hi&&hi[Ma]||(Qa=Tn=0)||bo.pop())&&!((Kt?A(hi,Kc):hi.nodeType===1)&&++Qa&&(Tf&&($i=hi[qe]||(hi[qe]={}),$i[ue]=[ke,Qa]),hi===_t)););return Qa-=We,Qa===Ue||Qa%Ue===0&&Qa/Ue>=0}}},PSEUDO:function(ue,Te){var Me,Ue=_.pseudos[ue]||_.setFilters[ue.toLowerCase()]||en.error("unsupported pseudo: "+ue);return Ue[qe]?Ue(Te):Ue.length>1?(Me=[ue,ue,"",Te],_.setFilters.hasOwnProperty(ue.toLowerCase())?lc(function(We,yt){for(var Dt,Kt=Ue(We,Te),_t=Kt.length;_t--;)Dt=o.call(We,Kt[_t]),We[Dt]=!(yt[Dt]=Kt[_t])}):function(We){return Ue(We,0,Me)}):Ue}},pseudos:{not:lc(function(ue){var Te=[],Me=[],Ue=Kw(ue.replace(G,"$1"));return Ue[qe]?lc(function(We,yt,Dt,Kt){for(var _t,Ki=Ue(We,null,Kt,[]),bi=We.length;bi--;)(_t=Ki[bi])&&(We[bi]=!(yt[bi]=_t))}):function(We,yt,Dt){return Te[0]=We,Ue(Te,null,Dt,Me),Te[0]=null,!Me.pop()}}),has:lc(function(ue){return function(Te){return en(ue,Te).length>0}}),contains:lc(function(ue){return ue=ue.replace(Vu,Hu),function(Te){return(Te.textContent||x.text(Te)).indexOf(ue)>-1}}),lang:lc(function(ue){return sy.test(ue||"")||en.error("unsupported lang: "+ue),ue=ue.replace(Vu,Hu).toLowerCase(),function(Te){var Me;do if(Me=be?Te.lang:Te.getAttribute("xml:lang")||Te.getAttribute("lang"))return Me=Me.toLowerCase(),Me===ue||Me.indexOf(ue+"-")===0;while((Te=Te.parentNode)&&Te.nodeType===1);return!1}}),target:function(ue){var Te=e.location&&e.location.hash;return Te&&Te.slice(1)===ue.id},root:function(ue){return ue===Ee},focus:function(ue){return ue===k6()&&re.hasFocus()&&!!(ue.type||ue.href||~ue.tabIndex)},enabled:i_(!1),disabled:i_(!0),checked:function(ue){return A(ue,"input")&&!!ue.checked||A(ue,"option")&&!!ue.selected},selected:function(ue){return ue.parentNode&&ue.parentNode.selectedIndex,ue.selected===!0},empty:function(ue){for(ue=ue.firstChild;ue;ue=ue.nextSibling)if(ue.nodeType<6)return!1;return!0},parent:function(ue){return!_.pseudos.empty(ue)},header:function(ue){return Yh.test(ue.nodeName)},input:function(ue){return Uh.test(ue.nodeName)},button:function(ue){return A(ue,"input")&&ue.type==="button"||A(ue,"button")},text:function(ue){var Te;return A(ue,"input")&&ue.type==="text"&&((Te=ue.getAttribute("type"))==null||Te.toLowerCase()==="text")},first:np(function(){return[0]}),last:np(function(ue,Te){return[Te-1]}),eq:np(function(ue,Te,Me){return[Me<0?Me+Te:Me]}),even:np(function(ue,Te){for(var Me=0;Me<Te;Me+=2)ue.push(Me);return ue}),odd:np(function(ue,Te){for(var Me=1;Me<Te;Me+=2)ue.push(Me);return ue}),lt:np(function(ue,Te,Me){var Ue;for(Me<0?Ue=Me+Te:Me>Te?Ue=Te:Ue=Me;--Ue>=0;)ue.push(Ue);return ue}),gt:np(function(ue,Te,Me){for(var Ue=Me<0?Me+Te:Me;++Ue<Te;)ue.push(Ue);return ue})}},_.pseudos.nth=_.pseudos.eq;for(v in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})_.pseudos[v]=F6(v);for(v in{submit:!0,reset:!0})_.pseudos[v]=G6(v);function r_(){}r_.prototype=_.filters=_.pseudos,_.setFilters=new r_;function ay(ue,Te){var Me,Ue,We,yt,Dt,Kt,_t,Ki=Sr[ue+" "];if(Ki)return Te?0:Ki.slice(0);for(Dt=ue,Kt=[],_t=_.preFilter;Dt;){(!Me||(Ue=ss.exec(Dt)))&&(Ue&&(Dt=Dt.slice(Ue[0].length)||Dt),Kt.push(We=[])),Me=!1,(Ue=ny.exec(Dt))&&(Me=Ue.shift(),We.push({value:Me,type:Ue[0].replace(G," ")}),Dt=Dt.slice(Me.length));for(yt in _.filter)(Ue=Jc[yt].exec(Dt))&&(!_t[yt]||(Ue=_t[yt](Ue)))&&(Me=Ue.shift(),We.push({value:Me,type:yt,matches:Ue}),Dt=Dt.slice(Me.length));if(!Me)break}return Te?Dt.length:Dt?en.error(ue):Sr(ue,Kt).slice(0)}function cb(ue){for(var Te=0,Me=ue.length,Ue="";Te<Me;Te++)Ue+=ue[Te].value;return Ue}function ub(ue,Te,Me){var Ue=Te.dir,We=Te.next,yt=We||Ue,Dt=Me&&yt==="parentNode",Kt=at++;return Te.first?function(_t,Ki,bi){for(;_t=_t[Ue];)if(_t.nodeType===1||Dt)return ue(_t,Ki,bi);return!1}:function(_t,Ki,bi){var Ai,$i,hi=[ke,Kt];if(bi){for(;_t=_t[Ue];)if((_t.nodeType===1||Dt)&&ue(_t,Ki,bi))return!0}else for(;_t=_t[Ue];)if(_t.nodeType===1||Dt)if($i=_t[qe]||(_t[qe]={}),We&&A(_t,We))_t=_t[Ue]||_t;else{if((Ai=$i[yt])&&Ai[0]===ke&&Ai[1]===Kt)return hi[2]=Ai[2];if($i[yt]=hi,hi[2]=ue(_t,Ki,bi))return!0}return!1}}function Ww(ue){return ue.length>1?function(Te,Me,Ue){for(var We=ue.length;We--;)if(!ue[We](Te,Me,Ue))return!1;return!0}:ue[0]}function U6(ue,Te,Me){for(var Ue=0,We=Te.length;Ue<We;Ue++)en(ue,Te[Ue],Me);return Me}function hb(ue,Te,Me,Ue,We){for(var yt,Dt=[],Kt=0,_t=ue.length,Ki=Te!=null;Kt<_t;Kt++)(yt=ue[Kt])&&(!Me||Me(yt,Ue,We))&&(Dt.push(yt),Ki&&Te.push(Kt));return Dt}function qw(ue,Te,Me,Ue,We,yt){return Ue&&!Ue[qe]&&(Ue=qw(Ue)),We&&!We[qe]&&(We=qw(We,yt)),lc(function(Dt,Kt,_t,Ki){var bi,Ai,$i,hi,Tn=[],bo=[],Ma=Kt.length,wl=Dt||U6(Te||"*",_t.nodeType?[_t]:_t,[]),Kc=ue&&(Dt||!Te)?hb(wl,Tn,ue,_t,Ki):wl;if(Me?(hi=We||(Dt?ue:Ma||Ue)?[]:Kt,Me(Kc,hi,_t,Ki)):hi=Kc,Ue)for(bi=hb(hi,bo),Ue(bi,[],_t,Ki),Ai=bi.length;Ai--;)($i=bi[Ai])&&(hi[bo[Ai]]=!(Kc[bo[Ai]]=$i));if(Dt){if(We||ue){if(We){for(bi=[],Ai=hi.length;Ai--;)($i=hi[Ai])&&bi.push(Kc[Ai]=$i);We(null,hi=[],bi,Ki)}for(Ai=hi.length;Ai--;)($i=hi[Ai])&&(bi=We?o.call(Dt,$i):Tn[Ai])>-1&&(Dt[bi]=!(Kt[bi]=$i))}}else hi=hb(hi===Kt?hi.splice(Ma,hi.length):hi),We?We(null,Kt,hi,Ki):Q.apply(Kt,hi)})}function Jw(ue){for(var Te,Me,Ue,We=ue.length,yt=_.relative[ue[0].type],Dt=yt||_.relative[" "],Kt=yt?1:0,_t=ub(function(Ai){return Ai===Te},Dt,!0),Ki=ub(function(Ai){return o.call(Te,Ai)>-1},Dt,!0),bi=[function(Ai,$i,hi){var Tn=!yt&&(hi||$i!=Y)||((Te=$i).nodeType?_t(Ai,$i,hi):Ki(Ai,$i,hi));return Te=null,Tn}];Kt<We;Kt++)if(Me=_.relative[ue[Kt].type])bi=[ub(Ww(bi),Me)];else{if(Me=_.filter[ue[Kt].type].apply(null,ue[Kt].matches),Me[qe]){for(Ue=++Kt;Ue<We&&!_.relative[ue[Ue].type];Ue++);return qw(Kt>1&&Ww(bi),Kt>1&&cb(ue.slice(0,Kt-1).concat({value:ue[Kt-2].type===" "?"*":""})).replace(G,"$1"),Me,Kt<Ue&&Jw(ue.slice(Kt,Ue)),Ue<We&&Jw(ue=ue.slice(Ue)),Ue<We&&cb(ue))}bi.push(Me)}return Ww(bi)}function Y6(ue,Te){var Me=Te.length>0,Ue=ue.length>0,We=function(yt,Dt,Kt,_t,Ki){var bi,Ai,$i,hi=0,Tn="0",bo=yt&&[],Ma=[],wl=Y,Kc=yt||Ue&&_.find.TAG("*",Ki),Tf=ke+=wl==null?1:Math.random()||.1,Qa=Kc.length;for(Ki&&(Y=Dt==re||Dt||Ki);Tn!==Qa&&(bi=Kc[Tn])!=null;Tn++){if(Ue&&bi){for(Ai=0,!Dt&&bi.ownerDocument!=re&&(Vh(bi),Kt=!be);$i=ue[Ai++];)if($i(bi,Dt||re,Kt)){Q.call(_t,bi);break}Ki&&(ke=Tf)}Me&&((bi=!$i&&bi)&&hi--,yt&&bo.push(bi))}if(hi+=Tn,Me&&Tn!==hi){for(Ai=0;$i=Te[Ai++];)$i(bo,Ma,Dt,Kt);if(yt){if(hi>0)for(;Tn--;)bo[Tn]||Ma[Tn]||(Ma[Tn]=O.call(_t));Ma=hb(Ma)}Q.apply(_t,Ma),Ki&&!yt&&Ma.length>0&&hi+Te.length>1&&x.uniqueSort(_t)}return Ki&&(ke=Tf,Y=wl),bo};return Me?lc(We):We}function Kw(ue,Te){var Me,Ue=[],We=[],yt=ki[ue+" "];if(!yt){for(Te||(Te=ay(ue)),Me=Te.length;Me--;)yt=Jw(Te[Me]),yt[qe]?Ue.push(yt):We.push(yt);yt=ki(ue,Y6(We,Ue)),yt.selector=ue}return yt}function n_(ue,Te,Me,Ue){var We,yt,Dt,Kt,_t,Ki=typeof ue=="function"&&ue,bi=!Ue&&ay(ue=Ki.selector||ue);if(Me=Me||[],bi.length===1){if(yt=bi[0]=bi[0].slice(0),yt.length>2&&(Dt=yt[0]).type==="ID"&&Te.nodeType===9&&be&&_.relative[yt[1].type]){if(Te=(_.find.ID(Dt.matches[0].replace(Vu,Hu),Te)||[])[0],Te)Ki&&(Te=Te.parentNode);else return Me;ue=ue.slice(yt.shift().value.length)}for(We=Jc.needsContext.test(ue)?0:yt.length;We--&&(Dt=yt[We],!_.relative[Kt=Dt.type]);)if((_t=_.find[Kt])&&(Ue=_t(Dt.matches[0].replace(Vu,Hu),zw.test(yt[0].type)&&Xw(Te.parentNode)||Te))){if(yt.splice(We,1),ue=Ue.length&&cb(yt),!ue)return Q.apply(Me,Ue),Me;break}}return(Ki||Kw(ue,bi))(Ue,Te,!be,Me,!Te||zw.test(ue)&&Xw(Te.parentNode)||Te),Me}p.sortStable=qe.split("").sort(Ms).join("")===qe,Vh(),p.sortDetached=vf(function(ue){return ue.compareDocumentPosition(re.createElement("fieldset"))&1}),x.find=en,x.expr[":"]=x.expr.pseudos,x.unique=x.uniqueSort,en.compile=Kw,en.select=n_,en.setDocument=Vh,en.tokenize=ay,en.escape=x.escapeSelector,en.getText=x.text,en.isXML=x.isXMLDoc,en.selectors=x.expr,en.support=x.support,en.uniqueSort=x.uniqueSort})();var T=function(v,_,Y){for(var W=[],Z=Y!==void 0;(v=v[_])&&v.nodeType!==9;)if(v.nodeType===1){if(Z&&x(v).is(Y))break;W.push(v)}return W},L=function(v,_){for(var Y=[];v;v=v.nextSibling)v.nodeType===1&&v!==_&&Y.push(v);return Y},P=x.expr.match.needsContext,B=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function U(v,_,Y){return f(_)?x.grep(v,function(W,Z){return!!_.call(W,Z,W)!==Y}):_.nodeType?x.grep(v,function(W){return W===_!==Y}):typeof _!="string"?x.grep(v,function(W){return o.call(_,W)>-1!==Y}):x.filter(_,v,Y)}x.filter=function(v,_,Y){var W=_[0];return Y&&(v=":not("+v+")"),_.length===1&&W.nodeType===1?x.find.matchesSelector(W,v)?[W]:[]:x.find.matches(v,x.grep(_,function(Z){return Z.nodeType===1}))},x.fn.extend({find:function(v){var _,Y,W=this.length,Z=this;if(typeof v!="string")return this.pushStack(x(v).filter(function(){for(_=0;_<W;_++)if(x.contains(Z[_],this))return!0}));for(Y=this.pushStack([]),_=0;_<W;_++)x.find(v,Z[_],Y);return W>1?x.uniqueSort(Y):Y},filter:function(v){return this.pushStack(U(this,v||[],!1))},not:function(v){return this.pushStack(U(this,v||[],!0))},is:function(v){return!!U(this,typeof v=="string"&&P.test(v)?x(v):v||[],!1).length}});var X,J=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,ne=x.fn.init=function(v,_,Y){var W,Z;if(!v)return this;if(Y=Y||X,typeof v=="string")if(v[0]==="<"&&v[v.length-1]===">"&&v.length>=3?W=[null,v,null]:W=J.exec(v),W&&(W[1]||!_))if(W[1]){if(_=_ instanceof x?_[0]:_,x.merge(this,x.parseHTML(W[1],_&&_.nodeType?_.ownerDocument||_:g,!0)),B.test(W[1])&&x.isPlainObject(_))for(W in _)f(this[W])?this[W](_[W]):this.attr(W,_[W]);return this}else return Z=g.getElementById(W[2]),Z&&(this[0]=Z,this.length=1),this;else return!_||_.jquery?(_||Y).find(v):this.constructor(_).find(v);else{if(v.nodeType)return this[0]=v,this.length=1,this;if(f(v))return Y.ready!==void 0?Y.ready(v):v(x)}return x.makeArray(v,this)};ne.prototype=x.fn,X=x(g);var fe=/^(?:parents|prev(?:Until|All))/,xe={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({has:function(v){var _=x(v,this),Y=_.length;return this.filter(function(){for(var W=0;W<Y;W++)if(x.contains(this,_[W]))return!0})},closest:function(v,_){var Y,W=0,Z=this.length,Q=[],re=typeof v!="string"&&x(v);if(!P.test(v)){for(;W<Z;W++)for(Y=this[W];Y&&Y!==_;Y=Y.parentNode)if(Y.nodeType<11&&(re?re.index(Y)>-1:Y.nodeType===1&&x.find.matchesSelector(Y,v))){Q.push(Y);break}}return this.pushStack(Q.length>1?x.uniqueSort(Q):Q)},index:function(v){return v?typeof v=="string"?o.call(x(v),this[0]):o.call(this,v.jquery?v[0]:v):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(v,_){return this.pushStack(x.uniqueSort(x.merge(this.get(),x(v,_))))},addBack:function(v){return this.add(v==null?this.prevObject:this.prevObject.filter(v))}});function ve(v,_){for(;(v=v[_])&&v.nodeType!==1;);return v}x.each({parent:function(v){var _=v.parentNode;return _&&_.nodeType!==11?_:null},parents:function(v){return T(v,"parentNode")},parentsUntil:function(v,_,Y){return T(v,"parentNode",Y)},next:function(v){return ve(v,"nextSibling")},prev:function(v){return ve(v,"previousSibling")},nextAll:function(v){return T(v,"nextSibling")},prevAll:function(v){return T(v,"previousSibling")},nextUntil:function(v,_,Y){return T(v,"nextSibling",Y)},prevUntil:function(v,_,Y){return T(v,"previousSibling",Y)},siblings:function(v){return L((v.parentNode||{}).firstChild,v)},children:function(v){return L(v.firstChild)},contents:function(v){return v.contentDocument!=null&&r(v.contentDocument)?v.contentDocument:(A(v,"template")&&(v=v.content||v),x.merge([],v.childNodes))}},function(v,_){x.fn[v]=function(Y,W){var Z=x.map(this,_,Y);return v.slice(-5)!=="Until"&&(W=Y),W&&typeof W=="string"&&(Z=x.filter(W,Z)),this.length>1&&(xe[v]||x.uniqueSort(Z),fe.test(v)&&Z.reverse()),this.pushStack(Z)}});var Fe=/[^\x20\t\r\n\f]+/g;function Ne(v){var _={};return x.each(v.match(Fe)||[],function(Y,W){_[W]=!0}),_}x.Callbacks=function(v){v=typeof v=="string"?Ne(v):x.extend({},v);var _,Y,W,Z,Q=[],re=[],Ee=-1,be=function(){for(Z=Z||v.once,W=_=!0;re.length;Ee=-1)for(Y=re.shift();++Ee<Q.length;)Q[Ee].apply(Y[0],Y[1])===!1&&v.stopOnFalse&&(Ee=Q.length,Y=!1);v.memory||(Y=!1),_=!1,Z&&(Y?Q=[]:Q="")},De={add:function(){return Q&&(Y&&!_&&(Ee=Q.length-1,re.push(Y)),(function He(qe){x.each(qe,function(ke,at){f(at)?(!v.unique||!De.has(at))&&Q.push(at):at&&at.length&&E(at)!=="string"&&He(at)})})(arguments),Y&&!_&&be()),this},remove:function(){return x.each(arguments,function(He,qe){for(var ke;(ke=x.inArray(qe,Q,ke))>-1;)Q.splice(ke,1),ke<=Ee&&Ee--}),this},has:function(He){return He?x.inArray(He,Q)>-1:Q.length>0},empty:function(){return Q&&(Q=[]),this},disable:function(){return Z=re=[],Q=Y="",this},disabled:function(){return!Q},lock:function(){return Z=re=[],!Y&&!_&&(Q=Y=""),this},locked:function(){return!!Z},fireWith:function(He,qe){return Z||(qe=qe||[],qe=[He,qe.slice?qe.slice():qe],re.push(qe),_||be()),this},fire:function(){return De.fireWith(this,arguments),this},fired:function(){return!!W}};return De};function nt(v){return v}function je(v){throw v}function vt(v,_,Y,W){var Z;try{v&&f(Z=v.promise)?Z.call(v).done(_).fail(Y):v&&f(Z=v.then)?Z.call(v,_,Y):_.apply(void 0,[v].slice(W))}catch(Q){Y.apply(void 0,[Q])}}x.extend({Deferred:function(v){var _=[["notify","progress",x.Callbacks("memory"),x.Callbacks("memory"),2],["resolve","done",x.Callbacks("once memory"),x.Callbacks("once memory"),0,"resolved"],["reject","fail",x.Callbacks("once memory"),x.Callbacks("once memory"),1,"rejected"]],Y="pending",W={state:function(){return Y},always:function(){return Z.done(arguments).fail(arguments),this},catch:function(Q){return W.then(null,Q)},pipe:function(){var Q=arguments;return x.Deferred(function(re){x.each(_,function(Ee,be){var De=f(Q[be[4]])&&Q[be[4]];Z[be[1]](function(){var He=De&&De.apply(this,arguments);He&&f(He.promise)?He.promise().progress(re.notify).done(re.resolve).fail(re.reject):re[be[0]+"With"](this,De?[He]:arguments)})}),Q=null}).promise()},then:function(Q,re,Ee){var be=0;function De(He,qe,ke,at){return function(){var Si=this,Sr=arguments,ki=function(){var Ms,Xc;if(!(He<be)){if(Ms=ke.apply(Si,Sr),Ms===qe.promise())throw new TypeError("Thenable self-resolution");Xc=Ms&&(typeof Ms=="object"||typeof Ms=="function")&&Ms.then,f(Xc)?at?Xc.call(Ms,De(be,qe,nt,at),De(be,qe,je,at)):(be++,Xc.call(Ms,De(be,qe,nt,at),De(be,qe,je,at),De(be,qe,nt,qe.notifyWith))):(ke!==nt&&(Si=void 0,Sr=[Ms]),(at||qe.resolveWith)(Si,Sr))}},da=at?ki:function(){try{ki()}catch(Ms){x.Deferred.exceptionHook&&x.Deferred.exceptionHook(Ms,da.error),He+1>=be&&(ke!==je&&(Si=void 0,Sr=[Ms]),qe.rejectWith(Si,Sr))}};He?da():(x.Deferred.getErrorHook?da.error=x.Deferred.getErrorHook():x.Deferred.getStackHook&&(da.error=x.Deferred.getStackHook()),e.setTimeout(da))}}return x.Deferred(function(He){_[0][3].add(De(0,He,f(Ee)?Ee:nt,He.notifyWith)),_[1][3].add(De(0,He,f(Q)?Q:nt)),_[2][3].add(De(0,He,f(re)?re:je))}).promise()},promise:function(Q){return Q!=null?x.extend(Q,W):W}},Z={};return x.each(_,function(Q,re){var Ee=re[2],be=re[5];W[re[1]]=Ee.add,be&&Ee.add(function(){Y=be},_[3-Q][2].disable,_[3-Q][3].disable,_[0][2].lock,_[0][3].lock),Ee.add(re[3].fire),Z[re[0]]=function(){return Z[re[0]+"With"](this===Z?void 0:this,arguments),this},Z[re[0]+"With"]=Ee.fireWith}),W.promise(Z),v&&v.call(Z,Z),Z},when:function(v){var _=arguments.length,Y=_,W=Array(Y),Z=n.call(arguments),Q=x.Deferred(),re=function(Ee){return function(be){W[Ee]=this,Z[Ee]=arguments.length>1?n.call(arguments):be,--_||Q.resolveWith(W,Z)}};if(_<=1&&(vt(v,Q.done(re(Y)).resolve,Q.reject,!_),Q.state()==="pending"||f(Z[Y]&&Z[Y].then)))return Q.then();for(;Y--;)vt(Z[Y],re(Y),Q.reject);return Q.promise()}});var Bt=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;x.Deferred.exceptionHook=function(v,_){e.console&&e.console.warn&&v&&Bt.test(v.name)&&e.console.warn("jQuery.Deferred exception: "+v.message,v.stack,_)},x.readyException=function(v){e.setTimeout(function(){throw v})};var Oi=x.Deferred();x.fn.ready=function(v){return Oi.then(v).catch(function(_){x.readyException(_)}),this},x.extend({isReady:!1,readyWait:1,ready:function(v){(v===!0?--x.readyWait:x.isReady)||(x.isReady=!0,!(v!==!0&&--x.readyWait>0)&&Oi.resolveWith(g,[x]))}}),x.ready.then=Oi.then;function Ti(){g.removeEventListener("DOMContentLoaded",Ti),e.removeEventListener("load",Ti),x.ready()}g.readyState==="complete"||g.readyState!=="loading"&&!g.documentElement.doScroll?e.setTimeout(x.ready):(g.addEventListener("DOMContentLoaded",Ti),e.addEventListener("load",Ti));var ze=function(v,_,Y,W,Z,Q,re){var Ee=0,be=v.length,De=Y==null;if(E(Y)==="object"){Z=!0;for(Ee in Y)ze(v,_,Ee,Y[Ee],!0,Q,re)}else if(W!==void 0&&(Z=!0,f(W)||(re=!0),De&&(re?(_.call(v,W),_=null):(De=_,_=function(He,qe,ke){return De.call(x(He),ke)})),_))for(;Ee<be;Ee++)_(v[Ee],Y,re?W:W.call(v[Ee],Ee,_(v[Ee],Y)));return Z?v:De?_.call(v):be?_(v[0],Y):Q},D=/^-ms-/,z=/-([a-z])/g;function $(v,_){return _.toUpperCase()}function K(v){return v.replace(D,"ms-").replace(z,$)}var ee=function(v){return v.nodeType===1||v.nodeType===9||!+v.nodeType};function pe(){this.expando=x.expando+pe.uid++}pe.uid=1,pe.prototype={cache:function(v){var _=v[this.expando];return _||(_={},ee(v)&&(v.nodeType?v[this.expando]=_:Object.defineProperty(v,this.expando,{value:_,configurable:!0}))),_},set:function(v,_,Y){var W,Z=this.cache(v);if(typeof _=="string")Z[K(_)]=Y;else for(W in _)Z[K(W)]=_[W];return Z},get:function(v,_){return _===void 0?this.cache(v):v[this.expando]&&v[this.expando][K(_)]},access:function(v,_,Y){return _===void 0||_&&typeof _=="string"&&Y===void 0?this.get(v,_):(this.set(v,_,Y),Y!==void 0?Y:_)},remove:function(v,_){var Y,W=v[this.expando];if(W!==void 0){if(_!==void 0)for(Array.isArray(_)?_=_.map(K):(_=K(_),_=_ in W?[_]:_.match(Fe)||[]),Y=_.length;Y--;)delete W[_[Y]];(_===void 0||x.isEmptyObject(W))&&(v.nodeType?v[this.expando]=void 0:delete v[this.expando])}},hasData:function(v){var _=v[this.expando];return _!==void 0&&!x.isEmptyObject(_)}};var ce=new pe,Be=new pe,st=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,pt=/[A-Z]/g;function tt(v){return v==="true"?!0:v==="false"?!1:v==="null"?null:v===+v+""?+v:st.test(v)?JSON.parse(v):v}function li(v,_,Y){var W;if(Y===void 0&&v.nodeType===1)if(W="data-"+_.replace(pt,"-$&").toLowerCase(),Y=v.getAttribute(W),typeof Y=="string"){try{Y=tt(Y)}catch{}Be.set(v,_,Y)}else Y=void 0;return Y}x.extend({hasData:function(v){return Be.hasData(v)||ce.hasData(v)},data:function(v,_,Y){return Be.access(v,_,Y)},removeData:function(v,_){Be.remove(v,_)},_data:function(v,_,Y){return ce.access(v,_,Y)},_removeData:function(v,_){ce.remove(v,_)}}),x.fn.extend({data:function(v,_){var Y,W,Z,Q=this[0],re=Q&&Q.attributes;if(v===void 0){if(this.length&&(Z=Be.get(Q),Q.nodeType===1&&!ce.get(Q,"hasDataAttrs"))){for(Y=re.length;Y--;)re[Y]&&(W=re[Y].name,W.indexOf("data-")===0&&(W=K(W.slice(5)),li(Q,W,Z[W])));ce.set(Q,"hasDataAttrs",!0)}return Z}return typeof v=="object"?this.each(function(){Be.set(this,v)}):ze(this,function(Ee){var be;if(Q&&Ee===void 0)return be=Be.get(Q,v),be!==void 0||(be=li(Q,v),be!==void 0)?be:void 0;this.each(function(){Be.set(this,v,Ee)})},null,_,arguments.length>1,null,!0)},removeData:function(v){return this.each(function(){Be.remove(this,v)})}}),x.extend({queue:function(v,_,Y){var W;if(v)return _=(_||"fx")+"queue",W=ce.get(v,_),Y&&(!W||Array.isArray(Y)?W=ce.access(v,_,x.makeArray(Y)):W.push(Y)),W||[]},dequeue:function(v,_){_=_||"fx";var Y=x.queue(v,_),W=Y.length,Z=Y.shift(),Q=x._queueHooks(v,_),re=function(){x.dequeue(v,_)};Z==="inprogress"&&(Z=Y.shift(),W--),Z&&(_==="fx"&&Y.unshift("inprogress"),delete Q.stop,Z.call(v,re,Q)),!W&&Q&&Q.empty.fire()},_queueHooks:function(v,_){var Y=_+"queueHooks";return ce.get(v,Y)||ce.access(v,Y,{empty:x.Callbacks("once memory").add(function(){ce.remove(v,[_+"queue",Y])})})}}),x.fn.extend({queue:function(v,_){var Y=2;return typeof v!="string"&&(_=v,v="fx",Y--),arguments.length<Y?x.queue(this[0],v):_===void 0?this:this.each(function(){var W=x.queue(this,v,_);x._queueHooks(this,v),v==="fx"&&W[0]!=="inprogress"&&x.dequeue(this,v)})},dequeue:function(v){return this.each(function(){x.dequeue(this,v)})},clearQueue:function(v){return this.queue(v||"fx",[])},promise:function(v,_){var Y,W=1,Z=x.Deferred(),Q=this,re=this.length,Ee=function(){--W||Z.resolveWith(Q,[Q])};for(typeof v!="string"&&(_=v,v=void 0),v=v||"fx";re--;)Y=ce.get(Q[re],v+"queueHooks"),Y&&Y.empty&&(W++,Y.empty.add(Ee));return Ee(),Z.promise(_)}});var Ji=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,cr=new RegExp("^(?:([+-])=|)("+Ji+")([a-z%]*)$","i"),Bi=["Top","Right","Bottom","Left"],An=g.documentElement,Mr=function(v){return x.contains(v.ownerDocument,v)},Or={composed:!0};An.getRootNode&&(Mr=function(v){return x.contains(v.ownerDocument,v)||v.getRootNode(Or)===v.ownerDocument});var Cn=function(v,_){return v=_||v,v.style.display==="none"||v.style.display===""&&Mr(v)&&x.css(v,"display")==="none"};function ua(v,_,Y,W){var Z,Q,re=20,Ee=W?function(){return W.cur()}:function(){return x.css(v,_,"")},be=Ee(),De=Y&&Y[3]||(x.cssNumber[_]?"":"px"),He=v.nodeType&&(x.cssNumber[_]||De!=="px"&&+be)&&cr.exec(x.css(v,_));if(He&&He[3]!==De){for(be=be/2,De=De||He[3],He=+be||1;re--;)x.style(v,_,He+De),(1-Q)*(1-(Q=Ee()/be||.5))<=0&&(re=0),He=He/Q;He=He*2,x.style(v,_,He+De),Y=Y||[]}return Y&&(He=+He||+be||0,Z=Y[1]?He+(Y[1]+1)*Y[2]:+Y[2],W&&(W.unit=De,W.start=He,W.end=Z)),Z}var Zt={};function Er(v){var _,Y=v.ownerDocument,W=v.nodeName,Z=Zt[W];return Z||(_=Y.body.appendChild(Y.createElement(W)),Z=x.css(_,"display"),_.parentNode.removeChild(_),Z==="none"&&(Z="block"),Zt[W]=Z,Z)}function mt(v,_){for(var Y,W,Z=[],Q=0,re=v.length;Q<re;Q++)W=v[Q],W.style&&(Y=W.style.display,_?(Y==="none"&&(Z[Q]=ce.get(W,"display")||null,Z[Q]||(W.style.display="")),W.style.display===""&&Cn(W)&&(Z[Q]=Er(W))):Y!=="none"&&(Z[Q]="none",ce.set(W,"display",Y)));for(Q=0;Q<re;Q++)Z[Q]!=null&&(v[Q].style.display=Z[Q]);return v}x.fn.extend({show:function(){return mt(this,!0)},hide:function(){return mt(this)},toggle:function(v){return typeof v=="boolean"?v?this.show():this.hide():this.each(function(){Cn(this)?x(this).show():x(this).hide()})}});var dn=/^(?:checkbox|radio)$/i,rs=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,di=/^$|^module$|\/(?:java|ecma)script/i;(function(){var v=g.createDocumentFragment(),_=v.appendChild(g.createElement("div")),Y=g.createElement("input");Y.setAttribute("type","radio"),Y.setAttribute("checked","checked"),Y.setAttribute("name","t"),_.appendChild(Y),p.checkClone=_.cloneNode(!0).cloneNode(!0).lastChild.checked,_.innerHTML="<textarea>x</textarea>",p.noCloneChecked=!!_.cloneNode(!0).lastChild.defaultValue,_.innerHTML="<option></option>",p.option=!!_.lastChild})();var Ii={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ii.tbody=Ii.tfoot=Ii.colgroup=Ii.caption=Ii.thead,Ii.th=Ii.td,p.option||(Ii.optgroup=Ii.option=[1,"<select multiple='multiple'>","</select>"]);function vn(v,_){var Y;return typeof v.getElementsByTagName<"u"?Y=v.getElementsByTagName(_||"*"):typeof v.querySelectorAll<"u"?Y=v.querySelectorAll(_||"*"):Y=[],_===void 0||_&&A(v,_)?x.merge([v],Y):Y}function ha(v,_){for(var Y=0,W=v.length;Y<W;Y++)ce.set(v[Y],"globalEval",!_||ce.get(_[Y],"globalEval"))}var Yu=/<|&#?\w+;/;function Ef(v,_,Y,W,Z){for(var Q,re,Ee,be,De,He,qe=_.createDocumentFragment(),ke=[],at=0,Si=v.length;at<Si;at++)if(Q=v[at],Q||Q===0)if(E(Q)==="object")x.merge(ke,Q.nodeType?[Q]:Q);else if(!Yu.test(Q))ke.push(_.createTextNode(Q));else{for(re=re||qe.appendChild(_.createElement("div")),Ee=(rs.exec(Q)||["",""])[1].toLowerCase(),be=Ii[Ee]||Ii._default,re.innerHTML=be[1]+x.htmlPrefilter(Q)+be[2],He=be[0];He--;)re=re.lastChild;x.merge(ke,re.childNodes),re=qe.firstChild,re.textContent=""}for(qe.textContent="",at=0;Q=ke[at++];){if(W&&x.inArray(Q,W)>-1){Z&&Z.push(Q);continue}if(De=Mr(Q),re=vn(qe.appendChild(Q),"script"),De&&ha(re),Y)for(He=0;Q=re[He++];)di.test(Q.type||"")&&Y.push(Q)}return qe}var Gh=/^([^.]*)(?:\.(.+)|)/;function zc(){return!0}function El(){return!1}function Br(v,_,Y,W,Z,Q){var re,Ee;if(typeof _=="object"){typeof Y!="string"&&(W=W||Y,Y=void 0);for(Ee in _)Br(v,Ee,Y,W,_[Ee],Q);return v}if(W==null&&Z==null?(Z=Y,W=Y=void 0):Z==null&&(typeof Y=="string"?(Z=W,W=void 0):(Z=W,W=Y,Y=void 0)),Z===!1)Z=El;else if(!Z)return v;return Q===1&&(re=Z,Z=function(be){return x().off(be),re.apply(this,arguments)},Z.guid=re.guid||(re.guid=x.guid++)),v.each(function(){x.event.add(this,_,Z,W,Y)})}x.event={global:{},add:function(v,_,Y,W,Z){var Q,re,Ee,be,De,He,qe,ke,at,Si,Sr,ki=ce.get(v);if(ee(v))for(Y.handler&&(Q=Y,Y=Q.handler,Z=Q.selector),Z&&x.find.matchesSelector(An,Z),Y.guid||(Y.guid=x.guid++),(be=ki.events)||(be=ki.events=Object.create(null)),(re=ki.handle)||(re=ki.handle=function(da){return typeof x<"u"&&x.event.triggered!==da.type?x.event.dispatch.apply(v,arguments):void 0}),_=(_||"").match(Fe)||[""],De=_.length;De--;)Ee=Gh.exec(_[De])||[],at=Sr=Ee[1],Si=(Ee[2]||"").split(".").sort(),at&&(qe=x.event.special[at]||{},at=(Z?qe.delegateType:qe.bindType)||at,qe=x.event.special[at]||{},He=x.extend({type:at,origType:Sr,data:W,handler:Y,guid:Y.guid,selector:Z,needsContext:Z&&x.expr.match.needsContext.test(Z),namespace:Si.join(".")},Q),(ke=be[at])||(ke=be[at]=[],ke.delegateCount=0,(!qe.setup||qe.setup.call(v,W,Si,re)===!1)&&v.addEventListener&&v.addEventListener(at,re)),qe.add&&(qe.add.call(v,He),He.handler.guid||(He.handler.guid=Y.guid)),Z?ke.splice(ke.delegateCount++,0,He):ke.push(He),x.event.global[at]=!0)},remove:function(v,_,Y,W,Z){var Q,re,Ee,be,De,He,qe,ke,at,Si,Sr,ki=ce.hasData(v)&&ce.get(v);if(!(!ki||!(be=ki.events))){for(_=(_||"").match(Fe)||[""],De=_.length;De--;){if(Ee=Gh.exec(_[De])||[],at=Sr=Ee[1],Si=(Ee[2]||"").split(".").sort(),!at){for(at in be)x.event.remove(v,at+_[De],Y,W,!0);continue}for(qe=x.event.special[at]||{},at=(W?qe.delegateType:qe.bindType)||at,ke=be[at]||[],Ee=Ee[2]&&new RegExp("(^|\\.)"+Si.join("\\.(?:.*\\.|)")+"(\\.|$)"),re=Q=ke.length;Q--;)He=ke[Q],(Z||Sr===He.origType)&&(!Y||Y.guid===He.guid)&&(!Ee||Ee.test(He.namespace))&&(!W||W===He.selector||W==="**"&&He.selector)&&(ke.splice(Q,1),He.selector&&ke.delegateCount--,qe.remove&&qe.remove.call(v,He));re&&!ke.length&&((!qe.teardown||qe.teardown.call(v,Si,ki.handle)===!1)&&x.removeEvent(v,at,ki.handle),delete be[at])}x.isEmptyObject(be)&&ce.remove(v,"handle events")}},dispatch:function(v){var _,Y,W,Z,Q,re,Ee=new Array(arguments.length),be=x.event.fix(v),De=(ce.get(this,"events")||Object.create(null))[be.type]||[],He=x.event.special[be.type]||{};for(Ee[0]=be,_=1;_<arguments.length;_++)Ee[_]=arguments[_];if(be.delegateTarget=this,!(He.preDispatch&&He.preDispatch.call(this,be)===!1)){for(re=x.event.handlers.call(this,be,De),_=0;(Z=re[_++])&&!be.isPropagationStopped();)for(be.currentTarget=Z.elem,Y=0;(Q=Z.handlers[Y++])&&!be.isImmediatePropagationStopped();)(!be.rnamespace||Q.namespace===!1||be.rnamespace.test(Q.namespace))&&(be.handleObj=Q,be.data=Q.data,W=((x.event.special[Q.origType]||{}).handle||Q.handler).apply(Z.elem,Ee),W!==void 0&&(be.result=W)===!1&&(be.preventDefault(),be.stopPropagation()));return He.postDispatch&&He.postDispatch.call(this,be),be.result}},handlers:function(v,_){var Y,W,Z,Q,re,Ee=[],be=_.delegateCount,De=v.target;if(be&&De.nodeType&&!(v.type==="click"&&v.button>=1)){for(;De!==this;De=De.parentNode||this)if(De.nodeType===1&&!(v.type==="click"&&De.disabled===!0)){for(Q=[],re={},Y=0;Y<be;Y++)W=_[Y],Z=W.selector+" ",re[Z]===void 0&&(re[Z]=W.needsContext?x(Z,this).index(De)>-1:x.find(Z,this,null,[De]).length),re[Z]&&Q.push(W);Q.length&&Ee.push({elem:De,handlers:Q})}}return De=this,be<_.length&&Ee.push({elem:De,handlers:_.slice(be)}),Ee},addProp:function(v,_){Object.defineProperty(x.Event.prototype,v,{enumerable:!0,configurable:!0,get:f(_)?function(){if(this.originalEvent)return _(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[v]},set:function(Y){Object.defineProperty(this,v,{enumerable:!0,configurable:!0,writable:!0,value:Y})}})},fix:function(v){return v[x.expando]?v:new x.Event(v)},special:{load:{noBubble:!0},click:{setup:function(v){var _=this||v;return dn.test(_.type)&&_.click&&A(_,"input")&&ns(_,"click",!0),!1},trigger:function(v){var _=this||v;return dn.test(_.type)&&_.click&&A(_,"input")&&ns(_,"click"),!0},_default:function(v){var _=v.target;return dn.test(_.type)&&_.click&&A(_,"input")&&ce.get(_,"click")||A(_,"a")}},beforeunload:{postDispatch:function(v){v.result!==void 0&&v.originalEvent&&(v.originalEvent.returnValue=v.result)}}}};function ns(v,_,Y){if(!Y){ce.get(v,_)===void 0&&x.event.add(v,_,zc);return}ce.set(v,_,!1),x.event.add(v,_,{namespace:!1,handler:function(W){var Z,Q=ce.get(this,_);if(W.isTrigger&1&&this[_]){if(Q)(x.event.special[_]||{}).delegateType&&W.stopPropagation();else if(Q=n.call(arguments),ce.set(this,_,Q),this[_](),Z=ce.get(this,_),ce.set(this,_,!1),Q!==Z)return W.stopImmediatePropagation(),W.preventDefault(),Z}else Q&&(ce.set(this,_,x.event.trigger(Q[0],Q.slice(1),this)),W.stopPropagation(),W.isImmediatePropagationStopped=zc)}})}x.removeEvent=function(v,_,Y){v.removeEventListener&&v.removeEventListener(_,Y)},x.Event=function(v,_){if(!(this instanceof x.Event))return new x.Event(v,_);v&&v.type?(this.originalEvent=v,this.type=v.type,this.isDefaultPrevented=v.defaultPrevented||v.defaultPrevented===void 0&&v.returnValue===!1?zc:El,this.target=v.target&&v.target.nodeType===3?v.target.parentNode:v.target,this.currentTarget=v.currentTarget,this.relatedTarget=v.relatedTarget):this.type=v,_&&x.extend(this,_),this.timeStamp=v&&v.timeStamp||Date.now(),this[x.expando]=!0},x.Event.prototype={constructor:x.Event,isDefaultPrevented:El,isPropagationStopped:El,isImmediatePropagationStopped:El,isSimulated:!1,preventDefault:function(){var v=this.originalEvent;this.isDefaultPrevented=zc,v&&!this.isSimulated&&v.preventDefault()},stopPropagation:function(){var v=this.originalEvent;this.isPropagationStopped=zc,v&&!this.isSimulated&&v.stopPropagation()},stopImmediatePropagation:function(){var v=this.originalEvent;this.isImmediatePropagationStopped=zc,v&&!this.isSimulated&&v.stopImmediatePropagation(),this.stopPropagation()}},x.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},x.event.addProp),x.each({focus:"focusin",blur:"focusout"},function(v,_){function Y(W){if(g.documentMode){var Z=ce.get(this,"handle"),Q=x.event.fix(W);Q.type=W.type==="focusin"?"focus":"blur",Q.isSimulated=!0,Z(W),Q.target===Q.currentTarget&&Z(Q)}else x.event.simulate(_,W.target,x.event.fix(W))}x.event.special[v]={setup:function(){var W;if(ns(this,v,!0),g.documentMode)W=ce.get(this,_),W||this.addEventListener(_,Y),ce.set(this,_,(W||0)+1);else return!1},trigger:function(){return ns(this,v),!0},teardown:function(){var W;if(g.documentMode)W=ce.get(this,_)-1,W?ce.set(this,_,W):(this.removeEventListener(_,Y),ce.remove(this,_));else return!1},_default:function(W){return ce.get(W.target,v)},delegateType:_},x.event.special[_]={setup:function(){var W=this.ownerDocument||this.document||this,Z=g.documentMode?this:W,Q=ce.get(Z,_);Q||(g.documentMode?this.addEventListener(_,Y):W.addEventListener(v,Y,!0)),ce.set(Z,_,(Q||0)+1)},teardown:function(){var W=this.ownerDocument||this.document||this,Z=g.documentMode?this:W,Q=ce.get(Z,_)-1;Q?ce.set(Z,_,Q):(g.documentMode?this.removeEventListener(_,Y):W.removeEventListener(v,Y,!0),ce.remove(Z,_))}}}),x.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(v,_){x.event.special[v]={delegateType:_,bindType:_,handle:function(Y){var W,Z=this,Q=Y.relatedTarget,re=Y.handleObj;return(!Q||Q!==Z&&!x.contains(Z,Q))&&(Y.type=re.origType,W=re.handler.apply(this,arguments),Y.type=_),W}}}),x.fn.extend({on:function(v,_,Y,W){return Br(this,v,_,Y,W)},one:function(v,_,Y,W){return Br(this,v,_,Y,W,1)},off:function(v,_,Y){var W,Z;if(v&&v.preventDefault&&v.handleObj)return W=v.handleObj,x(v.delegateTarget).off(W.namespace?W.origType+"."+W.namespace:W.origType,W.selector,W.handler),this;if(typeof v=="object"){for(Z in v)this.off(Z,_,v[Z]);return this}return(_===!1||typeof _=="function")&&(Y=_,_=void 0),Y===!1&&(Y=El),this.each(function(){x.event.remove(this,v,Y,_)})}});var ep=/<script|<style|<link/i,Qg=/checked\s*(?:[^=]|=\s*.checked.)/i,n6=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function RD(v,_){return A(v,"table")&&A(_.nodeType!==11?_:_.firstChild,"tr")&&x(v).children("tbody")[0]||v}function s6(v){return v.type=(v.getAttribute("type")!==null)+"/"+v.type,v}function a6(v){return(v.type||"").slice(0,5)==="true/"?v.type=v.type.slice(5):v.removeAttribute("type"),v}function ND(v,_){var Y,W,Z,Q,re,Ee,be;if(_.nodeType===1){if(ce.hasData(v)&&(Q=ce.get(v),be=Q.events,be)){ce.remove(_,"handle events");for(Z in be)for(Y=0,W=be[Z].length;Y<W;Y++)x.event.add(_,Z,be[Z][Y])}Be.hasData(v)&&(re=Be.access(v),Ee=x.extend({},re),Be.set(_,Ee))}}function o6(v,_){var Y=_.nodeName.toLowerCase();Y==="input"&&dn.test(v.type)?_.checked=v.checked:(Y==="input"||Y==="textarea")&&(_.defaultValue=v.defaultValue)}function Sf(v,_,Y,W){_=s(_);var Z,Q,re,Ee,be,De,He=0,qe=v.length,ke=qe-1,at=_[0],Si=f(at);if(Si||qe>1&&typeof at=="string"&&!p.checkClone&&Qg.test(at))return v.each(function(Sr){var ki=v.eq(Sr);Si&&(_[0]=at.call(this,Sr,ki.html())),Sf(ki,_,Y,W)});if(qe&&(Z=Ef(_,v[0].ownerDocument,!1,v,W),Q=Z.firstChild,Z.childNodes.length===1&&(Z=Q),Q||W)){for(re=x.map(vn(Z,"script"),s6),Ee=re.length;He<qe;He++)be=Z,He!==ke&&(be=x.clone(be,!0,!0),Ee&&x.merge(re,vn(be,"script"))),Y.call(v[He],be,He);if(Ee)for(De=re[re.length-1].ownerDocument,x.map(re,a6),He=0;He<Ee;He++)be=re[He],di.test(be.type||"")&&!ce.access(be,"globalEval")&&x.contains(De,be)&&(be.src&&(be.type||"").toLowerCase()!=="module"?x._evalUrl&&!be.noModule&&x._evalUrl(be.src,{nonce:be.nonce||be.getAttribute("nonce")},De):y(be.textContent.replace(n6,""),be,De))}return v}function MD(v,_,Y){for(var W,Z=_?x.filter(_,v):v,Q=0;(W=Z[Q])!=null;Q++)!Y&&W.nodeType===1&&x.cleanData(vn(W)),W.parentNode&&(Y&&Mr(W)&&ha(vn(W,"script")),W.parentNode.removeChild(W));return v}x.extend({htmlPrefilter:function(v){return v},clone:function(v,_,Y){var W,Z,Q,re,Ee=v.cloneNode(!0),be=Mr(v);if(!p.noCloneChecked&&(v.nodeType===1||v.nodeType===11)&&!x.isXMLDoc(v))for(re=vn(Ee),Q=vn(v),W=0,Z=Q.length;W<Z;W++)o6(Q[W],re[W]);if(_)if(Y)for(Q=Q||vn(v),re=re||vn(Ee),W=0,Z=Q.length;W<Z;W++)ND(Q[W],re[W]);else ND(v,Ee);return re=vn(Ee,"script"),re.length>0&&ha(re,!be&&vn(v,"script")),Ee},cleanData:function(v){for(var _,Y,W,Z=x.event.special,Q=0;(Y=v[Q])!==void 0;Q++)if(ee(Y)){if(_=Y[ce.expando]){if(_.events)for(W in _.events)Z[W]?x.event.remove(Y,W):x.removeEvent(Y,W,_.handle);Y[ce.expando]=void 0}Y[Be.expando]&&(Y[Be.expando]=void 0)}}}),x.fn.extend({detach:function(v){return MD(this,v,!0)},remove:function(v){return MD(this,v)},text:function(v){return ze(this,function(_){return _===void 0?x.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=_)})},null,v,arguments.length)},append:function(){return Sf(this,arguments,function(v){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var _=RD(this,v);_.appendChild(v)}})},prepend:function(){return Sf(this,arguments,function(v){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var _=RD(this,v);_.insertBefore(v,_.firstChild)}})},before:function(){return Sf(this,arguments,function(v){this.parentNode&&this.parentNode.insertBefore(v,this)})},after:function(){return Sf(this,arguments,function(v){this.parentNode&&this.parentNode.insertBefore(v,this.nextSibling)})},empty:function(){for(var v,_=0;(v=this[_])!=null;_++)v.nodeType===1&&(x.cleanData(vn(v,!1)),v.textContent="");return this},clone:function(v,_){return v=v==null?!1:v,_=_==null?v:_,this.map(function(){return x.clone(this,v,_)})},html:function(v){return ze(this,function(_){var Y=this[0]||{},W=0,Z=this.length;if(_===void 0&&Y.nodeType===1)return Y.innerHTML;if(typeof _=="string"&&!ep.test(_)&&!Ii[(rs.exec(_)||["",""])[1].toLowerCase()]){_=x.htmlPrefilter(_);try{for(;W<Z;W++)Y=this[W]||{},Y.nodeType===1&&(x.cleanData(vn(Y,!1)),Y.innerHTML=_);Y=0}catch{}}Y&&this.empty().append(_)},null,v,arguments.length)},replaceWith:function(){var v=[];return Sf(this,arguments,function(_){var Y=this.parentNode;x.inArray(this,v)<0&&(x.cleanData(vn(this)),Y&&Y.replaceChild(_,this))},v)}}),x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(v,_){x.fn[v]=function(Y){for(var W,Z=[],Q=x(Y),re=Q.length-1,Ee=0;Ee<=re;Ee++)W=Ee===re?this:this.clone(!0),x(Q[Ee])[_](W),a.apply(Z,W.get());return this.pushStack(Z)}});var Ow=new RegExp("^("+Ji+")(?!px)[a-z%]+$","i"),Rw=/^--/,sb=function(v){var _=v.ownerDocument.defaultView;return(!_||!_.opener)&&(_=e),_.getComputedStyle(v)},BD=function(v,_,Y){var W,Z,Q={};for(Z in _)Q[Z]=v.style[Z],v.style[Z]=_[Z];W=Y.call(v);for(Z in _)v.style[Z]=Q[Z];return W},l6=new RegExp(Bi.join("|"),"i");(function(){function v(){if(De){be.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",De.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",An.appendChild(be).appendChild(De);var He=e.getComputedStyle(De);Y=He.top!=="1%",Ee=_(He.marginLeft)===12,De.style.right="60%",Q=_(He.right)===36,W=_(He.width)===36,De.style.position="absolute",Z=_(De.offsetWidth/3)===12,An.removeChild(be),De=null}}function _(He){return Math.round(parseFloat(He))}var Y,W,Z,Q,re,Ee,be=g.createElement("div"),De=g.createElement("div");De.style&&(De.style.backgroundClip="content-box",De.cloneNode(!0).style.backgroundClip="",p.clearCloneStyle=De.style.backgroundClip==="content-box",x.extend(p,{boxSizingReliable:function(){return v(),W},pixelBoxStyles:function(){return v(),Q},pixelPosition:function(){return v(),Y},reliableMarginLeft:function(){return v(),Ee},scrollboxSize:function(){return v(),Z},reliableTrDimensions:function(){var He,qe,ke,at;return re==null&&(He=g.createElement("table"),qe=g.createElement("tr"),ke=g.createElement("div"),He.style.cssText="position:absolute;left:-11111px;border-collapse:separate",qe.style.cssText="box-sizing:content-box;border:1px solid",qe.style.height="1px",ke.style.height="9px",ke.style.display="block",An.appendChild(He).appendChild(qe).appendChild(ke),at=e.getComputedStyle(qe),re=parseInt(at.height,10)+parseInt(at.borderTopWidth,10)+parseInt(at.borderBottomWidth,10)===qe.offsetHeight,An.removeChild(He)),re}}))})();function ey(v,_,Y){var W,Z,Q,re,Ee=Rw.test(_),be=v.style;return Y=Y||sb(v),Y&&(re=Y.getPropertyValue(_)||Y[_],Ee&&re&&(re=re.replace(G,"$1")||void 0),re===""&&!Mr(v)&&(re=x.style(v,_)),!p.pixelBoxStyles()&&Ow.test(re)&&l6.test(_)&&(W=be.width,Z=be.minWidth,Q=be.maxWidth,be.minWidth=be.maxWidth=be.width=re,re=Y.width,be.width=W,be.minWidth=Z,be.maxWidth=Q)),re!==void 0?re+"":re}function kD(v,_){return{get:function(){if(v()){delete this.get;return}return(this.get=_).apply(this,arguments)}}}var FD=["Webkit","Moz","ms"],GD=g.createElement("div").style,UD={};function c6(v){for(var _=v[0].toUpperCase()+v.slice(1),Y=FD.length;Y--;)if(v=FD[Y]+_,v in GD)return v}function Nw(v){var _=x.cssProps[v]||UD[v];return _||(v in GD?v:UD[v]=c6(v)||v)}var u6=/^(none|table(?!-c[ea]).+)/,h6={position:"absolute",visibility:"hidden",display:"block"},YD={letterSpacing:"0",fontWeight:"400"};function VD(v,_,Y){var W=cr.exec(_);return W?Math.max(0,W[2]-(Y||0))+(W[3]||"px"):_}function Mw(v,_,Y,W,Z,Q){var re=_==="width"?1:0,Ee=0,be=0,De=0;if(Y===(W?"border":"content"))return 0;for(;re<4;re+=2)Y==="margin"&&(De+=x.css(v,Y+Bi[re],!0,Z)),W?(Y==="content"&&(be-=x.css(v,"padding"+Bi[re],!0,Z)),Y!=="margin"&&(be-=x.css(v,"border"+Bi[re]+"Width",!0,Z))):(be+=x.css(v,"padding"+Bi[re],!0,Z),Y!=="padding"?be+=x.css(v,"border"+Bi[re]+"Width",!0,Z):Ee+=x.css(v,"border"+Bi[re]+"Width",!0,Z));return!W&&Q>=0&&(be+=Math.max(0,Math.ceil(v["offset"+_[0].toUpperCase()+_.slice(1)]-Q-be-Ee-.5))||0),be+De}function HD(v,_,Y){var W=sb(v),Z=!p.boxSizingReliable()||Y,Q=Z&&x.css(v,"boxSizing",!1,W)==="border-box",re=Q,Ee=ey(v,_,W),be="offset"+_[0].toUpperCase()+_.slice(1);if(Ow.test(Ee)){if(!Y)return Ee;Ee="auto"}return(!p.boxSizingReliable()&&Q||!p.reliableTrDimensions()&&A(v,"tr")||Ee==="auto"||!parseFloat(Ee)&&x.css(v,"display",!1,W)==="inline")&&v.getClientRects().length&&(Q=x.css(v,"boxSizing",!1,W)==="border-box",re=be in v,re&&(Ee=v[be])),Ee=parseFloat(Ee)||0,Ee+Mw(v,_,Y||(Q?"border":"content"),re,W,Ee)+"px"}x.extend({cssHooks:{opacity:{get:function(v,_){if(_){var Y=ey(v,"opacity");return Y===""?"1":Y}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(v,_,Y,W){if(!(!v||v.nodeType===3||v.nodeType===8||!v.style)){var Z,Q,re,Ee=K(_),be=Rw.test(_),De=v.style;if(be||(_=Nw(Ee)),re=x.cssHooks[_]||x.cssHooks[Ee],Y!==void 0){if(Q=typeof Y,Q==="string"&&(Z=cr.exec(Y))&&Z[1]&&(Y=ua(v,_,Z),Q="number"),Y==null||Y!==Y)return;Q==="number"&&!be&&(Y+=Z&&Z[3]||(x.cssNumber[Ee]?"":"px")),!p.clearCloneStyle&&Y===""&&_.indexOf("background")===0&&(De[_]="inherit"),(!re||!("set"in re)||(Y=re.set(v,Y,W))!==void 0)&&(be?De.setProperty(_,Y):De[_]=Y)}else return re&&"get"in re&&(Z=re.get(v,!1,W))!==void 0?Z:De[_]}},css:function(v,_,Y,W){var Z,Q,re,Ee=K(_),be=Rw.test(_);return be||(_=Nw(Ee)),re=x.cssHooks[_]||x.cssHooks[Ee],re&&"get"in re&&(Z=re.get(v,!0,Y)),Z===void 0&&(Z=ey(v,_,W)),Z==="normal"&&_ in YD&&(Z=YD[_]),Y===""||Y?(Q=parseFloat(Z),Y===!0||isFinite(Q)?Q||0:Z):Z}}),x.each(["height","width"],function(v,_){x.cssHooks[_]={get:function(Y,W,Z){if(W)return u6.test(x.css(Y,"display"))&&(!Y.getClientRects().length||!Y.getBoundingClientRect().width)?BD(Y,h6,function(){return HD(Y,_,Z)}):HD(Y,_,Z)},set:function(Y,W,Z){var Q,re=sb(Y),Ee=!p.scrollboxSize()&&re.position==="absolute",be=Ee||Z,De=be&&x.css(Y,"boxSizing",!1,re)==="border-box",He=Z?Mw(Y,_,Z,De,re):0;return De&&Ee&&(He-=Math.ceil(Y["offset"+_[0].toUpperCase()+_.slice(1)]-parseFloat(re[_])-Mw(Y,_,"border",!1,re)-.5)),He&&(Q=cr.exec(W))&&(Q[3]||"px")!=="px"&&(Y.style[_]=W,W=x.css(Y,_)),VD(Y,W,He)}}}),x.cssHooks.marginLeft=kD(p.reliableMarginLeft,function(v,_){if(_)return(parseFloat(ey(v,"marginLeft"))||v.getBoundingClientRect().left-BD(v,{marginLeft:0},function(){return v.getBoundingClientRect().left}))+"px"}),x.each({margin:"",padding:"",border:"Width"},function(v,_){x.cssHooks[v+_]={expand:function(Y){for(var W=0,Z={},Q=typeof Y=="string"?Y.split(" "):[Y];W<4;W++)Z[v+Bi[W]+_]=Q[W]||Q[W-2]||Q[0];return Z}},v!=="margin"&&(x.cssHooks[v+_].set=VD)}),x.fn.extend({css:function(v,_){return ze(this,function(Y,W,Z){var Q,re,Ee={},be=0;if(Array.isArray(W)){for(Q=sb(Y),re=W.length;be<re;be++)Ee[W[be]]=x.css(Y,W[be],!1,Q);return Ee}return Z!==void 0?x.style(Y,W,Z):x.css(Y,W)},v,_,arguments.length>1)}});function yo(v,_,Y,W,Z){return new yo.prototype.init(v,_,Y,W,Z)}x.Tween=yo,yo.prototype={constructor:yo,init:function(v,_,Y,W,Z,Q){this.elem=v,this.prop=Y,this.easing=Z||x.easing._default,this.options=_,this.start=this.now=this.cur(),this.end=W,this.unit=Q||(x.cssNumber[Y]?"":"px")},cur:function(){var v=yo.propHooks[this.prop];return v&&v.get?v.get(this):yo.propHooks._default.get(this)},run:function(v){var _,Y=yo.propHooks[this.prop];return this.options.duration?this.pos=_=x.easing[this.easing](v,this.options.duration*v,0,1,this.options.duration):this.pos=_=v,this.now=(this.end-this.start)*_+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),Y&&Y.set?Y.set(this):yo.propHooks._default.set(this),this}},yo.prototype.init.prototype=yo.prototype,yo.propHooks={_default:{get:function(v){var _;return v.elem.nodeType!==1||v.elem[v.prop]!=null&&v.elem.style[v.prop]==null?v.elem[v.prop]:(_=x.css(v.elem,v.prop,""),!_||_==="auto"?0:_)},set:function(v){x.fx.step[v.prop]?x.fx.step[v.prop](v):v.elem.nodeType===1&&(x.cssHooks[v.prop]||v.elem.style[Nw(v.prop)]!=null)?x.style(v.elem,v.prop,v.now+v.unit):v.elem[v.prop]=v.now}}},yo.propHooks.scrollTop=yo.propHooks.scrollLeft={set:function(v){v.elem.nodeType&&v.elem.parentNode&&(v.elem[v.prop]=v.now)}},x.easing={linear:function(v){return v},swing:function(v){return .5-Math.cos(v*Math.PI)/2},_default:"swing"},x.fx=yo.prototype.init,x.fx.step={};var wf,ab,d6=/^(?:toggle|show|hide)$/,p6=/queueHooks$/;function Bw(){ab&&(g.hidden===!1&&e.requestAnimationFrame?e.requestAnimationFrame(Bw):e.setTimeout(Bw,x.fx.interval),x.fx.tick())}function jD(){return e.setTimeout(function(){wf=void 0}),wf=Date.now()}function ob(v,_){var Y,W=0,Z={height:v};for(_=_?1:0;W<4;W+=2-_)Y=Bi[W],Z["margin"+Y]=Z["padding"+Y]=v;return _&&(Z.opacity=Z.width=v),Z}function zD(v,_,Y){for(var W,Z=(oc.tweeners[_]||[]).concat(oc.tweeners["*"]),Q=0,re=Z.length;Q<re;Q++)if(W=Z[Q].call(Y,_,v))return W}function f6(v,_,Y){var W,Z,Q,re,Ee,be,De,He,qe="width"in _||"height"in _,ke=this,at={},Si=v.style,Sr=v.nodeType&&Cn(v),ki=ce.get(v,"fxshow");Y.queue||(re=x._queueHooks(v,"fx"),re.unqueued==null&&(re.unqueued=0,Ee=re.empty.fire,re.empty.fire=function(){re.unqueued||Ee()}),re.unqueued++,ke.always(function(){ke.always(function(){re.unqueued--,x.queue(v,"fx").length||re.empty.fire()})}));for(W in _)if(Z=_[W],d6.test(Z)){if(delete _[W],Q=Q||Z==="toggle",Z===(Sr?"hide":"show"))if(Z==="show"&&ki&&ki[W]!==void 0)Sr=!0;else continue;at[W]=ki&&ki[W]||x.style(v,W)}if(be=!x.isEmptyObject(_),!(!be&&x.isEmptyObject(at))){qe&&v.nodeType===1&&(Y.overflow=[Si.overflow,Si.overflowX,Si.overflowY],De=ki&&ki.display,De==null&&(De=ce.get(v,"display")),He=x.css(v,"display"),He==="none"&&(De?He=De:(mt([v],!0),De=v.style.display||De,He=x.css(v,"display"),mt([v]))),(He==="inline"||He==="inline-block"&&De!=null)&&x.css(v,"float")==="none"&&(be||(ke.done(function(){Si.display=De}),De==null&&(He=Si.display,De=He==="none"?"":He)),Si.display="inline-block")),Y.overflow&&(Si.overflow="hidden",ke.always(function(){Si.overflow=Y.overflow[0],Si.overflowX=Y.overflow[1],Si.overflowY=Y.overflow[2]})),be=!1;for(W in at)be||(ki?"hidden"in ki&&(Sr=ki.hidden):ki=ce.access(v,"fxshow",{display:De}),Q&&(ki.hidden=!Sr),Sr&&mt([v],!0),ke.done(function(){Sr||mt([v]),ce.remove(v,"fxshow");for(W in at)x.style(v,W,at[W])})),be=zD(Sr?ki[W]:0,W,ke),W in ki||(ki[W]=be.start,Sr&&(be.end=be.start,be.start=0))}}function m6(v,_){var Y,W,Z,Q,re;for(Y in v)if(W=K(Y),Z=_[W],Q=v[Y],Array.isArray(Q)&&(Z=Q[1],Q=v[Y]=Q[0]),Y!==W&&(v[W]=Q,delete v[Y]),re=x.cssHooks[W],re&&"expand"in re){Q=re.expand(Q),delete v[W];for(Y in Q)Y in v||(v[Y]=Q[Y],_[Y]=Z)}else _[W]=Z}function oc(v,_,Y){var W,Z,Q=0,re=oc.prefilters.length,Ee=x.Deferred().always(function(){delete be.elem}),be=function(){if(Z)return!1;for(var qe=wf||jD(),ke=Math.max(0,De.startTime+De.duration-qe),at=ke/De.duration||0,Si=1-at,Sr=0,ki=De.tweens.length;Sr<ki;Sr++)De.tweens[Sr].run(Si);return Ee.notifyWith(v,[De,Si,ke]),Si<1&&ki?ke:(ki||Ee.notifyWith(v,[De,1,0]),Ee.resolveWith(v,[De]),!1)},De=Ee.promise({elem:v,props:x.extend({},_),opts:x.extend(!0,{specialEasing:{},easing:x.easing._default},Y),originalProperties:_,originalOptions:Y,startTime:wf||jD(),duration:Y.duration,tweens:[],createTween:function(qe,ke){var at=x.Tween(v,De.opts,qe,ke,De.opts.specialEasing[qe]||De.opts.easing);return De.tweens.push(at),at},stop:function(qe){var ke=0,at=qe?De.tweens.length:0;if(Z)return this;for(Z=!0;ke<at;ke++)De.tweens[ke].run(1);return qe?(Ee.notifyWith(v,[De,1,0]),Ee.resolveWith(v,[De,qe])):Ee.rejectWith(v,[De,qe]),this}}),He=De.props;for(m6(He,De.opts.specialEasing);Q<re;Q++)if(W=oc.prefilters[Q].call(De,v,He,De.opts),W)return f(W.stop)&&(x._queueHooks(De.elem,De.opts.queue).stop=W.stop.bind(W)),W;return x.map(He,zD,De),f(De.opts.start)&&De.opts.start.call(v,De),De.progress(De.opts.progress).done(De.opts.done,De.opts.complete).fail(De.opts.fail).always(De.opts.always),x.fx.timer(x.extend(be,{elem:v,anim:De,queue:De.opts.queue})),De}x.Animation=x.extend(oc,{tweeners:{"*":[function(v,_){var Y=this.createTween(v,_);return ua(Y.elem,v,cr.exec(_),Y),Y}]},tweener:function(v,_){f(v)?(_=v,v=["*"]):v=v.match(Fe);for(var Y,W=0,Z=v.length;W<Z;W++)Y=v[W],oc.tweeners[Y]=oc.tweeners[Y]||[],oc.tweeners[Y].unshift(_)},prefilters:[f6],prefilter:function(v,_){_?oc.prefilters.unshift(v):oc.prefilters.push(v)}}),x.speed=function(v,_,Y){var W=v&&typeof v=="object"?x.extend({},v):{complete:Y||!Y&&_||f(v)&&v,duration:v,easing:Y&&_||_&&!f(_)&&_};return x.fx.off?W.duration=0:typeof W.duration!="number"&&(W.duration in x.fx.speeds?W.duration=x.fx.speeds[W.duration]:W.duration=x.fx.speeds._default),(W.queue==null||W.queue===!0)&&(W.queue="fx"),W.old=W.complete,W.complete=function(){f(W.old)&&W.old.call(this),W.queue&&x.dequeue(this,W.queue)},W},x.fn.extend({fadeTo:function(v,_,Y,W){return this.filter(Cn).css("opacity",0).show().end().animate({opacity:_},v,Y,W)},animate:function(v,_,Y,W){var Z=x.isEmptyObject(v),Q=x.speed(_,Y,W),re=function(){var Ee=oc(this,x.extend({},v),Q);(Z||ce.get(this,"finish"))&&Ee.stop(!0)};return re.finish=re,Z||Q.queue===!1?this.each(re):this.queue(Q.queue,re)},stop:function(v,_,Y){var W=function(Z){var Q=Z.stop;delete Z.stop,Q(Y)};return typeof v!="string"&&(Y=_,_=v,v=void 0),_&&this.queue(v||"fx",[]),this.each(function(){var Z=!0,Q=v!=null&&v+"queueHooks",re=x.timers,Ee=ce.get(this);if(Q)Ee[Q]&&Ee[Q].stop&&W(Ee[Q]);else for(Q in Ee)Ee[Q]&&Ee[Q].stop&&p6.test(Q)&&W(Ee[Q]);for(Q=re.length;Q--;)re[Q].elem===this&&(v==null||re[Q].queue===v)&&(re[Q].anim.stop(Y),Z=!1,re.splice(Q,1));(Z||!Y)&&x.dequeue(this,v)})},finish:function(v){return v!==!1&&(v=v||"fx"),this.each(function(){var _,Y=ce.get(this),W=Y[v+"queue"],Z=Y[v+"queueHooks"],Q=x.timers,re=W?W.length:0;for(Y.finish=!0,x.queue(this,v,[]),Z&&Z.stop&&Z.stop.call(this,!0),_=Q.length;_--;)Q[_].elem===this&&Q[_].queue===v&&(Q[_].anim.stop(!0),Q.splice(_,1));for(_=0;_<re;_++)W[_]&&W[_].finish&&W[_].finish.call(this);delete Y.finish})}}),x.each(["toggle","show","hide"],function(v,_){var Y=x.fn[_];x.fn[_]=function(W,Z,Q){return W==null||typeof W=="boolean"?Y.apply(this,arguments):this.animate(ob(_,!0),W,Z,Q)}}),x.each({slideDown:ob("show"),slideUp:ob("hide"),slideToggle:ob("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(v,_){x.fn[v]=function(Y,W,Z){return this.animate(_,Y,W,Z)}}),x.timers=[],x.fx.tick=function(){var v,_=0,Y=x.timers;for(wf=Date.now();_<Y.length;_++)v=Y[_],!v()&&Y[_]===v&&Y.splice(_--,1);Y.length||x.fx.stop(),wf=void 0},x.fx.timer=function(v){x.timers.push(v),x.fx.start()},x.fx.interval=13,x.fx.start=function(){ab||(ab=!0,Bw())},x.fx.stop=function(){ab=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fn.delay=function(v,_){return v=x.fx&&x.fx.speeds[v]||v,_=_||"fx",this.queue(_,function(Y,W){var Z=e.setTimeout(Y,v);W.stop=function(){e.clearTimeout(Z)}})},(function(){var v=g.createElement("input"),_=g.createElement("select"),Y=_.appendChild(g.createElement("option"));v.type="checkbox",p.checkOn=v.value!=="",p.optSelected=Y.selected,v=g.createElement("input"),v.value="t",v.type="radio",p.radioValue=v.value==="t"})();var XD,ty=x.expr.attrHandle;x.fn.extend({attr:function(v,_){return ze(this,x.attr,v,_,arguments.length>1)},removeAttr:function(v){return this.each(function(){x.removeAttr(this,v)})}}),x.extend({attr:function(v,_,Y){var W,Z,Q=v.nodeType;if(!(Q===3||Q===8||Q===2)){if(typeof v.getAttribute>"u")return x.prop(v,_,Y);if((Q!==1||!x.isXMLDoc(v))&&(Z=x.attrHooks[_.toLowerCase()]||(x.expr.match.bool.test(_)?XD:void 0)),Y!==void 0){if(Y===null){x.removeAttr(v,_);return}return Z&&"set"in Z&&(W=Z.set(v,Y,_))!==void 0?W:(v.setAttribute(_,Y+""),Y)}return Z&&"get"in Z&&(W=Z.get(v,_))!==null?W:(W=x.find.attr(v,_),W==null?void 0:W)}},attrHooks:{type:{set:function(v,_){if(!p.radioValue&&_==="radio"&&A(v,"input")){var Y=v.value;return v.setAttribute("type",_),Y&&(v.value=Y),_}}}},removeAttr:function(v,_){var Y,W=0,Z=_&&_.match(Fe);if(Z&&v.nodeType===1)for(;Y=Z[W++];)v.removeAttribute(Y)}}),XD={set:function(v,_,Y){return _===!1?x.removeAttr(v,Y):v.setAttribute(Y,Y),Y}},x.each(x.expr.match.bool.source.match(/\w+/g),function(v,_){var Y=ty[_]||x.find.attr;ty[_]=function(W,Z,Q){var re,Ee,be=Z.toLowerCase();return Q||(Ee=ty[be],ty[be]=re,re=Y(W,Z,Q)!=null?be:null,ty[be]=Ee),re}});var g6=/^(?:input|select|textarea|button)$/i,y6=/^(?:a|area)$/i;x.fn.extend({prop:function(v,_){return ze(this,x.prop,v,_,arguments.length>1)},removeProp:function(v){return this.each(function(){delete this[x.propFix[v]||v]})}}),x.extend({prop:function(v,_,Y){var W,Z,Q=v.nodeType;if(!(Q===3||Q===8||Q===2))return(Q!==1||!x.isXMLDoc(v))&&(_=x.propFix[_]||_,Z=x.propHooks[_]),Y!==void 0?Z&&"set"in Z&&(W=Z.set(v,Y,_))!==void 0?W:v[_]=Y:Z&&"get"in Z&&(W=Z.get(v,_))!==null?W:v[_]},propHooks:{tabIndex:{get:function(v){var _=x.find.attr(v,"tabindex");return _?parseInt(_,10):g6.test(v.nodeName)||y6.test(v.nodeName)&&v.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),p.optSelected||(x.propHooks.selected={get:function(v){var _=v.parentNode;return _&&_.parentNode&&_.parentNode.selectedIndex,null},set:function(v){var _=v.parentNode;_&&(_.selectedIndex,_.parentNode&&_.parentNode.selectedIndex)}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this});function tp(v){var _=v.match(Fe)||[];return _.join(" ")}function ip(v){return v.getAttribute&&v.getAttribute("class")||""}function kw(v){return Array.isArray(v)?v:typeof v=="string"?v.match(Fe)||[]:[]}x.fn.extend({addClass:function(v){var _,Y,W,Z,Q,re;return f(v)?this.each(function(Ee){x(this).addClass(v.call(this,Ee,ip(this)))}):(_=kw(v),_.length?this.each(function(){if(W=ip(this),Y=this.nodeType===1&&" "+tp(W)+" ",Y){for(Q=0;Q<_.length;Q++)Z=_[Q],Y.indexOf(" "+Z+" ")<0&&(Y+=Z+" ");re=tp(Y),W!==re&&this.setAttribute("class",re)}}):this)},removeClass:function(v){var _,Y,W,Z,Q,re;return f(v)?this.each(function(Ee){x(this).removeClass(v.call(this,Ee,ip(this)))}):arguments.length?(_=kw(v),_.length?this.each(function(){if(W=ip(this),Y=this.nodeType===1&&" "+tp(W)+" ",Y){for(Q=0;Q<_.length;Q++)for(Z=_[Q];Y.indexOf(" "+Z+" ")>-1;)Y=Y.replace(" "+Z+" "," ");re=tp(Y),W!==re&&this.setAttribute("class",re)}}):this):this.attr("class","")},toggleClass:function(v,_){var Y,W,Z,Q,re=typeof v,Ee=re==="string"||Array.isArray(v);return f(v)?this.each(function(be){x(this).toggleClass(v.call(this,be,ip(this),_),_)}):typeof _=="boolean"&&Ee?_?this.addClass(v):this.removeClass(v):(Y=kw(v),this.each(function(){if(Ee)for(Q=x(this),Z=0;Z<Y.length;Z++)W=Y[Z],Q.hasClass(W)?Q.removeClass(W):Q.addClass(W);else(v===void 0||re==="boolean")&&(W=ip(this),W&&ce.set(this,"__className__",W),this.setAttribute&&this.setAttribute("class",W||v===!1?"":ce.get(this,"__className__")||""))}))},hasClass:function(v){var _,Y,W=0;for(_=" "+v+" ";Y=this[W++];)if(Y.nodeType===1&&(" "+tp(ip(Y))+" ").indexOf(_)>-1)return!0;return!1}});var b6=/\r/g;x.fn.extend({val:function(v){var _,Y,W,Z=this[0];return arguments.length?(W=f(v),this.each(function(Q){var re;this.nodeType===1&&(W?re=v.call(this,Q,x(this).val()):re=v,re==null?re="":typeof re=="number"?re+="":Array.isArray(re)&&(re=x.map(re,function(Ee){return Ee==null?"":Ee+""})),_=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],(!_||!("set"in _)||_.set(this,re,"value")===void 0)&&(this.value=re))})):Z?(_=x.valHooks[Z.type]||x.valHooks[Z.nodeName.toLowerCase()],_&&"get"in _&&(Y=_.get(Z,"value"))!==void 0?Y:(Y=Z.value,typeof Y=="string"?Y.replace(b6,""):Y==null?"":Y)):void 0}}),x.extend({valHooks:{option:{get:function(v){var _=x.find.attr(v,"value");return _!=null?_:tp(x.text(v))}},select:{get:function(v){var _,Y,W,Z=v.options,Q=v.selectedIndex,re=v.type==="select-one",Ee=re?null:[],be=re?Q+1:Z.length;for(Q<0?W=be:W=re?Q:0;W<be;W++)if(Y=Z[W],(Y.selected||W===Q)&&!Y.disabled&&(!Y.parentNode.disabled||!A(Y.parentNode,"optgroup"))){if(_=x(Y).val(),re)return _;Ee.push(_)}return Ee},set:function(v,_){for(var Y,W,Z=v.options,Q=x.makeArray(_),re=Z.length;re--;)W=Z[re],(W.selected=x.inArray(x.valHooks.option.get(W),Q)>-1)&&(Y=!0);return Y||(v.selectedIndex=-1),Q}}}}),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(v,_){if(Array.isArray(_))return v.checked=x.inArray(x(v).val(),_)>-1}},p.checkOn||(x.valHooks[this].get=function(v){return v.getAttribute("value")===null?"on":v.value})});var iy=e.location,WD={guid:Date.now()},Fw=/\?/;x.parseXML=function(v){var _,Y;if(!v||typeof v!="string")return null;try{_=new e.DOMParser().parseFromString(v,"text/xml")}catch{}return Y=_&&_.getElementsByTagName("parsererror")[0],(!_||Y)&&x.error("Invalid XML: "+(Y?x.map(Y.childNodes,function(W){return W.textContent}).join(`
`):v)),_};var qD=/^(?:focusinfocus|focusoutblur)$/,JD=function(v){v.stopPropagation()};x.extend(x.event,{trigger:function(v,_,Y,W){var Z,Q,re,Ee,be,De,He,qe,ke=[Y||g],at=u.call(v,"type")?v.type:v,Si=u.call(v,"namespace")?v.namespace.split("."):[];if(Q=qe=re=Y=Y||g,!(Y.nodeType===3||Y.nodeType===8)&&!qD.test(at+x.event.triggered)&&(at.indexOf(".")>-1&&(Si=at.split("."),at=Si.shift(),Si.sort()),be=at.indexOf(":")<0&&"on"+at,v=v[x.expando]?v:new x.Event(at,typeof v=="object"&&v),v.isTrigger=W?2:3,v.namespace=Si.join("."),v.rnamespace=v.namespace?new RegExp("(^|\\.)"+Si.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,v.result=void 0,v.target||(v.target=Y),_=_==null?[v]:x.makeArray(_,[v]),He=x.event.special[at]||{},!(!W&&He.trigger&&He.trigger.apply(Y,_)===!1))){if(!W&&!He.noBubble&&!m(Y)){for(Ee=He.delegateType||at,qD.test(Ee+at)||(Q=Q.parentNode);Q;Q=Q.parentNode)ke.push(Q),re=Q;re===(Y.ownerDocument||g)&&ke.push(re.defaultView||re.parentWindow||e)}for(Z=0;(Q=ke[Z++])&&!v.isPropagationStopped();)qe=Q,v.type=Z>1?Ee:He.bindType||at,De=(ce.get(Q,"events")||Object.create(null))[v.type]&&ce.get(Q,"handle"),De&&De.apply(Q,_),De=be&&Q[be],De&&De.apply&&ee(Q)&&(v.result=De.apply(Q,_),v.result===!1&&v.preventDefault());return v.type=at,!W&&!v.isDefaultPrevented()&&(!He._default||He._default.apply(ke.pop(),_)===!1)&&ee(Y)&&be&&f(Y[at])&&!m(Y)&&(re=Y[be],re&&(Y[be]=null),x.event.triggered=at,v.isPropagationStopped()&&qe.addEventListener(at,JD),Y[at](),v.isPropagationStopped()&&qe.removeEventListener(at,JD),x.event.triggered=void 0,re&&(Y[be]=re)),v.result}},simulate:function(v,_,Y){var W=x.extend(new x.Event,Y,{type:v,isSimulated:!0});x.event.trigger(W,null,_)}}),x.fn.extend({trigger:function(v,_){return this.each(function(){x.event.trigger(v,_,this)})},triggerHandler:function(v,_){var Y=this[0];if(Y)return x.event.trigger(v,_,Y,!0)}});var x6=/\[\]$/,KD=/\r?\n/g,E6=/^(?:submit|button|image|reset|file)$/i,S6=/^(?:input|select|textarea|keygen)/i;function Gw(v,_,Y,W){var Z;if(Array.isArray(_))x.each(_,function(Q,re){Y||x6.test(v)?W(v,re):Gw(v+"["+(typeof re=="object"&&re!=null?Q:"")+"]",re,Y,W)});else if(!Y&&E(_)==="object")for(Z in _)Gw(v+"["+Z+"]",_[Z],Y,W);else W(v,_)}x.param=function(v,_){var Y,W=[],Z=function(Q,re){var Ee=f(re)?re():re;W[W.length]=encodeURIComponent(Q)+"="+encodeURIComponent(Ee==null?"":Ee)};if(v==null)return"";if(Array.isArray(v)||v.jquery&&!x.isPlainObject(v))x.each(v,function(){Z(this.name,this.value)});else for(Y in v)Gw(Y,v[Y],_,Z);return W.join("&")},x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var v=x.prop(this,"elements");return v?x.makeArray(v):this}).filter(function(){var v=this.type;return this.name&&!x(this).is(":disabled")&&S6.test(this.nodeName)&&!E6.test(v)&&(this.checked||!dn.test(v))}).map(function(v,_){var Y=x(this).val();return Y==null?null:Array.isArray(Y)?x.map(Y,function(W){return{name:_.name,value:W.replace(KD,`\r
`)}}):{name:_.name,value:Y.replace(KD,`\r
`)}}).get()}});var w6=/%20/g,v6=/#.*$/,T6=/([?&])_=[^&]*/,I6=/^(.*?):[ \t]*([^\r\n]*)$/mg,A6=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,C6=/^(?:GET|HEAD)$/,D6=/^\/\//,$D={},Uw={},ZD="*/".concat("*"),Yw=g.createElement("a");Yw.href=iy.href;function QD(v){return function(_,Y){typeof _!="string"&&(Y=_,_="*");var W,Z=0,Q=_.toLowerCase().match(Fe)||[];if(f(Y))for(;W=Q[Z++];)W[0]==="+"?(W=W.slice(1)||"*",(v[W]=v[W]||[]).unshift(Y)):(v[W]=v[W]||[]).push(Y)}}function e_(v,_,Y,W){var Z={},Q=v===Uw;function re(Ee){var be;return Z[Ee]=!0,x.each(v[Ee]||[],function(De,He){var qe=He(_,Y,W);if(typeof qe=="string"&&!Q&&!Z[qe])return _.dataTypes.unshift(qe),re(qe),!1;if(Q)return!(be=qe)}),be}return re(_.dataTypes[0])||!Z["*"]&&re("*")}function Vw(v,_){var Y,W,Z=x.ajaxSettings.flatOptions||{};for(Y in _)_[Y]!==void 0&&((Z[Y]?v:W||(W={}))[Y]=_[Y]);return W&&x.extend(!0,v,W),v}function _6(v,_,Y){for(var W,Z,Q,re,Ee=v.contents,be=v.dataTypes;be[0]==="*";)be.shift(),W===void 0&&(W=v.mimeType||_.getResponseHeader("Content-Type"));if(W){for(Z in Ee)if(Ee[Z]&&Ee[Z].test(W)){be.unshift(Z);break}}if(be[0]in Y)Q=be[0];else{for(Z in Y){if(!be[0]||v.converters[Z+" "+be[0]]){Q=Z;break}re||(re=Z)}Q=Q||re}if(Q)return Q!==be[0]&&be.unshift(Q),Y[Q]}function P6(v,_,Y,W){var Z,Q,re,Ee,be,De={},He=v.dataTypes.slice();if(He[1])for(re in v.converters)De[re.toLowerCase()]=v.converters[re];for(Q=He.shift();Q;)if(v.responseFields[Q]&&(Y[v.responseFields[Q]]=_),!be&&W&&v.dataFilter&&(_=v.dataFilter(_,v.dataType)),be=Q,Q=He.shift(),Q){if(Q==="*")Q=be;else if(be!=="*"&&be!==Q){if(re=De[be+" "+Q]||De["* "+Q],!re){for(Z in De)if(Ee=Z.split(" "),Ee[1]===Q&&(re=De[be+" "+Ee[0]]||De["* "+Ee[0]],re)){re===!0?re=De[Z]:De[Z]!==!0&&(Q=Ee[0],He.unshift(Ee[1]));break}}if(re!==!0)if(re&&v.throws)_=re(_);else try{_=re(_)}catch(qe){return{state:"parsererror",error:re?qe:"No conversion from "+be+" to "+Q}}}}return{state:"success",data:_}}x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:iy.href,type:"GET",isLocal:A6.test(iy.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":ZD,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(v,_){return _?Vw(Vw(v,x.ajaxSettings),_):Vw(x.ajaxSettings,v)},ajaxPrefilter:QD($D),ajaxTransport:QD(Uw),ajax:function(v,_){typeof v=="object"&&(_=v,v=void 0),_=_||{};var Y,W,Z,Q,re,Ee,be,De,He,qe,ke=x.ajaxSetup({},_),at=ke.context||ke,Si=ke.context&&(at.nodeType||at.jquery)?x(at):x.event,Sr=x.Deferred(),ki=x.Callbacks("once memory"),da=ke.statusCode||{},Ms={},Xc={},Wc="canceled",ur={readyState:0,getResponseHeader:function(Cr){var ss;if(be){if(!Q)for(Q={};ss=I6.exec(Z);)Q[ss[1].toLowerCase()+" "]=(Q[ss[1].toLowerCase()+" "]||[]).concat(ss[2]);ss=Q[Cr.toLowerCase()+" "]}return ss==null?null:ss.join(", ")},getAllResponseHeaders:function(){return be?Z:null},setRequestHeader:function(Cr,ss){return be==null&&(Cr=Xc[Cr.toLowerCase()]=Xc[Cr.toLowerCase()]||Cr,Ms[Cr]=ss),this},overrideMimeType:function(Cr){return be==null&&(ke.mimeType=Cr),this},statusCode:function(Cr){var ss;if(Cr)if(be)ur.always(Cr[ur.status]);else for(ss in Cr)da[ss]=[da[ss],Cr[ss]];return this},abort:function(Cr){var ss=Cr||Wc;return Y&&Y.abort(ss),rp(0,ss),this}};if(Sr.promise(ur),ke.url=((v||ke.url||iy.href)+"").replace(D6,iy.protocol+"//"),ke.type=_.method||_.type||ke.method||ke.type,ke.dataTypes=(ke.dataType||"*").toLowerCase().match(Fe)||[""],ke.crossDomain==null){Ee=g.createElement("a");try{Ee.href=ke.url,Ee.href=Ee.href,ke.crossDomain=Yw.protocol+"//"+Yw.host!=Ee.protocol+"//"+Ee.host}catch{ke.crossDomain=!0}}if(ke.data&&ke.processData&&typeof ke.data!="string"&&(ke.data=x.param(ke.data,ke.traditional)),e_($D,ke,_,ur),be)return ur;De=x.event&&ke.global,De&&x.active++===0&&x.event.trigger("ajaxStart"),ke.type=ke.type.toUpperCase(),ke.hasContent=!C6.test(ke.type),W=ke.url.replace(v6,""),ke.hasContent?ke.data&&ke.processData&&(ke.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(ke.data=ke.data.replace(w6,"+")):(qe=ke.url.slice(W.length),ke.data&&(ke.processData||typeof ke.data=="string")&&(W+=(Fw.test(W)?"&":"?")+ke.data,delete ke.data),ke.cache===!1&&(W=W.replace(T6,"$1"),qe=(Fw.test(W)?"&":"?")+"_="+WD.guid+++qe),ke.url=W+qe),ke.ifModified&&(x.lastModified[W]&&ur.setRequestHeader("If-Modified-Since",x.lastModified[W]),x.etag[W]&&ur.setRequestHeader("If-None-Match",x.etag[W])),(ke.data&&ke.hasContent&&ke.contentType!==!1||_.contentType)&&ur.setRequestHeader("Content-Type",ke.contentType),ur.setRequestHeader("Accept",ke.dataTypes[0]&&ke.accepts[ke.dataTypes[0]]?ke.accepts[ke.dataTypes[0]]+(ke.dataTypes[0]!=="*"?", "+ZD+"; q=0.01":""):ke.accepts["*"]);for(He in ke.headers)ur.setRequestHeader(He,ke.headers[He]);if(ke.beforeSend&&(ke.beforeSend.call(at,ur,ke)===!1||be))return ur.abort();if(Wc="abort",ki.add(ke.complete),ur.done(ke.success),ur.fail(ke.error),Y=e_(Uw,ke,_,ur),!Y)rp(-1,"No Transport");else{if(ur.readyState=1,De&&Si.trigger("ajaxSend",[ur,ke]),be)return ur;ke.async&&ke.timeout>0&&(re=e.setTimeout(function(){ur.abort("timeout")},ke.timeout));try{be=!1,Y.send(Ms,rp)}catch(Cr){if(be)throw Cr;rp(-1,Cr)}}function rp(Cr,ss,ny,jw){var qc,sy,Jc,Uh,Yh,Sl=ss;be||(be=!0,re&&e.clearTimeout(re),Y=void 0,Z=jw||"",ur.readyState=Cr>0?4:0,qc=Cr>=200&&Cr<300||Cr===304,ny&&(Uh=_6(ke,ur,ny)),!qc&&x.inArray("script",ke.dataTypes)>-1&&x.inArray("json",ke.dataTypes)<0&&(ke.converters["text script"]=function(){}),Uh=P6(ke,Uh,ur,qc),qc?(ke.ifModified&&(Yh=ur.getResponseHeader("Last-Modified"),Yh&&(x.lastModified[W]=Yh),Yh=ur.getResponseHeader("etag"),Yh&&(x.etag[W]=Yh)),Cr===204||ke.type==="HEAD"?Sl="nocontent":Cr===304?Sl="notmodified":(Sl=Uh.state,sy=Uh.data,Jc=Uh.error,qc=!Jc)):(Jc=Sl,(Cr||!Sl)&&(Sl="error",Cr<0&&(Cr=0))),ur.status=Cr,ur.statusText=(ss||Sl)+"",qc?Sr.resolveWith(at,[sy,Sl,ur]):Sr.rejectWith(at,[ur,Sl,Jc]),ur.statusCode(da),da=void 0,De&&Si.trigger(qc?"ajaxSuccess":"ajaxError",[ur,ke,qc?sy:Jc]),ki.fireWith(at,[ur,Sl]),De&&(Si.trigger("ajaxComplete",[ur,ke]),--x.active||x.event.trigger("ajaxStop")))}return ur},getJSON:function(v,_,Y){return x.get(v,_,Y,"json")},getScript:function(v,_){return x.get(v,void 0,_,"script")}}),x.each(["get","post"],function(v,_){x[_]=function(Y,W,Z,Q){return f(W)&&(Q=Q||Z,Z=W,W=void 0),x.ajax(x.extend({url:Y,type:_,dataType:Q,data:W,success:Z},x.isPlainObject(Y)&&Y))}}),x.ajaxPrefilter(function(v){var _;for(_ in v.headers)_.toLowerCase()==="content-type"&&(v.contentType=v.headers[_]||"")}),x._evalUrl=function(v,_,Y){return x.ajax({url:v,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(W){x.globalEval(W,_,Y)}})},x.fn.extend({wrapAll:function(v){var _;return this[0]&&(f(v)&&(v=v.call(this[0])),_=x(v,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&_.insertBefore(this[0]),_.map(function(){for(var Y=this;Y.firstElementChild;)Y=Y.firstElementChild;return Y}).append(this)),this},wrapInner:function(v){return f(v)?this.each(function(_){x(this).wrapInner(v.call(this,_))}):this.each(function(){var _=x(this),Y=_.contents();Y.length?Y.wrapAll(v):_.append(v)})},wrap:function(v){var _=f(v);return this.each(function(Y){x(this).wrapAll(_?v.call(this,Y):v)})},unwrap:function(v){return this.parent(v).not("body").each(function(){x(this).replaceWith(this.childNodes)}),this}}),x.expr.pseudos.hidden=function(v){return!x.expr.pseudos.visible(v)},x.expr.pseudos.visible=function(v){return!!(v.offsetWidth||v.offsetHeight||v.getClientRects().length)},x.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch{}};var L6={0:200,1223:204},ry=x.ajaxSettings.xhr();p.cors=!!ry&&"withCredentials"in ry,p.ajax=ry=!!ry,x.ajaxTransport(function(v){var _,Y;if(p.cors||ry&&!v.crossDomain)return{send:function(W,Z){var Q,re=v.xhr();if(re.open(v.type,v.url,v.async,v.username,v.password),v.xhrFields)for(Q in v.xhrFields)re[Q]=v.xhrFields[Q];v.mimeType&&re.overrideMimeType&&re.overrideMimeType(v.mimeType),!v.crossDomain&&!W["X-Requested-With"]&&(W["X-Requested-With"]="XMLHttpRequest");for(Q in W)re.setRequestHeader(Q,W[Q]);_=function(Ee){return function(){_&&(_=Y=re.onload=re.onerror=re.onabort=re.ontimeout=re.onreadystatechange=null,Ee==="abort"?re.abort():Ee==="error"?typeof re.status!="number"?Z(0,"error"):Z(re.status,re.statusText):Z(L6[re.status]||re.status,re.statusText,(re.responseType||"text")!=="text"||typeof re.responseText!="string"?{binary:re.response}:{text:re.responseText},re.getAllResponseHeaders()))}},re.onload=_(),Y=re.onerror=re.ontimeout=_("error"),re.onabort!==void 0?re.onabort=Y:re.onreadystatechange=function(){re.readyState===4&&e.setTimeout(function(){_&&Y()})},_=_("abort");try{re.send(v.hasContent&&v.data||null)}catch(Ee){if(_)throw Ee}},abort:function(){_&&_()}}}),x.ajaxPrefilter(function(v){v.crossDomain&&(v.contents.script=!1)}),x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(v){return x.globalEval(v),v}}}),x.ajaxPrefilter("script",function(v){v.cache===void 0&&(v.cache=!1),v.crossDomain&&(v.type="GET")}),x.ajaxTransport("script",function(v){if(v.crossDomain||v.scriptAttrs){var _,Y;return{send:function(W,Z){_=x("<script>").attr(v.scriptAttrs||{}).prop({charset:v.scriptCharset,src:v.url}).on("load error",Y=function(Q){_.remove(),Y=null,Q&&Z(Q.type==="error"?404:200,Q.type)}),g.head.appendChild(_[0])},abort:function(){Y&&Y()}}}});var t_=[],Hw=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var v=t_.pop()||x.expando+"_"+WD.guid++;return this[v]=!0,v}}),x.ajaxPrefilter("json jsonp",function(v,_,Y){var W,Z,Q,re=v.jsonp!==!1&&(Hw.test(v.url)?"url":typeof v.data=="string"&&(v.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&Hw.test(v.data)&&"data");if(re||v.dataTypes[0]==="jsonp")return W=v.jsonpCallback=f(v.jsonpCallback)?v.jsonpCallback():v.jsonpCallback,re?v[re]=v[re].replace(Hw,"$1"+W):v.jsonp!==!1&&(v.url+=(Fw.test(v.url)?"&":"?")+v.jsonp+"="+W),v.converters["script json"]=function(){return Q||x.error(W+" was not called"),Q[0]},v.dataTypes[0]="json",Z=e[W],e[W]=function(){Q=arguments},Y.always(function(){Z===void 0?x(e).removeProp(W):e[W]=Z,v[W]&&(v.jsonpCallback=_.jsonpCallback,t_.push(W)),Q&&f(Z)&&Z(Q[0]),Q=Z=void 0}),"script"}),p.createHTMLDocument=(function(){var v=g.implementation.createHTMLDocument("").body;return v.innerHTML="<form></form><form></form>",v.childNodes.length===2})(),x.parseHTML=function(v,_,Y){if(typeof v!="string")return[];typeof _=="boolean"&&(Y=_,_=!1);var W,Z,Q;return _||(p.createHTMLDocument?(_=g.implementation.createHTMLDocument(""),W=_.createElement("base"),W.href=g.location.href,_.head.appendChild(W)):_=g),Z=B.exec(v),Q=!Y&&[],Z?[_.createElement(Z[1])]:(Z=Ef([v],_,Q),Q&&Q.length&&x(Q).remove(),x.merge([],Z.childNodes))},x.fn.load=function(v,_,Y){var W,Z,Q,re=this,Ee=v.indexOf(" ");return Ee>-1&&(W=tp(v.slice(Ee)),v=v.slice(0,Ee)),f(_)?(Y=_,_=void 0):_&&typeof _=="object"&&(Z="POST"),re.length>0&&x.ajax({url:v,type:Z||"GET",dataType:"html",data:_}).done(function(be){Q=arguments,re.html(W?x("<div>").append(x.parseHTML(be)).find(W):be)}).always(Y&&function(be,De){re.each(function(){Y.apply(this,Q||[be.responseText,De,be])})}),this},x.expr.pseudos.animated=function(v){return x.grep(x.timers,function(_){return v===_.elem}).length},x.offset={setOffset:function(v,_,Y){var W,Z,Q,re,Ee,be,De,He=x.css(v,"position"),qe=x(v),ke={};He==="static"&&(v.style.position="relative"),Ee=qe.offset(),Q=x.css(v,"top"),be=x.css(v,"left"),De=(He==="absolute"||He==="fixed")&&(Q+be).indexOf("auto")>-1,De?(W=qe.position(),re=W.top,Z=W.left):(re=parseFloat(Q)||0,Z=parseFloat(be)||0),f(_)&&(_=_.call(v,Y,x.extend({},Ee))),_.top!=null&&(ke.top=_.top-Ee.top+re),_.left!=null&&(ke.left=_.left-Ee.left+Z),"using"in _?_.using.call(v,ke):qe.css(ke)}},x.fn.extend({offset:function(v){if(arguments.length)return v===void 0?this:this.each(function(Z){x.offset.setOffset(this,v,Z)});var _,Y,W=this[0];if(W)return W.getClientRects().length?(_=W.getBoundingClientRect(),Y=W.ownerDocument.defaultView,{top:_.top+Y.pageYOffset,left:_.left+Y.pageXOffset}):{top:0,left:0}},position:function(){if(this[0]){var v,_,Y,W=this[0],Z={top:0,left:0};if(x.css(W,"position")==="fixed")_=W.getBoundingClientRect();else{for(_=this.offset(),Y=W.ownerDocument,v=W.offsetParent||Y.documentElement;v&&(v===Y.body||v===Y.documentElement)&&x.css(v,"position")==="static";)v=v.parentNode;v&&v!==W&&v.nodeType===1&&(Z=x(v).offset(),Z.top+=x.css(v,"borderTopWidth",!0),Z.left+=x.css(v,"borderLeftWidth",!0))}return{top:_.top-Z.top-x.css(W,"marginTop",!0),left:_.left-Z.left-x.css(W,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var v=this.offsetParent;v&&x.css(v,"position")==="static";)v=v.offsetParent;return v||An})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(v,_){var Y=_==="pageYOffset";x.fn[v]=function(W){return ze(this,function(Z,Q,re){var Ee;if(m(Z)?Ee=Z:Z.nodeType===9&&(Ee=Z.defaultView),re===void 0)return Ee?Ee[_]:Z[Q];Ee?Ee.scrollTo(Y?Ee.pageXOffset:re,Y?re:Ee.pageYOffset):Z[Q]=re},v,W,arguments.length)}}),x.each(["top","left"],function(v,_){x.cssHooks[_]=kD(p.pixelPosition,function(Y,W){if(W)return W=ey(Y,_),Ow.test(W)?x(Y).position()[_]+"px":W})}),x.each({Height:"height",Width:"width"},function(v,_){x.each({padding:"inner"+v,content:_,"":"outer"+v},function(Y,W){x.fn[W]=function(Z,Q){var re=arguments.length&&(Y||typeof Z!="boolean"),Ee=Y||(Z===!0||Q===!0?"margin":"border");return ze(this,function(be,De,He){var qe;return m(be)?W.indexOf("outer")===0?be["inner"+v]:be.document.documentElement["client"+v]:be.nodeType===9?(qe=be.documentElement,Math.max(be.body["scroll"+v],qe["scroll"+v],be.body["offset"+v],qe["offset"+v],qe["client"+v])):He===void 0?x.css(be,De,Ee):x.style(be,De,He,Ee)},_,re?Z:void 0,re)}})}),x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(v,_){x.fn[_]=function(Y){return this.on(_,Y)}}),x.fn.extend({bind:function(v,_,Y){return this.on(v,null,_,Y)},unbind:function(v,_){return this.off(v,null,_)},delegate:function(v,_,Y,W){return this.on(_,v,Y,W)},undelegate:function(v,_,Y){return arguments.length===1?this.off(v,"**"):this.off(_,v||"**",Y)},hover:function(v,_){return this.on("mouseenter",v).on("mouseleave",_||v)}}),x.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(v,_){x.fn[_]=function(Y,W){return arguments.length>0?this.on(_,null,Y,W):this.trigger(_)}});var O6=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;x.proxy=function(v,_){var Y,W,Z;if(typeof _=="string"&&(Y=v[_],_=v,v=Y),!!f(v))return W=n.call(arguments,2),Z=function(){return v.apply(_||this,W.concat(n.call(arguments)))},Z.guid=v.guid=v.guid||x.guid++,Z},x.holdReady=function(v){v?x.readyWait++:x.ready(!0)},x.isArray=Array.isArray,x.parseJSON=JSON.parse,x.nodeName=A,x.isFunction=f,x.isWindow=m,x.camelCase=K,x.type=E,x.now=Date.now,x.isNumeric=function(v){var _=x.type(v);return(_==="number"||_==="string")&&!isNaN(v-parseFloat(v))},x.trim=function(v){return v==null?"":(v+"").replace(O6,"$1")},typeof define=="function"&&define.amd&&define("jquery",[],function(){return x});var R6=e.jQuery,N6=e.$;return x.noConflict=function(v){return e.$===x&&(e.$=N6),v&&e.jQuery===x&&(e.jQuery=R6),x},typeof t>"u"&&(e.jQuery=e.$=x),x})});var w_=oy(S_());document.write(w_.default);(!SVGPathElement.prototype.getPathData||!SVGPathElement.prototype.setPathData)&&(function(){var e={Z:"Z",M:"M",L:"L",C:"C",Q:"Q",A:"A",H:"H",V:"V",S:"S",T:"T",z:"Z",m:"m",l:"l",c:"c",q:"q",a:"a",h:"h",v:"v",s:"s",t:"t"},t=function(f){this._string=f,this._currentIndex=0,this._endIndex=this._string.length,this._prevCommand=null,this._skipOptionalSpaces()},i=window.navigator.userAgent.indexOf("MSIE ")!==-1;t.prototype={parseSegment:function(){var f=this._string[this._currentIndex],m=e[f]?e[f]:null;if(m===null){if(this._prevCommand===null||((f==="+"||f==="-"||f==="."||f>="0"&&f<="9")&&this._prevCommand!=="Z"?this._prevCommand==="M"?m="L":this._prevCommand==="m"?m="l":m=this._prevCommand:m=null,m===null))return null}else this._currentIndex+=1;this._prevCommand=m;var g=null,b=m.toUpperCase();return b==="H"||b==="V"?g=[this._parseNumber()]:b==="M"||b==="L"||b==="T"?g=[this._parseNumber(),this._parseNumber()]:b==="S"||b==="Q"?g=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber()]:b==="C"?g=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber()]:b==="A"?g=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseArcFlag(),this._parseArcFlag(),this._parseNumber(),this._parseNumber()]:b==="Z"&&(this._skipOptionalSpaces(),g=[]),g===null||g.indexOf(null)>=0?null:{type:m,values:g}},hasMoreData:function(){return this._currentIndex<this._endIndex},peekSegmentType:function(){var f=this._string[this._currentIndex];return e[f]?e[f]:null},initialCommandIsMoveTo:function(){if(!this.hasMoreData())return!0;var f=this.peekSegmentType();return f==="M"||f==="m"},_isCurrentSpace:function(){var f=this._string[this._currentIndex];return f<=" "&&(f===" "||f===`
`||f==="	"||f==="\r"||f==="\f")},_skipOptionalSpaces:function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex+=1;return this._currentIndex<this._endIndex},_skipOptionalSpacesOrDelimiter:function(){return this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&this._string[this._currentIndex]!==","?!1:(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&this._string[this._currentIndex]===","&&(this._currentIndex+=1,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},_parseNumber:function(){var f=0,m=0,g=1,b=0,y=1,E=1,S=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&this._string[this._currentIndex]==="+"?this._currentIndex+=1:this._currentIndex<this._endIndex&&this._string[this._currentIndex]==="-"&&(this._currentIndex+=1,y=-1),this._currentIndex===this._endIndex||(this._string[this._currentIndex]<"0"||this._string[this._currentIndex]>"9")&&this._string[this._currentIndex]!==".")return null;for(var w=this._currentIndex;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>="0"&&this._string[this._currentIndex]<="9";)this._currentIndex+=1;if(this._currentIndex!==w)for(var x=this._currentIndex-1,I=1;x>=w;)m+=I*(this._string[x]-"0"),x-=1,I*=10;if(this._currentIndex<this._endIndex&&this._string[this._currentIndex]==="."){if(this._currentIndex+=1,this._currentIndex>=this._endIndex||this._string[this._currentIndex]<"0"||this._string[this._currentIndex]>"9")return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>="0"&&this._string[this._currentIndex]<="9";)g*=10,b+=(this._string.charAt(this._currentIndex)-"0")/g,this._currentIndex+=1}if(this._currentIndex!==S&&this._currentIndex+1<this._endIndex&&(this._string[this._currentIndex]==="e"||this._string[this._currentIndex]==="E")&&this._string[this._currentIndex+1]!=="x"&&this._string[this._currentIndex+1]!=="m"){if(this._currentIndex+=1,this._string[this._currentIndex]==="+"?this._currentIndex+=1:this._string[this._currentIndex]==="-"&&(this._currentIndex+=1,E=-1),this._currentIndex>=this._endIndex||this._string[this._currentIndex]<"0"||this._string[this._currentIndex]>"9")return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>="0"&&this._string[this._currentIndex]<="9";)f*=10,f+=this._string[this._currentIndex]-"0",this._currentIndex+=1}var A=m+b;return A*=y,f&&(A*=Math.pow(10,E*f)),S===this._currentIndex?null:(this._skipOptionalSpacesOrDelimiter(),A)},_parseArcFlag:function(){if(this._currentIndex>=this._endIndex)return null;var f=null,m=this._string[this._currentIndex];if(this._currentIndex+=1,m==="0")f=0;else if(m==="1")f=1;else return null;return this._skipOptionalSpacesOrDelimiter(),f}};var r=function(f){if(!f||f.length===0)return[];var m=new t(f),g=[];if(m.initialCommandIsMoveTo())for(;m.hasMoreData();){var b=m.parseSegment();if(b===null)break;g.push(b)}return g},n=SVGPathElement.prototype.setAttribute,s=SVGPathElement.prototype.setAttributeNS,a=SVGPathElement.prototype.removeAttribute,o=SVGPathElement.prototype.removeAttributeNS,l=window.Symbol?Symbol():"__cachedPathData",c=window.Symbol?Symbol():"__cachedNormalizedPathData",u=function(f,m,g,b,y,E,S,w,x,I){var A=function(Be){return Math.PI*Be/180},O=function(Be,st,pt){var tt=Be*Math.cos(pt)-st*Math.sin(pt),li=Be*Math.sin(pt)+st*Math.cos(pt);return{x:tt,y:li}},R=A(S),M=[],F,G,V,q;if(I)F=I[0],G=I[1],V=I[2],q=I[3];else{var C=O(f,m,-R);f=C.x,m=C.y;var N=O(g,b,-R);g=N.x,b=N.y;var T=(f-g)/2,L=(m-b)/2,P=T*T/(y*y)+L*L/(E*E);P>1&&(P=Math.sqrt(P),y=P*y,E=P*E);var B;w===x?B=-1:B=1;var U=y*y,X=E*E,J=U*X-U*L*L-X*T*T,ne=U*L*L+X*T*T,fe=B*Math.sqrt(Math.abs(J/ne));V=fe*y*L/E+(f+g)/2,q=fe*-E*T/y+(m+b)/2,F=Math.asin(parseFloat(((m-q)/E).toFixed(9))),G=Math.asin(parseFloat(((b-q)/E).toFixed(9))),f<V&&(F=Math.PI-F),g<V&&(G=Math.PI-G),F<0&&(F=Math.PI*2+F),G<0&&(G=Math.PI*2+G),x&&F>G&&(F=F-Math.PI*2),!x&&G>F&&(G=G-Math.PI*2)}var xe=G-F;if(Math.abs(xe)>Math.PI*120/180){var ve=G,Fe=g,Ne=b;x&&G>F?G=F+Math.PI*120/180*1:G=F+Math.PI*120/180*-1,g=V+y*Math.cos(G),b=q+E*Math.sin(G),M=u(g,b,Fe,Ne,y,E,S,0,x,[G,ve,V,q])}xe=G-F;var nt=Math.cos(F),je=Math.sin(F),vt=Math.cos(G),Bt=Math.sin(G),Oi=Math.tan(xe/4),Ti=4/3*y*Oi,ze=4/3*E*Oi,D=[f,m],z=[f+Ti*je,m-ze*nt],$=[g+Ti*Bt,b-ze*vt],K=[g,b];if(z[0]=2*D[0]-z[0],z[1]=2*D[1]-z[1],I)return[z,$,K].concat(M);M=[z,$,K].concat(M);for(var ee=[],pe=0;pe<M.length;pe+=3){var y=O(M[pe][0],M[pe][1],R),E=O(M[pe+1][0],M[pe+1][1],R),ce=O(M[pe+2][0],M[pe+2][1],R);ee.push([y.x,y.y,E.x,E.y,ce.x,ce.y])}return ee},h=function(f){return f.map(function(m){return{type:m.type,values:Array.prototype.slice.call(m.values)}})},d=function(f){var m=[],g=null,b=null,y=null,E=null;return f.forEach(function(S){var w=S.type;if(w==="M"){var x=S.values[0],I=S.values[1];m.push({type:"M",values:[x,I]}),y=x,E=I,g=x,b=I}else if(w==="m"){var x=g+S.values[0],I=b+S.values[1];m.push({type:"M",values:[x,I]}),y=x,E=I,g=x,b=I}else if(w==="L"){var x=S.values[0],I=S.values[1];m.push({type:"L",values:[x,I]}),g=x,b=I}else if(w==="l"){var x=g+S.values[0],I=b+S.values[1];m.push({type:"L",values:[x,I]}),g=x,b=I}else if(w==="C"){var A=S.values[0],O=S.values[1],R=S.values[2],M=S.values[3],x=S.values[4],I=S.values[5];m.push({type:"C",values:[A,O,R,M,x,I]}),g=x,b=I}else if(w==="c"){var A=g+S.values[0],O=b+S.values[1],R=g+S.values[2],M=b+S.values[3],x=g+S.values[4],I=b+S.values[5];m.push({type:"C",values:[A,O,R,M,x,I]}),g=x,b=I}else if(w==="Q"){var A=S.values[0],O=S.values[1],x=S.values[2],I=S.values[3];m.push({type:"Q",values:[A,O,x,I]}),g=x,b=I}else if(w==="q"){var A=g+S.values[0],O=b+S.values[1],x=g+S.values[2],I=b+S.values[3];m.push({type:"Q",values:[A,O,x,I]}),g=x,b=I}else if(w==="A"){var x=S.values[5],I=S.values[6];m.push({type:"A",values:[S.values[0],S.values[1],S.values[2],S.values[3],S.values[4],x,I]}),g=x,b=I}else if(w==="a"){var x=g+S.values[5],I=b+S.values[6];m.push({type:"A",values:[S.values[0],S.values[1],S.values[2],S.values[3],S.values[4],x,I]}),g=x,b=I}else if(w==="H"){var x=S.values[0];m.push({type:"H",values:[x]}),g=x}else if(w==="h"){var x=g+S.values[0];m.push({type:"H",values:[x]}),g=x}else if(w==="V"){var I=S.values[0];m.push({type:"V",values:[I]}),b=I}else if(w==="v"){var I=b+S.values[0];m.push({type:"V",values:[I]}),b=I}else if(w==="S"){var R=S.values[0],M=S.values[1],x=S.values[2],I=S.values[3];m.push({type:"S",values:[R,M,x,I]}),g=x,b=I}else if(w==="s"){var R=g+S.values[0],M=b+S.values[1],x=g+S.values[2],I=b+S.values[3];m.push({type:"S",values:[R,M,x,I]}),g=x,b=I}else if(w==="T"){var x=S.values[0],I=S.values[1];m.push({type:"T",values:[x,I]}),g=x,b=I}else if(w==="t"){var x=g+S.values[0],I=b+S.values[1];m.push({type:"T",values:[x,I]}),g=x,b=I}else(w==="Z"||w==="z")&&(m.push({type:"Z",values:[]}),g=y,b=E)}),m},p=function(f){var m=[],g=null,b=null,y=null,E=null,S=null,w=null,x=null;return f.forEach(function(I){if(I.type==="M"){var A=I.values[0],O=I.values[1];m.push({type:"M",values:[A,O]}),w=A,x=O,E=A,S=O}else if(I.type==="C"){var R=I.values[0],M=I.values[1],F=I.values[2],G=I.values[3],A=I.values[4],O=I.values[5];m.push({type:"C",values:[R,M,F,G,A,O]}),b=F,y=G,E=A,S=O}else if(I.type==="L"){var A=I.values[0],O=I.values[1];m.push({type:"L",values:[A,O]}),E=A,S=O}else if(I.type==="H"){var A=I.values[0];m.push({type:"L",values:[A,S]}),E=A}else if(I.type==="V"){var O=I.values[0];m.push({type:"L",values:[E,O]}),S=O}else if(I.type==="S"){var F=I.values[0],G=I.values[1],A=I.values[2],O=I.values[3],V,q;g==="C"||g==="S"?(V=E+(E-b),q=S+(S-y)):(V=E,q=S),m.push({type:"C",values:[V,q,F,G,A,O]}),b=F,y=G,E=A,S=O}else if(I.type==="T"){var A=I.values[0],O=I.values[1],R,M;g==="Q"||g==="T"?(R=E+(E-b),M=S+(S-y)):(R=E,M=S);var V=E+2*(R-E)/3,q=S+2*(M-S)/3,C=A+2*(R-A)/3,N=O+2*(M-O)/3;m.push({type:"C",values:[V,q,C,N,A,O]}),b=R,y=M,E=A,S=O}else if(I.type==="Q"){var R=I.values[0],M=I.values[1],A=I.values[2],O=I.values[3],V=E+2*(R-E)/3,q=S+2*(M-S)/3,C=A+2*(R-A)/3,N=O+2*(M-O)/3;m.push({type:"C",values:[V,q,C,N,A,O]}),b=R,y=M,E=A,S=O}else if(I.type==="A"){var T=Math.abs(I.values[0]),L=Math.abs(I.values[1]),P=I.values[2],B=I.values[3],U=I.values[4],A=I.values[5],O=I.values[6];if(T===0||L===0)m.push({type:"C",values:[E,S,A,O,A,O]}),E=A,S=O;else if(E!==A||S!==O){var X=u(E,S,A,O,T,L,P,B,U);X.forEach(function(fe){m.push({type:"C",values:fe})}),E=A,S=O}}else I.type==="Z"&&(m.push(I),E=w,S=x);g=I.type}),m};SVGPathElement.prototype.setAttribute=function(f,m){f==="d"&&(this[l]=null,this[c]=null),n.call(this,f,m)},SVGPathElement.prototype.setAttributeNS=function(f,m,g){if(m==="d"){var b="http://www.w3.org/2000/svg";if(f)for(var y of this.ownerSVGElement.attributes)y.name===`xmlns:${f}`&&(b=y.value);b==="http://www.w3.org/2000/svg"&&(this[l]=null,this[c]=null)}s.call(this,f,m,g)},SVGPathElement.prototype.removeAttribute=function(f,m){f==="d"&&(this[l]=null,this[c]=null),a.call(this,f)},SVGPathElement.prototype.removeAttributeNS=function(f,m){if(m==="d"){var g="http://www.w3.org/2000/svg";if(f)for(var b of this.ownerSVGElement.attributes)b.name===`xmlns:${f}`&&(g=b.value);g==="http://www.w3.org/2000/svg"&&(this[l]=null,this[c]=null)}o.call(this,f,m)},SVGPathElement.prototype.getPathData=function(f){if(f&&f.normalize){if(this[c])return h(this[c]);var m;this[l]?m=h(this[l]):(m=r(this.getAttribute("d")||""),this[l]=h(m));var g=p(d(m));return this[c]=h(g),g}else{if(this[l])return h(this[l]);var m=r(this.getAttribute("d")||"");return this[l]=h(m),m}},SVGPathElement.prototype.setPathData=function(f){if(f.length===0)i?this.setAttribute("d",""):this.removeAttribute("d");else{for(var m="",g=0,b=f.length;g<b;g+=1){var y=f[g];g>0&&(m+=" "),m+=y.type,y.values&&y.values.length>0&&(m+=" "+y.values.join(" "))}this.setAttribute("d",m)}},SVGRectElement.prototype.getPathData=function(f){var m=this.x.baseVal.value,g=this.y.baseVal.value,b=this.width.baseVal.value,y=this.height.baseVal.value,E=this.hasAttribute("rx")?this.rx.baseVal.value:this.ry.baseVal.value,S=this.hasAttribute("ry")?this.ry.baseVal.value:this.rx.baseVal.value;E>b/2&&(E=b/2),S>y/2&&(S=y/2);var w=[{type:"M",values:[m+E,g]},{type:"H",values:[m+b-E]},{type:"A",values:[E,S,0,0,1,m+b,g+S]},{type:"V",values:[g+y-S]},{type:"A",values:[E,S,0,0,1,m+b-E,g+y]},{type:"H",values:[m+E]},{type:"A",values:[E,S,0,0,1,m,g+y-S]},{type:"V",values:[g+S]},{type:"A",values:[E,S,0,0,1,m+E,g]},{type:"Z",values:[]}];return w=w.filter(function(x){return!(x.type==="A"&&(x.values[0]===0||x.values[1]===0))}),f&&f.normalize===!0&&(w=p(w)),w},SVGCircleElement.prototype.getPathData=function(f){var m=this.cx.baseVal.value,g=this.cy.baseVal.value,b=this.r.baseVal.value,y=[{type:"M",values:[m+b,g]},{type:"A",values:[b,b,0,0,1,m,g+b]},{type:"A",values:[b,b,0,0,1,m-b,g]},{type:"A",values:[b,b,0,0,1,m,g-b]},{type:"A",values:[b,b,0,0,1,m+b,g]},{type:"Z",values:[]}];return f&&f.normalize===!0&&(y=p(y)),y},SVGEllipseElement.prototype.getPathData=function(f){var m=this.cx.baseVal.value,g=this.cy.baseVal.value,b=this.rx.baseVal.value,y=this.ry.baseVal.value,E=[{type:"M",values:[m+b,g]},{type:"A",values:[b,y,0,0,1,m,g+y]},{type:"A",values:[b,y,0,0,1,m-b,g]},{type:"A",values:[b,y,0,0,1,m,g-y]},{type:"A",values:[b,y,0,0,1,m+b,g]},{type:"Z",values:[]}];return f&&f.normalize===!0&&(E=p(E)),E},SVGLineElement.prototype.getPathData=function(){return[{type:"M",values:[this.x1.baseVal.value,this.y1.baseVal.value]},{type:"L",values:[this.x2.baseVal.value,this.y2.baseVal.value]}]},SVGPolylineElement.prototype.getPathData=function(){for(var f=[],m=0;m<this.points.numberOfItems;m+=1){var g=this.points.getItem(m);f.push({type:m===0?"M":"L",values:[g.x,g.y]})}return f},SVGPolygonElement.prototype.getPathData=function(){for(var f=[],m=0;m<this.points.numberOfItems;m+=1){var g=this.points.getItem(m);f.push({type:m===0?"M":"L",values:[g.x,g.y]})}return f.push({type:"Z",values:[]}),f}})();(function(){"use strict";typeof window>"u"||("SVGPathSeg"in window||(window.SVGPathSeg=function(e,t,i){this.pathSegType=e,this.pathSegTypeAsLetter=t,this._owningPathSegList=i},window.SVGPathSeg.prototype.classname="SVGPathSeg",window.SVGPathSeg.PATHSEG_UNKNOWN=0,window.SVGPathSeg.PATHSEG_CLOSEPATH=1,window.SVGPathSeg.PATHSEG_MOVETO_ABS=2,window.SVGPathSeg.PATHSEG_MOVETO_REL=3,window.SVGPathSeg.PATHSEG_LINETO_ABS=4,window.SVGPathSeg.PATHSEG_LINETO_REL=5,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS=6,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL=7,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS=8,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL=9,window.SVGPathSeg.PATHSEG_ARC_ABS=10,window.SVGPathSeg.PATHSEG_ARC_REL=11,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS=12,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL=13,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS=14,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL=15,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19,window.SVGPathSeg.prototype._segmentChanged=function(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)},window.SVGPathSegClosePath=function(e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CLOSEPATH,"z",e)},window.SVGPathSegClosePath.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegClosePath.prototype.toString=function(){return"[object SVGPathSegClosePath]"},window.SVGPathSegClosePath.prototype._asPathString=function(){return this.pathSegTypeAsLetter},window.SVGPathSegClosePath.prototype.clone=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathSegMovetoAbs=function(e,t,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_ABS,"M",e),this._x=t,this._y=i},window.SVGPathSegMovetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoAbs.prototype.toString=function(){return"[object SVGPathSegMovetoAbs]"},window.SVGPathSegMovetoAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegMovetoAbs.prototype.clone=function(){return new window.SVGPathSegMovetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegMovetoRel=function(e,t,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_REL,"m",e),this._x=t,this._y=i},window.SVGPathSegMovetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoRel.prototype.toString=function(){return"[object SVGPathSegMovetoRel]"},window.SVGPathSegMovetoRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegMovetoRel.prototype.clone=function(){return new window.SVGPathSegMovetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoAbs=function(e,t,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_ABS,"L",e),this._x=t,this._y=i},window.SVGPathSegLinetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoAbs.prototype.toString=function(){return"[object SVGPathSegLinetoAbs]"},window.SVGPathSegLinetoAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegLinetoAbs.prototype.clone=function(){return new window.SVGPathSegLinetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoRel=function(e,t,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_REL,"l",e),this._x=t,this._y=i},window.SVGPathSegLinetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoRel.prototype.toString=function(){return"[object SVGPathSegLinetoRel]"},window.SVGPathSegLinetoRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegLinetoRel.prototype.clone=function(){return new window.SVGPathSegLinetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicAbs=function(e,t,i,r,n,s,a){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,"C",e),this._x=t,this._y=i,this._x1=r,this._y1=n,this._x2=s,this._y2=a},window.SVGPathSegCurvetoCubicAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicAbs]"},window.SVGPathSegCurvetoCubicAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicAbs(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x1",{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y1",{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x2",{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y2",{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicRel=function(e,t,i,r,n,s,a){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,"c",e),this._x=t,this._y=i,this._x1=r,this._y1=n,this._x2=s,this._y2=a},window.SVGPathSegCurvetoCubicRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicRel]"},window.SVGPathSegCurvetoCubicRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicRel(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x1",{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y1",{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x2",{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y2",{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticAbs=function(e,t,i,r,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",e),this._x=t,this._y=i,this._x1=r,this._y1=n},window.SVGPathSegCurvetoQuadraticAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticAbs]"},window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x1",{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y1",{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticRel=function(e,t,i,r,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL,"q",e),this._x=t,this._y=i,this._x1=r,this._y1=n},window.SVGPathSegCurvetoQuadraticRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticRel]"},window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticRel(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x1",{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y1",{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcAbs=function(e,t,i,r,n,s,a,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_ABS,"A",e),this._x=t,this._y=i,this._r1=r,this._r2=n,this._angle=s,this._largeArcFlag=a,this._sweepFlag=o},window.SVGPathSegArcAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcAbs.prototype.toString=function(){return"[object SVGPathSegArcAbs]"},window.SVGPathSegArcAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y},window.SVGPathSegArcAbs.prototype.clone=function(){return new window.SVGPathSegArcAbs(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcAbs.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r1",{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r2",{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcRel=function(e,t,i,r,n,s,a,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_REL,"a",e),this._x=t,this._y=i,this._r1=r,this._r2=n,this._angle=s,this._largeArcFlag=a,this._sweepFlag=o},window.SVGPathSegArcRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcRel.prototype.toString=function(){return"[object SVGPathSegArcRel]"},window.SVGPathSegArcRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y},window.SVGPathSegArcRel.prototype.clone=function(){return new window.SVGPathSegArcRel(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcRel.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r1",{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r2",{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalAbs=function(e,t){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS,"H",e),this._x=t},window.SVGPathSegLinetoHorizontalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalAbs]"},window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x},window.SVGPathSegLinetoHorizontalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalAbs(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalRel=function(e,t){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL,"h",e),this._x=t},window.SVGPathSegLinetoHorizontalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalRel.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalRel]"},window.SVGPathSegLinetoHorizontalRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x},window.SVGPathSegLinetoHorizontalRel.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalRel(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalAbs=function(e,t){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS,"V",e),this._y=t},window.SVGPathSegLinetoVerticalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalAbs]"},window.SVGPathSegLinetoVerticalAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._y},window.SVGPathSegLinetoVerticalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalAbs(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalRel=function(e,t){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL,"v",e),this._y=t},window.SVGPathSegLinetoVerticalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalRel.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalRel]"},window.SVGPathSegLinetoVerticalRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._y},window.SVGPathSegLinetoVerticalRel.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalRel(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothAbs=function(e,t,i,r,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",e),this._x=t,this._y=i,this._x2=r,this._y2=n},window.SVGPathSegCurvetoCubicSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"},window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x2",{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y2",{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothRel=function(e,t,i,r,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",e),this._x=t,this._y=i,this._x2=r,this._y2=n},window.SVGPathSegCurvetoCubicSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothRel]"},window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x2",{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y2",{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothAbs=function(e,t,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",e),this._x=t,this._y=i},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothRel=function(e,t,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",e),this._x=t,this._y=i},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}),window.SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(e,t){return new window.SVGPathSegMovetoAbs(void 0,e,t)},window.SVGPathElement.prototype.createSVGPathSegMovetoRel=function(e,t){return new window.SVGPathSegMovetoRel(void 0,e,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(e,t){return new window.SVGPathSegLinetoAbs(void 0,e,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoRel=function(e,t){return new window.SVGPathSegLinetoRel(void 0,e,t)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(e,t,i,r,n,s){return new window.SVGPathSegCurvetoCubicAbs(void 0,e,t,i,r,n,s)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(e,t,i,r,n,s){return new window.SVGPathSegCurvetoCubicRel(void 0,e,t,i,r,n,s)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(e,t,i,r){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,e,t,i,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(e,t,i,r){return new window.SVGPathSegCurvetoQuadraticRel(void 0,e,t,i,r)},window.SVGPathElement.prototype.createSVGPathSegArcAbs=function(e,t,i,r,n,s,a){return new window.SVGPathSegArcAbs(void 0,e,t,i,r,n,s,a)},window.SVGPathElement.prototype.createSVGPathSegArcRel=function(e,t,i,r,n,s,a){return new window.SVGPathSegArcRel(void 0,e,t,i,r,n,s,a)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(e){return new window.SVGPathSegLinetoHorizontalAbs(void 0,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(e){return new window.SVGPathSegLinetoHorizontalRel(void 0,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(e){return new window.SVGPathSegLinetoVerticalAbs(void 0,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(e){return new window.SVGPathSegLinetoVerticalRel(void 0,e)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(e,t,i,r){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,e,t,i,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(e,t,i,r){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,e,t,i,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(e,t){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,e,t)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(e,t){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,e,t)},"getPathSegAtLength"in window.SVGPathElement.prototype||(window.SVGPathElement.prototype.getPathSegAtLength=function(e){if(e===void 0||!isFinite(e))throw"Invalid arguments.";var t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",this.getAttribute("d"));var i=t.pathSegList.numberOfItems-1;if(i<=0)return 0;do{if(t.pathSegList.removeItem(i),e>t.getTotalLength())break;i--}while(i>0);return i})),(!("SVGPathSegList"in window)||!("appendItem"in window.SVGPathSegList.prototype))&&(window.SVGPathSegList=function(e){this._pathElement=e,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.classname="SVGPathSegList",Object.defineProperty(window.SVGPathSegList.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathSegList.prototype,"length",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"pathSegList",{get:function(){return this._pathSegList||(this._pathSegList=new window.SVGPathSegList(this)),this._pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"normalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedNormalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),window.SVGPathSegList.prototype._checkPathSynchronizedToList=function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())},window.SVGPathSegList.prototype._updateListFromPathMutations=function(e){if(this._pathElement){var t=!1;e.forEach(function(i){i.attributeName=="d"&&(t=!0)}),t&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}},window.SVGPathSegList.prototype._writeListToPath=function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",window.SVGPathSegList._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.segmentChanged=function(e){this._writeListToPath()},window.SVGPathSegList.prototype.clear=function(){this._checkPathSynchronizedToList(),this._list.forEach(function(e){e._owningPathSegList=null}),this._list=[],this._writeListToPath()},window.SVGPathSegList.prototype.initialize=function(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e},window.SVGPathSegList.prototype._checkValidIndex=function(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw"INDEX_SIZE_ERR"},window.SVGPathSegList.prototype.getItem=function(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]},window.SVGPathSegList.prototype.insertItemBefore=function(e,t){return this._checkPathSynchronizedToList(),t>this.numberOfItems&&(t=this.numberOfItems),e._owningPathSegList&&(e=e.clone()),this._list.splice(t,0,e),e._owningPathSegList=this,this._writeListToPath(),e},window.SVGPathSegList.prototype.replaceItem=function(e,t){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._checkValidIndex(t),this._list[t]=e,e._owningPathSegList=this,this._writeListToPath(),e},window.SVGPathSegList.prototype.removeItem=function(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);var t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t},window.SVGPathSegList.prototype.appendItem=function(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e},window.SVGPathSegList._pathSegArrayAsString=function(e){var t="",i=!0;return e.forEach(function(r){i?(i=!1,t+=r._asPathString()):t+=" "+r._asPathString()}),t},window.SVGPathSegList.prototype._parsePath=function(e){if(!e||e.length==0)return[];var t=this,i=function(){this.pathSegList=[]};i.prototype.appendSegment=function(o){this.pathSegList.push(o)};var r=function(o){this._string=o,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=window.SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()};r.prototype._isCurrentSpace=function(){var o=this._string[this._currentIndex];return o<=" "&&(o==" "||o==`
`||o=="	"||o=="\r"||o=="\f")},r.prototype._skipOptionalSpaces=function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex},r.prototype._skipOptionalSpacesOrDelimiter=function(){return this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&this._string.charAt(this._currentIndex)!=","?!1:(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)==","&&(this._currentIndex++,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},r.prototype.hasMoreData=function(){return this._currentIndex<this._endIndex},r.prototype.peekSegmentType=function(){var o=this._string[this._currentIndex];return this._pathSegTypeFromChar(o)},r.prototype._pathSegTypeFromChar=function(o){switch(o){case"Z":case"z":return window.SVGPathSeg.PATHSEG_CLOSEPATH;case"M":return window.SVGPathSeg.PATHSEG_MOVETO_ABS;case"m":return window.SVGPathSeg.PATHSEG_MOVETO_REL;case"L":return window.SVGPathSeg.PATHSEG_LINETO_ABS;case"l":return window.SVGPathSeg.PATHSEG_LINETO_REL;case"C":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;case"c":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;case"Q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return window.SVGPathSeg.PATHSEG_ARC_ABS;case"a":return window.SVGPathSeg.PATHSEG_ARC_REL;case"H":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;case"v":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;case"S":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return window.SVGPathSeg.PATHSEG_UNKNOWN}},r.prototype._nextCommandHelper=function(o,l){return(o=="+"||o=="-"||o=="."||o>="0"&&o<="9")&&l!=window.SVGPathSeg.PATHSEG_CLOSEPATH?l==window.SVGPathSeg.PATHSEG_MOVETO_ABS?window.SVGPathSeg.PATHSEG_LINETO_ABS:l==window.SVGPathSeg.PATHSEG_MOVETO_REL?window.SVGPathSeg.PATHSEG_LINETO_REL:l:window.SVGPathSeg.PATHSEG_UNKNOWN},r.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return!0;var o=this.peekSegmentType();return o==window.SVGPathSeg.PATHSEG_MOVETO_ABS||o==window.SVGPathSeg.PATHSEG_MOVETO_REL},r.prototype._parseNumber=function(){var o=0,l=0,c=1,u=0,h=1,d=1,p=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)=="+"?this._currentIndex++:this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)=="-"&&(this._currentIndex++,h=-1),!(this._currentIndex==this._endIndex||(this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")&&this._string.charAt(this._currentIndex)!=".")){for(var f=this._currentIndex;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!=f)for(var m=this._currentIndex-1,g=1;m>=f;)l+=g*(this._string.charAt(m--)-"0"),g*=10;if(this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)=="."){if(this._currentIndex++,this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)c*=10,u+=(this._string.charAt(this._currentIndex)-"0")/c,this._currentIndex+=1}if(this._currentIndex!=p&&this._currentIndex+1<this._endIndex&&(this._string.charAt(this._currentIndex)=="e"||this._string.charAt(this._currentIndex)=="E")&&this._string.charAt(this._currentIndex+1)!="x"&&this._string.charAt(this._currentIndex+1)!="m"){if(this._currentIndex++,this._string.charAt(this._currentIndex)=="+"?this._currentIndex++:this._string.charAt(this._currentIndex)=="-"&&(this._currentIndex++,d=-1),this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)o*=10,o+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var b=l+u;if(b*=h,o&&(b*=Math.pow(10,d*o)),p!=this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),b}},r.prototype._parseArcFlag=function(){if(!(this._currentIndex>=this._endIndex)){var o=!1,l=this._string.charAt(this._currentIndex++);if(l=="0")o=!1;else if(l=="1")o=!0;else return;return this._skipOptionalSpacesOrDelimiter(),o}},r.prototype.parseSegment=function(){var o=this._string[this._currentIndex],l=this._pathSegTypeFromChar(o);if(l==window.SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==window.SVGPathSeg.PATHSEG_UNKNOWN||(l=this._nextCommandHelper(o,this._previousCommand),l==window.SVGPathSeg.PATHSEG_UNKNOWN))return null}else this._currentIndex++;switch(this._previousCommand=l,l){case window.SVGPathSeg.PATHSEG_MOVETO_REL:return new window.SVGPathSegMovetoRel(t,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_MOVETO_ABS:return new window.SVGPathSegMovetoAbs(t,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_REL:return new window.SVGPathSegLinetoRel(t,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_ABS:return new window.SVGPathSegLinetoAbs(t,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new window.SVGPathSegLinetoHorizontalRel(t,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new window.SVGPathSegLinetoHorizontalAbs(t,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new window.SVGPathSegLinetoVerticalRel(t,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new window.SVGPathSegLinetoVerticalAbs(t,this._parseNumber());case window.SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new window.SVGPathSegClosePath(t);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var c={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicRel(t,c.x,c.y,c.x1,c.y1,c.x2,c.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var c={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicAbs(t,c.x,c.y,c.x1,c.y1,c.x2,c.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:var c={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicSmoothRel(t,c.x,c.y,c.x2,c.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:var c={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicSmoothAbs(t,c.x,c.y,c.x2,c.y2);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var c={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoQuadraticRel(t,c.x,c.y,c.x1,c.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:var c={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoQuadraticAbs(t,c.x,c.y,c.x1,c.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new window.SVGPathSegCurvetoQuadraticSmoothRel(t,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new window.SVGPathSegCurvetoQuadraticSmoothAbs(t,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_ARC_REL:var c={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcRel(t,c.x,c.y,c.x1,c.y1,c.arcAngle,c.arcLarge,c.arcSweep);case window.SVGPathSeg.PATHSEG_ARC_ABS:var c={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcAbs(t,c.x,c.y,c.x1,c.y1,c.arcAngle,c.arcLarge,c.arcSweep);default:throw"Unknown path seg type."}};var n=new i,s=new r(e);if(!s.initialCommandIsMoveTo())return[];for(;s.hasMoreData();){var a=s.parseSegment();if(!a)return[];n.appendSegment(a)}return n.pathSegList}))})();var Lw=oy(gb());var w8=Object.create,fP=Object.defineProperty,v8=Object.getOwnPropertyDescriptor,T8=Object.getOwnPropertyNames,I8=Object.getPrototypeOf,A8=Object.prototype.hasOwnProperty,C8=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),D8=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T8(t))!A8.call(e,n)&&n!==i&&fP(e,n,{get:()=>t[n],enumerable:!(r=v8(t,n))||r.enumerable});return e},_8=(e,t,i)=>(i=e!=null?w8(I8(e)):{},D8(t||!e||!e.__esModule?fP(i,"default",{value:e,enumerable:!0}):i,e)),P8=C8((e,t)=>{"use strict";t.exports=i,t.exports.default=i;function i(T,L,P){P=P||2;var B=L&&L.length,U=B?L[0]*P:T.length,X=r(T,0,U,P,!0),J=[];if(!X||X.next===X.prev)return J;var ne,fe,xe,ve,Fe,Ne,nt;if(B&&(X=u(T,L,X,P)),T.length>80*P){ne=xe=T[0],fe=ve=T[1];for(var je=P;je<U;je+=P)Fe=T[je],Ne=T[je+1],Fe<ne&&(ne=Fe),Ne<fe&&(fe=Ne),Fe>xe&&(xe=Fe),Ne>ve&&(ve=Ne);nt=Math.max(xe-ne,ve-fe),nt=nt!==0?32767/nt:0}return s(X,J,P,ne,fe,nt,0),J}function r(T,L,P,B,U){var X,J;if(U===N(T,L,P,B)>0)for(X=L;X<P;X+=B)J=V(X,T[X],T[X+1],J);else for(X=P-B;X>=L;X-=B)J=V(X,T[X],T[X+1],J);return J&&x(J,J.next)&&(q(J),J=J.next),J}function n(T,L){if(!T)return T;L||(L=T);var P=T,B;do if(B=!1,!P.steiner&&(x(P,P.next)||w(P.prev,P,P.next)===0)){if(q(P),P=L=P.prev,P===P.next)break;B=!0}else P=P.next;while(B||P!==L);return L}function s(T,L,P,B,U,X,J){if(T){!J&&X&&m(T,B,U,X);for(var ne=T,fe,xe;T.prev!==T.next;){if(fe=T.prev,xe=T.next,X?o(T,B,U,X):a(T)){L.push(fe.i/P|0),L.push(T.i/P|0),L.push(xe.i/P|0),q(T),T=xe.next,ne=xe.next;continue}if(T=xe,T===ne){J?J===1?(T=l(n(T),L,P),s(T,L,P,B,U,X,2)):J===2&&c(T,L,P,B,U,X):s(n(T),L,P,B,U,X,1);break}}}}function a(T){var L=T.prev,P=T,B=T.next;if(w(L,P,B)>=0)return!1;for(var U=L.x,X=P.x,J=B.x,ne=L.y,fe=P.y,xe=B.y,ve=U<X?U<J?U:J:X<J?X:J,Fe=ne<fe?ne<xe?ne:xe:fe<xe?fe:xe,Ne=U>X?U>J?U:J:X>J?X:J,nt=ne>fe?ne>xe?ne:xe:fe>xe?fe:xe,je=B.next;je!==L;){if(je.x>=ve&&je.x<=Ne&&je.y>=Fe&&je.y<=nt&&E(U,ne,X,fe,J,xe,je.x,je.y)&&w(je.prev,je,je.next)>=0)return!1;je=je.next}return!0}function o(T,L,P,B){var U=T.prev,X=T,J=T.next;if(w(U,X,J)>=0)return!1;for(var ne=U.x,fe=X.x,xe=J.x,ve=U.y,Fe=X.y,Ne=J.y,nt=ne<fe?ne<xe?ne:xe:fe<xe?fe:xe,je=ve<Fe?ve<Ne?ve:Ne:Fe<Ne?Fe:Ne,vt=ne>fe?ne>xe?ne:xe:fe>xe?fe:xe,Bt=ve>Fe?ve>Ne?ve:Ne:Fe>Ne?Fe:Ne,Oi=b(nt,je,L,P,B),Ti=b(vt,Bt,L,P,B),ze=T.prevZ,D=T.nextZ;ze&&ze.z>=Oi&&D&&D.z<=Ti;){if(ze.x>=nt&&ze.x<=vt&&ze.y>=je&&ze.y<=Bt&&ze!==U&&ze!==J&&E(ne,ve,fe,Fe,xe,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0||(ze=ze.prevZ,D.x>=nt&&D.x<=vt&&D.y>=je&&D.y<=Bt&&D!==U&&D!==J&&E(ne,ve,fe,Fe,xe,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0))return!1;D=D.nextZ}for(;ze&&ze.z>=Oi;){if(ze.x>=nt&&ze.x<=vt&&ze.y>=je&&ze.y<=Bt&&ze!==U&&ze!==J&&E(ne,ve,fe,Fe,xe,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0)return!1;ze=ze.prevZ}for(;D&&D.z<=Ti;){if(D.x>=nt&&D.x<=vt&&D.y>=je&&D.y<=Bt&&D!==U&&D!==J&&E(ne,ve,fe,Fe,xe,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0)return!1;D=D.nextZ}return!0}function l(T,L,P){var B=T;do{var U=B.prev,X=B.next.next;!x(U,X)&&I(U,B,B.next,X)&&M(U,X)&&M(X,U)&&(L.push(U.i/P|0),L.push(B.i/P|0),L.push(X.i/P|0),q(B),q(B.next),B=T=X),B=B.next}while(B!==T);return n(B)}function c(T,L,P,B,U,X){var J=T;do{for(var ne=J.next.next;ne!==J.prev;){if(J.i!==ne.i&&S(J,ne)){var fe=G(J,ne);J=n(J,J.next),fe=n(fe,fe.next),s(J,L,P,B,U,X,0),s(fe,L,P,B,U,X,0);return}ne=ne.next}J=J.next}while(J!==T)}function u(T,L,P,B){var U=[],X,J,ne,fe,xe;for(X=0,J=L.length;X<J;X++)ne=L[X]*B,fe=X<J-1?L[X+1]*B:T.length,xe=r(T,ne,fe,B,!1),xe===xe.next&&(xe.steiner=!0),U.push(y(xe));for(U.sort(h),X=0;X<U.length;X++)P=d(U[X],P);return P}function h(T,L){return T.x-L.x}function d(T,L){var P=p(T,L);if(!P)return L;var B=G(P,T);return n(B,B.next),n(P,P.next)}function p(T,L){var P=L,B=T.x,U=T.y,X=-1/0,J;do{if(U<=P.y&&U>=P.next.y&&P.next.y!==P.y){var ne=P.x+(U-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(ne<=B&&ne>X&&(X=ne,J=P.x<P.next.x?P:P.next,ne===B))return J}P=P.next}while(P!==L);if(!J)return null;var fe=J,xe=J.x,ve=J.y,Fe=1/0,Ne;P=J;do B>=P.x&&P.x>=xe&&B!==P.x&&E(U<ve?B:X,U,xe,ve,U<ve?X:B,U,P.x,P.y)&&(Ne=Math.abs(U-P.y)/(B-P.x),M(P,T)&&(Ne<Fe||Ne===Fe&&(P.x>J.x||P.x===J.x&&f(J,P)))&&(J=P,Fe=Ne)),P=P.next;while(P!==fe);return J}function f(T,L){return w(T.prev,T,L.prev)<0&&w(L.next,T,T.next)<0}function m(T,L,P,B){var U=T;do U.z===0&&(U.z=b(U.x,U.y,L,P,B)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==T);U.prevZ.nextZ=null,U.prevZ=null,g(U)}function g(T){var L,P,B,U,X,J,ne,fe,xe=1;do{for(P=T,T=null,X=null,J=0;P;){for(J++,B=P,ne=0,L=0;L<xe&&(ne++,B=B.nextZ,!!B);L++);for(fe=xe;ne>0||fe>0&&B;)ne!==0&&(fe===0||!B||P.z<=B.z)?(U=P,P=P.nextZ,ne--):(U=B,B=B.nextZ,fe--),X?X.nextZ=U:T=U,U.prevZ=X,X=U;P=B}X.nextZ=null,xe*=2}while(J>1);return T}function b(T,L,P,B,U){return T=(T-P)*U|0,L=(L-B)*U|0,T=(T|T<<8)&16711935,T=(T|T<<4)&252645135,T=(T|T<<2)&858993459,T=(T|T<<1)&1431655765,L=(L|L<<8)&16711935,L=(L|L<<4)&252645135,L=(L|L<<2)&858993459,L=(L|L<<1)&1431655765,T|L<<1}function y(T){var L=T,P=T;do(L.x<P.x||L.x===P.x&&L.y<P.y)&&(P=L),L=L.next;while(L!==T);return P}function E(T,L,P,B,U,X,J,ne){return(U-J)*(L-ne)>=(T-J)*(X-ne)&&(T-J)*(B-ne)>=(P-J)*(L-ne)&&(P-J)*(X-ne)>=(U-J)*(B-ne)}function S(T,L){return T.next.i!==L.i&&T.prev.i!==L.i&&!R(T,L)&&(M(T,L)&&M(L,T)&&F(T,L)&&(w(T.prev,T,L.prev)||w(T,L.prev,L))||x(T,L)&&w(T.prev,T,T.next)>0&&w(L.prev,L,L.next)>0)}function w(T,L,P){return(L.y-T.y)*(P.x-L.x)-(L.x-T.x)*(P.y-L.y)}function x(T,L){return T.x===L.x&&T.y===L.y}function I(T,L,P,B){var U=O(w(T,L,P)),X=O(w(T,L,B)),J=O(w(P,B,T)),ne=O(w(P,B,L));return!!(U!==X&&J!==ne||U===0&&A(T,P,L)||X===0&&A(T,B,L)||J===0&&A(P,T,B)||ne===0&&A(P,L,B))}function A(T,L,P){return L.x<=Math.max(T.x,P.x)&&L.x>=Math.min(T.x,P.x)&&L.y<=Math.max(T.y,P.y)&&L.y>=Math.min(T.y,P.y)}function O(T){return T>0?1:T<0?-1:0}function R(T,L){var P=T;do{if(P.i!==T.i&&P.next.i!==T.i&&P.i!==L.i&&P.next.i!==L.i&&I(P,P.next,T,L))return!0;P=P.next}while(P!==T);return!1}function M(T,L){return w(T.prev,T,T.next)<0?w(T,L,T.next)>=0&&w(T,T.prev,L)>=0:w(T,L,T.prev)<0||w(T,T.next,L)<0}function F(T,L){var P=T,B=!1,U=(T.x+L.x)/2,X=(T.y+L.y)/2;do P.y>X!=P.next.y>X&&P.next.y!==P.y&&U<(P.next.x-P.x)*(X-P.y)/(P.next.y-P.y)+P.x&&(B=!B),P=P.next;while(P!==T);return B}function G(T,L){var P=new C(T.i,T.x,T.y),B=new C(L.i,L.x,L.y),U=T.next,X=L.prev;return T.next=L,L.prev=T,P.next=U,U.prev=P,B.next=P,P.prev=B,X.next=B,B.prev=X,B}function V(T,L,P,B){var U=new C(T,L,P);return B?(U.next=B.next,U.prev=B,B.next.prev=U,B.next=U):(U.prev=U,U.next=U),U}function q(T){T.next.prev=T.prev,T.prev.next=T.next,T.prevZ&&(T.prevZ.nextZ=T.nextZ),T.nextZ&&(T.nextZ.prevZ=T.prevZ)}function C(T,L,P){this.i=T,this.x=L,this.y=P,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(T,L,P,B){var U=L&&L.length,X=U?L[0]*P:T.length,J=Math.abs(N(T,0,X,P));if(U)for(var ne=0,fe=L.length;ne<fe;ne++){var xe=L[ne]*P,ve=ne<fe-1?L[ne+1]*P:T.length;J-=Math.abs(N(T,xe,ve,P))}var Fe=0;for(ne=0;ne<B.length;ne+=3){var Ne=B[ne]*P,nt=B[ne+1]*P,je=B[ne+2]*P;Fe+=Math.abs((T[Ne]-T[je])*(T[nt+1]-T[Ne+1])-(T[Ne]-T[nt])*(T[je+1]-T[Ne+1]))}return J===0&&Fe===0?0:Math.abs((Fe-J)/J)};function N(T,L,P,B){for(var U=0,X=L,J=P-B;X<P;X+=B)U+=(T[J]-T[X])*(T[X+1]+T[J+1]),J=X;return U}i.flatten=function(T){for(var L=T[0][0].length,P={vertices:[],holes:[],dimensions:L},B=0,U=0;U<T.length;U++){for(var X=0;X<T[U].length;X++)for(var J=0;J<L;J++)P.vertices.push(T[U][X][J]);U>0&&(B+=T[U-1].length,P.holes.push(B))}return P}}),O_={mil:1,inch:1e3,ft:12e3,yard:36e3,mile:6336e4,km:3937007874e-2,dm:3937,mm:39.37,um:.039,nm:394e-7,pt:13.88888888888889,"px(72)":13.88888888888889,"px(96)":10.416666666666666,"px(100)":10},Eie=(()=>{let e={};for(let t in O_)e[O_[t]]=t;return e})(),R_=class{constructor(t,i){this.ratio=t/i}wrap(t){return t*this.ratio}static convert(t,i,r){return t*i/r}};R_.ASIS=new R_(1,1);var Kb=class{conversion(e,t,i){if(e===t)return i;let r=e+2+t;return this[r](i)}conversion1(e,t,i){let r=e+2+t,n=this[r](i);return t=="mil"?Math.round(n*10)/10:Math.round(n*1e3)/1e3}mil2mil(e){return e}mil2mm(e){return e*.0254}mil2cm(e){return e*.00254}mil2inch(e){return e/1e3}mm2mm(e){return e}mm2mil(e){let t=Math.pow(10,5);return Math.round(e*39.37007874015748*t)/t}mm2cm(e){return e/10}mm2inch(e){let t=Math.pow(10,8);return Math.round(e*.03937007874015748*t)/t}cm2mil(e){let t=Math.pow(10,6);return Math.round(e*393.7007874015748*t)/t}cm2mm(e){return e*10}cm2inch(e){let t=Math.pow(10,7);return Math.round(e*.3937007874015748*t)/t}inch2mil(e){return e*1e3}inch2mm(e){return e*25.4}inch2cm(e){return e*2.54}};Kb.prototype["px(100)2mil"]=e=>e*10;Kb.prototype["px(100)2mm"]=e=>e*.254;Kb.prototype["mil2px(100)"]=e=>e/10;Kb.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var yb=null,Gv=new ArrayBuffer(8),av=new Float64Array(Gv),ov=new Uint32Array(Gv),N_=new Uint16Array(Gv),M_=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,n){if(e.length>=t+n&&i.length>=r+n)for(;n-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let n=0;n<t;n++){let s=e.charAt(n);if(r>=0){if(s===";"){let a=e.substring(r+1,n);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else s==="&"?r=n:i.push(s)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let n=0;n<r;n++)e[n]===t&&(e.splice(n,1),n--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!yb){let e=this.getUrlVars().version;e?yb="/analyzer/v"+e:yb="/analyzer"}return yb}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;av[0]=new Date().getTime(),e.push(ov[1].toString(16)),av[0]=Math.random(),e.push(N_[3].toString(16));let t=N_[2].toString(16);e.push("4"+t.substr(0,3)),av[0]=performance.now();let i=ov[0].toString(16)+ov[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},mP=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(kf.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(kf.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(kf.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(kf.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},L8=/(\.?0+)$/,kf=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,n=0,s,a=0,o=0;for(let l=0;l<e.length;l++){let c=e.charAt(l),u=c.charCodeAt(0);switch(r){case 0:u===37?r=1:i.push(c);break;case 1:switch(u){case 100:if(s=t[n++],typeof s=="number")i.push(s.toFixed(0)),r=0;else return l;break;case 102:if(s=t[n++],typeof s=="number")i.push(s.toString()),r=0;else return l;break;case 120:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16)),r=0;else return l;break;case 88:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:s=t[n++],i.push(s===null?"null":s.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(u){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(M_.lpad((s|0).toString(16),"0",h)),r=0;else return l}else return l;break;case 88:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(M_.lpad((s|0).toString(16).toUpperCase(),"0",h)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let n=e.exec(t);if(n!==null){let s=e.lastIndex-n[0].length;i.push(t.substring(r,s)),r=e.lastIndex}else{let s=t.substring(r);mP.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(L8,"")}};function O8(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var R8=(e,t)=>{e===3?console.error(t):console.log(t)},N8=(e,t)=>kf.format("%s %s: %s",new Date,O8(e),t),Av=class Cv{constructor(t,i=R8,r=N8){this.debug=!1,this.level=t,this.writer=i,this.fmt=r}static mix(...t){let i=4;for(let r of t)r.level<i&&(i=r.level);return new Cv(i,(r,n)=>{for(let s of t)s.write1(r,n)},(r,n)=>n)}wrap(t=null,i=null){let r=t===null?this.fmt:(s,a)=>(a=t(s,a),this.fmt(s,a)),n=i===null?this.writer:(s,a)=>{i(s,a),this.writer(s,a)};return new Cv(this.level,n,r)}chain(t){return t.wrap(this.fmt.bind(this),this.writer.bind(this))}include(t){return this.level<=t}write3(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,kf.format(i,...r)))}write2(t,i){this.include(t)&&(i instanceof Error?this.writer(t,this.fmt(t,i.stack)):this.writer(t,this.fmt(t,i.toString())))}write1(t,i){this.include(t)&&this.writer(t,this.fmt(t,i))}debug3(t,...i){this.write3(0,t,i)}debug2(t){this.write2(0,t)}debug1(t){this.write1(0,t)}info3(t,...i){this.write3(1,t,i)}info2(t){this.write2(1,t)}info1(t){this.write1(1,t)}warning3(t,...i){this.write3(2,t,i)}warning2(t){this.write2(2,t)}warning1(t){this.write1(2,t)}error3(t,...i){this.write3(3,t,i)}error2(t){this.write2(3,t)}error1(t){this.write1(3,t)}};Av.DUMMY=new Av(4);var $b=Av,Uv=new ArrayBuffer(8),lv=new Float64Array(Uv),cv=new Uint32Array(Uv),B_=new Uint16Array(Uv),k_=ArrayBuffer;try{k_=self.HTMLImageElement||k_}catch{}var bb=null;function hp(e,t,i=0,r=e.length){n(e,null,t,i,r);function n(a,o,l,c,u){let h,d,p,f;if(c<u-1){let m=u-c;if(m>50)o===null&&(o=new Array(m+1)),s(a,o,l,c,(c+u)/2|0,u);else{h=a[c],d=c,p=c,f=u;let g=d+1;for(;g<f;){if(p!=f){if(f=f+-1,l(h,a[f])<=0)continue;a[p]=a[f],p=f;continue}if(l(h,a[g])>=0){d=g,g=d+1;continue}a[p]=a[g],d=g,p=g,g=d+1}a[p]=h,n(a,o,l,c,p),n(a,o,l,p+1,u)}}}function s(a,o,l,c,u,h){n(a,o,l,c,u),n(a,o,l,u,h);for(var d=c,p=u,f=0,m=a[d],g=a[p];d<u&&p<h;){var b=l(m,g);isNaN(b)?(o[f++]=g,g=a[++p]):(b<=0&&(o[f++]=m,m=a[++d]),b>=0&&(o[f++]=g,g=a[++p]))}for(;d<u;d++)o[f++]=a[d];for(;p<h;p++)o[f++]=a[p];for(d=c,p=0;p<f;d++,p++)a[d]=o[p]}}var fa=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,n){if(e.length>=t+n&&i.length>=r+n)for(;n-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let n=0;n<t;n++){let s=e.charAt(n);if(r>=0){if(s===";"){let a=e.substring(r+1,n);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else s==="&"?r=n:i.push(s)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let n=0;n<r;n++)e[n]===t&&(e.splice(n,1),n--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!bb){let e=this.getUrlVars().version;e?bb="/analyzer/v"+e:bb="/analyzer"}return bb}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;lv[0]=new Date().getTime(),e.push(cv[1].toString(16)),lv[0]=Math.random(),e.push(B_[3].toString(16));let t=B_[2].toString(16);e.push("4"+t.substr(0,3)),lv[0]=performance.now();let i=cv[0].toString(16)+cv[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},M8=[1,10,100,1e3],xb=0,ap=0;function F_(e,t,i){return xb=Math.abs(e-t),i>=5&&xb>1e-5||isNaN(i)&&xb>1e-8?!1:xb<1e-13?!0:(ap=Math.min(G_(e),G_(t)),ap<10&&(ap=10),isNaN(i)||(ap=Math.min(ap,i)),U_(e,ap)===U_(t,ap))}var Eb=0,Sb=0;function G_(e){return Eb=0,Sb=0,e>0?Eb=e-Math.floor(e):Eb=e-Math.ceil(e),Sb=(Eb.toString()||"").length,Sb>2?Sb-2:0}function U_(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=M8[t]||Math.pow(10,t)||10;if(i){var n=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(n+e)}else return Math.round(e*r+1e-10)/r}var B8=/(\.?0+)$/,Ff=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,n=0,s,a=0,o=0;for(let l=0;l<e.length;l++){let c=e.charAt(l),u=c.charCodeAt(0);switch(r){case 0:u===37?r=1:i.push(c);break;case 1:switch(u){case 100:if(s=t[n++],typeof s=="number")i.push(s.toFixed(0)),r=0;else return l;break;case 102:if(s=t[n++],typeof s=="number")i.push(s.toString()),r=0;else return l;break;case 120:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16)),r=0;else return l;break;case 88:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:s=t[n++],i.push(s===null?"null":s.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(u){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(fa.lpad((s|0).toString(16),"0",h)),r=0;else return l}else return l;break;case 88:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(fa.lpad((s|0).toString(16).toUpperCase(),"0",h)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let n=e.exec(t);if(n!==null){let s=e.lastIndex-n[0].length;i.push(t.substring(r,s)),r=e.lastIndex}else{let s=t.substring(r);tn.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(B8,"")}},tn=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(Ff.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(Ff.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(Ff.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(Ff.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},_e=class{static regular(e){return Math.round(e*this.precision)/this.precision}static eq(e,t){return Math.abs(e-t)<=this.eps}static neq(e,t){return Math.abs(e-t)>this.eps}static less(e,t){return e-t<-this.eps}static lesseq(e,t){return e-t<=this.eps}static greater(e,t){return e-t>this.eps}static greatereq(e,t){return e-t>=-this.eps}static sqrt(e){return Math.abs(e)<=1e-10?0:Math.sqrt(e)}static sortAsc(e,t){return e-t}static sortDesc(e,t){return t-e}};_e.eps=1e-8,_e.precision=1e8;function Uf(e,t){Gb(e.iterator(),t)}function Gb(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var k8=class{constructor(e){this.idx=-1,this.lst=e}hasNext(){return this.idx<this.lst.length-1}next(){if(this.idx<this.lst.length-1)return this.idx++,this.lst[this.idx];throw new Error("bug")}};function Dv(e){return new k8(e)}var Ob=class Jo{static toDegrees(t){return t*180/Math.PI}static toRadians(t){return t/180*Math.PI}static regularD(t){return t=t%360,t=t<0?360+t:t,t===360?0:t}static regular(t){return t=t%Jo.PIx2,t=t<0?Jo.PIx2+t:t,t===Jo.PIx2?0:t}static toQuarterBase(t){return Jo.regular((t+Jo.PI_4)/Jo.PI_2*Jo.PI_2)}static toQuarterBaseD(t){return Jo.regularD(((t+45)/90|0)*90)}static transformD(t,i){return Jo.toDegrees(Jo.transform(Jo.toRadians(t),i))}static transform(t,i){let r=Math.cos(t),n=Math.sin(t),s=new j(i.data[6],i.data[7]),a=new j(r,n).multiply3(i);return Jo.regular(a.angle(s))}};Ob.PIx2=Math.PI*2,Ob.PI_2=Math.PI/2,Ob.PI_4=Math.PI/4;var Qt=Ob,Gn=class{static dotProd1(e,t,i,r){return e*i+t*r}static dotProd2(e,t,i,r,n,s){return this.dotProd1(i-e,r-t,n-i,s-r)}static dotProd3(e,t,i){return this.dotProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static crossProd1(e,t,i,r){return e*r-t*i}static crossProd2(e,t,i,r,n,s){return this.crossProd1(i-e,r-t,n-i,s-r)}static crossProd3(e,t,i){return this.crossProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static distance2(e,t,i,r){let n=i-e,s=r-t;return n*n+s*s}static distance1(e,t,i,r){return this.hypot(i-e,r-t)}static distance1p(e,t){return this.distance1(e.x,e.y,t.x,t.y)}static hypot(e,t){if(e=Math.abs(e),t=Math.abs(t),t>e){var i=t;t=e,e=i}if(e===0)return t;var r=t/e;return e*Math.sqrt(1+r*r)}},gP=new ArrayBuffer(16),Y_=new Float64Array(gP),wb=new Int32Array(gP),op=class qr{static sortByXAsc(t,i){return t.x-i.x}static sortByYAsc(t,i){return t.y-i.y}static sortByXYAsc(t,i){return t.x<i.x?-1:t.x>i.x?1:t.y-i.y}static caculateAngle(t,i){let r=Math.cos(t),n=Math.sin(t),s=r*i.data[0]+n*i.data[4],a=r*i.data[1]+n*i.data[5],o=new qr(s,a).normalize();return Math.atan2(o.y,o.x)}static normal(t,i,r){let n=i.sub(t),s=r.sub(i);return n.cross(s)}static getVector2(t){return new qr(Math.cos(t),Math.sin(t))}static getCrossPoint1(t,i,r,n){if(t.equals1(i)||r.equals1(n)||_e.eq(1,Math.abs(i.sub(t).normalize().dot(n.sub(r).normalize()))))return null;let s=i.y-t.y,a=t.x-i.x,o=i.x*t.y-t.x*i.y,l=n.y-r.y,c=r.x-n.x,u=n.x*r.y-r.x*n.y,h=s*c-l*a;return new qr((u*a-o*c)/h,(o*l-u*s)/h)}static getCrossPoint2(t,i,r,n){return this.getCrossPoint1(t,t.add(i),r,r.add(n))}constructor(t,i){this.x=tn.normal(t),this.y=tn.normal(i)}get hashed(){return this._hashed==null&&(Y_[0]=this.x,Y_[1]=this.y,this._hashed=wb[0]^wb[1]^wb[2]^wb[3]),this._hashed}dot(t){return this.x*t.x+this.y*t.y}length(){return Math.sqrt(this.dot(this))}getCos(){return this.x/this.length()}sub(t){var i=this.x-t.x,r=this.y-t.y;return new qr(i,r)}add(t){var i=this.x+t.x,r=this.y+t.y;return new qr(i,r)}div(t){return new qr(this.x/t,this.y/t)}add1(t,i){return new qr(this.x+t,this.y+i)}mul(t){return new qr(this.x*t,this.y*t)}cross(t){return this.x*t.y-this.y*t.x}getSin(){return this.y/this.length()}angle2(t){let i=this.y-t.y,r=this.x-t.x;return i=Math.abs(i-0)<10**-4?0:i,r=Math.abs(r-0)<10**-4?0:r,Math.atan2(i,r)}angleD2(t){return Qt.toDegrees(this.angle2(t))}angle(t){return Math.atan2(this.y-t.y,this.x-t.x)}angleX(t=qr.ORIGIN){let i=this.angle(t);return i<0&&(i=Math.PI*2+i),i}angleD(t){return Qt.toDegrees(this.angle(t))}distance1(t){let i=t.x-this.x,r=t.y-this.y;return Gn.hypot(i,r)}distance2(t){let i=t.x-this.x,r=t.y-this.y;return i*i+r*r}rotateD(t,i){return this.rotate(t,Qt.toRadians(i))}rotate(t,i){let r=Math.cos(i),n=Math.sin(i),s=this.x-t.x,a=this.y-t.y,o=s*r+a*-n,l=s*n+a*r;return t.add1(o,l)}multiply3(t){let i=this.x*t.data[0]+this.y*t.data[3]+t.data[6],r=this.x*t.data[1]+this.y*t.data[4]+t.data[7];return new qr(i,r)}multiply4(t){let i=this.x*t.data[0]+this.y*t.data[4]+t.data[12],r=this.x*t.data[1]+this.y*t.data[5]+t.data[13];return new qr(i,r)}hashCode(){return this.hashed}equals(t,i){return t instanceof qr?F_(t.x,this.x,i)&&F_(t.y,this.y,i):!1}equals1(t){return t?_e.eq(this.x,t.x)&&_e.eq(this.y,t.y):!1}equals2(t,i){return t instanceof qr?Math.abs(this.x-t.x)<=i&&Math.abs(this.y-t.y)<=i:!1}similarEquals(t,i=.5){return Math.abs(this.x*.1-t.x*.1)<=i&&Math.abs(this.y*.1-t.y*.1)<=i}toString(){return"Vector [X="+this.x+", Y="+this.y+"]"}bbox(){let t=this.x,i=this.y;return new St(t,t,i,i)}normalize(){if(this.x===0&&this.y===0)return new qr(0,0);let t=this.x/this.length(),i=this.y/this.length();return new qr(t,i)}regular(t=1e-4){let i=Math.round(1/t);return new qr(Math.round(this.x*i)/i,Math.round(this.y*i)/i)}round(t=4){let i=10**(t|0);return new qr(Math.round(this.x*i)/i,Math.round(this.y*i)/i)}mirrorX(t=qr.ORIGIN){return new qr(this.x,2*t.y-this.y)}mirrorY(t=qr.ORIGIN){return new qr(2*t.x-this.x,this.y)}mirrorCenter(t=qr.ORIGIN){return new qr(2*t.x-this.x,2*t.y-this.y)}clone(){return new qr(this.x,this.y)}mirror(t=qr.ORIGIN){return new qr(2*t.x-this.x,2*t.y-this.y)}pointOnRays(t,i){let r=Qt.toRadians(t);return new qr(this.x+Math.cos(r)*i,this.y+Math.sin(r)*i)}pointOnRays2(t,i){let r=t.angle(this);return new qr(this.x+Math.cos(r)*i,this.y+Math.sin(r)*i)}scale(t){return new qr(this.x*t,this.y*t)}};op.ORIGIN=new op(0,0),op.X_UNIT_VECTOR=new op(1,0),op.Y_UNIT_VECTOR=new op(0,1);var j=op,F8=(e=>(e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT",e))(F8||{}),G8=(e=>(e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM",e))(G8||{}),ks=class{constructor(t,i){this.horizontal=t,this.vertical=i}};ks.LT=new ks(0,0),ks.LC=new ks(0,1),ks.LB=new ks(0,2),ks.CT=new ks(1,0),ks.CC=new ks(1,1),ks.CB=new ks(1,2),ks.RT=new ks(2,0),ks.RC=new ks(2,1),ks.RB=new ks(2,2);var ju=ks,ot=class{constructor(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}ext1(e){return this.minX=Math.min(this.minX,e.minX),this.maxX=Math.max(this.maxX,e.maxX),this.minY=Math.min(this.minY,e.minY),this.maxY=Math.max(this.maxY,e.maxY),this}ext2(e){return this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y),this}ext3(e){for(let t=0;t<e.length;t++){let i=e[t];this.ext2(i)}return this}ext4(e){return Uf(e,(t,i)=>(this.ext2(i),!0)),this}ext5(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,t),this.minY=Math.min(this.minY,i),this.maxY=Math.max(this.maxY,r),this}ext6(e,t){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t),this}ext7(e){if(e<0){let t=e*2;if(t<this.minX-this.maxX||t<this.minY-this.maxY)throw new Error("")}return this.minX-=e,this.maxX+=e,this.minY-=e,this.maxY+=e,this}ext8(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(new j(e[i],e[i+1]));return this.ext3(t)}ext9(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e+i),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t+r),this}ext10({x:e,y:t,width:i,height:r}){return this.ext9(e,t,i,r)}valid(){return isFinite(this.minX)&&isFinite(this.maxX)&&isFinite(this.minY)&&isFinite(this.maxY)}clear(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}build(){return new St(this.minX,this.maxX,this.minY,this.maxY)}build1(){return this.valid()?new St(this.minX,this.maxX,this.minY,this.maxY):new St(0,0,0,0)}},cy=new Float64Array(4),St=class vl{static extendRect({x:t,y:i,width:r,height:n}){return new vl(t,t+r,i,i+n)}static extend1(t,i){if(t===null)return new vl(i.x,i.x,i.y,i.y);{let r=Math.min(t.minX,i.x),n=Math.max(t.maxX,i.x),s=Math.min(t.minY,i.y),a=Math.max(t.maxY,i.y);return new vl(r,n,s,a)}}static extend2(t,i){if(t){let r=Math.min(t.minX,i.minX),n=Math.max(t.maxX,i.maxX),s=Math.min(t.minY,i.minY),a=Math.max(t.maxY,i.maxY);return new vl(r,n,s,a)}else return i}static extend3(t,i){let r=Math.min(t.x,i.x),n=Math.max(t.x,i.x),s=Math.min(t.y,i.y),a=Math.max(t.y,i.y);return new vl(r,n,s,a)}static extend4(t,i,r){return new vl(t.x-i/2,t.x+i/2,t.y-r/2,t.y+r/2)}constructor(t,i,r,n){if(this.minX=tn.normal(t),this.maxX=tn.normal(i),this.minY=tn.normal(r),this.maxY=tn.normal(n),t>i||r>n)throw new Error(`min > max is not permitted: [${t}, ${i}, ${r}, ${n}]`)}get data(){return cy[0]=this.minX,cy[1]=this.maxX,cy[2]=this.minY,cy[3]=this.maxY,cy}isContains(t){return this.isContains1(t.x,t.y)}points(){return[this.LL(),this.LR(),this.UR(),this.UL(),this.LL()]}isContains1(t,i){return this.isContainsX(t)&&this.isContainsY(i)}isContains2(t,i){return this.isContainsX1(t)&&this.isContainsY1(i)}isContainsX(t){return t>=this.minX&&t<=this.maxX}isContainsX1(t){return _e.greatereq(t,this.minX)&&_e.lesseq(t,this.maxX)}isContainsY(t){return t>=this.minY&&t<=this.maxY}isContainsY1(t){return _e.greatereq(t,this.minY)&&_e.lesseq(t,this.maxY)}isIntersect(t){return!(this.maxX<t.minX||this.minX>t.maxX||this.maxY<t.minY||this.minY>t.maxY)}extendOfSize(t){return tn.positiveOr0(this.maxX-this.minX+t*2),tn.positiveOr0(this.maxY-this.minY+t*2),new vl(this.minX-t,this.maxX+t,this.minY-t,this.maxY+t)}isInside(t){return this.minX>=t.minX&&this.maxX<=t.maxX&&this.minY>=t.minY&&this.maxY<=t.maxY}isContainsBBox(t){return this.maxX>=t.maxX&&this.minX<=t.minX&&this.maxY>=t.maxY&&this.minY<=t.minY}isContainsBBox1(t){return _e.greatereq(this.maxX,t.maxX)&&_e.lesseq(this.minX,t.minX)&&_e.greatereq(this.maxY,t.maxY)&&_e.lesseq(this.minY,t.minY)}intersect(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(i>r)return null;let n=Math.max(this.minY,t.minY),s=Math.min(this.maxY,t.maxY);return n>s?null:new vl(i,r,n,s)}intersection1(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(_e.greater(i,r))return null;i>r&&(r=i);let n=Math.max(this.minY,t.minY),s=Math.min(this.maxY,t.maxY);return _e.greater(n,s)?null:(n>s&&(s=n),new vl(i,r,n,s))}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}UL(){return new j(this.minX,this.maxY)}UR(){return new j(this.maxX,this.maxY)}LL(){return new j(this.minX,this.minY)}LR(){return new j(this.maxX,this.minY)}center(){return new j(this.maxX-(this.maxX-this.minX)/2,this.maxY-(this.maxY-this.minY)/2)}area(){return this.width()*this.height()}transform(t){let i=new ot;return i.ext2(this.LL().multiply3(t)),i.ext2(this.LR().multiply3(t)),i.ext2(this.UR().multiply3(t)),i.ext2(this.UL().multiply3(t)),i.build()}transform4(t){let i=new ot;return i.ext2(this.LL().multiply4(t)),i.ext2(this.LR().multiply4(t)),i.ext2(this.UR().multiply4(t)),i.ext2(this.UL().multiply4(t)),i.build()}isSeparated(t){if(t==null||t==null)return!1;let i;this.minX>=t.minX?i=this.minX:i=t.minX;let r;if(this.maxX<=t.maxX?r=this.maxX:r=t.maxX,i>r)return!0;{let n;this.minY>=t.minY?n=this.minY:n=t.minY;let s;return this.maxY<=t.maxY?s=this.maxY:s=t.maxY,n>s}}relation(t){let i=0,r=0,n;this.minX>t.minX?(i++,n=this.minX):this.minX===t.minX?n=this.minX:(r++,n=t.minX);let s;if(this.maxX<t.maxX?(i++,s=this.maxX):this.maxX===t.maxX?s=this.maxX:(r++,s=t.maxX),n>s)return 2;{let a;this.minY>t.minY?(i++,a=this.minY):this.minY===t.minY?a=this.minY:(r++,a=t.minY);let o;return this.maxY<t.maxY?(i++,o=this.maxY):this.maxY===t.maxY?o=this.maxY:(r++,o=t.maxY),a>o?2:i===4?0:r===4?1:i===0&&r===0?4:n===s||a===o?6:i!==r?5:3}}zoom(t){let i=this.width(),r=this.height(),n=this.center();return t!=0&&(i/=t/2,r/=t/2),new vl(n.x-i,n.x+i,n.y-i,n.y+i)}toString(){return"BBox [minX="+this.minX+", maxX="+this.maxX+", minY="+this.minY+", maxY="+this.maxY+"]"}equals(t){return this.minY==t.minY&&this.minX==t.minX&&this.maxX==t.maxX&&this.maxY==t.maxY}extendSize(t,i){return Object.is(void 0,i)&&(i=t),vl.extend4(this.center(),this.width()+t,this.height()+i)}positionOnBBox(t,i=0){let r=this.center(),n=this.width()*i/2,s=this.height()*i/2,a=t.x-r.x,o=t.y-r.y;return a>n?o>s?ju.RT:o<-s?ju.RB:ju.RC:a<-n?o>s?ju.LT:o<-s?ju.LB:ju.LC:o>s?ju.CT:o<-s?ju.CB:ju.CC}bbox(){return this}},Ub=class Ui{static mul(t,i,r,n,s,a){let o=0,l=0;for(let c=0;c<t;c++){for(let u=0;u<r;u++){let h=u,d=0;for(let p=0;p<i;p++)d+=n[l+p]*s[h],h+=r;a[o++]=d}l+=i}}constructor(t,i,r){this.m=tn.normal(t),this.n=tn.normal(i);let n=t*i;if(r.length===n){for(let s=0;s<r.length;s++)tn.normal(r[s]);this.data=r}else throw new Error("invalid matrix size")}mul(t){if(this.n===t.m){let i=new Array(this.m*t.n);return Ui.mul(this.m,this.n,t.n,this.data,t.data,i),new Ui(this.m,t.n,i)}else throw new Error("m !== p")}toString(){let t=[];t.push("Matrix ("),t.push(this.m.toString()),t.push(" x "),t.push(this.n.toString()),t.push(")");let i=0;for(let r=0;r<this.m;r++)for(let n=0;n<this.n;n++){let s=this.data[i++].toString();n===0?(t.push(`
`),t.push("	"),t.push(s)):(t.push(", "),t.push(s))}return t.join("")}static on(t,i,r){return t*i+r}initExpandMatrix(t){let i=this.m,r=this.n,n=r*2,s=new Array(i*n);for(let a=0;a<i;a++)for(let o=0;o<n;o++)o<r?s[Ui.on(n,a,o)]=t[Ui.on(r,a,o)]:o===i+a?s[Ui.on(n,a,o)]=1:s[Ui.on(n,a,o)]=0;return s}inverseMatrix(t,i,r){for(let n=0;n<i;n++){let s=t[Ui.on(r,n,n)];for(let a=0;a<r;a++)t[Ui.on(r,n,a)]/=s}return t}getMatrixRank(t,i,r){let n=Math.min(i,r);for(let s=0;s<i;s++){if(t[Ui.on(r,s,s)]===0){let a=new Array(r),o;for(o=s;o<i;o++)if(t[Ui.on(r,o,s)]!==0){fa.arraycopy(t,Ui.on(r,o,0),a,0,r),fa.arraycopy(t,Ui.on(r,s,0),t,Ui.on(r,o,0),r),fa.arraycopy(a,0,t,Ui.on(r,s,0),r);break}o>=i&&(n-=1)}if(!(n<i))for(let a=0;a<i;a++){if(a===s)continue;let o=t[Ui.on(r,a,s)]/t[Ui.on(r,s,s)];for(let l=0;l<r;l++)t[Ui.on(r,a,l)]-=t[Ui.on(r,s,l)]*o}}return n}getInverseMatrix(){if(this.m!==this.n)throw new Error("The matrix is an "+this.m+"x"+this.n+" order matrix, non-square matrix, please check!");function t(a){return _e.lesseq(Math.abs(a),0)}let i=this.initExpandMatrix(this.data.slice(0)),r=this.n*2;function n(a,o){for(let l=0;l<r;l++){let c=i[Ui.on(r,a,l)];i[Ui.on(r,a,l)]=i[Ui.on(r,o,l)],i[Ui.on(r,o,l)]=c}}for(let a=0;a<this.m;a++){let o=Math.abs(i[Ui.on(r,a,a)]),l=a;if(t(i[Ui.on(r,a,a)]))for(let u=a+1;u<this.m;u++){if(t(i[Ui.on(r,u,a)])){Math.abs(i[Ui.on(r,u,a)])>o&&(o=Math.abs(i[Ui.on(r,u,a)]),l=u);continue}n(a,u);break}if(t(i[Ui.on(r,a,a)])){if(o===0)throw new Error("The matrix is a non-full rank matrix, please check!");console.warn("The matrix may be a non-full rank matrix, please check!"),l!==a&&n(a,l)}let c=1/i[Ui.on(r,a,a)];for(let u=0;u<r;u++)i[Ui.on(r,a,u)]*=c;for(let u=0;u<this.m;u++){if(a===u)continue;let h=i[Ui.on(r,u,a)];for(let d=a;d<r;d++)i[Ui.on(r,u,d)]-=i[Ui.on(r,a,d)]*h}}let s=[];for(let a=0;a<this.m;a++)for(let o=this.n;o<r;o++)s[Ui.on(this.n,a,o-this.n)]=i[Ui.on(r,a,o)];return new Ui(this.m,this.n,s)}getTransposeMatrix(){let t=new Array(this.data.length);for(let i=0;i<this.m;i++)for(let r=0;r<this.n;r++)t[r*this.n+i]=this.data[i*this.m+r];return new Ui(this.n,this.m,t)}hashCode(){let t=0;for(let i of this.data)t+=i;return t}equals(t){return this===t?!0:t===null?!1:t instanceof Ui?!(this.m!=t.m||this.n!=t.n||!fa.equals(this.data,t.data)):!1}},U8=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],_v=class Dn extends Ub{static translate(t,i,r){return new Dn([1,0,0,0,0,1,0,0,0,0,1,0,t,i,r,1])}static translate1(t){return new Dn([1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1])}static rotateX(t){let i=Math.cos(t),r=Math.sin(t);return new Dn([1,0,0,0,0,i,r,0,0,-r,i,0,0,0,0,1])}static rotateY(t){let i=Math.cos(t),r=Math.sin(t);return new Dn([i,0,-r,0,0,1,0,0,r,0,i,0,0,0,0,1])}static rotateZ(t){let i=Math.cos(t),r=Math.sin(t);return new Dn([i,r,0,0,-r,i,0,0,0,0,1,0,0,0,0,1])}static rotateAxis(t,i){t=t.normalize();let r=t.x,n=t.y,s=t.z,a=Math.sin(i),o=Math.cos(i);return new Dn([r*r*(1-o)+o,r*n*(1-o)+s*a,r*s*(1-o)-n*a,0,r*n*(1-o)-s*a,n*n*(1-o)+o,n*s*(1-o)+r*a,0,r*s*(1-o)+n*a,n*s*(1-o)-r*a,s*s*(1-o)+o,0,0,0,0,1])}static scale(t,i=t,r=t){return new Dn([t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1])}static flipX(){return new Dn([1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1])}static flipY(){return new Dn([-1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}static rotateZForPoint(t,i){return t.equals1(j.ORIGIN)?Dn.rotateZ(i):Dn.translate(-t.x,-t.y,0).rotateZ(i).translate1(t.x,t.y,0)}static getMatrix4(t,i,r,n){let s=Math.cos(i),a=Math.sin(i),o=r*(t.x*s-t.y*a)+n.x,l=t.x*a+t.y*s+n.y,c=[r*s,a,0,0,-a*r,s,0,0,0,0,1,0,o,l,0,1];return new Dn(c)}constructor(t=U8){super(4,4,t)}translate(t){return this.multiply4(Dn.translate1(t))}translate1(t,i,r){return this.multiply4(Dn.translate(t,i,r))}rotateX(t){return this.multiply4(Dn.rotateX(t))}rotateY(t){return this.multiply4(Dn.rotateY(t))}rotateZ(t){return this.multiply4(Dn.rotateZ(t))}scale(t,i=t,r=t){return this.multiply4(Dn.scale(t,i,r))}scale1(t){return this.multiply4(Dn.scale(t.x,t.y,t.z))}setOrigin(t,i,r){return Dn.translate(-t,-i,-r).multiply4(this).translate1(t,i,r)}setOrigin1(t){return this.setOrigin(t.x,t.y,t.z)}multiply4(t){let i=new Array(16);return Ub.mul(4,4,4,this.data,t.data,i),new Dn(i)}getInverseMatrix(){let t=super.getInverseMatrix();return new Dn(t.data)}getTransposeMatrix(){let t=super.getTransposeMatrix();return new Dn(t.data)}inverse(){let t=this.getInverseMatrix();return new Dn(t.data)}toMatrix3(){let t=this.data;return new de([t[0],t[1],0,t[4],t[5],0,t[12],t[13],1])}};_v.ORIGIN=new _v;var yP=_v;function uy(e){return mP.normal(parseFloat(e))}var Y8=[1,0,0,0,1,0,0,0,1],uc=class Fs extends Ub{static translate(t,i){return new Fs([1,0,0,0,1,0,t,i,1])}static translate1(t){return this.translate(t.x,t.y)}static rotate(t){let i=Math.cos(t),r=Math.sin(t);return new Fs([i,r,0,-r,i,0,0,0,1])}static rotateD(t){return this.rotate(Qt.toRadians(t))}static scale(t,i=t){return new Fs([t,0,0,0,i,0,0,0,1])}static scale1(t,i){return new Fs([t,0,0,0,i,0,0,0,1])}static toDOMMatrix(t){let[i,r,,n,s,,a,o]=t.data;return`matrix(${[i,r,n,s,a,o].join(",")})`}static svgTrasform(t){let i=t.split(" "),r=null;return i.forEach(n=>{n=n.trim();let s=n.trim().replace(")","").split("("),a=s[0],o=s[1].split(",");switch(a){case"translate":let l=uy(o[0]),c=uy(o[1]);r=r?r.translate(l,c):Fs.translate(l,c);break;case"rotate":let u=uy(o[0]),h=uy(o[1]),d=uy(o[2]);r=r?r.setOrigin(h,d):Fs.translate(h,d),r=r.rotateD(u);break;default:return}}),r}constructor(t=Y8){super(3,3,t);let i=t[0],r=t[3],n=t[1],s=t[4];this.iScale=Math.sqrt(i*i+n*n),this.jScale=Math.sqrt(r*r+s*s)}isMirrored(){return this.det()<0}multiply3(t){let i=new Array(9);return Ub.mul(3,3,3,this.data,t.data,i),new Fs(i)}translate(t,i){return this.multiply3(Fs.translate(t,i))}translate1(t){return this.multiply3(Fs.translate1(t))}scale(t,i=t){return this.multiply3(Fs.scale(t,i))}scale1(t,i){return this.multiply3(Fs.scale1(t,i))}det(){return this.data[0]*this.data[4]-this.data[3]*this.data[1]}invert(){let t=this.getInverseMatrix();return new Fs(t.data)}rotateD(t){return this.multiply3(Fs.rotateD(t))}rotate(t){return this.multiply3(Fs.rotate(t))}resetOffset(){let t=this.data;return new Fs([t[0],t[1],0,t[3],t[4],0,0,0,1])}setOrigin(t,i){return Fs.translate(-t,-i).multiply3(this).translate(t,i)}setOrigin1(t){return this.setOrigin(t.x,t.y)}getInverseMatrix(){return new Fs(super.getInverseMatrix().data)}getTransposeMatrix(){let t=super.getTransposeMatrix();return new Fs(t.data)}toMatrix4(){let t=this.data;return new yP([t[0],t[1],0,t[2],t[3],t[4],0,t[5],0,0,1,0,t[6],t[7],0,t[8]])}scaleNum(t){return!t||isNaN(t)?t:t*this.iScale}};uc.ORIGIN=new uc,uc.MIRROR_Y=new uc([1,0,0,0,-1,0,0,0,1]),uc.MIRROR_X=new uc([-1,0,0,0,1,0,0,0,1]),uc.ROT_90=new uc([0,1,0,-1,0,0,0,0,1]),uc.ROT_N90=new uc([0,-1,0,1,0,0,0,0,1]);var de=uc,pp=(e=>(e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE",e))(pp||{}),vs=(e=>(e[e.CW=0]="CW",e[e.CCW=1]="CCW",e))(vs||{}),Dy=class{},Vf=class fy{constructor(t,i,r){this.p1=t,this.p2=i,this.p3=r}barycentre(){return fy.barycentre(this.p1,this.p2,this.p3)}incentre(){return fy.incentre(this.p1,this.p2,this.p3)}static barycentre(t,i,r){let n=t.x+i.x+r.x,s=t.y+i.y+r.y;return new j(n/3,s/3)}static incentre(t,i,r){let n=i.sub(r).length(),s=t.sub(r).length(),a=t.sub(i).length(),o=n+s+a,l=n*t.x+s*i.x+a*r.x,c=n*t.y+s*i.y+a*r.y;return new j(l/o,c/o)}area(){return fy.area(this.p1,this.p2,this.p3)}static area(t,i,r){return this.area2(t.x,t.y,i.x,i.y,r.x,r.y)/2}static area2(t,i,r,n,s,a){return Math.abs(Gn.crossProd2(t,i,r,n,s,a))}scale(t,i){let r=de.translate(-t.x,-t.y).scale(i).translate1(t),n=this.p1.multiply3(r),s=this.p2.multiply3(r),a=this.p3.multiply3(r);return new fy(n,s,a)}scaleOnBarycentre(t){return this.scale(this.barycentre(),t)}scaleOnIncentre(t){return this.scale(this.incentre(),t)}extend(t){let i=this.incentre(),r=this.p1.add(this.p2).sub(i).scale(1/2),n=r.length(),s=j.ORIGIN.pointOnRays2(r,n+t).length()/n;return this.scaleOnIncentre(s)}container(t){let i=this.p3.sub(this.p1),r=this.p2.sub(this.p1),n=t.sub(this.p1),s=i.dot(i),a=i.dot(r),o=i.dot(n),l=r.dot(r),c=r.dot(n),u=1/(s*l-a*a),h=(l*o-a*c)*u;if(h<0||h>1)return!1;let d=(s*c-a*o)*u;return d<0||d>1?!1:h+d<=1}};function vb(){return{minDistance:Number.POSITIVE_INFINITY,start:null,end:null}}var fc=class Wh{static getMinDistanceWithoutCross(t,i){let r=vb();return Wh.minLine(t,i,r),r.minDistance}static getMinDistance(t,i){return So(t,i)?0:this.getMinDistanceWithoutCross(t,i)}static getMinLineWithCross(t,i){let r=vb();return Wh.minLine(t,i,r),new ie(r.start,r.end)}static getMinLine(t,i){return Wh.intersection(t,i)||this.getMinLineWithCross(t,i)}static getMinDistanceFromPoint(t,i){let r=vb();if(i instanceof ie)this.point2LineMinLine(r,i,t);else if(i instanceof Se)this.point2ArcMinDistance(t,i,r);else throw new Error("not support");return r.minDistance}constructor(t,i){if(this.pt1=t,this.pt2=i,this.minline=Wh.intersection(t,i),this.minline)this.minDistance=0;else{let r=vb();Wh.minLine(t,i,r),this.minline=new ie(r.start,r.end),this.minDistance=r.minDistance}}getDistance(){return this.minDistance}getLine(){return this.minline}static intersection(t,i){let r=So(t,i);if(r===0)return;let n=new Array;for(let s=0;s<r;s+=2){let a=new j(se[s],se[s+1]);n.push(a)}return n.length>1?new ie(n[0],n[1]):new ie(n[0],n[0])}static minLine(t,i,r){if(t instanceof ie&&i instanceof ie)return this.minDistanceForLines(t,i,r);if(t instanceof Se&&i instanceof ie)return this.minDistanceForLineAndArc(t,i,r);if(t instanceof ie&&i instanceof Se)return this.minDistanceForLineAndArc(i,t,r);if(t instanceof Se&&i instanceof Se)return this.minDistanceForArcs(t,i,r);throw new Error("not support")}static minDistanceForLines(t,i,r){[t.start(),t.end(),i.start(),i.end()].forEach((n,s)=>{s<2?this.point2LineMinLine(r,i,n):this.point2LineMinLine(r,t,n)})}static minDistanceForLineAndArc(t,i,r){this.point2LineMinLine(r,i,t.start()),this.point2LineMinLine(r,i,t.svgEnd);let n=Wh.foot(i,t.center);i.bbox().extendOfSize(1e-8).isContains(n)&&this.point2ArcMinLine(r,t,n),this.point2ArcMinLine(r,t,i.start()),this.point2ArcMinLine(r,t,i.end())}static minDistanceForArcs(t,i,r){this.concentricArc(t,i,r),this.point2ArcMinDistance(i.start(),t,r),this.point2ArcMinDistance(i.svgEnd,t,r),this.point2ArcMinDistance(t.start(),i,r),this.point2ArcMinDistance(t.svgEnd,i,r),(cc(t,i.center)||cc(i,t.center))&&this.shortestLineForArcs(t,i,r)}static minLineForArcAndLine(t,i,r){let n=t.pointOn(r.angleD(t.center)),s=t.pointOn(t.center.angleD(r));this.arcShortestLine(t,i,r,n),this.arcShortestLine(t,i,r,s)}static arcInnerLineFootSegment(t,i,r){let n=r.distance1(t.center);if(n!==0){let s=t.rx*(r.y-t.center.y)/n+t.center.y,a=t.rx*(r.x-t.center.x)/n+t.center.x;n=t.rx-n,n<i.minDistance&&(i.minDistance=n,i.start=new j(a,s),i.end=r)}else n=t.rx-n,n<i.minDistance&&(i.minDistance=n,i.start=t.start(),i.end=r)}static shortestLineForArcs(t,i,r){let n=t.center.angleD(i.center),s=i.center.angleD(t.center),a=t.pointOn(n),o=t.pointOn(s),l=i.pointOn(n),c=i.pointOn(s);cc(t,a)&&(this.arcShortestLine(i,r,a,l),this.arcShortestLine(i,r,a,c)),cc(t,o)&&(this.arcShortestLine(i,r,o,l),this.arcShortestLine(i,r,o,c)),this.shortestLineForArcs1(t,i,r)}static shortestLineForArcs1(t,i,r){let n=i.start().sub(t.center).normalize(),s=i.end().sub(t.center).normalize(),a=t.start().sub(i.center).normalize(),o=t.end().sub(i.center).normalize(),l=t.center.add(n.mul(t.rx)),c=t.center.add(s.mul(t.rx)),u=i.center.add(a.mul(i.rx)),h=i.center.add(o.mul(i.rx));cc(t,l)&&_e.greater(i.start().distance2(t.center),0)&&this.arcShortestLine(t,r,i.start(),l),cc(t,c)&&_e.greater(i.end().distance2(t.center),0)&&this.arcShortestLine(t,r,i.end(),c),cc(i,u)&&_e.greater(t.start().distance2(i.center),0)&&this.arcShortestLine(i,r,t.start(),u),cc(i,h)&&_e.greater(t.end().distance2(i.center),0)&&this.arcShortestLine(i,r,t.end(),h)}static concentricArc(t,i,r){if(!(t.center.distance1(i.center)<1e-5&&t.rx===i.rx&&t.ry===i.ry))return;let n=t.start().distance1(i.svgEnd);n<r.minDistance&&(r.minDistance=n,r.start=t.start(),r.end=i.svgEnd),n=i.start().distance1(t.svgEnd),n<r.minDistance&&(r.minDistance=n,r.start=i.start(),r.end=t.svgEnd)}static point2ArcMinDistance(t,i,r){if(cc(i,t)){let n=i.pointOn(t.angleD(i.center)),s=i.pointOn(i.center.angleD(t));this.arcShortestLine(i,r,t,n),this.arcShortestLine(i,r,t,s)}else this.minLineSegment(r,i.start(),t),this.minLineSegment(r,i.svgEnd,t)}static point2ArcMinLine(t,i,r){if(cc(i,r)){let n=r.distance1(i.center);n>i.rx||n>i.ry?this.minLineForArcAndLine(i,t,r):this.arcInnerLineFootSegment(i,t,r)}}static point2LineMinLine(t,i,r){let n=Wh.foot(i,r);i.bbox().extendOfSize(1e-8).isContains(n)?this.minLineSegment(t,n,r):(this.minLineSegment(t,i.start(),r),this.minLineSegment(t,i.end(),r))}static minLineSegment(t,i,r){let n=i.distance1(r);n<t.minDistance&&(t.minDistance=n,t.start=i,t.end=r)}static arcShortestLine(t,i,r,n){if(!cc(t,n))return;let s=r.distance1(n);s<i.minDistance&&(i.minDistance=s,i.start=r,i.end=n)}static foot(t,i){if(t.isPoint())return t.start();if(!_e.eq(t.b,0)&&!_e.eq(t.a,0)){let r=t.start(),n=t.direct,s=(i.x-r.x)*n.x+(i.y-r.y)*n.y;return new j(r.x+n.x*s,r.y+n.y*s)}else return _e.eq(t.b,0)&&!_e.eq(t.a,0)?new j(t.start().x,i.y):!_e.eq(t.b,0)&&_e.eq(t.a,0)?new j(i.x,t.start().y):i}};function cc(e,t){if(_e.eq(e.sweepAngle,360))return!0;let i=Qt.regularD(t.angleD(e.center));return e.sweepAngle>0?(_e.less(i,e.startAngle)&&(i+=360),_e.greatereq(e.endAngle(),i)):(_e.greater(i,e.startAngle)&&(i-=360),_e.lesseq(e.endAngle(),i))}var V8=[1,10,100,1e3],V_="http://www.w3.org/2000/svg",H_="http://www.w3.org/1999/xlink",j_="http://www.w3.org/XML/1998/namespace",z_="https://easyeda.com/",vie=(function(){var e={svg:V_,xlink:H_,xml:j_,c:z_};return e[V_]="svg",e[H_]="xlink",e[j_]="xml",e[z_]="c",e})(),qn=(function(){var e={RATLINES:9,MODEL3D:19,ALL:11,TOPSILKLAYER:3,TOPLAYER:1,TOPPASTERLAYER:5,TOPSOLDERLAYER:7,LIBBODY:99,PADSURFACE:100,BOARDOUTLINE:10,DOCUMENT:12,TOPASSEMBLY:13,MECHANICAL:15,TOPCOMPONENT:16,SUBSTRATE:18},t;for(t=21;t<53;t++)e["INNER"+(t-20)]=t;for(e.BOTTOMSILKLAYER=4,e.BOTTOMLAYER=2,e.BOTTOMPASTERLAYER=6,e.BOTTOMSOLDERLAYER=8,e.BOTTOMASSEMBLY=14,e.BOTTOMCOMPONENT=17,t=53;t<85;t++)e["BOARD"+(t-52)]=t;return e})(),Tie=(function(){var e={COPPERAREA:[1,2,21,22,23,24],PLANEZONE:[1,2,21,22,23,24],RECT:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,99],TRACK:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],PAD:[11,1,2],VIA:[11],HOLE:[11],TEXT:[3,4,1,2,7,8,12,13,14,15,21,22,23,24],ARC:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],ELLIPSE:[3,4,12,13,14,15],CIRCLE:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],DIMENSION:[3,4,12,13,14,15],FOOTPRINT:[1,2],SOLIDREGION:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,11,99,100],SVGNODE:[1,2,3,4,7,8,12,13,14,15],PROTRACTOR:[3,4,12,13,14,15],SHEET:[12,13,14,15]};e["3D"]=(function(){for(var n=[16,19,3,7,5,1],s=21;s<52;s++)n.push(s+32,s);return n.push(2,6,8,4,17),n})();var t,i,r;for(t in e)if(e.hasOwnProperty(t)&&(r=e[t],r.indexOf(21)>0&&r.indexOf(25)===-1))for(i=25;i<=52;i++)r.push(i);return e})(),Bs=(function(){var e={1:"TopLayer",2:"BottomLayer",3:"TopSilkLayer",4:"BottomSilkLayer",5:"TopPasteMaskLayer",6:"BottomPasteMaskLayer",7:"TopSolderMaskLayer",8:"BottomSolderMaskLayer",9:"Ratlines",10:"BoardOutLine",11:"Multi-Layer",12:"Document",13:"TopAssembly",14:"BottomAssembly",15:"Mechanical",16:"TopComponents",17:"BottomComponents",18:"Substrate",19:"3DModel",99:"ComponentShapeLayer",100:"LeadShapeLayer"},t;for(t=21;t<53;t++)e[t]="Inner"+(t-20);for(t=53;t<85;t++)e[t]="Substrate"+(t-52);return e})(),Iie=(function(){var e=[],t=[];for(var i in qn)if(qn.hasOwnProperty(i)){if(i.match(/^BOARD\d+/))continue;e.push(qn[i])}e.sort(),t.sort();var r={},n,s={21:"#999966",22:"#008000",23:"#00FF00",24:"#BC8E00",25:"#70DBFA",26:"#00CC66",27:"#9966FF",28:"#800080",29:"#008080",30:"#15935F",31:"#000080",32:"#00B400",33:"#2E4756",34:"#99842F",35:"#FFFFAA",36:"#99842F",37:"#2E4756",38:"#3535FF",39:"#8000BC",40:"#43AE5F",41:"#C3ECCE",42:"#728978",43:"#39503F",44:"#0C715D",45:"#5A8A80",46:"#2B937E",47:"#23999D",48:"#45B4E3",49:"#215DA1",50:"#4564D7",51:"#6969E9",52:"#9069E9"};e.forEach(function(o){switch(o){case qn.TOPLAYER:n={name:Bs[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case qn.BOTTOMLAYER:n={name:Bs[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case qn.TOPSILKLAYER:n={name:Bs[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case qn.BOTTOMSILKLAYER:n={name:Bs[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case qn.TOPPASTERLAYER:n={name:Bs[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case qn.BOTTOMPASTERLAYER:n={name:Bs[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case qn.TOPSOLDERLAYER:n={name:Bs[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case qn.BOTTOMSOLDERLAYER:n={name:Bs[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case qn.RATLINES:n={name:Bs[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case qn.BOARDOUTLINE:n={name:Bs[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case qn.ALL:n={name:Bs[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case qn.DOCUMENT:n={name:Bs[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case qn.TOPASSEMBLY:n={name:Bs[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case qn.BOTTOMASSEMBLY:n={name:Bs[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case qn.MECHANICAL:n={name:Bs[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case qn.MODEL3D:n={name:Bs[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case qn.LIBBODY:n={name:Bs[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case qn.PADSURFACE:n={name:Bs[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=qn.INNER1&&o<=qn.INNER32?n={name:Bs[o],color:s[o],darkColor:a(s[o]),visible:!1,active:!1,config:!1}:n=null;break}n&&(r[o]=n)}),r.Hole={config:!0,name:"Hole",darkColor:"#222222",color:"#222222"},r.DRCError={config:!0,name:"DRCError",color:"#FAD609",darkColor:"#FAD609"};function a(o){if(typeof o!="string"||!o.match(/#?([\da-f]{6})/i))return o;var l=parseInt(RegExp.$1,16),c=.5,u=Math.min(255,Math.round((l>>16)*c)),h=Math.min(255,Math.round((l>>8&255)*c)),d=Math.min(255,Math.round((l&255)*c)),p=((u<<16)+(h<<8)+d).toString(16);return"#"+("00000"+p).substr(-6).toUpperCase()}return r})(),X_={BLANK:0,SCH:1,PART:2,PCB:3,FOOTPRINT:4,PRJ:5,SUBPART:6,SPICESYMBOL:7,SUBCKT:8,NETLIST:9,WAVEFORM:10,SCHLIB3D:11,PHOTOVIEW:12,SCHMODULE:13,PCBMODULE:14,VIEW3D:15,PCBLIB3D:16,BLOCK_SYMBOL:17,NETFLAG:18,NETPORT:19,SHEET_SYMBOL:20,NONEELEC_SYMBOL:21,SHORT_SYMBOL:22,FOOTPRINTVIEW:23,CNCPRINTVIEW:24,PCB2D:31,PCB3D:32},Aie=(function(){var e={};for(let t in X_)e[X_[t]]=t;return e})(),Zb=Math.PI*2,Yb=Math.PI/2,Cie=Math.sin(Math.PI/180);function H8(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=V8[t]||Math.pow(10,t)||10;if(i){var n=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(n+e)}else return Math.round(e*r+1e-10)/r}function bP(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function j8(e,t,i){var r=u(e)&&u(t)&&u(i);if(!r)return console.warn("Bad arguments"),null;var n=t.x-i.x>0?t.x:i.x,s=t.y-i.y>0?t.y:i.y,a=t.x-i.x>0?i.x:t.x,o=t.y-i.y>0?i.y:t.y,l=e.x,c=e.y;return l<=n+.001&&l>=a-.001&&c<=s+.001&&c>=o-.001;function u(h){return h?(h.x=Number(h.x),h.y=Number(h.y),isNaN(h.x)||isNaN(h.y)?(console.warn("Can not convert to Number, NaN found"),!1):!0):(console.warn("Empty input!"),!1)}}function z8(e,t,i,r,n,s){var a=(n-i)*(e-i)+(s-r)*(t-r),o=(n-i)*(n-i)+(s-r)*(s-r),l=a/o,c=i+(n-i)*l,u=r+(s-r)*l;return a<=0?Math.sqrt((e-i)*(e-i)+(t-r)*(t-r)):a>=o?Math.sqrt((e-n)*(e-n)+(t-s)*(t-s)):Math.sqrt((e-c)*(e-c)+(u-t)*(u-t))}function X8(e,t,i){return j8(e,t,i)?bP((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}var my=1e-4,se=new Float64Array(100);function So(e,t){if(e instanceof ie&&t instanceof ie)return iu(e,t);if(e instanceof Se&&t instanceof ie)return Pv(e,t);if(e instanceof ie&&t instanceof Se)return Pv(t,e);if(e instanceof Se&&t instanceof Se)return EP(e,t);if(e instanceof Ye&&t instanceof Ye)return Rb(e,t);if(e instanceof Ye&&t instanceof ie)return Rb(e,new Ye([t.start(),t.end()]));if(e instanceof ie&&t instanceof Ye)return Rb(new Ye([e.start(),e.end()]),t);if(e instanceof Ye&&t instanceof Se)return Q_(t,e);if(e instanceof Se&&t instanceof Ye)return Q_(e,t);throw new Error("not supported operation")}function W8(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new ie(new j(i.minX-1,t),new j(i.maxX+1,t));return iu(r,e)>0?1:0}else return 0}function q8(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new ie(new j(i.minX-1,t),new j(i.maxX+1,t));return Vb(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function W_(e,t){let i=e.bbox();return i.isContainsY1(t)&&Rb(new Ye([new j(i.minX-1,t),new j(i.maxX+1,t)]),e)>0?1:0}function q_(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function J8(e,t){let i=t.length(),r=Gn.crossProd3(t.start(),t.end(),e.start())/i,n=Gn.crossProd3(t.start(),t.end(),e.end())/i;return Math.abs(r)<1e-8||Math.abs(n)<1e-8||r*n<0}function iu(e,t){let i=e.bbox().intersection1(t.bbox());if(!i)return 0;if(e.isPoint())if(t.isPoint()){let r=i.center();return se[0]=r.x,se[1]=r.y,2}else return J_(t,e,i);else{if(t.isPoint())return J_(e,t,i);{let r=function(E,S){i.isContains2(E,S)&&(se[y++]=E,se[y++]=S)};if(!J8(e,t))return 0;let n=e.start().x,s=e.start().y,a=e.end().x,o=e.end().y,l=t.start().x,c=t.start().y,u=t.end().x,h=t.end().y,d=t.length(),p=Gn.crossProd2(n,s,l,c,u,h)/d,f=Gn.crossProd2(a,o,l,c,u,h)/d;if(p*f>0&&!_e.eq(p,0)&&!_e.eq(f,0))return 0;let m=e.length(),g=Gn.crossProd2(l,c,n,s,a,o)/m,b=Gn.crossProd2(u,h,n,s,a,o)/m;if(g*b>0&&!_e.eq(g,0)&&!_e.eq(b,0))return 0;let y=0;if(_e.eq(p,0)&&_e.eq(f,0)){let E=i.UL(),S=i.UR(),w=i.LL(),x=i.LR();if(_e.eq(i.width(),0))_e.eq(i.height(),0)?(se[y++]=E.x,se[y++]=E.y):(se[y++]=E.x,se[y++]=E.y,se[y++]=w.x,se[y++]=w.y);else if(_e.eq(i.height(),0))se[y++]=E.x,se[y++]=E.y,se[y++]=S.x,se[y++]=S.y;else{let I=Vf.area2(E.x,E.y,l,c,u,h),A=Vf.area2(S.x,S.y,l,c,u,h);I<A?(se[y++]=E.x,se[y++]=E.y,se[y++]=x.x,se[y++]=x.y):(se[y++]=S.x,se[y++]=S.y,se[y++]=w.x,se[y++]=w.y)}}else if(_e.eq(p,0))r(n,s);else if(_e.eq(f,0))r(a,o);else{let E=Math.abs(p/(p-f));r(n+(a-n)*E,s+(o-s)*E)}return y}}}function J_(e,t,i){let r=t.start(),n=t.end(),s=Gn.crossProd3(e.start(),e.end(),t.start()),a=Gn.crossProd3(e.start(),e.end(),t.end());if(s*a<0){let o=i.center();return se[0]=o.x,se[1]=o.y,2}else if(Math.abs(s)<Math.abs(a)){if(_e.eq(s/e.length(),0))return se[0]=r.x,se[1]=r.y,2}else if(_e.eq(a/e.length(),0))return se[0]=n.x,se[1]=n.y,2;return 0}function Vb(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(my);let r=e.center.x,n=e.center.y,s=e.rx,a=e.rx2,o=t.start().x,l=t.start().y,c=t.end().x,u=t.end().y,h=e.center.distance1(t.start()),d=e.center.distance1(t.end()),p=_e.eq(h,s)?0:h>s?1:-1,f=_e.eq(d,s)?0:d>s?1:-1,m=0;if(p===-1&&f===-1)return 0;if(p===0&&f===0)se[m++]=o,se[m++]=l,se[m++]=c,se[m++]=u;else if(p===1&&f===1){let g=fc.foot(t,e.center),b=g.distance1(e.center);if(_e.greater(b,s))return 0;if(_e.eq(b,s))_e.eq(t.distance2(e.start()),0)?(se[m++]=e.start().x,se[m++]=e.start().y,se[m++]=e.start().x,se[m++]=e.start().y):_e.eq(t.distance2(e.end()),0)?(se[m++]=e.end().x,se[m++]=e.end().y,se[m++]=e.end().x,se[m++]=e.end().y):(se[m++]=g.x,se[m++]=g.y,se[m++]=g.x,se[m++]=g.y);else{m=xP(r,n,o,l,c,u,m,g);let y=se[m-2],E=se[m-1];m-=2;let S=Gn.distance1(r,n,y,E);if(_e.eq(S,s))se[m++]=y,se[m++]=E,se[m++]=y,se[m++]=E;else if(S<s)m=Ss(a,r,n,o,l,y,E,m),m=Ss(a,r,n,y,E,c,u,m);else return 0}}else if(p===-1||f===-1)m=Ss(a,r,n,o,l,c,u,m);else{let g=fc.foot(t,e.center),b=g.distance1(e.center);if(_e.eq(b,s)){let y=function(w){return q_(i,w.x,w.y)&&Fn(e,w)},E=e.start(),S=e.end();if(p===0){let w=t.start();if(y(w))return se[m++]=w.x,se[m++]=w.y,se[m++]=w.x,se[m++]=w.y,m;if(y(g))return se[m++]=g.x,se[m++]=g.y,se[m++]=g.x,se[m++]=g.y,m;if(_e.eq(t.distance2(E),0)&&y(E))return se[m++]=E.x,se[m++]=E.y,se[m++]=E.x,se[m++]=E.y,m;if(_e.eq(t.distance2(S),0)&&y(S))return se[m++]=S.x,se[m++]=S.y,se[m++]=S.x,se[m++]=S.y,m;if(h<=s)m=Ss(a,r,n,g.x,g.y,c,u,m),m===2&&(se[m++]=se[0],se[m++]=se[1]);else if(b<s){if(m=Ss(a,r,n,g.x,g.y,c,u,m),m===2&&y(new j(se[0],se[1])))return se[m++]=se[0],se[m++]=se[1],m;m=Ss(a,r,n,g.x,g.y,o,l,0),m===2&&(se[m++]=se[0],se[m++]=se[1])}}else{let w=t.end();if(y(w))return se[m++]=w.x,se[m++]=w.y,se[m++]=w.x,se[m++]=w.y,m;if(y(g))return se[m++]=g.x,se[m++]=g.y,se[m++]=g.x,se[m++]=g.y,m;if(_e.eq(t.distance2(E),0)&&y(E))return se[m++]=E.x,se[m++]=E.y,se[m++]=E.x,se[m++]=E.y,m;if(_e.eq(t.distance2(S),0)&&y(S))return se[m++]=S.x,se[m++]=S.y,se[m++]=S.x,se[m++]=S.y,m;if(d<=s)m=Ss(a,r,n,g.x,g.y,o,l,m),m===2&&(se[m++]=se[0],se[m++]=se[1]);else if(b<s){if(m=Ss(a,r,n,g.x,g.y,o,l,m),m===2&&y(new j(se[0],se[1])))return se[m++]=se[0],se[m++]=se[1],m;m=Ss(a,r,n,g.x,g.y,c,u,0),m===2&&(se[m++]=se[0],se[m++]=se[1])}}}else if(p===0){let y=t.start();se[m++]=y.x,se[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=Ss(a,r,n,g.x,g.y,c,u,m))}else{let y=t.end();se[m++]=y.x,se[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=Ss(a,r,n,g.x,g.y,o,l,m))}}if(m>0){let g=0;for(let b=0;b<m;b+=2){let y=se[b],E=se[b+1];isFinite(y)&&isFinite(E)&&q_(i,y,E)&&Fn(e,new j(y,E))&&(se[g++]=y,se[g++]=E)}return g}else return 0}else return 0}function K8(e,t){if(e.bbox()){let i=e.center.x,r=e.center.y,n=e.rx2,s=t.start().x,a=t.start().y,o=t.end().x,l=t.end().y,c=e.center.distance2(t.start()),u=e.center.distance2(t.end()),h=_e.eq(c,n)?0:c>n?1:-1,d=_e.eq(u,n)?0:u>n?1:-1,p=0;if(h===-1&&d===-1)return 0;if(h===0&&d===0)se[p++]=s,se[p++]=a,se[p++]=o,se[p++]=l;else if(h===1&&d===1){let f=fc.foot(t,e.center),m=f.distance2(e.center);if(_e.greater(m,n))return 0;if(_e.eq(m,n)){let g=f.distance2(e.start()),b=f.distance2(e.end());_e.eq(g,0)?(se[p++]=e.start().x,se[p++]=e.start().y):_e.eq(b,0)?(se[p++]=e.end().x,se[p++]=e.end().y):(se[p++]=f.x,se[p++]=f.y)}else{p=xP(i,r,s,a,o,l,p,f);let g=se[p-2],b=se[p-1],y=Gn.distance2(i,r,g,b);if(p-=2,_e.eq(y,n))se[p++]=g,se[p++]=b;else if(y<n)p=Ss(n,i,r,s,a,g,b,p),p=Ss(n,i,r,g,b,o,l,p);else return 0}}else if(h===-1||d===-1)p=Ss(n,i,r,s,a,o,l,p);else{let f=fc.foot(t,e.center);h===0?(se[p++]=t.start().x,se[p++]=t.start().y,_e.neq(f.distance2(t.start()),0)&&(s-f.x)*(o-f.x)+(a-f.y)*(l-f.y)<0&&(p=Ss(n,i,r,f.x,f.y,o,l,p))):(se[p++]=t.end().x,se[p++]=t.end().y,_e.neq(f.distance2(t.end()),0)&&(s-f.x)*(o-f.x)+(a-f.y)*(l-f.y)<0&&(p=Ss(n,i,r,f.x,f.y,s,a,p)))}if(p>0){let f=0;for(let m=0;m<p;m+=2){let g=se[m],b=se[m+1];isFinite(g)&&isFinite(b)&&(se[f++]=g,se[f++]=b)}return f}else return 0}else return 0}function Ss(e,t,i,r,n,s,a,o){if(n==a){let y=e-(n-i)*(n-i);if(_e.greater(y,0)){let E=Math.sqrt(y),S=t-E,w=t+E,x=Math.min(r,s),I=Math.max(r,s);return S>=x&&S<=I&&(se[o++]=S,se[o++]=n),w>=x&&w<=I&&(se[o++]=w,se[o++]=n),o}}let l=Gn.distance2(r,n,t,i)-e;if(l===0)return se[o++]=r,se[o++]=n,o;let c=Gn.distance2(s,a,t,i)-e;if(c===0)return se[o++]=s,se[o++]=a,o;if(l<0&&c<0)return l>c?_e.eq(l,0)&&(se[o++]=r,se[o++]=n):_e.eq(c,0)&&(se[o++]=s,se[o++]=a),o;if(l>0&&c>0&&(r-t)*(s-t)+(n-i)*(a-i)>0)return l<c?_e.eq(l,0)&&(se[o++]=r,se[o++]=n):_e.eq(c,0)&&(se[o++]=s,se[o++]=a),o;let u=r,h=n,d=s,p=a,f=NaN,m=NaN,g=Number.POSITIVE_INFINITY,b=0;for(;g!==0;){b++;let y=Math.max(Math.min(Math.abs(l)/(Math.abs(l)+Math.abs(c)),.75),.25);if(f=u+(d-u)*y,m=h+(p-h)*y,u===f&&h===m||d===f&&p===m){Math.abs(l)>Math.abs(c)?(f=d,m=p,g=c):(f=u,m=h,g=l);break}else g=Gn.distance2(f,m,t,i)-e,(g<0?l>c:l<c)?(d=f,p=m,c=g):(u=f,h=m,l=g)}return se[o++]=f,se[o++]=m,o}function xP(e,t,i,r,n,s,a,o){let l=Gn.dotProd2(i,r,n,s,e,t),c=Gn.dotProd2(n,s,i,r,e,t);if(l>=0)return se[a++]=n,se[a++]=s,a;if(c>=0)return se[a++]=i,se[a++]=r,a;if(Gn.crossProd2(i,r,n,s,e,t)==0)return se[a++]=e,se[a++]=t,a;{let u=NaN,h=NaN,d=i,p=r,f=n,m=s,g=Gn.distance2(i,r,e,t),b=Gn.distance2(n,s,e,t),y=Number.POSITIVE_INFINITY,E=0;for(;y>0&&(E++,u=d+(f-d)*.5,h=p+(m-p)*.5,!(g==b||d==u&&p==h||f==u&&m==h));){y=Gn.distance2(u,h,e,t);let S=Gn.dotProd2(d,p,u,h,e,t);if(S==0)break;S<0?(f=u,m=h,b=y):(d=u,p=h,g=y)}return Gn.distance2(u,h,e,t)<Gn.distance2(o.x,o.y,e,t)?(se[a++]=u,se[a++]=h):(se[a++]=o.x,se[a++]=o.y),a}}function Pv(e,t){if(e.rx===e.ry)return Vb(e,t);throw new Error("not supported")}function $8(e,t){if(e.rx===e.ry)return K8(e,t);throw new Error("not supported")}function EP(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return Z8(e,t);throw new Error("not supported operation")}return 0}function Z8(e,t){let i=e.center.x,r=e.center.y,n=t.center.x,s=t.center.y,a=e.rx,o=t.rx,l=e.rx2,c=t.rx2,u=e.center.distance1(t.center),h=Math.abs(a-o),d=a+o;if(_e.greater(u,d)||_e.less(u,h))return 0;if(_e.eq(h+u,0)){let p=0,f;return Fn(e,t.start())&&(se[p]=t.start().x,se[p+1]=t.start().y,p+=2,f=t.start()),Fn(e,t.end())&&(se[p]=t.end().x,se[p+1]=t.end().y,p+=2,f=t.end()),p===0?(Fn(t,e.start())&&(se[p]=e.start().x,se[p+1]=e.start().y,p+=2),Fn(t,e.end())&&(se[p]=e.end().x,se[p+1]=e.end().y,p+=2)):p===2&&(!f.equals1(e.start())&&Fn(t,e.start())&&(se[p]=e.start().x,se[p+1]=e.start().y,p+=2),!f.equals1(e.end())&&Fn(t,e.end())&&(se[p]=e.end().x,se[p+1]=e.end().y,p+=2)),p}else if(_e.eq(u,d)){if(K_(e,t))return 4;let p=new ie(e.center,t.center),f=Vb(t,p);return f=$_(e,f),f!==0?f:(f=Vb(e,p),$_(t,f))}else if(_e.eq(u,h)){if(K_(e,t))return 4;if(a>o){let p=(a-o)/a;return se[0]=i+(n-i)/p,se[1]=r+(s-r)/p,Z_(e,t,2)}else{let p=(o-a)/o;return se[0]=n+(i-n)/p,se[1]=s+(r-s)/p,Z_(e,t,2)}}else{let p,f;if(e.rx>t.rx){let O=(e.center.distance2(t.center)-l+c)/(u*2)/u;p=(i-n)*O+n,f=(r-s)*O+s}else{let O=(e.center.distance2(t.center)-c+l)/(u*2)/u;p=(n-i)*O+i,f=(s-r)*O+r}let m=n-i,g=s-r,b=Math.max(a,o)*2,y,E,S,w;if(Math.abs(m)<Math.abs(g)){let O=m/-g,R=f-O*p;y=p-b,E=O*y+R,S=p+b,w=O*S+R}else{let O=g/-m,R=p-O*f;E=f-b,y=O*E+R,w=f+b,S=O*w+R}let x;if(e.rx>t.rx?(x=Ss(c,n,s,y,E,p,f,0),x=Ss(c,n,s,p,f,S,w,x)):(x=Ss(l,i,r,y,E,p,f,0),x=Ss(l,i,r,p,f,S,w,x)),x!==4)throw new Error("cnt !== 4");let I=new j(se[0],se[1]),A=new j(se[2],se[3]);if(Fn(e,I)&&Fn(t,I))return Fn(e,A)&&Fn(t,A)?4:zh(e.start(),t,A,I)?(se[2]=e.start().x,se[3]=e.start().y,4):zh(e.end(),t,A,I)?(se[2]=e.end().x,se[3]=e.end().y,4):zh(t.start(),e,A,I)?(se[2]=t.start().x,se[3]=t.start().y,4):zh(t.end(),e,A,I)?(se[2]=t.end().x,se[3]=t.end().y,4):2;if(Fn(e,A)&&Fn(t,A))return zh(e.start(),t,I,A)?(se[0]=e.start().x,se[1]=e.start().y,4):zh(e.end(),t,I,A)?(se[0]=e.end().x,se[1]=e.end().y,4):zh(t.start(),e,I,A)?(se[0]=t.start().x,se[1]=t.start().y,4):zh(t.end(),e,I,A)?(se[0]=t.end().x,se[1]=t.end().y,4):(se[0]=se[2],se[1]=se[3],2);{let O=function(G,V){if(_e.eq(G.distance1(V.center),V.rx)&&Fn(V,G)){if(G.distance2(I)<G.distance2(A)){if(R)return;R=!0}else{if(M)return;M=!0}se[F++]=G.x,se[F++]=G.y}},R=!1,M=!1,F=0;return O(e.start(),t),O(e.end(),t),O(t.start(),e),O(t.end(),e),F}}}function zh(e,t,i,r){return _e.eq(e.distance1(t.center),t.rx)&&Fn(t,e)&&e.distance2(i)<e.distance2(r)}function K_(e,t){return _e.eq(t.start().distance1(e.center),e.rx)&&Fn(e,t.start())?(se[0]=t.start().x,se[1]=t.start().y,se[2]=t.start().x,se[3]=t.start().y,!0):_e.eq(t.end().distance1(e.center),e.rx)&&Fn(e,t.end())?(se[0]=t.end().x,se[1]=t.end().y,se[2]=t.end().x,se[3]=t.end().y,!0):_e.eq(e.start().distance1(t.center),t.rx)&&Fn(t,e.start())?(se[0]=e.start().x,se[1]=e.start().y,se[2]=e.start().x,se[3]=e.start().y,!0):_e.eq(e.end().distance1(t.center),t.rx)&&Fn(t,e.end())?(se[0]=e.end().x,se[1]=e.end().y,se[2]=e.end().x,se[3]=e.end().y,!0):!1}function $_(e,t){if(t===0)return 0;let i=se[0],r=se[1];return Fn(e,new j(i,r))?(se[0]=i,se[1]=r,se[2]=i,se[3]=r,4):0}function Z_(e,t,i){if(i===0)return 0;let r=se[0],n=se[1],s=new j(r,n);return Fn(e,s)&&Fn(t,s)?(se[0]=r,se[1]=n,se[2]=r,se[3]=n,4):0}function Cf(e,t){return Math.abs(e-t)<=1e-6}function Fn(e,t){let i=e.bbox();if(t.x-i.minX>-my&&t.x-i.maxX<my&&t.y-i.minY>-my&&t.y-i.maxY<my){let r=Qt.regularD(t.angleD(e.center));return Cf(r,e.startAngle)||Cf(r,e.startAngle+360)||Cf(r,e.startAngle-360)||Cf(r,e.endAngle())||Cf(r,e.endAngle()+360)||Cf(r,e.endAngle()-360)?!0:e.sweepAngle>0?(_e.less(r,e.startAngle)&&(r+=360),_e.greatereq(e.endAngle(),r)):(_e.greater(r,e.startAngle)&&(r-=360),_e.lesseq(e.endAngle(),r))}else return!1}function Q8(e,t){let i=e[1].x-e[0].x,r=e[1].y-e[0].y,n=t[1].x-t[0].x,s=t[1].y-t[0].y;if(i===0&&n!==0||i!==0&&n===0)return!1;if(i===0&&n===0)return!0;let a=r/i,o=s/n;return bP(a,o,Math.sin(Math.PI/180))}function e7(e,t,i){var r,n=+t.x,s=+t.y,a=+i.x,o=+i.y,l=+e.x,c=+e.y,u=a-n,h=o-s,d=l-n,p=c-s,f,m,g,b,y,E;return u===0&&h===0?{d:Math.sqrt(d*d+p*p),point:new j(n,s)}:(r=(d*u+p*h)/(u*u+h*h),r<0?{d:Math.sqrt(d*d+p*p),point:new j(n,s)}:r>1?(f=l-a,m=c-o,{d:Math.sqrt(f*f+m*m),point:new j(a,o)}):(y=n+r*u,E=s+r*h,g=l-y,b=c-E,{d:Math.sqrt(g*g+b*b),point:new j(y,E)}))}function pc(e,t){if(!e||!t||e.length!=t.length)return!1;let i="equals1";return!e.some((r,n)=>{let s=t[n],a=!1;return r&&s&&typeof r=="object"&&typeof s=="object"?typeof r[i]=="function"&&i7(r,s)?a=!r[i].call(r,s):a=!(r===s||r.toString()===s.toString()):typeof r=="number"&&typeof s=="number"?a=!(t7(r,s)||Number.isNaN(r)&&Number.isNaN(s)):a=r!==s,a})}function t7(e,t,i=5){return Math.abs(e-t)*Math.pow(10,i)<1}function i7(e,t){return!e||!t||typeof e!="object"||typeof t!="object"?e===t:e.constructor===t.constructor}var mi=new Float64Array(100);function Rb(e,t){if(e.bbox().extendOfSize(_e.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,n=0,s=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(C){M=Math.min(M,C),F=Math.max(F,C)},o=function(C,N){let T=iu(C,N);if(T===0)throw new Error("cnt === 0");for(let L=0;L<T;L+=2)a(se[L])};if(n>r){for(let C=n-2;C>=2;C-=2)for(let N=C-2;N>=0;N-=2)if(_e.eq(mi[C],mi[N])&&_e.eq(mi[C+1],mi[N+1])){mi[N]=(mi[C]+mi[N])/2,mi[N+1]=(mi[C+1]+mi[N+1])/2;for(let T=n-3;T>=C;T--)mi[T]=mi[T+2];n-=2;break}if(n>r){n=0;let C=t.start(),N=new Float64Array(8);e.getPercent(C)!==null&&(N[n++]=C.x,N[n++]=C.y);let T=t.end();e.getPercent(T)!==null&&(N[n++]=T.x,N[n++]=T.y);let L=e.start();t.getPercent(L)!==null&&(N[n++]=L.x,N[n++]=L.y);let P=e.end();return t.getPercent(P)!==null&&(N[n++]=P.x,N[n++]=P.y),se.set(N),n}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let C=iu(new ie(u[0],u[1]),new ie(h[0],h[1]));for(let N=0;N<C;N++)mi[n++]=se[N];continue}let d=u[0],p=u[u.length-1];d.equals1(p)&&(p=d.add1(1,0));let f=p.y-d.y,m=d.x-p.x,g=-f*d.x-m*d.y,b=Math.sqrt(1/(f**2+m**2));f*=b,m*=b,g*=b;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(C=>{let N=f*C.x+m*C.y+g;N<y&&(y=N),N>E&&(E=N)}),_e.eq(y,E)){if(c.controls.length===2){let C=iu(new ie(l.start(),l.end()),new ie(c.start(),c.end()));for(let N=0;N<C;N++)mi[n++]=se[N];if(C!==0)continue}l=new Ye([u[0],u[u.length-1]]),u=l.controls}let S=h.map(C=>{let N=f*C.x+m*C.y+g,T=Math.abs(N);return T<s&&(s=T),N}),w=0;for(let C of S){if(_e.less(C,y))w=w|1;else if(_e.greater(C,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let x=0,I=0,A=p.x-d.x,O=p.y-d.y,R=Math.sqrt(1/(A**2+O**2));A*=R,O*=R;for(let C=1;C<u.length;C++){let N=u[C],T=(N.x-d.x)*A+(N.y-d.y)*O;T<x?x=T:T>I&&(I=T)}w=0;for(let C of h){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(_e.less(N,x))w=w|1;else if(_e.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;s/=2,s<=_e.eps&&(s=_e.eps),y-=s,E+=s,S.forEach((C,N)=>{C>=y&&C<=E&&a(N/(S.length-1))});let G=new ie(new j(0,y),new j(1,y)),V=new ie(new j(0,E),new j(1,E));for(let C=0;C<S.length-1;C++){let N=new j(C/(S.length-1),S[C]),T=N.y<y?1:N.y>E?2:3;for(let L=0;L<S.length;L++){let P=new j(L/(S.length-1),S[L]),B=P.y<y?1:P.y>E?2:3;T!==B&&(T===1?B===2?(o(new ie(N,P),G),o(new ie(N,P),V)):o(new ie(N,P),G):T===2?B===1?(o(new ie(N,P),G),o(new ie(N,P),V)):o(new ie(N,P),V):B===1?o(new ie(N,P),G):o(new ie(N,P),V))}}M!==0&&(c=c.clip(M)[1]),F!==1&&(c=c.clip((F-M)/(1-M))[0]);let q=c.bbox();if(_e.eq(q.minX,q.maxX)&&_e.eq(q.minY,q.maxY)){w=0;for(let C of c.controls){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(_e.less(N,x))w=w|1;else if(_e.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let C=new j((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(C)&&(mi[n++]=C.x,mi[n++]=C.y)}continue}if(F-M>.8){let[C,N]=c.clip(.5);i.push([C,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)se[a]=mi[a];return n}function r7(e,t){if(e.bbox().extendOfSize(_e.eps).isSeparated(t.bbox()))return{cnt:0};let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,n=0,s=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(C){M=Math.min(M,C),F=Math.max(F,C)},o=function(C,N){let T=iu(C,N);if(T===0)throw new Error("cnt === 0");for(let L=0;L<T;L+=2)a(se[L])};if(n>r){for(let C=n-2;C>=2;C-=2)for(let N=C-2;N>=0;N-=2)if(_e.eq(mi[C],mi[N])&&_e.eq(mi[C+1],mi[N+1])){mi[N]=(mi[C]+mi[N])/2,mi[N+1]=(mi[C+1]+mi[N+1])/2;for(let T=n-3;T>=C;T--)mi[T]=mi[T+2];n-=2;break}if(n>r){n=0;let C=new Float64Array(8),N=t.end(),T=0;e.getPercent(N)!==null&&(C[n++]=N.x,C[n++]=N.y,T=2);let L=e.end();return t.getPercent(L)!==null&&(C[n++]=L.x,C[n++]=L.y,T=T===0?1:3),se.set(C),{havOverlap:T,cnt:n}}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let C=iu(new ie(u[0],u[1]),new ie(h[0],h[1]));for(let N=0;N<C;N++)mi[n++]=se[N];continue}let d=u[0],p=u[u.length-1];d.equals1(p)&&(p=d.add1(1,0));let f=p.y-d.y,m=d.x-p.x,g=-f*d.x-m*d.y,b=Math.sqrt(1/(f**2+m**2));f*=b,m*=b,g*=b;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(C=>{let N=f*C.x+m*C.y+g;N<y&&(y=N),N>E&&(E=N)}),_e.eq(y,E)){if(c.controls.length===2){let C=iu(new ie(l.start(),l.end()),new ie(c.start(),c.end()));for(let N=0;N<C;N++)mi[n++]=se[N];if(C!==0)continue}l=new Ye([u[0],u[u.length-1]]),u=l.controls}let S=h.map(C=>{let N=f*C.x+m*C.y+g,T=Math.abs(N);return T<s&&(s=T),N}),w=0;for(let C of S){if(_e.less(C,y))w=w|1;else if(_e.greater(C,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let x=0,I=0,A=p.x-d.x,O=p.y-d.y,R=Math.sqrt(1/(A**2+O**2));A*=R,O*=R;for(let C=1;C<u.length;C++){let N=u[C],T=(N.x-d.x)*A+(N.y-d.y)*O;T<x?x=T:T>I&&(I=T)}w=0;for(let C of h){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(_e.less(N,x))w=w|1;else if(_e.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;s/=2,s<=_e.eps&&(s=_e.eps),y-=s,E+=s,S.forEach((C,N)=>{C>=y&&C<=E&&a(N/(S.length-1))});let G=new ie(new j(0,y),new j(1,y)),V=new ie(new j(0,E),new j(1,E));for(let C=0;C<S.length-1;C++){let N=new j(C/(S.length-1),S[C]),T=N.y<y?1:N.y>E?2:3;for(let L=0;L<S.length;L++){let P=new j(L/(S.length-1),S[L]),B=P.y<y?1:P.y>E?2:3;T!==B&&(T===1?B===2?(o(new ie(N,P),G),o(new ie(N,P),V)):o(new ie(N,P),G):T===2?B===1?(o(new ie(N,P),G),o(new ie(N,P),V)):o(new ie(N,P),V):B===1?o(new ie(N,P),G):o(new ie(N,P),V))}}M!==0&&(c=c.clip(M)[1]),F!==1&&(c=c.clip((F-M)/(1-M))[0]);let q=c.bbox();if(_e.eq(q.minX,q.maxX)&&_e.eq(q.minY,q.maxY)){w=0;for(let C of c.controls){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(_e.less(N,x))w=w|1;else if(_e.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let C=new j((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(C)&&(mi[n++]=C.x,mi[n++]=C.y)}continue}if(F-M>.8){let[C,N]=c.clip(.5);i.push([C,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)se[a]=mi[a];return{cnt:n}}var n7=class{constructor(e=_e.eps){this.eps=e}eq(e,t){return Math.abs(e-t)<=this.eps}setEps(e){this.eps=e}},hy=new n7;function Q_(e,t){if(e.bbox().extendOfSize(_e.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(t.controls.length-1)*16,n=0;for(;i.length!==0;){if(n>r){let a=function(){for(let c=0;c<n;c+=2)for(let u=c+2;u<n;u+=2)if(!(hy.eq(mi[c],mi[u])&&hy.eq(mi[c+1],mi[u+1]))){l(mi[u],mi[u+1],o);break}function l(c,u,h){let d=!1;for(let p=0;p<h.length;p+=2)if(hy.eq(c,h[p])&&hy.eq(u,h[p+1])){d=!0;break}d||h.push(c,u)}},o=[mi[0],mi[1]];if(a(),o.length>=100&&(hy.setEps(.001),o=[mi[0],mi[1]],a(),o.length>=100))throw new Error("clearSamePoint()");n=o.length,o.forEach((l,c)=>mi[c]=l)}let s=i.pop();if(s[0]instanceof Se){let a=function(V){O=Math.min(O,V),R=Math.max(R,V)},o=function(V,q){let C=iu(V,q);if(C===0)throw new Error("cnt === 0");for(let N=0;N<C;N+=2)a(se[N])},[l,c]=s,u=c.controls;if(u.length===2){let V=Pv(l,new ie(u[0],u[1]));for(let q=0;q<V;q++)mi[n++]=se[q];continue}let h=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,p,f,m,g,b;if(Math.abs(l.sweepAngle)>359){let V=l.rx;p=l.center.add1(V,0),f=l.center.add1(-V,0),h=-V,d=V,m=0,g=1,b=-l.center.y}else{p=l.start(),f=l.end(),m=f.y-p.y,g=p.x-f.x,b=-m*p.x-g*p.y;let V=Math.sqrt(1/(m**2+g**2));m*=V,g*=V,b*=V;let q=m*l.center.x+g*l.center.y+b;l.isCCW?(d=l.rx+q,h=0):(h=q-l.rx,d=0)}let y=u.map(V=>m*V.x+g*V.y+b),E=0;for(let V of y){if(_e.less(V,h))E=E|1;else if(_e.greater(V,d))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let S=0,w=0,x=f.x-p.x,I=f.y-p.y,A=Math.sqrt(1/(x**2+I**2));if(x*=A,I*=A,Math.abs(l.sweepAngle)<=180)S=0,w=(f.x-p.x)*x+(f.y-p.y)*I;else throw new Error("not support");E=0;for(let V of u){let q=(V.x-p.x)*x+(V.y-p.y)*I;if(_e.less(q,S))E=E|1;else if(_e.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let O=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY;h-=_e.eps,d+=_e.eps,y.forEach((V,q)=>{V>=h&&V<=d&&a(q/(y.length-1))});let M=new ie(new j(0,h),new j(1,h)),F=new ie(new j(0,d),new j(1,d));for(let V=0;V<y.length-1;V++){let q=new j(V/(y.length-1),y[V]),C=q.y<h?1:q.y>d?2:3;for(let N=0;N<y.length;N++){let T=new j(N/(y.length-1),y[N]),L=T.y<h?1:T.y>d?2:3;C!==L&&(C===1?L===2?(o(new ie(q,T),M),o(new ie(q,T),F)):o(new ie(q,T),M):C===2?L===1?(o(new ie(q,T),M),o(new ie(q,T),F)):o(new ie(q,T),F):L===1?o(new ie(q,T),M):o(new ie(q,T),F))}}O!==0&&(c=c.clip(O)[1]),R!==1&&(c=c.clip((R-O)/(1-O))[0]);let G=c.bbox();if(_e.eq(G.minX,G.maxX)&&_e.eq(G.minY,G.maxY)){E=0;for(let V of c.controls){let q=(V.x-p.x)*x+(V.y-p.y)*I;if(_e.less(q,S))E=E|1;else if(_e.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}E===3&&(mi[n++]=(G.minX+G.maxX)/2,mi[n++]=(G.minY+G.maxY)/2);continue}R-O>.8?c.clip(.5).forEach(V=>i.push([V,l])):i.push([c,l])}else{let[a,o]=s;i.push([Se.build3(o.center,o.startAngle,o.sweepAngle/2,o.rx,o.ry),a]),i.push([Se.build3(o.center,o.startAngle+o.sweepAngle/2,o.sweepAngle/2,o.rx,o.ry),a])}}for(let s=0;s<n;s++)se[s]=mi[s];return n}var s7=class{static getSweep(e){if(e.length>2){let t=0,i=e.length;for(let s=0;s<i-1;s++){let a=e[s],o=e[s+1];t+=(o.x+a.x)*(o.y-a.y)}let r=e[0],n=e[i-1];return t+=(r.x+n.x)*(r.y-n.y),t>0}else throw new Error("Unable to determine the direction of rotation!")}static isClose(e){return!!(e.primitives.length>0&&e.primitives[0].start().equals1(e.primitives[e.primitives.length-1].end()))}};function a7(e){let t=e.primitives,i=t[0],r=i instanceof Se?i.sweepAngle%360:null;if(t.length===1&&i instanceof Se&&(_e.eq(r,0)||_e.eq(Math.abs(r),360)))return!!i.isCCW;let n=new Array;return e.points(.1,s=>{n.push(s)}),s7.getSweep(n)}var o7=class{static zoomCorner(e,t){let i=new Array,r=new Array,n=new Array;return this.getPanPrimitive(e,i,n,t),this.rearrange(i,n),this.processStart(i,n),this.getResult(i,n,r,t),r.length>0?Tt.build2(r):null}static zoomPolygon(e,t){let i=new Array,r=new Array,n=new Array;return a7(e)&&(e=e.reverse().asClose()),this.getPanPrimitive(e,i,n,t),this.rearrange(i,n),this.processStart(i,n),this.getResult(i,n,r,t),r.length>0?Tt.build2(r):null}static zoomLines(e,t){return this.zoomPolygon(Tt.build2(e.primitives.concat(e.reverse().primitives)),t/2)}static getPanPrimitive(e,t,i,r){let n=e.primitives;for(let s of n){let a=this.panDistance(s,r);a!==void 0&&(t.push(a),i.push(s))}}static rearrange(e,t){let i=e.length,r=0;for(let a=0;a<i;a++){let o=t[a],l=e[a],c=a==i-1?e[0]:e[a+1];if(!(l instanceof Se&&c instanceof Se)&&!this.isCW(l.end(),c.start(),o.end())){if(So(l,c)!=0){r=a==i-1?0:a+1;break}}else{r=a;break}}let n=this.start4Index(t,r),s=this.start4Index(e,r);t.length=0,e.length=0,n.forEach(a=>{t.push(a)}),s.forEach(a=>{e.push(a)})}static processStart(e,t){let i=e.length;if(i>2){let r=e[i-1],n=e[0],s=t[i-1];if(!(r instanceof Se&&n instanceof Se)&&!this.isCW(r.end(),n.start(),s.end())){let a=So(r,n);for(let o=0;o<a;o+=2){let l=new j(se[o],se[o+1]);e[i-1]=this.generatePrimitive(r,r.start(),l),e[0]=this.generatePrimitive(n,l,n.end())}}}}static getResult(e,t,i,r){let n=e.length;for(let s=0;s<n;s++){let a=t[s],o=s===n-1?t[0]:t[s+1],l=s==n-1?0:s+1,c=l==n-1?t[0]:t[l+1],u=e[s],h=s==n-1?e[0]:e[s+1],d=l==n-1?e[0]:e[l+1];if(!(u instanceof Se&&h instanceof Se)&&!this.isCW(u.end(),h.start(),a.end())){let f=this.add(e,i,s,u,h,0);f=this.update(e,i,s,h,f);let m=this.generateArc(o,c,h,d,r);if(f=this.add(e,i,s,u,m,f),f=this.update(e,i,s,m,f),f>0)continue}i.push(u);let p=this.generateArc(a,o,u,h,r);p!==void 0&&i.push(p)}}static generateArc(e,t,i,r,n){if(n>0){let s=e.end(),a=t.start(),o=i.end(),l=r.start();if(o.distance2(l)>1e-8)if(s.equals(a)){let c=o.angleD(s),u=l.angleD(s);return Se.build2(s,c,u,n,n,0)}else{let c=o.angleD(s),u=l.angleD(s),h=o.angleD(a),d=l.angleD(a),p=Se.build2(s,c,u,n,n,0),f=Se.build2(a,h,d,n,n,0);return p.pointOn(p.endAngle()).equals1(l)?p:f.pointOn(f.endAngle()).equals1(l)?f:p}}}static updateNews(e,t,i,r){let n=e.length,s=t==n-1?0:t+1;e[s]=this.generatePrimitive(i,r,i.end())}static add(e,t,i,r,n,s){if(s>0)return s;if(r!=null&&n!=null){let a=So(r,n);for(let o=0;o<a;o+=2){let l=new j(se[o],se[o+1]);t.push(this.generatePrimitive(r,r.start(),l)),this.updateNews(e,i,n,l);break}return a}else return 0}static update(e,t,i,r,n){if(n>0)return n;let s=t.length;if(s>0&&r!=null){let a=t[s-1],o=So(a,r);for(let l=0;l<o;l+=2){let c=new j(se[l],se[l+1]);t[s-1]=this.generatePrimitive(a,a.start(),c),this.updateNews(e,i,r,c)}return o}else return 0}static generatePrimitive(e,t,i){if(e instanceof ie)return new ie(t,i);if(e instanceof Se){let r=e,n=t.angleD(r.center),s=i.angleD(r.center);return Se.build2(r.center,n,s,r.rx,r.ry,r.sweep())}else throw new Error("not supported operation")}static start4Index(e,t){let i=e.length,r=new Array;for(let n=t;n<i;n++)r.push(e[n]);for(let n=0;n<t;n++)r.push(e[n]);return r}static isCW(e,t,i){let r=new ie(i,e),n=new ie(i,t),s=r.end().x-r.start().x,a=r.end().y-r.start().y,o=n.end().x-n.start().x,l=n.end().y-n.start().y;return!(s*l-a*o>0)}static panDistance(e,t){if(e instanceof ie){if(e.isPoint())return;{let i=e.panDistance(t);return i.length()>1e-5?i:void 0}}else if(e instanceof Se){let i=e;if(i.sweepAngle>0){if(i.rx-t<=0||i.ry-t<=0)return}else if(i.sweepAngle<0&&(i.rx+t<=0||i.ry+t<=0))return;return i=i.panDistance(t),i.start().distance1(i.end())>1e-5||_e.eq(Math.abs(i.sweepAngle),360)?i:void 0}else throw new Error("not supported operation")}},Ft=.001,ga=Ft**2;function It(e,t){return e.distance2(t)<ga}function ru(e,t){return Math.abs(e-t)<=1e-4}function l7(e,t){if(e instanceof ie)return new ie(e.start(),t);if(e instanceof Se){let i=t.angleD(e.center);return ru(Qt.regularD(e.startAngle),Qt.regularD(i))?Se.build3(e.center,e.startAngle,0,e.rx,e.ry):Se.build2(e.center,e.startAngle,i,e.rx,e.ry,e.isCCW?1:0)}else{if(e instanceof Ye)return e.clip(e.getPercent(t,Ft))[0];throw new Error("not supported operation")}}function mc(e,t=Qt.toRadians(e.startAngle)){return e.isCCW?t+=Yb:t-=Yb,new j(Math.cos(t),Math.sin(t))}function Iy(e,t=0){let i=e.controls;if(t===0){let r=i[0],n=i.slice(1).find(s=>!(s.x===r.x&&s.y===r.y));if(!n)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return n.sub(r)}else if(t===1){let r=i[i.length-1],n=i.slice(0,-1).reverse().find(s=>!(s.x===r.x&&s.y===r.y));if(!n)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return r.sub(n)}if(i.length===3){let[r,n,s]=i;return n.sub(r).mul(2*(1-t)).add(s.sub(n).mul(2*t)).normalize()}else{let[r,n,s,a]=i;return n.sub(r).mul(3*(1-t)**2).add(s.sub(n).mul(6*(1-t)*t)).add(a.sub(s).mul(3*t**2)).normalize()}}function Gf(e,t,i){let r=e.slice(1).findIndex(s=>!(s.x===t.x&&s.y===t.y)),n=e[r+1];if(i&&(i.getPercent(n,Ft)!==null||new ie(i.start(),i.end()).distance(n)<=Ft)&&(n=e[r+2]),!n)throw Error("getSecondPoint(controls: readonly Vector2[])");return n}function kt(e,t){if(e instanceof ie)return e.end().sub(e.start()).normalize();if(e instanceof Se)return(t?mc(e,t.angle(e.center)):mc(e)).normalize();if(e instanceof Ye)if(e.controls.length===2){let[i,r]=e.controls;if(It(i,r))throw Error("equalsPP(p0, p1)");return r.sub(i).normalize()}else return(t?Iy(e,e.getPercent(t,Ft)):Iy(e)).normalize();else throw new Error("not support")}function c7(e,t,i){let r=[],n=t**2-4*e*i;if(n>=0){let s=-t/(2*e),a=Math.sqrt(n)/(2*e),o=s+a;if(r.push(o),n>0){let l=s-a;r.push(l)}}return r}function u7(e,t,i,r,n=0,s=1){let a=[],o=e*Math.pow(n,3)+t*Math.pow(n,2)+i*n+r,l=e*Math.pow(s,3)+t*Math.pow(s,2)+i*s+r,c,u;if(o*l<0)for(;Math.abs(n-s)>Ft;)if(c=(n+s)/2,u=e*Math.pow(c,3)+t*Math.pow(c,2)+i*c+r,Math.abs(u)<Ft){a.push(c);break}else o*u<0?s=c:l*u<0&&(n=c);else o*l===0&&(o===0&&a.push(n),l===0&&a.push(s));return a}function uv(e,t,i){if(e instanceof ie||t.distance2(i)<=ga)return new ie(t,i);if(e instanceof Se)return Se.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof Ye){let r=e.getPercent(t,Ft),n=e.getPercent(i,Ft);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function Nb(e){return _e.greater(e,0)&&_e.less(e,1)}function Hb(e,t,i,r){let n=e[r]-2*t[r]+i[r],s=t[r]-e[r];if(n===0)return[];let a=-s/n,o=[];return Nb(a)&&o.push(a),o}function jb(e,t,i,r,n){let s,a,o=-e[n]+3*t[n]-3*i[n]+r[n],l=2*(e[n]-2*t[n]+i[n]),c=t[n]-e[n],u=l**2-4*o*c;if(_e.lesseq(u,0))s=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;else if(_e.lesseq(o,0)){let d=-c/l;return Nb(d)?[d]:[]}else{let d=Math.sqrt(u);s=(-l-d)/(2*o),a=(-l+d)/(2*o);let p=o*2;if(_e.lesseq(s,1)&&_e.greatereq(s,0)){let f=Number.NEGATIVE_INFINITY;for(;_e.neq(s,f);){f=s;let m=p*s+l;s=-(o*s**2+l*s+c-m*s)/m}}if(_e.lesseq(a,1)&&_e.greatereq(a,0)){let f=Number.NEGATIVE_INFINITY;for(;_e.neq(a,f);){f=a;let m=p*a+l;a=-(o*a**2+l*a+c-m*a)/m}}}let h=[];return Nb(a)&&h.push(a),Nb(s)&&h.push(s),h}function Qb(e,t){if(e.controls.length===2){let[o,l]=e.controls;It(o,l)||t.push(new ie(o,l));return}let i,r;if(e.controls.length===3){let[o,l,c]=e.controls;i=Hb(o,l,c,"x"),r=Hb(o,l,c,"y")}else{let[o,l,c,u]=e.controls;i=jb(o,l,c,u,"x"),r=jb(o,l,c,u,"y")}i.sort((o,l)=>l-o),r.sort((o,l)=>l-o);let n=i.pop()||1,s=r.pop()||1,a=0;for(;n!==1||s!==1;)if(_e.eq(n,s))n=i.pop()||1,s=r.pop()||1;else if(n<s){let[o,l]=e.clip((n-a)/(1-a));a=n,t.push(o),e=l,n=i.pop()||1}else{let[o,l]=e.clip((s-a)/(1-a));a=s,t.push(o),e=l,s=r.pop()||1}t.push(e)}var h7=1e-5,Yv=1,Ye=class Ba extends Dy{constructor(t){if(super(),this._startToEndL=null,t.length<2)throw new Error("Bezier needs at least 2 endpoints");this.controls=t.slice()}get startToEndL(){return this._startToEndL===null&&(this._startToEndL=new ie(this.start(),this.end())),this._startToEndL}build1(t){let i=[];return Uf(t,(r,n)=>(i.push(n),!0)),new Ba(i)}start(){return this.controls[0]}end(){return this.controls[this.controls.length-1]}static pointOn(t,i){if(i.length<1)throw new Error("bezier must have at least 1 point");if(i.length===1)return i[0];{let r=new Array(i.length-1);for(let n=1;n<i.length;n++){let s=i[n-1],a=i[n],o=(a.x-s.x)*t,l=(a.y-s.y)*t;r[n-1]=s.add1(o,l)}return Ba.pointOn(t,r)}}clip1(t,i,r,n){if(r.push(i[0]),n.push(i[i.length-1]),i.length<2)throw new Error("bezier clip must have at least 2 point");if(i.length===2){let s=i[0],a=i[1],o=(a.x-s.x)*t,l=(a.y-s.y)*t,c=s.add1(o,l);r.push(c),n.push(c)}else{let s=new Array(i.length-1);for(let a=1;a<i.length;a++){let o=i[a-1],l=i[a],c=(l.x-o.x)*t,u=(l.y-o.y)*t;s[a-1]=o.add1(c,u)}this.clip1(t,s,r,n)}}clip(t){let i=[],r=[];return this.clip1(t,this.controls,i,r),[new Ba(i),new Ba(r.reverse())]}greater(t,i,r){return t-i>r}less(t,i,r){return t-i<-r}eq(t,i,r){return Math.abs(t-i)<=r}eqPP(t,i,r){return!t||!i?!1:this.eq(t.x,i.x,r)&&this.eq(t.y,i.y,r)}isInRange(t,i=_e.eps){let r=this.controls.map(s=>s.y-t.y),n=0;for(let s of r){if(this.less(s,0,i))n=n|1;else if(this.greater(s,0,i))n=n|2;else{n=3;break}if(n===3)break}if(n!==3)return!1;n=0;for(let s of this.controls){let a=s.x-t.x;if(this.less(a,0,i))n=n|1;else if(this.greater(a,0,i))n=n|2;else{n=3;break}if(n===3)break}return n===3}getPercent(t,i=_e.eps){if(!this.isInRange(t,i))return null;let r=Number.POSITIVE_INFINITY,n=[[this,0,1]];for(;n.length!==0;){let s=function(g){u=Math.min(u,g),h=Math.max(h,g)},a=function(g,b){let y=iu(g,b);if(y===0)throw new Error("cnt === 0");for(let E=0;E<y;E+=2)s(se[E])},[o,l,c]=n.pop();if(this.eqPP(o.start(),t,i))return l;if(this.eqPP(o.end(),t,i))return c;let u=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,d=o.controls.map(g=>g.y-t.y);r=d.reduce((g,b)=>{let y=Math.abs(b);return y<g?y:g},r),r/=2,r<=i&&(r=i),d.forEach((g,b)=>{this.eq(g,0,i)&&s(b/(d.length-1))});let p=new ie(new j(0,-r),new j(1,-r)),f=new ie(new j(0,r),new j(1,r));for(let g=0;g<d.length-1;g++){let b=new j(g/(d.length-1),d[g]),y=this.less(b.y,0,i)?1:this.greater(b.y,0,i)?2:3;for(let E=0;E<d.length;E++){let S=new j(E/(d.length-1),d[E]),w=this.less(S.y,0,i)?1:this.greater(S.y,0,i)?2:3;y!==w&&(y===1?w===2?(a(new ie(b,S),p),a(new ie(b,S),f)):a(new ie(b,S),p):y===2?w===1?(a(new ie(b,S),p),a(new ie(b,S),f)):a(new ie(b,S),f):w===1?a(new ie(b,S),p):a(new ie(b,S),f))}}if(!isFinite(u)){if(Math.max(...d.map(g=>Math.abs(g)))<i*4)return(l+c)/2;continue}if(u!==0&&(o=o.clip(u)[1],l=(c-l)*u+l),h!==1){let g=(h-u)/(1-u);o=o.clip(g)[0],c=(c-l)*g+l}if(!o.isInRange(t,i))continue;let m=o.controls.reduce((g,b)=>g.ext2(b),new ot).build1();if(this.eq(m.minX,m.maxX,i)&&this.eq(m.minY,m.maxY,i))return(l+c)/2;if(h-u>.8){let[g,b]=o.clip(.5);g.isInRange(t,i)?(n.push([g,l,(l+c)/2]),b.isInRange(t,i)&&n.push([b,(l+c)/2,c])):n.push([b,(l+c)/2,c])}else n.push([o,l,c])}return null}toBezier(){return this}toString(){return"Bezier ["+this.controls.join(" ")+"]"}bbox(){return this._bbox||(this._bbox=new ot().ext3(this.points(.1)).build1()),this._bbox}bboxWithControls(){return this._bbox_controls||(this._bbox_controls=new ot().ext3(this.controls).build()),this._bbox_controls}multiply3(t){let i=new Array(this.controls.length);for(let r=0;r<this.controls.length;r++){let n=this.controls[r];i[r]=n.multiply3(t)}return new Ba(i)}stroke(t,i,r,n=Yv){let s=o7.zoomLines(Tt.build4(this.points(n)),t);return r===0?s:s.reverse()}points(t){let i=[];return this.getBezierPoints(t,r=>i.push(r)),i}getBezierPoints(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=[this];for(i(this.start());r.length!==0;){let s=r.pop(),a=new ie(s.start(),s.end());if(n(s.controls,a)<=t)i(s.end());else{let[o,l]=s.clip(.5);r.push(l,o)}}function n(s,a){let o=a.start(),l=a.end();o.equals1(l)&&(l=o.add1(1,0));let c=l.y-o.y,u=o.x-l.x,h=-c*o.x-u*o.y,d=Math.sqrt(1/(c**2+u**2));c*=d,u*=d,h*=d;let p=s.map(f=>Math.abs(c*f.x+u*f.y+h));return Math.max(...p)}}getBezierPoints3(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=t*t,n=this.controls[0],s=.5;for(;s>h7&&!(n.distance2(Ba.pointOn(s,this.controls))<=r);s*=.5);let a=Math.ceil(1/s);s=1/a,i(n);let o=0;for(let l=1;l<a;l++)o+=s,i(Ba.pointOn(o,this.controls));i(this.end())}getPointsBySlope(t){if(this.controls.length===4)return this.getPointsBySlope4(t);throw new Error("Currently, only 4 control points are supported!")}getPointsBySlope4(t){let[i,r,n,s]=this.controls,a=-3*i.x+9*r.x-9*n.x+3*s.x,o=6*i.x-12*r.x+6*n.x,l=-3*i.x+3*r.x,c=[];if(Number.isFinite(t)){let u=-3*i.y+9*r.y-9*n.y+3*s.y,h=6*i.y-12*r.y+6*n.y,d=-3*i.y+3*r.y,p=u-a*t,f=h-o*t,m=d-l*t,g=-f/(2*p),b=Math.sqrt(f**2-4*p*m)/(2*p),y=g+b;y>=0&&y<=1&&c.push(Ba.pointOn(y,this.controls));let E=g-b;E>=0&&E<=1&&c.push(Ba.pointOn(E,this.controls))}else{let u=-o/(2*a),h=Math.sqrt(o**2-4*a*l)/(2*a),d=u+h;d>=0&&d<=1&&c.push(Ba.pointOn(d,this.controls));let p=u-h;p>=0&&p<=1&&c.push(Ba.pointOn(p,this.controls))}return c}buildConverxHull(t=_e.eps){let i=[...this.controls],r=[],n=i[0],s=1;do{let a=i[s%i.length];this.eqPP(n,a,t)||r.push(new ie(n,a)),n=a,s++}while(n!==i[0]);if(r.length===0)throw Error("buildConverxHull(diff = DoubleKit.eps)");return Tt.build7(r).asClose()}getExtremePoints(t){if(!t)return a(this.controls);let i=t.start(),r=t.end(),n=r.x-i.x,s=r.y-i.y;if(Math.abs(n)<=_e.eps||Math.abs(s)<=_e.eps)return a(this.controls);{let o=s/n;if(this.controls.length===3){i.equals1(r)&&(r=i.add1(1,0));let l=r.y-i.y,c=i.x-r.x,u=-l*i.x-c*i.y,h=Math.sqrt(1/(l**2+c**2));l*=h,c*=h,u*=h;let d=this.controls.map(m=>l*m.x+c*m.y+u),p=d[0]-2*d[1]+d[2],f=d[1]-d[0]-o/2;if(p!==0){let m=-f/p;if(_e.greater(m,0)&&_e.less(m,1))return[Ba.pointOn(m,this.controls)]}}else if(this.controls.length===4)return this.getPointsBySlope(o)}return[];function a(o){let l,c;if(o.length===3){let[p,f,m]=o;l=Hb(p,f,m,"x"),c=Hb(p,f,m,"y")}else if(o.length===4){let[p,f,m,g]=o;l=jb(p,f,m,g,"x"),c=jb(p,f,m,g,"y")}l.sort((p,f)=>f-p),c.sort((p,f)=>f-p);let u=l.pop()||1,h=c.pop()||1,d=[];for(;u!==1||h!==1;)_e.eq(u,h)?(u=l.pop()||1,h=c.pop()||1):u<h?(d.push(Ba.pointOn(u,o)),u=l.pop()||1):(d.push(Ba.pointOn(h,o)),h=c.pop()||1);return d}}getToLineMaxDis2(t){let i=this.getExtremePoints(t),r=t.distance2(this.start()),n=t.distance2(this.end()),s=Math.max(r,n);return i.forEach(o=>a(t.distance2(o))),s;function a(o){s=Math.max(s,o)}}getToLineMinAndMaxDis_Controls(t){let i=t.start(),r=t.end();t.start().equals1(t.end())&&(r=i.add1(1,0));let n=r.y-i.y,s=i.x-r.x,a=-n*i.x-s*i.y,o=Math.sqrt(1/(n**2+s**2));n*=o,s*=o,a*=o;let l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;return this.controls.forEach(u=>{let h=n*u.x+s*u.y+a;h<l&&(l=h),h>c&&(c=h)}),{minDis:l,maxDis:c}}getPercentInLine(t){let i=[],r=[],n=this.controls,s=t.start(),a=t.end(),o=a.y-s.y,l=s.x-a.x,c=-o*s.x-l*s.y,u=Math.sqrt(1/(o**2+l**2));if(o*=u,l*=u,c*=u,o**2+l**2<=0)return i;if(n.length===3){let[h,d,p]=n,f=o*(h.x-2*d.x+p.x)+l*(h.y-2*d.y+p.y),m=2*(o*(d.x-h.x)+l*(d.y-h.y)),g=o*h.x+l*h.y+c;r=c7(f,m,g)}else if(n.length===4){let[h,d,p,f]=n,m=f.sub(p.mul(3)).add(d.mul(3)).sub(h),g=h.sub(d.mul(2)).add(p).mul(3),b=d.sub(h).mul(3),y=h,E=o*m.x+l*m.y,S=o*g.x+l*g.y,w=o*b.x+l*b.y,x=o*y.x+l*y.y+c,I=Math.sqrt(1/(E**2+S**2));E*=I,S*=I,w*=I,x*=I,r=u7(E,S,w,x)}else throw Error("not support getBeizerPointInLine");return r.forEach(h=>{h>=0&&h<=1&&i.push(h)}),i}reverse(){return new Ba(this.controls.slice().reverse())}},SP=class gy{constructor(){this.textCache=new Map,this.numCache=new Array(20),this.boxCache=new Array(4),this.textOffsetCache=new Array(9),this.BuildLineCache=new Array(7),this.BuildTrackCache=new Array(7),this.BuildViaCache=new Array(11),this.BuildBoxCache=new Array(10),this.BuildArcCache=new Array(10),this.BuildArcTrackCache=new Array(10),this.BuildTextCache=new Array(7),this.BuildPadStyleCache=new Array(4),this.BuildPadCache=new Array(12),this.ARRAY1=new Array(1),this.ARRAY2=new Array(2),this.ARRAY3=new Array(3),this.ARRAY4=new Array(4),this.ARRAY5=new Array(5),this.ARRAY6=new Array(6),this.ARRAY7=new Array(7),this.ARRAY8=new Array(8),this.ARRAY9=new Array(9),this.ARRAY10=new Array(10),this.ARRAY11=new Array(11),this.ARRAY12=new Array(12),this.textOffsetCache[0]=j.ORIGIN,this.textOffsetCache[1]=new j(0,-.5),this.textOffsetCache[2]=new j(0,-1),this.textOffsetCache[3]=new j(-.5,0),this.textOffsetCache[4]=new j(-.5,-.5),this.textOffsetCache[5]=new j(-.5,-1),this.textOffsetCache[6]=new j(-1,0),this.textOffsetCache[7]=new j(-1,-.5),this.textOffsetCache[8]=new j(-1,-1)}static getCache(){return gy.instance==null&&(gy.instance=new gy),gy.instance}};SP.instance=null;var wP=SP,ie=class lp extends Dy{constructor(t,i){super(),this._start=t,this._end=i}get a(){return this._a==null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._a}get b(){return this._b==null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._b}get c(){return this._c==null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._c}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}get direct(){return this._direct==null&&(this._direct=this._end.sub(this._start).normalize()),this._direct}cutLine(t){if(_e.eq(this.distance(t),0)){let i=new lp(this._start,t);return i._a=this._a,i._b=this._b,i._c=this._c,i}return new lp(this._start,t)}get midPoint(){return this._start.add(this._end).mul(.5)}toBezier(){return new Ye([this._start,this._end])}_hashCode(){let t=31,i=1;return i=t*i+this._start.hashCode(),i=t*i+this._end.hashCode(),i}start(){return this._start}end(){return this._end}center(){let t=this.start(),i=this.end();return t.add(i).mul(.5)}panDistance(t){let i=this._end.x-this._start.x,r=this._end.y-this._start.y,n=this.length();i=i*t/n,r=-r*t/n;let s=new j(this._start.x+r,this._start.y+i),a=new j(this._end.x+r,this._end.y+i);return new lp(s,a)}isPoint(){return this._start.distance2(this._end)<=1e-8}length(){return this._start.distance1(this._end)}toString(){return"Line [start="+this._start+", end="+this._end+"]"}bbox(){if(this.__bbox==null){let t=wP.getCache().boxCache;t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.__bbox=new St(t[0],t[1],t[2],t[3])}return this.__bbox}multiply3(t){return new lp(this._start.multiply3(t),this._end.multiply3(t))}hashCode(){return this.hashed}equals(t){let i=t;return this.hashed===i.hashed&&this._start.equals(i._start)&&this._end.equals(i._end)}equals1(t){let i=t;return this.hashed===i.hashed&&this._start.equals1(i._start)&&this._end.equals1(i._end)}equals2(t){let i=[this.start(),this.end()],r=[t.start(),t.end()];return pc(i,r)||pc(i,r.reverse())}stroke(t,i,r){let n,s,a;this._end.x<this._start.x?(s=this._start.x-this._end.x,a=this._start.y-this._end.y,n=this._end):(s=this._end.x-this._start.x,a=this._end.y-this._start.y,n=this._start);let o=Math.sqrt(s*s+a*a),l=t/2,c,u,h;i===2?(u=-l,h=o+l):(u=0,h=o),i===0||i===2?r===0?c=Tt.build5([u,-l,u,l,h,l,h,-l]):c=Tt.build5([u,l,u,-l,h,-l,h,l]):r===0?c=Tt.build2([Se.build3(new j(u,0),-90,-180,l,l),Se.build3(new j(h,0),90,-180,l,l)]):c=Tt.build2([Se.build3(new j(u,0),90,180,l,l),Se.build3(new j(h,0),-90,180,l,l)]);let d=Math.atan2(a,s),p=de.rotate(d).translate1(n);return c.asClose().multiply3(p)}points(t){return[this._start,this._end]}mirrorY(t){return new lp(this.start().mirrorY(t),this.end().mirrorY(t))}reverse(){return new lp(this._end,this._start)}inArea(t,i,r){let n=t.x,s=t.y,a=this._start,o=this._end,l=r==1,c=n-a.x,u=s-a.y,h=n-o.x,d=s-o.y,p=o.x-a.x,f=o.y-a.y,m=new j(-f,p).normalize(),g=p+m.x*i/2,b=f+m.y*i/2,y=g*g+b*b,E=c*c+u*u,S=h*h+d*d,w=Math.abs(c*f-u*p)/2,x=Math.sqrt(p*p+f*f)*i/4;if(w<=x&&E<=y&&S<=y){if(l)return!0;{let I=new j(n,s).sub(o).normalize(),A=new j(n,s).sub(a).normalize(),O=new j(m.x,m.y).cross(I),R=new j(m.x,m.y).cross(A);return O>=0&&R<=0}}else if(l){let I=i/2;return E<=I*I?!0:S<=I*I}else return!1}isParallel(t,i=!1){let r=_e.eq(Math.abs(this.direct.cross(t.direct)),0),n=!i||_e.greatereq(this.direct.dot(t.direct),0);return r&&n}distance2(t){return(this.a*t.x+this.b*t.y+this.c)**2/(this.a**2+this.b**2)}distance2ForPP(t){let{x:i,y:r}=t,{x:n,y:s}=this.start(),{x:a,y:o}=this.end();return((i-n)*(o-s)-(r-s)*(a-n))**2/((o-s)**2+(a-n)**2)}distance(t){return Math.abs(this.a*t.x+this.b*t.y+this.c)/Math.sqrt(this.a**2+this.b**2)}};function d7(e,t=.05){if(e.length<3)return e.slice();let i=e.slice(0,1),r=(s,a,o)=>z8(s.x,s.y,a.x,a.y,o.x,o.y);for(;;){i=e.slice(0,1);for(let s=1;s<e.length-1;s+=2)r(e[s],e[s-1],e[s+1])>t&&i.push(e[s]),i.push(e[s+1]);if(i.at(-1).equals1(e.at(-1))||i.push(e.at(-1)),e.length==i.length)break;e=i}let n=e[e.length-1];return i.push(n),i}var p7=_8(P8());function vP(e){if(e.length>2){let t=e[0],i=new Array;i.push(t);for(let r=1,n=e.length;r<n;r++){let s=e[r],a=!1;if(r+1<n){let o=s.sub(t).normalize(),l=e[r+1].sub(t).normalize(),c=o.cross(l);Math.abs(c)<.01&&(a=!0)}a||(i.push(s),t=s)}return i}else return e}var f7=class{constructor(){this.fac=new ot,this.length=0,this.box=null,this.pt=null,this.i=0}calcBBox(e){for(this.fac.clear(),this.length=e.length,this.box=null,this.pt=null,this.i=0;this.i<this.length;this.i++)this.pt=e[this.i],this.box=this.pt.bbox(),this.fac.ext1(this.box);return this.fac.build1()}},m7=new f7,Tt=class kn{constructor(t,i){this.primitives=t,this.__bbox=i}static calcBBox(t){return m7.calcBBox(t)}static build1(t){let i=[],r=null;return Gb(t,(n,s)=>{let a=s.start();return r!==null&&!a.equals(r)&&i.push(new ie(r,a)),i.push(s),r=s.end(),!0}),i.length===0&&r!=null&&i.push(new ie(r,r)),new kn(i)}static build2(t){return kn.build1(Dv(t))}static build3(t){let i=[],r=null;return Gb(t,(n,s)=>(r!==null&&i.push(new ie(r,s)),r=s,!0)),new kn(i)}static build4(t){return this.build3(Dv(t))}static build5(t){let i=[];for(let r=0;r<t.length;r+=2)i.push(new j(t[r],t[r+1]));return this.build4(i)}static build6(t){return kn.build4([t.LL(),t.LR(),t.UR(),t.UL(),t.LL()])}static build7(t){return new kn(t)}static build8(t){let i=new j(t[0],t[1]),r,n=[],s,a=(o,l)=>o.length==l&&o.every(c=>typeof c=="number");for(let o=2;o<t.length;)switch(typeof t[o]=="string"?s=t[o]:o-=1,s){case"ARC":{let l=t.slice(o+1,o+4);if(!a(l,3))throw new Error("invalid rawData");let c=l[0];r=new j(l[1],l[2]),n.push(Se.build5(i,r,c)),i=r,o+=4;break}case"L":{let l=t.slice(o+1,o+3);if(!a(l,2))throw new Error("invalid rawData");r=new j(l[0],l[1]),n.push(new ie(i,r)),i=r,o+=3;break}case"C":{let l=t.slice(o+1,o+7);if(!a(l,7))throw new Error("invalid rawData");let c=new j(l[0],l[1]),u=new j(l[2],l[3]);r=new j(l[4],l[5]),n.push(new Ye([i,c,u,r])),i=r,o+=7;break}default:throw new Error("invalid rawData")}return kn.build2(n)}static buildBBox(t,i=0){return i===1?kn.build5([t.minX,t.minY,t.maxX,t.minY,t.maxX,t.maxY,t.minX,t.maxY,t.minX,t.minY]):kn.build5([t.minX,t.minY,t.minX,t.maxY,t.maxX,t.maxY,t.maxX,t.minY,t.minX,t.minY])}static triangulate(t,i,r=1,n=!1){let s=n?(u,h)=>{u.points(r,h)}:(u,h)=>{u.points2(r,h)};if(t.length===1){let u=new Array;s(t[0].asClose(),f=>u.push(f));let h,d=u[0],p=[];for(let f=0;f<u.length-2;f+=2){let m=u[f+1],g=u[f+2],b=m.sub(d).normalize().cross(g.sub(d).normalize());if(_e.neq(b,0)){if(h===!0){if(b<0){p.length=0;break}}else if(h===!1){if(b>0){p.length=0;break}}else h=b>0;p.push(d),p.push(m),p.push(g)}u.push(d),d=g}if(p.length!==0){for(let f=0;f<p.length;f+=3)i(p[f],p[f+1],p[f+2]);return}}let a=[],o=[];t.forEach(u=>{a.length!==0&&o.push(a.length/2),s(u.asClose(),h=>a.push(h.x,h.y))});let l=p7.default(a,o),c=[];for(let u=1;u<a.length;u+=2)c.push(new j(a[u-1],a[u]));for(let u=0;u<l.length;u+=3)i(c[l[u]],c[l[u+1]],c[l[u+2]])}lines(t,i){let r=new Array;this.points(t,s=>r.push(s));let n=r[0];for(let s=1;s<r.length;s++){let a=r[s];i(n),i(a),n=a}}triangles(t,i,r=!1){kn.triangulate([this],(...n)=>{n.forEach(s=>i(s))},t,r)}mirror(){let t=[];return this.primitives.forEach(i=>{if(i instanceof ie)i=new ie(i.start().mirror(),i.end().mirror());else if(i instanceof Se)i=i.mirror();else if(i instanceof Ye){let r=i.controls.map(n=>n.mirror());i=new Ye(r)}else throw new Error("bug");t.push(i)}),new kn(t,this.__bbox)}getPoints(t){let i=[];for(let r of this.primitives)for(let n of r.points(t))i.push(n);return i}round(t=4){let i=this.primitives.slice();for(let r=0;r<i.length;r++){let n=i[r];if(n instanceof ie){let s=n.start().round(t),a=n.end().round(t);i[r]=new ie(s,a)}else if(n instanceof Ye){let s=n.controls.map(a=>a.round(t));i[r]=new Ye(s)}else if(n instanceof Se){let s=n.start().round(t),a=n.end().round(t),o=n.sweepAngle;i[r]=Se.build5(s,a,o)}}return new kn(i,this.__bbox)}simplify(t=.05){let i=[],r=!1,n=[],s=this.closed();if(this.primitives.length<=1)return kn.build2(this.primitives);let a=()=>{if(n.length>2){let l=d7(n,t);for(let c=1;c<l.length;c++)i.push(new ie(l[c-1],l[c]))}else i.push(new ie(n[0],n[1]));n.length=0,r=!1};for(let l=0;l<this.primitives.length;l++){let c=this.primitives[l];c instanceof ie?(r?n.push(c.end()):(n.length=0,n.push(c.start(),c.end()),r=!0),l===this.primitives.length-1&&a()):(r&&a(),i.push(c))}let o=new kn(i,this.__bbox);return s&&!o.closed()&&(o=o.asClose()),o}hasBackLine(){let{primitives:t}=this,i;for(let r=0;r<t.length;r++){let n=t[r];if(n instanceof ie){if(n.end().equals1(n.start()))continue;if(i&&(n.end().equals1(i.start())||X8(n.end(),i.start(),i.end())))return!0;i=n}else i=null}return!1}area(t=.1){let i=0,r=this.end();return this.primitives.forEach(n=>{let s=n.start(),a=n.end();if(i+=(s.x+r.x)*(s.y-r.y),n instanceof ie)i+=(a.x+s.x)*(a.y-s.y);else if(n instanceof Se)i+=(a.x+s.x)*(a.y-s.y),i+=Math.PI*n.rx2*n.sweepAngle/180-j.normal(n.center,n.start(),n.end());else if(n instanceof Ye){let o=s;n.points(t).forEach(l=>{i+=(l.x+o.x)*(l.y-o.y),o=l}),i+=(a.x+o.x)*(a.y-o.y)}r=a}),i/2}closed(t){return this.primitives.length===0?!1:this.start().equals(this.end(),t)}asClose(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),n=i.end();if(r.equals(n))return this;{let s=new Array;return fa.addAll(s,this.primitives),s.push(new ie(n,r)),kn.build2(s)}}closeEndpoint(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),n=i.end();if(r.equals1(n))return this;{let s=new Array;return fa.addAll(s,this.primitives),s.push(new ie(n,r)),new kn(s)}}reverse(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let n=this.primitives[r];if(n instanceof ie)n=new ie(n.end(),n.start());else if(n instanceof Se)n=n.exchangeSweep();else if(n instanceof Ye)n=new Ye(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new kn(t,this.__bbox)}reverse1(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let n=this.primitives[r];if(n instanceof ie)n=new ie(n.end(),n.start());else if(n instanceof Se)n=n.exchangeSweep1();else if(n instanceof Ye)n=new Ye(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new kn(t,this.__bbox)}mirrorY(t){let i=[];return this.primitives.forEach(r=>{if(r instanceof ie)r=r.mirrorY(t);else if(r instanceof Se)r=r.mirrorY(t);else if(r instanceof Ye){let n=r.controls.map(s=>s.mirrorY(t));r=new Ye(n)}else throw new Error("bug");i.push(r)}),new kn(i,this.__bbox)}points(t,i){if(this.primitives.length!==0){for(let r=0;r<this.primitives.length-1;r++){let n=this.primitives[r].points(t);n.pop(),n.forEach(s=>i(s))}this.primitives[this.primitives.length-1].points(t).forEach(r=>i(r))}}points1(t,i){if(this.primitives.length===0)return;for(let n=0;n<this.primitives.length-1;n++){let s=this.primitives[n],a=s instanceof Se?s.points1(t):s.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Se?r.points1(t):r.points(t)).forEach(n=>i(n))}points2(t,i){if(this.primitives.length===0)return;for(let n=0;n<this.primitives.length-1;n++){let s=this.primitives[n],a=s instanceof Se?s.points2():s.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Se?r.points2():r.points(t)).forEach(n=>i(n))}multiply3(t){let i=new Array(this.primitives.length);for(let r=0;r<this.primitives.length;r++)i[r]=this.primitives[r].multiply3(t);return kn.build7(i)}bbox(){return this.__bbox==null&&(this.__bbox=kn.calcBBox(this.primitives)),this.__bbox}start(){return this.primitives.length!==0?this.primitives[0].start():null}end(){return this.primitives.length!==0?this.primitives[this.primitives.length-1].end():null}isClose(t){if(this.primitives.length<=1&&!(this.primitives[0]instanceof Se))return!1;{let i=this.primitives[0],r=this.primitives[this.primitives.length-1];return i.start().equals(r.end(),t)}}isEqual(t){if(t instanceof kn&&t.primitives.length==this.primitives.length){let i=t.primitives.length;for(let r=0;r<i;r++){let n=t.primitives[r],s=this.primitives[r];if(JSON.stringify(n)!=JSON.stringify(s))return!1}return!0}return!1}equals(t){if(!t)return!1;let i=this.primitives,r=t.primitives;if(i.length!=r.length)return!1;if(t.isClose()){let n=0;for(;n<i.length;){let s=i.slice(n).concat(i.slice(0,n));if(pc(s,r)||pc(s.reverse(),r))return!0;n++}return!1}else return pc(this.primitives,t.primitives)}clone(){return kn.build2(this.primitives)}putItem(t,i){if(!t)return!1;if(t instanceof kn)return this.mergePolyline(t,i);let r=this.start();if(!r){this.primitives.push(t),this.__bbox=t.bbox();return}let n=this.end();if(r.equals(n,i))return!1;let s=t.start(),a=t.end(),o=!1,l=!1;if(r.equals(s,i))o=!0,l=!1;else if(r.equals(a,i))o=!1,l=!1;else if(n.equals(s,i))o=!1,l=!0;else if(n.equals(a,i))o=!0,l=!0;else return!1;return l?this.primitives.push(o?t.reverse():t):this.primitives.unshift(o?t.reverse():t),this.__bbox=St.extend2(this.__bbox,t.bbox()),!0}mergePolyline(t,i,r=0){if(!t)return!1;let n=this.start();if(!n){this.primitives.push(...t.primitives),this.__bbox=t.bbox();return}let s=this.end();if(n.equals(s,i))return!1;let a=t.start(),o=t.end(),l=!1,c=!1;if(n.equals(a,i))l=!0,c=!1;else if(n.equals(o,i))l=!1,c=!1;else if(s.equals(a,i))l=!1,c=!0;else if(s.equals(o,i))l=!0,c=!0;else return!1;let u=l?t.reverse():t;return c?this.primitives.push(...u.primitives):this.primitives.unshift(...u.primitives),this.__bbox=St.extend2(this.__bbox,t.bbox()),!0}deDuplicationPoint(t){let i=this.primitives[this.primitives.length-1].start(),r=this.primitives[this.primitives.length-1].end(),n=t.primitives[0].start(),s=t.primitives[0].end();if(this.primitives[this.primitives.length-1]instanceof ie&&t.primitives[0]instanceof ie&&Q8([i,r],[n,s])){this.primitives.pop(),t.primitives.shift();let a=[];a.push(new ie(i,s)),this.primitives.push(...a)}}getMaxBBoxHeightByVec(t){let i=t.normalize(),r=-1/0,n=1/0;if(this.primitives.forEach(a=>{let o=a.start().dot(i),l=a.end().dot(i);if(s(o),s(l),a instanceof Se){let c=t.angleD(j.ORIGIN);if(a.angleIsInArc(c)){let u=a.pointOn(c).dot(i);s(u)}if(a.angleIsInArc(c+180)){let u=a.pointOn(c-180).dot(i);s(u)}}}),r-n<=0)throw new Error("getMaxBBoxHeightByVec");return r-n;function s(a){a>r&&(r=a),a<n&&(n=a)}}getWindingNum(t){let i=this.end(),r=0,{x:n,y:s}=t;for(let o of this.primitives){if(i.y>s?o.bbox().minY>s:o.bbox().maxY<=s){i=o.end();continue}if(o instanceof Se&&(o.isCCW?Math.floor(o.startAngle/90)+1!==Math.ceil(o.endAngle()/90):Math.ceil(o.startAngle/90)-1!==Math.floor(o.endAngle()/90))){let l=o.startAngle,c=o.endAngle();if(o.sweepAngle>0){let u=90;for(;u<=c;)u>l&&(a(Se.build3(o.center,l,u-l,o.rx,o.ry)),l=u),u+=90;l<c&&a(Se.build3(o.center,l,c-l,o.rx,o.ry))}else{let u=270;for(;u>=c;)u<l&&(a(Se.build3(o.center,l,u-l,o.rx,o.ry)),l=u),u-=90;l>c&&a(Se.build3(o.center,l,c-l,o.rx,o.ry))}}else if(o instanceof Ye){let l=[];Qb(o,l),l.forEach(c=>a(c))}else a(o)}return r;function a(o){let l=o.start(),c=o.end();if(i.y>s!=l.y>s&&(i.x>n?l.x>n?r+=l.y>i.y?1:-1:i.y>l.y?(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)<0&&r--:(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)>0&&r++:l.x>n&&(i.y>l.y?(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)<0&&r--:(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)>0&&r++)),l.y>s!=c.y>s){if(l.x>n)if(c.x>n)r+=c.y>l.y?1:-1;else if(o instanceof ie)l.y>c.y?(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)<0&&r--:(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)>0&&r++;else if(o instanceof Se){let{center:u,isCCW:h,rx2:d}=o,p=(u.x-n)**2+(u.y-s)**2;l.y>c.y?(h?p>d:p<d)&&r--:(h?p<d:p>d)&&r++}else if(o instanceof Ye){if(W_(o,s)===0)throw new Error("no inters");se[0]>n&&(r+=c.y>l.y?1:-1)}else throw new Error("not support!");else if(c.x>n)if(o instanceof ie)l.y>c.y?(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)<0&&r--:(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)>0&&r++;else if(o instanceof Se){let{center:u,isCCW:h,rx2:d}=o,p=(u.x-n)**2+(u.y-s)**2;l.y>c.y?(h?p>d:p<d)&&r--:(h?p<d:p>d)&&r++}else if(o instanceof Ye){if(W_(o,s)===0)throw new Error("no inters");se[0]>n&&(r+=c.y>l.y?1:-1)}else throw new Error("not support!")}i=c}}},Tb=Math.PI*2,Die=Math.PI/2,_ie=Math.sin(Math.PI/180),g7=4,Se=class gr extends Dy{constructor(t,i,r,n,s){super(),this.rx=t,this.ry=i,this.center=r,this.startAngle=n,this.sweepAngle=s,this._start=j.ORIGIN,this._end=j.ORIGIN,this._start=this.pointOn(n),this._end=this.pointOn(n+s)}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}hashCode(){return this.hashed}_hashCode(){let t=31,i=1;return i=t*i+new j(this.rx,this.rx).hashCode(),i=t*i+this.center.hashCode(),i=t*i+new j(this.startAngle,this.sweepAngle).hashCode(),i}get rx2(){return this._rx2==null&&(this._rx2=this.rx*this.rx),this._rx2}get ry2(){return this._ry2==null&&(this._ry2=this.ry*this.ry),this._ry2}get svgEnd(){return this._svgEnd==null&&(this._svgEnd=this.getSvgEnd(this.startAngle,this.sweepAngle,this._start,this._end)),this._svgEnd}getSvgEnd(t,i,r,n){let s=i>=0?-.01:.01,a=t+i;for(;(i>=0&&a>t||i<0&&a<t)&&r.distance2(n)<2e-4;)s*=2,a+=s,n=this.pointOn(a);return n}static build1(t,i,r,n,s,a){tn.positive(r),tn.positive(n);let o=t.equals(i);if(o)return new gr(r,n,t,0,s?360:0);{let l=t.x,c=-t.y,u=i.x,h=-i.y,d=a===0,p=(l-u)/2,f=(c-h)/2,m=Math.cos(0),g=Math.sin(0),b=m*p+g*f,y=-g*p+m*f;r=Math.abs(r),n=Math.abs(n);let E=r*r,S=n*n,w=b*b,x=y*y,I=s===d?-1:1,A=(E*S-E*x-S*w)/(E*x+S*w);A=A<0?0:A;let O=I*Math.sqrt(A),R=O*(r*y/n),M=O*-(n*b/r),F=(l+u)/2,G=(c+h)/2,V=F+(m*R-g*M),q=G+(g*R+m*M),C=(b-R)/r,N=(y-M)/n,T=(-b-R)/r,L=(-y-M)/n,P,B;B=Math.sqrt(C*C+N*N),P=C,I=N<0?-1:1;let U=Qt.toDegrees(I*Math.acos(P/B));B=Math.sqrt((C*C+N*N)*(T*T+L*L)),P=C*T+N*L,I=C*L-N*T<0?-1:1;let X=P/B,J;X<-1?J=Math.acos(-1):X>1?J=Math.acos(1):J=Math.acos(X);let ne=Qt.toDegrees(I*J);!d&&ne>0?ne-=360:d&&ne<0&&(ne+=360),tn.normal(U),tn.normal(ne);let fe=p*p/E+f*f/S,xe=t.distance1(i)/2;r<xe&&n<xe&&(r*=Math.sqrt(fe),n*=Math.sqrt(fe));let ve=o?0:Qt.regularD(-U),Fe=o?s?360:0:-ne;return new gr(r,n,new j(V,-q),ve,Fe)}}static build2(t,i,r,n,s,a){tn.positive(n),tn.positive(s),tn.normal(i),tn.normal(r);let o;return i===r?(i=Qt.regularD(i),r=Qt.regularD(r),o=0):(i=Qt.regularD(i),r=Qt.regularD(r),a===1?r<=i&&(r+=360):r>=i&&(i+=360),o=r-i),new gr(n,s,t,Qt.regularD(i),o)}static build3(t,i,r,n,s){return tn.positive(n),tn.positive(s),tn.normal(r),new gr(n,s,t,Qt.regularD(i),r)}static build4(t,i,r,n,s,a){let o=t.angleD(r),l=i.angleD(r);return gr.build2(r,o,l,n,s,a)}static build5(t,i,r){r=Qt.toRadians(r);let n=i.sub(t),s=new j(-n.y,n.x).normalize(),a=Math.abs(r)/2,o;if(a!=0)o=n.length()/2/Math.sin(a);else throw new Error("Can't represent circle!!!");let l=s.rotate(j.ORIGIN,a),c,u;r>0?(c=1,u=i.add(l.scale(o))):(c=0,u=t.sub(l.scale(o)));let h=Qt.toDegrees(t.angle(u)),d=Qt.toDegrees(i.angle(u));return gr.build2(u,h,d,o,o,c)}static buildCircle(t,i,r=0){return gr.build2(t,0,360,i,i,r)}start(){return this._start}end(){return this._end}isLarge(){return Math.abs(this.sweepAngle)>180}sweep(){return this.sweepAngle>=0?1:0}get isCCW(){return this.sweepAngle>=0}endAngle(){return this.startAngle+this.sweepAngle}pointOn(t){t=Qt.regularD(t);let i=this.rx,r=this.ry;if(t===0)return this.center.add1(i,0);if(t===90)return this.center.add1(0,r);if(t===180)return this.center.add1(-i,0);if(t===270)return this.center.add1(0,-r);{let n=this.rx2,s=this.ry2,a=Math.tan(Qt.toRadians(t)),o=a*a,l=Math.sqrt(n*s/(n+s/o)),c=Math.sqrt(n*s/(s+n*o));return t>90&&t<270&&(c=-c),t>180&&t<360&&(l=-l),isNaN(c)&&(c=0),isNaN(l)&&(l=0),this.center.add1(c,l)}}exchangeSweep(){return gr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,this.rx,this.ry)}exchangeSweepAndStart(){return gr.build1(this.end(),this.start(),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}exchangeSweep1(){return gr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle+.01,this.rx,this.ry)}mirrorY(t){let i=this.start(),r=this.end();return i.equals(r)?gr.build3(this.center.mirrorY(),0,360,this.rx,this.ry):gr.build1(i.mirrorY(t),r.mirrorY(t),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}mirror(t=j.ORIGIN){let i=this.start(),r=this.end();return i.equals(r)?gr.build3(this.center.mirror(t),0,360,this.rx,this.ry):gr.build1(i.mirror(t),r.mirror(t),this.rx,this.ry,this.isLarge(),this.sweep())}sectorArea(){return Math.abs(this.sweepAngle)/360*Math.PI*this.rx*this.ry}area(){let t=Vf.area(this.center,this._start,this.pointOn(this.endAngle()));return this.sectorArea()-t}multiply3(t){let i;t.isMirrored()?i=-this.sweepAngle:i=this.sweepAngle;let r;return t.equals(de.ROT_90)?r=Qt.regularD(this.startAngle+90):t.equals(de.ROT_N90)?r=Qt.regularD(this.startAngle-90):r=Qt.transformD(this.startAngle,t),gr.build3(this.center.multiply3(t),r,i,t.iScale*this.rx,t.iScale*this.ry)}angleIsInArc(t){return t=Qt.regularD(t),this.sweepAngle>0?(t<this.startAngle&&(t+=360),this.endAngle()>t):(t>this.startAngle&&(t-=360),this.endAngle()<t)}toBezier(){if(Math.abs(this.sweepAngle)>90)throw new Error("not support!");let t=this.start(),i=this.end(),r=Qt.toRadians(this.sweepAngle)/2,n=4/3*(1-Math.cos(r))/Math.sin(r)*this.rx;return new Ye([t,t.add(new j(n,0).multiply3(de.rotateD(this.startAngle+90))),i.add(new j(n,0).multiply3(de.rotateD(this.endAngle()-90))),i])}toBezier2(){let t=[];r(this,90);let i=[];return t.forEach(n=>i.push(n.toBezier())),i;function r(n,s){if(Math.abs(n.sweepAngle)>s){let a=n.sweepAngle/2;r(gr.build3(n.center,n.startAngle,a,n.rx,n.ry),s),r(gr.build3(n.center,n.startAngle+a,a,n.rx,n.ry),s)}else t.push(n)}}buildBBox(){let t=wP.getCache().boxCache,i=this.startAngle+this.sweepAngle;if(t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.sweepAngle>0){let r=0;for(;r<i;){if(r>this.startAngle){let n=this.pointOn(r);t[0]=Math.min(t[0],n.x),t[1]=Math.max(t[1],n.x),t[2]=Math.min(t[2],n.y),t[3]=Math.max(t[3],n.y)}r+=90}}else if(this.sweepAngle<0){let r=360;for(;r>i;){if(r<this.startAngle){let n=this.pointOn(r);t[0]=Math.min(t[0],n.x),t[1]=Math.max(t[1],n.x),t[2]=Math.min(t[2],n.y),t[3]=Math.max(t[3],n.y)}r-=90}}return new St(t[0],t[1],t[2],t[3])}bbox(){return this.__bbox==null&&(this.__bbox=this.buildBBox()),this.__bbox}length(){return Math.abs(this.rx*this.sweepAngle*Math.PI/180)}toString(){return Ff.format("Arc [start=%s, end=%s, rx=%s, ry=%s, center=%s, startAngle=%s, sweepAngle=%s]",this._start,this._end,this.rx,this.ry,this.center,this.startAngle,this.sweepAngle)}stroke(t,i,r){let n=t/2,s=this.rx+n,a=this.ry+n,o=this.rx-n,l=this.ry-n,c=new de;o<0&&(o=-o,c=c.multiply3(de.MIRROR_Y)),l<0&&(l=-l,c=c.multiply3(de.MIRROR_X)),o===0&&(o=.001),l===0&&(l=.001),c=c.setOrigin1(this.center);let u,h;switch(r===this.sweep()?(u=gr.build3(this.center,this.startAngle,this.sweepAngle,s,a),h=gr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,o,l)):(u=gr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,s,a),h=gr.build3(this.center,this.startAngle,this.sweepAngle,o,l)),h=h.multiply3(c),i){case 1:{let d=r===1?180:-180,p=r===this.sweep()?this.pointOn(this.endAngle()):this.pointOn(this.startAngle),f=r===this.sweep()?this.pointOn(this.startAngle):this.pointOn(this.endAngle()),m=u.pointOn(u.endAngle()).angleD(p),g=h.pointOn(h.endAngle()).angleD(f);return Tt.build2([u,gr.build3(p,m,d,n,n),h,gr.build3(f,g,d,n,n)])}default:return Tt.build2([u,h])}}points2(){let t=Math.ceil(Math.abs(this.sweepAngle)/g7),i=this.sweepAngle/t,r=[this._start];for(let n=1;n<t;n++)r.push(this.pointOn(this.startAngle+i*n));return r.push(this._end),r}points1(t){let i=Math.max(this.rx,this.ry);if(i<=t)return[this.start(),this.svgEnd];let r=(i-t)/i,n=Math.ceil(Math.abs(this.sweepAngle/Qt.toDegrees(Math.acos(r))/2)),s=new Array(n+1),a=this.sweepAngle/n,o=this.startAngle;for(let l=0;l<=n;l++,o+=a)s[l]=this.pointOn(o);return s}points(t){let i=Math.max(this.rx,this.ry);if(t=Math.abs(t),i<=t)return[this.start(),this.svgEnd];t=Math.max(t,i*1e-5),t=Math.min(t,i*(1-Math.SQRT1_2));let r=(i-t)/i,n=Math.ceil(Math.abs(this.sweepAngle/Qt.toDegrees(Math.acos(r))/2));n=Math.max(n,2);let s=new Array(n+1),a=this.sweepAngle/n,o=this.startAngle+a;s[0]=this.start();for(let l=1;l<n;l++,o+=a)s[l]=this.pointOn(o);return s[n]=this.end(),s}panDistance(t){return this.sweepAngle>0?new gr(this.rx-t,this.ry-t,this.center,this.startAngle,this.sweepAngle):new gr(this.rx+t,this.ry+t,this.center,this.startAngle,this.sweepAngle)}panDistance1(t){if(this.sweepAngle>0){let i=this.rx-t;return i<0?(i=Math.abs(i),gr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new gr(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;return i<0?(i=Math.abs(i),gr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new gr(i,i,this.center,this.startAngle,this.sweepAngle)}}get bulge(){let t=Math.abs(H8(this.sweepAngle,3))/180*Math.PI;return Math.tan(t/4)}get midPoint(){let t=Qt.toRadians(this.startAngle),i=Qt.toRadians(this.endAngle()),r=this.sweep(),n=this.center,s=this.rx;if(r==1)if(i>t){let a=(i-t)/2+t;return n.add(new j(Math.cos(a),Math.sin(a)).mul(s))}else{if(i==t)return n.add(new j(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(s));{let a=(i+Tb-t)/2+t;return n.add(new j(Math.cos(a),Math.sin(a)).mul(s))}}else if(i>t){let a=(t+Tb-i)/2+i;return n.add(new j(Math.cos(a),Math.sin(a)).mul(s))}else{if(i==t)return n.add(new j(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(s));{let a=(t-i)/2+i;return n.add(new j(Math.cos(a),Math.sin(a)).mul(s))}}}get svgPathData(){return[{type:"M",values:[this._start.x,this._start.y]},{type:"A",values:[this.rx,this.ry,0,this.isLarge()?1:0,this.isCCW,this._end.x,this._end.y]}]}equals(t){let i=Qt.regularD(this.startAngle),r=Qt.regularD(this.sweepAngle),n=Qt.regularD(t.startAngle),s=Qt.regularD(t.sweepAngle);return pc([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(pc([r,i],[s,n])||pc([Qt.regularD(i+r)],[n]))}equals1(t){let i=Qt.regularD(this.startAngle),r=Qt.regularD(this.sweepAngle),n=Qt.regularD(t.startAngle),s=Qt.regularD(t.sweepAngle);return pc([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(pc([r,i],[s,n])||pc([Qt.regularD(i+r)],[n]))}inArea(t,i){let r=t.x,n=t.y,s=this.center,a=this.rx,o=Qt.toRadians(this.startAngle);this.sweep()==0&&(o=Qt.toRadians(this.endAngle()));let l=Qt.toRadians(this.endAngle());this.sweep()==0&&(l=Qt.toRadians(this.startAngle));let c=a-i/2,u=a+i/2;var h=r-s.x,d=n-s.y,p=Math.atan2(d,h);if(p<0&&(p+=Tb),o<=l&&p>=o&&p<=l||o>l&&(p>=o&&p<=Tb||p>=0&&p<=l)||o==l){var f=Math.sqrt(h*h+d*d);return f<=u&&f>=c}else{var f=(u+c)/2,m=new j(s.x+Math.cos(o)*f,s.y+Math.sin(o)*f),g=new j(s.x+Math.cos(l)*f,s.y+Math.sin(l)*f),b=r-m.x,y=n-m.y,E=r-g.x,S=n-g.y;return b*b+y*y<=i*i/4?!0:E*E+S*S<=i*i/4}}isCircle(){return(_e.eq(Math.abs(this.sweepAngle),360)||this._start.equals1(this._end))&&this.rx==this.ry}reverse(){return gr.build3(this.center,this.endAngle(),-this.sweepAngle,this.rx,this.ry)}getAngle(){let t=Math.PI*2;return this.sweep()==1?(this.endAngle()-this.startAngle+t)%t:(this.startAngle-this.endAngle()+t)%t}isValid(){return this.rx>0&&this.ry>0}panDistance2(t){if(this.sweepAngle>0){let i=this.rx-t;if(i===0)return new ie(this.center,this.center);if(i<_e.eps){i=Math.abs(i);let r=gr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i);return r.area()<1e-5?new ie(r.start(),r.end()):r}return new gr(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;if(i===0)return new ie(this.center,this.center);if(i<_e.eps){i=Math.abs(i);let r=gr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i);return r.area()<1e-5?new ie(r.start(),r.end()):r}return new gr(i,i,this.center,this.startAngle,this.sweepAngle)}}},TP=new ArrayBuffer(24),hv=new Float64Array(TP),Df=new Int32Array(TP),Xh=class hc{static normal(t,i,r){let n=i.sub(t),s=r.sub(i);return n.cross(s)}static random(){return new hc(t(),t(),t()).normalize();function t(){return Math.sqrt(-2*Math.log(Math.random()))*Math.cos(2*Math.PI*Math.random())}}constructor(t,i,r){this.x=tn.normal(t),this.y=tn.normal(i),this.z=tn.normal(r),hv[0]=t,hv[1]=i,hv[2]=r,this.hashed=Df[0]^Df[1]^Df[2]^Df[3]^Df[4]^Df[5]}isNormalized(){return _e.eq(this.length(),1)}isZeroVector(){return this.x===0&&this.y===0&&this.z===0}hashCode(){return this.hashed}equals(t){return t instanceof hc?t.x===this.x&&t.y===this.y&&t.z===this.z:!1}cross(t){return new hc(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x)}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){var t=this.length();return new hc(this.x/t,this.y/t,this.z/t)}sub(t){return new hc(this.x-t.x,this.y-t.y,this.z-t.z)}add(t){return new hc(this.x+t.x,this.y+t.y,this.z+t.z)}scale(t){return new hc(this.x*t,this.y*t,this.z*t)}neg(){return new hc(-this.x,-this.y,-this.z)}multiply4(t){var i=this.x*t.data[0]+this.y*t.data[4]+this.z*t.data[8]+t.data[12],r=this.x*t.data[1]+this.y*t.data[5]+this.z*t.data[9]+t.data[13],n=this.x*t.data[2]+this.y*t.data[6]+this.z*t.data[10]+t.data[14],s=this.x*t.data[3]+this.y*t.data[7]+this.z*t.data[11]+t.data[15];return s!=0?new hc(i/s,r/s,n/s):new hc(i,r,n)}rotate(t,i){return this.multiply4(yP.rotateAxis(t,i))}toVector2(){return new j(this.x,this.y)}};Xh.ORIGIN=new Xh(0,0,0),Xh.X_UNIT_VECTOR=new Xh(1,0,0),Xh.Y_UNIT_VECTOR=new Xh(0,1,0),Xh.Z_UNIT_VECTOR=new Xh(0,0,1);var wr=class Rf{static build(t){return t instanceof Tt?new Rf([new rn([t])]):t instanceof rn?new Rf([t]):t}static buildByPolygon(t){return t?new Rf([t]):new Rf([])}static buildByStroke(t,i,r=1,n){return this.buildByPolygon(rn.buildByStroke(t,i,r,Yv,n))}static buildCircle(t,i){return this.buildByPolygon(rn.buildCircle(t,i))}static buildRect(t){return this.buildByPolygon(rn.buildRect(t))}static buildBBox(t){return this.buildByPolygon(rn.buildBBox(t))}constructor(t){this.items=t.slice()}multiply3(t){return new Rf(this.items.map(i=>i.multiply3(t)))}bbox(){return this._bbox||(this._bbox=this.items.reduce((t,i)=>t.ext1(i.bbox()),new ot).build1()),this._bbox}toPolylineGroups(){return this.items.map(t=>t.toPolylineGroup())}},Gs=class Tl{static isHexFormate(t){return!t||typeof t!="string"?!1:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}static of1(t){return this.of2(t>>16&255,t>>8&255,t&255)}static of2(t,i,r,n=255){return new Tl(t/255,i/255,r/255,n/255)}static of3(t){t.startsWith("#")&&(t=t.substr(1));let i=t.length;if(i==3)return new Tl(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15);if(i==6)return new Tl(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255);if(i==8)return new Tl(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255,parseInt(t.substr(6,2),16)/255);throw new Error("invalid color string")}static of4(t){let i=parseInt(t.r*255+"").toString(16),r=parseInt(t.g*255+"").toString(16),n=parseInt(t.b*255+"").toString(16);return i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),n.length<2&&(n="0"+n),("#"+i+r+n).toUpperCase()}static of5(t,i){if(t.startsWith("#")&&(t=t.substr(1)),t.length==3)return new Tl(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15,i);if(t.length==6)return new Tl(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255,i);throw new Error("invalid color string")}static of6(t,i){return new Tl(t.r,t.g,t.b,i)}static of7(t){return t==null?null:Tl.of3(t)}constructor(t,i,r,n=1){this.r=tn.positiveOr0(t),this.g=tn.positiveOr0(i),this.b=tn.positiveOr0(r),this.alpha=n}hashCode(){return this.r+this.g+this.b+this.alpha}equals(t,i=!1){let r=this.r===t.r&&this.g===t.g&&this.b===t.b;return i?r:r&&this.alpha===t.alpha}add(t,i,r,n){return new Tl(Math.max(0,Math.min(1,this.r+t)),Math.max(0,Math.min(1,this.g+i)),Math.max(0,Math.min(1,this.b+r)),Math.max(0,Math.min(1,this.alpha+n)))}mul(t){return new Tl(Math.max(0,Math.min(1,this.r*t)),Math.max(0,Math.min(1,this.g*t)),Math.max(0,Math.min(1,this.b*t)),this.alpha)}mul1(t){return new Tl(Math.max(0,this.r*t),Math.max(0,this.g*t),Math.max(0,this.b*t),this.alpha)}getData(){return[this.r,this.g,this.b,this.alpha]}toString(){let t=(this.r*255).toString(16),i=(this.g*255).toString(16),r=(this.b*255).toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),"#"+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)}toString1(){let t=(this.r*255).toString(16),i=(this.g*255).toString(16),r=(this.b*255).toString(16),n=(this.alpha*255).toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),n.length<2&&(n="0"+n),"#"+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)+n.substr(0,2)}toRGBA(){let t=this.r*255,i=this.g*255,r=this.b*255;return[t,i,r,this.alpha]}toRGBAString(){let t=this.r*255,i=this.g*255,r=this.b*255;return`rgba(${t},${i},${r},${this.alpha})`}isWHITE(){return this.r===1&&this.g===1&&this.b===1&&this.alpha===1}};Gs.WHITE=new Gs(1,1,1,1),Gs.BLACK=new Gs(0,0,0,1),Gs.RED=new Gs(1,0,0,1),Gs.GREEN=new Gs(0,1,0,1),Gs.BLUE=new Gs(0,0,1,1),Gs.Gray=Gs.of3("#9966ff"),Gs.Silver=Gs.of3("#D2D2D2"),Gs.Golden=Gs.of3("#DCAA14"),Gs.Pink=Gs.of3("#ffaec9");var Hi=Gs,eP=!1,IP=class{onRTreeBBox(e){}onResultSide(e){}onOriginSide(e){}onSplitedSide(e){}onDebugSide(e){}onSweep(e,t,i,r,n,s){}onIntersect(e,t,i){}onSegment(e,t,i,r,n,s){}onSegment1(e,t,i){if(eP){let r=new j(e.getX(i),i),n=new j(t.getX(i),i);this.onSegment(r,e.weight,e,n,t.weight,t)}else this.onSegment(e.start,e.weight,e,t.end,t.weight,t)}onSweep1(e,t,i){if(eP){let r=new j(e.getX(i),i),n=new j(t.getX(i),i);this.onSweep(r,e.weight,e,n,t.weight,t)}else this.onSweep(e.start,e.weight,e,t.end,t.weight,t)}},vy=class extends IP{constructor(e){super(),this.plGrps=new Array,this.debug=e}onPolylineGroup(e,t){this.plGrps.push(e)}},_y=class{constructor(e){this.cache={},this.levels=e,this.result=new Array(e),this.weights=new Array(e),this.maxIdx=e-1,this.rule=this.decide.bind(this);let t=1;for(let i=0;i<e;i++)this.weights[i]=t,t*=50}weight(e){return this.weights[e]}decide(e){e=Math.abs(e);let t=this.cache[e];if(t===void 0){let i=e;for(let r=this.maxIdx;r>=0;r--){let n=this.weights[r],s=e/n|0,a=e%n;a>(n/2|0)?(e=n-a,s++):e=a,this.result[r]=s>0}t=this.decide1(this.result),this.cache[i]=t}return t}},y7=e=>e!==0;var b7=new class extends _y{decide1(e){return e[0]||e[1]}}(2),Mb=new class extends _y{decide1(e){return e[0]&&!e[1]}}(2),Bb=new class extends _y{decide1(e){return e[0]&&e[1]}}(2),dv=new class extends _y{decide1(e){return e[0]&&!e[1]||!e[0]&&e[1]}}(2),Hf=class Nf{constructor(t,i,r,n,s,a,o){this.inters=[],this.connect=new Array,this.previous=null,this.next=null,this.finalGrp=-1,this.trans=NaN,this.outsideWeight=0,this.insideWeight=0,this.invalidWeight=0,this._confidence=0,this._confidence_y=NaN,this._x=NaN,this._x_y=NaN,this.status=0,this.bo=t,this.shape=i,this.baseWeight=r,n.y>s.y?this.weight=-r:n.y==s.y?this.weight=0:this.weight=r,this.start=n,this.end=s,this.polyGrp=a,this.polyIndex=o,this._bbox=new ot().ext1(i.bbox()).ext2(n).ext2(s).build1(),this.inters.push(n),this.inters.push(s);let l=31,c=1;c=l*c+this.polyGrp,c=l*c+this.polyIndex,this._hashcode=c}static rebuild(t,i,r){if(t instanceof ie||i.distance2(r)<1e-6)return new ie(i,r);if(t instanceof Se){let n=t,s=t.bbox().center().x,a;i.y>r.y?a=s>n.center.x?0:1:a=s>n.center.x?1:0;let o=i.angleD(n.center),l=r.angleD(n.center);return Se.build2(n.center,o,l,n.rx,n.ry,a)}else throw new Error("not supported operation")}updateBbox(){this._bbox=new ot().ext2(this.start).ext2(this.end).build1()}is(t,i){return t===this.polyGrp&&i===this.polyIndex}confidence(t){if(this._confidence_y!=t){let i=this._bbox.height();if(i!==0)if(Math.abs(t-this._bbox.maxY)>5e-4&&Math.abs(t-this._bbox.minY)>5e-4){let r=1-Math.abs(2*t-this._bbox.maxY-this._bbox.minY)/i;this._confidence=r*1e4|0}else this._confidence=0;else this._confidence=1;this._confidence_y=t}return this._confidence}needCountWeight(){return this.outsideWeight+this.insideWeight+this.invalidWeight<5e3}revokeOutside(t){let i=this.confidence(t);return this.outsideWeight-=i,this.invalidWeight+=i,i}revokeInside(t){let i=this.confidence(t);return this.insideWeight-=i,this.invalidWeight+=i,i}setOutside(t){let i=this.confidence(t);return this.outsideWeight+=i,i}setInside(t){let i=this.confidence(t);return this.insideWeight+=i,i}setInvalid(t){let i=this.confidence(t);return this.invalidWeight+=i,i}prevNot0(){let t=this.previous;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.previous}return null}nextNot0(){let t=this.next;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.next}return null}getX(t){if(this.bo!==null)return(this._x_y!=t||isNaN(this._x))&&(A7(this,t)>0?this._x=se[0]:this._x=NaN,this._x_y=t),this._x;throw new Error("not supported operation")}voteStatus(){return this.outsideWeight>this.insideWeight&&this.outsideWeight>this.invalidWeight?2:this.insideWeight>this.outsideWeight&&this.insideWeight>this.invalidWeight?1:this.invalidWeight>this.outsideWeight&&this.invalidWeight>this.insideWeight?3:0}reverse(t){if(t===2)if(this.start.y>this.end.y){let i=Nf.rebuild(this.shape,this.end,this.start),r=new Nf(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return fa.addAll(r.connect,this.connect),r}else return this;else if(t===1)if(this.start.y<this.end.y){let i=Nf.rebuild(this.shape,this.end,this.start),r=new Nf(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return fa.addAll(r.connect,this.connect),r}else return this;return this}isNeedScan(t){return this.needCountWeight()&&this.confidence(t)>0}hashCode(){return this._hashcode}equals(t){return t instanceof Nf?!(this.polyGrp!==t.polyGrp||this.polyIndex!==t.polyIndex):!1}bbox(){return this._bbox}toString(){return Ff.format("(%d,%d,%d) (%d,%d,%d) %s %s",this.polyGrp,this.polyIndex,this.weight,this.outsideWeight,this.invalidWeight,this.insideWeight,this.start,this.end)}};function x7(e,t){let i=e.bbox(),r=t.bbox(),n=(i.minY+i.maxY)/2,s=(r.minY+r.maxY)/2;return n-s}function E7(e,t){let i=e.bbox(),r=t.bbox(),n=(i.minX+i.maxX)/2,s=(r.minX+r.maxX)/2;return n-s}var _f=class{constructor(e){if(this.__bbox=null,typeof e<"u")if(e instanceof Array){this.__items=[];for(let t of e)this.add(t)}else this.__items=e,this.__bbox=e.bbox();else this.__items=[]}add(e){if(this.__items instanceof Array)this.__items.push(e),this.__bbox=St.extend2(this.__bbox,e.bbox());else throw new Error("can't insert multiple item into leaf node")}items(){return this.__items}bbox(){if(this.__bbox!==null)return this.__bbox;throw new Error("bug")}},Ay=class{constructor(e){this.changed=!1,this.root=new _f,this.capacity=e,this.capacity2=e*e,this.itemList=[]}size(){return this.itemList.length}items(){return this.flushWhenNeed(),this.itemList}add(e){this.itemList.push(e),this.changed=!0}remove(e){fa.remove(this.itemList,e),this.changed=!0}clear(){this.changed=!1,this.root=new _f,this.itemList.length=0}flushWhenNeed(){if(this.changed){let e=new Array;for(let t of this.itemList)e.push(new _f(t));for(;;){let t=this.organize(e);if(t.length>1)e=t;else break}this.root=new _f(e),this.changed=!1}}organize(e){hp(e,E7,0,e.length);let t=e.length,i=[];for(let r=0;r<t;)if(r+this.capacity2<=t){let n=r+this.capacity2;hp(e,x7,r,n);for(let s=r;s<n;s+=this.capacity){let a=new _f(e.slice(s,s+this.capacity));i.push(a)}r=r+this.capacity*this.capacity}else{let n=new _f(e.slice(r,r+this.capacity));i.push(n),r=r+this.capacity}return i}search(e){this.flushWhenNeed();let t=[],i=[];for(i.push(this.root);;){let r=i.shift();if(typeof r<"u"){let n=r.items();if(n instanceof Array){for(let s of n)if(!e.isSeparated(s.bbox())){let a=s.items();a instanceof Array?i.push(s):t.push(a)}}else e.isSeparated(r.bbox())||t.push(n)}else break}return t}walker(e){this.flushWhenNeed(),this._walker(this.root,0,e)}_walker(e,t,i){this.flushWhenNeed();let r=e.items();if(r instanceof Array)for(let n of r)this._walker(n,t+1,i);else i(r,t)}bbox(){return this.flushWhenNeed(),this.root.bbox()}};function pv(e,t){S7(e.iterator(),t)}function S7(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var Ib=new Error("list is empty"),Ab=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},w7=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},v7=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},cp=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw Ib;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw Ib;return this.remove(e),e.item}addLast(e){return this.first===null||this.last===null?(this.first=new Ab(this,e),this.last=this.first,this.cnt=1,this.first):this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new Ab(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw Ib;return this.first.item}getLast(){if(this.last===null)throw Ib;return this.last.item}insertAfter(e,t){let i=new Ab(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new Ab(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new w7(this.first)}listIterator(){return new v7(this.first)}toArray(){let e=new Array(this.cnt),t=this.first,i=0;for(;t!=null;)e[i]=t.item,t=t.next,i++;return e}};function fv(e){throw new Error("")}var Cb=class{constructor(e,t){this.node1=null,this.node2=null,this.key=e,this.value=t}},T7=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},I7=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},zb=class{constructor(){this.innerList=new cp,this.innerMap={}}replace(e,t){e.node1!==null&&(e.node1.set(t),t.node1=e.node1),e.node2!==null&&(e.node2.set(t),t.node2=e.node2)}clear(){this.innerList.clear();for(let e in this.innerMap)delete this.innerMap[e]}put(e,t){let i=e.hashCode(),r=new Cb(e,t),n=this.innerMap[i];if(n===void 0)return r.node1=this.innerList.add(r),this.innerMap[i]=r,null;if(n instanceof Cb){if(n.key.equals(e))return this.innerMap[i]=r,this.replace(n,r),n.value;{r.node1=this.innerList.add(r);let s=new cp;return n.node2=s.add(n),r.node2=s.add(r),this.innerMap[i]=s,null}}if(n instanceof cp){let s=null;return pv(n,(a,o)=>o.key.equals(e)?(this.replace(o,r),s=o.value,!1):!0),s===null?(r.node1=this.innerList.add(r),r.node2=n.push(r),null):s}return fv(n)}get(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof Cb)return i.key.equals(e)?i.value:null;if(i instanceof cp){let r=null;return pv(i,(n,s)=>s.key.equals(e)?(r=s.value,!1):!0),r}return fv(i)}containsKey(e){return this.get(e)!==null}delete(e){e.node1!==null&&e.node1.parent.remove(e.node1),e.node2===null?delete this.innerMap[e.key.hashCode()]:e.node2.parent.remove(e.node2)}remove(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof Cb)return i.key.equals(e)?(this.delete(i),i.value):null;if(i instanceof cp){let r=null;return pv(i,(n,s)=>s.key.equals(e)?(r=s.value,this.delete(s),!1):!0),r}return fv(i)}computeIfAbsent(e,t){let i=this.get(e);if(i===null){let r=t(e);return this.put(e,r),r}else return i}size(){return this.innerList.size()}isEmpty(){return this.innerList.size()===0}keys(){return new T7(this.innerList.iterator())}values(){return new I7(this.innerList.iterator())}entries(){return this.innerList.iterator()}},Yf=class{constructor(){this.innerMap=new zb}add(e){return this.innerMap.put(e,!0)!==!0}remove(e){this.innerMap.remove(e)}contains(e){return this.innerMap.get(e)===!0}iterator(){return this.innerMap.keys()}addAll(e){let t=e.iterator();for(;t.hasNext();)this.add(t.next())}size(){return this.innerMap.size()}clear(){let e=this.iterator();for(;e.hasNext();){let t=e.next();this.remove(t)}}},tP=fa.funcCopy(hp);function A7(e,t){let i=0;if(Math.abs(e.start.y-t)<=1e-4)se[i++]=e.start.x;else if(Math.abs(e.end.y-t)<=1e-4)se[i++]=e.end.x;else if(e.shape instanceof ie)i=W8(e.shape,t);else if(e.shape instanceof Se)i=q8(e.shape,t);else throw new Error("not supported operation");return i}var kb=class{constructor(e,t,i,r){this.sides=new Array,this.loader=e,this.loader.bo=this,this.logger=i,this.rule=t,this.event=r}static sortByBBoxMinY(e,t){return e.bbox().minY-t.bbox().minY}static sortByBBoxAreaDesc(e,t){return t.bbox().area()-e.bbox().area()}addPolyline(e,t=1,i=.01,r=!0){for(let n of this.loader.buildGroup(e,t,i,r))this.sides.push(n),this.event.onOriginSide(n)}buildRTree(){let e=new Ay(10);for(let t of this.sides)e.add(t);return e}fillValidSides(e,t,i){for(let r of t)isFinite(r.getX(i))&&e.push(r)}getSortedEndpointsLineAsc(e){let t=new Array;for(let n of e)n.needCountWeight()&&(t.push(n.start),t.push(n.end));tP(t,j.sortByYAsc,0,t.length);let i=new Array,r=Number.NEGATIVE_INFINITY;for(let n of t){let s=n.y;s>r&&(i.push(s),r=s)}return i}splitSides(e,t,i){let r=e.start,n=e.end,s=new j(n.x+(r.x-n.x)*2,n.y+(r.y-n.y)*2);tP(e.inters,(o,l)=>o.distance2(s)-l.distance2(s),0,e.inters.length);let a=null;for(let o of e.inters)if(a==null)o.equals(r)&&(a=o);else if(!o.equals(a)){let l=Hf.rebuild(e.shape,a,o);l instanceof Se&&Math.abs(l.sweepAngle)>190&&(l=new ie(a,o));let c=new Hf(this,l,e.baseWeight,a,o,e.polyGrp,i++);if(t.push(c),c.updateBbox(),o.equals(n))break;a=o}return i}splitSidesByInters(){let e=new Array;for(let t of this.sides)if(t.polyIndex==0){let i=0,r=null,n=null;do{let s=new Array;i=this.splitSides(t,s,i);for(let a of s)r!=null?(r.next=a,a.previous=r):n=a,r=a,this.event.onSplitedSide(a),e.push(a);if(t.next===null)throw new Error("not supported operation");t=t.next}while(t.polyIndex!==0);n!=null&&r!=null&&(n.previous=r,r.next=n)}this.sides.length=0;for(let t of e)this.sides.push(t)}seekIntersection(){if(this.sides.length>0){let e=this.buildRTree(),t=new Yf;for(let i of this.sides){t.add(i);let r=i.bbox().extendOfSize(1e-5),n=i.shape instanceof ie;for(let s of e.search(r))if(!t.contains(s)){let a=s.shape instanceof ie;if(!(n&&a&&i.next!==null&&i.previous!==null&&(i.next.equals(s)||i.previous.equals(s)))){let o=So(i.shape,s.shape);for(let l=0;l<o;l+=2){let c=new j(se[l],se[l+1]);i.inters.push(c),s.inters.push(c),this.event.onIntersect(c,i,s)}}}}}}},C7=class AP{constructor(t){this.sides=new Yf,this.others=new Yf,this.id=t}add(t){this.sides.add(t),t.finalGrp=this.id;for(let i of t.connect)this.others.add(i)}polyline(){let t=new Array;return Uf(this.sides,(i,r)=>(t.push(r.shape),!0)),Tt.build2(t).asClose()}hashCode(){return this.id}equals(t){return t!=null&&t instanceof AP?this.id===t.id:!1}},CP=class{constructor(e){this.bo=null,this.sides=new Array,this.polyGrp=0,this.polyIndex=0,this.prevSide=null,this.firstSide=null,this.noWeight0=e}completeGroup(e){this.prevSide!=null&&this.firstSide!=null&&!this.prevSide.end.equals(this.firstSide.start)&&this.addSide(new ie(this.prevSide.end,this.firstSide.start),e);let t=new Array,i=null,r=null;for(let n of this.sides)(!this.noWeight0||n.weight!==0)&&(i!=null?(i.next=n,n.previous=i):r=n,i=n,t.push(n));return i!=null&&r!=null&&(r.previous=i,i.next=r),this.polyGrp++,this.sides.length=0,this.prevSide=null,this.firstSide=null,this.polyIndex=0,t}buildGroup(e,t,i,r=!0){for(let n of e.primitives)if(n instanceof ie)this.addSide(n,t);else if(r&&n instanceof Se&&n.rx===n.ry)this.addArc(n,t);else{let s=null;for(let a of n.points(i))s!=null&&this.addSide(new ie(s,a),t),s=a}return this.completeGroup(t)}addArc(e,t){let i=e.sweepAngle,r=Qt.regularD(e.startAngle),n=r+i;if(i>0){let s=90;for(;s<=n;)s>r&&(this.addSide(Se.build3(e.center,r,s-r,e.rx,e.ry),t),r=s),s+=90;r<n&&this.addSide(Se.build3(e.center,r,n-r,e.rx,e.ry),t)}else if(i<0){let s=270;for(;s>=n;)s<r&&(this.addSide(Se.build3(e.center,r,s-r,e.rx,e.ry),t),r=s),s-=90;r>n&&this.addSide(Se.build3(e.center,r,n-r,e.rx,e.ry),t)}}addSide(e,t){if(e.start().equals(e.end()))return;let i=e.start(),r;this.prevSide!=null?(this.prevSide.end.equals(i)||this.addSide(new ie(this.prevSide.end,i),t),r=new Hf(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++)):(r=new Hf(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++),this.firstSide=r),this.prevSide=r,this.sides.push(r)}},DP=class{constructor(e,t,i){this.eps=new Array,this.curWeight=0,this.start=null,this.last=null,this.prevStart=null,this.prevEnd=null,this.y=i,this.rule=e,this.bo=t,this.event=t.event}onEp(e){this.tuningWeight(e),this.start===null?this.rule(this.curWeight)?this.in(e):e.setInvalid(this.y):this.rule(this.curWeight)?e.setInvalid(this.y):this.out(e,this.start),this.last!==null&&this.event.onSweep1(this.last,e,this.y),this.last=e}in(e){this.prevEnd!=null&&this.onSameX(e,this.prevEnd)?(this.start=this.prevStart,this.prevStart=null,this.prevEnd.revokeInside(this.y),this.prevEnd=null):(this.start=e,this.start.setOutside(this.y))}out(e,t){if(this.onSameX(t,e))t.revokeOutside(this.y);else{if(e.setInside(this.y)>0&&t.confidence(this.y)>0){let i=t.voteStatus(),r=e.voteStatus();this.isValid(i)&&this.isValid(r)?i==2&&r==1&&(e.connect.push(t),t.connect.push(e)):(e.connect.push(t),t.connect.push(e))}this.event.onSegment1(t,e,this.y),this.eps.push(t),this.eps.push(e),this.prevStart=t,this.prevEnd=e}this.start=null}isValid(e){return e==1||e==2}onSameX(e,t){return e.bbox().isIntersect(t.bbox())&&_e.eq(e.getX(this.y),t.getX(this.y))}tuningWeight(e){this.curWeight+=e.weight;let t=e.nextNot0(),i=e.prevNot0();t!=null&&e.weight===t.weight&&t.trans===this.y&&(this.curWeight-=e.weight),i!=null&&e.weight===i.weight&&i.trans===this.y&&(this.curWeight-=e.weight),e.trans=this.y}},Xb=new Error,iP=new class extends _y{decide1(e){return e[0]&&e[1]}}(2),D7=new class extends IP{onPolylineGroup(e,t){throw Xb}onSegment(e,t,i,r,n,s){throw Xb}},_7=class{constructor(e,t){this.rtree=e,this.level=t}},P7=class _P extends kb{static isIntersect(t,i,r=$b.DUMMY){let n=new _P(r),s=n.createGroup1(t.items),a=n.createGroup2(i.items);return s.rtree.itemList.length==0||a.rtree.itemList.length==0?!1:n.isIntersect(s,a)}constructor(t){super(new CP(!1),iP.rule,t,D7)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=iP.weight(i);for(let s of t)this.addPolyline(s,r);let n=this.buildRTree();return this.sides.length=0,new _7(n,i)}isIntersect(t,i){if(t.level!==i.level){let r=t.rtree.bbox().intersection1(i.rtree.bbox());if(r!==null){try{this.inters(t,i);let n=(r.minY+r.maxY)/2;this.sweep(t,i,n)}catch(n){if(n===Xb)return!0;throw n}return!1}else return!1}else throw new Error("inersection detection should not in same group")}inters(t,i){if(t.rtree.size()>i.rtree.size()){let r=t;t=i,i=r}for(let r of t.rtree.items()){r.trans=NaN;let n=r.bbox().extendOfSize(1e-5);for(let s of i.rtree.search(n))if(s.trans=NaN,So(r.shape,s.shape)>0)throw Xb}}sweep(t,i,r){let n=St.extend2(t.rtree.bbox(),i.rtree.bbox()).extendOfSize(1e-5),s=new Array;this.fillValidSides(s,t.rtree.search(n),r),this.fillValidSides(s,i.rtree.search(n),r),hp(s,(o,l)=>o.getX(r)-l.getX(r),0,s.length);let a=new DP(this.rule,this,r);for(let o of s)a.onEp(o)}},kr=class zu{constructor(t){this.items=new Array(t.length),fa.arraycopy(t,0,this.items,0,t.length),this.__bbox=this.calcBBox()}static build1(t){let i=[];return Gb(t,(r,n)=>(i.push(n),!0)),new zu(i)}static build2(t){let i=t.map(r=>Tt.build8(r));return new zu(i)}static combinePolylineGroupArr(t){let i=[];for(let r of t)i=i.concat(r.items);return new zu(i)}calcBBox(){let t=new ot;for(let i=0;i<this.items.length;i++)t.ext1(this.items[i].bbox());return t.build1()}multiply3(t){let i=new Array(this.items.length);for(let r=0;r<i.length;r++)i[r]=this.items[r].multiply3(t);return new zu(i)}bbox(){return this.__bbox}asClose(){return this.items.forEach(t=>t.asClose()),this}mirrorY(t){return this.items.forEach(i=>i.mirrorY(t)),this}closeEndpoint(){return this.items.forEach(t=>t.closeEndpoint()),this}get primitives(){return this.items.map(t=>t.primitives).flat(2)}isEqual(t){return t instanceof zu?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items.reduce((t,i)=>i.bbox().area()>t.bbox().area()?i:t,this.items[0])}getOutline(){let t=this.items;if(t.length===1)return{outline:t,hole:new Array};let i=new Set,r=new Set;for(let n=0,s=t.length;n<s;n++){let a=t[n];if(!i.has(a)&&!r.has(a)){n+1>=s&&i.add(a);for(let o=n+1;o<s;o++){let l=t[o];if(!i.has(l)&&!r.has(l)){if(!a.bbox().isInside(l.bbox().extendOfSize(1e-4))&&!l.bbox().isInside(a.bbox().extendOfSize(1e-4)))continue;P7.isIntersect(new zu([a]),new zu([l]))&&(a.bbox().area()>l.bbox().area()?(i.add(a),r.add(l)):(i.add(l),r.add(a)))}}!i.has(a)&&!r.has(a)&&i.add(a)}}return{outline:[...i],hole:[...r]}}round(t=4){let i=this.items.map(r=>r.round(t));return new zu(i)}},L7=fa.funcCopy(hp),O7=fa.funcCopy(hp),R7=fa.funcCopy(hp);function N7(e){return new Array}function M7(e,t){let i=new vy(!1),r=new Ty(e,$b.DUMMY,i);for(let n of t)r.addPolyline(n);return r.simplify(),i.plGrps}var Ty=class extends kb{constructor(e,t,i){super(new CP(!1),e,t,i),this.finalSides=new Array,this.sideGroups={},this.vecSides=new Array,this.scanY=NaN,this.curNetIndex=0,this.curIndex=-1,this.scanLines=0}sweep(e,t,i){this.scanY=NaN,this.scanLines=0,L7(t,kb.sortByBBoxMinY,0,t.length);let r=new cp;this.curNetIndex=0;let n=Number.POSITIVE_INFINITY;for(let s of e)s>n&&this.scan(r,(n+s)/2,t),n=s;this.getAllMarkPrimitive(i,t),this.logger.debug3("scan %s %d",i,this.scanLines)}simplify(){this.seekIntersection(),this.splitSidesByInters(),this.sweep(this.getSortedEndpointsLineAsc(this.sides),this.sides,!1),this.flipSides(),this.sweep(this.getSortedEndpointsLineAsc(this.vecSides),this.vecSides,!0),this.connectSides(),this.fillResult()}addPolyline(e,t=1,i=.01,r=!0){super.addPolyline(e,t,i,r)}scan(e,t,i){if(this.scanY==t)return;this.scanY=t;let r=!1,n=e.listIterator();for(;n.hasNext();){let s=n.next(),a=s.item;_e.less(a.bbox().maxY,t)?e.remove(s):!r&&a.isNeedScan(t)&&(r=!0)}for(;this.curNetIndex<i.length;){let s=i[this.curNetIndex];if(_e.less(s.bbox().minY,t))_e.greatereq(s.bbox().maxY,t)&&(this.add2AET(e,s),!r&&s.isNeedScan(t)&&(r=!0)),this.curNetIndex++;else break}if(r){this.scanLines++;let s=new DP(this.rule,this,t),a=e.iterator();for(;a.hasNext();){let o=a.next();s.onEp(o)}}}add2AET(e,t){let i=t.bbox().minX,r=t.bbox().maxX,n=t.bbox().minY,s=t.bbox().maxY,a=e.listIterator(),o=null;for(;a.hasNext();){let l,c=a.next(),u=c.item,h=u.bbox().minX,d=u.bbox().maxX;if(r<=h)l=-1;else if(d<=i)l=1;else{let f=u.bbox().minY,m=u.bbox().maxY,g=Math.max(n,f),b=Math.min(s,m);l=this.compareBySweep(t,u,(g+b)/2)}let p=u.shape;if(p instanceof ie&&p.length()<.001&&o==null&&l<0){o=c;continue}if(o!=null&&l<0){e.insertBefore(o,t);return}if(l<0){e.insertBefore(c,t);return}else o=null}e.add(t)}getLineAngle(e){let t=e.start().angle(e.end());return t<0&&(t+=Math.PI),t}getArcAngle(e,t){let i=Math.asin((t-e.center.y)/e.rx);return e.startAngle>90&&e.startAngle<270&&(i=-i),i<0&&(i+=Math.PI),(i+Math.PI/2)%Math.PI}compareArcLine(e,t,i){let r=this.getArcAngle(e,i),n=this.getLineAngle(t);return _e.eq(r,n)?-e.sweepAngle:n-r}compareBySweep(e,t,i){let r=e.getX(i);if(!isFinite(r))return 0;let n=t.getX(i);if(!isFinite(n))return 0;if(!_e.eq(r,n))return r-n;if(e.shape instanceof ie)return t.shape instanceof ie?this.getLineAngle(t.shape)-this.getLineAngle(e.shape):-this.compareArcLine(t.shape,e.shape,i);if(t.shape instanceof ie)return this.compareArcLine(e.shape,t.shape,i);{let s=e.shape,a=t.shape,o=this.getArcAngle(s,i),l=this.getArcAngle(a,i);return _e.eq(o,l)?s.sweepAngle*a.sweepAngle<=0?s.sweepAngle<=0?1:-1:s.sweepAngle>0?s.rx-a.rx:a.rx-s.rx:l-o}}getAllMarkPrimitive(e,t){for(let i of t)if(i.status===0&&i.bbox().height()!=0){let r=i.voteStatus();if(r===2||r===1){i.status=r;let n=i.reverse(r);if(e){this.event.onResultSide(n);let s=n.shape.multiply3(de.ROT_N90),a=n.start.multiply3(de.ROT_N90),o=n.end.multiply3(de.ROT_N90);n=new Hf(this,s,n.baseWeight,a,o,n.polyGrp,n.polyIndex)}this.finalSides.push(n),this.event.onResultSide(n)}}}flipSides(){for(let e of this.sides)if(e.polyIndex==0){let t=null,i=null;do{let r=e.shape.multiply3(de.ROT_90),n=e.start.multiply3(de.ROT_90),s=e.end.multiply3(de.ROT_90),a=new Hf(this,r,e.baseWeight,n,s,e.polyGrp,e.polyIndex);if(a.outsideWeight=e.outsideWeight,a.insideWeight=e.insideWeight,a.invalidWeight=e.invalidWeight,a.status=e.status,t!=null?(t.next=a,a.previous=t):i=a,this.vecSides.push(a),this.event.onSplitedSide(a),t=a,e.next!==null)e=e.next;else break}while(e.polyIndex!=0);i!=null&&(i.previous=t,t.next=i)}}canBeEnd(e,t){if(e.size()==1){let i=e.getFirst().shape;if(i instanceof Se){if(t&&i.rx<=t)return!1}else if(i instanceof ie&&t&&i.length()<=t)return!1}return!0}connectSides(){let e=new zb,t=new Ay(10);for(let s of this.finalSides)e.computeIfAbsent(s.start,N7).push(s),t.add(s.start);let i=0,r=new Yf,n=new Array;for(let s of this.finalSides)if(!r.contains(s)){let a=new Yf,o=s.start,l=new cp;l.add(s),r.add(s);let c=s.end;for(;l.size()>0;)if(this.isStart(o,c)&&this.canBeEnd(l,.01)){l.size()>1&&this.fillSideGroups(l,i++);break}else{let u=e.get(c),h=this.findNext(r,u);if(h==null&&(c=this.findNeigber(c,a,t,.01),c!==null&&(u=e.get(c),h=this.findNext(r,u))),h!=null)l.add(h),r.add(h),c=h.end;else if(c!=null?a.add(c):(n.length==0&&l.size()>1&&this.logger.warning3("unable to connect at %s",l.getLast()),n.push(l.removeLast())),l.size()>0)c=l.getLast().end;else break}}}fillSideGroups(e,t){let i=new C7(t);Uf(e,(r,n)=>(i.add(n),!0)),this.sideGroups[i.id]=i}isStart(e,t){return e.distance2(t)<=1e-4}findNext(e,t){if(t!=null){for(let i of t)if(!e.contains(i))return i}return null}fillResult(){let e=0,t=new zb;for(let r in this.sideGroups){let n=this.sideGroups[r];Uf(n.sides,(s,a)=>(a.polyGrp!=-2&&t.put(a,a),!0))}let i=new Yf;for(let r in this.sideGroups){let n=this.sideGroups[r];if(i.add(n)){let s=0,a=new Array;for(a.push(n);s<a.length;){let l=a[s],c=new Array;Uf(l.others,(h,d)=>{let p=t.get(d);return p!=null&&c.push(p.finalGrp),!0}),O7(c,fa.sortAsc,0,c.length);let u=l.id;for(let h of c)if(h!=u&&h!=l.id){let d=this.sideGroups[h];i.add(d)&&a.push(d),u=h}s++}let o=new Array;for(let l of a)o.push(l.polyline());R7(o,kb.sortByBBoxAreaDesc,0,o.length),this.event.onPolylineGroup(new kr(o),e++)}}}findNeigber(e,t,i,r){let n=r*r,s=Number.MAX_VALUE,a=null;for(let o of i.search(e.bbox().extendOfSize(r)))if(!t.contains(o)){let l=e.distance2(o);l<s&&(s=l,a=o)}return s<n?a:null}},B7=class{constructor(){this.points=[],this.lines=[],this.arcs=[],this.beziers=[],this.listText=[],this.fonts=[]}addPt(e,t=!0){if(e instanceof ie)this.lines.push(e);else if(e instanceof Se)this.arcs.push(e);else if(e instanceof Ye)this.beziers.push(e);else throw new Error("not support");t&&this.points.push(e.start())}addPoint(e){this.points.push(e)}addText(e,t,i=1,r=.1,n=!0){this.listText.push({pos:e,str:t,size:i,width:r}),n&&this.points.push(e)}addPly(e,t=!0){e.primitives.forEach(i=>this.addPt(i,t))}build(){let e=[],t=[],i=[],r=[],n=[],s=[];return this.points.forEach(a=>e.push(a.x,a.y)),this.lines.forEach(a=>t.push(a.start().x,a.start().y,a.end().x,a.end().y)),this.arcs.forEach(a=>i.push(a.center.x,a.center.y,a.rx,Qt.toRadians(a.startAngle),Qt.toRadians(a.endAngle()),a.sweep())),this.beziers.forEach(a=>{a.controls.forEach(o=>{r.push(o.x,o.y)}),r.push("end")}),this.listText.forEach(a=>n.push(a.pos.x,a.pos.y,a.str,a.width,a.size)),this.fonts.forEach(a=>s.push(a)),{points:e,lines:t,arcs:i,texts:n,beziers:r,fonts:s}}},Lv=class PP{constructor(t){this.map=new zb,this.bus=t}initColor(t){return this.map.computeIfAbsent(t,()=>new B7)}draw(){let t={},i=this.map.entries();for(;i.hasNext();){let r=i.next();t[r.key.toString()]=r.value.build()}this.bus.publish("/debug/draw",t)}clear(){this.map.clear()}static init(t){if(!t)throw new Error("bus is undefined!");this.palette=new PP(t)}static initPalette(t){this.palette=t}static getDefaultColor(){for(let t of this.colorBuffersMap)if(t[0]!==null&&t[0])return t[0]=!1,t[1];return this.colorBuffersMap.forEach(t=>{if(t[0]===null){console.log(1);return}t[0]=!0}),this.getDefaultColor()}static clear(){this.palette.clear()}static auto(t,i=this.getDefaultColor()){if(Array.isArray(t))t.forEach(r=>{this.auto(r,i)});else if(t instanceof j)this.point(t,i);else if(t instanceof St)this.bbox(t,i);else if(t instanceof Dy)this.primitive(t,i);else if(t instanceof Tt)this.polyline(t,i);else if(t instanceof rn)this.polygon(t,i);else if(t instanceof wr)this.group(t,i);else if(t instanceof kr)this.auto(t.items,i);else{debugger;throw new Error("No incoming type!")}}static text(t,i,r=.5,n=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");this.palette.initColor(n).addText(t,i,r,r/10),this.palette.draw()}static point(t,i=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let r=this.palette.initColor(i);Array.isArray(t)?t.forEach(n=>{this.point(n,i)}):r.addPoint(t),this.palette.draw()}static bbox(t,i=this.getDefaultColor()){Array.isArray(t)?t.forEach(r=>{this.bbox(r,i)}):(this.primitive(new ie(new j(t.maxX,t.maxY),new j(t.maxX,t.minY)),i),this.primitive(new ie(new j(t.maxX,t.maxY),new j(t.minX,t.maxY)),i),this.primitive(new ie(new j(t.minX,t.minY),new j(t.maxX,t.minY)),i),this.primitive(new ie(new j(t.minX,t.minY),new j(t.minX,t.maxY)),i))}static primitive(t,i=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let r=this.palette.initColor(i);Array.isArray(t)?t.forEach(n=>{this.primitive(n,i)}):r.addPt(t),this.palette.draw()}static polyline(t,i=this.getDefaultColor()){Array.isArray(t)?t.forEach(r=>{this.polyline(r,i)}):t.primitives.forEach(r=>{this.primitive(r,i)})}static polygon(t,i=this.getDefaultColor()){Array.isArray(t)?t.forEach(r=>{this.polygon(r,i)}):t.items.forEach(r=>{this.polyline(r,i)})}static group(t,i=this.getDefaultColor()){Array.isArray(t)?t.forEach(r=>{this.group(r,i)}):t.items.forEach(r=>{this.polygon(r,i)})}static async begin(){this.t1=performance.now()}static async end(t){console.log(t||"t1:",performance.now()-this.t1)}static async log(t){console.log(t||"==================")}};Lv.colorBuffersMap=[[!0,Hi.BLUE],[!0,Hi.GREEN],[!0,Hi.WHITE],[!0,Hi.RED],[!0,Hi.Golden],[!0,Hi.Gray]],Lv.t1=0;var Py=Lv,k7=0,Ly=class Ov{constructor(t,i){this.inters=[],this.shape=t,this.start=t.start(),this.end=t.end(),this.judgeOverlapMap=new Map,i&&(this.id=k7++)}reverse(){this.shape=this.shape.reverse();let t=this.start;this.start=this.end,this.end=t}getCenterPoint(t=this.end){let{x:i,y:r}=this.start,{x:n,y:s}=t;if(this.shape instanceof Se){let a=this.shape.rx,o=new j((i+n)/2,(r+s)/2),l=this.shape.center,c;return o.x!==l.x||o.y!==l.y?(c=o.angle(l),Math.abs(this.shape.sweepAngle)>180&&(c+=c>=0?-180:180)):c=(this.shape.startAngle+this.shape.endAngle())/2,new j(l.x+Math.cos(c)*a,l.y+Math.sin(c)*a)}else{if(this.shape instanceof ie)return new j((i+n)/2,(r+s)/2);if(this.shape instanceof Ye){let a=this.shape.getPercent(t,Ft);return Ye.pointOn(a/2,this.shape.controls)}else throw Error("not support")}}static finalAngle(t,i,r){let n=t.cross(i)>0,s=Math.acos(Math.min(1,Math.max(-1,t.dot(i)/i.length())));return(r?!n:n)&&(s=Zb-s),s}sortInters(){if(this.shape instanceof Se){let t=this.shape.center,i=this.shape.start().sub(t).normalize(),r=this.shape.isCCW;this.inters.sort((n,s)=>{let a=n.coord.sub(t),o=s.coord.sub(t);return Ov.finalAngle(i,a,r)-Ov.finalAngle(i,o,r)<=0?-1:1})}else if(this.shape instanceof ie){let t=this.start,i=this.end,r=new j(i.x+(t.x-i.x)*2,i.y+(t.y-i.y)*2);this.inters.sort((n,s)=>n.coord.distance2(r)-s.coord.distance2(r)<=0?-1:1)}else if(this.shape instanceof Ye){let t=this.shape;this.inters.sort((i,r)=>t.getPercent(i.coord,Ft)-t.getPercent(r.coord,Ft)<=0?-1:1)}else throw Error("not support the primitive type");this.inters.forEach((t,i)=>t.setIndex(i))}getStart(){return this.start}getEnd(){return this.end}getShape(){return this.shape}connect(t){this.nextSide=t,t.prevSide=this}static returnPolygonList(t){let i=[];return t.forEach(r=>{let n=[];r.forEach((s,a)=>{let o=[];s.forEach(l=>{o.push(l.shape)}),n.push(Tt.build7(o))}),i.push(new rn(n))}),i}addInter(t){this.inters.push(t)}static returnPolygonGroup(t){let i=[];return t.forEach(r=>{let n=[];r.forEach((s,a)=>{let o=[];s.forEach(l=>{o.push(l.shape)}),n.push(Tt.build7(o))}),i.push(new rn(n))}),new wr(i)}static rebuild(t,i,r){let n;if(t instanceof ie||i.distance2(r)<1e-6)n=new ie(i,r);else if(t instanceof Se)n=Se.build2(t.center,i.angleD(t.center),r.angleD(t.center),t.rx,t.ry,t.isCCW?1:0);else if(t instanceof Ye){let s=t.getPercent(i,Ft),a=t.clip(s)[1];n=a.clip(a.getPercent(r,Ft))[0]}else throw new Error("not supported operation");return kt(t,i).dot(kt(n,i))<0?null:n}static returnPolyline(t){return Tt.build7(t.map(i=>i.shape))}bbox(){return this.shape.bbox()}};function ma(e,t,i){if(e instanceof Se&&t instanceof Se)return U7(e,t);if(e instanceof Se&&t instanceof ie)return sP(e,t);if(e instanceof ie&&t instanceof Se)return nP(e,t);if(e instanceof ie&&t instanceof ie)return up(e,t);if(e instanceof Ye&&t instanceof ie)return e.controls.length===2||Ku(e)?up(new ie(e.start(),e.end()),t):LP(e,t);if(e instanceof ie&&t instanceof Ye)return t.controls.length===2||Ku(t)?up(e,new ie(t.start(),t.end())):Rv(e,t);if(e instanceof Se&&t instanceof Ye)return t.controls.length===2||Ku(t)?sP(e,new ie(t.start(),t.end())):F7(e,t);if(e instanceof Ye&&t instanceof Se)return e.controls.length===2||Ku(e)?nP(new ie(e.start(),e.end()),t):G7(e,t);if(e instanceof Ye&&t instanceof Ye)return Vv(e,t);throw new Error("not support")}function Pf(e,t){return kt(e,t.start()).dot(kt(t,t.start()))<=0?!1:ma(e,t).state<=2}function mv(e,t){let i=t.getPercent(e.end(),Ft);if(i===null)return!1;if(i===0)return!0;let r=t.clip(i)[0],n=e.buildConverxHull(Ft),s=r.buildConverxHull(Ft),a=c(n),o=c(s);return l(a,o);function l(u,h){let d=new Map([[0,1],[1,0],[2,2],[3,4],[4,3]]),p=u[0],f=h[0];if(!p||!f)throw Error("isAllOverlap(sides1: PackSide[], sides2: PackSide[])");let m=!0;do{let g=p.getShape(),b=f.getShape();if(g instanceof ie&&b instanceof ie){let y=m?up(g,b).state:d.get(up(b,g).state);if(y===0)p=p.nextSide,m=!1;else if(y===1)f=f.nextSide,m=!0;else if(y===2)p=p.nextSide,f=f.nextSide,m=!0;else return!1}else throw Error("not support")}while(p!==u[0].prevSide&&f!==h[0].prevSide);return!0}function c(u){let h=u.primitives.map(p=>new Ly(p)),d=h[h.length-1];return h.forEach(p=>{d.connect(p),d=p}),h}}function rP(e,t){let i=e.end().distance2(t.center);if(i>(t.rx+Ft)**2||i<(t.rx-Ft)**2||!(It(e.end(),t.end())||Hv(t,e.end())))return!1;if(e.center.equals1(t.center))return!0;let r=e.center.distance1(t.center),n=Math.abs(e.rx-t.rx);if(r>Math.min(e.rx,t.rx)){let s=e.center.angleD(t.center);return e.rx>t.rx?!(r+n>Ft&&Qc(e,s))&&!(r-n>Ft&&e.rx+t.rx-r>Ft&&Qc(e,s+180)):!(r-n>Ft&&Qc(e,s))&&!(e.rx+t.rx-r>Ft&&Qc(e,s+180))}else{if(r+n<=Ft)return!0;let s=e.rx>t.rx?e.center.angleD(t.center):t.center.angleD(e.center);return Qc(e,s)?!1:r-n<=Ft?!0:!Qc(e,s+180)}}function F7(e,t){let i=jv(e,t.start()).toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=Vv(a,t).state,r!==0)break}return r===2&&n!==i.length-1?{state:1}:{state:r}}function G7(e,t){let i=t.toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=Vv(e,a).state,r!==1)break}return r===2&&n!==i.length-1?{state:0}:{state:r}}function Vv(e,t){if(e.controls.length===2||Ku(e))return t.controls.length===2||Ku(t)?up(new ie(e.start(),t.end()),new ie(t.start(),t.end())):Rv(new ie(t.start(),e.end()),t);if(t.controls.length===2||Ku(t))return LP(Nv(e,t.start()),new ie(t.start(),t.end()));let i=Nv(e,t.start());if(Ku(i))return Rv(new ie(t.start(),e.end()),t);let r=mv(i,t),n=mv(t,i);if(!r&&!n){let s=r7(i,t);if(s.havOverlap){let a=s.havOverlap!==2,o=s.havOverlap!==1;return $u(e,t,a,o)}else{let a=function(){for(let h=0;h<c;h+=2)se[h]=u[h],se[h+1]=u[h+1]},o,l,c=s.cnt,u=new Array(c).fill(0).map((h,d)=>se[d]);for(let h=0;h<c;h+=2){let d=new j(se[h],se[h+1]),p=i.getPercent(d,Ft),f=t.getPercent(d,Ft);if(p===0||f===0)continue;let m=p===1?i:i.clip(p)[0],g=f===1?t:t.clip(f)[0];if(mv(m,g)){let b=kt(e,d).cross(kt(t,d));if(b===0){o=i.end(),l=t.end();break}return{state:b<0?3:4}}a()}return(!o||!l)&&(o=Gf(i.controls,i.controls[0],t),l=Gf(t.controls,i.controls[0],i)),{state:o.sub(i.controls[0]).cross(l.sub(i.controls[0]))>0?4:3}}}return $u(e,t,r,n)}function LP(e,t){let i=Nv(e,t.start());if(Ku(i))return up(new ie(i.start(),i.end()),t);let r=RP(i,t),{isIn:n,bezierIsInLeft:s}=OP(t,i);if(!r&&!n){if(s!==void 0)return{state:s?3:4};let a=null,o=e.getPercent(t.start(),Ft)+.01;for(let l=o>1?1:o;l<=1;){let c=Ye.pointOn(l,e.controls);if(Cy(t,c)>ga){a=c;break}l+=.01,l>1&&(l=1)}if(!a)throw Error("!end1 && !end2 not result");return{state:t.direct.cross(a.sub(t.start()))<0?4:3}}return $u(i,t,r,n)}function Rv(e,t){let{isIn:i,bezierIsInLeft:r}=OP(e,t),n=RP(t,e);if(!i&&!n){if(r!==void 0)return{state:r?4:3};let s=null;for(let a=.01;a<=1;){let o=Ye.pointOn(a,t.controls);if(Cy(e,o)>ga){s=o;break}a+=.01,a>1&&(a=1)}if(!s)throw Error("!end1 && !end2 not result");return{state:e.direct.cross(s.sub(e.start()))<0?3:4}}return $u(t,e,i,n)}function U7(e,t){let i=rP(jv(e,t.start()),t),r=rP(t,e);if(!i&&!r){let n=mc(t);if(e.center.sub(t.start()).dot(t.center.sub(t.start()))>0){if(e.rx===t.rx)return e.isCCW?{state:n.dot(e.center.sub(t.center))<0?3:4,exitIsInvalid:!1}:{state:n.dot(e.center.sub(t.center))>0?3:4,exitIsInvalid:!1};let s,a;return e.rx>t.rx?(s=e,a=t):(s=t,a=e),n.dot(a.center.sub(s.center))>0&&a.rx+a.center.distance1(s.center)-s.rx>Ft?e.isCCW?{state:e.rx>t.rx?3:4,exitIsInvalid:!1}:{state:e.rx<t.rx?3:4,exitIsInvalid:!1}:e.isCCW?{state:e.rx<t.rx?3:4,exitIsInvalid:!0}:{state:e.rx>t.rx?3:4,exitIsInvalid:!0}}else return e.rx+t.rx-e.center.distance1(t.center)>Ft&&n.dot(e.center.sub(t.center))>0?{state:t.isCCW?3:4,exitIsInvalid:!1}:{state:e.isCCW?3:4,exitIsInvalid:!0}}return $u(e,t,i,r)}function nP(e,t){let i=fc.foot(e,t.center),r=e.end().distance2(t.center),n=e.end().sub(e.start()),s=(t.rx-Ft)**2,a=r<=(t.rx+Ft)**2&&r>=s&&(n.dot(i.sub(t.start()))<=0||e.start().distance2(e.end())<=e.start().distance2(i)||i.distance2(t.center)>=s)&&(It(e.end(),t.end())||Hv(t,e.end())),o=NP(t,e);if(!a&&!o){let l=e.distance2(t.center);return l<=ga?{state:n.cross(mc(t))>0?4:3}:n.dot(i.sub(t.start()))>=0&&(r<s||e.start().distance2(t.center)<s||l<s)?{state:n.cross(t.center.sub(e.start()))<0?4:3}:{state:n.cross(t.center.sub(e.start()))>0?4:3}}return $u(t,e,a,o)}function Qc(e,t){return t=Qt.regularD(t),e.sweepAngle>0?(t<e.startAngle&&(t+=360),e.endAngle()>t):(t>e.startAngle&&(t-=360),e.endAngle()<t)}function Hv(e,t){return It(e.end(),t)||It(e.start(),t)||Qc(e,t.angleD(e.center))}function OP(e,t){let i=e.panDistance(Ft),r=e.panDistance(-Ft),n=aP(t,i),s=aP(t,r);if(!n.length&&!s.length)return{isIn:t.getPercent(e.end(),Ft)!==null};let a=[...n,...s].sort((u,h)=>u.t-h.t),o=new ie(r.start(),i.start()),l=[];for(let u=0,h=a.length;u<h;u++){let d=a[u];if(l.push(d),o.distance(d.interP)>e.length()+Ft)break;if(l.length===2){let p=(l[1].t*10+l.shift().t*10)/20,f=Ye.pointOn(p,t.controls);if(e.distance2(f)>ga)return{isIn:!1,bezierIsInLeft:e.direct.cross(f.sub(e.start()))>0}}}let c=l.length?o.distance(l[0].interP)>=e.length()+Ft:!0;return{isIn:c,bezierIsInLeft:c?void 0:e.direct.cross(l[0].interP.sub(e.start()))>0}}function RP(e,t){if(Cy(t,e.end())>ga||e.getToLineMaxDis2(t)>ga)return!1;let i=V7(t,ga);return e.getToLineMaxDis2(i)<=(t.length()+Ft)**2}function NP(e,t){let i=t.end().angleD(t.start()),r=Y7(t,e.end());if(r>ga)return!1;if(Qc(e,i+90)){if(fc.foot(t,e.center).distance1(e.pointOn(i+90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}if(Qc(e,i-90)){if(fc.foot(t,e.center).distance1(e.pointOn(i-90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}return r<=ga&&(It(e.end(),t.end())||Mv(t,e.end()))}var MP=(Ft*2)**2;function jv(e,t){if(It(e.end(),t))return Se.build3(e.center,e.endAngle(),0,e.rx,e.ry);if(e.start().distance2(t)<MP)return e;let i=Qt.regularD(t.angleD(e.center));if(!Qc(e,i))throw new Error("!angleIsInArc(arc, angle)");return Se.build2(e.center,i,e.endAngle(),e.rx,e.ry,e.isCCW?1:0)}function Nv(e,t){if(It(e.end(),t))return new Ye([t,t]);if(e.start().distance2(t)<MP)return e;let i=e.getPercent(t,Ft);if(i===null)throw new Error("!cutBezier(bezier: Bezier, p: Vector2)");return e.clip(i)[1]}function sP(e,t){let i=NP(jv(e,t.start()),t),r=t.end().distance2(e.center),n=t.end().sub(t.start()),s=fc.foot(t,e.center),a=(e.rx-Ft)**2,o=r<=(e.rx+Ft)**2&&r>=a&&(n.dot(s.sub(t.start()))<=0||t.start().distance2(t.end())<=t.start().distance2(s)||s.distance2(e.center)>=a)&&(It(e.end(),t.end())||Hv(e,t.end()));if(!i&&!o){let l=t.distance2(e.center);return l<=ga?{state:n.cross(mc(e,t.start().angle(e.center)))>0?3:4}:n.dot(s.sub(t.start()))>=0&&(r<a||t.start().distance2(e.center)<a||l<a)?{state:n.cross(e.center.sub(t.start()))>0?4:3}:{state:n.cross(e.center.sub(t.start()))<0?4:3}}return $u(t,e,i,o)}function up(e,t){if(It(e.end(),t.end()))return $u(e,t,!0,!0);let i=Cy(t,e.end())<=ga&&Mv(t,e.end()),r=Cy(e,t.end())<=ga&&Mv(e,t.end());if(!i&&!r){let n=e.direct.x===0&&e.direct.y===0,s=t.direct.x===0&&t.direct.y===0;if(n&&s)throw Error("2LineAllIsPoint");return n?{state:t.direct.cross(e.end().sub(t.start()))>0?3:4}:{state:e.end().sub(e.start()).cross(t.end().sub(e.start()))>0?4:3}}return $u(e,t,i,r)}function Mv(e,t){return fc.foot(e,t).distance2(e.start())<e.end().distance2(e.start())}function $u(e,t,i,r){if(i)return r?It(e.end(),t.end())?{state:2}:{state:0}:{state:0};if(r)return{state:1};throw new Error("!end1 && !end2")}function Cy(e,t){return(e.a*t.x+e.b*t.y+e.c)**2/(e.a**2+e.b**2)}function Y7(e,t){return Math.min(e.distance2(t),fc.foot(e,t).distance2(t))}function V7(e,t){let i=e.panDistance(t),r=e.panDistance(-t);return new ie(r.start(),i.start())}function Ku(e){let t=e.start(),i=e.end();t.equals1(i)&&(i=t.add1(1,0));let r=i.y-t.y,n=t.x-i.x,s=-r*t.x-n*t.y,a=Math.sqrt(1/(r**2+n**2));r*=a,n*=a,s*=a;let o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;return e.controls.forEach(c=>{let u=r*c.x+n*c.y+s;u<o&&(o=u),u>l&&(l=u)}),ru(o,l)}function aP(e,t){let i=So(e,t),r=[],n=new Array(i).fill(0).map((a,o)=>se[o]);for(let a=0;a<i;a+=2){let o=new j(se[a],se[a+1]),l=e.getPercent(o);r.push({interP:o,t:l}),s()}function s(){for(let a=0;a<i;a+=2)se[a]=n[a],se[a+1]=n[a+1]}return r}var Zc=.01,H7=270;function Al(e){let t=Zc**2,i=e.end(),r=[],n=[];for(let p=0,f=e.primitives.length;p<f;p++){let m=function(R,M){return R instanceof ie&&M instanceof ie&&Math.abs(R.direct.cross(M.direct))<_e.eps&&R.direct.dot(M.direct)>0||R instanceof Se&&M instanceof Se&&Math.abs(R.rx-M.rx)<=_e.eps&&R.center.distance2(M.center)<_e.eps&&R.isCCW===M.isCCW},g=function(R){if(Ko(R,Zc))n.push(null);else{if(R instanceof ie)n.push(R);else if(R instanceof Se&&R.rx===R.ry)h(R,n);else if(R instanceof Ye){let M=[];Qb(R,M),M.forEach(F=>{let G=F.start(),V=F.end();u(G,V)||n.push(F)})}else throw new Error("not support!");i=S}},b=function(R){if(R instanceof ie)return R.direct.x===0&&R.direct.y===0;if(R instanceof Se)return R.sweepAngle===0;if(R instanceof Ye){let M=new Set(R.controls.map(G=>G.x)),F=new Set(R.controls.map(G=>G.y));return M.size===1&&F.size===1}else throw new Error("not support")},y=e.primitives[p],E=y.start(),S=y.end();if(b(y))continue;u(i,E)||(n.push(new ie(i,E)),i=E);let w=(p+1)%f,x=e.primitives[w];for(;m(y,x)&&(w=(w+1)%f,x=e.primitives[w],x!==y););if(w===(p+1)%f){g(y);continue}if(x===y){if(!(y instanceof Se)){if(Math.abs(e.area(.1))<t)return null;throw new Error("simplifyPolyline not support")}let R=y instanceof Se?y.isCCW:e.area(.1)>0;n.length=0;let M=R?180:-180;n.push(Se.build3(y.center,y.startAngle,M,y.rx,y.ry),Se.build3(y.center,y.startAngle+M,M,y.rx,y.ry));break}let I=(()=>{if(y instanceof ie)return(R,M)=>{let F=new ie(R,M);return Ko(F,Zc)?null:[F]};if(y instanceof Se)return(R,M)=>{let F;if(R.equals1(M)?F=Se.build3(y.center,y.startAngle,y.sweep()===1?360:-360,y.rx,y.ry):F=Se.build4(R,M,y.center,y.rx,y.ry,y.sweep()),Ko(F,Zc))return null;let G=F.pointOn(F.startAngle+F.sweepAngle/2),V=Se.build4(F.start(),G,y.center,y.rx,y.ry,y.sweep()),q=Se.build4(G,F.end(),y.center,y.rx,y.ry,y.sweep());return Ko(V,Zc)||Ko(q,Zc)?[F]:[V,q]};throw new Error("not support")})(),A=w===0;if(w<p&&!A&&(A=!I(e.primitives[0].start(),e.primitives[w-1].end()),!A)){let R=I(y.start(),n[0].end());if(R.length===1)n[0]=R[0];else if(R.length===2)n[0]=R[1],n.push(R[0]);else throw new Error("!!!generatorPt");break}p=w===0?f-1:w-1,x=e.primitives[p];let O=I(y.start(),x.end());if(O?(O.forEach(R=>n.push(R)),i=x.end()):g(null),A)break}let s=n.length;if(n.forEach((p,f)=>{if(p)r.push(p);else{let m,g;f===s-1&&(m=r[0],g=r[r.length-1]);let b=(f+1)%s;if(m=m!=null?m:n[b],m){let y=f,E=!1;for(;g=g!=null?g:n[(--y+s)%s],g!==m;)if(g){E=!0;break}if(E){if(m.start().equals1(g.end()))return;if(kt(g,g.end()).dot(kt(m,m.start()))<0){if(!u(g.end(),m.start())){let I=new ie(g.end(),m.start());r.push(I);return}let{rebuildPrevPt:S,rebuildNextPt:w,rebuildLinkLine:x}=oP(n[(y-1+s)%s],g,new ie(g.end(),m.start()),m,n[(f+2)%s]);S&&w&&(S!==g?(n[(y+s)%s]=S,r[r.length-1]&&(r[r.length-1]=S)):w!==m&&(n[(f+1)%s]=w,r[0]===m&&(r[0]=w)),x&&r.push(x))}}}}}),r.length===0)return null;u(i,r[0].start())||r.push(new ie(i,r[0].start()));let a=r[r.length-1];if(r.length===1)return a instanceof Se?Tt.build7([Se.build2(a.center,0,180,a.rx,a.ry,a.sweep()),Se.build2(a.center,180,360,a.rx,a.ry,a.sweep())]):a instanceof Ye?Tt.build7(a.clip(.5)):null;let o=r.map(p=>new j7(p)),l=o[o.length-1];for(o.forEach(p=>{p.connect(l),l=p});!l.isVisited;){let p=function(){l.next.connect(m),l=l.next,l.isConnected=!1,l.isVisited=!1},f=function(){l.connect(m.prev),l.isConnected=!1},m=l.prev;if(l===m)break;let g=l.pt,b=m.pt,y=b.end();if(!l.isConnected&&!y.equals(g.start())){let E=function(w){l.isConnected=!0,l.pt=g=w,l.next.isVisited=!1},S=function(w){l.isConnected=!0,m.pt=w,m.isVisited=!1,l=m};if(g instanceof ie)if(u(y,g.end())){p();continue}else E(new ie(y,g.end()));else if(b instanceof ie){u(b.start(),g.start())?f():S(new ie(b.start(),g.start()));continue}else if(g instanceof Ye)if(u(y,g.end())&&!(g.controls.length!==2&&g.getToLineMaxDis2(g.startToEndL)>=t)){p();continue}else E(new Ye([y,...g.controls.slice(1)]));else if(b instanceof Ye)u(b.start(),g.start())&&!(b.controls.length!==2&&b.getToLineMaxDis2(b.startToEndL)>=t)?f():S(new Ye([...b.controls.slice(0,-1),g.start()]));else if(g instanceof Se&&b instanceof Se)if(Math.abs(Math.abs(g.sweepAngle)-180)<Math.abs(Math.abs(b.sweepAngle)-180)){let w=Se.build5(y,g.end(),g.sweepAngle);if(u(w.start(),w.end())&&!(w.rx>=Zc&&Math.abs(w.sweepAngle)>180)){p();continue}else E(w)}else{let w=Se.build5(b.start(),g.start(),b.sweepAngle);u(w.start(),w.end())&&!(w.rx>=Zc&&Math.abs(w.sweepAngle)>180)?f():S(w);continue}else throw new Error("not support")}if(kt(g,g.start()).dot(kt(b,b.end()))<0){let E=function(x,I,A,O,R,M){if(l.next===m){l=null;return}let{rebuildLinkLine:F,rebuildPrevPt:G,rebuildNextPt:V}=oP(x,I,A,O,R);G&&V&&(G!==I&&(m.prev.pt=G),V!==O&&(l.next.pt=V),F?M.pt=F:p())},S=function(){l.next===m?l=null:(l.next.connect(m.prev),l=l.next,l.isConnected=!1,l.isVisited=!1)},w=ma(b.reverse(),g).state;if(w===0){let x=lP(g,b.start(),g.end());if(d(x)){let I=m.prev.pt,A=l.next.pt;if(kt(A,A.start()).dot(kt(I,I.end()))>=0){if(S(),!l)break;continue}if(E(m.prev.prev.pt,I,x instanceof ie?x:new ie(x.start(),x.end()),A,l.next.next.pt,l),!l)break}else l.pt=x;f();continue}else if(w===1){let x=lP(b,b.start(),g.end());if(d(x)){let I=m.prev.pt,A=l.next.pt;if(kt(A,A.start()).dot(kt(I,I.end()))>=0){if(S(),!l)break;continue}if(E(m.prev.prev.pt,I,x instanceof ie?x:new ie(x.start(),x.end()),A,l.next.next.pt,m),!l)break}else m.pt=x;p();continue}else if(w===2){if(S(),!l)break;continue}}l.isVisited=!0,l=l.next}if(!l)return null;r.length=0;let c=l;for(r.push(l.pt),l=l.next;l!==c;)r.push(l.pt),l=l.next;if(r.length===1){let p=r[0];return p instanceof Se?(u(p.start(),p.end())?r[0]=Se.buildCircle(p.center,p.rx,p.sweep()):r.push(new ie(p.end(),p.start())),Tt.build7(r)):p instanceof Ye?(u(p.start(),p.end())||r.push(new ie(p.end(),p.start())),Tt.build7(r)):null}if(e=Tt.build7(r),Math.abs(e.area(.1))<t)return null;return e;function u(p,f){return p.distance2(f)<t}function h(p,f){if(Math.abs(p.sweepAngle)>H7){let m=p.sweepAngle/2;h(Se.build3(p.center,p.startAngle,m,p.rx,p.ry),f),h(Se.build3(p.center,p.startAngle+m,m,p.rx,p.ry),f)}else f.push(p)}function d(p){return p.start().distance2(p.end())<t&&!(p instanceof Se&&p.rx>=Zc&&Math.abs(p.sweepAngle)>180||p instanceof Ye&&p.controls.length!==2&&p.getToLineMaxDis2(new ie(p.start().add1(1,0),p.end()))>=t)}}function Ko(e,t){if(!e)return!0;let i=e.start(),r=e.end();if(i.distance2(r)<t**2)if(e instanceof Se){if(!(e.rx>=t&&Math.abs(e.sweepAngle)>180))return!0}else if(e instanceof Ye){if(!(e.controls.length!==2&&e.getToLineMaxDis2(new ie(e.start().add1(1,0),e.end()))>=t))return!0}else return!0;return!1}function Lf(e){if(e.direct.x===0&&e.direct.y===0)throw Error("getEndOfExtendLine(line: Line, distance: number)");let t=Math.abs(Zc-e.length())+_e.eps,i={x:e.direct.normalize().x*t,y:e.direct.normalize().y*t},r=e.end();return new j(r.x+i.x,r.y+i.y)}function oP(e,t,i,r,n){if(!e)a();else if(!n)o();else{let l=kt(e,e.end()),c=kt(t,e.end()),u=l.dot(c);if(u>=0)a();else{let h=kt(r,r.end()),d=kt(n,r.end()),p=h.dot(d);if(p>=0)o();else if(ru(u,-1)&&ru(p,-1)){let f=i.center();s(f),i=null}else u>p?a():o()}}function s(l){let c;if(t instanceof ie)c=new ie(t.start(),l);else if(t instanceof Ye)c=new Ye([...t.controls.slice(0,-1),l]);else if(t instanceof Se)c=Se.build5(t.start(),l,t.sweepAngle);else throw new Error("not supported");t=Ko(c,Ft)?null:c;let u;if(r instanceof ie)u=new ie(l,r.end());else if(r instanceof Ye)u=new Ye([l,...r.controls.slice(1)]);else if(r instanceof Se)u=Se.build5(l,r.end(),r.sweepAngle);else throw new Error("supported");r=Ko(u,Ft)?null:u}function a(){if(t instanceof ie){let l=Lf(i.reverse());i=new ie(l,i.end());let c=new ie(t.start(),l);t=Ko(c,Ft)?null:c}else if(t instanceof Ye){let l=Lf(i.reverse());i=new ie(l,i.end());let c=new Ye([...t.controls.slice(0,-1),l]);t=Ko(c,Ft)?null:c}else if(t instanceof Se){let l=Lf(i.reverse());i=new ie(l,i.end());let c=Se.build5(t.start(),l,t.sweepAngle);t=Ko(c,Ft)?null:c}else throw new Error("not supported")}function o(){if(r instanceof ie){let l=Lf(i);i=new ie(i.start(),l);let c=new ie(l,r.end());r=Ko(c,Ft)?null:c}else if(r instanceof Ye){let l=Lf(i);i=new ie(i.start(),l);let c=new Ye([l,...r.controls.slice(1)]);r=Ko(c,Ft)?null:c}else if(r instanceof Se){let l=Lf(i);i=new ie(i.start(),l);let c=Se.build5(l,r.end(),r.sweepAngle);r=Ko(c,Ft)?null:c}else throw new Error("not supported")}return{rebuildPrevPt:t,rebuildNextPt:r,rebuildLinkLine:i}}function lP(e,t,i){if(e instanceof ie||t.distance2(i)<=ga)return new ie(t,i);if(e instanceof Se)return Se.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof Ye){let r=e.getPercent(t,Ft),n=e.getPercent(i,Ft);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}var j7=class{constructor(e){this.pt=e}connect(e){this.prev=e,e.next=this}};function Wb(e){let t=fp(),i;if(e instanceof Tt){let r=Al(e);if(r===null)return null;i=r}else if(e instanceof rn){let r=e.items.map(n=>Wb(n)).filter(n=>n!==null);if(r.length===0)return null;i=new rn(r)}else{let r=e.items.map(n=>Wb(n)).filter(n=>n!==null);if(r.length===0)return null;i=new wr(r)}return Il.preprocessPolyline+=tu(t),i}var Il={addDocShapes2RTree:0,getPour:0,prepare:0,getSinglePourLayerPolyline:0,combindOutlines:0,mergeSameNet:0,run:0,end:0,deSelfIntersection:0,changeDirect:0,extend:0,preprocessPolyline:0,runBoolean:0,IntersectionSeeker:0,BooleanTools:0,totalBool:0};function fp(){return{timeIndex:Object.assign({},Il),start:performance.now()}}function cP(e){return Object.values(e).reduce((t,i)=>t+i,0)}function tu(e){return performance.now()-e.start-(cP(Il)-cP(e.timeIndex))}function ws(e,t,i,r){let n=Hi.RED,s=Hi.Golden;function a(){if(!r)return;let d=r.initColor(Hi.Golden);d.addPt(o),d.addPoint(o.end()),r.initColor(Hi.RED).addPt(l),r.draw();debugger}let o=e.getShape(),l=i?t.getShape():t.getShape().reverse(),c=kt(o,l.start()),u=kt(l),h=c.cross(u);if(ru(h,0))if(o instanceof ie)if(l instanceof ie){if(_e.eq(h,0)&&(c.dot(u)>0?!It(o.end(),l.start()):!It(o.start(),l.start())))throw a(),new Error("line and line");return h<0}else{if(l instanceof Se)return c.cross(l.center.sub(o.start()))<0;if(l instanceof Ye){let d=l.getExtremePoints(o),p=d.length?d[0]:Gf(l.controls,o.start());return c.cross(p.sub(o.start()))<0}else throw new Error("not support")}else if(o instanceof Se){if(l instanceof ie)return o.isCCW;if(l instanceof Se){if(l.center.equals1(o.center)&&(c.dot(u)>0?!It(o.end(),l.start())&&o.end().sub(l.start()).dot(u)>0:!It(o.start(),l.start())&&o.start().sub(l.start()).dot(u)>0))throw a(),new Error("arc and arc");return l.rx>=o.rx||l.center.distance2(o.center)>o.rx2?o.isCCW:!o.isCCW}else throw new Error("not support")}else if(o instanceof Ye)if(l instanceof ie){let d=o.getPercent(l.start(),Ft),p=o.clip(d)[1],f=p.getExtremePoints(l);return(f.length?f[0]:Gf(p.controls,l.start())).sub(l.start()).cross(u)<0}else if(l instanceof Ye){let d=o.getPercent(l.start(),Ft),p=o.clip(d)[1],f=p.getExtremePoints(new ie(l.start(),l.end())),m=l.getExtremePoints(new ie(p.start(),p.end())),g=f.length?f[0]:Gf(p.controls,l.start()),b=m.length?m[0]:Gf(l.controls,l.start()),y=g.sub(l.start()),E=b.sub(l.start());return y.cross(E)<0}else throw Error("not support");else throw new Error("not support");else return h<0}function dp(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Se?mc(s,Qt.toRadians(s.endAngle())):s instanceof Ye?Iy(s,1):s.end().sub(s.start()).normalize(),l=kt(a),c=o.dot(l);if(ru(c,-1))return ws(e,t,!0,n)?ws(e,i,r,n)&&ws(t,i,r,n):ws(e,i,r,n)||ws(t,i,r,n);{let u=o.scale(-1).angle(j.ORIGIN),h=l.angle(j.ORIGIN);u>h&&(u-=Zb);let d=(u+h)/2,p=new j(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=kt(f);return p.cross(m)<0?ws(e,i,r,n):ws(t,i,r,n)}}function gv(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Se?mc(s,Qt.toRadians(s.endAngle())):s instanceof Ye?Iy(s,1):s.end().sub(s.start()).normalize(),l=kt(a),c=o.dot(l);if(ru(c,-1))return ws(e,t,!0,n)?ws(e,i,r,n)&&ws(t,i,r,n):ws(e,i,r,n)||ws(t,i,r,n);{let u=o.scale(-1).angle(j.ORIGIN),h=l.angle(j.ORIGIN);u>h&&(u-=Zb);let d=(u+h)/2,p=new j(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=kt(f);if(p.cross(m)<0){let g=o.dot(m)<0,b=ma(g?e.getShape().reverse():e.getShape(),f).state;return b!==3&&b!==4?ws(e,i,r,n):b===(g?4:3)}else{let g=l.dot(m)<0,b=ma(g?t.getShape().reverse():t.getShape(),f).state;return b!==3&&b!==4?ws(t,i,r,n):b===(g?4:3)}}}var eu,Jh=!1;function $o(e,t,i,r,n,s,a,o=i.side===t,l=!0,c){return eu=n,Jh=s,BP(kP(e,t,l,c,a,i,o,r),i,o,r,0)}function Wu(e,t,i,r,n,s,a,o=r.side===i){eu=n,Jh=s;let l=FP(e,t,i,new Map,r,o,a),c=l instanceof Array?-1:1;return BP(l,r,o,a,c)}function BP(e,t,i,r,n){for(;e instanceof Array;)n++,e.length===4?e=FP(...e,t,i,r):e=kP(...e,t,i,r);return{...e,existOverlap:n>0}}function kP(e,t,i,r,n,s,a,o){if(qb===-1){o.initColor(Hi.RED).addPt(e.getShape()),o.initColor(Hi.Golden).addPt(t.getShape()),o.draw();debugger}let l=e.getShape(),c=a?t.getShape().reverse():t.getShape(),u=(l instanceof Se?mc(l,i?c.start().angle(l.center):r?Qt.toRadians(l.endAngle()):void 0):l instanceof Ye?kt(l,i?c.start():r?l.end():l.start()):l.end().sub(l.start())).normalize(),h=(c instanceof Se?mc(c,i?void 0:(r?l.end():l.start()).angle(c.center)):c instanceof Ye?kt(c,i?void 0:r?l.end():l.start()):c.end().sub(c.start())).normalize();if(r===void 0){let f=u.dot(h);if(r=f<0,ru(f,0))return{state:ws(e,t,!a,o)?1:0,inter:qu(e,t,s,a,i,r,n)}}else if(r?u.dot(h)>0:u.dot(h)<0)if(i){let f,m=!0;if(l instanceof ie&&It(fc.foot(l,c.start()),r?l.end():l.start()))m=!1;else if(l instanceof Se||l instanceof Ye){let g=r?l.reverse():l,b=ma(c,l7(g,c.start()).reverse()).state;(b===1||b===2)&&(m=!1)}if(m){let g=!r;f=ma(g?l.reverse():l,c,o).state===(g?4:3)?1:0}else r?f=dp(e,e.nextSide,t,!a,o)?1:0:f=dp(e.prevSide,e,t,!a,o)?1:0;return{state:f,inter:qu(e,t,s,a,i,r,n)}}else return r?{state:ws(e,e.nextSide,!0,o)?0:1,inter:qu(e,t,s,a,i,r,n),isReversed:!0}:{state:ws(e.prevSide,e,!0,o)?0:1,inter:qu(e,t,s,a,i,r,n),isReversed:!0};let d,p=new Map([[3,4],[4,3],[0,1],[1,0],[2,2]]);if(i)if(e.judgeOverlapMap.has(t)&&!Jh){let f=e.judgeOverlapMap.get(t);d=r?p.get(f.state):f.state}else d=ma(r?l.reverse():l,c).state,(d===3||d===4)&&e.judgeOverlapMap.set(t,{state:r?p.get(d):d});else{if(t.judgeOverlapMap.has(e)&&!Jh){let f=t.judgeOverlapMap.get(e);d=a?p.get(f.state):f.state}else d=ma(c,r?l.reverse():l).state,(d===3||d===4)&&t.judgeOverlapMap.set(e,{state:a?p.get(d):d});d=p.get(d)}if(d===1||d===2){let f=a?t.prevSide:t,m=f.inters,g=f.getEnd();for(let b=m.length-1;b>=0;b--){let y=m[b];if(!(f.getShape()instanceof Ye)&&!It(g,y.coord))break;if(y===s)return{state:2,inter:qu(e,t,s,a,i,r,n)}}}if(d===3||d===4)return{state:d===(r?4:3)?1:0,inter:qu(e,t,s,a,i,r,n)};if(n.has(e)?n.get(e).mapSideList.push(t):n.set(e,{sideIsReversed:r,mapSideList:[t]}),n.has(t)?n.get(t).mapSideList.push(e):n.set(t,{sideIsReversed:a,mapSideList:[e]}),d===2)return r?[e.prevSide,e,a?t.prevSide:t.nextSide,n]:[e,e.nextSide,a?t.prevSide:t.nextSide,n];if(d===0)return[r?e.prevSide:e.nextSide,t,!1,r,n];if(d===1)return[e,a?t.prevSide:t.nextSide,!0,r,n];throw Error("not support")}function qu(e,t,i,r,n,s,a){if(Jh)return null;let o=e.getShape(),l=r?t.getShape().reverse():t.getShape(),c=r;if(!n){let p=t;t=e,e=p,r=s,i=i.getBindedInter()}let u=p=>!(n?s:c)&&It(p,e.prevSide.getEnd())?e.prevSide:e;if(r){let p=t.inters;for(let f=0;f<p.length;f++){let m=p[f];if(m.isInvalid&&s===void 0)continue;if(m===i&&It(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,b=u(m.coord);if(g===b&&h(m))return d(m)}for(;;){t=t.nextSide;let f=t.inters;for(let m=0;m<f.length;m++){let g=f[m];if(g===i)return n?g:g.getBindedInter();if(a.has(t)){let b=g.getBindedInter().side;if(a.get(t).mapSideList.includes(b)||It(g.coord,b.getEnd())&&a.get(t).mapSideList.includes(b.nextSide))return d(g);if(a.has(b)){let y=t.getShape().reverse(),E=kt(y,g.coord).dot(kt(b.getShape(),g.coord))<0,S=E?b.getShape().reverse():b.getShape(),w=ma(y,E?uv(S,g.coord,S.end()):uv(S,S.start(),g.coord)).state;if(w===1||w===2)return d(g)}else a.has(b.nextSide)}else if(g.side===i.side&&h(g))return d(g)}}}else{let p=t.inters;for(let f=p.length-1;f>=0;f--){let m=p[f];if(m.isInvalid&&s===void 0)continue;if(m===i&&It(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,b=u(m.coord);if(g===b&&h(m))return d(m)}for(;;){t=t.prevSide;let f=t.inters;for(let m=f.length-1;m>=0;m--){let g=f[m];if(g===i)return n?g:g.getBindedInter();if(a.has(t)){let b=g.getBindedInter().side;if(a.get(t).mapSideList.includes(b)||It(g.coord,g.getBindedInter().side.getEnd())&&a.get(t).mapSideList.includes(b.nextSide))return d(g);if(!a.has(b)&&a.has(b.prevSide)){let y=t.getShape().reverse(),E=kt(y,g.coord).dot(kt(b.getShape(),g.coord))<0;if(a.has(b.prevSide)){let S=E?b.getShape().reverse():b.getShape(),w=ma(t.getShape(),uv(S,g.coord,S.end())).state;if(w===1||w===2)return d(g)}}}else if(g.side===i.side&&h(g))return d(g)}}}function h(p){if(p.isInvalid||p.getBindedInter().side!==(It(p.coord,e.prevSide.getEnd())?e.prevSide:e))return!1;let f;if(n){if(It(p.coord,l.start()))return!0;f=ma(s?o.reverse():o,m(l)).state}else{if(It(p.coord,s?o.end():o.start()))return!0;f=ma(l,m(s?o.reverse():o)).state}return f===2||f===1;function m(g){if(g instanceof ie)return It(p.coord,g.end())?g:g.cutLine(p.coord);if(g instanceof Se)return Se.build2(g.center,g.startAngle,p.coord.angleD(g.center),g.rx,g.ry,g.isCCW?1:0);if(g instanceof Ye)return g.clip(g.getPercent(p.coord,Ft))[0];throw new Error("not supported operation")}}function d(p){let f=i.getBindedInter(),m=i.side,g=f.side,b=i===p,y=i;if(r){let E=i.getIndex()-1;for(;m;){let S=m.inters;for(;E>=0;E--)if(i=S[E],i===p){b||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(eu===0)!i.isInvalid&&(!It(i.coord,p.coord)||i.side===p.side&&i.getBindedInter().side===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(eu===1){if(i.isInvalid)continue;let w=i.getBindedInter().side;a.has(m)&&a.get(m).mapSideList.includes(w)&&(i.setIsInvalid(),i.isDealed(),y=i)}m=m==null?void 0:m.prevSide,E=(m==null?void 0:m.inters.length)-1}}else{let E=i.getIndex()+1;for(;m;){let S=m.inters;for(;E<S.length;E++){i=S[E];let w=i.getBindedInter();if(i===p){b||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(eu===0)!i.isInvalid&&(!It(i.coord,p.coord)||m===p.side&&(It(w.side.getEnd(),i.coord)?w.side.nextSide:w.side)===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(eu===1){let x=w.side;a.has(m)&&a.get(m).mapSideList.includes(x)&&(i.setIsInvalid(),i.isDealed(),y=i)}}m=m==null?void 0:m.nextSide,E=0}}if(eu===0&&!It(f.coord,p.coord))if(n?a.has(g)?a.get(g).sideIsReversed:s:c){let E=f.getIndex()-1;for(;g;){let S=a.has(g),w=g.inters;for(;E>=0;E--){if(f=w[E],f===p.getBindedInter()){g=null;break}f.isInvalid||!S||(!It(f.coord,p.getBindedInter().coord)||f.side===p.side&&f.getBindedInter().side===p.getBindedInter().side)&&(f.setIsInvalid(),f.isDealed())}g=g==null?void 0:g.prevSide,E=(g==null?void 0:g.inters.length)-1}}else{let E=f.getIndex()+1;for(;g;){let S=g.inters,w=a.has(g);for(;E<S.length;E++){if(f=S[E],f===p.getBindedInter()){g=null;break}let x=It(g.getEnd(),f.coord)?a.has(g.nextSide):!1;f.isInvalid||!(w||x)||(!It(f.coord,p.getBindedInter().coord)||f.side===p.side&&f.getBindedInter().side===p.getBindedInter().side)&&(f.setIsInvalid(),f.isDealed())}g=g==null?void 0:g.nextSide,E=0}}return n?y:y.getBindedInter()}}function FP(e,t,i,r,n,s,a){let o=e.getShape(),l=t.getShape(),c=s?i.getShape().reverse():i.getShape(),u=(o instanceof Se?mc(o,c.start().angle(o.center)):o instanceof Ye?kt(o,c.start()):o.end().sub(o.start())).normalize(),h=(l instanceof Se?mc(l,c.start().angle(l.center)):l instanceof Ye?kt(l,c.start()):l.end().sub(l.start())).normalize(),d=u.dot(h);if(ru(d,-1)){let p=s?i.getShape().reverse():i.getShape(),f=kt(p).normalize(),m=u.add(h.scale(-1)).normalize().dot(f),g=ma(o.reverse(),l,a).state;if(m>-.9&&(g===3||g===4))return{state:g===4?0:1,inter:qu(t,i,n,s,!0,!1,r)};let b=$o(e,i,n,a,eu,Jh,r.size===0?new Map:r,s);return b.state===2?b:g===4?b.state===0||b.inter!==n?b:$o(t,i,n,a,eu,Jh,r.size===0?new Map:r,s):b.state===1||b.inter!==n?b:$o(t,i,n,a,eu,Jh,r.size===0?new Map:r,s)}else{let p=u.scale(-1).angle(j.ORIGIN),f=h.angle(j.ORIGIN);p>f&&(p-=Zb);let m=(p+f)/2,g=new j(Math.cos(m),Math.sin(m)),b=kt(c).normalize(),y=b.angle(j.ORIGIN),E=p<y&&y<f&&o instanceof ie&&l instanceof ie&&c instanceof ie;if(g.cross(b)<=0){if(u.scale(-1).dot(b)<0){let S;return n.coord.equals1(c.start())?S=kt(o,n.coord).dot(kt(c,n.coord))<0:c instanceof ie&&(S=kt(o,o.end()).dot(c.direct)<0),{state:dp(e,t,i,!s,a)?1:0,inter:qu(e,i,n,s,!0,S,r)}}return E&&o.distance2(c.start())>ga?[t,i,!0,void 0,r]:[e,i,!0,void 0,r]}else return h.dot(b)<=0?{state:dp(e,t,i,!s,a)?1:0,inter:qu(t,i,n,s,!0,void 0,r)}:E&&l.distance2(c.start())>ga?[e,i,!0,void 0,r]:[t,i,!0,void 0,r]}}var qb=0;function z7(e,t,i,r){let n=t.getBindedInter(),s=t.side,a=n.side,o=s.getShape(),l=a.getShape();if(r&&(qb++,qb===-1)){r.initColor(Hi.RED).addPt(o),r.initColor(Hi.Golden).addPt(l),r.draw();debugger}let c=0,u=!1;if(e===-1){let I=Wu(s,s.nextSide,a,n,c,u,r),A=I.state!==0;if(I.state===2){let R=kt(o,t.coord).add(kt(s.nextSide.getShape(),t.coord)).normalize(),M=kt(l,t.coord).add(kt(a.nextSide.getShape(),t.coord)).normalize();return x(A,R.dot(M)>0)}let O=Wu(s,s.nextSide,a.nextSide,n,c,u,r);return I.state!==O.state?(w(I,O),1):x(A,I.state!==Wu(a,a.nextSide,s,t,c,!0,r).state,I.inter,O.inter)}if(e===1){let I=$o(s,a,n,r,c,u,new Map),A=I.state!==0;if(I.state===2)return x(A,kt(o,t.coord).dot(kt(l,t.coord))>0);let O;if(I.isReversed&&I.existOverlap&&It(I.inter.coord,a.getEnd())&&I.inter.getBindedInter().side!==s){let F=I.inter.getBindedInter().side;if(F===s.nextSide)O={state:dp(s,F,a.nextSide,!0,r)?1:0,inter:n};else if(F===s.prevSide){if(O={state:dp(F,s,a.nextSide,!0,r)?1:0,inter:I.inter},I.state===O.state&&t!==I.inter){let G=kt(l,t.coord),V=kt(a.nextSide.getShape(),t.coord),q=kt(F.getShape(),t.coord);return x(A,G.add(V).dot(q)>0,I.inter,O.inter)}}else O=$o(s,a.nextSide,n,r,c,u,new Map)}else O=$o(s,a.nextSide,n,r,c,u,new Map);if(I.state!==O.state)return w(I,O),1;let R=kt(l,t.coord),M=kt(a.nextSide.getShape(),t.coord);if(ru(R.dot(M),-1)){let F=ws(a,a.nextSide,!0,r);return x(A,I.state!==$o(a.nextSide,s,t,r,c,!0,new Map,F?!A:A,!1).state,I.inter,O.inter)}else{let F=kt(o,t.coord);return x(A,R.add(M).dot(F)>0,I.inter,O.inter)}}if(!(o instanceof Ye||l instanceof Ye))return 1;let h=kt(o,t.coord),d=kt(l,t.coord),p,f;if(l instanceof ie)p=new ie(t.coord,l.start()),f=new ie(t.coord,l.end());else if(l instanceof Se){let I=t.coord.angleD(l.center);p=Se.build2(l.center,I,l.startAngle,l.rx,l.ry,l.isCCW?0:1),f=Se.build2(l.center,I,l.endAngle(),l.rx,l.ry,l.isCCW?1:0)}else if(l instanceof Ye){let I=l.getPercent(t.coord,Ft);[p,f]=l.clip(I),p=p.reverse()}else throw new Error("not support");let m=h.dot(d)>0,g,b;m?(g=ma(o.reverse(),p).state,b=ma(o,f).state):(g=ma(o,p).state,b=ma(o.reverse(),f).state);let y;g===0?y=$o(m?s.prevSide:s.nextSide,a,n,r,c,u,new Map,!0,!1,m):g===1?y=$o(s,a.prevSide,n,r,c,u,new Map,!0,!0,m):g===2?m?y=Wu(s.prevSide,s,a.prevSide,n,c,u,r,!0):y=Wu(s,s.nextSide,a.prevSide,n,c,u,r,!0):m?g===3?y={inter:n,state:0}:y={inter:n,state:1}:g===3?y={inter:n,state:1}:y={inter:n,state:0};let E=y.state!==0;if(y.state===2)return x(E,m);let S;if(b===0?S=$o(m?s.nextSide:s.prevSide,a,n,r,c,u,new Map,!1,!1,!m):b===1?S=$o(s,a.nextSide,n,r,c,u,new Map,!1,!0,!m):b===2?m?S=Wu(s,s.nextSide,a.nextSide,n,c,u,r,!1):S=Wu(s.prevSide,s,a.nextSide,n,c,u,r,!1):m?b===3?S={inter:n,state:1}:S={inter:n,state:0}:b===3?S={inter:n,state:0}:S={inter:n,state:1},y.state===S.state)return y.inter===S.inter?(t.setIsInvalid(),0):x(E,m,y.inter,S.inter);return w(y,S),1;function w(I,A){let O=I.state!==0;if(I.inter===A.inter){t.setOutToIn(O);return}else Of(I.inter,A.inter,!0),Of(A.inter,I.inter,!1);let R=[];if(e===-1){let F=kt(o,t.coord),G=kt(s.nextSide.getShape(),t.coord),V=kt(l,t.coord),q=kt(a.nextSide.getShape(),t.coord);R.push(F.dot(V)),R.push(F.dot(q)),R.push(G.dot(V)),R.push(G.dot(q))}else{let F=kt(o,t.coord);R.push(kt(l,t.coord).dot(F)),R.push(kt(a.nextSide.getShape(),t.coord).dot(F))}if(R.reduce((F,G)=>Math.abs(F)>Math.abs(G)?F:G,0)>0)if(i===1||i===0||i===2||i===3)t.setOutToIn(O);else throw new Error("not support");else if(i===1)M(!O);else if(i===0||i===2||i===3)M(O);else throw new Error("not support");function M(F){t.setIsInvalid();let G=(F?I:A).inter;delete G.isInvalid,delete G.getBindedInter().isInvalid,G.setOutToIn(!O)}}function x(I,A,O,R){if(O===R){if(t.side.outline.inters.find(G=>!G.isInvalid&&G!==t&&It(G.coord,t.coord)))return t.setIsInvalid(),0;let M=new Ju(t.coord,s,r),F=new Ju(t.coord,a,r);return M.bind(F),A?s.inters.splice(t.getIndex(),0,M):s.inters.splice(t.getIndex()+1,0,M),a.inters.splice(t.getBindedInter().getIndex(),0,F),M.setOutToIn(I),t.setOutToIn(!I),M.isDealed(),s.inters.forEach((G,V)=>G.setIndex(V)),a.inters.forEach((G,V)=>G.setIndex(V)),2}else{let M=function(){let F=O.getBindedInter(),G=R.getBindedInter();delete O.isInvalid,delete F.isInvalid,delete R.isInvalid,delete G.isInvalid,O.setOutToIn(!I),R.setOutToIn(I),Of(O,R,!0),Of(R,O,!1),Of(F,G,A),Of(G,F,!A)};if(t.setIsInvalid(),A){if(i===1||i===0||i===2||i===3)return M(),2;throw new Error("not support")}else{if(i===1)return I?0:(M(),2);if(i===0||i===2||i===3)return I?(M(),2):0;throw new Error("not support")}}}}function Of(e,t,i){let{judge:r,changeNum:n}=a(),s=e.getIndex();for(let o=s+n,l=e.side.inters;r(o);o+=n){if(l[o].isInvalid)continue;if(!It(l[o].coord,e.coord))break;l[o].setIndex(s),l[s].setIndex(o);let c=l[o];l[o]=l[s],l[s]=c,s=o}function a(){let o=e.side===t.side;if(i){let l=o?t.getIndex():e.side.inters.length;return{judge:c=>c<l,changeNum:1}}else{let l=o?t.getIndex()+1:0;return{judge:c=>c>=l,changeNum:-1}}}}var uP=0,Ju=class{constructor(e,t,i){this.id=uP++,this.coord=e,this.side=t,i&&(this.id=uP++,this.drawDebug=i);let r=new ot;r.ext2(e),this._bbox=r.build1()}bbox(){return this._bbox}resetVisitStatus(){this.visited=!1,this.bindedInter.visited=!1}isDealed(){this.dealed=!0,this.getBindedInter().dealed=!0}setOutToIn(e){this.outToIn=e,this.bindedInter.outToIn=!e}setIsInvalid(){this.isInvalid=!0,this.getBindedInter().isInvalid=!0}getBindedInter(){return this.bindedInter}bind(e){this.bindedInter=e,e.bindedInter=this}setIndex(e){this.index=e}isSorted(){return this.index!==void 0}getIndex(){return this.index}getVisited(){return this.visited}visitSelf(){this.visited=!0}visit(){this.visited=!0,this.bindedInter.visited=!0}getPrevPoint(){let e=this.getIndex(),t=this.side.getStart();return e&&(t=this.side.inters[e-1].coord),t}getTangent(){let e=this.side.getShape();if(e instanceof ie)return e.end().sub(e.start());if(e instanceof Se){let t=this.coord.angle(e.center);return e.isCCW?t+=Yb:t-=Yb,new j(Math.cos(t),Math.sin(t))}else{if(e instanceof Ye)return Iy(e,e.getPercent(this.coord,Ft));throw new Error("not support")}}findStartInter(){return this.outToIn===void 0?this.getTangent().cross(this.bindedInter.getTangent())>0?this:this.bindedInter:this.outToIn?this:this.bindedInter}run(){let e=[],t=this,i;if(this.drawDebug){yv++;let r=yv===-1,n=this.drawDebug.initColor(Hi.RED);if(r){this.drawDebug.draw();debugger}i=s=>{if(e.push(s),r){n.addPt(e[e.length-1]),this.drawDebug.draw();debugger}}}else i=r=>e.push(r);for(;!t.visited;){let r=function(o,l){if(_e.eq(o.distance2(l),0))return;let c=Ly.rebuild(s.getShape(),o,l);if(!c)return!0;i(c)};t.visit();let n=t.getIndex(),s=t.side,a=s.inters[n+1];for(;a!=null&&a.isInvalid;)a=s.inters[a.getIndex()+1];if(a)r(t.coord,a.coord),t=a.bindedInter;else{let o=r(t.coord,s.getEnd()),l=t.coord;for(s=s.nextSide,t=null;;){for(let c of s.inters)if(!c.isInvalid){t=c.bindedInter;break}if(t)break;o?(r(l,s.getEnd()),o=!1):i(s.getShape()),s=s.nextSide}o?(_e.eq(l.distance2(t.coord),0)?r(l,s.getEnd()):r(l,t.coord),o=!1):_e.eq(s.getEnd().distance2(t.coord),0)?i(s.getShape()):r(s.getStart(),t.coord)}}if(t!==this)throw this.drawDebug&&console.log(JSON.stringify({runId:yv,handleId:qb,boolId:by})),new Error("inter !== this");return Al(Tt.build7(e))}},yv=0,bv=class Bv{constructor(t,i,r,n,s){this.inters=[],this.allInterIsInvalid=!0,this.isVisit=!1,this.sides=t,this.isGroup1=r,this.isOutside=n,this.finalIsOutside=n,this.polyline=i,s&&(this.polygon=s),t.forEach(a=>a.outline=this)}static build(t,i,r,n,s){let a=t.primitives.map(l=>new Ly(l,n)),o=a[a.length-1];return a.forEach(l=>{o.connect(l),o=l}),s?new Bv(a,t,i,r,s):new Bv(a,t,i,r)}setFinalIsOutSide(t){this.finalIsOutside=t}startAndEndIsSameOutsideFlag(){return this.isOutside===this.finalIsOutside}get hasInter(){return!!this.interOutlines}isAllInterIsInvalid(){return this.allInterIsInvalid}setAllInterIsInvalidToFalse(){this.allInterIsInvalid=!1}resetVisited(){this.isVisit=!1}intersect(t,i){if(!(t.interOutlines&&t.interOutlines===this.interOutlines))if(t.interOutlines)if(this.interOutlines){let r,n;this.interOutlines.length>t.interOutlines.length?(r=this.interOutlines,n=t.interOutlines):(r=t.interOutlines,n=this.interOutlines),n.forEach(s=>{r.push(s),s.interOutlines=r}),i.delete(n)}else t.interOutlines.push(this),this.interOutlines=t.interOutlines;else this.interOutlines?(this.interOutlines.push(t),t.interOutlines=this.interOutlines):(t.interOutlines=this.interOutlines=[this,t],i.add(this.interOutlines))}isContain(t){if(!this.polyline.bbox().extendOfSize(Ft).isContainsBBox(t.polyline.bbox()))return!1;let i=t.polyline.primitives[0].start();if(t.hasInter&&t.isAllInterIsInvalid()){let r=t.inters[0];r.getBindedInter().side.outline!==this?i=r.side.getCenterPoint():i=r.side.getCenterPoint(r.coord)}return!!this.polyline.getWindingNum(i)}isInternally(t){return!!this.polyline.getWindingNum(t)}isEqual(t){return this.polyline===t.polyline}bbox(){return this.polyline.bbox()}reverse(){this.sides.reverse();let t=this.sides[this.sides.length-1];this.sides.forEach(i=>{i.reverse(),t.connect(i),t=i})}returnPolyline(){let t=this.sides.map(r=>r.getShape()),i=this.polyline.primitives;if(this.sides.length===i.length){let r=new Set(i);if(!t.some(n=>!r.has(n)))return this.polyline}return Tt.build7(t)}};function hP(e,t,i){let r=[];return e.forEach(n=>n.forEach(s=>{if(s.hasInter&&!s.isAllInterIsInvalid())return;let a=s.bbox(),o=t.search(a.extendOfSize(Ft)).filter(l=>l.bbox().extendOfSize(Ft).isContainsBBox(a)).sort((l,c)=>l.bbox().area()-c.bbox().area());for(let l of o)if(l.isContain(s)){let c=i(!s.isOutside,l.isOutside),u=i(s.isOutside,l.isOutside);c!==u&&(r.push(s),s.setFinalIsOutSide(!c));return}i(s.isOutside,!1)!==i(!s.isOutside,!1)&&r.push(s)})),r}function X7(e,t,i){let r;switch(i){case 0:r=(o,l)=>o&&l;break;case 1:r=(o,l)=>o||l;break;case 2:r=(o,l)=>o&&!l;break;case 3:r=(o,l)=>o&&!l||!o&&l;break;default:throw Error("not support the rule")}let n=new Ay(10),s=new Ay(10);e.forEach(o=>o.forEach(l=>n.add(l))),t.forEach(o=>o.forEach(l=>s.add(l)));let a=hP(e,s,r);return hP(t,n,(o,l)=>r(l,o)).forEach(o=>a.push(o)),a}var W7=class{constructor(e){this.roots=[],this.nodes=e.sort((t,i)=>t.bbox().minX-i.bbox().minX).map(t=>new q7(t)),this.nodes.forEach((t,i)=>{t.visit()&&(this.roots.push(t),this.build(i))})}build(e){let t=this.nodes[e];for(let i=e+1,r=this.nodes.length;i<r;i++){let n=this.nodes[i];if(t.key.bbox().maxX<n.key.bbox().minX)break;n.getIsVisit()||t.isContain(n)&&(n.visit(),t.addChild(n),this.build(i))}}getPolygons(){let e=[];return this.roots.forEach(t=>t.getPolygons().forEach(i=>e.push(i))),e}},q7=class{constructor(e){this.children=[],this.isVisit=!1,this.key=e}getIsVisit(){return this.isVisit}isContain(e){return this.key.isContain(e.key)}addChild(e){this.children.push(e)}getPolygons(){let e=[];return this.getPolylineList(e),e.map(t=>{let i=t[0].polygon;if(i&&i.items.length===t.length){let r=t.map(s=>s.returnPolyline()),n=new Set(i.items);return r.some(s=>!n.has(s))?new rn(r):i}else return new rn(t.map(r=>r.returnPolyline()))})}getPolylineList(e,t){t?(t.push(this.key),t=null):(t=[this.key],e.push(t)),this.children.forEach(i=>i.getPolylineList(e,t))}visit(){return this.isVisit?!1:(this.isVisit=!0,!0)}};function dP(e){let t="";return e.items.forEach((i,r)=>{let n="$";if(i.items.forEach((s,a)=>{let o="[";if(s.primitives.forEach((l,c)=>{let u="";if(l instanceof ie)u=`Line,${l.start().x},${l.start().y},${l.end().x},${l.end().y}`;else if(l instanceof Se)u=`Arc,${l.center.x},${l.center.y},${l.startAngle},${l.sweepAngle},${l.rx}`;else if(l instanceof Ye)u=`Bezier,${l.controls.map(h=>`${h.x},${h.y}`).join(",")}`;else throw new Error("not supported");if(c===s.primitives.length-1){o+=`${u}]`;return}o+=`${u},`}),a===i.items.length-1){n+=`${o}$`;return}n+=`${o}_`}),r===e.items.length-1){t+=`${n}`;return}t+=`${n}^`}),console.log(t),t}function pP(e){let t=e.split("^"),i=[];return t.forEach(n=>{let s=/\$(.*?)\$/,a=n.match(s)[1].split("_"),o=[];a.forEach(c=>{let u=/\[(.*?)\]/,h=c.match(u)[1].split(","),d=[],p=[];for(let m=0;m<h.length;m++){let g=h[m];if(g==="Line"||g==="Arc"||g==="Bezier"){if(d.length){let b=r(d);p.push(b),d.length=0}d.push(g);continue}d.push(Number(g))}d.length&&(p.push(r(d)),d.length=0);let f=Tt.build7(p);o.push(f)});let l=new rn(o);i.push(l)}),new wr(i);function r(n){let s=n[0];if(s==="Line")return new ie(new j(n[1],n[2]),new j(n[3],n[4]));if(s==="Arc")return Se.build3(new j(n[1],n[2]),n[3],n[4],n[5],n[5]);if(s==="Bezier"){let a=[];for(let o=1;o<n.length;o+=2)a.push(new j(n[o],n[o+1]));return new Ye(a)}else throw new Error("not support")}}var J7=class{constructor(e=1){this.group1Str="$[Line,20193.777980000017,4122.200439600661,20193.77082,4211.848760073709,Arc,20193.972672902382,4211.8487570980205,179.99915535323618,-89.99540000050294,0.2018529024026465,Line,20193.972659672283,4212.050609999989,20193.972660393258,4212.039610000013,Arc,20193.97217289501,4211.848257065248,89.85403133887164,89.99540000041924,0.19135355574930143,Line,20193.78082,4211.848759926291,20193.78897999998,4122.200440479205,Line,20193.78897999998,4122.200440479205,20193.777980000017,4122.200439600661]$",this.group2Str="$[Arc,20209.72784128151,4122.2007625157785,258.46768032837986,-75.66780748375947,4.138846238512183,Line,20205.593935808283,4121.998590004101,20193.97982992629,4121.998600000001,Arc,20193.97983290198,4122.2004529023825,269.9991553532362,-89.99540000050297,0.20185290240401074,Arc,20193.782979999996,4122.20044,180.00375535340328,-180.0000000000027,0.004999999999025513,Arc,20193.979332869207,4122.200952909754,180.15347936671733,89.99540000008247,0.19135355575111057,Line,20193.97983008845,4122.009599999999,20205.603694309226,4122.003828485546,Arc,20209.733142304296,4122.194577876843,182.64475341258483,75.73379999998886,4.133851239977064,Line,20208.900400396684,4118.145470939558,20208.902599535475,4118.156248870184,Arc,20206.972515961093,4108.700057667588,78.46393309088245,-78.46759999998636,9.65115405866796,Arc,20216.618669999996,4108.69944,359.99996825446135,-180,0.004999999999200412,Arc,20206.973015966745,4108.699445349495,359.99996822365375,78.46759999998409,9.640654033253735]$^$[Line,20193.997796883676,4095.399470032799,20205.596133314026,4095.4013992171836,Arc,20209.72470159858,4095.1923799234505,177.10172964919312,-75.64935037184974,4.133855965730166,Arc,20209.73000213952,4095.198565517174,101.5415133143569,75.7293000000185,4.128850963459707,Line,20205.605834328744,4095.395161923586,20193.997203529463,4095.389485743675,Arc,20193.994588809255,4095.197684525904,89.21896662213764,4.544099999999517,0.19181903946188483,Arc,20193.981499796217,4095.1977402038,89.85034659953621,89.9999999995926,0.19135044893494071,Arc,20193.78515,4095.19824,0,-180,0.005,Arc,20193.98200016982,4095.1982398301675,179.99995179248322,-89.99999999974185,0.20185016982129908,Arc,20193.981986624152,4095.198185381971,89.9961078637802,-4.487285276547311,0.2019046184835962]$",this.rule=e}getGroup1(){return pP(this.group1Str)}getGroup2(){return pP(this.group2Str)}},xv=new $b(2),yy=class{getUnion(e,t=!0){return t&&(e=e.map(i=>this.asSameSweep([i])[0])),M7(y7,e)}asSameSweep(e){let t=0;return e.forEach(i=>t+=i.area(.01)),t>0?e.map(i=>i.reverse()):e}getSubtraction(e,t){let i=new vy(!1),r=new Ty(Mb.rule,xv,i);for(let n of e){let s=Mb.weight(0);r.addPolyline(n,s)}for(let n of t){let s=Mb.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getIntersection(e,t){let i=new vy(!1),r=new Ty(Bb.rule,xv,i);for(let n of e){let s=Bb.weight(0);r.addPolyline(n,s)}for(let n of t){let s=Bb.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getMutuallyExclusive(e,t){let i=new vy(!1),r=new Ty(dv.rule,xv,i);for(let n of e){let s=dv.weight(0);r.addPolyline(n,s)}for(let n of t){let s=dv.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}},by=0,Ev=!1;function xy(e,t,i,r,n){let s=fp(),a=[],o=[],l=[],c=new Set,u;if(n){if(u=new Py(n),by++,Ev){debugger;Ev=!1;let S=new J7;xy(S.rule,S.getGroup1(),S.getGroup2(),r,n)}if(by===-1||Ev){console.table({rule:e,group1:dP(t),group2:dP(i)}),u.clear();let S=u.initColor(Hi.GREEN),w=u.initColor(Hi.WHITE),x=u.initColor(Hi.BLUE),I=u.initColor(Hi.Gray);t.items.forEach(A=>A.items.forEach((O,R)=>{R>0?w.addPly(O):S.addPly(O)})),i.items.forEach(A=>A.items.forEach((O,R)=>{R>0?I.addPly(O):x.addPly(O)})),u.draw();debugger}}let h=t.items.length!==0&&i.items.length!==0?t.bbox().extendOfSize(Ft).intersection1(i.bbox().extendOfSize(Ft)):null;if(h){let S=[],w=[];switch(e){case 0:{for(let x of t.items)x.bbox().isIntersect(h)&&S.push(x);for(let x of i.items)x.bbox().isIntersect(h)&&w.push(x);break}case 1:case 3:{for(let x of t.items)x.bbox().isIntersect(h)?S.push(x):a.push(x);for(let x of i.items)x.bbox().isIntersect(h)?w.push(x):a.push(x);break}case 2:{for(let x of t.items)x.bbox().isIntersect(h)?S.push(x):a.push(x);for(let x of i.items)x.bbox().isIntersect(h)&&w.push(x);break}default:throw new Error("not support")}S.length!==t.items.length&&(t=new wr(S)),w.length!==i.items.length&&(i=new wr(w))}else{switch(e){case 0:break;case 1:case 3:{t.items.forEach(S=>a.push(S)),i.items.forEach(S=>a.push(S));break}case 2:{t.items.forEach(S=>a.push(S));break}default:throw new Error("not support")}t=new wr([]),i=new wr([])}y(t,o,!0),y(i,l,!1);let d=e===2||e===3?(S,w)=>It(S.getEnd(),w)?S.nextSide:S:(S,w)=>It(S.prevSide.getEnd(),w)?S.prevSide:S,p=(S,w,x)=>{if(It(S.getEnd(),x)){if(S.inters.findIndex(I=>I.getBindedInter().side===w&&It(I.coord,S.getEnd()))===-1)return new Ju(x,S,u)}else return new Ju(x,S,u)},f=e===2||e===3?(S,w,x)=>{if(It(S.getStart(),x)){if(S.inters.findIndex(I=>I.getBindedInter().side===w&&It(I.coord,S.getStart()))===-1)return new Ju(x,S,u)}else return new Ju(x,S,u)}:p;r.seek(t,i,(S,w,x,I,A,O)=>{let R=o[S][w],M=l[I][A],F=R.sides[x],G=M.sides[O],V=So(F.getShape(),G.getShape());if((F.getShape()instanceof Ye||G.getShape()instanceof Ye)&&V>=4){if(F.getShape()instanceof Se||G.getShape()instanceof Se){let C=function(T,L){let P=!1;for(let B=0;B<L.length;B+=2)It(new j(L[B],L[B+1]),T)&&(P=!0);P||L.push(T.x,T.y)},N=[se[0],se[1]];for(let T=0;T<V;T+=2){let L=new j(se[T],se[T+1]);for(let P=T+2;P<V;P+=2){let B=new j(se[P],se[P+1]);if(!It(L,B)){C(B,N);break}}}V=N.length,N.forEach((T,L)=>se[L]=T)}else for(let C=V-2;C>=2;C-=2)for(let N=C-2;N>=0;N-=2)if(It(new j(se[C],se[C+1]),new j(se[N],se[N+1]))){se[N]=(se[C]+se[N])/2,se[N+1]=(se[C+1]+se[N+1])/2;for(let T=V-3;T>=C;T--)se[T]=se[T+2];V-=2;break}}let q=0;if(V===4){let C=function(L){return It(F.getEnd(),L)||It(F.prevSide.getEnd(),L)||It(G.prevSide.getEnd(),L)||It(G.getEnd(),L)},N=new j(se[0],se[1]),T=()=>{let L=new Ju(N,F,u),P=new Ju(N,G,u);L.bind(P),L.setIsInvalid(),L.isDealed(),R.inters.push(L),M.inters.push(P)};if(se[0]===se[2]&&se[1]===se[3])if(C(N))q=2;else{T();return}}for(;q<V;q+=2){let C=new j(se[q],se[q+1]),N=F,T=G;if(It(N.prevSide.getEnd(),C)&&(N=N.prevSide),T=d(T,C),F!==N&&G!==T){let P=e===2||e===3?G.getEnd():T.getEnd();N.getEnd().distance1(C)<P.distance1(C)?(C=N.getEnd(),It(P,C)||(T=G)):(C=P,It(N.getEnd(),C)||(N=F))}let L=p(N,T,C);if(L){let P=f(T,N,C);P&&(N.addInter(L),R.inters.push(L),T.addInter(P),M.inters.push(P),L.bind(P),R.intersect(M,c))}}return V},n);let m=E(),g=X7(o,l,e);g.forEach(S=>!S.startAndEndIsSameOutsideFlag()&&S.reverse()),new W7(m.concat(g)).getPolygons().forEach(S=>a.push(S));let b=new wr(a);if(u){if(by===-1){let S=u.initColor(Hi.RED),w=u.initColor(Hi.Golden);a.forEach(x=>{S.addPly(x.items[0]),x.items.slice(1).forEach(I=>w.addPly(I))}),u.draw();debugger;throw new Error}b.id=by}return Il.BooleanTools+=tu(s),b;function y(S,w,x){S.items.forEach(I=>{let A=[];A.push(bv.build(I.items[0],x,!0,u,I)),I.items.slice(1).forEach(O=>{A.push(bv.build(O,x,!1,u))}),w.push(A)})}function E(){let S=[];return c.forEach(x=>{e===2||e===3?x.forEach(A=>{A.isGroup1||A.reverse(),A.sides.forEach(O=>O.sortInters())}):x.forEach(A=>A.sides.forEach(O=>O.sortInters())),x.map(A=>A.sides.filter(O=>O.inters.length)).flat(2).sort((A,O)=>{let R=A.inters,M=O.inters,F=It(R[R.length-1].coord,A.getEnd()),G=It(M[M.length-1].coord,O.getEnd());if(F&&G){let V=0,q=0;for(let C=R.length-2;C>=0&&It(R[C].coord,A.getEnd());C--)V++;for(let C=M.length-2;C>=0&&It(M[C].coord,O.getEnd());C--)q++;return q-V}else return F?-1:1}).forEach(A=>{A.inters.forEach(O=>{if(O.dealed)return;let R=O.side,M=O.getBindedInter().side,F;It(R.getEnd(),O.coord)&&It(M.getEnd(),O.coord)?F=-1:It(R.getEnd(),O.coord)?(F=1,O=O.getBindedInter()):It(M.getEnd(),O.coord)&&(F=1);let G=z7(F,O,e,u);O.isDealed(),G&&(R.outline.setAllInterIsInvalidToFalse(),M.outline.setAllInterIsInvalidToFalse())})}),I(x),e===3&&(x.forEach(A=>{A.reverse(),A.sides.forEach(O=>{O.sortInters(),O.inters.forEach(R=>{R.resetVisitStatus()})})}),I(x));function I(A){A.forEach(O=>{O.inters.forEach(R=>{if(R.isInvalid||R.getVisited())return;let M=R.findStartInter(),F=w(e)?M.run():M.getBindedInter().run(),G=O.polyline.primitives;if(F){if(G.length===F.primitives.length){let V=new Set(G);if(!F.primitives.some(q=>!V.has(q))){S.push(O);return}}S.push(bv.build(F,!0,!0,u))}})})}}),S;function w(x){switch(x){case 0:case 2:case 3:return!0;case 1:return!1;default:throw Error("not support the rule")}}}}var Db=/\bstablilizetion\b/.test(self.location.href)||!0,_b={intersect(e,t,i,r){try{return xy(0,e,t,i,r)}catch(n){if(Db){let s=new yy().getIntersection(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new wr(s.map(a=>new rn(a.items)))}throw n}},union(e,t,i,r){try{return xy(1,e,t,i,r)}catch(n){if(Db){let s=new yy,a=e.items.map(l=>l.items.map(c=>c)).flat(2);t.items.forEach(l=>l.items.forEach(c=>a.push(c)));let o=s.getUnion(a);return new wr(o.map(l=>new rn(l.items)))}throw n}},diff(e,t,i,r){try{return xy(2,e,t,i,r)}catch(n){if(Db){let s=new yy().getSubtraction(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new wr(s.map(a=>new rn(a.items)))}throw n}},xor(e,t,i,r){try{return xy(3,e,t,i,r)}catch(n){if(Db){let s=new yy().getMutuallyExclusive(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new wr(s.map(a=>new rn(a.items)))}throw n}}},K7=class extends Ty{constructor(e,t,i,r,n,s){super(e.rule,$b.DUMMY,t),this.sideGroup1=[],this.sideGroup2=[],this.group1=i,this.group2=r,this.seeker=n,this.addGroup(i,e.weight(0),this.sideGroup1),this.addGroup(r,e.weight(1),this.sideGroup2),this.bus=s}addGroup(e,t,i){if(!e)debugger;e.items.forEach(r=>{let n=[];r.items.forEach(s=>{let a=this.sides.length;this.addPolyline(s,t),n.push(this.sides.slice(a))}),i.push(n)})}seekIntersection(){this.seeker.seek(this.group1,this.group2,(e,t,i,r,n,s)=>{let a=this.sideGroup1[e][t][i],o=this.sideGroup2[r][n][s],l=So(a.shape,o.shape);for(let c=0;c<l;c+=2){let u=new j(se[c],se[c+1]);a.inters.push(u),o.inters.push(u),this.event.onIntersect(u,a,o)}return l},this.bus)}},$7=class extends vy{constructor(e){super(!!e),e&&(this.drawDebug=new Py(e),this.blueDrawing=this.drawDebug.initColor(Hi.BLUE),this.greenDrawing=this.drawDebug.initColor(Hi.GREEN),this.redDrawing=this.drawDebug.initColor(Hi.RED))}onOriginSide(e){super.onOriginSide(e),this.debug&&this.blueDrawing.addPt(e.shape)}onPolylineGroup(e,t){super.onPolylineGroup(e,t),this.debug&&e.items.forEach(i=>this.greenDrawing.addPly(i))}draw(){this.drawDebug.draw()}};function Sv(e,t,i,r,n){let s=fp(),a=new $7(n);new K7(e,a,t,i,r,n).simplify();let o=[];a.plGrps.forEach(c=>{let u=c.items.map(h=>Wb(h));u[0]&&o.push(new rn(u.filter(h=>h)))});let l=new wr(o);return Il.BooleanTools+=tu(s),l}var wv=!0,dy={intersect(e,t,i,r){try{return _b.intersect(e,t,i,r)}catch(n){if(wv)throw n;return console.error(n),Sv(Bb,e,t,i,r)}},union(e,t,i,r){try{return _b.union(e,t,i,r)}catch(n){if(wv)throw n;return console.error(n),Sv(b7,e,t,i,r)}},diff(e,t,i,r){try{return _b.diff(e,t,i,r)}catch(n){if(wv)throw n;return console.error(n),Sv(Mb,e,t,i,r)}},xor(e,t,i,r){return _b.xor(e,t,i,r)}},Z7=class{init(e){}seek(e,t,i,r){let n=e.bbox().extendOfSize(5e-6).intersection1(t.bbox().extendOfSize(5e-6));if(!n)return;let s=fp(),a=[];for(let d=0,p=e.items.length;d<p;d++){let f=e.items[d];if(n.isIntersect(f.bbox()))for(let m=0,g=f.items.length;m<g;m++){let b=f.items[m];if(n.isIntersect(b.bbox()))for(let y=0,E=b.primitives.length;y<E;y++){let S=b.primitives[y].bbox();n.isIntersect(S)&&a.push({bbox:S,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let o=a.length;if(o===0){Il.IntersectionSeeker+=tu(s);return}let l=[];for(let d=0,p=t.items.length;d<p;d++){let f=t.items[d];if(n.isIntersect(f.bbox()))for(let m=0,g=f.items.length;m<g;m++){let b=f.items[m];if(n.isIntersect(b.bbox()))for(let y=0,E=b.primitives.length;y<E;y++){let S=b.primitives[y].bbox();n.isIntersect(S)&&l.push({bbox:S,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let c=l.length;if(c===0){Il.IntersectionSeeker+=tu(s);return}if(o<5||c<5){for(let d=0,p=a.length;d<p;d++)for(let f=0,m=l.length;f<m;f++)if(a[d].bbox.isIntersect(l[f].bbox.extendOfSize(1e-5))){let g=a[d],b=l[f];i(g.polygonIndex,g.polylineIndex,g.ptIndex,b.polygonIndex,b.polylineIndex,b.ptIndex)}Il.IntersectionSeeker+=tu(s);return}a.sort((d,p)=>d.bbox.minX-p.bbox.minX),l.sort((d,p)=>d.bbox.minX-p.bbox.minX);let u=0,h=0;for(;u<o&&h<c;)if(a[u].bbox.minX<l[h].bbox.minX){let d=a[u],p=d.bbox;for(let f=h;f<c;f++){let m=l[f],g=m.bbox;if(g.minX>p.maxX+1e-5)break;(p.minY<g.minY?g.minY:p.minY)<(p.maxY<g.maxY?p.maxY:g.maxY)+1e-5&&i(d.polygonIndex,d.polylineIndex,d.ptIndex,m.polygonIndex,m.polylineIndex,m.ptIndex)}u++}else{let d=l[h],p=d.bbox;for(let f=u;f<o;f++){let m=a[f],g=m.bbox;if(g.minX>p.maxX+1e-5)break;(g.minY<p.minY?p.minY:g.minY)<(g.maxY<p.maxY?g.maxY:p.maxY)+1e-5&&i(m.polygonIndex,m.polylineIndex,m.ptIndex,d.polygonIndex,d.polylineIndex,d.ptIndex)}h++}Il.IntersectionSeeker+=tu(s)}},Mf=class Xu{static getDebug(){return Xu.drawDebug||(Xu.drawDebug=new Py(Xu.curBus)),Xu.drawDebug}static getDrawing(t=Hi.GREEN){return this.getDebug().initColor(t)}static clearDrawing(){Xu.getDebug().clear()}static drawText(t,i,r=Hi.GREEN){Xu.getDrawing(r).addText(t,i,1.5,.1,!0)}static drawBBox(t,i=Hi.GREEN){if(!t)return;let r=Xu.getDrawing(i),n=new ie(t.UL(),t.UR()),s=new ie(t.UR(),t.LR()),a=new ie(t.LR(),t.LL()),o=new ie(t.LL(),t.UL());r.addPt(n),r.addPt(s),r.addPt(a),r.addPt(o)}static drawPolyType(t,i){let r=Xu.getDrawing(i);if(t instanceof Tt)r.addPly(t);else if(t instanceof rn)for(let n of t.items)n instanceof Tt?r.addPly(n):this.drawPolyType(n,i);else if(t instanceof wr)for(let n of t.items)this.drawPolyType(n,i)}static translate(t){switch(t){case 0:return"\u2229";case 2:return"-";case 1:return"U";case 3:return"X";default:break}}};Mf.UseOptimizeSplit=!0,Mf.LocalBestThread=4,Mf.HandleDiff=!0,Mf.OcTreeSplitStep=4,Mf.PrintStart=new j(150,-200);var pa=Mf,py=class kv{static getPolyTypeLine(t){let i=[];if(t instanceof Tt)for(let r of t.primitives)i.push(r);else if(t instanceof rn)for(let r of t.items)if(r instanceof Tt)for(let n of r.primitives)i.push(n);else{let n=this.getPolyTypeLine(r);for(let s of n)i.push(s)}else if(t instanceof wr)for(let r of t.items){let n=this.getPolyTypeLine(r);for(let s of n)i.push(s)}return i}static getPolyTypePolyLine(t){let i=[];if(t instanceof Tt)i.push(t);else if(t instanceof rn)for(let r of t.items)if(r instanceof Tt)i.push(r);else{let n=this.getPolyTypePolyLine(r);for(let s of n)i.push(s)}else if(t instanceof wr)for(let r of t.items){let n=this.getPolyTypePolyLine(r);for(let s of n)i.push(s)}return i}static getListBBox(t){if(t.length<=0)return;let i=new ot;for(let r of t){let n=kv.getSingleBBox(r);i.ext1(n)}return i.build1()}static getSingleBBox(t){if(t instanceof Array){let i=new ot,r=kv.getListBBox(t.slice(1));return i.ext1(r),i.build1()}else return t.bbox()}static doDrawRule(t,i=pa.PrintStart){if(t.length<2)return[i,i,i];let r=5,n=10,s=t[0],a=pa.translate(s),o=[],l=i.y,c=i.x,u=i.x;i=i.add(new j(0,-n));for(let p=1;p<t.length;p++){let f=t[p];if(f instanceof Array){i=i.add(new j(r,0));let m=this.doDrawRule(f,i);o.push(m[0]),m[1].x<=c&&(c=m[1].x),m[2].x>=u&&(u=m[2].x),i=new j(m[2].x+r,i.y)}else o.push(i.clone()),i.x<=c&&(c=i.x),i.x>=u&&(u=i.x),pa.drawText(i,f.name),i=i.add(new j(r,0))}let h=0;for(let p of o)h+=p.x;let d=new j(h/o.length,i.y+n);pa.drawText(d,"N:"+a);for(let p of o){let f=new ie(p,d),m=new Array;m.push(f);let g=Tt.build1(Dv(m));pa.drawPolyType(g,Hi.GREEN)}return[d,new j(c,l),new j(u,l)]}static drawRule(t,i=pa.PrintStart,r=!1,n){pa.clearDrawing(),this.doDrawRule(t,i),r&&this.doDrawRulePolygon(t,n),pa.getDebug().draw()}static doDrawRulePolygon(t,i){let r=t[0];for(let n=1;n<t.length;n++){let s=t[n];if(s instanceof Array)this.doDrawRulePolygon(s,i);else{let a=i;r===2&&n===1&&(a=Hi.RED),s.name&&pa.drawText(s.bbox().UL(),s.name,a),pa.drawPolyType(s,a)}}}static IsCenterBBoxPointInPolygonType(t,i){let r=t.center();for(let n of i.items)if(n.getOutMostPolyline().getWindingNum(r))return!0;return!1}static KeepBBoxPolygonGroup(t,i){let r=i.bbox().intersection1(t);if(!r)return!1;for(let n of i.items)if(n.bbox().isIntersect(r)){for(let s of n.items)if(s.bbox().isIntersect(r)){for(let a of s.primitives)if(r.isIntersect(a.bbox()))return!0}}return!!this.IsCenterBBoxPointInPolygonType(t,i)}},Q7=class Bf{static createNode(t,i,r){let n=t.UL(),s=t.width()/i,a=t.height()/i,o=~~(r/i),l=r-o*i,c=n.x+l*s,u=n.y-(o+1)*a,h=c+s,d=u+a;return new St(c,h,u,d)}static ocTreeSplitNode(t,i,r,n,s=2){if(t.length<=r)return t;let a=[],o=s**2,l=new Array(o),c=new Array(o);for(let p=0;p<o;p++)l[p]=new Array(t.length),c[p]=0;let u=i.UL(),h=i.width()/s,d=i.height()/s;for(let p of t){let f=n(p).center(),m=~~((f.x-u.x)/h),g=~~((u.y-f.y)/d)*s+m;try{l[g][c[g]]=p,c[g]+=1}catch{a.push(p)}}for(let p=0;p<l.length;p++){let f=c[p];if(f<=0)continue;let m=l[p].slice(0,f);if(m.length===t.length)return t;let g=Bf.createNode(i,s,p),b=Bf.ocTreeSplitNode(m,g,r,n,s);if(b.length===t.length)return t;a.push(b)}return a}static ocTreeSplitNodeMinIntersect(t,i,r,n){let s=[];if(t.length<=r)return t;let a=3,o=i.LL(),l=i.UR(),c=i.width()/(a+1),u=i.height()/(a+1),h=-(2**32),d=[],p=[];for(let f=1;f<=a;f++)for(let m=1;m<=a;m++){let g=o.x+c*f,b=o.y+u*m,y=[[],[],[],[]],E=new Array(4),S=new Array(4);S[0]=new St(o.x,g,b,l.y),S[1]=new St(g,l.x,b,l.y),S[2]=new St(o.x,g,o.y,b),S[3]=new St(g,l.x,o.y,b);for(let A of t){let O=n(A).center(),R=-1,M=-1;O.x===g?R=Math.random()>=.5?1:-1:O.x>g?R=1:O.x<g&&(R=-1),O.y===b?M=Math.random()>=.5?1:-1:O.y>b?M=1:O.y<b&&(M=-1),R===1&&M===1?y[1].push(A):R===1&&M===-1?y[3].push(A):R===-1&&M===-1?y[2].push(A):R===-1&&M===1&&y[0].push(A)}for(let A=0;A<4;A++){let O=y[A];if(O.length<=0)continue;let R=new ot;for(let M of O)R.ext1(n(M));E[A]=R.build1()}let w=0,x=0;for(let A of E)A&&(w+=A.area());x=w;let I=(A,O)=>{if(!E[A]||!E[O])return 0;let R=E[A].intersection1(E[O]);return R?R.area():0};x-=I(0,1),x-=I(0,2),x-=I(0,3),x-=I(1,2),x-=I(1,3),x-=I(2,3),x/w>=h&&(d=y,p=S)}for(let f=0;f<d.length;f++){let m=d[f];if(m.length<=0)continue;let g=p[f],b;if(m.length===t.length?b=Bf.ocTreeSplitNode(m,g,r,n):b=Bf.ocTreeSplitNodeMinIntersect(m,g,r,n),b.length===t.length)return t;s.push(b)}return s}static ocTreeSplit(t,i,r,n){return Bf.ocTreeSplitNode(t,i,r,n,pa.OcTreeSplitStep)}},e9=class GP{static OcTreeOptimizeSplit(t){let i=t[0];if(i!==1||t.length<=pa.LocalBestThread+1)return t;let r=t.slice(1),n=new Array(r.length);for(let c=1;c<t.length;c++)n[c-1]=c;let s=py.getListBBox(r),a=Q7.ocTreeSplit(n,s,pa.LocalBestThread,c=>{let u=t[c];return py.getSingleBBox(u)}),o=(c,u)=>{if(!(c.length<=0))for(let h of c)if(Array.isArray(h)){let d=[u[0]];o(h,d),u.push(d)}else{let d=t[h];u.push(d)}},l=[i];return o(a,l),l}static optimizeSplit(t,i){let r=t[0];if(r===2){if(pa.HandleDiff){let s=t[1],a;if(Array.isArray(s)){let o=this.optimizeSplit(s,i);if(o.length<=1)return[2];a=Jb(o,i)}else a=Jb([2,s],i);if(t.length>3){let o;o=[1];for(let l=2;l<t.length;l++){let c=t[l];if(Array.isArray(c)){let u=py.getListBBox([...c.slice(1)]);py.KeepBBoxPolygonGroup(u,a)&&o.push(c)}else py.KeepBBoxPolygonGroup(c.bbox(),a)&&o.push(c)}return o.length<=1?[2,a]:(o=this.optimizeSplit(o,i),o.length>1?[2,a,...o.slice(1)]:[2,a])}else{let o=t[2];if(Array.isArray(o)&&o[0]===1&&o.length>2){let l=o.slice(1);return this.optimizeSplit([2,a,...l],i)}}}else if(t.slice(1).length>2){let s=t[1],a=t.slice(2),o=this.optimizeSplit([1,...a],i);return o.length>1?[2,s,...o.slice(1)]:s}}else if(r===1){if(t.length-1>pa.LocalBestThread){let s=!1;for(let a=1;a<t.length;a++){let o=t[a];if(!Array.isArray(o)){s=!0;break}}s&&(t=GP.OcTreeOptimizeSplit(t))}}else if(r===0&&t.length<=2)return[0];let n=[r];for(let s=1;s<t.length;s++){let a=t[s];if(Array.isArray(a)){let o=this.optimizeSplit(a,i);if(o.length<=1)continue;n.push(o)}else n.push(a)}return n}},gc=(e=>(e[e.INTERSECT=0]="INTERSECT",e[e.UNION=1]="UNION",e[e.DIFF=2]="DIFF",e[e.XOR=3]="XOR",e))(gc||{});function Ey(e){let t=e[0],i=[t];switch(t){case 0:for(let n=1;n<e.length;n++){let s=e[n];if(Array.isArray(s)&&(s=Ey(s),!s))return null;i.push(s)}break;case 1:case 3:for(let n=1;n<e.length;n++){let s=e[n];Array.isArray(s)&&(s=Ey(s),!s)||i.push(s)}break;case 2:let r=e[1];if(Array.isArray(r)&&(r=Ey(r)),!r)return null;i.push(r);for(let n=2;n<e.length;n++){let s=e[n];Array.isArray(s)&&(s=Ey(s),!s)||i.push(s)}break;default:throw new Error("not support boolean rule!")}return i.length===1?null:i.length===2?i[1]:i}function vv(e,t,i){return Array.isArray(e)?UP(e,t,i):e}function Tv(e,t,i,r,n=!0){if(n)for(;e.length>1;){let s,a=[];for(e.length%2===1?(a.push(e[0]),s=1):s=0;s<e.length;s+=2)a.push(t(e[s],e[s+1],i,r));e=a}else for(;e.length>1;){if(e.length===2)return t(e[0],e[1],i,r);e=[t(e[0],e[1],i,r),...e.slice(2)]}return e[0]}function UP(e,t,i,r=!0){let n=new Array(e.length-1);for(let s=1;s<e.length;s++)n[s-1]=vv(e[s],t,i);switch(e[0]){case 0:return Tv(n,dy.intersect,t,i);case 1:return Tv(n,dy.union,t,i);case 2:let s=Tv(n.slice(1),dy.union,t,i);return s?dy.diff(n[0],s,t,i):n[0];case 3:let a=vv(e[1],t,i);for(let o=2;o<e.length;o++)a=dy.xor(a,vv(e[o],t,i),t,i);return a;default:throw new Error("not support boolean rule! "+e[0])}}function YP(e){let t=[e[0]];for(let i=1;i<e.length;i++){let r=e[i];if(Array.isArray(r))t.push(YP(r));else{let n=Wb(r);n?t.push(wr.build(n)):t.push(new wr([]))}}return t}function t9(e){let t=[];for(let i=0;i<e.length;i+=2){let r=e[i],n=e[i+1];n?t.push({xor:qh([3,r,n]),union:qh([1,r,n])}):t.push({xor:r,union:r})}for(;t.length!==1;){for(let i=0;i<t.length;i+=2){let r=t[i],n=t[i+1],s=i/2;if(!n){t[s]=r;break}let a=qh([2,r.xor,n.union]),o=qh([2,n.xor,r.union]),l=[];a.items.forEach(c=>l.push(c)),o.items.forEach(c=>l.push(c)),t[s]={xor:new wr(l),union:qh([1,r.union,n.union])}}t.length=Math.ceil(t.length/2)}return t[0].xor}function Fv(e){let t=e[0];if(t===3&&e.length>3){let r=[];for(let n=1;n<e.length;n++){let s=e[n];if(s instanceof wr)r.push(s);else{let a=Fv(s);a instanceof wr?r.push(a):r.push(qh(a))}}return t9(r)}let i=[t];for(let r=1;r<e.length;r++){let n=e[r];n instanceof wr?i.push(n):i.push(Fv(n))}return qh(i)}function qh(e,t){if(!pa.UseOptimizeSplit)return Jb(e,t);let i=e9.optimizeSplit(e,t);return i.length<=1?new wr([]):Jb(i,t)}function zv(e,t){pa.curBus=t;let i=YP(e),r=Ey(i);if(!(r instanceof Array))return r||new wr([]);let n=Fv(r);return n instanceof wr?n:qh(n)}function Jb(e,t,i=!0){if(!e||e.length===1)return new wr([]);let r=e,n=new Z7,s=[];function a(o){for(let l=1;l<o.length;l++){let c=o[l];Array.isArray(c)?a(c):s.push(c)}}return a(r),n.init(s),UP(r,n,t,i)}var Pb=new Error("list is empty"),Lb=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},i9=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},r9=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},n9=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw Pb;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw Pb;return this.remove(e),e.item}addLast(e){if(this.first===null||this.last===null){let t=new Lb(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new Lb(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw Pb;return this.first.item}getLast(){if(this.last===null)throw Pb;return this.last.item}insertAfter(e,t){let i=new Lb(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new Lb(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new i9(this.first)}listIterator(){return new r9(this.first)}toArray(){let e=new Array,t=this.first;for(;t!=null;)e.push(t.item),t=t.next;return e}},Fb=class{constructor(e){this.inters=[],e&&(this.inters=e)}addInter(e){this.inters.push(e),e.group=this}findInter(e){let t=this.inters.find(i=>It(i.coord,e.coord));return t&&this.inters.find(i=>i.side===e.side)&&e.visitSelf(),t}getOutInter(e){let t=this.inters.filter(i=>!i.getVisited());if(t.length!==0)return t.length===1?t[0]:t.reduce((i,r)=>{if(!i||i.side.getShape()===e)return r;if(r.side.getShape()===e)return i;let n=i.coord,s=kt(e,n),a=kt(i.side.getShape(),n),o=kt(r.side.getShape(),n);return s.dot(a)>s.dot(o)?i:r},void 0)}getEntryInter(){}},Iv=0;function VP(e,t){let i=e.primitives[0];if(e.primitives.length===1&&i instanceof Se&&Math.abs(i.sweepAngle)===360)return[e];let r=fp();Iv++;let n,s=p9(e);if(s.length===0)return[];let a=o9(s);if(Iv===-1){n=new Py(t);let u=n.initColor(Hi.BLUE);s.forEach(d=>u.addPt(d.getShape()));let h=n.initColor(Hi.GREEN);a.forEach(d=>h.addPoint(d.coord)),n.draw();debugger;throw new Error}if(a.length===0)return[Tt.build7(s.map(u=>u.getShape()))];l9(a);let o=[],l=!1;try{h9(a,n)}catch(u){u.customType==="IS_OVERLAP"?(l=!0,o=new yy().getUnion([e]).map(h=>h.items).flat(2)):console.error(u)}if(l)return o;let c=u9(a);if(!c.length)return[Tt.build7(s.map(u=>u.getShape()))];if(o=s9(c,n),o.length===0)return console.warn("=====deSelfIntersection=====",Iv),[];if(n)throw o.forEach(u=>{n.initColor(Hi.WHITE).addPly(u),n.draw();debugger}),new Error;return Il.deSelfIntersection+=tu(r),o}function s9(e,t){let i=[];return e.forEach(r=>{let n=r;r.inters.forEach(s=>{if(s.getVisited())return;let a=[],o=[],l;if(t){debugger;let u=t.initColor(Hi.RED);l=h=>{a.push(h),u.addPt(a[a.length-1]),t.draw();debugger}}else l=u=>a.push(u);do{let u=function(m,g){_e.eq(m.distance2(g),0)||l(HP(p.getShape(),m,g))},h=o.findIndex(m=>m===s.group);if(h!==-1){let m=a.findIndex(y=>y===s.group),g=a.splice(m).filter(y=>!(y instanceof Fb));if(g.length){let y=Al(Tt.build7(g));y&&i.push(y)}let b=a.filter(y=>!(y instanceof Fb));if(s=o[h].getOutInter(b[b.length-1]),o.splice(h),!s)throw Error("interGroup not hav inter!!!2");continue}s.visitSelf(),o.push(s.group),a.push(s.group);let d=s.getIndex(),p=s.side,f=p.inters[d+1];for(;f!=null&&f.isInvalid||f&&f.group===s.group;)f=p.inters[f.getIndex()+1];if(f){u(s.coord,f.coord);let m=f.getBindedInter();if(s=m.getVisited()?m.group.getOutInter(m.side.getShape()):m,!s){if(f.group===n)break;throw new Error("interGroup not hav inter!!!3")}}else{for(u(s.coord,p.getEnd()),p=p.nextSide,s=null;;){for(let m of p.inters)if(!m.isInvalid){let g=m.group.getOutInter(p.getShape());if(!g){if(m.group===n){s=m;break}else if(m.getBindedInter().group===n){s=m.getBindedInter();break}continue}s=g;break}if(s)break;l(p.getShape()),p=p.nextSide}_e.eq(p.getEnd().distance2(s.coord),0)?l(p.getShape()):u(p.getStart(),s.coord)}}while(s.group!==n);let c=Al(Tt.build7(a.filter(u=>!(u instanceof Fb))));c&&i.push(c)})}),i}function a9(e){return{next(){return e.hasNext()?{value:e.next()}:{done:!0,value:void 0}},[Symbol.iterator](){return this}}}function o9(e){let t=[],i=new n9;for(let r of e.slice().sort((n,s)=>n.bbox().minY-s.bbox().minY)){for(let n of a9(i.listIterator())){let s=n.item;if(s.bbox().maxY<r.bbox().minY)i.remove(n);else{let a=function(d,p){let f=new Ju(p,d,null);return d.inters.push(f),t.push(f),f},o=function(d,p){let f=d.getEnd(),m=new j(se[0],se[1]),g=new j(se[2],se[3]),b=f.distance2(m)>f.distance2(g)?m:g,y=d.prevSide;a(It(y.getEnd(),b)?y:d,b).bind(a(p,b))},l=s.getShape(),c=r.getShape(),u=So(l,c),h=u===4&&se[0]===se[2]&&se[1]===se[3];if(h&&(u-=2),s.nextSide===r)s.prevSide!==r&&u===4&&o(s,r);else if(s.prevSide===r)u===4&&o(r,s);else if(u!==0){let d=function(f,m){let g=f.prevSide;return a(It(g.getEnd(),m)?g:f,m)},p=new j(se[0],se[1]);if(h&&!It(p,s.prevSide.getEnd())&&!It(p,r.prevSide.getEnd())&&kt(l,p).dot(kt(c,p))>0)continue;for(let f=0;f<u;f+=2){let m=new j(se[f],se[f+1]);d(s,m).bind(d(r,m))}}}}i.add(r)}return t.forEach(r=>{r.getIndex()===void 0&&r.side.sortInters()}),t}function l9(e){e.forEach(t=>{let i=t.side.getEnd();if(t.isInvalid||!It(t.coord,i))return;let r=t.side.inters,n=t.getBindedInter().side;for(let s=r.length-1;s>=0;s--){let a=r[s];if(!It(a.coord,i))break;a!==t&&a.getBindedInter().side===n&&a.setIsInvalid()}})}function c9(e){let t=new Ay(10);return e.forEach(i=>{i.isInvalid||t.add(i)}),t}function u9(e){let t=[],i=c9(e);return e.forEach(r=>{if(r.isInvalid||r.group)return;let n=i.search(r.bbox().extendOfSize(_e.eps)).filter(s=>!s.group);if(n.length){let s=new Set,a=new Fb(n);n.forEach(o=>{o.group=a,s.has(o.side)&&o.visitSelf(),s.add(o.side)}),t.push(a)}}),t}function h9(e,t){e.forEach(i=>{if(i.isInvalid||i.dealed)return;let r=i.side,n=i.getBindedInter().side,s;It(r.getEnd(),i.coord)&&It(n.getEnd(),i.coord)?s=-1:It(r.getEnd(),i.coord)?r.nextSide!==n&&(s=1,i=i.getBindedInter()):It(n.getEnd(),i.coord)&&n.nextSide!==r&&(s=1),d9(s,i,t),i.isDealed()})}function d9(e,t,i){let r=t.getBindedInter(),n=t.side,s=r.side,a=n.getShape(),o=s.getShape(),l=1,c=!1;if(e===-1){if(Pf(a.reverse(),o.reverse())||Pf(n.nextSide.getShape(),s.nextSide.getShape())){let h=Wu(n,n.nextSide,s,r,l,c,i);if(h.state===2){let p=new Error("info1.state === InState.IS_OVERLAP");throw p.customType="IS_OVERLAP",p}let d=Wu(n,n.nextSide,s.nextSide,r,l,c,i);h.state===d.state&&u(h,d)}else if(!(Pf(a.reverse(),s.nextSide.getShape())||Pf(n.nextSide.getShape(),o.reverse()))){let h=gv(n,n.nextSide,s,!1,i);h===gv(n,n.nextSide,s.nextSide,!0,i)&&h!==gv(s,s.nextSide,n.nextSide,!0,i)&&t.setIsInvalid()}}else if(e===1){let h=function(d,p){return kt(d,p.start()).dot(kt(p,p.start()))>0};if(Pf(a.reverse(),o.reverse())||Pf(a,s.nextSide.getShape())){let d=$o(n,s,r,i,l,c,new Map);if(d.state===2){let f=new Error("info1.state === InState.IS_OVERLAP");throw f.customType="IS_OVERLAP",f}let p=$o(n,s.nextSide,r,i,l,c,new Map);d.state===p.state&&u(d,p)}else if(h(a.reverse(),o.reverse())&&h(a,s.nextSide.getShape())){let d=ws(n,s,!1,i);d===ws(n,s.nextSide,!0,i)&&d!==dp(s,s.nextSide,new Ly(HP(a,t.coord,a.end()),i),!0,i)&&t.setIsInvalid()}}function u(h,d){h.inter.setIsInvalid(),d.inter.setIsInvalid(),t.setIsInvalid()}}function HP(e,t,i){if(e instanceof ie||t.distance2(i)<1e-6)return new ie(t,i);if(e instanceof Se)return Se.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.sweep());if(e instanceof Ye){let r=e.getPercent(t,Ft),n=e.getPercent(i,Ft);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function p9(e){let t=Al(e);if(!t)return[];let i=t.primitives.map(n=>new Ly(n,null)),r=i[i.length-1];return i.forEach(n=>{r.connect(n),r=n}),i}var Sy=class{static clearData(e){this.originalPrimitive=[],this.offsetPrimitive=[],this.rawOffsetPrimitive=[],this.offsetDistance=0,this.testI++,this.testI===0?this.drawDebug=new Py(e):delete this.drawDebug}static createRawOffsetEdge(){if(this.drawDebug){let e=this.drawDebug.initColor(Hi.WHITE);this.originalPrimitive.forEach(t=>e.addPt(t)),this.drawDebug.draw();debugger}for(let e=0;e<this.originalPrimitive.length;e+=1){let t=this.originalPrimitive[e];this.offsetPrimitive.push({index:e,offsetEdge:this.createOffsetEdge(t)})}if(this.drawDebug){let e=this.drawDebug.initColor(Hi.Golden);this.offsetPrimitive.forEach(t=>e.addPt(t.offsetEdge)),this.drawDebug.draw();debugger}if(this.offsetPrimitive.length>1)for(let e=0;e<this.offsetPrimitive.length;e+=1)if(e===this.offsetPrimitive.length-1){this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[0]);let t=this.rawOffsetPrimitive[0],i;t instanceof Se?i=Se.build4(this.offsetPrimitive[0].offsetEdge.start(),t.end(),t.center,t.rx,t.ry,t.sweep()):i=new ie(this.offsetPrimitive[0].offsetEdge.start(),t.end()),this.rawOffsetPrimitive.shift(),this.rawOffsetPrimitive.unshift(i)}else this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[e+1]);else this.rawOffsetPrimitive=[]}static createCirclePrimitive(e,t){let i=e.width()*.5,r=e.height()*.5,n=Math.sqrt(i**2+r**2)+t;return[Se.buildCircle(e.center(),n)]}static getExtendPolyLine(e,t,i=!0,r){var n,s;if(!((n=e==null?void 0:e.primitives)!=null&&n.length))return[];this.isExpansion=t>0;let a=Al(e);if(!((s=a==null?void 0:a.primitives)!=null&&s.length)){if(this.isExpansion){let l=[1],c=t*2;e.primitives.forEach(h=>l.push(h.stroke(c,1,0)));let u=zv(l,r);if(u.items.length!==1)throw new Error("group.items.length !== 1 ");return[u.items[0].items[0]]}return[]}if(e=a,this.clearData(r),this.originalPrimitive=e.primitives,this.offsetDistance=t,this.createRawOffsetEdge(),this.drawDebug){let l=this.drawDebug.initColor(Hi.BLUE);this.rawOffsetPrimitive.forEach(c=>l.addPt(c)),this.drawDebug.draw();debugger}let o=i?this.createClippingEdge(r):[Tt.build2(this.rawOffsetPrimitive)];if(this.drawDebug){let l=this.drawDebug.initColor(Hi.RED);o.forEach(c=>l.addPly(c)),this.drawDebug.draw();debugger}if(o.length&&(!this.isExpansion||this.isExpansion&&o.length>1)&&(o=this.getValidityPrimitive(o)),this.drawDebug){let l=this.drawDebug.initColor(Hi.GREEN);o.forEach(c=>l.addPly(c)),this.drawDebug.draw();debugger;throw new Error}return o}static getValidityPrimitive(e){let t=[],i=Math.abs(this.offsetDistance);for(let r=0;r<e.length;r+=1){let n=!0,s=e[r].primitives;e:for(let a=0;a<s.length;a+=1){let o=s[a],l;if(o instanceof Se)l=o.midPoint;else if(o instanceof ie)l=o.start();else throw new Error("not support!");for(let c=0;c<this.originalPrimitive.length;c+=1){let u=this.originalPrimitive[c],h;if(u instanceof Se?h=this.pointArcClosest(l,u):h=e7(l,u.start(),u.end()).d,i-h>.01){n=!1;break e}}}n&&t.push(e[r])}return t}static getInters(e){let t=[];for(let i=0;i<e;i+=2)t.push(new j(se[i],se[i+1]));return t}static pointArcClosest(e,t){let i=t.center;if(e.equals1(t.center))return t.rx;if(t.inArea(e,0)){let s=e.sub(i);return Math.abs(s.length()-t.rx)}let r=e.distance2(t.start()),n=e.distance2(t.end());return _e.less(r,n)?Math.sqrt(r):Math.sqrt(n)}static createClippingEdge(e){let t=[],i=[],r=VP(Tt.build2(this.rawOffsetPrimitive),e);r.forEach(s=>{let a=s.area(.01);t.push(a)});let n=Math.min(...t.filter(s=>s<0));for(let s=0;s<t.length;s+=1){let a=t[s];_e.eq(a,0)||(!this.isExpansion&&a<0||this.isExpansion&&(a<0&&t[s]===n||a>0))&&i.push(r[s])}return i}static createOffsetEdge(e){if(e instanceof Se)return e.panDistance2(this.offsetDistance);if(e instanceof ie)return e.panDistance(this.offsetDistance);throw new Error("not support!")}static connectPrimitive(e,t){e.offsetEdge instanceof ie&&t.offsetEdge instanceof ie?this.lineToLineConnect(e,t):e.offsetEdge instanceof Se&&t.offsetEdge instanceof Se?this.arcToArcConnect(e,t):e.offsetEdge instanceof ie&&t.offsetEdge instanceof Se?this.lineToArcConnect(e,t):this.arcToLineConnect(e,t)}static isFalseIntersection(e){return e>1||e<0}static lineToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=e.index,s=t.index,a=this.originalPrimitive[s].start();if(i.isParallel(r))i.bbox().intersection1(r.bbox())?this.rawOffsetPrimitive.push(i):this.lineToLineUseArcToConnect(a,i,r,n);else{let o=this.getLineToLineT(i,r),l=o[0],c=o[1];if(this.isFalseIntersection(l)||this.isFalseIntersection(c))l>1&&this.isFalseIntersection(c)?this.lineToLineUseArcToConnect(a,i,r,n):this.useLineToConnect(i,r);else if(!this.isFalseIntersection(l)&&!this.isFalseIntersection(c)){let u=i.end().sub(i.start()),h=i.start().add(u.mul(l)),d=new ie(i.start(),h);this.rawOffsetPrimitive.push(d);let p=new ie(h,r.end());this.updateNextOffsetPrimitive(s,p)}}}static updateNextOffsetPrimitive(e,t){this.offsetPrimitive[e].offsetEdge=t}static useLineToConnect(e,t){this.rawOffsetPrimitive.push(e);let i=new ie(e.end(),t.start());this.rawOffsetPrimitive.push(i)}static lineToLineUseArcToConnect(e,t,i,r){let n=this.getSweep(e,t,r),s=this.getSweepAngel(t.end(),i.start(),e,n);if(s===0){this.useLineToConnect(t,i);return}this.rawOffsetPrimitive.push(t);let a=Se.build5(t.end(),i.start(),s);this.rawOffsetPrimitive.push(a)}static getSweep(e,t,i){let r=null,n=i||i===0?this.originalPrimitive[i]:t;if(n instanceof Se){let s=n.center.sub(n.end()).normalize();n.isCCW?r=new j(s.y,-s.x):r=new j(-s.y,s.x)}else r=t.end().sub(t.start()).normalize();return e.sub(t.end()).normalize().cross(r)>0?0:1}static getLineToLineT(e,t){let i=e.end().sub(e.start()),r=t.end().sub(t.start()),n=i.cross(r),s=t.start().sub(e.start()),a=e.start().sub(t.start()),o=s.cross(r)/n,l=a.cross(i)/-n;return[o,l]}static lineToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=e.index,s=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(i,r),o=this.originalPrimitive[s].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,n);else if(a.intersectionNum===1){let l=a.points[0];this.lineAndArcConnectionDetail(i,r,a.t[0],l,o,n,s)}else if(a.intersectionNum===2){let l=a.points[0],c=a.points[1],u=l.distance2(o),h=c.distance2(o);this.lineAndArcConnectionDetail(i,r,u<h?a.t[0]:a.t[1],u<h?l:c,o,n,s)}}static lineAndArcConnectionDetail(e,t,i,r,n,s,a){let o=this.isTrueArcIntersection(t,r);if(!this.isFalseIntersection(i)&&o){let l=new ie(e.start(),r);this.rawOffsetPrimitive.push(l);let c;!t.center.equals1(r)||t.sweepAngle>1e-4?(c=Se.build4(r,t.end(),t.center,t.rx,t.ry,t.sweep()),c instanceof Se&&c.sweepAngle===0&&(c=new ie(c.start(),c.end()))):c=new ie(t.center,r),this.updateNextOffsetPrimitive(a,c)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(n,e,t,s)}static lineAndArcUseArcConnect(e,t,i,r){let n=this.getSweep(e,t,r),s=this.getSweepAngel(t.end(),i.start(),e,n);if(s===0){this.useLineToConnect(t,i);return}let a=Se.build5(t.end(),i.start(),s);this.rawOffsetPrimitive.push(t),this.rawOffsetPrimitive.push(a)}static arcToLineConnectionDetail(e,t,i,r,n,s,a){let o=this.isTrueArcIntersection(e,r);if(!this.isFalseIntersection(i)&&o){let l;e.center.equals1(r)?l=new ie(e.center,r):Math.abs(e.sweepAngle)<1e-4?l=new ie(e.start(),r):(l=Se.build4(e.start(),r,e.center,e.rx,e.ry,e.sweep()),l instanceof Se&&l.sweepAngle===0&&(l=new ie(l.start(),l.end()))),this.rawOffsetPrimitive.push(l);let c=new ie(r,t.end());this.updateNextOffsetPrimitive(a,c)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(n,e,t,s)}static isTrueArcIntersection(e,t){return Fn(e,t)}static getSweepAngel(e,t,i,r){let n=e.angleD(i),s=t.angleD(i),a;return n===s?a=0:(n=Qt.regularD(n),s=Qt.regularD(s),r===1?s<=n&&(s+=360):s>=n&&(n+=360),a=s-n),a}static getLineJoinArcScalarAndIntersectionNum(e,t){let i={t:[],intersectionNum:0,points:[]},r=$8(t,e);if(r){i.intersectionNum=r/2;for(let n=0;n<r-1;n+=2){let s=new j(se[n],se[n+1]);i.points.push(s),s.sub(e.start()).x<1e-4||s.sub(e.start()).y<1e-4?i.t.push(0):i.t.push(s.sub(e.start()).x/e.end().sub(e.start()).x)}}else i.intersectionNum=0;return i}static arcToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=e.index,s=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(r,i),o=this.originalPrimitive[s].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,n);else if(a.intersectionNum===1){let l=a.points[0];this.arcToLineConnectionDetail(i,r,a.t[0],l,o,n,s)}else if(a.intersectionNum===2){let l=a.points[0],c=a.points[1],u=l.distance2(o),h=c.distance2(o);this.arcToLineConnectionDetail(i,r,u<h?a.t[0]:a.t[1],u<h?l:c,o,n,s)}}static rxChangeStatus(e){return e===1?!this.isExpansion:this.isExpansion}static arcToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=EP(i,r);if(n){let s=this.getInters(n),a;if(s.length===2){let c=this.originalPrimitive[t.index].start(),u=s[0],h=s[1],d=u.distance2(c),p=h.distance2(c);d<p?a=u:a=h}else a=s[0];let o,l;a.equals1(i.center)?o=new ie(i.center,a):Math.abs(i.sweepAngle)<1e-4?o=new ie(i.start(),a):(o=Se.build4(i.start(),a,i.center,i.rx,i.ry,i.sweep()),o instanceof Se&&o.sweepAngle===0&&(o=new ie(o.start(),o.end()))),this.rawOffsetPrimitive.push(o),a.equals1(r.center)?l=new ie(a,r.center):Math.abs(r.sweepAngle)<1e-4?l=new ie(a,r.end()):(l=Se.build4(a,r.end(),r.center,r.rx,r.ry,r.sweep()),l instanceof Se&&l.sweepAngle===0&&(l=new ie(l.start(),l.end()))),this.updateNextOffsetPrimitive(t.index,l)}else{let s=this.originalPrimitive[e.index],a=this.originalPrimitive[t.index],o=this.rxChangeStatus(s.sweep()),l=this.rxChangeStatus(a.sweep()),c=this.originalPrimitive[t.index].start(),u=this.getSweep(c,i,e.index),h=Math.abs(this.offsetDistance),d=Se.build2(c,o?s.endAngle():s.endAngle()+180,l?a.startAngle:a.startAngle+180,h,h,u);this.rawOffsetPrimitive.push(i),this.rawOffsetPrimitive.push(d)}}};Sy.originalPrimitive=[],Sy.offsetPrimitive=[],Sy.rawOffsetPrimitive=[],Sy.testI=0;var f9=class wy extends Dy{constructor(t,i,r,n,s,a){if(super(),i<0||r<0)throw new Error("The width and height of rect can't be less than 0!");this.leftUpPoint=t,this.width=i,this.height=r,this.angle=n,this.isCCW=s,this.radius=Math.min(Math.max(a,0),i/2,r/2)}get radiusRatio(){return this.radius/Math.min(this.width,this.height)}start(){return this.leftUpPoint.add(new j(this.radius,0).multiply3(de.rotateD(this.angle)))}end(){return this.start()}getLeftPoint(){return this.leftUpPoint.add(new j(0,-this.height/2).multiply3(de.rotateD(this.angle)))}getRightPoint(){return this.leftUpPoint.add(new j(this.width,-this.height/2).multiply3(de.rotateD(this.angle)))}extend(t){return new wy(this.leftUpPoint.add(new j(-t,t).rotateD(j.ORIGIN,this.angle)),this.width+t*2,this.height+t*2,this.angle,this.isCCW,this.radius+t)}bbox(){let t=de.rotateD(this.angle),{leftUpPoint:i,width:r,height:n,radius:s}=this,a=i.add(new j(s,-s).multiply3(t)),o=i.add(new j(s,s-n).multiply3(t)),l=i.add(new j(r-s,-s).multiply3(t)),c=i.add(new j(r-s,s-n).multiply3(t));return new St(Math.min(a.x,o.x,l.x,c.x)-s,Math.max(a.x,o.x,l.x,c.x)+s,Math.min(a.y,o.y,l.y,c.y)-s,Math.max(a.y,o.y,l.y,c.y)+s)}toPolyline(){let t=[],{leftUpPoint:i,width:r,height:n,radius:s}=this;if(s===0){let o=j.ORIGIN,l=new j(r,0),c=new j(r,-n),u=new j(0,-n);t.push(new ie(o,l),new ie(l,c),new ie(c,u),new ie(u,o))}else{let o=new j(0,-s),l=new j(s,0),c=new j(r-s,0),u=new j(r,-s),h=new j(r,s-n),d=new j(r-s,-n),p=new j(s,-n),f=new j(0,s-n);t.push(Se.build1(o,l,s,s,!1,0),new ie(l,c),Se.build1(c,u,s,s,!1,0),new ie(u,h),Se.build1(h,d,s,s,!1,0),new ie(d,p),Se.build1(p,f,s,s,!1,0),new ie(f,o))}t=t.filter(o=>!o.start().equals1(o.end())),this.isCCW&&(t.forEach((o,l)=>t[l]=o.reverse()),t.reverse());let a=de.rotateD(this.angle).translate1(i);return Tt.build2(t.map(o=>o.multiply3(a)))}center(){return this.leftUpPoint.add1(this.width/2,this.height/2).rotateD(this.leftUpPoint,this.angle)}multiply3(t){let i=this.leftUpPoint.multiply3(t),r=new j(this.width,0).multiply3(de.rotateD(this.angle)).multiply3(t),n=new j(0,-this.height).multiply3(de.rotateD(this.angle)).multiply3(t);return t.isMirrored()?new wy(i,n.length(),r.length(),n.angleD(j.ORIGIN),this.isCCW===1?0:1,this.radius*r.length()/this.width):new wy(i,r.length(),n.length(),r.angleD(j.ORIGIN),this.isCCW,this.radius*r.length()/this.width)}reverse(){return new wy(this.leftUpPoint,this.width,this.height,this.angle,this.isCCW===1?0:1,this.radius)}stroke(t,i,r){let n=this.stroke1(t,i,r);if(n.length===1)return n[0];{let[s,a]=n;return Tt.build2(s.primitives.concat(new ie(s.primitives[0].start(),a.primitives[0].start()),a.primitives,new ie(a.primitives[0].start(),s.primitives[0].start())))}}stroke1(t,i,r){let n=r===this.isCCW?this:this.reverse(),s=t/2,a=Math.min(n.width,n.height)/2,o=n.extend(s).toPolyline();return a<=s?[o]:[o,n.extend(-s).toPolyline().reverse()]}points(t){let i=this.toPolyline(),r=[];return i.points(t,n=>r.push(n)),r}toBezier(){throw new Error("Method not implemented.")}},m9=.01,rn=class dc{static simplify(t){return t=Al(t),t?new dc([t]):null}static buildByStroke(t,i,r=1,n=Yv,s){if(t instanceof Se&&(t.rx<i/2+m9||Math.abs(t.sweepAngle)>180&&_e.lesseq(t.start().distance1(t.end()),i))){let o=VP(t.stroke(i,r,0),s);if(o.length===0)return null;if(o.length===1)return new dc(o);let l=[null],c=Number.POSITIVE_INFINITY;return o.forEach(u=>{let h=u.area(.1);h<0?h<c&&(l[0]=u,c=h):l.push(u)}),new dc(l)}else if(t instanceof f9){let o=t.stroke1(i,r,0).map(l=>Al(l));return o[0]?o[1]?new dc(o):new dc([o[0]]):null}let a=t.stroke(i,r,0,n);return a?this.simplify(a):null}static buildCircle(t,i){return this.simplify(Tt.build7([Se.buildCircle(t,i,0)]))}static buildRect(t){return this.simplify(t.toPolyline())}static buildBBox(t){return this.simplify(Tt.buildBBox(t,0))}constructor(t){this.items=t.slice()}multiply3(t){return new dc(this.items.map(i=>i.multiply3(t)))}bbox(){return this.items[0].bbox()}isEqual(t){return t instanceof dc?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items[0]}extend(t,i){if(this.items.length!==1)throw new Error("this.items.length !== 1");if(t===0)return new wr([this]);let r=this.items[0],n=[];for(let u of r.primitives)if(u instanceof ie)n.push(u);else if(u instanceof Se&&u.rx===u.ry)a(u);else if(u instanceof Ye)s(u);else throw new Error("not support!");r=Tt.build7(n);function s(u){let h=u.points(.1);for(let d=0;d<h.length-1;d++){let p=h[d],f=h[d+1];n.push(new ie(p,f))}}function a(u){if(Math.abs(u.sweepAngle)>270){let h=u.sweepAngle/2;a(Se.build3(u.center,u.startAngle,h,u.rx,u.ry)),a(Se.build3(u.center,u.startAngle+h,h,u.rx,u.ry))}else n.push(u)}let o=[],l=[];Sy.getExtendPolyLine(r,t,!0,i).forEach(u=>{(u.area(.1)>0?l:o).push(u)});let c;if(o.length===1)l.forEach(u=>o.push(u)),c=new wr([new dc(o)]);else if(o.length===0)console.warn("outlines.length === 0"),c=new wr([]);else if(l.length===0)c=new wr(o.map(u=>new dc([u])));else{let u=o.map(h=>[h]);l.forEach(h=>{let d=[],p=h.bbox();if(u.forEach(f=>{f[0].bbox().isContainsBBox1(p)&&d.push(f)}),d.length===1)d[0].push(h);else{if(d.length===0)throw new Error("inPlsArr.length === 0");for(let f of d.sort((m,g)=>m[0].bbox().area()-g[0].bbox().area()))if(f[0].getWindingNum(h.start())===-1){f.push(h);break}}}),c=new wr(u.map(h=>new dc(h)))}return c}toPolylineGroup(){return new kr(this.items)}};var g9=Object.create,eI=Object.defineProperty,y9=Object.getOwnPropertyDescriptor,b9=Object.getOwnPropertyNames,x9=Object.getPrototypeOf,E9=Object.prototype.hasOwnProperty,jf=(e=>typeof xo<"u"?xo:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof xo<"u"?xo:t)[i]}):e)(function(e){if(typeof xo<"u")return xo.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),S9=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),w9=(e,t)=>{for(var i in t)eI(e,i,{get:t[i],enumerable:!0})},v9=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of b9(t))!E9.call(e,n)&&n!==i&&eI(e,n,{get:()=>t[n],enumerable:!(r=y9(t,n))||r.enumerable});return e},o0=(e,t,i)=>(i=e!=null?g9(x9(e)):{},v9(t||!e||!e.__esModule?eI(i,"default",{value:e,enumerable:!0}):i,e)),l0=S9((e,t)=>{"use strict";var i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a=(D,z)=>{for(var $ in z)i(D,$,{get:z[$],enumerable:!0})},o=(D,z,$,K)=>{if(z&&typeof z=="object"||typeof z=="function")for(let ee of n(z))!s.call(D,ee)&&ee!==$&&i(D,ee,{get:()=>z[ee],enumerable:!(K=r(z,ee))||K.enumerable});return D},l=D=>o(i({},"__esModule",{value:!0}),D),c={};a(c,{BroadcastChannelMessageBus:()=>xe,MessageBus:()=>T,MessageBus2:()=>ne,MessageBusTask:()=>N,MessageBusTask2:()=>X,WindowMessageBridge:()=>C,WorkerMessageBridge:()=>q,createBroadcastP2PStream:()=>vt,createBufferedByteBufferStream:()=>je,createBufferedStream:()=>Ne,createBufferedStringStream:()=>nt,dropP2PStream:()=>Bt,flowRead:()=>ze,flowWrite:()=>Ti}),t.exports=l(c);var u=class{constructor(D=1.5){this.growthFactor=D,this.capacity=10,this.buffer=new Array(this.capacity),this.head=0,this.tail=0,this.count=0}enqueue(D){if(this.count===this.capacity){let z=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,z);let $=new Array(z);for(let K=0;K<this.count;K++)$[K]=this.buffer[(this.head+K)%this.capacity];this.buffer=$,this.head=0,this.tail=this.count,this.capacity=z}this.buffer[this.tail]=D,this.tail=(this.tail+1)%this.capacity,this.count++}dequeue(){if(this.isEmpty())return;let D=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,D}peek(){return this.buffer[this.head]}isEmpty(){return this.count===0}clear(){this.buffer.length=0,this.head=0,this.tail=0,this.count=0}},h=new ArrayBuffer(8),d=new Float64Array(h),p=new Uint32Array(h),f=new Uint16Array(h),m=ArrayBuffer;try{m=self.HTMLImageElement||m}catch{}var g=typeof SharedArrayBuffer<"u";function b(D){if(typeof D!="object"||D===null||D instanceof Date||D instanceof ArrayBuffer||g&&D instanceof SharedArrayBuffer||D instanceof Blob||D instanceof FormData||D instanceof Function||D instanceof Uint8ClampedArray||D instanceof m)return D;if(Array.isArray(D))return D.map(b);{let z={};for(let $ in D)Object.hasOwnProperty.call(D,$)&&(z[$]=b(D[$]));return z}}function y(D,z){return E(D,z,()=>[])}function E(D,z,$){let K=D[z];return K!==void 0||(K=$(z),D[z]=K),K}var S=class{constructor(D){this.maxResources=D,this.idle=new u,this.isClosed=!1,this.resources=D}acquire(D){this.isClosed?Promise.resolve(!1).then(D):this.resources>0?(this.resources--,Promise.resolve(!0).then(D)):this.idle.enqueue(D)}acquireSync(){return new Promise(D=>{this.acquire(D)})}release(){if(!this.isClosed){let D=this.idle.dequeue();D?Promise.resolve(!0).then(D):this.resources++}}close(){if(!this.isClosed)for(this.isClosed=!0;!this.idle.isEmpty();){let D=this.idle.dequeue();Promise.resolve(!1).then(D)}}};function w(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global}function x(D,z){let $=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===z&&(D.splice(ee,1),ee--,K--,$++);return $}var I=w(),A=I.WeakRef||(D=>D);function O(D){if(D!=null){if(typeof D=="object")return new A(D);console.error(D,D instanceof Object,typeof D);return}}function R(D){return D==null?void 0:D.deref()}var M="_MSG_BUS_RPC_",F=300*1e3,G=(D=>(D.PUBLISH="publish",D.SUBSCRIBE="subscribe",D.PUSH="push",D.PULL="pull",D))(G||{}),V=class{constructor(D){this.bus=D}processRemoteMessage(D,z){let $=O(z),K=D.topic,ee=D.type,pe=D.message;switch(ee){case"pull":this.bus.pull(K,ce=>{this.push(K,ce,R($))});break;case"subscribe":this.bus.subscribe(K,ce=>{this.publish(K,ce,R($))});break;case"publish":this.bus.publish(K,pe,this,R($));break;case"push":this.bus.push(K,pe,this,R($));break;default:console.debug("unknown message type "+ee)}}rpcCall(D,z,$,K=F){let ee=O($),pe=new Promise(ce=>{let Be=this.bus.uniqueRpcTopic(D);this.publish(D,{message:z,reply:Be},R(ee)),this.bus.pull(Be,(st,pt,tt)=>{ce({message:st,bridge:pt,source:O(tt)})})});return K>0?Promise.race([pe,new Promise((ce,Be)=>{setTimeout(Be,K)})]):pe}},q=class extends V{constructor(D,z){super(D),this.worker=z,z.onmessage=$=>{this.processRemoteMessage($.data,void 0)}}publish(D,z){this.postMessage(D,"publish",z)}subscribe(D){this.postMessage(D,"subscribe",null)}push(D,z){this.postMessage(D,"push",z)}pull(D){this.postMessage(D,"pull",null)}rpcCall(D,z,$=F){return super.rpcCall(D,z,void 0,$)}postMessage(D,z,$){let K={topic:D,type:z,message:$};this.worker.postMessage(K)}discard(){this.worker.terminate()}},C=class extends V{constructor(D){super(D),window.addEventListener("message",z=>{this.processRemoteMessage(z.data,z.source)},!1)}publish(D,z,$){this.postMessage(D,"publish",z,$)}subscribe(D,z){if(z===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(D,"subscribe",null,z)}push(D,z,$){this.postMessage(D,"push",z,$)}pull(D,z){if(z===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(D,"pull",null,z)}postMessage(D,z,$,K){let ee={topic:D,type:z,message:$};K&&K.postMessage(ee,"*")}},N=class{constructor(D){this.isRunning=!0,this.callback=D}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}execute(D,z,$,K){try{D=K?D:b(D),this.callback(D,z,$)}catch(ee){console.error(ee)}}},T=class{constructor(D=!1){this.subscribed={},this.pulled={},this.pushed={},this.uuid=crypto.randomUUID().replace(/-/g,""),this.rpcTicket=0,this.unsafe=D}uniqueRpcTopic(D){return`${M}-${D}-${this.uuid}-${this.rpcTicket++}`}publish(D,z,$,K){let ee=this.subscribed[D];if(ee){let pe;for(let ce of ee)ce.running()?ce.execute(z,$,K,this.unsafe):(pe=pe||new Array,pe.push(ce));if(pe)for(let ce of pe)x(ee,ce)}else console.debug("no sub on topic: "+D)}subscribe(D,z){let $=new N(z);return y(this.subscribed,D).push($),$}push(D,z,$,K){let ee=!1,pe=this.pulled[D];if(pe){for(;pe.length>0;){let ce=pe.shift();if(ce.running()){ce.execute(z,$,K,this.unsafe),ee=!0;break}}pe.length===0&&delete this.pulled[D]}ee||y(this.pushed,D).push({message:z,bridge:$,source:O(K)})}pull(D,z){let $=new N(z),K=this.pushed[D];if(K){let ee=K.shift();$.execute(ee.message,ee.bridge,R(ee.source),this.unsafe),K.length===0&&delete this.pushed[D]}else y(this.pulled,D).push($);return $}pullA(D){return new Promise(z=>{this.pull(D,($,K,ee)=>{z({message:$,bridge:K,source:O(ee)})})})}rpcService(D,z){this.subscribe(D,($,K,ee)=>{let{message:pe,reply:ce}=$;try{let Be=z(pe);if(Be instanceof Promise){let st=O(ee);Be.then(pt=>{this.rpcReply(pt,ce,K,R(st))},pt=>{console.error(pt),this.rpcReply(void 0,ce,K,R(st))})}else this.rpcReply(Be,ce,K,ee)}catch(Be){console.error(Be),this.rpcReply(void 0,ce,K,ee)}})}rpcCall(D,z,$=F){let K=new Promise(ee=>{let pe=this.uniqueRpcTopic(D);this.publish(D,{message:z,reply:pe}),this.pull(pe,(ce,Be,st)=>{ee({message:ce,bridge:Be,source:O(st)})})});return $>0?Promise.race([K,new Promise((ee,pe)=>{setTimeout(pe,$)})]):K}rpcReply(D,z,$,K){$?$.push(z,D,K):this.push(z,D)}},L="_MSG_BUS_RPC_";function P(D,z){let $=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===z&&(D.splice(ee,1),ee--,K--,$++);return $}function B(D,z){return U(D,z,()=>[])}function U(D,z,$){let K=D[z];return K!==void 0||(K=$(z),D[z]=K),K}var X=class{constructor(D,z){this.callback=D,this.unsafe=z,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(D){try{D=this.unsafe?D:b(D),this.callback(D)}catch(z){console.error(z)}}},J=class{constructor(D=crypto.randomUUID()){this.uuid=D,this.rpcTicket=0}subscribeOnce(D,z){let $=this.subscribe(D,K=>{$.cancel(),z(K)});return $}pullA(D){return new Promise(z=>{this.pull(D,z)})}rpcService(D,z){let $=K=>{try{let{message:ee,replyTopic:pe}=K;try{let ce=z(ee);ce instanceof Promise?ce.then(Be=>{this.publish(pe,{success:!0,result:Be})}).catch(Be=>{console.error(Be),this.publish(pe,{success:!1,err:String(Be)})}):this.publish(pe,{success:!0,result:ce})}catch(ce){this.publish(pe,{success:!1,err:String(ce)})}}finally{this.pull(D,$)}};this.pull(D,$)}rpcCall(D,z,$=0){let K=new Promise((ee,pe)=>{let ce=`${L}-${D}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(ce,Be=>{Be.success?ee(Be.result):pe(new Error(Be.err))}),this.push(D,{message:z,replyTopic:ce})});return $>0?Promise.race([K,new Promise((ee,pe)=>{setTimeout(pe,$)})]):K}},ne=class extends J{constructor(D=!1){super(),this.unsafe=D,this.subscribed={},this.pulled={},this.pushed={}}publish(D,z){let $=this.subscribed[D];if($){let K;for(let ee of $)ee.running()?ee.execute(z):(K=K||new Array,K.push(ee));if(K)for(let ee of K)P($,ee)}}subscribe(D,z){let $=new X(z,this.unsafe);return B(this.subscribed,D).push($),$}push(D,z){let $=!1,K=this.pulled[D];if(K){for(;K.length>0;){let ee=K.shift();if(ee&&ee.running()){ee.execute(z),$=!0;break}}K.length===0&&delete this.pulled[D]}$||B(this.pushed,D).push(z)}pull(D,z){let $=new X(z,this.unsafe);return this.repull(D,$),$}repull(D,z){let $=this.pushed[D];if($){let K=$.shift();K&&(z.execute(K),$.length===0&&delete this.pushed[D])}else B(this.pulled,D).push(z)}},fe=class extends J{constructor(D=crypto.randomUUID()){super(D),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(D,z){console.debug("BC",this.uuid,"PUBLISH",D,z),this.broadcastPublish(D,z)}subscribe(D,z){console.debug("BC",this.uuid,"SUBSCRIBE",D);let $=new X(z,!0);return B(this.subscribed,D).push($),$}push(D,z){let $=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",D,`(${$})`,z),B(this.pushed,D).push({id:$,message:z}),this.broadcastPushedHeadMessage(D)}pull(D,z){console.debug("BC",this.uuid,"PULL",D);let $=new X(z,!0);return B(this.pulled,D).push($),this.broadcastWhoHas(D),$}broadcastPushedHeadMessage(D){let z=this.pushed[D];z&&z[0]&&this.broadcastIHave(D,z[0].id)}onReceivedPublish(D,z,$){console.debug("BCMSG(",this.uuid,")","from",D,"PUBLISH",z,"message",$);let K=this.subscribed[z];if(K){let ee;for(let pe of K)pe.running()?pe.execute($):(ee=ee||new Array,ee.push(pe));if(ee)for(let pe of ee)P(K,pe);K.length===0&&delete this.subscribed[z]}}onReceivedWhoHas(D,z){console.debug("BCMSG(",this.uuid,")","from",D,"WHOHAS",z),this.broadcastPushedHeadMessage(z)}onReceivedIHave(D,z,$){console.debug("BCMSG(",this.uuid,")","from",D,"IHAVE",z,"id",$);let K=this.pulled[z];if(K){let ee;for(let pe of K)if(pe.running()){this.broadcastINeed(z,D,$);break}else ee=ee||new Array,ee.push(pe);if(ee)for(let pe of ee)P(K,pe);K.length===0&&delete this.pulled[z]}}onReceivedINeed(D,z,$,K){if(console.debug("BCMSG(",this.uuid,")","from",D,"INEED",z,"source",$,"id",K),this.uuid===$){let ee=this.pushed[z];if(ee&&ee[0]&&ee[0].id===K){let{message:pe}=ee.shift();this.broadcastIGive(z,K,D,pe),this.broadcastPushedHeadMessage(z),ee.length===0&&delete this.pushed[z]}}}onReceivedIGive(D,z,$,K,ee){console.debug("BCMSG(",this.uuid,")","from",D,"IGIVE",z,"id",$,"target",K,"message",ee);let pe=this.pulled[z];if(pe&&this.uuid===K){let ce=!1;for(;pe.length>0;){let Be=pe.shift();if(Be.running()){Be.execute(ee),ce=!0;break}}ce||this.push(z,ee),pe.length===0&&delete this.pulled[z]}}},xe=class extends fe{constructor(D,z=crypto.randomUUID()){super(z),this.bc=new BroadcastChannel(D),this.bc.onmessage=$=>{this.onMessage($.data)}}onMessage(D){let{type:z,uuid:$,topic:K}=D;switch(z){case"PUBLISH":{let{message:ee}=D;this.onReceivedPublish($,K,ee);break}case"WHOHAS":{this.onReceivedWhoHas($,K);break}case"IHAVE":{let{id:ee}=D;this.onReceivedIHave($,K,ee);break}case"INEED":{let{source:ee,id:pe}=D;this.onReceivedINeed($,K,ee,pe);break}case"IGIVE":{let{target:ee,id:pe,message:ce}=D;this.onReceivedIGive($,K,pe,ee,ce);break}default:console.warn("unsupported",D)}}broadcastPublish(D,z){this.post({type:"PUBLISH",uuid:this.uuid,topic:D,message:z})}broadcastWhoHas(D){this.post({type:"WHOHAS",uuid:this.uuid,topic:D})}broadcastIHave(D,z){this.post({type:"IHAVE",uuid:this.uuid,topic:D,id:z})}broadcastINeed(D,z,$){this.post({type:"INEED",uuid:this.uuid,topic:D,source:z,id:$})}broadcastIGive(D,z,$,K){this.post({type:"IGIVE",uuid:this.uuid,topic:D,id:z,target:$,message:K})}post(D){this.bc.postMessage(D),Promise.resolve().then(()=>{this.onMessage(D)})}},ve=Symbol("BLOCKING_QUEUE_RESET"),Fe=class{constructor(D,z=()=>1){if(this.maxSize=D,this.itemSizeOf=z,this.queue=new u,this.waitingConsumers=new u,this.waitingProducers=new u,this.queueSize=0,this.closePromise=null,this.closeResolve=null,D<=0)throw new Error("Max size must be greater than 0")}enqueue(D){return this.closePromise?!1:this.isFull()?(async()=>{console.debug("queue is full",this.queueSize,this.maxSize);let z=await new Promise($=>{this.waitingProducers.enqueue($)});return console.debug("queue is not full",this.size(),z),z?(this.innerEnqueue(D),!0):!1})():(this.innerEnqueue(D),!0)}innerEnqueue(D){if(this.waitingConsumers.isEmpty())this.queue.enqueue(D),this.queueSize+=this.itemSizeOf(D),console.debug("queue pushed",D,"size",this.queueSize);else{let z=this.waitingConsumers.dequeue();Promise.resolve(D).then(z),console.debug("queue direct",D,"size",this.queueSize)}}dequeue(){if(this.queue.isEmpty())if(this.closePromise){for(;!this.waitingConsumers.isEmpty();){let D=this.waitingConsumers.dequeue();Promise.resolve(ve).then(D)}return setTimeout(()=>this.closeResolve(),0),ve}else return new Promise(D=>{this.waitingConsumers.enqueue(D)});else{let D=this.queue.dequeue();if(this.queueSize-=this.itemSizeOf(D),!this.waitingProducers.isEmpty()){let z=this.waitingProducers.dequeue();Promise.resolve(!0).then(z)}return D}}size(){return this.queueSize}isEmpty(){return this.queueSize===0}isFull(){return this.queueSize>=this.maxSize}close(){return this.closePromise||(this.closePromise=new Promise(D=>{for(this.closeResolve=D;!this.waitingProducers.isEmpty();){let z=this.waitingProducers.dequeue();Promise.resolve(!1).then(z)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let z=this.waitingConsumers.dequeue();Promise.resolve(ve).then(z)}D()}})),this.closePromise}};function Ne(D,z,$=Number.MAX_SAFE_INTEGER){let K=new Fe($,z),ee=new ReadableStream({pull(ce){let Be=!0,st=(async()=>{let pt=new Array;do{let tt=K.dequeue();if(tt instanceof Promise){Be=!1;let li=await tt;li===ve?ce.close():pt.push(li)}else{let li=tt;li===ve?ce.close():pt.push(li)}}while(K.size()>0);if(pt.length>0){let tt=D(pt);ce.enqueue(tt)}})();if(!Be)return console.debug("read stream stucked --------------------------------------"),st},async cancel(){console.debug("buffered readable cancel"),await K.close()}}),pe=new WritableStream({write(ce,Be){let st=!0,pt=(async()=>{let tt=K.enqueue(ce);typeof tt=="boolean"?tt||Be.error(new Error("Write stream closed")):(st=!1,await tt||Be.error(new Error("Write stream closed")))})();if(!st)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),pt},async close(){console.debug("buffered writable closing",K.size()),await K.close(),console.debug("buffered writable closed",K.size())},async abort(){console.debug("buffered writable aborting",K.size()),await K.close(),console.debug("buffered writable aborted",K.size())}});return{readable:ee,writable:pe}}function nt(D=Number.MAX_SAFE_INTEGER){return Ne(z=>z.join(""),z=>z.length,D)}function je(D=Number.MAX_SAFE_INTEGER){return Ne(z=>{let $=new Uint8Array(z.reduce((ee,pe)=>ee+pe.byteLength,0)),K=0;return z.forEach(ee=>{$.set(ee,K),K+=ee.byteLength}),$},z=>z.byteLength,D)}function vt(D){return new Promise((z,$)=>{let K=new BroadcastChannel(D),ee=new Fe(1),pe=new S(1),ce=null,Be=!1,st=!1,pt=!1;K.onmessage=tt=>{let li=tt.data,{type:Ji}=li;if(console.debug("p2p",D,"type",Ji,"data",Ji==="DATA"&&li.data),Ji==="DATA")ee.enqueue(li.data);else if(Ji==="HI"){if(!ce){K.postMessage({type:"HI"});let Mr=0;ce={rs:new ReadableStream({async pull(Or){let Cn=await ee.dequeue();Cn===ve?(await Bi(),Or.close()):(Or.enqueue(Cn),K.postMessage({type:"ACK"}))},cancel(){return Bi()}}),ws:new WritableStream({async write(Or,Cn){await pe.acquireSync()?K.postMessage({type:"DATA",id:Mr++,data:Or}):(cr(),Cn.error(new Error("Write stream closed")))},close(){cr()},abort(){cr()}})},z(ce)}}else Ji==="REND"?ce?pe.close():An("REND1"):Ji==="WEND"?ce?ee.close():An("WEND1"):Ji==="ACK"&&pe.release();function cr(){Be||(Be=!0,console.debug(D,"p2p write stream closed"),pe.close(),K.postMessage({type:"WEND"}),st&&(console.debug(D,"p2p channel closed on ws"),K.close()))}async function Bi(){st||(st=!0,console.debug(D,"p2p read stream closed"),K.postMessage({type:"REND"}),await ee.close(),Be&&(console.debug(D,"p2p channel closed on rs"),K.close()))}async function An(Mr){pt||(pt=!0,console.debug(D,"p2p channel connection released on",Mr),pe.close(),ee.close(),ce?(ce.rs.locked||(console.debug(D,"p2p unlocked read stream direct cancel"),ce.rs.cancel()),ce.ws.locked||(console.debug(D,"p2p unlocked write stream direct close"),ce.ws.close())):(K.postMessage({type:"HI"}),K.close()),$(new Error("p2p channel connection released")))}},K.postMessage({type:"HI"})})}function Bt(D){return new Promise(z=>{let $=new BroadcastChannel(D);$.onmessage=K=>{let ee=K.data,{type:pe}=ee;pe==="HI"&&($.postMessage({type:"REND"}),$.close(),z())},$.postMessage({type:"REND"})})}async function Oi(D){try{return await vt(D)}catch(z){z.message!=="p2p channel connection released"&&console.error(z)}}async function Ti(D,z,$=10*1024*1024,K=!0){let ee=await Oi(D);if(!ee)return!1;let pe=!1;try{let ce,Be=st=>{if(!ce)if(!K)ce=ee.ws.getWriter();else if(typeof st=="string"){let pt=nt($);pt.readable.pipeTo(ee.ws),ce=pt.writable.getWriter()}else{let pt=je($);pt.readable.pipeTo(ee.ws),ce=pt.writable.getWriter()}return ce.write(st)};if(Array.isArray(z))for(let st of z)await Be(st);else await z({write:Be,get desiredSize(){return((ce==null?void 0:ce.desiredSize)||0)+10}});ce&&await ce.close(),pe=!0}catch(ce){console.error(ce)}finally{return ee.rs.cancel(),pe}}async function ze(D,z){var $,K;let ee=await Oi(D);if(ee)try{let pe=ee.rs.getReader();for(($=z.start)==null?void 0:$.call(z);;){let{value:ce,done:Be}=await pe.read();if(ce!==void 0){let st;if(z.update instanceof Promise?st=await z.update(ce):st=z.update(ce),st){await pe.cancel();break}}if(Be){(K=z.end)==null||K.call(z);break}}}catch(pe){console.error(pe)}finally{ee.ws.close()}}}),T9={UNAUTHORIZED:"Not logged in yet, please log in and try again",LOGIN_FAIL:"The login status is invalid",PERMISSION_DENIED:"No permission or project does not exist",PERMISSION_DENIED1:"No permission",PRJ_NOT_EXIST:"No permission or project does not exist",ERROR_PATH:"No permission or project does not exist",PROJECT_NOT_FOUND:"The project was not found",PERMISSION_DENIED_PARAMS:"No permission to operate {type}",DATA_NOT_FOUND:"Data not found",PARAMS_DATA_NOT_FOUND:"The {type} data was not found",REQUEST_PARAM_ILLEGAL:"Parameter error",REQUEST_PARAM_ILLEGAL1:"Parameter error",REQUEST_PARAMS_ILLEGAL2:"The {type} parameter request is incorrect",REQUEST_PARAMS_NOT_NULL:"The {type} parameter of the request cannot be empty",REQUEST_PARAMS_NOT_ALL_NULL:"The {type} parameter of the request cannot be empty simultaneously",REQUEST_PARAMS_MUST_ARRAY:"The request parameter {type} must be an array",REQUEST_PARAMS_MUST_STRING:"The request parameter {type} must be a string",REQUEST_PARAMS_MUST_NUMBER:"The request parameter {type} must be a number",REQUEST_PARAMS_MUST_NUMBER_ARRAY:"The request parameter {type} must be a numeric array",REQUEST_PARAMS_MUST_STRING_ARRAY:"The request parameter {type} must be a string array",REQUEST_PARAMS_LENGTH_ERROR:"The length of the request parameter {type} is incorrect",REQUEST_PARAMS_TYPE_ERROR:"The request parameter {type} is of incorrect type",ILLEGAL_NAME:'The name is illegal and contains illegal characters such as /:*?"<>|',ILLEGAL_NAME1:'The name is illegal and contains illegal characters such as /:*?"<>|',ILLEGAL_NAME_ZH:"The name cannot contain Chinese characters",UUID_ERROR:"uuid error",DUPLICATE_DATA:"Duplicate title",DUPLICATE_DATA1:"Library duplicate name",DUPLICATE_DATA_PARAMS:"{type} Duplicate data",UPLOAD_LIMIT:"Document {documentName} size over 15MB, it is too big to save in the server, please modify and then try again.",MORE_THAN_LIMIT:"Exceed the maximum limit",FILE_MORE_THAN_LIMIT:"Exceed the maximum upload limit of {type}",PARAMS_MORE_THAN_LIMIT:"Exceed the maximum upload limit of the parameter {type}",IMAGE_MORE_THAN_LIMIT_PARAMS:"The picture exceeds the maximum upload limit",FILE_MORE_THAN_LIMIT_PARAMS:"The file exceeds the maximum upload limit",END_MUST_AFTER_START:"The start time cannot be later than the end time",FILE_READ_ONLY:"The project file eprj or library file elib property was set as read only, please enable the read only property at File Manager and try again, and contact with support",FILE_READ_ONLY1:"The project file eprj or library file elib property was set as read only, please enable the read only property at File Manager and try again, and contact with support",DATA_NOT_EXIST:"document {documentName} not exists",REQUEST_PARAMS_TIME_ERROR:"The time request parameter is incorrect",FILES_PATH_NOT_FOUND:"The file address cannot be found",FILES_DATA_NOT_FOUND:"The file data cannot be found",FILES_TYPE_ERROR:"File type error",FILES_TYPE_MUST_BE_ONE:"The file type must be {type}",SET_WATERMARK_FAIL:"Watermark setting failed",MYSQL_CRUD_ERROR:"{type} data execution failed. Please contact technical support for resolution",PARAMS_JSON_FAILED:"{type} data parsing failed",MYSQL_ERROR:"Database operation anomaly",NOT_FOUND:"The request does not exist",PRJ_NAME_EXISTS:"The name of the project already exists",BACKUP_NAME_EXISTS:"Backup Name already exists",TITLE_ILLEGAL_LEN:"The {documentName} length must be 1~128 bytes!",LIB_NOT_EXIST:"The component library does not exist",CONFIG_API_URLS_ERROR:"Real-time prices and inventory are not enabled. Please contact the administrator",ONE_CLICK_ORDER_NOT_OPEN:"The order placement function is not enabled. Please contact the administrator",MATERIAL_NOT_OPEN:"The material warehouse is not open. Please contact the administrator",SNAPSHOT_DEPTH_LIMIT:"There is a snapshot near the latest node or the snapshot has been applied for",OCR_SYMBOL_URL_ERROR:"The OCR request address is not configured",USER_DATA_NOT_FOUND:"The user does not exist",USER_DISABLE_ERROR:"The account has been deactivated",USER_EXISTS_LOGIN_ERROR:"The user has logged in elsewhere",USER_UNAUTHORIZED_MODULES_ERROR:"This account has not authorized the module",USER_UNAUTHORIZED_ACCESS_ERROR:"Access type error",ADMIN_NOT_CHANGE_PASSWORD:"The super administrator cannot reset the password",SAME_PASSWORD_NEW_PASSWORD:"The original password is the same as the new one",USER_ONLINE_REGISTRATION_FAILED:"The registration of the user online failed",USER_PASSWORD_CAN_NOT_DEFAULT:"The default password cannot be used",USER_BEFORE_PASSWORD_ERROR:"The original password is incorrect",USER_PASSWORD_LENGTH_ERROR:"The password length is 8 to 255 characters",ORG_ROLE_NOT_CREATE:"System roles cannot be created. Please make the necessary modifications",ORG_ROLE_NAME_DUPLICATE:"The character name already exists. Please modify it",ORG_ROLE_ORIGIN_ERROR:"Unknown character source {message}",ORG_ROLE_NOT_DEFAULT:"This character is not a preset one and cannot be operated",ADMIN_ROLE_NOT_CHANGE:"Administrator privileges do not allow for modification",ADMIN_NOT_CHANGE_STATUS:"The admin account cannot change its status",PROJECT_ARCHIVED:"The project has been locked",PROJECT_UUID_NULL:"The project uuid cannot be empty",PROJECT_UUID_ERROR:"uuid error or the project uuid already exists",PROJECT_OR_TEAM_UUID_ERROR:"The project uuid is incorrect or the team uuid already exists",PROJECT_NOT_PERSON_ERROR:"Personal projects are not allowed to be created",PROJECT_DUPLICATE_NAME:"Duplicate title",ANNOTATION_HAS_BE_FOUND:"The annotation has been created",ANNOTATION_NOT_FOUND:"The annotation block does not exist",ANNOTATION_CREATE_ERROR:"The annotation block creation failed",ANNOTATION_UPDATE_ERROR:"The update of the annotation block failed",ANNOTATION_DELETE_ERROR:"The annotation failed to be deleted",PROJECT_DUPLICATE_PATH:"The same path cannot be created",TEAM_NOT_FOUND:"The team does not exist",TEAM_UUID_NULL:"The team uuid cannot be empty",TEAM_FOLDER_ERROR:"The parent folder does not exist or does not belong to the current team",TEAM_FOLDER_UUID_ERROR:"The folder uuid is incorrect or the project uuid already exists",TEAM_URL_DUPLICATE:"Team link repetition",TEAM_CAN_NOT_DELETE:"There are still projects in the team. Please transfer or delete them first",COMPONENT_UUID_NULL:"The uuid of a component cannot be empty",COMPONENT_DATA_NOT_FOUND:"The component library data does not exist",COMPONENT_NAME_DUPLICATE:"Component libraries cannot have the same name",COMPONENT_TYPE_ERROR:"Library type error",DELETE_SON_CATEGORY:"The subcategories need to be deleted first",LICENSE:"License not found",START_TIME:"The start time of the license is incorrect",END_TIME:"The end time of the license is incorrect",PROJECT_LIMIT:"Number of projects created exceeds the limit",USER_LIMIT:"The maximum number of accounts has been reached",ONLINE_NUMBER_LIMIT:"The maximum number of online users has been reached",LIMIT_PCB:"The PCB authorization quota has been reached and the addition failed",LIMIT_SCH:"The schematic authorization number is full, and the addition failed",LIMIT_PANEL:"The panel authorization number is full and the addition failed",TIME_ERROR:"If the system time is incorrect, please restart the server or fix the system time. After fixing, the private service needs to be restarted",LICENSE_ERROR:"Authorization error",LICENSE_TYPE_ERROR:"The type of authorized application is incorrect",LICENSE_ORIGIN_ERROR:"Unknown authorized application {type}",BRANCH_DATA_NOT_FOUND:"There is no engineering branch",PARENT_UUID_ERROR:"parent uuid error",BRANCH_MUST_AFTER_NODE:"The branch must be after the node",BRANCH_NAME_ERROR:"Incorrect branch name",BRANCH_NAME_DUPLICATE:"The branch name already exists",BRANCH_UUID_ERROR:"The branch uuid is incorrect",BRANCH_NODE_SET_ERROR:"Nodes cannot be set as default branches or marked as master",BRANCH_DELETE_MAIN_ERROR:"Nodes or branches on the main branch cannot be deleted",BRANCH_CHECK_OUT_ERROR:"There are documents that have been checked out",DOCUMENT_UUID_ERROR:"The document uuid is incorrect",UPDATE_FAILED:"Update failed",INNER_API_KEY_ERROR:"The ApiKey of the internal interface of the server is incorrect",BRANCH_MORE_THAN_LIMIT:"The version exceeds the maximum limit",WORKSPACE_API_ERROR:"The workspace request response is abnormal"},I9={UNAUTHORIZED:"\u5C1A\u672A\u767B\u5F55\uFF0C\u8BF7\u767B\u5F55\u540E\u518D\u8BD5",LOGIN_FAIL:"\u767B\u5F55\u72B6\u6001\u5F02\u5E38",PERMISSION_DENIED:"\u6CA1\u6709\u6743\u9650\u6216\u5DE5\u7A0B\u4E0D\u5B58\u5728",PERMISSION_DENIED1:"\u6CA1\u6709\u6743\u9650",PRJ_NOT_EXIST:"\u6CA1\u6709\u6743\u9650\u6216\u5DE5\u7A0B\u4E0D\u5B58\u5728",ERROR_PATH:"\u6CA1\u6709\u6743\u9650\u6216\u5DE5\u7A0B\u4E0D\u5B58\u5728",PROJECT_NOT_FOUND:"\u5DE5\u7A0B\u672A\u627E\u5230",PERMISSION_DENIED_PARAMS:"\u6CA1\u6709\u6743\u9650\u64CD\u4F5C{type}",DATA_NOT_FOUND:"\u6570\u636E\u672A\u627E\u5230",PARAMS_DATA_NOT_FOUND:"{type}\u6570\u636E\u672A\u627E\u5230",REQUEST_PARAM_ILLEGAL:"\u53C2\u6570\u9519\u8BEF",REQUEST_PARAM_ILLEGAL1:"\u53C2\u6570\u9519\u8BEF",REQUEST_PARAMS_ILLEGAL2:"\u8BF7\u6C42{type}\u53C2\u6570\u9519\u8BEF",REQUEST_PARAMS_NOT_NULL:"\u8BF7\u6C42{type}\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A",REQUEST_PARAMS_NOT_ALL_NULL:"\u8BF7\u6C42{type}\u53C2\u6570\u4E0D\u80FD\u540C\u65F6\u4E3A\u7A7A",REQUEST_PARAMS_MUST_ARRAY:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u6570\u7EC4",REQUEST_PARAMS_MUST_STRING:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u5B57\u7B26\u4E32",REQUEST_PARAMS_MUST_NUMBER:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u6570\u5B57",REQUEST_PARAMS_MUST_NUMBER_ARRAY:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u6570\u5B57\u6570\u7EC4",REQUEST_PARAMS_MUST_STRING_ARRAY:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4",REQUEST_PARAMS_LENGTH_ERROR:"\u8BF7\u6C42\u53C2\u6570{type}\u957F\u5EA6\u9519\u8BEF",REQUEST_PARAMS_TYPE_ERROR:"\u8BF7\u6C42\u53C2\u6570{type}\u7C7B\u578B\u9519\u8BEF",ILLEGAL_NAME:'\u540D\u79F0\u975E\u6CD5, \u5305\u542B /:*?"<>| \u7B49\u975E\u6CD5\u5B57\u7B26',ILLEGAL_NAME1:'\u540D\u79F0\u975E\u6CD5, \u5305\u542B /:*?"<>| \u7B49\u975E\u6CD5\u5B57\u7B26',ILLEGAL_NAME_ZH:"\u540D\u79F0\u4E0D\u80FD\u5305\u542B\u4E2D\u6587",UUID_ERROR:"uuid \u9519\u8BEF",DUPLICATE_DATA:"\u6807\u9898\u5DF2\u5B58\u5728",DUPLICATE_DATA1:"\u5E93\u91CD\u540D",DUPLICATE_DATA_PARAMS:"{type}\u91CD\u590D\u6570\u636E",UPLOAD_LIMIT:"\u6587\u6863 {documentName} \u8D85\u8FC715MB\uFF0C\u5BFC\u81F4\u65E0\u6CD5\u6B63\u5E38\u4FDD\u5B58\uFF0C\u8BF7\u4FEE\u6539\u540E\u518D\u5BFC\u5165",MORE_THAN_LIMIT:"\u8D85\u8FC7\u6700\u5927\u9650\u5236",FILE_MORE_THAN_LIMIT:"\u8D85\u8FC7{type}\u6700\u5927\u4E0A\u4F20\u9650\u5236",PARAMS_MORE_THAN_LIMIT:"\u8D85\u8FC7\u53C2\u6570{type}\u7684\u6700\u5927\u4E0A\u4F20\u9650\u5236",IMAGE_MORE_THAN_LIMIT_PARAMS:"\u56FE\u7247\u8D85\u8FC7\u6700\u5927\u4E0A\u4F20\u9650\u5236",FILE_MORE_THAN_LIMIT_PARAMS:"\u6587\u4EF6\u8D85\u8FC7\u6700\u5927\u4E0A\u4F20\u9650\u5236",END_MUST_AFTER_START:"\u5F00\u59CB\u65F6\u95F4\u4E0D\u80FD\u665A\u4E8E\u7ED3\u675F\u65F6\u95F4",FILE_READ_ONLY:"\u5DE5\u7A0B\u6587\u4EF6eprj\u6216\u5E93\u6587\u4EF6elib\u5C5E\u6027\u53D8\u4E3A\u53EA\u8BFB\uFF0C\u8BF7\u5728\u8D44\u6E90\u7BA1\u7406\u5668\u53D6\u6D88\u53EA\u8BFB\u540E\u518D\u8BD5\uFF0C\u5E76\u8054\u7CFB\u6280\u672F\u652F\u6301",FILE_READ_ONLY1:"\u5DE5\u7A0B\u6587\u4EF6eprj\u6216\u5E93\u6587\u4EF6elib\u5C5E\u6027\u53D8\u4E3A\u53EA\u8BFB\uFF0C\u8BF7\u5728\u8D44\u6E90\u7BA1\u7406\u5668\u53D6\u6D88\u53EA\u8BFB\u540E\u518D\u8BD5\uFF0C\u5E76\u8054\u7CFB\u6280\u672F\u652F\u6301",DATA_NOT_EXIST:"\u6587\u6863{documentName}\u4E0D\u5B58\u5728",REQUEST_PARAMS_TIME_ERROR:"\u65F6\u95F4\u8BF7\u6C42\u53C2\u6570\u9519\u8BEF",FILES_PATH_NOT_FOUND:"\u627E\u4E0D\u5230\u6587\u4EF6\u5730\u5740",FILES_DATA_NOT_FOUND:"\u627E\u4E0D\u5230\u6587\u4EF6\u6570\u636E",FILES_TYPE_ERROR:"\u6587\u4EF6\u7C7B\u578B\u9519\u8BEF",FILES_TYPE_MUST_BE_ONE:"\u6587\u4EF6\u7C7B\u578B\u5FC5\u987B\u4E3A{type}",SET_WATERMARK_FAIL:"\u6C34\u5370\u8BBE\u7F6E\u5931\u8D25",MYSQL_CRUD_ERROR:"{type}\u6570\u636E\u6267\u884C\u5931\u8D25, \u8BF7\u8054\u7CFB\u6280\u672F\u652F\u6301\u89E3\u51B3",PARAMS_JSON_FAILED:"{type}\u6570\u636E\u89E3\u6790\u5931\u8D25",MYSQL_ERROR:"\u6570\u636E\u5E93\u64CD\u4F5C\u5F02\u5E38",NOT_FOUND:"\u8BF7\u6C42\u4E0D\u5B58\u5728",PRJ_NAME_EXISTS:"\u5DE5\u7A0B\u540D\u79F0\u5DF2\u5B58\u5728",BACKUP_NAME_EXISTS:"\u5907\u4EFD\u540D\u79F0\u5DF2\u5B58\u5728",TITLE_ILLEGAL_LEN:"{documentName}\u957F\u5EA6\u5FC5\u987B\u4E3A1~128\u5B57\u7B26\u957F\u5EA6\uFF01",LIB_NOT_EXIST:"\u5143\u4EF6\u5E93\u4E0D\u5B58\u5728",CONFIG_API_URLS_ERROR:"\u5B9E\u65F6\u4EF7\u683C\u548C\u5E93\u5B58\u672A\u5F00\u542F, \u8BF7\u8054\u7CFB\u7BA1\u7406\u5458",ONE_CLICK_ORDER_NOT_OPEN:"\u4E00\u4EF6\u4E0B\u5355\u529F\u80FD\u672A\u5F00\u542F, \u8BF7\u8054\u7CFB\u7BA1\u7406\u5458",MATERIAL_NOT_OPEN:"\u7269\u6599\u5E93\u672A\u5F00\u542F, \u8BF7\u8054\u7CFB\u7BA1\u7406\u5458",SNAPSHOT_DEPTH_LIMIT:"\u6700\u65B0\u8282\u70B9\u9644\u8FD1\u5B58\u5728\u5FEB\u7167\u6216\u5FEB\u7167\u5DF2\u88AB\u7533\u8BF7",OCR_SYMBOL_URL_ERROR:"OCR\u8BF7\u6C42\u5730\u5740\u672A\u914D\u7F6E",USER_DATA_NOT_FOUND:"\u7528\u6237\u4E0D\u5B58\u5728",USER_DISABLE_ERROR:"\u8D26\u53F7\u5DF2\u505C\u7528",USER_EXISTS_LOGIN_ERROR:"\u7528\u6237\u5DF2\u5728\u522B\u7684\u5730\u65B9\u767B\u5F55",USER_UNAUTHORIZED_MODULES_ERROR:"\u8BE5\u8D26\u53F7\u672A\u6388\u6743\u6A21\u5757",USER_UNAUTHORIZED_ACCESS_ERROR:"\u8BBF\u95EE\u7C7B\u578B\u9519\u8BEF",ADMIN_NOT_CHANGE_PASSWORD:"\u8D85\u7EA7\u7BA1\u7406\u5458\u65E0\u6CD5\u91CD\u7F6E\u5BC6\u7801",SAME_PASSWORD_NEW_PASSWORD:"\u539F\u5BC6\u7801\u8DDF\u65B0\u5BC6\u7801\u76F8\u540C",USER_ONLINE_REGISTRATION_FAILED:"\u767B\u8BB0\u7528\u6237\u5728\u7EBF\u5931\u8D25",USER_PASSWORD_CAN_NOT_DEFAULT:"\u4E0D\u80FD\u4F7F\u7528\u9ED8\u8BA4\u5BC6\u7801",USER_BEFORE_PASSWORD_ERROR:"\u539F\u5BC6\u7801\u9519\u8BEF",USER_PASSWORD_LENGTH_ERROR:"\u5BC6\u7801\u957F\u5EA6\u4E3A8-255\u4F4D",ORG_ROLE_NOT_CREATE:"\u4E0D\u80FD\u521B\u5EFA\u7CFB\u7EDF\u89D2\u8272, \u8BF7\u4FEE\u6539",ORG_ROLE_NAME_DUPLICATE:"\u89D2\u8272\u540D\u79F0\u5DF2\u5B58\u5728, \u8BF7\u4FEE\u6539",ORG_ROLE_ORIGIN_ERROR:"\u672A\u77E5\u7684\u89D2\u8272\u6765\u6E90{message}",ORG_ROLE_NOT_DEFAULT:"\u8BE5\u89D2\u8272\u4E0D\u662F\u9884\u8BBE\u89D2\u8272, \u4E0D\u80FD\u64CD\u4F5C",ADMIN_ROLE_NOT_CHANGE:"\u7BA1\u7406\u5458\u6743\u9650\u4E0D\u5141\u8BB8\u4FEE\u6539",ADMIN_NOT_CHANGE_STATUS:"admin\u8D26\u53F7\u4E0D\u80FD\u66F4\u6539\u72B6\u6001",PROJECT_ARCHIVED:"\u5DE5\u7A0B\u5DF2\u88AB\u9501\u5B9A",PROJECT_UUID_NULL:"\u5DE5\u7A0Buuid\u4E0D\u80FD\u4E3A\u7A7A",PROJECT_UUID_ERROR:"uuid\u9519\u8BEF\u6216\u8005\u5DE5\u7A0Buuid\u5DF2\u5B58\u5728",PROJECT_OR_TEAM_UUID_ERROR:"\u5DE5\u7A0Buuid\u9519\u8BEF\u6216\u8005\u5DF2\u5B58\u5728\u56E2\u961Fuuid",PROJECT_NOT_PERSON_ERROR:"\u4E0D\u5141\u8BB8\u521B\u5EFA\u4E2A\u4EBA\u5DE5\u7A0B",PROJECT_DUPLICATE_NAME:"\u6807\u9898\u5DF2\u5B58\u5728",ANNOTATION_HAS_BE_FOUND:"\u6279\u6CE8\u5DF2\u521B\u5EFA",ANNOTATION_NOT_FOUND:"\u6279\u6CE8\u5757\u4E0D\u5B58\u5728",ANNOTATION_CREATE_ERROR:"\u6279\u6CE8\u5757\u521B\u5EFA\u5931\u8D25",ANNOTATION_UPDATE_ERROR:"\u66F4\u65B0\u6279\u6CE8\u5757\u5931\u8D25",ANNOTATION_DELETE_ERROR:"\u6279\u6CE8\u6761\u5220\u9664\u5931\u8D25",PROJECT_DUPLICATE_PATH:"\u4E0D\u80FD\u521B\u5EFA\u76F8\u540C\u7684\u8DEF\u5F84",TEAM_NOT_FOUND:"\u56E2\u961F\u4E0D\u5B58\u5728",TEAM_UUID_NULL:"\u56E2\u961Fuuid\u4E0D\u80FD\u4E3A\u7A7A",TEAM_FOLDER_ERROR:"\u7236\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\u6216\u4E0D\u5C5E\u4E8E\u5F53\u524D\u56E2\u961F",TEAM_FOLDER_UUID_ERROR:"\u6587\u4EF6\u5939uuid\u9519\u8BEF\u6216\u8005\u5DE5\u7A0Buuid\u5DF2\u5B58\u5728",TEAM_URL_DUPLICATE:"\u56E2\u961F\u94FE\u63A5\u91CD\u590D",TEAM_CAN_NOT_DELETE:"\u56E2\u961F\u4ECD\u5B58\u5728\u5DE5\u7A0B, \u8BF7\u5148\u8F6C\u79FB\u6216\u8005\u5220\u9664",COMPONENT_UUID_NULL:"\u5143\u4EF6uuid\u4E0D\u80FD\u4E3A\u7A7A",COMPONENT_DATA_NOT_FOUND:"\u5143\u4EF6\u5E93\u6570\u636E\u4E0D\u5B58\u5728",COMPONENT_NAME_DUPLICATE:"\u5143\u4EF6\u5E93\u4E0D\u80FD\u91CD\u540D",COMPONENT_TYPE_ERROR:"\u5E93\u7C7B\u578B\u9519\u8BEF",DELETE_SON_CATEGORY:"\u9700\u8981\u5148\u5220\u9664\u5B50\u7C7B\u522B",LICENSE:"\u672A\u627E\u5230\u8BB8\u53EF\u8BC1",START_TIME:"\u8BB8\u53EF\u8BC1\u5F00\u59CB\u65F6\u95F4\u9519\u8BEF",END_TIME:"\u8BB8\u53EF\u8BC1\u7ED3\u675F\u65F6\u95F4\u9519\u8BEF",PROJECT_LIMIT:"\u521B\u5EFA\u7684\u9879\u76EE\u6570\u91CF\u8D85\u8FC7\u9650\u5236",USER_LIMIT:"\u5DF2\u8FBE\u5230\u6700\u5927\u8D26\u53F7\u6570",ONLINE_NUMBER_LIMIT:"\u5DF2\u8FBE\u5230\u6700\u5927\u5728\u7EBF\u6570",LIMIT_PCB:"PCB\u6388\u6743\u6570\u5DF2\u6EE1, \u6DFB\u52A0\u5931\u8D25",LIMIT_SCH:"\u539F\u7406\u56FE\u6388\u6743\u6570\u5DF2\u6EE1, \u6DFB\u52A0\u5931\u8D25",LIMIT_PANEL:"\u9762\u677F\u6388\u6743\u6570\u5DF2\u6EE1, \u6DFB\u52A0\u5931\u8D25",TIME_ERROR:"\u7CFB\u7EDF\u65F6\u95F4\u9519\u8BEF\u8BF7\u91CD\u542F\u670D\u52A1\u5668\u6216\u4FEE\u590D\u7CFB\u7EDF\u65F6\u95F4, \u4FEE\u590D\u540E\u9700\u8981\u91CD\u542F\u79C1\u6709\u5316\u670D\u52A1",LICENSE_ERROR:"\u6388\u6743\u9519\u8BEF",LICENSE_TYPE_ERROR:"\u6388\u6743\u5E94\u7528\u7C7B\u578B\u9519\u8BEF",LICENSE_ORIGIN_ERROR:"\u672A\u77E5\u7684\u6388\u6743\u5E94\u7528{type}",BRANCH_DATA_NOT_FOUND:"\u5DE5\u7A0B\u5206\u652F\u4E0D\u5B58\u5728",PARENT_UUID_ERROR:"\u7236\u7EA7uuid\u9519\u8BEF",BRANCH_MUST_AFTER_NODE:"\u5206\u652F\u5FC5\u987B\u5728\u8282\u70B9\u540E",BRANCH_NAME_ERROR:"\u5206\u652F\u540D\u9519\u8BEF",BRANCH_NAME_DUPLICATE:"\u5206\u652F\u540D\u5DF2\u5B58\u5728",BRANCH_UUID_ERROR:"\u5206\u652Fuuid\u9519\u8BEF",BRANCH_NODE_SET_ERROR:"\u8282\u70B9\u4E0D\u80FD\u8BBE\u7F6E\u4E3A\u9ED8\u8BA4\u5206\u652F\u6216\u6807\u8BB0\u4E3Amaster",BRANCH_DELETE_MAIN_ERROR:"\u4E0D\u80FD\u5220\u9664\u4E3B\u5206\u652F\u4E0A\u7684\u8282\u70B9\u6216\u5206\u652F",BRANCH_CHECK_OUT_ERROR:"\u5B58\u5728\u6587\u6863\u5DF2\u7B7E\u51FA",DOCUMENT_UUID_ERROR:"\u6587\u6863uuid\u9519\u8BEF",UPDATE_FAILED:"\u66F4\u65B0\u5931\u8D25",INNER_API_KEY_ERROR:"\u670D\u52A1\u7AEF\u5185\u90E8\u63A5\u53E3 ApiKey \u9519\u8BEF",BRANCH_MORE_THAN_LIMIT:"\u7248\u672C\u8D85\u8FC7\u6700\u5927\u9650\u5236",WORKSPACE_API_ERROR:"\u5DE5\u4F5C\u533A\u8BF7\u6C42\u54CD\u5E94\u5F02\u5E38"},jP={codeEN:T9,codeCN:I9},JL=class KL{static load(){typeof jP=="object"&&(KL.cache=jP)}static match(t,i,r){if(!this.cache||!this.cache[t])return;let n=this.cache[t][i];if(r&&Object.prototype.toString.call(r)==="[object Object]")for(let s in r){let a=r[s];n=n.replace(`{${s}}`,a)}return n}};JL.cache={};var IT=JL;function A9(){console.log("common init----------------"),IT.load()}function Zo(e,t){throw new Error(`invalid format state on (${t}) of ${e}`)}function C9(e,...t){let i=[],r=0,n=0,s,a=0,o=0;for(let l=0;l<e.length;l++){let c=e.charAt(l);switch(r){case 0:c==="%"?r=1:i.push(c);break;case 1:switch(c){case"d":s=t[n++],typeof s=="number"?(i.push(s.toFixed(0)),r=0):Zo(e,l);break;case"f":s=t[n++],typeof s=="number"?(i.push(s.toString()),r=0):Zo(e,l);break;case"x":s=t[n++],typeof s=="number"?(i.push((s|0).toString(16)),r=0):Zo(e,l);break;case"X":s=t[n++],typeof s=="number"?(i.push((s|0).toString(16).toUpperCase()),r=0):Zo(e,l);break;case"s":case"c":s=t[n++],i.push(s===null?"null":s.toString()),r=0;break;case"0":a=l+1,o=-1,r=2;break;case"%":i.push("%"),r=0;break;default:Zo(e,l)}break;case 2:switch(c){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":o=l;break;case"d":if(o>=a){let u=parseInt(e.substring(a,o+1));s=t[n++],typeof s=="number"?(i.push((s|0).toString(10).padStart(u,"0")),r=0):Zo(e,l)}else Zo(e,l);break;case"x":if(o>=a){let u=parseInt(e.substring(a,o+1));s=t[n++],typeof s=="number"?(i.push((s|0).toString(16).padStart(u,"0")),r=0):Zo(e,l)}else Zo(e,l);break;case"X":if(o>=a){let u=parseInt(e.substring(a,o+1));s=t[n++],typeof s=="number"?(i.push((s|0).toString(16).toUpperCase().padStart(u,"0")),r=0):Zo(e,l)}else Zo(e,l);break;default:Zo(e,l)}break;default:Zo(e,l)}}return i.join("")}function $L(e){let t="";try{let i=/.*\\(.*)$/.exec(e);i&&i[1]&&typeof i[1]=="string"&&(t=i[1])}catch(i){console.error("Query Folder Name Error:",i)}return t}function ZL(e,t){let i=Math.max(e.length,t.length);for(let r=0;r<i;r++){let n=e[r],s=t[r],a=0;if(typeof n=="string"&&typeof s=="string")a=n.localeCompare(s);else if(typeof n=="number"&&typeof s=="number")a=n-s;else{if(typeof n=="number"&&typeof s=="string")return-1;if(typeof n=="string"&&typeof s=="number")return 1;if(n===void 0&&s!==void 0)return-1;if(n!==void 0&&s===void 0)return 1}if(a!==0)return a}return 0}function AT(e){let t=/\d+/g,i=new Array,r=0;for(;;){let n=t.exec(e);if(n)r<n.index&&i.push(e.substring(r,n.index)),r=n.index+n[0].length,i.push(parseInt(n[0]));else break}return i.push(e),i}function D9(e,t,i,r){var n,s;let a=[],o=[],l=[];for(let h=0,d=e.length;h<d;h++){a[h]=h;let p;if(Array.isArray(t)){let f="";for(let m=0;m<t.length;m++)if(Object.hasOwnProperty.call(e[h],t[m])){f=e[h][t[m]];break}}else p=t?e[h][t]||((s=(n=e[h])==null?void 0:n[r])==null?void 0:s[t])||"":e[h];if(o[h]=String(p).toUpperCase().match(/\D+|\d+(?:\.\d+)?/g),l[h]=[],o[h])for(let f=0;f<o[h].length;f++)l[h][f]=o[h][f].match(/\d/)?1:2}let c=function(h,d){let p=o[h],f=o[d],m=l[h],g=l[d];if(!p||!f)return i?p==f?0:p?-1:1:p==f?0:p?1:-1;let b=Math.max(p.length,f.length);for(let y=0;y<b;y++){if(i)if(p[y])if(f[y]){if(p[y]!=f[y])return m[y]!=g[y]?m[y]==1?1:-1:m[y]==1?f[y]-p[y]:p[y]<f[y]?1:-1}else return-1;else return 1;if(p[y])if(f[y]){if(p[y]!=f[y])return m[y]!=g[y]?m[y]==1?-1:1:m[y]==1?p[y]-f[y]:p[y]<f[y]?-1:1}else return 1;else return-1}return 0};a.sort(c);let u=[];for(let h=0;h<e.length;h++)u[h]=e[a[h]];return u}function _9(e,t,i){let r=[],n=[],s=[],a=[e,t];for(let o=0,l=a.length;o<l;o++){r[o]=o;let c=a[o];if(n[o]=String(c).toUpperCase().match(/\D+|\d+(?:\.\d+)?/g),s[o]=[],n[o])for(let u=0;u<n[o].length;u++)s[o][u]=n[o][u].match(/\d/)?1:2}return(function(o,l){let c=n[o],u=n[l],h=s[o],d=s[l];if(!c||!u)return i?c==u?0:c?-1:1:c==u?0:c?1:-1;let p=Math.max(c.length,u.length);for(let f=0;f<p;f++){if(i)if(c[f])if(u[f]){if(c[f]!=u[f])return h[f]!=d[f]?h[f]==1?1:-1:h[f]==1?u[f]-c[f]:c[f]<u[f]?1:-1}else return-1;else return 1;if(c[f])if(u[f]){if(c[f]!=u[f])return h[f]!=d[f]?h[f]==1?-1:1:h[f]==1?c[f]-u[f]:c[f]<u[f]?-1:1}else return 1;else return-1}return 0})(r[0],r[1])}function Zx(e,t){let i=!1;for(let r in t)if(Object.hasOwnProperty.call(t,r)&&e.indexOf(r)!==-1){i=!0;break}return i}function P9(e,t=""){return e.sort((r,n)=>ZL(AT(i(r)),AT(i(n)))),e;function i(r){if(!r)return r;let n;if(Array.isArray(t)){let s="";for(let a=0;a<t.length;a++)if(Object.hasOwnProperty.call(r,t[a])){s=r[t[a]];break}}else n=r[t]||r;return n}}function L9(e,t,i=1){var r,n,s,a;let o=(r=e.match(/^\D+/))==null?void 0:r[0],l=(n=e.match(/\d+$/))==null?void 0:n[0],c=(s=t.match(/^\D+/))==null?void 0:s[0],u=(a=t.match(/\d+$/))==null?void 0:a[0];return o&&c?o!==c?i===1?o.localeCompare(c):c.localeCompare(o):l!==u?+l>+u?1*i:-1*i:0:o?-1*i:c?1*i:0}function O9(e){return new Promise(t=>{setTimeout(t,e)})}var Nre=Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map(e=>e.charCodeAt(0));function R9(){try{if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis}catch{return null}}function ut(){return self.EDITOR_TOP||self}var vr=(e,t)=>{let i=/{([^}]*)}/gim,r=[...new Set(e.match(i))];for(let n=0;n<r.length;n++){let s=r[n],a=s.substring(1,s.length-1);t[a]&&(e=e.replace(s,t[a]))}return e};function N9(e,t,i){t=t||1,i=i||32;var r="",n=t,s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];e&&(n=Math.round(Math.random()*(i-t))+t);for(var a=0;a<n;a++){let o=Math.round(Math.random()*(s.length-1));r+=s[o]}return r}function M9(e){try{return JSON.parse(e)}catch{return console.error(`ParseJSON failed:
`+e),null}}var B9=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.DUMMY=5]="DUMMY",e))(B9||{}),k9=(e,t)=>{switch(e){case 4:console.error(...t);break;case 3:console.warn(...t);break;case 2:console.info(...t);break;default:console.log(...t)}},F9=(e,t)=>t,G9=class Gy{constructor(t,i=k9,r=F9){this.level=t,this.writer=i,this.formatter=r}wrap(t){return new Gy(this.level,this.writer,(i,r)=>(r=this.formatter(i,r),t(i,r)))}inject(t){return new Gy(this.level,this.writer,(i,r)=>(r=t(i,r),this.formatter(i,r)))}shadow(...t){return new Gy(this.level,(i,r)=>{this.writer(i,r);for(let n of t)n(i,r)},this.formatter)}mix(...t){return new Gy(0,(i,r)=>{this.process(i,r);for(let n of t)n.process(i,r)},(i,r)=>r)}process(t,i){this.level<=t&&this.writer(t,this.formatter(t,i))}process1(t,i,r){this.level<=t&&this.writer(t,this.formatter(t,[C9(i,...r)]))}trace(...t){this.process(0,t)}trace1(t,...i){this.process1(0,t,i)}debug(...t){this.process(1,t)}debug1(t,...i){this.process1(1,t,i)}info(...t){this.process(2,t)}info1(t,...i){this.process1(2,t,i)}warn(...t){this.process(3,t)}warn1(t,...i){this.process1(3,t,i)}error(...t){this.process(4,t)}error1(t,...i){this.process1(4,t,i)}},Mre=new G9(5),Bre=Date.now()-performance.now(),QL=new ArrayBuffer(10),kre=new Float64Array(QL,0,1),Fre=new Uint8Array(QL);var tI={};w9(tI,{HAS_PANEL:()=>aF,HAS_PCB:()=>sF,HAS_SCH:()=>nF,HAS_SIM:()=>oF,IS_CLIENT:()=>Sc,IS_CLIENT_HALF_OFFLINE:()=>Zy,IS_CLIENT_NOT_ONLINE:()=>Z9,IS_CLIENT_OFFLINE:()=>iO,IS_CLIENT_ONLINE:()=>Nx,IS_DEV:()=>V9,IS_EASYEDA:()=>tO,IS_EASYEDA_CLIENT:()=>$9,IS_ECAD:()=>H9,IS_ENTERPRISE_CLIENT:()=>j9,IS_HALF_OFFLINE:()=>eE,IS_LCEDA:()=>eO,IS_LCEDA_CLIENT:()=>K9,IS_OFFLINE:()=>tE,IS_ONLINE:()=>Qx,IS_PCBLUXSHARE:()=>z9,IS_PRIVATE:()=>u0,PRO_EDITOR_MODE:()=>Q9,PRO_EDITOR_MODES:()=>Ds,SSO_EXTERNAL_IDENTITY_DOMAIN:()=>W9,SSO_EXTERNAL_PERMISSION_DOMAIN:()=>q9,SSO_EXTERNAL_PERMISSION_MANAGED_DOMAIN:()=>J9,SSO_IDENTITY_CONNECT:()=>X9});var U9=(e=>(e.ruler="ruler",e.un_ruler="un_ruler",e))(U9||{}),c0=(e=>(e[e.HOME=-1]="HOME",e[e.BLANKTAB=0]="BLANKTAB",e[e.SCH=1]="SCH",e[e.PART=2]="PART",e[e.PCB=3]="PCB",e[e.FOOTPRINT=4]="FOOTPRINT",e[e.PRJ=5]="PRJ",e[e.SUBPART=6]="SUBPART",e[e.NGSPICE_MODEL=7]="NGSPICE_MODEL",e[e.NGSPICE=8]="NGSPICE",e[e.SIMULIDE=9]="SIMULIDE",e[e.WAVEFORM=10]="WAVEFORM",e[e.SCHLIB3D=11]="SCHLIB3D",e[e.PHOTOVIEW=12]="PHOTOVIEW",e[e.SCHMODULE=13]="SCHMODULE",e[e.PCBMODULE=14]="PCBMODULE",e[e.VIEW3D=15]="VIEW3D",e[e.PCBLIB3D=16]="PCBLIB3D",e[e.BLOCK_SYMBOL=17]="BLOCK_SYMBOL",e[e.NETFLAG=18]="NETFLAG",e[e.NETPORT=19]="NETPORT",e[e.SHEET_SYMBOL=20]="SHEET_SYMBOL",e[e.NONEELEC_SYMBOL=21]="NONEELEC_SYMBOL",e[e.SHORT_SYMBOL=22]="SHORT_SYMBOL",e[e.FOOTPRINTVIEW=23]="FOOTPRINTVIEW",e[e.CNCPRINTVIEW=24]="CNCPRINTVIEW",e[e.OFF_PAGE_CONNECTOR=25]="OFF_PAGE_CONNECTOR",e[e.PANEL=26]="PANEL",e[e.PANEL3D=27]="PANEL3D",e[e.DEVICE=28]="DEVICE",e[e.PANEL_LIB=29]="PANEL_LIB",e[e.ASSEMBLY_VARIANT=30]="ASSEMBLY_VARIANT",e[e.DIFF_PAIRS_FLAG=31]="DIFF_PAIRS_FLAG",e[e.SIMULIDE_MODEL=32]="SIMULIDE_MODEL",e))(c0||{}),Y9=(e=>(e.SCH="SCH",e.PCB="PCB",e.PANEL="PANEL",e.SIM="SIM",e))(Y9||{}),zP=R9(),Ds=String((zP==null?void 0:zP.PRO_EDITOR_MODE)||"LCEDA").split("-"),V9=Ds.indexOf("DEVPRO")>=0,Sc=Ds.indexOf("CLIENT")>=0,eO=Ds.indexOf("LCEDA")>=0,tO=Ds.indexOf("EASYEDA")>=0,u0=Ds.indexOf("PRIVATE")>=0,Qx=Ds.indexOf("ONLINE")>=0,eE=Ds.indexOf("HALF_OFFLINE")>=0,tE=Ds.indexOf("OFFLINE")>=0,H9=Ds.indexOf("ECAD")>=0,j9=Ds.indexOf("ENTERPRISE")>=0,z9=Ds.indexOf("PCB_LUXSHARE")>=0,X9=Ds.indexOf("SSO_IDENTITY_CONNECT")>=0,W9=Ds.indexOf("SSO_EXTERNAL_IDENTITY_DOMAIN")>=0,q9=Ds.indexOf("SSO_EXTERNAL_PERMISSION_DOMAIN")>=0,J9=Ds.indexOf("SSO_EXTERNAL_PERMISSION_MANAGED_DOMAIN")>=0,K9=Sc&&eO,$9=Sc&&tO,Zy=Sc&&eE,Z9=Sc&&!Qx,iO=Sc&&tE,Nx=Sc&&Qx,Q9=Sc?Qx?"ONLINE":eE?"HALF_OFFLINE":tE?"OFFLINE":"":"",eF=Ds.indexOf("SCH")>=0,tF=Ds.indexOf("PCB")>=0,iF=Ds.indexOf("PANEL")>=0,rF=Ds.indexOf("SIM")>=0,nF=eF,sF=tF,aF=iF,oF=rF,iI=(e=>(e.PROJECT_BACKUPS_MANUAL="Backup Project Manually",e.PROJECT_BACKUPS_AUTO="Backup Project Automatically",e.DELETE_BACKUPS="Delete Backup",e.SAVE="Save",e.CREATE_SHEET="New Page",e.DELETE_SHEET="Delete Page",e.RENAME_SHEET="Rename Page",e.SIGNED_SHEET="Check Out Page",e.SIGNIN_SHEET="Check In Page",e.CLEAR_SIGNED="Clear Check Out",e.PROJECT_LOCK="Lock Project",e.PROJECT_UNLOCK="Unlock Project",e.PROJECT_OPEN="Open Project",e.PROJECT_CLOSE="Close Project",e.DOCUMENT_PASTE="Paste Document",e.DOCUMENT_PASTE_ACROSS_PROJECT="Paste Document Across Projects",e.SCHEMATIC_PASTE="Paste Schematic",e.SCHEMATIC_PASTE_ACROSS_PROJECT="Paste Schematic Across Projects",e.PRIMITIVE_PASTE_ACROSS_PROJECT="Paste Elements Across Projects",e.PROJECT_SAVEAS_REMOTE="Save Project to Cloud",e.PROJECT_SAVEAS_LOCAL="Save Project to Local",e.LIBRARY_SAVEAS_LOCAL="Save Library to Local",e.DOCUMENT_SAVEAS_REMOTE="Save Document to Cloud",e.DOCUMENT_SAVEAS_LOCAL="Save Document to Local",e.CBB_SAVEAS_REMOTE="Save Reuse Module to Cloud",e.CBB_SAVEAS_LOCAL="Save Reuse Module to Local",e.SVG_EXPORT="Export SVG",e.PNG_EXPORT="Export PNG",e.PDF_EXPORT="Export PDF",e.BOM_EXPORT="Export BOM",e.PRINT="Print",e.GERBER_EXPORT="Export Gerber",e.COORDINATE_EXPORT="Export Pick and Place File",e.D3FILE_EXPORT="Export 3D File",e.D3SHELLFILE_EXPORT="Export 3D Shell File",e.TESTPOINT_REPORT_EXPORT="Export Test Point Report",e.DXF_EXPORT="Export DXF",e.ODBPLUSS_EXPORT="Export ODB++",e.AD_EXPORT="Export Altium Designer",e.DEVICE_REPLACE="Replace Device",e.FOOTPRINT_REPLACE="Replace Footprint",e.D3MODEL_REPLACE="Replace 3D Model",e.PROJECTLIB_UPDATE="Update Project Library",e.REPLACE="Find and Replace",e.TRACK_BATCH_RENAME="Rename Wires in Batch",e.SHEET_BATCH_RENAME="Rename Pages in Batch",e.NET_CREATED_AUTO="Automatic Network Generation",e.DESIGNATOR_ALLOCATION="Annotate Designator",e.UNIQUE_ID_RESET="Reset Unique ID",e.NET_TABLE_EXPORT="Export Netlist",e.REFRESH_PCB_BY_SCH="Update Schematic to PCB",e.REFRESH_SCH_BY_PCB="Update PCB to Schematic",e.CLEAR_DESIGNATOR="Clear Designator",e.UPDATE_PORT_BY_MODULE_SYMBOL="Update Ports from Module Symbol",e.DESIGN_RULE="Set Design Rules",e.NET_CLASS="Set Network Class",e.EQUAL_LENGTH_GROUP="Set Equal Length Group",e.DIFFERENTIAL_PAIR="Set Differential Pair",e))(iI||{}),zf=class Qh{constructor(t,i=crypto.randomUUID()){this.fileName=t,this.uuid=i,this._params=new URLSearchParams,this._aTarget=document.createElement("a"),this._params.append("uuid",i),this._params.append("fileName",t)}static get URL_VERSION(){var t;try{let i=location.host,r="/";return((t=new RegExp(`${i}(/[\\w|.]+)${r}`).exec(location.href))==null?void 0:t[1])||""}catch{return""}}static getOpenedStream(t){return this._openedInstances.get(t)}get createURL(){return`${Qh.CREATE_URL}?${this._params}`}get writeURL(){return`${Qh.WRITE_URL}?${this._params}`}get closeURL(){return`${Qh.CLOSE_URL}?${this._params}`}get cancelURL(){return`${Qh.CANCEL_URL}?${this._params}`}async create(){this._aTarget.href=this.createURL,this._aTarget.click(),this._aTarget.remove(),Qh._openedInstances.set(this.uuid,this),await O9(100)}async write(t){await(await fetch(this.writeURL,{method:"post",body:t})).json()}async close(){await fetch(this.closeURL,{method:"post"}),Qh._openedInstances.delete(this.uuid)}async cancel(){await fetch(this.cancelURL,{method:"post"}),Qh._openedInstances.delete(this.uuid)}};zf.CREATE_URL=`${zf.URL_VERSION}/sw/download/stream/create`,zf.WRITE_URL="/sw/download/stream/write",zf.CLOSE_URL="/sw/download/stream/close",zf.CANCEL_URL="/sw/download/stream/cancel",zf._openedInstances=new Map;var lF=Object.create,rO=Object.defineProperty,cF=Object.getOwnPropertyDescriptor,uF=Object.getOwnPropertyNames,hF=Object.getPrototypeOf,dF=Object.prototype.hasOwnProperty,XP=(e=>typeof jf<"u"?jf:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof jf<"u"?jf:t)[i]}):e)(function(e){if(typeof jf<"u")return jf.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),er=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),pF=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of uF(t))!dF.call(e,n)&&n!==i&&rO(e,n,{get:()=>t[n],enumerable:!(r=cF(t,n))||r.enumerable});return e},Em=(e,t,i)=>(i=e!=null?lF(hF(e)):{},pF(t||!e||!e.__esModule?rO(i,"default",{value:e,enumerable:!0}):i,e)),h0=er((e,t)=>{"use strict";var i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a=(D,z)=>{for(var $ in z)i(D,$,{get:z[$],enumerable:!0})},o=(D,z,$,K)=>{if(z&&typeof z=="object"||typeof z=="function")for(let ee of n(z))!s.call(D,ee)&&ee!==$&&i(D,ee,{get:()=>z[ee],enumerable:!(K=r(z,ee))||K.enumerable});return D},l=D=>o(i({},"__esModule",{value:!0}),D),c={};a(c,{BroadcastChannelMessageBus:()=>xe,MessageBus:()=>T,MessageBus2:()=>ne,MessageBusTask:()=>N,MessageBusTask2:()=>X,WindowMessageBridge:()=>C,WorkerMessageBridge:()=>q,createBroadcastP2PStream:()=>vt,createBufferedByteBufferStream:()=>je,createBufferedStream:()=>Ne,createBufferedStringStream:()=>nt,dropP2PStream:()=>Bt,flowRead:()=>ze,flowWrite:()=>Ti}),t.exports=l(c);var u=class{constructor(D=1.5){this.growthFactor=D,this.capacity=10,this.buffer=new Array(this.capacity),this.head=0,this.tail=0,this.count=0}enqueue(D){if(this.count===this.capacity){let z=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,z);let $=new Array(z);for(let K=0;K<this.count;K++)$[K]=this.buffer[(this.head+K)%this.capacity];this.buffer=$,this.head=0,this.tail=this.count,this.capacity=z}this.buffer[this.tail]=D,this.tail=(this.tail+1)%this.capacity,this.count++}dequeue(){if(this.isEmpty())return;let D=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,D}peek(){return this.buffer[this.head]}isEmpty(){return this.count===0}clear(){this.buffer.length=0,this.head=0,this.tail=0,this.count=0}},h=new ArrayBuffer(8),d=new Float64Array(h),p=new Uint32Array(h),f=new Uint16Array(h),m=ArrayBuffer;try{m=self.HTMLImageElement||m}catch{}var g=typeof SharedArrayBuffer<"u";function b(D){if(typeof D!="object"||D===null||D instanceof Date||D instanceof ArrayBuffer||g&&D instanceof SharedArrayBuffer||D instanceof Blob||D instanceof FormData||D instanceof Function||D instanceof Uint8ClampedArray||D instanceof m)return D;if(Array.isArray(D))return D.map(b);{let z={};for(let $ in D)Object.hasOwnProperty.call(D,$)&&(z[$]=b(D[$]));return z}}function y(D,z){return E(D,z,()=>[])}function E(D,z,$){let K=D[z];return K!==void 0||(K=$(z),D[z]=K),K}var S=class{constructor(D){this.maxResources=D,this.idle=new u,this.isClosed=!1,this.resources=D}acquire(D){this.isClosed?Promise.resolve(!1).then(D):this.resources>0?(this.resources--,Promise.resolve(!0).then(D)):this.idle.enqueue(D)}acquireSync(){return new Promise(D=>{this.acquire(D)})}release(){if(!this.isClosed){let D=this.idle.dequeue();D?Promise.resolve(!0).then(D):this.resources++}}close(){if(!this.isClosed)for(this.isClosed=!0;!this.idle.isEmpty();){let D=this.idle.dequeue();Promise.resolve(!1).then(D)}}};function w(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global}function x(D,z){let $=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===z&&(D.splice(ee,1),ee--,K--,$++);return $}var I=w(),A=I.WeakRef||(D=>D);function O(D){if(D!=null){if(typeof D=="object")return new A(D);console.error(D,D instanceof Object,typeof D);return}}function R(D){return D==null?void 0:D.deref()}var M="_MSG_BUS_RPC_",F=300*1e3,G=(D=>(D.PUBLISH="publish",D.SUBSCRIBE="subscribe",D.PUSH="push",D.PULL="pull",D))(G||{}),V=class{constructor(D){this.bus=D}processRemoteMessage(D,z){let $=O(z),K=D.topic,ee=D.type,pe=D.message;switch(ee){case"pull":this.bus.pull(K,ce=>{this.push(K,ce,R($))});break;case"subscribe":this.bus.subscribe(K,ce=>{this.publish(K,ce,R($))});break;case"publish":this.bus.publish(K,pe,this,R($));break;case"push":this.bus.push(K,pe,this,R($));break;default:console.debug("unknown message type "+ee)}}rpcCall(D,z,$,K=F){let ee=O($),pe=new Promise(ce=>{let Be=this.bus.uniqueRpcTopic(D);this.publish(D,{message:z,reply:Be},R(ee)),this.bus.pull(Be,(st,pt,tt)=>{ce({message:st,bridge:pt,source:O(tt)})})});return K>0?Promise.race([pe,new Promise((ce,Be)=>{setTimeout(Be,K)})]):pe}},q=class extends V{constructor(D,z){super(D),this.worker=z,z.onmessage=$=>{this.processRemoteMessage($.data,void 0)}}publish(D,z){this.postMessage(D,"publish",z)}subscribe(D){this.postMessage(D,"subscribe",null)}push(D,z){this.postMessage(D,"push",z)}pull(D){this.postMessage(D,"pull",null)}rpcCall(D,z,$=F){return super.rpcCall(D,z,void 0,$)}postMessage(D,z,$){let K={topic:D,type:z,message:$};this.worker.postMessage(K)}discard(){this.worker.terminate()}},C=class extends V{constructor(D){super(D),window.addEventListener("message",z=>{this.processRemoteMessage(z.data,z.source)},!1)}publish(D,z,$){this.postMessage(D,"publish",z,$)}subscribe(D,z){if(z===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(D,"subscribe",null,z)}push(D,z,$){this.postMessage(D,"push",z,$)}pull(D,z){if(z===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(D,"pull",null,z)}postMessage(D,z,$,K){let ee={topic:D,type:z,message:$};K&&K.postMessage(ee,"*")}},N=class{constructor(D){this.isRunning=!0,this.callback=D}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}execute(D,z,$,K){try{D=K?D:b(D),this.callback(D,z,$)}catch(ee){console.error(ee)}}},T=class{constructor(D=!1){this.subscribed={},this.pulled={},this.pushed={},this.uuid=crypto.randomUUID().replace(/-/g,""),this.rpcTicket=0,this.unsafe=D}uniqueRpcTopic(D){return`${M}-${D}-${this.uuid}-${this.rpcTicket++}`}publish(D,z,$,K){let ee=this.subscribed[D];if(ee){let pe;for(let ce of ee)ce.running()?ce.execute(z,$,K,this.unsafe):(pe=pe||new Array,pe.push(ce));if(pe)for(let ce of pe)x(ee,ce)}else console.debug("no sub on topic: "+D)}subscribe(D,z){let $=new N(z);return y(this.subscribed,D).push($),$}push(D,z,$,K){let ee=!1,pe=this.pulled[D];if(pe){for(;pe.length>0;){let ce=pe.shift();if(ce.running()){ce.execute(z,$,K,this.unsafe),ee=!0;break}}pe.length===0&&delete this.pulled[D]}ee||y(this.pushed,D).push({message:z,bridge:$,source:O(K)})}pull(D,z){let $=new N(z),K=this.pushed[D];if(K){let ee=K.shift();$.execute(ee.message,ee.bridge,R(ee.source),this.unsafe),K.length===0&&delete this.pushed[D]}else y(this.pulled,D).push($);return $}pullA(D){return new Promise(z=>{this.pull(D,($,K,ee)=>{z({message:$,bridge:K,source:O(ee)})})})}rpcService(D,z){this.subscribe(D,($,K,ee)=>{let{message:pe,reply:ce}=$;try{let Be=z(pe);if(Be instanceof Promise){let st=O(ee);Be.then(pt=>{this.rpcReply(pt,ce,K,R(st))},pt=>{console.error(pt),this.rpcReply(void 0,ce,K,R(st))})}else this.rpcReply(Be,ce,K,ee)}catch(Be){console.error(Be),this.rpcReply(void 0,ce,K,ee)}})}rpcCall(D,z,$=F){let K=new Promise(ee=>{let pe=this.uniqueRpcTopic(D);this.publish(D,{message:z,reply:pe}),this.pull(pe,(ce,Be,st)=>{ee({message:ce,bridge:Be,source:O(st)})})});return $>0?Promise.race([K,new Promise((ee,pe)=>{setTimeout(pe,$)})]):K}rpcReply(D,z,$,K){$?$.push(z,D,K):this.push(z,D)}},L="_MSG_BUS_RPC_";function P(D,z){let $=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===z&&(D.splice(ee,1),ee--,K--,$++);return $}function B(D,z){return U(D,z,()=>[])}function U(D,z,$){let K=D[z];return K!==void 0||(K=$(z),D[z]=K),K}var X=class{constructor(D,z){this.callback=D,this.unsafe=z,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(D){try{D=this.unsafe?D:b(D),this.callback(D)}catch(z){console.error(z)}}},J=class{constructor(D=crypto.randomUUID()){this.uuid=D,this.rpcTicket=0}subscribeOnce(D,z){let $=this.subscribe(D,K=>{$.cancel(),z(K)});return $}pullA(D){return new Promise(z=>{this.pull(D,z)})}rpcService(D,z){let $=K=>{try{let{message:ee,replyTopic:pe}=K;try{let ce=z(ee);ce instanceof Promise?ce.then(Be=>{this.publish(pe,{success:!0,result:Be})}).catch(Be=>{console.error(Be),this.publish(pe,{success:!1,err:String(Be)})}):this.publish(pe,{success:!0,result:ce})}catch(ce){this.publish(pe,{success:!1,err:String(ce)})}}finally{this.pull(D,$)}};this.pull(D,$)}rpcCall(D,z,$=0){let K=new Promise((ee,pe)=>{let ce=`${L}-${D}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(ce,Be=>{Be.success?ee(Be.result):pe(new Error(Be.err))}),this.push(D,{message:z,replyTopic:ce})});return $>0?Promise.race([K,new Promise((ee,pe)=>{setTimeout(pe,$)})]):K}},ne=class extends J{constructor(D=!1){super(),this.unsafe=D,this.subscribed={},this.pulled={},this.pushed={}}publish(D,z){let $=this.subscribed[D];if($){let K;for(let ee of $)ee.running()?ee.execute(z):(K=K||new Array,K.push(ee));if(K)for(let ee of K)P($,ee)}}subscribe(D,z){let $=new X(z,this.unsafe);return B(this.subscribed,D).push($),$}push(D,z){let $=!1,K=this.pulled[D];if(K){for(;K.length>0;){let ee=K.shift();if(ee&&ee.running()){ee.execute(z),$=!0;break}}K.length===0&&delete this.pulled[D]}$||B(this.pushed,D).push(z)}pull(D,z){let $=new X(z,this.unsafe);return this.repull(D,$),$}repull(D,z){let $=this.pushed[D];if($){let K=$.shift();K&&(z.execute(K),$.length===0&&delete this.pushed[D])}else B(this.pulled,D).push(z)}},fe=class extends J{constructor(D=crypto.randomUUID()){super(D),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(D,z){console.debug("BC",this.uuid,"PUBLISH",D,z),this.broadcastPublish(D,z)}subscribe(D,z){console.debug("BC",this.uuid,"SUBSCRIBE",D);let $=new X(z,!0);return B(this.subscribed,D).push($),$}push(D,z){let $=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",D,`(${$})`,z),B(this.pushed,D).push({id:$,message:z}),this.broadcastPushedHeadMessage(D)}pull(D,z){console.debug("BC",this.uuid,"PULL",D);let $=new X(z,!0);return B(this.pulled,D).push($),this.broadcastWhoHas(D),$}broadcastPushedHeadMessage(D){let z=this.pushed[D];z&&z[0]&&this.broadcastIHave(D,z[0].id)}onReceivedPublish(D,z,$){console.debug("BCMSG(",this.uuid,")","from",D,"PUBLISH",z,"message",$);let K=this.subscribed[z];if(K){let ee;for(let pe of K)pe.running()?pe.execute($):(ee=ee||new Array,ee.push(pe));if(ee)for(let pe of ee)P(K,pe);K.length===0&&delete this.subscribed[z]}}onReceivedWhoHas(D,z){console.debug("BCMSG(",this.uuid,")","from",D,"WHOHAS",z),this.broadcastPushedHeadMessage(z)}onReceivedIHave(D,z,$){console.debug("BCMSG(",this.uuid,")","from",D,"IHAVE",z,"id",$);let K=this.pulled[z];if(K){let ee;for(let pe of K)if(pe.running()){this.broadcastINeed(z,D,$);break}else ee=ee||new Array,ee.push(pe);if(ee)for(let pe of ee)P(K,pe);K.length===0&&delete this.pulled[z]}}onReceivedINeed(D,z,$,K){if(console.debug("BCMSG(",this.uuid,")","from",D,"INEED",z,"source",$,"id",K),this.uuid===$){let ee=this.pushed[z];if(ee&&ee[0]&&ee[0].id===K){let{message:pe}=ee.shift();this.broadcastIGive(z,K,D,pe),this.broadcastPushedHeadMessage(z),ee.length===0&&delete this.pushed[z]}}}onReceivedIGive(D,z,$,K,ee){console.debug("BCMSG(",this.uuid,")","from",D,"IGIVE",z,"id",$,"target",K,"message",ee);let pe=this.pulled[z];if(pe&&this.uuid===K){let ce=!1;for(;pe.length>0;){let Be=pe.shift();if(Be.running()){Be.execute(ee),ce=!0;break}}ce||this.push(z,ee),pe.length===0&&delete this.pulled[z]}}},xe=class extends fe{constructor(D,z=crypto.randomUUID()){super(z),this.bc=new BroadcastChannel(D),this.bc.onmessage=$=>{this.onMessage($.data)}}onMessage(D){let{type:z,uuid:$,topic:K}=D;switch(z){case"PUBLISH":{let{message:ee}=D;this.onReceivedPublish($,K,ee);break}case"WHOHAS":{this.onReceivedWhoHas($,K);break}case"IHAVE":{let{id:ee}=D;this.onReceivedIHave($,K,ee);break}case"INEED":{let{source:ee,id:pe}=D;this.onReceivedINeed($,K,ee,pe);break}case"IGIVE":{let{target:ee,id:pe,message:ce}=D;this.onReceivedIGive($,K,pe,ee,ce);break}default:console.warn("unsupported",D)}}broadcastPublish(D,z){this.post({type:"PUBLISH",uuid:this.uuid,topic:D,message:z})}broadcastWhoHas(D){this.post({type:"WHOHAS",uuid:this.uuid,topic:D})}broadcastIHave(D,z){this.post({type:"IHAVE",uuid:this.uuid,topic:D,id:z})}broadcastINeed(D,z,$){this.post({type:"INEED",uuid:this.uuid,topic:D,source:z,id:$})}broadcastIGive(D,z,$,K){this.post({type:"IGIVE",uuid:this.uuid,topic:D,id:z,target:$,message:K})}post(D){this.bc.postMessage(D),Promise.resolve().then(()=>{this.onMessage(D)})}},ve=Symbol("BLOCKING_QUEUE_RESET"),Fe=class{constructor(D,z=()=>1){if(this.maxSize=D,this.itemSizeOf=z,this.queue=new u,this.waitingConsumers=new u,this.waitingProducers=new u,this.queueSize=0,this.closePromise=null,this.closeResolve=null,D<=0)throw new Error("Max size must be greater than 0")}enqueue(D){return this.closePromise?!1:this.isFull()?(async()=>{console.debug("queue is full",this.queueSize,this.maxSize);let z=await new Promise($=>{this.waitingProducers.enqueue($)});return console.debug("queue is not full",this.size(),z),z?(this.innerEnqueue(D),!0):!1})():(this.innerEnqueue(D),!0)}innerEnqueue(D){if(this.waitingConsumers.isEmpty())this.queue.enqueue(D),this.queueSize+=this.itemSizeOf(D),console.debug("queue pushed",D,"size",this.queueSize);else{let z=this.waitingConsumers.dequeue();Promise.resolve(D).then(z),console.debug("queue direct",D,"size",this.queueSize)}}dequeue(){if(this.queue.isEmpty())if(this.closePromise){for(;!this.waitingConsumers.isEmpty();){let D=this.waitingConsumers.dequeue();Promise.resolve(ve).then(D)}return setTimeout(()=>this.closeResolve(),0),ve}else return new Promise(D=>{this.waitingConsumers.enqueue(D)});else{let D=this.queue.dequeue();if(this.queueSize-=this.itemSizeOf(D),!this.waitingProducers.isEmpty()){let z=this.waitingProducers.dequeue();Promise.resolve(!0).then(z)}return D}}size(){return this.queueSize}isEmpty(){return this.queueSize===0}isFull(){return this.queueSize>=this.maxSize}close(){return this.closePromise||(this.closePromise=new Promise(D=>{for(this.closeResolve=D;!this.waitingProducers.isEmpty();){let z=this.waitingProducers.dequeue();Promise.resolve(!1).then(z)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let z=this.waitingConsumers.dequeue();Promise.resolve(ve).then(z)}D()}})),this.closePromise}};function Ne(D,z,$=Number.MAX_SAFE_INTEGER){let K=new Fe($,z),ee=new ReadableStream({pull(ce){let Be=!0,st=(async()=>{let pt=new Array;do{let tt=K.dequeue();if(tt instanceof Promise){Be=!1;let li=await tt;li===ve?ce.close():pt.push(li)}else{let li=tt;li===ve?ce.close():pt.push(li)}}while(K.size()>0);if(pt.length>0){let tt=D(pt);ce.enqueue(tt)}})();if(!Be)return console.debug("read stream stucked --------------------------------------"),st},async cancel(){console.debug("buffered readable cancel"),await K.close()}}),pe=new WritableStream({write(ce,Be){let st=!0,pt=(async()=>{let tt=K.enqueue(ce);typeof tt=="boolean"?tt||Be.error(new Error("Write stream closed")):(st=!1,await tt||Be.error(new Error("Write stream closed")))})();if(!st)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),pt},async close(){console.debug("buffered writable closing",K.size()),await K.close(),console.debug("buffered writable closed",K.size())},async abort(){console.debug("buffered writable aborting",K.size()),await K.close(),console.debug("buffered writable aborted",K.size())}});return{readable:ee,writable:pe}}function nt(D=Number.MAX_SAFE_INTEGER){return Ne(z=>z.join(""),z=>z.length,D)}function je(D=Number.MAX_SAFE_INTEGER){return Ne(z=>{let $=new Uint8Array(z.reduce((ee,pe)=>ee+pe.byteLength,0)),K=0;return z.forEach(ee=>{$.set(ee,K),K+=ee.byteLength}),$},z=>z.byteLength,D)}function vt(D){return new Promise((z,$)=>{let K=new BroadcastChannel(D),ee=new Fe(1),pe=new S(1),ce=null,Be=!1,st=!1,pt=!1;K.onmessage=tt=>{let li=tt.data,{type:Ji}=li;if(console.debug("p2p",D,"type",Ji,"data",Ji==="DATA"&&li.data),Ji==="DATA")ee.enqueue(li.data);else if(Ji==="HI"){if(!ce){K.postMessage({type:"HI"});let Mr=0;ce={rs:new ReadableStream({async pull(Or){let Cn=await ee.dequeue();Cn===ve?(await Bi(),Or.close()):(Or.enqueue(Cn),K.postMessage({type:"ACK"}))},cancel(){return Bi()}}),ws:new WritableStream({async write(Or,Cn){await pe.acquireSync()?K.postMessage({type:"DATA",id:Mr++,data:Or}):(cr(),Cn.error(new Error("Write stream closed")))},close(){cr()},abort(){cr()}})},z(ce)}}else Ji==="REND"?ce?pe.close():An("REND1"):Ji==="WEND"?ce?ee.close():An("WEND1"):Ji==="ACK"&&pe.release();function cr(){Be||(Be=!0,console.debug(D,"p2p write stream closed"),pe.close(),K.postMessage({type:"WEND"}),st&&(console.debug(D,"p2p channel closed on ws"),K.close()))}async function Bi(){st||(st=!0,console.debug(D,"p2p read stream closed"),K.postMessage({type:"REND"}),await ee.close(),Be&&(console.debug(D,"p2p channel closed on rs"),K.close()))}async function An(Mr){pt||(pt=!0,console.debug(D,"p2p channel connection released on",Mr),pe.close(),ee.close(),ce?(ce.rs.locked||(console.debug(D,"p2p unlocked read stream direct cancel"),ce.rs.cancel()),ce.ws.locked||(console.debug(D,"p2p unlocked write stream direct close"),ce.ws.close())):(K.postMessage({type:"HI"}),K.close()),$(new Error("p2p channel connection released")))}},K.postMessage({type:"HI"})})}function Bt(D){return new Promise(z=>{let $=new BroadcastChannel(D);$.onmessage=K=>{let ee=K.data,{type:pe}=ee;pe==="HI"&&($.postMessage({type:"REND"}),$.close(),z())},$.postMessage({type:"REND"})})}async function Oi(D){try{return await vt(D)}catch(z){z.message!=="p2p channel connection released"&&console.error(z)}}async function Ti(D,z,$=10*1024*1024,K=!0){let ee=await Oi(D);if(!ee)return!1;let pe=!1;try{let ce,Be=st=>{if(!ce)if(!K)ce=ee.ws.getWriter();else if(typeof st=="string"){let pt=nt($);pt.readable.pipeTo(ee.ws),ce=pt.writable.getWriter()}else{let pt=je($);pt.readable.pipeTo(ee.ws),ce=pt.writable.getWriter()}return ce.write(st)};if(Array.isArray(z))for(let st of z)await Be(st);else await z({write:Be,get desiredSize(){return((ce==null?void 0:ce.desiredSize)||0)+10}});ce&&await ce.close(),pe=!0}catch(ce){console.error(ce)}finally{return ee.rs.cancel(),pe}}async function ze(D,z){var $,K;let ee=await Oi(D);if(ee)try{let pe=ee.rs.getReader();for(($=z.start)==null?void 0:$.call(z);;){let{value:ce,done:Be}=await pe.read();if(ce!==void 0){let st;if(z.update instanceof Promise?st=await z.update(ce):st=z.update(ce),st){await pe.cancel();break}}if(Be){(K=z.end)==null||K.call(z);break}}}catch(pe){console.error(pe)}finally{ee.ws.close()}}}),yr=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r():typeof define=="function"&&define.amd?define([],r):i.CryptoJS=r()})(e,function(){var i=i||(function(r,n){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof global<"u"&&global.crypto&&(s=global.crypto),!s&&typeof XP=="function")try{s=XP("crypto")}catch{}var a=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||(function(){function E(){}return function(S){var w;return E.prototype=S,w=new E,E.prototype=null,w}})(),l={},c=l.lib={},u=c.Base=(function(){return{extend:function(E){var S=o(this);return E&&S.mixIn(E),(!S.hasOwnProperty("init")||this.init===S.init)&&(S.init=function(){S.$super.init.apply(this,arguments)}),S.init.prototype=S,S.$super=this,S},create:function(){var E=this.extend();return E.init.apply(E,arguments),E},init:function(){},mixIn:function(E){for(var S in E)E.hasOwnProperty(S)&&(this[S]=E[S]);E.hasOwnProperty("toString")&&(this.toString=E.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),h=c.WordArray=u.extend({init:function(E,S){E=this.words=E||[],S!=n?this.sigBytes=S:this.sigBytes=E.length*4},toString:function(E){return(E||p).stringify(this)},concat:function(E){var S=this.words,w=E.words,x=this.sigBytes,I=E.sigBytes;if(this.clamp(),x%4)for(var A=0;A<I;A++){var O=w[A>>>2]>>>24-A%4*8&255;S[x+A>>>2]|=O<<24-(x+A)%4*8}else for(var R=0;R<I;R+=4)S[x+R>>>2]=w[R>>>2];return this.sigBytes+=I,this},clamp:function(){var E=this.words,S=this.sigBytes;E[S>>>2]&=4294967295<<32-S%4*8,E.length=r.ceil(S/4)},clone:function(){var E=u.clone.call(this);return E.words=this.words.slice(0),E},random:function(E){for(var S=[],w=0;w<E;w+=4)S.push(a());return new h.init(S,E)}}),d=l.enc={},p=d.Hex={stringify:function(E){for(var S=E.words,w=E.sigBytes,x=[],I=0;I<w;I++){var A=S[I>>>2]>>>24-I%4*8&255;x.push((A>>>4).toString(16)),x.push((A&15).toString(16))}return x.join("")},parse:function(E){for(var S=E.length,w=[],x=0;x<S;x+=2)w[x>>>3]|=parseInt(E.substr(x,2),16)<<24-x%8*4;return new h.init(w,S/2)}},f=d.Latin1={stringify:function(E){for(var S=E.words,w=E.sigBytes,x=[],I=0;I<w;I++){var A=S[I>>>2]>>>24-I%4*8&255;x.push(String.fromCharCode(A))}return x.join("")},parse:function(E){for(var S=E.length,w=[],x=0;x<S;x++)w[x>>>2]|=(E.charCodeAt(x)&255)<<24-x%4*8;return new h.init(w,S)}},m=d.Utf8={stringify:function(E){try{return decodeURIComponent(escape(f.stringify(E)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(E){return f.parse(unescape(encodeURIComponent(E)))}},g=c.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(E){typeof E=="string"&&(E=m.parse(E)),this._data.concat(E),this._nDataBytes+=E.sigBytes},_process:function(E){var S,w=this._data,x=w.words,I=w.sigBytes,A=this.blockSize,O=A*4,R=I/O;E?R=r.ceil(R):R=r.max((R|0)-this._minBufferSize,0);var M=R*A,F=r.min(M*4,I);if(M){for(var G=0;G<M;G+=A)this._doProcessBlock(x,G);S=x.splice(0,M),w.sigBytes-=F}return new h.init(S,F)},clone:function(){var E=u.clone.call(this);return E._data=this._data.clone(),E},_minBufferSize:0}),b=c.Hasher=g.extend({cfg:u.extend(),init:function(E){this.cfg=this.cfg.extend(E),this.reset()},reset:function(){g.reset.call(this),this._doReset()},update:function(E){return this._append(E),this._process(),this},finalize:function(E){E&&this._append(E);var S=this._doFinalize();return S},blockSize:512/32,_createHelper:function(E){return function(S,w){return new E.init(w).finalize(S)}},_createHmacHelper:function(E){return function(S,w){return new y.HMAC.init(E,w).finalize(S)}}}),y=l.algo={};return l})(Math);return i})}),iE=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.Base,o=s.WordArray,l=n.x64={},c=l.Word=a.extend({init:function(h,d){this.high=h,this.low=d}}),u=l.WordArray=a.extend({init:function(h,d){h=this.words=h||[],d!=r?this.sigBytes=d:this.sigBytes=h.length*8},toX32:function(){for(var h=this.words,d=h.length,p=[],f=0;f<d;f++){var m=h[f];p.push(m.high),p.push(m.low)}return o.create(p,this.sigBytes)},clone:function(){for(var h=a.clone.call(this),d=h.words=this.words.slice(0),p=d.length,f=0;f<p;f++)d[f]=d[f].clone();return h}})})(),i})}),fF=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){if(typeof ArrayBuffer=="function"){var r=i,n=r.lib,s=n.WordArray,a=s.init,o=s.init=function(l){if(l instanceof ArrayBuffer&&(l=new Uint8Array(l)),(l instanceof Int8Array||typeof Uint8ClampedArray<"u"&&l instanceof Uint8ClampedArray||l instanceof Int16Array||l instanceof Uint16Array||l instanceof Int32Array||l instanceof Uint32Array||l instanceof Float32Array||l instanceof Float64Array)&&(l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength)),l instanceof Uint8Array){for(var c=l.byteLength,u=[],h=0;h<c;h++)u[h>>>2]|=l[h]<<24-h%4*8;a.call(this,u,c)}else a.apply(this,arguments)};o.prototype=s}})(),i.lib.WordArray})}),mF=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=r.enc,o=a.Utf16=a.Utf16BE={stringify:function(c){for(var u=c.words,h=c.sigBytes,d=[],p=0;p<h;p+=2){var f=u[p>>>2]>>>16-p%4*8&65535;d.push(String.fromCharCode(f))}return d.join("")},parse:function(c){for(var u=c.length,h=[],d=0;d<u;d++)h[d>>>1]|=c.charCodeAt(d)<<16-d%2*16;return s.create(h,u*2)}};a.Utf16LE={stringify:function(c){for(var u=c.words,h=c.sigBytes,d=[],p=0;p<h;p+=2){var f=l(u[p>>>2]>>>16-p%4*8&65535);d.push(String.fromCharCode(f))}return d.join("")},parse:function(c){for(var u=c.length,h=[],d=0;d<u;d++)h[d>>>1]|=l(c.charCodeAt(d)<<16-d%2*16);return s.create(h,u*2)}};function l(c){return c<<8&4278255360|c>>>8&16711935}})(),i.enc.Utf16})}),_p=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=r.enc,o=a.Base64={stringify:function(c){var u=c.words,h=c.sigBytes,d=this._map;c.clamp();for(var p=[],f=0;f<h;f+=3)for(var m=u[f>>>2]>>>24-f%4*8&255,g=u[f+1>>>2]>>>24-(f+1)%4*8&255,b=u[f+2>>>2]>>>24-(f+2)%4*8&255,y=m<<16|g<<8|b,E=0;E<4&&f+E*.75<h;E++)p.push(d.charAt(y>>>6*(3-E)&63));var S=d.charAt(64);if(S)for(;p.length%4;)p.push(S);return p.join("")},parse:function(c){var u=c.length,h=this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var p=0;p<h.length;p++)d[h.charCodeAt(p)]=p}var f=h.charAt(64);if(f){var m=c.indexOf(f);m!==-1&&(u=m)}return l(c,u,d)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function l(c,u,h){for(var d=[],p=0,f=0;f<u;f++)if(f%4){var m=h[c.charCodeAt(f-1)]<<f%4*2,g=h[c.charCodeAt(f)]>>>6-f%4*2,b=m|g;d[p>>>2]|=b<<24-p%4*8,p++}return s.create(d,p)}})(),i.enc.Base64})}),gF=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=r.enc,o=a.Base64url={stringify:function(c,u){u===void 0&&(u=!0);var h=c.words,d=c.sigBytes,p=u?this._safe_map:this._map;c.clamp();for(var f=[],m=0;m<d;m+=3)for(var g=h[m>>>2]>>>24-m%4*8&255,b=h[m+1>>>2]>>>24-(m+1)%4*8&255,y=h[m+2>>>2]>>>24-(m+2)%4*8&255,E=g<<16|b<<8|y,S=0;S<4&&m+S*.75<d;S++)f.push(p.charAt(E>>>6*(3-S)&63));var w=p.charAt(64);if(w)for(;f.length%4;)f.push(w);return f.join("")},parse:function(c,u){u===void 0&&(u=!0);var h=c.length,d=u?this._safe_map:this._map,p=this._reverseMap;if(!p){p=this._reverseMap=[];for(var f=0;f<d.length;f++)p[d.charCodeAt(f)]=f}var m=d.charAt(64);if(m){var g=c.indexOf(m);g!==-1&&(h=g)}return l(c,h,p)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function l(c,u,h){for(var d=[],p=0,f=0;f<u;f++)if(f%4){var m=h[c.charCodeAt(f-1)]<<f%4*2,g=h[c.charCodeAt(f)]>>>6-f%4*2,b=m|g;d[p>>>2]|=b<<24-p%4*8,p++}return s.create(d,p)}})(),i.enc.Base64url})}),Pp=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.WordArray,o=s.Hasher,l=n.algo,c=[];(function(){for(var m=0;m<64;m++)c[m]=r.abs(r.sin(m+1))*4294967296|0})();var u=l.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(m,g){for(var b=0;b<16;b++){var y=g+b,E=m[y];m[y]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360}var S=this._hash.words,w=m[g+0],x=m[g+1],I=m[g+2],A=m[g+3],O=m[g+4],R=m[g+5],M=m[g+6],F=m[g+7],G=m[g+8],V=m[g+9],q=m[g+10],C=m[g+11],N=m[g+12],T=m[g+13],L=m[g+14],P=m[g+15],B=S[0],U=S[1],X=S[2],J=S[3];B=h(B,U,X,J,w,7,c[0]),J=h(J,B,U,X,x,12,c[1]),X=h(X,J,B,U,I,17,c[2]),U=h(U,X,J,B,A,22,c[3]),B=h(B,U,X,J,O,7,c[4]),J=h(J,B,U,X,R,12,c[5]),X=h(X,J,B,U,M,17,c[6]),U=h(U,X,J,B,F,22,c[7]),B=h(B,U,X,J,G,7,c[8]),J=h(J,B,U,X,V,12,c[9]),X=h(X,J,B,U,q,17,c[10]),U=h(U,X,J,B,C,22,c[11]),B=h(B,U,X,J,N,7,c[12]),J=h(J,B,U,X,T,12,c[13]),X=h(X,J,B,U,L,17,c[14]),U=h(U,X,J,B,P,22,c[15]),B=d(B,U,X,J,x,5,c[16]),J=d(J,B,U,X,M,9,c[17]),X=d(X,J,B,U,C,14,c[18]),U=d(U,X,J,B,w,20,c[19]),B=d(B,U,X,J,R,5,c[20]),J=d(J,B,U,X,q,9,c[21]),X=d(X,J,B,U,P,14,c[22]),U=d(U,X,J,B,O,20,c[23]),B=d(B,U,X,J,V,5,c[24]),J=d(J,B,U,X,L,9,c[25]),X=d(X,J,B,U,A,14,c[26]),U=d(U,X,J,B,G,20,c[27]),B=d(B,U,X,J,T,5,c[28]),J=d(J,B,U,X,I,9,c[29]),X=d(X,J,B,U,F,14,c[30]),U=d(U,X,J,B,N,20,c[31]),B=p(B,U,X,J,R,4,c[32]),J=p(J,B,U,X,G,11,c[33]),X=p(X,J,B,U,C,16,c[34]),U=p(U,X,J,B,L,23,c[35]),B=p(B,U,X,J,x,4,c[36]),J=p(J,B,U,X,O,11,c[37]),X=p(X,J,B,U,F,16,c[38]),U=p(U,X,J,B,q,23,c[39]),B=p(B,U,X,J,T,4,c[40]),J=p(J,B,U,X,w,11,c[41]),X=p(X,J,B,U,A,16,c[42]),U=p(U,X,J,B,M,23,c[43]),B=p(B,U,X,J,V,4,c[44]),J=p(J,B,U,X,N,11,c[45]),X=p(X,J,B,U,P,16,c[46]),U=p(U,X,J,B,I,23,c[47]),B=f(B,U,X,J,w,6,c[48]),J=f(J,B,U,X,F,10,c[49]),X=f(X,J,B,U,L,15,c[50]),U=f(U,X,J,B,R,21,c[51]),B=f(B,U,X,J,N,6,c[52]),J=f(J,B,U,X,A,10,c[53]),X=f(X,J,B,U,q,15,c[54]),U=f(U,X,J,B,x,21,c[55]),B=f(B,U,X,J,G,6,c[56]),J=f(J,B,U,X,P,10,c[57]),X=f(X,J,B,U,M,15,c[58]),U=f(U,X,J,B,T,21,c[59]),B=f(B,U,X,J,O,6,c[60]),J=f(J,B,U,X,C,10,c[61]),X=f(X,J,B,U,I,15,c[62]),U=f(U,X,J,B,V,21,c[63]),S[0]=S[0]+B|0,S[1]=S[1]+U|0,S[2]=S[2]+X|0,S[3]=S[3]+J|0},_doFinalize:function(){var m=this._data,g=m.words,b=this._nDataBytes*8,y=m.sigBytes*8;g[y>>>5]|=128<<24-y%32;var E=r.floor(b/4294967296),S=b;g[(y+64>>>9<<4)+15]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,g[(y+64>>>9<<4)+14]=(S<<8|S>>>24)&16711935|(S<<24|S>>>8)&4278255360,m.sigBytes=(g.length+1)*4,this._process();for(var w=this._hash,x=w.words,I=0;I<4;I++){var A=x[I];x[I]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360}return w},clone:function(){var m=o.clone.call(this);return m._hash=this._hash.clone(),m}});function h(m,g,b,y,E,S,w){var x=m+(g&b|~g&y)+E+w;return(x<<S|x>>>32-S)+g}function d(m,g,b,y,E,S,w){var x=m+(g&y|b&~y)+E+w;return(x<<S|x>>>32-S)+g}function p(m,g,b,y,E,S,w){var x=m+(g^b^y)+E+w;return(x<<S|x>>>32-S)+g}function f(m,g,b,y,E,S,w){var x=m+(b^(g|~y))+E+w;return(x<<S|x>>>32-S)+g}n.MD5=o._createHelper(u),n.HmacMD5=o._createHmacHelper(u)})(Math),i.MD5})}),nO=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=n.Hasher,o=r.algo,l=[],c=o.SHA1=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(u,h){for(var d=this._hash.words,p=d[0],f=d[1],m=d[2],g=d[3],b=d[4],y=0;y<80;y++){if(y<16)l[y]=u[h+y]|0;else{var E=l[y-3]^l[y-8]^l[y-14]^l[y-16];l[y]=E<<1|E>>>31}var S=(p<<5|p>>>27)+b+l[y];y<20?S+=(f&m|~f&g)+1518500249:y<40?S+=(f^m^g)+1859775393:y<60?S+=(f&m|f&g|m&g)-1894007588:S+=(f^m^g)-899497514,b=g,g=m,m=f<<30|f>>>2,f=p,p=S}d[0]=d[0]+p|0,d[1]=d[1]+f|0,d[2]=d[2]+m|0,d[3]=d[3]+g|0,d[4]=d[4]+b|0},_doFinalize:function(){var u=this._data,h=u.words,d=this._nDataBytes*8,p=u.sigBytes*8;return h[p>>>5]|=128<<24-p%32,h[(p+64>>>9<<4)+14]=Math.floor(d/4294967296),h[(p+64>>>9<<4)+15]=d,u.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var u=a.clone.call(this);return u._hash=this._hash.clone(),u}});r.SHA1=a._createHelper(c),r.HmacSHA1=a._createHmacHelper(c)})(),i.SHA1})}),rI=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.WordArray,o=s.Hasher,l=n.algo,c=[],u=[];(function(){function p(b){for(var y=r.sqrt(b),E=2;E<=y;E++)if(!(b%E))return!1;return!0}function f(b){return(b-(b|0))*4294967296|0}for(var m=2,g=0;g<64;)p(m)&&(g<8&&(c[g]=f(r.pow(m,1/2))),u[g]=f(r.pow(m,1/3)),g++),m++})();var h=[],d=l.SHA256=o.extend({_doReset:function(){this._hash=new a.init(c.slice(0))},_doProcessBlock:function(p,f){for(var m=this._hash.words,g=m[0],b=m[1],y=m[2],E=m[3],S=m[4],w=m[5],x=m[6],I=m[7],A=0;A<64;A++){if(A<16)h[A]=p[f+A]|0;else{var O=h[A-15],R=(O<<25|O>>>7)^(O<<14|O>>>18)^O>>>3,M=h[A-2],F=(M<<15|M>>>17)^(M<<13|M>>>19)^M>>>10;h[A]=R+h[A-7]+F+h[A-16]}var G=S&w^~S&x,V=g&b^g&y^b&y,q=(g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22),C=(S<<26|S>>>6)^(S<<21|S>>>11)^(S<<7|S>>>25),N=I+C+G+u[A]+h[A],T=q+V;I=x,x=w,w=S,S=E+N|0,E=y,y=b,b=g,g=N+T|0}m[0]=m[0]+g|0,m[1]=m[1]+b|0,m[2]=m[2]+y|0,m[3]=m[3]+E|0,m[4]=m[4]+S|0,m[5]=m[5]+w|0,m[6]=m[6]+x|0,m[7]=m[7]+I|0},_doFinalize:function(){var p=this._data,f=p.words,m=this._nDataBytes*8,g=p.sigBytes*8;return f[g>>>5]|=128<<24-g%32,f[(g+64>>>9<<4)+14]=r.floor(m/4294967296),f[(g+64>>>9<<4)+15]=m,p.sigBytes=f.length*4,this._process(),this._hash},clone:function(){var p=o.clone.call(this);return p._hash=this._hash.clone(),p}});n.SHA256=o._createHelper(d),n.HmacSHA256=o._createHmacHelper(d)})(Math),i.SHA256})}),yF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),rI()):typeof define=="function"&&define.amd?define(["./core","./sha256"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=r.algo,o=a.SHA256,l=a.SHA224=o.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var c=o._doFinalize.call(this);return c.sigBytes-=4,c}});r.SHA224=o._createHelper(l),r.HmacSHA224=o._createHmacHelper(l)})(),i.SHA224})}),sO=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),iE()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.Hasher,a=r.x64,o=a.Word,l=a.WordArray,c=r.algo;function u(){return o.create.apply(o,arguments)}var h=[u(1116352408,3609767458),u(1899447441,602891725),u(3049323471,3964484399),u(3921009573,2173295548),u(961987163,4081628472),u(1508970993,3053834265),u(2453635748,2937671579),u(2870763221,3664609560),u(3624381080,2734883394),u(310598401,1164996542),u(607225278,1323610764),u(1426881987,3590304994),u(1925078388,4068182383),u(2162078206,991336113),u(2614888103,633803317),u(3248222580,3479774868),u(3835390401,2666613458),u(4022224774,944711139),u(264347078,2341262773),u(604807628,2007800933),u(770255983,1495990901),u(1249150122,1856431235),u(1555081692,3175218132),u(1996064986,2198950837),u(2554220882,3999719339),u(2821834349,766784016),u(2952996808,2566594879),u(3210313671,3203337956),u(3336571891,1034457026),u(3584528711,2466948901),u(113926993,3758326383),u(338241895,168717936),u(666307205,1188179964),u(773529912,1546045734),u(1294757372,1522805485),u(1396182291,2643833823),u(1695183700,2343527390),u(1986661051,1014477480),u(2177026350,1206759142),u(2456956037,344077627),u(2730485921,1290863460),u(2820302411,3158454273),u(3259730800,3505952657),u(3345764771,106217008),u(3516065817,3606008344),u(3600352804,1432725776),u(4094571909,1467031594),u(275423344,851169720),u(430227734,3100823752),u(506948616,1363258195),u(659060556,3750685593),u(883997877,3785050280),u(958139571,3318307427),u(1322822218,3812723403),u(1537002063,2003034995),u(1747873779,3602036899),u(1955562222,1575990012),u(2024104815,1125592928),u(2227730452,2716904306),u(2361852424,442776044),u(2428436474,593698344),u(2756734187,3733110249),u(3204031479,2999351573),u(3329325298,3815920427),u(3391569614,3928383900),u(3515267271,566280711),u(3940187606,3454069534),u(4118630271,4000239992),u(116418474,1914138554),u(174292421,2731055270),u(289380356,3203993006),u(460393269,320620315),u(685471733,587496836),u(852142971,1086792851),u(1017036298,365543100),u(1126000580,2618297676),u(1288033470,3409855158),u(1501505948,4234509866),u(1607167915,987167468),u(1816402316,1246189591)],d=[];(function(){for(var f=0;f<80;f++)d[f]=u()})();var p=c.SHA512=s.extend({_doReset:function(){this._hash=new l.init([new o.init(1779033703,4089235720),new o.init(3144134277,2227873595),new o.init(1013904242,4271175723),new o.init(2773480762,1595750129),new o.init(1359893119,2917565137),new o.init(2600822924,725511199),new o.init(528734635,4215389547),new o.init(1541459225,327033209)])},_doProcessBlock:function(f,m){for(var g=this._hash.words,b=g[0],y=g[1],E=g[2],S=g[3],w=g[4],x=g[5],I=g[6],A=g[7],O=b.high,R=b.low,M=y.high,F=y.low,G=E.high,V=E.low,q=S.high,C=S.low,N=w.high,T=w.low,L=x.high,P=x.low,B=I.high,U=I.low,X=A.high,J=A.low,ne=O,fe=R,xe=M,ve=F,Fe=G,Ne=V,nt=q,je=C,vt=N,Bt=T,Oi=L,Ti=P,ze=B,D=U,z=X,$=J,K=0;K<80;K++){var ee,pe,ce=d[K];if(K<16)pe=ce.high=f[m+K*2]|0,ee=ce.low=f[m+K*2+1]|0;else{var Be=d[K-15],st=Be.high,pt=Be.low,tt=(st>>>1|pt<<31)^(st>>>8|pt<<24)^st>>>7,li=(pt>>>1|st<<31)^(pt>>>8|st<<24)^(pt>>>7|st<<25),Ji=d[K-2],cr=Ji.high,Bi=Ji.low,An=(cr>>>19|Bi<<13)^(cr<<3|Bi>>>29)^cr>>>6,Mr=(Bi>>>19|cr<<13)^(Bi<<3|cr>>>29)^(Bi>>>6|cr<<26),Or=d[K-7],Cn=Or.high,ua=Or.low,Zt=d[K-16],Er=Zt.high,mt=Zt.low;ee=li+ua,pe=tt+Cn+(ee>>>0<li>>>0?1:0),ee=ee+Mr,pe=pe+An+(ee>>>0<Mr>>>0?1:0),ee=ee+mt,pe=pe+Er+(ee>>>0<mt>>>0?1:0),ce.high=pe,ce.low=ee}var dn=vt&Oi^~vt&ze,rs=Bt&Ti^~Bt&D,di=ne&xe^ne&Fe^xe&Fe,Ii=fe&ve^fe&Ne^ve&Ne,vn=(ne>>>28|fe<<4)^(ne<<30|fe>>>2)^(ne<<25|fe>>>7),ha=(fe>>>28|ne<<4)^(fe<<30|ne>>>2)^(fe<<25|ne>>>7),Yu=(vt>>>14|Bt<<18)^(vt>>>18|Bt<<14)^(vt<<23|Bt>>>9),Ef=(Bt>>>14|vt<<18)^(Bt>>>18|vt<<14)^(Bt<<23|vt>>>9),Gh=h[K],zc=Gh.high,El=Gh.low,Br=$+Ef,ns=z+Yu+(Br>>>0<$>>>0?1:0),Br=Br+rs,ns=ns+dn+(Br>>>0<rs>>>0?1:0),Br=Br+El,ns=ns+zc+(Br>>>0<El>>>0?1:0),Br=Br+ee,ns=ns+pe+(Br>>>0<ee>>>0?1:0),ep=ha+Ii,Qg=vn+di+(ep>>>0<ha>>>0?1:0);z=ze,$=D,ze=Oi,D=Ti,Oi=vt,Ti=Bt,Bt=je+Br|0,vt=nt+ns+(Bt>>>0<je>>>0?1:0)|0,nt=Fe,je=Ne,Fe=xe,Ne=ve,xe=ne,ve=fe,fe=Br+ep|0,ne=ns+Qg+(fe>>>0<Br>>>0?1:0)|0}R=b.low=R+fe,b.high=O+ne+(R>>>0<fe>>>0?1:0),F=y.low=F+ve,y.high=M+xe+(F>>>0<ve>>>0?1:0),V=E.low=V+Ne,E.high=G+Fe+(V>>>0<Ne>>>0?1:0),C=S.low=C+je,S.high=q+nt+(C>>>0<je>>>0?1:0),T=w.low=T+Bt,w.high=N+vt+(T>>>0<Bt>>>0?1:0),P=x.low=P+Ti,x.high=L+Oi+(P>>>0<Ti>>>0?1:0),U=I.low=U+D,I.high=B+ze+(U>>>0<D>>>0?1:0),J=A.low=J+$,A.high=X+z+(J>>>0<$>>>0?1:0)},_doFinalize:function(){var f=this._data,m=f.words,g=this._nDataBytes*8,b=f.sigBytes*8;m[b>>>5]|=128<<24-b%32,m[(b+128>>>10<<5)+30]=Math.floor(g/4294967296),m[(b+128>>>10<<5)+31]=g,f.sigBytes=m.length*4,this._process();var y=this._hash.toX32();return y},clone:function(){var f=s.clone.call(this);return f._hash=this._hash.clone(),f},blockSize:1024/32});r.SHA512=s._createHelper(p),r.HmacSHA512=s._createHmacHelper(p)})(),i.SHA512})}),bF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),iE(),sO()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./sha512"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.x64,s=n.Word,a=n.WordArray,o=r.algo,l=o.SHA512,c=o.SHA384=l.extend({_doReset:function(){this._hash=new a.init([new s.init(3418070365,3238371032),new s.init(1654270250,914150663),new s.init(2438529370,812702999),new s.init(355462360,4144912697),new s.init(1731405415,4290775857),new s.init(2394180231,1750603025),new s.init(3675008525,1694076839),new s.init(1203062813,3204075428)])},_doFinalize:function(){var u=l._doFinalize.call(this);return u.sigBytes-=16,u}});r.SHA384=l._createHelper(c),r.HmacSHA384=l._createHmacHelper(c)})(),i.SHA384})}),xF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),iE()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.WordArray,o=s.Hasher,l=n.x64,c=l.Word,u=n.algo,h=[],d=[],p=[];(function(){for(var g=1,b=0,y=0;y<24;y++){h[g+5*b]=(y+1)*(y+2)/2%64;var E=b%5,S=(2*g+3*b)%5;g=E,b=S}for(var g=0;g<5;g++)for(var b=0;b<5;b++)d[g+5*b]=b+(2*g+3*b)%5*5;for(var w=1,x=0;x<24;x++){for(var I=0,A=0,O=0;O<7;O++){if(w&1){var R=(1<<O)-1;R<32?A^=1<<R:I^=1<<R-32}w&128?w=w<<1^113:w<<=1}p[x]=c.create(I,A)}})();var f=[];(function(){for(var g=0;g<25;g++)f[g]=c.create()})();var m=u.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var g=this._state=[],b=0;b<25;b++)g[b]=new c.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(g,b){for(var y=this._state,E=this.blockSize/2,S=0;S<E;S++){var w=g[b+2*S],x=g[b+2*S+1];w=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360,x=(x<<8|x>>>24)&16711935|(x<<24|x>>>8)&4278255360;var I=y[S];I.high^=x,I.low^=w}for(var A=0;A<24;A++){for(var O=0;O<5;O++){for(var R=0,M=0,F=0;F<5;F++){var I=y[O+5*F];R^=I.high,M^=I.low}var G=f[O];G.high=R,G.low=M}for(var O=0;O<5;O++)for(var V=f[(O+4)%5],q=f[(O+1)%5],C=q.high,N=q.low,R=V.high^(C<<1|N>>>31),M=V.low^(N<<1|C>>>31),F=0;F<5;F++){var I=y[O+5*F];I.high^=R,I.low^=M}for(var T=1;T<25;T++){var R,M,I=y[T],L=I.high,P=I.low,B=h[T];B<32?(R=L<<B|P>>>32-B,M=P<<B|L>>>32-B):(R=P<<B-32|L>>>64-B,M=L<<B-32|P>>>64-B);var U=f[d[T]];U.high=R,U.low=M}var X=f[0],J=y[0];X.high=J.high,X.low=J.low;for(var O=0;O<5;O++)for(var F=0;F<5;F++){var T=O+5*F,I=y[T],ne=f[T],fe=f[(O+1)%5+5*F],xe=f[(O+2)%5+5*F];I.high=ne.high^~fe.high&xe.high,I.low=ne.low^~fe.low&xe.low}var I=y[0],ve=p[A];I.high^=ve.high,I.low^=ve.low}},_doFinalize:function(){var g=this._data,b=g.words,y=this._nDataBytes*8,E=g.sigBytes*8,S=this.blockSize*32;b[E>>>5]|=1<<24-E%32,b[(r.ceil((E+1)/S)*S>>>5)-1]|=128,g.sigBytes=b.length*4,this._process();for(var w=this._state,x=this.cfg.outputLength/8,I=x/8,A=[],O=0;O<I;O++){var R=w[O],M=R.high,F=R.low;M=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360,F=(F<<8|F>>>24)&16711935|(F<<24|F>>>8)&4278255360,A.push(F),A.push(M)}return new a.init(A,x)},clone:function(){for(var g=o.clone.call(this),b=g._state=this._state.slice(0),y=0;y<25;y++)b[y]=b[y].clone();return g}});n.SHA3=o._createHelper(m),n.HmacSHA3=o._createHmacHelper(m)})(Math),i.SHA3})}),EF=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.WordArray,o=s.Hasher,l=n.algo,c=a.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=a.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),h=a.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),d=a.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),p=a.create([0,1518500249,1859775393,2400959708,2840853838]),f=a.create([1352829926,1548603684,1836072691,2053994217,0]),m=l.RIPEMD160=o.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(x,I){for(var A=0;A<16;A++){var O=I+A,R=x[O];x[O]=(R<<8|R>>>24)&16711935|(R<<24|R>>>8)&4278255360}var M=this._hash.words,F=p.words,G=f.words,V=c.words,q=u.words,C=h.words,N=d.words,T,L,P,B,U,X,J,ne,fe,xe;X=T=M[0],J=L=M[1],ne=P=M[2],fe=B=M[3],xe=U=M[4];for(var ve,A=0;A<80;A+=1)ve=T+x[I+V[A]]|0,A<16?ve+=g(L,P,B)+F[0]:A<32?ve+=b(L,P,B)+F[1]:A<48?ve+=y(L,P,B)+F[2]:A<64?ve+=E(L,P,B)+F[3]:ve+=S(L,P,B)+F[4],ve=ve|0,ve=w(ve,C[A]),ve=ve+U|0,T=U,U=B,B=w(P,10),P=L,L=ve,ve=X+x[I+q[A]]|0,A<16?ve+=S(J,ne,fe)+G[0]:A<32?ve+=E(J,ne,fe)+G[1]:A<48?ve+=y(J,ne,fe)+G[2]:A<64?ve+=b(J,ne,fe)+G[3]:ve+=g(J,ne,fe)+G[4],ve=ve|0,ve=w(ve,N[A]),ve=ve+xe|0,X=xe,xe=fe,fe=w(ne,10),ne=J,J=ve;ve=M[1]+P+fe|0,M[1]=M[2]+B+xe|0,M[2]=M[3]+U+X|0,M[3]=M[4]+T+J|0,M[4]=M[0]+L+ne|0,M[0]=ve},_doFinalize:function(){var x=this._data,I=x.words,A=this._nDataBytes*8,O=x.sigBytes*8;I[O>>>5]|=128<<24-O%32,I[(O+64>>>9<<4)+14]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,x.sigBytes=(I.length+1)*4,this._process();for(var R=this._hash,M=R.words,F=0;F<5;F++){var G=M[F];M[F]=(G<<8|G>>>24)&16711935|(G<<24|G>>>8)&4278255360}return R},clone:function(){var x=o.clone.call(this);return x._hash=this._hash.clone(),x}});function g(x,I,A){return x^I^A}function b(x,I,A){return x&I|~x&A}function y(x,I,A){return(x|~I)^A}function E(x,I,A){return x&A|I&~A}function S(x,I,A){return x^(I|~A)}function w(x,I){return x<<I|x>>>32-I}n.RIPEMD160=o._createHelper(m),n.HmacRIPEMD160=o._createHmacHelper(m)})(Math),i.RIPEMD160})}),nI=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(yr()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){(function(){var r=i,n=r.lib,s=n.Base,a=r.enc,o=a.Utf8,l=r.algo,c=l.HMAC=s.extend({init:function(u,h){u=this._hasher=new u.init,typeof h=="string"&&(h=o.parse(h));var d=u.blockSize,p=d*4;h.sigBytes>p&&(h=u.finalize(h)),h.clamp();for(var f=this._oKey=h.clone(),m=this._iKey=h.clone(),g=f.words,b=m.words,y=0;y<d;y++)g[y]^=1549556828,b[y]^=909522486;f.sigBytes=m.sigBytes=p,this.reset()},reset:function(){var u=this._hasher;u.reset(),u.update(this._iKey)},update:function(u){return this._hasher.update(u),this},finalize:function(u){var h=this._hasher,d=h.finalize(u);h.reset();var p=h.finalize(this._oKey.clone().concat(d));return p}})})()})}),SF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),rI(),nI()):typeof define=="function"&&define.amd?define(["./core","./sha256","./hmac"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.Base,a=n.WordArray,o=r.algo,l=o.SHA256,c=o.HMAC,u=o.PBKDF2=s.extend({cfg:s.extend({keySize:128/32,hasher:l,iterations:25e4}),init:function(h){this.cfg=this.cfg.extend(h)},compute:function(h,d){for(var p=this.cfg,f=c.create(p.hasher,h),m=a.create(),g=a.create([1]),b=m.words,y=g.words,E=p.keySize,S=p.iterations;b.length<E;){var w=f.update(d).finalize(g);f.reset();for(var x=w.words,I=x.length,A=w,O=1;O<S;O++){A=f.finalize(A),f.reset();for(var R=A.words,M=0;M<I;M++)x[M]^=R[M]}m.concat(w),y[0]++}return m.sigBytes=E*4,m}});r.PBKDF2=function(h,d,p){return u.create(p).compute(h,d)}})(),i.PBKDF2})}),cd=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),nO(),nI()):typeof define=="function"&&define.amd?define(["./core","./sha1","./hmac"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.Base,a=n.WordArray,o=r.algo,l=o.MD5,c=o.EvpKDF=s.extend({cfg:s.extend({keySize:128/32,hasher:l,iterations:1}),init:function(u){this.cfg=this.cfg.extend(u)},compute:function(u,h){for(var d,p=this.cfg,f=p.hasher.create(),m=a.create(),g=m.words,b=p.keySize,y=p.iterations;g.length<b;){d&&f.update(d),d=f.update(u).finalize(h),f.reset();for(var E=1;E<y;E++)d=f.finalize(d),f.reset();m.concat(d)}return m.sigBytes=b*4,m}});r.EvpKDF=function(u,h,d){return c.create(d).compute(u,h)}})(),i.EvpKDF})}),Zs=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),cd()):typeof define=="function"&&define.amd?define(["./core","./evpkdf"],r):r(i.CryptoJS)})(e,function(i){i.lib.Cipher||(function(r){var n=i,s=n.lib,a=s.Base,o=s.WordArray,l=s.BufferedBlockAlgorithm,c=n.enc,u=c.Utf8,h=c.Base64,d=n.algo,p=d.EvpKDF,f=s.Cipher=l.extend({cfg:a.extend(),createEncryptor:function(G,V){return this.create(this._ENC_XFORM_MODE,G,V)},createDecryptor:function(G,V){return this.create(this._DEC_XFORM_MODE,G,V)},init:function(G,V,q){this.cfg=this.cfg.extend(q),this._xformMode=G,this._key=V,this.reset()},reset:function(){l.reset.call(this),this._doReset()},process:function(G){return this._append(G),this._process()},finalize:function(G){G&&this._append(G);var V=this._doFinalize();return V},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:(function(){function G(V){return typeof V=="string"?F:O}return function(V){return{encrypt:function(q,C,N){return G(C).encrypt(V,q,C,N)},decrypt:function(q,C,N){return G(C).decrypt(V,q,C,N)}}}})()}),m=s.StreamCipher=f.extend({_doFinalize:function(){var G=this._process(!0);return G},blockSize:1}),g=n.mode={},b=s.BlockCipherMode=a.extend({createEncryptor:function(G,V){return this.Encryptor.create(G,V)},createDecryptor:function(G,V){return this.Decryptor.create(G,V)},init:function(G,V){this._cipher=G,this._iv=V}}),y=g.CBC=(function(){var G=b.extend();G.Encryptor=G.extend({processBlock:function(q,C){var N=this._cipher,T=N.blockSize;V.call(this,q,C,T),N.encryptBlock(q,C),this._prevBlock=q.slice(C,C+T)}}),G.Decryptor=G.extend({processBlock:function(q,C){var N=this._cipher,T=N.blockSize,L=q.slice(C,C+T);N.decryptBlock(q,C),V.call(this,q,C,T),this._prevBlock=L}});function V(q,C,N){var T,L=this._iv;L?(T=L,this._iv=r):T=this._prevBlock;for(var P=0;P<N;P++)q[C+P]^=T[P]}return G})(),E=n.pad={},S=E.Pkcs7={pad:function(G,V){for(var q=V*4,C=q-G.sigBytes%q,N=C<<24|C<<16|C<<8|C,T=[],L=0;L<C;L+=4)T.push(N);var P=o.create(T,C);G.concat(P)},unpad:function(G){var V=G.words[G.sigBytes-1>>>2]&255;G.sigBytes-=V}},w=s.BlockCipher=f.extend({cfg:f.cfg.extend({mode:y,padding:S}),reset:function(){var G;f.reset.call(this);var V=this.cfg,q=V.iv,C=V.mode;this._xformMode==this._ENC_XFORM_MODE?G=C.createEncryptor:(G=C.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==G?this._mode.init(this,q&&q.words):(this._mode=G.call(C,this,q&&q.words),this._mode.__creator=G)},_doProcessBlock:function(G,V){this._mode.processBlock(G,V)},_doFinalize:function(){var G,V=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(V.pad(this._data,this.blockSize),G=this._process(!0)):(G=this._process(!0),V.unpad(G)),G},blockSize:128/32}),x=s.CipherParams=a.extend({init:function(G){this.mixIn(G)},toString:function(G){return(G||this.formatter).stringify(this)}}),I=n.format={},A=I.OpenSSL={stringify:function(G){var V,q=G.ciphertext,C=G.salt;return C?V=o.create([1398893684,1701076831]).concat(C).concat(q):V=q,V.toString(h)},parse:function(G){var V,q=h.parse(G),C=q.words;return C[0]==1398893684&&C[1]==1701076831&&(V=o.create(C.slice(2,4)),C.splice(0,4),q.sigBytes-=16),x.create({ciphertext:q,salt:V})}},O=s.SerializableCipher=a.extend({cfg:a.extend({format:A}),encrypt:function(G,V,q,C){C=this.cfg.extend(C);var N=G.createEncryptor(q,C),T=N.finalize(V),L=N.cfg;return x.create({ciphertext:T,key:q,iv:L.iv,algorithm:G,mode:L.mode,padding:L.padding,blockSize:G.blockSize,formatter:C.format})},decrypt:function(G,V,q,C){C=this.cfg.extend(C),V=this._parse(V,C.format);var N=G.createDecryptor(q,C).finalize(V.ciphertext);return N},_parse:function(G,V){return typeof G=="string"?V.parse(G,this):G}}),R=n.kdf={},M=R.OpenSSL={execute:function(G,V,q,C,N){if(C||(C=o.random(64/8)),N)var T=p.create({keySize:V+q,hasher:N}).compute(G,C);else var T=p.create({keySize:V+q}).compute(G,C);var L=o.create(T.words.slice(V),q*4);return T.sigBytes=V*4,x.create({key:T,iv:L,salt:C})}},F=s.PasswordBasedCipher=O.extend({cfg:O.cfg.extend({kdf:M}),encrypt:function(G,V,q,C){C=this.cfg.extend(C);var N=C.kdf.execute(q,G.keySize,G.ivSize,C.salt,C.hasher);C.iv=N.iv;var T=O.encrypt.call(this,G,V,N.key,C);return T.mixIn(N),T},decrypt:function(G,V,q,C){C=this.cfg.extend(C),V=this._parse(V,C.format);var N=C.kdf.execute(q,G.keySize,G.ivSize,V.salt,C.hasher);C.iv=N.iv;var T=O.decrypt.call(this,G,V,N.key,C);return T}})})()})}),wF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CFB=(function(){var r=i.lib.BlockCipherMode.extend();r.Encryptor=r.extend({processBlock:function(s,a){var o=this._cipher,l=o.blockSize;n.call(this,s,a,l,o),this._prevBlock=s.slice(a,a+l)}}),r.Decryptor=r.extend({processBlock:function(s,a){var o=this._cipher,l=o.blockSize,c=s.slice(a,a+l);n.call(this,s,a,l,o),this._prevBlock=c}});function n(s,a,o,l){var c,u=this._iv;u?(c=u.slice(0),this._iv=void 0):c=this._prevBlock,l.encryptBlock(c,0);for(var h=0;h<o;h++)s[a+h]^=c[h]}return r})(),i.mode.CFB})}),vF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CTR=(function(){var r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(s,a){var o=this._cipher,l=o.blockSize,c=this._iv,u=this._counter;c&&(u=this._counter=c.slice(0),this._iv=void 0);var h=u.slice(0);o.encryptBlock(h,0),u[l-1]=u[l-1]+1|0;for(var d=0;d<l;d++)s[a+d]^=h[d]}});return r.Decryptor=n,r})(),i.mode.CTR})}),TF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CTRGladman=(function(){var r=i.lib.BlockCipherMode.extend();function n(o){if((o>>24&255)===255){var l=o>>16&255,c=o>>8&255,u=o&255;l===255?(l=0,c===255?(c=0,u===255?u=0:++u):++c):++l,o=0,o+=l<<16,o+=c<<8,o+=u}else o+=1<<24;return o}function s(o){return(o[0]=n(o[0]))===0&&(o[1]=n(o[1])),o}var a=r.Encryptor=r.extend({processBlock:function(o,l){var c=this._cipher,u=c.blockSize,h=this._iv,d=this._counter;h&&(d=this._counter=h.slice(0),this._iv=void 0),s(d);var p=d.slice(0);c.encryptBlock(p,0);for(var f=0;f<u;f++)o[l+f]^=p[f]}});return r.Decryptor=a,r})(),i.mode.CTRGladman})}),IF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.OFB=(function(){var r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(s,a){var o=this._cipher,l=o.blockSize,c=this._iv,u=this._keystream;c&&(u=this._keystream=c.slice(0),this._iv=void 0),o.encryptBlock(u,0);for(var h=0;h<l;h++)s[a+h]^=u[h]}});return r.Decryptor=n,r})(),i.mode.OFB})}),AF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.ECB=(function(){var r=i.lib.BlockCipherMode.extend();return r.Encryptor=r.extend({processBlock:function(n,s){this._cipher.encryptBlock(n,s)}}),r.Decryptor=r.extend({processBlock:function(n,s){this._cipher.decryptBlock(n,s)}}),r})(),i.mode.ECB})}),CF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.AnsiX923={pad:function(r,n){var s=r.sigBytes,a=n*4,o=a-s%a,l=s+o-1;r.clamp(),r.words[l>>>2]|=o<<24-l%4*8,r.sigBytes+=o},unpad:function(r){var n=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=n}},i.pad.Ansix923})}),DF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.Iso10126={pad:function(r,n){var s=n*4,a=s-r.sigBytes%s;r.concat(i.lib.WordArray.random(a-1)).concat(i.lib.WordArray.create([a<<24],1))},unpad:function(r){var n=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=n}},i.pad.Iso10126})}),_F=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.Iso97971={pad:function(r,n){r.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(r,n)},unpad:function(r){i.pad.ZeroPadding.unpad(r),r.sigBytes--}},i.pad.Iso97971})}),PF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.ZeroPadding={pad:function(r,n){var s=n*4;r.clamp(),r.sigBytes+=s-(r.sigBytes%s||s)},unpad:function(r){for(var n=r.words,s=r.sigBytes-1,s=r.sigBytes-1;s>=0;s--)if(n[s>>>2]>>>24-s%4*8&255){r.sigBytes=s+1;break}}},i.pad.ZeroPadding})}),LF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding})}),OF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),Zs()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.CipherParams,o=n.enc,l=o.Hex,c=n.format,u=c.Hex={stringify:function(h){return h.ciphertext.toString(l)},parse:function(h){var d=l.parse(h);return a.create({ciphertext:d})}}})(),i.format.Hex})}),RF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),_p(),Pp(),cd(),Zs()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.BlockCipher,a=r.algo,o=[],l=[],c=[],u=[],h=[],d=[],p=[],f=[],m=[],g=[];(function(){for(var E=[],S=0;S<256;S++)S<128?E[S]=S<<1:E[S]=S<<1^283;for(var w=0,x=0,S=0;S<256;S++){var I=x^x<<1^x<<2^x<<3^x<<4;I=I>>>8^I&255^99,o[w]=I,l[I]=w;var A=E[w],O=E[A],R=E[O],M=E[I]*257^I*16843008;c[w]=M<<24|M>>>8,u[w]=M<<16|M>>>16,h[w]=M<<8|M>>>24,d[w]=M;var M=R*16843009^O*65537^A*257^w*16843008;p[I]=M<<24|M>>>8,f[I]=M<<16|M>>>16,m[I]=M<<8|M>>>24,g[I]=M,w?(w=A^E[E[E[R^A]]],x^=E[E[x]]):w=x=1}})();var b=[0,1,2,4,8,16,32,64,128,27,54],y=a.AES=s.extend({_doReset:function(){var E;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var S=this._keyPriorReset=this._key,w=S.words,x=S.sigBytes/4,I=this._nRounds=x+6,A=(I+1)*4,O=this._keySchedule=[],R=0;R<A;R++)R<x?O[R]=w[R]:(E=O[R-1],R%x?x>6&&R%x==4&&(E=o[E>>>24]<<24|o[E>>>16&255]<<16|o[E>>>8&255]<<8|o[E&255]):(E=E<<8|E>>>24,E=o[E>>>24]<<24|o[E>>>16&255]<<16|o[E>>>8&255]<<8|o[E&255],E^=b[R/x|0]<<24),O[R]=O[R-x]^E);for(var M=this._invKeySchedule=[],F=0;F<A;F++){var R=A-F;if(F%4)var E=O[R];else var E=O[R-4];F<4||R<=4?M[F]=E:M[F]=p[o[E>>>24]]^f[o[E>>>16&255]]^m[o[E>>>8&255]]^g[o[E&255]]}}},encryptBlock:function(E,S){this._doCryptBlock(E,S,this._keySchedule,c,u,h,d,o)},decryptBlock:function(E,S){var w=E[S+1];E[S+1]=E[S+3],E[S+3]=w,this._doCryptBlock(E,S,this._invKeySchedule,p,f,m,g,l);var w=E[S+1];E[S+1]=E[S+3],E[S+3]=w},_doCryptBlock:function(E,S,w,x,I,A,O,R){for(var M=this._nRounds,F=E[S]^w[0],G=E[S+1]^w[1],V=E[S+2]^w[2],q=E[S+3]^w[3],C=4,N=1;N<M;N++){var T=x[F>>>24]^I[G>>>16&255]^A[V>>>8&255]^O[q&255]^w[C++],L=x[G>>>24]^I[V>>>16&255]^A[q>>>8&255]^O[F&255]^w[C++],P=x[V>>>24]^I[q>>>16&255]^A[F>>>8&255]^O[G&255]^w[C++],B=x[q>>>24]^I[F>>>16&255]^A[G>>>8&255]^O[V&255]^w[C++];F=T,G=L,V=P,q=B}var T=(R[F>>>24]<<24|R[G>>>16&255]<<16|R[V>>>8&255]<<8|R[q&255])^w[C++],L=(R[G>>>24]<<24|R[V>>>16&255]<<16|R[q>>>8&255]<<8|R[F&255])^w[C++],P=(R[V>>>24]<<24|R[q>>>16&255]<<16|R[F>>>8&255]<<8|R[G&255])^w[C++],B=(R[q>>>24]<<24|R[F>>>16&255]<<16|R[G>>>8&255]<<8|R[V&255])^w[C++];E[S]=T,E[S+1]=L,E[S+2]=P,E[S+3]=B},keySize:256/32});r.AES=s._createHelper(y)})(),i.AES})}),NF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),_p(),Pp(),cd(),Zs()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=n.BlockCipher,o=r.algo,l=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],c=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],h=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],d=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],p=o.DES=a.extend({_doReset:function(){for(var b=this._key,y=b.words,E=[],S=0;S<56;S++){var w=l[S]-1;E[S]=y[w>>>5]>>>31-w%32&1}for(var x=this._subKeys=[],I=0;I<16;I++){for(var A=x[I]=[],O=u[I],S=0;S<24;S++)A[S/6|0]|=E[(c[S]-1+O)%28]<<31-S%6,A[4+(S/6|0)]|=E[28+(c[S+24]-1+O)%28]<<31-S%6;A[0]=A[0]<<1|A[0]>>>31;for(var S=1;S<7;S++)A[S]=A[S]>>>(S-1)*4+3;A[7]=A[7]<<5|A[7]>>>27}for(var R=this._invSubKeys=[],S=0;S<16;S++)R[S]=x[15-S]},encryptBlock:function(b,y){this._doCryptBlock(b,y,this._subKeys)},decryptBlock:function(b,y){this._doCryptBlock(b,y,this._invSubKeys)},_doCryptBlock:function(b,y,E){this._lBlock=b[y],this._rBlock=b[y+1],f.call(this,4,252645135),f.call(this,16,65535),m.call(this,2,858993459),m.call(this,8,16711935),f.call(this,1,1431655765);for(var S=0;S<16;S++){for(var w=E[S],x=this._lBlock,I=this._rBlock,A=0,O=0;O<8;O++)A|=h[O][((I^w[O])&d[O])>>>0];this._lBlock=I,this._rBlock=x^A}var R=this._lBlock;this._lBlock=this._rBlock,this._rBlock=R,f.call(this,1,1431655765),m.call(this,8,16711935),m.call(this,2,858993459),f.call(this,16,65535),f.call(this,4,252645135),b[y]=this._lBlock,b[y+1]=this._rBlock},keySize:64/32,ivSize:64/32,blockSize:64/32});function f(b,y){var E=(this._lBlock>>>b^this._rBlock)&y;this._rBlock^=E,this._lBlock^=E<<b}function m(b,y){var E=(this._rBlock>>>b^this._lBlock)&y;this._lBlock^=E,this._rBlock^=E<<b}r.DES=a._createHelper(p);var g=o.TripleDES=a.extend({_doReset:function(){var b=this._key,y=b.words;if(y.length!==2&&y.length!==4&&y.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var E=y.slice(0,2),S=y.length<4?y.slice(0,2):y.slice(2,4),w=y.length<6?y.slice(0,2):y.slice(4,6);this._des1=p.createEncryptor(s.create(E)),this._des2=p.createEncryptor(s.create(S)),this._des3=p.createEncryptor(s.create(w))},encryptBlock:function(b,y){this._des1.encryptBlock(b,y),this._des2.decryptBlock(b,y),this._des3.encryptBlock(b,y)},decryptBlock:function(b,y){this._des3.decryptBlock(b,y),this._des2.encryptBlock(b,y),this._des1.decryptBlock(b,y)},keySize:192/32,ivSize:64/32,blockSize:64/32});r.TripleDES=a._createHelper(g)})(),i.TripleDES})}),MF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),_p(),Pp(),cd(),Zs()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.StreamCipher,a=r.algo,o=a.RC4=s.extend({_doReset:function(){for(var u=this._key,h=u.words,d=u.sigBytes,p=this._S=[],f=0;f<256;f++)p[f]=f;for(var f=0,m=0;f<256;f++){var g=f%d,b=h[g>>>2]>>>24-g%4*8&255;m=(m+p[f]+b)%256;var y=p[f];p[f]=p[m],p[m]=y}this._i=this._j=0},_doProcessBlock:function(u,h){u[h]^=l.call(this)},keySize:256/32,ivSize:0});function l(){for(var u=this._S,h=this._i,d=this._j,p=0,f=0;f<4;f++){h=(h+1)%256,d=(d+u[h])%256;var m=u[h];u[h]=u[d],u[d]=m,p|=u[(u[h]+u[d])%256]<<24-f*8}return this._i=h,this._j=d,p}r.RC4=s._createHelper(o);var c=a.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var u=this.cfg.drop;u>0;u--)l.call(this)}});r.RC4Drop=s._createHelper(c)})(),i.RC4})}),BF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),_p(),Pp(),cd(),Zs()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.StreamCipher,a=r.algo,o=[],l=[],c=[],u=a.Rabbit=s.extend({_doReset:function(){for(var d=this._key.words,p=this.cfg.iv,f=0;f<4;f++)d[f]=(d[f]<<8|d[f]>>>24)&16711935|(d[f]<<24|d[f]>>>8)&4278255360;var m=this._X=[d[0],d[3]<<16|d[2]>>>16,d[1],d[0]<<16|d[3]>>>16,d[2],d[1]<<16|d[0]>>>16,d[3],d[2]<<16|d[1]>>>16],g=this._C=[d[2]<<16|d[2]>>>16,d[0]&4294901760|d[1]&65535,d[3]<<16|d[3]>>>16,d[1]&4294901760|d[2]&65535,d[0]<<16|d[0]>>>16,d[2]&4294901760|d[3]&65535,d[1]<<16|d[1]>>>16,d[3]&4294901760|d[0]&65535];this._b=0;for(var f=0;f<4;f++)h.call(this);for(var f=0;f<8;f++)g[f]^=m[f+4&7];if(p){var b=p.words,y=b[0],E=b[1],S=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360,w=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,x=S>>>16|w&4294901760,I=w<<16|S&65535;g[0]^=S,g[1]^=x,g[2]^=w,g[3]^=I,g[4]^=S,g[5]^=x,g[6]^=w,g[7]^=I;for(var f=0;f<4;f++)h.call(this)}},_doProcessBlock:function(d,p){var f=this._X;h.call(this),o[0]=f[0]^f[5]>>>16^f[3]<<16,o[1]=f[2]^f[7]>>>16^f[5]<<16,o[2]=f[4]^f[1]>>>16^f[7]<<16,o[3]=f[6]^f[3]>>>16^f[1]<<16;for(var m=0;m<4;m++)o[m]=(o[m]<<8|o[m]>>>24)&16711935|(o[m]<<24|o[m]>>>8)&4278255360,d[p+m]^=o[m]},blockSize:128/32,ivSize:64/32});function h(){for(var d=this._X,p=this._C,f=0;f<8;f++)l[f]=p[f];p[0]=p[0]+1295307597+this._b|0,p[1]=p[1]+3545052371+(p[0]>>>0<l[0]>>>0?1:0)|0,p[2]=p[2]+886263092+(p[1]>>>0<l[1]>>>0?1:0)|0,p[3]=p[3]+1295307597+(p[2]>>>0<l[2]>>>0?1:0)|0,p[4]=p[4]+3545052371+(p[3]>>>0<l[3]>>>0?1:0)|0,p[5]=p[5]+886263092+(p[4]>>>0<l[4]>>>0?1:0)|0,p[6]=p[6]+1295307597+(p[5]>>>0<l[5]>>>0?1:0)|0,p[7]=p[7]+3545052371+(p[6]>>>0<l[6]>>>0?1:0)|0,this._b=p[7]>>>0<l[7]>>>0?1:0;for(var f=0;f<8;f++){var m=d[f]+p[f],g=m&65535,b=m>>>16,y=((g*g>>>17)+g*b>>>15)+b*b,E=((m&4294901760)*m|0)+((m&65535)*m|0);c[f]=y^E}d[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,d[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,d[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,d[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,d[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,d[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,d[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,d[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}r.Rabbit=s._createHelper(u)})(),i.Rabbit})}),kF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),_p(),Pp(),cd(),Zs()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.StreamCipher,a=r.algo,o=[],l=[],c=[],u=a.RabbitLegacy=s.extend({_doReset:function(){var d=this._key.words,p=this.cfg.iv,f=this._X=[d[0],d[3]<<16|d[2]>>>16,d[1],d[0]<<16|d[3]>>>16,d[2],d[1]<<16|d[0]>>>16,d[3],d[2]<<16|d[1]>>>16],m=this._C=[d[2]<<16|d[2]>>>16,d[0]&4294901760|d[1]&65535,d[3]<<16|d[3]>>>16,d[1]&4294901760|d[2]&65535,d[0]<<16|d[0]>>>16,d[2]&4294901760|d[3]&65535,d[1]<<16|d[1]>>>16,d[3]&4294901760|d[0]&65535];this._b=0;for(var g=0;g<4;g++)h.call(this);for(var g=0;g<8;g++)m[g]^=f[g+4&7];if(p){var b=p.words,y=b[0],E=b[1],S=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360,w=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,x=S>>>16|w&4294901760,I=w<<16|S&65535;m[0]^=S,m[1]^=x,m[2]^=w,m[3]^=I,m[4]^=S,m[5]^=x,m[6]^=w,m[7]^=I;for(var g=0;g<4;g++)h.call(this)}},_doProcessBlock:function(d,p){var f=this._X;h.call(this),o[0]=f[0]^f[5]>>>16^f[3]<<16,o[1]=f[2]^f[7]>>>16^f[5]<<16,o[2]=f[4]^f[1]>>>16^f[7]<<16,o[3]=f[6]^f[3]>>>16^f[1]<<16;for(var m=0;m<4;m++)o[m]=(o[m]<<8|o[m]>>>24)&16711935|(o[m]<<24|o[m]>>>8)&4278255360,d[p+m]^=o[m]},blockSize:128/32,ivSize:64/32});function h(){for(var d=this._X,p=this._C,f=0;f<8;f++)l[f]=p[f];p[0]=p[0]+1295307597+this._b|0,p[1]=p[1]+3545052371+(p[0]>>>0<l[0]>>>0?1:0)|0,p[2]=p[2]+886263092+(p[1]>>>0<l[1]>>>0?1:0)|0,p[3]=p[3]+1295307597+(p[2]>>>0<l[2]>>>0?1:0)|0,p[4]=p[4]+3545052371+(p[3]>>>0<l[3]>>>0?1:0)|0,p[5]=p[5]+886263092+(p[4]>>>0<l[4]>>>0?1:0)|0,p[6]=p[6]+1295307597+(p[5]>>>0<l[5]>>>0?1:0)|0,p[7]=p[7]+3545052371+(p[6]>>>0<l[6]>>>0?1:0)|0,this._b=p[7]>>>0<l[7]>>>0?1:0;for(var f=0;f<8;f++){var m=d[f]+p[f],g=m&65535,b=m>>>16,y=((g*g>>>17)+g*b>>>15)+b*b,E=((m&4294901760)*m|0)+((m&65535)*m|0);c[f]=y^E}d[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,d[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,d[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,d[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,d[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,d[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,d[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,d[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}r.RabbitLegacy=s._createHelper(u)})(),i.RabbitLegacy})}),FF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),_p(),Pp(),cd(),Zs()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.BlockCipher,a=r.algo;let o=16,l=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],c=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var u={pbox:[],sbox:[]};function h(g,b){let y=b>>24&255,E=b>>16&255,S=b>>8&255,w=b&255,x=g.sbox[0][y]+g.sbox[1][E];return x=x^g.sbox[2][S],x=x+g.sbox[3][w],x}function d(g,b,y){let E=b,S=y,w;for(let x=0;x<o;++x)E=E^g.pbox[x],S=h(g,E)^S,w=E,E=S,S=w;return w=E,E=S,S=w,S=S^g.pbox[o],E=E^g.pbox[o+1],{left:E,right:S}}function p(g,b,y){let E=b,S=y,w;for(let x=o+1;x>1;--x)E=E^g.pbox[x],S=h(g,E)^S,w=E,E=S,S=w;return w=E,E=S,S=w,S=S^g.pbox[1],E=E^g.pbox[0],{left:E,right:S}}function f(g,b,y){for(let I=0;I<4;I++){g.sbox[I]=[];for(let A=0;A<256;A++)g.sbox[I][A]=c[I][A]}let E=0;for(let I=0;I<o+2;I++)g.pbox[I]=l[I]^b[E],E++,E>=y&&(E=0);let S=0,w=0,x=0;for(let I=0;I<o+2;I+=2)x=d(g,S,w),S=x.left,w=x.right,g.pbox[I]=S,g.pbox[I+1]=w;for(let I=0;I<4;I++)for(let A=0;A<256;A+=2)x=d(g,S,w),S=x.left,w=x.right,g.sbox[I][A]=S,g.sbox[I][A+1]=w;return!0}var m=a.Blowfish=s.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var g=this._keyPriorReset=this._key,b=g.words,y=g.sigBytes/4;f(u,b,y)}},encryptBlock:function(g,b){var y=d(u,g[b],g[b+1]);g[b]=y.left,g[b+1]=y.right},decryptBlock:function(g,b){var y=p(u,g[b],g[b+1]);g[b]=y.left,g[b+1]=y.right},blockSize:64/32,keySize:128/32,ivSize:64/32});r.Blowfish=s._createHelper(m)})(),i.Blowfish})}),GF=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(yr(),iE(),fF(),mF(),_p(),gF(),Pp(),nO(),rI(),yF(),sO(),bF(),xF(),EF(),nI(),SF(),cd(),Zs(),wF(),vF(),TF(),IF(),AF(),CF(),DF(),_F(),PF(),LF(),OF(),RF(),NF(),MF(),BF(),kF(),FF()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./lib-typedarrays","./enc-utf16","./enc-base64","./enc-base64url","./md5","./sha1","./sha256","./sha224","./sha512","./sha384","./sha3","./ripemd160","./hmac","./pbkdf2","./evpkdf","./cipher-core","./mode-cfb","./mode-ctr","./mode-ctr-gladman","./mode-ofb","./mode-ecb","./pad-ansix923","./pad-iso10126","./pad-iso97971","./pad-zeropadding","./pad-nopadding","./format-hex","./aes","./tripledes","./rc4","./rabbit","./rabbit-legacy","./blowfish"],r):i.CryptoJS=r(i.CryptoJS)})(e,function(i){return i})}),UF=(e=>(e.Device="Device",e.Symbol="Symbol",e.Footprint="Footprint",e.OBJ="OBJ",e.ModelID="3D Model",e.ModelName="3D Model Title",e.OriginModelName="Origin 3D Model Title",e.ModelTransform="3D Model Transform",e.OriginFootprint="Origin Footprint",e))(UF||{}),qy=(e=>(e.DOCHEAD="DOCHEAD",e.EDIT_HEAD="EDIT_HEAD",e.SCH="SCH",e.SCH_PAGE="SCH_PAGE",e.PCB="PCB",e.PANEL="PANEL",e.PANEL_LIB="PANEL_LIB",e.SYMBOL="SYMBOL",e.FOOTPRINT="FOOTPRINT",e.DEVICE="DEVICE",e.BLOB="BLOB",e.INSTANCE="INSTANCE",e.CONFIG="CONFIG",e.BOARD="BOARD",e.FONT="FONT",e.VARIANT="VARIANT",e.COMPONENT_GROUP="COMPONENT_GROUP",e.COMPONENT_GROUP_DATA="COMPONENT_GROUP_DATA",e.SIMULATION="SIMULATION",e))(qy||{}),YF=(e=>(e.META="META",e.META_SORT="META_SORT",e.META_CREATE="META_CREATE",e.META_MODIFY="META_MODIFY",e.FONT="FONT",e.BLOB="BLOB",e.MAX_NUM="MAX_NUM",e.INSTANCE_ATTR="INSTANCE_ATTR",e.DELETE_DOC="DELETE_DOC",e.META_Z_INDEX="META_Z_INDEX",e.VARIANT_GROUPED="VARIANT_GROUPED",e.GROUP_INDEX="GROUP_INDEX",e.GROUP_DATA="GROUP_DATA",e.RULE_TEMPLATE="RULE_TEMPLATE",e.RULE="RULE",e.RULE_SELECTOR="RULE_SELECTOR",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e.META_PLACEHOLDER="META_PLACEHOLDER",e))(YF||{});function Jy(e,t,i){return e.slice(t,i)}function Mx(e,t,i){let r=e.length,n=0;for(;n<r;){let s=e.indexOf(`|
`,n);if(s<0){if(i)return e.substring(n);s=r}let a=Jy(e,n,s);try{if(a){let o=a.indexOf("||"),l=o>-1,c=l?Jy(a,0,o):a,u=l?Jy(a,o+2):"";if(t(c,u,a,l?n+o+2:n)===!1){a=null;break}a=null}}catch(o){console.error(o)}n=s+2}e=null}var VF=["SYMBOL","FOOTPRINT","BLOB","FONT","PANEL_LIB","DEVICE","BOARD","INSTANCE","CONFIG","VARIANT","COMPONENT_GROUP","COMPONENT_GROUP_DATA"];function Xv(e,t){return VF.includes(t)?t:e}var HF=class{parseFull(e,t,i){let r=t,n=i,s,a=null;Mx(e,(o,l,c)=>{let u=JSON.parse(o);if(u.type==="EDIT_HEAD")a=JSON.parse(l),this.onEditHead&&this.onEditHead(a);else if(u.type==="DOCHEAD"){let h=JSON.parse(l);n=h.docType,r=h.uuid,s=h.client,h.ticket=u.ticket,this.onDocHead(h,a,c)}else this.onLine(u.id,u.ticket,l,u.type,u.client||s,n,r,u.firstTicket,u.pend,a,u.num,c)}),this.onEnd(),e=null}flowParseFull(e={}){let{cache:t,chunkLength:i=100*1024*1024,idsData:r,history:n}=e,s="",a=null,o,l=null,c=!0,u="",h=0,d=!1,p={},f=t?{}:void 0,m=new Set,g=E=>{f[E]===void 0&&(f[E]=-1),t(E,++f[E],p[E].data.join(`|
`)),p[E].data.length=0,p[E].size=0,p[E].data.push(p[E].head),p[E].size+=p[E].head.length},b=E=>{if(m.add(s),!t)return;let S=Xv(s,a);p[S].data.push(E),p[S].size+=(p[S].size?2:0)+E.length,p[S].size+E.length>i&&g(S)},y=(E,S)=>Mx(E,(w,x,I,A)=>{var O,R,M,F,G,V,q,C;let N=JSON.parse(w);if(N.type==="EDIT_HEAD")l=JSON.parse(x),(O=this.onEditHead)==null||O.call(this,l),(R=e.onEditHead)==null||R.call(e,l),d=!0;else if(N.type==="DOCHEAD"){let T=JSON.parse(x);a=T.docType,s=T.uuid,o=T.client,T.ticket=N.ticket,d||(l={uuid:T.uuid,username:(M=T==null?void 0:T.user)==null?void 0:M.username,nickname:(F=T==null?void 0:T.user)==null?void 0:F.nickname,updateTime:T==null?void 0:T.updateTime},(G=e.onEditHead)==null||G.call(e,l),d=!0),this.onDocHead(T,l,I);let L=Xv(s,a);t&&!p[L]&&(p[L]={size:0,data:[],head:""}),t&&(p[L].head=I),b(I)}else{let T=N.num,L=N.client||o;if(r){let P=(C=(q=(V=r.ids)==null?void 0:V[s])==null?void 0:q[L])==null?void 0:C[N.id];if(!P||P[0]!==N.ticket)return;T=P[1],r.size-=1,delete r.ids[s][L][N.id]}if(n){let P=Xv(s,a);t&&(n.dNum=(f==null?void 0:f[P])===void 0?0:(f==null?void 0:f[P])+1),n.start=t?p[P].size+2+w.length+2:h+A}this.onLine(N.id,N.ticket,x,N.type,L,a,s,N.firstTicket,N.pend,l||(n==null?void 0:n.editHead),T,I,n),b(I)}},S);return{start:()=>{c=!0},end:()=>{if(u&&y(u,!1),t)for(let E in p)p[E].size&&p[E].data.length>1&&g(E),p[E]=null;c=!1,u="",s="",s=null,o="",l=null,this.onEnd()},update:E=>{if(!c)throw new Error("\u66F4\u65B0\u524D\u672A\u8C03\u7528 start \u65B9\u6CD5");let S=y(u+E,!0);h=h+u.length+E.length-((S==null?void 0:S.length)||0),u="",S&&(u=S)},docMap:f,getDocIds:()=>Array.from(m)}}parseLine(e,t,i){let r=e.indexOf("||"),n=r!==-1,s=n?Jy(e,0,r):e,a=n?Jy(e,r+2):"",o=JSON.parse(s);this.onLine(o.id,o.ticket,a,o.type,o.client,i,t,o.firstTicket,o.pend,void 0,o.num,e),e=null}onEditHead(e){}},Wv=new Uint8Array(8);function _l(){crypto.getRandomValues(Wv);let e="";for(let t=0;t<Wv.length;t++)e+=Wv[t].toString(16).padStart(2,"0");return e}function wp(e,t,i,r,n,s,a){let o={docType:e,client:t,uuid:i};return(r||r===0)&&(o.updateTime=r),(n||o.updateTime||o.updateTime===0)&&(o.version=n||String(r)),s&&(o.user=s),`${JSON.stringify({type:"DOCHEAD",ticket:a})}||${JSON.stringify(o)}`}function To(e,t,i,r,n,s,a,o){let l={type:e,ticket:t,id:i};return s!==void 0&&(l.firstTicket=s),a!==void 0&&(l.pend=a),o!==void 0&&(l.num=o),n&&(l.client=n),`${JSON.stringify(l)}||${r}`}var aO=class extends HF{constructor(e){super(),this.unique=_l(),this.maxTicket=0,this.isPendChange=!0,this.isLocalChange=!0,this.cbArr=[],this.tempLocalIds={},this.docMaxTicket={},this.client=e||_l()}onLine(e,t,i,r,n,s,a,o,l,c,u){this.remoteChange(t,n,a,e,i,r,s,void 0,o,l,c,void 0,void 0,u)}getUnique(){return this.unique}setUnique(e){this.unique=e}setDocMaxTicket(e,t,i){i||(!this.docMaxTicket[e]||this.docMaxTicket[e]<t)&&(this.docMaxTicket[e]=t)}getDocMaxTicket(e){var t;return(t=this.docMaxTicket[e])!=null?t:0}onDocHead(e,t){}onEnd(){}setIsPendChange(e){this.isPendChange=e}getIsPendChange(){return this.isPendChange}getMaxTicket(){return this.maxTicket}setMaxTicket(e,t){e&&(t||this.maxTicket<e)&&(this.maxTicket=e)}setIsLocalChange(e){this.isLocalChange=e}getIsLocalChange(){return this.isLocalChange}revoke(e,t,i,r,n,s,a,o,l,c,u){var h;if(!((h=this.tempLocalIds[e])!=null&&h[t]))return u?u(t,n,i,a,`${r}-1`,e,s,void 0,void 0,!0,c):this.cbArr.forEach(d=>d(e,t,i,a,`${r}-1`,n,void 0,s,void 0,void 0,void 0,c)),!0}getRandomUuid(){return _l()}getClient(){return this.client}onChange(e){this.cbArr.push(e)}localChange(e,t,i,r,n,s){let a=this.maxTicket+1;return this.tempLocalIds[e]||(this.tempLocalIds[e]={}),this.tempLocalIds[e][t]=[this.getClient(),a],this.remoteChange(a,this.client,e,t,i,r,n,!0,void 0,!0,void 0,this.unique,void 0,s),a}remoteChange(e,t,i,r,n,s,a,o,l,c,u,h,d,p){var f;this.setMaxTicket(e);let m=h===this.unique,g=o||m,b=(!g||g&&this.isLocalChange)&&(!d||d&&this.isPendChange),y=(f=this.tempLocalIds[i])==null?void 0:f[r];!o&&m?y?(b=!1,y[0]===t&&y[1]===e&&delete this.tempLocalIds[i][r]):b=!0:!o&&y&&(y[1]>e||y[1]===e&&y[0]>t?b=!1:delete this.tempLocalIds[i][r]),this.setDocMaxTicket(i,e,c),b&&this.cbArr.forEach(E=>E(i,r,n,s,t,e,l,c,void 0,d,h,p))}},jF=class{constructor(e){this.item=e,this.parent=null,this.left=null,this.right=null,this.height=1}getParent(){return this.parent}getLeft(){return this.left}getRight(){return this.right}getHeight(){return this.height}setLeft(e){if(this.left!==null)throw new Error("insert exists left is not permitted");if(e!==null){if(e.parent!==null)throw new Error("insert left with node has parent is not permitted");this.left=e,e.parent=this,this.updateHeight()}}setRight(e){if(this.right!==null)throw new Error("insert exists right is not permitted");if(e!==null){if(e.parent!==null)throw new Error("insert right with node has parent is not permitted");this.right=e,e.parent=this,this.updateHeight()}}removeLeft(){if(this.left===null)return null;{let e=this.left;return e.parent=null,this.left=null,this.updateHeight(),e}}removeRight(){if(this.right===null)return null;{let e=this.right;return e.parent=null,this.right=null,this.updateHeight(),e}}rotateRight(e){let t=this.removeLeft();if(this.setLeft(t.removeRight()),this.parent){let i=this.parent;i.getLeft()===this?(i.removeLeft(),i.setLeft(t)):(i.removeRight(),i.setRight(t)),t.setRight(this)}else t.setRight(this),e(t)}rotateLeft(e){let t=this.removeRight();if(this.setRight(t.removeLeft()),this.parent){let i=this.parent;i.getLeft()===this?(i.removeLeft(),i.setLeft(t)):(i.removeRight(),i.setRight(t)),t.setLeft(this)}else t.setLeft(this),e(t)}updateHeight(){var e,t;let i=this;for(;i!==null;)i.height=Math.max(((e=i.left)==null?void 0:e.height)||0,((t=i.right)==null?void 0:t.height)||0)+1,i=i.parent}},zF=class{constructor(e){this.comparator=e,this.root=null,this.minNode=null,this.maxNode=null,this.size=0}balance(e){var t,i;let r=((t=e.getLeft())==null?void 0:t.getHeight())||0,n=((i=e.getRight())==null?void 0:i.getHeight())||0,s=e.getParent();r>n?r-n>1?(e.rotateRight(a=>this.root=a),this.verify()):s!==null?s.getRight()===e&&(e.rotateRight(a=>this.root=a),this.verify()):(e.rotateRight(a=>this.root=a),this.verify()):n>r&&(n-r>1?(e.rotateLeft(a=>this.root=a),this.verify()):s!==null?s.getLeft()===e&&(e.rotateLeft(a=>this.root=a),this.verify()):(e.rotateLeft(a=>this.root=a),this.verify())),s&&this.balance(s)}forwardTraverse(e){let t=new Array(10),i=this.minNode;for(;i;)switch(t.pop()||2){case 1:i.getLeft()!==null?(t.push(2),t.push(1),i=i.getLeft()):t.push(2);break;case 2:if(!e(i.item))return;i.getRight()!==null?(t.push(3),t.push(1),i=i.getRight()):t.push(3);break;case 3:i=i.getParent();break;default:throw new Error("invalid status")}}backwardTraverse(e){let t=new Array(10),i=this.maxNode;for(;i;)switch(t.pop()||2){case 1:i.getRight()!==null?(t.push(2),t.push(1),i=i.getRight()):t.push(2);break;case 2:if(!e(i.item))return;i.getLeft()!==null?(t.push(3),t.push(1),i=i.getLeft()):t.push(3);break;case 3:i=i.getParent();break;default:throw new Error("invalid status")}}display(e=this.root,t=new Array,i=0){let r="| ".repeat(i);return t.push(r+`\u25CF(${e.item})
`),e.getLeft()?this.display(e.getLeft(),t,i+1):t.push(r+`| \u2609
`),e.getRight()?this.display(e.getRight(),t,i+1):t.push(r+`| \u2609
`),t}getHeight(){var e;return((e=this.root)==null?void 0:e.getHeight())||0}getSize(){return this.size}updateMinMax(e){this.minNode?this.comparator(e.item,this.minNode.item)<0&&(this.minNode=e):this.minNode=e,this.maxNode?this.comparator(e.item,this.maxNode.item)>0&&(this.maxNode=e):this.maxNode=e}insert(e){let t=new jF(e);if(this.root===null)return this.root=t,this.size++,this.updateMinMax(t),!0;{let i=this.root;for(;;){let r=this.comparator(e,i.item);if(r<0){if(i.getLeft()===null)return i.setLeft(t),this.size++,this.updateMinMax(t),this.verify(),this.balance(i),!0;i=i.getLeft()}else if(r>0){if(i.getRight()===null)return i.setRight(t),this.size++,this.updateMinMax(t),this.verify(),this.balance(i),!0;i=i.getRight()}else return!1}}}verify(){}remove(e){let t=this.root;for(this.verify();;){if(t===null)return!1;let i=this.comparator(e,t.item);if(i<0)t=t.getLeft();else if(i>0)t=t.getRight();else return this.minNode===t&&(t.getRight()?this.minNode=this.findMinChild(t.getRight()):this.minNode=t.getParent()),this.maxNode===t&&(t.getLeft()?this.maxNode=this.findMaxChild(t.getLeft()):this.maxNode=t.getParent()),this.removeNode(t),this.size--,this.verify(),!0}}removeNode(e){var t,i;let r=e.getParent();if(r===null)e.getLeft()===null&&e.getRight()===null?(this.root=null,this.minNode=null,this.maxNode=null):((((t=e.getLeft())==null?void 0:t.getHeight())||0)>(((i=e.getRight())==null?void 0:i.getHeight())||0)?(e.rotateRight(n=>this.root=n),this.verify()):(e.rotateLeft(n=>this.root=n),this.verify()),this.removeNode(e));else if(r.getLeft()===e){r.removeLeft();let n=this.combineNodes(e.removeLeft(),e.removeRight());r.setLeft(n),this.verify(),this.balance(r)}else{r.removeRight();let n=this.combineNodes(e.removeLeft(),e.removeRight());r.setRight(n),this.verify(),this.balance(r)}}combineNodes(e,t){if(e&&t)if(e.getHeight()>t.getHeight()){let i=this.findMaxChild(e);if(i){let r=i.getParent();return r.removeRight(),r.setRight(i.removeLeft()),i.setLeft(e),i.setRight(t),i}else return e.setRight(t),e}else{let i=this.findMinChild(t);if(i){let r=i.getParent();return r.removeLeft(),r.setLeft(i.removeRight()),i.setLeft(e),i.setRight(t),i}else return t.setLeft(e),t}else return e||t||null}findMinChild(e){let t=e;for(;;){if(t.getLeft()===null)return t!==e?t:null;t=t.getLeft()}}findMaxChild(e){let t=e;for(;;){if(t.getRight()===null)return t!==e?t:null;t=t.getRight()}}};var sI=/^[a-zA-Z]+(\d+)$/;function Qy(e){let t=e.match(sI);return t?Number(t[1]):null}function ji(e){if(!e||typeof e!="string")return e;let t=e.match(/[a-zA-Z]+\d+/g);return t&&t.length===2&&t.join("")===e?t.join("-"):e}function qs(e){return e&&typeof e=="number"&&!isNaN(e)?-e:e}function XF(e,t){let i=[];for(let r=0;r<e.length;r+=2){let n={x:e[r],y:t?qs(e[r+1]):e[r+1]};i.push(n)}return i}function vo(e,t){return JSON.stringify([t,e])}function Kh(e){try{let t=JSON.parse(e);return typeof t=="string"?e:t[1]}catch{return e}}function qv(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var WF=(e=>(e.META="META",e.CANVAS="CANVAS",e.GROUP="GROUP",e.POLY="POLY",e.STRING="STRING",e.AUX_LINE="AUXLINE",e.DIMENSION="DIMENSION",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e))(WF||{}),qF=(e=>(e.META="META",e.CANVAS="CANVAS",e.LAYER="LAYER",e.LAYER_PHYS="LAYER_PHYS",e.ACTIVE_LAYER="ACTIVE_LAYER",e.PARTITION="PARTITION",e.NET="NET",e.PRIMITIVE="PRIMITIVE",e.GROUP="GROUP",e.SILK_OPTS="SILK_OPTS",e.PREFERENCE="PREFERENCE",e.VIA="VIA",e.PAD="PAD",e.LINE="LINE",e.ARC="ARC",e.OBJ="OBJ",e.EQLEN_GRP="EQLEN_GRP",e.POLY="POLY",e.FILL="FILL",e.LAYER_FILL="LAYER_FILL",e.REGION="REGION",e.POUR="POUR",e.POURED="POURED",e.IMAGE="IMAGE",e.TEARDROP="TEARDROP",e.FPC_FILL="FPC_FILL",e.SHELL="SHELL",e.CREASE="CREASE",e.SHELLCUT="SHELLCUT",e.SHELL_ENTITY="SHELL_ENTITY",e.BOSS="BOSS",e.STRING="STRING",e.ATTR="ATTR",e.DIMENSION="DIMENSION",e.COMPONENT="COMPONENT",e.PAD_NET="PAD_NET",e.RULE_TEMPLATE="RULE_TEMPLATE",e.RULE="RULE",e.RULE_SELECTOR="RULE_SELECTOR",e.PANELIZE="PANELIZE",e.BOARD="BOARD",e.X_SIGNALS_GROUP="X_SIGNAL_GROUP",e.X_SIGNALS="X_SIGNALS",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e))(qF||{}),JF=(e=>(e.META="META",e.CANVAS="CANVAS",e.GROUP="GROUP",e.ATTR="ATTR",e.LINE="LINE",e.WIRE="WIRE",e.BUS="BUS",e.TEXT="TEXT",e.POLY="POLY",e.CIRCLE="CIRCLE",e.ARC="ARC",e.BUSENTRY="BUSENTRY",e.RECT="RECT",e.MASK_REGION="MASK_REGION",e.PIN="PIN",e.OBJ="OBJ",e.COMPONENT="COMPONENT",e.PART="PART",e.ELLIPSE="ELLIPSE",e.BEZIER="BEZIER",e.TABLE="TABLE",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e.NG_SETTING="NG_SETTING",e))(JF||{}),KF=["PARTITION","VIA","PAD","LINE","ARC","OBJ","POLY","FILL","REGION","POUR","POURED","IMAGE","TEARDROP","FPC_FILL","SHELL","CREASE","SHELLCUT","SHELL_ENTITY","BOSS","STRING","ATTR","DIMENSION","COMPONENT"],Gre=Em(h0()),$F=(e=>(e.SOLID="SOLID",e.SHORT_DASH="SHORT_DASH",e.DOT="DOT",e.DOT_DASH="DOT_DASH",e))($F||{}),ZF=(e=>(e.PRINT="PRINT",e.COVER="COVER",e.PRINT_AND_COVER="PRINT&COVER",e))(ZF||{}),QF=(e=>(e.LEFT="LEFT",e.CENTER="CENTER",e.RIGHT="RIGHT",e))(QF||{}),eG=(e=>(e.TOP="TOP",e.MIDDLE="MIDDLE",e.BOTTOM="BOTTOM",e))(eG||{}),tG=(e=>(e.LEFT_BOTTOM="LEFT_BOTTOM",e.CENTER_BOTTOM="CENTER_BOTTOM",e.RIGHT_BOTTOM="RIGHT_BOTTOM",e.LEFT_MIDDLE="LEFT_MIDDLE",e.CENTER_MIDDLE="CENTER_MIDDLE",e.RIGHT_MIDDLE="RIGHT_MIDDLE",e.LEFT_TOP="LEFT_TOP",e.CENTER_TOP="CENTER_TOP",e.RIGHT_TOP="RIGHT_TOP",e))(tG||{}),iG=(e=>(e.NONE="NONE",e.SOLID="SOLID",e.GRID="GRID",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e.RHOMBIC="RHOMBIC",e.LEFT_SLASH_LINE="LEFT_SLASH_LINE",e.RIGHT_SLASH_LINE="RIGHT_SLASH_LINE",e))(iG||{}),rG=(e=>(e.NONE="NONE",e.CLOCK="CLOCK",e.INVERTED="INVERTED",e.INVERTED_CLOCK="INVERTED_CLOCK",e))(rG||{}),nG=(e=>(e.NONE="NONE",e.GRID="GRID",e.OUTLETS="OUTLETS",e))(nG||{}),sG=(e=>(e.NONE="NONE",e.PUSH="PUSH",e.SURROUND="SURROUND",e.OBSTRUCT="OBSTRUCT",e.SURROUND_AND_PUSH="SURROUND&PUSH",e))(sG||{}),aG=(e=>(e.ELLIPSE="ELLIPSE",e.RECT="RECT",e.OVAL="OVAL",e.POLYGON="POLYGON",e))(aG||{}),oG=(e=>(e.ROUND="ROUND",e.RECT="RECT",e.SLOT="SLOT",e))(oG||{}),lG=(e=>(e.SOLID="SOLID",e.GRID_LINE="GRID_LINE",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e))(lG||{}),cG=(e=>(e.ALL="ALL",e.PAD="PAD",e.VIA="VIA",e))(cG||{}),uG=(e=>(e.NONE="NONE",e.SINGLE="SINGLE",e.ALL="ALL",e))(uG||{}),hG=(e=>(e.OPTIMIZA_OPEN="OPTIMIZA_OPEN",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(hG||{}),dG=(e=>(e.OPTIMIZA_STRONG="OPTIMIZA_STRONG",e.OPTIMIZA_WEAK="OPTIMIZA_WEAK",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(dG||{}),pG=(e=>(e.L45="L45",e.L90="L90",e.L="L",e.R45="R45",e.R90="R90",e.R="R",e))(pG||{}),fG=(e=>(e.NORMAL="NORMAL",e.BLIND="BLIND",e.SUTURE="SUTURE",e))(fG||{}),mG=(e=>(e.NORMAL="NORMAL",e.TEST="TEST",e.MARKER="MARKER",e))(mG||{}),gG=(e=>(e.DIVERGENCE="DIVERGENCE",e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(gG||{}),yG=(e=>(e.DOT="DOT",e.CENTER="CENT",e))(yG||{}),bG=(e=>(e.NORMAL="NORMAL",e.BOARD_OUTLINE="BOARD_OUTLINE",e))(bG||{}),xG=(e=>(e.SOLID="SOLID",e.GRID="GRID",e.PLANE="PLANE",e))(xG||{}),EG=(e=>(e.PROHIBIT="PROHIBIT",e.CONSTRAINT="CONSTRAINT",e))(EG||{}),SG=(e=>(e.COMPONENT="COMPONENT",e.VIA="VIA",e.TRACK="TRACK",e.FILL="FILL",e.COPPER="COPPER",e.PLANE="PLANE",e))(SG||{}),wG=(e=>(e.PI="Polyimide",e.FR4="FR4",e.STEEL_SHEET="Stainless Steel",e.M3_DOUBLE_SIDED_TAPE="3M Tape",e.EMI_SHIELDING_FILM="EMI Shielding Film",e))(wG||{}),vG=(e=>(e.PUSH_COVER="DRAWER",e.UPPER_LOWER_SHELLS="T&B",e))(vG||{}),TG=(e=>(e.X_AXIS_POSITIVE="X_AXIS_POSITIVE",e.X_AXIS_NEGATIVE="X_AXIS_NEGATIVE",e.Y_AXIS_POSITIVE="Y_AXIS_POSITIVE",e.Y_AXIS_NEGATIVE="Y_AXIS_NEGATIVE",e))(TG||{}),IG=(e=>(e.SLOT="SLOT",e.ENTITY="ENTITY",e))(IG||{}),AG=(e=>(e.AUTO="AUTO",e.UPPER_SHELLS="UPPER_SHELLS",e.LOWER_SHELLS="LOWER_SHELLS",e))(AG||{}),CG=(e=>(e.OUTLINE="OUTLINE",e.SCREW_PILLAR="SCREW_PILLAR",e.ENTITY="ENTITY",e))(CG||{}),DG=(e=>(e.M2="M2",e.M3="M3",e.M4="M4",e.M5="M5",e.M6="M6",e))(DG||{}),_G=(e=>(e.LENGTH="LENGTH",e.RADIUS="RADIUS",e.ANGLE="ANGLE",e))(_G||{}),PG=(e=>(e.MIL="mil",e.INCH="inch",e.CM="cm",e.MM="mm",e))(PG||{}),LG=(e=>(e.SAFE="SAFE",e.OTHER="OTHER",e.TRACK="TRACK",e.BLIND="BLIND",e.RADIUS="RADIUS",e.PLANE="PLANE",e.COPPER="COPPER",e.PASTE="PASTE",e.SOLDER="SOLDER",e.DIFFER_ENTAIL="DIFFER_ENTAIL",e.NET_LENGTH="NET_LENGTH",e.AUTO_ROUTER="AUTO_ROUTER",e.NET_LENGTH_TOLERANCE="NET_LENGTH_TOLERANCE",e))(LG||{}),OG=(e=>(e.NORMAL="NORMAL",e.DEFAULT="DEFAULT",e))(OG||{}),RG=(e=>(e.ALL="ALL",e.LAYERED="LAYERED",e))(RG||{}),NG=(e=>(e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(NG||{}),MG=(e=>(e.FORTY_FIVE="L45",e.NINETY="L90",e.NINETY_ARC="A90",e))(MG||{}),BG=(e=>(e.LESS="LESS",e.MID="MID",e.MORE="MORE",e))(BG||{}),kG=(e=>(e.SPEED_FIRST="SPEED_FIRST",e.COMPLETION_FIRST="COMPLETION_FIRST",e))(kG||{}),FG=(e=>(e.DesignRule="DesignRule",e.Board="Board",e.SlotRegion="SlotRegion",e.ProhibitedRegion="ProhibitedRegion",e.ConstraintRegion="ConstraintRegion",e.Component="Component",e.Track="Track",e.TestPoint="TestPoint",e.Pad="Pad",e.Via="Via",e.SutureHole="SutureHole",e.Text="Text",e.ColorfulImage="ColorfulImage",e.Image="Image",e.FPCStiffener="FPCStiffener",e.Dimension="Dimension",e.CopperRegion="CopperRegion",e.FillRegion="Fill Region",e.Line="Line",e.Teardrop="Teardrop",e.D3Shell="D3Shell",e))(FG||{}),GG=Em(GF());function CT(e,t,i,r,n,s,a,o){return JSON.stringify([e||"",t||"",i,r,n?1:0,s?1:0,a?1:0,o])}function UG(e){let t=JSON.parse(e);return{text:t[0],fontFamily:t[1],fontSize:t[2],thickness:t[3],bold:!!t[4],italic:!!t[5],reverse:!!t[6],expansion:t[7]}}function rE(e){return GG.default.SHA256(e).toString()}function YG(e,t){let i=[],r=[],n={};Mx(e,(c,u)=>{let h=JSON.parse(c);if(h.type==="DOCHEAD"||h.type==="META"||h.type==="META_CREATE"||h.type==="META_MODIFY"||h.type==="ELE_PLACEHOLDER"||h.type==="ELE_PLACEHOLDER"||h.type==="ELE_PLACEHOLDER")return;let{id:d}=h;n[d]=Object.assign(h,{data:u})});let s={};Mx(t,(c,u="")=>{let h=JSON.parse(c);if(h.type==="BLOB")i.push(c+"||"+u);else if(h.type==="FONT")r.push(c+"||"+u);else{if(h.type==="DOCHEAD"||h.type==="META_MODIFY")return;let{id:d}=h;s[d]=Object.assign(h,{data:u})}});let a={},o={},l={};for(let c in n)if(!s.hasOwnProperty(c))o[c]=n[c];else{let{ticket:u}=n[c],{type:h,data:d,client:p}=s[c];a[c]={type:h,ticket:u,data:d,client:p},delete s[c]}for(let c in s){let{type:u,data:h,ticket:d,client:p}=s[c];l[c]={type:u,data:h,ticket:d,client:p}}return{delete:o,cover:a,add:l,blobs:i,fonts:r}}function Jv(e,t,i){let{docType:r,uuid:n,client:s,updateTime:a,version:o,user:l,ticket:c}=i,u=[wp(r,s,n,a,o,l,c)],{delete:h,cover:d,add:p,blobs:f,fonts:m}=YG(e,t);for(let g in h){let{ticket:b,type:y,client:E}=h[g];u.push(To(y,b+1,g,"",E))}for(let g in d){let{type:b,ticket:y,data:E,client:S}=d[g];u.push(To(b,y+1,g,E,S))}for(let g in p){let{type:b,ticket:y,data:E,client:S}=p[g];u.push(To(b,y,g,E,S))}return f.length&&(u.push(wp("BLOB",s,"BLOB",a,o,l,c)),u=u.concat(f)),m.length&&(u.push(wp("FONT",s,"FONT",a,o,l,c)),u=u.concat(m)),u.join(`|
`)}function VG(e,t){return e.ticket===t.ticket?e.client===t.client?e.id===t.id?0:e.id<t.id?-1:1:e.client<t.client?-1:1:e.ticket<t.ticket?-1:1}var HG=class{constructor(e=1){this.startNum=e,this.orderLists={},this.idOrderLists={},this.cbArr=new Array,this.maxNum={}}orderChange(e){this.cbArr.push(e)}setOrderNum(e,t,i,r,n=1){if(n<1)throw new Error("step must be greater than 0");let s=qv(this.orderLists,t,()=>new zF(VG)),a=qv(this.maxNum,t,()=>this.startNum-1),o=qv(this.idOrderLists,t,()=>new Map),l=o.get(e);if(l){if(l.ticket<=i)return;s.remove(l),a-=l.step}let c={id:e,ticket:i,num:0,client:r,step:n};o.set(e,c),s.insert(c),a+=n;let u=a,h=0;s.backwardTraverse(d=>(h++,d.num=u,this.cbArr.forEach(p=>p(d.id,t,d.num)),u-=d.step,d!==c)),this.maxNum[t]=a,h>1e4&&(console.log("------------------ notify --------",c,"height: ",s.getHeight(),"total: ",s.getSize(),"notifies: ",h),console.log("------------------ all --------"))}getOrderNum(e,t){var i,r,n,s;return(s=(n=(r=(i=this.idOrderLists)==null?void 0:i[t])==null?void 0:r.get)==null?void 0:n.call(r,e))==null?void 0:s.num}getMaxNum(e){var t;return((t=this.orderLists[e])==null?void 0:t.getSize())||0}clearNum(){for(let e in this.idOrderLists)this.idOrderLists[e].clear(),delete this.idOrderLists[e];for(let e in this.orderLists)delete this.orderLists[e]}},jG=class{constructor(e,t=1,i=[]){this.consistencyManager=e,this.startNum=t,this.needOrderType=i,this.initIng=!1,this.allOrderNum={},this.maxNum={},this.consistencyManager.onChange((r,n,s,a,o,l,c,u,h,d,p,f)=>{try{if(this.calculation)if(a==="ELE_PLACEHOLDER"){let m=s?JSON.parse(s):null;m&&this.calculation.setOrderNum(n,m.dataType,c!=null?c:l,o,m.max)}else this.calculation.setOrderNum(n,a,c!=null?c:l,o);this.onParseLine(n,a,s?JSON.parse(s):null,o,l,u,f)}catch(m){console.error(m)}})}initCalculation(){this.calculation=new HG(this.startNum)}setIsInit(e){this.initIng=e}setNeedNum(e){this.needNum=e}setOrderNum(e,t,i){this.needNum&&this.needOrderType&&this.needOrderType.includes(i)&&t!==void 0&&(this.allOrderNum[e]=t,this.setMaxNum(i,t))}deleteOrderNum(e){delete this.allOrderNum[e]}getOrderNum(e){return this.allOrderNum[e]}setMaxNum(e,t,i){(i||this.maxNum[e]===void 0||this.maxNum[e]<t)&&(this.maxNum[e]=t)}getMaxNum(e){return this.maxNum[e]===void 0&&(this.maxNum[e]=this.startNum-1),++this.maxNum[e]}};function oO(e){switch(e=String(e),e){case"1":return"SAFE";case"2":return"OTHER";case"3":return"TRACK";case"4":return"BLIND";case"5":return"RADIUS";case"6":return"PLANE";case"7":return"COPPER";case"8":return"PASTE";case"9":return"SOLDER";case"10":return"DIFFER_ENTAIL";case"11":return"NET_LENGTH";case"12":return"AUTO_ROUTER";case"13":return"NET_LENGTH_TOLERANCE"}return e}function tm(e){if(!e)return{};let t=["1","2","3","4","5","6","7","8","9","10","11","12","13"];for(let i of t)if(e.hasOwnProperty(i)){let r=e[i];delete e[i],e[oO(i)]=r}return e}var WP=class{constructor(){this.init=!1,this.defaultSafeData=null,this.defaultCopperSpace=null,this.defaultInnerSpace=null,this.copperChangeMap=new Map,this.innerChangeMap=new Map}addDefaultSafeSpaceData(e){this.init=!0,this.defaultSafeData=e}addDefaultCopperSpace(e,t){this.defaultCopperSpace={netClearance:e,boardClearance:t}}addDefaultInnerSpace(e,t){this.defaultInnerSpace={netClearance:e,boardClearance:t}}getNewDefaultData(e,t){if(e&&this.defaultSafeData==null||!e&&this.defaultInnerSpace==null)return null;let i=e?this.copperChangeMap.get(t):this.innerChangeMap.get(t);if(i==null)return null;let{netClearance:r,boardClearance:n}=i,s=this.defaultSafeData.safeSpacing[0].content,a=new Array(s.length);for(let o=0;o<s.length;o++)a[o]=Array.from(s[o]);return this.updateSafeData(a,r,n),a}fixSafeData(e){if(this.defaultCopperSpace!=null)for(let t of e.safeSpacing)this.updateSafeData(t.content,this.defaultCopperSpace.netClearance,this.defaultCopperSpace.netClearance)}updateSafeData(e,t,i){for(let r=0;r<e.length;r++){let n=e[r];for(let s=0;s<n.length;s++)r==7?s==11||s==8?n[s]=i:n[s]=t:s==7&&(r==11||r==8?n[s]=i:n[s]=t)}}addCopper2SafeChangeMap(e,t,i,r,n){this.copperChangeMap.set(e,{name:t,isDefault:i,netClearance:r,boardClearance:n})}addInner2SafeChangeMap(e,t,i,r,n){this.innerChangeMap.set(e,{name:t,isDefault:i,netClearance:r,boardClearance:n})}getSafeName4Copper(e){var t;return(t=this.copperChangeMap.get(e))==null?void 0:t.name}getSafeName4Plane(e){var t;return(t=this.innerChangeMap.get(e))==null?void 0:t.name}getDefaultCopper(){for(let[,e]of this.copperChangeMap)if(e.isDefault)return e.name;return null}getDefaultPlane(){for(let[,e]of this.innerChangeMap)if(e.isDefault)return e.name;return null}};function qP(e,t){let i=e,r={TWO_LAYERS_BOARD:"JLCPCB Capability(Two Layers Board)",SINGLE_LAYER_BOARD:"JLCPCB Capability(Single Layer Board)",MULTIPLE_LAYERS_BOARD:"JLCPCB Capability(Multiple Layers Board)",HIGH_FREQUENCY_BOARD:"JLCPCB Capability(High Frequency Board)",ALUMINUM_SUBSTRATE_BOARD:"JLCPCB Capability(Aluminum Substrate Board)",COPPER_SUBSTRATE_BOARD:"JLCPCB Capability(Copper Substrate Board)"};if(i.length==8){Object.values(r).includes(t)&&(i[4][0]=11.811,i[5][4]=11.811),i.splice(1,0,i[1].slice(0));for(let s=2;s<i.length;s++)i[s].splice(1,0,i[s][1]);i.push([].concat(i[1][0],i.slice(1).map(s=>s[1])))}i[1].push(i[1][i[1].length-1]),i.splice(3,0,[...i[1]]),i.splice(4,0,[...i[2]]),i[1].pop();for(let s=5;s<i.length;s++)i[s].splice(3,0,i[s][1]),i[s].splice(4,0,i[s][2]);i[3][3]=i[1][1],i[4][3]=i[2][1],i[4][4]=i[2][2];let n=6;i.splice(7,0,new Array(7).fill(n));for(let s=7;s<i.length;s++)i[s].splice(7,0,n);return i}function zG(e,t){let i=e[0],r=e[1],n=[],s="ALL";if(r instanceof Array){let a=qP(r,t);n.push({layerId:1,isOpen:!0,content:a})}else{for(let a in r){let o=r[a],l=qP(o,t);n.push({layerId:+a,isOpen:!0,content:l})}Object.keys(r).length>1&&(s="LAYERED")}return{unit:i,isForAll:s,safeSpacing:n}}function XG(e){let t=e[0],i=e[1],r=e[2];isNaN(r)&&(r=0);let n=e[3];return isNaN(n)&&(n=11.8),{unit:t,deviceClearance:i,thru2SmdClearance:r,holeClearance:n}}function WG(e){let t=e[0],i=e[1],r=!0,n=[];if(i instanceof Object)for(let s in i){let a=i[s];n.push({layerId:+s,stroMin:a[0],stroDef:a[1],stroMax:a[2]})}else n.push({layerId:1,stroMin:e[1],stroDef:e[2],stroMax:e[3]});return{unit:t,track:{isOpen:r,content:n}}}function qG(e){return{unit:e[0],netLenMin:e[1],netLenMax:e[2]}}function JG(e){return{unit:e[0],netLengthTolerance:e[1]}}function KG(e){let t=e[0],i=e[1],r=!0,n=[],s=[],a=0;if(i instanceof Object)for(let o in i){let l=i[o],{stroke:c,spacing:u,lenTolerMax:h}=l;n.push({layerId:+o,stroMin:c[0],stroDef:c[1],stroMax:c[2]}),s.push({layerId:+o,spacMin:u[0],spacDef:u[1]}),a=h}else n.push({layerId:1,stroMin:e[1],stroDef:e[2],stroMax:e[3]}),s.push({layerId:1,spacMin:e[4],spacDef:e[5]}),a=e[7];return{unit:t,stroWidth:{isOpen:r,content:n},spacing:{isOpen:r,content:s},differPairLenTolerMax:a}}function $G(e){let t=new Array;for(let i of e){let r=+i[1],n=+i[2];isNaN(r)||r<=0||isNaN(n)||n<=0||r===n||r===1&&n===2||r===2&&n===1||t.push({name:i[0],staLayerId:r,endLayerId:n,viaSizeRule:i[3]})}return{blinds:{content:t}}}function ZG(e){return{unit:e[0],minRadius:e[1],defRadius:e[2],maxRadius:e[3],minInner:e[4],defInner:e[5],maxInner:e[6]}}function QG(e){let t=[{layerId:1,connType:pm(e[7]!==void 0?e[7]:e[3]),spoWidth:e[8]!==void 0?e[8]:e[4],spoSpac:e[9]!==void 0?e[9]:e[5],spoAng:e[10]?e[10]:e[6]}];return{unit:e[0],mulPad:{isOpen:!0,content:t}}}function eU(e){let t=[{layerId:1,connType:pm(e[3]),spoWidth:e[4],spoSpac:e[5],spoAng:e[6]}],i=[{layerId:1,connType:Number(e[7])?"NON_CONNECT":"DIRECT"}],r=[{layerId:1,connType:pm(e[8]!==void 0?e[8]:e[3]),spoWidth:e[9]!==void 0?e[9]:e[4],spoSpac:e[10]!==void 0?e[10]:e[5],spoAng:e[11]?e[11]:e[6]}];return{unit:e[0],sglPad:{isOpen:!0,content:t},mulPad:{isOpen:!0,content:r},track:{isOpen:!0,content:i}}}function tU(e){return{unit:e[0],padTopExpan:e[1],padBotExpan:e[2],testPointTopExpan:e[3]?e[3]:-1e3,testPointBotExpan:e[4]?e[4]:-1e3}}function iU(e){return{unit:e[0],padTopExpan:e[1],padBotExpan:e[2],viaTopExpan:e[3],viaBotExpan:e[4],testPointTopExpan:e[5]?e[5]:2,testPointBotExpan:e[6]?e[6]:2}}function rU(e){function t(n){switch(n=n&&Number(n),n){case 0:return"L45";case 1:return"L90";case 2:return"A90";default:return"L45"}}function i(n){switch(n=n&&Number(n),n){case 0:return"LESS";case 1:return"MID";case 2:return"MORE";default:return"LESS"}}function r(n){switch(n=n&&Number(n),n){case 0:return"SPEED_FIRST";case 1:return"COMPLETION_FIRST";default:return"COMPLETION_FIRST"}}return{routingCorner:t(e[0]),isKeep:!!e[1],viaQuantity:i(e[2]),routingEffectPriority:r(e[3]),layers:e[5],ignoreNets:e[6]}}function pm(e){switch(e=e&&Number(e),e){case 0:return"DIVERGENCE";case 1:return"DIRECT";case 2:return"NON_CONNECT";default:return null}}function nU(e,t){let i=t;switch(e){case"SAFE":{let r=t;if(r.isForAll=r.isForAll?"LAYERED":"ALL",r.safeSpacing)for(let n of r.safeSpacing)n.isOpen=!!n.isOpen;i=r;break}case"OTHER":break;case"TRACK":{let r=t;r!=null&&r.track&&(r.track.isOpen=!!r.track.isOpen),i=r;break}case"NET_LENGTH":break;case"NET_LENGTH_TOLERANCE":break;case"DIFFER_ENTAIL":{let r=t;r!=null&&r.stroWidth&&(r.stroWidth.isOpen=!!r.stroWidth.isOpen),r!=null&&r.spacing&&(r.spacing.isOpen=!!r.spacing.isOpen),i=r;break}case"BLIND":break;case"RADIUS":break;case"PLANE":{let r=t;if(r!=null&&r.mulPad&&(r.mulPad.isOpen=!!r.mulPad.isOpen),r.mulPad&&r.mulPad.content)for(let n of r.mulPad.content)n.connType=pm(n.connType);i=r;break}case"COPPER":{let r=t;if(r!=null&&r.sglPad&&(r.sglPad.isOpen=!!r.sglPad.isOpen),r!=null&&r.mulPad&&(r.mulPad.isOpen=!!r.mulPad.isOpen),r!=null&&r.track&&(r.track.isOpen=!!r.track.isOpen),r.track&&r.track.content&&(r.track.content=r.track.content.map(n=>(n.connType=Number(n.connType)?"NON_CONNECT":"DIRECT",n))),r.sglPad&&r.sglPad.content)for(let n of r.sglPad.content)n.connType=pm(n.connType);if(r.mulPad&&r.mulPad.content)for(let n of r.mulPad.content)n.connType=pm(n.connType);i=r;break}case"PASTE":break;case"SOLDER":break;case"AUTO_ROUTER":break}return i}function sU(e,t,i,r,n,s){if(!(r instanceof Array))return nU(e,r);let a,o=!1;switch(i&&(i==="NORMAL"?o=!1:i==="DEFAULT"&&(o=!0)),e){case"SAFE":{a=zG(r,s),o&&n.addDefaultSafeSpaceData(a);break}case"OTHER":{a=XG(r);break}case"TRACK":{a=WG(r);break}case"NET_LENGTH":{a=qG(r);break}case"NET_LENGTH_TOLERANCE":{a=JG(r);break}case"DIFFER_ENTAIL":{a=KG(r);break}case"BLIND":{a=$G(r);break}case"RADIUS":{a=ZG(r);break}case"PLANE":{let l=r[1],c=r[2];o&&n.addDefaultInnerSpace(l,c),n.addInner2SafeChangeMap(t,"Plane_"+t,o,l,c),a=QG(r);break}case"COPPER":{let l=r[1],c=r[2];o&&n.addDefaultCopperSpace(l,c),n.addCopper2SafeChangeMap(t,"Copper_"+t,o,l,c),a=eU(r);break}case"PASTE":{a=tU(r);break}case"SOLDER":{a=iU(r);break}case"AUTO_ROUTER":{a=rU(r);break}}return a}function aU(e,t,i,r){if(!r.init)return null;function n(s,a){let o=s?"Copper_":"Plane_",l=["RULE"];l[1]="SAFE",l[2]=o+t,l[3]=0;let c=a.getNewDefaultData(s,t);return c==null?null:(l[4]={unit:a.defaultSafeData.unit,isForAll:"ALL",safeSpacing:[{layerId:1,isOpen:!0,content:c}]},l)}switch(e){case"SAFE":return r.fixSafeData(i),null;case"PLANE":return n(!1,r);case"COPPER":return n(!0,r);default:return null}}function oU(e,t,i,r){if(!r.init)return{ruleKeyValue:i};let n=e[0],s,a;if(t==4){if(n==="NET_CLASS"||n==="NET"){for(let o in i)String(o)==="COPPER"&&(s={COPPER:r.getSafeName4Copper(i[o])}),String(o)==="PLANE"&&(a={PLANE:r.getSafeName4Plane(i[o])});e[1]==""?(s!=null&&s.COPPER||(s={COPPER:"default"}),a!=null&&a.PLANE||(a={PLANE:"default"})):(s!=null&&s.COPPER||(s={COPPER:r.getDefaultCopper()}),a!=null&&a.PLANE||(a={PLANE:r.getDefaultPlane()}))}}else for(let o in i){if(String(o)==="COPPER"){let l=i[o],c=r.getSafeName4Copper(l);if(c==null&&l=="default"&&(c=r.getDefaultCopper()),c==null)continue;s={COPPER:c}}if(String(o)==="PLANE"){let l=i[o],c=r.getSafeName4Plane(l);if(c==null&&l=="default"&&(c=r.getDefaultPlane()),c==null)continue;a={PLANE:c}}}return{ruleKeyValue:i,copperRuleValue:s,innerPlaneRuleValue:a}}function lO(e,t){let i=e.length,r=0;for(;r<i;){let n=e.indexOf(`
`,r);n<0&&(n=i);let s=e.substring(r,n);try{if(t(s)===!1)break}catch(a){console.error(a)}r=n+1}}function lU(e){let t={};return lO(e,i=>{if(i.startsWith('["PAD"')){let r=JSON.parse(i);t[r[5]]||(t[r[5]]=[]),t[r[5]].push(r[1])}}),t}var aI=class{parseFull(e){lO(e,t=>this.onParseLine(JSON.parse(t))),this.onParseEnd()}},cU=class extends aI{constructor(e={},t={},i=[],r=[],n=!1){super(),this.deviceName=e,this.footprintName=t,this.footprints=i,this.devices=r,this.footprintIsConnectDevice=n,this.fontCache=[],this.poured={},this.curPartition="",this.eQLenData={},this.eQLenSort=1,this.cache={},this.components={},this.errorIds={},this.dimension={},this.connects={},this.specialColors={},this.reuseBlock={},this.panelize={data:[],stamp:{h:null,v:null},size:{h:null,v:null}},this.layerPhys=0,this.fac=new WP,this.rules=[],this.ruleSelectors=[],this.ruleTemplateName="",this.layerFill={},this.idsSet=new Set,this.oldId={},this.cachePadNet={},this.creaseIds=[],this.stringId={},this.substrateLayer=new Set,this.layerPhysCache=[],this.randomUuid=0,this.padNumId={},this.componentPadNum={}}getOldId(e){var t;return(t=this.oldId[e])!=null?t:e}handConnect(){for(let e of this.creaseIds)if(this.connects[e])for(let t of this.connects[e])this.connects[t]?this.connects[t].push(e):this.connects[t]=[e]}getConnect(e){return this.connects[e]||[]}transRuleType(e){return oO(e)}transRuleStatus(e){switch(e=e&&Number(e),e){case 0:return"NORMAL";case 1:return"DEFAULT";default:return"NORMAL"}}transGridType(e){switch(e=e&&Number(e),e){case 0:return"NONE";case 1:return"GRID";case 2:return"OUTLETS";default:return"NONE"}}transLayerStatus(e){e=e&&Number(e);let t=!1,i=!1,r=!1;return e!=null&&!isNaN(e)?(e>=4&&(r=!0,e-=4),e>=2&&(i=!0,e-=2),e===1&&(t=!0)):t=!0,{use:t,show:i,locked:r}}transRoutingMode(e){switch(e=e&&Number(e),e){case 0:return"NONE";case 1:return"PUSH";case 2:return"SURROUND";case 3:return"OBSTRUCT";case 4:return"SURROUND&PUSH";default:return"NONE"}}transPadDef(e){switch(e==null?void 0:e[0]){case"ELLIPSE":return{padType:"ELLIPSE",width:e[1],height:e[2]};case"RECT":return{padType:"RECT",width:e[1],height:e[2],radius:e[3]};case"OVAL":return{padType:"OVAL",width:e[1],height:e[2]};case"POLYGON":case"POLY":return{padType:"POLYGON",path:e[1]};default:return null}}transHoleDef(e){return e?{holeType:e[0],width:e[1],height:e[2]}:null}transPourDef(e){function t(i){switch(i=i&&Number(i),i){case 0:return"GRID_LINE";case 1:return"HORIZONTAL_LINE";case 2:return"VERTICAL_LINE";default:return"GRID_LINE"}}switch(e==null?void 0:e[0]){case"SOLID":return{pourType:"SOLID",fineness:e[1]};case"LINE":return{pourType:t(e[1]),angle:e[2],strokeWidth:e[3],strokeSpacing:e[4]};default:return null}}transUnusedPadRange(e){switch(e=e&&Number(e),e){case 1:return"ALL";case 2:return"PAD";case 3:return"VIA";default:return"VIA"}}transPathOptimization(e){switch(e=e&&Number(e),e){case 0:return"SINGLE";case 1:return"ALL";case 2:return"NONE";default:return"SINGLE"}}transViaType(e){switch(e=e&&Number(e),e){case 0:return"NORMAL";case 1:return"SUTURE";default:return"NORMAL"}}transPadFuncType(e){switch(e=e&&Number(e),e){case 0:return"NORMAL";case 1:return"TEST";case 2:return"MARKER";default:return"NORMAL"}}transPadConnect(e){switch(e=e&&Number(e),e){case 0:return"DIVERGENCE";case 1:return"DIRECT";case 2:return"NON_CONNECT";default:return null}}transFillStyle(e){switch(e=e&&Number(e),e){case 0:return"SOLID";case 1:return"GRID";case 2:return"PLANE";default:return null}}transProhibitType(e){let t=new Set;if(!e)return[];for(let i of e)switch(i=i&&Number(i),i){case 1:t.add("TRACK"),t.add("FILL");break;case 2:t.add("COMPONENT");break;case 3:t.add("VIA");break;case 4:t.add("COPPER"),t.add("PLANE");break;case 5:t.add("TRACK");break;case 6:t.add("FILL");break;case 7:t.add("COPPER");break;case 8:t.add("PLANE");break}return Array.from(t)}transPushCoverDir(e){switch(e=e&&Number(e),e){case 1:return"X_AXIS_POSITIVE";case 2:return"X_AXIS_NEGATIVE";case 4:return"Y_AXIS_POSITIVE";case 8:return"Y_AXIS_NEGATIVE";default:return"X_AXIS_POSITIVE"}}transEntityBelong(e){switch(e=e&&Number(e),e){case 0:return"AUTO";case 1:return"UPPER_SHELLS";case 2:return"LOWER_SHELLS";default:return"AUTO"}}transSlotOption(e){e=e&&Number(e);let t=e;if(!t||t<4)return["OUTLINE","SCREW_PILLAR","ENTITY"];let i=[];return t>=16&&(i.push("ENTITY"),t-=16),t>=8&&(i.push("SCREW_PILLAR"),t-=8),t>=4&&(i.push("OUTLINE"),t-=4),i}transAlignType(e){switch(e=e&&Number(e),e){case 1:return"LEFT_TOP";case 4:return"CENTER_TOP";case 7:return"RIGHT_TOP";case 2:return"LEFT_MIDDLE";case 5:return"CENTER_MIDDLE";case 8:return"RIGHT_MIDDLE";case 3:return"LEFT_BOTTOM";case 6:return"CENTER_BOTTOM";case 9:return"RIGHT_BOTTOM";default:return"LEFT_BOTTOM"}}onParseLine(e){var t;let i=e[0];switch(i){case"DOCTYPE":this.parseDocType(e);break;case"HEAD":this.parseHead(e);break;case"CANVAS":this.parseCanvas(e);break;case"LAYER":this.parseLayer(e);break;case"LAYER_PHYS":this.layerPhysCache.push(e);break;case"ACTIVE_LAYER":this.parseActiveLayer(e);break;case"NET":this.parseNet(e);break;case"PRIMITIVE":this.parsePrimitive(e);break;case"GROUP":this.parseGroup(e);break;case"SILK_OPTS":this.parseSilkOpts(e);break;case"PREFERENCE":this.parsePreference(e);break;case"CONNECT":this.parseConnect(e);break;case"ITEM_ORDER":this.parseItemOrder(e);break;case"PROP":this.parseProp(e);break;case"EQLEN_GRP":this.parseEQLenGrp(e);break;case"EQLEN":this.parseEQLen(e);break;case"FONT":this.parseFont(e);break;case"PAD_NET":{this.cachePadNet[e[1]]||(this.cachePadNet[e[1]]=[]),this.cachePadNet[e[1]].push(e);break}case"REUSE_BLOCK":this.parseReuseBlock(e);break;case"RULE_TEMPLATE":this.parseRuleTemplate(e);break;case"RULE":this.rules.push(e);break;case"RULE_SELECTOR":this.ruleSelectors.push(e);break;case"PANELIZE":this.panelize.data=e;break;case"PANELIZE_STAMP":this.parsePanelizeStamp(e);break;case"PANELIZE_SIDE":this.parsePanelizeSide(e);break;case"POURED":{this.parsePoured(e);break}case"PARTITION":i==="PARTITION"&&(this.curPartition=e[3]?e[1]:"");case"VIA":case"PAD":case"LINE":case"ARC":case"CARC":case"OBJ":case"POLY":case"FILL":if(i==="FILL"&&e[6]===2){this.layerFill[e[4]]||(this.layerFill[e[4]]=[]),this.layerFill[e[4]].push(e);break}case"REGION":case"POUR":case"IMAGE":case"TEARDROP":case"FPC_FILL":case"SHELL":case"CREASE":i==="CREASE"&&this.creaseIds.push(e[1]);case"SHELLCUT":case"SHELL_ENTITY":case"BOSS":case"STRING":if(i==="STRING"&&!/^[a-zA-Z]+\d+$/.test(e[1])){let r=e[1],n=r.split(/([0-9].*)/);if(n.length>=2){let s=n[0],a=n[1];for(let o=0;o<a.length;o++){let l=a.charCodeAt(o);s+=l}r=s}this.stringId[r]=e[1],e[1]=r}case"DIMENSION":case"COMPONENT":{let r=i==="CARC"?"ARC":i,n=Qy(e[1]);this.cache[r]||(this.cache[r]={}),n!==null&&!this.cache[r][n]?this.cache[r][n]={part:this.curPartition,value:e}:(this.errorIds[r]||(this.errorIds[r]=[]),this.errorIds[r].push({part:this.curPartition,value:e})),r==="COMPONENT"&&(this.components[e[1]]||(this.components[e[1]]={attrs:{},footprint:"",device:""}),this.components[e[1]].attrs=e[7]||{}),r==="DIMENSION"&&(this.dimension[e[1]]={attr:[]});break}case"ATTR":{if(this.docType==="PCB"&&!e[3])break;if(e[7]==="Footprint"&&(this.components[e[3]]||(this.components[e[3]]={attrs:{},footprint:"",device:""}),this.components[e[3]].footprint=e[8]),e[7]==="Device"&&(this.components[e[3]]||(this.components[e[3]]={attrs:{},footprint:"",device:""}),this.components[e[3]].device=e[8]),this.dimension[e[1]]){this.dimension[e[1]].attr=e;break}let r=Object.keys(((t=this.cache)==null?void 0:t.COMPONENT)||{}).find(s=>this.cache.COMPONENT[s].value[1]===e[3]);if(r){let s=this.cache.COMPONENT[r];s.attr||(s.attr=[]),s.attr.push({part:this.curPartition,value:e});break}let n=Qy(e[1]);this.cache[i]||(this.cache[i]={}),n!==null&&!this.cache[i][n]?this.cache[i][n]={part:this.curPartition,value:e}:(this.errorIds[i]||(this.errorIds[i]=[]),this.errorIds[i].push({part:this.curPartition,value:e}));break}default:console.warn("can not find hanlder with",e)}}async secondParseLine(e,t,i){let r=e[0];if(this.idsSet.has(e[1])||!e[1]){let n=`randomuuid${++this.randomUuid}`;if(this.oldId[n]=e[1],e[1]=n,i)for(let s of i)s[3]=n}else this.idsSet.add(e[1]);switch(r){case"DOCTYPE":case"HEAD":case"CANVAS":case"LAYER":case"LAYER_PHYS":case"ACTIVE_LAYER":case"NET":case"PRIMITIVE":case"GROUP":case"SILK_OPTS":case"PREFERENCE":case"ITEM_ORDER":case"RULE_TEMPLATE":case"RULE":case"RULE_SELECTOR":case"PANELIZE":case"PANELIZE_STAMP":case"PANELIZE_SIDE":case"CONNECT":case"EQLEN_GRP":case"EQLEN":case"FONT":case"PAD_NET":case"REUSE_BLOCK":case"PROP":break;case"PARTITION":this.parsePartition(e);break;case"VIA":this.parseVia(e);break;case"PAD":this.parsePad(e);break;case"LINE":await this.parseLine(e);break;case"ARC":this.parseArc(e);break;case"CARC":this.parseCArc(e);break;case"OBJ":this.parseObj(e);break;case"POLY":this.parsePoly(e);break;case"FILL":this.parseFill(e);break;case"REGION":this.parseRegion(e);break;case"POUR":this.parsePour(e);break;case"IMAGE":this.parseImage(e);break;case"TEARDROP":this.parseTeardrop(e);break;case"FPC_FILL":this.parseFpcFill(e);break;case"SHELL":this.parseShell(e);break;case"CREASE":this.parseCrease(e);break;case"SHELLCUT":this.parseShellCut(e);break;case"SHELL_ENTITY":this.parseShellEntity(e);break;case"BOSS":this.parseBoss(e);break;case"STRING":this.parseString(e);break;case"ATTR":this.parseAttr(e,t);break;case"DIMENSION":this.parseDimension(e);break;case"COMPONENT":this.parseComponent(e);break;default:console.warn("can not find hanlder with",e)}}onParseEnd(){for(let t of this.layerPhysCache)this.parseLayerPhys(t);this.layerPhysCache=[];for(let t of this.rules)t[1]=this.transRuleType(t[1]),t[3]=this.transRuleStatus(t[3]),t[4]=sU(t[1],t[2],t[3],t[4],this.fac,this.ruleTemplateName);if(this.fac.init){let t=Array.from(this.rules);for(let i of t){let r=aU(i[1],i[2],i[4],this.fac);r&&this.rules.push(r)}}for(let t of this.rules)this.parseRule(t);let e={};for(let t of this.ruleSelectors){let i=oU(t[1],t[2],tm(t[3]),this.fac),r=JSON.stringify(t[1]);e[r]?(t[2]&&(e[r].ruleOrder=t[2]),i.ruleKeyValue&&(e[r].ruleKeyValue=Object.assign(e[r].ruleKeyValue,i.ruleKeyValue)),(i.copperRuleValue||t[4])&&(e[r].copperValue=i.copperRuleValue||tm(t[4])),(i.innerPlaneRuleValue||t[5])&&(e[r].innerPlaneValue=i.innerPlaneRuleValue||tm(t[5]))):e[r]={ruleSelect:t[1],ruleOrder:t[2],ruleKeyValue:i.ruleKeyValue,copperValue:i.copperRuleValue||tm(t[4])||{},innerPlaneValue:i.innerPlaneRuleValue||tm(t[5])||{}}}for(let t in e)this.parseRuleSelector(e[t]);this.handConnect(),this.parseEQLenGrpFull(),this.parsePanelize(),this.parseLayerFill();for(let t in this.cache){let i=this.cache[t],r=Object.keys(i).sort((s,a)=>Number(s)-Number(a)),n=-1;for(let s of r){let a=Number(s),o=a-n-1;o>=1&&this.onPHolder(t,o),n=a,this.curPartition=i[a].part,this.secondParseLine(i[a].value,void 0,i[a].attr),i[a].attr&&i[a].attr.forEach(l=>{this.curPartition=l.part,this.secondParseLine(l.value)})}if(this.errorIds[t])for(let s of this.errorIds[t])this.curPartition=s.part,this.secondParseLine(s.value)}this.clearCache()}clearCache(){this.version=void 0,this.docType=void 0,this.curPartition="",this.eQLenData={},this.eQLenSort=1,this.cache={},this.components={},this.errorIds={},this.dimension={},this.connects={},this.specialColors={},this.reuseBlock={},this.panelize.data.length&&(this.panelize.data.length=0,this.panelize.stamp={h:null,v:null},this.panelize.size={h:null,v:null}),this.layerPhys=0,this.fac.init&&(this.fac=new WP),this.rules=[],this.ruleSelectors=[],this.ruleTemplateName="",this.layerFill={},this.idsSet.clear(),this.oldId={},this.creaseIds.length=0,this.substrateLayer.clear()}fixPolygon(e){if(e[0]=="R"){let t=parseFloat(e[3])/10,i=parseFloat(e[4])/10;e[6]=Math.min(t,i)/2*(parseFloat(e[6])||0)*10}}handleSimplePolygon(e){return!e||this.version>=1.5||this.fixPolygon(e),e}handlePolygon(e){if(this.version<1.5&&e&&e.length){if(!Array.isArray(e[0]))return this.handleSimplePolygon(e);for(let t of e)this.fixPolygon(t)}return e}parseEQLen(e){this.eQLenData[e[1]]?this.eQLenData[e[1]].pads?this.eQLenData[e[1]].pads.push(e[2]):this.eQLenData[e[1]].pads=[e[2]]:this.eQLenData[e[1]]={pads:[e[2]]}}parseEQLenGrp(e){this.eQLenData[e[1]]?(this.eQLenData[e[1]].id=e[1],this.eQLenData[e[1]].name=e[2],this.eQLenData[e[1]].sort=++this.eQLenSort):this.eQLenData[e[1]]={id:e[1],name:e[2],sort:++this.eQLenSort}}parseCanvas(e){this.onCanvas(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],this.transGridType(e[10]),this.transGridType(e[11]),e[12])}parseDocType(e){this.docType=e[1];let t=parseFloat(e[2]);this.version=t}parseHead(e){}parseLayer(e){let t=e[8];this.version<1.7&&(t=.5);let i=this.transLayerStatus(e[4]),r=Number(e[1]);if(e[2]==="SUBSTRATE"){if(this.substrateLayer.add(r),r<101)return;r<361&&(r=r+260)}this.onLayer(r,e[2],e[3],i.use,i.show,i.locked,e[5],e[6],e[7],t)}parseLayerPhys(e){let t=Number(e[1]);if(t>=101&&t<361&&this.substrateLayer.has(t))t=t+260;else if(t<101&&this.substrateLayer.has(t))return;this.onLayerPhys(t,e[2],e[3],e[4],e[5],!!e[6],++this.layerPhys)}parseActiveLayer(e){this.onActiveLayer(e[1])}parsePartition(e){this.onPartition(e[1],e[2],e[3],this.handlePolygon(e[4]))}parseNet(e){var t,i,r,n;this.onNet(e[1],(t=e[2])!=null?t:null,(i=e[3])!=null?i:null,!!e[4],(r=e[5])!=null?r:null,!!e[6],(n=e[7])!=null?n:null)}parsePrimitive(e){this.onPrimitive(e[1],!!e[2],!!e[3])}parseGroup(e){this.onGroup(e[1],e[2])}parseSilkOpts(e){this.onSilkOpts(e[1],e[2],e[3])}parsePreference(e){this.onPreference(!!e[1],e[2],!!e[3],e[4],e[5],!!e[6],this.transRoutingMode(e[7]),e[8],!!e[9],!!e[10],!!e[11],e[12],e[13],!!e[14],this.transUnusedPadRange(e[15]),e[16],this.transPathOptimization(e[17]),e[18],e[19],e[20])}parseConnect(e){this.connects[e[1]]=e[2]}parseVia(e){var t,i;this.onVia(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],this.transViaType(e[9]),(t=e[10])!=null?t:null,(i=e[11])!=null?i:null,!!e[12],e[13])}parsePad(e){var t,i,r,n,s,a,o,l,c;this.onPad(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],this.transHoleDef(e[9]),this.transPadDef(e[10]),e[11]&&(i=(t=e[11])==null?void 0:t.map(u=>({startLayer:u[0],endLayer:u[1],pad:this.transPadDef(u[2])})))!=null?i:null,e[12],e[13],e[14],!!e[15],this.transPadFuncType(e[16]),(r=e[17])!=null?r:null,(n=e[18])!=null?n:null,(s=e[19])!=null?s:null,(a=e[20])!=null?a:null,!!e[21],this.transPadConnect(e[22]),(o=e[23])!=null?o:null,(l=e[24])!=null?l:null,(c=e[25])!=null?c:null,e[26],this.getConnect(e[1]))}parseLine(e){this.onLine(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],!!e[10])}parseArc(e){this.onArc(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],!!e[11],this.specialColors[this.getOldId(e[1])])}parseCArc(e){this.onCArc(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],!!e[11],this.specialColors[this.getOldId(e[1])])}parseObj(e){this.onObj(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],!!e[10],e[11],!!e[12],this.specialColors[this.getOldId(e[1])])}parseItemOrder(e){this.itemOrder=e[1]}parseProp(e){this.specialColors[e[1]]=e[2]}parseEQLenGrpFull(){for(let e in this.eQLenData){let t=this.eQLenData[e];t.id&&this.onEQLenGrp(t.id,t.name,t.sort,t.pads||[])}this.eQLenData={},this.eQLenSort=1}parsePoly(e){this.onPoly(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],this.handleSimplePolygon(e[6]),!!e[7],this.specialColors[this.getOldId(e[1])])}parseFill(e){this.onFill(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],this.transFillStyle(e[6]),this.handlePolygon(e[7]),!!e[8],this.getConnect(e[1]),this.specialColors[this.getOldId(e[1])])}getZIndex1(e){let t=e.match(sI);return t!=null&&t.length?t[1]:null}parseLayerFill(){for(let e in this.layerFill){let t=this.layerFill[e];this.onLayerFill(Number(e),{fill:t.map(i=>{let r=this.getZIndex1(i[1]);return{id:i[1],partitionId:this.curPartition||"",groupId:i[2],locked:!!i[8],zIndex:r===null?null:Number(r),netName:i[3],width:i[5],path:this.handlePolygon(i[7]),refs:this.getConnect(i[1]),specialColor:this.specialColors[this.getOldId(i[1])]}})})}}parseRegion(e){let t=e[5],i=t&&t.includes(9)?"CONSTRAINT":"PROHIBIT";t=i?t.filter(r=>r!==9):t,this.onRegion(e[1],this.curPartition||"",e[2],e[3],e[4],this.transProhibitType(t),this.handlePolygon(e[6]),!!e[7],e[8],i)}parsePour(e){let t=e[9];this.version<=1.7&&t&&t[0]==="SOLID"&&t[1]&&(t[1]=8),this.onPour(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],this.handlePolygon(e[8]),this.transPourDef(t),!!e[10],!!e[11]),this.poured[e[1]]&&this.onPoured(e[1],this.poured[e[1]])}parsePoured(e){if(this.version<1.1){if(this.curPourId){let t={id:e[1],strokeWidth:e[2],fill:e[3],path:this.handlePolygon(e[4])};this.poured[this.curPourId]||(this.poured[this.curPourId]={pourFill:[]}),this.poured[this.curPourId].pourFill.push(t)}}else{let t={id:e[1],strokeWidth:e[3],fill:e[4],path:this.handlePolygon(e[5])};this.poured[e[2]]||(this.poured[e[2]]={pourFill:[]}),this.poured[e[2]].pourFill.push(t)}}parseImage(e){this.onImage(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],!!e[9],e[10],!!e[11],this.specialColors[this.getOldId(e[1])])}parseTeardrop(e){let t,i,r;this.version<1.2?(t=e[5],r=e[4]):(t=e[4],i=e[5],r=this.getConnect(e[1])),this.onTeardrop(e[1],this.curPartition||"",e[2],e[3],this.handleSimplePolygon(t),i!=null?i:null,r)}parseFpcFill(e){this.onFpcFill(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],this.handlePolygon(e[6]),!!e[7])}parseShell(e){let t=e[8];t&&t.Direction&&(t.Direction=this.transPushCoverDir(t.Direction)),this.onShell(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],this.handlePolygon(e[7]),t,!!e[9])}parseCrease(e){this.onCrease(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],!!e[9])}parseShellCut(e){this.onShellCut(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],this.handlePolygon(e[6]),!!e[7],this.getConnect(e[1]))}parseShellEntity(e){this.onShellEntity(e[1],this.curPartition||"",e[2],e[3],e[4],this.transEntityBelong(e[5]),this.transSlotOption(e[5]),e[6],e[7],this.handlePolygon(e[8]),!!e[9],this.getConnect(e[1]))}parseBoss(e){var t,i,r,n,s,a;this.version<1.4?this.onBoss(e[1],this.curPartition||"",e[2],e[3],e[5],e[6],(t=e[4])!=null?t:null,e[7],null,null,(i=e[8])!=null?i:null,(r=e[9])!=null?r:null,!!e[10]):this.onBoss(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],(n=e[6])!=null?n:null,e[7],e[8],e[9],(s=e[10])!=null?s:null,(a=e[11])!=null?a:null,!!e[12])}parseDimension(e){var t;let i=this.getOldId(e[1]),r=((t=this.dimension[i])==null?void 0:t.attr)||[];if(r.length){let s=this.fontCache.find(a=>a.id&&a.id===this.getOldId(r[1]));this.version<1.6&&s&&(s.text=r[8],s.fontFamily=r[11],s.fontSize=r[12]/10,s.thickness=r[13]/10,s.bold=r[15],s.italic=r[16],s.reverse=r[18],s.expansion=r[19]/10)}let n={groupId:r[2],layerId:r[4],x:r[5],y:r[6],text:r[8],fontFamily:r[11],fontSize:r[12],strokeWidth:r[13],bold:r[14],italic:r[15],origin:r[16],angle:r[17],reverse:r[18],expansion:r[19],mirror:r[20],locked:r[21],zIndex:null,specialColor:this.specialColors[this.getOldId(r[1])]};this.onDimension(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],!!e[7],e[8],!!e[9],n,this.specialColors[this.getOldId(e[1])],r[2]||"")}parseRuleTemplate(e){this.ruleTemplateName=e[1],this.onRuleTemplate(e[1])}parseRule(e){this.onRule(e[1],e[2],e[3],e[4])}parseRuleSelector(e){this.onRuleSelector(e.ruleSelect,e.ruleOrder,e.ruleKeyValue,e.copperValue,e.innerPlaneValue)}parsePanelize(){let e=this.panelize.data;e.length&&this.onPanelize(!!e[1],e[2],e[3],e[4],e[5],!!e[6],this.panelize.stamp.h,this.panelize.stamp.v,this.panelize.size.h,this.panelize.size.v)}parsePanelizeStamp(e){let t={on:!!e[2],stampHoleGroupQuantity:e[3],stampHoleDiameter:e[4],stampHoleQuantityPerGroup:e[5],stampHoleSpacing:e[6]};e[1]?this.panelize.stamp.v=t:this.panelize.stamp.h=t}parsePanelizeSide(e){let t={on:!!e[2],sideHeight:e[3],positionHoleDiameter:e[4],markDiameter:e[5],markExpansion:e[6]};e[1]?this.panelize.size.v=t:this.panelize.size.h=t}parseComponent(e){let t=this.getOldId(e[1]),i=e[7]||{},r=this.reuseBlock[t];if(r&&Object.assign(i,{"Group ID":r[2]||"","Channel ID":r[3]||""}),this.onComponent(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],i,!!e[8],this.specialColors[t]),this.cachePadNet[t])for(let n of this.cachePadNet[t])this.parsePadNet(n)}parsePadNet(e){let t=this.getOldId(e[1]);if(e[4]===void 0&&this.components[t]){let i=this.components[t].footprint;if(!i){let n=this.components[t].device;i=this.devices.find(s=>s.uuid===n).attributes.Footprint}let r=this.padNumId[i];if(!r){let n=this.footprints.find(s=>s.uuid===i);n&&(this.padNumId[i]=lU(n==null?void 0:n.dataStr),r=this.padNumId[i])}if(r&&r[e[2]]){this.componentPadNum[t]||(this.componentPadNum[t]={}),this.componentPadNum[t][e[2]]===void 0&&(this.componentPadNum[t][e[2]]=-1);let n=++this.componentPadNum[t][e[2]];e[4]=r[e[2]][n]}else e[4]=e[2]}this.onPadNet(e[1],this.curPartition||"",e[2],e[3],e[4])}parseReuseBlock(e){this.reuseBlock[e[1]]=e}getFontCache(e,t,i,r,n,s,a,o){let l;return this.version<1.6?l=this.fontCache.find(c=>c.id===e):l=this.fontCache.find(c=>i==c.fontFamily&&t==c.text&&r/10==c.fontSize&&!!a==c.reverse&&o==c.expansion&&!!n==c.bold&&!!s==c.italic&&c.path.length>0),{paths:l==null?void 0:l.path,width:l==null?void 0:l.width,height:l==null?void 0:l.height}}getTextValue(e,t,i,r,n){let s="";return e!=""&&t===""&&this.docType!="PCB"&&!n&&e!="Footprint"&&!this.footprintIsConnectDevice&&(t=`<${e}>`),i?r?s=e+":"+t:s=e:r?s=t:s="",s}getFormulaName(e,t){if(!e||!e.startsWith("="))return e;e=e.slice(1);let i=/\{([^\}]+)\}/g,r=[],n=[];for(;r=i.exec(e);)n.push(r[1]);for(let s=0;s<n.length;s++){let a=n[s],o=`{${a}!}`;t.has(a)&&(o=t.get(a)),e=e.replace(`{${a}}`,o)}return e}parseAttr(e,t){let i=e[11],r=e[12];r&&this.version<1.2&&(i=="default"||i=="")&&(r*=1.5);let n=e[7],s=e[8],a=!!e[9],o=!!e[10],l=this.getOldId(e[3]),c=s;if(n==="Device"){let h=this.deviceName[s]||s;c=this.getTextValue(n,h,a,o,l)}else if(n==="Footprint"){let h=this.footprintName[s]||s;c=this.getTextValue(n,h,a,o,l)}else if(n==="Name"){let h=new Map;if(l){let d=this.components[l];if(h.set("ID",l),Object.entries(d.attrs).forEach(p=>h.set(p[0],p[1])),d.device){let p=this.devices.find(f=>f.uuid===d.device);p&&Object.entries(p.attributes).forEach(f=>h.set(f[0],f[1]))}}c=this.getTextValue(n,this.getFormulaName(s,h),a,o,l)}else c=this.getTextValue(n,s,a,o,l);let u=this.fontCache.find(h=>h.id&&h.id===this.getOldId(e[1]));this.version<1.6&&u&&(u.text=c,u.fontFamily=i,u.fontSize=r/10,u.thickness=e[13]/10,u.bold=e[15],u.italic=e[16],u.reverse=e[18],u.expansion=e[19]/10),this.onAttr(e[1],this.curPartition||"",e[2],l,e[4],e[5],e[6],n,s,a,o,i,r,e[13],!!e[14],!!e[15],this.transAlignType(e[16]),e[17],!!e[18],e[19],!!e[20],!!e[21],t,this.specialColors[this.getOldId(e[1])])}parseFont(e){let t;switch(this.version){case 1:case 1.1:t={id:e[1],path:e[2]};break;case 1.2:case 1.3:case 1.4:case 1.5:t={id:e[1],width:e[2],height:e[3],path:e[4]};break;default:t={text:e[1],fontFamily:e[2],fontSize:e[3],thickness:e[4],bold:!!e[5],italic:!!e[6],reverse:!!e[7],expansion:e[8],width:e[9],height:e[10],path:e[11]};break}this.fontCache.push(t)}parseString(e){var t;let[,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y]=e,E=(t=this.stringId[i])!=null?t:i;c&&this.version<1.2&&(l=="default"||l=="")&&(c*=1.5);let S=this.fontCache.find(w=>w.id&&w.id===this.getOldId(E));this.version<1.6&&S&&(S.text=o,S.fontFamily=l,S.fontSize=c/10,S.thickness=u/10,S.bold=h,S.italic=d,S.reverse=m,S.expansion=g/10),this.onString(i,this.curPartition||"",r,n,s,a,o,l,c,u,!!h,!!d,this.transAlignType(p),f,!!m,g,!!b,!!y,this.specialColors[this.getOldId(E)])}},uU=Object.create,cO=Object.defineProperty,hU=Object.getOwnPropertyDescriptor,dU=Object.getOwnPropertyNames,pU=Object.getPrototypeOf,fU=Object.prototype.hasOwnProperty,mU=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),gU=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of dU(t))!fU.call(e,n)&&n!==i&&cO(e,n,{get:()=>t[n],enumerable:!(r=hU(t,n))||r.enumerable});return e},yU=(e,t,i)=>(i=e!=null?uU(pU(e)):{},gU(t||!e||!e.__esModule?cO(i,"default",{value:e,enumerable:!0}):i,e)),bU=mU((e,t)=>{"use strict";t.exports=i,t.exports.default=i;function i(T,L,P){P=P||2;var B=L&&L.length,U=B?L[0]*P:T.length,X=r(T,0,U,P,!0),J=[];if(!X||X.next===X.prev)return J;var ne,fe,xe,ve,Fe,Ne,nt;if(B&&(X=u(T,L,X,P)),T.length>80*P){ne=xe=T[0],fe=ve=T[1];for(var je=P;je<U;je+=P)Fe=T[je],Ne=T[je+1],Fe<ne&&(ne=Fe),Ne<fe&&(fe=Ne),Fe>xe&&(xe=Fe),Ne>ve&&(ve=Ne);nt=Math.max(xe-ne,ve-fe),nt=nt!==0?32767/nt:0}return s(X,J,P,ne,fe,nt,0),J}function r(T,L,P,B,U){var X,J;if(U===N(T,L,P,B)>0)for(X=L;X<P;X+=B)J=V(X,T[X],T[X+1],J);else for(X=P-B;X>=L;X-=B)J=V(X,T[X],T[X+1],J);return J&&x(J,J.next)&&(q(J),J=J.next),J}function n(T,L){if(!T)return T;L||(L=T);var P=T,B;do if(B=!1,!P.steiner&&(x(P,P.next)||w(P.prev,P,P.next)===0)){if(q(P),P=L=P.prev,P===P.next)break;B=!0}else P=P.next;while(B||P!==L);return L}function s(T,L,P,B,U,X,J){if(T){!J&&X&&m(T,B,U,X);for(var ne=T,fe,xe;T.prev!==T.next;){if(fe=T.prev,xe=T.next,X?o(T,B,U,X):a(T)){L.push(fe.i/P|0),L.push(T.i/P|0),L.push(xe.i/P|0),q(T),T=xe.next,ne=xe.next;continue}if(T=xe,T===ne){J?J===1?(T=l(n(T),L,P),s(T,L,P,B,U,X,2)):J===2&&c(T,L,P,B,U,X):s(n(T),L,P,B,U,X,1);break}}}}function a(T){var L=T.prev,P=T,B=T.next;if(w(L,P,B)>=0)return!1;for(var U=L.x,X=P.x,J=B.x,ne=L.y,fe=P.y,xe=B.y,ve=U<X?U<J?U:J:X<J?X:J,Fe=ne<fe?ne<xe?ne:xe:fe<xe?fe:xe,Ne=U>X?U>J?U:J:X>J?X:J,nt=ne>fe?ne>xe?ne:xe:fe>xe?fe:xe,je=B.next;je!==L;){if(je.x>=ve&&je.x<=Ne&&je.y>=Fe&&je.y<=nt&&E(U,ne,X,fe,J,xe,je.x,je.y)&&w(je.prev,je,je.next)>=0)return!1;je=je.next}return!0}function o(T,L,P,B){var U=T.prev,X=T,J=T.next;if(w(U,X,J)>=0)return!1;for(var ne=U.x,fe=X.x,xe=J.x,ve=U.y,Fe=X.y,Ne=J.y,nt=ne<fe?ne<xe?ne:xe:fe<xe?fe:xe,je=ve<Fe?ve<Ne?ve:Ne:Fe<Ne?Fe:Ne,vt=ne>fe?ne>xe?ne:xe:fe>xe?fe:xe,Bt=ve>Fe?ve>Ne?ve:Ne:Fe>Ne?Fe:Ne,Oi=b(nt,je,L,P,B),Ti=b(vt,Bt,L,P,B),ze=T.prevZ,D=T.nextZ;ze&&ze.z>=Oi&&D&&D.z<=Ti;){if(ze.x>=nt&&ze.x<=vt&&ze.y>=je&&ze.y<=Bt&&ze!==U&&ze!==J&&E(ne,ve,fe,Fe,xe,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0||(ze=ze.prevZ,D.x>=nt&&D.x<=vt&&D.y>=je&&D.y<=Bt&&D!==U&&D!==J&&E(ne,ve,fe,Fe,xe,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0))return!1;D=D.nextZ}for(;ze&&ze.z>=Oi;){if(ze.x>=nt&&ze.x<=vt&&ze.y>=je&&ze.y<=Bt&&ze!==U&&ze!==J&&E(ne,ve,fe,Fe,xe,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0)return!1;ze=ze.prevZ}for(;D&&D.z<=Ti;){if(D.x>=nt&&D.x<=vt&&D.y>=je&&D.y<=Bt&&D!==U&&D!==J&&E(ne,ve,fe,Fe,xe,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0)return!1;D=D.nextZ}return!0}function l(T,L,P){var B=T;do{var U=B.prev,X=B.next.next;!x(U,X)&&I(U,B,B.next,X)&&M(U,X)&&M(X,U)&&(L.push(U.i/P|0),L.push(B.i/P|0),L.push(X.i/P|0),q(B),q(B.next),B=T=X),B=B.next}while(B!==T);return n(B)}function c(T,L,P,B,U,X){var J=T;do{for(var ne=J.next.next;ne!==J.prev;){if(J.i!==ne.i&&S(J,ne)){var fe=G(J,ne);J=n(J,J.next),fe=n(fe,fe.next),s(J,L,P,B,U,X,0),s(fe,L,P,B,U,X,0);return}ne=ne.next}J=J.next}while(J!==T)}function u(T,L,P,B){var U=[],X,J,ne,fe,xe;for(X=0,J=L.length;X<J;X++)ne=L[X]*B,fe=X<J-1?L[X+1]*B:T.length,xe=r(T,ne,fe,B,!1),xe===xe.next&&(xe.steiner=!0),U.push(y(xe));for(U.sort(h),X=0;X<U.length;X++)P=d(U[X],P);return P}function h(T,L){return T.x-L.x}function d(T,L){var P=p(T,L);if(!P)return L;var B=G(P,T);return n(B,B.next),n(P,P.next)}function p(T,L){var P=L,B=T.x,U=T.y,X=-1/0,J;do{if(U<=P.y&&U>=P.next.y&&P.next.y!==P.y){var ne=P.x+(U-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(ne<=B&&ne>X&&(X=ne,J=P.x<P.next.x?P:P.next,ne===B))return J}P=P.next}while(P!==L);if(!J)return null;var fe=J,xe=J.x,ve=J.y,Fe=1/0,Ne;P=J;do B>=P.x&&P.x>=xe&&B!==P.x&&E(U<ve?B:X,U,xe,ve,U<ve?X:B,U,P.x,P.y)&&(Ne=Math.abs(U-P.y)/(B-P.x),M(P,T)&&(Ne<Fe||Ne===Fe&&(P.x>J.x||P.x===J.x&&f(J,P)))&&(J=P,Fe=Ne)),P=P.next;while(P!==fe);return J}function f(T,L){return w(T.prev,T,L.prev)<0&&w(L.next,T,T.next)<0}function m(T,L,P,B){var U=T;do U.z===0&&(U.z=b(U.x,U.y,L,P,B)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==T);U.prevZ.nextZ=null,U.prevZ=null,g(U)}function g(T){var L,P,B,U,X,J,ne,fe,xe=1;do{for(P=T,T=null,X=null,J=0;P;){for(J++,B=P,ne=0,L=0;L<xe&&(ne++,B=B.nextZ,!!B);L++);for(fe=xe;ne>0||fe>0&&B;)ne!==0&&(fe===0||!B||P.z<=B.z)?(U=P,P=P.nextZ,ne--):(U=B,B=B.nextZ,fe--),X?X.nextZ=U:T=U,U.prevZ=X,X=U;P=B}X.nextZ=null,xe*=2}while(J>1);return T}function b(T,L,P,B,U){return T=(T-P)*U|0,L=(L-B)*U|0,T=(T|T<<8)&16711935,T=(T|T<<4)&252645135,T=(T|T<<2)&858993459,T=(T|T<<1)&1431655765,L=(L|L<<8)&16711935,L=(L|L<<4)&252645135,L=(L|L<<2)&858993459,L=(L|L<<1)&1431655765,T|L<<1}function y(T){var L=T,P=T;do(L.x<P.x||L.x===P.x&&L.y<P.y)&&(P=L),L=L.next;while(L!==T);return P}function E(T,L,P,B,U,X,J,ne){return(U-J)*(L-ne)>=(T-J)*(X-ne)&&(T-J)*(B-ne)>=(P-J)*(L-ne)&&(P-J)*(X-ne)>=(U-J)*(B-ne)}function S(T,L){return T.next.i!==L.i&&T.prev.i!==L.i&&!R(T,L)&&(M(T,L)&&M(L,T)&&F(T,L)&&(w(T.prev,T,L.prev)||w(T,L.prev,L))||x(T,L)&&w(T.prev,T,T.next)>0&&w(L.prev,L,L.next)>0)}function w(T,L,P){return(L.y-T.y)*(P.x-L.x)-(L.x-T.x)*(P.y-L.y)}function x(T,L){return T.x===L.x&&T.y===L.y}function I(T,L,P,B){var U=O(w(T,L,P)),X=O(w(T,L,B)),J=O(w(P,B,T)),ne=O(w(P,B,L));return!!(U!==X&&J!==ne||U===0&&A(T,P,L)||X===0&&A(T,B,L)||J===0&&A(P,T,B)||ne===0&&A(P,L,B))}function A(T,L,P){return L.x<=Math.max(T.x,P.x)&&L.x>=Math.min(T.x,P.x)&&L.y<=Math.max(T.y,P.y)&&L.y>=Math.min(T.y,P.y)}function O(T){return T>0?1:T<0?-1:0}function R(T,L){var P=T;do{if(P.i!==T.i&&P.next.i!==T.i&&P.i!==L.i&&P.next.i!==L.i&&I(P,P.next,T,L))return!0;P=P.next}while(P!==T);return!1}function M(T,L){return w(T.prev,T,T.next)<0?w(T,L,T.next)>=0&&w(T,T.prev,L)>=0:w(T,L,T.prev)<0||w(T,T.next,L)<0}function F(T,L){var P=T,B=!1,U=(T.x+L.x)/2,X=(T.y+L.y)/2;do P.y>X!=P.next.y>X&&P.next.y!==P.y&&U<(P.next.x-P.x)*(X-P.y)/(P.next.y-P.y)+P.x&&(B=!B),P=P.next;while(P!==T);return B}function G(T,L){var P=new C(T.i,T.x,T.y),B=new C(L.i,L.x,L.y),U=T.next,X=L.prev;return T.next=L,L.prev=T,P.next=U,U.prev=P,B.next=P,P.prev=B,X.next=B,B.prev=X,B}function V(T,L,P,B){var U=new C(T,L,P);return B?(U.next=B.next,U.prev=B,B.next.prev=U,B.next=U):(U.prev=U,U.next=U),U}function q(T){T.next.prev=T.prev,T.prev.next=T.next,T.prevZ&&(T.prevZ.nextZ=T.nextZ),T.nextZ&&(T.nextZ.prevZ=T.prevZ)}function C(T,L,P){this.i=T,this.x=L,this.y=P,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(T,L,P,B){var U=L&&L.length,X=U?L[0]*P:T.length,J=Math.abs(N(T,0,X,P));if(U)for(var ne=0,fe=L.length;ne<fe;ne++){var xe=L[ne]*P,ve=ne<fe-1?L[ne+1]*P:T.length;J-=Math.abs(N(T,xe,ve,P))}var Fe=0;for(ne=0;ne<B.length;ne+=3){var Ne=B[ne]*P,nt=B[ne+1]*P,je=B[ne+2]*P;Fe+=Math.abs((T[Ne]-T[je])*(T[nt+1]-T[Ne+1])-(T[Ne]-T[nt])*(T[je+1]-T[Ne+1]))}return J===0&&Fe===0?0:Math.abs((Fe-J)/J)};function N(T,L,P,B){for(var U=0,X=L,J=P-B;X<P;X+=B)U+=(T[J]-T[X])*(T[X+1]+T[J+1]),J=X;return U}i.flatten=function(T){for(var L=T[0][0].length,P={vertices:[],holes:[],dimensions:L},B=0,U=0;U<T.length;U++){for(var X=0;X<T[U].length;X++)for(var J=0;J<L;J++)P.vertices.push(T[U][X][J]);U>0&&(B+=T[U-1].length,P.holes.push(B))}return P}}),xU=(e=>(e[e.MIL=1]="MIL",e[e.INCH=1e3]="INCH",e[e.FT=12e3]="FT",e[e.YARD=36e3]="YARD",e[e.MILE=6336e4]="MILE",e[e.KM=3937007874e-2]="KM",e[e.M=39370]="M",e[e.DM=3937]="DM",e[e.CM=393.7]="CM",e[e.MM=39.37]="MM",e[e.UM=.039]="UM",e[e.NM=394e-7]="NM",e[e.PT=13.88888888888889]="PT",e[e.PX72=13.88888888888889]="PX72",e[e.PX96=10.416666666666666]="PX96",e[e.PX100=10]="PX100",e[e.LTSPICE=6.25]="LTSPICE",e[e.PX1=.1]="PX1",e[e.PX001=.001]="PX001",e))(xU||{}),EU=(e=>(e.MIL="mil",e.INCH="inch",e.FT="ft",e.YARD="yard",e.MILE="mile",e.KM="km",e.M="m",e.DM="dm",e.CM="cm",e.MM="mm",e.UM="um",e.NM="nm",e.PT="pt",e.PX72="px(72)",e.PX96="px(96)",e.PX100="px(100)",e))(EU||{}),JP={mil:1,inch:1e3,ft:12e3,yard:36e3,mile:6336e4,km:3937007874e-2,dm:3937,mm:39.37,um:.039,nm:394e-7,pt:13.88888888888889,"px(72)":13.88888888888889,"px(96)":10.416666666666666,"px(100)":10},Ure=(()=>{let e={};for(let t in JP)e[JP[t]]=t;return e})(),ex,Yre=(ex=class{constructor(e,t){this.ratio=e/t}wrap(e){return e*this.ratio}static convert(e,t,i){return e*t/i}},ex.ASIS=new ex(1,1),ex),tx=class{conversion(e,t,i){if(e===t)return i;let r=e+2+t;return this[r](i)}conversion1(e,t,i){let r=e+2+t,n=this[r](i);return t=="mil"?Math.round(n*10)/10:Math.round(n*1e3)/1e3}mil2mil(e){return e}mil2mm(e){return e*.0254}mil2cm(e){return e*.00254}mil2inch(e){return e/1e3}mm2mm(e){return e}mm2mil(e){let t=Math.pow(10,5);return Math.round(e*39.37007874015748*t)/t}mm2cm(e){return e/10}mm2inch(e){let t=Math.pow(10,8);return Math.round(e*.03937007874015748*t)/t}cm2mil(e){let t=Math.pow(10,6);return Math.round(e*393.7007874015748*t)/t}cm2mm(e){return e*10}cm2inch(e){let t=Math.pow(10,7);return Math.round(e*.3937007874015748*t)/t}inch2mil(e){return e*1e3}inch2mm(e){return e*25.4}inch2cm(e){return e*2.54}};tx.prototype["px(100)2mil"]=e=>e*10,tx.prototype["px(100)2mm"]=e=>e*.254,tx.prototype["mil2px(100)"]=e=>e/10,tx.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var ix=null,oI=new ArrayBuffer(8),Kv=new Float64Array(oI),$v=new Uint32Array(oI),KP=new Uint16Array(oI),$P=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,n){if(e.length>=t+n&&i.length>=r+n)for(;n-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let n=0;n<t;n++){let s=e.charAt(n);if(r>=0){if(s===";"){let a=e.substring(r+1,n);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else s==="&"?r=n:i.push(s)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let n=0;n<r;n++)e[n]===t&&(e.splice(n,1),n--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!ix){let e=this.getUrlVars().version;e?ix="/analyzer/v"+e:ix="/analyzer"}return ix}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;Kv[0]=new Date().getTime(),e.push($v[1].toString(16)),Kv[0]=Math.random(),e.push(KP[3].toString(16));let t=KP[2].toString(16);e.push("4"+t.substr(0,3)),Kv[0]=performance.now();let i=$v[0].toString(16)+$v[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},uO=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(lm.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(lm.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(lm.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(lm.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},SU=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(SU||{}),wU=/(\.?0+)$/,lm=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,n=0,s,a=0,o=0;for(let l=0;l<e.length;l++){let c=e.charAt(l),u=c.charCodeAt(0);switch(r){case 0:u===37?r=1:i.push(c);break;case 1:switch(u){case 100:if(s=t[n++],typeof s=="number")i.push(s.toFixed(0)),r=0;else return l;break;case 102:if(s=t[n++],typeof s=="number")i.push(s.toString()),r=0;else return l;break;case 120:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16)),r=0;else return l;break;case 88:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:s=t[n++],i.push(s===null?"null":s.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(u){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push($P.lpad((s|0).toString(16),"0",h)),r=0;else return l}else return l;break;case 88:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push($P.lpad((s|0).toString(16).toUpperCase(),"0",h)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let n=e.exec(t);if(n!==null){let s=e.lastIndex-n[0].length;i.push(t.substring(r,s)),r=e.lastIndex}else{let s=t.substring(r);uO.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(wU,"")}},vU=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARNING=2]="WARNING",e[e.ERROR=3]="ERROR",e[e.DUMMY=4]="DUMMY",e))(vU||{});function TU(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var IU=(e,t)=>{e===3?console.error(t):console.log(t)},AU=(e,t)=>lm.format("%s %s: %s",new Date,TU(e),t),Xf,nE=(Xf=class{constructor(e,t=IU,i=AU){this.debug=!1,this.level=e,this.writer=t,this.fmt=i}static mix(...e){let t=4;for(let i of e)i.level<t&&(t=i.level);return new Xf(t,(i,r)=>{for(let n of e)n.write1(i,r)},(i,r)=>r)}wrap(e=null,t=null){let i=e===null?this.fmt:(n,s)=>(s=e(n,s),this.fmt(n,s)),r=t===null?this.writer:(n,s)=>{t(n,s),this.writer(n,s)};return new Xf(this.level,r,i)}chain(e){return e.wrap(this.fmt.bind(this),this.writer.bind(this))}include(e){return this.level<=e}write3(e,t,i){this.include(e)&&this.writer(e,this.fmt(e,lm.format(t,...i)))}write2(e,t){this.include(e)&&(t instanceof Error?this.writer(e,this.fmt(e,t.stack)):this.writer(e,this.fmt(e,t.toString())))}write1(e,t){this.include(e)&&this.writer(e,this.fmt(e,t))}debug3(e,...t){this.write3(0,e,t)}debug2(e){this.write2(0,e)}debug1(e){this.write1(0,e)}info3(e,...t){this.write3(1,e,t)}info2(e){this.write2(1,e)}info1(e){this.write1(1,e)}warning3(e,...t){this.write3(2,e,t)}warning2(e){this.write2(2,e)}warning1(e){this.write1(2,e)}error3(e,...t){this.write3(3,e,t)}error2(e){this.write2(3,e)}error1(e){this.write1(3,e)}},Xf.DUMMY=new Xf(4),Xf),lI=new ArrayBuffer(8),Zv=new Float64Array(lI),Qv=new Uint32Array(lI),ZP=new Uint16Array(lI),QP=ArrayBuffer;try{QP=self.HTMLImageElement||QP}catch{}var rx=null;function Ap(e,t,i=0,r=e.length){n(e,null,t,i,r);function n(a,o,l,c,u){let h,d,p,f;if(c<u-1){let m=u-c;if(m>50)o===null&&(o=new Array(m+1)),s(a,o,l,c,(c+u)/2|0,u);else{h=a[c],d=c,p=c,f=u;let g=d+1;for(;g<f;){if(p!=f){if(f=f+-1,l(h,a[f])<=0)continue;a[p]=a[f],p=f;continue}if(l(h,a[g])>=0){d=g,g=d+1;continue}a[p]=a[g],d=g,p=g,g=d+1}a[p]=h,n(a,o,l,c,p),n(a,o,l,p+1,u)}}}function s(a,o,l,c,u,h){n(a,o,l,c,u),n(a,o,l,u,h);for(var d=c,p=u,f=0,m=a[d],g=a[p];d<u&&p<h;){var b=l(m,g);isNaN(b)?(o[f++]=g,g=a[++p]):(b<=0&&(o[f++]=m,m=a[++d]),b>=0&&(o[f++]=g,g=a[++p]))}for(;d<u;d++)o[f++]=a[d];for(;p<h;p++)o[f++]=a[p];for(d=c,p=0;p<f;d++,p++)a[d]=o[p]}}var xa=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,n){if(e.length>=t+n&&i.length>=r+n)for(;n-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let n=0;n<t;n++){let s=e.charAt(n);if(r>=0){if(s===";"){let a=e.substring(r+1,n);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else s==="&"?r=n:i.push(s)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let n=0;n<r;n++)e[n]===t&&(e.splice(n,1),n--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!rx){let e=this.getUrlVars().version;e?rx="/analyzer/v"+e:rx="/analyzer"}return rx}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;Zv[0]=new Date().getTime(),e.push(Qv[1].toString(16)),Zv[0]=Math.random(),e.push(ZP[3].toString(16));let t=ZP[2].toString(16);e.push("4"+t.substr(0,3)),Zv[0]=performance.now();let i=Qv[0].toString(16)+Qv[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},CU=[1,10,100,1e3],nx=0,mp=0;function eL(e,t,i){return nx=Math.abs(e-t),i>=5&&nx>1e-5||isNaN(i)&&nx>1e-8?!1:nx<1e-13?!0:(mp=Math.min(tL(e),tL(t)),mp<10&&(mp=10),isNaN(i)||(mp=Math.min(mp,i)),iL(e,mp)===iL(t,mp))}var sx=0,ax=0;function tL(e){return sx=0,ax=0,e>0?sx=e-Math.floor(e):sx=e-Math.ceil(e),ax=(sx.toString()||"").length,ax>2?ax-2:0}function iL(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=CU[t]||Math.pow(10,t)||10;if(i){var n=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(n+e)}else return Math.round(e*r+1e-10)/r}var DU=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(DU||{}),_U=/(\.?0+)$/,cm=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,n=0,s,a=0,o=0;for(let l=0;l<e.length;l++){let c=e.charAt(l),u=c.charCodeAt(0);switch(r){case 0:u===37?r=1:i.push(c);break;case 1:switch(u){case 100:if(s=t[n++],typeof s=="number")i.push(s.toFixed(0)),r=0;else return l;break;case 102:if(s=t[n++],typeof s=="number")i.push(s.toString()),r=0;else return l;break;case 120:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16)),r=0;else return l;break;case 88:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:s=t[n++],i.push(s===null?"null":s.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(u){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(xa.lpad((s|0).toString(16),"0",h)),r=0;else return l}else return l;break;case 88:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(xa.lpad((s|0).toString(16).toUpperCase(),"0",h)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let n=e.exec(t);if(n!==null){let s=e.lastIndex-n[0].length;i.push(t.substring(r,s)),r=e.lastIndex}else{let s=t.substring(r);nn.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(_U,"")}},nn=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(cm.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(cm.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(cm.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(cm.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},ox,Oe=(ox=class{static regular(e){return Math.round(e*this.precision)/this.precision}static eq(e,t){return Math.abs(e-t)<=this.eps}static neq(e,t){return Math.abs(e-t)>this.eps}static less(e,t){return e-t<-this.eps}static lesseq(e,t){return e-t<=this.eps}static greater(e,t){return e-t>this.eps}static greatereq(e,t){return e-t>=-this.eps}static sqrt(e){return Math.abs(e)<=1e-10?0:Math.sqrt(e)}static sortAsc(e,t){return e-t}static sortDesc(e,t){return t-e}},ox.eps=1e-8,ox.precision=1e8,ox);function fm(e,t){Bx(e.iterator(),t)}function Bx(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var PU=class{constructor(e){this.idx=-1,this.lst=e}hasNext(){return this.idx<this.lst.length-1}next(){if(this.idx<this.lst.length-1)return this.idx++,this.lst[this.idx];throw new Error("bug")}};function DT(e){return new PU(e)}var ya,ei=(ya=class{static toDegrees(e){return e*180/Math.PI}static toRadians(e){return e/180*Math.PI}static regularD(e){return e=e%360,e=e<0?360+e:e,e===360?0:e}static regular(e){return e=e%ya.PIx2,e=e<0?ya.PIx2+e:e,e===ya.PIx2?0:e}static toQuarterBase(e){return ya.regular((e+ya.PI_4)/ya.PI_2*ya.PI_2)}static toQuarterBaseD(e){return ya.regularD(((e+45)/90|0)*90)}static transformD(e,t){return ya.toDegrees(ya.transform(ya.toRadians(e),t))}static transform(e,t){let i=Math.cos(e),r=Math.sin(e),n=new we(t.data[6],t.data[7]),s=new we(i,r).multiply3(t);return ya.regular(s.angle(n))}},ya.PIx2=Math.PI*2,ya.PI_2=Math.PI/2,ya.PI_4=Math.PI/4,ya),_n=class{static dotProd1(e,t,i,r){return e*i+t*r}static dotProd2(e,t,i,r,n,s){return this.dotProd1(i-e,r-t,n-i,s-r)}static dotProd3(e,t,i){return this.dotProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static crossProd1(e,t,i,r){return e*r-t*i}static crossProd2(e,t,i,r,n,s){return this.crossProd1(i-e,r-t,n-i,s-r)}static crossProd3(e,t,i){return this.crossProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static distance2(e,t,i,r){let n=i-e,s=r-t;return n*n+s*s}static distance1(e,t,i,r){return this.hypot(i-e,r-t)}static distance1p(e,t){return this.distance1(e.x,e.y,t.x,t.y)}static hypot(e,t){if(e=Math.abs(e),t=Math.abs(t),t>e){var i=t;t=e,e=i}if(e===0)return t;var r=t/e;return e*Math.sqrt(1+r*r)}},hO=new ArrayBuffer(16),rL=new Float64Array(hO),lx=new Int32Array(hO),Zi,we=(Zi=class{static sortByXAsc(e,t){return e.x-t.x}static sortByYAsc(e,t){return e.y-t.y}static sortByXYAsc(e,t){return e.x<t.x?-1:e.x>t.x?1:e.y-t.y}static caculateAngle(e,t){let i=Math.cos(e),r=Math.sin(e),n=i*t.data[0]+r*t.data[4],s=i*t.data[1]+r*t.data[5],a=new Zi(n,s).normalize();return Math.atan2(a.y,a.x)}static normal(e,t,i){let r=t.sub(e),n=i.sub(t);return r.cross(n)}static getVector2(e){return new Zi(Math.cos(e),Math.sin(e))}static getCrossPoint1(e,t,i,r){if(e.equals1(t)||i.equals1(r)||Oe.eq(1,Math.abs(t.sub(e).normalize().dot(r.sub(i).normalize()))))return null;let n=t.y-e.y,s=e.x-t.x,a=t.x*e.y-e.x*t.y,o=r.y-i.y,l=i.x-r.x,c=r.x*i.y-i.x*r.y,u=n*l-o*s;return new Zi((c*s-a*l)/u,(a*o-c*n)/u)}static getCrossPoint2(e,t,i,r){return this.getCrossPoint1(e,e.add(t),i,i.add(r))}constructor(e,t){this.x=nn.normal(e),this.y=nn.normal(t)}get hashed(){return this._hashed==null&&(rL[0]=this.x,rL[1]=this.y,this._hashed=lx[0]^lx[1]^lx[2]^lx[3]),this._hashed}dot(e){return this.x*e.x+this.y*e.y}length(){return Math.sqrt(this.dot(this))}getCos(){return this.x/this.length()}sub(e){var t=this.x-e.x,i=this.y-e.y;return new Zi(t,i)}add(e){var t=this.x+e.x,i=this.y+e.y;return new Zi(t,i)}div(e){return new Zi(this.x/e,this.y/e)}add1(e,t){return new Zi(this.x+e,this.y+t)}mul(e){return new Zi(this.x*e,this.y*e)}cross(e){return this.x*e.y-this.y*e.x}getSin(){return this.y/this.length()}angle2(e){let t=this.y-e.y,i=this.x-e.x;return t=Math.abs(t-0)<10**-4?0:t,i=Math.abs(i-0)<10**-4?0:i,Math.atan2(t,i)}angleD2(e){return ei.toDegrees(this.angle2(e))}angle(e){return Math.atan2(this.y-e.y,this.x-e.x)}angleX(e=Zi.ORIGIN){let t=this.angle(e);return t<0&&(t=Math.PI*2+t),t}angleD(e){return ei.toDegrees(this.angle(e))}distance1(e){let t=e.x-this.x,i=e.y-this.y;return _n.hypot(t,i)}distance2(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i}rotateD(e,t){return this.rotate(e,ei.toRadians(t))}rotate(e,t){let i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,s=this.y-e.y,a=n*i+s*-r,o=n*r+s*i;return e.add1(a,o)}multiply3(e){let t=this.x*e.data[0]+this.y*e.data[3]+e.data[6],i=this.x*e.data[1]+this.y*e.data[4]+e.data[7];return new Zi(t,i)}multiply4(e){let t=this.x*e.data[0]+this.y*e.data[4]+e.data[12],i=this.x*e.data[1]+this.y*e.data[5]+e.data[13];return new Zi(t,i)}hashCode(){return this.hashed}equals(e,t){return e instanceof Zi?eL(e.x,this.x,t)&&eL(e.y,this.y,t):!1}equals1(e){return e?Oe.eq(this.x,e.x)&&Oe.eq(this.y,e.y):!1}equals2(e,t){return e instanceof Zi?Math.abs(this.x-e.x)<=t&&Math.abs(this.y-e.y)<=t:!1}similarEquals(e,t=.5){return Math.abs(this.x*.1-e.x*.1)<=t&&Math.abs(this.y*.1-e.y*.1)<=t}toString(){return"Vector [X="+this.x+", Y="+this.y+"]"}bbox(){let e=this.x,t=this.y;return new ba(e,e,t,t)}normalize(){if(this.x===0&&this.y===0)return new Zi(0,0);let e=this.x/this.length(),t=this.y/this.length();return new Zi(e,t)}regular(e=1e-4){let t=Math.round(1/e);return new Zi(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}round(e=4){let t=10**(e|0);return new Zi(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}mirrorX(e=Zi.ORIGIN){return new Zi(this.x,2*e.y-this.y)}mirrorY(e=Zi.ORIGIN){return new Zi(2*e.x-this.x,this.y)}mirrorCenter(e=Zi.ORIGIN){return new Zi(2*e.x-this.x,2*e.y-this.y)}clone(){return new Zi(this.x,this.y)}mirror(e=Zi.ORIGIN){return new Zi(2*e.x-this.x,2*e.y-this.y)}pointOnRays(e,t){let i=ei.toRadians(e);return new Zi(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}pointOnRays2(e,t){let i=e.angle(this);return new Zi(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}scale(e){return new Zi(this.x*e,this.y*e)}},Zi.ORIGIN=new Zi(0,0),Zi.X_UNIT_VECTOR=new Zi(1,0),Zi.Y_UNIT_VECTOR=new Zi(0,1),Zi),LU=(e=>(e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT",e))(LU||{}),OU=(e=>(e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM",e))(OU||{}),Ts,Zu=(Ts=class{constructor(e,t){this.horizontal=e,this.vertical=t}},Ts.LT=new Ts(0,0),Ts.LC=new Ts(0,1),Ts.LB=new Ts(0,2),Ts.CT=new Ts(1,0),Ts.CC=new Ts(1,1),Ts.CB=new Ts(1,2),Ts.RT=new Ts(2,0),Ts.RC=new Ts(2,1),Ts.RB=new Ts(2,2),Ts),RU=(e=>(e[e.INNER=0]="INNER",e[e.OUTER=1]="OUTER",e[e.SEPARATED=2]="SEPARATED",e[e.INTERSECTED=3]="INTERSECTED",e[e.EQ=4]="EQ",e[e.INSIDE_TOUCHED=5]="INSIDE_TOUCHED",e[e.OUTSIDE_TOUCHED=6]="OUTSIDE_TOUCHED",e))(RU||{}),to=class{constructor(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}ext1(e){return this.minX=Math.min(this.minX,e.minX),this.maxX=Math.max(this.maxX,e.maxX),this.minY=Math.min(this.minY,e.minY),this.maxY=Math.max(this.maxY,e.maxY),this}ext2(e){return this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y),this}ext3(e){for(let t=0;t<e.length;t++){let i=e[t];this.ext2(i)}return this}ext4(e){return fm(e,(t,i)=>(this.ext2(i),!0)),this}ext5(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,t),this.minY=Math.min(this.minY,i),this.maxY=Math.max(this.maxY,r),this}ext6(e,t){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t),this}ext7(e){if(e<0){let t=e*2;if(t<this.minX-this.maxX||t<this.minY-this.maxY)throw new Error("")}return this.minX-=e,this.maxX+=e,this.minY-=e,this.maxY+=e,this}ext8(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(new we(e[i],e[i+1]));return this.ext3(t)}ext9(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e+i),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t+r),this}ext10({x:e,y:t,width:i,height:r}){return this.ext9(e,t,i,r)}valid(){return isFinite(this.minX)&&isFinite(this.maxX)&&isFinite(this.minY)&&isFinite(this.maxY)}clear(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}build(){return new ba(this.minX,this.maxX,this.minY,this.maxY)}build1(){return this.valid()?new ba(this.minX,this.maxX,this.minY,this.maxY):new ba(0,0,0,0)}},Oy=new Float64Array(4),ba=class Cl{static extendRect({x:t,y:i,width:r,height:n}){return new Cl(t,t+r,i,i+n)}static extend1(t,i){if(t===null)return new Cl(i.x,i.x,i.y,i.y);{let r=Math.min(t.minX,i.x),n=Math.max(t.maxX,i.x),s=Math.min(t.minY,i.y),a=Math.max(t.maxY,i.y);return new Cl(r,n,s,a)}}static extend2(t,i){if(t){let r=Math.min(t.minX,i.minX),n=Math.max(t.maxX,i.maxX),s=Math.min(t.minY,i.minY),a=Math.max(t.maxY,i.maxY);return new Cl(r,n,s,a)}else return i}static extend3(t,i){let r=Math.min(t.x,i.x),n=Math.max(t.x,i.x),s=Math.min(t.y,i.y),a=Math.max(t.y,i.y);return new Cl(r,n,s,a)}static extend4(t,i,r){return new Cl(t.x-i/2,t.x+i/2,t.y-r/2,t.y+r/2)}constructor(t,i,r,n){if(this.minX=nn.normal(t),this.maxX=nn.normal(i),this.minY=nn.normal(r),this.maxY=nn.normal(n),t>i||r>n)throw new Error(`min > max is not permitted: [${t}, ${i}, ${r}, ${n}]`)}get data(){return Oy[0]=this.minX,Oy[1]=this.maxX,Oy[2]=this.minY,Oy[3]=this.maxY,Oy}isContains(t){return this.isContains1(t.x,t.y)}points(){return[this.LL(),this.LR(),this.UR(),this.UL(),this.LL()]}isContains1(t,i){return this.isContainsX(t)&&this.isContainsY(i)}isContains2(t,i){return this.isContainsX1(t)&&this.isContainsY1(i)}isContainsX(t){return t>=this.minX&&t<=this.maxX}isContainsX1(t){return Oe.greatereq(t,this.minX)&&Oe.lesseq(t,this.maxX)}isContainsY(t){return t>=this.minY&&t<=this.maxY}isContainsY1(t){return Oe.greatereq(t,this.minY)&&Oe.lesseq(t,this.maxY)}isIntersect(t){return!(this.maxX<t.minX||this.minX>t.maxX||this.maxY<t.minY||this.minY>t.maxY)}extendOfSize(t){return nn.positiveOr0(this.maxX-this.minX+t*2),nn.positiveOr0(this.maxY-this.minY+t*2),new Cl(this.minX-t,this.maxX+t,this.minY-t,this.maxY+t)}isInside(t){return this.minX>=t.minX&&this.maxX<=t.maxX&&this.minY>=t.minY&&this.maxY<=t.maxY}isContainsBBox(t){return this.maxX>=t.maxX&&this.minX<=t.minX&&this.maxY>=t.maxY&&this.minY<=t.minY}isContainsBBox1(t){return Oe.greatereq(this.maxX,t.maxX)&&Oe.lesseq(this.minX,t.minX)&&Oe.greatereq(this.maxY,t.maxY)&&Oe.lesseq(this.minY,t.minY)}intersect(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(i>r)return null;let n=Math.max(this.minY,t.minY),s=Math.min(this.maxY,t.maxY);return n>s?null:new Cl(i,r,n,s)}intersection1(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(Oe.greater(i,r))return null;i>r&&(r=i);let n=Math.max(this.minY,t.minY),s=Math.min(this.maxY,t.maxY);return Oe.greater(n,s)?null:(n>s&&(s=n),new Cl(i,r,n,s))}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}UL(){return new we(this.minX,this.maxY)}UR(){return new we(this.maxX,this.maxY)}LL(){return new we(this.minX,this.minY)}LR(){return new we(this.maxX,this.minY)}center(){return new we(this.maxX-(this.maxX-this.minX)/2,this.maxY-(this.maxY-this.minY)/2)}area(){return this.width()*this.height()}transform(t){let i=new to;return i.ext2(this.LL().multiply3(t)),i.ext2(this.LR().multiply3(t)),i.ext2(this.UR().multiply3(t)),i.ext2(this.UL().multiply3(t)),i.build()}transform4(t){let i=new to;return i.ext2(this.LL().multiply4(t)),i.ext2(this.LR().multiply4(t)),i.ext2(this.UR().multiply4(t)),i.ext2(this.UL().multiply4(t)),i.build()}isSeparated(t){if(t==null||t==null)return!1;let i;this.minX>=t.minX?i=this.minX:i=t.minX;let r;if(this.maxX<=t.maxX?r=this.maxX:r=t.maxX,i>r)return!0;{let n;this.minY>=t.minY?n=this.minY:n=t.minY;let s;return this.maxY<=t.maxY?s=this.maxY:s=t.maxY,n>s}}relation(t){let i=0,r=0,n;this.minX>t.minX?(i++,n=this.minX):this.minX===t.minX?n=this.minX:(r++,n=t.minX);let s;if(this.maxX<t.maxX?(i++,s=this.maxX):this.maxX===t.maxX?s=this.maxX:(r++,s=t.maxX),n>s)return 2;{let a;this.minY>t.minY?(i++,a=this.minY):this.minY===t.minY?a=this.minY:(r++,a=t.minY);let o;return this.maxY<t.maxY?(i++,o=this.maxY):this.maxY===t.maxY?o=this.maxY:(r++,o=t.maxY),a>o?2:i===4?0:r===4?1:i===0&&r===0?4:n===s||a===o?6:i!==r?5:3}}zoom(t){let i=this.width(),r=this.height(),n=this.center();return t!=0&&(i/=t/2,r/=t/2),new Cl(n.x-i,n.x+i,n.y-i,n.y+i)}toString(){return"BBox [minX="+this.minX+", maxX="+this.maxX+", minY="+this.minY+", maxY="+this.maxY+"]"}equals(t){return this.minY==t.minY&&this.minX==t.minX&&this.maxX==t.maxX&&this.maxY==t.maxY}extendSize(t,i){return Object.is(void 0,i)&&(i=t),Cl.extend4(this.center(),this.width()+t,this.height()+i)}positionOnBBox(t,i=0){let r=this.center(),n=this.width()*i/2,s=this.height()*i/2,a=t.x-r.x,o=t.y-r.y;return a>n?o>s?Zu.RT:o<-s?Zu.RB:Zu.RC:a<-n?o>s?Zu.LT:o<-s?Zu.LB:Zu.LC:o>s?Zu.CT:o<-s?Zu.CB:Zu.CC}bbox(){return this}},kx=class Yi{static mul(t,i,r,n,s,a){let o=0,l=0;for(let c=0;c<t;c++){for(let u=0;u<r;u++){let h=u,d=0;for(let p=0;p<i;p++)d+=n[l+p]*s[h],h+=r;a[o++]=d}l+=i}}constructor(t,i,r){this.m=nn.normal(t),this.n=nn.normal(i);let n=t*i;if(r.length===n){for(let s=0;s<r.length;s++)nn.normal(r[s]);this.data=r}else throw new Error("invalid matrix size")}mul(t){if(this.n===t.m){let i=new Array(this.m*t.n);return Yi.mul(this.m,this.n,t.n,this.data,t.data,i),new Yi(this.m,t.n,i)}else throw new Error("m !== p")}toString(){let t=[];t.push("Matrix ("),t.push(this.m.toString()),t.push(" x "),t.push(this.n.toString()),t.push(")");let i=0;for(let r=0;r<this.m;r++)for(let n=0;n<this.n;n++){let s=this.data[i++].toString();n===0?(t.push(`
`),t.push("	"),t.push(s)):(t.push(", "),t.push(s))}return t.join("")}static on(t,i,r){return t*i+r}initExpandMatrix(t){let i=this.m,r=this.n,n=r*2,s=new Array(i*n);for(let a=0;a<i;a++)for(let o=0;o<n;o++)o<r?s[Yi.on(n,a,o)]=t[Yi.on(r,a,o)]:o===i+a?s[Yi.on(n,a,o)]=1:s[Yi.on(n,a,o)]=0;return s}inverseMatrix(t,i,r){for(let n=0;n<i;n++){let s=t[Yi.on(r,n,n)];for(let a=0;a<r;a++)t[Yi.on(r,n,a)]/=s}return t}getMatrixRank(t,i,r){let n=Math.min(i,r);for(let s=0;s<i;s++){if(t[Yi.on(r,s,s)]===0){let a=new Array(r),o;for(o=s;o<i;o++)if(t[Yi.on(r,o,s)]!==0){xa.arraycopy(t,Yi.on(r,o,0),a,0,r),xa.arraycopy(t,Yi.on(r,s,0),t,Yi.on(r,o,0),r),xa.arraycopy(a,0,t,Yi.on(r,s,0),r);break}o>=i&&(n-=1)}if(!(n<i))for(let a=0;a<i;a++){if(a===s)continue;let o=t[Yi.on(r,a,s)]/t[Yi.on(r,s,s)];for(let l=0;l<r;l++)t[Yi.on(r,a,l)]-=t[Yi.on(r,s,l)]*o}}return n}getInverseMatrix(){if(this.m!==this.n)throw new Error("The matrix is an "+this.m+"x"+this.n+" order matrix, non-square matrix, please check!");function t(a){return Oe.lesseq(Math.abs(a),0)}let i=this.initExpandMatrix(this.data.slice(0)),r=this.n*2;function n(a,o){for(let l=0;l<r;l++){let c=i[Yi.on(r,a,l)];i[Yi.on(r,a,l)]=i[Yi.on(r,o,l)],i[Yi.on(r,o,l)]=c}}for(let a=0;a<this.m;a++){let o=Math.abs(i[Yi.on(r,a,a)]),l=a;if(t(i[Yi.on(r,a,a)]))for(let u=a+1;u<this.m;u++){if(t(i[Yi.on(r,u,a)])){Math.abs(i[Yi.on(r,u,a)])>o&&(o=Math.abs(i[Yi.on(r,u,a)]),l=u);continue}n(a,u);break}if(t(i[Yi.on(r,a,a)])){if(o===0)throw new Error("The matrix is a non-full rank matrix, please check!");console.warn("The matrix may be a non-full rank matrix, please check!"),l!==a&&n(a,l)}let c=1/i[Yi.on(r,a,a)];for(let u=0;u<r;u++)i[Yi.on(r,a,u)]*=c;for(let u=0;u<this.m;u++){if(a===u)continue;let h=i[Yi.on(r,u,a)];for(let d=a;d<r;d++)i[Yi.on(r,u,d)]-=i[Yi.on(r,a,d)]*h}}let s=[];for(let a=0;a<this.m;a++)for(let o=this.n;o<r;o++)s[Yi.on(this.n,a,o-this.n)]=i[Yi.on(r,a,o)];return new Yi(this.m,this.n,s)}getTransposeMatrix(){let t=new Array(this.data.length);for(let i=0;i<this.m;i++)for(let r=0;r<this.n;r++)t[r*this.n+i]=this.data[i*this.m+r];return new Yi(this.n,this.m,t)}hashCode(){let t=0;for(let i of this.data)t+=i;return t}equals(t){return this===t?!0:t===null?!1:t instanceof Yi?!(this.m!=t.m||this.n!=t.n||!xa.equals(this.data,t.data)):!1}},NU=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],pn,dO=(pn=class extends kx{static translate(e,t,i){return new pn([1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1])}static translate1(e){return new pn([1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,e.z,1])}static rotateX(e){let t=Math.cos(e),i=Math.sin(e);return new pn([1,0,0,0,0,t,i,0,0,-i,t,0,0,0,0,1])}static rotateY(e){let t=Math.cos(e),i=Math.sin(e);return new pn([t,0,-i,0,0,1,0,0,i,0,t,0,0,0,0,1])}static rotateZ(e){let t=Math.cos(e),i=Math.sin(e);return new pn([t,i,0,0,-i,t,0,0,0,0,1,0,0,0,0,1])}static rotateAxis(e,t){e=e.normalize();let i=e.x,r=e.y,n=e.z,s=Math.sin(t),a=Math.cos(t);return new pn([i*i*(1-a)+a,i*r*(1-a)+n*s,i*n*(1-a)-r*s,0,i*r*(1-a)-n*s,r*r*(1-a)+a,r*n*(1-a)+i*s,0,i*n*(1-a)+r*s,r*n*(1-a)-i*s,n*n*(1-a)+a,0,0,0,0,1])}static scale(e,t=e,i=e){return new pn([e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1])}static flipX(){return new pn([1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1])}static flipY(){return new pn([-1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}static rotateZForPoint(e,t){return e.equals1(we.ORIGIN)?pn.rotateZ(t):pn.translate(-e.x,-e.y,0).rotateZ(t).translate1(e.x,e.y,0)}static getMatrix4(e,t,i,r){let n=Math.cos(t),s=Math.sin(t),a=i*(e.x*n-e.y*s)+r.x,o=e.x*s+e.y*n+r.y,l=[i*n,s,0,0,-s*i,n,0,0,0,0,1,0,a,o,0,1];return new pn(l)}constructor(e=NU){super(4,4,e)}translate(e){return this.multiply4(pn.translate1(e))}translate1(e,t,i){return this.multiply4(pn.translate(e,t,i))}rotateX(e){return this.multiply4(pn.rotateX(e))}rotateY(e){return this.multiply4(pn.rotateY(e))}rotateZ(e){return this.multiply4(pn.rotateZ(e))}scale(e,t=e,i=e){return this.multiply4(pn.scale(e,t,i))}scale1(e){return this.multiply4(pn.scale(e.x,e.y,e.z))}setOrigin(e,t,i){return pn.translate(-e,-t,-i).multiply4(this).translate1(e,t,i)}setOrigin1(e){return this.setOrigin(e.x,e.y,e.z)}multiply4(e){let t=new Array(16);return kx.mul(4,4,4,this.data,e.data,t),new pn(t)}getInverseMatrix(){let e=super.getInverseMatrix();return new pn(e.data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new pn(e.data)}inverse(){let e=this.getInverseMatrix();return new pn(e.data)}toMatrix3(){let e=this.data;return new hr([e[0],e[1],0,e[4],e[5],0,e[12],e[13],1])}},pn.ORIGIN=new pn,pn);function Ry(e){return uO.normal(parseFloat(e))}var MU=[1,0,0,0,1,0,0,0,1],Jr,hr=(Jr=class extends kx{static translate(e,t){return new Jr([1,0,0,0,1,0,e,t,1])}static translate1(e){return this.translate(e.x,e.y)}static rotate(e){let t=Math.cos(e),i=Math.sin(e);return new Jr([t,i,0,-i,t,0,0,0,1])}static rotateD(e){return this.rotate(ei.toRadians(e))}static scale(e,t=e){return new Jr([e,0,0,0,t,0,0,0,1])}static scale1(e,t){return new Jr([e,0,0,0,t,0,0,0,1])}static toDOMMatrix(e){let[t,i,,r,n,,s,a]=e.data;return`matrix(${[t,i,r,n,s,a].join(",")})`}static svgTrasform(e){let t=e.split(" "),i=null;return t.forEach(r=>{r=r.trim();let n=r.trim().replace(")","").split("("),s=n[0],a=n[1].split(",");switch(s){case"translate":let o=Ry(a[0]),l=Ry(a[1]);i=i?i.translate(o,l):Jr.translate(o,l);break;case"rotate":let c=Ry(a[0]),u=Ry(a[1]),h=Ry(a[2]);i=i?i.setOrigin(u,h):Jr.translate(u,h),i=i.rotateD(c);break;default:return}}),i}constructor(e=MU){super(3,3,e);let t=e[0],i=e[3],r=e[1],n=e[4];this.iScale=Math.sqrt(t*t+r*r),this.jScale=Math.sqrt(i*i+n*n)}isMirrored(){return this.det()<0}multiply3(e){let t=new Array(9);return kx.mul(3,3,3,this.data,e.data,t),new Jr(t)}translate(e,t){return this.multiply3(Jr.translate(e,t))}translate1(e){return this.multiply3(Jr.translate1(e))}scale(e,t=e){return this.multiply3(Jr.scale(e,t))}scale1(e,t){return this.multiply3(Jr.scale1(e,t))}det(){return this.data[0]*this.data[4]-this.data[3]*this.data[1]}invert(){let e=this.getInverseMatrix();return new Jr(e.data)}rotateD(e){return this.multiply3(Jr.rotateD(e))}rotate(e){return this.multiply3(Jr.rotate(e))}resetOffset(){let e=this.data;return new Jr([e[0],e[1],0,e[3],e[4],0,0,0,1])}setOrigin(e,t){return Jr.translate(-e,-t).multiply3(this).translate(e,t)}setOrigin1(e){return this.setOrigin(e.x,e.y)}getInverseMatrix(){return new Jr(super.getInverseMatrix().data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new Jr(e.data)}toMatrix4(){let e=this.data;return new dO([e[0],e[1],0,e[2],e[3],e[4],0,e[5],0,0,1,0,e[6],e[7],0,e[8]])}scaleNum(e){return!e||isNaN(e)?e:e*this.iScale}},Jr.ORIGIN=new Jr,Jr.MIRROR_Y=new Jr([1,0,0,0,-1,0,0,0,1]),Jr.MIRROR_X=new Jr([-1,0,0,0,1,0,0,0,1]),Jr.ROT_90=new Jr([0,1,0,-1,0,0,0,0,1]),Jr.ROT_N90=new Jr([0,-1,0,1,0,0,0,0,1]),Jr),BU=(e=>(e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE",e))(BU||{}),td=(e=>(e[e.CW=0]="CW",e[e.CCW=1]="CCW",e))(td||{}),d0=class{},_T=class Uy{constructor(t,i,r){this.p1=t,this.p2=i,this.p3=r}barycentre(){return Uy.barycentre(this.p1,this.p2,this.p3)}incentre(){return Uy.incentre(this.p1,this.p2,this.p3)}static barycentre(t,i,r){let n=t.x+i.x+r.x,s=t.y+i.y+r.y;return new we(n/3,s/3)}static incentre(t,i,r){let n=i.sub(r).length(),s=t.sub(r).length(),a=t.sub(i).length(),o=n+s+a,l=n*t.x+s*i.x+a*r.x,c=n*t.y+s*i.y+a*r.y;return new we(l/o,c/o)}area(){return Uy.area(this.p1,this.p2,this.p3)}static area(t,i,r){return this.area2(t.x,t.y,i.x,i.y,r.x,r.y)/2}static area2(t,i,r,n,s,a){return Math.abs(_n.crossProd2(t,i,r,n,s,a))}scale(t,i){let r=hr.translate(-t.x,-t.y).scale(i).translate1(t),n=this.p1.multiply3(r),s=this.p2.multiply3(r),a=this.p3.multiply3(r);return new Uy(n,s,a)}scaleOnBarycentre(t){return this.scale(this.barycentre(),t)}scaleOnIncentre(t){return this.scale(this.incentre(),t)}extend(t){let i=this.incentre(),r=this.p1.add(this.p2).sub(i).scale(1/2),n=r.length(),s=we.ORIGIN.pointOnRays2(r,n+t).length()/n;return this.scaleOnIncentre(s)}container(t){let i=this.p3.sub(this.p1),r=this.p2.sub(this.p1),n=t.sub(this.p1),s=i.dot(i),a=i.dot(r),o=i.dot(n),l=r.dot(r),c=r.dot(n),u=1/(s*l-a*a),h=(l*o-a*c)*u;if(h<0||h>1)return!1;let d=(s*c-a*o)*u;return d<0||d>1?!1:h+d<=1}};function cx(){return{minDistance:Number.POSITIVE_INFINITY,start:null,end:null}}var wc=class ed{static getMinDistanceWithoutCross(t,i){let r=cx();return ed.minLine(t,i,r),r.minDistance}static getMinDistance(t,i){return Pl(t,i)?0:this.getMinDistanceWithoutCross(t,i)}static getMinLineWithCross(t,i){let r=cx();return ed.minLine(t,i,r),new me(r.start,r.end)}static getMinLine(t,i){return ed.intersection(t,i)||this.getMinLineWithCross(t,i)}static getMinDistanceFromPoint(t,i){let r=cx();if(i instanceof me)this.point2LineMinLine(r,i,t);else if(i instanceof Pe)this.point2ArcMinDistance(t,i,r);else throw new Error("not support");return r.minDistance}constructor(t,i){if(this.pt1=t,this.pt2=i,this.minline=ed.intersection(t,i),this.minline)this.minDistance=0;else{let r=cx();ed.minLine(t,i,r),this.minline=new me(r.start,r.end),this.minDistance=r.minDistance}}getDistance(){return this.minDistance}getLine(){return this.minline}static intersection(t,i){let r=Pl(t,i);if(r===0)return;let n=new Array;for(let s=0;s<r;s+=2){let a=new we(ae[s],ae[s+1]);n.push(a)}return n.length>1?new me(n[0],n[1]):new me(n[0],n[0])}static minLine(t,i,r){if(t instanceof me&&i instanceof me)return this.minDistanceForLines(t,i,r);if(t instanceof Pe&&i instanceof me)return this.minDistanceForLineAndArc(t,i,r);if(t instanceof me&&i instanceof Pe)return this.minDistanceForLineAndArc(i,t,r);if(t instanceof Pe&&i instanceof Pe)return this.minDistanceForArcs(t,i,r);throw new Error("not support")}static minDistanceForLines(t,i,r){[t.start(),t.end(),i.start(),i.end()].forEach((n,s)=>{s<2?this.point2LineMinLine(r,i,n):this.point2LineMinLine(r,t,n)})}static minDistanceForLineAndArc(t,i,r){this.point2LineMinLine(r,i,t.start()),this.point2LineMinLine(r,i,t.svgEnd);let n=ed.foot(i,t.center);i.bbox().extendOfSize(1e-8).isContains(n)&&this.point2ArcMinLine(r,t,n),this.point2ArcMinLine(r,t,i.start()),this.point2ArcMinLine(r,t,i.end())}static minDistanceForArcs(t,i,r){this.concentricArc(t,i,r),this.point2ArcMinDistance(i.start(),t,r),this.point2ArcMinDistance(i.svgEnd,t,r),this.point2ArcMinDistance(t.start(),i,r),this.point2ArcMinDistance(t.svgEnd,i,r),(yc(t,i.center)||yc(i,t.center))&&this.shortestLineForArcs(t,i,r)}static minLineForArcAndLine(t,i,r){let n=t.pointOn(r.angleD(t.center)),s=t.pointOn(t.center.angleD(r));this.arcShortestLine(t,i,r,n),this.arcShortestLine(t,i,r,s)}static arcInnerLineFootSegment(t,i,r){let n=r.distance1(t.center);if(n!==0){let s=t.rx*(r.y-t.center.y)/n+t.center.y,a=t.rx*(r.x-t.center.x)/n+t.center.x;n=t.rx-n,n<i.minDistance&&(i.minDistance=n,i.start=new we(a,s),i.end=r)}else n=t.rx-n,n<i.minDistance&&(i.minDistance=n,i.start=t.start(),i.end=r)}static shortestLineForArcs(t,i,r){let n=t.center.angleD(i.center),s=i.center.angleD(t.center),a=t.pointOn(n),o=t.pointOn(s),l=i.pointOn(n),c=i.pointOn(s);yc(t,a)&&(this.arcShortestLine(i,r,a,l),this.arcShortestLine(i,r,a,c)),yc(t,o)&&(this.arcShortestLine(i,r,o,l),this.arcShortestLine(i,r,o,c)),this.shortestLineForArcs1(t,i,r)}static shortestLineForArcs1(t,i,r){let n=i.start().sub(t.center).normalize(),s=i.end().sub(t.center).normalize(),a=t.start().sub(i.center).normalize(),o=t.end().sub(i.center).normalize(),l=t.center.add(n.mul(t.rx)),c=t.center.add(s.mul(t.rx)),u=i.center.add(a.mul(i.rx)),h=i.center.add(o.mul(i.rx));yc(t,l)&&Oe.greater(i.start().distance2(t.center),0)&&this.arcShortestLine(t,r,i.start(),l),yc(t,c)&&Oe.greater(i.end().distance2(t.center),0)&&this.arcShortestLine(t,r,i.end(),c),yc(i,u)&&Oe.greater(t.start().distance2(i.center),0)&&this.arcShortestLine(i,r,t.start(),u),yc(i,h)&&Oe.greater(t.end().distance2(i.center),0)&&this.arcShortestLine(i,r,t.end(),h)}static concentricArc(t,i,r){if(!(t.center.distance1(i.center)<1e-5&&t.rx===i.rx&&t.ry===i.ry))return;let n=t.start().distance1(i.svgEnd);n<r.minDistance&&(r.minDistance=n,r.start=t.start(),r.end=i.svgEnd),n=i.start().distance1(t.svgEnd),n<r.minDistance&&(r.minDistance=n,r.start=i.start(),r.end=t.svgEnd)}static point2ArcMinDistance(t,i,r){if(yc(i,t)){let n=i.pointOn(t.angleD(i.center)),s=i.pointOn(i.center.angleD(t));this.arcShortestLine(i,r,t,n),this.arcShortestLine(i,r,t,s)}else this.minLineSegment(r,i.start(),t),this.minLineSegment(r,i.svgEnd,t)}static point2ArcMinLine(t,i,r){if(yc(i,r)){let n=r.distance1(i.center);n>i.rx||n>i.ry?this.minLineForArcAndLine(i,t,r):this.arcInnerLineFootSegment(i,t,r)}}static point2LineMinLine(t,i,r){let n=ed.foot(i,r);i.bbox().extendOfSize(1e-8).isContains(n)?this.minLineSegment(t,n,r):(this.minLineSegment(t,i.start(),r),this.minLineSegment(t,i.end(),r))}static minLineSegment(t,i,r){let n=i.distance1(r);n<t.minDistance&&(t.minDistance=n,t.start=i,t.end=r)}static arcShortestLine(t,i,r,n){if(!yc(t,n))return;let s=r.distance1(n);s<i.minDistance&&(i.minDistance=s,i.start=r,i.end=n)}static foot(t,i){if(t.isPoint())return t.start();if(!Oe.eq(t.b,0)&&!Oe.eq(t.a,0)){let r=t.start(),n=t.direct,s=(i.x-r.x)*n.x+(i.y-r.y)*n.y;return new we(r.x+n.x*s,r.y+n.y*s)}else return Oe.eq(t.b,0)&&!Oe.eq(t.a,0)?new we(t.start().x,i.y):!Oe.eq(t.b,0)&&Oe.eq(t.a,0)?new we(i.x,t.start().y):i}};function yc(e,t){if(Oe.eq(e.sweepAngle,360))return!0;let i=ei.regularD(t.angleD(e.center));return e.sweepAngle>0?(Oe.less(i,e.startAngle)&&(i+=360),Oe.greatereq(e.endAngle(),i)):(Oe.greater(i,e.startAngle)&&(i-=360),Oe.lesseq(e.endAngle(),i))}var kU=[1,10,100,1e3],nL="http://www.w3.org/2000/svg",sL="http://www.w3.org/1999/xlink",aL="http://www.w3.org/XML/1998/namespace",oL="https://easyeda.com/",Vre=(function(){var e={svg:nL,xlink:sL,xml:aL,c:oL};return e[nL]="svg",e[sL]="xlink",e[aL]="xml",e[oL]="c",e})(),Jn=(function(){var e={RATLINES:9,MODEL3D:19,ALL:11,TOPSILKLAYER:3,TOPLAYER:1,TOPPASTERLAYER:5,TOPSOLDERLAYER:7,LIBBODY:99,PADSURFACE:100,BOARDOUTLINE:10,DOCUMENT:12,TOPASSEMBLY:13,MECHANICAL:15,TOPCOMPONENT:16,SUBSTRATE:18},t;for(t=21;t<53;t++)e["INNER"+(t-20)]=t;for(e.BOTTOMSILKLAYER=4,e.BOTTOMLAYER=2,e.BOTTOMPASTERLAYER=6,e.BOTTOMSOLDERLAYER=8,e.BOTTOMASSEMBLY=14,e.BOTTOMCOMPONENT=17,t=53;t<85;t++)e["BOARD"+(t-52)]=t;return e})(),Hre=(function(){var e={COPPERAREA:[1,2,21,22,23,24],PLANEZONE:[1,2,21,22,23,24],RECT:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,99],TRACK:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],PAD:[11,1,2],VIA:[11],HOLE:[11],TEXT:[3,4,1,2,7,8,12,13,14,15,21,22,23,24],ARC:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],ELLIPSE:[3,4,12,13,14,15],CIRCLE:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],DIMENSION:[3,4,12,13,14,15],FOOTPRINT:[1,2],SOLIDREGION:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,11,99,100],SVGNODE:[1,2,3,4,7,8,12,13,14,15],PROTRACTOR:[3,4,12,13,14,15],SHEET:[12,13,14,15]};e["3D"]=(function(){for(var n=[16,19,3,7,5,1],s=21;s<52;s++)n.push(s+32,s);return n.push(2,6,8,4,17),n})();var t,i,r;for(t in e)if(e.hasOwnProperty(t)&&(r=e[t],r.indexOf(21)>0&&r.indexOf(25)===-1))for(i=25;i<=52;i++)r.push(i);return e})(),Us=(function(){var e={1:"TopLayer",2:"BottomLayer",3:"TopSilkLayer",4:"BottomSilkLayer",5:"TopPasteMaskLayer",6:"BottomPasteMaskLayer",7:"TopSolderMaskLayer",8:"BottomSolderMaskLayer",9:"Ratlines",10:"BoardOutLine",11:"Multi-Layer",12:"Document",13:"TopAssembly",14:"BottomAssembly",15:"Mechanical",16:"TopComponents",17:"BottomComponents",18:"Substrate",19:"3DModel",99:"ComponentShapeLayer",100:"LeadShapeLayer"},t;for(t=21;t<53;t++)e[t]="Inner"+(t-20);for(t=53;t<85;t++)e[t]="Substrate"+(t-52);return e})(),jre=(function(){var e=[],t=[];for(var i in Jn)if(Jn.hasOwnProperty(i)){if(i.match(/^BOARD\d+/))continue;e.push(Jn[i])}e.sort(),t.sort();var r={},n,s={21:"#999966",22:"#008000",23:"#00FF00",24:"#BC8E00",25:"#70DBFA",26:"#00CC66",27:"#9966FF",28:"#800080",29:"#008080",30:"#15935F",31:"#000080",32:"#00B400",33:"#2E4756",34:"#99842F",35:"#FFFFAA",36:"#99842F",37:"#2E4756",38:"#3535FF",39:"#8000BC",40:"#43AE5F",41:"#C3ECCE",42:"#728978",43:"#39503F",44:"#0C715D",45:"#5A8A80",46:"#2B937E",47:"#23999D",48:"#45B4E3",49:"#215DA1",50:"#4564D7",51:"#6969E9",52:"#9069E9"};e.forEach(function(o){switch(o){case Jn.TOPLAYER:n={name:Us[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case Jn.BOTTOMLAYER:n={name:Us[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case Jn.TOPSILKLAYER:n={name:Us[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case Jn.BOTTOMSILKLAYER:n={name:Us[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case Jn.TOPPASTERLAYER:n={name:Us[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case Jn.BOTTOMPASTERLAYER:n={name:Us[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case Jn.TOPSOLDERLAYER:n={name:Us[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case Jn.BOTTOMSOLDERLAYER:n={name:Us[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case Jn.RATLINES:n={name:Us[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case Jn.BOARDOUTLINE:n={name:Us[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case Jn.ALL:n={name:Us[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case Jn.DOCUMENT:n={name:Us[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case Jn.TOPASSEMBLY:n={name:Us[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case Jn.BOTTOMASSEMBLY:n={name:Us[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case Jn.MECHANICAL:n={name:Us[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case Jn.MODEL3D:n={name:Us[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case Jn.LIBBODY:n={name:Us[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case Jn.PADSURFACE:n={name:Us[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=Jn.INNER1&&o<=Jn.INNER32?n={name:Us[o],color:s[o],darkColor:a(s[o]),visible:!1,active:!1,config:!1}:n=null;break}n&&(r[o]=n)}),r.Hole={config:!0,name:"Hole",darkColor:"#222222",color:"#222222"},r.DRCError={config:!0,name:"DRCError",color:"#FAD609",darkColor:"#FAD609"};function a(o){if(typeof o!="string"||!o.match(/#?([\da-f]{6})/i))return o;var l=parseInt(RegExp.$1,16),c=.5,u=Math.min(255,Math.round((l>>16)*c)),h=Math.min(255,Math.round((l>>8&255)*c)),d=Math.min(255,Math.round((l&255)*c)),p=((u<<16)+(h<<8)+d).toString(16);return"#"+("00000"+p).substr(-6).toUpperCase()}return r})(),lL={BLANK:0,SCH:1,PART:2,PCB:3,FOOTPRINT:4,PRJ:5,SUBPART:6,SPICESYMBOL:7,SUBCKT:8,NETLIST:9,WAVEFORM:10,SCHLIB3D:11,PHOTOVIEW:12,SCHMODULE:13,PCBMODULE:14,VIEW3D:15,PCBLIB3D:16,BLOCK_SYMBOL:17,NETFLAG:18,NETPORT:19,SHEET_SYMBOL:20,NONEELEC_SYMBOL:21,SHORT_SYMBOL:22,FOOTPRINTVIEW:23,CNCPRINTVIEW:24,PCB2D:31,PCB3D:32},zre=(function(){var e={};for(let t in lL)e[lL[t]]=t;return e})(),sE=Math.PI*2,Fx=Math.PI/2,Xre=Math.sin(Math.PI/180);function FU(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=kU[t]||Math.pow(10,t)||10;if(i){var n=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(n+e)}else return Math.round(e*r+1e-10)/r}function pO(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function GU(e,t,i){var r=u(e)&&u(t)&&u(i);if(!r)return console.warn("Bad arguments"),null;var n=t.x-i.x>0?t.x:i.x,s=t.y-i.y>0?t.y:i.y,a=t.x-i.x>0?i.x:t.x,o=t.y-i.y>0?i.y:t.y,l=e.x,c=e.y;return l<=n+.001&&l>=a-.001&&c<=s+.001&&c>=o-.001;function u(h){return h?(h.x=Number(h.x),h.y=Number(h.y),isNaN(h.x)||isNaN(h.y)?(console.warn("Can not convert to Number, NaN found"),!1):!0):(console.warn("Empty input!"),!1)}}function UU(e,t,i,r,n,s){var a=(n-i)*(e-i)+(s-r)*(t-r),o=(n-i)*(n-i)+(s-r)*(s-r),l=a/o,c=i+(n-i)*l,u=r+(s-r)*l;return a<=0?Math.sqrt((e-i)*(e-i)+(t-r)*(t-r)):a>=o?Math.sqrt((e-n)*(e-n)+(t-s)*(t-s)):Math.sqrt((e-c)*(e-c)+(u-t)*(u-t))}function YU(e,t,i){return GU(e,t,i)?pO((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}var Yy=1e-4,ae=new Float64Array(100);function Pl(e,t){if(e instanceof me&&t instanceof me)return uu(e,t);if(e instanceof Pe&&t instanceof me)return PT(e,t);if(e instanceof me&&t instanceof Pe)return PT(t,e);if(e instanceof Pe&&t instanceof Pe)return mO(e,t);if(e instanceof ct&&t instanceof ct)return Tx(e,t);if(e instanceof ct&&t instanceof me)return Tx(e,new ct([t.start(),t.end()]));if(e instanceof me&&t instanceof ct)return Tx(new ct([e.start(),e.end()]),t);if(e instanceof ct&&t instanceof Pe)return mL(t,e);if(e instanceof Pe&&t instanceof ct)return mL(e,t);throw new Error("not supported operation")}function VU(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new me(new we(i.minX-1,t),new we(i.maxX+1,t));return uu(r,e)>0?1:0}else return 0}function HU(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new me(new we(i.minX-1,t),new we(i.maxX+1,t));return Gx(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function cL(e,t){let i=e.bbox();return i.isContainsY1(t)&&Tx(new ct([new we(i.minX-1,t),new we(i.maxX+1,t)]),e)>0?1:0}function uL(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function jU(e,t){let i=t.length(),r=_n.crossProd3(t.start(),t.end(),e.start())/i,n=_n.crossProd3(t.start(),t.end(),e.end())/i;return Math.abs(r)<1e-8||Math.abs(n)<1e-8||r*n<0}function uu(e,t){let i=e.bbox().intersection1(t.bbox());if(!i)return 0;if(e.isPoint())if(t.isPoint()){let r=i.center();return ae[0]=r.x,ae[1]=r.y,2}else return hL(t,e,i);else{if(t.isPoint())return hL(e,t,i);{let r=function(E,S){i.isContains2(E,S)&&(ae[y++]=E,ae[y++]=S)};if(!jU(e,t))return 0;let n=e.start().x,s=e.start().y,a=e.end().x,o=e.end().y,l=t.start().x,c=t.start().y,u=t.end().x,h=t.end().y,d=t.length(),p=_n.crossProd2(n,s,l,c,u,h)/d,f=_n.crossProd2(a,o,l,c,u,h)/d;if(p*f>0&&!Oe.eq(p,0)&&!Oe.eq(f,0))return 0;let m=e.length(),g=_n.crossProd2(l,c,n,s,a,o)/m,b=_n.crossProd2(u,h,n,s,a,o)/m;if(g*b>0&&!Oe.eq(g,0)&&!Oe.eq(b,0))return 0;let y=0;if(Oe.eq(p,0)&&Oe.eq(f,0)){let E=i.UL(),S=i.UR(),w=i.LL(),x=i.LR();if(Oe.eq(i.width(),0))Oe.eq(i.height(),0)?(ae[y++]=E.x,ae[y++]=E.y):(ae[y++]=E.x,ae[y++]=E.y,ae[y++]=w.x,ae[y++]=w.y);else if(Oe.eq(i.height(),0))ae[y++]=E.x,ae[y++]=E.y,ae[y++]=S.x,ae[y++]=S.y;else{let I=_T.area2(E.x,E.y,l,c,u,h),A=_T.area2(S.x,S.y,l,c,u,h);I<A?(ae[y++]=E.x,ae[y++]=E.y,ae[y++]=x.x,ae[y++]=x.y):(ae[y++]=S.x,ae[y++]=S.y,ae[y++]=w.x,ae[y++]=w.y)}}else if(Oe.eq(p,0))r(n,s);else if(Oe.eq(f,0))r(a,o);else{let E=Math.abs(p/(p-f));r(n+(a-n)*E,s+(o-s)*E)}return y}}}function hL(e,t,i){let r=t.start(),n=t.end(),s=_n.crossProd3(e.start(),e.end(),t.start()),a=_n.crossProd3(e.start(),e.end(),t.end());if(s*a<0){let o=i.center();return ae[0]=o.x,ae[1]=o.y,2}else if(Math.abs(s)<Math.abs(a)){if(Oe.eq(s/e.length(),0))return ae[0]=r.x,ae[1]=r.y,2}else if(Oe.eq(a/e.length(),0))return ae[0]=n.x,ae[1]=n.y,2;return 0}function Gx(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(Yy);let r=e.center.x,n=e.center.y,s=e.rx,a=e.rx2,o=t.start().x,l=t.start().y,c=t.end().x,u=t.end().y,h=e.center.distance1(t.start()),d=e.center.distance1(t.end()),p=Oe.eq(h,s)?0:h>s?1:-1,f=Oe.eq(d,s)?0:d>s?1:-1,m=0;if(p===-1&&f===-1)return 0;if(p===0&&f===0)ae[m++]=o,ae[m++]=l,ae[m++]=c,ae[m++]=u;else if(p===1&&f===1){let g=wc.foot(t,e.center),b=g.distance1(e.center);if(Oe.greater(b,s))return 0;if(Oe.eq(b,s))Oe.eq(t.distance2(e.start()),0)?(ae[m++]=e.start().x,ae[m++]=e.start().y,ae[m++]=e.start().x,ae[m++]=e.start().y):Oe.eq(t.distance2(e.end()),0)?(ae[m++]=e.end().x,ae[m++]=e.end().y,ae[m++]=e.end().x,ae[m++]=e.end().y):(ae[m++]=g.x,ae[m++]=g.y,ae[m++]=g.x,ae[m++]=g.y);else{m=fO(r,n,o,l,c,u,m,g);let y=ae[m-2],E=ae[m-1];m-=2;let S=_n.distance1(r,n,y,E);if(Oe.eq(S,s))ae[m++]=y,ae[m++]=E,ae[m++]=y,ae[m++]=E;else if(S<s)m=Js(a,r,n,o,l,y,E,m),m=Js(a,r,n,y,E,c,u,m);else return 0}}else if(p===-1||f===-1)m=Js(a,r,n,o,l,c,u,m);else{let g=wc.foot(t,e.center),b=g.distance1(e.center);if(Oe.eq(b,s)){let y=function(w){return uL(i,w.x,w.y)&&Yn(e,w)},E=e.start(),S=e.end();if(p===0){let w=t.start();if(y(w))return ae[m++]=w.x,ae[m++]=w.y,ae[m++]=w.x,ae[m++]=w.y,m;if(y(g))return ae[m++]=g.x,ae[m++]=g.y,ae[m++]=g.x,ae[m++]=g.y,m;if(Oe.eq(t.distance2(E),0)&&y(E))return ae[m++]=E.x,ae[m++]=E.y,ae[m++]=E.x,ae[m++]=E.y,m;if(Oe.eq(t.distance2(S),0)&&y(S))return ae[m++]=S.x,ae[m++]=S.y,ae[m++]=S.x,ae[m++]=S.y,m;if(h<=s)m=Js(a,r,n,g.x,g.y,c,u,m),m===2&&(ae[m++]=ae[0],ae[m++]=ae[1]);else if(b<s){if(m=Js(a,r,n,g.x,g.y,c,u,m),m===2&&y(new we(ae[0],ae[1])))return ae[m++]=ae[0],ae[m++]=ae[1],m;m=Js(a,r,n,g.x,g.y,o,l,0),m===2&&(ae[m++]=ae[0],ae[m++]=ae[1])}}else{let w=t.end();if(y(w))return ae[m++]=w.x,ae[m++]=w.y,ae[m++]=w.x,ae[m++]=w.y,m;if(y(g))return ae[m++]=g.x,ae[m++]=g.y,ae[m++]=g.x,ae[m++]=g.y,m;if(Oe.eq(t.distance2(E),0)&&y(E))return ae[m++]=E.x,ae[m++]=E.y,ae[m++]=E.x,ae[m++]=E.y,m;if(Oe.eq(t.distance2(S),0)&&y(S))return ae[m++]=S.x,ae[m++]=S.y,ae[m++]=S.x,ae[m++]=S.y,m;if(d<=s)m=Js(a,r,n,g.x,g.y,o,l,m),m===2&&(ae[m++]=ae[0],ae[m++]=ae[1]);else if(b<s){if(m=Js(a,r,n,g.x,g.y,o,l,m),m===2&&y(new we(ae[0],ae[1])))return ae[m++]=ae[0],ae[m++]=ae[1],m;m=Js(a,r,n,g.x,g.y,c,u,0),m===2&&(ae[m++]=ae[0],ae[m++]=ae[1])}}}else if(p===0){let y=t.start();ae[m++]=y.x,ae[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=Js(a,r,n,g.x,g.y,c,u,m))}else{let y=t.end();ae[m++]=y.x,ae[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=Js(a,r,n,g.x,g.y,o,l,m))}}if(m>0){let g=0;for(let b=0;b<m;b+=2){let y=ae[b],E=ae[b+1];isFinite(y)&&isFinite(E)&&uL(i,y,E)&&Yn(e,new we(y,E))&&(ae[g++]=y,ae[g++]=E)}return g}else return 0}else return 0}function zU(e,t){if(e.bbox()){let i=e.center.x,r=e.center.y,n=e.rx2,s=t.start().x,a=t.start().y,o=t.end().x,l=t.end().y,c=e.center.distance2(t.start()),u=e.center.distance2(t.end()),h=Oe.eq(c,n)?0:c>n?1:-1,d=Oe.eq(u,n)?0:u>n?1:-1,p=0;if(h===-1&&d===-1)return 0;if(h===0&&d===0)ae[p++]=s,ae[p++]=a,ae[p++]=o,ae[p++]=l;else if(h===1&&d===1){let f=wc.foot(t,e.center),m=f.distance2(e.center);if(Oe.greater(m,n))return 0;if(Oe.eq(m,n)){let g=f.distance2(e.start()),b=f.distance2(e.end());Oe.eq(g,0)?(ae[p++]=e.start().x,ae[p++]=e.start().y):Oe.eq(b,0)?(ae[p++]=e.end().x,ae[p++]=e.end().y):(ae[p++]=f.x,ae[p++]=f.y)}else{p=fO(i,r,s,a,o,l,p,f);let g=ae[p-2],b=ae[p-1],y=_n.distance2(i,r,g,b);if(p-=2,Oe.eq(y,n))ae[p++]=g,ae[p++]=b;else if(y<n)p=Js(n,i,r,s,a,g,b,p),p=Js(n,i,r,g,b,o,l,p);else return 0}}else if(h===-1||d===-1)p=Js(n,i,r,s,a,o,l,p);else{let f=wc.foot(t,e.center);h===0?(ae[p++]=t.start().x,ae[p++]=t.start().y,Oe.neq(f.distance2(t.start()),0)&&(s-f.x)*(o-f.x)+(a-f.y)*(l-f.y)<0&&(p=Js(n,i,r,f.x,f.y,o,l,p))):(ae[p++]=t.end().x,ae[p++]=t.end().y,Oe.neq(f.distance2(t.end()),0)&&(s-f.x)*(o-f.x)+(a-f.y)*(l-f.y)<0&&(p=Js(n,i,r,f.x,f.y,s,a,p)))}if(p>0){let f=0;for(let m=0;m<p;m+=2){let g=ae[m],b=ae[m+1];isFinite(g)&&isFinite(b)&&(ae[f++]=g,ae[f++]=b)}return f}else return 0}else return 0}function Js(e,t,i,r,n,s,a,o){if(n==a){let E=e-(n-i)*(n-i);if(Oe.greater(E,0)){let S=Math.sqrt(E),w=t-S,x=t+S,I=Math.min(r,s),A=Math.max(r,s);return w>=I&&w<=A&&(ae[o++]=w,ae[o++]=n),x>=I&&x<=A&&(ae[o++]=x,ae[o++]=n),o}}let l=_n.distance2(r,n,t,i)-e;if(l===0)return ae[o++]=r,ae[o++]=n,o;let c=_n.distance2(s,a,t,i)-e;if(c===0)return ae[o++]=s,ae[o++]=a,o;let u=r,h=n,d=s,p=a,f=NaN,m=NaN,g=Number.POSITIVE_INFINITY,b=0;for(;g!==0;){b++;let E=Math.max(Math.min(Math.abs(l)/(Math.abs(l)+Math.abs(c)),.75),.25);if(f=u+(d-u)*E,m=h+(p-h)*E,u===f&&h===m||d===f&&p===m){Math.abs(l)>Math.abs(c)?(f=d,m=p,g=c):(f=u,m=h,g=l);break}else g=_n.distance2(f,m,t,i)-e,g<0&&l>c||g>0&&l<c?(d=f,p=m,c=g):(u=f,h=m,l=g)}let y=Math.sqrt(e)-_n.distance1(f,m,t,i);return(Oe.eq(0,g)||Oe.eq(0,y))&&(ae[o++]=f,ae[o++]=m),o}function fO(e,t,i,r,n,s,a,o){let l=_n.dotProd2(i,r,n,s,e,t),c=_n.dotProd2(n,s,i,r,e,t);if(l>=0)return ae[a++]=n,ae[a++]=s,a;if(c>=0)return ae[a++]=i,ae[a++]=r,a;if(_n.crossProd2(i,r,n,s,e,t)==0)return ae[a++]=e,ae[a++]=t,a;{let u=NaN,h=NaN,d=i,p=r,f=n,m=s,g=_n.distance2(i,r,e,t),b=_n.distance2(n,s,e,t),y=Number.POSITIVE_INFINITY,E=0;for(;y>0&&(E++,u=d+(f-d)*.5,h=p+(m-p)*.5,!(g==b||d==u&&p==h||f==u&&m==h));){y=_n.distance2(u,h,e,t);let S=_n.dotProd2(d,p,u,h,e,t);if(S==0)break;S<0?(f=u,m=h,b=y):(d=u,p=h,g=y)}return _n.distance2(u,h,e,t)<_n.distance2(o.x,o.y,e,t)?(ae[a++]=u,ae[a++]=h):(ae[a++]=o.x,ae[a++]=o.y),a}}function PT(e,t){if(e.rx===e.ry)return Gx(e,t);throw new Error("not supported")}function XU(e,t){if(e.rx===e.ry)return zU(e,t);throw new Error("not supported")}function mO(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return WU(e,t);throw new Error("not supported operation")}return 0}function WU(e,t){let i=e.center.x,r=e.center.y,n=t.center.x,s=t.center.y,a=e.rx,o=t.rx,l=e.rx2,c=t.rx2,u=e.center.distance1(t.center),h=Math.abs(a-o),d=a+o;if(Oe.greater(u,d)||Oe.less(u,h))return 0;if(Oe.eq(h+u,0)){let p=0,f;return Yn(e,t.start())&&(ae[p]=t.start().x,ae[p+1]=t.start().y,p+=2,f=t.start()),Yn(e,t.end())&&(ae[p]=t.end().x,ae[p+1]=t.end().y,p+=2,f=t.end()),p===0?(Yn(t,e.start())&&(ae[p]=e.start().x,ae[p+1]=e.start().y,p+=2),Yn(t,e.end())&&(ae[p]=e.end().x,ae[p+1]=e.end().y,p+=2)):p===2&&(!f.equals1(e.start())&&Yn(t,e.start())&&(ae[p]=e.start().x,ae[p+1]=e.start().y,p+=2),!f.equals1(e.end())&&Yn(t,e.end())&&(ae[p]=e.end().x,ae[p+1]=e.end().y,p+=2)),p}else if(Oe.eq(u,d)){if(dL(e,t))return 4;let p=new me(e.center,t.center),f=Gx(t,p);return f=pL(e,f),f!==0?f:(f=Gx(e,p),pL(t,f))}else if(Oe.eq(u,h)){if(dL(e,t))return 4;if(a>o){let p=(a-o)/a;return ae[0]=i+(n-i)/p,ae[1]=r+(s-r)/p,fL(e,t,2)}else{let p=(o-a)/o;return ae[0]=n+(i-n)/p,ae[1]=s+(r-s)/p,fL(e,t,2)}}else{let p=(e.center.distance2(t.center)-c+l)/(u*2)/u,f=(n-i)*p+i,m=(s-r)*p+r,g=n-i,b=s-r,y=Math.max(a,o),E,S,w,x;if(Math.abs(g)<Math.abs(b)){let R=g/-b,M=m-R*f;E=f-y,S=R*E+M,w=f+y,x=R*w+M}else{let R=b/-g,M=f-R*m;S=m-y,E=R*S+M,x=m+y,w=R*x+M}let I=Js(l,i,r,E,S,f,m,0);if(I=Js(l,i,r,f,m,w,x,I),I!==4)throw new Error("cnt !== 4");let A=new we(ae[0],ae[1]),O=new we(ae[2],ae[3]);if(Yn(e,A)&&Yn(t,A))return Yn(e,O)&&Yn(t,O)?4:$h(e.start(),t,O,A)?(ae[2]=e.start().x,ae[3]=e.start().y,4):$h(e.end(),t,O,A)?(ae[2]=e.end().x,ae[3]=e.end().y,4):$h(t.start(),e,O,A)?(ae[2]=t.start().x,ae[3]=t.start().y,4):$h(t.end(),e,O,A)?(ae[2]=t.end().x,ae[3]=t.end().y,4):2;if(Yn(e,O)&&Yn(t,O))return $h(e.start(),t,A,O)?(ae[0]=e.start().x,ae[1]=e.start().y,4):$h(e.end(),t,A,O)?(ae[0]=e.end().x,ae[1]=e.end().y,4):$h(t.start(),e,A,O)?(ae[0]=t.start().x,ae[1]=t.start().y,4):$h(t.end(),e,A,O)?(ae[0]=t.end().x,ae[1]=t.end().y,4):(ae[0]=ae[2],ae[1]=ae[3],2);{let R=function(V,q){if(Oe.eq(V.distance1(q.center),q.rx)&&Yn(q,V)){if(V.distance2(A)<V.distance2(O)){if(M)return;M=!0}else{if(F)return;F=!0}ae[G++]=V.x,ae[G++]=V.y}},M=!1,F=!1,G=0;return R(e.start(),t),R(e.end(),t),R(t.start(),e),R(t.end(),e),G}}}function $h(e,t,i,r){return Oe.eq(e.distance1(t.center),t.rx)&&Yn(t,e)&&e.distance2(i)<e.distance2(r)}function dL(e,t){return Oe.eq(t.start().distance1(e.center),e.rx)&&Yn(e,t.start())?(ae[0]=t.start().x,ae[1]=t.start().y,ae[2]=t.start().x,ae[3]=t.start().y,!0):Oe.eq(t.end().distance1(e.center),e.rx)&&Yn(e,t.end())?(ae[0]=t.end().x,ae[1]=t.end().y,ae[2]=t.end().x,ae[3]=t.end().y,!0):Oe.eq(e.start().distance1(t.center),t.rx)&&Yn(t,e.start())?(ae[0]=e.start().x,ae[1]=e.start().y,ae[2]=e.start().x,ae[3]=e.start().y,!0):Oe.eq(e.end().distance1(t.center),t.rx)&&Yn(t,e.end())?(ae[0]=e.end().x,ae[1]=e.end().y,ae[2]=e.end().x,ae[3]=e.end().y,!0):!1}function pL(e,t){if(t===0)return 0;let i=ae[0],r=ae[1];return Yn(e,new we(i,r))?(ae[0]=i,ae[1]=r,ae[2]=i,ae[3]=r,4):0}function fL(e,t,i){if(i===0)return 0;let r=ae[0],n=ae[1],s=new we(r,n);return Yn(e,s)&&Yn(t,s)?(ae[0]=r,ae[1]=n,ae[2]=r,ae[3]=n,4):0}function Wf(e,t){return Math.abs(e-t)<=1e-6}function Yn(e,t){let i=e.bbox();if(t.x-i.minX>-Yy&&t.x-i.maxX<Yy&&t.y-i.minY>-Yy&&t.y-i.maxY<Yy){let r=ei.regularD(t.angleD(e.center));return Wf(r,e.startAngle)||Wf(r,e.startAngle+360)||Wf(r,e.startAngle-360)||Wf(r,e.endAngle())||Wf(r,e.endAngle()+360)||Wf(r,e.endAngle()-360)?!0:e.sweepAngle>0?(Oe.less(r,e.startAngle)&&(r+=360),Oe.greatereq(e.endAngle(),r)):(Oe.greater(r,e.startAngle)&&(r-=360),Oe.lesseq(e.endAngle(),r))}else return!1}function qU(e,t){let i=e[1].x-e[0].x,r=e[1].y-e[0].y,n=t[1].x-t[0].x,s=t[1].y-t[0].y;if(i===0&&n!==0||i!==0&&n===0)return!1;if(i===0&&n===0)return!0;let a=r/i,o=s/n;return pO(a,o,Math.sin(Math.PI/180))}function JU(e,t,i){var r,n=+t.x,s=+t.y,a=+i.x,o=+i.y,l=+e.x,c=+e.y,u=a-n,h=o-s,d=l-n,p=c-s,f,m,g,b,y,E;return u===0&&h===0?{d:Math.sqrt(d*d+p*p),point:new we(n,s)}:(r=(d*u+p*h)/(u*u+h*h),r<0?{d:Math.sqrt(d*d+p*p),point:new we(n,s)}:r>1?(f=l-a,m=c-o,{d:Math.sqrt(f*f+m*m),point:new we(a,o)}):(y=n+r*u,E=s+r*h,g=l-y,b=c-E,{d:Math.sqrt(g*g+b*b),point:new we(y,E)}))}function Ec(e,t){if(!e||!t||e.length!=t.length)return!1;let i="equals1";return!e.some((r,n)=>{let s=t[n],a=!1;return r&&s&&typeof r=="object"&&typeof s=="object"?typeof r[i]=="function"&&$U(r,s)?a=!r[i].call(r,s):a=!(r===s||r.toString()===s.toString()):typeof r=="number"&&typeof s=="number"?a=!(KU(r,s)||Number.isNaN(r)&&Number.isNaN(s)):a=r!==s,a})}function KU(e,t,i=5){return Math.abs(e-t)*Math.pow(10,i)<1}function $U(e,t){return!e||!t||typeof e!="object"||typeof t!="object"?e===t:e.constructor===t.constructor}var gi=new Float64Array(100);function Tx(e,t){if(e.bbox().extendOfSize(Oe.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,n=0,s=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(C){M=Math.min(M,C),F=Math.max(F,C)},o=function(C,N){let T=uu(C,N);if(T===0)throw new Error("cnt === 0");for(let L=0;L<T;L+=2)a(ae[L])};if(n>r){for(let C=n-2;C>=2;C-=2)for(let N=C-2;N>=0;N-=2)if(Oe.eq(gi[C],gi[N])&&Oe.eq(gi[C+1],gi[N+1])){gi[N]=(gi[C]+gi[N])/2,gi[N+1]=(gi[C+1]+gi[N+1])/2;for(let T=n-3;T>=C;T--)gi[T]=gi[T+2];n-=2;break}if(n>r){n=0;let C=t.start(),N=new Float64Array(8);e.getPercent(C)!==null&&(N[n++]=C.x,N[n++]=C.y);let T=t.end();e.getPercent(T)!==null&&(N[n++]=T.x,N[n++]=T.y);let L=e.start();t.getPercent(L)!==null&&(N[n++]=L.x,N[n++]=L.y);let P=e.end();return t.getPercent(P)!==null&&(N[n++]=P.x,N[n++]=P.y),ae.set(N),n}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let C=uu(new me(u[0],u[1]),new me(h[0],h[1]));for(let N=0;N<C;N++)gi[n++]=ae[N];continue}let d=u[0],p=u[u.length-1];d.equals1(p)&&(p=d.add1(1,0));let f=p.y-d.y,m=d.x-p.x,g=-f*d.x-m*d.y,b=Math.sqrt(1/(f**2+m**2));f*=b,m*=b,g*=b;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(C=>{let N=f*C.x+m*C.y+g;N<y&&(y=N),N>E&&(E=N)}),Oe.eq(y,E)){if(c.controls.length===2){let C=uu(new me(l.start(),l.end()),new me(c.start(),c.end()));for(let N=0;N<C;N++)gi[n++]=ae[N];if(C!==0)continue}l=new ct([u[0],u[u.length-1]]),u=l.controls}let S=h.map(C=>{let N=f*C.x+m*C.y+g,T=Math.abs(N);return T<s&&(s=T),N}),w=0;for(let C of S){if(Oe.less(C,y))w=w|1;else if(Oe.greater(C,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let x=0,I=0,A=p.x-d.x,O=p.y-d.y,R=Math.sqrt(1/(A**2+O**2));A*=R,O*=R;for(let C=1;C<u.length;C++){let N=u[C],T=(N.x-d.x)*A+(N.y-d.y)*O;T<x?x=T:T>I&&(I=T)}w=0;for(let C of h){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(Oe.less(N,x))w=w|1;else if(Oe.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;s/=2,s<=Oe.eps&&(s=Oe.eps),y-=s,E+=s,S.forEach((C,N)=>{C>=y&&C<=E&&a(N/(S.length-1))});let G=new me(new we(0,y),new we(1,y)),V=new me(new we(0,E),new we(1,E));for(let C=0;C<S.length-1;C++){let N=new we(C/(S.length-1),S[C]),T=N.y<y?1:N.y>E?2:3;for(let L=0;L<S.length;L++){let P=new we(L/(S.length-1),S[L]),B=P.y<y?1:P.y>E?2:3;T!==B&&(T===1?B===2?(o(new me(N,P),G),o(new me(N,P),V)):o(new me(N,P),G):T===2?B===1?(o(new me(N,P),G),o(new me(N,P),V)):o(new me(N,P),V):B===1?o(new me(N,P),G):o(new me(N,P),V))}}M!==0&&(c=c.clip(M)[1]),F!==1&&(c=c.clip((F-M)/(1-M))[0]);let q=c.bbox();if(Oe.eq(q.minX,q.maxX)&&Oe.eq(q.minY,q.maxY)){w=0;for(let C of c.controls){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(Oe.less(N,x))w=w|1;else if(Oe.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let C=new we((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(C)&&(gi[n++]=C.x,gi[n++]=C.y)}continue}if(F-M>.8){let[C,N]=c.clip(.5);i.push([C,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)ae[a]=gi[a];return n}function ZU(e,t){if(e.bbox().extendOfSize(Oe.eps).isSeparated(t.bbox()))return{cnt:0};let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,n=0,s=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(C){M=Math.min(M,C),F=Math.max(F,C)},o=function(C,N){let T=uu(C,N);if(T===0)throw new Error("cnt === 0");for(let L=0;L<T;L+=2)a(ae[L])};if(n>r){for(let C=n-2;C>=2;C-=2)for(let N=C-2;N>=0;N-=2)if(Oe.eq(gi[C],gi[N])&&Oe.eq(gi[C+1],gi[N+1])){gi[N]=(gi[C]+gi[N])/2,gi[N+1]=(gi[C+1]+gi[N+1])/2;for(let T=n-3;T>=C;T--)gi[T]=gi[T+2];n-=2;break}if(n>r){n=0;let C=new Float64Array(8),N=t.end(),T=0;e.getPercent(N)!==null&&(C[n++]=N.x,C[n++]=N.y,T=2);let L=e.end();return t.getPercent(L)!==null&&(C[n++]=L.x,C[n++]=L.y,T=T===0?1:3),ae.set(C),{havOverlap:T,cnt:n}}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let C=uu(new me(u[0],u[1]),new me(h[0],h[1]));for(let N=0;N<C;N++)gi[n++]=ae[N];continue}let d=u[0],p=u[u.length-1];d.equals1(p)&&(p=d.add1(1,0));let f=p.y-d.y,m=d.x-p.x,g=-f*d.x-m*d.y,b=Math.sqrt(1/(f**2+m**2));f*=b,m*=b,g*=b;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(C=>{let N=f*C.x+m*C.y+g;N<y&&(y=N),N>E&&(E=N)}),Oe.eq(y,E)){if(c.controls.length===2){let C=uu(new me(l.start(),l.end()),new me(c.start(),c.end()));for(let N=0;N<C;N++)gi[n++]=ae[N];if(C!==0)continue}l=new ct([u[0],u[u.length-1]]),u=l.controls}let S=h.map(C=>{let N=f*C.x+m*C.y+g,T=Math.abs(N);return T<s&&(s=T),N}),w=0;for(let C of S){if(Oe.less(C,y))w=w|1;else if(Oe.greater(C,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let x=0,I=0,A=p.x-d.x,O=p.y-d.y,R=Math.sqrt(1/(A**2+O**2));A*=R,O*=R;for(let C=1;C<u.length;C++){let N=u[C],T=(N.x-d.x)*A+(N.y-d.y)*O;T<x?x=T:T>I&&(I=T)}w=0;for(let C of h){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(Oe.less(N,x))w=w|1;else if(Oe.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;s/=2,s<=Oe.eps&&(s=Oe.eps),y-=s,E+=s,S.forEach((C,N)=>{C>=y&&C<=E&&a(N/(S.length-1))});let G=new me(new we(0,y),new we(1,y)),V=new me(new we(0,E),new we(1,E));for(let C=0;C<S.length-1;C++){let N=new we(C/(S.length-1),S[C]),T=N.y<y?1:N.y>E?2:3;for(let L=0;L<S.length;L++){let P=new we(L/(S.length-1),S[L]),B=P.y<y?1:P.y>E?2:3;T!==B&&(T===1?B===2?(o(new me(N,P),G),o(new me(N,P),V)):o(new me(N,P),G):T===2?B===1?(o(new me(N,P),G),o(new me(N,P),V)):o(new me(N,P),V):B===1?o(new me(N,P),G):o(new me(N,P),V))}}M!==0&&(c=c.clip(M)[1]),F!==1&&(c=c.clip((F-M)/(1-M))[0]);let q=c.bbox();if(Oe.eq(q.minX,q.maxX)&&Oe.eq(q.minY,q.maxY)){w=0;for(let C of c.controls){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(Oe.less(N,x))w=w|1;else if(Oe.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let C=new we((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(C)&&(gi[n++]=C.x,gi[n++]=C.y)}continue}if(F-M>.8){let[C,N]=c.clip(.5);i.push([C,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)ae[a]=gi[a];return{cnt:n}}var QU=class{constructor(e=Oe.eps){this.eps=e}eq(e,t){return Math.abs(e-t)<=this.eps}setEps(e){this.eps=e}},Ny=new QU;function mL(e,t){if(e.bbox().extendOfSize(Oe.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(t.controls.length-1)*16,n=0;for(;i.length!==0;){if(n>r){let a=function(){for(let c=0;c<n;c+=2)for(let u=c+2;u<n;u+=2)if(!(Ny.eq(gi[c],gi[u])&&Ny.eq(gi[c+1],gi[u+1]))){l(gi[u],gi[u+1],o);break}function l(c,u,h){let d=!1;for(let p=0;p<h.length;p+=2)if(Ny.eq(c,h[p])&&Ny.eq(u,h[p+1])){d=!0;break}d||h.push(c,u)}},o=[gi[0],gi[1]];if(a(),o.length>=100&&(Ny.setEps(.001),o=[gi[0],gi[1]],a(),o.length>=100))throw new Error("clearSamePoint()");n=o.length,o.forEach((l,c)=>gi[c]=l)}let s=i.pop();if(s[0]instanceof Pe){let a=function(V){O=Math.min(O,V),R=Math.max(R,V)},o=function(V,q){let C=uu(V,q);if(C===0)throw new Error("cnt === 0");for(let N=0;N<C;N+=2)a(ae[N])},[l,c]=s,u=c.controls;if(u.length===2){let V=PT(l,new me(u[0],u[1]));for(let q=0;q<V;q++)gi[n++]=ae[q];continue}let h=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,p,f,m,g,b;if(Math.abs(l.sweepAngle)>359){let V=l.rx;p=l.center.add1(V,0),f=l.center.add1(-V,0),h=-V,d=V,m=0,g=1,b=-l.center.y}else{p=l.start(),f=l.end(),m=f.y-p.y,g=p.x-f.x,b=-m*p.x-g*p.y;let V=Math.sqrt(1/(m**2+g**2));m*=V,g*=V,b*=V;let q=m*l.center.x+g*l.center.y+b;l.isCCW?(d=l.rx+q,h=0):(h=q-l.rx,d=0)}let y=u.map(V=>m*V.x+g*V.y+b),E=0;for(let V of y){if(Oe.less(V,h))E=E|1;else if(Oe.greater(V,d))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let S=0,w=0,x=f.x-p.x,I=f.y-p.y,A=Math.sqrt(1/(x**2+I**2));if(x*=A,I*=A,Math.abs(l.sweepAngle)<=180)S=0,w=(f.x-p.x)*x+(f.y-p.y)*I;else throw new Error("not support");E=0;for(let V of u){let q=(V.x-p.x)*x+(V.y-p.y)*I;if(Oe.less(q,S))E=E|1;else if(Oe.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let O=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY;h-=Oe.eps,d+=Oe.eps,y.forEach((V,q)=>{V>=h&&V<=d&&a(q/(y.length-1))});let M=new me(new we(0,h),new we(1,h)),F=new me(new we(0,d),new we(1,d));for(let V=0;V<y.length-1;V++){let q=new we(V/(y.length-1),y[V]),C=q.y<h?1:q.y>d?2:3;for(let N=0;N<y.length;N++){let T=new we(N/(y.length-1),y[N]),L=T.y<h?1:T.y>d?2:3;C!==L&&(C===1?L===2?(o(new me(q,T),M),o(new me(q,T),F)):o(new me(q,T),M):C===2?L===1?(o(new me(q,T),M),o(new me(q,T),F)):o(new me(q,T),F):L===1?o(new me(q,T),M):o(new me(q,T),F))}}O!==0&&(c=c.clip(O)[1]),R!==1&&(c=c.clip((R-O)/(1-O))[0]);let G=c.bbox();if(Oe.eq(G.minX,G.maxX)&&Oe.eq(G.minY,G.maxY)){E=0;for(let V of c.controls){let q=(V.x-p.x)*x+(V.y-p.y)*I;if(Oe.less(q,S))E=E|1;else if(Oe.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}E===3&&(gi[n++]=(G.minX+G.maxX)/2,gi[n++]=(G.minY+G.maxY)/2);continue}R-O>.8?c.clip(.5).forEach(V=>i.push([V,l])):i.push([c,l])}else{let[a,o]=s;i.push([Pe.build3(o.center,o.startAngle,o.sweepAngle/2,o.rx,o.ry),a]),i.push([Pe.build3(o.center,o.startAngle+o.sweepAngle/2,o.sweepAngle/2,o.rx,o.ry),a])}}for(let s=0;s<n;s++)ae[s]=gi[s];return n}var eY=class{static getSweep(e){if(e.length>2){let t=0,i=e.length;for(let s=0;s<i-1;s++){let a=e[s],o=e[s+1];t+=(o.x+a.x)*(o.y-a.y)}let r=e[0],n=e[i-1];return t+=(r.x+n.x)*(r.y-n.y),t>0}else throw new Error("Unable to determine the direction of rotation!")}static isClose(e){return!!(e.primitives.length>0&&e.primitives[0].start().equals1(e.primitives[e.primitives.length-1].end()))}};function tY(e){let t=e.primitives,i=t[0],r=i instanceof Pe?i.sweepAngle%360:null;if(t.length===1&&i instanceof Pe&&(Oe.eq(r,0)||Oe.eq(Math.abs(r),360)))return!!i.isCCW;let n=new Array;return e.points(.1,s=>{n.push(s)}),eY.getSweep(n)}var iY=class{static zoomCorner(e,t){let i=new Array,r=new Array,n=new Array;return this.getPanPrimitive(e,i,n,t),this.rearrange(i,n),this.processStart(i,n),this.getResult(i,n,r,t),r.length>0?wi.build2(r):null}static zoomPolygon(e,t){let i=new Array,r=new Array,n=new Array;return tY(e)&&(e=e.reverse().asClose()),this.getPanPrimitive(e,i,n,t),this.rearrange(i,n),this.processStart(i,n),this.getResult(i,n,r,t),r.length>0?wi.build2(r):null}static zoomLines(e,t){return this.zoomPolygon(wi.build2(e.primitives.concat(e.reverse().primitives)),t/2)}static getPanPrimitive(e,t,i,r){let n=e.primitives;for(let s of n){let a=this.panDistance(s,r);a!==void 0&&(t.push(a),i.push(s))}}static rearrange(e,t){let i=e.length,r=0;for(let a=0;a<i;a++){let o=t[a],l=e[a],c=a==i-1?e[0]:e[a+1];if(!(l instanceof Pe&&c instanceof Pe)&&!this.isCW(l.end(),c.start(),o.end())){if(Pl(l,c)!=0){r=a==i-1?0:a+1;break}}else{r=a;break}}let n=this.start4Index(t,r),s=this.start4Index(e,r);t.length=0,e.length=0,n.forEach(a=>{t.push(a)}),s.forEach(a=>{e.push(a)})}static processStart(e,t){let i=e.length;if(i>2){let r=e[i-1],n=e[0],s=t[i-1];if(!(r instanceof Pe&&n instanceof Pe)&&!this.isCW(r.end(),n.start(),s.end())){let a=Pl(r,n);for(let o=0;o<a;o+=2){let l=new we(ae[o],ae[o+1]);e[i-1]=this.generatePrimitive(r,r.start(),l),e[0]=this.generatePrimitive(n,l,n.end())}}}}static getResult(e,t,i,r){let n=e.length;for(let s=0;s<n;s++){let a=t[s],o=s===n-1?t[0]:t[s+1],l=s==n-1?0:s+1,c=l==n-1?t[0]:t[l+1],u=e[s],h=s==n-1?e[0]:e[s+1],d=l==n-1?e[0]:e[l+1];if(!(u instanceof Pe&&h instanceof Pe)&&!this.isCW(u.end(),h.start(),a.end())){let f=this.add(e,i,s,u,h,0);f=this.update(e,i,s,h,f);let m=this.generateArc(o,c,h,d,r);if(f=this.add(e,i,s,u,m,f),f=this.update(e,i,s,m,f),f>0)continue}i.push(u);let p=this.generateArc(a,o,u,h,r);p!==void 0&&i.push(p)}}static generateArc(e,t,i,r,n){if(n>0){let s=e.end(),a=t.start(),o=i.end(),l=r.start();if(o.distance2(l)>1e-8)if(s.equals(a)){let c=o.angleD(s),u=l.angleD(s);return Pe.build2(s,c,u,n,n,0)}else{let c=o.angleD(s),u=l.angleD(s),h=o.angleD(a),d=l.angleD(a),p=Pe.build2(s,c,u,n,n,0),f=Pe.build2(a,h,d,n,n,0);return p.pointOn(p.endAngle()).equals1(l)?p:f.pointOn(f.endAngle()).equals1(l)?f:p}}}static updateNews(e,t,i,r){let n=e.length,s=t==n-1?0:t+1;e[s]=this.generatePrimitive(i,r,i.end())}static add(e,t,i,r,n,s){if(s>0)return s;if(r!=null&&n!=null){let a=Pl(r,n);for(let o=0;o<a;o+=2){let l=new we(ae[o],ae[o+1]);t.push(this.generatePrimitive(r,r.start(),l)),this.updateNews(e,i,n,l);break}return a}else return 0}static update(e,t,i,r,n){if(n>0)return n;let s=t.length;if(s>0&&r!=null){let a=t[s-1],o=Pl(a,r);for(let l=0;l<o;l+=2){let c=new we(ae[l],ae[l+1]);t[s-1]=this.generatePrimitive(a,a.start(),c),this.updateNews(e,i,r,c)}return o}else return 0}static generatePrimitive(e,t,i){if(e instanceof me)return new me(t,i);if(e instanceof Pe){let r=e,n=t.angleD(r.center),s=i.angleD(r.center);return Pe.build2(r.center,n,s,r.rx,r.ry,r.sweep())}else throw new Error("not supported operation")}static start4Index(e,t){let i=e.length,r=new Array;for(let n=t;n<i;n++)r.push(e[n]);for(let n=0;n<t;n++)r.push(e[n]);return r}static isCW(e,t,i){let r=new me(i,e),n=new me(i,t),s=r.end().x-r.start().x,a=r.end().y-r.start().y,o=n.end().x-n.start().x,l=n.end().y-n.start().y;return!(s*l-a*o>0)}static panDistance(e,t){if(e instanceof me){if(e.isPoint())return;{let i=e.panDistance(t);return i.length()>1e-5?i:void 0}}else if(e instanceof Pe){let i=e;if(i.sweepAngle>0){if(i.rx-t<=0||i.ry-t<=0)return}else if(i.sweepAngle<0&&(i.rx+t<=0||i.ry+t<=0))return;return i=i.panDistance(t),i.start().distance1(i.end())>1e-5||Oe.eq(Math.abs(i.sweepAngle),360)?i:void 0}else throw new Error("not supported operation")}},Ut=.001,Sa=Ut**2;function At(e,t){return e.distance2(t)<Sa}function du(e,t){return Math.abs(e-t)<=1e-4}function rY(e,t){if(e instanceof me)return new me(e.start(),t);if(e instanceof Pe){let i=t.angleD(e.center);return du(ei.regularD(e.startAngle),ei.regularD(i))?Pe.build3(e.center,e.startAngle,0,e.rx,e.ry):Pe.build2(e.center,e.startAngle,i,e.rx,e.ry,e.isCCW?1:0)}else{if(e instanceof ct)return e.clip(e.getPercent(t,Ut))[0];throw new Error("not supported operation")}}function vc(e,t=ei.toRadians(e.startAngle)){return e.isCCW?t+=Fx:t-=Fx,new we(Math.cos(t),Math.sin(t))}function e0(e,t=0){let i=e.controls;if(t===0){let r=i[0],n=i.slice(1).find(s=>!(s.x===r.x&&s.y===r.y));if(!n)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return n.sub(r)}else if(t===1){let r=i[i.length-1],n=i.slice(0,-1).reverse().find(s=>!(s.x===r.x&&s.y===r.y));if(!n)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return r.sub(n)}if(i.length===3){let[r,n,s]=i;return n.sub(r).mul(2*(1-t)).add(s.sub(n).mul(2*t)).normalize()}else{let[r,n,s,a]=i;return n.sub(r).mul(3*(1-t)**2).add(s.sub(n).mul(6*(1-t)*t)).add(a.sub(s).mul(3*t**2)).normalize()}}function um(e,t,i){let r=e.slice(1).findIndex(s=>!(s.x===t.x&&s.y===t.y)),n=e[r+1];if(i&&(i.getPercent(n,Ut)!==null||new me(i.start(),i.end()).distance(n)<=Ut)&&(n=e[r+2]),!n)throw Error("getSecondPoint(controls: readonly Vector2[])");return n}function Gt(e,t){if(e instanceof me)return e.end().sub(e.start()).normalize();if(e instanceof Pe)return(t?vc(e,t.angle(e.center)):vc(e)).normalize();if(e instanceof ct)if(e.controls.length===2){let[i,r]=e.controls;if(At(i,r))throw Error("equalsPP(p0, p1)");return r.sub(i).normalize()}else return(t?e0(e,e.getPercent(t,Ut)):e0(e)).normalize();else throw new Error("not support")}function nY(e,t,i){let r=[],n=t**2-4*e*i;if(n>=0){let s=-t/(2*e),a=Math.sqrt(n)/(2*e),o=s+a;if(r.push(o),n>0){let l=s-a;r.push(l)}}return r}function sY(e,t,i,r,n=0,s=1){let a=[],o=e*Math.pow(n,3)+t*Math.pow(n,2)+i*n+r,l=e*Math.pow(s,3)+t*Math.pow(s,2)+i*s+r,c,u;if(o*l<0)for(;Math.abs(n-s)>Ut;)if(c=(n+s)/2,u=e*Math.pow(c,3)+t*Math.pow(c,2)+i*c+r,Math.abs(u)<Ut){a.push(c);break}else o*u<0?s=c:l*u<0&&(n=c);else o*l===0&&(o===0&&a.push(n),l===0&&a.push(s));return a}function eT(e,t,i){if(e instanceof me||t.distance2(i)<=Sa)return new me(t,i);if(e instanceof Pe)return Pe.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof ct){let r=e.getPercent(t,Ut),n=e.getPercent(i,Ut);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function LT(e){return Oe.greater(e,0)&&Oe.less(e,1)}function Ux(e,t,i,r){let n=e[r]-2*t[r]+i[r],s=t[r]-e[r];if(n===0)return[];let a=-s/n,o=[];return LT(a)&&o.push(a),o}function Yx(e,t,i,r,n){let s,a,o=-e[n]+3*t[n]-3*i[n]+r[n],l=2*(e[n]-2*t[n]+i[n]),c=t[n]-e[n],u=l**2-4*o*c;if(Oe.lesseq(u,0))s=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;else{let d=Math.sqrt(u);s=(-l-d)/(2*o),a=(-l+d)/(2*o);let p=o*2;if(Oe.lesseq(s,1)&&Oe.greatereq(s,0)){let f=Number.NEGATIVE_INFINITY;for(;Oe.neq(s,f);){f=s;let m=p*s+l;s=-(o*s**2+l*s+c-m*s)/m}}if(Oe.lesseq(a,1)&&Oe.greatereq(a,0)){let f=Number.NEGATIVE_INFINITY;for(;Oe.neq(a,f);){f=a;let m=p*a+l;a=-(o*a**2+l*a+c-m*a)/m}}}let h=[];return LT(a)&&h.push(a),LT(s)&&h.push(s),h}function gO(e,t){if(e.controls.length===2){let[o,l]=e.controls;At(o,l)||t.push(new me(o,l));return}let i,r;if(e.controls.length===3){let[o,l,c]=e.controls;i=Ux(o,l,c,"x"),r=Ux(o,l,c,"y")}else{let[o,l,c,u]=e.controls;i=Yx(o,l,c,u,"x"),r=Yx(o,l,c,u,"y")}i.sort((o,l)=>l-o),r.sort((o,l)=>l-o);let n=i.pop()||1,s=r.pop()||1,a=0;for(;n!==1||s!==1;)if(Oe.eq(n,s))n=i.pop()||1,s=r.pop()||1;else if(n<s){let[o,l]=e.clip((n-a)/(1-a));a=n,t.push(o),e=l,n=i.pop()||1}else{let[o,l]=e.clip((s-a)/(1-a));a=s,t.push(o),e=l,s=r.pop()||1}t.push(e)}var aY=1e-5,cI=1,ct=class Fa extends d0{constructor(t){if(super(),this._startToEndL=null,t.length<2)throw new Error("Bezier needs at least 2 endpoints");this.controls=t.slice()}get startToEndL(){return this._startToEndL===null&&(this._startToEndL=new me(this.start(),this.end())),this._startToEndL}build1(t){let i=[];return fm(t,(r,n)=>(i.push(n),!0)),new Fa(i)}start(){return this.controls[0]}end(){return this.controls[this.controls.length-1]}static pointOn(t,i){if(i.length<1)throw new Error("bezier must have at least 1 point");if(i.length===1)return i[0];{let r=new Array(i.length-1);for(let n=1;n<i.length;n++){let s=i[n-1],a=i[n],o=(a.x-s.x)*t,l=(a.y-s.y)*t;r[n-1]=s.add1(o,l)}return Fa.pointOn(t,r)}}clip1(t,i,r,n){if(r.push(i[0]),n.push(i[i.length-1]),i.length<2)throw new Error("bezier clip must have at least 2 point");if(i.length===2){let s=i[0],a=i[1],o=(a.x-s.x)*t,l=(a.y-s.y)*t,c=s.add1(o,l);r.push(c),n.push(c)}else{let s=new Array(i.length-1);for(let a=1;a<i.length;a++){let o=i[a-1],l=i[a],c=(l.x-o.x)*t,u=(l.y-o.y)*t;s[a-1]=o.add1(c,u)}this.clip1(t,s,r,n)}}clip(t){let i=[],r=[];return this.clip1(t,this.controls,i,r),[new Fa(i),new Fa(r.reverse())]}greater(t,i,r){return t-i>r}less(t,i,r){return t-i<-r}eq(t,i,r){return Math.abs(t-i)<=r}eqPP(t,i,r){return!t||!i?!1:this.eq(t.x,i.x,r)&&this.eq(t.y,i.y,r)}isInRange(t,i=Oe.eps){let r=this.controls.map(s=>s.y-t.y),n=0;for(let s of r){if(this.less(s,0,i))n=n|1;else if(this.greater(s,0,i))n=n|2;else{n=3;break}if(n===3)break}if(n!==3)return!1;n=0;for(let s of this.controls){let a=s.x-t.x;if(this.less(a,0,i))n=n|1;else if(this.greater(a,0,i))n=n|2;else{n=3;break}if(n===3)break}return n===3}getPercent(t,i=Oe.eps){if(!this.isInRange(t,i))return null;let r=Number.POSITIVE_INFINITY,n=[[this,0,1]];for(;n.length!==0;){let s=function(g){u=Math.min(u,g),h=Math.max(h,g)},a=function(g,b){let y=uu(g,b);if(y===0)throw new Error("cnt === 0");for(let E=0;E<y;E+=2)s(ae[E])},[o,l,c]=n.pop();if(this.eqPP(o.start(),t,i))return l;if(this.eqPP(o.end(),t,i))return c;let u=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,d=o.controls.map(g=>g.y-t.y);r=d.reduce((g,b)=>{let y=Math.abs(b);return y<g?y:g},r),r/=2,r<=i&&(r=i),d.forEach((g,b)=>{this.eq(g,0,i)&&s(b/(d.length-1))});let p=new me(new we(0,-r),new we(1,-r)),f=new me(new we(0,r),new we(1,r));for(let g=0;g<d.length-1;g++){let b=new we(g/(d.length-1),d[g]),y=this.less(b.y,0,i)?1:this.greater(b.y,0,i)?2:3;for(let E=0;E<d.length;E++){let S=new we(E/(d.length-1),d[E]),w=this.less(S.y,0,i)?1:this.greater(S.y,0,i)?2:3;y!==w&&(y===1?w===2?(a(new me(b,S),p),a(new me(b,S),f)):a(new me(b,S),p):y===2?w===1?(a(new me(b,S),p),a(new me(b,S),f)):a(new me(b,S),f):w===1?a(new me(b,S),p):a(new me(b,S),f))}}if(!isFinite(u)){if(Math.max(...d.map(g=>Math.abs(g)))<i*4)return(l+c)/2;continue}if(u!==0&&(o=o.clip(u)[1],l=(c-l)*u+l),h!==1){let g=(h-u)/(1-u);o=o.clip(g)[0],c=(c-l)*g+l}if(!o.isInRange(t,i))continue;let m=o.controls.reduce((g,b)=>g.ext2(b),new to).build1();if(this.eq(m.minX,m.maxX,i)&&this.eq(m.minY,m.maxY,i))return(l+c)/2;if(h-u>.8){let[g,b]=o.clip(.5);g.isInRange(t,i)?(n.push([g,l,(l+c)/2]),b.isInRange(t,i)&&n.push([b,(l+c)/2,c])):n.push([b,(l+c)/2,c])}else n.push([o,l,c])}return null}toBezier(){return this}toString(){return"Bezier ["+this.controls.join(" ")+"]"}bbox(){return this._bbox||(this._bbox=new to().ext3(this.points(.1)).build1()),this._bbox}bboxWithControls(){return this._bbox_controls||(this._bbox_controls=new to().ext3(this.controls).build()),this._bbox_controls}multiply3(t){let i=new Array(this.controls.length);for(let r=0;r<this.controls.length;r++){let n=this.controls[r];i[r]=n.multiply3(t)}return new Fa(i)}stroke(t,i,r,n=cI){let s=iY.zoomLines(wi.build4(this.points(n)),t);return r===0?s:s.reverse()}points(t){let i=[];return this.getBezierPoints(t,r=>i.push(r)),i}getBezierPoints(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=[this];for(i(this.start());r.length!==0;){let s=r.pop(),a=new me(s.start(),s.end());if(n(s.controls,a)<=t)i(s.end());else{let[o,l]=s.clip(.5);r.push(l,o)}}function n(s,a){let o=a.start(),l=a.end();o.equals1(l)&&(l=o.add1(1,0));let c=l.y-o.y,u=o.x-l.x,h=-c*o.x-u*o.y,d=Math.sqrt(1/(c**2+u**2));c*=d,u*=d,h*=d;let p=s.map(f=>Math.abs(c*f.x+u*f.y+h));return Math.max(...p)}}getBezierPoints3(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=t*t,n=this.controls[0],s=.5;for(;s>aY&&!(n.distance2(Fa.pointOn(s,this.controls))<=r);s*=.5);let a=Math.ceil(1/s);s=1/a,i(n);let o=0;for(let l=1;l<a;l++)o+=s,i(Fa.pointOn(o,this.controls));i(this.end())}getPointsBySlope(t){if(this.controls.length===4)return this.getPointsBySlope4(t);throw new Error("Currently, only 4 control points are supported!")}getPointsBySlope4(t){let[i,r,n,s]=this.controls,a=-3*i.x+9*r.x-9*n.x+3*s.x,o=6*i.x-12*r.x+6*n.x,l=-3*i.x+3*r.x,c=[];if(Number.isFinite(t)){let u=-3*i.y+9*r.y-9*n.y+3*s.y,h=6*i.y-12*r.y+6*n.y,d=-3*i.y+3*r.y,p=u-a*t,f=h-o*t,m=d-l*t,g=-f/(2*p),b=Math.sqrt(f**2-4*p*m)/(2*p),y=g+b;y>=0&&y<=1&&c.push(Fa.pointOn(y,this.controls));let E=g-b;E>=0&&E<=1&&c.push(Fa.pointOn(E,this.controls))}else{let u=-o/(2*a),h=Math.sqrt(o**2-4*a*l)/(2*a),d=u+h;d>=0&&d<=1&&c.push(Fa.pointOn(d,this.controls));let p=u-h;p>=0&&p<=1&&c.push(Fa.pointOn(p,this.controls))}return c}buildConverxHull(t=Oe.eps){let i=[...this.controls],r=[],n=i[0],s=1;do{let a=i[s%i.length];this.eqPP(n,a,t)||r.push(new me(n,a)),n=a,s++}while(n!==i[0]);if(r.length===0)throw Error("buildConverxHull(diff = DoubleKit.eps)");return wi.build7(r).asClose()}getExtremePoints(t){if(!t)return a(this.controls);let i=t.start(),r=t.end(),n=r.x-i.x,s=r.y-i.y;if(Math.abs(n)<=Oe.eps||Math.abs(s)<=Oe.eps)return a(this.controls);{let o=s/n;if(this.controls.length===3){i.equals1(r)&&(r=i.add1(1,0));let l=r.y-i.y,c=i.x-r.x,u=-l*i.x-c*i.y,h=Math.sqrt(1/(l**2+c**2));l*=h,c*=h,u*=h;let d=this.controls.map(m=>l*m.x+c*m.y+u),p=d[0]-2*d[1]+d[2],f=d[1]-d[0]-o/2;if(p!==0){let m=-f/p;if(Oe.greater(m,0)&&Oe.less(m,1))return[Fa.pointOn(m,this.controls)]}}else if(this.controls.length===4)return this.getPointsBySlope(o)}return[];function a(o){let l,c;if(o.length===3){let[p,f,m]=o;l=Ux(p,f,m,"x"),c=Ux(p,f,m,"y")}else if(o.length===4){let[p,f,m,g]=o;l=Yx(p,f,m,g,"x"),c=Yx(p,f,m,g,"y")}l.sort((p,f)=>f-p),c.sort((p,f)=>f-p);let u=l.pop()||1,h=c.pop()||1,d=[];for(;u!==1||h!==1;)Oe.eq(u,h)?(u=l.pop()||1,h=c.pop()||1):u<h?(d.push(Fa.pointOn(u,o)),u=l.pop()||1):(d.push(Fa.pointOn(h,o)),h=c.pop()||1);return d}}getToLineMaxDis2(t){let i=this.getExtremePoints(t),r=t.distance2(this.start()),n=t.distance2(this.end()),s=Math.max(r,n);return i.forEach(o=>a(t.distance2(o))),s;function a(o){s=Math.max(s,o)}}getToLineMinAndMaxDis_Controls(t){let i=t.start(),r=t.end();t.start().equals1(t.end())&&(r=i.add1(1,0));let n=r.y-i.y,s=i.x-r.x,a=-n*i.x-s*i.y,o=Math.sqrt(1/(n**2+s**2));n*=o,s*=o,a*=o;let l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;return this.controls.forEach(u=>{let h=n*u.x+s*u.y+a;h<l&&(l=h),h>c&&(c=h)}),{minDis:l,maxDis:c}}getPercentInLine(t){let i=[],r=[],n=this.controls,s=t.start(),a=t.end(),o=a.y-s.y,l=s.x-a.x,c=-o*s.x-l*s.y,u=Math.sqrt(1/(o**2+l**2));if(o*=u,l*=u,c*=u,o**2+l**2<=0)return i;if(n.length===3){let[h,d,p]=n,f=o*(h.x-2*d.x+p.x)+l*(h.y-2*d.y+p.y),m=2*(o*(d.x-h.x)+l*(d.y-h.y)),g=o*h.x+l*h.y+c;r=nY(f,m,g)}else if(n.length===4){let[h,d,p,f]=n,m=f.sub(p.mul(3)).add(d.mul(3)).sub(h),g=h.sub(d.mul(2)).add(p).mul(3),b=d.sub(h).mul(3),y=h,E=o*m.x+l*m.y,S=o*g.x+l*g.y,w=o*b.x+l*b.y,x=o*y.x+l*y.y+c,I=Math.sqrt(1/(E**2+S**2));E*=I,S*=I,w*=I,x*=I,r=sY(E,S,w,x)}else throw Error("not support getBeizerPointInLine");return r.forEach(h=>{h>=0&&h<=1&&i.push(h)}),i}reverse(){return new Fa(this.controls.slice().reverse())}},gp,yO=(gp=class{constructor(){this.textCache=new Map,this.numCache=new Array(20),this.boxCache=new Array(4),this.textOffsetCache=new Array(9),this.BuildLineCache=new Array(7),this.BuildTrackCache=new Array(7),this.BuildViaCache=new Array(11),this.BuildBoxCache=new Array(10),this.BuildArcCache=new Array(10),this.BuildArcTrackCache=new Array(10),this.BuildTextCache=new Array(7),this.BuildPadStyleCache=new Array(4),this.BuildPadCache=new Array(12),this.ARRAY1=new Array(1),this.ARRAY2=new Array(2),this.ARRAY3=new Array(3),this.ARRAY4=new Array(4),this.ARRAY5=new Array(5),this.ARRAY6=new Array(6),this.ARRAY7=new Array(7),this.ARRAY8=new Array(8),this.ARRAY9=new Array(9),this.ARRAY10=new Array(10),this.ARRAY11=new Array(11),this.ARRAY12=new Array(12),this.textOffsetCache[0]=we.ORIGIN,this.textOffsetCache[1]=new we(0,-.5),this.textOffsetCache[2]=new we(0,-1),this.textOffsetCache[3]=new we(-.5,0),this.textOffsetCache[4]=new we(-.5,-.5),this.textOffsetCache[5]=new we(-.5,-1),this.textOffsetCache[6]=new we(-1,0),this.textOffsetCache[7]=new we(-1,-.5),this.textOffsetCache[8]=new we(-1,-1)}static getCache(){return gp.instance==null&&(gp.instance=new gp),gp.instance}},gp.instance=null,gp),me=class bp extends d0{constructor(t,i){super(),this._a=null,this._b=null,this._c=null,this.__bbox=null,this._hashed=null,this._direct=null,this._start=t,this._end=i}get a(){return this._a===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._a}get b(){return this._b===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._b}get c(){return this._c===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._c}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}get direct(){return this._direct==null&&(this._direct=this._end.sub(this._start).normalize()),this._direct}cutLine(t){if(Oe.eq(this.distance(t),0)){let i=new bp(this._start,t);return i._a=this._a,i._b=this._b,i._c=this._c,i}return new bp(this._start,t)}get midPoint(){return this._start.add(this._end).mul(.5)}toBezier(){return new ct([this._start,this._end])}_hashCode(){let t=31,i=1;return i=t*i+this._start.hashCode(),i=t*i+this._end.hashCode(),i}start(){return this._start}end(){return this._end}center(){let t=this.start(),i=this.end();return t.add(i).mul(.5)}panDistance(t){let i=this._end.x-this._start.x,r=this._end.y-this._start.y,n=this.length();i=i*t/n,r=-r*t/n;let s=new we(this._start.x+r,this._start.y+i),a=new we(this._end.x+r,this._end.y+i);return new bp(s,a)}isPoint(){return this._start.distance2(this._end)<=1e-8}length(){return this._start.distance1(this._end)}toString(){return"Line [start="+this._start+", end="+this._end+"]"}bbox(){if(this.__bbox==null){let t=yO.getCache().boxCache;t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.__bbox=new ba(t[0],t[1],t[2],t[3])}return this.__bbox}multiply3(t){return new bp(this._start.multiply3(t),this._end.multiply3(t))}hashCode(){return this.hashed}equals(t){let i=t;return this.hashed===i.hashed&&this._start.equals(i._start)&&this._end.equals(i._end)}equals1(t){let i=t;return this.hashed===i.hashed&&this._start.equals1(i._start)&&this._end.equals1(i._end)}equals2(t){let i=[this.start(),this.end()],r=[t.start(),t.end()];return Ec(i,r)||Ec(i,r.reverse())}stroke(t,i,r){let n,s,a;this._end.x<this._start.x?(s=this._start.x-this._end.x,a=this._start.y-this._end.y,n=this._end):(s=this._end.x-this._start.x,a=this._end.y-this._start.y,n=this._start);let o=Math.sqrt(s*s+a*a),l=t/2,c,u,h;i===2?(u=-l,h=o+l):(u=0,h=o),i===0||i===2?r===0?c=wi.build5([u,-l,u,l,h,l,h,-l]):c=wi.build5([u,l,u,-l,h,-l,h,l]):r===0?c=wi.build2([Pe.build3(new we(u,0),-90,-180,l,l),Pe.build3(new we(h,0),90,-180,l,l)]):c=wi.build2([Pe.build3(new we(u,0),90,180,l,l),Pe.build3(new we(h,0),-90,180,l,l)]);let d=Math.atan2(a,s),p=hr.rotate(d).translate1(n);return c.asClose().multiply3(p)}points(t){return[this._start,this._end]}mirrorY(t){return new bp(this.start().mirrorY(t),this.end().mirrorY(t))}reverse(){return new bp(this._end,this._start)}inArea(t,i,r){let n=t.x,s=t.y,a=this._start,o=this._end,l=r==1,c=n-a.x,u=s-a.y,h=n-o.x,d=s-o.y,p=o.x-a.x,f=o.y-a.y,m=new we(-f,p).normalize(),g=p+m.x*i/2,b=f+m.y*i/2,y=g*g+b*b,E=c*c+u*u,S=h*h+d*d,w=Math.abs(c*f-u*p)/2,x=Math.sqrt(p*p+f*f)*i/4;if(w<=x&&E<=y&&S<=y){if(l)return!0;{let I=new we(n,s).sub(o).normalize(),A=new we(n,s).sub(a).normalize(),O=new we(m.x,m.y).cross(I),R=new we(m.x,m.y).cross(A);return O>=0&&R<=0}}else if(l){let I=i/2;return E<=I*I?!0:S<=I*I}else return!1}isParallel(t,i=!1){let r=Oe.eq(Math.abs(this.direct.cross(t.direct)),0),n=!i||Oe.greatereq(this.direct.dot(t.direct),0);return r&&n}distance2(t){return(this.a*t.x+this.b*t.y+this.c)**2/(this.a**2+this.b**2)}distance2ForPP(t){let{x:i,y:r}=t,{x:n,y:s}=this.start(),{x:a,y:o}=this.end();return((i-n)*(o-s)-(r-s)*(a-n))**2/((o-s)**2+(a-n)**2)}distance(t){return Math.abs(this.a*t.x+this.b*t.y+this.c)/Math.sqrt(this.a**2+this.b**2)}};function oY(e,t=.05){if(e.length<3)return e.slice();let i=e.slice(0,1),r=(s,a,o)=>UU(s.x,s.y,a.x,a.y,o.x,o.y);for(;;){i=e.slice(0,1);for(let s=1;s<e.length-1;s+=2)r(e[s],e[s-1],e[s+1])>t&&i.push(e[s]),i.push(e[s+1]);if(i.at(-1).equals1(e.at(-1))||i.push(e.at(-1)),e.length==i.length)break;e=i}let n=e[e.length-1];return i.push(n),i}var lY=yU(bU()),cY=class{constructor(){this.fac=new to,this.length=0,this.box=null,this.pt=null,this.i=0}calcBBox(e){for(this.fac.clear(),this.length=e.length,this.box=null,this.pt=null,this.i=0;this.i<this.length;this.i++)this.pt=e[this.i],this.box=this.pt.bbox(),this.fac.ext1(this.box);return this.fac.build1()}},uY=new cY,wi=class Un{constructor(t,i){this.__bbox=null,this.primitives=t,this.__bbox=i}static calcBBox(t){return uY.calcBBox(t)}static build1(t){let i=[],r=null;return Bx(t,(n,s)=>{let a=s.start();return r!==null&&!a.equals(r)&&i.push(new me(r,a)),i.push(s),r=s.end(),!0}),i.length===0&&r!=null&&i.push(new me(r,r)),new Un(i)}static build2(t){return Un.build1(DT(t))}static build3(t){let i=[],r=null;return Bx(t,(n,s)=>(r!==null&&i.push(new me(r,s)),r=s,!0)),new Un(i)}static build4(t){return this.build3(DT(t))}static build5(t){let i=[];for(let r=0;r<t.length;r+=2)i.push(new we(t[r],t[r+1]));return this.build4(i)}static build6(t){return Un.build4([t.LL(),t.LR(),t.UR(),t.UL(),t.LL()])}static build7(t){return new Un(t)}static build8(t){let i=new we(t[0],t[1]),r,n=[],s,a=(o,l)=>o.length==l&&o.every(c=>typeof c=="number");for(let o=2;o<t.length;)switch(typeof t[o]=="string"?s=t[o]:o-=1,s){case"ARC":{let l=t.slice(o+1,o+4);if(!a(l,3))throw new Error("invalid rawData");let c=l[0];r=new we(l[1],l[2]),n.push(Pe.build5(i,r,c)),i=r,o+=4;break}case"L":{let l=t.slice(o+1,o+3);if(!a(l,2))throw new Error("invalid rawData");r=new we(l[0],l[1]),n.push(new me(i,r)),i=r,o+=3;break}case"C":{let l=t.slice(o+1,o+7);if(!a(l,7))throw new Error("invalid rawData");let c=new we(l[0],l[1]),u=new we(l[2],l[3]);r=new we(l[4],l[5]),n.push(new ct([i,c,u,r])),i=r,o+=7;break}default:throw new Error("invalid rawData")}return Un.build2(n)}static buildBBox(t,i=0){return i===1?Un.build5([t.minX,t.minY,t.maxX,t.minY,t.maxX,t.maxY,t.minX,t.maxY,t.minX,t.minY]):Un.build5([t.minX,t.minY,t.minX,t.maxY,t.maxX,t.maxY,t.maxX,t.minY,t.minX,t.minY])}static triangulate(t,i,r=1){if(t.length===1){let l=new Array;t[0].asClose().points2(r,d=>l.push(d));let c,u=l[0],h=[];for(let d=0;d<l.length-2;d+=2){let p=l[d+1],f=l[d+2],m=p.sub(u).normalize().cross(f.sub(u).normalize());if(Oe.neq(m,0)){if(c===!0){if(m<0){h.length=0;break}}else if(c===!1){if(m>0){h.length=0;break}}else c=m>0;h.push(u),h.push(p),h.push(f)}l.push(u),u=f}if(h.length!==0){for(let d=0;d<h.length;d+=3)i(h[d],h[d+1],h[d+2]);return}}let n=[],s=[];t.forEach(l=>{n.length!==0&&s.push(n.length/2),l.asClose().points2(r,c=>n.push(c.x,c.y))});let a=lY.default(n,s),o=[];for(let l=1;l<n.length;l+=2)o.push(new we(n[l-1],n[l]));for(let l=0;l<a.length;l+=3)i(o[a[l]],o[a[l+1]],o[a[l+2]])}lines(t,i){let r=new Array;this.points(t,s=>r.push(s));let n=r[0];for(let s=1;s<r.length;s++){let a=r[s];i(n),i(a),n=a}}triangles(t,i){Un.triangulate([this],(...r)=>{r.forEach(n=>i(n))},t)}mirror(){let t=[];return this.primitives.forEach(i=>{if(i instanceof me)i=new me(i.start().mirror(),i.end().mirror());else if(i instanceof Pe)i=i.mirror();else if(i instanceof ct){let r=i.controls.map(n=>n.mirror());i=new ct(r)}else throw new Error("bug");t.push(i)}),new Un(t,this.__bbox)}getPoints(t){let i=[];for(let r of this.primitives)for(let n of r.points(t))i.push(n);return i}round(t=4){let i=this.primitives.slice();for(let r=0;r<i.length;r++){let n=i[r];if(n instanceof me){let s=n.start().round(t),a=n.end().round(t);i[r]=new me(s,a)}else if(n instanceof ct){let s=n.controls.map(a=>a.round(t));i[r]=new ct(s)}else if(n instanceof Pe){let s=n.start().round(t),a=n.end().round(t),o=n.sweepAngle;i[r]=Pe.build5(s,a,o)}}return new Un(i,this.__bbox)}simplify(t=.05){let i=[],r=!1,n=[],s=this.closed();if(this.primitives.length<=1)return Un.build2(this.primitives);let a=()=>{if(n.length>2){let l=oY(n,t);for(let c=1;c<l.length;c++)i.push(new me(l[c-1],l[c]))}else i.push(new me(n[0],n[1]));n.length=0,r=!1};for(let l=0;l<this.primitives.length;l++){let c=this.primitives[l];c instanceof me?(r?n.push(c.end()):(n.length=0,n.push(c.start(),c.end()),r=!0),l===this.primitives.length-1&&a()):(r&&a(),i.push(c))}let o=new Un(i,this.__bbox);return s&&!o.closed()&&(o=o.asClose()),o}hasBackLine(){let{primitives:t}=this,i;for(let r=0;r<t.length;r++){let n=t[r];if(n instanceof me){if(n.end().equals1(n.start()))continue;if(i&&(n.end().equals1(i.start())||YU(n.end(),i.start(),i.end())))return!0;i=n}else i=null}return!1}area(t=.1){let i=0,r=this.end();return this.primitives.forEach(n=>{let s=n.start(),a=n.end();if(i+=(s.x+r.x)*(s.y-r.y),n instanceof me)i+=(a.x+s.x)*(a.y-s.y);else if(n instanceof Pe)i+=(a.x+s.x)*(a.y-s.y),i+=Math.PI*n.rx2*n.sweepAngle/180-we.normal(n.center,n.start(),n.end());else if(n instanceof ct){let o=s;n.points(t).forEach(l=>{i+=(l.x+o.x)*(l.y-o.y),o=l}),i+=(a.x+o.x)*(a.y-o.y)}r=a}),i/2}closed(t){return this.primitives.length===0?!1:this.start().equals(this.end(),t)}asClose(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),n=i.end();if(r.equals(n))return this;{let s=new Array;return xa.addAll(s,this.primitives),s.push(new me(n,r)),Un.build2(s)}}closeEndpoint(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),n=i.end();if(r.equals1(n))return this;{let s=new Array;return xa.addAll(s,this.primitives),s.push(new me(n,r)),new Un(s)}}reverse(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let n=this.primitives[r];if(n instanceof me)n=new me(n.end(),n.start());else if(n instanceof Pe)n=n.exchangeSweep();else if(n instanceof ct)n=new ct(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new Un(t,this.__bbox)}reverse1(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let n=this.primitives[r];if(n instanceof me)n=new me(n.end(),n.start());else if(n instanceof Pe)n=n.exchangeSweep1();else if(n instanceof ct)n=new ct(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new Un(t,this.__bbox)}mirrorY(t){let i=[];return this.primitives.forEach(r=>{if(r instanceof me)r=r.mirrorY(t);else if(r instanceof Pe)r=r.mirrorY(t);else if(r instanceof ct){let n=r.controls.map(s=>s.mirrorY(t));r=new ct(n)}else throw new Error("bug");i.push(r)}),new Un(i,this.__bbox)}points(t,i){if(this.primitives.length!==0){for(let r=0;r<this.primitives.length-1;r++){let n=this.primitives[r].points(t);n.pop(),n.forEach(s=>i(s))}this.primitives[this.primitives.length-1].points(t).forEach(r=>i(r))}}points1(t,i){if(this.primitives.length===0)return;for(let n=0;n<this.primitives.length-1;n++){let s=this.primitives[n],a=s instanceof Pe?s.points1(t):s.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Pe?r.points1(t):r.points(t)).forEach(n=>i(n))}points2(t,i){if(this.primitives.length===0)return;for(let n=0;n<this.primitives.length-1;n++){let s=this.primitives[n],a=s instanceof Pe?s.points2():s.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Pe?r.points2():r.points(t)).forEach(n=>i(n))}multiply3(t){let i=new Array(this.primitives.length);for(let r=0;r<this.primitives.length;r++)i[r]=this.primitives[r].multiply3(t);return Un.build7(i)}bbox(){return this.__bbox==null&&(this.__bbox=Un.calcBBox(this.primitives)),this.__bbox}start(){return this.primitives.length!==0?this.primitives[0].start():null}end(){return this.primitives.length!==0?this.primitives[this.primitives.length-1].end():null}isClose(t){if(this.primitives.length<=1&&!(this.primitives[0]instanceof Pe))return!1;{let i=this.primitives[0],r=this.primitives[this.primitives.length-1];return i.start().equals(r.end(),t)}}isEqual(t){if(t instanceof Un&&t.primitives.length==this.primitives.length){let i=t.primitives.length;for(let r=0;r<i;r++){let n=t.primitives[r],s=this.primitives[r];if(JSON.stringify(n)!=JSON.stringify(s))return!1}return!0}return!1}equals(t){if(!t)return!1;let i=this.primitives,r=t.primitives;if(i.length!=r.length)return!1;if(t.isClose()){let n=0;for(;n<i.length;){let s=i.slice(n).concat(i.slice(0,n));if(Ec(s,r)||Ec(s.reverse(),r))return!0;n++}return!1}else return Ec(this.primitives,t.primitives)}clone(){return Un.build2(this.primitives)}putItem(t,i){if(!t)return!1;if(t instanceof Un)return this.mergePolyline(t,i);let r=this.start();if(!r){this.primitives.push(t),this.__bbox=t.bbox();return}let n=this.end();if(r.equals(n,i))return!1;let s=t.start(),a=t.end(),o=!1,l=!1;if(r.equals(s,i))o=!0,l=!1;else if(r.equals(a,i))o=!1,l=!1;else if(n.equals(s,i))o=!1,l=!0;else if(n.equals(a,i))o=!0,l=!0;else return!1;return l?this.primitives.push(o?t.reverse():t):this.primitives.unshift(o?t.reverse():t),this.__bbox=ba.extend2(this.__bbox,t.bbox()),!0}mergePolyline(t,i,r=0){if(!t)return!1;let n=this.start();if(!n){this.primitives.push(...t.primitives),this.__bbox=t.bbox();return}let s=this.end();if(n.equals(s,i))return!1;let a=t.start(),o=t.end(),l=!1,c=!1;if(n.equals(a,i))l=!0,c=!1;else if(n.equals(o,i))l=!1,c=!1;else if(s.equals(a,i))l=!1,c=!0;else if(s.equals(o,i))l=!0,c=!0;else return!1;let u=l?t.reverse():t;return c?this.primitives.push(...u.primitives):this.primitives.unshift(...u.primitives),this.__bbox=ba.extend2(this.__bbox,t.bbox()),!0}deDuplicationPoint(t){let i=this.primitives[this.primitives.length-1].start(),r=this.primitives[this.primitives.length-1].end(),n=t.primitives[0].start(),s=t.primitives[0].end();if(this.primitives[this.primitives.length-1]instanceof me&&t.primitives[0]instanceof me&&qU([i,r],[n,s])){this.primitives.pop(),t.primitives.shift();let a=[];a.push(new me(i,s)),this.primitives.push(...a)}}getMaxBBoxHeightByVec(t){let i=t.normalize(),r=-1/0,n=1/0;if(this.primitives.forEach(a=>{let o=a.start().dot(i),l=a.end().dot(i);if(s(o),s(l),a instanceof Pe){let c=t.angleD(we.ORIGIN);if(a.angleIsInArc(c)){let u=a.pointOn(c).dot(i);s(u)}if(a.angleIsInArc(c+180)){let u=a.pointOn(c-180).dot(i);s(u)}}}),r-n<=0)throw new Error("getMaxBBoxHeightByVec");return r-n;function s(a){a>r&&(r=a),a<n&&(n=a)}}getWindingNum(t){let i=this.end(),r=0,{x:n,y:s}=t;for(let o of this.primitives){if(i.y>s?o.bbox().minY>s:o.bbox().maxY<=s){i=o.end();continue}if(o instanceof Pe&&(o.isCCW?Math.floor(o.startAngle/90)+1!==Math.ceil(o.endAngle()/90):Math.ceil(o.startAngle/90)-1!==Math.floor(o.endAngle()/90))){let l=o.startAngle,c=o.endAngle();if(o.sweepAngle>0){let u=90;for(;u<=c;)u>l&&(a(Pe.build3(o.center,l,u-l,o.rx,o.ry)),l=u),u+=90;l<c&&a(Pe.build3(o.center,l,c-l,o.rx,o.ry))}else{let u=270;for(;u>=c;)u<l&&(a(Pe.build3(o.center,l,u-l,o.rx,o.ry)),l=u),u-=90;l>c&&a(Pe.build3(o.center,l,c-l,o.rx,o.ry))}}else if(o instanceof ct){let l=[];gO(o,l),l.forEach(c=>a(c))}else a(o)}return r;function a(o){let l=o.start(),c=o.end();if(i.y>s!=l.y>s&&(i.x>n?l.x>n?r+=l.y>i.y?1:-1:i.y>l.y?(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)<0&&r--:(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)>0&&r++:l.x>n&&(i.y>l.y?(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)<0&&r--:(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)>0&&r++)),l.y>s!=c.y>s){if(l.x>n)if(c.x>n)r+=c.y>l.y?1:-1;else if(o instanceof me)l.y>c.y?(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)<0&&r--:(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)>0&&r++;else if(o instanceof Pe){let{center:u,isCCW:h,rx2:d}=o,p=(u.x-n)**2+(u.y-s)**2;l.y>c.y?(h?p>d:p<d)&&r--:(h?p<d:p>d)&&r++}else if(o instanceof ct){if(cL(o,s)===0)throw new Error("no inters");ae[0]>n&&(r+=c.y>l.y?1:-1)}else throw new Error("not support!");else if(c.x>n)if(o instanceof me)l.y>c.y?(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)<0&&r--:(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)>0&&r++;else if(o instanceof Pe){let{center:u,isCCW:h,rx2:d}=o,p=(u.x-n)**2+(u.y-s)**2;l.y>c.y?(h?p>d:p<d)&&r--:(h?p<d:p>d)&&r++}else if(o instanceof ct){if(cL(o,s)===0)throw new Error("no inters");ae[0]>n&&(r+=c.y>l.y?1:-1)}else throw new Error("not support!")}i=c}}},ux=Math.PI*2,Wre=Math.PI/2,qre=Math.sin(Math.PI/180),hY=4,Pe=class Gr extends d0{constructor(t,i,r,n,s){super(),this._rx2=null,this._ry2=null,this._svgEnd=null,this._hashed=null,this.__bbox=null,this.rx=t,this.ry=i,this.center=r,this.startAngle=n,this.sweepAngle=s,this._start=we.ORIGIN,this._end=we.ORIGIN,this._start=this.pointOn(n),this._end=this.pointOn(n+s)}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}hashCode(){return this.hashed}_hashCode(){let t=31,i=1;return i=t*i+new we(this.rx,this.rx).hashCode(),i=t*i+this.center.hashCode(),i=t*i+new we(this.startAngle,this.sweepAngle).hashCode(),i}get rx2(){return this._rx2==null&&(this._rx2=this.rx*this.rx),this._rx2}get ry2(){return this._ry2==null&&(this._ry2=this.ry*this.ry),this._ry2}get svgEnd(){return this._svgEnd==null&&(this._svgEnd=this.getSvgEnd(this.startAngle,this.sweepAngle,this._start,this._end)),this._svgEnd}getSvgEnd(t,i,r,n){let s=i>=0?-.01:.01,a=t+i;for(;(i>=0&&a>t||i<0&&a<t)&&r.distance2(n)<2e-4;)s*=2,a+=s,n=this.pointOn(a);return n}static build1(t,i,r,n,s,a){nn.positive(r),nn.positive(n);let o=t.equals(i);if(o)return new Gr(r,n,t,0,s?360:0);{let l=t.x,c=-t.y,u=i.x,h=-i.y,d=a===0,p=(l-u)/2,f=(c-h)/2,m=Math.cos(0),g=Math.sin(0),b=m*p+g*f,y=-g*p+m*f;r=Math.abs(r),n=Math.abs(n);let E=r*r,S=n*n,w=b*b,x=y*y,I=s===d?-1:1,A=(E*S-E*x-S*w)/(E*x+S*w);A=A<0?0:A;let O=I*Math.sqrt(A),R=O*(r*y/n),M=O*-(n*b/r),F=(l+u)/2,G=(c+h)/2,V=F+(m*R-g*M),q=G+(g*R+m*M),C=(b-R)/r,N=(y-M)/n,T=(-b-R)/r,L=(-y-M)/n,P,B;B=Math.sqrt(C*C+N*N),P=C,I=N<0?-1:1;let U=ei.toDegrees(I*Math.acos(P/B));B=Math.sqrt((C*C+N*N)*(T*T+L*L)),P=C*T+N*L,I=C*L-N*T<0?-1:1;let X=P/B,J;X<-1?J=Math.acos(-1):X>1?J=Math.acos(1):J=Math.acos(X);let ne=ei.toDegrees(I*J);!d&&ne>0?ne-=360:d&&ne<0&&(ne+=360),nn.normal(U),nn.normal(ne);let fe=p*p/E+f*f/S,xe=t.distance1(i)/2;r<xe&&n<xe&&(r*=Math.sqrt(fe),n*=Math.sqrt(fe));let ve=o?0:ei.regularD(-U),Fe=o?s?360:0:-ne;return new Gr(r,n,new we(V,-q),ve,Fe)}}static build2(t,i,r,n,s,a){nn.positive(n),nn.positive(s),nn.normal(i),nn.normal(r);let o;return i===r?(i=ei.regularD(i),r=ei.regularD(r),o=0):(i=ei.regularD(i),r=ei.regularD(r),a===1?r<=i&&(r+=360):r>=i&&(i+=360),o=r-i),new Gr(n,s,t,ei.regularD(i),o)}static build3(t,i,r,n,s){return nn.positive(n),nn.positive(s),nn.normal(r),new Gr(n,s,t,ei.regularD(i),r)}static build4(t,i,r,n,s,a){let o=t.angleD(r),l=i.angleD(r);return Gr.build2(r,o,l,n,s,a)}static build5(t,i,r){r=ei.toRadians(r);let n=i.sub(t),s=new we(-n.y,n.x).normalize(),a=Math.abs(r)/2,o;if(a!=0)o=n.length()/2/Math.sin(a);else throw new Error("Can't represent circle!!!");let l=s.rotate(we.ORIGIN,a),c,u;r>0?(c=1,u=i.add(l.scale(o))):(c=0,u=t.sub(l.scale(o)));let h=ei.toDegrees(t.angle(u)),d=ei.toDegrees(i.angle(u));return Gr.build2(u,h,d,o,o,c)}static buildCircle(t,i,r=0){return Gr.build2(t,0,360,i,i,r)}start(){return this._start}end(){return this._end}isLarge(){return Math.abs(this.sweepAngle)>180}sweep(){return this.sweepAngle>=0?1:0}get isCCW(){return this.sweepAngle>=0}endAngle(){return this.startAngle+this.sweepAngle}pointOn(t){t=ei.regularD(t);let i=this.rx,r=this.ry;if(t===0)return this.center.add1(i,0);if(t===90)return this.center.add1(0,r);if(t===180)return this.center.add1(-i,0);if(t===270)return this.center.add1(0,-r);{let n=this.rx2,s=this.ry2,a=Math.tan(ei.toRadians(t)),o=a*a,l=Math.sqrt(n*s/(n+s/o)),c=Math.sqrt(n*s/(s+n*o));return t>90&&t<270&&(c=-c),t>180&&t<360&&(l=-l),isNaN(c)&&(c=0),isNaN(l)&&(l=0),this.center.add1(c,l)}}exchangeSweep(){return Gr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,this.rx,this.ry)}exchangeSweepAndStart(){return Gr.build1(this.end(),this.start(),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}exchangeSweep1(){return Gr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle+.01,this.rx,this.ry)}mirrorY(t){let i=this.start(),r=this.end();return i.equals(r)?Gr.build3(this.center.mirrorY(),0,360,this.rx,this.ry):Gr.build1(i.mirrorY(t),r.mirrorY(t),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}mirror(t=we.ORIGIN){let i=this.start(),r=this.end();return i.equals(r)?Gr.build3(this.center.mirror(t),0,360,this.rx,this.ry):Gr.build1(i.mirror(t),r.mirror(t),this.rx,this.ry,this.isLarge(),this.sweep())}sectorArea(){return Math.abs(this.sweepAngle)/360*Math.PI*this.rx*this.ry}area(){let t=_T.area(this.center,this._start,this.pointOn(this.endAngle()));return this.sectorArea()-t}multiply3(t){let i;t.isMirrored()?i=-this.sweepAngle:i=this.sweepAngle;let r;return t.equals(hr.ROT_90)?r=ei.regularD(this.startAngle+90):t.equals(hr.ROT_N90)?r=ei.regularD(this.startAngle-90):r=ei.transformD(this.startAngle,t),Gr.build3(this.center.multiply3(t),r,i,t.iScale*this.rx,t.iScale*this.ry)}angleIsInArc(t){return t=ei.regularD(t),this.sweepAngle>0?(t<this.startAngle&&(t+=360),this.endAngle()>t):(t>this.startAngle&&(t-=360),this.endAngle()<t)}toBezier(){if(Math.abs(this.sweepAngle)>90)throw new Error("not support!");let t=this.start(),i=this.end(),r=ei.toRadians(this.sweepAngle)/2,n=4/3*(1-Math.cos(r))/Math.sin(r)*this.rx;return new ct([t,t.add(new we(n,0).multiply3(hr.rotateD(this.startAngle+90))),i.add(new we(n,0).multiply3(hr.rotateD(this.endAngle()-90))),i])}toBezier2(){let t=[];r(this,90);let i=[];return t.forEach(n=>i.push(n.toBezier())),i;function r(n,s){if(Math.abs(n.sweepAngle)>s){let a=n.sweepAngle/2;r(Gr.build3(n.center,n.startAngle,a,n.rx,n.ry),s),r(Gr.build3(n.center,n.startAngle+a,a,n.rx,n.ry),s)}else t.push(n)}}buildBBox(){let t=yO.getCache().boxCache,i=this.startAngle+this.sweepAngle;if(t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.sweepAngle>0){let r=0;for(;r<i;){if(r>this.startAngle){let n=this.pointOn(r);t[0]=Math.min(t[0],n.x),t[1]=Math.max(t[1],n.x),t[2]=Math.min(t[2],n.y),t[3]=Math.max(t[3],n.y)}r+=90}}else if(this.sweepAngle<0){let r=360;for(;r>i;){if(r<this.startAngle){let n=this.pointOn(r);t[0]=Math.min(t[0],n.x),t[1]=Math.max(t[1],n.x),t[2]=Math.min(t[2],n.y),t[3]=Math.max(t[3],n.y)}r-=90}}return new ba(t[0],t[1],t[2],t[3])}bbox(){return this.__bbox==null&&(this.__bbox=this.buildBBox()),this.__bbox}length(){return Math.abs(this.rx*this.sweepAngle*Math.PI/180)}toString(){return cm.format("Arc [start=%s, end=%s, rx=%s, ry=%s, center=%s, startAngle=%s, sweepAngle=%s]",this._start,this._end,this.rx,this.ry,this.center,this.startAngle,this.sweepAngle)}stroke(t,i,r){let n=t/2,s=this.rx+n,a=this.ry+n,o=this.rx-n,l=this.ry-n,c=new hr;o<0&&(o=-o,c=c.multiply3(hr.MIRROR_Y)),l<0&&(l=-l,c=c.multiply3(hr.MIRROR_X)),o===0&&(o=.001),l===0&&(l=.001),c=c.setOrigin1(this.center);let u,h;switch(r===this.sweep()?(u=Gr.build3(this.center,this.startAngle,this.sweepAngle,s,a),h=Gr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,o,l)):(u=Gr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,s,a),h=Gr.build3(this.center,this.startAngle,this.sweepAngle,o,l)),h=h.multiply3(c),i){case 1:{let d=r===1?180:-180,p=r===this.sweep()?this.pointOn(this.endAngle()):this.pointOn(this.startAngle),f=r===this.sweep()?this.pointOn(this.startAngle):this.pointOn(this.endAngle()),m=u.pointOn(u.endAngle()).angleD(p),g=h.pointOn(h.endAngle()).angleD(f);return wi.build2([u,Gr.build3(p,m,d,n,n),h,Gr.build3(f,g,d,n,n)])}default:return wi.build2([u,h])}}points2(){let t=Math.ceil(Math.abs(this.sweepAngle)/hY),i=this.sweepAngle/t,r=[this._start];for(let n=1;n<t;n++)r.push(this.pointOn(this.startAngle+i*n));return r.push(this._end),r}points1(t){let i=Math.max(this.rx,this.ry);if(i<=t)return[this.start(),this.svgEnd];let r=(i-t)/i,n=Math.ceil(Math.abs(this.sweepAngle/ei.toDegrees(Math.acos(r))/2)),s=new Array(n+1),a=this.sweepAngle/n,o=this.startAngle;for(let l=0;l<=n;l++,o+=a)s[l]=this.pointOn(o);return s}points(t){let i=Math.max(this.rx,this.ry);if(t=Math.abs(t),i<=t)return[this.start(),this.svgEnd];t=Math.max(t,i*1e-5),t=Math.min(t,i*(1-Math.SQRT1_2));let r=(i-t)/i,n=Math.ceil(Math.abs(this.sweepAngle/ei.toDegrees(Math.acos(r))/2));n=Math.max(n,2);let s=new Array(n+1),a=this.sweepAngle/n,o=this.startAngle+a;s[0]=this.start();for(let l=1;l<n;l++,o+=a)s[l]=this.pointOn(o);return s[n]=this.end(),s}panDistance(t){return this.sweepAngle>0?new Gr(this.rx-t,this.ry-t,this.center,this.startAngle,this.sweepAngle):new Gr(this.rx+t,this.ry+t,this.center,this.startAngle,this.sweepAngle)}panDistance1(t){if(this.sweepAngle>0){let i=this.rx-t;return i<0?(i=Math.abs(i),Gr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new Gr(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;return i<0?(i=Math.abs(i),Gr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new Gr(i,i,this.center,this.startAngle,this.sweepAngle)}}get bulge(){let t=Math.abs(FU(this.sweepAngle,3))/180*Math.PI;return Math.tan(t/4)}get midPoint(){let t=ei.toRadians(this.startAngle),i=ei.toRadians(this.endAngle()),r=this.sweep(),n=this.center,s=this.rx;if(r==1)if(i>t){let a=(i-t)/2+t;return n.add(new we(Math.cos(a),Math.sin(a)).mul(s))}else{if(i==t)return n.add(new we(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(s));{let a=(i+ux-t)/2+t;return n.add(new we(Math.cos(a),Math.sin(a)).mul(s))}}else if(i>t){let a=(t+ux-i)/2+i;return n.add(new we(Math.cos(a),Math.sin(a)).mul(s))}else{if(i==t)return n.add(new we(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(s));{let a=(t-i)/2+i;return n.add(new we(Math.cos(a),Math.sin(a)).mul(s))}}}get svgPathData(){return[{type:"M",values:[this._start.x,this._start.y]},{type:"A",values:[this.rx,this.ry,0,this.isLarge()?1:0,this.isCCW,this._end.x,this._end.y]}]}equals(t){let i=ei.regularD(this.startAngle),r=ei.regularD(this.sweepAngle),n=ei.regularD(t.startAngle),s=ei.regularD(t.sweepAngle);return Ec([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(Ec([r,i],[s,n])||Ec([ei.regularD(i+r)],[n]))}equals1(t){let i=ei.regularD(this.startAngle),r=ei.regularD(this.sweepAngle),n=ei.regularD(t.startAngle),s=ei.regularD(t.sweepAngle);return Ec([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(Ec([r,i],[s,n])||Ec([ei.regularD(i+r)],[n]))}inArea(t,i){let r=t.x,n=t.y,s=this.center,a=this.rx,o=ei.toRadians(this.startAngle);this.sweep()==0&&(o=ei.toRadians(this.endAngle()));let l=ei.toRadians(this.endAngle());this.sweep()==0&&(l=ei.toRadians(this.startAngle));let c=a-i/2,u=a+i/2;var h=r-s.x,d=n-s.y,p=Math.atan2(d,h);if(p<0&&(p+=ux),o<=l&&p>=o&&p<=l||o>l&&(p>=o&&p<=ux||p>=0&&p<=l)||o==l){var f=Math.sqrt(h*h+d*d);return f<=u&&f>=c}else{var f=(u+c)/2,m=new we(s.x+Math.cos(o)*f,s.y+Math.sin(o)*f),g=new we(s.x+Math.cos(l)*f,s.y+Math.sin(l)*f),b=r-m.x,y=n-m.y,E=r-g.x,S=n-g.y;return b*b+y*y<=i*i/4?!0:E*E+S*S<=i*i/4}}isCircle(){return(Oe.eq(Math.abs(this.sweepAngle),360)||this._start.equals1(this._end))&&this.rx==this.ry}reverse(){return Gr.build3(this.center,this.endAngle(),-this.sweepAngle,this.rx,this.ry)}getAngle(){let t=Math.PI*2;return this.sweep()==1?(this.endAngle()-this.startAngle+t)%t:(this.startAngle-this.endAngle()+t)%t}isValid(){return this.rx>0&&this.ry>0}},bO=new ArrayBuffer(24),tT=new Float64Array(bO),qf=new Int32Array(bO),Ys,Jre=(Ys=class{static normal(e,t,i){let r=t.sub(e),n=i.sub(t);return r.cross(n)}constructor(e,t,i){this.x=nn.normal(e),this.y=nn.normal(t),this.z=nn.normal(i),tT[0]=e,tT[1]=t,tT[2]=i,this.hashed=qf[0]^qf[1]^qf[2]^qf[3]^qf[4]^qf[5]}isZeroVector(){return this.x===0&&this.y===0&&this.z===0}hashCode(){return this.hashed}equals(e){return e instanceof Ys?e.x===this.x&&e.y===this.y&&e.z===this.z:!1}cross(e){return new Ys(this.y*e.z-this.z*e.y,this.z*e.x-this.x*e.z,this.x*e.y-this.y*e.x)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){var e=this.length();return new Ys(this.x/e,this.y/e,this.z/e)}sub(e){return new Ys(this.x-e.x,this.y-e.y,this.z-e.z)}add(e){return new Ys(this.x+e.x,this.y+e.y,this.z+e.z)}scale(e){return new Ys(this.x*e,this.y*e,this.z*e)}neg(){return new Ys(-this.x,-this.y,-this.z)}multiply4(e){var t=this.x*e.data[0]+this.y*e.data[4]+this.z*e.data[8]+e.data[12],i=this.x*e.data[1]+this.y*e.data[5]+this.z*e.data[9]+e.data[13],r=this.x*e.data[2]+this.y*e.data[6]+this.z*e.data[10]+e.data[14],n=this.x*e.data[3]+this.y*e.data[7]+this.z*e.data[11]+e.data[15];return n!=0?new Ys(t/n,i/n,r/n):new Ys(t,i,r)}rotate(e,t){return this.multiply4(dO.rotateAxis(e,t))}toVector2(){return new we(this.x,this.y)}},Ys.ORIGIN=new Ys(0,0,0),Ys.X_UNIT_VECTOR=new Ys(1,0,0),Ys.Y_UNIT_VECTOR=new Ys(0,1,0),Ys.Z_UNIT_VECTOR=new Ys(0,0,1),Ys),Pn=class im{static build(t){return t instanceof wi?new im([new as([t])]):t instanceof as?new im([t]):t}static buildByPolygon(t){return t?new im([t]):new im([])}static buildByStroke(t,i,r=1,n){return this.buildByPolygon(as.buildByStroke(t,i,r,cI,n))}static buildCircle(t,i){return this.buildByPolygon(as.buildCircle(t,i))}static buildRect(t){return this.buildByPolygon(as.buildRect(t))}static buildBBox(t){return this.buildByPolygon(as.buildBBox(t))}constructor(t){this.items=t.slice()}multiply3(t){return new im(this.items.map(i=>i.multiply3(t)))}bbox(){return this._bbox||(this._bbox=this.items.reduce((t,i)=>t.ext1(i.bbox()),new to).build1()),this._bbox}toPolylineGroups(){return this.items.map(t=>t.toPolylineGroup())}},Fr,zi=(Fr=class{static isHexFormate(e){return!e||typeof e!="string"?!1:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)}static of1(e){return this.of2(e>>16&255,e>>8&255,e&255)}static of2(e,t,i,r=255){return new Fr(e/255,t/255,i/255,r/255)}static of3(e){e.startsWith("#")&&(e=e.substr(1));let t=e.length;if(t==3)return new Fr(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15);if(t==6)return new Fr(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255);if(t==8)return new Fr(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255,parseInt(e.substr(6,2),16)/255);throw new Error("invalid color string")}static of4(e){let t=parseInt(e.r*255+"").toString(16),i=parseInt(e.g*255+"").toString(16),r=parseInt(e.b*255+"").toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),("#"+t+i+r).toUpperCase()}static of5(e,t){if(e.startsWith("#")&&(e=e.substr(1)),e.length==3)return new Fr(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15,t);if(e.length==6)return new Fr(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255,t);throw new Error("invalid color string")}static of6(e,t){return new Fr(e.r,e.g,e.b,t)}static of7(e){return e==null?null:Fr.of3(e)}constructor(e,t,i,r=1){this.r=nn.positiveOr0(e),this.g=nn.positiveOr0(t),this.b=nn.positiveOr0(i),this.alpha=r}hashCode(){return this.r+this.g+this.b+this.alpha}equals(e,t=!1){let i=this.r===e.r&&this.g===e.g&&this.b===e.b;return t?i:i&&this.alpha===e.alpha}add(e,t,i,r){return new Fr(Math.max(0,Math.min(1,this.r+e)),Math.max(0,Math.min(1,this.g+t)),Math.max(0,Math.min(1,this.b+i)),Math.max(0,Math.min(1,this.alpha+r)))}mul(e){return new Fr(Math.max(0,Math.min(1,this.r*e)),Math.max(0,Math.min(1,this.g*e)),Math.max(0,Math.min(1,this.b*e)),this.alpha)}mul1(e){return new Fr(Math.max(0,this.r*e),Math.max(0,this.g*e),Math.max(0,this.b*e),this.alpha)}getData(){return[this.r,this.g,this.b,this.alpha]}toString(){let e=(this.r*255).toString(16),t=(this.g*255).toString(16),i=(this.b*255).toString(16);return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),"#"+e.substr(0,2)+t.substr(0,2)+i.substr(0,2)}toString1(){let e=(this.r*255).toString(16),t=(this.g*255).toString(16),i=(this.b*255).toString(16),r=(this.alpha*255).toString(16);return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),"#"+e.substr(0,2)+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)}toRGBA(){let e=this.r*255,t=this.g*255,i=this.b*255;return[e,t,i,this.alpha]}toRGBAString(){let e=this.r*255,t=this.g*255,i=this.b*255;return`rgba(${e},${t},${i},${this.alpha})`}isWHITE(){return this.r===1&&this.g===1&&this.b===1&&this.alpha===1}},Fr.WHITE=new Fr(1,1,1,1),Fr.BLACK=new Fr(0,0,0,1),Fr.RED=new Fr(1,0,0,1),Fr.GREEN=new Fr(0,1,0,1),Fr.BLUE=new Fr(0,0,1,1),Fr.Gray=Fr.of3("#9966ff"),Fr.Silver=Fr.of3("#D2D2D2"),Fr.Golden=Fr.of3("#DCAA14"),Fr.Pink=Fr.of3("#ffaec9"),Fr),gL=!1,xO=class{onRTreeBBox(e){}onResultSide(e){}onOriginSide(e){}onSplitedSide(e){}onDebugSide(e){}onSweep(e,t,i,r,n,s){}onIntersect(e,t,i){}onSegment(e,t,i,r,n,s){}onSegment1(e,t,i){if(gL){let r=new we(e.getX(i),i),n=new we(t.getX(i),i);this.onSegment(r,e.weight,e,n,t.weight,t)}else this.onSegment(e.start,e.weight,e,t.end,t.weight,t)}onSweep1(e,t,i){if(gL){let r=new we(e.getX(i),i),n=new we(t.getX(i),i);this.onSweep(r,e.weight,e,n,t.weight,t)}else this.onSweep(e.start,e.weight,e,t.end,t.weight,t)}},Ky=class extends xO{constructor(e){super(),this.plGrps=new Array,this.debug=e}onPolylineGroup(e,t){this.plGrps.push(e)}},p0=class{constructor(e){this.cache={},this.levels=e,this.result=new Array(e),this.weights=new Array(e),this.maxIdx=e-1,this.rule=this.decide.bind(this);let t=1;for(let i=0;i<e;i++)this.weights[i]=t,t*=50}weight(e){return this.weights[e]}decide(e){e=Math.abs(e);let t=this.cache[e];if(t===void 0){let i=e;for(let r=this.maxIdx;r>=0;r--){let n=this.weights[r],s=e/n|0,a=e%n;a>(n/2|0)?(e=n-a,s++):e=a,this.result[r]=s>0}t=this.decide1(this.result),this.cache[i]=t}return t}},dY=e=>e!==0,pY=new class extends p0{decide1(e){return e[0]||e[1]}}(2),Ix=new class extends p0{decide1(e){return e[0]&&!e[1]}}(2),Ax=new class extends p0{decide1(e){return e[0]&&e[1]}}(2),iT=new class extends p0{decide1(e){return e[0]&&!e[1]||!e[0]&&e[1]}}(2),fY=(e=>(e[e.UNMARKED=0]="UNMARKED",e[e.INSIDE=1]="INSIDE",e[e.OUTSIDE=2]="OUTSIDE",e[e.INVALID=3]="INVALID",e))(fY||{}),bm=class rm{constructor(t,i,r,n,s,a,o){this.inters=[],this.connect=new Array,this.previous=null,this.next=null,this.finalGrp=-1,this.trans=NaN,this.outsideWeight=0,this.insideWeight=0,this.invalidWeight=0,this._confidence=0,this._confidence_y=NaN,this._x=NaN,this._x_y=NaN,this.status=0,this.bo=t,this.shape=i,this.baseWeight=r,n.y>s.y?this.weight=-r:n.y==s.y?this.weight=0:this.weight=r,this.start=n,this.end=s,this.polyGrp=a,this.polyIndex=o,this._bbox=new to().ext1(i.bbox()).ext2(n).ext2(s).build1(),this.inters.push(n),this.inters.push(s);let l=31,c=1;c=l*c+this.polyGrp,c=l*c+this.polyIndex,this._hashcode=c}static rebuild(t,i,r){if(t instanceof me||i.distance2(r)<1e-6)return new me(i,r);if(t instanceof Pe){let n=t,s=t.bbox().center().x,a;i.y>r.y?a=s>n.center.x?0:1:a=s>n.center.x?1:0;let o=i.angleD(n.center),l=r.angleD(n.center);return Pe.build2(n.center,o,l,n.rx,n.ry,a)}else throw new Error("not supported operation")}updateBbox(){this._bbox=new to().ext2(this.start).ext2(this.end).build1()}is(t,i){return t===this.polyGrp&&i===this.polyIndex}confidence(t){if(this._confidence_y!=t){let i=this._bbox.height();if(i!==0)if(Math.abs(t-this._bbox.maxY)>5e-4&&Math.abs(t-this._bbox.minY)>5e-4){let r=1-Math.abs(2*t-this._bbox.maxY-this._bbox.minY)/i;this._confidence=r*1e4|0}else this._confidence=0;else this._confidence=1;this._confidence_y=t}return this._confidence}needCountWeight(){return this.outsideWeight+this.insideWeight+this.invalidWeight<5e3}revokeOutside(t){let i=this.confidence(t);return this.outsideWeight-=i,this.invalidWeight+=i,i}revokeInside(t){let i=this.confidence(t);return this.insideWeight-=i,this.invalidWeight+=i,i}setOutside(t){let i=this.confidence(t);return this.outsideWeight+=i,i}setInside(t){let i=this.confidence(t);return this.insideWeight+=i,i}setInvalid(t){let i=this.confidence(t);return this.invalidWeight+=i,i}prevNot0(){let t=this.previous;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.previous}return null}nextNot0(){let t=this.next;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.next}return null}getX(t){if(this.bo!==null)return(this._x_y!=t||isNaN(this._x))&&(wY(this,t)>0?this._x=ae[0]:this._x=NaN,this._x_y=t),this._x;throw new Error("not supported operation")}voteStatus(){return this.outsideWeight>this.insideWeight&&this.outsideWeight>this.invalidWeight?2:this.insideWeight>this.outsideWeight&&this.insideWeight>this.invalidWeight?1:this.invalidWeight>this.outsideWeight&&this.invalidWeight>this.insideWeight?3:0}reverse(t){if(t===2)if(this.start.y>this.end.y){let i=rm.rebuild(this.shape,this.end,this.start),r=new rm(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return xa.addAll(r.connect,this.connect),r}else return this;else if(t===1)if(this.start.y<this.end.y){let i=rm.rebuild(this.shape,this.end,this.start),r=new rm(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return xa.addAll(r.connect,this.connect),r}else return this;return this}isNeedScan(t){return this.needCountWeight()&&this.confidence(t)>0}hashCode(){return this._hashcode}equals(t){return t instanceof rm?!(this.polyGrp!==t.polyGrp||this.polyIndex!==t.polyIndex):!1}bbox(){return this._bbox}toString(){return cm.format("(%d,%d,%d) (%d,%d,%d) %s %s",this.polyGrp,this.polyIndex,this.weight,this.outsideWeight,this.invalidWeight,this.insideWeight,this.start,this.end)}};function mY(e,t){let i=e.bbox(),r=t.bbox(),n=(i.minY+i.maxY)/2,s=(r.minY+r.maxY)/2;return n-s}function gY(e,t){let i=e.bbox(),r=t.bbox(),n=(i.minX+i.maxX)/2,s=(r.minX+r.maxX)/2;return n-s}var Jf=class{constructor(e){if(this.__bbox=null,typeof e<"u")if(e instanceof Array){this.__items=[];for(let t of e)this.add(t)}else this.__items=e,this.__bbox=e.bbox();else this.__items=[]}add(e){if(this.__items instanceof Array)this.__items.push(e),this.__bbox=ba.extend2(this.__bbox,e.bbox());else throw new Error("can't insert multiple item into leaf node")}items(){return this.__items}bbox(){if(this.__bbox!==null)return this.__bbox;throw new Error("bug")}},t0=class{constructor(e){this.changed=!1,this.root=new Jf,this.capacity=e,this.capacity2=e*e,this.itemList=[]}size(){return this.itemList.length}items(){return this.flushWhenNeed(),this.itemList}add(e){this.itemList.push(e),this.changed=!0}remove(e){xa.remove(this.itemList,e),this.changed=!0}clear(){this.changed=!1,this.root=new Jf,this.itemList.length=0}flushWhenNeed(){if(this.changed){let e=new Array;for(let t of this.itemList)e.push(new Jf(t));for(;;){let t=this.organize(e);if(t.length>1)e=t;else break}this.root=new Jf(e),this.changed=!1}}organize(e){Ap(e,gY,0,e.length);let t=e.length,i=[];for(let r=0;r<t;)if(r+this.capacity2<=t){let n=r+this.capacity2;Ap(e,mY,r,n);for(let s=r;s<n;s+=this.capacity){let a=new Jf(e.slice(s,s+this.capacity));i.push(a)}r=r+this.capacity*this.capacity}else{let n=new Jf(e.slice(r,r+this.capacity));i.push(n),r=r+this.capacity}return i}search(e){this.flushWhenNeed();let t=[],i=[];for(i.push(this.root);;){let r=i.shift();if(typeof r<"u"){let n=r.items();if(n instanceof Array){for(let s of n)if(!e.isSeparated(s.bbox())){let a=s.items();a instanceof Array?i.push(s):t.push(a)}}else e.isSeparated(r.bbox())||t.push(n)}else break}return t}walker(e){this.flushWhenNeed(),this._walker(this.root,0,e)}_walker(e,t,i){this.flushWhenNeed();let r=e.items();if(r instanceof Array)for(let n of r)this._walker(n,t+1,i);else i(r,t)}bbox(){return this.flushWhenNeed(),this.root.bbox()}};function rT(e,t){yY(e.iterator(),t)}function yY(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var hx=new Error("list is empty"),dx=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},bY=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},xY=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},Sp=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw hx;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw hx;return this.remove(e),e.item}addLast(e){return this.first===null||this.last===null?(this.first=new dx(this,e),this.last=this.first,this.cnt=1,this.first):this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new dx(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw hx;return this.first.item}getLast(){if(this.last===null)throw hx;return this.last.item}insertAfter(e,t){let i=new dx(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new dx(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new bY(this.first)}listIterator(){return new xY(this.first)}toArray(){let e=new Array(this.cnt),t=this.first,i=0;for(;t!=null;)e[i]=t.item,t=t.next,i++;return e}};function nT(e){throw new Error("")}var px=class{constructor(e,t){this.node1=null,this.node2=null,this.key=e,this.value=t}},EY=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},SY=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},Vx=class{constructor(){this.innerList=new Sp,this.innerMap={}}replace(e,t){e.node1!==null&&(e.node1.set(t),t.node1=e.node1),e.node2!==null&&(e.node2.set(t),t.node2=e.node2)}clear(){this.innerList.clear();for(let e in this.innerMap)delete this.innerMap[e]}put(e,t){let i=e.hashCode(),r=new px(e,t),n=this.innerMap[i];if(n===void 0)return r.node1=this.innerList.add(r),this.innerMap[i]=r,null;if(n instanceof px){if(n.key.equals(e))return this.innerMap[i]=r,this.replace(n,r),n.value;{r.node1=this.innerList.add(r);let s=new Sp;return n.node2=s.add(n),r.node2=s.add(r),this.innerMap[i]=s,null}}if(n instanceof Sp){let s=null;return rT(n,(a,o)=>o.key.equals(e)?(this.replace(o,r),s=o.value,!1):!0),s===null?(r.node1=this.innerList.add(r),r.node2=n.push(r),null):s}return nT(n)}get(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof px)return i.key.equals(e)?i.value:null;if(i instanceof Sp){let r=null;return rT(i,(n,s)=>s.key.equals(e)?(r=s.value,!1):!0),r}return nT(i)}containsKey(e){return this.get(e)!==null}delete(e){e.node1!==null&&e.node1.parent.remove(e.node1),e.node2===null?delete this.innerMap[e.key.hashCode()]:e.node2.parent.remove(e.node2)}remove(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof px)return i.key.equals(e)?(this.delete(i),i.value):null;if(i instanceof Sp){let r=null;return rT(i,(n,s)=>s.key.equals(e)?(r=s.value,this.delete(s),!1):!0),r}return nT(i)}computeIfAbsent(e,t){let i=this.get(e);if(i===null){let r=t(e);return this.put(e,r),r}else return i}size(){return this.innerList.size()}isEmpty(){return this.innerList.size()===0}keys(){return new EY(this.innerList.iterator())}values(){return new SY(this.innerList.iterator())}entries(){return this.innerList.iterator()}},mm=class{constructor(){this.innerMap=new Vx}add(e){return this.innerMap.put(e,!0)!==!0}remove(e){this.innerMap.remove(e)}contains(e){return this.innerMap.get(e)===!0}iterator(){return this.innerMap.keys()}addAll(e){let t=e.iterator();for(;t.hasNext();)this.add(t.next())}size(){return this.innerMap.size()}clear(){let e=this.iterator();for(;e.hasNext();){let t=e.next();this.remove(t)}}},yL=xa.funcCopy(Ap);function wY(e,t){let i=0;if(Math.abs(e.start.y-t)<=1e-4)ae[i++]=e.start.x;else if(Math.abs(e.end.y-t)<=1e-4)ae[i++]=e.end.x;else if(e.shape instanceof me)i=VU(e.shape,t);else if(e.shape instanceof Pe)i=HU(e.shape,t);else throw new Error("not supported operation");return i}var Cx=class{constructor(e,t,i,r){this.sides=new Array,this.loader=e,this.loader.bo=this,this.logger=i,this.rule=t,this.event=r}static sortByBBoxMinY(e,t){return e.bbox().minY-t.bbox().minY}static sortByBBoxAreaDesc(e,t){return t.bbox().area()-e.bbox().area()}addPolyline(e,t=1,i=.01,r=!0){for(let n of this.loader.buildGroup(e,t,i,r))this.sides.push(n),this.event.onOriginSide(n)}buildRTree(){let e=new t0(10);for(let t of this.sides)e.add(t);return e}fillValidSides(e,t,i){for(let r of t)isFinite(r.getX(i))&&e.push(r)}getSortedEndpointsLineAsc(e){let t=new Array;for(let n of e)n.needCountWeight()&&(t.push(n.start),t.push(n.end));yL(t,we.sortByYAsc,0,t.length);let i=new Array,r=Number.NEGATIVE_INFINITY;for(let n of t){let s=n.y;s>r&&(i.push(s),r=s)}return i}splitSides(e,t,i){let r=e.start,n=e.end,s=new we(n.x+(r.x-n.x)*2,n.y+(r.y-n.y)*2);yL(e.inters,(o,l)=>o.distance2(s)-l.distance2(s),0,e.inters.length);let a=null;for(let o of e.inters)if(a==null)o.equals(r)&&(a=o);else if(!o.equals(a)){let l=bm.rebuild(e.shape,a,o);l instanceof Pe&&Math.abs(l.sweepAngle)>190&&(l=new me(a,o));let c=new bm(this,l,e.baseWeight,a,o,e.polyGrp,i++);if(t.push(c),c.updateBbox(),o.equals(n))break;a=o}return i}splitSidesByInters(){let e=new Array;for(let t of this.sides)if(t.polyIndex==0){let i=0,r=null,n=null;do{let s=new Array;i=this.splitSides(t,s,i);for(let a of s)r!=null?(r.next=a,a.previous=r):n=a,r=a,this.event.onSplitedSide(a),e.push(a);if(t.next===null)throw new Error("not supported operation");t=t.next}while(t.polyIndex!==0);n!=null&&r!=null&&(n.previous=r,r.next=n)}this.sides.length=0;for(let t of e)this.sides.push(t)}seekIntersection(){if(this.sides.length>0){let e=this.buildRTree(),t=new mm;for(let i of this.sides){t.add(i);let r=i.bbox().extendOfSize(1e-5),n=i.shape instanceof me;for(let s of e.search(r))if(!t.contains(s)){let a=s.shape instanceof me;if(!(n&&a&&i.next!==null&&i.previous!==null&&(i.next.equals(s)||i.previous.equals(s)))){let o=Pl(i.shape,s.shape);for(let l=0;l<o;l+=2){let c=new we(ae[l],ae[l+1]);i.inters.push(c),s.inters.push(c),this.event.onIntersect(c,i,s)}}}}}}},vY=class EO{constructor(t){this.sides=new mm,this.others=new mm,this.id=t}add(t){this.sides.add(t),t.finalGrp=this.id;for(let i of t.connect)this.others.add(i)}polyline(){let t=new Array;return fm(this.sides,(i,r)=>(t.push(r.shape),!0)),wi.build2(t).asClose()}hashCode(){return this.id}equals(t){return t!=null&&t instanceof EO?this.id===t.id:!1}},SO=class{constructor(e){this.bo=null,this.sides=new Array,this.polyGrp=0,this.polyIndex=0,this.prevSide=null,this.firstSide=null,this.noWeight0=e}completeGroup(e){this.prevSide!=null&&this.firstSide!=null&&!this.prevSide.end.equals(this.firstSide.start)&&this.addSide(new me(this.prevSide.end,this.firstSide.start),e);let t=new Array,i=null,r=null;for(let n of this.sides)(!this.noWeight0||n.weight!==0)&&(i!=null?(i.next=n,n.previous=i):r=n,i=n,t.push(n));return i!=null&&r!=null&&(r.previous=i,i.next=r),this.polyGrp++,this.sides.length=0,this.prevSide=null,this.firstSide=null,this.polyIndex=0,t}buildGroup(e,t,i,r=!0){for(let n of e.primitives)if(n instanceof me)this.addSide(n,t);else if(r&&n instanceof Pe&&n.rx===n.ry)this.addArc(n,t);else{let s=null;for(let a of n.points(i))s!=null&&this.addSide(new me(s,a),t),s=a}return this.completeGroup(t)}addArc(e,t){let i=e.sweepAngle,r=ei.regularD(e.startAngle),n=r+i;if(i>0){let s=90;for(;s<=n;)s>r&&(this.addSide(Pe.build3(e.center,r,s-r,e.rx,e.ry),t),r=s),s+=90;r<n&&this.addSide(Pe.build3(e.center,r,n-r,e.rx,e.ry),t)}else if(i<0){let s=270;for(;s>=n;)s<r&&(this.addSide(Pe.build3(e.center,r,s-r,e.rx,e.ry),t),r=s),s-=90;r>n&&this.addSide(Pe.build3(e.center,r,n-r,e.rx,e.ry),t)}}addSide(e,t){if(e.start().equals(e.end()))return;let i=e.start(),r;this.prevSide!=null?(this.prevSide.end.equals(i)||this.addSide(new me(this.prevSide.end,i),t),r=new bm(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++)):(r=new bm(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++),this.firstSide=r),this.prevSide=r,this.sides.push(r)}},wO=class{constructor(e,t,i){this.eps=new Array,this.curWeight=0,this.start=null,this.last=null,this.prevStart=null,this.prevEnd=null,this.y=i,this.rule=e,this.bo=t,this.event=t.event}onEp(e){this.tuningWeight(e),this.start===null?this.rule(this.curWeight)?this.in(e):e.setInvalid(this.y):this.rule(this.curWeight)?e.setInvalid(this.y):this.out(e,this.start),this.last!==null&&this.event.onSweep1(this.last,e,this.y),this.last=e}in(e){this.prevEnd!=null&&this.onSameX(e,this.prevEnd)?(this.start=this.prevStart,this.prevStart=null,this.prevEnd.revokeInside(this.y),this.prevEnd=null):(this.start=e,this.start.setOutside(this.y))}out(e,t){if(this.onSameX(t,e))t.revokeOutside(this.y);else{if(e.setInside(this.y)>0&&t.confidence(this.y)>0){let i=t.voteStatus(),r=e.voteStatus();this.isValid(i)&&this.isValid(r)?i==2&&r==1&&(e.connect.push(t),t.connect.push(e)):(e.connect.push(t),t.connect.push(e))}this.event.onSegment1(t,e,this.y),this.eps.push(t),this.eps.push(e),this.prevStart=t,this.prevEnd=e}this.start=null}isValid(e){return e==1||e==2}onSameX(e,t){return e.bbox().isIntersect(t.bbox())&&Oe.eq(e.getX(this.y),t.getX(this.y))}tuningWeight(e){this.curWeight+=e.weight;let t=e.nextNot0(),i=e.prevNot0();t!=null&&e.weight===t.weight&&t.trans===this.y&&(this.curWeight-=e.weight),i!=null&&e.weight===i.weight&&i.trans===this.y&&(this.curWeight-=e.weight),e.trans=this.y}},Hx=new Error,bL=new class extends p0{decide1(e){return e[0]&&e[1]}}(2),TY=new class extends xO{onPolylineGroup(e,t){throw Hx}onSegment(e,t,i,r,n,s){throw Hx}},IY=class{constructor(e,t){this.rtree=e,this.level=t}},AY=class vO extends Cx{static isIntersect(t,i,r=nE.DUMMY){let n=new vO(r),s=n.createGroup1(t.items),a=n.createGroup2(i.items);return s.rtree.itemList.length==0||a.rtree.itemList.length==0?!1:n.isIntersect(s,a)}constructor(t){super(new SO(!1),bL.rule,t,TY)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=bL.weight(i);for(let s of t)this.addPolyline(s,r);let n=this.buildRTree();return this.sides.length=0,new IY(n,i)}isIntersect(t,i){if(t.level!==i.level){let r=t.rtree.bbox().intersection1(i.rtree.bbox());if(r!==null){try{this.inters(t,i);let n=(r.minY+r.maxY)/2;this.sweep(t,i,n)}catch(n){if(n===Hx)return!0;throw n}return!1}else return!1}else throw new Error("inersection detection should not in same group")}inters(t,i){if(t.rtree.size()>i.rtree.size()){let r=t;t=i,i=r}for(let r of t.rtree.items()){r.trans=NaN;let n=r.bbox().extendOfSize(1e-5);for(let s of i.rtree.search(n))if(s.trans=NaN,Pl(r.shape,s.shape)>0)throw Hx}}sweep(t,i,r){let n=ba.extend2(t.rtree.bbox(),i.rtree.bbox()).extendOfSize(1e-5),s=new Array;this.fillValidSides(s,t.rtree.search(n),r),this.fillValidSides(s,i.rtree.search(n),r),Ap(s,(o,l)=>o.getX(r)-l.getX(r),0,s.length);let a=new wO(this.rule,this,r);for(let o of s)a.onEp(o)}},uI=class th{constructor(t){this.items=new Array(t.length),xa.arraycopy(t,0,this.items,0,t.length),this.__bbox=this.calcBBox()}static build1(t){let i=[];return Bx(t,(r,n)=>(i.push(n),!0)),new th(i)}static build2(t){let i=t.map(r=>wi.build8(r));return new th(i)}static combinePolylineGroupArr(t){let i=[];for(let r of t)i=i.concat(r.items);return new th(i)}calcBBox(){let t=new to;for(let i=0;i<this.items.length;i++)t.ext1(this.items[i].bbox());return t.build1()}multiply3(t){let i=new Array(this.items.length);for(let r=0;r<i.length;r++)i[r]=this.items[r].multiply3(t);return new th(i)}bbox(){return this.__bbox}asClose(){return this.items.forEach(t=>t.asClose()),this}mirrorY(t){return this.items.forEach(i=>i.mirrorY(t)),this}closeEndpoint(){return this.items.forEach(t=>t.closeEndpoint()),this}get primitives(){return this.items.map(t=>t.primitives).flat(2)}isEqual(t){return t instanceof th?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items.reduce((t,i)=>i.bbox().area()>t.bbox().area()?i:t,this.items[0])}getOutline(){let t=this.items;if(t.length===1)return{outline:t,hole:new Array};let i=new Set,r=new Set;for(let n=0,s=t.length;n<s;n++){let a=t[n];if(!i.has(a)&&!r.has(a)){n+1>=s&&i.add(a);for(let o=n+1;o<s;o++){let l=t[o];if(!i.has(l)&&!r.has(l)){if(!a.bbox().isInside(l.bbox().extendOfSize(1e-4))&&!l.bbox().isInside(a.bbox().extendOfSize(1e-4)))continue;AY.isIntersect(new th([a]),new th([l]))&&(a.bbox().area()>l.bbox().area()?(i.add(a),r.add(l)):(i.add(l),r.add(a)))}}!i.has(a)&&!r.has(a)&&i.add(a)}}return{outline:[...i],hole:[...r]}}round(t=4){let i=this.items.map(r=>r.round(t));return new th(i)}},CY=xa.funcCopy(Ap),DY=xa.funcCopy(Ap),_Y=xa.funcCopy(Ap);function PY(e){return new Array}function LY(e,t){let i=new Ky(!1),r=new $y(e,nE.DUMMY,i);for(let n of t)r.addPolyline(n);return r.simplify(),i.plGrps}var $y=class extends Cx{constructor(e,t,i){super(new SO(!1),e,t,i),this.finalSides=new Array,this.sideGroups={},this.vecSides=new Array,this.scanY=NaN,this.curNetIndex=0,this.curIndex=-1,this.scanLines=0}sweep(e,t,i){this.scanY=NaN,this.scanLines=0,CY(t,Cx.sortByBBoxMinY,0,t.length);let r=new Sp;this.curNetIndex=0;let n=Number.POSITIVE_INFINITY;for(let s of e)s>n&&this.scan(r,(n+s)/2,t),n=s;this.getAllMarkPrimitive(i,t),this.logger.debug3("scan %s %d",i,this.scanLines)}simplify(){this.seekIntersection(),this.splitSidesByInters(),this.sweep(this.getSortedEndpointsLineAsc(this.sides),this.sides,!1),this.flipSides(),this.sweep(this.getSortedEndpointsLineAsc(this.vecSides),this.vecSides,!0),this.connectSides(),this.fillResult()}addPolyline(e,t=1,i=.01,r=!0){super.addPolyline(e,t,i,r)}scan(e,t,i){if(this.scanY==t)return;this.scanY=t;let r=!1,n=e.listIterator();for(;n.hasNext();){let s=n.next(),a=s.item;Oe.less(a.bbox().maxY,t)?e.remove(s):!r&&a.isNeedScan(t)&&(r=!0)}for(;this.curNetIndex<i.length;){let s=i[this.curNetIndex];if(Oe.less(s.bbox().minY,t))Oe.greatereq(s.bbox().maxY,t)&&(this.add2AET(e,s),!r&&s.isNeedScan(t)&&(r=!0)),this.curNetIndex++;else break}if(r){this.scanLines++;let s=new wO(this.rule,this,t),a=e.iterator();for(;a.hasNext();){let o=a.next();s.onEp(o)}}}add2AET(e,t){let i=t.bbox().minX,r=t.bbox().maxX,n=t.bbox().minY,s=t.bbox().maxY,a=e.listIterator(),o=null;for(;a.hasNext();){let l,c=a.next(),u=c.item,h=u.bbox().minX,d=u.bbox().maxX;if(r<=h)l=-1;else if(d<=i)l=1;else{let f=u.bbox().minY,m=u.bbox().maxY,g=Math.max(n,f),b=Math.min(s,m);l=this.compareBySweep(t,u,(g+b)/2)}let p=u.shape;if(p instanceof me&&p.length()<.001&&o==null&&l<0){o=c;continue}if(o!=null&&l<0){e.insertBefore(o,t);return}if(l<0){e.insertBefore(c,t);return}else o=null}e.add(t)}getLineAngle(e){let t=e.start().angle(e.end());return t<0&&(t+=Math.PI),t}getArcAngle(e,t){let i=Math.asin((t-e.center.y)/e.rx);return e.startAngle>90&&e.startAngle<270&&(i=-i),i<0&&(i+=Math.PI),(i+Math.PI/2)%Math.PI}compareArcLine(e,t,i){let r=this.getArcAngle(e,i),n=this.getLineAngle(t);return Oe.eq(r,n)?-e.sweepAngle:n-r}compareBySweep(e,t,i){let r=e.getX(i);if(!isFinite(r))return 0;let n=t.getX(i);if(!isFinite(n))return 0;if(!Oe.eq(r,n))return r-n;if(e.shape instanceof me)return t.shape instanceof me?this.getLineAngle(t.shape)-this.getLineAngle(e.shape):-this.compareArcLine(t.shape,e.shape,i);if(t.shape instanceof me)return this.compareArcLine(e.shape,t.shape,i);{let s=e.shape,a=t.shape,o=this.getArcAngle(s,i),l=this.getArcAngle(a,i);return Oe.eq(o,l)?s.sweepAngle*a.sweepAngle<=0?s.sweepAngle<=0?1:-1:s.sweepAngle>0?s.rx-a.rx:a.rx-s.rx:l-o}}getAllMarkPrimitive(e,t){for(let i of t)if(i.status===0&&i.bbox().height()!=0){let r=i.voteStatus();if(r===2||r===1){i.status=r;let n=i.reverse(r);if(e){this.event.onResultSide(n);let s=n.shape.multiply3(hr.ROT_N90),a=n.start.multiply3(hr.ROT_N90),o=n.end.multiply3(hr.ROT_N90);n=new bm(this,s,n.baseWeight,a,o,n.polyGrp,n.polyIndex)}this.finalSides.push(n),this.event.onResultSide(n)}}}flipSides(){for(let e of this.sides)if(e.polyIndex==0){let t=null,i=null;do{let r=e.shape.multiply3(hr.ROT_90),n=e.start.multiply3(hr.ROT_90),s=e.end.multiply3(hr.ROT_90),a=new bm(this,r,e.baseWeight,n,s,e.polyGrp,e.polyIndex);if(a.outsideWeight=e.outsideWeight,a.insideWeight=e.insideWeight,a.invalidWeight=e.invalidWeight,a.status=e.status,t!=null?(t.next=a,a.previous=t):i=a,this.vecSides.push(a),this.event.onSplitedSide(a),t=a,e.next!==null)e=e.next;else break}while(e.polyIndex!=0);i!=null&&(i.previous=t,t.next=i)}}canBeEnd(e,t){if(e.size()==1){let i=e.getFirst().shape;if(i instanceof Pe){if(t&&i.rx<=t)return!1}else if(i instanceof me&&t&&i.length()<=t)return!1}return!0}connectSides(){let e=new Vx,t=new t0(10);for(let s of this.finalSides)e.computeIfAbsent(s.start,PY).push(s),t.add(s.start);let i=0,r=new mm,n=new Array;for(let s of this.finalSides)if(!r.contains(s)){let a=new mm,o=s.start,l=new Sp;l.add(s),r.add(s);let c=s.end;for(;l.size()>0;)if(this.isStart(o,c)&&this.canBeEnd(l,.01)){l.size()>1&&this.fillSideGroups(l,i++);break}else{let u=e.get(c),h=this.findNext(r,u);if(h==null&&(c=this.findNeigber(c,a,t,.01),c!==null&&(u=e.get(c),h=this.findNext(r,u))),h!=null)l.add(h),r.add(h),c=h.end;else if(c!=null?a.add(c):(n.length==0&&l.size()>1&&this.logger.warning3("unable to connect at %s",l.getLast()),n.push(l.removeLast())),l.size()>0)c=l.getLast().end;else break}}}fillSideGroups(e,t){let i=new vY(t);fm(e,(r,n)=>(i.add(n),!0)),this.sideGroups[i.id]=i}isStart(e,t){return e.distance2(t)<=1e-4}findNext(e,t){if(t!=null){for(let i of t)if(!e.contains(i))return i}return null}fillResult(){let e=0,t=new Vx;for(let r in this.sideGroups){let n=this.sideGroups[r];fm(n.sides,(s,a)=>(a.polyGrp!=-2&&t.put(a,a),!0))}let i=new mm;for(let r in this.sideGroups){let n=this.sideGroups[r];if(i.add(n)){let s=0,a=new Array;for(a.push(n);s<a.length;){let l=a[s],c=new Array;fm(l.others,(h,d)=>{let p=t.get(d);return p!=null&&c.push(p.finalGrp),!0}),DY(c,xa.sortAsc,0,c.length);let u=l.id;for(let h of c)if(h!=u&&h!=l.id){let d=this.sideGroups[h];i.add(d)&&a.push(d),u=h}s++}let o=new Array;for(let l of a)o.push(l.polyline());_Y(o,Cx.sortByBBoxAreaDesc,0,o.length),this.event.onPolylineGroup(new uI(o),e++)}}}findNeigber(e,t,i,r){let n=r*r,s=Number.MAX_VALUE,a=null;for(let o of i.search(e.bbox().extendOfSize(r)))if(!t.contains(o)){let l=e.distance2(o);l<s&&(s=l,a=o)}return s<n?a:null}},OY=class{constructor(){this.points=[],this.lines=[],this.arcs=[],this.beziers=[],this.listText=[],this.fonts=[]}addPt(e,t=!0){if(e instanceof me)this.lines.push(e);else if(e instanceof Pe)this.arcs.push(e);else if(e instanceof ct)this.beziers.push(e);else throw new Error("not support");t&&this.points.push(e.start())}addPoint(e){this.points.push(e)}addText(e,t,i=1,r=.1,n=!0){this.listText.push({pos:e,str:t,size:i,width:r}),n&&this.points.push(e)}addPly(e,t=!0){e.primitives.forEach(i=>this.addPt(i,t))}build(){let e=[],t=[],i=[],r=[],n=[],s=[];return this.points.forEach(a=>e.push(a.x,a.y)),this.lines.forEach(a=>t.push(a.start().x,a.start().y,a.end().x,a.end().y)),this.arcs.forEach(a=>i.push(a.center.x,a.center.y,a.rx,ei.toRadians(a.startAngle),ei.toRadians(a.endAngle()),a.sweep())),this.beziers.forEach(a=>{a.controls.forEach(o=>{r.push(o.x,o.y)}),r.push("end")}),this.listText.forEach(a=>n.push(a.pos.x,a.pos.y,a.str,a.width,a.size)),this.fonts.forEach(a=>s.push(a)),{points:e,lines:t,arcs:i,texts:n,beziers:r,fonts:s}}},My,f0=(My=class{constructor(e){this.map=new Vx,this.bus=e}initColor(e){return this.map.computeIfAbsent(e,()=>new OY)}draw(){let e={},t=this.map.entries();for(;t.hasNext();){let i=t.next();e[i.key.toString()]=i.value.build()}this.bus.publish("/debug/draw",e)}clear(){this.map.clear()}static init(e){if(!e)throw new Error("bus is undefined!");this.palette=new My(e)}static initPalette(e){this.palette=e}static getDefaultColor(){for(let e of this.colorBuffersMap)if(e[0]!==null&&e[0])return e[0]=!1,e[1];return this.colorBuffersMap.forEach(e=>{if(e[0]===null){console.log(1);return}e[0]=!0}),this.getDefaultColor()}static clear(){this.palette.clear()}static auto(e,t=this.getDefaultColor()){if(Array.isArray(e))e.forEach(i=>{this.auto(i,t)});else if(e instanceof we)this.point(e,t);else if(e instanceof ba)this.bbox(e,t);else if(e instanceof d0)this.primitive(e,t);else if(e instanceof wi)this.polyline(e,t);else if(e instanceof as)this.polygon(e,t);else if(e instanceof Pn)this.group(e,t);else if(e instanceof uI)this.auto(e.items,t);else{debugger;throw new Error("No incoming type!")}}static text(e,t,i=.5,r=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");this.palette.initColor(r).addText(e,t,i,i/10),this.palette.draw()}static point(e,t=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let i=this.palette.initColor(t);Array.isArray(e)?e.forEach(r=>{this.point(r,t)}):i.addPoint(e),this.palette.draw()}static bbox(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.bbox(i,t)}):(this.primitive(new me(new we(e.maxX,e.maxY),new we(e.maxX,e.minY)),t),this.primitive(new me(new we(e.maxX,e.maxY),new we(e.minX,e.maxY)),t),this.primitive(new me(new we(e.minX,e.minY),new we(e.maxX,e.minY)),t),this.primitive(new me(new we(e.minX,e.minY),new we(e.minX,e.maxY)),t))}static primitive(e,t=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let i=this.palette.initColor(t);Array.isArray(e)?e.forEach(r=>{this.primitive(r,t)}):i.addPt(e),this.palette.draw()}static polyline(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.polyline(i,t)}):e.primitives.forEach(i=>{this.primitive(i,t)})}static polygon(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.polygon(i,t)}):e.items.forEach(i=>{this.polyline(i,t)})}static group(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.group(i,t)}):e.items.forEach(i=>{this.polygon(i,t)})}static async begin(){this.t1=performance.now()}static async end(e){console.log(e||"t1:",performance.now()-this.t1)}static async log(e){console.log(e||"==================")}},My.colorBuffersMap=[[!0,zi.BLUE],[!0,zi.GREEN],[!0,zi.WHITE],[!0,zi.RED],[!0,zi.Golden],[!0,zi.Gray]],My.t1=0,My),RY=0,m0=class OT{constructor(t,i){this.inters=[],this.shape=t,this.start=t.start(),this.end=t.end(),this.judgeOverlapMap=new Map,i&&(this.id=RY++)}reverse(){this.shape=this.shape.reverse();let t=this.start;this.start=this.end,this.end=t}getCenterPoint(t=this.end){let{x:i,y:r}=this.start,{x:n,y:s}=t;if(this.shape instanceof Pe){let a=this.shape.rx,o=new we((i+n)/2,(r+s)/2),l=this.shape.center,c;return o.x!==l.x||o.y!==l.y?(c=o.angle(l),Math.abs(this.shape.sweepAngle)>180&&(c+=c>=0?-180:180)):c=(this.shape.startAngle+this.shape.endAngle())/2,new we(l.x+Math.cos(c)*a,l.y+Math.sin(c)*a)}else{if(this.shape instanceof me)return new we((i+n)/2,(r+s)/2);if(this.shape instanceof ct){let a=this.shape.getPercent(t,Ut);return ct.pointOn(a/2,this.shape.controls)}else throw Error("not support")}}static finalAngle(t,i,r){let n=t.cross(i)>0,s=Math.acos(Math.min(1,Math.max(-1,t.dot(i)/i.length())));return(r?!n:n)&&(s=sE-s),s}sortInters(){if(this.shape instanceof Pe){let t=this.shape.center,i=this.shape.start().sub(t).normalize(),r=this.shape.isCCW;this.inters.sort((n,s)=>{let a=n.coord.sub(t),o=s.coord.sub(t);return OT.finalAngle(i,a,r)-OT.finalAngle(i,o,r)<=0?-1:1})}else if(this.shape instanceof me){let t=this.start,i=this.end,r=new we(i.x+(t.x-i.x)*2,i.y+(t.y-i.y)*2);this.inters.sort((n,s)=>n.coord.distance2(r)-s.coord.distance2(r)<=0?-1:1)}else if(this.shape instanceof ct){let t=this.shape;this.inters.sort((i,r)=>t.getPercent(i.coord,Ut)-t.getPercent(r.coord,Ut)<=0?-1:1)}else throw Error("not support the primitive type");this.inters.forEach((t,i)=>t.setIndex(i))}getStart(){return this.start}getEnd(){return this.end}getShape(){return this.shape}connect(t){this.nextSide=t,t.prevSide=this}static returnPolygonList(t){let i=[];return t.forEach(r=>{let n=[];r.forEach((s,a)=>{let o=[];s.forEach(l=>{o.push(l.shape)}),n.push(wi.build7(o))}),i.push(new as(n))}),i}addInter(t){this.inters.push(t)}static returnPolygonGroup(t){let i=[];return t.forEach(r=>{let n=[];r.forEach((s,a)=>{let o=[];s.forEach(l=>{o.push(l.shape)}),n.push(wi.build7(o))}),i.push(new as(n))}),new Pn(i)}static rebuild(t,i,r){let n;if(t instanceof me||i.distance2(r)<1e-6)n=new me(i,r);else if(t instanceof Pe)n=Pe.build2(t.center,i.angleD(t.center),r.angleD(t.center),t.rx,t.ry,t.isCCW?1:0);else if(t instanceof ct){let s=t.getPercent(i,Ut),a=t.clip(s)[1];n=a.clip(a.getPercent(r,Ut))[0]}else throw new Error("not supported operation");return Gt(t,i).dot(Gt(n,i))<0?null:n}static returnPolyline(t){return wi.build7(t.map(i=>i.shape))}bbox(){return this.shape.bbox()}},NY=(e=>(e[e.END1=0]="END1",e[e.END2=1]="END2",e[e.END12=2]="END12",e[e.LEFT1=3]="LEFT1",e[e.LEFT2=4]="LEFT2",e))(NY||{});function Ea(e,t,i){if(e instanceof Pe&&t instanceof Pe)return kY(e,t);if(e instanceof Pe&&t instanceof me)return SL(e,t);if(e instanceof me&&t instanceof Pe)return EL(e,t);if(e instanceof me&&t instanceof me)return vp(e,t);if(e instanceof ct&&t instanceof me)return e.controls.length===2||sh(e)?vp(new me(e.start(),e.end()),t):TO(e,t);if(e instanceof me&&t instanceof ct)return t.controls.length===2||sh(t)?vp(e,new me(t.start(),t.end())):RT(e,t);if(e instanceof Pe&&t instanceof ct)return t.controls.length===2||sh(t)?SL(e,new me(t.start(),t.end())):MY(e,t);if(e instanceof ct&&t instanceof Pe)return e.controls.length===2||sh(e)?EL(new me(e.start(),e.end()),t):BY(e,t);if(e instanceof ct&&t instanceof ct)return hI(e,t);throw new Error("not support")}function Kf(e,t){return Gt(e,t.start()).dot(Gt(t,t.start()))<=0?!1:Ea(e,t).state<=2}function sT(e,t){let i=t.getPercent(e.end(),Ut);if(i===null)return!1;if(i===0)return!0;let r=t.clip(i)[0],n=e.buildConverxHull(Ut),s=r.buildConverxHull(Ut),a=c(n),o=c(s);return l(a,o);function l(u,h){let d=new Map([[0,1],[1,0],[2,2],[3,4],[4,3]]),p=u[0],f=h[0];if(!p||!f)throw Error("isAllOverlap(sides1: PackSide[], sides2: PackSide[])");let m=!0;do{let g=p.getShape(),b=f.getShape();if(g instanceof me&&b instanceof me){let y=m?vp(g,b).state:d.get(vp(b,g).state);if(y===0)p=p.nextSide,m=!1;else if(y===1)f=f.nextSide,m=!0;else if(y===2)p=p.nextSide,f=f.nextSide,m=!0;else return!1}else throw Error("not support")}while(p!==u[0].prevSide&&f!==h[0].prevSide);return!0}function c(u){let h=u.primitives.map(p=>new m0(p)),d=h[h.length-1];return h.forEach(p=>{d.connect(p),d=p}),h}}function xL(e,t){let i=e.end().distance2(t.center);if(i>(t.rx+Ut)**2||i<(t.rx-Ut)**2||!(At(e.end(),t.end())||dI(t,e.end())))return!1;if(e.center.equals1(t.center))return!0;let r=e.center.distance1(t.center),n=Math.abs(e.rx-t.rx);if(r>Math.min(e.rx,t.rx)){let s=e.center.angleD(t.center);return e.rx>t.rx?!(r+n>Ut&&ou(e,s))&&!(r-n>Ut&&e.rx+t.rx-r>Ut&&ou(e,s+180)):!(r-n>Ut&&ou(e,s))&&!(e.rx+t.rx-r>Ut&&ou(e,s+180))}else{if(r+n<=Ut)return!0;let s=e.rx>t.rx?e.center.angleD(t.center):t.center.angleD(e.center);return ou(e,s)?!1:r-n<=Ut?!0:!ou(e,s+180)}}function MY(e,t){let i=pI(e,t.start()).toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=hI(a,t).state,r!==0)break}return r===2&&n!==i.length-1?{state:1}:{state:r}}function BY(e,t){let i=t.toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=hI(e,a).state,r!==1)break}return r===2&&n!==i.length-1?{state:0}:{state:r}}function hI(e,t){if(e.controls.length===2||sh(e))return t.controls.length===2||sh(t)?vp(new me(e.start(),t.end()),new me(t.start(),t.end())):RT(new me(t.start(),e.end()),t);if(t.controls.length===2||sh(t))return TO(NT(e,t.start()),new me(t.start(),t.end()));let i=NT(e,t.start());if(sh(i))return RT(new me(t.start(),e.end()),t);let r=sT(i,t),n=sT(t,i);if(!r&&!n){let s=ZU(i,t);if(s.havOverlap){let a=s.havOverlap!==2,o=s.havOverlap!==1;return oh(e,t,a,o)}else{let a=function(){for(let h=0;h<c;h+=2)ae[h]=u[h],ae[h+1]=u[h+1]},o,l,c=s.cnt,u=new Array(c).fill(0).map((h,d)=>ae[d]);for(let h=0;h<c;h+=2){let d=new we(ae[h],ae[h+1]),p=i.getPercent(d,Ut),f=t.getPercent(d,Ut);if(p===0||f===0)continue;let m=p===1?i:i.clip(p)[0],g=f===1?t:t.clip(f)[0];if(sT(m,g)){let b=Gt(e,d).cross(Gt(t,d));if(b===0){o=i.end(),l=t.end();break}return{state:b<0?3:4}}a()}return(!o||!l)&&(o=um(i.controls,i.controls[0],t),l=um(t.controls,i.controls[0],i)),{state:o.sub(i.controls[0]).cross(l.sub(i.controls[0]))>0?4:3}}}return oh(e,t,r,n)}function TO(e,t){let i=NT(e,t.start());if(sh(i))return vp(new me(i.start(),i.end()),t);let r=AO(i,t),{isIn:n,bezierIsInLeft:s}=IO(t,i);if(!r&&!n){if(s!==void 0)return{state:s?3:4};let a=null,o=e.getPercent(t.start(),Ut)+.01;for(let l=o>1?1:o;l<=1;){let c=ct.pointOn(l,e.controls);if(i0(t,c)>Sa){a=c;break}l+=.01,l>1&&(l=1)}if(!a)throw Error("!end1 && !end2 not result");return{state:t.direct.cross(a.sub(t.start()))<0?4:3}}return oh(i,t,r,n)}function RT(e,t){let{isIn:i,bezierIsInLeft:r}=IO(e,t),n=AO(t,e);if(!i&&!n){if(r!==void 0)return{state:r?4:3};let s=null;for(let a=.01;a<=1;){let o=ct.pointOn(a,t.controls);if(i0(e,o)>Sa){s=o;break}a+=.01,a>1&&(a=1)}if(!s)throw Error("!end1 && !end2 not result");return{state:e.direct.cross(s.sub(e.start()))<0?3:4}}return oh(t,e,i,n)}function kY(e,t){let i=xL(pI(e,t.start()),t),r=xL(t,e);if(!i&&!r){let n=vc(t);if(e.center.sub(t.start()).dot(t.center.sub(t.start()))>0){if(e.rx===t.rx)return e.isCCW?{state:n.dot(e.center.sub(t.center))<0?3:4,exitIsInvalid:!1}:{state:n.dot(e.center.sub(t.center))>0?3:4,exitIsInvalid:!1};let s,a;return e.rx>t.rx?(s=e,a=t):(s=t,a=e),n.dot(a.center.sub(s.center))>0&&a.rx+a.center.distance1(s.center)-s.rx>Ut?e.isCCW?{state:e.rx>t.rx?3:4,exitIsInvalid:!1}:{state:e.rx<t.rx?3:4,exitIsInvalid:!1}:e.isCCW?{state:e.rx<t.rx?3:4,exitIsInvalid:!0}:{state:e.rx>t.rx?3:4,exitIsInvalid:!0}}else return e.rx+t.rx-e.center.distance1(t.center)>Ut&&n.dot(e.center.sub(t.center))>0?{state:t.isCCW?3:4,exitIsInvalid:!1}:{state:e.isCCW?3:4,exitIsInvalid:!0}}return oh(e,t,i,r)}function EL(e,t){let i=wc.foot(e,t.center),r=e.end().distance2(t.center),n=e.end().sub(e.start()),s=(t.rx-Ut)**2,a=r<=(t.rx+Ut)**2&&r>=s&&(n.dot(i.sub(t.start()))<=0||e.start().distance2(e.end())<=e.start().distance2(i)||i.distance2(t.center)>=s)&&(At(e.end(),t.end())||dI(t,e.end())),o=CO(t,e);if(!a&&!o){let l=e.distance2(t.center);return l<=Sa?{state:n.cross(vc(t))>0?4:3}:n.dot(i.sub(t.start()))>=0&&(r<s||e.start().distance2(t.center)<s||l<s)?{state:n.cross(t.center.sub(e.start()))<0?4:3}:{state:n.cross(t.center.sub(e.start()))>0?4:3}}return oh(t,e,a,o)}function ou(e,t){return t=ei.regularD(t),e.sweepAngle>0?(t<e.startAngle&&(t+=360),e.endAngle()>t):(t>e.startAngle&&(t-=360),e.endAngle()<t)}function dI(e,t){return At(e.end(),t)||At(e.start(),t)||ou(e,t.angleD(e.center))}function IO(e,t){let i=e.panDistance(Ut),r=e.panDistance(-Ut),n=wL(t,i),s=wL(t,r);if(!n.length&&!s.length)return{isIn:t.getPercent(e.end(),Ut)!==null};let a=[...n,...s].sort((u,h)=>u.t-h.t),o=new me(r.start(),i.start()),l=[];for(let u=0,h=a.length;u<h;u++){let d=a[u];if(l.push(d),o.distance(d.interP)>e.length()+Ut)break;if(l.length===2){let p=(l[1].t*10+l.shift().t*10)/20,f=ct.pointOn(p,t.controls);if(e.distance2(f)>Sa)return{isIn:!1,bezierIsInLeft:e.direct.cross(f.sub(e.start()))>0}}}let c=l.length?o.distance(l[0].interP)>=e.length()+Ut:!0;return{isIn:c,bezierIsInLeft:c?void 0:e.direct.cross(l[0].interP.sub(e.start()))>0}}function AO(e,t){if(i0(t,e.end())>Sa||e.getToLineMaxDis2(t)>Sa)return!1;let i=GY(t,Sa);return e.getToLineMaxDis2(i)<=(t.length()+Ut)**2}function CO(e,t){let i=t.end().angleD(t.start()),r=FY(t,e.end());if(r>Sa)return!1;if(ou(e,i+90)){if(wc.foot(t,e.center).distance1(e.pointOn(i+90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}if(ou(e,i-90)){if(wc.foot(t,e.center).distance1(e.pointOn(i-90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}return r<=Sa&&(At(e.end(),t.end())||MT(t,e.end()))}var DO=(Ut*2)**2;function pI(e,t){if(At(e.end(),t))return Pe.build3(e.center,e.endAngle(),0,e.rx,e.ry);if(e.start().distance2(t)<DO)return e;let i=ei.regularD(t.angleD(e.center));if(!ou(e,i))throw new Error("!angleIsInArc(arc, angle)");return Pe.build2(e.center,i,e.endAngle(),e.rx,e.ry,e.isCCW?1:0)}function NT(e,t){if(At(e.end(),t))return new ct([t,t]);if(e.start().distance2(t)<DO)return e;let i=e.getPercent(t,Ut);if(i===null)throw new Error("!cutBezier(bezier: Bezier, p: Vector2)");return e.clip(i)[1]}function SL(e,t){let i=CO(pI(e,t.start()),t),r=t.end().distance2(e.center),n=t.end().sub(t.start()),s=wc.foot(t,e.center),a=(e.rx-Ut)**2,o=r<=(e.rx+Ut)**2&&r>=a&&(n.dot(s.sub(t.start()))<=0||t.start().distance2(t.end())<=t.start().distance2(s)||s.distance2(e.center)>=a)&&(At(e.end(),t.end())||dI(e,t.end()));if(!i&&!o){let l=t.distance2(e.center);return l<=Sa?{state:n.cross(vc(e,t.start().angle(e.center)))>0?3:4}:n.dot(s.sub(t.start()))>=0&&(r<a||t.start().distance2(e.center)<a||l<a)?{state:n.cross(e.center.sub(t.start()))>0?4:3}:{state:n.cross(e.center.sub(t.start()))<0?4:3}}return oh(t,e,i,o)}function vp(e,t){if(At(e.end(),t.end()))return oh(e,t,!0,!0);let i=i0(t,e.end())<=Sa&&MT(t,e.end()),r=i0(e,t.end())<=Sa&&MT(e,t.end());if(!i&&!r){let n=e.direct.x===0&&e.direct.y===0,s=t.direct.x===0&&t.direct.y===0;if(n&&s)throw Error("2LineAllIsPoint");return n?{state:t.direct.cross(e.end().sub(t.start()))>0?3:4}:{state:e.end().sub(e.start()).cross(t.end().sub(e.start()))>0?4:3}}return oh(e,t,i,r)}function MT(e,t){return wc.foot(e,t).distance2(e.start())<e.end().distance2(e.start())}function oh(e,t,i,r){if(i)return r?At(e.end(),t.end())?{state:2}:{state:0}:{state:0};if(r)return{state:1};throw new Error("!end1 && !end2")}function i0(e,t){return(e.a*t.x+e.b*t.y+e.c)**2/(e.a**2+e.b**2)}function FY(e,t){return Math.min(e.distance2(t),wc.foot(e,t).distance2(t))}function GY(e,t){let i=e.panDistance(t),r=e.panDistance(-t);return new me(r.start(),i.start())}function sh(e){let t=e.start(),i=e.end();t.equals1(i)&&(i=t.add1(1,0));let r=i.y-t.y,n=t.x-i.x,s=-r*t.x-n*t.y,a=Math.sqrt(1/(r**2+n**2));r*=a,n*=a,s*=a;let o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;return e.controls.forEach(c=>{let u=r*c.x+n*c.y+s;u<o&&(o=u),u>l&&(l=u)}),du(o,l)}function wL(e,t){let i=Pl(e,t),r=[],n=new Array(i).fill(0).map((a,o)=>ae[o]);for(let a=0;a<i;a+=2){let o=new we(ae[a],ae[a+1]),l=e.getPercent(o);r.push({interP:o,t:l}),s()}function s(){for(let a=0;a<i;a+=2)ae[a]=n[a],ae[a+1]=n[a+1]}return r}var su=.01,UY=270;function ad(e){let t=su**2,i=e.end(),r=[],n=[];for(let p=0,f=e.primitives.length;p<f;p++){let m=function(R,M){return R instanceof me&&M instanceof me&&Math.abs(R.direct.cross(M.direct))<Oe.eps&&R.direct.dot(M.direct)>0||R instanceof Pe&&M instanceof Pe&&Math.abs(R.rx-M.rx)<=Oe.eps&&R.center.distance2(M.center)<Oe.eps&&R.isCCW===M.isCCW},g=function(R){if(el(R,su))n.push(null);else{if(R instanceof me)n.push(R);else if(R instanceof Pe&&R.rx===R.ry)h(R,n);else if(R instanceof ct){let M=[];gO(R,M),M.forEach(F=>{let G=F.start(),V=F.end();u(G,V)||n.push(F)})}else throw new Error("not support!");i=S}},b=function(R){if(R instanceof me)return R.direct.x===0&&R.direct.y===0;if(R instanceof Pe)return R.sweepAngle===0;if(R instanceof ct){let M=new Set(R.controls.map(G=>G.x)),F=new Set(R.controls.map(G=>G.y));return M.size===1&&F.size===1}else throw new Error("not support")},y=e.primitives[p],E=y.start(),S=y.end();if(b(y))continue;u(i,E)||(n.push(new me(i,E)),i=E);let w=(p+1)%f,x=e.primitives[w];for(;m(y,x)&&(w=(w+1)%f,x=e.primitives[w],x!==y););if(w===(p+1)%f){g(y);continue}if(x===y){if(!(y instanceof Pe)){if(Math.abs(e.area(.1))<t)return null;throw new Error("simplifyPolyline not support")}let R=y instanceof Pe?y.isCCW:e.area(.1)>0;n.length=0;let M=R?180:-180;n.push(Pe.build3(y.center,y.startAngle,M,y.rx,y.ry),Pe.build3(y.center,y.startAngle+M,M,y.rx,y.ry));break}let I=(()=>{if(y instanceof me)return(R,M)=>{let F=new me(R,M);return el(F,su)?null:[F]};if(y instanceof Pe)return(R,M)=>{let F;if(R.equals1(M)?F=Pe.build3(y.center,y.startAngle,y.sweep()===1?360:-360,y.rx,y.ry):F=Pe.build4(R,M,y.center,y.rx,y.ry,y.sweep()),el(F,su))return null;let G=F.pointOn(F.startAngle+F.sweepAngle/2),V=Pe.build4(F.start(),G,y.center,y.rx,y.ry,y.sweep()),q=Pe.build4(G,F.end(),y.center,y.rx,y.ry,y.sweep());return el(V,su)||el(q,su)?[F]:[V,q]};throw new Error("not support")})(),A=w===0;if(w<p&&!A&&(A=!I(e.primitives[0].start(),e.primitives[w-1].end()),!A)){let R=I(y.start(),e.primitives[f-1].end());if(R)n.push(...R);else{let M=I(y.start(),n[0].end());if(M.length===1)n[0]=M[0];else if(M.length===2)n[0]=M[1],n.push(M[0]);else throw new Error("!!!generatorPt")}break}p=w===0?f-1:w-1,x=e.primitives[p];let O=I(y.start(),x.end());if(O?(O.forEach(R=>n.push(R)),i=x.end()):g(null),A)break}let s=n.length;if(n.forEach((p,f)=>{if(p)r.push(p);else{let m,g;f===s-1&&(m=r[0],g=r[r.length-1]);let b=(f+1)%s;if(m=m!=null?m:n[b],m){let y=f,E=!1;for(;g=g!=null?g:n[(--y+s)%s],g!==m;)if(g){E=!0;break}if(E){if(m.start().equals1(g.end()))return;if(Gt(g,g.end()).dot(Gt(m,m.start()))<0){if(!u(g.end(),m.start())){let I=new me(g.end(),m.start());r.push(I);return}let{rebuildPrevPt:S,rebuildNextPt:w,rebuildLinkLine:x}=vL(n[(y-1+s)%s],g,new me(g.end(),m.start()),m,n[(f+2)%s]);S&&w&&(S!==g?(n[(y+s)%s]=S,r[r.length-1]&&(r[r.length-1]=S)):w!==m&&(n[(f+1)%s]=w,r[0]===m&&(r[0]=w)),x&&r.push(x))}}}}}),r.length===0)return null;u(i,r[0].start())||r.push(new me(i,r[0].start()));let a=r[r.length-1];if(r.length===1)return a instanceof Pe?wi.build7([Pe.build2(a.center,0,180,a.rx,a.ry,a.sweep()),Pe.build2(a.center,180,360,a.rx,a.ry,a.sweep())]):a instanceof ct?wi.build7(a.clip(.5)):null;let o=r.map(p=>new YY(p)),l=o[o.length-1];for(o.forEach(p=>{p.connect(l),l=p});!l.isVisited;){let p=function(){l.next.connect(m),l=l.next,l.isConnected=!1,l.isVisited=!1},f=function(){l.connect(m.prev),l.isConnected=!1},m=l.prev;if(l===m)break;let g=l.pt,b=m.pt,y=b.end();if(!l.isConnected&&!y.equals(g.start())){let E=function(w){l.isConnected=!0,l.pt=g=w,l.next.isVisited=!1},S=function(w){l.isConnected=!0,m.pt=w,m.isVisited=!1,l=m};if(g instanceof me)if(u(y,g.end())){p();continue}else E(new me(y,g.end()));else if(b instanceof me){u(b.start(),g.start())?f():S(new me(b.start(),g.start()));continue}else if(g instanceof ct)if(u(y,g.end())&&!(g.controls.length!==2&&g.getToLineMaxDis2(g.startToEndL)>=t)){p();continue}else E(new ct([y,...g.controls.slice(1)]));else if(b instanceof ct)u(b.start(),g.start())&&!(b.controls.length!==2&&b.getToLineMaxDis2(b.startToEndL)>=t)?f():S(new ct([...b.controls.slice(0,-1),g.start()]));else if(g instanceof Pe&&b instanceof Pe)if(Math.abs(Math.abs(g.sweepAngle)-180)<Math.abs(Math.abs(b.sweepAngle)-180)){let w=Pe.build5(y,g.end(),g.sweepAngle);if(u(w.start(),w.end())&&!(w.rx>=su&&Math.abs(w.sweepAngle)>180)){p();continue}else E(w)}else{let w=Pe.build5(b.start(),g.start(),b.sweepAngle);u(w.start(),w.end())&&!(w.rx>=su&&Math.abs(w.sweepAngle)>180)?f():S(w);continue}else throw new Error("not support")}if(Gt(g,g.start()).dot(Gt(b,b.end()))<0){let E=function(x,I,A,O,R,M){if(l.next===m){l=null;return}let{rebuildLinkLine:F,rebuildPrevPt:G,rebuildNextPt:V}=vL(x,I,A,O,R);G&&V&&(G!==I&&(m.prev.pt=G),V!==O&&(l.next.pt=V),F?M.pt=F:p())},S=function(){l.next===m?l=null:(l.next.connect(m.prev),l=l.next,l.isConnected=!1,l.isVisited=!1)},w=Ea(b.reverse(),g).state;if(w===0){let x=TL(g,b.start(),g.end());if(d(x)){let I=m.prev.pt,A=l.next.pt;if(Gt(A,A.start()).dot(Gt(I,I.end()))>=0){if(S(),!l)break;continue}if(E(m.prev.prev.pt,I,x instanceof me?x:new me(x.start(),x.end()),A,l.next.next.pt,l),!l)break}else l.pt=x;f();continue}else if(w===1){let x=TL(b,b.start(),g.end());if(d(x)){let I=m.prev.pt,A=l.next.pt;if(Gt(A,A.start()).dot(Gt(I,I.end()))>=0){if(S(),!l)break;continue}if(E(m.prev.prev.pt,I,x instanceof me?x:new me(x.start(),x.end()),A,l.next.next.pt,m),!l)break}else m.pt=x;p();continue}else if(w===2){if(S(),!l)break;continue}}l.isVisited=!0,l=l.next}if(!l)return null;r.length=0;let c=l;for(r.push(l.pt),l=l.next;l!==c;)r.push(l.pt),l=l.next;if(r.length===1){let p=r[0];return p instanceof Pe?(u(p.start(),p.end())?r[0]=Pe.buildCircle(p.center,p.rx,p.sweep()):r.push(new me(p.end(),p.start())),wi.build7(r)):p instanceof ct?(u(p.start(),p.end())||r.push(new me(p.end(),p.start())),wi.build7(r)):null}if(e=wi.build7(r),Math.abs(e.area(.1))<t)return null;return e;function u(p,f){return p.distance2(f)<t}function h(p,f){if(Math.abs(p.sweepAngle)>UY){let m=p.sweepAngle/2;h(Pe.build3(p.center,p.startAngle,m,p.rx,p.ry),f),h(Pe.build3(p.center,p.startAngle+m,m,p.rx,p.ry),f)}else f.push(p)}function d(p){return p.start().distance2(p.end())<t&&!(p instanceof Pe&&p.rx>=su&&Math.abs(p.sweepAngle)>180||p instanceof ct&&p.controls.length!==2&&p.getToLineMaxDis2(new me(p.start().add1(1,0),p.end()))>=t)}}function el(e,t){if(!e)return!0;let i=e.start(),r=e.end();if(i.distance2(r)<t**2)if(e instanceof Pe){if(!(e.rx>=t&&Math.abs(e.sweepAngle)>180))return!0}else if(e instanceof ct){if(!(e.controls.length!==2&&e.getToLineMaxDis2(new me(e.start().add1(1,0),e.end()))>=t))return!0}else return!0;return!1}function $f(e){if(e.direct.x===0&&e.direct.y===0)throw Error("getEndOfExtendLine(line: Line, distance: number)");let t=Math.abs(su-e.length())+Oe.eps,i={x:e.direct.normalize().x*t,y:e.direct.normalize().y*t},r=e.end();return new we(r.x+i.x,r.y+i.y)}function vL(e,t,i,r,n){if(!e)a();else if(!n)o();else{let l=Gt(e,e.end()),c=Gt(t,e.end()),u=l.dot(c);if(u>=0)a();else{let h=Gt(r,r.end()),d=Gt(n,r.end()),p=h.dot(d);if(p>=0)o();else if(du(u,-1)&&du(p,-1)){let f=i.center();s(f),i=null}else u>p?a():o()}}function s(l){let c;if(t instanceof me)c=new me(t.start(),l);else if(t instanceof ct)c=new ct([...t.controls.slice(0,-1),l]);else if(t instanceof Pe)c=Pe.build5(t.start(),l,t.sweepAngle);else throw new Error("not supported");t=el(c,Ut)?null:c;let u;if(r instanceof me)u=new me(l,r.end());else if(r instanceof ct)u=new ct([l,...r.controls.slice(1)]);else if(r instanceof Pe)u=Pe.build5(l,r.end(),r.sweepAngle);else throw new Error("supported");r=el(u,Ut)?null:u}function a(){if(t instanceof me){let l=$f(i.reverse());i=new me(l,i.end());let c=new me(t.start(),l);t=el(c,Ut)?null:c}else if(t instanceof ct){let l=$f(i.reverse());i=new me(l,i.end());let c=new ct([...t.controls.slice(0,-1),l]);t=el(c,Ut)?null:c}else if(t instanceof Pe){let l=$f(i.reverse());i=new me(l,i.end());let c=Pe.build5(t.start(),l,t.sweepAngle);t=el(c,Ut)?null:c}else throw new Error("not supported")}function o(){if(r instanceof me){let l=$f(i);i=new me(i.start(),l);let c=new me(l,r.end());r=el(c,Ut)?null:c}else if(r instanceof ct){let l=$f(i);i=new me(i.start(),l);let c=new ct([l,...r.controls.slice(1)]);r=el(c,Ut)?null:c}else if(r instanceof Pe){let l=$f(i);i=new me(i.start(),l);let c=Pe.build5(l,r.end(),r.sweepAngle);r=el(c,Ut)?null:c}else throw new Error("not supported")}return{rebuildPrevPt:t,rebuildNextPt:r,rebuildLinkLine:i}}function TL(e,t,i){if(e instanceof me||t.distance2(i)<=Sa)return new me(t,i);if(e instanceof Pe)return Pe.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof ct){let r=e.getPercent(t,Ut),n=e.getPercent(i,Ut);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}var YY=class{constructor(e){this.pt=e}connect(e){this.prev=e,e.next=this}};function jx(e){let t=g0(),i;if(e instanceof wi){let r=ad(e);if(r===null)return null;i=r}else if(e instanceof as){let r=e.items.map(n=>jx(n)).filter(n=>n!==null);if(r.length===0)return null;i=new as(r)}else{let r=e.items.map(n=>jx(n)).filter(n=>n!==null);if(r.length===0)return null;i=new Pn(r)}return cu.preprocessPolyline+=id(t),i}var cu={addDocShapes2RTree:0,getPour:0,prepare:0,getSinglePourLayerPolyline:0,combindOutlines:0,mergeSameNet:0,run:0,end:0,deSelfIntersection:0,changeDirect:0,extend:0,preprocessPolyline:0,runBoolean:0,IntersectionSeeker:0,BooleanTools:0,totalBool:0};function g0(){return{timeIndex:Object.assign({},cu),start:performance.now()}}function IL(e){return Object.values(e).reduce((t,i)=>t+i,0)}function id(e){return performance.now()-e.start-(IL(cu)-IL(e.timeIndex))}function Cs(e,t,i,r){let n=zi.RED,s=zi.Golden;function a(){if(!r)return;let d=r.initColor(zi.Golden);d.addPt(o),d.addPoint(o.end()),r.initColor(zi.RED).addPt(l),r.draw();debugger}let o=e.getShape(),l=i?t.getShape():t.getShape().reverse(),c=Gt(o,l.start()),u=Gt(l),h=c.cross(u);if(du(h,0))if(o instanceof me)if(l instanceof me){if(Oe.eq(h,0)&&(c.dot(u)>0?!At(o.end(),l.start()):!At(o.start(),l.start())))throw a(),new Error("line and line");return h<0}else{if(l instanceof Pe)return c.cross(l.center.sub(o.start()))<0;if(l instanceof ct){let d=l.getExtremePoints(o),p=d.length?d[0]:um(l.controls,o.start());return c.cross(p.sub(o.start()))<0}else throw new Error("not support")}else if(o instanceof Pe){if(l instanceof me)return o.isCCW;if(l instanceof Pe){if(l.center.equals1(o.center)&&(c.dot(u)>0?!At(o.end(),l.start())&&o.end().sub(l.start()).dot(u)>0:!At(o.start(),l.start())&&o.start().sub(l.start()).dot(u)>0))throw a(),new Error("arc and arc");return l.rx>=o.rx||l.center.distance2(o.center)>o.rx2?o.isCCW:!o.isCCW}else throw new Error("not support")}else if(o instanceof ct)if(l instanceof me){let d=o.getPercent(l.start(),Ut),p=o.clip(d)[1],f=p.getExtremePoints(l);return(f.length?f[0]:um(p.controls,l.start())).sub(l.start()).cross(u)<0}else if(l instanceof ct){let d=o.getPercent(l.start(),Ut),p=o.clip(d)[1],f=p.getExtremePoints(new me(l.start(),l.end())),m=l.getExtremePoints(new me(p.start(),p.end())),g=f.length?f[0]:um(p.controls,l.start()),b=m.length?m[0]:um(l.controls,l.start()),y=g.sub(l.start()),E=b.sub(l.start());return y.cross(E)<0}else throw Error("not support");else throw new Error("not support");else return h<0}function Cp(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Pe?vc(s,ei.toRadians(s.endAngle())):s instanceof ct?e0(s,1):s.end().sub(s.start()).normalize(),l=Gt(a),c=o.dot(l);if(du(c,-1))return Cs(e,t,!0,n)?Cs(e,i,r,n)&&Cs(t,i,r,n):Cs(e,i,r,n)||Cs(t,i,r,n);{let u=o.scale(-1).angle(we.ORIGIN),h=l.angle(we.ORIGIN);u>h&&(u-=sE);let d=(u+h)/2,p=new we(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=Gt(f);return p.cross(m)<0?Cs(e,i,r,n):Cs(t,i,r,n)}}function aT(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Pe?vc(s,ei.toRadians(s.endAngle())):s instanceof ct?e0(s,1):s.end().sub(s.start()).normalize(),l=Gt(a),c=o.dot(l);if(du(c,-1))return Cs(e,t,!0,n)?Cs(e,i,r,n)&&Cs(t,i,r,n):Cs(e,i,r,n)||Cs(t,i,r,n);{let u=o.scale(-1).angle(we.ORIGIN),h=l.angle(we.ORIGIN);u>h&&(u-=sE);let d=(u+h)/2,p=new we(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=Gt(f);if(p.cross(m)<0){let g=o.dot(m)<0,b=Ea(g?e.getShape().reverse():e.getShape(),f).state;return b!==3&&b!==4?Cs(e,i,r,n):b===(g?4:3)}else{let g=l.dot(m)<0,b=Ea(g?t.getShape().reverse():t.getShape(),f).state;return b!==3&&b!==4?Cs(t,i,r,n):b===(g?4:3)}}}var VY=(e=>(e[e.NOT_IN=0]="NOT_IN",e[e.IS_IN=1]="IS_IN",e[e.IS_OVERLAP=2]="IS_OVERLAP",e))(VY||{}),HY=(e=>(e[e.AllClear=0]="AllClear",e[e.MapClear=1]="MapClear",e))(HY||{}),lu,nd=!1;function tl(e,t,i,r,n,s,a,o=i.side===t,l=!0,c){return lu=n,nd=s,_O(PO(e,t,l,c,a,i,o,r),i,o,r,0)}function ih(e,t,i,r,n,s,a,o=r.side===i){lu=n,nd=s;let l=LO(e,t,i,new Map,r,o,a),c=l instanceof Array?-1:1;return _O(l,r,o,a,c)}function _O(e,t,i,r,n){for(;e instanceof Array;)n++,e.length===4?e=LO(...e,t,i,r):e=PO(...e,t,i,r);return{...e,existOverlap:n>0}}function PO(e,t,i,r,n,s,a,o){if(zx===-1){o.initColor(zi.RED).addPt(e.getShape()),o.initColor(zi.Golden).addPt(t.getShape()),o.draw();debugger}let l=e.getShape(),c=a?t.getShape().reverse():t.getShape(),u=(l instanceof Pe?vc(l,i?c.start().angle(l.center):r?ei.toRadians(l.endAngle()):void 0):l instanceof ct?Gt(l,i?c.start():r?l.end():l.start()):l.end().sub(l.start())).normalize(),h=(c instanceof Pe?vc(c,i?void 0:(r?l.end():l.start()).angle(c.center)):c instanceof ct?Gt(c,i?void 0:r?l.end():l.start()):c.end().sub(c.start())).normalize();if(r===void 0){let f=u.dot(h);if(r=f<0,du(f,0))return{state:Cs(e,t,!a,o)?1:0,inter:rh(e,t,s,a,i,r,n)}}else if(r?u.dot(h)>0:u.dot(h)<0)if(i){let f,m=!0;if(l instanceof me&&At(wc.foot(l,c.start()),r?l.end():l.start()))m=!1;else if(l instanceof Pe||l instanceof ct){let g=r?l.reverse():l,b=Ea(c,rY(g,c.start()).reverse()).state;(b===1||b===2)&&(m=!1)}if(m){let g=!r;f=Ea(g?l.reverse():l,c,o).state===(g?4:3)?1:0}else r?f=Cp(e,e.nextSide,t,!a,o)?1:0:f=Cp(e.prevSide,e,t,!a,o)?1:0;return{state:f,inter:rh(e,t,s,a,i,r,n)}}else return r?{state:Cs(e,e.nextSide,!0,o)?0:1,inter:rh(e,t,s,a,i,r,n),isReversed:!0}:{state:Cs(e.prevSide,e,!0,o)?0:1,inter:rh(e,t,s,a,i,r,n),isReversed:!0};let d,p=new Map([[3,4],[4,3],[0,1],[1,0],[2,2]]);if(i)if(e.judgeOverlapMap.has(t)&&!nd){let f=e.judgeOverlapMap.get(t);d=r?p.get(f.state):f.state}else d=Ea(r?l.reverse():l,c).state,(d===3||d===4)&&e.judgeOverlapMap.set(t,{state:r?p.get(d):d});else{if(t.judgeOverlapMap.has(e)&&!nd){let f=t.judgeOverlapMap.get(e);d=a?p.get(f.state):f.state}else d=Ea(c,r?l.reverse():l).state,(d===3||d===4)&&t.judgeOverlapMap.set(e,{state:a?p.get(d):d});d=p.get(d)}if(d===1||d===2){let f=a?t.prevSide:t,m=f.inters,g=f.getEnd();for(let b=m.length-1;b>=0;b--){let y=m[b];if(!(f.getShape()instanceof ct)&&!At(g,y.coord))break;if(y===s)return{state:2,inter:rh(e,t,s,a,i,r,n)}}}if(d===3||d===4)return{state:d===(r?4:3)?1:0,inter:rh(e,t,s,a,i,r,n)};if(n.has(e)?n.get(e).mapSideList.push(t):n.set(e,{sideIsReversed:r,mapSideList:[t]}),n.has(t)?n.get(t).mapSideList.push(e):n.set(t,{sideIsReversed:a,mapSideList:[e]}),d===2)return r?[e.prevSide,e,a?t.prevSide:t.nextSide,n]:[e,e.nextSide,a?t.prevSide:t.nextSide,n];if(d===0)return[r?e.prevSide:e.nextSide,t,!1,r,n];if(d===1)return[e,a?t.prevSide:t.nextSide,!0,r,n];throw Error("not support")}function rh(e,t,i,r,n,s,a){if(nd)return null;let o=e.getShape(),l=r?t.getShape().reverse():t.getShape(),c=r;if(!n){let p=t;t=e,e=p,r=s,i=i.getBindedInter()}let u=p=>!(n?s:c)&&At(p,e.prevSide.getEnd())?e.prevSide:e;if(r){let p=t.inters;for(let f=0;f<p.length;f++){let m=p[f];if(m.isInvalid&&s===void 0)continue;if(m===i&&At(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,b=u(m.coord);if(g===b&&h(m))return d(m)}for(;;){t=t.nextSide;let f=t.inters;for(let m=0;m<f.length;m++){let g=f[m];if(g===i)return n?g:g.getBindedInter();if(a.has(t)){let b=g.getBindedInter().side;if(a.get(t).mapSideList.includes(b)||At(g.coord,b.getEnd())&&a.get(t).mapSideList.includes(b.nextSide))return d(g);if(a.has(b)){let y=t.getShape().reverse(),E=Gt(y,g.coord).dot(Gt(b.getShape(),g.coord))<0,S=E?b.getShape().reverse():b.getShape(),w=Ea(y,E?eT(S,g.coord,S.end()):eT(S,S.start(),g.coord)).state;if(w===1||w===2)return d(g)}else a.has(b.nextSide)}else if(g.side===i.side&&h(g))return d(g)}}}else{let p=t.inters;for(let f=p.length-1;f>=0;f--){let m=p[f];if(m.isInvalid&&s===void 0)continue;if(m===i&&At(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,b=u(m.coord);if(g===b&&h(m))return d(m)}for(;;){t=t.prevSide;let f=t.inters;for(let m=f.length-1;m>=0;m--){let g=f[m];if(g===i)return n?g:g.getBindedInter();if(a.has(t)){let b=g.getBindedInter().side;if(a.get(t).mapSideList.includes(b)||At(g.coord,g.getBindedInter().side.getEnd())&&a.get(t).mapSideList.includes(b.nextSide))return d(g);if(!a.has(b)&&a.has(b.prevSide)){let y=t.getShape().reverse(),E=Gt(y,g.coord).dot(Gt(b.getShape(),g.coord))<0;if(a.has(b.prevSide)){let S=E?b.getShape().reverse():b.getShape(),w=Ea(t.getShape(),eT(S,g.coord,S.end())).state;if(w===1||w===2)return d(g)}}}else if(g.side===i.side&&h(g))return d(g)}}}function h(p){if(p.isInvalid||p.getBindedInter().side!==(At(p.coord,e.prevSide.getEnd())?e.prevSide:e))return!1;let f;if(n){if(At(p.coord,l.start()))return!0;f=Ea(s?o.reverse():o,m(l)).state}else{if(At(p.coord,s?o.end():o.start()))return!0;f=Ea(l,m(s?o.reverse():o)).state}return f===2||f===1;function m(g){if(g instanceof me)return At(p.coord,g.end())?g:g.cutLine(p.coord);if(g instanceof Pe)return Pe.build2(g.center,g.startAngle,p.coord.angleD(g.center),g.rx,g.ry,g.isCCW?1:0);if(g instanceof ct)return g.clip(g.getPercent(p.coord,Ut))[0];throw new Error("not supported operation")}}function d(p){let f=i.getBindedInter(),m=i.side,g=f.side,b=i===p,y=i;if(r){let E=i.getIndex()-1;for(;m;){let S=m.inters;for(;E>=0;E--)if(i=S[E],i===p){b||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(lu===0)!i.isInvalid&&(!At(i.coord,p.coord)||i.side===p.side&&i.getBindedInter().side===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(lu===1){if(i.isInvalid)continue;let w=i.getBindedInter().side;a.has(m)&&a.get(m).mapSideList.includes(w)&&(i.setIsInvalid(),i.isDealed(),y=i)}m=m==null?void 0:m.prevSide,E=(m==null?void 0:m.inters.length)-1}}else{let E=i.getIndex()+1;for(;m;){let S=m.inters;for(;E<S.length;E++){i=S[E];let w=i.getBindedInter();if(i===p){b||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(lu===0)!i.isInvalid&&(!At(i.coord,p.coord)||m===p.side&&(At(w.side.getEnd(),i.coord)?w.side.nextSide:w.side)===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(lu===1){let x=w.side;a.has(m)&&a.get(m).mapSideList.includes(x)&&(i.setIsInvalid(),i.isDealed(),y=i)}}m=m==null?void 0:m.nextSide,E=0}}if(lu===0&&!At(f.coord,p.coord))if(n?a.has(g)?a.get(g).sideIsReversed:s:c){let E=f.getIndex()-1;for(;g;){let S=a.has(g),w=g.inters;for(;E>=0;E--){if(f=w[E],f===p.getBindedInter()){g=null;break}f.isInvalid||!S||(!At(f.coord,p.getBindedInter().coord)||f.side===p.side&&f.getBindedInter().side===p.getBindedInter().side)&&(f.setIsInvalid(),f.isDealed())}g=g==null?void 0:g.prevSide,E=(g==null?void 0:g.inters.length)-1}}else{let E=f.getIndex()+1;for(;g;){let S=g.inters,w=a.has(g);for(;E<S.length;E++){if(f=S[E],f===p.getBindedInter()){g=null;break}let x=At(g.getEnd(),f.coord)?a.has(g.nextSide):!1;f.isInvalid||!(w||x)||(!At(f.coord,p.getBindedInter().coord)||f.side===p.side&&f.getBindedInter().side===p.getBindedInter().side)&&(f.setIsInvalid(),f.isDealed())}g=g==null?void 0:g.nextSide,E=0}}return n?y:y.getBindedInter()}}function LO(e,t,i,r,n,s,a){let o=e.getShape(),l=t.getShape(),c=s?i.getShape().reverse():i.getShape(),u=(o instanceof Pe?vc(o,c.start().angle(o.center)):o instanceof ct?Gt(o,c.start()):o.end().sub(o.start())).normalize(),h=(l instanceof Pe?vc(l,c.start().angle(l.center)):l instanceof ct?Gt(l,c.start()):l.end().sub(l.start())).normalize(),d=u.dot(h);if(du(d,-1)){let p=s?i.getShape().reverse():i.getShape(),f=Gt(p).normalize(),m=u.add(h.scale(-1)).normalize().dot(f),g=Ea(o.reverse(),l,a).state;if(m>-.9&&(g===3||g===4))return{state:g===4?0:1,inter:rh(t,i,n,s,!0,!1,r)};let b=tl(e,i,n,a,lu,nd,r.size===0?new Map:r,s);return b.state===2?b:g===4?b.state===0||b.inter!==n?b:tl(t,i,n,a,lu,nd,r.size===0?new Map:r,s):b.state===1||b.inter!==n?b:tl(t,i,n,a,lu,nd,r.size===0?new Map:r,s)}else{let p=u.scale(-1).angle(we.ORIGIN),f=h.angle(we.ORIGIN);p>f&&(p-=sE);let m=(p+f)/2,g=new we(Math.cos(m),Math.sin(m)),b=Gt(c).normalize(),y=b.angle(we.ORIGIN),E=p<y&&y<f&&o instanceof me&&l instanceof me&&c instanceof me;if(g.cross(b)<=0){if(u.scale(-1).dot(b)<0){let S;return n.coord.equals1(c.start())?S=Gt(o,n.coord).dot(Gt(c,n.coord))<0:c instanceof me&&(S=Gt(o,o.end()).dot(c.direct)<0),{state:Cp(e,t,i,!s,a)?1:0,inter:rh(e,i,n,s,!0,S,r)}}return E&&o.distance2(c.start())>Sa?[t,i,!0,void 0,r]:[e,i,!0,void 0,r]}else return h.dot(b)<=0?{state:Cp(e,t,i,!s,a)?1:0,inter:rh(t,i,n,s,!0,void 0,r)}:E&&l.distance2(c.start())>Sa?[e,i,!0,void 0,r]:[t,i,!0,void 0,r]}}var zx=0;function jY(e,t,i,r){let n=t.getBindedInter(),s=t.side,a=n.side,o=s.getShape(),l=a.getShape();if(r&&(zx++,zx===-1)){r.initColor(zi.RED).addPt(o),r.initColor(zi.Golden).addPt(l),r.draw();debugger}let c=0,u=!1;if(e===-1){let I=ih(s,s.nextSide,a,n,c,u,r),A=I.state!==0;if(I.state===2){let R=Gt(o,t.coord).add(Gt(s.nextSide.getShape(),t.coord)).normalize(),M=Gt(l,t.coord).add(Gt(a.nextSide.getShape(),t.coord)).normalize();return x(A,R.dot(M)>0)}let O=ih(s,s.nextSide,a.nextSide,n,c,u,r);return I.state!==O.state?(w(I,O),1):x(A,I.state!==ih(a,a.nextSide,s,t,c,!0,r).state,I.inter,O.inter)}if(e===1){let I=tl(s,a,n,r,c,u,new Map),A=I.state!==0;if(I.state===2)return x(A,Gt(o,t.coord).dot(Gt(l,t.coord))>0);let O;if(I.isReversed&&I.existOverlap&&At(I.inter.coord,a.getEnd())&&I.inter.getBindedInter().side!==s){let F=I.inter.getBindedInter().side;if(F===s.nextSide)O={state:Cp(s,F,a.nextSide,!0,r)?1:0,inter:n};else if(F===s.prevSide){if(O={state:Cp(F,s,a.nextSide,!0,r)?1:0,inter:I.inter},I.state===O.state&&t!==I.inter){let G=Gt(l,t.coord),V=Gt(a.nextSide.getShape(),t.coord),q=Gt(F.getShape(),t.coord);return x(A,G.add(V).dot(q)>0,I.inter,O.inter)}}else O=tl(s,a.nextSide,n,r,c,u,new Map)}else O=tl(s,a.nextSide,n,r,c,u,new Map);if(I.state!==O.state)return w(I,O),1;let R=Gt(l,t.coord),M=Gt(a.nextSide.getShape(),t.coord);if(du(R.dot(M),-1)){let F=Cs(a,a.nextSide,!0,r);return x(A,I.state!==tl(a.nextSide,s,t,r,c,!0,new Map,F?!A:A,!1).state,I.inter,O.inter)}else{let F=Gt(o,t.coord);return x(A,R.add(M).dot(F)>0,I.inter,O.inter)}}if(!(o instanceof ct||l instanceof ct))return 1;let h=Gt(o,t.coord),d=Gt(l,t.coord),p,f;if(l instanceof me)p=new me(t.coord,l.start()),f=new me(t.coord,l.end());else if(l instanceof Pe){let I=t.coord.angleD(l.center);p=Pe.build2(l.center,I,l.startAngle,l.rx,l.ry,l.isCCW?0:1),f=Pe.build2(l.center,I,l.endAngle(),l.rx,l.ry,l.isCCW?1:0)}else if(l instanceof ct){let I=l.getPercent(t.coord,Ut);[p,f]=l.clip(I),p=p.reverse()}else throw new Error("not support");let m=h.dot(d)>0,g,b;m?(g=Ea(o.reverse(),p).state,b=Ea(o,f).state):(g=Ea(o,p).state,b=Ea(o.reverse(),f).state);let y;g===0?y=tl(m?s.prevSide:s.nextSide,a,n,r,c,u,new Map,!0,!1,m):g===1?y=tl(s,a.prevSide,n,r,c,u,new Map,!0,!0,m):g===2?m?y=ih(s.prevSide,s,a.prevSide,n,c,u,r,!0):y=ih(s,s.nextSide,a.prevSide,n,c,u,r,!0):m?g===3?y={inter:n,state:0}:y={inter:n,state:1}:g===3?y={inter:n,state:1}:y={inter:n,state:0};let E=y.state!==0;if(y.state===2)return x(E,m);let S;if(b===0?S=tl(m?s.nextSide:s.prevSide,a,n,r,c,u,new Map,!1,!1,!m):b===1?S=tl(s,a.nextSide,n,r,c,u,new Map,!1,!0,!m):b===2?m?S=ih(s,s.nextSide,a.nextSide,n,c,u,r,!1):S=ih(s.prevSide,s,a.nextSide,n,c,u,r,!1):m?b===3?S={inter:n,state:1}:S={inter:n,state:0}:b===3?S={inter:n,state:0}:S={inter:n,state:1},y.state===S.state)return y.inter===S.inter?(t.setIsInvalid(),0):x(E,m,y.inter,S.inter);return w(y,S),1;function w(I,A){let O=I.state!==0;if(I.inter===A.inter){t.setOutToIn(O);return}else Zf(I.inter,A.inter,!0),Zf(A.inter,I.inter,!1);let R=[];if(e===-1){let F=Gt(o,t.coord),G=Gt(s.nextSide.getShape(),t.coord),V=Gt(l,t.coord),q=Gt(a.nextSide.getShape(),t.coord);R.push(F.dot(V)),R.push(F.dot(q)),R.push(G.dot(V)),R.push(G.dot(q))}else{let F=Gt(o,t.coord);R.push(Gt(l,t.coord).dot(F)),R.push(Gt(a.nextSide.getShape(),t.coord).dot(F))}if(R.reduce((F,G)=>Math.abs(F)>Math.abs(G)?F:G,0)>0)if(i===1||i===0||i===2||i===3)t.setOutToIn(O);else throw new Error("not support");else if(i===1)M(!O);else if(i===0||i===2||i===3)M(O);else throw new Error("not support");function M(F){t.setIsInvalid();let G=(F?I:A).inter;delete G.isInvalid,delete G.getBindedInter().isInvalid,G.setOutToIn(!O)}}function x(I,A,O,R){if(O===R){if(t.side.outline.inters.find(G=>!G.isInvalid&&G!==t&&At(G.coord,t.coord)))return t.setIsInvalid(),0;let M=new nh(t.coord,s,r),F=new nh(t.coord,a,r);return M.bind(F),A?s.inters.splice(t.getIndex(),0,M):s.inters.splice(t.getIndex()+1,0,M),a.inters.splice(t.getBindedInter().getIndex(),0,F),M.setOutToIn(I),t.setOutToIn(!I),M.isDealed(),s.inters.forEach((G,V)=>G.setIndex(V)),a.inters.forEach((G,V)=>G.setIndex(V)),2}else{let M=function(){let F=O.getBindedInter(),G=R.getBindedInter();delete O.isInvalid,delete F.isInvalid,delete R.isInvalid,delete G.isInvalid,O.setOutToIn(!I),R.setOutToIn(I),Zf(O,R,!0),Zf(R,O,!1),Zf(F,G,A),Zf(G,F,!A)};if(t.setIsInvalid(),A){if(i===1||i===0||i===2||i===3)return M(),2;throw new Error("not support")}else{if(i===1)return I?0:(M(),2);if(i===0||i===2||i===3)return I?(M(),2):0;throw new Error("not support")}}}}function Zf(e,t,i){let{judge:r,changeNum:n}=a(),s=e.getIndex();for(let o=s+n,l=e.side.inters;r(o);o+=n){if(l[o].isInvalid)continue;if(!At(l[o].coord,e.coord))break;l[o].setIndex(s),l[s].setIndex(o);let c=l[o];l[o]=l[s],l[s]=c,s=o}function a(){let o=e.side===t.side;if(i){let l=o?t.getIndex():e.side.inters.length;return{judge:c=>c<l,changeNum:1}}else{let l=o?t.getIndex()+1:0;return{judge:c=>c>=l,changeNum:-1}}}}var AL=0,nh=class{constructor(e,t,i){this.id=AL++,this.coord=e,this.side=t,i&&(this.id=AL++,this.drawDebug=i);let r=new to;r.ext2(e),this._bbox=r.build1()}bbox(){return this._bbox}resetVisitStatus(){this.visited=!1,this.bindedInter.visited=!1}isDealed(){this.dealed=!0,this.getBindedInter().dealed=!0}setOutToIn(e){this.outToIn=e,this.bindedInter.outToIn=!e}setIsInvalid(){this.isInvalid=!0,this.getBindedInter().isInvalid=!0}getBindedInter(){return this.bindedInter}bind(e){this.bindedInter=e,e.bindedInter=this}setIndex(e){this.index=e}isSorted(){return this.index!==void 0}getIndex(){return this.index}getVisited(){return this.visited}visitSelf(){this.visited=!0}visit(){this.visited=!0,this.bindedInter.visited=!0}getPrevPoint(){let e=this.getIndex(),t=this.side.getStart();return e&&(t=this.side.inters[e-1].coord),t}getTangent(){let e=this.side.getShape();if(e instanceof me)return e.end().sub(e.start());if(e instanceof Pe){let t=this.coord.angle(e.center);return e.isCCW?t+=Fx:t-=Fx,new we(Math.cos(t),Math.sin(t))}else{if(e instanceof ct)return e0(e,e.getPercent(this.coord,Ut));throw new Error("not support")}}findStartInter(){return this.outToIn===void 0?this.getTangent().cross(this.bindedInter.getTangent())>0?this:this.bindedInter:this.outToIn?this:this.bindedInter}run(){let e=[],t=this,i;if(this.drawDebug){oT++;let r=oT===-1,n=this.drawDebug.initColor(zi.RED);if(r){this.drawDebug.draw();debugger}i=s=>{if(e.push(s),r){n.addPt(e[e.length-1]),this.drawDebug.draw();debugger}}}else i=r=>e.push(r);for(;!t.visited;){let r=function(o,l){if(Oe.eq(o.distance2(l),0))return;let c=m0.rebuild(s.getShape(),o,l);if(!c)return!0;i(c)};t.visit();let n=t.getIndex(),s=t.side,a=s.inters[n+1];for(;a!=null&&a.isInvalid;)a=s.inters[a.getIndex()+1];if(a)r(t.coord,a.coord),t=a.bindedInter;else{let o=r(t.coord,s.getEnd()),l=t.coord;for(s=s.nextSide,t=null;;){for(let c of s.inters)if(!c.isInvalid){t=c.bindedInter;break}if(t)break;o?(r(l,s.getEnd()),o=!1):i(s.getShape()),s=s.nextSide}o?(Oe.eq(l.distance2(t.coord),0)?r(l,s.getEnd()):r(l,t.coord),o=!1):Oe.eq(s.getEnd().distance2(t.coord),0)?i(s.getShape()):r(s.getStart(),t.coord)}}if(t!==this)throw this.drawDebug&&console.log(JSON.stringify({runId:oT,handleId:zx,boolId:Hy})),new Error("inter !== this");return ad(wi.build7(e))}},oT=0,lT=class BT{constructor(t,i,r,n,s){this.inters=[],this.allInterIsInvalid=!0,this.isVisit=!1,this.sides=t,this.isGroup1=r,this.isOutside=n,this.finalIsOutside=n,this.polyline=i,s&&(this.polygon=s),t.forEach(a=>a.outline=this)}static build(t,i,r,n,s){let a=t.primitives.map(l=>new m0(l,n)),o=a[a.length-1];return a.forEach(l=>{o.connect(l),o=l}),s?new BT(a,t,i,r,s):new BT(a,t,i,r)}setFinalIsOutSide(t){this.finalIsOutside=t}startAndEndIsSameOutsideFlag(){return this.isOutside===this.finalIsOutside}get hasInter(){return!!this.interOutlines}isAllInterIsInvalid(){return this.allInterIsInvalid}setAllInterIsInvalidToFalse(){this.allInterIsInvalid=!1}resetVisited(){this.isVisit=!1}intersect(t,i){if(!(t.interOutlines&&t.interOutlines===this.interOutlines))if(t.interOutlines)if(this.interOutlines){let r,n;this.interOutlines.length>t.interOutlines.length?(r=this.interOutlines,n=t.interOutlines):(r=t.interOutlines,n=this.interOutlines),n.forEach(s=>{r.push(s),s.interOutlines=r}),i.delete(n)}else t.interOutlines.push(this),this.interOutlines=t.interOutlines;else this.interOutlines?(this.interOutlines.push(t),t.interOutlines=this.interOutlines):(t.interOutlines=this.interOutlines=[this,t],i.add(this.interOutlines))}isContain(t){if(!this.polyline.bbox().extendOfSize(Ut).isContainsBBox(t.polyline.bbox()))return!1;let i=t.polyline.primitives[0].start();if(t.hasInter&&t.isAllInterIsInvalid()){let r=t.inters[0];r.getBindedInter().side.outline!==this?i=r.side.getCenterPoint():i=r.side.getCenterPoint(r.coord)}return!!this.polyline.getWindingNum(i)}isInternally(t){return!!this.polyline.getWindingNum(t)}isEqual(t){return this.polyline===t.polyline}bbox(){return this.polyline.bbox()}reverse(){this.sides.reverse();let t=this.sides[this.sides.length-1];this.sides.forEach(i=>{i.reverse(),t.connect(i),t=i})}returnPolyline(){let t=this.sides.map(r=>r.getShape()),i=this.polyline.primitives;if(this.sides.length===i.length){let r=new Set(i);if(!t.some(n=>!r.has(n)))return this.polyline}return wi.build7(t)}};function CL(e,t,i){let r=[];return e.forEach(n=>n.forEach(s=>{if(s.hasInter&&!s.isAllInterIsInvalid())return;let a=s.bbox(),o=t.search(a.extendOfSize(Ut)).filter(l=>l.bbox().extendOfSize(Ut).isContainsBBox(a)).sort((l,c)=>l.bbox().area()-c.bbox().area());for(let l of o)if(l.isContain(s)){let c=i(!s.isOutside,l.isOutside),u=i(s.isOutside,l.isOutside);c!==u&&(r.push(s),s.setFinalIsOutSide(!c));return}i(s.isOutside,!1)!==i(!s.isOutside,!1)&&r.push(s)})),r}function zY(e,t,i){let r;switch(i){case 0:r=(o,l)=>o&&l;break;case 1:r=(o,l)=>o||l;break;case 2:r=(o,l)=>o&&!l;break;case 3:r=(o,l)=>o&&!l||!o&&l;break;default:throw Error("not support the rule")}let n=new t0(10),s=new t0(10);e.forEach(o=>o.forEach(l=>n.add(l))),t.forEach(o=>o.forEach(l=>s.add(l)));let a=CL(e,s,r);return CL(t,n,(o,l)=>r(l,o)).forEach(o=>a.push(o)),a}var XY=class{constructor(e){this.roots=[],this.nodes=e.sort((t,i)=>t.bbox().minX-i.bbox().minX).map(t=>new WY(t)),this.nodes.forEach((t,i)=>{t.visit()&&(this.roots.push(t),this.build(i))})}build(e){let t=this.nodes[e];for(let i=e+1,r=this.nodes.length;i<r;i++){let n=this.nodes[i];if(t.key.bbox().maxX<n.key.bbox().minX)break;n.getIsVisit()||t.isContain(n)&&(n.visit(),t.addChild(n),this.build(i))}}getPolygons(){let e=[];return this.roots.forEach(t=>t.getPolygons().forEach(i=>e.push(i))),e}},WY=class{constructor(e){this.children=[],this.isVisit=!1,this.key=e}getIsVisit(){return this.isVisit}isContain(e){return this.key.isContain(e.key)}addChild(e){this.children.push(e)}getPolygons(){let e=[];return this.getPolylineList(e),e.map(t=>{let i=t[0].polygon;if(i&&i.items.length===t.length){let r=t.map(s=>s.returnPolyline()),n=new Set(i.items);return r.some(s=>!n.has(s))?new as(r):i}else return new as(t.map(r=>r.returnPolyline()))})}getPolylineList(e,t){t?(t.push(this.key),t=null):(t=[this.key],e.push(t)),this.children.forEach(i=>i.getPolylineList(e,t))}visit(){return this.isVisit?!1:(this.isVisit=!0,!0)}};function DL(e){let t="";return e.items.forEach((i,r)=>{let n="$";if(i.items.forEach((s,a)=>{let o="[";if(s.primitives.forEach((l,c)=>{let u="";if(l instanceof me)u=`Line,${l.start().x},${l.start().y},${l.end().x},${l.end().y}`;else if(l instanceof Pe)u=`Arc,${l.center.x},${l.center.y},${l.startAngle},${l.sweepAngle},${l.rx}`;else if(l instanceof ct)u=`Bezier,${l.controls.map(h=>`${h.x},${h.y}`).join(",")}`;else throw new Error("not supported");if(c===s.primitives.length-1){o+=`${u}]`;return}o+=`${u},`}),a===i.items.length-1){n+=`${o}$`;return}n+=`${o}_`}),r===e.items.length-1){t+=`${n}`;return}t+=`${n}^`}),console.log(t),t}function _L(e){let t=e.split("^"),i=[];return t.forEach(n=>{let s=/\$(.*?)\$/,a=n.match(s)[1].split("_"),o=[];a.forEach(c=>{let u=/\[(.*?)\]/,h=c.match(u)[1].split(","),d=[],p=[];for(let m=0;m<h.length;m++){let g=h[m];if(g==="Line"||g==="Arc"||g==="Bezier"){if(d.length){let b=r(d);p.push(b),d.length=0}d.push(g);continue}d.push(Number(g))}d.length&&(p.push(r(d)),d.length=0);let f=wi.build7(p);o.push(f)});let l=new as(o);i.push(l)}),new Pn(i);function r(n){let s=n[0];if(s==="Line")return new me(new we(n[1],n[2]),new we(n[3],n[4]));if(s==="Arc")return Pe.build3(new we(n[1],n[2]),n[3],n[4],n[5],n[5]);if(s==="Bezier"){let a=[];for(let o=1;o<n.length;o+=2)a.push(new we(n[o],n[o+1]));return new ct(a)}else throw new Error("not support")}}var qY=class{constructor(e=1){this.group1Str="$[Line,20193.777980000017,4122.200439600661,20193.77082,4211.848760073709,Arc,20193.972672902382,4211.8487570980205,179.99915535323618,-89.99540000050294,0.2018529024026465,Line,20193.972659672283,4212.050609999989,20193.972660393258,4212.039610000013,Arc,20193.97217289501,4211.848257065248,89.85403133887164,89.99540000041924,0.19135355574930143,Line,20193.78082,4211.848759926291,20193.78897999998,4122.200440479205,Line,20193.78897999998,4122.200440479205,20193.777980000017,4122.200439600661]$",this.group2Str="$[Arc,20209.72784128151,4122.2007625157785,258.46768032837986,-75.66780748375947,4.138846238512183,Line,20205.593935808283,4121.998590004101,20193.97982992629,4121.998600000001,Arc,20193.97983290198,4122.2004529023825,269.9991553532362,-89.99540000050297,0.20185290240401074,Arc,20193.782979999996,4122.20044,180.00375535340328,-180.0000000000027,0.004999999999025513,Arc,20193.979332869207,4122.200952909754,180.15347936671733,89.99540000008247,0.19135355575111057,Line,20193.97983008845,4122.009599999999,20205.603694309226,4122.003828485546,Arc,20209.733142304296,4122.194577876843,182.64475341258483,75.73379999998886,4.133851239977064,Line,20208.900400396684,4118.145470939558,20208.902599535475,4118.156248870184,Arc,20206.972515961093,4108.700057667588,78.46393309088245,-78.46759999998636,9.65115405866796,Arc,20216.618669999996,4108.69944,359.99996825446135,-180,0.004999999999200412,Arc,20206.973015966745,4108.699445349495,359.99996822365375,78.46759999998409,9.640654033253735]$^$[Line,20193.997796883676,4095.399470032799,20205.596133314026,4095.4013992171836,Arc,20209.72470159858,4095.1923799234505,177.10172964919312,-75.64935037184974,4.133855965730166,Arc,20209.73000213952,4095.198565517174,101.5415133143569,75.7293000000185,4.128850963459707,Line,20205.605834328744,4095.395161923586,20193.997203529463,4095.389485743675,Arc,20193.994588809255,4095.197684525904,89.21896662213764,4.544099999999517,0.19181903946188483,Arc,20193.981499796217,4095.1977402038,89.85034659953621,89.9999999995926,0.19135044893494071,Arc,20193.78515,4095.19824,0,-180,0.005,Arc,20193.98200016982,4095.1982398301675,179.99995179248322,-89.99999999974185,0.20185016982129908,Arc,20193.981986624152,4095.198185381971,89.9961078637802,-4.487285276547311,0.2019046184835962]$",this.rule=e}getGroup1(){return _L(this.group1Str)}getGroup2(){return _L(this.group2Str)}},cT=new nE(2),Vy=class{getUnion(e,t=!0){return t&&(e=e.map(i=>this.asSameSweep([i])[0])),LY(dY,e)}asSameSweep(e){let t=0;return e.forEach(i=>t+=i.area(.01)),t>0?e.map(i=>i.reverse()):e}getSubtraction(e,t){let i=new Ky(!1),r=new $y(Ix.rule,cT,i);for(let n of e){let s=Ix.weight(0);r.addPolyline(n,s)}for(let n of t){let s=Ix.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getIntersection(e,t){let i=new Ky(!1),r=new $y(Ax.rule,cT,i);for(let n of e){let s=Ax.weight(0);r.addPolyline(n,s)}for(let n of t){let s=Ax.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getMutuallyExclusive(e,t){let i=new Ky(!1),r=new $y(iT.rule,cT,i);for(let n of e){let s=iT.weight(0);r.addPolyline(n,s)}for(let n of t){let s=iT.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}},Hy=0,uT=!1;function jy(e,t,i,r,n){let s=g0(),a=[],o=[],l=[],c=new Set,u;if(n){if(u=new f0(n),Hy++,uT){debugger;uT=!1;let S=new qY;jy(S.rule,S.getGroup1(),S.getGroup2(),r,n)}if(Hy===-1||uT){console.table({rule:e,group1:DL(t),group2:DL(i)}),u.clear();let S=u.initColor(zi.GREEN),w=u.initColor(zi.WHITE),x=u.initColor(zi.BLUE),I=u.initColor(zi.Gray);t.items.forEach(A=>A.items.forEach((O,R)=>{R>0?w.addPly(O):S.addPly(O)})),i.items.forEach(A=>A.items.forEach((O,R)=>{R>0?I.addPly(O):x.addPly(O)})),u.draw();debugger}}let h=t.items.length!==0&&i.items.length!==0?t.bbox().extendOfSize(Ut).intersection1(i.bbox().extendOfSize(Ut)):null;if(h){let S=[],w=[];switch(e){case 0:{for(let x of t.items)x.bbox().isIntersect(h)&&S.push(x);for(let x of i.items)x.bbox().isIntersect(h)&&w.push(x);break}case 1:case 3:{for(let x of t.items)x.bbox().isIntersect(h)?S.push(x):a.push(x);for(let x of i.items)x.bbox().isIntersect(h)?w.push(x):a.push(x);break}case 2:{for(let x of t.items)x.bbox().isIntersect(h)?S.push(x):a.push(x);for(let x of i.items)x.bbox().isIntersect(h)&&w.push(x);break}default:throw new Error("not support")}S.length!==t.items.length&&(t=new Pn(S)),w.length!==i.items.length&&(i=new Pn(w))}else{switch(e){case 0:break;case 1:case 3:{t.items.forEach(S=>a.push(S)),i.items.forEach(S=>a.push(S));break}case 2:{t.items.forEach(S=>a.push(S));break}default:throw new Error("not support")}t=new Pn([]),i=new Pn([])}y(t,o,!0),y(i,l,!1);let d=e===2||e===3?(S,w)=>At(S.getEnd(),w)?S.nextSide:S:(S,w)=>At(S.prevSide.getEnd(),w)?S.prevSide:S,p=(S,w,x)=>{if(At(S.getEnd(),x)){if(S.inters.findIndex(I=>I.getBindedInter().side===w&&At(I.coord,S.getEnd()))===-1)return new nh(x,S,u)}else return new nh(x,S,u)},f=e===2||e===3?(S,w,x)=>{if(At(S.getStart(),x)){if(S.inters.findIndex(I=>I.getBindedInter().side===w&&At(I.coord,S.getStart()))===-1)return new nh(x,S,u)}else return new nh(x,S,u)}:p;r.seek(t,i,(S,w,x,I,A,O)=>{let R=o[S][w],M=l[I][A],F=R.sides[x],G=M.sides[O],V=Pl(F.getShape(),G.getShape());if((F.getShape()instanceof ct||G.getShape()instanceof ct)&&V>=4){if(F.getShape()instanceof Pe||G.getShape()instanceof Pe){let C=function(T,L){let P=!1;for(let B=0;B<L.length;B+=2)At(new we(L[B],L[B+1]),T)&&(P=!0);P||L.push(T.x,T.y)},N=[ae[0],ae[1]];for(let T=0;T<V;T+=2){let L=new we(ae[T],ae[T+1]);for(let P=T+2;P<V;P+=2){let B=new we(ae[P],ae[P+1]);if(!At(L,B)){C(B,N);break}}}V=N.length,N.forEach((T,L)=>ae[L]=T)}else for(let C=V-2;C>=2;C-=2)for(let N=C-2;N>=0;N-=2)if(At(new we(ae[C],ae[C+1]),new we(ae[N],ae[N+1]))){ae[N]=(ae[C]+ae[N])/2,ae[N+1]=(ae[C+1]+ae[N+1])/2;for(let T=V-3;T>=C;T--)ae[T]=ae[T+2];V-=2;break}}let q=0;if(V===4){let C=function(L){return At(F.getEnd(),L)||At(F.prevSide.getEnd(),L)||At(G.prevSide.getEnd(),L)||At(G.getEnd(),L)},N=new we(ae[0],ae[1]),T=()=>{let L=new nh(N,F,u),P=new nh(N,G,u);L.bind(P),L.setIsInvalid(),L.isDealed(),R.inters.push(L),M.inters.push(P)};if(ae[0]===ae[2]&&ae[1]===ae[3])if(C(N))q=2;else{T();return}}for(;q<V;q+=2){let C=new we(ae[q],ae[q+1]),N=F,T=G;if(At(N.prevSide.getEnd(),C)&&(N=N.prevSide),T=d(T,C),F!==N&&G!==T){let P=e===2||e===3?G.getEnd():T.getEnd();N.getEnd().distance1(C)<P.distance1(C)?(C=N.getEnd(),At(P,C)||(T=G)):(C=P,At(N.getEnd(),C)||(N=F))}let L=p(N,T,C);if(L){let P=f(T,N,C);P&&(N.addInter(L),R.inters.push(L),T.addInter(P),M.inters.push(P),L.bind(P),R.intersect(M,c))}}return V},n);let m=E(),g=zY(o,l,e);g.forEach(S=>!S.startAndEndIsSameOutsideFlag()&&S.reverse()),new XY(m.concat(g)).getPolygons().forEach(S=>a.push(S));let b=new Pn(a);if(u){if(Hy===-1){let S=u.initColor(zi.RED),w=u.initColor(zi.Golden);a.forEach(x=>{S.addPly(x.items[0]),x.items.slice(1).forEach(I=>w.addPly(I))}),u.draw();debugger;throw new Error}b.id=Hy}return cu.BooleanTools+=id(s),b;function y(S,w,x){S.items.forEach(I=>{let A=[];A.push(lT.build(I.items[0],x,!0,u,I)),I.items.slice(1).forEach(O=>{A.push(lT.build(O,x,!1,u))}),w.push(A)})}function E(){let S=[];return c.forEach(x=>{e===2||e===3?x.forEach(A=>{A.isGroup1||A.reverse(),A.sides.forEach(O=>O.sortInters())}):x.forEach(A=>A.sides.forEach(O=>O.sortInters())),x.map(A=>A.sides.filter(O=>O.inters.length)).flat(2).sort((A,O)=>{let R=A.inters,M=O.inters,F=At(R[R.length-1].coord,A.getEnd()),G=At(M[M.length-1].coord,O.getEnd());if(F&&G){let V=0,q=0;for(let C=R.length-2;C>=0&&At(R[C].coord,A.getEnd());C--)V++;for(let C=M.length-2;C>=0&&At(M[C].coord,O.getEnd());C--)q++;return q-V}else return F?-1:1}).forEach(A=>{A.inters.forEach(O=>{if(O.dealed)return;let R=O.side,M=O.getBindedInter().side,F;At(R.getEnd(),O.coord)&&At(M.getEnd(),O.coord)?F=-1:At(R.getEnd(),O.coord)?(F=1,O=O.getBindedInter()):At(M.getEnd(),O.coord)&&(F=1);let G=jY(F,O,e,u);O.isDealed(),G&&(R.outline.setAllInterIsInvalidToFalse(),M.outline.setAllInterIsInvalidToFalse())})}),I(x),e===3&&(x.forEach(A=>{A.reverse(),A.sides.forEach(O=>{O.sortInters(),O.inters.forEach(R=>{R.resetVisitStatus()})})}),I(x));function I(A){A.forEach(O=>{O.inters.forEach(R=>{if(R.isInvalid||R.getVisited())return;let M=R.findStartInter(),F=w(e)?M.run():M.getBindedInter().run(),G=O.polyline.primitives;if(F){if(G.length===F.primitives.length){let V=new Set(G);if(!F.primitives.some(q=>!V.has(q))){S.push(O);return}}S.push(lT.build(F,!0,!0,u))}})})}}),S;function w(x){switch(x){case 0:case 2:case 3:return!0;case 1:return!1;default:throw Error("not support the rule")}}}}var fx=/\bstablilizetion\b/.test(self.location.href)||!0,mx={intersect(e,t,i,r){try{return jy(0,e,t,i,r)}catch(n){if(fx){let s=new Vy().getIntersection(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new Pn(s.map(a=>new as(a.items)))}throw n}},union(e,t,i,r){try{return jy(1,e,t,i,r)}catch(n){if(fx){let s=new Vy,a=e.items.map(l=>l.items.map(c=>c)).flat(2);t.items.forEach(l=>l.items.forEach(c=>a.push(c)));let o=s.getUnion(a);return new Pn(o.map(l=>new as(l.items)))}throw n}},diff(e,t,i,r){try{return jy(2,e,t,i,r)}catch(n){if(fx){let s=new Vy().getSubtraction(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new Pn(s.map(a=>new as(a.items)))}throw n}},xor(e,t,i,r){try{return jy(3,e,t,i,r)}catch(n){if(fx){let s=new Vy().getMutuallyExclusive(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new Pn(s.map(a=>new as(a.items)))}throw n}}},JY=class extends $y{constructor(e,t,i,r,n,s){super(e.rule,nE.DUMMY,t),this.sideGroup1=[],this.sideGroup2=[],this.group1=i,this.group2=r,this.seeker=n,this.addGroup(i,e.weight(0),this.sideGroup1),this.addGroup(r,e.weight(1),this.sideGroup2),this.bus=s}addGroup(e,t,i){if(!e)debugger;e.items.forEach(r=>{let n=[];r.items.forEach(s=>{let a=this.sides.length;this.addPolyline(s,t),n.push(this.sides.slice(a))}),i.push(n)})}seekIntersection(){this.seeker.seek(this.group1,this.group2,(e,t,i,r,n,s)=>{let a=this.sideGroup1[e][t][i],o=this.sideGroup2[r][n][s],l=Pl(a.shape,o.shape);for(let c=0;c<l;c+=2){let u=new we(ae[c],ae[c+1]);a.inters.push(u),o.inters.push(u),this.event.onIntersect(u,a,o)}return l},this.bus)}},KY=class extends Ky{constructor(e){super(!!e),e&&(this.drawDebug=new f0(e),this.blueDrawing=this.drawDebug.initColor(zi.BLUE),this.greenDrawing=this.drawDebug.initColor(zi.GREEN),this.redDrawing=this.drawDebug.initColor(zi.RED))}onOriginSide(e){super.onOriginSide(e),this.debug&&this.blueDrawing.addPt(e.shape)}onPolylineGroup(e,t){super.onPolylineGroup(e,t),this.debug&&e.items.forEach(i=>this.greenDrawing.addPly(i))}draw(){this.drawDebug.draw()}};function hT(e,t,i,r,n){let s=g0(),a=new KY(n);new JY(e,a,t,i,r,n).simplify();let o=[];a.plGrps.forEach(c=>{let u=c.items.map(h=>jx(h));u[0]&&o.push(new as(u.filter(h=>h)))});let l=new Pn(o);return cu.BooleanTools+=id(s),l}var dT=!0,By={intersect(e,t,i,r){try{return mx.intersect(e,t,i,r)}catch(n){if(dT)throw n;return console.error(n),hT(Ax,e,t,i,r)}},union(e,t,i,r){try{return mx.union(e,t,i,r)}catch(n){if(dT)throw n;return console.error(n),hT(pY,e,t,i,r)}},diff(e,t,i,r){try{return mx.diff(e,t,i,r)}catch(n){if(dT)throw n;return console.error(n),hT(Ix,e,t,i,r)}},xor(e,t,i,r){return mx.xor(e,t,i,r)}},$Y=class{init(e){}seek(e,t,i,r){let n=e.bbox().extendOfSize(5e-6).intersection1(t.bbox().extendOfSize(5e-6));if(!n)return;let s=g0(),a=[];for(let d=0,p=e.items.length;d<p;d++){let f=e.items[d];if(n.isIntersect(f.bbox()))for(let m=0,g=f.items.length;m<g;m++){let b=f.items[m];if(n.isIntersect(b.bbox()))for(let y=0,E=b.primitives.length;y<E;y++){let S=b.primitives[y].bbox();n.isIntersect(S)&&a.push({bbox:S,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let o=a.length;if(o===0){cu.IntersectionSeeker+=id(s);return}let l=[];for(let d=0,p=t.items.length;d<p;d++){let f=t.items[d];if(n.isIntersect(f.bbox()))for(let m=0,g=f.items.length;m<g;m++){let b=f.items[m];if(n.isIntersect(b.bbox()))for(let y=0,E=b.primitives.length;y<E;y++){let S=b.primitives[y].bbox();n.isIntersect(S)&&l.push({bbox:S,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let c=l.length;if(c===0){cu.IntersectionSeeker+=id(s);return}if(o<5||c<5){for(let d=0,p=a.length;d<p;d++)for(let f=0,m=l.length;f<m;f++)if(a[d].bbox.isIntersect(l[f].bbox.extendOfSize(1e-5))){let g=a[d],b=l[f];i(g.polygonIndex,g.polylineIndex,g.ptIndex,b.polygonIndex,b.polylineIndex,b.ptIndex)}cu.IntersectionSeeker+=id(s);return}a.sort((d,p)=>d.bbox.minX-p.bbox.minX),l.sort((d,p)=>d.bbox.minX-p.bbox.minX);let u=0,h=0;for(;u<o&&h<c;)if(a[u].bbox.minX<l[h].bbox.minX){let d=a[u],p=d.bbox;for(let f=h;f<c;f++){let m=l[f],g=m.bbox;if(g.minX>p.maxX+1e-5)break;(p.minY<g.minY?g.minY:p.minY)<(p.maxY<g.maxY?p.maxY:g.maxY)+1e-5&&i(d.polygonIndex,d.polylineIndex,d.ptIndex,m.polygonIndex,m.polylineIndex,m.ptIndex)}u++}else{let d=l[h],p=d.bbox;for(let f=u;f<o;f++){let m=a[f],g=m.bbox;if(g.minX>p.maxX+1e-5)break;(g.minY<p.minY?p.minY:g.minY)<(g.maxY<p.maxY?g.maxY:p.maxY)+1e-5&&i(m.polygonIndex,m.polylineIndex,m.ptIndex,d.polygonIndex,d.polylineIndex,d.ptIndex)}h++}cu.IntersectionSeeker+=id(s)}},ka,Ks=(ka=class{static getDebug(){return ka.drawDebug||(ka.drawDebug=new f0(ka.curBus)),ka.drawDebug}static getDrawing(e=zi.GREEN){return this.getDebug().initColor(e)}static clearDrawing(){ka.getDebug().clear()}static drawText(e,t,i=zi.GREEN){ka.getDrawing(i).addText(e,t,1.5,.1,!0)}static drawBBox(e,t=zi.GREEN){if(!e)return;let i=ka.getDrawing(t),r=new me(e.UL(),e.UR()),n=new me(e.UR(),e.LR()),s=new me(e.LR(),e.LL()),a=new me(e.LL(),e.UL());i.addPt(r),i.addPt(n),i.addPt(s),i.addPt(a)}static drawPolyType(e,t){let i=ka.getDrawing(t);if(e instanceof wi)i.addPly(e);else if(e instanceof as)for(let r of e.items)r instanceof wi?i.addPly(r):this.drawPolyType(r,t);else if(e instanceof Pn)for(let r of e.items)this.drawPolyType(r,t)}static translate(e){switch(e){case 0:return"\u2229";case 2:return"-";case 1:return"U";case 3:return"X";default:break}}},ka.UseRunArrange=!0,ka.UseOptimizeSplit=!0,ka.LocalBestThread=4,ka.HandleDiff=!0,ka.OcTreeSplitStep=4,ka.PrintStart=new we(150,-200),ka),ky=class kT{static getPolyTypeLine(t){let i=[];if(t instanceof wi)for(let r of t.primitives)i.push(r);else if(t instanceof as)for(let r of t.items)if(r instanceof wi)for(let n of r.primitives)i.push(n);else{let n=this.getPolyTypeLine(r);for(let s of n)i.push(s)}else if(t instanceof Pn)for(let r of t.items){let n=this.getPolyTypeLine(r);for(let s of n)i.push(s)}return i}static getPolyTypePolyLine(t){let i=[];if(t instanceof wi)i.push(t);else if(t instanceof as)for(let r of t.items)if(r instanceof wi)i.push(r);else{let n=this.getPolyTypePolyLine(r);for(let s of n)i.push(s)}else if(t instanceof Pn)for(let r of t.items){let n=this.getPolyTypePolyLine(r);for(let s of n)i.push(s)}return i}static getListBBox(t){if(t.length<=0)return;let i=new to;for(let r of t){let n=kT.getSingleBBox(r);i.ext1(n)}return i.build1()}static getSingleBBox(t){if(t instanceof Array){let i=new to,r=kT.getListBBox(t.slice(1));return i.ext1(r),i.build1()}else return t.bbox()}static doDrawRule(t,i=Ks.PrintStart){if(t.length<2)return[i,i,i];let r=5,n=10,s=t[0],a=Ks.translate(s),o=[],l=i.y,c=i.x,u=i.x;i=i.add(new we(0,-n));for(let p=1;p<t.length;p++){let f=t[p];if(f instanceof Array){i=i.add(new we(r,0));let m=this.doDrawRule(f,i);o.push(m[0]),m[1].x<=c&&(c=m[1].x),m[2].x>=u&&(u=m[2].x),i=new we(m[2].x+r,i.y)}else o.push(i.clone()),i.x<=c&&(c=i.x),i.x>=u&&(u=i.x),Ks.drawText(i,f.name),i=i.add(new we(r,0))}let h=0;for(let p of o)h+=p.x;let d=new we(h/o.length,i.y+n);Ks.drawText(d,"N:"+a);for(let p of o){let f=new me(p,d),m=new Array;m.push(f);let g=wi.build1(DT(m));Ks.drawPolyType(g,zi.GREEN)}return[d,new we(c,l),new we(u,l)]}static drawRule(t,i=Ks.PrintStart,r=!1,n){Ks.clearDrawing(),this.doDrawRule(t,i),r&&this.doDrawRulePolygon(t,n),Ks.getDebug().draw()}static doDrawRulePolygon(t,i){let r=t[0];for(let n=1;n<t.length;n++){let s=t[n];if(s instanceof Array)this.doDrawRulePolygon(s,i);else{let a=i;r===2&&n===1&&(a=zi.RED),s.name&&Ks.drawText(s.bbox().UL(),s.name,a),Ks.drawPolyType(s,a)}}}static IsCenterBBoxPointInPolygonType(t,i){let r=t.center();for(let n of i.items)if(n.getOutMostPolyline().getWindingNum(r))return!0;return!1}static KeepBBoxPolygonGroup(t,i){let r=i.bbox().intersection1(t);if(!r)return!1;for(let n of i.items)if(n.bbox().isIntersect(r)){for(let s of n.items)if(s.bbox().isIntersect(r)){for(let a of s.primitives)if(r.isIntersect(a.bbox()))return!0}}return!!this.IsCenterBBoxPointInPolygonType(t,i)}},ZY=class nm{static createNode(t,i,r){let n=t.UL(),s=t.width()/i,a=t.height()/i,o=~~(r/i),l=r-o*i,c=n.x+l*s,u=n.y-(o+1)*a,h=c+s,d=u+a;return new ba(c,h,u,d)}static ocTreeSplitNode(t,i,r,n,s=2){if(t.length<=r)return t;let a=[],o=s**2,l=new Array(o),c=new Array(o);for(let p=0;p<o;p++)l[p]=new Array(t.length),c[p]=0;let u=i.UL(),h=i.width()/s,d=i.height()/s;for(let p of t){let f=n(p).center(),m=~~((f.x-u.x)/h),g=~~((u.y-f.y)/d)*s+m;try{l[g][c[g]]=p,c[g]+=1}catch{a.push(p)}}for(let p=0;p<l.length;p++){let f=c[p];if(f<=0)continue;let m=l[p].slice(0,f);if(m.length===t.length)return t;let g=nm.createNode(i,s,p),b=nm.ocTreeSplitNode(m,g,r,n,s);if(b.length===t.length)return t;a.push(b)}return a}static ocTreeSplitNodeMinIntersect(t,i,r,n){let s=[];if(t.length<=r)return t;let a=3,o=i.LL(),l=i.UR(),c=i.width()/(a+1),u=i.height()/(a+1),h=-(2**32),d=[],p=[];for(let f=1;f<=a;f++)for(let m=1;m<=a;m++){let g=o.x+c*f,b=o.y+u*m,y=[[],[],[],[]],E=new Array(4),S=new Array(4);S[0]=new ba(o.x,g,b,l.y),S[1]=new ba(g,l.x,b,l.y),S[2]=new ba(o.x,g,o.y,b),S[3]=new ba(g,l.x,o.y,b);for(let A of t){let O=n(A).center(),R=-1,M=-1;O.x===g?R=Math.random()>=.5?1:-1:O.x>g?R=1:O.x<g&&(R=-1),O.y===b?M=Math.random()>=.5?1:-1:O.y>b?M=1:O.y<b&&(M=-1),R===1&&M===1?y[1].push(A):R===1&&M===-1?y[3].push(A):R===-1&&M===-1?y[2].push(A):R===-1&&M===1&&y[0].push(A)}for(let A=0;A<4;A++){let O=y[A];if(O.length<=0)continue;let R=new to;for(let M of O)R.ext1(n(M));E[A]=R.build1()}let w=0,x=0;for(let A of E)A&&(w+=A.area());x=w;let I=(A,O)=>{if(!E[A]||!E[O])return 0;let R=E[A].intersection1(E[O]);return R?R.area():0};x-=I(0,1),x-=I(0,2),x-=I(0,3),x-=I(1,2),x-=I(1,3),x-=I(2,3),x/w>=h&&(d=y,p=S)}for(let f=0;f<d.length;f++){let m=d[f];if(m.length<=0)continue;let g=p[f],b;if(m.length===t.length?b=nm.ocTreeSplitNode(m,g,r,n):b=nm.ocTreeSplitNodeMinIntersect(m,g,r,n),b.length===t.length)return t;s.push(b)}return s}static ocTreeSplit(t,i,r,n){return nm.ocTreeSplitNode(t,i,r,n,Ks.OcTreeSplitStep)}},QY=class OO{static simplifyRules(t,i){return Ks.UseOptimizeSplit&&(t=this.optimizeSplit(t,i)),t}static OcTreeOptimizeSplit(t){let i=t[0];if(i!==1||t.length<=Ks.LocalBestThread+1)return t;let r=t.slice(1),n=new Array(r.length);for(let c=1;c<t.length;c++)n[c-1]=c;let s=ky.getListBBox(r),a=ZY.ocTreeSplit(n,s,Ks.LocalBestThread,c=>{let u=t[c];return ky.getSingleBBox(u)}),o=(c,u)=>{if(!(c.length<=0))for(let h of c)if(Array.isArray(h)){let d=[u[0]];o(h,d),u.push(d)}else{let d=t[h];u.push(d)}},l=[i];return o(a,l),l}static optimizeSplit(t,i){let r=t[0];if(r===2){if(Ks.HandleDiff){let s=t[1],a;if(Array.isArray(s)){let o=this.optimizeSplit(s,i);if(o.length<=1)return[2];a=FT(o,i)}else a=FT([2,s],i);if(t.length>3){let o;o=[1];for(let l=2;l<t.length;l++){let c=t[l];if(Array.isArray(c)){let u=ky.getListBBox([...c.slice(1)]);ky.KeepBBoxPolygonGroup(u,a)&&o.push(c)}else ky.KeepBBoxPolygonGroup(c.bbox(),a)&&o.push(c)}return o.length<=1?[2,a]:(o=this.optimizeSplit(o,i),o.length>1?[2,a,...o.slice(1)]:[2,a])}else{let o=t[2];if(Array.isArray(o)&&o[0]===1&&o.length>2){let l=o.slice(1);return this.optimizeSplit([2,a,...l],i)}}}else if(t.slice(1).length>2){let s=t[1],a=t.slice(2),o=this.optimizeSplit([1,...a],i);return o.length>1?[2,s,...o.slice(1)]:s}}else if(r===1){if(t.length-1>Ks.LocalBestThread){let s=!1;for(let a=1;a<t.length;a++){let o=t[a];if(!Array.isArray(o)){s=!0;break}}s&&(t=OO.OcTreeOptimizeSplit(t))}}else if(r===0&&t.length<=2)return[0];let n=[r];for(let s=1;s<t.length;s++){let a=t[s];if(Array.isArray(a)){let o=this.optimizeSplit(a,i);if(o.length<=1)continue;n.push(o)}else n.push(a)}return n}},eV=(e=>(e[e.INTERSECT=0]="INTERSECT",e[e.UNION=1]="UNION",e[e.DIFF=2]="DIFF",e[e.XOR=3]="XOR",e))(eV||{});function zy(e){let t=e[0],i=[t];switch(t){case 0:for(let n=1;n<e.length;n++){let s=e[n];if(Array.isArray(s)&&(s=zy(s),!s))return null;i.push(s)}break;case 1:case 3:for(let n=1;n<e.length;n++){let s=e[n];Array.isArray(s)&&(s=zy(s),!s)||i.push(s)}break;case 2:let r=e[1];if(Array.isArray(r)&&(r=zy(r)),!r)return null;i.push(r);for(let n=2;n<e.length;n++){let s=e[n];Array.isArray(s)&&(s=zy(s),!s)||i.push(s)}break;default:throw new Error("not support boolean rule!")}return i.length===1?null:i}function pT(e,t,i){return Array.isArray(e)?RO(e,t,i):e}function fT(e,t,i,r,n=!0){if(n)for(;e.length>1;){let s,a=[];for(e.length%2===1?(a.push(e[0]),s=1):s=0;s<e.length;s+=2)a.push(t(e[s],e[s+1],i,r));e=a}else for(;e.length>1;){if(e.length===2)return t(e[0],e[1],i,r);e=[t(e[0],e[1],i,r),...e.slice(2)]}return e[0]}function RO(e,t,i,r=!0){let n=new Array(e.length-1);for(let s=1;s<e.length;s++)n[s-1]=pT(e[s],t,i);switch(e[0]){case 0:return fT(n,By.intersect,t,i);case 1:return fT(n,By.union,t,i);case 2:let s=fT(n.slice(1),By.union,t,i);return s?By.diff(n[0],s,t,i):n[0];case 3:let a=pT(e[1],t,i);for(let o=2;o<e.length;o++)a=By.xor(a,pT(e[o],t,i),t,i);return a;default:throw new Error("not support boolean rule! "+e[0])}}function NO(e){let t=[e[0]];for(let i=1;i<e.length;i++){let r=e[i];if(Array.isArray(r)){let n=NO(r);Array.isArray(n)?n.length>1&&t.push(n):t.push(n)}else{let n=jx(r);n!==null&&t.push(Pn.build(n))}}return t}function tV(e,t){Ks.curBus=t,e=NO(e);let i;return Ks.UseRunArrange?i=QY.simplifyRules(e,t):i=zy(e),i.length<=1?new Pn([]):FT(i,t)}function FT(e,t,i=!0){if(!e||e.length===1)return new Pn([]);let r=e,n=new $Y,s=[];function a(o){for(let l=1;l<o.length;l++){let c=o[l];Array.isArray(c)?a(c):s.push(c)}}return a(r),n.init(s),RO(r,n,t,i)}var gx=new Error("list is empty"),yx=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},iV=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},rV=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},nV=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw gx;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw gx;return this.remove(e),e.item}addLast(e){if(this.first===null||this.last===null){let t=new yx(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new yx(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw gx;return this.first.item}getLast(){if(this.last===null)throw gx;return this.last.item}insertAfter(e,t){let i=new yx(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new yx(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new iV(this.first)}listIterator(){return new rV(this.first)}toArray(){let e=new Array,t=this.first;for(;t!=null;)e.push(t.item),t=t.next;return e}},Dx=class{constructor(e){this.inters=[],e&&(this.inters=e)}addInter(e){this.inters.push(e),e.group=this}findInter(e){let t=this.inters.find(i=>At(i.coord,e.coord));return t&&this.inters.find(i=>i.side===e.side)&&e.visitSelf(),t}getOutInter(e){let t=this.inters.filter(i=>!i.getVisited());if(t.length!==0)return t.length===1?t[0]:t.reduce((i,r)=>{if(!i||i.side.getShape()===e)return r;if(r.side.getShape()===e)return i;let n=i.coord,s=Gt(e,n),a=Gt(i.side.getShape(),n),o=Gt(r.side.getShape(),n);return s.dot(a)>s.dot(o)?i:r},void 0)}getEntryInter(){}},mT=0;function MO(e,t){let i=e.primitives[0];if(e.primitives.length===1&&i instanceof Pe&&Math.abs(i.sweepAngle)===360)return[e];let r=g0();mT++;let n,s=pV(e);if(s.length===0)return[];let a=oV(s);if(mT===-1){n=new f0(t);let u=n.initColor(zi.BLUE);s.forEach(d=>u.addPt(d.getShape()));let h=n.initColor(zi.GREEN);a.forEach(d=>h.addPoint(d.coord)),n.draw();debugger;throw new Error}if(a.length===0)return[wi.build7(s.map(u=>u.getShape()))];lV(a);let o=[],l=!1;try{hV(a,n)}catch(u){u.customType==="IS_OVERLAP"?(l=!0,o=new Vy().getUnion([e]).map(h=>h.items).flat(2)):console.error(u)}if(l)return o;let c=uV(a);if(!c.length)return[wi.build7(s.map(u=>u.getShape()))];if(o=sV(c,n),o.length===0)return console.warn("=====deSelfIntersection=====",mT),[];if(n)throw o.forEach(u=>{n.initColor(zi.WHITE).addPly(u),n.draw();debugger}),new Error;return cu.deSelfIntersection+=id(r),o}function sV(e,t){let i=[];return e.forEach(r=>{let n=r;r.inters.forEach(s=>{if(s.getVisited())return;let a=[],o=[],l;if(t){debugger;let u=t.initColor(zi.RED);l=h=>{a.push(h),u.addPt(a[a.length-1]),t.draw();debugger}}else l=u=>a.push(u);do{let u=function(m,g){Oe.eq(m.distance2(g),0)||l(BO(p.getShape(),m,g))},h=o.findIndex(m=>m===s.group);if(h!==-1){let m=a.findIndex(y=>y===s.group),g=a.splice(m).filter(y=>!(y instanceof Dx));if(g.length){let y=ad(wi.build7(g));y&&i.push(y)}let b=a.filter(y=>!(y instanceof Dx));if(s=o[h].getOutInter(b[b.length-1]),o.splice(h),!s)throw Error("interGroup not hav inter!!!2");continue}s.visitSelf(),o.push(s.group),a.push(s.group);let d=s.getIndex(),p=s.side,f=p.inters[d+1];for(;f!=null&&f.isInvalid||f&&f.group===s.group;)f=p.inters[f.getIndex()+1];if(f){u(s.coord,f.coord);let m=f.getBindedInter();if(s=m.getVisited()?m.group.getOutInter(m.side.getShape()):m,!s){if(f.group===n)break;throw new Error("interGroup not hav inter!!!3")}}else{for(u(s.coord,p.getEnd()),p=p.nextSide,s=null;;){for(let m of p.inters)if(!m.isInvalid){let g=m.group.getOutInter(p.getShape());if(!g){if(m.group===n){s=m;break}else if(m.getBindedInter().group===n){s=m.getBindedInter();break}continue}s=g;break}if(s)break;l(p.getShape()),p=p.nextSide}Oe.eq(p.getEnd().distance2(s.coord),0)?l(p.getShape()):u(p.getStart(),s.coord)}}while(s.group!==n);let c=ad(wi.build7(a.filter(u=>!(u instanceof Dx))));c&&i.push(c)})}),i}function aV(e){return{next(){return e.hasNext()?{value:e.next()}:{done:!0,value:void 0}},[Symbol.iterator](){return this}}}function oV(e){let t=[],i=new nV;for(let r of e.slice().sort((n,s)=>n.bbox().minY-s.bbox().minY)){for(let n of aV(i.listIterator())){let s=n.item;if(s.bbox().maxY<r.bbox().minY)i.remove(n);else{let a=function(d,p){let f=new nh(p,d,null);return d.inters.push(f),t.push(f),f},o=function(d,p){let f=d.getEnd(),m=new we(ae[0],ae[1]),g=new we(ae[2],ae[3]),b=f.distance2(m)>f.distance2(g)?m:g,y=d.prevSide;a(At(y.getEnd(),b)?y:d,b).bind(a(p,b))},l=s.getShape(),c=r.getShape(),u=Pl(l,c),h=u===4&&ae[0]===ae[2]&&ae[1]===ae[3];if(h&&(u-=2),s.nextSide===r)s.prevSide!==r&&u===4&&o(s,r);else if(s.prevSide===r)u===4&&o(r,s);else if(u!==0){let d=function(f,m){let g=f.prevSide;return a(At(g.getEnd(),m)?g:f,m)},p=new we(ae[0],ae[1]);if(h&&!At(p,s.prevSide.getEnd())&&!At(p,r.prevSide.getEnd())&&Gt(l,p).dot(Gt(c,p))>0)continue;for(let f=0;f<u;f+=2){let m=new we(ae[f],ae[f+1]);d(s,m).bind(d(r,m))}}}}i.add(r)}return t.forEach(r=>{r.getIndex()===void 0&&r.side.sortInters()}),t}function lV(e){e.forEach(t=>{let i=t.side.getEnd();if(t.isInvalid||!At(t.coord,i))return;let r=t.side.inters,n=t.getBindedInter().side;for(let s=r.length-1;s>=0;s--){let a=r[s];if(!At(a.coord,i))break;a!==t&&a.getBindedInter().side===n&&a.setIsInvalid()}})}function cV(e){let t=new t0(10);return e.forEach(i=>{i.isInvalid||t.add(i)}),t}function uV(e){let t=[],i=cV(e);return e.forEach(r=>{if(r.isInvalid||r.group)return;let n=i.search(r.bbox().extendOfSize(Oe.eps)).filter(s=>!s.group);if(n.length){let s=new Set,a=new Dx(n);n.forEach(o=>{o.group=a,s.has(o.side)&&o.visitSelf(),s.add(o.side)}),t.push(a)}}),t}function hV(e,t){e.forEach(i=>{if(i.isInvalid||i.dealed)return;let r=i.side,n=i.getBindedInter().side,s;At(r.getEnd(),i.coord)&&At(n.getEnd(),i.coord)?s=-1:At(r.getEnd(),i.coord)?r.nextSide!==n&&(s=1,i=i.getBindedInter()):At(n.getEnd(),i.coord)&&n.nextSide!==r&&(s=1),dV(s,i,t),i.isDealed()})}function dV(e,t,i){let r=t.getBindedInter(),n=t.side,s=r.side,a=n.getShape(),o=s.getShape(),l=1,c=!1;if(e===-1){if(Kf(a.reverse(),o.reverse())||Kf(n.nextSide.getShape(),s.nextSide.getShape())){let h=ih(n,n.nextSide,s,r,l,c,i);if(h.state===2){let p=new Error("info1.state === InState.IS_OVERLAP");throw p.customType="IS_OVERLAP",p}let d=ih(n,n.nextSide,s.nextSide,r,l,c,i);h.state===d.state&&u(h,d)}else if(!(Kf(a.reverse(),s.nextSide.getShape())||Kf(n.nextSide.getShape(),o.reverse()))){let h=aT(n,n.nextSide,s,!1,i);h===aT(n,n.nextSide,s.nextSide,!0,i)&&h!==aT(s,s.nextSide,n.nextSide,!0,i)&&t.setIsInvalid()}}else if(e===1){let h=function(d,p){return Gt(d,p.start()).dot(Gt(p,p.start()))>0};if(Kf(a.reverse(),o.reverse())||Kf(a,s.nextSide.getShape())){let d=tl(n,s,r,i,l,c,new Map);if(d.state===2){let f=new Error("info1.state === InState.IS_OVERLAP");throw f.customType="IS_OVERLAP",f}let p=tl(n,s.nextSide,r,i,l,c,new Map);d.state===p.state&&u(d,p)}else if(h(a.reverse(),o.reverse())&&h(a,s.nextSide.getShape())){let d=Cs(n,s,!1,i);d===Cs(n,s.nextSide,!0,i)&&d!==Cp(s,s.nextSide,new m0(BO(a,t.coord,a.end()),i),!0,i)&&t.setIsInvalid()}}function u(h,d){h.inter.setIsInvalid(),d.inter.setIsInvalid(),t.setIsInvalid()}}function BO(e,t,i){if(e instanceof me||t.distance2(i)<1e-6)return new me(t,i);if(e instanceof Pe)return Pe.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.sweep());if(e instanceof ct){let r=e.getPercent(t,Ut),n=e.getPercent(i,Ut);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function pV(e){let t=ad(e);if(!t)return[];let i=t.primitives.map(n=>new m0(n,null)),r=i[i.length-1];return i.forEach(n=>{r.connect(n),r=n}),i}var Qf,fV=(Qf=class{static clearData(e){this.originalPrimitive=[],this.offsetPrimitive=[],this.rawOffsetPrimitive=[],this.offsetDistance=0,this.testI++,this.testI===0?this.drawDebug=new f0(e):delete this.drawDebug}static createRawOffsetEdge(){if(this.drawDebug){let e=this.drawDebug.initColor(zi.WHITE);this.originalPrimitive.forEach(t=>e.addPt(t)),this.drawDebug.draw();debugger}for(let e=0;e<this.originalPrimitive.length;e+=1){let t=this.originalPrimitive[e];this.offsetPrimitive.push({index:e,offsetEdge:this.createOffsetEdge(t)})}if(this.drawDebug){let e=this.drawDebug.initColor(zi.Golden);this.offsetPrimitive.forEach(t=>e.addPt(t.offsetEdge)),this.drawDebug.draw();debugger}if(this.offsetPrimitive.length>1)for(let e=0;e<this.offsetPrimitive.length;e+=1)if(e===this.offsetPrimitive.length-1){this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[0]);let t=this.rawOffsetPrimitive[0],i;t instanceof Pe?i=Pe.build4(this.offsetPrimitive[0].offsetEdge.start(),t.end(),t.center,t.rx,t.ry,t.sweep()):i=new me(this.offsetPrimitive[0].offsetEdge.start(),t.end()),this.rawOffsetPrimitive.shift(),this.rawOffsetPrimitive.unshift(i)}else this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[e+1]);else this.rawOffsetPrimitive=[]}static createCirclePrimitive(e,t){let i=e.width()*.5,r=e.height()*.5,n=Math.sqrt(i**2+r**2)+t;return[Pe.buildCircle(e.center(),n)]}static getExtendPolyLine(e,t,i=!0,r){var n,s;if(!((n=e==null?void 0:e.primitives)!=null&&n.length))return[];let a=ad(e);if(!((s=a==null?void 0:a.primitives)!=null&&s.length)){if(this.isExpansion){let l=[1],c=t*2;e.primitives.forEach(h=>l.push(h.stroke(c,1,0)));let u=tV(l,r);if(u.items.length!==1)throw new Error("group.items.length !== 1 ");return[u.items[0].items[0]]}return[]}if(e=a,this.clearData(r),this.originalPrimitive=e.primitives,this.isExpansion=t>0,this.offsetDistance=t,this.createRawOffsetEdge(),this.drawDebug){let l=this.drawDebug.initColor(zi.BLUE);this.rawOffsetPrimitive.forEach(c=>l.addPt(c)),this.drawDebug.draw();debugger}let o=i?this.createClippingEdge(r):[wi.build2(this.rawOffsetPrimitive)];if(this.drawDebug){let l=this.drawDebug.initColor(zi.RED);o.forEach(c=>l.addPly(c)),this.drawDebug.draw();debugger}if(o.length&&(!this.isExpansion||this.isExpansion&&o.length>1)&&(o=this.getValidityPrimitive(o)),this.drawDebug){let l=this.drawDebug.initColor(zi.GREEN);o.forEach(c=>l.addPly(c)),this.drawDebug.draw();debugger;throw new Error}return o}static getValidityPrimitive(e){let t=[],i=Math.abs(this.offsetDistance);for(let r=0;r<e.length;r+=1){let n=!0,s=e[r].primitives;e:for(let a=0;a<s.length;a+=1){let o=s[a],l;if(o instanceof Pe)l=o.midPoint;else if(o instanceof me)l=o.start();else throw new Error("not support!");for(let c=0;c<this.originalPrimitive.length;c+=1){let u=this.originalPrimitive[c],h;if(u instanceof Pe?h=this.pointArcClosest(l,u):h=JU(l,u.start(),u.end()).d,i-h>.01){n=!1;break e}}}n&&t.push(e[r])}return t}static getInters(e){let t=[];for(let i=0;i<e;i+=2)t.push(new we(ae[i],ae[i+1]));return t}static pointArcClosest(e,t){let i=t.center;if(e.equals1(t.center))return t.rx;if(t.inArea(e,0)){let s=e.sub(i);return Math.abs(s.length()-t.rx)}let r=e.distance2(t.start()),n=e.distance2(t.end());return Oe.less(r,n)?Math.sqrt(r):Math.sqrt(n)}static createClippingEdge(e){let t=[],i=[],r=MO(wi.build2(this.rawOffsetPrimitive),e);r.forEach(s=>{let a=s.area(.01);t.push(a)});let n=Math.min(...t.filter(s=>s<0));for(let s=0;s<t.length;s+=1){let a=t[s];Oe.eq(a,0)||(!this.isExpansion&&a<0||this.isExpansion&&(a<0&&t[s]===n||a>0))&&i.push(r[s])}return i}static createOffsetEdge(e){if(e instanceof Pe)return e.panDistance1(this.offsetDistance);if(e instanceof me)return e.panDistance(this.offsetDistance);throw new Error("not support!")}static connectPrimitive(e,t){e.offsetEdge instanceof me&&t.offsetEdge instanceof me?this.lineToLineConnect(e,t):e.offsetEdge instanceof Pe&&t.offsetEdge instanceof Pe?this.arcToArcConnect(e,t):e.offsetEdge instanceof me&&t.offsetEdge instanceof Pe?this.lineToArcConnect(e,t):this.arcToLineConnect(e,t)}static isFalseIntersection(e){return e>1||e<0}static lineToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=t.index,s=this.originalPrimitive[n].start();if(i.isParallel(r))i.bbox().intersection1(r.bbox())?this.rawOffsetPrimitive.push(i):this.lineToLineUseArcToConnect(s,i,r);else{let a=this.getLineToLineT(i,r),o=a[0],l=a[1];if(this.isFalseIntersection(o)||this.isFalseIntersection(l))o>1&&this.isFalseIntersection(l)?this.lineToLineUseArcToConnect(s,i,r):this.useLineToConnect(i,r);else if(!this.isFalseIntersection(o)&&!this.isFalseIntersection(l)){let c=i.end().sub(i.start()),u=i.start().add(c.mul(o)),h=new me(i.start(),u);this.rawOffsetPrimitive.push(h);let d=new me(u,r.end());this.updateNextOffsetPrimitive(n,d)}}}static updateNextOffsetPrimitive(e,t){this.offsetPrimitive[e].offsetEdge=t}static useLineToConnect(e,t){this.rawOffsetPrimitive.push(e);let i=new me(e.end(),t.start());this.rawOffsetPrimitive.push(i)}static lineToLineUseArcToConnect(e,t,i){let r=this.getSweep(e,t),n=this.getSweepAngel(t.end(),i.start(),e,r);if(n===0){this.useLineToConnect(t,i);return}this.rawOffsetPrimitive.push(t);let s=Pe.build5(t.end(),i.start(),n);this.rawOffsetPrimitive.push(s)}static getSweep(e,t,i){let r=null,n=i||i===0?this.originalPrimitive[i]:t;if(n instanceof Pe){let s=n.center.sub(n.end()).normalize();n.isCCW?r=new we(s.y,-s.x):r=new we(-s.y,s.x)}else r=t.end().sub(t.start()).normalize();return e.sub(t.end()).normalize().cross(r)>0?0:1}static getLineToLineT(e,t){let i=e.end().sub(e.start()),r=t.end().sub(t.start()),n=i.cross(r),s=t.start().sub(e.start()),a=e.start().sub(t.start()),o=s.cross(r)/n,l=a.cross(i)/-n;return[o,l]}static lineToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=e.index,s=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(i,r),o=this.originalPrimitive[s].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,n);else if(a.intersectionNum===1){let l=a.points[0];this.lineAndArcConnectionDetail(i,r,a.t[0],l,o,n,s)}else if(a.intersectionNum===2){let l=a.points[0],c=a.points[1],u=l.distance2(o),h=c.distance2(o);this.lineAndArcConnectionDetail(i,r,u<h?a.t[0]:a.t[1],u<h?l:c,o,n,s)}}static lineAndArcConnectionDetail(e,t,i,r,n,s,a){let o=this.isTrueArcIntersection(t,r);if(!this.isFalseIntersection(i)&&o){let l=new me(e.start(),r);this.rawOffsetPrimitive.push(l);let c;!t.center.equals1(r)||t.sweepAngle>1e-4?(c=Pe.build4(r,t.end(),t.center,t.rx,t.ry,t.sweep()),c instanceof Pe&&c.sweepAngle===0&&(c=new me(c.start(),c.end()))):c=new me(t.center,r),this.updateNextOffsetPrimitive(a,c)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(n,e,t,s)}static lineAndArcUseArcConnect(e,t,i,r){let n=this.getSweep(e,t,r),s=this.getSweepAngel(t.end(),i.start(),e,n);if(s===0){this.useLineToConnect(t,i);return}let a=Pe.build5(t.end(),i.start(),s);this.rawOffsetPrimitive.push(t),this.rawOffsetPrimitive.push(a)}static arcToLineConnectionDetail(e,t,i,r,n,s,a){let o=this.isTrueArcIntersection(e,r);if(!this.isFalseIntersection(i)&&o){let l;e.center.equals1(r)?l=new me(e.center,r):Math.abs(e.sweepAngle)<1e-4?l=new me(e.start(),r):(l=Pe.build4(e.start(),r,e.center,e.rx,e.ry,e.sweep()),l instanceof Pe&&l.sweepAngle===0&&(l=new me(l.start(),l.end()))),this.rawOffsetPrimitive.push(l);let c=new me(r,t.end());this.updateNextOffsetPrimitive(a,c)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(n,e,t,s)}static isTrueArcIntersection(e,t){return Yn(e,t)}static getSweepAngel(e,t,i,r){let n=e.angleD(i),s=t.angleD(i),a;return n===s?a=0:(n=ei.regularD(n),s=ei.regularD(s),r===1?s<=n&&(s+=360):s>=n&&(n+=360),a=s-n),a}static getLineJoinArcScalarAndIntersectionNum(e,t){let i={t:[],intersectionNum:0,points:[]},r=XU(t,e);if(r){i.intersectionNum=r/2;for(let n=0;n<r-1;n+=2){let s=new we(ae[n],ae[n+1]);i.points.push(s),s.sub(e.start()).x<1e-4||s.sub(e.start()).y<1e-4?i.t.push(0):i.t.push(s.sub(e.start()).x/e.end().sub(e.start()).x)}}else i.intersectionNum=0;return i}static arcToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=e.index,s=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(r,i),o=this.originalPrimitive[s].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,n);else if(a.intersectionNum===1){let l=a.points[0];this.arcToLineConnectionDetail(i,r,a.t[0],l,o,n,s)}else if(a.intersectionNum===2){let l=a.points[0],c=a.points[1],u=l.distance2(o),h=c.distance2(o);this.arcToLineConnectionDetail(i,r,u<h?a.t[0]:a.t[1],u<h?l:c,o,n,s)}}static rxChangeStatus(e){return e===1?!this.isExpansion:this.isExpansion}static arcToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=mO(i,r);if(n){let s=this.getInters(n),a;if(s.length===2){let c=this.originalPrimitive[t.index].start(),u=s[0],h=s[1],d=u.distance2(c),p=h.distance2(c);d<p?a=u:a=h}else a=s[0];let o,l;a.equals1(i.center)?o=new me(i.center,a):Math.abs(i.sweepAngle)<1e-4?o=new me(i.start(),a):(o=Pe.build4(i.start(),a,i.center,i.rx,i.ry,i.sweep()),o instanceof Pe&&o.sweepAngle===0&&(o=new me(o.start(),o.end()))),this.rawOffsetPrimitive.push(o),a.equals1(r.center)?l=new me(a,r.center):Math.abs(r.sweepAngle)<1e-4?l=new me(a,r.end()):(l=Pe.build4(a,r.end(),r.center,r.rx,r.ry,r.sweep()),l instanceof Pe&&l.sweepAngle===0&&(l=new me(l.start(),l.end()))),this.updateNextOffsetPrimitive(t.index,l)}else{let s=this.originalPrimitive[e.index],a=this.originalPrimitive[t.index],o=this.rxChangeStatus(s.sweep()),l=this.rxChangeStatus(a.sweep()),c=this.originalPrimitive[t.index].start(),u=this.getSweep(c,i,e.index),h=Math.abs(this.offsetDistance),d=Pe.build2(c,o?s.endAngle():s.endAngle()+180,l?a.startAngle:a.startAngle+180,h,h,u);this.rawOffsetPrimitive.push(i),this.rawOffsetPrimitive.push(d)}}},Qf.originalPrimitive=[],Qf.offsetPrimitive=[],Qf.rawOffsetPrimitive=[],Qf.testI=0,Qf),mV=class Xy extends d0{constructor(t,i,r,n,s,a){if(super(),i<0||r<0)throw new Error("The width and height of rect can't be less than 0!");this.leftUpPoint=t,this.width=i,this.height=r,this.angle=n,this.isCCW=s,this.radius=Math.min(Math.max(a,0),i/2,r/2)}get radiusRatio(){return this.radius/Math.min(this.width,this.height)}start(){return this.leftUpPoint.add(new we(this.radius,0).multiply3(hr.rotateD(this.angle)))}end(){return this.start()}getLeftPoint(){return this.leftUpPoint.add(new we(0,-this.height/2).multiply3(hr.rotateD(this.angle)))}getRightPoint(){return this.leftUpPoint.add(new we(this.width,-this.height/2).multiply3(hr.rotateD(this.angle)))}extend(t){return new Xy(this.leftUpPoint.add(new we(-t,t).rotateD(we.ORIGIN,this.angle)),this.width+t*2,this.height+t*2,this.angle,this.isCCW,this.radius+t)}bbox(){let t=hr.rotateD(this.angle),{leftUpPoint:i,width:r,height:n,radius:s}=this,a=i.add(new we(s,-s).multiply3(t)),o=i.add(new we(s,s-n).multiply3(t)),l=i.add(new we(r-s,-s).multiply3(t)),c=i.add(new we(r-s,s-n).multiply3(t));return new ba(Math.min(a.x,o.x,l.x,c.x)-s,Math.max(a.x,o.x,l.x,c.x)+s,Math.min(a.y,o.y,l.y,c.y)-s,Math.max(a.y,o.y,l.y,c.y)+s)}toPolyline(){let t=[],{leftUpPoint:i,width:r,height:n,radius:s}=this;if(s===0){let o=we.ORIGIN,l=new we(r,0),c=new we(r,-n),u=new we(0,-n);t.push(new me(o,l),new me(l,c),new me(c,u),new me(u,o))}else{let o=new we(0,-s),l=new we(s,0),c=new we(r-s,0),u=new we(r,-s),h=new we(r,s-n),d=new we(r-s,-n),p=new we(s,-n),f=new we(0,s-n);t.push(Pe.build1(o,l,s,s,!1,0),new me(l,c),Pe.build1(c,u,s,s,!1,0),new me(u,h),Pe.build1(h,d,s,s,!1,0),new me(d,p),Pe.build1(p,f,s,s,!1,0),new me(f,o))}t=t.filter(o=>!o.start().equals1(o.end())),this.isCCW&&(t.forEach((o,l)=>t[l]=o.reverse()),t.reverse());let a=hr.rotateD(this.angle).translate1(i);return wi.build2(t.map(o=>o.multiply3(a)))}center(){return this.leftUpPoint.add1(this.width/2,this.height/2).rotateD(this.leftUpPoint,this.angle)}multiply3(t){let i=this.leftUpPoint.multiply3(t),r=new we(this.width,0).multiply3(hr.rotateD(this.angle)).multiply3(t),n=new we(0,-this.height).multiply3(hr.rotateD(this.angle)).multiply3(t);return t.isMirrored()?new Xy(i,n.length(),r.length(),n.angleD(we.ORIGIN),this.isCCW===1?0:1,this.radius*r.length()/this.width):new Xy(i,r.length(),n.length(),r.angleD(we.ORIGIN),this.isCCW,this.radius*r.length()/this.width)}reverse(){return new Xy(this.leftUpPoint,this.width,this.height,this.angle,this.isCCW===1?0:1,this.radius)}stroke(t,i,r){let n=this.stroke1(t,i,r);if(n.length===1)return n[0];{let[s,a]=n;return wi.build2(s.primitives.concat(new me(s.primitives[0].start(),a.primitives[0].start()),a.primitives,new me(a.primitives[0].start(),s.primitives[0].start())))}}stroke1(t,i,r){let n=r===this.isCCW?this:this.reverse(),s=t/2,a=Math.min(n.width,n.height)/2,o=n.extend(s).toPolyline();return a<=s?[o]:[o,n.extend(-s).toPolyline().reverse()]}points(t){let i=this.toPolyline(),r=[];return i.points(t,n=>r.push(n)),r}toBezier(){throw new Error("Method not implemented.")}},gV=.01,as=class bc{static simplify(t){return t=ad(t),t?new bc([t]):null}static buildByStroke(t,i,r=1,n=cI,s){if(t instanceof Pe&&(t.rx<i/2+gV||Math.abs(t.sweepAngle)>180&&Oe.lesseq(t.start().distance1(t.end()),i))){let o=MO(t.stroke(i,r,0),s);if(o.length===0)return null;if(o.length===1)return new bc(o);let l=[null],c=Number.POSITIVE_INFINITY;return o.forEach(u=>{let h=u.area(.1);h<0?h<c&&(l[0]=u,c=h):l.push(u)}),new bc(l)}else if(t instanceof mV){let o=t.stroke1(i,r,0).map(l=>ad(l));return o[0]?o[1]?new bc(o):new bc([o[0]]):null}let a=t.stroke(i,r,0,n);return a?this.simplify(a):null}static buildCircle(t,i){return this.simplify(wi.build7([Pe.buildCircle(t,i,0)]))}static buildRect(t){return this.simplify(t.toPolyline())}static buildBBox(t){return this.simplify(wi.buildBBox(t,0))}constructor(t){this.items=t.slice()}multiply3(t){return new bc(this.items.map(i=>i.multiply3(t)))}bbox(){return this.items[0].bbox()}isEqual(t){return t instanceof bc?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items[0]}extend(t,i){if(this.items.length!==1)throw new Error("this.items.length !== 1");if(t===0)return new Pn([this]);let r=this.items[0],n=[];for(let u of r.primitives)if(u instanceof me)n.push(u);else if(u instanceof Pe&&u.rx===u.ry)a(u);else if(u instanceof ct)s(u);else throw new Error("not support!");r=wi.build7(n);function s(u){let h=u.points(.1);for(let d=0;d<h.length-1;d++){let p=h[d],f=h[d+1];n.push(new me(p,f))}}function a(u){if(Math.abs(u.sweepAngle)>270){let h=u.sweepAngle/2;a(Pe.build3(u.center,u.startAngle,h,u.rx,u.ry)),a(Pe.build3(u.center,u.startAngle+h,h,u.rx,u.ry))}else n.push(u)}let o=[],l=[];fV.getExtendPolyLine(r,t,!0,i).forEach(u=>{(u.area(.1)>0?l:o).push(u)});let c;if(o.length===1)l.forEach(u=>o.push(u)),c=new Pn([new bc(o)]);else if(o.length===0)console.warn("outlines.length === 0"),c=new Pn([]);else if(l.length===0)c=new Pn(o.map(u=>new bc([u])));else{let u=o.map(h=>[h]);l.forEach(h=>{let d=[],p=h.bbox();if(u.forEach(f=>{f[0].bbox().isContainsBBox1(p)&&d.push(f)}),d.length===1)d[0].push(h);else{if(d.length===0)throw new Error("inPlsArr.length === 0");for(let f of d.sort((m,g)=>m[0].bbox().area()-g[0].bbox().area()))if(f[0].getWindingNum(h.start())===-1){f.push(h);break}}}),c=new Pn(u.map(h=>new bc(h)))}return c}toPolylineGroup(){return new uI(this.items)}},yV=(e=>(e[e.POLYGON=1]="POLYGON",e[e.POLYLINE=2]="POLYLINE",e[e.LINE=3]="LINE",e[e.ARC=4]="ARC",e[e.BEZIER2=5]="BEZIER2",e[e.BEZIER3=6]="BEZIER3",e[e.BOOLEAN_OUTPUT=7]="BOOLEAN_OUTPUT",e[e.BOOLEAN_INTERSECTION=8]="BOOLEAN_INTERSECTION",e[e.BOOLEAN_UNION=9]="BOOLEAN_UNION",e[e.BOOLEAN_DIFF=10]="BOOLEAN_DIFF",e[e.BOOLEAN_RESULT=11]="BOOLEAN_RESULT",e[e.LINES=12]="LINES",e[e.ARCS=13]="ARCS",e[e.BEZIER2S=14]="BEZIER2S",e[e.BEZIER3S=15]="BEZIER3S",e[e.CIRCLE_CW=16]="CIRCLE_CW",e[e.CIRCLE_CCW=17]="CIRCLE_CCW",e[e.POLYGON_GROUP=18]="POLYGON_GROUP",e))(yV||{}),bV=class{constructor(e){this.idx=-1,this.lst=e}hasNext(){return this.idx<this.lst.length-1}next(){if(this.idx<this.lst.length-1)return this.idx++,this.lst[this.idx];throw new Error("bug")}};function xV(e){return new bV(e)}function EV(e){return e===32||e===9||e===13||e===10}var SV=class{constructor(){this._line=1,this._col=0}line(){return this._line}col(){return this._col}_feed(e){return e===10?(this._col=0,this._line++):this._col++,this.feed(e)}parse(e){let t=e.length;for(let i=0;i<t;i++){let r=e.charCodeAt(i);if(!this._feed(r))return this}return this.finish(),this}},gT=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}},wV=/(\.?0+)$/,GT=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,n=0,s,a=0,o=0;for(let l=0;l<e.length;l++){let c=e.charAt(l),u=c.charCodeAt(0);switch(r){case 0:u===37?r=1:i.push(c);break;case 1:switch(u){case 100:if(s=t[n++],typeof s=="number")i.push(s.toFixed(0)),r=0;else return l;break;case 102:if(s=t[n++],typeof s=="number")i.push(s.toString()),r=0;else return l;break;case 120:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16)),r=0;else return l;break;case 88:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:s=t[n++],i.push(s===null?"null":s.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(u){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 100:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(gT.lpad((s|0).toString(10),"0",h)),r=0;else return l}else return l;break;case 120:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(gT.lpad((s|0).toString(16),"0",h)),r=0;else return l}else return l;break;case 88:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(gT.lpad((s|0).toString(16).toUpperCase(),"0",h)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static fmtNumber(e){return e.toFixed(5).replace(wV,"")}};function vV(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var TV=(e,t)=>{e===3?console.error(...t):e===2?console.warn(...t):console.log(...t)},IV=(e,t)=>[vV(e)].concat(t),UT=class YT{static mix(...t){return new YT(0,(i,r)=>{for(let n of t)n.write(i,r)},(i,r)=>r)}constructor(t,i=TV,r=IV){this.level=t,this.writer=i,this.fmt=r}setLevel(t){this.level=t}prepend(t=null,i=null){let r=t===null?this.fmt:(s,a)=>(a=t(s,a),this.fmt(s,a)),n=i===null?this.writer:(s,a)=>{i(s,a),this.writer(s,a)};return new YT(this.level,n,r)}chain(t){return t.prepend(this.fmt.bind(this),this.writer.bind(this))}include(t){return this.level<=t}formatWrite(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[GT.format(i,...r)]))}write(t,i){this.include(t)&&this.writer(t,this.fmt(t,i))}write3(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[GT.format(i,...r)]))}debug3(t,...i){this.write3(0,t,i)}warning3(t,...i){this.write3(2,t,i)}debugFmt(t,...i){this.formatWrite(0,t,i)}debug(...t){this.write(0,t)}infoFmt(t,...i){this.formatWrite(1,t,i)}info(...t){this.write(1,t)}warningFmt(t,...i){this.formatWrite(2,t,i)}warning(...t){this.write(2,t)}errorFmt(t,...i){this.formatWrite(3,t,i)}error(...t){this.write(3,t)}};UT.DUMMY=new UT(4);var AV=UT,yT=500,PL=String.fromCharCode,CV=class{constructor(){this.buffer=new Array}size(){return this.buffer.length}isEOF(){return!1}write(e){return this.buffer.push(e),1}writen1(e){return this.writen2(e,0,e.length)}writen2(e,t,i){let r=this.buffer;for(let n=0,s=t;n<i;n++,s++)r.push(e[s]);return i}writeAsync(e,t){t(this.write(e))}writenAsync1(e,t){t(this.writen1(e))}writenAsync2(e,t,i,r){r(this.writen2(e,t,i))}writeStr(e){let t=e.length,i=new Array(t);for(let r=0;r<t;r++)i[r]=e.charCodeAt(r);return this.writen1(i)}clear(){this.buffer.length=0}toString(){let e=this.buffer,t=e.length;if(t<=yT)return PL.apply(null,e);{let i=new Array;for(let r=0;r<e.length;r+=yT){let n=Math.min(t-r,yT),s=PL.apply(null,e.slice(r,r+n));i.push(s)}return i.join("")}}},kO=(e=>(e[e.UNKNOW=0]="UNKNOW",e[e.NUMBER_INTEGER=1]="NUMBER_INTEGER",e[e.NUMBER_DECIMAL=2]="NUMBER_DECIMAL",e[e.NUMBER_E=3]="NUMBER_E",e[e.NUMBER_E_SIGNED=4]="NUMBER_E_SIGNED",e))(kO||{}),FO=(e=>(e[e.UNKNOW=0]="UNKNOW",e[e.MOVE_X=1]="MOVE_X",e[e.MOVE_Y=2]="MOVE_Y",e[e.LINE_X=3]="LINE_X",e[e.LINE_Y=4]="LINE_Y",e[e.HORIZONTAL_X=5]="HORIZONTAL_X",e[e.VERTICAL_Y=6]="VERTICAL_Y",e[e.CUBIC_BEZIER_X1=7]="CUBIC_BEZIER_X1",e[e.CUBIC_BEZIER_Y1=8]="CUBIC_BEZIER_Y1",e[e.CUBIC_BEZIER_X2=9]="CUBIC_BEZIER_X2",e[e.CUBIC_BEZIER_Y2=10]="CUBIC_BEZIER_Y2",e[e.CUBIC_BEZIER_X=11]="CUBIC_BEZIER_X",e[e.CUBIC_BEZIER_Y=12]="CUBIC_BEZIER_Y",e[e.ARC_RX=13]="ARC_RX",e[e.ARC_RY=14]="ARC_RY",e[e.ARC_ROTATION=15]="ARC_ROTATION",e[e.ARC_LARGE=16]="ARC_LARGE",e[e.ARC_SWEEP=17]="ARC_SWEEP",e[e.ARC_X=18]="ARC_X",e[e.ARC_Y=19]="ARC_Y",e[e.SMOOTH_CUBIC_BEZIER_X2=20]="SMOOTH_CUBIC_BEZIER_X2",e[e.SMOOTH_CUBIC_BEZIER_Y2=21]="SMOOTH_CUBIC_BEZIER_Y2",e[e.SMOOTH_CUBIC_BEZIER_X=22]="SMOOTH_CUBIC_BEZIER_X",e[e.SMOOTH_CUBIC_BEZIER_Y=23]="SMOOTH_CUBIC_BEZIER_Y",e[e.QUADRATIC_BEZIER_X1=24]="QUADRATIC_BEZIER_X1",e[e.QUADRATIC_BEZIER_Y1=25]="QUADRATIC_BEZIER_Y1",e[e.QUADRATIC_BEZIER_X=26]="QUADRATIC_BEZIER_X",e[e.QUADRATIC_BEZIER_Y=27]="QUADRATIC_BEZIER_Y",e))(FO||{});function DV(e){return 97<=e&&e<=122||65<=e&&e<=90}function Is(e){let t=parseFloat(e);if(isFinite(t))return t;throw new Error("expect number")}var LL=class extends SV{constructor(e,t=!0,i=AV.DUMMY){super(),this.buffer=new CV,this.group=new Array,this.subPartStart=we.ORIGIN,this.curPoint=we.ORIGIN,this.lexState=0,this.parseState=0,this.isAbsolute=!1,this.isLargeArc=!1,this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.x=Number.NaN,this.y=Number.NaN,this.rx=Number.NaN,this.ry=Number.NaN,this.rotation=Number.NaN,this.sweep=td.CCW,this.prevBezierCtrl2=null,this.logger=i,this.cb=e,this.yAxis=t?-1:1}on(e){return this.cb(e)}feed(e){switch(this.logger.include(0)&&this.logger.debug3("L: %c(%s)|%s",e,String.fromCharCode(e),kO[this.lexState]),this.lexState){case 0:return EV(e)?!0:48<=e&&e<=57||e===45||e===43?(this.pushBuffer(e),this.lexState=1,!0):e===46?(this.pushBuffer(e),this.lexState=2,!0):DV(e)?this.feedS(String.fromCharCode(e)):(this.logger.warning3("unknow letter %c",e),!0);case 1:return 48<=e&&e<=57?(this.pushBuffer(e),!0):e===46?(this.pushBuffer(e),this.lexState=2,!0):e===101||e===69?(this.pushBuffer(e),this.lexState=3,!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(e)):!1;case 2:return 48<=e&&e<=57?(this.pushBuffer(e),!0):e===101||e===69?(this.pushBuffer(e),this.lexState=3,!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(e)):!1;case 3:return 48<=e&&e<=57?(this.pushBuffer(e),!0):e===45||e===43?(this.pushBuffer(e),this.lexState=4,!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(e)):!1;case 4:return 48<=e&&e<=57?(this.pushBuffer(e),!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(e)):!1;default:return!0}}finish(){this.feed(32),this.tryNotify()}feedS(e){switch(this.logger.include(0)&&this.logger.debug3("P: %s|%s|%s|%s",e,FO[this.parseState],this.curPoint,this.subPartStart),this.parseState){case 0:switch(e){case"M":this.isAbsolute=!0,this.parseState=1;break;case"m":this.isAbsolute=!1,this.parseState=1;break;case"L":this.isAbsolute=!0,this.parseState=3;break;case"l":this.isAbsolute=!1,this.parseState=3;break;case"H":this.isAbsolute=!0,this.parseState=5;break;case"h":this.isAbsolute=!1,this.parseState=5;break;case"V":this.isAbsolute=!0,this.parseState=6;break;case"v":this.isAbsolute=!1,this.parseState=6;break;case"z":case"Z":{this.group.push(new me(this.curPoint,this.subPartStart));let r=this.tryNotify();return this.curPoint=this.subPartStart,r}case"C":this.isAbsolute=!0,this.parseState=7;break;case"c":this.isAbsolute=!1,this.parseState=7;break;case"S":this.isAbsolute=!0,this.parseState=20;break;case"s":this.isAbsolute=!1,this.parseState=20;break;case"A":this.isAbsolute=!0,this.parseState=13;break;case"a":this.isAbsolute=!1,this.parseState=13;break;case"Q":this.isAbsolute=!0,this.parseState=24;break;case"q":this.isAbsolute=!1,this.parseState=24;break;default:this.logger.warning3("unknow %s",e)}return!0;case 1:let t=this.tryNotify();return this.x=Is(e),this.parseState=2,t;case 2:{this.y=this.yAxis*Is(e);let r;return this.isAbsolute?r=new we(this.x,this.y):r=this.curPoint.add1(this.x,this.y),this.curPoint=r,this.subPartStart=r,this.parseState=3,!0}case 3:return this.x=parseFloat(e),isFinite(this.x)?(this.parseState=4,!0):(this.parseState=0,this.feedS(e));case 4:{this.y=this.yAxis*Is(e);let r;return this.isAbsolute?r=new we(this.x,this.y):r=this.curPoint.add1(this.x,this.y),this.group.push(new me(this.curPoint,r)),this.curPoint=r,this.parseState=3,!0}case 5:if(this.x=parseFloat(e),isFinite(this.x)){let r;return this.isAbsolute?r=new we(this.x,this.curPoint.y):r=this.curPoint.add1(this.x,0),this.group.push(new me(this.curPoint,r)),this.curPoint=r,!0}else return this.parseState=0,this.feedS(e);case 6:if(this.y=parseFloat(e),isFinite(this.y)){this.y=this.yAxis*this.y;let r;return this.isAbsolute?r=new we(this.curPoint.x,this.y):r=this.curPoint.add1(0,this.y),this.group.push(new me(this.curPoint,r)),this.curPoint=r,!0}else return this.parseState=0,this.feedS(e);case 7:let i=parseFloat(e);return isFinite(i)?(this.x1=i,this.parseState=8,!0):(e!=="s"&&e!=="S"&&(this.prevBezierCtrl2=null),this.parseState=0,this.feedS(e));case 8:return this.y1=this.yAxis*Is(e),this.parseState=9,!0;case 9:return this.x2=Is(e),this.parseState=10,!0;case 10:return this.y2=this.yAxis*Is(e),this.parseState=11,!0;case 11:return this.x=Is(e),this.parseState=12,!0;case 12:{this.y=this.yAxis*Is(e);let r,n,s;return this.isAbsolute?(r=new we(this.x1,this.y1),n=new we(this.x2,this.y2),s=new we(this.x,this.y)):(r=this.curPoint.add1(this.x1,this.y1),n=this.curPoint.add1(this.x2,this.y2),s=this.curPoint.add1(this.x,this.y)),this.prevBezierCtrl2=n,this.group.push(new ct([this.curPoint,r,n,s])),this.curPoint=s,this.parseState=7,!0}case 13:return this.rx=parseFloat(e),isFinite(this.rx)?(this.parseState=14,!0):(this.parseState=0,this.feedS(e));case 14:return this.ry=Is(e),this.parseState=15,!0;case 15:return this.rotation=Is(e),this.parseState=16,!0;case 16:return this.isLargeArc=Is(e)===1,this.parseState=17,!0;case 17:return this.sweep=Is(e)===1?td.CW:td.CCW,this.parseState=18,!0;case 18:return this.x=Is(e),this.parseState=19,!0;case 19:{this.y=this.yAxis*Is(e);let r;return this.isAbsolute?r=new we(this.x,this.y):r=this.curPoint.add1(this.x,this.y),this.rx&&this.ry&&this.group.push(Pe.build1(this.curPoint,r,this.rx,this.ry,this.isLargeArc,this.sweep)),this.curPoint=r,this.parseState=13,!0}case 20:return this.x2=parseFloat(e),isFinite(this.x2)?(this.parseState=21,!0):(e!=="s"&&e!=="S"&&(this.prevBezierCtrl2=null),this.parseState=0,this.feedS(e));case 21:return this.y2=this.yAxis*Is(e),this.parseState=22,!0;case 22:return this.x=Is(e),this.parseState=23,!0;case 23:{this.y=this.yAxis*Is(e);let r,n;this.isAbsolute?(r=new we(this.x2,this.y2),n=new we(this.x,this.y)):(r=this.curPoint.add1(this.x2,this.y2),n=this.curPoint.add1(this.x,this.y));let s;return this.prevBezierCtrl2?s=this.curPoint.add(this.curPoint.sub(this.prevBezierCtrl2)):s=this.curPoint,this.prevBezierCtrl2=r,this.group.push(new ct([this.curPoint,s,r,n])),this.curPoint=n,this.parseState=20,!0}case 24:return this.x1=parseFloat(e),isFinite(this.x1)?(this.parseState=25,!0):(e!=="s"&&e!=="S"&&(this.prevBezierCtrl2=null),this.parseState=0,this.feedS(e));case 25:return this.y1=this.yAxis*Is(e),this.parseState=26,!0;case 26:return this.x=Is(e),this.parseState=27,!0;case 27:{this.y=this.yAxis*Is(e);let r,n;return this.isAbsolute?(r=new we(this.x1,this.y1),n=new we(this.x,this.y)):(r=this.curPoint.add1(this.x1,this.y1),n=this.curPoint.add1(this.x,this.y)),this.prevBezierCtrl2=r,this.group.push(new ct([this.curPoint,r,n])),this.curPoint=n,this.parseState=24,!0}default:return this.logger.warning3("unsupported parse state %s",this.parseState),!0}}pushBuffer(e){this.buffer.write(e)}getCleanBuffer(){let e=this.buffer.toString();return this.buffer.clear(),e}tryNotify(){if(this.group.length===0)return!0;{let e=wi.build1(xV(this.group));return this.group.length=0,this.on(e)}}onException(e){throw e}},Kre=GT.fmtNumber,OL=class{constructor(e=!0){this.buffer=new Array,this.state=0,this.prev=null,this.yAxis=e?-1:1}encPl(e){for(let t of e.primitives)this.encPt(t);return this}encPt(e){if(e instanceof me)this.encLine1(e);else if(e instanceof Pe)this.encArc(e);else if(e instanceof ct)this.encBezier(e);else throw new Error("");return this}encBezier(e){if(e.controls.length===3){let t=e.controls[0],i=e.controls[1],r=e.controls[2];this.state===0?this.buffer.push("M",t.x,this.yAxis*t.y,"Q",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y):t.equals1(this.prev)?this.state!==4?this.buffer.push("Q",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y):this.buffer.push(i.x,this.yAxis*i.y,r.x,this.yAxis*r.y):this.buffer.push("L",t.x,this.yAxis*t.y,"Q",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y),this.prev=r,this.state=4}else if(e.controls.length===4){let t=e.controls[0],i=e.controls[1],r=e.controls[2],n=e.controls[3];this.state===0?this.buffer.push("M",t.x,this.yAxis*t.y,"C",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y,n.x,this.yAxis*n.y):t.equals1(this.prev)?this.state!==3?this.buffer.push("C",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y,n.x,this.yAxis*n.y):this.buffer.push(i.x,this.yAxis*i.y,r.x,this.yAxis*r.y,n.x,this.yAxis*n.y):this.buffer.push("L",t.x,this.yAxis*t.y,"C",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y,n.x,this.yAxis*n.y),this.prev=n,this.state=3}else throw new Error("only bezier has 3 or 4 control points supported");return this}encArc(e){let t=e.svgEnd;return this.state===0?this.buffer.push("M",e.start().x,this.yAxis*e.start().y,"A",e.rx,e.ry,0,e.isLarge()?1:0,e.sweep()===td.CCW?0:1,t.x,this.yAxis*t.y):e.start().equals1(this.prev)?this.state!==2?this.buffer.push("A",e.rx,e.ry,0,e.isLarge()?1:0,e.sweep()===td.CCW?0:1,t.x,this.yAxis*t.y):this.buffer.push(e.rx,e.ry,0,e.isLarge()?1:0,e.sweep()===td.CCW?0:1,t.x,this.yAxis*t.y):this.buffer.push("L",e.start().x,this.yAxis*e.start().y,"A",e.rx,e.ry,0,e.isLarge()?1:0,e.sweep()===td.CCW?0:1,t.x,this.yAxis*t.y),this.prev=t,this.state=2,this}encLine1(e){return this.encLine2(e.start(),e.end()),this}encLine2(e,t){return this.state===0?this.buffer.push("M",e.x,this.yAxis*e.y,"L",t.x,this.yAxis*t.y):(this.state!==1&&this.buffer.push("L"),e.equals1(this.prev)?this.buffer.push(t.x,this.yAxis*t.y):this.buffer.push(e.x,this.yAxis*e.y,t.x,this.yAxis*t.y)),this.prev=t,this.state=1,this}close(e){return this.state!==0&&(e&&this.buffer.push("Z"),this.state=0,this.prev=null),this}fixNumber(e=4){return this.buffer.forEach((t,i,r)=>{typeof t=="number"&&(t|0)!==t&&(r[i]=+t.toFixed(e))}),this}toString(){return this.buffer.join(" ")}toArray(){return this.buffer}},_V=class extends aI{constructor(){super(),this.lockConfig=[],this.hideConfig=[],this.invisibleConfig=[],this.coverConfig={},this.commentConfig={},this.trnCtrlConfig={},this.transformConfig={},this.fontCache={},this.cache={},this.zIndex=0,this.zIndexMap=new Map}onParseLine(e){let t=e[0];switch(t){case"DOCTYPE":this.parseDocType(e);break;case"HEAD":this.parseHead(e);break;case"LOCK":this.parseLock(e);break;case"HIDE":this.parseHide(e);break;case"INVISIBLE":this.parseInvisible(e);break;case"COVER":this.parseCover(e);break;case"TRN_CTRL":this.parseTrnCtrl(e);break;case"COMMENT":this.parseComment(e);break;case"FONT_CACHE":this.parseFontCache(e);break;case"TRANSFORM":this.parseTransform(e);break;case"GROUP":{let i=e[1];this.cache[t]||(this.cache[t]={errorIds:[]}),i!==null&&!this.cache[t][i]?this.cache[t][i]=e:this.cache[t].errorIds.push(e);break}case"POLY":case"STRING":case"AUXLINE":case"DIMENSION":{this.zIndexMap.set(e[1],++this.zIndex);let i=Qy(e[1]);this.cache[t]||(this.cache[t]={errorIds:[]}),i!==null&&!this.cache[t][i]?this.cache[t][i]=e:this.cache[t].errorIds.push(e);break}default:console.warn("can not find hanlder with",e)}}getZIndex(e){var t;return(t=this.zIndexMap.get(e))!=null?t:null}secondParseLine(e){switch(e[0]){case"GROUP":this.parseGroup(e);break;case"POLY":this.parsePoly(e);break;case"STRING":this.parseString(e);break;case"AUXLINE":this.parseAuxLine(e);break;case"DIMENSION":this.parseDimension(e);break}}onParseEnd(){for(let e in this.cache){let t=this.cache[e],i=Object.keys(t).sort((n,s)=>Number(n)-Number(s)),r=0;for(let n of i){if(n==="errorIds")continue;let s=Number(n),a=s-r-1;a>=1&&this.onPHolder(e,a),r=s,this.secondParseLine(t[s])}t.errorIds.forEach(n=>this.secondParseLine(n))}this.clearCache()}clearCache(){this.lockConfig=[],this.hideConfig=[],this.invisibleConfig=[],this.coverConfig={},this.commentConfig={},this.trnCtrlConfig={},this.transformConfig={},this.fontCache={},this.cache={},this.version=void 0}parseDocType(e){this.version=Number(e[2])}parseHead(e){this.version<2&&e[1]&&e[1].print==="AHead Side"&&(e[1].print="Ahead Side"),this.onCanvas(e[1])}parseGroup(e){this.onGroup(e[1],e[2],e[3],!!e[4],!!e[5])}parseLock(e){this.lockConfig.push(...e[1])}parseHide(e){this.hideConfig.push(...e[1])}parseInvisible(e){this.invisibleConfig.push(...e[1])}parseCover(e){this.coverConfig[e[1]]=e[2]}parseTrnCtrl(e){this.trnCtrlConfig[e[1]]={scope:e[2],trans_print:e[3],trans_white:e[4]}}parseComment(e){this.commentConfig[e[1]]=e[2]}matrix2svg(e){let[t,i,r,n,s,a,o,l,c]=e.data;return[t,i,n,s,o,l]}encPath(e){let t=new Array;return new LL(i=>(t.push(new OL(!0).encPl(i).toArray().slice(1)),!0),!0).parse(e),t}parseRect(e){var t,i,r,n,s,a,o,l;let[,c,,u,h,d,p,f,m,,,g,b]=e,y=g[0],E=y[1],S=-y[2],w=y[1]+y[3],x=-y[2]+y[4],I=y[5],A=y[6],O=+y[7],R=+y[8],M=hr.scale(w-E,x-S).rotateD(-O);R&&(M=M.multiply3(hr.MIRROR_X)),M=M.translate(E,S),M=this.matrix2svg(M),M=this.encMatrix(M),this.onPoly(c,0,u,-O,h,d,p,f,m,!0,[["R",0,0,1,1,I,A,0,0]],!0,!0,this.lockConfig.some(F=>F===e[1]),this.hideConfig.some(F=>F===e[1]),this.invisibleConfig.some(F=>F===e[1]),u===1?1:(t=this.coverConfig[e[1]])!=null?t:null,b||((i=this.commentConfig[e[1]])!=null?i:null),u===2?3:(n=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?n:null,u===2?m:(a=(s=this.trnCtrlConfig[e[1]])==null?void 0:s.trans_print)!=null?a:null,u===2?1-m:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,M!=null?M:null)}parseObj(e){var t,i,r,n,s,a,o,l;let[,c,,u,h,d,p,f,m,,,g,b]=e,[y,E,S,w,x,I,A,O,R]=g[0],M=hr.rotateD(O);R&&(M=M.multiply3(hr.MIRROR_X));let F;R?F=new me(new we(0,0),new we(0,-x)).multiply3(M):F=new me(new we(0,0),new we(w,0)).multiply3(M);let G=F.end().angleD(F.start()),V=R===1;w=R===1?x:w,x=R===1?w:x;let q=hr.scale(w,x).rotateD(-G);V&&(q=q.multiply3(hr.MIRROR_X)),q=q.translate(E,-S),q=this.matrix2svg(q),q=this.encMatrix(q),this.onPoly(c,0,u,-G,h,d,p,f,m,!0,[["R",0,0,1,1,0,0,0,0]],!1,!1,this.lockConfig.some(C=>C===e[1]),this.hideConfig.some(C=>C===e[1]),this.invisibleConfig.some(C=>C===e[1]),u===1?1:(t=this.coverConfig[e[1]])!=null?t:null,b||((i=this.commentConfig[e[1]])!=null?i:null),u===2?3:(n=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?n:null,u===2?m:(a=(s=this.trnCtrlConfig[e[1]])==null?void 0:s.trans_print)!=null?a:null,u===2?1-m:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,q!=null?q:null)}parseEllipse(e){var t,i,r,n,s,a,o,l;let[,c,,u,h,d,p,f,m,,,g,b]=e,y=g[0],E=y[1],S=-y[2],w=y[3],x=y[4],I=+y[5],A=+y[6],O=hr.scale(w,x).rotateD(-I);A&&(O=O.multiply3(hr.MIRROR_X)),O=O.translate(E,S),O=this.matrix2svg(O),O=this.encMatrix(O),this.onPoly(c,0,u,-I,h,d,p,f,m,!0,[["ELLIPSE",0,0,1,1,0,0]],!0,!0,this.lockConfig.some(R=>R===e[1]),this.hideConfig.some(R=>R===e[1]),this.invisibleConfig.some(R=>R===e[1]),u===1?1:(t=this.coverConfig[e[1]])!=null?t:null,b||((i=this.commentConfig[e[1]])!=null?i:null),u===2?3:(n=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?n:null,u===2?m:(a=(s=this.trnCtrlConfig[e[1]])==null?void 0:s.trans_print)!=null?a:null,u===2?1-m:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,O!=null?O:null)}parsePolyGroup(e){var t,i,r,n,s,a,o,l;let[,c,,u,h,d,p,f,m,,,g,b]=e,y=!0,E=!0,S=this.decMultiPoly(g).d;this.onPoly(c,0,u,0,h,d,p,f,m,!0,this.encPath(S),y,E,this.lockConfig.some(w=>w===e[1]),this.hideConfig.some(w=>w===e[1]),this.invisibleConfig.some(w=>w===e[1]),u===1?1:(t=this.coverConfig[e[1]])!=null?t:null,b||((i=this.commentConfig[e[1]])!=null?i:null),u===2?3:(n=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?n:null,u===2?m:(a=(s=this.trnCtrlConfig[e[1]])==null?void 0:s.trans_print)!=null?a:null,u===2?1-m:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,null)}parsePoly(e){var t,i,r,n,s,a,o,l,c,u;if(this.version<2)if(e[11].length===1)switch(e[11][0][0]){case"R":{let h=e[7];return h.startsWith("data:")||h.startsWith("blob:")?this.parseObj(e):this.parseRect(e)}case"ELLIPSE":return this.parseEllipse(e);default:return this.parsePolyGroup(e)}else return this.parsePolyGroup(e);else this.onPoly(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],!!(e[12]||e[12]===void 0),!!(e[13]||e[13]===void 0),this.lockConfig.some(h=>h===e[1]),this.hideConfig.some(h=>h===e[1]),this.invisibleConfig.some(h=>h===e[1]),(t=this.coverConfig[e[1]])!=null?t:null,(i=this.commentConfig[e[1]])!=null?i:null,(n=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?n:null,(a=(s=this.trnCtrlConfig[e[1]])==null?void 0:s.trans_print)!=null?a:null,(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,(u=(c=this.transformConfig[e[1]])==null?void 0:c.matrix)!=null?u:null)}decMultiPoly(e){let t=new to,i=e.map(r=>{let n="";return new LL(s=>(t.ext1(s.bbox()),n=new OL().encPl(s).toString(),!1),!1).parse("M"+r.join(" ")),n}).join(" ");return{bbox:t.build(),d:i}}encMatrix(e){let[t,i,r,n,s,a]=e,o=new hr([t,i,0,r,n,0,s,a,1]);o=hr.MIRROR_Y.multiply3(o).multiply3(hr.MIRROR_Y);let[l,c,u,h,d,p,f,m,g]=o.data;return[l,h,f,c,d,m]}parseString(e){var t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E;if(this.version<2){let[,S,w,x,I,A,O,R,M,F,G,V,q,C,N,T,L,P,B,U]=e;A=qs(A);let X=M;R=R===1,q=q===1,C=C===1,N=N===1;let J=-(T[15]/3|0)+2,ne=T%3;B=B||1,U=U||1;let fe=this.fontCache[e[1]],{bbox:xe,d:ve}=this.decMultiPoly(fe),Fe=xe.width(),Ne=xe.height();Ne=Ne||0,Fe=Fe||0;let nt=0;switch(ne){case 1:nt=-Fe/2;break;case 2:nt=-Fe;break}let je=0;switch(J){case 1:je=Ne/2;break;case 0:je=Ne;break}let vt=hr.translate(nt,je).scale(B,U).rotateD(-O);R&&(vt=vt.multiply3(hr.MIRROR_X)),vt=vt.translate(I,A);let Bt=this.matrix2svg(vt),Oi=this.encMatrix(Bt);this.onString(S,w,x,O,X,F,G,V,q,C,N,((-J||0)+2)*3+(ne||0),L,P,this.lockConfig.some(Ti=>Ti===e[1]),this.hideConfig.some(Ti=>Ti===e[1]),this.invisibleConfig.some(Ti=>Ti===e[1]),x===1?1:(t=this.coverConfig[e[1]])!=null?t:null,(i=this.commentConfig[e[1]])!=null?i:null,x===2?3:(n=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?n:null,x===2?P:(a=(s=this.trnCtrlConfig[e[1]])==null?void 0:s.trans_print)!=null?a:null,x===2?1-P:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,Oi,!!Oi,this.encPath(ve))}else this.onString(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9]===1,e[10]===1,e[11]===1,e[12],e[13],e[14],this.lockConfig.some(S=>S===e[1]),this.hideConfig.some(S=>S===e[1]),this.invisibleConfig.some(S=>S===e[1]),(c=this.coverConfig[e[1]])!=null?c:null,(u=this.commentConfig[e[1]])!=null?u:null,(d=(h=this.trnCtrlConfig[e[1]])==null?void 0:h.scope)!=null?d:null,(f=(p=this.trnCtrlConfig[e[1]])==null?void 0:p.trans_print)!=null?f:null,(g=(m=this.trnCtrlConfig[e[1]])==null?void 0:m.trans_white)!=null?g:null,(y=(b=this.transformConfig[e[1]])==null?void 0:b.matrix)!=null?y:null,!!((E=this.transformConfig[e[1]])!=null&&E.matrix),this.fontCache[e[1]])}parseFontCache(e){this.fontCache[e[1]]=e[2]}parseDimension(e){var t,i,r,n,s,a,o,l,c,u,h,d;this.onDimension(e[1],e[2],e[3],(t=e[4])!=null?t:null,e[5],e[6],e[7],e[8],this.lockConfig.some(p=>p===e[1]),this.hideConfig.some(p=>p===e[1]),this.invisibleConfig.some(p=>p===e[1]),(i=this.coverConfig[e[1]])!=null?i:null,(r=this.commentConfig[e[1]])!=null?r:null,(s=(n=this.trnCtrlConfig[e[1]])==null?void 0:n.scope)!=null?s:null,(o=(a=this.trnCtrlConfig[e[1]])==null?void 0:a.trans_print)!=null?o:null,(c=(l=this.trnCtrlConfig[e[1]])==null?void 0:l.trans_white)!=null?c:null,(h=(u=this.transformConfig[e[1]])==null?void 0:u.matrix)!=null?h:null,!!((d=this.transformConfig[e[1]])!=null&&d.matrix))}parseTransform(e){this.transformConfig[e[1]]={matrix:e[2],strokes:!!e[3]}}parseAuxLine(e){var t,i,r,n,s,a,o,l,c,u,h;this.onAuxLine(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],this.lockConfig.some(d=>d===e[1]),this.hideConfig.some(d=>d===e[1]),this.invisibleConfig.some(d=>d===e[1]),(t=this.coverConfig[e[1]])!=null?t:null,(i=this.commentConfig[e[1]])!=null?i:null,(n=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?n:null,(a=(s=this.trnCtrlConfig[e[1]])==null?void 0:s.trans_print)!=null?a:null,(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,(u=(c=this.transformConfig[e[1]])==null?void 0:c.matrix)!=null?u:null,!!((h=this.transformConfig[e[1]])!=null&&h.matrix))}},PV=class extends aI{constructor(e={},t=[]){super(),this.symbolPartIds=e,this.device=t,this.defaultPartId="pid8a0e77bacb214e",this.curPart="",this.onlyPart="",this.partIdMap={},this.fontStyleIndex={},this.lineStyleIndex={},this.groupIndex={},this.zIndex=0,this.zIndexMap=new Map,this.cache={},this.errorIds={},this.tableCell={},this.hasPart=!1,this.components={},this.busEntryMap={},this.defaultLineStyle={strokeColor:null,strokeStyle:null,fillColor:null,strokeWidth:null,fillStyle:null},this.defaultFontStyle={color:null,fillColor:null,fontFamily:null,fontSize:null,strikeout:null,underline:null,italic:null,fontWeight:null,hAlign:null,vAlign:null}}getZIndex(e){var t;return(t=this.zIndexMap.get(e))!=null?t:null}transPinAttrKey(e){switch(e){case"NUMBER":{e="Pin Number";break}case"NAME":{e="Pin Name";break}}return e}transFontStyle(e){return{color:e.color,fillColor:e.fillColor,fontFamily:e.fontFamily,fontSize:e.fontSize,strikeout:e.strikeout,underline:e.underline,italic:e.italic,fontWeight:e.fontWeight,align:this.transAlign(e.vAlign,e.hAlign)}}transTableFontStyle(e){return{color:e.color,fillColor:e.fillColor,fontFamily:e.fontFamily,fontSize:e.fontSize,strikeout:e.strikeout,underline:e.underline,italic:e.italic,fontWeight:e.fontWeight,vAlign:this.transVAlign(e.vAlign),hAlign:this.transHAlign(e.hAlign)}}transVAlign(e){switch(e=e&&Number(e),e){case 0:return"TOP";case 1:return"MIDDLE";case 2:return"BOTTOM";default:return null}}transHAlign(e){switch(e=e&&Number(e),e){case 0:return"LEFT";case 1:return"CENTER";case 2:return"RIGHT";default:return null}}transAlign(e,t){if(e=e&&Number(e),t=t&&Number(t),t===0)switch(e){case 0:return"LEFT_TOP";case 1:return"LEFT_MIDDLE";case 2:return"LEFT_BOTTOM";default:return"LEFT_BOTTOM"}if(t===1)switch(e){case 0:return"CENTER_TOP";case 1:return"CENTER_MIDDLE";case 2:return"CENTER_BOTTOM";default:return"CENTER_BOTTOM"}if(t===2)switch(e){case 0:return"RIGHT_TOP";case 1:return"RIGHT_MIDDLE";case 2:return"RIGHT_BOTTOM";default:return"RIGHT_BOTTOM"}switch(e){case 0:return"LEFT_TOP";case 1:return"LEFT_MIDDLE";case 2:return"LEFT_BOTTOM";default:return null}}transStrokeStyle(e){switch(e=e&&Number(e),e){case 0:return"SOLID";case 1:return"SHORT_DASH";case 2:return"DOT";case 3:return"DOT_DASH";default:return null}}transFillStyle(e){switch(e=e&&Number(e),e){case 0:return"NONE";case 1:return"SOLID";case 2:return"GRID";case 3:return"HORIZONTAL_LINE";case 4:return"VERTICAL_LINE";case 5:return"RHOMBIC";case 6:return"LEFT_SLASH_LINE";case 7:return"RIGHT_SLASH_LINE";default:return null}}transPinShape(e){switch(e=e&&Number(e),e){case 0:return"NONE";case 1:return"CLOCK";case 2:return"INVERTED";case 3:return"INVERTED_CLOCK";default:return"NONE"}}onParseLine(e){var t,i;let r=e[0];switch(r){case"DOCTYPE":this.parseDocType(e);break;case"HEAD":this.parseHead(e);break;case"GROUP":this.parseGroup(e);break;case"FONTSTYLE":this.parseFontStyle(e);break;case"LINESTYLE":this.parseLineStyle(e);break;case"TERM":break;case"PART":this.hasPart=!0,this.parsePart(e);break;case"TABEL_CELL":this.parseTableCell(e);break;case"BUSENTRY":{this.parseBusEntry(e);break}case"WIRE":case"BUS":case"TEXT":case"POLY":case"CIRCLE":case"ARC":case"RECT":case"PIN":case"OBJ":case"COMPONENT":case"ELLIPSE":case"BEZIER":case"TABLE":{this.zIndexMap.set(e[1],++this.zIndex);let n=Qy(e[1]);this.cache[r]||(this.cache[r]={}),n!==null&&!this.cache[r][n]?this.cache[r][n]={part:this.curPart,value:e}:(this.errorIds[r]||(this.errorIds[r]=[]),this.errorIds[r].push({part:this.curPart,value:e}));break}case"ATTR":{this.zIndexMap.set(e[1],++this.zIndex),e[3]==="Symbol"&&(this.components[e[2]]||(this.components[e[2]]={symbol:"",device:""}),this.components[e[2]].symbol=e[4]),e[3]==="Device"&&(this.components[e[3]]||(this.components[e[3]]={symbol:"",device:""}),this.components[e[3]].device=e[4]);let n=Object.keys(((t=this.cache)==null?void 0:t.COMPONENT)||{}).find(o=>this.cache.COMPONENT[o].value[1]===e[2]);if(n){let o=this.cache.COMPONENT[n];o.attr||(o.attr=[]),o.attr.push({part:this.curPart,value:e});break}let s=Object.keys(((i=this.cache)==null?void 0:i.PIN)||{}).find(o=>this.cache.PIN[o].value[1]===e[2]);if(s){let o=this.cache.PIN[s];o.attr||(o.attr=[]),o.attr.push({part:this.curPart,value:e});break}let a=Qy(e[1]);this.cache[r]||(this.cache[r]={}),a!==null&&!(this.cache[r][a]&&this.cache[r][a].value[1]!==e[1])?this.cache[r][a]||(this.cache[r][a]={part:this.curPart,value:e}):(this.errorIds[r]||(this.errorIds[r]=[]),this.errorIds[r].push({part:this.curPart,value:e}));break}default:console.warn("can not find hanlder with",e)}}secondParseLine(e){switch(e[0]){case"DOCTYPE":case"HEAD":case"GROUP":case"FONTSTYLE":case"LINESTYLE":break;case"ATTR":this.parseAttr(e);break;case"WIRE":this.parseWire(e);break;case"BUS":this.parseBus(e);break;case"TEXT":this.parseText(e);break;case"POLY":this.parsePoly(e);break;case"CIRCLE":this.parseCircle(e);break;case"ARC":this.parseArc(e);break;case"BUSENTRY":break;case"RECT":this.parseRect(e);break;case"PIN":this.parsePin(e);break;case"OBJ":this.parseObj(e);break;case"COMPONENT":this.parseComponent(e);break;case"ELLIPSE":this.parseEllipse(e);break;case"BEZIER":this.parseBezier(e);break;case"TABLE":this.parseTable(e);break;case"TABEL_CELL":break}}onParseEnd(){this.docType==="SYMBOL"&&!this.hasPart&&(this.curPart=this.defaultPartId,this.onlyPart=this.curPart,this.partIdMap[""]=this.curPart,this.onPart(this.curPart,{title:""}));for(let e in this.cache){let t=this.cache[e],i=Object.keys(t).sort((n,s)=>Number(n)-Number(s)),r=0;for(let n of i){let s=Number(n),a=s-r-1;a>=1&&this.onPHolder(e,a),r=s,this.curPart=this.hasPart?t[s].part||this.onlyPart:this.curPart,this.secondParseLine(t[s].value),t[s].attr&&t[s].attr.forEach(o=>{this.curPart=this.hasPart?o.part||this.onlyPart:this.curPart,this.secondParseLine(o.value)})}if(this.errorIds[e])for(let n of this.errorIds[e])this.curPart=this.hasPart?n.part||this.onlyPart:this.curPart,this.secondParseLine(n.value)}this.clearCache()}clearCache(){this.fontStyleIndex={},this.lineStyleIndex={},this.groupIndex={},this.cache={},this.errorIds={},this.curPart="",this.components={},this.tableCell={},this.hasPart=!1,this.version=void 0,this.docType=void 0}parseDocType(e){this.docType=e[1];let t=parseFloat(e[2]);this.version=t}parseHead(e){this.onCanvas(e[1])}parseFontStyle(e){this.fontStyleIndex[e[1]]={color:e[3]===""?"none":e[3],fillColor:e[2],fontFamily:e[4],fontSize:typeof e[5]=="number"?e[5]:null,strikeout:e[9]===null?null:e[9]===1,underline:e[8]===null?null:e[8]===1,italic:e[6]===null?null:e[6]===1,fontWeight:e[7]===null?null:e[7]===1,vAlign:e[10],hAlign:e[11]}}parseLineStyle(e){this.lineStyleIndex[e[1]]={strokeColor:e[2],strokeStyle:this.transStrokeStyle(e[3]),fillColor:e[4]===""?"none":e[4],strokeWidth:e[5],fillStyle:this.transFillStyle(e[6])}}getGroupId(e){let t=this;for(let i in t.groupIndex){let r=t.groupIndex[i];if(r!=null&&r.includes(e))return i}return""}parseBezier(e){let t=this.lineStyleIndex[e[3]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);for(let r=0;r<e[2].length;r+=2)e[2][r+1]=qs(e[2][r+1]);this.onBezier(e[1],this.curPart,i,!!e[4],e[2],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseGroup(e){this.groupIndex[e[1]]=e[4]||[],this.onGroup(e[1],e[2]||"",e[3]||"")}parseBus(e){let t=this.lineStyleIndex[e[3]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=e[2]||[],r=this.getGroupId(e[1]);this.onBus(e[1],this.curPart,r,!!e[4],i,t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle,this.busEntryMap[e[1]]||{})}parseWire(e){let t=this.lineStyleIndex[e[3]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=e[2]||[],r=this.getGroupId(e[1]);this.onWire(e[1],this.curPart,r,!!e[4],i,t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseText(e){let t=this.fontStyleIndex[e[6]];t||(t=this.defaultFontStyle,console.warn("font not found",e));let i=this.transFontStyle(t),r=this.getGroupId(e[1]);this.onText(e[1],this.curPart,r,!!e[7],e[2],e[3],e[4],e[5],i.color,i.fillColor,i.fontFamily,i.fontSize,i.strikeout,i.underline,i.italic,i.fontWeight,i.align)}parsePoly(e){let t=this.lineStyleIndex[e[4]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onPoly(e[1],this.curPart,i,!!e[5],e[2]||[],!!e[3],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseCircle(e){let t=this.lineStyleIndex[e[5]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onCircle(e[1],this.curPart,i,!!e[6],e[2],e[3],e[4],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseArc(e){let t=this.lineStyleIndex[e[8]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onArc(e[1],this.curPart,i,!!e[9],e[2],e[3],e[4],e[5],e[6],e[7],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseBusEntry(e){let t=e[2],i={groupId:this.getGroupId(e[1]),locked:!1,zIndex:++this.zIndex,order:e[3],pointX:e[4],pointY:qs(e[5]),rotation:e[6]};this.busEntryMap[t]||(this.busEntryMap[t]={}),this.busEntryMap[t][e[1]]=i}parseRect(e){let t=this.lineStyleIndex[e[9]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onRect(e[1],this.curPart,i,!!e[10],e[2],e[3],e[4],e[5],e[6],e[7],e[8],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parsePin(e){let t=this.getGroupId(e[1]);this.onPin(e[1],this.curPart,t,!!e[10],!!e[2],e[3],e[4],e[5],e[6],e[7],e[8],this.transPinShape(e[9]))}parseObj(e){let t=this.getGroupId(e[1]);this.version>=1.1?this.onObj(e[1],this.curPart,t,!!e[10],e[2],e[3],e[4],e[5],e[6],e[7],!!e[8],e[9]):this.onObj(e[1],this.curPart,t,!!e[10],e[2],e[4],e[5],e[6],e[7],e[8],!1,`data:${e[3]},${e[9]}`)}parseComponent(e){var t,i,r;let n=this.getGroupId(e[1]),s=e[2],a=this.components[e[1]];if(a){if(a.symbol){let o=this.symbolPartIds[a.symbol];o&&(s=o[e[2]]||e[2]||o[(t=Object.keys(o))==null?void 0:t[0]]||"")}else if(a.device){let o=this.device.find(c=>c.uuid===a.device),l=o?this.symbolPartIds[(i=o==null?void 0:o.attributes)==null?void 0:i.Symbol]:null;l&&(s=l[e[2]]||e[2]||l[(r=Object.keys(l))==null?void 0:r[0]]||"")}}this.onComponent(e[1],!!e[8],s,n,e[3],e[4],e[5],e[6]===1,e[7])}parseEllipse(e){let t=this.lineStyleIndex[e[7]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onEllipse(e[1],this.curPart,i,!!e[8],e[2],e[3],e[4],e[5],e[6],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseTable(e){let t=this.getGroupId(e[1]);this.onTable(e[1],this.curPart,t,e[2],e[3],e[4],e[5],e[6],e[7],e[8],this.tableCell[e[1]]||[])}parseTableCell(e){let t=this.lineStyleIndex[e[8]],i=this.lineStyleIndex[e[9]],r=this.lineStyleIndex[e[10]],n=this.lineStyleIndex[e[11]],s=this.fontStyleIndex[e[12]],a=Object.assign({},s);a.color=s.fillColor,a.fillColor=s.color,(!t||!i||!r||!n||!a)&&console.warn("style not found",e);let o={id:e[1],value:e[3],rowIndex:e[4],columnIndex:e[5],rowSpan:e[6],colSpan:e[7],topStyle:t||this.defaultLineStyle,rightStyle:i||this.defaultLineStyle,bottomStyle:r||this.defaultLineStyle,leftStyle:n||this.defaultLineStyle,fontStyle:this.transTableFontStyle(a||this.defaultFontStyle),lineHeight:e[13],zIndex:++this.zIndex};this.tableCell[e[2]]||(this.tableCell[e[2]]=[]),this.tableCell[e[2]].push(o)}parseAttr(e){let t=this.fontStyleIndex[e[10]];t||(t=this.defaultFontStyle,console.warn("fontStyle not found",e));let i=this.transFontStyle(t),r=this.getGroupId(e[1]);this.onAttr(e[1],this.curPart,r,!!e[11],e[2]||"",this.transPinAttrKey(String(e[3])),e[4],e[5]===null?null:!!e[5],e[6]===null?null:!!e[6],e[7]!==null?e[7]:null,e[8]!==null?e[8]:null,e[9],i.color,i.fillColor,i.fontFamily,i.fontSize,i.strikeout,i.underline,i.italic,i.fontWeight,i.align)}parsePart(e){this.curPart=e[1]||this.defaultPartId,this.onlyPart=this.curPart,this.partIdMap[e[1]]=this.curPart;let t=Object.assign(e[2]||{},{title:e[1]||""});this.onPart(this.curPart,t)}},LV=class{constructor(){}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}encodeGroup(e,t){return{id:e,dataType:"GROUP",data:JSON.stringify(t)}}encodeAuxLine(e,t){return{id:e,dataType:"AUXLINE",data:JSON.stringify(t)}}encodeDimension(e,t){return{id:e,dataType:"DIMENSION",data:JSON.stringify(t)}}encodeString(e,t){return{id:e,dataType:"STRING",data:JSON.stringify(t)}}encodePoly(e,t){return{id:e,dataType:"POLY",data:JSON.stringify(t)}}},GO=class{constructor(){}editHead(e,t){let i={uuid:e.uuid,nickname:e.nickname,username:e.username,updateTime:t};return`${JSON.stringify({type:"EDIT_HEAD"})}||${JSON.stringify(i)}`}head(e){return wp(this.doctype,e.client,e.doc,e.updateTime,e.version||String(e.updateTime),e.user,e.ticket)}creator(e,t){let i=typeof t=="string"?t:JSON.stringify(t);return To("META_CREATE",e,"META_CREATE",i)}modifier(e,t){let i=typeof t=="string"?t:JSON.stringify(t);return To("META_MODIFY",e,"META_MODIFY",i)}delete(e,t){let i=t||JSON.stringify({isDelete:!0});return To("DELETE_DOC",e,"DELETE_DOC",i)}},fI=class extends GO{constructor(){super(...arguments),this.doctype="BLOB"}buildStr(e,t,i){let r=typeof i=="string"?i:JSON.stringify(this.buildData(i));return To("BLOB",e,t,r)}buildData(e){return{filename:e.filename,content:e.content}}};var UO=class{constructor(){}encodeString(e,t){return{id:e,dataType:"STRING",data:JSON.stringify(t)}}encodeAttr(e,t){return{id:e,dataType:"ATTR",data:JSON.stringify(t)}}encodePanelize(e){return{id:"PANELIZE",dataType:"PANELIZE",data:JSON.stringify(e)}}encodeRuleSelector(e){let t=JSON.stringify(["RULE_SELECTOR",e.ruleSelect]),i={...e};return delete i.ruleSelect,{id:t,dataType:"RULE_SELECTOR",data:JSON.stringify(i)}}encodeRule(e){let t=JSON.stringify(["RULE",e.ruleType,e.ruleName]),i={...e};return delete i.ruleType,delete i.ruleName,{id:t,dataType:"RULE",data:JSON.stringify(i)}}encodeRuleTemplate(e){return{id:"RULE_TEMPLATE",dataType:"RULE_TEMPLATE",data:JSON.stringify(e)}}encodeDimension(e,t){return{id:e,dataType:"DIMENSION",data:JSON.stringify(t)}}encodeBoss(e,t){return{id:e,dataType:"BOSS",data:JSON.stringify(t)}}encodeShellEntity(e,t){return{id:e,dataType:"SHELL_ENTITY",data:JSON.stringify(t)}}encodeShellCut(e,t){return{id:e,dataType:"SHELLCUT",data:JSON.stringify(t)}}encodeCrease(e,t){return{id:e,dataType:"CREASE",data:JSON.stringify(t)}}encodeShell(e,t){return{id:e,dataType:"SHELL",data:JSON.stringify(t)}}encodeFpcFill(e,t){return{id:e,dataType:"FPC_FILL",data:JSON.stringify(t)}}encodeTeardrop(e,t){return{id:e,dataType:"TEARDROP",data:JSON.stringify(t)}}encodeImage(e,t){return{id:e,dataType:"IMAGE",data:JSON.stringify(t)}}encodePoured(e,t){return{id:vo(e,"POURED"),dataType:"POURED",data:JSON.stringify(t)}}encodePour(e,t){return{id:e,dataType:"POUR",data:JSON.stringify(t)}}encodeRegion(e,t){return{id:e,dataType:"REGION",data:JSON.stringify(t)}}encodeFill(e,t){return{id:e,dataType:"FILL",data:JSON.stringify(t)}}encodeLayerFill(e,t){return{id:vo(e,"LAYER_FILL"),dataType:"LAYER_FILL",data:JSON.stringify(t)}}encodePoly(e,t){return{id:e,dataType:"POLY",data:JSON.stringify(t)}}encodeEQLenGrp(e,t){return{id:e,dataType:"EQLEN_GRP",data:JSON.stringify(t)}}encodeObj(e,t){return{id:e,dataType:"OBJ",data:JSON.stringify(t)}}encodeArc(e,t){return{id:e,dataType:"ARC",data:JSON.stringify(t)}}encodeLine(e,t){return{id:e,dataType:"LINE",data:JSON.stringify(t)}}encodePad(e,t){return{id:e,dataType:"PAD",data:JSON.stringify(t)}}encodeVia(e,t){return{id:e,dataType:"VIA",data:JSON.stringify(t)}}encodePreference(e){return{id:"PREFERENCE",dataType:"PREFERENCE",data:JSON.stringify(e)}}encodeSilkOpts(e,t){return{id:vo(e,"SILK_OPTS"),dataType:"SILK_OPTS",data:JSON.stringify(t)}}encodeGroup(e,t){return{id:e,dataType:"GROUP",data:JSON.stringify(t)}}encodePrimitive(e,t){return{id:vo(e,"PRIMITIVE"),dataType:"PRIMITIVE",data:JSON.stringify(t)}}encodeNet(e,t){return{id:vo(e,"NET"),dataType:"NET",data:JSON.stringify(t)}}encodeActiveLayer(e){return{id:"ACTIVE_LAYER",dataType:"ACTIVE_LAYER",data:JSON.stringify(e)}}encodeLayerPhys(e,t){return{id:vo(e,"LAYER_PHYS"),dataType:"LAYER_PHYS",data:JSON.stringify(t)}}encodeLayer(e,t){return{id:vo(e,"LAYER"),dataType:"LAYER",data:JSON.stringify(t)}}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}},OV=class extends cU{constructor(e=!1){super(void 0,void 0,void 0,void 0,e),this.encode=new UO,this.maxTicket=0,this.blobEncode=new fI,this.blobData=[],this.encodeData="",this.placeholder=0}handleData(e){this.encodeData?this.encodeData=this.encodeData+`|
`+To(e.dataType,++this.maxTicket,e.id,e.data):this.encodeData=To(e.dataType,++this.maxTicket,e.id,e.data)}getZIndex(e){let t=e.match(sI);return t!=null&&t.length?t[1]:null}onPHolder(e,t){let i={dataType:e,max:t};this.handleData({id:`placeholder${++this.placeholder}`,dataType:"ELE_PLACEHOLDER",data:JSON.stringify(i)})}onLayerFill(e,t){this.handleData(this.encode.encodeLayerFill(e,t))}onString(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y){let E=this.getZIndex(e);this.handleData(this.encode.encodeString(ji(e),{groupId:i,layerId:r,x:n,y:s,text:a,fontFamily:o,fontSize:l,strokeWidth:c,bold:u,italic:h,origin:d,angle:p,reverse:f,expansion:m,mirror:g,locked:b,zIndex:E===null?null:Number(E),specialColor:y}))}onAttr(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E,S,w,x,I){let A=this.getZIndex(e);A&&x&&(A=A+"."+String(x)),this.handleData(this.encode.encodeAttr(ji(e),{groupId:i,parentId:r,layerId:n,x:s,y:a,key:o,value:l,keyVisible:c,valueVisible:u,fontFamily:h,fontSize:d,strokeWidth:p,bold:f,italic:m,origin:g,angle:b,reverse:y,expansion:E,mirror:S,locked:w,zIndex:A===null?null:Number(A),specialColor:I}))}onPadNet(e,t,i,r,n){}onComponent(e,t,i,r,n,s,a,o,l){}onPanelize(e,t,i,r,n,s,a,o,l,c){this.handleData(this.encode.encodePanelize({on:e,row:t,column:i,rowSpacing:r,columnSpacing:n,onlyOutline:s,horizontalStamp:a,verticalStamp:o,horizontalSize:l,verticalSize:c}))}onRuleSelector(e,t,i,r,n){this.handleData(this.encode.encodeRuleSelector({ruleSelect:e,ruleOrder:t,ruleKeyValue:i,copperValue:r,innerPlaneValue:n}))}onRule(e,t,i,r){this.handleData(this.encode.encodeRule({ruleType:e,ruleName:t,ruleState:i,ruleContext:r}))}onRuleTemplate(e){this.handleData(this.encode.encodeRuleTemplate({name:e}))}onDimension(e,t,i,r,n,s,a,o,l,c,u,h,d){let p=this.getZIndex(e);this.handleData(this.encode.encodeDimension(ji(e),{type:i,layerId:r,unit:n,strokeWidth:s,precision:a,textFollow:o,coords:l,locked:c,zIndex:p===null?null:Number(p),text:u,specialColor:h,groupId:d}))}onBoss(e,t,i,r,n,s,a,o,l,c,u,h,d){let p=this.getZIndex(e);this.handleData(this.encode.encodeBoss(ji(e),{groupId:i,layerId:r,centerX:n,centerY:s,specification:a,depth:o,thickness:l,holeDiameter:c,counterBore:u?{height:u[0],diameter:u[1]}:null,stiffener:h?{topWidth:h[0],bottomWidth:h[1],height:h[2],stiffThickness:h[3]}:null,locked:d,zIndex:p===null?null:Number(p)}))}onShellEntity(e,t,i,r,n,s,a,o,l,c,u,h){let d=this.getZIndex(e),p={groupId:i,layerId:r,type:n?"ENTITY":"SLOT",depth:o,strokeWidth:l,path:c,locked:u,zIndex:d===null?null:Number(d),refs:h};p.type==="ENTITY"&&(p.entityBelong=s),p.type==="SLOT"&&(p.slotOptions=a),this.handleData(this.encode.encodeShellEntity(ji(e),p))}onShellCut(e,t,i,r,n,s,a,o,l){let c=this.getZIndex(e);this.handleData(this.encode.encodeShellCut(ji(e),{groupId:i,layerId:r,depth:n,strokeWidth:s,path:a,locked:o,zIndex:c===null?null:Number(c),refs:l}))}onCrease(e,t,i,r,n,s,a,o,l,c){let u=this.getZIndex(e);this.handleData(this.encode.encodeCrease(ji(e),{groupId:i,layerId:r,startX:n,startY:s,endX:a,endY:o,angle:l,locked:c,zIndex:u===null?null:Number(u)}))}onShell(e,t,i,r,n,s,a,o,l,c){let u=this.getZIndex(e),h={groupId:i,shellType:r,shellHeight:n,pcbHeight:s,strokeWidth:a,path:o,thickness:l.Thickness,locked:c,zIndex:u===null?null:Number(u)};r==="DRAWER"&&(h.direction=l.Direction),r==="T&B"&&(h.bottomHeight=l.BottomHeight,h.topInnerHeight=l.TopInnerHeight,h.bottomInnerHeight=l.BottomInnerHeight),this.handleData(this.encode.encodeShell(ji(e),h))}onFpcFill(e,t,i,r,n,s,a,o){let l=this.getZIndex(e);this.handleData(this.encode.encodeFpcFill(ji(e),{groupId:i,layerId:r,material:n,thickness:s,path:a,locked:o,zIndex:l===null?null:Number(l)}))}onTeardrop(e,t,i,r,n,s,a){this.handleData(this.encode.encodeTeardrop(ji(e),{netName:i,layerId:r,path:n,groupId:s,refs:a,locked:!1}))}onImage(e,t,i,r,n,s,a,o,l,c,u,h,d){let p=this.getZIndex(e);this.handleData(this.encode.encodeImage(ji(e),{groupId:i,layerId:r,startX:n,startY:s,width:a,height:o,angle:l,mirror:c,path:u,locked:h,zIndex:p===null?null:Number(p),specialColor:d}))}onPoured(e,t){this.handleData(this.encode.encodePoured(ji(e),t))}onPour(e,t,i,r,n,s,a,o,l,c,u,h){let d=this.getZIndex(e);this.handleData(this.encode.encodePour(ji(e),{groupId:i,netName:r,layerId:n,width:s,name:a,order:o,path:l,pourType:c,keepIsland:u,locked:h,zIndex:d===null?null:Number(d)}))}onRegion(e,t,i,r,n,s,a,o,l,c){let u=this.getZIndex(e);this.handleData(this.encode.encodeRegion(ji(e),{groupId:i,layerId:r,width:n,prohibitType:s,path:a,locked:o,zIndex:u===null?null:Number(u),name:l,regionType:c}))}onFill(e,t,i,r,n,s,a,o,l,c,u){let h=this.getZIndex(e);this.handleData(this.encode.encodeFill(ji(e),{groupId:i,netName:r,layerId:n,width:s,fillStyle:a,path:o,locked:l,zIndex:h===null?null:Number(h),isBridgingCopper:!1,networkList:[],refs:c,specialColor:u}))}onPoly(e,t,i,r,n,s,a,o,l){let c=this.getZIndex(e);this.handleData(this.encode.encodePoly(ji(e),{groupId:i,netName:r,layerId:n,width:s,path:a,locked:o,zIndex:c===null?null:Number(c),specialColor:l,polyType:n==11?"BOARD_OUTLINE":"NORMAL"}))}onEQLenGrp(e,t,i,r){this.handleData(this.encode.encodeEQLenGrp(ji(e),{name:t,sort:i,pads:r}))}onObj(e,t,i,r,n,s,a,o,l,c,u,h,d,p){if(h.startsWith("data:")){let m=rE(h);this.blobData.push(this.blobEncode.buildStr(1,m,{filename:n,content:h})),h=`blob:${m}`}let f=this.getZIndex(e);this.handleData(this.encode.encodeObj(ji(e),{groupId:i,layerId:r,fileName:n,startX:s,startY:a,width:o,height:l,angle:c,mirror:u,path:h,locked:d,zIndex:f===null?null:Number(f),specialColor:p}))}onArc(e,t,i,r,n,s,a,o,l,c,u,h,d){let p=this.getZIndex(e);this.handleData(this.encode.encodeArc(ji(e),{groupId:i,netName:r,layerId:n,startX:s,startY:a,endX:o,endY:l,angle:c,width:u,locked:h,zIndex:p===null?null:Number(p),arcType:"DOT",specialColor:d}))}onCArc(e,t,i,r,n,s,a,o,l,c,u,h,d){let p=this.getZIndex(e);this.handleData(this.encode.encodeArc(ji(e),{groupId:i,netName:r,layerId:n,startX:s,startY:a,endX:o,endY:l,angle:c,width:u,locked:h,zIndex:p===null?null:Number(p),arcType:"CENT",specialColor:d}))}onLine(e,t,i,r,n,s,a,o,l,c,u){let h=this.getZIndex(e);this.handleData(this.encode.encodeLine(ji(e),{groupId:i,netName:r,layerId:n,startX:s,startY:a,endX:o,endY:l,width:c,locked:u,zIndex:h===null?null:Number(h)}))}onPad(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E,S,w,x,I,A,O,R){let M=this.getZIndex(e);this.handleData(this.encode.encodePad(ji(e),{groupId:i,netName:r,layerId:n,num:s,centerX:a,centerY:o,padAngle:l,hole:c,defaultPad:u,specialPad:h,padOffsetX:d,padOffsetY:p,relativeAngle:f,plated:m,padType:g,topSolderExpansion:b,bottomSolderExpansion:y,topPasteExpansion:E,bottomPasteExpansion:S,locked:w,zIndex:M===null?null:Number(M),connectMode:x,spokeSpace:I,spokeWidth:A,spokeAngle:O,unusedInnerLayers:R,padLen:0}))}onVia(e,t,i,r,n,s,a,o,l,c,u,h,d,p){let f=this.getZIndex(e);this.handleData(this.encode.encodeVia(ji(e),{groupId:i,netName:r,ruleName:n,centerX:s,centerY:a,holeDiameter:o,viaDiameter:l,viaType:c,topSolderExpansion:u,bottomSolderExpansion:h,locked:d,zIndex:f===null?null:Number(f),unusedInnerLayers:p}))}onPreference(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E){this.handleData(this.encode.encodePreference({startTrackWidthFollowLast:e,lastTrackWidth:t,startViaSizeFollowLast:i,lastViaInnerDiameter:r,lastViaDiameter:n,snap:s,routingMode:a,routingCorner:o,removeLoop:l,rotatingObject:c,trackFollow:u,stretchTrackMinCorner:h,preferenceConfig:d,realTimeUpdateUnusedLayers:p,unusedPadRange:f,pushVia:m,pathOptimization4BePushed:g,currentPathOptimization4BePushed:b,removeCircuitsContainingVias:y,removeAntenna:E}))}onSilkOpts(e,t,i){this.handleData(this.encode.encodeSilkOpts(e,{defaultColor:t,baseColor:i}))}onGroup(e,t){this.handleData(this.encode.encodeGroup(e,{groupName:t}))}onPrimitive(e,t,i){this.handleData(this.encode.encodePrimitive(e,{display:t,pick:i}))}onNet(e,t,i,r,n,s,a){this.handleData(this.encode.encodeNet(e,{netType:t,specialColor:i,retLine:r,differentialName:n,isPositiveNet:s,equalLengthGroupName:a}))}onPartition(e,t,i,r){}onActiveLayer(e){this.handleData(this.encode.encodeActiveLayer({layerId:e}))}onLayerPhys(e,t,i,r,n,s,a){this.handleData(this.encode.encodeLayerPhys(e,{material:t,thickness:i,permittivity:r,lossTangent:n,isKeepIsland:s,zIndex:a}))}onLayer(e,t,i,r,n,s,a,o,l,c){this.handleData(this.encode.encodeLayer(e,{layerType:t,layerName:i,use:r,show:n,locked:s,activeColor:a,activateTransparency:o,inactiveColor:l,inactiveTransparency:c}))}onCanvas(e,t,i,r,n,s,a,o,l,c,u,h){this.handleData(this.encode.encodeCanvas({originX:e,originY:t,unit:i,gridXSize:r,gridYSize:n,snapXSize:s,snapYSize:a,altSnapXSize:o,altSnapYSize:l,gridType:c,multiGridType:u,multiGridRatio:h,highlightValue:.5}))}};function RV(e,t,i,r=new Date().getTime(),n=String(r),s){let a=new OV(i),o="",l=_l();if(o=wp("FOOTPRINT",l,e,r,n,s),a.parseFull(t),a.encodeData&&(o=o+`|
`+a.encodeData),a.blobData.length&&(o=o+`|
`+a.blobEncode.head({doc:"BLOB",client:l,updateTime:r,version:n,user:s})+`|
`+a.blobData.join(`|
`)),a.fontCache.length){let c=new kV,u=c.head({doc:"FONT",client:l,updateTime:r,version:n,user:s});for(let h of a.fontCache){let d=CT(h.text,h.fontFamily,h.fontSize,h.thickness,h.bold,h.italic,h.reverse,h.expansion),p=c.buildStr(1,d,h);u=u+`|
`+p}o=u+`|
`+o}return o}var NV=class{constructor(){}encodePart(e,t){return{id:e,dataType:"PART",data:JSON.stringify(t)}}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}encodeAttr(e,t){return{id:e,dataType:"ATTR",data:JSON.stringify(t)}}encodeTable(e,t){return{id:e,dataType:"TABLE",data:JSON.stringify(t)}}encodeEllipse(e,t){return{id:e,dataType:"ELLIPSE",data:JSON.stringify(t)}}encodeObj(e,t){return{id:e,dataType:"OBJ",data:JSON.stringify(t)}}encodePin(e,t){return{id:e,dataType:"PIN",data:JSON.stringify(t)}}encodeRect(e,t){return{id:e,dataType:"RECT",data:JSON.stringify(t)}}encodeArc(e,t){return{id:e,dataType:"ARC",data:JSON.stringify(t)}}encodeCircle(e,t){return{id:e,dataType:"CIRCLE",data:JSON.stringify(t)}}encodePoly(e,t){return{id:e,dataType:"POLY",data:JSON.stringify(t)}}encodeText(e,t){return{id:e,dataType:"TEXT",data:JSON.stringify(t)}}encodeBezier(e,t){return{id:e,dataType:"BEZIER",data:JSON.stringify(t)}}encodeGroup(e,t){return{id:e,dataType:"GROUP",data:JSON.stringify(t)}}},MV=class extends PV{constructor(){super(),this.encode=new NV,this.maxTicket=0,this.blobEncode=new fI,this.blobData=[],this.encodeData="",this.placeholder=0}handleData(e){this.encodeData?this.encodeData=this.encodeData+`|
`+To(e.dataType,++this.maxTicket,e.id,e.data):this.encodeData=To(e.dataType,++this.maxTicket,e.id,e.data)}onPHolder(e,t){let i={dataType:e,max:t};this.handleData({id:`placeholder${++this.placeholder}`,dataType:"ELE_PLACEHOLDER",data:JSON.stringify(i)})}onPart(e,t){this.handleData(this.encode.encodePart(e,t||{}))}onAttr(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E,S){this.handleData(this.encode.encodeAttr(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),parentId:n,key:s,value:a,keyVisible:o,valueVisible:l,x:c,y:qs(u),rotation:h,color:d,fillColor:p,fontFamily:f,fontSize:m,strikeout:g,underline:b,italic:y,fontWeight:E,align:S,version:"2.0"}))}onTable(e,t,i,r,n,s,a,o,l,c,u){this.handleData(this.encode.encodeTable(ji(e),{partId:t,groupId:i,startX:r,startY:qs(n),rowSizes:s,colSizes:a,rowLocked:o,colLocked:l,rotation:c,tableCell:u,zIndex:this.getZIndex(e)}))}onEllipse(e,t,i,r,n,s,a,o,l,c,u,h,d,p){this.handleData(this.encode.encodeEllipse(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),centerX:n,centerY:qs(s),radiusX:a,radiusY:qs(o),rotation:l,strokeColor:c,strokeStyle:u,fillColor:h,strokeWidth:d,fillStyle:p}))}onComponent(){}onObj(e,t,i,r,n,s,a,o,l,c,u,h){if(h.startsWith("data:")){let d=rE(h);this.blobData.push(this.blobEncode.buildStr(1,d,{filename:"",content:h})),h=`blob:${d}`}this.handleData(this.encode.encodeObj(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),fileName:n,startX:s,startY:qs(a),width:o,height:l,rotation:c,isMirror:u,content:h}))}onPin(e,t,i,r,n,s,a,o,l,c,u,h){this.handleData(this.encode.encodePin(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),display:n,x:a,y:qs(o),length:l,rotation:c,color:u,pinShape:h}))}onRect(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m){this.handleData(this.encode.encodeRect(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),dotX1:n,dotY1:qs(s),dotX2:a,dotY2:qs(o),radiusX:l,radiusY:c,rotation:u,strokeColor:h,strokeStyle:d,fillColor:p,strokeWidth:f,fillStyle:m}))}onArc(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f){this.handleData(this.encode.encodeArc(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),startX:n,startY:qs(s),referX:a,referY:qs(o),endX:l,endY:qs(c),strokeColor:u,strokeStyle:h,fillColor:d,strokeWidth:p,fillStyle:f}))}onCircle(e,t,i,r,n,s,a,o,l,c,u,h){this.handleData(this.encode.encodeCircle(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),centerX:n,centerY:qs(s),radius:a,strokeColor:o,strokeStyle:l,fillColor:c,strokeWidth:u,fillStyle:h}))}onPoly(e,t,i,r,n,s,a,o,l,c,u){this.handleData(this.encode.encodePoly(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),points:XF(n,!0),closed:s,strokeColor:a,strokeStyle:o,fillColor:l,strokeWidth:c,fillStyle:u}))}onText(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g){this.handleData(this.encode.encodeText(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),x:n,y:qs(s),rotation:a,value:o,color:l,fillColor:c,fontFamily:u,fontSize:h,strikeout:d,underline:p,italic:f,fontWeight:m,align:g,version:"2.0"}))}onCanvas(e){this.handleData(this.encode.encodeCanvas({originX:e.originX,originY:qs(e.originY)}))}onBezier(e,t,i,r,n,s,a,o,l,c){this.handleData(this.encode.encodeBezier(ji(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),controls:n,strokeColor:s,strokeStyle:a,fillColor:o,strokeWidth:l,fillStyle:c}))}onGroup(e,t,i){this.handleData(this.encode.encodeGroup(String(e),{parentId:t,title:i}))}onBus(){}onWire(){}};function BV(e,t,i=new Date().getTime(),r=String(i),n){let s=new MV,a="";s.parseFull(t);let o=_l();s.encodeData&&(a=wp("SYMBOL",o,e,i,r,n)+`|
`+s.encodeData),a&&s.blobData.length&&(a=a+`|
`+s.blobEncode.head({doc:"BLOB",client:o,updateTime:i,version:r,user:n})+`|
`+s.blobData.join(`|
`));let l=s.partIdMap;return s.partIdMap={},{dataStr:a,partIdMap:l}}var kV=class extends GO{constructor(){super(...arguments),this.doctype="FONT"}buildStr(e,t,i){let r=typeof i=="string"?i:JSON.stringify(this.buildData(i));return To("FONT",e,t,r)}buildData(e){return{width:e.width,height:e.height,path:e.path}}};var FV=class extends _V{constructor(){super(),this.encode=new LV,this.maxTicket=0,this.blobEncode=new fI,this.blobData=[],this.encodeData="",this.placeholder=0}handleData(e){this.encodeData?this.encodeData=this.encodeData+`|
`+To(e.dataType,++this.maxTicket,e.id,e.data):this.encodeData=To(e.dataType,++this.maxTicket,e.id,e.data)}onPHolder(e,t){let i={dataType:e,max:t};this.handleData({id:`placeholder${++this.placeholder}`,dataType:"ELE_PLACEHOLDER",data:JSON.stringify(i)})}strokeStyleType(e){switch(e=e&&Number(e),e){case 0:return"SOLID";case 1:return"SHORT_DASH";case 2:return"DOT";case 3:return"DOT_DASH";default:return null}}transScopeType(e){switch(e=e&&Number(e),e){case 1:return"PRINT";case 2:return"COVER";case 3:return"PRINT&COVER";default:return null}}transAlignType(e){switch(e=e&&Number(e),e){case 0:return"LEFT_BOTTOM";case 1:return"CENTER_BOTTOM";case 2:return"RIGHT_BOTTOM";case 3:return"LEFT_MIDDLE";case 4:return"CENTER_MIDDLE";case 5:return"RIGHT_MIDDLE";case 6:return"LEFT_TOP";case 7:return"CENTER_TOP";case 8:return"RIGHT_TOP";default:return null}}onAuxLine(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E){this.handleData(this.encode.encodeAuxLine(ji(e),{groupId:t?`e${t}`:"",layer:i,x:r,y:n,rotation:s,strokeWidth:a,strokeStyle:this.strokeStyleType(o),color:l,length:c,locked:u,zIndex:this.getZIndex(e),visible:!d,cover:p,name:f}))}onDimension(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b){this.handleData(this.encode.encodeDimension(ji(e),{layer:t,dimensionType:i,unit:r,strokeWidth:n,accuracy:s,controlDot:a,relationIds:o,locked:l,zIndex:this.getZIndex(e),valid:!c,visible:!u,cover:h,name:d,rotation:0}))}onString(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E,S,w,x,I,A){this.handleData(this.encode.encodeString(ji(e),{groupId:t?`e${t}`:"",layer:i,rotation:r,value:n,fontFamily:s,fontSize:a,fontWeight:o,italic:l,underline:c,strikeout:u,align:this.transAlignType(h),strokeColor:d,opacity:p,locked:f,zIndex:this.getZIndex(e),valid:!m,visible:!g,cover:b,transScope:this.transScopeType(E),transPrint:S,transWhite:w,matrix:x,strokes:I,path:A,name:y}))}onPoly(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E,S,w){if(typeof o=="string"&&o.startsWith("data:")){let x=rE(o);this.blobData.push(this.blobEncode.buildStr(1,x,{filename:"",content:o})),o=`blob:${x}`}this.handleData(this.encode.encodePoly(ji(e),{groupId:t?`e${t}`:"",layer:i,rotation:r,strokeWidth:n,strokeStyle:this.strokeStyleType(s),strokeColor:a,fillColor:o,opacity:l,autoClose:c,ploys:u,displayFill:h,displayStroke:d,locked:p,zIndex:this.getZIndex(e),valid:!f,visible:!m,cover:g,transScope:this.transScopeType(y),transPrint:E,transWhite:S,matrix:w,name:b}))}onGroup(e,t,i,r,n){this.handleData(this.encode.encodeGroup(`e${e}`,{parentId:t?`e${t}`:"",title:i,visible:r,locked:n}))}onCanvas(e){this.handleData(this.encode.encodeCanvas(e))}};function GV(e,t,i,r=new Date().getTime(),n=String(r),s){let a=new FV,o="";a.parseFull(t);let l=_l();return a.encodeData&&(o=wp(i,l,e,r,n,s)+`|
`+a.encodeData),o&&a.blobData.length&&(o=o+`|
`+a.blobEncode.head({doc:"BLOB",client:l,updateTime:r,version:n,user:s})+`|
`+a.blobData.join(`|
`)),o}var YO=class extends jG{constructor(e){let t=e||new aO;super(t,0,KF),this.cacheNum=null}onParseLine(e,t,i,r,n,s,a){switch(this.setOrderNum(e,a,t),this.cacheNum=a,t){case"MAX_NUM":if(i)for(let l in i)this.setMaxNum(l,i[l]);break;case"BLOB":i?this.onBlob(e,r,n,i,s):this.onDelBlob(e,r,n,s);break;case"FONT":this.parseFont(e,i,r,n,s);break;case"META":i&&this.parseDetail(i,r,n,s);break;case"ELE_PLACEHOLDER":break;case"CANVAS":i&&this.parseCanvas(i,r,n,s);break;case"BOARD":i?this.parseBoard(i,r,n,s):this.onDelBoard(r,n,s);break;case"LAYER":{let l=Kh(e);i?this.parseLayer(l,i,r,n,s):this.onDelLayer(l,r,n,s);break}case"LAYER_PHYS":{let l=Kh(e);i?this.parseLayerPhys(l,i,r,n,s):this.onDelLayerPhys(l,r,n,s);break}case"ACTIVE_LAYER":i&&this.parseActiveLayer(e,i,r,n,s);break;case"PARTITION":i?this.parsePartition(e,i,r,n,s):this.onDelPartition(e,r,n,s);break;case"NET":{let l=Kh(e);i?this.parseNet(l,i,r,n,s):this.onDelNet(l,r,n,s);break}case"PRIMITIVE":{let l=Kh(e);i?this.parsePrimitive(l,i,r,n,s):this.onDelPrimitive(l,r,n,s);break}case"GROUP":i?this.parseGroup(e,i,r,n,s):this.onDelGroup(e,r,n,s);break;case"X_SIGNAL_GROUP":i?this.parseXSignalsGroup(e,i,r,n,s):this.onDelXSignalsGroup(e,r,n,s);break;case"X_SIGNALS":i?this.parseXSignals(e,i,r,n,s):this.onDelXSignals(e,r,n,s);break;case"SILK_OPTS":{let l=Kh(e);i?this.parseSilkOpts(l,i,r,n,s):this.onDelSilkOpts(l,r,n,s);break}case"PREFERENCE":i&&this.parsePreference(e,i,r,n,s);break;case"VIA":i?this.parseVia(e,i,r,n,s):this.onDelVia(e,r,n,s);break;case"PAD":i?this.parsePad(e,i,r,n,s):this.onDelPad(e,r,n,s);break;case"LINE":i?this.parseLine(e,i,r,n,s):this.onDelLine(e,r,n,s);break;case"ARC":i?this.parseArc(e,i,r,n,s):this.onDelArc(e,r,n,s);break;case"OBJ":i?this.parseObj(e,i,r,n,s):this.onDelObj(e,r,n,s);break;case"EQLEN_GRP":i?this.parseEQLenGrp(e,i,r,n,s):this.onDelEQLenGrp(e,r,n,s);break;case"POLY":i?this.parsePoly(e,i,r,n,s):this.onDelPoly(e,r,n,s);break;case"FILL":i?this.parseFill(e,i,r,n,s):this.onDelFill(e,r,n,s);break;case"LAYER_FILL":let o=Kh(e);i?this.parseLayerFill(o,i,r,n,s):this.onDelLayerFill(o,r,n,s);break;case"REGION":i?this.parseRegion(e,i,r,n,s):this.onDelRegion(e,r,n,s);break;case"POUR":i?this.parsePour(e,i,r,n,s):this.onDelPour(e,r,n,s);break;case"POURED":{e=Kh(e),i?this.parsePoured(e,i,r,n,s):this.onDelPoured(e,r,n,s);break}case"IMAGE":i?this.parseImage(e,i,r,n,s):this.onDelImage(e,r,n,s);break;case"TEARDROP":i?this.parseTeardrop(e,i,r,n,s):this.onDelTeardrop(e,r,n,s);break;case"FPC_FILL":i?this.parseFpcFill(e,i,r,n,s):this.onDelFpcFill(e,r,n,s);break;case"SHELL":i?this.parseShell(e,i,r,n,s):this.onDelShell(e,r,n,s);break;case"CREASE":i?this.parseCrease(e,i,r,n,s):this.onDelCrease(e,r,n,s);break;case"SHELLCUT":i?this.parseShellCut(e,i,r,n,s):this.onDelShellCut(e,r,n,s);break;case"SHELL_ENTITY":i?this.parseShellEntity(e,i,r,n,s):this.onDelShellEntity(e,r,n,s);break;case"BOSS":i?this.parseBoss(e,i,r,n,s):this.onDelBoss(e,r,n,s);break;case"STRING":i?this.parseString(e,i,r,n,s):this.onDelString(e,r,n,s);break;case"ATTR":i?this.parseAttr(e,i,r,n,s):this.onDelAttr(e,r,n,s);break;case"DIMENSION":i?this.parseDimension(e,i,r,n,s):this.onDelDimension(e,r,n,s);break;case"COMPONENT":i?this.parseComponent(e,i,r,n,s):this.onDelComponent(e,r,n,s);break;case"PAD_NET":{let l=JSON.parse(e);i?(i.componentId=l[1],i.padNum=l[2],i.padId=l[3],this.parsePadNet(i,r,n,s)):this.onDelPadNet(l[1],l[2],l[3]||"",r,n,s);break}case"RULE_TEMPLATE":i&&this.parseRuleTemplate(e,i,r,n,s);break;case"RULE":{let l=JSON.parse(e);i?(i.ruleType=l[1],i.ruleName=l[2],this.parseRule(i,r,n,s)):this.onDelRule(l[1],l[2],r,n,s);break}case"RULE_SELECTOR":{let l=JSON.parse(e);i?(i.ruleSelect=l[1],this.parseRuleSelector(i,r,n,s)):this.onDelRuleSelector(l[1],r,n,s);break}case"PANELIZE":i?this.parsePanelize(e,i,r,n,s):this.onDelPanelize(r,n,s);break;default:console.warn("can not find hanlder with",i,r,n)}this.cacheNum=null}onOrderNum(e,t,i){switch(this.setOrderNum(e,i,t),t){case"PARTITION":this.onPartitionNum&&this.onPartitionNum(e,i);break;case"VIA":this.onViaNum&&this.onViaNum(e,i);break;case"PAD":this.onPadNum&&this.onPadNum(e,i);break;case"LINE":this.onLineNum&&this.onLineNum(e,i);break;case"ARC":this.onArcNum&&this.onArcNum(e,i);break;case"OBJ":this.onObjNum&&this.onObjNum(e,i);break;case"POLY":this.onPolyNum&&this.onPolyNum(e,i);break;case"FILL":this.onFillNum&&this.onFillNum(e,i);break;case"REGION":this.onRegionNum&&this.onRegionNum(e,i);break;case"POUR":this.onPourNum&&this.onPourNum(e,i);break;case"POURED":let r=Kh(e);this.onPouredNum&&this.onPouredNum(r,i);break;case"IMAGE":this.onImageNum&&this.onImageNum(e,i);break;case"TEARDROP":this.onTeardropNum&&this.onTeardropNum(e,i);break;case"FPC_FILL":this.onFpcFillNum&&this.onFpcFillNum(e,i);break;case"SHELL":this.onShellNum&&this.onShellNum(e,i);break;case"CREASE":this.onCreaseNum&&this.onCreaseNum(e,i);break;case"SHELLCUT":this.onShellCutNum&&this.onShellCutNum(e,i);break;case"SHELL_ENTITY":this.onShellEntityNum&&this.onShellEntityNum(e,i);break;case"BOSS":this.onBossNum&&this.onBossNum(e,i);break;case"STRING":this.onStringNum&&this.onStringNum(e,i);break;case"ATTR":this.onAttrNum&&this.onAttrNum(e,i);break;case"DIMENSION":this.onDimensionNum&&this.onDimensionNum(e,i);break;case"COMPONENT":this.onComponentNum&&this.onComponentNum(e,i);break}}onParseEnd(){}parseCanvas(e,t,i,r){this.onCanvas(t,i,e,r)}parseBoard(e,t,i,r){this.onBoard(e,t,i,r)}parseDetail(e,t,i,r){this.onDocDetail(t,i,e,r)}parseFont(e,t,i,r,n){let s=UG(e);t?this.onFont(i,r,Object.assign(t,s),n):this.onDelFont(s,i,r,n)}parseLayer(e,t,i,r,n){this.onLayer(e,i,r,t,n)}parseLayerPhys(e,t,i,r,n){this.onLayerPhys(e,i,r,t,n)}parseActiveLayer(e,t,i,r,n){this.onActiveLayer(i,r,t,n)}parsePartition(e,t,i,r,n){this.onPartition(e,this.cacheNum,i,r,t,n)}parseNet(e,t,i,r,n){this.onNet(e,i,r,t,n)}parsePrimitive(e,t,i,r,n){this.onPrimitive(e,i,r,t,n)}parseGroup(e,t,i,r,n){this.onGroup(e,i,r,t,n)}parseXSignalsGroup(e,t,i,r,n){this.onXSignalsGroup(e,t,i,r,n)}parseXSignals(e,t,i,r,n){this.onXSignals(e,t,i,r,n)}parseSilkOpts(e,t,i,r,n){this.onSilkOpts(e,i,r,t,n)}parsePreference(e,t,i,r,n){this.onPreference(i,r,t,n)}parseVia(e,t,i,r,n){this.onVia(e,this.cacheNum,i,r,t,n)}parsePad(e,t,i,r,n){this.onPad(e,this.cacheNum,i,r,t,n)}parseLine(e,t,i,r,n){this.onLine(e,this.cacheNum,i,r,t,n)}parseArc(e,t,i,r,n){this.onArc(e,this.cacheNum,i,r,t,n)}parseObj(e,t,i,r,n){this.onObj(e,this.cacheNum,i,r,t,n)}parseEQLenGrp(e,t,i,r,n){this.onEQLenGrp(e,i,r,t,n)}parsePoly(e,t,i,r,n){this.onPoly(e,this.cacheNum,i,r,t,n)}parseFill(e,t,i,r,n){t.fillStyle!=="PLANE"&&this.onFill(e,this.cacheNum,i,r,t,n)}parseLayerFill(e,t,i,r,n){this.onLayerFill(e,i,r,t,n)}parseRegion(e,t,i,r,n){this.onRegion(e,this.cacheNum,i,r,t,n)}parsePour(e,t,i,r,n){this.onPour(e,this.cacheNum,i,r,t,n)}parsePoured(e,t,i,r,n){let s=t;Array.isArray(t)&&(s={pourFill:t}),s.pourFill&&this.onPoured(e,this.cacheNum,i,r,s,n)}parseImage(e,t,i,r,n){this.onImage(e,this.cacheNum,i,r,t,n)}parseTeardrop(e,t,i,r,n){this.onTeardrop(e,this.cacheNum,i,r,t,n)}parseFpcFill(e,t,i,r,n){this.onFpcFill(e,this.cacheNum,i,r,t,n)}parseShell(e,t,i,r,n){this.onShell(e,this.cacheNum,i,r,t,n)}parseCrease(e,t,i,r,n){this.onCrease(e,this.cacheNum,i,r,t,n)}parseShellCut(e,t,i,r,n){this.onShellCut(e,this.cacheNum,i,r,t,n)}parseShellEntity(e,t,i,r,n){this.onShellEntity(e,this.cacheNum,i,r,t,n)}parseBoss(e,t,i,r,n){this.onBoss(e,this.cacheNum,i,r,t,n)}parseDimension(e,t,i,r,n){this.onDimension(e,this.cacheNum,i,r,t,n)}parseRuleTemplate(e,t,i,r,n){this.onRuleTemplate(i,r,t,n)}parseRule(e,t,i,r){this.onRule(t,i,e,r)}parseRuleSelector(e,t,i,r){if(e.ruleKeyValue&&(e.ruleKeyValue=tm(e.ruleKeyValue)),e.copperValue&&e.copperValue.hasOwnProperty("7")){let n=e.copperValue[7];delete e.copperValue[7],e.copperValue.COPPER=n}if(e.innerPlaneValue&&e.innerPlaneValue.hasOwnProperty("6")){let n=e.innerPlaneValue[6];delete e.innerPlaneValue[6],e.innerPlaneValue.PLANE=n}this.onRuleSelector(t,i,e,r)}parsePanelize(e,t,i,r,n){this.onPanelize(i,r,t,n)}parseComponent(e,t,i,r,n){this.onComponent(e,this.cacheNum,i,r,t,n)}parsePadNet(e,t,i,r){this.onPadNet(t,i,e,r)}parseAttr(e,t,i,r,n){this.onAttr(e,this.cacheNum,i,r,t,n)}parseString(e,t,i,r,n){this.onString(e,this.cacheNum,i,r,t,n)}},UV=(e=>(e.UNIVERSAL="UNIVERSAL",e))(UV||{}),YV=(e=>(e.SINGLE="SINGLE",e.MULTIPLE="MULTIPLE",e))(YV||{}),VV=(e=>(e.NONE="NONE",e.NAME="NAME",e.NUMBER="NUMBER",e))(VV||{}),HV=(e=>(e.NONE="NONE",e.ZONE="ZONE",e))(HV||{}),jV=Em(h0());function r0(){return self.EDITOR_TOP||self}function gm(e){return self[e]=self[e]||new jV.BroadcastChannelMessageBus(e)}var xp=(e,t)=>{let i=/{([^}]*)}/gim,r=[...new Set(e.match(i))];for(let n=0;n<r.length;n++){let s=r[n],a=s.substring(1,s.length-1);t[a]&&(e=e.replace(s,t[a]))}return e},zV=Em(h0()),Ur={getTime:"/pro-mgr/serverTime/now",getUserL:"/pro-ui/loginUser/get",subMaxTick:"/pro-mgr/project/ticket",subBlob:"/pro-mgr/canvas/BLOB/update",subFont:"/pro-mgr/canvas/FONT/update",subRevoke:"/pro-mgr/{uuid}/revoke",pushPend:"/pro-mgr/worker/batchPendData",pushSync:"/pro-mgr/dataWorker/sync",pushRevoke:"/pro-mgr/worker/revoke",pullASync:"/pro-mgr/dataWorker/sync/{id}",personDestroy:"/mgr/libWorker/destroy",projectUpdate:"/pro-mgr/canvas/{uuid}/update",personUpdate:"/mgr/libWorker/component/{uuid}/update",personSave:"/mgr/libWorker/save",projectSave:"/mgr/projectWorker/setCanvas",canSavePend:"/mgr/projectWorker/canSavePend",hasSaveData:"/mgr/check/hasSaveData"},XV={projectUpdate:Ur.projectUpdate,personUpdate:Ur.personUpdate,projectCanSave:Ur.canSavePend,getProject:"/mgr/projectWorker/footprint/getCanvas",getPerson:"/mgr/libWorker/getFootprint",unwatch:"/mgr/projectWorker/footprint/unwatchCanvas"},WV={projectUpdate:Ur.projectUpdate,projectCanSave:Ur.canSavePend,getProject:"/mgr/projectWorker/pcb/getCanvas",unwatch:"/mgr/projectWorker/pcb/unwatchCanvas"},$re={projectUpdate:Ur.projectUpdate,projectCanSave:Ur.canSavePend,getProject:"/mgr/projectWorker/sheet/getCanvas",unwatch:"/mgr/projectWorker/sheet/unwatchCanvas"},Zre={projectUpdate:Ur.projectUpdate,getProject:"/mgr/projectWorker/schematic/getCanvas",unwatch:"/mgr/projectWorker/schematic/unwatchCanvas"},Qre={projectUpdate:Ur.projectUpdate,projectCanSave:Ur.canSavePend,getProject:"/mgr/projectWorker/simulation/getCanvas",unwatch:"/mgr/projectWorker/simulation/unwatchCanvas"},ene={projectUpdate:Ur.projectUpdate,personUpdate:Ur.personUpdate,projectCanSave:Ur.canSavePend,getProject:"/mgr/projectWorker/symbol/getCanvasOnCompiler",getPerson:"/mgr/libWorker/getSymbol",unwatch:"/mgr/projectWorker/symbol/unwatchCanvas"},tne={projectUpdate:Ur.projectUpdate,personUpdate:Ur.personUpdate,projectCanSave:Ur.canSavePend,getProject:"/mgr/projectWorker/panel/getCanvas",getPerson:"/mgr/libWorker/getPanelLib",unwatch:"/mgr/projectWorker/panel/unwatchCanvas"},wo={send:"/pro-mgr/notify/send",sendMsg:"/document/sendMsg/cooperation",unwatch:"/document/unwatch/cooperation",watch:"/document/watch/cooperation",message:"/pro-mgr/notify/message/{path}/{uuid}/cooperation",established:"/pro-mgr/notify/message/ws/established",getWsId:"/pro-mgr/notify/getWsId",disconnect:"/pro-mgr/notify/message/ws/disconnect"},mI=class{constructor(e=!0){this._lockerTicket=0,this.isPull=!1,this.compiler={},this.order={SYMBOL:1,FOOTPRINT:2,DEVICE:3,SCH_PAGE:4,PCB:5},this._locker=e?++this._lockerTicket:0}getOrder(e){return this.order[e]||6}publish(){if(!this.isPull){this.isPull=!0,this._temporaryUnlock=this._locker;try{let e=Object.keys(this.compiler).sort((i,r)=>this.getOrder(i)-this.getOrder(r)),t=!1;for(let i of e){for(let[,r]of this.compiler[i])if(t=r.publish(),t)break;if(t)break}}finally{this._temporaryUnlock=0,this.isPull=!1}}}canPush(){return!this._locker||this._locker===this._temporaryUnlock}addCompiler(e){this.compiler[e.headType]||(this.compiler[e.headType]=new Map),this.compiler[e.headType].set(e.uniqueId,e)}removeCompiler(e){var t,i,r;(r=(i=(t=this.compiler)==null?void 0:t[e.headType])==null?void 0:i.delete)==null||r.call(i,e.uniqueId)}pull(){if(!this._locker)throw Error("\u4E0D\u5141\u8BB8\u5728\u975E pause \u72B6\u6001\u4E0B\u62C9\u53D6\u6570\u636E");this.publish()}resume(){this._locker=0,this.publish()}pause(){this._locker=++this._lockerTicket}dispose(){for(let e in this.compiler)this.compiler[e].clear();this.compiler=null}},Zh={publish:"publish",destroy:"destroy",init:"init",selected:"selected"},qV=class{constructor(e,t,i,r=(a=>(a=r0())==null?void 0:a._TAB_ID_)(),n,s){this.uuid=e,this.path=t,this.user=i,this.windowId=r,this.initIds={},this.sub=[];var a;this.wsBus=s||gm(`/${this.windowId}/notify`),this.dataBus=n||this.wsBus,this._client=(a=r0())==null?void 0:a._WS_ID_}get client(){return this._client}watch(){this.dataBus.publish(wo.send,{topic:wo.watch,uuid:this.uuid,path:this.path})}initPublish(){var e;this.dataBus.publish(wo.send,{topic:wo.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Zh.publish,user:this.user,client:this.client,data:((e=this.getSelect)==null?void 0:e.call(this))||""}})}async init(){if(!this.isInit){if(this.sub.push(this.wsBus.subscribe(wo.established,e=>{this._client=e,this.watch(),this.initPublish()})),!this.client){let e=await this.wsBus.rpcCall(wo.getWsId);if(!e||this.client)return;this._client=e}this.watch(),this.sub.push(this.wsBus.subscribe(wo.disconnect,e=>{this.initIds[e]&&this.onDestroy(this.initIds[e],e)})),this.sub.push(this.dataBus.subscribe(xp(wo.message,{uuid:this.uuid,path:this.path}),e=>{if(e.type===1)e.connectId&&this.initIds[e.connectId]&&this.onDestroy(this.initIds[e.connectId],e.connectId);else if(e.msg){let t=e.msg;if(t.client===this.client)return;switch(t.type){case Zh.destroy:this.onDestroy(t.userId,t.client),delete this.initIds[t.client];break;case Zh.init:this.initIds[t.client]||(this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||""));break;case Zh.selected:this.onSelected(t.user,t.client,t.data||"");break;case Zh.publish:this.dataBus.publish(wo.send,{topic:wo.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Zh.init,user:this.user,client:this.client,data:this.getSelect()||""}}),this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||"");break;default:break}}})),this.initPublish(),this.isInit=!0}}publishSelected(e,t){this.dataBus.publish(wo.send,{topic:wo.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Zh.selected,user:this.user,client:this.client,data:e}}),t&&this.onSelected(this.user,this.client,e)}destroy(){if(this.isInit){this.isInit=!1,this.dataBus.publish(wo.send,{topic:wo.unwatch,uuid:this.uuid,path:this.path,msg:{type:Zh.destroy,userId:this.user.uuid,client:this.client}});for(let e of this.sub)e.cancel();this.sub=[],this.initIds={}}}},RL=class extends qV{constructor(e,t,i,r,n,s,a,o){super(e,t,o,i,n,s),this.channel=r,this.selectedProps=a,this.cache=new Map,this.deleteCache=new Map}rePublish(){var e,t,i,r;if(this.channel.canPush()){for(let[n,s]of this.cache)(t=(e=this.selectedProps)==null?void 0:e.onSelect)==null||t.call(e,s.user,n,s.data);for(let[n,s]of this.deleteCache)(r=(i=this.selectedProps)==null?void 0:i.onQuit)==null||r.call(i,s,n)}}getSelect(){var e,t;return((t=(e=this.selectedProps)==null?void 0:e.getSelect)==null?void 0:t.call(e))||""}onSelected(e,t,i){var r,n;this.channel.canPush()?!this.deleteCache.has(t)&&this.cache.set(t,{user:e,data:i}):(n=(r=this.selectedProps)==null?void 0:r.onSelect)==null||n.call(r,e,t,i)}onDestroy(e,t){var i,r;this.channel.canPush()?(this.deleteCache.set(t,e),this.cache.delete(t)):(r=(i=this.selectedProps)==null?void 0:i.onQuit)==null||r.call(i,e,t)}dispose(){this.destroy(),this.cache.clear(),this.deleteCache.clear()}publishSelected(e,t){super.publishSelected(e,t)}},JV=class{constructor(e,t,i,r=(b=>(b=r0())==null?void 0:b._TAB_ID_)(),n=new mI,s=null,a,o,l,c,u,h,d,p,f,m,g){this.uuid=e,this.path=t,this.isProject=i,this.windowId=r,this.channel=n,this.consistencyManager=s,this.selectedProps=l,this.setInit=c,this.onDocDetail=u,this.onUpdate=h,this.handleInit=d,this.onDelete=p,this.publishCache=f,this.onOrderNm=m,this.setMaxNum=g,this.isInit=!1,this.canSave=!0,this.sub=[],this.isInitIng=!1,this.cache={},this.deleteCache=new Map,this.pendTimer=null,this.pendCache={},this.pendCacheLength=0,this.wsBus=gm(`/${r}/notify`),s||(this._unique=_l()),this._headType=a,this.busTopic=o}get uniqueId(){return this._unique||this.consistencyManager.getUnique()}get headType(){return this._headType}setIsInitIng(e){var t;(t=this.setInit)==null||t.call(this,e),this.isInitIng=e}consoleDebug(...e){console.debug("[lc-protocol]",this._headType,this.uuid,...e)}publishLine(e,t,i,r,n,s=this.uuid,a,o,l,c,u){if(this.channel.canPush())return this.consistencyManager.remoteChange(t,n,s,e,i,r,void 0,void 0,void 0,a,void 0,o,l,u),!1;this.cache[s]||(this.cache[s]=new Map);let h=this.cache[s].get(e);return(c||!h||h.ticket<t||h.ticket===t&&(h.client<n||h.client===n&&!!h.pend!=!!a))&&this.cache[s].set(e,{client:n,ticket:t,dataType:r,data:i,pend:a,unique:o,pChange:h?void 0:l,num:u}),!0}onDocHead(){}onEnd(){}setDocType(e,t){e===this.uuid&&(this._headType=t)}setBusTopic(e){this.busTopic=e}publish(){var e,t,i;if(this.publishCache)return this.publishCache();let r=!1;for(let[n,s]of this.deleteCache){if(this.channel.canPush()){(e=this.onDelete)==null||e.call(this,s),delete this.cache[n];continue}r=!0;break}if(r)return r;for(let n in this.cache){let s=this.cache[n].keys();for(let a of s){let o=this.cache[n].get(a);if(r=this.publishLine(a,o.ticket,o.data,o.dataType,o.client,n,o.pend,o.unique,o.pChange,!1,o.num),r)break;this.cache[n].delete(a)}if(r)break}return(i=(t=this.selectManager)==null?void 0:t.rePublish)==null||i.call(t),r}publishSelected(e,t){this.selectManager.publishSelected(e,t)}clear(){var e,t;for(let i of this.sub)i.cancel();this.sub.length=0,this.cache={},this.deleteCache.clear(),this.setIsInitIng(!1),this.channel.removeCompiler(this),(t=(e=this.selectManager)==null?void 0:e.dispose)==null||t.call(e),this.selectManager=null,this.isInit=!1,this.setIsInitIng(!1)}async init(e=!0,t=!0,i=!0,r,n,s,a){try{if(this.isInit)return{success:!0};if(this.isInitIng)throw new Error("\u6B63\u5728\u521D\u59CB\u5316\u4E2D");return this.isProject?await this.initProject(e,t,i,r,s,a):await this.initLib(i,r,n,s,a)}catch(o){throw this.clear(),new Error(`${this._headType}+'Compiler' ${this.uuid} init false: ${(o==null?void 0:o.message)||o||""}`,{cause:o})}finally{this.isInitIng=!1}}async flowRead(e){let t=this.consistencyManager.flowParseFull(),i=t.update,r=this;t.update=n=>{if(r.isDestroy)return!0;i(n)},await(0,zV.flowRead)(e,t)}pushOnLine(e,t){if(this.consistencyManager)for(let i of e)this.publishLine(i[0],i[1],i[2],i[3],i[4],t,i[5],i[6],i[7],!1,i[8])}async initProject(e,t,i,r,n,s){if(this.setIsInitIng(!0),this.channel.addCompiler(this),this.dataBus=gm(`/${this.windowId}/project/${this.path}`),n&&this.sub.push(this.dataBus.subscribe(`/pro-mgr/${this.uuid}/number/update`,l=>{if(this.onOrderNm)for(let c of l)this.onOrderNm(c[0],c[1],c[2])})),i&&this.busTopic.projectUpdate&&this.sub.push(this.dataBus.subscribe(xp(this.busTopic.projectUpdate,{uuid:this.uuid}),l=>{this.onUpdate?this.onUpdate(l):this.pushOnLine(l,this.uuid)})),i&&this.busTopic.projectCanSave&&this.sub.push(this.dataBus.subscribe(this.busTopic.projectCanSave,l=>{this.canSave=l})),i&&this.busTopic.subDelete&&this.sub.push(this.dataBus.subscribe(this.busTopic.subDelete,l=>{var c;this.channel.canPush()?(c=this.onDelete)==null||c.call(this,l):this.deleteCache.set(l[0],l)})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(Ur.subMaxTick,l=>{this.consistencyManager.setMaxTicket(l.ticket,l.force)})),i&&t&&this.sub.push(this.dataBus.subscribe(Ur.subBlob,l=>{this.pushOnLine(l,"BLOB")})),i&&e&&this.sub.push(this.dataBus.subscribe(Ur.subFont,l=>{this.pushOnLine(l,"FONT")})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(xp(Ur.subRevoke,{uuid:this.uuid}),l=>this.revoke(l))),!this.busTopic.getProject)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");this.isDestroy=!1;let a={doc:[this.uuid],watch:i,needNum:n,needDelete:s};t&&a.doc.push("BLOB"),e&&a.doc.push("FONT");let o=await this.dataBus.rpcCall(this.busTopic.getProject,a);if(this.isWatch=i,!this.isDestroy){if(!o.success)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01",o);if(this.canSave=!(o!=null&&o.readOnly),this.consoleDebug("init",o.result),o.maxTicket&&this.consistencyManager&&this.consistencyManager.setMaxTicket(o.maxTicket),o.data&&this.onDocDetail&&this.onDocDetail(o.client||_l(),0,o.data,!1),o.channel&&await this.flowRead(o.channel),!this.isDestroy){if(this.handleInit?this.handleInit(o):o.result&&this.consistencyManager&&this.consistencyManager.parseFull(o.result,this.uuid,this._headType),r){let l=this.user=this.user||o.user||await this.wsBus.rpcCall(Ur.getUserL);this.selectManager=new RL(this.uuid,this.path,this.windowId,this.channel,this.dataBus,this.wsBus,this.selectedProps,l),await this.selectManager.init()}return this.isInit=!0,this.setIsInitIng(!1),{success:!0}}}}async initLib(e,t,i,r,n){if(this.setIsInitIng(!0),this.channel.addCompiler(this),this.dataBus=gm(`/${this.windowId}/libWorker`),!this.busTopic.getPerson)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");let s=i?_l():"";this.isDestroy=!1;let a=await this.dataBus.rpcCall(this.busTopic.getPerson,{uuid:this.uuid,path:this.path,watch:e,channel:s,needNum:r,needDelete:n});if(this.isWatch=e,this.isDestroy)return;if(!a.success)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01",a);this.consoleDebug("init",a.dataStr);let o=a.data||a.result;if(o&&this.onDocDetail&&this.onDocDetail(a.client||_l(),0,o,!1),r&&this.sub.push(this.dataBus.subscribe(`/pro-mgr/${this.uuid}/number/update`,l=>{if(this.onOrderNm)for(let c of l)this.onOrderNm(c[0],c[1],c[2])})),e&&this.busTopic.personUpdate&&this.sub.push(this.dataBus.subscribe(xp(this.busTopic.personUpdate,{uuid:this.uuid}),l=>{this.pushOnLine(l,this.uuid)})),e&&this.sub.push(this.dataBus.subscribe(xp(xp(Ur.subRevoke,{uuid:this.uuid}),{uuid:this.uuid}),l=>this.revoke(l))),s&&await this.flowRead(s),!this.isDestroy){if(a.dataStr&&this.consistencyManager&&this.consistencyManager.parseFull(a.dataStr),t){let l=this.user=this.user||a.user||await this.wsBus.rpcCall(Ur.getUserL);this.selectManager=new RL(this.uuid,this.path,this.windowId,this.channel,this.wsBus,this.wsBus,this.selectedProps,l),await this.selectManager.init()}return this.isInit=!0,this.setIsInitIng(!1),{success:!0}}}revoke(e){for(let t of e)this.consistencyManager&&this.consistencyManager.revoke(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],(...i)=>this.publishLine(...i)),t[10]&&this.setMaxNum&&this.setMaxNum(t[6],t[10],t[1])}cachePendData(e,t,i,r,n,s){this.pendCache[e]||(this.pendCache[e]={type:s,pend:[]}),this.pendCache[e].pend.push([t,i,n,r]),this.pendCacheLength+=r.length+1,this.pendCacheLength>1e7&&this.publishPendData(),this.pendTimer||(this.pendTimer=setTimeout(()=>{this.publishPendData(),this.pendTimer=null},0))}publishPendData(){if(this.pendCacheLength){this.dataBus.publish(Ur.pushPend,[this.pendCache,this.consistencyManager.getClient(),this.uniqueId,this.uuid]);for(let e in this.pendCache)this.pendCache[e].pend.length=0;this.pendCache={},this.pendCacheLength=0}}localChange(e,t,i,r=this.uuid,n,s){if(!this.isInit||!this.canSave||!this.consistencyManager)return 0;if(t&&!t.startsWith("{"))return console.error("\u4E0A\u4F20\u7684\u683C\u5F0F\u4E0D\u6B63\u786E",e,i,t),0;let a=this.consistencyManager.localChange(r,e,t,i,n,s);return this.cachePendData(r,e,a,t,i,n||this.headType),a}async sync(){if(!this.isInit)throw new Error("\u6570\u636E\u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u540C\u6B65");let e=_l();this.dataBus.publish(Ur.pushSync,e),await this.dataBus.pullA(xp(Ur.pullASync,{id:e}))}async destroy(){return this.isDestroy?{success:!1}:(this.consistencyManager&&this.dataBus&&this.dataBus.publish(Ur.pushRevoke,[this.uuid,this.uniqueId,this.consistencyManager.getClient()]),this.clear(),this.isDestroy=!0,this.isWatch&&this.dataBus&&!this.isProject&&this.dataBus.publish(Ur.personDestroy,{uuid:this.uuid,path:this.path}),this.isWatch&&this.dataBus&&this.busTopic.unwatch&&this.dataBus.publish(this.busTopic.unwatch,this.uuid),this.isWatch=!1,{success:!0})}async save(e=[this.uuid,"BLOB","FONT"]){try{if(!this.isInit)throw new Error("\u6570\u636E\u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u4FDD\u5B58");if(!this.consistencyManager)throw new Error("\u65E0\u6CD5\u652F\u6301\u4FDD\u5B58");let t=this.isProject?Ur.projectSave:Ur.personSave;if(!t)throw new Error("\u65E0\u6CD5\u652F\u6301\u4FDD\u5B58");let i=await this.dataBus.rpcCall(t,{uuid:this.uuid,path:this.path,docIds:e,uniqueId:this.uniqueId,client:this.consistencyManager.getClient()});return this.consoleDebug("save",i),i}catch(t){throw new Error(`${this._headType}+'Compiler' ${this.uuid} \u4FDD\u5B58\u5931\u8D25: ${(t==null?void 0:t.message)||t||""}`,{cause:t})}}async getBlob(e){return this.dataBus.rpcCall("/mgr/projectWorker/blob/getBlob",e)}async getFont(e,t,i,r,n,s,a,o){let l={text:e,fontFamily:t,fontSize:i,thickness:r,bold:n,italic:s,reverse:a,expansion:o},c=await this.dataBus.rpcCall("/mgr/projectWorker/font/get",l);return c.success?{success:!0,result:Object.assign(l,JSON.parse(c.result))}:c}async checkSave(){return await this.dataBus.rpcCall(Ur.hasSaveData,{uuid:this.uuid,uniqueId:this.uniqueId})}},KV=(e=>(e.DIFFERENTIAL_PAIR="DIFFERENTIAL_PAIR",e.NET_CLASS="NET_CLASS",e.EQL_NET_GRP="EQL_NET_GRP",e))(KV||{}),$V=class extends YO{constructor(e){super(e)}onComponent(){}onComponentNum(){}onDelComponent(){}onPadNet(){}onDelPadNet(){}};var ine=Em(h0()),rne=Em(h0());var ZV=class extends YO{constructor(e,t,i,r,n,s,a,o=(l=>(l=r0())==null?void 0:l._TAB_ID_)()){let l=new aO(o);super(l),this.isProject=i,this.encode=s,this.base=new JV(e,t,i,o,r,l,n,n==="PCB"?WV:XV,a,(...c)=>this.setIsInit(...c),(...c)=>this.onDocDetail(...c),void 0,void 0,void 0,void 0,(c,u,h)=>this.onOrderNum(c,u,h),(c,u,h)=>{this.setMaxNum(c,u,!!h),h&&this.deleteOrderNum(h)})}get dataBus(){return this.base.dataBus}set dataBus(e){this.base.dataBus=e}async init(e=!0,t=!0,i=!0,r,n=!0,s){return this.setNeedNum(n),this.base.init(e,t,i,r,!0,n,s)}async sync(){return this.base.sync()}async destroy(){return this.base.destroy()}async save(){return this.base.save()}checkSave(){return this.base.checkSave()}publishSelected(e,t){this.base.publishSelected(e,t)}uploadBlob(e,t){let i=rE(t),r={filename:e,content:t};return{success:!0,ticket:this.localChange({id:i,data:JSON.stringify(r),dataType:"BLOB"},"BLOB","BLOB"),hash:i}}deleteBlob(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"BLOB"},"BLOB","BLOB")}}uploadFont(e){let{text:t,fontFamily:i,fontSize:r,thickness:n,bold:s,italic:a,reverse:o,expansion:l,width:c,height:u,path:h}=e,d={width:c,height:u,path:h},p=CT(t,i,r,n,s,a,o,l);return{success:!0,ticket:this.localChange({id:p,data:JSON.stringify(d),dataType:"FONT"},"FONT","FONT")}}deleteFont(e){let{text:t,fontFamily:i,fontSize:r,thickness:n,bold:s,italic:a,reverse:o,expansion:l}=e,c=CT(t,i,r,n,s,a,o,l);return{success:!0,ticket:this.localChange({id:c,data:"",dataType:"FONT"},"FONT","FONT")}}async updateFootprint(e){return this.isProject?this.dataBus.rpcCall("/mgr/projectWorker/footprint/update",e):{success:!1,message:"compiler \u6682\u4E0D\u652F\u6301\u4E2A\u4EBA\u5E93\u76F4\u63A5\u4FEE\u6539\u5C01\u88C5\u4FE1\u606F"}}async generateTemplate(e,t){return this.isProject?this.dataBus.rpcCall("/mgr/projectWorker/footprint/generateTemplate",{custom:e,renameKey:t}):{success:!1,message:"compiler \u6682\u4E0D\u652F\u6301\u4E2A\u4EBA\u5E93\u8C03\u7528\u8BE5\u63A5\u53E3"}}localChange(e,t=this.base.uuid,i){var r,n;let s=this.getOrderNum(e.id);return(n=(r=this.needOrderType)==null?void 0:r.includes)!=null&&n.call(r,e.dataType)&&s===void 0&&(s=this.getMaxNum(e.dataType),this.setOrderNum(e.id,s,e.dataType),this.onOrderNum(e.id,e.dataType,s)),this.base.localChange(e.id,e.data,e.dataType,t,i,s)}uploadString(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeString(e,t))}}deleteString(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"STRING"})}}uploadAttr(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeAttr(e,t))}}deleteAttr(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"ATTR"})}}uploadPanelize(e){return{success:!0,ticket:this.localChange(this.encode.encodePanelize(e))}}deletePanelize(){return{success:!0,ticket:this.localChange({id:"PANELIZE",data:"",dataType:"PANELIZE"})}}uploadRuleSelector(e){return{success:!0,ticket:this.localChange(this.encode.encodeRuleSelector(e))}}deleteRuleSelector(e){return{success:!0,ticket:this.localChange({id:JSON.stringify(["RULE_SELECTOR",e]),data:"",dataType:"RULE_SELECTOR"})}}uploadRule(e){return{success:!0,ticket:this.localChange(this.encode.encodeRule(e))}}deleteRule(e,t){return{success:!0,ticket:this.localChange({id:JSON.stringify(["RULE",e,t]),data:"",dataType:"RULE"})}}uploadRuleTemplate(e){return{success:!0,ticket:this.localChange(this.encode.encodeRuleTemplate(e))}}uploadDimension(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeDimension(e,t))}}deleteDimension(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"DIMENSION"})}}uploadBoss(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeBoss(e,t))}}deleteBoss(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"BOSS"})}}uploadShellEntity(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeShellEntity(e,t))}}deleteShellEntity(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"SHELL_ENTITY"})}}uploadShellCut(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeShellCut(e,t))}}deleteShellCut(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"SHELLCUT"})}}uploadCrease(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeCrease(e,t))}}deleteCrease(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"CREASE"})}}uploadShell(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeShell(e,t))}}deleteShell(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"SHELL"})}}uploadFpcFill(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeFpcFill(e,t))}}deleteFpcFill(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"FPC_FILL"})}}uploadTeardrop(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeTeardrop(e,t))}}deleteTeardrop(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"TEARDROP"})}}uploadImage(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeImage(e,t))}}deleteImage(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"IMAGE"})}}uploadPoured(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePoured(e,t))}}deletePoured(e){return{success:!0,ticket:this.localChange({id:vo(e,"POURED"),data:"",dataType:"POURED"})}}uploadPour(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePour(e,t))}}deletePour(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"POUR"})}}uploadRegion(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeRegion(e,t))}}deleteRegion(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"REGION"})}}uploadFill(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeFill(e,t))}}deleteFill(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"FILL"})}}uploadLayerFill(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLayerFill(e,t))}}deleteLayerFill(e){return{success:!0,ticket:this.localChange({id:vo(e,"LAYER_FILL"),data:"",dataType:"LAYER_FILL"})}}uploadPoly(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePoly(e,t))}}deletePoly(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"POLY"})}}uploadEQLenGrp(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeEQLenGrp(e,t))}}deleteEQLenGrp(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"EQLEN_GRP"})}}uploadObj(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeObj(e,t))}}deleteObj(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"OBJ"})}}uploadArc(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeArc(e,t))}}deleteArc(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"ARC"})}}uploadLine(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLine(e,t))}}deleteLine(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"LINE"})}}uploadPad(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePad(e,t))}}deletePad(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"PAD"})}}uploadVia(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeVia(e,t))}}deleteVia(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"VIA"})}}uploadPreference(e){return{success:!0,ticket:this.localChange(this.encode.encodePreference(e))}}uploadSilkOpts(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeSilkOpts(e,t))}}deleteSilkOpts(e){return{success:!0,ticket:this.localChange({id:vo(e,"SILK_OPTS"),data:"",dataType:"SILK_OPTS"})}}uploadGroup(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeGroup(e,t))}}deleteGroup(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"GROUP"})}}uploadPrimitive(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePrimitive(e,t))}}deletePrimitive(e){return{success:!0,ticket:this.localChange({id:vo(e,"PRIMITIVE"),data:"",dataType:"PRIMITIVE"})}}uploadNet(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeNet(e,t))}}deleteNet(e){return{success:!0,ticket:this.localChange({id:vo(e,"NET"),data:"",dataType:"NET"})}}uploadActiveLayer(e){return{success:!0,ticket:this.localChange(this.encode.encodeActiveLayer(e))}}uploadLayerPhys(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLayerPhys(e,t))}}deleteLayerPhys(e){return{success:!0,ticket:this.localChange({id:vo(e,"LAYER_PHYS"),data:"",dataType:"LAYER_PHYS"})}}uploadLayer(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLayer(e,t))}}deleteLayer(e){return{success:!0,ticket:this.localChange({id:vo(e,"LAYER"),data:"",dataType:"LAYER"})}}uploadCanvas(e){return{success:!0,ticket:this.localChange(this.encode.encodeCanvas(e))}}uploadBoard(e){return{success:!0,ticket:this.localChange({id:"BOARD",data:JSON.stringify(e),dataType:"BOARD"})}}deleteBoard(){return{success:!0,ticket:this.localChange({id:"BOARD",data:"",dataType:"BOARD"})}}uploadXSignalsGroup(e,t){return{success:!0,ticket:this.localChange({id:e,data:JSON.stringify(t),dataType:"X_SIGNAL_GROUP"})}}deleteXSignalsGroup(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"X_SIGNAL_GROUP"})}}uploadXSignals(e,t){return{success:!0,ticket:this.localChange({id:e,data:JSON.stringify(t),dataType:"X_SIGNALS"})}}deleteXSignals(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"X_SIGNALS"})}}},VO=class extends ZV{constructor(e,t,i,r,n=(s=>(s=r0())==null?void 0:s._TAB_ID_)()){super(e,t,i,r,"FOOTPRINT",new UO,{getSelect:()=>{var s;return(s=this.canvasSelected)==null?void 0:s.call(this)},onSelect:(...s)=>{var a;return(a=this.onSelectChange)==null?void 0:a.call(this,s[0],s[1],s[2])},onQuit:(...s)=>{var a;return(a=this.onSelectQuit)==null?void 0:a.call(this,s[0],s[1])}},n),this.uuid=e,this.path=t,this.isProject=i,this.windowId=n}onComponent(){}onComponentNum(){}onDelComponent(){}onPadNet(){}onDelPadNet(){}},QV=class extends $V{constructor(){super(...arguments),this.data={}}onXSignalsGroup(e,t,i,r,n){}onDelXSignalsGroup(e,t,i,r){}onXSignals(e,t,i,r,n){}onDelXSignals(e,t,i,r){}onBoard(e,t,i,r){}onDelBoard(e,t,i){}onLayerFill(e,t,i,r,n){}onDelLayerFill(e,t,i,r){}onBlob(e,t,i,r,n){}onDelBlob(e,t,i,r){}onFont(e,t,i,r){}onDelFont(e,t,i,r){}onString(e,t,i,r,n,s){this.data[e]=n}onDelString(e,t,i,r){delete this.data[e]}onStringNum(e,t){}onAttr(e,t,i,r,n,s){this.data[e]=n}onDelAttr(e,t,i,r){delete this.data[e]}onAttrNum(e,t){}onPanelizeSide(e,t,i,r){}onDelPanelizeSide(e,t,i,r){}onPanelizeStamp(e,t,i,r){}onDelPanelizeStamp(e,t,i,r){}onPanelize(e,t,i,r){}onDelPanelize(e,t,i){}onRuleSelector(e,t,i,r){}onDelRuleSelector(e,t,i,r){}onRule(e,t,i,r){}onDelRule(e,t,i,r,n){}onRuleTemplate(e,t,i,r){}onDimension(e,t,i,r,n,s){this.data[e]=n}onDelDimension(e,t,i,r){delete this.data[e]}onDimensionNum(e,t){}onBoss(e,t,i,r,n,s){this.data[e]=n}onDelBoss(e,t,i,r){delete this.data[e]}onBossNum(e,t){}onShellEntity(e,t,i,r,n,s){this.data[e]=n}onDelShellEntity(e,t,i,r){}onShellEntityNum(e,t){}onShellCut(e,t,i,r,n,s){this.data[e]=n}onDelShellCut(e,t,i,r){delete this.data[e]}onShellCutNum(e,t){}onCrease(e,t,i,r,n,s){this.data[e]=n}onDelCrease(e,t,i,r){delete this.data[e]}onCreaseNum(e,t){}onShell(e,t,i,r,n,s){this.data[e]=n}onDelShell(e,t,i,r){delete this.data[e]}onShellNum(e,t){}onFpcFill(e,t,i,r,n,s){this.data[e]=n}onDelFpcFill(e,t,i,r){delete this.data[e]}onFpcFillNum(e,t){}onTeardrop(e,t,i,r,n,s){this.data[e]=n}onDelTeardrop(e,t,i,r){delete this.data[e]}onTeardropNum(e,t){}onImage(e,t,i,r,n,s){this.data[e]=n}onDelImage(e,t,i,r){delete this.data[e]}onImageNum(e,t){}onPoured(e,t,i,r,n,s){this.data[e]=n}onDelPoured(e,t,i,r){delete this.data[e]}onPouredNum(e,t){}onPour(e,t,i,r,n,s){this.data[e]=n}onDelPour(e,t,i,r){delete this.data[e]}onPourNum(e,t){}onRegion(e,t,i,r,n,s){this.data[e]=n}onDelRegion(e,t,i,r){delete this.data[e]}onRegionNum(e,t){}onFill(e,t,i,r,n,s){this.data[e]=n}onDelFill(e,t,i,r){delete this.data[e]}onFillNum(e,t){}onPoly(e,t,i,r,n,s){this.data[e]=n}onDelPoly(e,t,i,r){delete this.data[e]}onPolyNum(e,t){}onEQLenGrp(e,t,i,r,n){this.data[e]=r}onDelEQLenGrp(e,t,i,r){delete this.data[e]}onDelProp(e,t,i,r){delete this.data[e]}onObj(e,t,i,r,n,s){this.data[e]=n}onDelObj(e,t,i,r){delete this.data[e]}onObjNum(e,t){}onArc(e,t,i,r,n,s){this.data[e]=n}onDelArc(e,t,i,r){delete this.data[e]}onArcNum(e,t){}onCArc(e,t,i,r,n,s){this.data[e]=n}onDelCArc(e,t,i,r){delete this.data[e]}onCArcNum(e,t){}onLine(e,t,i,r,n,s){this.data[e]=n}onDelLine(e,t,i,r){delete this.data[e]}onLineNum(e,t){}onPad(e,t,i,r,n,s){this.data[e]=n}onDelPad(e,t,i,r){delete this.data[e]}onPadNum(e,t){}onVia(e,t,i,r,n,s){this.data[e]=n}onDelVia(e,t,i,r){delete this.data[e]}onViaNum(e,t){}onDelConnect(e,t,i,r){}onPreference(e,t,i,r){}onSilkOpts(e,t,i,r,n){this.data[e]=r}onDelSilkOpts(e,t,i,r){delete this.data[e]}onGroup(e,t,i,r,n){this.data[e]=r}onDelGroup(e,t,i,r){delete this.data[e]}onPrimitive(e,t,i,r,n){}onDelPrimitive(e,t,i,r){}onNet(e,t,i,r,n){}onDelNet(e,t,i,r){}onPartition(e,t,i,r,n,s){this.data[e]=n}onDelPartition(e,t,i,r){delete this.data[e]}onPartitionNum(e,t){}onEditorMeta(e,t,i,r){}onDocDetail(e,t,i,r){}onActiveLayer(e,t,i,r){}onLayerPhys(e,t,i,r,n){this.data[e]=r}onDelLayerPhys(e,t,i,r){delete this.data[e]}onLayer(e,t,i,r,n){this.data[e]=r}onDelLayer(e,t,i,r){}onCanvas(e,t,i,r){}},eH=class extends VO{onXSignalsGroup(e,t,i,r,n){}onDelXSignalsGroup(e,t,i,r){}onXSignals(e,t,i,r,n){}onDelXSignals(e,t,i,r){}onBoard(e,t,i,r){}onDelBoard(e,t,i){}onLayerFill(e,t,i,r,n){}onDelLayerFill(e,t,i,r){}constructor(e,t,i,r){super(e,t,i,new mI,r)}canvasSelected(){return""}onSelectChange(e,t,i){}onSelectQuit(e,t){}async getByDataType(e){let t="";if(this.isProject?(this.dataBus=this.dataBus||gm(`/${this.windowId}/project/${this.path}`),t=await this.dataBus.rpcCall("/mgr/projectWorker/getDataByType",{doc:this.uuid,dataType:e})):(this.dataBus=this.dataBus||gm(`/${this.windowId}/libWorker`),t=await this.dataBus.rpcCall("/mgr/libWorker/getDataByType",{uuid:this.uuid,path:this.path,dataType:e,docType:"FOOTPRINT"})),!t)return{};let i=new QV;return i.consistencyManager.parseFull(t,this.uuid,"FOOTPRINT"),i.data}async getPads(){return this.getByDataType("PAD")}onBlob(e,t,i,r,n){}onDelBlob(e,t,i,r){}onFont(e,t,i,r){}onDelFont(e,t,i,r){}onString(e,t,i,r,n,s){}onDelString(e,t,i,r){}onStringNum(e,t){}onAttr(e,t,i,r,n,s){}onDelAttr(e,t,i,r){}onAttrNum(e,t){}onPanelizeSide(e,t,i,r){}onDelPanelizeSide(e,t,i,r){}onPanelizeStamp(e,t,i,r){}onDelPanelizeStamp(e,t,i,r){}onPanelize(e,t,i,r){}onDelPanelize(e,t,i){}onRuleSelector(e,t,i,r){}onDelRuleSelector(e,t,i,r){}onRule(e,t,i,r){}onDelRule(e,t,i,r,n){}onRuleTemplate(e,t,i,r){}onDimension(e,t,i,r,n,s){}onDelDimension(e,t,i,r){}onDimensionNum(e,t){}onBoss(e,t,i,r,n,s){}onDelBoss(e,t,i,r){}onBossNum(e,t){}onShellEntity(e,t,i,r,n,s){}onDelShellEntity(e,t,i,r){}onShellEntityNum(e,t){}onShellCut(e,t,i,r,n,s){}onDelShellCut(e,t,i,r){}onShellCutNum(e,t){}onCrease(e,t,i,r,n,s){}onDelCrease(e,t,i,r){}onCreaseNum(e,t){}onShell(e,t,i,r,n,s){}onDelShell(e,t,i,r){}onShellNum(e,t){}onFpcFill(e,t,i,r,n,s){}onDelFpcFill(e,t,i,r){}onFpcFillNum(e,t){}onTeardrop(e,t,i,r,n,s){}onDelTeardrop(e,t,i,r){}onTeardropNum(e,t){}onImage(e,t,i,r,n,s){}onDelImage(e,t,i,r){}onImageNum(e,t){}onPoured(e,t,i,r,n,s){}onDelPoured(e,t,i,r){}onPouredNum(e,t){}onPour(e,t,i,r,n,s){}onDelPour(e,t,i,r){}onPourNum(e,t){}onRegion(e,t,i,r,n,s){}onDelRegion(e,t,i,r){}onRegionNum(e,t){}onFill(e,t,i,r,n,s){}onDelFill(e,t,i,r){}onFillNum(e,t){}onPoly(e,t,i,r,n,s){}onDelPoly(e,t,i,r){}onPolyNum(e,t){}onEQLenGrp(e,t,i,r,n){}onDelEQLenGrp(e,t,i,r){}onDelProp(e,t,i,r){}onObj(e,t,i,r,n,s){}onDelObj(e,t,i,r){}onObjNum(e,t){}onArc(e,t,i,r,n,s){}onDelArc(e,t,i,r){}onArcNum(e,t){}onCArc(e,t,i,r,n,s){}onDelCArc(e,t,i,r){}onCArcNum(e,t){}onLine(e,t,i,r,n,s){}onDelLine(e,t,i,r){}onLineNum(e,t){}onPad(e,t,i,r,n,s){}onDelPad(e,t,i,r){}onPadNum(e,t){}onVia(e,t,i,r,n,s){}onDelVia(e,t,i,r){}onViaNum(e,t){}onDelConnect(e,t,i,r){}onPreference(e,t,i,r){}onSilkOpts(e,t,i,r,n){}onDelSilkOpts(e,t,i,r){}onGroup(e,t,i,r,n){}onDelGroup(e,t,i,r){}onPrimitive(e,t,i,r,n){}onDelPrimitive(e,t,i,r){}onNet(e,t,i,r,n){}onDelNet(e,t,i,r){}onPartition(e,t,i,r,n,s){}onDelPartition(e,t,i,r){}onPartitionNum(e,t){}onEditorMeta(e,t,i,r){}onDocDetail(e,t,i,r){}onActiveLayer(e,t,i,r){}onLayerPhys(e,t,i,r,n){}onDelLayerPhys(e,t,i,r){}onLayer(e,t,i,r,n){}onDelLayer(e,t,i,r){}onCanvas(e,t,i,r){}},HO=(e=>(e.LIST="/pro-mgr/api/project/list",e.CREATE="/pro-mgr/api/project/create",e.GET="/pro-mgr/api/project/get",e.UPDATE="/pro-mgr/api/project/update",e.DELETE="/pro-mgr/api/project/delete",e.TICKET="/pro-mgr/api/project/ticket",e.TICKET1="/pro-mgr/api/project/ticket1",e.BACKUP_LIST="/pro-mgr/api/project/backupList",e.BACKUP="/pro-mgr/api/project/backup",e.GET_BACKUP="/pro-mgr/api/project/getBackup",e.DELETE_BACKUP="/pro-mgr/api/project/deleteBackup",e.ARCHIVE="/pro-mgr/api/project/archive",e.CREATE_BOARD="/pro-mgr/api/project/createBoards",e.STAR="/pro-mgr/api/project/star",e.UNSTAR="/pro-mgr/api/project/unstar",e.GET_PROFILE="/pro-mgr/api/project/getProfile",e))(HO||{}),jO=(e=>(e.LIST="/pro-mgr/api/branch/list",e.GET="/pro-mgr/api/branch/get",e.CREATE="/pro-mgr/api/branch/create",e.UPDATE="/pro-mgr/api/branch/update",e.DELETE="/pro-mgr/api/branch/delete",e))(jO||{}),zO=(e=>(e.LIST="/pro-mgr/api/schematic/list",e.CREATE="/pro-mgr/api/schematic/create",e.UPLOAD="/pro-mgr/api/schematic/upload",e.DELETE="/pro-mgr/api/schematic/delete",e.UPDATE="/pro-mgr/api/schematic/update",e))(zO||{}),XO=(e=>(e.LIST="/pro-mgr/api/document/list",e.SEARCH_LIST="/pro-mgr/api/document/searchList",e.CREATE="/pro-mgr/api/document/create",e.UPLOAD="/pro-mgr/api/document/upload",e.UPDATE="/pro-mgr/api/document/update",e.BATCH_UPDATE="/pro-mgr/api/document/batchUpdate",e.DELETE="/pro-mgr/api/document/delete",e.GET="/pro-mgr/api/document/get",e.GET_BY_SID="/pro-mgr/api/document/getBySid",e.MOVE="/pro-mgr/api/document/move",e.CHECK_IN="/pro-mgr/api/document/checkIn",e.CHECK_OUT="/pro-mgr/api/document/checkOut",e.GET_CHECK="/pro-mgr/api/document/getCheck",e.DELETE_PCB_RELATED="/pro-mgr/api/document/deletePcbRelated",e))(XO||{}),WO=(e=>(e.LIST="/pro-mgr/api/device/list",e.SEARCH_LIST="/pro-mgr/api/device/searchList",e.CREATE="/pro-mgr/api/device/create",e.UPLOAD="/pro-mgr/api/device/upload",e.UPDATE="/pro-mgr/api/device/update",e.BATCH_UPDATE="/pro-mgr/api/device/batchUpdate",e.GET="/pro-mgr/api/device/get",e.SEARCH_BY_USERS_AND_TITLES="/pro-mgr/api/device/searchByUsersAndTitles",e.GET_ATTR_VALUES="/pro-mgr/api/device/getAttributeValues",e.GET_ATTR_KEYS="/pro-mgr/api/device/getAttrKeys",e.DELETE="/pro-mgr/api/device/delete",e.STAR="/pro-mgr/api/device/star",e.UNSTAR="/pro-mgr/api/device/unstar",e.PLACE="/pro-mgr/api/device/place",e))(WO||{}),qO=(e=>(e.LIST="/pro-mgr/api/component/list",e.SEARCH_LIST="/pro-mgr/api/component/searchList",e.CREATE="/pro-mgr/api/component/create",e.UPLOAD="/pro-mgr/api/component/upload",e.UPDATE="/pro-mgr/api/component/update",e.BATCH_UPDATE="/pro-mgr/api/component/batchUpdate",e.DELETE="/pro-mgr/api/component/delete",e.GET="/pro-mgr/api/component/get",e.SEARCH_BY_USERS_AND_TITLES="/pro-mgr/api/component/searchByUsersAndTitles",e.STAR="/pro-mgr/api/component/star",e.UNSTAR="/pro-mgr/api/component/unstar",e.GET_HISTORY="/pro-mgr/api/component/getHistory",e.SET_HISTORY="/pro-mgr/api/component/setHistory",e.GET_HISTORY_DATA="/pro-mgr/api/component/getHistoryData",e))(qO||{}),JO=(e=>(e.LIST="/pro-mgr/api/tag/list",e.CREATE="/pro-mgr/api/tag/create",e.UPDATE="/pro-mgr/api/tag/update",e.DELETE="/pro-mgr/api/tag/delete",e))(JO||{}),KO=(e=>(e.SEARCH_LIST="/pro-mgr/api/copper/searchList",e.SET="/pro-mgr/api/copper/set",e.DELETE="/pro-mgr/api/copper/delete",e))(KO||{}),$O=(e=>(e.SEARCH_LIST="/pro-mgr/api/font/searchList",e.SET="/pro-mgr/api/font/set",e.DELETE="/pro-mgr/api/font/delete",e))($O||{}),ZO=(e=>(e.SEARCH_LIST="/pro-mgr/api/blob/searchList",e.SET="/pro-mgr/api/blob/set",e))(ZO||{}),QO=(e=>(e.LIST="/pro-mgr/api/attr/list",e.SEARCH_LIST="/pro-mgr/api/attr/searchList",e.CREATE="/pro-mgr/api/attr/create",e.UPLOAD="/pro-mgr/api/attr/upload",e.DELETE="/pro-mgr/api/attr/delete",e.TICKET="/pro-mgr/api/attr/ticket",e))(QO||{}),eR=(e=>(e.GET_BACKUP="/pro-mgr/api/client/getBackup",e.GET_LIBS="/pro-mgr/api/client/getLibs",e.CREATE_LIB="/pro-mgr/api/client/createLib",e.CREATE_PROJECT="/pro-mgr/api/client/createProject",e.OPEN_PROJECT="/pro-mgr/api/client/openProject",e.DELETE_PROJECT="/pro-mgr/api/client/deleteProject",e.COPY_PROJECT="/pro-mgr/api/client/copyProject",e.CLOSE_PROJECT="/pro-mgr/api/client/closeProject",e.GET_PROJECT_PATHS="/pro-mgr/api/client/getProjectPaths",e.SELECT_PATH="/pro-mgr/api/client/selectPath",e.OPEN_DIALOG="/pro-mgr/api/client/openDialog",e.SELECT_DIR="/pro-mgr/api/client/selectDir",e.SELECT_FILE="/pro-mgr/api/client/selectFile",e.EXPORT_FILE="/pro-mgr/api/client/exportFile",e.CACHE_LIST="/pro-mgr/api/client/cacheList",e.GET_CACHE="/pro-mgr/api/client/getCache",e.SET_CACHE="/pro-mgr/api/client/setCache",e.DELETE_CACHE="/pro-mgr/api/client/deleteCache",e.PROJECT_HISTORY="/pro-mgr/api/client/projectHistory",e.DELETE_HISTORY="/pro-mgr/api/client/deletHistory",e.IS_EXIST_KV_CACHE="/pro-mgr/api/client/isExistKVCache",e.OPEN_URL="/pro-mgr/api/client/openURL",e))(eR||{}),tR=(e=>(e.LOG="/pro-mgr/api/other/log",e.COMPONENT_LOG="/pro-mgr/api/other/componentLog",e.TEAMS="/pro-mgr/api/other/teams",e.GET_EDITOR_VERSION="/pro-mgr/api/other/getEditorVersion",e.SET_EDITOR_VERSION="/pro-mgr/api/other/setEditorVersion",e))(tR||{}),lh={PROJECT:HO,BRANCH:jO,SCHEMATIC:zO,DOCUMENT:XO,DEVICE:WO,COMPONENT:qO,TAG:JO,COPPER:KO,FONT:$O,BLOB:ZO,ATTR:QO,CLIENT:eR,OTHER:tR},bx=o0(l0()),Wy={bus:void 0,get messageBus(){if(Wy.bus===void 0)if(typeof window<"u"){let e=ut();e._MSG_BUS_=e._MSG_BUS_||new bx.MessageBus,Wy.bus=e._MSG_BUS_}else self._WORKER_BUS_=self._WORKER_BUS_||new bx.WorkerMessageBridge(new bx.MessageBus,self),Wy.bus=self._WORKER_BUS_;return Wy.bus},get messageBus2(){return self._MSG_BUS2_=self._MSG_BUS2_||new bx.MessageBus2},loginedUserUuid:void 0},xt=Wy,tH=(e=>(e[e.COMPONENT=2]="COMPONENT",e[e.NET_FLAG=18]="NET_FLAG",e[e.NET_PORT=19]="NET_PORT",e[e.DRAWING=20]="DRAWING",e[e.NON_ELECTRICAL=21]="NON_ELECTRICAL",e[e.SHORT_CIRCUIT_FLAG=22]="SHORT_CIRCUIT_FLAG",e[e.BLOCK_SYMBOL=17]="BLOCK_SYMBOL",e))(tH||{}),iH=(e=>(e.SYMBOL="S",e.FOOTPRINT="F",e.PRODUCT="P",e.MODEL_3D="3D",e))(iH||{}),rH=(e=>(e.BOTTOM_COMPONENT_LIB="BOTTOM_COMPONENT_LIB",e.DIALOG="DIALOG",e))(rH||{}),nH=["S","F","P","3D"],sH=["F","3D"],aH=(e=>(e.ZIP=".zip",e.PRJ=".epro",e.PRJ2=".epro2",e.EPRU=".epru",e.SCH=".esch",e.PCB=".epcb",e.PANEL=".epan",e.PANEL_LIB=".epanl",e.SYMBOL=".esym",e.FOOTPRINT=".efoo",e.INSTANCE=".eins",e.COPPER=".ecop",e.BLOB=".eblob",e.FONT=".efon",e.ELIBZ=".elibz",e.ELIBZ2=".elibz2",e.ELIBU=".elibu",e.IMAGE=".webp",e))(aH||{}),sd="|",oH=/^[^|]+(\|[^|]+)?$/,lH=(e=>(e.Board="Board",e.Schematic="Schematic",e.Sheet="Sheet",e.Simulation="Simulation",e.Pcb="Pcb",e.Panel="Panel",e.SchCanvas="SchCanvas",e.PcbCanvas="PcbCanvas",e.PanelCanvas="PanelCanvas",e.SimulationCanvas="SimulationCanvas",e))(lH||{}),cH=(e=>(e.Device="Device",e.Symbol="Symbol",e.Footprint="Footprint",e))(cH||{}),NL=[{value:"",text:"All"},{value:2,text:"Component"},{value:20,text:{content:"symbolType",value:"Drawing",options:null}},{value:18,text:"Net Flag"},{value:19,text:"Net Port"},{value:25,text:"Off Page Connector"},{value:31,text:"Differential Pairs Flag"},{value:21,text:{content:"symbolType",value:"Non-Electronic Flag",options:null}},{value:22,text:"Short Flag"}],ML=[{value:"",text:"All"},{value:2,text:"Component Symbol"},{value:20,text:"Drawing Symbol"},{value:18,text:"Netflag Symbol"},{value:19,text:"Netport Symbol"},{value:25,text:"Off Page Connector Symbol"},{value:31,text:"Differential Pairs Flag Symbol"},{value:21,text:"Non-Electronic Symbol"},{value:22,text:"Short Flag"}],uH=["S"],hH=["S"],dH=["S"],pH=["3D"],fH={footprint:sH,device:nH,symbol:uH,model3D:pH,panelLib:hH,cbb:dH,modelSimLib:[]},mH=(e=>(e.eprj=".eprj",e.eprj_backup=".eprj_backup",e.eprj2=".eprj2",e))(mH||{});async function gH(e){let t=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(i)).map(r=>r.toString(16).padStart(2,"0")).join("")}var iR=[2,20,18,19,21,22,17,25,31];function Xx(e){return e&&iR.indexOf(e)>=0}function rR(e){return iR.indexOf(e)>=0&&e!==17}function yH(e){return e===""?!1:!!(e&&oH.test(e))}var bH=async e=>{let{keys:t,values:i}=nR(e);return await gH([...t,...i].sort().join(""))},nR=e=>{let t=new Set,i=new Set;for(let r in e){let n=e[r];if(t.add(r),Array.isArray(n))i.add(JSON.stringify(n.sort()));else if(Object.prototype.toString.call(n)==="[object Object]"){let{keys:s,values:a}=nR(n);t=new Set([...t,...s]),i=new Set([...i,...a])}else i.add(JSON.stringify(n))}return{keys:t,values:i}};function BL(e){let{uuid:t,path:i}=e;return t?t+(i?`${sd}${i}`:""):void 0}function xH(e){let{source:t,path:i}=e;return t+(i?`${sd}${i}`:"")}async function bT(e,t){if(t)return t;let{updateTime:i}=e;return i?String(i):await bH(e)}async function EH(e){let{data:t,force:i=!0,defalut:r}=e,{source:n,version:s}=t;n?(yH(n)||(t.source=BL(t)),n.includes(sd)||(t.source=xH(t)),s?s==="1"&&(t.version=await bT(t)):t.version=await bT(t,r)):i&&(t.source=BL(t),t.version=await bT(t,r))}function sR(){let e=navigator.userLanguage||navigator.language;return e&&e.includes("zh")?"zh-cn":"en"}function xT(e){let{tags:t,custom_tags:i="[]"}=e;if(i==="[object Object]"&&(i=""),(!i||typeof i!="string"||i==="[]")&&t){if(Array.isArray(t)&&t.length)i=JSON.stringify(t);else if(Object.prototype.toString.call(t)==="[object Object]"){let r=sR()==="en",n=[];if(t.parent_tag){let{name:s,name_cn:a}=t.parent_tag;if(r&&s?n.push(s):!r&&a?n.push(a):s&&n.push(s),t.child_tag){let{name:o,name_cn:l}=t.child_tag;r&&o?n.push(o):!r&&l?n.push(l):o&&n.push(o)}}i=JSON.stringify(n)}}return e.custom_tags=i,e.custom_tags}function wa(e){return String(e).length===13?Number(e):String(e).length===10?Number(e)*1e3:Number(e)}function Sm(e){var t;return e.path||e.project_uuid||((t=e.owner)==null?void 0:t.uuid)}var SH=o0(l0()),aR=(e=>e)(aR||{}),oR=(e=>(e.GET="/PrjDB/project/getData",e.UPDATE="/PrjDB/project/updateData",e.COUNT_DOC="/PrjDB/project/countDoc",e.GET_HISTORY_NODE="/PrjDB/project/getHistoricalNodes",e.GET_HISTORY_UPDATETIME="/PrjDB/project/getHistoryUpdatetime",e.GET_HISTORY_PROJECT="/PrjDB/project/getHistoricalProject",e.START_BATCH_UPLOAD="/PrjDB/project/startBatchUpload",e.END_BATCH_UPLOAD="/PrjDB/project/endBatchUpload",e.AWAIT_UPLOAD_END="/PrjDB/project/awaitUploadEnd",e.GET_MAX_TICKET="/PrjDB/project/getMaxTicket",e.GET_DOC_MAX_TICKET="/PrjDB/project/getDocMaxTicket",e.SAVE_PEND_DATA="/PrjDB/project/savePendData",e.REVOKE_PEND_DATA="/PrjDB/project/revokePendData",e.GET_CLIENT="/PrjDB/project/getClient",e.GET_BRANCH_DATA="/PrjDB/project/getBranchData",e.HISTORIES="/PrjDB/project/histories",e.COMPRESS="/PrjDB/project/compress",e.FLOW_WRITE="/PrjDB/project/flowWrite",e.GET_RELATED="/PrjDB/project/getRelated",e))(oR||{}),lR=(e=>(e.GET="/PrjDB/config/getData",e.UPDATE="/PrjDB/config/updateData",e))(lR||{}),cR=(e=>(e.GET="/PrjDB/board/getData",e.ADD="/PrjDB/board/addData",e.UPDATE="/PrjDB/board/updateData",e.DELETE="/PrjDB/board/deleteData",e.GET_ALL_KV="/PrjDB/board/getAllKVData",e.GET_ALL_ARR="/PrjDB/board/getAllArrData",e.TRY_RENAME="/PrjDB/board/tryRename",e.IS_RENAME="/PrjDB/board/isRename",e.BATCH_DELETE="/PrjDB/board/batchDelete",e.GET_BIND_KEYS="/PrjDB/board/getBindKeys",e))(cR||{}),uR=(e=>(e.GET="/PrjDB/schematic/getData",e.GET_BY_NAME="/PrjDB/schematic/getDataByName",e.TRY_RENAME="/PrjDB/schematic/tryRename",e.UPDATE_IN_LOCAL="/PrjDB/schematic/updateDataInLocal",e.ADD="/PrjDB/schematic/addData",e.UPDATE="/PrjDB/schematic/updateData",e.DEL="/PrjDB/schematic/delData",e.GET_ALL_KV="/PrjDB/schematic/getAllKVDatas",e.GET_UUID_BY_NAME="/PrjDB/schematic/getIdByName",e.GET_NAME_BY_UUID="/PrjDB/schematic/getNameById",e.GET_DISPLAY_NAME_BY_UUID="/PrjDB/schematic/getDisplayNameById",e.GET_ALL_ARR="/PrjDB/schematic/getAllArrDatas",e.GET_BY_SOURCE_VERSION="/PrjDB/schematic/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/schematic/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/schematic/getAllArrDatasBySource",e.IS_RENAME="/PrjDB/schematic/isRename",e.BATCH_DELETE="/PrjDB/schematic/batchDelete",e))(uR||{}),hR=(e=>(e.ADD="/PrjDB/sheet/addData",e.DEL="/PrjDB/sheet/delData",e.UPDATE="/PrjDB/sheet/updateData",e.UPDATE_LOTS="/PrjDB/sheet/updateLotDatas",e.GET_ALL_KV="/PrjDB/sheet/getAllKVDatas",e.GET="/PrjDB/sheet/getData",e.GET_ALL_ARR="/PrjDB/sheet/getAllArrDatas",e.GET_LOTS_ARR="/PrjDB/sheet/getLotsArrDatas",e.GET_CANVAS="/PrjDB/sheet/getCanvas",e.SET_CANVAS="/PrjDB/sheet/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/sheet/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/sheet/unwatchCanvas",e.GET_BY_SOURCE_VERSION="/PrjDB/sheet/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/sheet/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/sheet/getAllArrDatasBySource",e.TRY_RENAME="/PrjDB/sheet/tryRename",e.IS_RENAME="/PrjDB/sheet/isRename",e.BATCH_DELETE="/PrjDB/sheet/batchDelete",e.GET_ALL_KEYS="/PrjDB/sheet/getAllPrimaryKeys",e))(hR||{}),dR=(e=>(e.ADD="/PrjDB/simulation/addData",e.DEL="/PrjDB/simulation/delData",e.UPDATE="/PrjDB/simulation/updateData",e.UPDATE_LOTS="/PrjDB/simulation/updateLotDatas",e.GET_ALL_KV="/PrjDB/simulation/getAllKVDatas",e.GET="/PrjDB/simulation/getData",e.GET_ALL_ARR="/PrjDB/simulation/getAllArrDatas",e.GET_LOTS_ARR="/PrjDB/simulation/getLotsArrDatas",e.GET_CANVAS="/PrjDB/simulation/getCanvas",e.SET_CANVAS="/PrjDB/simulation/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/simulation/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/simulation/unwatchCanvas",e.GET_BY_SOURCE_VERSION="/PrjDB/simulation/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/simulation/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/simulation/getAllArrDatasBySource",e.TRY_RENAME="/PrjDB/simulation/tryRename",e.IS_RENAME="/PrjDB/simulation/isRename",e.BATCH_DELETE="/PrjDB/simulation/batchDelete",e.GET_ALL_KEYS="/PrjDB/simulation/getAllPrimaryKeys",e))(dR||{}),pR=(e=>(e.GET="/PrjDB/pcb/getData",e.GET_BY_TITLE="/PrjDB/pcb/getDataByTitle",e.GET_UUID_BY_TITLE="/PrjDB/pcb/getIdByTitle",e.ADD="/PrjDB/pcb/addData",e.DEL="/PrjDB/pcb/delData",e.CREATE_SUB="/PrjDB/pcb/createSub",e.UPDATE_SUB="/PrjDB/pcb/updateSubInherit",e.UPDATE="/PrjDB/pcb/updateData",e.UPDATE_LOTS="/PrjDB/pcb/updateLotDatas",e.GET_ALL_KV="/PrjDB/pcb/getAllKVDatas",e.GET_ALL_ARR="/PrjDB/pcb/getAllArrDatas",e.GET_CANVAS="/PrjDB/pcb/getCanvas",e.SET_CANVAS="/PrjDB/pcb/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/pcb/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/pcb/unwatchCanvas",e.GET_BY_SOURCE_VERSION="/PrjDB/pcb/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/pcb/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/pcb/getAllArrDatasBySource",e.TRY_RENAME="/PrjDB/pcb/tryRename",e.IS_RENAME="/PrjDB/pcb/isRename",e.BATCH_DELETE="/PrjDB/pcb/batchDelete",e.GET_ALL_KEYS="/PrjDB/pcb/getAllPrimaryKeys",e))(pR||{}),fR=(e=>(e.GET="/PrjDB/panel/getData",e.ADD="/PrjDB/panel/addData",e.DEL="/PrjDB/panel/delData",e.UPDATE="/PrjDB/panel/updateData",e.UPDATE_LOTS="/PrjDB/panel/updateLotDatas",e.GET_ALL_KV="/PrjDB/panel/getAllKVDatas",e.GET_ALL_ARR="/PrjDB/panel/getAllArrDatas",e.GET_CANVAS="/PrjDB/panel/getCanvas",e.SET_CANVAS="/PrjDB/panel/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/panel/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/panel/unwatchCanvas",e.TRY_RENAME="/PrjDB/panel/tryRename",e.IS_RENAME="/PrjDB/panel/isRename",e.BATCH_DELETE="/PrjDB/panel/batchDelete",e.GET_ALL_KEYS="/PrjDB/panel/getAllPrimaryKeys",e))(fR||{}),mR=(e=>(e.GET_BY_TITLE="/PrjDB/symbol/getDataByTitle",e.GET="/PrjDB/symbol/getData",e.ADD="/PrjDB/symbol/addData",e.CREATE="/PrjDB/symbol/createData",e.COVER="/PrjDB/symbol/coverData",e.CLONE="/PrjDB/symbol/cloneData",e.DEL="/PrjDB/symbol/delData",e.UPDATE="/PrjDB/symbol/updateData",e.GET_UUIDS_BY_TITLE="/PrjDB/symbol/getIdsByTitle",e.GET_TITLE_BY_UUID="/PrjDB/symbol/getTitleById",e.GET_ALL_KV="/PrjDB/symbol/getAllKVDatas",e.GET_BY_SOURCE_VERSION="/PrjDB/symbol/getDataBySourceAndVersion",e.GET_COMPARE_TICKET="/PrjDB/symbol/getDataCompareTicket",e.GET_LAST="/PrjDB/symbol/getLastData",e.IS_EXIST="/PrjDB/symbol/isExist",e.GET_ALL_KEYS="/PrjDB/symbol/getAllPrimaryKeys",e.GET_TYPE_KEYS="/PrjDB/symbol/getTypePrimaryKeys",e.GET_ALL_ARR="/PrjDB/symbol/getAllArrDatas",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/symbol/getAllArrDatasBySource",e.GET_KEYS_BY_SOURCE="/PrjDB/symbol/getKeysBySource",e.GET_ALL_ARR_BY_TYPE="/PrjDB/symbol/getTypeDatas",e.GET_STR="/PrjDB/symbol/getStr",e.GET_CANVAS="/PrjDB/symbol/getCanvas",e.SET_CANVAS="/PrjDB/symbol/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/symbol/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/symbol/unwatchCanvas",e.TRY_RENAME="/PrjDB/symbol/tryRename",e.WITH_ORIGINS="/PrjDB/symbol/withOrigins",e.IS_RENAME="/PrjDB/symbol/isRename",e.IS_CHANGE="/PrjDB/symbol/isChange",e.BATCH_DELETE="/PrjDB/symbol/batchDelete",e.GET_LIST="/PrjDB/symbol/getList",e))(mR||{}),gR=(e=>(e.GET_BY_TITLE="/PrjDB/footprint/getDataByTitle",e.GET="/PrjDB/footprint/getData",e.IS_EXIST="/PrjDB/footprint/isExist",e.ADD="/PrjDB/footprint/addData",e.CREATE="/PrjDB/footprint/createData",e.COVER="/PrjDB/footprint/coverData",e.CLONE="/PrjDB/footprint/cloneData",e.DEL="/PrjDB/footprint/delData",e.GET_ALL_KV="/PrjDB/footprint/getAllKVDatas",e.UPDATE="/PrjDB/footprint/updateData",e.UPDATE_IN_LOCAL="/PrjDB/footprint/updateDataInLocal",e.GET_TITLE_BY_UUID="/PrjDB/footprint/getTitleById",e.GET_BY_SOURCE_VERSION="/PrjDB/footprint/getDataBySourceAndVersion",e.GET_COMPARE_TICKET="/PrjDB/footprint/getDataCompareTicket",e.GET_LAST="/PrjDB/footprint/getLastData",e.GET_ALL_KEYS="/PrjDB/footprint/getAllPrimaryKeys",e.GET_ALL_ARR="/PrjDB/footprint/getAllArrDatas",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/footprint/getAllArrDatasBySource",e.GET_KEYS_BY_SOURCE="/PrjDB/footprint/getKeysBySource",e.GET_ALL_ARR_BY_PCB_UUID="/PrjDB/footprint/getAllArrDatasByPcbId",e.GET_KEYS_BY_PCB_UUID="/PrjDB/footprint/getKeysByPcbId",e.GET_STR="/PrjDB/footprint/getStr",e.GET_CANVAS="/PrjDB/footprint/getCanvas",e.SET_CANVAS="/PrjDB/footprint/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/footprint/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/footprint/unwatchCanvas",e.TRY_RENAME="/PrjDB/footprint/tryRename",e.WITH_ORIGINS="/PrjDB/footprint/withOrigins",e.IS_CHANGE="/PrjDB/footprint/isChange",e.IS_RENAME="/PrjDB/footprint/isRename",e.BATCH_DELETE="/PrjDB/footprint/batchDelete",e.GET_LIST="/PrjDB/footprint/getList",e))(gR||{}),yR=(e=>(e.GET="/PrjDB/device/getData",e.GET_ATTRIBUTES_KEYS="/PrjDB/device/getDeviceAttributesKeys",e.GET_ATTRIBUTES_VALUES="/PrjDB/device/getDeviceAttributesValues",e.GET_BY_TITLE="/PrjDB/device/getDataByTitle",e.ADD="/PrjDB/device/addData",e.CREATE="/PrjDB/device/createData",e.DEL="/PrjDB/device/delData",e.GET_ALL_KV="/PrjDB/device/getAllKVDatas",e.UPDATE="/PrjDB/device/updateData",e.GET_TITLE_BY_UUID="/PrjDB/device/getTitleById",e.GET_SYMBOL_UUID="/PrjDB/device/getSymbolIdById",e.GET_BY_SOURCE_VERSION="/PrjDB/device/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/device/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/device/getAllArrDatasBySource",e.GET_KEYS_BY_SOURCE="/PrjDB/device/getKeysBySource",e.GET_COMPARE_TICKET="/PrjDB/device/getDataCompareTicket",e.IS_EXIST="/PrjDB/device/isExist",e.GET_ALL_KEYS="/PrjDB/device/getAllPrimaryKeys",e.GET_ALL_ARR="/PrjDB/device/getAllArrDatas",e.GET_ALL_ARR_BY_SYMBOL_UUID="/PrjDB/device/getAllArrDatasBySymbolId",e.GET_ALL_ARR_BY_FOOTPRINT_UUID="/PrjDB/device/getAllArrDatasByfootprintId",e.TRY_RENAME="/PrjDB/device/tryRename",e.BIND_SYMBOL="/PrjDB/device/bindSymbol",e.BIND_fOOTPRINT="/PrjDB/device/bindFootprint",e.WITH_ORIGINS="/PrjDB/device/withOrigins",e.IS_CHANGE="/PrjDB/device/isChange",e.IS_RENAME="/PrjDB/device/isRename",e.BATCH_DELETE="/PrjDB/device/batchDelete",e.GET_LIST="/PrjDB/device/getList",e))(yR||{}),bR=(e=>(e.GET="/PrjDB/attr/getData",e.UPDATE="/PrjDB/attr/updateData",e.BATCH_UPDATE="/PrjDB/attr/batchUpdateData",e.ADD="/PrjDB/attr/addData",e.DEL="/PrjDB/attr/delData",e.GET_ALL_KV="/PrjDB/attr/getAllKVDatas",e.GET_ALL_ARR="/PrjDB/attr/getAllArrDatas",e.GET_ALL_ARR_BY_HASH="/PrjDB/attr/getAllArrDatasByHash",e.BATCH_DELETE="/PrjDB/attr/batchDelete",e))(bR||{}),xR=(e=>(e.GET="/PrjDB/blob/getData",e.ADD="/PrjDB/blob/addData",e.DEL="/PrjDB/blob/delData",e.GET_ALL_ARR="/PrjDB/blob/getAllArrDatas",e.BATCH_DELETE="/PrjDB/blob/batchDelete",e))(xR||{}),ER=(e=>(e.GET="/PrjDB/copper/getData",e.ADD="/PrjDB/copper/addData",e.DEL_LOTS="/PrjDB/copper/delLotDatas",e.DEL="/PrjDB/copper/delData",e.GET_ALL_KEYS="/PrjDB/copper/getAllPrimaryKeys",e.UPDATE="/PrjDB/copper/updateData",e.GET_ALL_ARR="/PrjDB/copper/getAllArrDatas",e.GET_ALL_ARR_BY_PCB_UUID="/PrjDB/copper/getAllArrDatasByPcbId",e.GET_ALL_KEYS_BY_PCB_UUID="/PrjDB/copper/getAllArrKeysByPcbId",e))(ER||{}),SR=(e=>(e.GET="/PrjDB/font/getData",e.ADD="/PrjDB/font/addData",e.DEL_LOTS="/PrjDB/font/delLotDatas",e.DEL="/PrjDB/font/delData",e.GET_ALL_KEYS="/PrjDB/font/getAllPrimaryKeys",e.UPDATE="/PrjDB/font/updateData",e.GET_ALL_ARR="/PrjDB/font/getAllArrDatas",e.GET_ALL_ARR_BY_PCB_UUID="/PrjDB/font/getAllArrDatasByPcbId",e.GET_ALL_KEYS_BY_PCB_UUID="/PrjDB/font/getAllArrKeysByPcbId",e))(SR||{}),wR=(e=>(e.BATCH_ADD="/PrjDB/variant/batchAddVariant",e.ADD="/PrjDB/variant/addData",e.DELETE="/PrjDB/variant/deleteData",e.BATCH_DELETE="/PrjDB/variant/batchDeleteData",e.BATCH_RESTORE="/PrjDB/variant/batchRestoreData",e.GET="/PrjDB/variant/getData",e.GET_ALL_ARR_BY_SID="/PrjDB/variant/getAllArrDatasBySid",e.UPDATE_TITLE="/PrjDB/variant/updateTitle",e.UPDATE_NOT_GROUPED="/PrjDB/variant/updateNotGrouped",e.BATCH_UPDATE_SORT="/PrjDB/variant/batchUpdateZIndex",e))(wR||{}),vR=(e=>(e.BATCH_ADD="/PrjDB/componentGroup/batchAddData",e.ADD="/PrjDB/componentGroup/addData",e.DELETE="/PrjDB/componentGroup/deleteData",e.BATCH_DELETE="/PrjDB/componentGroup/batchDeleteData",e.BATCH_RESTORE="/PrjDB/componentGroup/batchRestoreData",e.GET="/PrjDB/componentGroup/getData",e.GET_ALL_ARR_BY_SID="/PrjDB/componentGroup/getAllArrDatasBySid",e.GET_ATTR_DATA="/PrjDB/componentGroup/getComponentGroupData",e.UPDATE_TITLE="/PrjDB/componentGroup/updateTitle",e.BATCH_UPDATE_SORT="/PrjDB/componentGroup/batchUpdateZIndex",e.BATCH_UPLOAD_VARIANT_INDEX="/PrjDB/componentGroup/batchUploadGroupSortInVariant",e.BATCH_DELETE_VARIANT_INDEX="/PrjDB/componentGroup/batchDeleteGroupSortInVariant",e.UPLOAD_ATTR_DATA="/PrjDB/componentGroup/uploadComponentGroupData",e.BATCH_DELETE_ATTR_DATA="/PrjDB/componentGroup/batchDeleteComponentGroupData",e))(vR||{}),ci={VARIANT:wR,COMPONENT_GROUP:vR,COMMON:aR,PROJECT:oR,CONFIG:lR,BOARD:cR,SCHEMATIC:uR,SHEET:hR,SIMULATION:dR,PCB:pR,PANEL:fR,SYMBOL:mR,FOOTPRINT:gR,DEVICE:yR,ATTR:bR,BLOB:xR,COPPER:ER,FONT:SR};function Lp(e){return!e.data}function wH(e){return!!(e.path&&e.uuid&&e.docType&&e.isProject!==void 0&&Object.keys(e).length===4)}async function ud(e){let{origin:t,target:i}=e;if(i.isProject){let r={uuid:i.uuid,data:t,overwriteCanvas:Lp(t)};if(i.docType===4)return{success:(await xt.messageBus.rpcCall(ci.FOOTPRINT.COVER,[r,i.path])).message.success};if(Xx(i.docType))return{success:(await xt.messageBus.rpcCall(ci.SYMBOL.COVER,[r,i.path])).message.success};throw new Error("Api call error!")}else{let r=await qL.getProLibSource(t);if(r.success===!1)return{success:!1,code:r.code,message:r.message};let n=r.result,s=await qL.getProLibSource(i);if(s.success===!1)return{success:!1,code:s.code,message:s.message};let a=s.result,o=_l(),l;if(i.docType===4)l=Jv(a,n,{docType:qy.FOOTPRINT,uuid:i.uuid,client:o});else if(i.docType===29)l=Jv(a,n,{docType:qy.PANEL_LIB,uuid:i.uuid,client:o});else if(Xx(i.docType))l=Jv(a,n,{docType:qy.SYMBOL,uuid:i.uuid,client:o});else throw new Error("Api call error!");let c={path:i.path,uuid:i.uuid,dataStr:l},{message:u}=await xt.messageBus.rpcCall(lh.COMPONENT.SET_HISTORY,c);return u.success===!1?{success:!1,code:u.code,message:u.message}:{success:!0}}}function TR(e){return self[e]=self[e]||new SH.BroadcastChannelMessageBus(e)}var vH=(e=>(e.OPEN="/pro-mgr/project/open",e.CLOSE="/pro-mgr/project/close",e.TEMP_OPEN="/pro-mgr/project/tempOpen",e.TEMP_OPEN_BY_STRING="/pro-mgr/project/tempOpenByString",e.TEMP_CLOSE="/pro-mgr/project/tempClose",e.ON_OPENED="/pro-mgr/project/onOpened",e.ON_TEMP_OPENED="/pro-mgr/project/onTempOpened",e.BEFORE_CLOSE="/pro-mgr/project/beforeClose",e.ON_CLOSED="/pro-mgr/project/onClosed",e.ON_TEMP_CLOSED="/pro-mgr/project/onTempClosed",e.ON_FAILED="/pro-mgr/project/onFailed",e.GET_RECENT_PROJECT_LIST="/pro-mgr/getRecentPrjList",e.UPDATE_PROJECT="/pro-mgr/updateProject",e.DEL_PROJECT="/pro-mgr/deleteProject",e.HAS="/pro-mgr/hasProject",e))(vH||{}),TH=(e=>(e.SYSTEM="system",e.INTERNAL="Internal",e.PERSONAL="personal",e.PROJECT="project",e.STAR="star",e.TEAMS="teams",e.USER="user",e.CLIENT="client",e.PUBLIC="public",e.OSHWHUB="oshwhub",e.EXTEND="extend",e))(TH||{}),IH=(e=>(e.DEVICE="device",e.SYMBOL="symbol",e.FOOTPRINT="footprint",e.CBB="cbb",e.MODEL3D="model3D",e.PANEL_LIB="panelLib",e.MODEL_SIM_LIB="modelSimLib",e))(IH||{}),gI={D3Model:{client3DModelList:"api/client/steps"}},it=class{};it.CANVAS_UNIT_MM="mm",it.CANVAS_UNIT_MIL="mil",it.HEX_BLACK_COLOR="#000000",it.HEX_WHITE_COLOR="#FFFFFF",it.HEX_RED_COLOR="#FF0000",it.HEX_GREEN_COLOR="#00FF00",it.HEX_BLUE_COLOR="#0000FF",it.HEX_GRAY_COLOR1="#F1F1F1",it.HEX_GRAY_COLOR2="#EFEFEF",it.HEX_GRAY_COLOR3="#999999",it.HEX_GRAY_COLOR4="#666666",it.HEX_GRAY_COLOR5="#333333",it.HEX_GRAY_COLOR6="#CCCCCC",it.DEFAULT_PAGESIZE=50,it.SYMBOLTYPE_ITEM_ALL_VALUE="@all",it.SYMBOLTYPE_ITEM_ALL_TITLE="All",it.D3MVIEW_DEFAULT_TRANSFORM="0, 0, 0, 0, 0, 0, 0, 0, 0",it.DEVICE_INDEX_TAG="$_",it.DEVICE_SPLIT_TAG="@_",it.LIB_SPLIT_TAG="#_",it.CATEGORY_ITEM_ALL_VALUE="@all",it.CATEGORY_ITEM_ALL_TITLE="All",it.FAVORITELIB_UUID="star",it.SYSTEMLIB_UUID="0819f05c4eef4c71ace90d822a990e87",it.SYSTEMLIB_UUID_ALIAS="lcsc",it.USERLIB_ALIAS="mine",it.PUBLICLIB_ALIAS="user",it.STD_PUBLIC_LIB_UUID="stdPublic",it.RECENT_LIB_UUID="recent",it.INTERNAL_LIB_ALIAS="Internal",it.PERSIONAL_WORKSPACE="Personal",it.EDU_WORKSPACE="6d84b27f18f540b6a31c4d657314ab13",it.EDA_TEST_WORKSPACE="407ec92f2a2f4275bf08cbebf64f5e08",it.LIB_SYSTEM_KEY="system",it.LIB_PROJECT_KEY="project",it.LIB_PERSONAL_KEY="personal",it.LIB_PUBLIC_KEY="public",it.LIB_INTERNAL_KEY="Internal",it.LIB_FAVORITE_KEY="favorite",it.LIB_TEMAS_KEY="teams",it.API=gI,it.ERR_CODE={NORMAL:-1,DUP_NAME:-9001};var kL={},AH=(function(e,t,i,r,n){var s=new Worker(kL[t]||(kL[t]=URL.createObjectURL(new Blob([e+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return s.onmessage=function(a){var o=a.data,l=o.$e$;if(l){var c=new Error(l[0]);c.code=l[1],c.stack=l[2],n(c,null)}else n(null,o)},s.postMessage(i,r),s}),dr=Uint8Array,eo=Uint16Array,y0=Int32Array,wm=new dr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),vm=new dr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),n0=new dr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),IR=function(e,t){for(var i=new eo(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];for(var n=new y0(i[30]),r=1;r<30;++r)for(var s=i[r];s<i[r+1];++s)n[s]=s-i[r]<<5|r;return{b:i,r:n}},AR=IR(wm,2),yI=AR.b,Wx=AR.r;yI[28]=258,Wx[258]=28;var CR=IR(vm,0),DR=CR.b,VT=CR.r,s0=new eo(32768);for(Yr=0;Yr<32768;++Yr)Qu=(Yr&43690)>>1|(Yr&21845)<<1,Qu=(Qu&52428)>>2|(Qu&13107)<<2,Qu=(Qu&61680)>>4|(Qu&3855)<<4,s0[Yr]=((Qu&65280)>>8|(Qu&255)<<8)>>1;var Qu,Yr,Ll=(function(e,t,i){for(var r=e.length,n=0,s=new eo(t);n<r;++n)e[n]&&++s[e[n]-1];var a=new eo(t);for(n=1;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;var o;if(i){o=new eo(1<<t);var l=15-t;for(n=0;n<r;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],h=a[e[n]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)o[s0[h]>>l]=c}else for(o=new eo(r),n=0;n<r;++n)e[n]&&(o[n]=s0[a[e[n]-1]++]>>15-e[n]);return o}),ch=new dr(288);for(Yr=0;Yr<144;++Yr)ch[Yr]=8;var Yr;for(Yr=144;Yr<256;++Yr)ch[Yr]=9;var Yr;for(Yr=256;Yr<280;++Yr)ch[Yr]=7;var Yr;for(Yr=280;Yr<288;++Yr)ch[Yr]=8;var Yr,xm=new dr(32);for(Yr=0;Yr<32;++Yr)xm[Yr]=5;var Yr,_R=Ll(ch,9,0),PR=Ll(ch,9,1),LR=Ll(xm,5,0),OR=Ll(xm,5,1),_x=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},Dl=function(e,t,i){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&i},Px=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(t&7)},Tm=function(e){return(e+7)/8|0},hu=function(e,t,i){return(t==null||t<0)&&(t=0),(i==null||i>e.length)&&(i=e.length),new dr(e.subarray(t,i))},RR=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Pi=function(e,t,i){var r=new Error(t||RR[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Pi),!i)throw r;return r},aE=function(e,t,i,r){var n=e.length,s=r?r.length:0;if(!n||t.f&&!t.l)return i||new dr(0);var a=!i,o=a||t.i!=2,l=t.i;a&&(i=new dr(n*3));var c=function(nt){var je=i.length;if(nt>je){var vt=new dr(Math.max(je*2,nt));vt.set(i),i=vt}},u=t.f||0,h=t.p||0,d=t.b||0,p=t.l,f=t.d,m=t.m,g=t.n,b=n*8;do{if(!p){u=Dl(e,h,1);var y=Dl(e,h+1,3);if(h+=3,y)if(y==1)p=PR,f=OR,m=9,g=5;else if(y==2){var E=Dl(e,h,31)+257,S=Dl(e,h+10,15)+4,w=E+Dl(e,h+5,31)+1;h+=14;for(var x=new dr(w),I=new dr(19),A=0;A<S;++A)I[n0[A]]=Dl(e,h+A*3,7);h+=S*3;for(var O=_x(I),R=(1<<O)-1,M=Ll(I,O,1),A=0;A<w;){var F=M[Dl(e,h,R)];h+=F&15;var G=F>>4;if(G<16)x[A++]=G;else{var V=0,q=0;for(G==16?(q=3+Dl(e,h,3),h+=2,V=x[A-1]):G==17?(q=3+Dl(e,h,7),h+=3):G==18&&(q=11+Dl(e,h,127),h+=7);q--;)x[A++]=V}}var C=x.subarray(0,E),N=x.subarray(E);m=_x(C),g=_x(N),p=Ll(C,m,1),f=Ll(N,g,1)}else Pi(1);else{var G=Tm(h)+4,T=e[G-4]|e[G-3]<<8,L=G+T;if(L>n){l&&Pi(0);break}o&&c(d+T),i.set(e.subarray(G,L),d),t.b=d+=T,t.p=h=L*8,t.f=u;continue}if(h>b){l&&Pi(0);break}}o&&c(d+131072);for(var P=(1<<m)-1,B=(1<<g)-1,U=h;;U=h){var V=p[Px(e,h)&P],X=V>>4;if(h+=V&15,h>b){l&&Pi(0);break}if(V||Pi(2),X<256)i[d++]=X;else if(X==256){U=h,p=null;break}else{var J=X-254;if(X>264){var A=X-257,ne=wm[A];J=Dl(e,h,(1<<ne)-1)+yI[A],h+=ne}var fe=f[Px(e,h)&B],xe=fe>>4;fe||Pi(3),h+=fe&15;var N=DR[xe];if(xe>3){var ne=vm[xe];N+=Px(e,h)&(1<<ne)-1,h+=ne}if(h>b){l&&Pi(0);break}o&&c(d+131072);var ve=d+J;if(d<N){var Fe=s-N,Ne=Math.min(N,ve);for(Fe+d<0&&Pi(3);d<Ne;++d)i[d]=r[Fe+d]}for(;d<ve;++d)i[d]=i[d-N]}}t.l=p,t.p=U,t.b=d,t.f=u,p&&(u=1,t.m=m,t.d=f,t.n=g)}while(!u);return d!=i.length&&a?hu(i,0,d):i.subarray(0,d)},au=function(e,t,i){i<<=t&7;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},sm=function(e,t,i){i<<=t&7;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8,e[r+2]|=i>>16},Lx=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var n=i.length,s=i.slice();if(!n)return{t:rd,l:0};if(n==1){var a=new dr(i[0].s+1);return a[i[0].s]=1,{t:a,l:1}}i.sort(function(w,x){return w.f-x.f}),i.push({s:-1,f:25001});var o=i[0],l=i[1],c=0,u=1,h=2;for(i[0]={s:-1,f:o.f+l.f,l:o,r:l};u!=n-1;)o=i[i[c].f<i[h].f?c++:h++],l=i[c!=u&&i[c].f<i[h].f?c++:h++],i[u++]={s:-1,f:o.f+l.f,l:o,r:l};for(var d=s[0].s,r=1;r<n;++r)s[r].s>d&&(d=s[r].s);var p=new eo(d+1),f=qx(i[u-1],p,0);if(f>t){var r=0,m=0,g=f-t,b=1<<g;for(s.sort(function(x,I){return p[I.s]-p[x.s]||x.f-I.f});r<n;++r){var y=s[r].s;if(p[y]>t)m+=b-(1<<f-p[y]),p[y]=t;else break}for(m>>=g;m>0;){var E=s[r].s;p[E]<t?m-=1<<t-p[E]++-1:++r}for(;r>=0&&m;--r){var S=s[r].s;p[S]==t&&(--p[S],++m)}f=t}return{t:new dr(p),l:f}},qx=function(e,t,i){return e.s==-1?Math.max(qx(e.l,t,i+1),qx(e.r,t,i+1)):t[e.s]=i},HT=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new eo(++t),r=0,n=e[0],s=1,a=function(l){i[r++]=l},o=1;o<=t;++o)if(e[o]==n&&o!=t)++s;else{if(!n&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(n),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(n);s=1,n=e[o]}return{c:i.subarray(0,r),n:t}},am=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},bI=function(e,t,i){var r=i.length,n=Tm(t+2);e[n]=r&255,e[n+1]=r>>8,e[n+2]=e[n]^255,e[n+3]=e[n+1]^255;for(var s=0;s<r;++s)e[n+s+4]=i[s];return(n+4+r)*8},jT=function(e,t,i,r,n,s,a,o,l,c,u){au(t,u++,i),++n[256];for(var h=Lx(n,15),d=h.t,p=h.l,f=Lx(s,15),m=f.t,g=f.l,b=HT(d),y=b.c,E=b.n,S=HT(m),w=S.c,x=S.n,I=new eo(19),A=0;A<y.length;++A)++I[y[A]&31];for(var A=0;A<w.length;++A)++I[w[A]&31];for(var O=Lx(I,7),R=O.t,M=O.l,F=19;F>4&&!R[n0[F-1]];--F);var G=c+5<<3,V=am(n,ch)+am(s,xm)+a,q=am(n,d)+am(s,m)+a+14+3*F+am(I,R)+2*I[16]+3*I[17]+7*I[18];if(l>=0&&G<=V&&G<=q)return bI(t,u,e.subarray(l,l+c));var C,N,T,L;if(au(t,u,1+(q<V)),u+=2,q<V){C=Ll(d,p,0),N=d,T=Ll(m,g,0),L=m;var P=Ll(R,M,0);au(t,u,E-257),au(t,u+5,x-1),au(t,u+10,F-4),u+=14;for(var A=0;A<F;++A)au(t,u+3*A,R[n0[A]]);u+=3*F;for(var B=[y,w],U=0;U<2;++U)for(var X=B[U],A=0;A<X.length;++A){var J=X[A]&31;au(t,u,P[J]),u+=R[J],J>15&&(au(t,u,X[A]>>5&127),u+=X[A]>>12)}}else C=_R,N=ch,T=LR,L=xm;for(var A=0;A<o;++A){var ne=r[A];if(ne>255){var J=ne>>18&31;sm(t,u,C[J+257]),u+=N[J+257],J>7&&(au(t,u,ne>>23&31),u+=wm[J]);var fe=ne&31;sm(t,u,T[fe]),u+=L[fe],fe>3&&(sm(t,u,ne>>5&8191),u+=vm[fe])}else sm(t,u,C[ne]),u+=N[ne]}return sm(t,u,C[256]),u+N[256]},NR=new y0([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),rd=new dr(0),MR=function(e,t,i,r,n,s){var a=s.z||e.length,o=new dr(r+a+5*(1+Math.ceil(a/7e3))+n),l=o.subarray(r,o.length-n),c=s.l,u=(s.r||0)&7;if(t){u&&(l[0]=s.r>>3);for(var h=NR[t-1],d=h>>13,p=h&8191,f=(1<<i)-1,m=s.p||new eo(32768),g=s.h||new eo(f+1),b=Math.ceil(i/3),y=2*b,E=function(Bt){return(e[Bt]^e[Bt+1]<<b^e[Bt+2]<<y)&f},S=new y0(25e3),w=new eo(288),x=new eo(32),I=0,A=0,O=s.i||0,R=0,M=s.w||0,F=0;O+2<a;++O){var G=E(O),V=O&32767,q=g[G];if(m[V]=q,g[G]=V,M<=O){var C=a-O;if((I>7e3||R>24576)&&(C>423||!c)){u=jT(e,l,0,S,w,x,A,R,F,O-F,u),R=I=A=0,F=O;for(var N=0;N<286;++N)w[N]=0;for(var N=0;N<30;++N)x[N]=0}var T=2,L=0,P=p,B=V-q&32767;if(C>2&&G==E(O-B))for(var U=Math.min(d,C)-1,X=Math.min(32767,O),J=Math.min(258,C);B<=X&&--P&&V!=q;){if(e[O+T]==e[O+T-B]){for(var ne=0;ne<J&&e[O+ne]==e[O+ne-B];++ne);if(ne>T){if(T=ne,L=B,ne>U)break;for(var fe=Math.min(B,ne-2),xe=0,N=0;N<fe;++N){var ve=O-B+N&32767,Fe=m[ve],Ne=ve-Fe&32767;Ne>xe&&(xe=Ne,q=ve)}}}V=q,q=m[V],B+=V-q&32767}if(L){S[R++]=268435456|Wx[T]<<18|VT[L];var nt=Wx[T]&31,je=VT[L]&31;A+=wm[nt]+vm[je],++w[257+nt],++x[je],M=O+T,++I}else S[R++]=e[O],++w[e[O]]}}for(O=Math.max(O,M);O<a;++O)S[R++]=e[O],++w[e[O]];u=jT(e,l,c,S,w,x,A,R,F,O-F,u),c||(s.r=u&7|l[u/8|0]<<3,u-=7,s.h=g,s.p=m,s.i=O,s.w=M)}else{for(var O=s.w||0;O<a+c;O+=65535){var vt=O+65535;vt>=a&&(l[u/8|0]=c,vt=a),u=bI(l,u+1,e.subarray(O,vt))}s.i=a}return hu(o,0,r+Tm(u)+n)},CH=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(i&1&&-306674912)^i>>>1;e[t]=i}return e})(),xI=function(){var e=-1;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=CH[i&255^t[r]]^i>>>8;e=i},d:function(){return~e}}},BR=function(){var e=1,t=0;return{p:function(i){for(var r=e,n=t,s=i.length|0,a=0;a!=s;){for(var o=Math.min(a+2655,s);a<o;++a)n+=r+=i[a];r=(r&65535)+15*(r>>16),n=(n&65535)+15*(n>>16)}e=r,t=n},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},Im=function(e,t,i,r,n){if(!n&&(n={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),a=new dr(s.length+e.length);a.set(s),a.set(e,s.length),e=a,n.w=s.length}return MR(e,t.level==null?6:t.level,t.mem==null?n.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,i,r,n)},kR=function(e,t){var i={};for(var r in e)i[r]=e[r];for(var r in t)i[r]=t[r];return i},FL=function(e,t,i){for(var r=e(),n=e.toString(),s=n.slice(n.indexOf("[")+1,n.lastIndexOf("]")).replace(/\s+/g,"").split(","),a=0;a<r.length;++a){var o=r[a],l=s[a];if(typeof o=="function"){t+=";"+l+"=";var c=o.toString();if(o.prototype)if(c.indexOf("[native code]")!=-1){var u=c.indexOf(" ",8)+1;t+=c.slice(u,c.indexOf("(",u))}else{t+=c;for(var h in o.prototype)t+=";"+l+".prototype."+h+"="+o.prototype[h].toString()}else t+=c}else i[l]=o}return t},xx=[],DH=function(e){var t=[];for(var i in e)e[i].buffer&&t.push((e[i]=new e[i].constructor(e[i])).buffer);return t},_H=function(e,t,i,r){if(!xx[i]){for(var n="",s={},a=e.length-1,o=0;o<a;++o)n=FL(e[o],n,s);xx[i]={c:FL(e[a],n,s),e:s}}var l=kR({},xx[i].e);return AH(xx[i].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",i,l,DH(l),r)},EI=function(){return[dr,eo,y0,wm,vm,n0,yI,DR,PR,OR,s0,RR,Ll,_x,Dl,Px,Tm,hu,Pi,aE,kH,FR,RH]},PH=function(){return[dr,eo,y0,wm,vm,n0,Wx,VT,_R,ch,LR,xm,s0,NR,rd,Ll,au,sm,Lx,qx,HT,am,bI,jT,Tm,hu,MR,Im,BH,FR]},LH=function(){return[SI,UR]},OH=function(){return[VR]},FR=function(e){return postMessage(e,[e.buffer])},RH=function(e){return e&&{out:e.size&&new dr(e.size),dictionary:e.dictionary}},od=function(e){return e.ondata=function(t,i){return postMessage([t,i],[t.buffer])},function(t){t.data.length?(e.push(t.data[0],t.data[1]),postMessage([t.data[0].length])):e.flush()}},oE=function(e,t,i,r,n,s,a){var o,l=_H(e,r,n,function(c,u){c?(l.terminate(),t.ondata.call(t,c)):Array.isArray(u)?u.length==1?(t.queuedSize-=u[0],t.ondrain&&t.ondrain(u[0])):(u[1]&&l.terminate(),t.ondata.call(t,c,u[0],u[1])):a(u)});l.postMessage(i),t.queuedSize=0,t.push=function(c,u){t.ondata||Pi(5),o&&t.ondata(Pi(4,0,1),null,!!u),t.queuedSize+=c.length,l.postMessage([c,o=u],[c.buffer])},t.terminate=function(){l.terminate()},s&&(t.flush=function(){l.postMessage([])})},hm=function(e,t){return e[t]|e[t+1]<<8},dm=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},ET=function(e,t){return dm(e,t)+dm(e,t+4)*4294967296},fn=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},GR=function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&fn(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}},SI=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&Pi(6,"invalid gzip data");var t=e[3],i=10;t&4&&(i+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[i++]);return i+(t&2)},UR=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},YR=function(e){return 10+(e.filename?e.filename.length+1:0)},NH=function(e,t){var i=t.level,r=i==0?0:i<6?1:i==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var n=BR();n.p(t.dictionary),fn(e,2,n.d())}},VR=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Pi(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&Pi(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function b0(e,t){return typeof e=="function"&&(t=e,e={}),this.ondata=t,e}var ah=(function(){function e(t,i){if(typeof t=="function"&&(i=t,t={}),this.ondata=i,this.o=t||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new dr(98304),this.o.dictionary){var r=this.o.dictionary.subarray(-32768);this.b.set(r,32768-r.length),this.s.i=32768-r.length}}return e.prototype.p=function(t,i){this.ondata(Im(t,this.o,0,0,this.s),i)},e.prototype.push=function(t,i){this.ondata||Pi(5),this.s.l&&Pi(4);var r=t.length+this.s.z;if(r>this.b.length){if(r>2*this.b.length-32768){var n=new dr(r&-32768);n.set(this.b.subarray(0,this.s.z)),this.b=n}var s=this.b.length-this.s.z;this.b.set(t.subarray(0,s),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(t.subarray(s),32768),this.s.z=t.length-s+32768,this.s.i=32766,this.s.w=32768}else this.b.set(t,this.s.z),this.s.z+=t.length;this.s.l=i&1,(this.s.z>this.s.w+8191||i)&&(this.p(this.b,i||!1),this.s.w=this.s.i,this.s.i-=2)},e.prototype.flush=function(){this.ondata||Pi(5),this.s.l&&Pi(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},e})(),MH=(function(){function e(t,i){oE([PH,function(){return[od,ah]}],this,b0.call(this,t,i),function(r){var n=new ah(r.data);onmessage=od(n)},6,1)}return e})();function BH(e,t){return Im(e,t||{},0,0)}var il=(function(){function e(t,i){typeof t=="function"&&(i=t,t={}),this.ondata=i;var r=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new dr(32768),this.p=new dr(0),r&&this.o.set(r)}return e.prototype.e=function(t){if(this.ondata||Pi(5),this.d&&Pi(4),!this.p.length)this.p=t;else if(t.length){var i=new dr(this.p.length+t.length);i.set(this.p),i.set(t,this.p.length),this.p=i}},e.prototype.c=function(t){this.s.i=+(this.d=t||!1);var i=this.s.b,r=aE(this.p,this.s,this.o);this.ondata(hu(r,i,this.s.b),this.d),this.o=hu(r,this.s.b-32768),this.s.b=this.o.length,this.p=hu(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(t,i){this.e(t),this.c(i)},e})(),HR=(function(){function e(t,i){oE([EI,function(){return[od,il]}],this,b0.call(this,t,i),function(r){var n=new il(r.data);onmessage=od(n)},7,0)}return e})();function kH(e,t){return aE(e,{i:2},t&&t.out,t&&t.dictionary)}var nne=(function(){function e(t,i){this.c=xI(),this.l=0,this.v=1,ah.call(this,t,i)}return e.prototype.push=function(t,i){this.c.p(t),this.l+=t.length,ah.prototype.push.call(this,t,i)},e.prototype.p=function(t,i){var r=Im(t,this.o,this.v&&YR(this.o),i&&8,this.s);this.v&&(GR(r,this.o),this.v=0),i&&(fn(r,r.length-8,this.c.d()),fn(r,r.length-4,this.l)),this.ondata(r,i)},e.prototype.flush=function(){ah.prototype.flush.call(this)},e})();function ST(e,t){t||(t={});var i=xI(),r=e.length;i.p(e);var n=Im(e,t,YR(t),8),s=n.length;return GR(n,t),fn(n,s-8,i.d()),fn(n,s-4,r),n}var zT=(function(){function e(t,i){this.v=1,this.r=0,il.call(this,t,i)}return e.prototype.push=function(t,i){if(il.prototype.e.call(this,t),this.r+=t.length,this.v){var r=this.p.subarray(this.v-1),n=r.length>3?SI(r):4;if(n>r.length){if(!i)return}else this.v>1&&this.onmember&&this.onmember(this.r-r.length);this.p=r.subarray(n),this.v=0}il.prototype.c.call(this,i),this.s.f&&!this.s.l&&!i&&(this.v=Tm(this.s.p)+9,this.s={i:0},this.o=new dr(0),this.push(new dr(0),i))},e})(),FH=(function(){function e(t,i){var r=this;oE([EI,LH,function(){return[od,il,zT]}],this,b0.call(this,t,i),function(n){var s=new zT(n.data);s.onmember=function(a){return postMessage(a)},onmessage=od(s)},9,0,function(n){return r.onmember&&r.onmember(n)})}return e})();function GH(e,t){var i=SI(e);return i+8>e.length&&Pi(6,"invalid gzip data"),aE(e.subarray(i,-8),{i:2},t&&t.out||new dr(UR(e)),t&&t.dictionary)}var sne=(function(){function e(t,i){this.c=BR(),this.v=1,ah.call(this,t,i)}return e.prototype.push=function(t,i){this.c.p(t),ah.prototype.push.call(this,t,i)},e.prototype.p=function(t,i){var r=Im(t,this.o,this.v&&(this.o.dictionary?6:2),i&&4,this.s);this.v&&(NH(r,this.o),this.v=0),i&&fn(r,r.length-4,this.c.d()),this.ondata(r,i)},e.prototype.flush=function(){ah.prototype.flush.call(this)},e})(),XT=(function(){function e(t,i){il.call(this,t,i),this.v=t&&t.dictionary?2:1}return e.prototype.push=function(t,i){if(il.prototype.e.call(this,t),this.v){if(this.p.length<6&&!i)return;this.p=this.p.subarray(VR(this.p,this.v-1)),this.v=0}i&&(this.p.length<4&&Pi(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),il.prototype.c.call(this,i)},e})(),UH=(function(){function e(t,i){oE([EI,OH,function(){return[od,il,XT]}],this,b0.call(this,t,i),function(r){var n=new XT(r.data);onmessage=od(n)},11,0)}return e})(),GL=(function(){function e(t,i){this.o=b0.call(this,t,i)||{},this.G=zT,this.I=il,this.Z=XT}return e.prototype.i=function(){var t=this;this.s.ondata=function(i,r){t.ondata(i,r)}},e.prototype.push=function(t,i){if(this.ondata||Pi(5),this.s)this.s.push(t,i);else{if(this.p&&this.p.length){var r=new dr(this.p.length+t.length);r.set(this.p),r.set(t,this.p.length)}else this.p=t;this.p.length>2&&(this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(this.o):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,i),this.p=null)}},e})(),ane=(function(){function e(t,i){GL.call(this,t,i),this.queuedSize=0,this.G=FH,this.I=HR,this.Z=UH}return e.prototype.i=function(){var t=this;this.s.ondata=function(i,r,n){t.ondata(i,r,n)},this.s.ondrain=function(i){t.queuedSize-=i,t.ondrain&&t.ondrain(i)}},e.prototype.push=function(t,i){this.queuedSize+=t.length,GL.prototype.push.call(this,t,i)},e})();var UL=typeof TextEncoder<"u"&&new TextEncoder,WT=typeof TextDecoder<"u"&&new TextDecoder,jR=0;try{WT.decode(rd,{stream:!0}),jR=1}catch{}var zR=function(e){for(var t="",i=0;;){var r=e[i++],n=(r>127)+(r>223)+(r>239);if(i+n>e.length)return{s:t,r:hu(e,i-1)};n?n==3?(r=((r&15)<<18|(e[i++]&63)<<12|(e[i++]&63)<<6|e[i++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):n&1?t+=String.fromCharCode((r&31)<<6|e[i++]&63):t+=String.fromCharCode((r&15)<<12|(e[i++]&63)<<6|e[i++]&63):t+=String.fromCharCode(r)}},one=(function(){function e(t){this.ondata=t,jR?this.t=new TextDecoder:this.p=rd}return e.prototype.push=function(t,i){if(this.ondata||Pi(5),i=!!i,this.t){this.ondata(this.t.decode(t,{stream:!0}),i),i&&(this.t.decode().length&&Pi(8),this.t=null);return}this.p||Pi(4);var r=new dr(this.p.length+t.length);r.set(this.p),r.set(t,this.p.length);var n=zR(r),s=n.s,a=n.r;i?(a.length&&Pi(8),this.p=null):this.p=a,this.ondata(s,i)},e})(),lne=(function(){function e(t){this.ondata=t}return e.prototype.push=function(t,i){this.ondata||Pi(5),this.d&&Pi(4),this.ondata(qT(t),this.d=i||!1)},e})();function qT(e,t){if(t){for(var i=new dr(e.length),r=0;r<e.length;++r)i[r]=e.charCodeAt(r);return i}if(UL)return UL.encode(e);for(var n=e.length,s=new dr(e.length+(e.length>>1)),a=0,o=function(h){s[a++]=h},r=0;r<n;++r){if(a+5>s.length){var l=new dr(a+8+(n-r<<1));l.set(s),s=l}var c=e.charCodeAt(r);c<128||t?o(c):c<2048?(o(192|c>>6),o(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++r)&1023,o(240|c>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|c&63)):(o(224|c>>12),o(128|c>>6&63),o(128|c&63))}return hu(s,0,a)}function YH(e,t){if(t){for(var i="",r=0;r<e.length;r+=16384)i+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return i}else{if(WT)return WT.decode(e);var n=zR(e),s=n.s,i=n.r;return i.length&&Pi(8),s}}var XR=function(e){return e==1?3:e<6?2:e==9?1:0},VH=function(e,t){for(;hm(e,t)!=1;t+=4+hm(e,t+2));return[ET(e,t+12),ET(e,t+4),ET(e,t+20)]},Ox=function(e){var t=0;if(e)for(var i in e){var r=e[i].length;r>65535&&Pi(9),t+=r+4}return t},YL=function(e,t,i,r,n,s,a,o){var l=r.length,c=i.extra,u=o&&o.length,h=Ox(c);fn(e,t,a!=null?33639248:67324752),t+=4,a!=null&&(e[t++]=20,e[t++]=i.os),e[t]=20,t+=2,e[t++]=i.flag<<1|(s<0&&8),e[t++]=n&&8,e[t++]=i.compression&255,e[t++]=i.compression>>8;var d=new Date(i.mtime==null?Date.now():i.mtime),p=d.getFullYear()-1980;if((p<0||p>119)&&Pi(10),fn(e,t,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1&&(fn(e,t,i.crc),fn(e,t+4,s<0?-s-2:s),fn(e,t+8,i.size)),fn(e,t+12,l),fn(e,t+14,h),t+=16,a!=null&&(fn(e,t,u),fn(e,t+6,i.attrs),fn(e,t+10,a),t+=14),e.set(r,t),t+=l,h)for(var f in c){var m=c[f],g=m.length;fn(e,t,+f),fn(e,t+2,g),e.set(m,t+4),t+=4+g}return u&&(e.set(o,t),t+=u),t},HH=function(e,t,i,r,n){fn(e,t,101010256),fn(e,t+8,i),fn(e,t+10,i),fn(e,t+12,r),fn(e,t+16,n)},Jx=(function(){function e(t){this.filename=t,this.c=xI(),this.size=0,this.compression=0}return e.prototype.process=function(t,i){this.ondata(null,t,i)},e.prototype.push=function(t,i){this.ondata||Pi(5),this.c.p(t),this.size+=t.length,i&&(this.crc=this.c.d()),this.process(t,i||!1)},e})(),cne=(function(){function e(t,i){var r=this;i||(i={}),Jx.call(this,t),this.d=new ah(i,function(n,s){r.ondata(null,n,s)}),this.compression=8,this.flag=XR(i.level)}return e.prototype.process=function(t,i){try{this.d.push(t,i)}catch(r){this.ondata(r,null,i)}},e.prototype.push=function(t,i){Jx.prototype.push.call(this,t,i)},e})(),une=(function(){function e(t,i){var r=this;i||(i={}),Jx.call(this,t),this.d=new MH(i,function(n,s,a){r.ondata(n,s,a)}),this.compression=8,this.flag=XR(i.level),this.terminate=this.d.terminate}return e.prototype.process=function(t,i){this.d.push(t,i)},e.prototype.push=function(t,i){Jx.prototype.push.call(this,t,i)},e})(),hne=(function(){function e(t){this.ondata=t,this.u=[],this.d=1}return e.prototype.add=function(t){var i=this;if(this.ondata||Pi(5),this.d&2)this.ondata(Pi(4+(this.d&1)*8,0,1),null,!1);else{var r=qT(t.filename),n=r.length,s=t.comment,a=s&&qT(s),o=n!=t.filename.length||a&&s.length!=a.length,l=n+Ox(t.extra)+30;n>65535&&this.ondata(Pi(11,0,1),null,!1);var c=new dr(l);YL(c,0,t,r,o,-1);var u=[c],h=function(){for(var g=0,b=u;g<b.length;g++){var y=b[g];i.ondata(null,y,!1)}u=[]},d=this.d;this.d=0;var p=this.u.length,f=kR(t,{f:r,u:o,o:a,t:function(){t.terminate&&t.terminate()},r:function(){if(h(),d){var g=i.u[p+1];g?g.r():i.d=1}d=1}}),m=0;t.ondata=function(g,b,y){if(g)i.ondata(g,b,y),i.terminate();else if(m+=b.length,u.push(b),y){var E=new dr(16);fn(E,0,134695760),fn(E,4,t.crc),fn(E,8,m),fn(E,12,t.size),u.push(E),f.c=m,f.b=l+m+16,f.crc=t.crc,f.size=t.size,d&&f.r(),d=1}else d&&h()},this.u.push(f)}},e.prototype.end=function(){var t=this;if(this.d&2){this.ondata(Pi(4+(this.d&1)*8,0,1),null,!0);return}this.d?this.e():this.u.push({r:function(){t.d&1&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var t=0,i=0,r=0,n=0,s=this.u;n<s.length;n++){var a=s[n];r+=46+a.f.length+Ox(a.extra)+(a.o?a.o.length:0)}for(var o=new dr(r+22),l=0,c=this.u;l<c.length;l++){var a=c[l];YL(o,t,a,a.f,a.u,-a.c-2,i,a.o),t+=46+a.f.length+Ox(a.extra)+(a.o?a.o.length:0),i+=a.b}HH(o,t,this.u.length,r,i),this.ondata(null,o,!0),this.d=2},e.prototype.terminate=function(){for(var t=0,i=this.u;t<i.length;t++){var r=i[t];r.t()}this.d=2},e})();var jH=(function(){function e(){}return e.prototype.push=function(t,i){this.ondata(null,t,i)},e.compression=0,e})(),dne=(function(){function e(){var t=this;this.i=new il(function(i,r){t.ondata(null,i,r)})}return e.prototype.push=function(t,i){try{this.i.push(t,i)}catch(r){this.ondata(r,null,i)}},e.compression=8,e})(),pne=(function(){function e(t,i){var r=this;i<32e4?this.i=new il(function(n,s){r.ondata(null,n,s)}):(this.i=new HR(function(n,s,a){r.ondata(n,s,a)}),this.terminate=this.i.terminate)}return e.prototype.push=function(t,i){this.i.terminate&&(t=hu(t,0)),this.i.push(t,i)},e.compression=8,e})(),fne=(function(){function e(t){this.onfile=t,this.k=[],this.o={0:jH},this.p=rd}return e.prototype.push=function(t,i){var r=this;if(this.onfile||Pi(5),this.p||Pi(4),this.c>0){var n=Math.min(this.c,t.length),s=t.subarray(0,n);if(this.c-=n,this.d?this.d.push(s,!this.c):this.k[0].push(s),t=t.subarray(n),t.length)return this.push(t,i)}else{var a=0,o=0,l=void 0,c=void 0;this.p.length?t.length?(c=new dr(this.p.length+t.length),c.set(this.p),c.set(t,this.p.length)):c=this.p:c=t;for(var u=c.length,h=this.c,d=h&&this.d,p=function(){var b,y=dm(c,o);if(y==67324752){a=1,l=o,f.d=null,f.c=0;var E=hm(c,o+6),S=hm(c,o+8),w=E&2048,x=E&8,I=hm(c,o+26),A=hm(c,o+28);if(u>o+30+I+A){var O=[];f.k.unshift(O),a=2;var R=dm(c,o+18),M=dm(c,o+22),F=YH(c.subarray(o+30,o+=30+I),!w);R==4294967295?(b=x?[-2]:VH(c,o),R=b[0],M=b[1]):x&&(R=-1),o+=A,f.c=R;var G,V={name:F,compression:S,start:function(){if(V.ondata||Pi(5),!R)V.ondata(null,rd,!0);else{var q=r.o[S];q||V.ondata(Pi(14,"unknown compression type "+S,1),null,!1),G=R<0?new q(F):new q(F,R,M),G.ondata=function(L,P,B){V.ondata(L,P,B)};for(var C=0,N=O;C<N.length;C++){var T=N[C];G.push(T,!1)}r.k[0]==O&&r.c?r.d=G:G.push(rd,!0)}},terminate:function(){G&&G.terminate&&G.terminate()}};R>=0&&(V.size=R,V.originalSize=M),f.onfile(V)}return"break"}else if(h){if(y==134695760)return l=o+=12+(h==-2&&8),a=3,f.c=0,"break";if(y==33639248)return l=o-=4,a=3,f.c=0,"break"}},f=this;o<u-4;++o){var m=p();if(m==="break")break}if(this.p=rd,h<0){var g=a?c.subarray(0,l-12-(h==-2&&8)-(dm(c,l-16)==134695760&&4)):c.subarray(0,o);d?d.push(g,!!a):this.k[+(a==2)].push(g)}if(a&2)return this.push(c.subarray(o),i);this.p=c.subarray(o)}i&&(this.c&&Pi(13),this.p=null)},e.prototype.register=function(t){this.o[t.compression]=t},e})(),zH=(e=>(e[e.UNAUTHORIZED=401]="UNAUTHORIZED",e[e.LOGIN_FAIL=402]="LOGIN_FAIL",e[e.PERMISSION_DENIED=422]="PERMISSION_DENIED",e[e.PERMISSION_DENIED1=1111111]="PERMISSION_DENIED1",e[e.PERMISSION_DENIED_PARAMS=1111112]="PERMISSION_DENIED_PARAMS",e[e.DATA_NOT_FOUND=1111113]="DATA_NOT_FOUND",e[e.PARAMS_DATA_NOT_FOUND=1111114]="PARAMS_DATA_NOT_FOUND",e[e.REQUEST_PARAM_ILLEGAL=42222]="REQUEST_PARAM_ILLEGAL",e[e.REQUEST_PARAM_ILLEGAL1=1111115]="REQUEST_PARAM_ILLEGAL1",e[e.REQUEST_PARAMS_ILLEGAL2=1111116]="REQUEST_PARAMS_ILLEGAL2",e[e.REQUEST_PARAMS_NOT_NULL=1111117]="REQUEST_PARAMS_NOT_NULL",e[e.REQUEST_PARAMS_NOT_ALL_NULL=1111118]="REQUEST_PARAMS_NOT_ALL_NULL",e[e.REQUEST_PARAMS_MUST_ARRAY=1111119]="REQUEST_PARAMS_MUST_ARRAY",e[e.REQUEST_PARAMS_MUST_STRING=1111120]="REQUEST_PARAMS_MUST_STRING",e[e.REQUEST_PARAMS_MUST_NUMBER=1111121]="REQUEST_PARAMS_MUST_NUMBER",e[e.REQUEST_PARAMS_MUST_NUMBER_ARRAY=1111122]="REQUEST_PARAMS_MUST_NUMBER_ARRAY",e[e.REQUEST_PARAMS_MUST_STRING_ARRAY=1111123]="REQUEST_PARAMS_MUST_STRING_ARRAY",e[e.REQUEST_PARAMS_LENGTH_ERROR=1111124]="REQUEST_PARAMS_LENGTH_ERROR",e[e.REQUEST_PARAMS_TYPE_ERROR=1111125]="REQUEST_PARAMS_TYPE_ERROR",e[e.ILLEGAL_NAME=2001]="ILLEGAL_NAME",e[e.ILLEGAL_NAME1=1111126]="ILLEGAL_NAME1",e[e.ILLEGAL_NAME_ZH=1111128]="ILLEGAL_NAME_ZH",e[e.UUID_ERROR=1111127]="UUID_ERROR",e[e.DUPLICATE_DATA=1000001]="DUPLICATE_DATA",e[e.DUPLICATE_DATA1=11e3]="DUPLICATE_DATA1",e[e.DUPLICATE_DATA_PARAMS=1000017]="DUPLICATE_DATA_PARAMS",e[e.UPLOAD_LIMIT=10034]="UPLOAD_LIMIT",e[e.MORE_THAN_LIMIT=1000003]="MORE_THAN_LIMIT",e[e.FILE_MORE_THAN_LIMIT=1000004]="FILE_MORE_THAN_LIMIT",e[e.PARAMS_MORE_THAN_LIMIT=1000005]="PARAMS_MORE_THAN_LIMIT",e[e.IMAGE_MORE_THAN_LIMIT_PARAMS=1000006]="IMAGE_MORE_THAN_LIMIT_PARAMS",e[e.FILE_MORE_THAN_LIMIT_PARAMS=1000007]="FILE_MORE_THAN_LIMIT_PARAMS",e[e.END_MUST_AFTER_START=1000019]="END_MUST_AFTER_START",e[e.REQUEST_PARAMS_TIME_ERROR=1000009]="REQUEST_PARAMS_TIME_ERROR",e[e.FILES_PATH_NOT_FOUND=1000018]="FILES_PATH_NOT_FOUND",e[e.FILES_DATA_NOT_FOUND=1000011]="FILES_DATA_NOT_FOUND",e[e.FILES_TYPE_ERROR=1000012]="FILES_TYPE_ERROR",e[e.FILES_TYPE_MUST_BE_ONE=1000013]="FILES_TYPE_MUST_BE_ONE",e[e.SET_WATERMARK_FAIL=1000014]="SET_WATERMARK_FAIL",e[e.MYSQL_CRUD_ERROR=1000015]="MYSQL_CRUD_ERROR",e[e.PARAMS_JSON_FAILED=1000016]="PARAMS_JSON_FAILED",e[e.MYSQL_ERROR=3000001]="MYSQL_ERROR",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.PRJ_NAME_EXISTS=2002]="PRJ_NAME_EXISTS",e[e.BACKUP_NAME_EXISTS=3002]="BACKUP_NAME_EXISTS",e[e.PRJ_NOT_EXIST=2000001]="PRJ_NOT_EXIST",e[e.ERROR_PATH=4000002]="ERROR_PATH",e[e.PROJECT_NOT_FOUND=6000001]="PROJECT_NOT_FOUND",e[e.TITLE_ILLEGAL_LEN=2003]="TITLE_ILLEGAL_LEN",e[e.FILE_READ_ONLY=1000002]="FILE_READ_ONLY",e[e.FILE_READ_ONLY1=1000008]="FILE_READ_ONLY1",e[e.DATA_NOT_EXIST=1000010]="DATA_NOT_EXIST",e[e.LIB_NOT_EXIST=2000001]="LIB_NOT_EXIST",e[e.CONFIG_API_URLS_ERROR=3001001]="CONFIG_API_URLS_ERROR",e[e.ONE_CLICK_ORDER_NOT_OPEN=3001002]="ONE_CLICK_ORDER_NOT_OPEN",e[e.MATERIAL_NOT_OPEN=3001003]="MATERIAL_NOT_OPEN",e[e.SNAPSHOT_DEPTH_LIMIT=3001004]="SNAPSHOT_DEPTH_LIMIT",e[e.OCR_SYMBOL_URL_ERROR=3001005]="OCR_SYMBOL_URL_ERROR",e[e.USER_DATA_NOT_FOUND=4000001]="USER_DATA_NOT_FOUND",e[e.USER_DISABLE_ERROR=4000012]="USER_DISABLE_ERROR",e[e.USER_EXISTS_LOGIN_ERROR=4000003]="USER_EXISTS_LOGIN_ERROR",e[e.USER_UNAUTHORIZED_MODULES_ERROR=4000004]="USER_UNAUTHORIZED_MODULES_ERROR",e[e.USER_UNAUTHORIZED_ACCESS_ERROR=4000005]="USER_UNAUTHORIZED_ACCESS_ERROR",e[e.ADMIN_NOT_CHANGE_PASSWORD=4000006]="ADMIN_NOT_CHANGE_PASSWORD",e[e.SAME_PASSWORD_NEW_PASSWORD=4000007]="SAME_PASSWORD_NEW_PASSWORD",e[e.USER_ONLINE_REGISTRATION_FAILED=4000008]="USER_ONLINE_REGISTRATION_FAILED",e[e.USER_PASSWORD_CAN_NOT_DEFAULT=4000009]="USER_PASSWORD_CAN_NOT_DEFAULT",e[e.USER_BEFORE_PASSWORD_ERROR=4000010]="USER_BEFORE_PASSWORD_ERROR",e[e.USER_PASSWORD_LENGTH_ERROR=4000011]="USER_PASSWORD_LENGTH_ERROR",e[e.ORG_ROLE_NOT_CREATE=5000001]="ORG_ROLE_NOT_CREATE",e[e.ORG_ROLE_NAME_DUPLICATE=5000002]="ORG_ROLE_NAME_DUPLICATE",e[e.ORG_ROLE_ORIGIN_ERROR=5000003]="ORG_ROLE_ORIGIN_ERROR",e[e.ORG_ROLE_NOT_DEFAULT=5000004]="ORG_ROLE_NOT_DEFAULT",e[e.ADMIN_ROLE_NOT_CHANGE=5000005]="ADMIN_ROLE_NOT_CHANGE",e[e.ADMIN_NOT_CHANGE_STATUS=5000006]="ADMIN_NOT_CHANGE_STATUS",e[e.PROJECT_ARCHIVED=6000002]="PROJECT_ARCHIVED",e[e.PROJECT_UUID_NULL=6000003]="PROJECT_UUID_NULL",e[e.PROJECT_UUID_ERROR=6000004]="PROJECT_UUID_ERROR",e[e.PROJECT_OR_TEAM_UUID_ERROR=6000005]="PROJECT_OR_TEAM_UUID_ERROR",e[e.PROJECT_NOT_PERSON_ERROR=6000006]="PROJECT_NOT_PERSON_ERROR",e[e.PROJECT_DUPLICATE_NAME=6000007]="PROJECT_DUPLICATE_NAME",e[e.ANNOTATION_HAS_BE_FOUND=6000008]="ANNOTATION_HAS_BE_FOUND",e[e.ANNOTATION_NOT_FOUND=6000009]="ANNOTATION_NOT_FOUND",e[e.ANNOTATION_CREATE_ERROR=6000010]="ANNOTATION_CREATE_ERROR",e[e.ANNOTATION_UPDATE_ERROR=6000011]="ANNOTATION_UPDATE_ERROR",e[e.ANNOTATION_DELETE_ERROR=6000012]="ANNOTATION_DELETE_ERROR",e[e.PROJECT_DUPLICATE_PATH=6000013]="PROJECT_DUPLICATE_PATH",e[e.TEAM_NOT_FOUND=7000001]="TEAM_NOT_FOUND",e[e.TEAM_UUID_NULL=7000002]="TEAM_UUID_NULL",e[e.TEAM_FOLDER_ERROR=7000003]="TEAM_FOLDER_ERROR",e[e.TEAM_FOLDER_DEEP_ERROR=7000004]="TEAM_FOLDER_DEEP_ERROR",e[e.TEAM_FOLDER_UUID_ERROR=7000005]="TEAM_FOLDER_UUID_ERROR",e[e.TEAM_URL_DUPLICATE=7000006]="TEAM_URL_DUPLICATE",e[e.TEAM_CAN_NOT_DELETE=7000007]="TEAM_CAN_NOT_DELETE",e[e.COMPONENT_UUID_NULL=8000001]="COMPONENT_UUID_NULL",e[e.COMPONENT_DATA_NOT_FOUND=8000002]="COMPONENT_DATA_NOT_FOUND",e[e.COMPONENT_NAME_DUPLICATE=8000003]="COMPONENT_NAME_DUPLICATE",e[e.COMPONENT_TYPE_ERROR=8000004]="COMPONENT_TYPE_ERROR",e[e.DELETE_SON_CATEGORY=8001001]="DELETE_SON_CATEGORY",e[e.LICENSE=9000001]="LICENSE",e[e.START_TIME=9000002]="START_TIME",e[e.END_TIME=9000003]="END_TIME",e[e.PROJECT_LIMIT=9000004]="PROJECT_LIMIT",e[e.USER_LIMIT=9000005]="USER_LIMIT",e[e.ONLINE_NUMBER_LIMIT=9000006]="ONLINE_NUMBER_LIMIT",e[e.COMPANY_CODE=9000007]="COMPANY_CODE",e[e.LIMIT_PCB=9000008]="LIMIT_PCB",e[e.LIMIT_SCH=9000009]="LIMIT_SCH",e[e.LIMIT_PANEL=9000011]="LIMIT_PANEL",e[e.TIME_ERROR=9000010]="TIME_ERROR",e[e.LICENSE_ERROR=9000012]="LICENSE_ERROR",e[e.LICENSE_TYPE_ERROR=9000013]="LICENSE_TYPE_ERROR",e[e.LICENSE_ORIGIN_ERROR=9000014]="LICENSE_ORIGIN_ERROR",e[e.BRANCH_DATA_NOT_FOUND=11000001]="BRANCH_DATA_NOT_FOUND",e[e.PARENT_UUID_ERROR=11000002]="PARENT_UUID_ERROR",e[e.BRANCH_MUST_AFTER_NODE=11000003]="BRANCH_MUST_AFTER_NODE",e[e.BRANCH_NAME_ERROR=11000004]="BRANCH_NAME_ERROR",e[e.BRANCH_NAME_DUPLICATE=11000005]="BRANCH_NAME_DUPLICATE",e[e.BRANCH_UUID_ERROR=11000006]="BRANCH_UUID_ERROR",e[e.BRANCH_NODE_SET_ERROR=11000007]="BRANCH_NODE_SET_ERROR",e[e.BRANCH_DELETE_MAIN_ERROR=11000008]="BRANCH_DELETE_MAIN_ERROR",e[e.BRANCH_CHECK_OUT_ERROR=11000009]="BRANCH_CHECK_OUT_ERROR",e[e.DOCUMENT_UUID_ERROR=12000001]="DOCUMENT_UUID_ERROR",e[e.UPDATE_FAILED=12000002]="UPDATE_FAILED",e[e.INNER_API_KEY_ERROR=1000020]="INNER_API_KEY_ERROR",e[e.BRANCH_MORE_THAN_LIMIT=11000010]="BRANCH_MORE_THAN_LIMIT",e[e.WORKSPACE_API_ERROR=1000021]="WORKSPACE_API_ERROR",e))(zH||{}),XH=(e=>(e[e.DB_INIT_ERROR=0]="DB_INIT_ERROR",e[e.PRJ_NOT_EXIST=1]="PRJ_NOT_EXIST",e[e.NET_ERROR=2]="NET_ERROR",e[e.IS_OPENING=3]="IS_OPENING",e[e.NOT_LOGGED_IN=4]="NOT_LOGGED_IN",e[e.HAS_UNSAVED=5]="HAS_UNSAVED",e[e.DIFF_TICKET=6]="DIFF_TICKET",e))(XH||{});function Tp(e,t={}){if(!e)return"";let{proCode:i,code:r,message:n}=e;switch(i||r){case 401:return Xe("UNAUTHORIZED");case 402:return Xe("LOGIN_FAIL");case 422:return Xe("PERMISSION_DENIED");case 1111111:return Xe("PERMISSION_DENIED1");case 2000001:return Xe("PRJ_NOT_EXIST");case 4000002:return Xe("ERROR_PATH");case 6000001:return Xe("PROJECT_NOT_FOUND");case 1111112:return Xe("PERMISSION_DENIED_PARAMS",{type:n});case 1111113:return Xe("DATA_NOT_FOUND");case 1111114:return Xe("PARAMS_DATA_NOT_FOUND",{type:n});case 42222:return Xe("REQUEST_PARAM_ILLEGAL");case 1111115:return Xe("REQUEST_PARAM_ILLEGAL1");case 1111116:return Xe("REQUEST_PARAMS_ILLEGAL2",{type:n});case 1111117:return Xe("REQUEST_PARAMS_NOT_NULL",{type:n});case 1111118:return Xe("REQUEST_PARAMS_NOT_ALL_NULL",{type:n});case 1111119:return Xe("REQUEST_PARAMS_MUST_ARRAY",{type:n});case 1111120:return Xe("REQUEST_PARAMS_MUST_STRING",{type:n});case 1111121:return Xe("REQUEST_PARAMS_MUST_NUMBER",{type:n});case 1111122:return Xe("REQUEST_PARAMS_MUST_NUMBER_ARRAY",{type:n});case 1111123:return Xe("REQUEST_PARAMS_MUST_STRING_ARRAY",{type:n});case 1111124:return Xe("REQUEST_PARAMS_LENGTH_ERROR",{type:n});case 1111125:return Xe("REQUEST_PARAMS_TYPE_ERROR",{type:n});case 2001:return Xe("ILLEGAL_NAME");case 1111126:return Xe("ILLEGAL_NAME1");case 1111128:return Xe("ILLEGAL_NAME_ZH");case 1111127:return Xe("UUID_ERROR");case 1000001:return Xe("DUPLICATE_DATA");case 11e3:return Xe("DUPLICATE_DATA1");case 1000017:return Xe("DUPLICATE_DATA_PARAMS",{type:n});case 10034:return Xe("UPLOAD_LIMIT");case 1000003:return Xe("MORE_THAN_LIMIT");case 1000004:return Xe("FILE_MORE_THAN_LIMIT",{type:n});case 1000005:return Xe("PARAMS_MORE_THAN_LIMIT",{type:n});case 1000006:return Xe("IMAGE_MORE_THAN_LIMIT_PARAMS");case 1000007:return Xe("FILE_MORE_THAN_LIMIT_PARAMS");case 1000019:return Xe("END_MUST_AFTER_START");case 1000002:return Xe("FILE_READ_ONLY");case 1000008:return Xe("FILE_READ_ONLY1");case 1000010:return Xe("DATA_NOT_EXIST",{documentName:t.documentName});case 1000009:return Xe("REQUEST_PARAMS_TIME_ERROR");case 1000018:return Xe("FILES_PATH_NOT_FOUND");case 1000011:return Xe("FILES_DATA_NOT_FOUND");case 1000012:return Xe("FILES_TYPE_ERROR");case 1000013:return Xe("FILES_TYPE_MUST_BE_ONE",{type:n});case 1000014:return Xe("SET_WATERMARK_FAIL");case 1000015:return Xe("MYSQL_CRUD_ERROR",{type:n});case 1000016:return Xe("PARAMS_JSON_FAILED",{type:n});case 3000001:return Xe("MYSQL_ERROR");case 404:return Xe("NOT_FOUND");case 2002:return Xe("PRJ_NAME_EXISTS");case 3002:return Xe("BACKUP_NAME_EXISTS");case 2003:return Xe("TITLE_ILLEGAL_LEN",{documentName:t.documentName});case 2000001:return Xe("LIB_NOT_EXIST");case 3001001:return Xe("CONFIG_API_URLS_ERROR");case 3001002:return Xe("ONE_CLICK_ORDER_NOT_OPEN");case 3001003:return Xe("MATERIAL_NOT_OPEN");case 3001004:return Xe("SNAPSHOT_DEPTH_LIMIT");case 3001005:return Xe("OCR_SYMBOL_URL_ERROR");case 4000001:return Xe("USER_DATA_NOT_FOUND");case 4000012:return Xe("USER_DISABLE_ERROR");case 4000003:return Xe("USER_EXISTS_LOGIN_ERROR");case 4000004:return Xe("USER_UNAUTHORIZED_MODULES_ERROR");case 4000005:return Xe("USER_UNAUTHORIZED_ACCESS_ERROR");case 4000006:return Xe("ADMIN_NOT_CHANGE_PASSWORD");case 4000007:return Xe("SAME_PASSWORD_NEW_PASSWORD");case 4000008:return Xe("USER_ONLINE_REGISTRATION_FAILED");case 4000009:return Xe("USER_PASSWORD_CAN_NOT_DEFAULT");case 4000010:return Xe("USER_BEFORE_PASSWORD_ERROR");case 4000011:return Xe("USER_PASSWORD_LENGTH_ERROR");case 5000001:return Xe("ORG_ROLE_NOT_CREATE");case 5000002:return Xe("ORG_ROLE_NAME_DUPLICATE");case 5000003:return Xe("ORG_ROLE_ORIGIN_ERROR",{message:n});case 5000004:return Xe("ORG_ROLE_NOT_DEFAULT");case 5000005:return Xe("ADMIN_ROLE_NOT_CHANGE");case 5000006:return Xe("ADMIN_NOT_CHANGE_STATUS");case 6000002:return Xe("PROJECT_ARCHIVED");case 6000003:return Xe("PROJECT_UUID_NULL");case 6000004:return Xe("PROJECT_UUID_ERROR");case 6000005:return Xe("PROJECT_OR_TEAM_UUID_ERROR");case 6000006:return Xe("PROJECT_NOT_PERSON_ERROR");case 6000007:return Xe("PROJECT_DUPLICATE_NAME");case 6000008:return Xe("ANNOTATION_HAS_BE_FOUND");case 6000009:return Xe("ANNOTATION_NOT_FOUND");case 6000010:return Xe("ANNOTATION_CREATE_ERROR");case 6000011:return Xe("ANNOTATION_UPDATE_ERROR");case 6000012:return Xe("ANNOTATION_DELETE_ERROR");case 6000013:return Xe("PROJECT_DUPLICATE_PATH");case 7000001:return Xe("TEAM_NOT_FOUND");case 7000002:return Xe("TEAM_UUID_NULL");case 7000003:return Xe("TEAM_FOLDER_ERROR");case 7000004:return Xe("TEAM_FOLDER_DEEP_ERROR");case 7000005:return Xe("TEAM_FOLDER_UUID_ERROR");case 7000006:return Xe("TEAM_URL_DUPLICATE");case 7000007:return Xe("TEAM_CAN_NOT_DELETE");case 8000001:return Xe("COMPONENT_UUID_NULL");case 8000002:return Xe("COMPONENT_DATA_NOT_FOUND");case 8000003:return Xe("COMPONENT_NAME_DUPLICATE");case 8000004:return Xe("COMPONENT_TYPE_ERROR");case 8001001:return Xe("DELETE_SON_CATEGORY");case 9000001:return Xe("LICENSE");case 9000002:return Xe("START_TIME");case 9000003:return Xe("END_TIME");case 9000004:return Xe("PROJECT_LIMIT");case 9000005:return Xe("USER_LIMIT");case 9000006:return Xe("ONLINE_NUMBER_LIMIT");case 9000007:return Xe("COMPANY_CODE");case 9000008:return Xe("LIMIT_PCB");case 9000009:return Xe("LIMIT_SCH");case 9000011:return Xe("LIMIT_PANEL");case 9000010:return Xe("TIME_ERROR");case 9000012:return Xe("LICENSE_ERROR");case 9000013:return Xe("LICENSE_TYPE_ERROR");case 9000014:return Xe("LICENSE_ORIGIN_ERROR",{type:n});case 11000001:return Xe("BRANCH_DATA_NOT_FOUND");case 11000002:return Xe("PARENT_UUID_ERROR");case 11000003:return Xe("BRANCH_MUST_AFTER_NODE");case 11000004:return Xe("BRANCH_NAME_ERROR");case 11000005:return Xe("BRANCH_NAME_DUPLICATE");case 11000006:return Xe("BRANCH_UUID_ERROR");case 11000007:return Xe("BRANCH_NODE_SET_ERROR");case 11000008:return Xe("BRANCH_DELETE_MAIN_ERROR");case 11000009:return Xe("BRANCH_CHECK_OUT_ERROR");case 12000001:return Xe("DOCUMENT_UUID_ERROR");case 12000002:return Xe("UPDATE_FAILED");case 1000020:return Xe("INNER_API_KEY_ERROR");case 11000010:return Xe("BRANCH_MORE_THAN_LIMIT");case 1000021:return Xe("WORKSPACE_API_ERROR")}return n}function Xe(e,t){return sR()==="zh-cn"?IT.match("codeCN",e,t)||"":IT.match("codeEN",e,t)||""}function rl(e){return e===422||e===1111111||e===6000002}function Ol(e){return e===1000001||e===11e3||e===8000003}var WH=class{static blobToUint8Array(e){return new Promise((t,i)=>{let r=new FileReader;r.onload=()=>{r.result instanceof ArrayBuffer?t(new Uint8Array(r.result)):i(new Error("FileReader result is not an ArrayBuffer"))},r.onerror=()=>i(r.error),r.readAsArrayBuffer(e)})}static bufferToString(e,t="utf-8"){return new TextDecoder(t).decode(e)}},qH=(e=>(e.IsActive="/pro-ui/liveness/monitor/isActive",e))(qH||{});async function JH(){var e;if(!u0)return!0;let t=!1,i=ut();return typeof window>"u"&&i._TAB_ID_?t=await TR(`/${i._TAB_ID_}/notify`).rpcCall("/pro-ui/liveness/monitor/isActive"):t=(e=await xt.messageBus.rpcCall("/pro-ui/liveness/monitor/isActive"))==null?void 0:e.message,t?!0:(console.error("[\u7F16\u8F91\u5668\u5904\u4E8E\u5931\u6D3B\u72B6\u6001, \u8BF7\u68B3\u7406\u903B\u8F91, \u4E0D\u8981\u53D1\u9001\u4E0D\u5FC5\u8981\u7684\u8BF7\u6C42!!!]"),!1)}var KH=(e=>(e.Text="text/plain;charset=UTF-8",e.Json="application/json",e.Form="application/x-www-form-urlencoded;charset=UTF-8",e.FormData="multipart/form-data",e))(KH||{}),$H=(e=>(e.ContentType="Content-Type",e.Editorversion="Editor-Version",e))($H||{}),ZH=(e=>(e.Json="json",e.Blob="blob",e))(ZH||{}),QH=0;async function Rt(e,t,i={},r={},n=!1){if(!await ej())throw new Error("\u975E\u6CD5\u8BF7\u6C42!!!");return await tj(e,t,i,r,n)}async function ej(){return await JH()}async function tj(e,t,i={},r={},n=!1){return new Promise(async(s,a)=>{try{let l=QH++;var o;e=e||"GET",ij(e,i,r),o=i,r=r;let c=rj(e,t,o,r);o=c.params,t=c.url;let u=new XMLHttpRequest;if(r.withCredentials!==void 0&&(u.withCredentials=r.withCredentials),r.responseType!==void 0&&(u.responseType=r.responseType),u.open(e,t,!0),nj(u,e,r,n),o=await sj(u,e,t,o,r),u.onreadystatechange=function(){if(u.readyState===4&&u.status===200)try{if(r.responseType==="blob")s(u.response);else{let h=JSON.parse(u.responseText);h.success===!1&&(h.message=Tp(h)||h.message),s(h)}}catch(h){console.warn("catch ajax error...",h),s({success:!1,message:"Network Error!"})}else u.status===404?(console.warn("catch ajax error...",u.status),s({success:!1,code:u.status,message:"Network Error!"})):u.status===500&&(console.warn("catch ajax error...",u.status),s({success:!1,code:u.status,message:"Network Error!"}))},u.onerror=function(h){console.warn("catch ajax error...",h),s({success:!1,message:"Network Error!"})},o instanceof Uint8Array){let h=new Blob([o]);u.send(h)}else u.send(o)}catch(l){console.warn("catch ajax error...",l),s({success:!1,message:"Network Error!"})}})}function ij(e,t,i={}){var r;if(e.toLowerCase()!=="get"&&!(t instanceof FormData)&&typeof t!="string"&&(i==null?void 0:i.contentType)!==!1&&!((r=i==null?void 0:i.headers)!=null&&r["Content-Type"])&&(i=i||{},i.headers=Object.assign(i.headers||{},{"Content-Type":"application/json"})),i.headers){let n={};for(let s in i.headers){let a=i.headers[s];n[s]=a}i.headers=n}}function VL(e,t=50){return typeof e!="string"?!1:e.length*2>t*1024*1024}function rj(e,t,i,r={}){var n;let s,a,o,l=[],c=r.headers,u=!1;if(i instanceof FormData)s=i;else if(typeof i=="string")s=i;else if((n=c==null?void 0:c["Content-Type"])!=null&&n.includes("application/json")){if(typeof i=="object"&&i!==null){for(let p in i)if(VL(i[p])){u=!0;break}}if(u){let p=new FormData;for(let f in i){let m=i[f];VL(m)?p.append(f,new Blob([m],{type:"text/plain"})):p.append(f,typeof m=="object"?JSON.stringify(m):m)}s=p,r.headers&&(r.headers["Content-Type"]="multipart/form-data")}else s=JSON.stringify(i)}else{for(a in i)if(o=i[a],o instanceof Array)for(let p=0;p<o.length;p++){let f=o[p];l.push(encodeURIComponent(`${a}[]`)+"="+encodeURIComponent(f))}else if(Object.prototype.toString.call(o)==="[object Object]")for(let p in o){let f=o[p];l.push(encodeURIComponent(`${a}[${p}]`)+"="+(f?encodeURIComponent(f):""))}else l.push(encodeURIComponent(a)+"="+encodeURIComponent(o));s=l.join("&"),e==="GET"&&s&&typeof s=="string"&&r.searchParams===!0&&(t=t+"?"+s,s={})}let h=/{[a-zA-Z]+}/gim,d=[...new Set(t.match(h))];for(let p of d){let f=p.substring(1,p.length-1);t=t.replace(p,i[f]||"")}return{params:s,url:t}}function nj(e,t,i={},r=!1){let n=i.headers;if(n){for(let s in n){let a=n[s];e.setRequestHeader(encodeURI(s),encodeURI(a))}i.contentType!==!1&&!n["Content-Type"]&&e.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8")}else i.contentType!==!1&&e.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");e.setRequestHeader("Editor-Version",self.PRO_EDITOR_VERSION||"");try{if(!r&&!n.path)throw new Error("Missing path")}catch(s){console.error(s)}if(self.document){let s=t.toUpperCase();if(s!=="GET"&&s!=="HEAD"){let a=/XSRF-TOKEN=(\S+);?/.exec(document.cookie);a&&e.setRequestHeader("X-XSRF-TOKEN",decodeURIComponent(a[1]))}}}var wT=1e4;async function sj(e,t,i,r,n={}){if(t.match(/post/i)&&i.startsWith("/")&&!i.startsWith("/servicecenter/")&&typeof r=="string"&&r.length>=wT&&(r=ST(new TextEncoder().encode(r),{level:1}),e.setRequestHeader("Content-Encoding","gzip")),t.match(/post/i)&&i.startsWith("/")&&!i.startsWith("/servicecenter/")&&r instanceof FormData&&n.gzipFormData===!0){let s=new Set;r.forEach((a,o)=>{s.add(o)});for(let a of s){let o=r.get(a);if(typeof o=="string"&&o.length>=wT){let l=new Blob([ST(new TextEncoder().encode(o),{level:1})]);r.set(a,l)}else if(o instanceof Blob&&o.size>=wT){let l=new Blob([ST(await WH.blobToUint8Array(o),{level:9})]);r.set(a,l,o.name)}}e.setRequestHeader("Content-Encoding","gzip")}return r}async function WR(e,t,i,r){if(!r||!i){let a=`invalid parameters ${r}|${i}.`;return{code:it.ERR_CODE.NORMAL,success:!1,msg:a,message:a,result:null}}let n=await Rt("POST",t?vr(Lt.DEVICE.DELETE,{uuid:r}):vr(Lt.COMPONENT.DELETE,{uuid:r}),{},{headers:{"Content-Type":"application/json",path:i}});if(n.code===0&&n.success)return{code:0,success:!0,msg:"",message:"",result:{componentId:r}};let s=n.message||n.msg||"Request Error.";return{...n,msg:s,message:s,result:{componentId:r}}}async function aj(e,t,i){if(e){let u="operations not currently supported.";return{code:it.ERR_CODE.NORMAL,success:!1,msg:u,message:u,result:null}}let r={code:0,success:!0,result:{devices:{succeed:[],failed:[]},symbols:{succeed:[],failed:[]},footprints:{succeed:[],failed:[]},d3models:{succeed:[],failed:[]},cbbs:{succeed:[],failed:[]},panels:{succeed:[],failed:[]}},msg:"",message:""},n=await em(e,!0,t,i.devices||[]);r.result.devices={...n.result};let s=await em(e,!1,t,i.symbols||[]);r.result.symbols={...s.result};let a=await em(e,!1,t,i.footprints||[]);r.result.footprints={...a.result};let o=await em(e,!1,t,i.d3models||[]);r.result.d3models={...o.result};let l=await em(e,!1,t,i.cbbs||[]);r.result.cbbs={...l.result};let c=await em(e,!1,t,i.panels||[]);return r.result.panels={...c.result},r}async function em(e,t,i,r){let n=[],s=[];for(let a=0;a<r.length;a++){let o=await WR(e,t,i,r[a]);if(o.code===0&&o.success){n.push(r[a]);continue}n.push(r[a])}return{code:0,success:!0,result:{succeed:n,failed:s},msg:"",message:""}}function qR(e){if(!e)return[];if(e instanceof Array)return e;let t=[];return e!=null&&e.parent_tag&&e!=null&&e.parent_tag.uuid&&t.push(e==null?void 0:e.parent_tag.uuid),e!=null&&e.child_tag&&e!=null&&e.child_tag.uuid&&t.push(e==null?void 0:e.child_tag.uuid),t}function hd(e){if(!e)return[];if(e instanceof Array)return e;let t=[];return e!=null&&e.parent_tag&&e!=null&&e.parent_tag.name&&t.push(e==null?void 0:e.parent_tag.name),e!=null&&e.child_tag&&e!=null&&e.child_tag.name&&t.push(e==null?void 0:e.child_tag.name),t}function x0(e,t=!1){return e?t?HL(e):e.indexOf("@")>=0?oj(e):e.indexOf("_")>=0?lj(e):HL(e):{componentTitleOrId:void 0,path:void 0,isLocaleFilenameMode:!1}}function HL(e){let t={componentTitleOrId:void 0,path:void 0,isLocaleFilenameMode:!1};if(!/\|/i.test(e))return t.isLocaleFilenameMode=!1,t.componentTitleOrId=e,t;let i=e.split("|");return t.componentTitleOrId=i[0],t.path=i[1],/\./.test(i[0])?(t.isLocaleFilenameMode=!0,t):(t.isLocaleFilenameMode=!1,t)}function oj(e){let t={componentTitleOrId:void 0,path:void 0,isLocaleFilenameMode:!1};if(!/\@/i.test(e))return t.isLocaleFilenameMode=!1,t.componentTitleOrId=e,t;let i=e.split("@");return t.componentTitleOrId=i[0],t.path=i[1],/\./.test(i[0])?(t.isLocaleFilenameMode=!0,t):(t.isLocaleFilenameMode=!1,t)}function lj(e){let t={componentTitleOrId:void 0,path:void 0,isLocaleFilenameMode:!1};if(!/_/i.test(e))return t.isLocaleFilenameMode=!1,t.componentTitleOrId=e,t;let i=e.split("_");return t.componentTitleOrId=i[0],t.path=i[1],/\./.test(i[0])?(t.isLocaleFilenameMode=!0,t):(t.isLocaleFilenameMode=!1,t)}async function wI(e,t){let i=x0(e,!0),r=i.path||t,n={code:it.ERR_CODE.NORMAL,success:!0,result:null,msg:""};return n.result={createTime:0,created_at:"",creator:null,dataStr:JSON.stringify({model:`${i.componentTitleOrId}|${r}`,unit:"mm"}),display_title:i.componentTitleOrId||"-",uuid:`${i.componentTitleOrId}|${r}`||"",path:r,description:"",docType:16,modifier:null,owner:null,source:"",tags:{child_tag:[],parent_tag:[]},title:i.componentTitleOrId||"",updateTime:0,updated_at:"",version:"",public:void 0},n}var cj=class{constructor(){if(!crypto||!crypto.subtle)throw new Error("\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301crypto api");this.tool=crypto.subtle}},uj=class extends cj{constructor(){super(),this.keyBuffer=null,this.key=null,this.iv=null}async init(e){try{return this.keyBuffer=e.key,this.key=await this.setKey(this.keyBuffer),this.iv=await this.setIV(e.iv),this}catch{throw new Error(`invalid key or iv! ${e}`)}}setKey(e){if(e instanceof ArrayBuffer)return this.tool.importKey("raw",e,"AES-GCM",!0,["encrypt","decrypt"]);throw new Error(`invalid key! ${e}`)}setIV(e){if(e instanceof ArrayBuffer)return e;throw new Error(`invalid iv! ${e}`)}encrypt(e){return this.tool.encrypt({name:"AES-GCM",iv:this.iv},this.key,e)}decrypt(e){return this.tool.decrypt({name:"AES-GCM",iv:this.iv},this.key,e)}decrypt2(e){return this.tool.decrypt({name:"AES-GCM",iv:this.iv,tagLength:128},this.key,e)}getKey(){return this.keyBuffer}getIV(){return this.iv}};function jL(e){let t=e.match(/[\da-f]{2}/gi);return t?new Uint8Array(t.map(function(i){return parseInt(i,16)})).buffer:null}function hj(e,t="utf-8"){var i=new TextDecoder(t);return i.decode(e)}async function E0(e){try{if(e.dataStrId){let t=new Headers;t.append("Content-Type","text/plain;charset=UTF-8");let i=await(await fetch(e.dataStrId,{method:"GET",redirect:"error",headers:t})).arrayBuffer();if(i){let r=await dj(e,i);return hj(r)}}else if(e.dataStr)return e.dataStr;return null}catch(t){throw new Error("fetch\u5931\u8D25!!!"+t)}}async function dj(e,t){let i=new uj;try{let{key:r,iv:n}=e;if(t&&n&&r){let s=jL(r),a=jL(n);await i.init({key:s,iv:a});let o=await i.decrypt(t);return GH(new Uint8Array(o))}else throw new Error(`\u6570\u636E\u89E3\u5BC6\u5931\u8D25!!!\u6570\u636E\u4E0D\u6B63\u786E:data:${t},key:${r},iv:${n}`)}catch(r){throw new Error("\u6570\u636E\u89E3\u5BC6\u5931\u8D25!!!"+r)}}var JR=(e=>(e.LIST="/api/projects",e.CBB_LIST="/api/cbbProject",e.CREATE="/api/v4/projects/add",e.GET="/api/v4/projects/{uuid}",e.UPDATE="/api/projects/{uuid}/update",e.DELETE="/api/v4/projects/{uuid}/delete",e.TICKET="/api/projects/{uuid}/ticket",e.BACKUP_LIST="/api/backups",e.BACKUP="/api/backups",e.OPERATE_BACKUP="/api/backups/{uuid}",e.ARCHIVE="/api/backups/archive",e.CREATE_BOARD="/api/projects/{uuid}/boards",e.STAR="/api/projects/{uuid}/star",e.UNSTAR="/api/projects/{uuid}/unstar",e.CREATE_DRAFT="/api/v4/projects/{project_uuid}/draft-history",e.UPLOAD_DRAFT="/api/v4/projects/{project_uuid}/draft-history/{draft_uuid}",e.STRUCTURE="/api/v4/projects/{project_uuid}/branches/{branch_uuid}/structures",e.UPDATE_IMAGES="/api/v4/projects/{projectUuid}/branches/{branchUuid}/thumbs",e.DELETE_IMAGES="/api/v4/projects/{projectUuid}/branches/{branchUuid}/thumbs/{thumbUuid}",e.GET_IMAGES="/api/v4/projects/{projectUuid}/branches/{branchUuid}/thumbs",e))(JR||{}),KR=(e=>(e.CREATE="/api/v4/projects/{project_uuid}/branches",e.LIST="/api/v4/projects/{project_uuid}/branches",e.GET="/api/v4/projects/{project_uuid}/branches/{branch_uuid}",e.UPDATE="/api/v4/projects/{project_uuid}/branches/{branch_uuid}",e.DELETE="/api/v4/projects/{project_uuid}/branches/{branch_uuid}",e))(KR||{}),$R=(e=>(e.APPLY="/api/v4/snapshots/apply",e.CREATE="/api/v4/snapshots/create",e.GET="/api/v4/projects/branches/histories?path={path}&project={project}&branch={branch}&history={history}&limit={limit}",e.UPLOAD="/api/v4/snapshots/upload-signatures",e.CONFIRM="/api/v4/snapshots/upload-confirm",e))($R||{}),ZR=(e=>(e.SET="/api/v4/projects/{project_uuid}/branches/{branch_uuid}/histories",e.GET="/api/v4/projects/{project_uuid}/branches/{branch_uuid}/histories/{history_uuid}",e))(ZR||{}),QR=(e=>(e.SET="/api/v4/components/{uuid}/histories",e.GET="/api/v4/components/{uuid}/histories/{historyUuid}",e))(QR||{}),eN=(e=>(e.LIST="/api/schematic/lists",e.CREATE="/api/schematic/create",e.UPLOAD="/api/schematic/upload",e.DELETE="/api/schematic/{uuid}/delete",e.UPDATE="/api/schematic/{uuid}/update",e.UPDATE_SORT="/api/schematic/{uuid}/update_sort",e.UPDATE_SORT1="/api/v2/documents/updateSorts",e))(eN||{}),tN=(e=>(e.LIST="/api/v2/documents/lists",e.CREATE="/api/v2/documents/create",e.UPLOAD="/api/v2/documents/upload",e.UPDATE="/api/v2/documents/{uuid}/update",e.UPDATE_CANVAS="/api/v2/documents/{uuid}/update_canvas",e.BATCH_UPDATE="/api/v2/documents/updateMany",e.DELETE="/api/v2/documents/{uuid}/delete",e.GET="/api/v2/documents/{uuid}",e.GET_BY_TITLE="/api/v2/documents/searchByName",e.GET_BY_SID="/api/v2/schematic/{schematicUuid}/documents",e.MOVE="/api/v2/documents/{uuid}/sort",e.CHECK_IN="/api/v4/documents/checkin/{project}/{branch}",e.CHECK_OUT="/api/v4/documents/checkout/{project}/{branch}",e.GET_CHECK="/api/v4/documents/checkout/{project}/{branch}",e.DELETE_PCB_RELATED="/api/v2/deleteCopperFontComponents",e))(tN||{}),iN=(e=>(e.LIST="/api/v2/devices",e.SEARCH_LIST="/api/devices/search",e.CREATE="/api/devices",e.UPLOAD="/api/devices/upload",e.UPDATE="/api/devices/{uuid}",e.BATCH_UPDATE="/api/devices/updateMany",e.GET="/api/v2/devices/{uuid}",e.GET_ATTR_VALUE="/api/devices/attributes",e.GET_ATTR_KEYS="/api/devices/attributeKeys",e.GET_BY_USER_AND_TITLE="/api/v2/devices/searchByUserUuidAndTitle",e.BATCH_GET="/api/devices/searchByIds",e.DELETE="/api/v4/devices/{uuid}/delete",e.STAR="/api/devices/{uuid}/star",e.UNSTAR="/api/devices/{uuid}/unstar",e.PLACE="/api/v2/upload",e))(iN||{}),rN=(e=>(e.LIST="/api/v2/components",e.SEARCH_LIST="/api/v2/components/search",e.CREATE="/api/v2/components/add",e.UPLOAD="/api/v2/components/upload",e.UPDATE="/api/v2/components/{uuid}/update",e.UPDATE_CANVAS="/api/v2/components/{uuid}/update_canvas",e.BATCH_UPDATE="/api/v2/components/updateMany",e.DELETE="/api/v4/components/{uuid}/delete",e.GET="/api/v2/components/{uuid}",e.GET_BY_TITLE="/api/v2/searchByTitles",e.GET_BY_DOC_UUID="/api/v2/components/searchByPcbId",e.GET_BY_USER_AND_TITLE="/api/v2/components/searchByUserUuidAndTitle",e.GET_BY_C="/api/searchProductByCode",e.BATCH_GET="/api/v2/components/searchByIds",e.STAR="/api/v2/components/{uuid}/star",e.UNSTAR="/api/v2/components/{uuid}/unstar",e.UPLOAD_3DMODEL="/api/3dmodel/upload",e))(rN||{}),nN=(e=>(e.LIST="/api/categories",e.CREATE="/api/categories",e.DELETE="/api/categories/{uuid}/delete",e.UPDATE="/api/categories/{uuid}",e.DEVICE_CATE="/api/open/deviceCate",e))(nN||{}),sN=(e=>(e.SEARCH_LIST="/api/coppers/search",e.SEARCH_BY_PCB_UUID="/api/coppers/searchByPcbId",e.SET="/api/coppers/upload",e.DELETE="/api/coppers/delete",e))(sN||{}),aN=(e=>(e.SEARCH_LIST="/api/textpath/search",e.SEARCH_BY_PCB_UUID="/api/textpath/searchByPcbId",e.SET="/api/textpath/upload",e.DELETE="/api/textpath/delete",e))(aN||{}),oN=(e=>(e.SEARCH_LIST="/api/v2/resources/search",e.SET="/api/v2/resources/upload",e))(oN||{}),lN=(e=>(e.LIST="/api/projects/projectUuid/attributes",e.SEARCH_LIST="/api/block_symbol_attributes/search",e.CREATE="/api/block_symbol_attributes",e.UPLOAD="/api/block_symbol_attributes/upload",e.DELETE="/api/block_symbol_attributes/delete",e.TICKET="/api/block_symbol_attributes/tickets",e))(lN||{}),cN=(e=>(e.GET_BACKUP="/api/backups/{name}",e.GET_COMPONENT="/api/v2/components/clientSearch",e.GET_DEVICE="/api/devices/clientSearch",e.GET_LIBS="/api/client/libraryPaths",e.CREATE_LIB="/api/client/createPath",e.CREATE_PROJECT="/api/client/createProject",e.OPEN_PROJECT="/api/client/openProject",e.CLOSE_PROJECT="/api/client/closeProject",e.COPY_PROJECT="/api/client/copyProject",e.DELETE_PROJECT="/api/client/deleteProject",e.GET_PROJECT_PATHS="/api/client/projectPaths",e.SELECT_PATH_ON_OFFLINE="/api/fileDialog/saveFile",e.SELECT_PATH_ON_LINE="app://api/fileDialog/saveFile",e.OPEN_DIALOG="/api/fileDialog/openPath",e.SELECT_DIR_ON_OFFLINE="/api/fileDialog/dirtory",e.SELECT_DIR_ON_LINE="app://api/client/openDir",e.SELECT_FILE="/api/fileDialog/file",e.EXPORT_FILE_ON_OFFLINE="/api/client/uploadFile",e.EXPORT_FILE_ON_LINE="app://api/client/uploadFile",e.GET_PRJ_CACHE_LIST="/api/client/tmpBackupList",e.OPERATE_PRJ_CACHE="/api/client/tmpBackup",e.CREATE_PRJ_CACHE_ONLINE="/api/client/tmpBackup/create",e.DELETE_PRJ_CACHE_ONLINE="/api/client/tmpBackup/delete",e.GET_RECENT_PROJECT="/api/client/projectHistory",e.DELETE_RECENT_PROJECT="/api/client/projectHistory/delete",e.SET_KV_CACHE="/api/client/setEditorCache",e.GET_KV_CACHE="/api/client/getEditorCache",e.IS_EXIST_KV_CACHE="/api/client/existEditorCache",e.SEARCH_SCHEMATIC_BY_NAME="/api/schematic/searchByName",e.OPEN_URL="app://api/system/openURL",e.FIND_3DMODEL="/api/client/model/find",e))(cN||{}),uN=(e=>(e.LOG="/api/v3/editor_log/upload",e.COMPONENT_LOG="/api/v4/componentLogs",e.TEAMS="/api/teams",e.GET_EDITOR_VERSION="/api/editor/version",e.SET_EDITOR_VERSION="/api/editor/changeVersion",e.ONLINE="/api/userStatistics/registerOnline",e))(uN||{}),Lt={PROJECT:JR,BRANCH:KR,SNAPSHOT:$R,PROJECT_HISTORY:ZR,COMPONENT_HISTORY:QR,SCHEMATIC:eN,DOCUMENT:tN,DEVICE:iN,COMPONENT:rN,TAG:nN,COPPER:sN,FONT:aN,BLOB:oN,ATTR:lN,CLIENT:cN,OTHER:uN};function ld(e=new Date,t="yyyy-MM-dd HH:ii:ss"){if(Number.isNaN(e.getTime()))return"-";let i={"M+":e.getMonth()+1,"d+":e.getDate(),"H+":e.getHours(),"h+":e.getHours(),"i+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length)));for(let r in i)new RegExp("("+r+")").test(t)&&(t=t.replace(RegExp.$1,RegExp.$1.length==1?i[r]:("00"+i[r]).substr((""+i[r]).length)));return t}function pj(e,t){function i(u){return u>=10?String(u):"0"+u}e instanceof Date?e.getTime().toString().length>13&&(e=new Date(e.getTime()/1e3)):Number.isNaN(Number(e))||e.toString().length>13&&(e=new Date(Number(e)/1e3));let r=new Date(e);if(Number.isNaN(r.getTime()))return"-";let n=r.getFullYear(),s=i(r.getMonth()+1),a=i(r.getDate()),o=i(r.getHours()),l=i(r.getMinutes()),c=i(r.getSeconds());return t==="downProject"?n+"-"+s+"-"+a:t==="migrateStandardProject"?n+"-"+s+"-"+a+"_"+o+"-"+l+"-"+c:t==="y-m-d"||t==="yyyy-MM-dd"?n+"-"+s+"-"+a:t==="y-m-d_h-m-s"?`${n}-${s}-${a}_${o}-${l}-${c}`:n+"-"+s+"-"+a+" "+o+":"+l+":"+c}function vI(e,t,i){let r=new Date().getTime(),n=ld(new Date(r)),s={avatar:"",nickname:"",username:"",uuid:""},a=e+(i?`|${i}`:"");return{createTime:r,created_at:n,creator:{...s},dataStr:JSON.stringify({model:a,unit:"mm"}),description:"",display_title:t,docType:16,modifier:{...s},owner:{...s},path:i,public:!1,source:"",std_uuid:"",tags:{child_tag:[],parent_tag:[]},ticket:0,title:t,type:0,updateTime:r,updated_at:n,uuid:e,version:""}}async function hN(e){return e?new Promise((t,i)=>{window.fetch(`https://modules.lceda.cn/3dmodel/${e}`,{method:"GET"}).then(async r=>{let n=await r.blob();t({code:0,success:!0,result:n,message:""})}).catch(async r=>{t({code:r?r.code:-9,success:!1,result:null,message:"fetch 3D model file failed."})})}):{code:-1,success:!1,result:null,message:"missing uuid or path or detail data."}}async function S0(e,t=it.SYSTEMLIB_UUID,i){if(!e)return null;let r=null,n=x0(e,!0),s=n.path||t;if(n.isLocaleFilenameMode)return r=(await wI(n.componentTitleOrId,s)).result,r;let a=await Rt("GET",vr(Lt.COMPONENT.GET,{uuid:n.componentTitleOrId}),{},{headers:{"Content-Type":"application/json",path:s||void 0}});if(a.code===0&&a.success&&typeof a.result=="object"&&(r=a.result),r&&!r.dataStr)try{let o=await E0(r);r.dataStr=o}catch(o){console.error(o)}if(!r&&e&&i){let o=await hN(e);o.success&&o.result instanceof Blob&&(r=vI(e,i,n.path))}return r}var TI=class{},fj=(e=>(e.PROJECT_DOCUMENT_LOCKED="PROJECT_DOCUMENT_LOCKED",e.PROJECT_DOCUMENT_UPDATE_REJECT="PROJECT_DOCUMENT_UPDATE_REJECT",e.NOSYMBOL_ON_TARGETPATH_BY_DEVICE_BOUND="NOSYMBOL_ON_TARGETPATH_BY_DEVICE_BOUND",e.NOFOOTPRINT_ON_TARGETPATH_BY_DEVICE_BOUND="NOFOOTPRINT_ON_TARGETPATH_BY_DEVICE_BOUND",e.DEVICE_ATTRIBUTES_ERROR="DEVICE_ATTRIBUTES_ERROR",e.DEVICE_DESCRIPTION_ERROR="DEVICE_DESCRIPTION_ERROR",e.SYMBOL_DESCRIPTION_ERROR="SYMBOL_DESCRIPTION_ERROR",e.FOOTPRINT_DESCRIPTION_ERROR="FOOTPRINT_DESCRIPTION_ERROR",e.D3MODEL_DESCRIPTION_ERROR="D3MODEL_DESCRIPTION_ERROR",e.DEVICE_NAMA_ERROR="DEVICE_NAMA_ERROR",e.SYMBOL_NAMA_ERROR="SYMBOL_NAMA_ERROR",e.FOOTPRINT_NAMA_ERROR="FOOTPRINT_NAMA_ERROR",e.PANEL_LIB_NAMA_ERROR="PANEL_LIB_NAMA_ERROR",e.D3MODEL_NAMA_ERROR="D3MODEL_NAMA_ERROR",e.SIM_MODEL_NAMA_ERROR="SIM_MODEL_NAMA_ERROR",e.DEVICE_SAME_NAMA_EXISTS="DEVICE_SAME_NAMA_EXISTS",e.SYMBOL_SAME_NAMA_EXISTS="SYMBOL_SAME_NAMA_EXISTS",e.FOOTPRINT_SAME_NAMA_EXISTS="FOOTPRINT_SAME_NAMA_EXISTS",e.D3MODEL_SAME_NAMA_EXISTS="D3MODEL_SAME_NAMA_EXISTS",e.SIM_MODEL_SAME_NAMA_EXISTS="SIM_MODEL_SAME_NAMA_EXISTS",e.PANELLIB_SAME_NAMA_EXISTS="PANELLIB_SAME_NAMA_EXISTS",e.PARAMETER_VERIFICATION="PARAMETER_VERIFICATION",e.RESULT_VERIFICATION="RESULT_VERIFICATION",e.GET_DEVICE="GET_DEVICE",e.GET_DEVICE_ATTRIBUTES_KEYS="GET_DEVICE_ATTRIBUTES_KEYS",e.GET_DEVICE_ATTRIBUTES_VALUES="GET_DEVICE_ATTRIBUTES_VALUES",e.GET_DEVICE_NOT_FOUND="GET_DEVICE_NOT_FOUND",e.GET_DEVICE_LIST="GET_DEVICE_LIST",e.GET_DEVICE_SEARCH_LIST="GET_DEVICE_SEARCH_LIST",e.GET_DEVICE_SEARCH_UUIDS="GET_DEVICE_SEARCH_UUIDS",e.STAR_DEVICE="STAR_DEVICE",e.UNSTAR_DEVICE="UNSTAR_DEVICE",e.GET_SYMBOL="GET_SYMBOL",e.GET_SYMBOL_NOT_FOUND="GET_SYMBOL_NOT_FOUND",e.GET_SYMBOL_LIST="GET_SYMBOL_LIST",e.GET_SYMBOL_SEARCH_LIST="GET_SYMBOL_SEARCH_LIST",e.GET_SYMBOL_SEARCH_UUIDS="GET_SYMBOL_SEARCH_UUIDS",e.STAR_SYMBOL="STAR_SYMBOL",e.UNSTAR_SYMBOL="UNSTAR_SYMBOL",e.GET_FOOTPRINT="GET_FOOTPRINT",e.GET_FOOTPRINT_NOT_FOUND="GET_FOOTPRINT_NOT_FOUND",e.GET_FOOTPRINT_LIST="GET_FOOTPRINT_LIST",e.GET_FOOTPRINT_SEARCH_LIST="GET_FOOTPRINT_SEARCH_LIST",e.GET_FOOTPRINT_SEARCH_UUIDS="GET_FOOTPRINT_SEARCH_UUIDS",e.STAR_FOOTPRINT="STAR_FOOTPRINT",e.UNSTAR_FOOTPRINT="UNSTAR_FOOTPRINT",e.GET_PANEL_LIB="GET_PANEL_LIB",e.GET_PANEL_LIB_LIST="GET_PANEL_LIB_LIST",e.GET_PANEL_LIB_NOT_FOUND="GET_PANEL_LIB_NOT_FOUND",e.GET_PANEL_LIB_SEARCH_LIST="GET_PANEL_LIB_SEARCH_LIST",e.GET_PANEL_LIB_SEARCH_UUIDS="GET_PANEL_LIB_SEARCH_UUIDS",e.STAR_PANEL_LIB="STAR_PANEL_LIB",e.UNSTAR_PANEL_LIB="UNSTAR_PANEL_LIB",e.GET_D3MODEL="GET_D3MODEL",e.GET_D3MODEL_NOT_FOUND="GET_D3MODEL_NOT_FOUND",e.GET_D3MODEL_LIST="GET_D3MODEL_LIST",e.GET_D3MODEL_SEARCH_LIST="GET_D3MODEL_SEARCH_LIST",e.GET_D3MODEL_SEARCH_UUIDS="GET_D3MODEL_SEARCH_UUIDS",e.GET_SIM_MODEL="GET_SIM_MODEL",e.GET_SIM_NOT_FOUND="GET_SIM_NOT_FOUND",e.GET_SIM_MODEL_LIST="GET_SIM_MODEL_LIST",e.GET_SIM_MODEL_SEARCH_LIST="GET_SIM_MODEL_SEARCH_LIST",e.GET_SIM_MODEL_SEARCH_UUIDS="GET_SIM_MODEL_SEARCH_UUIDS",e.CROSS_BIND="CROSS_BIND",e.CROSS_BIND_EXIT="CROSS_BIND_EXIT",e.IMPORT_EXIST_PROJECT="IMPORT_EXIST_PROJECT",e.CREATE_PROJECT="CREATE_PROJECT",e.CREATE_DEVICE="CREATE_DEVICE",e.CREATE_DEVICE_PERMISSIONS="CREATE_DEVICE_PERMISSIONS",e.CREATE_DEVICE_GET_ORIGIN="CREATE_DEVICE_GET_ORIGIN",e.CREATE_SYMBOL="CREATE_SYMBOL",e.CREATE_SYMBOL_PERMISSIONS="CREATE_SYMBOL_PERMISSIONS",e.CREATE_SYMBOL_GET_ORIGIN="CREATE_SYMBOL_GET_ORIGIN",e.CREATE_SYMBOL_MIGRATE_CANVAS_ERROR="CREATE_SYMBOL_MIGRATE_CANVAS_ERROR",e.CREATE_FOOTPRINT="CREATE_FOOTPRINT",e.CREATE_FOOTPRINT_PERMISSIONS="CREATE_FOOTPRINT_PERMISSIONS",e.CREATE_FOOTPRINT_GET_ORIGIN="CREATE_FOOTPRINT_GET_ORIGIN",e.CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR="CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",e.CREATE_D3MODEL="CREATE_D3MODEL",e.CREATE_D3MODEL_PERMISSIONS="CREATE_D3MODEL_PERMISSIONS",e.CREATE_PANEL_LIB="CREATE_PANEL_LIB",e.CREATE_PANEL_LIB_PERMISSIONS="CREATE_PANEL_LIB_PERMISSIONS",e.CREATE_PANEL_LIB_MIGRATE_CANVAS_ERROR="CREATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",e.CREATE_SIM_MODEL="CREATE_SIM_MODEL",e.CREATE_SIM_MODEL_PERMISSIONS="CREATE_SIM_MODEL_PERMISSIONS",e.CREATE_SIM_MODEL_MIGRATE_CANVAS_ERROR="CREATE_SIM_MODEL_MIGRATE_CANVAS_ERROR",e.UPDATE_DEVICE="UPDATE_DEVICE",e.UPDATE_DEVICE_ATTRIBUTES="UPDATE_DEVICE_ATTRIBUTES",e.UPDATE_DEVICE_PERMISSIONS="CREATE_DEVICE_PERMISSIONS",e.UPDATE_SYMBOL="UPDATE_SYMBOL",e.UPDATE_SYMBOL_MIGRATE_CANVAS_ERROR="UPDATE_SYMBOL_MIGRATE_CANVAS_ERROR",e.UPDATE_SYMBOL_PERMISSIONS="UPDATE_SYMBOL_PERMISSIONS",e.UPDATE_FOOTPRINT="UPDATE_FOOTPRINT",e.UPDATE_FOOTPRINT_MIGRATE_CANVAS_ERROR="UPDATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",e.UPDATE_FOOTPRINT_PERMISSIONS="UPDATE_FOOTPRINT_PERMISSIONS",e.UPDATE_D3MODEL="UPDATE_D3MODEL",e.UPDATE_D3MODEL_PERMISSIONS="UPDATE_D3MODEL_PERMISSIONS",e.UPDATE_SIM_MODEL="UPDATE_SIM_MODEL",e.UPDATE_SIM_MODEL_PERMISSIONS="UPDATE_SIM_MODEL_PERMISSIONS",e.UPDATE_PANEL_LIB="UPDATE_PANEL_LIB",e.UPDATE_PANEL_LIB_MIGRATE_CANVAS_ERROR="UPDATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",e.UPDATE_PANEL_LIB_PERMISSIONS="UPDATE_PANEL_LIB_PERMISSIONS",e.DELETE_DEVICE="DELETE_DEVICE",e.DELETE_SYMBOL="DELETE_SYMBOL",e.DELETE_FOOTPRINT="DELETE_FOOTPRINT",e.DELETE_PANEL_LIB="DELETE_PANEL_LIB",e.DELETE_SIM_MODEL="DELETE_SIM_MODEL",e.DELETE_3DMODEL="DELETE_3DMODEL",e))(fj||{}),he=class{constructor(e,t=""){this._message=t,this._action=e}get message(){return this._message}set message(e){this._message=e}get action(){return this._action}set action(e){this._action=e}toJSON(){return{message:this.message,action:this.action}}};function $s(e,t){let i=Object.keys(t);for(let r=0;r<i.length;r++)mX.indexOf(i[r])<=-1||(i[r]==="title"&&"display_title"in e&&t.title&&(e.display_title=String(t.title),e.title=String(t.title).toLocaleLowerCase()),e[i[r]]=t[i[r]])}function w0(e,t){return e[t]}function dN(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new he("DEVICE_NAMA_ERROR",i)}}function pN(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new he("SYMBOL_NAMA_ERROR",i)}}function fN(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new he("FOOTPRINT_NAMA_ERROR",i)}}function mN(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new he("PANEL_LIB_NAMA_ERROR",i)}}function gN(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new he("D3MODEL_NAMA_ERROR",i)}}function yN(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new he("SIM_MODEL_NAMA_ERROR",i)}}async function ym(e,t){let i=[],r=[],n=async o=>{let{message:l}=await xt.messageBus.rpcCall(lh.TAG.CREATE,o);return l},s=null;try{for(let o=0;o<e.length;o++){let l=await n({...e[o],path:e[o].user_uuid});if(l.code===0&&l.success){let u={...l,message:"",result:{...e[o],path:e[o].user_uuid,...l.result[0]}};i.push(u),t&&t(u,o);continue}let c={...l,result:{...e[o]}};r.push(c)}return{code:0,success:!0,result:{successList:i,failList:r},message:""}}catch(o){s=o}let a=s?s.msg||s.message:"Add Categories Batch Error";return{code:s?s.code:it.ERR_CODE.NORMAL,success:!1,result:null,message:a}}function Ga(e=[],t,i){if(!e||!e.length||!t)return{index:-1,data:null};let r={index:-1,data:null};for(let n=0;n<e.length;n++)if(typeof e[n]=="object"&&e[n][t]===i){r.data=e[n],r.index=n;break}return r}function mj(e=[],t,i){if(!e||!e.length||!t)return{indexs:[],datas:[]};let r={indexs:[],datas:[]};for(let n=0;n<e.length;n++)typeof e[n]=="object"&&e[n][t]===i&&(r.datas.push(e[n]),r.indexs.push(n));return r}function Fy(e=0,t=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(t-e+1))+e}function a0(e=36){let t=[],i="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let r=0;r<e;r++)t[r]=i.substr(Math.floor(Math.random()*16),1);return t[14]&&(t[14]=String(Fy(1,9))),t[19]&&(t[19]=i.substr(+t[19]&3|8,1)),t[8]&&(t[8]=String(Fy(1,9))),t[13]&&(t[13]=String(Fy(1,9))),t[18]&&(t[18]=String(Fy(1,9))),t[23]&&(t[23]=String(Fy(1,9))),t.join("")}function zL(e,t=!0){return(i,r)=>{let n=i[e],s=r[e];return typeof n<"u"&&typeof s<"u"?t?n-s:s-n:0}}var gj=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree,this.getFile=e.getDetail}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:n,lists:s,totalPage:a}=t;return{count:i,page:r,pageSize:n,totalPage:a,lists:s.map(o=>this.extendLib.transformer.transformCbbListItem(o))}}async getTransformedDetail(e){return await this.getDetail(e)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},yj=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getSupportedSymbolTypes=e.getSupportedSymbolTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:n,lists:s,totalPage:a}=t;return{count:i,page:r,pageSize:n,totalPage:a,lists:s.map(o=>this.extendLib.transformer.transformDeviceListItem(o))}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return this.extendLib.transformer.transformDeviceListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},bj=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:n,lists:s=[],totalPage:a}=t,o=[];for(let l of s)o.push(await this.extendLib.transformer.transformFootprintListItem(l));return{count:i,page:r,pageSize:n,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformFootprintListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},xj=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:n,lists:s=[],totalPage:a}=t,o=[];for(let l of s)o.push(await this.extendLib.transformer.transformModel3DListItem(l));return{count:i,page:r,pageSize:n,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformModel3DListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},Ej=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:n,lists:s=[],totalPage:a}=t,o=[];for(let l of s)o.push(await this.extendLib.transformer.transformPanelLibListItem(l));return{count:i,page:r,pageSize:n,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformPanelLibListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},Sj=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:n,lists:s=[],totalPage:a}=t,o=[];for(let l of s)o.push(await this.extendLib.transformer.transformSimModelListItem(l));return{count:i,page:r,pageSize:n,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformSimModelListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},wj=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getSupportedSymbolTypes=e.getSupportedSymbolTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:n,lists:s,totalPage:a}=t,o=[];for(let l of s)o.push(await this.extendLib.transformer.transformSymbolListItem(l));return{count:i,page:r,pageSize:n,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformSymbolListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},vj=class{constructor(e){this.extendLib=e}transformTime(e=Date.now()){return e.toString().length>13?e/1e3:e}transformTimeStr(e=Date.now()){let t=this.transformTime(e);return ld(new Date(t*1e3))}transformTags(e){let{primaryClassificationName:t,primaryClassificationUuid:i,secondaryClassificationName:r,secondaryClassificationUuid:n}=e||{};return{parent_tag:t?{uuid:i,name:t}:void 0,child_tag:r?{uuid:n,name:r}:void 0}}transformCategory(e,t){var i,r;let n=(i=e.uuid)!=null?i:crypto.randomUUID();return{id:n,title:e.name,titleAdditional:e.name_cn,children:(r=e.children)==null?void 0:r.map(s=>this.transformCategory(s,n)),parentId:t}}transformDeviceListItem(e){var t,i,r,n,s,a,o,l,c,u;return e.edaFormatedData?e.edaFormatedData:{title:e.name||"",description:e.description||"",images:[],uuid:e.uuid||this.extendLib.getDefaultItemId(),path:this.extendLib.id,source:"",version:"",ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},attributes:{...(t=e.attributes)!=null?t:{},Footprint:((i=e.footprint)==null?void 0:i.uuid)||"",Symbol:((r=e.symbol)==null?void 0:r.uuid)||"",Value:e.value||((n=e.attributes)==null?void 0:n.value)||"","Supplier Part":e.supplierPart||((s=e.attributes)==null?void 0:s.supplierPart)||"",Manufacturer:e.manufacturer||((a=e.attributes)==null?void 0:a.manufacturer)||"",Description:e.description||((o=e.attributes)==null?void 0:o.description)||""},symbol:e.symbol?{display_title:e.symbol.name||"",title:((l=e.symbol.name)==null?void 0:l.toLocaleLowerCase())||"",docType:+e.symbol.symbolType,path:this.extendLib.id,uuid:e.symbol.uuid,description:void 0,version:void 0,ticket:void 0,updateTime:void 0,createTime:void 0,creator:void 0,modifier:void 0,owner:void 0,tags:void 0,source:void 0,has_device:void 0,dataStr:void 0,dataStrId:void 0}:void 0,footprint:e.footprint?{display_title:e.footprint.name||"",title:((c=e.footprint.name)==null?void 0:c.toLocaleLowerCase())||"",docType:4,path:this.extendLib.id,uuid:e.footprint.uuid,description:void 0,version:void 0,ticket:void 0,updateTime:void 0,createTime:void 0,creator:void 0,modifier:void 0,owner:void 0,tags:void 0,source:void 0,has_device:void 0,dataStr:void 0,dataStrId:void 0}:void 0,tags:this.transformTags(e.classification),symbol_type:(u=e.symbol)==null?void 0:u.symbolType}}async transformSymbolListItem(e){var t,i,r,n,s,a,o,l,c,u;return e.edaFormatedData?e.edaFormatedData:{docType:e.symbolType,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",description:e.description||"",path:this.extendLib.id,source:"",version:(t=e.version)!=null?t:"",ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(i=e.creator.name)!=null?i:"",username:(r=e.creator.name)!=null?r:"",uuid:(n=e.creator.uuid)!=null?n:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(s=e.modifier.name)!=null?s:"",username:(a=e.modifier.name)!=null?a:"",uuid:(o=e.modifier.uuid)!=null?o:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(l=e.owner.name)!=null?l:"",username:(c=e.owner.name)!=null?c:"",uuid:(u=e.owner.uuid)!=null?u:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},dataStr:e.data instanceof Blob?await e.data.text():e.data,tags:this.transformTags(e.classification)}}async transformFootprintListItem(e){var t,i,r,n,s,a,o,l,c,u;return e.edaFormatedData?e.edaFormatedData:{docType:4,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",description:e.description||"",path:this.extendLib.id,source:"",version:(t=e.version)!=null?t:"",ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(i=e.creator.name)!=null?i:"",username:(r=e.creator.name)!=null?r:"",uuid:(n=e.creator.uuid)!=null?n:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(s=e.modifier.name)!=null?s:"",username:(a=e.modifier.name)!=null?a:"",uuid:(o=e.modifier.uuid)!=null?o:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(l=e.owner.name)!=null?l:"",username:(c=e.owner.name)!=null?c:"",uuid:(u=e.owner.uuid)!=null?u:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},dataStr:e.data instanceof Blob?await e.data.text():e.data,tags:this.transformTags(e.classification)}}async transformPanelLibListItem(e){var t,i,r,n,s,a,o,l,c;return e.edaFormatedData?e.edaFormatedData:{...e.edaFormatedData,docType:29,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",description:e.description||"",path:this.extendLib.id,ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(t=e.creator.name)!=null?t:"",username:(i=e.creator.name)!=null?i:"",uuid:(r=e.creator.uuid)!=null?r:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(n=e.modifier.name)!=null?n:"",username:(s=e.modifier.name)!=null?s:"",uuid:(a=e.modifier.uuid)!=null?a:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(o=e.owner.name)!=null?o:"",username:(l=e.owner.name)!=null?l:"",uuid:(c=e.owner.uuid)!=null?c:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},tags:this.transformTags(e.classification)}}async transformModel3DListItem(e){var t,i,r,n,s,a,o,l,c;return e.edaFormatedData?e.edaFormatedData:{...e.edaFormatedData,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",description:e.description||"",path:this.extendLib.id,ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(t=e.creator.name)!=null?t:"",username:(i=e.creator.name)!=null?i:"",uuid:(r=e.creator.uuid)!=null?r:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(n=e.modifier.name)!=null?n:"",username:(s=e.modifier.name)!=null?s:"",uuid:(a=e.modifier.uuid)!=null?a:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(o=e.owner.name)!=null?o:"",username:(l=e.owner.name)!=null?l:"",uuid:(c=e.owner.uuid)!=null?c:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},tags:this.transformTags(e.classification)}}async transformSimModelListItem(e){var t,i,r,n,s,a,o,l,c;return e.edaFormatedData?e.edaFormatedData:{...e.edaFormatedData,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",path:this.extendLib.id,ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(t=e.creator.name)!=null?t:"",username:(i=e.creator.name)!=null?i:"",uuid:(r=e.creator.uuid)!=null?r:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(n=e.modifier.name)!=null?n:"",username:(s=e.modifier.name)!=null?s:"",uuid:(a=e.modifier.uuid)!=null?a:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(o=e.owner.name)!=null?o:"",username:(l=e.owner.name)!=null?l:"",uuid:(c=e.owner.uuid)!=null?c:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},tags:this.transformTags(e.classification)}}transformCbbListItem(e){var t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E,S,w,x,I,A,O,R,M,F,G,V,q,C,N,T,L,P,B;return e.edaFormatedData?e.edaFormatedData:{cbb_project:!0,content:(t=e.description)!=null?t:"",creator:e.creator?{avatar:"",nickname:(i=e.creator.name)!=null?i:"",username:(r=e.creator.name)!=null?r:"",uuid:(n=e.creator.uuid)!=null?n:""}:{avatar:"",nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(s=e.modifier.name)!=null?s:"",username:(a=e.modifier.name)!=null?a:"",uuid:(o=e.modifier.uuid)!=null?o:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{avatar:"",team:!1,nickname:(l=e.owner.name)!=null?l:"",username:(c=e.owner.name)!=null?c:"",uuid:(u=e.owner.uuid)!=null?u:""}:{avatar:"",team:!1,nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},name:e.name,path:this.extendLib.id,block_symbol:(d=(h=e.blockSymbols)==null?void 0:h.map(U=>{var X;return{uuid:U.uuid,display_title:U.name,docType:17,project_uuid:(X=e.uuid)!=null?X:e.name,title:U.name.toLocaleLowerCase()}}))!=null?d:[],schematics:(f=(p=e.schematics)==null?void 0:p.map(U=>{var X,J;let ne=(J=(X=e.sheets)==null?void 0:X.filter(fe=>fe.belongSchematicUuid===U.uuid).map(fe=>({uuid:fe.uuid,ticket:0})))!=null?J:[];return{create_at:this.transformTimeStr(U.createTime||U.updateTime),createtime:this.transformTime(U.createTime||U.updateTime),display_name:U.name,name:U.name.toLocaleLowerCase(),project_uuid:e.uuid,sheet_count:ne.length,sort:ne,ticket:0,update_at:this.transformTimeStr(U.updateTime),uuid:U.uuid,updateTime:this.transformTime(U.updateTime)}}))!=null?f:[],pcb:(g=(m=e.pcbs)==null?void 0:m.map(U=>{var X,J,ne,fe,xe,ve,Fe,Ne,nt,je,vt;return{description:(X=U.description)!=null?X:"",display_title:U.name,docType:3,project_uuid:(J=e.uuid)!=null?J:"",thumb:U.thumb,title:U.name.toLocaleLowerCase(),updateTime:this.transformTime(U.updateTime),uuid:U.uuid,creator:U.creator?{avatar:"",nickname:(fe=(ne=U.creator)==null?void 0:ne.name)!=null?fe:"",username:(ve=(xe=U.creator)==null?void 0:xe.name)!=null?ve:"",uuid:(Ne=(Fe=U.creator)==null?void 0:Fe.uuid)!=null?Ne:""}:{avatar:"",nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:U.modifier?{nickname:(nt=U==null?void 0:U.modifier.name)!=null?nt:"",username:(je=U==null?void 0:U.modifier.name)!=null?je:"",uuid:(vt=U==null?void 0:U.modifier.uuid)!=null?vt:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id}}}))!=null?g:[],schs:(y=(b=e.sheets)==null?void 0:b.map(U=>{var X,J,ne,fe,xe,ve,Fe,Ne;return{description:(X=U.description)!=null?X:"",display_title:U.name,docType:1,project_uuid:(J=e.uuid)!=null?J:"",schematic_uuid:U.belongSchematicUuid,thumb:U.thumb,title:U.name.toLocaleLowerCase(),updateTime:this.transformTime(U.updateTime),uuid:U.uuid,creator:U.creator?{avatar:"",nickname:(ne=U==null?void 0:U.creator.name)!=null?ne:"",username:(fe=U==null?void 0:U.creator.name)!=null?fe:"",uuid:(xe=U==null?void 0:U.creator.uuid)!=null?xe:""}:{avatar:"",nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:U!=null&&U.modifier?{nickname:(ve=U==null?void 0:U.modifier.name)!=null?ve:"",username:(Fe=U==null?void 0:U.modifier.name)!=null?Fe:"",uuid:(Ne=U==null?void 0:U.modifier.uuid)!=null?Ne:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id}}}))!=null?y:[],tags:{parent_tag:{name:(S=(E=e.classification)==null?void 0:E.primaryClassificationName)!=null?S:"",name_cn:(x=(w=e.classification)==null?void 0:w.primaryClassificationName)!=null?x:"",title:(A=(I=e.classification)==null?void 0:I.primaryClassificationName)!=null?A:"",uuid:(R=(O=e.classification)==null?void 0:O.primaryClassificationUuid)!=null?R:""},child_tag:{name:(F=(M=e.classification)==null?void 0:M.secondaryClassificationName)!=null?F:"",name_cn:(V=(G=e.classification)==null?void 0:G.secondaryClassificationName)!=null?V:"",title:(C=(q=e.classification)==null?void 0:q.secondaryClassificationName)!=null?C:"",uuid:(T=(N=e.classification)==null?void 0:N.secondaryClassificationUuid)!=null?T:""}},updated_at:this.transformTimeStr(e.updateTime),uuid:(L=e.uuid)!=null?L:e.name,boards:(B=(P=e.boards)==null?void 0:P.map(U=>({name:U.name,pcb:U.pcbUuid,sch:U.schUuid})))!=null?B:[]}}},Tj=class bN{constructor(t){this.transformer=new vj(this),this.id=t.id,this.isVisible=i=>t.isVisible?t.isVisible(i)&&this.isInTab(i.tabName):this.isInTab(i.tabName),this.title=t.title,this.position=t.position,t.device&&(this.device=new yj(t.device,this)),t.symbol&&(this.symbol=new wj(t.symbol,this)),t.footprint&&(this.footprint=new bj(t.footprint,this)),t.panelLib&&(this.panelLib=new Ej(t.panelLib,this)),t.cbb&&(this.cbb=new gj(t.cbb,this)),t.model3D&&(this.model3D=new xj(t.model3D,this)),t.modelSimLib&&(this.modelSimLib=new Sj(t.modelSimLib,this))}static async set(t){var i,r,n,s,a,o,l,c,u,h;let d=new bN(t);return d._deviceSupportedSymbolTypes=await((r=(i=t.device)==null?void 0:i.getSupportedSymbolTypes)==null?void 0:r.call(i)),d._symbolSupportedSymbolTypes=await((s=(n=t.symbol)==null?void 0:n.getSupportedSymbolTypes)==null?void 0:s.call(n)),d._deviceSupportedPreviewTypes=await((o=(a=t.device)==null?void 0:a.getSupportedPriviewTypes)==null?void 0:o.call(a)),d._footprintSupportedPreviewTypes=await((c=(l=t.footprint)==null?void 0:l.getSupportedPriviewTypes)==null?void 0:c.call(l)),d._panelLibSupportedPreviewTypes=await((h=(u=t.panelLib)==null?void 0:u.getSupportedPriviewTypes)==null?void 0:h.call(u)),d}getDefaultItemId(){return crypto.randomUUID().replace("-","")}getLibraryFunctionsClassInTab(t){switch(t){case"cbb":return this==null?void 0:this.cbb;case"device":return this==null?void 0:this.device;case"symbol":return this==null?void 0:this.symbol;case"footprint":return this==null?void 0:this.footprint;case"panelLib":return this==null?void 0:this.panelLib;case"model3D":return this==null?void 0:this.model3D;case"modelSimLib":return this==null?void 0:this.modelSimLib;default:return null}}isInTab(t){return!!this.getLibraryFunctionsClassInTab(t)}isHasCategoryTreeInTab(t){let i=this.getLibraryFunctionsClassInTab(t);return!!(i!=null&&i.getClassificationTree)}async getAmountByWd(t,i){var r;let n=this.getLibraryFunctionsClassInTab(t),s=await(n==null?void 0:n.getList({page:1,pageSize:1,query:{wd:i}}));return(r=s==null?void 0:s.count)!=null?r:0}getTabByCategoryType(t){switch(t){case 1:return"cbb";case 3:return"device";case 2:return"symbol";case 4:return"footprint";default:return null}}async getClassificationTreeInTab(t){var i;return this.isHasCategoryTreeInTab(t)?await((i=this.getLibraryFunctionsClassInTab(t))==null?void 0:i.getClassificationTree()):null}async getCategoryTreeDataItemsInTab(t){let i=await this.getClassificationTreeInTab(t);return i==null?void 0:i.map(r=>this.transformer.transformCategory(r))}async getClassificationTreeByCategoryType(t){let i=this.getTabByCategoryType(t);return i&&this.getClassificationTreeInTab(i)}async getCategoryTreeDataItemsByCategoryType(t){let i=this.getTabByCategoryType(t);return i&&this.getCategoryTreeDataItemsInTab(i)}getSelectTypeListInTab(t){let i=[];if(t==="device"){let r=this._deviceSupportedSymbolTypes;i=r?NL.filter(n=>r.includes(Number(n.value))||!n.value):NL}else if(t==="symbol"){let r=this._symbolSupportedSymbolTypes;i=r?ML.filter(n=>r.includes(Number(n.value))||!n.value):ML}return i.length>2?i:[]}getPreviewTypesInTab(t){let i=fH[t];return t==="device"&&this._deviceSupportedPreviewTypes?i=i.filter(r=>{var n;return(n=this._deviceSupportedPreviewTypes)==null?void 0:n.includes(r)}):t==="footprint"&&this._footprintSupportedPreviewTypes&&(i=i.filter(r=>{var n;return(n=this._footprintSupportedPreviewTypes)==null?void 0:n.includes(r)})),i}async getListInTab(t,i){var r;return await((r=this.getLibraryFunctionsClassInTab(t))==null?void 0:r.getList(i))}async getTransformedListInTab(t,i){var r;return await((r=this.getLibraryFunctionsClassInTab(t))==null?void 0:r.getTransformedList(i))}async getDetailInTab(t,i,r){var n;return await((n=this.getLibraryFunctionsClassInTab(t))==null?void 0:n.getDetail(i,r))}async getTransformedDetailInTab(t,i,r){var n;return await((n=this.getLibraryFunctionsClassInTab(t))==null?void 0:n.getTransformedDetail(i,r))}},Ij=class{constructor(e=10){this._runingCount=0,this._handleCount=0,this._queue=[],this._results=[],this._windowSize=e,this._finishCallback=null,this._taskStartCallback=null,this._taskEndCallback=null}pushTask(e){this._queue.push(e)}setFinishCallback(e){this._finishCallback=e}setTaskStartCallback(e){this._taskStartCallback=e}setTaskEndCallback(e){this._taskEndCallback=e}next(){for(;this._runingCount<this._windowSize&&this._queue.length>0;){this._runingCount+=1,this._handleCount+=1;let e=this._handleCount-1,t=this._queue.shift();this._taskStartCallback&&this._taskStartCallback(e),t(e).then(i=>{this._results.push(i)}).catch(i=>{this._results.push(i)}).finally(()=>{this._runingCount-=1,this._taskEndCallback&&this._taskEndCallback(this._results[this._results.length-1]),this.next()})}this._runingCount<=0&&this._finishCallback&&this._finishCallback(this._results)}},II=class{onString(e,t,i){}onAttr(e,t,i){}onGroup(e,t,i,r,n){}onDelGroup(e,t,i,r){}onDelString(e,t,i,r){}onDelAttr(e,t,i,r){}onPanelizeSide(e,t,i,r){}onDelPanelizeSide(e,t,i,r){}onPanelizeStamp(e,t,i,r){}onDelPanelizeStamp(e,t,i,r){}onPanelize(e,t,i,r){}onDelPanelize(e,t,i){}onRuleSelector(e,t,i,r){}onDelRuleSelector(e,t,i,r){}onRule(e,t,i,r){}onDelRule(e,t,i,r,n){}onRuleTemplate(e,t,i,r){}onDimension(e,t,i,r,n,s){}onDelDimension(e,t,i,r){}onBoss(e,t,i,r,n,s){}onDelBoss(e,t,i,r){}onShellEntity(e,t,i,r,n,s){}onDelShellEntity(e,t,i,r){}onShellCut(e,t,i,r,n,s){}onDelShellCut(e,t,i,r){}onCrease(e,t,i,r,n,s){}onDelCrease(e,t,i,r){}onShell(e,t,i,r,n,s){}onDelShell(e,t,i,r){}onFpcFill(e,t,i,r,n,s){}onDelFpcFill(e,t,i,r){}onTeardrop(e,t,i,r,n,s){}onDelTeardrop(e,t,i,r){}onImage(e,t,i,r,n,s){}onDelImage(e,t,i,r){}onPoured(e,t,i,r,n,s){}onDelPoured(e,t,i,r){}onPour(e,t,i,r,n,s){}onDelPour(e,t,i,r){}onRegion(e,t,i,r,n,s){}onDelRegion(e,t,i,r){}onFill(e,t,i,r,n,s){}onDelFill(e,t,i,r){}onPoly(e,t,i,r,n,s){}onDelPoly(e,t,i,r){}onEQLenGrp(e,t,i,r,n){}onDelEQLenGrp(e,t,i,r){}onDelProp(e,t,i,r){}onObj(e,t,i,r,n,s){}onDelObj(e,t,i,r){}onArc(e,t,i,r,n,s){}onDelArc(e,t,i,r){}onCArc(e,t,i,r,n,s){}onDelCArc(e,t,i,r){}onLine(e,t,i,r,n,s){}onDelLine(e,t,i,r){}onPad(e,t,i,r,n,s){}onDelPad(e,t,i,r){}onVia(e,t,i,r,n,s){}onDelVia(e,t,i,r){}onDelConnect(e,t,i,r){}onPreference(e,t,i,r){}onSilkOpts(e,t,i,r,n){}onDelSilkOpts(e,t,i,r){}onPrimitive(e,t,i,r,n){}onDelPrimitive(e,t,i,r){}onNet(e,t,i,r,n){}onDelNet(e,t,i,r){}onPartition(e,t,i,r,n,s){}onDelPartition(e,t,i,r){}onActiveLayer(e,t,i,r){}onLayerPhys(e,t,i,r,n){}onDelLayerPhys(e,t,i,r){}onLayer(e,t,i,r,n){}onDelLayer(e,t,i,r){}onCanvas(e,t,i,r){}onDocDetail(e,t,i,r){}onStringNum(e,t){}onAttrNum(e,t){}onDimensionNum(e,t){}onBossNum(e,t){}onShellEntityNum(e,t){}onShellCutNum(e,t){}onCreaseNum(e,t){}onShellNum(e,t){}onFpcFillNum(e,t){}onTeardropNum(e,t){}onImageNum(e,t){}onPouredNum(e,t){}onPourNum(e,t){}onRegionNum(e,t){}onFillNum(e,t){}onPolyNum(e,t){}onObjNum(e,t){}onArcNum(e,t){}onCArcNum(e,t){}onLineNum(e,t){}onPadNum(e,t){}onViaNum(e,t){}onPartitionNum(e,t){}},Aj=class extends II{constructor(e){super(),this.source={},this._action=e}get action(){return this._action}getSource(){return this.source}onString(e,t,i){this.source[e]=t}onAttr(e,t,i){i||(this.action&&this.action(e,t),this.source[e]=t)}onDimension(e,t,i,r,n,s){this.source[e]=n}onBoss(e,t,i,r,n,s){this.source[e]=n}onShellEntity(e,t,i,r,n,s){this.source[e]=n}onShellCut(e,t,i,r,n,s){this.source[e]=n}onCrease(e,t,i,r,n,s){this.source[e]=n}onShell(e,t,i,r,n,s){this.source[e]=n}onFpcFill(e,t,i,r,n,s){this.source[e]=n}onTeardrop(e,t,i,r,n,s){this.source[e]=n}onImage(e,t,i,r,n,s){this.source[e]=n}onPoured(e,t,i,r,n,s){this.source[e]=n}onPour(e,t,i,r,n,s){this.source[e]=n}onRegion(e,t,i,r,n,s){this.source[e]=n}onFill(e,t,i,r,n,s){this.source[e]=n}onPoly(e,t,i,r,n,s){this.source[e]=n}onObj(e,t,i,r,n,s){this.source[e]=n}onArc(e,t,i,r,n,s){this.source[e]=n}onCArc(e,t,i,r,n,s){this.source[e]=n}onLine(e,t,i,r,n,s){this.source[e]=n}onPad(e,t,i,r,n,s){this.source[e]=n}onVia(e,t,i,r,n,s){this.source[e]=n}},xN=class extends VO{onXSignalsGroup(e,t,i,r,n){}onDelXSignalsGroup(e,t,i,r){}onXSignals(e,t,i,r,n){}onDelXSignals(e,t,i,r){}onBoard(e,t,i,r){}onDelBoard(e,t,i){}constructor(e,t,i){super(e,t,i,new mI(!1)),this._compilerHandler=null}async init(e=!1,t=!1,i=!1,r=!1){if(!this.uuid)debugger;return super.init(e,t,i,r)}onBlob(e,t,i,r,n){}onDelBlob(e,t,i,r){}onFont(e,t,i,r){}onDelFont(e,t,i,r){}canvasSelected(){return""}onSelectChange(e,t,i){}onSelectQuit(e,t){}onLayerFill(e,t,i,r,n){}onDelLayerFill(e,t,i,r){}setHandler(e){this._compilerHandler=e}onGroup(e,t,i,r,n){this._compilerHandler&&this._compilerHandler.onGroup(e,t,i,r,n)}onDelGroup(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelGroup(e,t,i,r)}onString(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onString(e,n,s)}onDelString(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelString(e,t,i,r)}onAttr(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onAttr(e,n,s)}onDelAttr(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelAttr(e,t,i,r)}onPanelizeSide(e,t,i,r){this._compilerHandler&&this._compilerHandler.onPanelizeSide(e,t,i,r)}onDelPanelizeSide(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPanelizeSide(e,t,i,r)}onPanelizeStamp(e,t,i,r){this._compilerHandler&&this._compilerHandler.onPanelizeStamp(e,t,i,r)}onDelPanelizeStamp(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPanelizeStamp(e,t,i,r)}onPanelize(e,t,i,r){this._compilerHandler&&this._compilerHandler.onPanelize(e,t,i,r)}onDelPanelize(e,t,i){this._compilerHandler&&this._compilerHandler.onDelPanelize(e,t,i)}onRuleSelector(e,t,i,r){this._compilerHandler&&this._compilerHandler.onRuleSelector(e,t,i,r)}onDelRuleSelector(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelRuleSelector(e,t,i,r)}onRule(e,t,i,r){this._compilerHandler&&this._compilerHandler.onRule(e,t,i,r)}onDelRule(e,t,i,r,n){this._compilerHandler&&this._compilerHandler.onDelRule(e,t,i,r,n)}onRuleTemplate(e,t,i,r){this._compilerHandler&&this._compilerHandler.onRuleTemplate(e,t,i,r)}onDimension(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onDimension(e,t,i,r,n,s)}onDelDimension(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelDimension(e,t,i,r)}onBoss(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onBoss(e,t,i,r,n,s)}onDelBoss(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelBoss(e,t,i,r)}onShellEntity(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onShellEntity(e,t,i,r,n,s)}onDelShellEntity(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelShellEntity(e,t,i,r)}onShellCut(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onShellCut(e,t,i,r,n,s)}onDelShellCut(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelShellCut(e,t,i,r)}onCrease(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onCrease(e,t,i,r,n,s)}onDelCrease(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelCrease(e,t,i,r)}onShell(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onShell(e,t,i,r,n,s)}onDelShell(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelShell(e,t,i,r)}onFpcFill(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onFpcFill(e,t,i,r,n,s)}onDelFpcFill(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelFpcFill(e,t,i,r)}onTeardrop(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onTeardrop(e,t,i,r,n,s)}onDelTeardrop(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelTeardrop(e,t,i,r)}onImage(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onImage(e,t,i,r,n,s)}onDelImage(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelImage(e,t,i,r)}onPoured(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onPoured(e,t,i,r,n,s)}onDelPoured(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPoured(e,t,i,r)}onPour(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onPour(e,t,i,r,n,s)}onDelPour(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPour(e,t,i,r)}onRegion(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onRegion(e,t,i,r,n,s)}onDelRegion(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelRegion(e,t,i,r)}onFill(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onFill(e,t,i,r,n,s)}onDelFill(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelFill(e,t,i,r)}onPoly(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onPoly(e,t,i,r,n,s)}onDelPoly(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPoly(e,t,i,r)}onEQLenGrp(e,t,i,r,n){this._compilerHandler&&this._compilerHandler.onEQLenGrp(e,t,i,r,n)}onDelEQLenGrp(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelEQLenGrp(e,t,i,r)}onDelProp(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelProp(e,t,i,r)}onObj(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onObj(e,t,i,r,n,s)}onDelObj(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelObj(e,t,i,r)}onArc(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onArc(e,t,i,r,n,s)}onDelArc(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelArc(e,t,i,r)}onCArc(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onCArc(e,t,i,r,n,s)}onDelCArc(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelCArc(e,t,i,r)}onLine(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onLine(e,t,i,r,n,s)}onDelLine(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelLine(e,t,i,r)}onPad(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onPad(e,t,i,r,n,s)}onDelPad(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPad(e,t,i,r)}onVia(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onVia(e,t,i,r,n,s)}onDelVia(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelVia(e,t,i,r)}onDelConnect(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelConnect(e,t,i,r)}onPreference(e,t,i,r){this._compilerHandler&&this._compilerHandler.onPreference(e,t,i,r)}onSilkOpts(e,t,i,r,n){this._compilerHandler&&this._compilerHandler.onSilkOpts(e,t,i,r,n)}onDelSilkOpts(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelSilkOpts(e,t,i,r)}onPrimitive(e,t,i,r,n){this._compilerHandler&&this._compilerHandler.onPrimitive(e,t,i,r,n)}onDelPrimitive(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPrimitive(e,t,i,r)}onNet(e,t,i,r,n){this._compilerHandler&&this._compilerHandler.onNet(e,t,i,r,n)}onDelNet(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelNet(e,t,i,r)}onPartition(e,t,i,r,n,s){this._compilerHandler&&this._compilerHandler.onPartition(e,t,i,r,n,s)}onDelPartition(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPartition(e,t,i,r)}onActiveLayer(e,t,i,r){this._compilerHandler&&this._compilerHandler.onActiveLayer(e,t,i,r)}onLayerPhys(e,t,i,r,n){this._compilerHandler&&this._compilerHandler.onLayerPhys(e,t,i,r,n)}onDelLayerPhys(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelLayerPhys(e,t,i,r)}onLayer(e,t,i,r,n){this._compilerHandler&&this._compilerHandler.onLayer(e,t,i,r,n)}onDelLayer(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelLayer(e,t,i,r)}onCanvas(e,t,i,r){this._compilerHandler&&this._compilerHandler.onCanvas(e,t,i,r)}onDocDetail(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDocDetail(e,t,i,r)}onStringNum(e,t){this._compilerHandler&&this._compilerHandler.onStringNum(e,t)}onAttrNum(e,t){this._compilerHandler&&this._compilerHandler.onAttrNum(e,t)}onDimensionNum(e,t){this._compilerHandler&&this._compilerHandler.onDimensionNum(e,t)}onBossNum(e,t){this._compilerHandler&&this._compilerHandler.onBossNum(e,t)}onShellEntityNum(e,t){this._compilerHandler&&this._compilerHandler.onShellEntityNum(e,t)}onShellCutNum(e,t){this._compilerHandler&&this._compilerHandler.onShellCutNum(e,t)}onCreaseNum(e,t){this._compilerHandler&&this._compilerHandler.onCreaseNum(e,t)}onShellNum(e,t){this._compilerHandler&&this._compilerHandler.onShellNum(e,t)}onFpcFillNum(e,t){this._compilerHandler&&this._compilerHandler.onFpcFillNum(e,t)}onTeardropNum(e,t){this._compilerHandler&&this._compilerHandler.onTeardropNum(e,t)}onImageNum(e,t){this._compilerHandler&&this._compilerHandler.onImageNum(e,t)}onPouredNum(e,t){this._compilerHandler&&this._compilerHandler.onPouredNum(e,t)}onPourNum(e,t){this._compilerHandler&&this._compilerHandler.onPourNum(e,t)}onRegionNum(e,t){this._compilerHandler&&this._compilerHandler.onRegionNum(e,t)}onFillNum(e,t){this._compilerHandler&&this._compilerHandler.onFillNum(e,t)}onPolyNum(e,t){this._compilerHandler&&this._compilerHandler.onPolyNum(e,t)}onObjNum(e,t){this._compilerHandler&&this._compilerHandler.onObjNum(e,t)}onArcNum(e,t){this._compilerHandler&&this._compilerHandler.onArcNum(e,t)}onCArcNum(e,t){this._compilerHandler&&this._compilerHandler.onCArcNum(e,t)}onLineNum(e,t){this._compilerHandler&&this._compilerHandler.onLineNum(e,t)}onPadNum(e,t){this._compilerHandler&&this._compilerHandler.onPadNum(e,t)}onViaNum(e,t){this._compilerHandler&&this._compilerHandler.onViaNum(e,t)}onPartitionNum(e,t){this._compilerHandler&&this._compilerHandler.onPartitionNum(e,t)}};function Cj(e,t){let i=0;return function(...r){let n=new Date().getTime();n-i>t&&(e.apply(this,r),i=n)}}function Dj(e,t,i){let r,n,s,a,o,l,c=0,u=!1,h=!1,d=!0;if(typeof e!="function")throw new TypeError("Expected a function");t=Number(t)||0,typeof i=="object"&&(u=!!i.leading,h="maxWait"in i,s=h?Math.max(Number(i.maxWait)||0,t):s,d="trailing"in i?!!i.trailing:d);function p(x){let I=r,A=n;return r=n=void 0,c=x,a=e.apply(A,I),a}function f(x){return c=x,o=window.setTimeout(b,t),u?p(x):a}function m(x){let I=x-l,A=x-c,O=t-I;return h?Math.min(O,s-A):O}function g(x){let I=x-l,A=x-c;return l===void 0||I>=t||I<0||h&&A>=s}function b(){let x=Date.now();if(g(x))return y(x);o=window.setTimeout(b,m(x))}function y(x){return o=void 0,d&&r?p(x):(r=n=void 0,a)}function E(){o!==void 0&&clearTimeout(o),c=0,r=l=n=o=void 0}function S(){return o===void 0?a:y(Date.now())}function w(){let x=Date.now(),I=g(x);if(r=arguments,n=this,l=x,I){if(o===void 0)return f(l);if(h)return o=window.setTimeout(b,t),p(l)}return o===void 0&&(o=window.setTimeout(b,t)),a}return w.cancel=E,w.flush=S,w}var Dp=new Map;Dp.set("<","&lt;");Dp.set(">","&gt;");Dp.set('"',"&quot;");Dp.set("'","&apos;");Dp.set("&","&amp;");function EN(e){if(typeof e!="string")return e;if(e==null)return"";function t(i){return Dp.get(i)}return e==null?"":Zx(e,Dp)?(e+"").replace(/[<>'"&]/g,t):e}var Op=new Map;Op.set("&lt;","<");Op.set("&gt;",">");Op.set("&quot;",'"');Op.set("&apos;","'");Op.set("&amp;","&");Op.set("&#039;","'");function _j(e){if(typeof e!="string")return e;if(e==null)return"";let t={"&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&amp;":"&","&#039;":"'"};function i(r){return Op.get(r)}return Zx(e,t)?(e+"").replace(/&([^;]+);/g,i):e}var v0=new Map;v0.set("~","&#126;");v0.set("^","&#94;");v0.set("#@$","&#35;&#64;&#36;");v0.set("`","&#96;");function Pj(e){if(typeof e!="string")return e;if(e==null)return"";let t={"~":"&#126;","^":"&#94;","#@$":"&#35;&#64;&#36;","`":"&#96;"};function i(r){return v0.get(r)}return Zx(e,t)?e.replace(/(\~|\^|#@\$|\`)/g,i):e}function JT(e){if(typeof e!="object"||e===null||e===void 0)return e;if(Array.isArray(e))return e.map(JT);{let t={};for(let i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=JT(e[i]));return t}}function KT(e){if(typeof e!="object"||e===null||e instanceof Date)return typeof e=="string"&&e.includes("<")&&(e=EN(e)),e;if(Array.isArray(e))return e.map(KT);{let t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=KT(e[i]));return t}}function Lj(e,t){let i="",r="";for(let n=0;n<e.length;n++)String(e[n])&&(r+=e[n]+"	");r=r.slice(0,-1),i+=r+`\r
`;for(let n=0;n<t.length;n++){r="";for(let s=0;s<e.length;s++)r+='"'+(typeof t[n][s]<"u"?t[n][s]:"")+'"	';r=r.slice(0,r.length-1),i+=r+`\r
`}return i}function Oj(e,t={targetType:"blob"}){let{targetType:i,width:r,height:n}=t,s=new Image(r,n);return new Promise((a,o)=>{s.onload=function(){let l=document.createElement("canvas"),c=l.getContext("2d");switch(l.width=s.width,l.height=s.height,c.drawImage(s,0,0,s.width,s.height),i){case"dataURL":{a(l.toDataURL());break}case"blob":default:{l.toBlob(u=>{a(u)});break}}},s.onerror=l=>{o(l)},s.src=e})}async function Rj(e,t={}){return new Promise((i,r)=>{try{let{targetType:n="blob",imageType:s="image/png"}=t,a=document.createElement("canvas"),o=a.getContext("2d");switch(a.width=e.width,a.height=e.height,o.putImageData(e,0,0),n){case"dataURL":{i(a.toDataURL(s));break}case"blob":default:{a.toBlob(l=>{i(l)},s);break}}}catch(n){r(n)}})}var Nj=class extends II{constructor(e){super(),this._action=e}get action(){return this._action}onAttr(e,t,i){i||this.action(t.key,t.value)}};async function Mj(e,t,i,r=!0){let n={initResponse:null,d3modelItem:null,d3modelItemName:void 0,d3modelItemTransform:void 0,d3modelItemPath:void 0,d3modelItemId:void 0,compiler:null},s=new Map;return new Promise(async a=>{let o=new xN(e,t,i);n.compiler=o,o.setHandler(new Nj(async(l,c)=>{if(typeof c<"u"&&s.set(l,c),s.has("3D Model")&&s.has("3D Model Title")&&s.has("3D Model Transform")){n.d3modelItemId=s.get("3D Model"),n.d3modelItemName=s.get("3D Model Title"),n.d3modelItemTransform=s.get("3D Model Transform");let u=x0(n.d3modelItemId,!0);n.d3modelItemPath=u.path}})),n.initResponse=await o.init().catch(l=>({message:l.message,success:!1})),n.d3modelItemId&&r&&(n.d3modelItem=await S0(n.d3modelItemId)),n.compiler.destroy(),s.clear(),a(n)})}async function Bj(e,t){let i={padList:[]};return new Promise(async r=>{try{let n=new eH(e,t,!0),s=await n.getPads()||{},a=Object.keys(s);for(let o=0;o<a.length;o++)i.padList.push({...s[a[o]]});n.destroy(),r(i)}catch{r(i)}})}function kj(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);let r=[1,10,100,1e3][t]||Math.pow(10,t)||10;if(i){let n=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),n+e}else return Math.round(e*r+1e-10)/r}function Fj(e,t){typeof e=="string"&&(e=parseFloat(e));let i=Math.pow(10,t);return Math.round(e*i)/i}var Gj={conversion(e,t,i){let r=e+2+t;return this[r](i)},conversion1(e,t,i){let r=e+2+t,n=this[r](i);return t=="mil"?Math.round(n*10)/10:Math.round(n*1e3)/1e3},mil2mil(e){return e},mil2mm(e){return e*.0254},mil2cm(e){return e*.00254},mil2inch(e){return e/1e3},mm2mm(e){return e},mm2mil(e){let t=Math.pow(10,5);return Math.round(e*39.37007874015748*t)/t},mm2cm(e){return e/10},mm2inch(e){let t=Math.pow(10,8);return Math.round(e*.03937007874015748*t)/t},cm2mil(e){let t=Math.pow(10,6);return Math.round(e*3.937007874015748*t)/t},cm2mm(e){return e*10},cm2inch(e){let t=Math.pow(10,7);return Math.round(e*.3937007874015748*t)/t},inch2mil(e){return e*1e3},inch2mm(e){return e*25.4},inch2cm(e){return e*2.54}};function Uj(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function Yj(e){return e<0?(360+e%360)%360:e>=360?e%360:e}function SN(e,t,i,r){var n=e-i,s=t-r;return n*n+s*s}function Vj(e,t,i,r){return Math.sqrt(SN(e,t,i,r))}function Hj(e,t,i,r){var n=i-e,s=r-t,a=Math.atan2(s,n);return a=a<0?a+Math.PI+Math.PI:a,a}function jj(e){return wN(e)&&Object.keys(e).length===0}function wN(e){return Object.prototype.toString.call(e).slice(8,-1)==="Object"}function zj(e){return vN(e)||TN(e)}function vN(e){return Object.prototype.toString.call(e).slice(8,-1)==="AsyncFunction"}function TN(e){return Object.prototype.toString.call(e).slice(8,-1)==="Function"}var Qi=class{};Qi.unitConversion=Gj,Qi.ConcurrencyTaskQueue=Ij,Qi.FootprintCompilerInstance=xN,Qi.FootprintCompilerHandlerProxy=II,Qi.FootprintCompilerAttr=Aj,Qi.createCSVString=Lj,Qi.svg2png=Oj,Qi.imageData2NewImage=Rj,Qi.htmlEncode=EN,Qi.htmlDecode=_j,Qi.strEncode=Pj,Qi.isEmptyObj=jj,Qi.isPlainObject=wN,Qi.isFn=zj,Qi.isAsyncFunction=vN,Qi.isNormalFunction=TN,Qi.formatDate=ld,Qi.formatDate2=pj,Qi.deepClone=JT,Qi.deepCloneWithHtmlEncode=KT,Qi.naturalSortComparator=ZL,Qi.naturalSortSplitor=AT,Qi.naturalSort=D9,Qi.naturalStrSort=_9,Qi.naturalSort1=P9,Qi.naturalCompare=L9,Qi.isObjKeyInStr=Zx,Qi.throttle=Cj,Qi.debounce=Dj,Qi.findList=Ga,Qi.findListAll=mj,Qi.randomString=N9,Qi.parseJSON=M9,Qi.splitComponentId2FolderAndFilenameMixin=x0,Qi.getFootprintPadInfo=Bj,Qi.getFootprint3DInfo=Mj;var yp=class{};yp.toFixed=kj,yp.toFixed1=Fj,yp.floatEqual=Uj,yp.fixAngle=Yj,yp.getDistance=Vj,yp.getDistance2=SN,yp.getAngleByDot=Hj;var IN=class $T{constructor(){this._changeCbs=new Set,this._map=new Map,this._debounceNotify=Qi.debounce(()=>{this._notify()},50)}static get context(){return ut()}static getInstance(){var t;return(t=this.context.extendLibManager)!=null?t:this.context.extendLibManager=new $T}_notify(){for(let t of this._changeCbs)t()}onChange(t){this._changeCbs.add(t)}offChange(t){this._changeCbs.delete(t)}_getLibId(t){return`${$T.LIB_ID_PREFFIX}${t}`}async addLibWithId(t){this._map.set(t.id,await Tj.set(t)),this._debounceNotify()}async addLib(t){let i=this._getLibId(t.title);return await this.addLibWithId({...t,id:i}),i}deleteLib(t){return this._debounceNotify(),this._map.delete(t)}hasLib(t){return this._map.has(t)}getLib(t){return this._map.get(t)}getLibs(){return Array.from(this._map.values())}updateLibTitle(t,i){let r=this._map.get(t);r&&(r.title=i,this._debounceNotify())}updateLibPosition(t,i){let r=this._map.get(t);r&&(r.position=i,this._debounceNotify())}};IN.LIB_ID_PREFFIX="extend_lib_";var hs=IN,Xj=0;async function T0(e,t,i,r,n=!0,s,a){let o=null,l="requestid"+ ++Xj;s&&s(l);let c={user_uuid:e,path:t,type:i};r!==void 0&&(c.bindTypes=r),a&&a(c);try{if(hs.getInstance().hasLib(e))return await Wj(e,i,n);let h=await Rt("GET",Lt.TAG.LIST,c,{headers:{path:t},searchParams:!0});if(h.success)return{...h,result:await AI(h.result,n)}}catch(h){o=h,console.error("Fetch Category List Error",h)}let u=o?o.msg||o.message:void 0;return{code:o?o.code:it.ERR_CODE.NORMAL,success:!1,result:null,msg:u||"Fetch Category List Error"}}async function Wj(e,t,i){var r;let n=[];for(let s of t){let a=await((r=hs.getInstance().getLib(e))==null?void 0:r.getCategoryTreeDataItemsByCategoryType(s));a&&n.push(a)}return{code:0,success:!0,result:await AI(n.flat().map(s=>({uuid:s.id,parent_uuid:s.parentId,user_uuid:e,type:void 0,order_no:void 0,name_cn:void 0,name:s.title,created_at:s.created_at,updated_at:s.updated_at,title:s.title})),i)}}async function qj(e=!0){let t=null;try{let r=await Rt("POST",Lt.TAG.DEVICE_CATE);if(r.success)return{...r,result:await AI(r.result,e)}}catch(r){t=r,console.error("Fetch Category List Error",r)}let i=t?t.msg||t.message:void 0;return{code:t?t.code:it.ERR_CODE.NORMAL,success:!1,result:null,msg:i||"Fetch Category List Error"}}async function AI(e,t=!0){let i=[],r=[],n=[],s={},a={};e.forEach(h=>{h.name&&(a[h.name]=h.name_cn||h.name)});let o=e.filter(h=>!h.parent_uuid),l=e.filter(h=>!!h.parent_uuid),c=[],u={};if(o.forEach((h,d)=>{c.push(h.uuid),n.push({name:h.name,name_cn:h.name_cn,title:h.name,titleAdditional:h.name_cn||h.name,disableTranslate:h.name_cn===""?!0:h.name_cn===h.name,id:h.uuid,children:[],order_no:+h.order_no||0,parentId:void 0,created_at:h.created_at,updated_at:h.updated_at}),s[h.uuid]=d}),l.forEach(h=>{c.push(h.uuid);let d=s[h.parent_uuid];if(typeof d<"u"&&n[d]){let p=n[d];p.children.push({name:h.name,name_cn:h.name_cn,title:h.name,titleAdditional:h.name_cn||h.name,disableTranslate:h.name_cn===""?!0:h.name_cn===h.name,id:h.uuid,order_no:+h.order_no||0,children:[],parentId:p.id,created_at:h.created_at,updated_at:h.updated_at})}u[h.uuid]=h.parent_uuid}),n.sort(zL("order_no")),n.forEach(h=>{h.children.length>1&&h.children.sort(zL("order_no"))}),n.forEach(h=>{i.push({...h})}),t){let h=(await xt.messageBus.rpcCall("I18nTranslateService",{str:it.CATEGORY_ITEM_ALL_TITLE})).message;i.unshift({title:it.CATEGORY_ITEM_ALL_TITLE,titleAdditional:h||it.CATEGORY_ITEM_ALL_TITLE,id:it.CATEGORY_ITEM_ALL_VALUE,order_no:Number.MAX_SAFE_INTEGER,disableTranslate:!1,children:[],parentId:void 0}),r.push(it.CATEGORY_ITEM_ALL_VALUE)}return{languageHashtable:a,treeData:i,selectedIds:r,categoryIds:c,childCategory2ParentCategoryMap:u,sourceCategoryList:e}}async function Ip(e){let{categories:t,type:i,uuid:r}=e,n=await T0(r,r,i),s=n.result?n.result.treeData:[],a=[],o=[],l=[],c=[];for(let f=0;f<t.length;f++){let{parentName:m,childName:g,parent_order_no:b,child_order_no:y}=t[f];if(m){let E=Ga(s,"title",m);if(E.index>=0){if(a.push({name:E.data.title,type:i,user_uuid:r,order_no:E.data.order_no,parent_uuid:void 0,uuid:E.data.id}),g){let x=Ga(E.data.children,"title",g);if(x.index>=0){o.push({name:x.data.title,type:i,user_uuid:r,order_no:x.data.order_no,parent_uuid:E.data.id,uuid:x.data.id});continue}c.push({name:g,type:i,user_uuid:r,order_no:f+1,parent_uuid:E.data.id,uuid:void 0});continue}continue}let S=a0(),w=a0();l.push({name:m,type:i,user_uuid:r,order_no:typeof b<"u"?b:f+1,parent_uuid:void 0,uuid:S}),g&&c.push({name:g,type:i,user_uuid:r,order_no:typeof y<"u"?y:f+1,parent_uuid:S,uuid:w})}}let u=[];if(l.length){let f=await ym(l,(m,g)=>{l[g].__remoteId=m.result.uuid});u=f.result?f.result.successList.map(m=>m.result):[]}let h=[];if(c.length){for(let m=0;m<c.length;m++){let g=Ga(l,"uuid",c[m].parent_uuid);g.index>=0&&g.data.__remoteId&&(c[m].parent_uuid=g.data.__remoteId)}let f=await ym(c);h=f.result?f.result.successList.map(m=>m.result):[]}let d=u.concat(a),p=h.concat(o);return{allParentCreated:d,allChildCreated:p}}async function CI(e){let{uuid:t,path:i,types:r,names:n}=e;return new Promise(async(s,a)=>{let o=await T0(t,i,r,void 0,!1);if(o.code!==0){s({...o,code:it.ERR_CODE.NORMAL,success:!1,result:null});return}let l={detail:[],arguments:e},{treeData:c}=o.result;for(let u=0;u<n.length;u++){let h=n[u].primary,d=n[u].secondary,p={primary:{name:h,name_cn:"",uuid:"",exist:!1,undefine:!1},secondary:{name:d,name_cn:"",uuid:"",exist:!1,undefine:!1}};if(typeof h>"u"){p.primary.exist=!1,p.primary.undefine=!0;continue}let f=Ga(c,"title",h);if(f.index<=-1){p.primary.exist=!1,p.secondary.exist=!1,l.detail.push(p);continue}if(p.primary.exist=!0,p.primary.uuid=f.data.id,p.primary.name_cn=f.data.titleAdditional||h,typeof d>"u"){p.secondary.exist=!1,p.secondary.undefine=!0,l.detail.push(p);continue}let m=Ga(f.data.children,"title",d);if(m.index<=-1){p.secondary.exist=!1,l.detail.push(p);continue}p.secondary.exist=!0,p.secondary.uuid=m.data.id,p.secondary.name_cn=m.data.titleAdditional||d,l.detail.push(p)}s({code:0,success:!0,result:l})})}function Jj(e){let t=new Map,i=[];for(let r of e)(!t.has(r.primary)||t.get(r.primary)!==r.secondary)&&(t.set(r.primary,r.secondary),i.push(r));return i}async function AN(e){try{let{uuid:t,path:i,types:r,names:n}=e,s={primary:n[0],secondary:n[1]},a=await CI({uuid:t,path:i,types:r,names:[s]});if(!a.success)return{success:!1,code:a.code,message:a.message,result:null};let o=[],{detail:l}=a.result;if(l[0]){let{primary:c,secondary:u}=l[0];c!=null&&c.uuid&&o.push(c==null?void 0:c.uuid),u!=null&&u.uuid&&o.push(u==null?void 0:u.uuid)}return{success:!0,code:0,result:o}}catch(t){return{success:!1,code:it.ERR_CODE.NORMAL,message:t.message,result:null}}}async function Kj(e,t,i,r=!1){let n=await CI(e),s=[],a=[],o=[],l=[],c=[];if(!r&&n.success&&n.result.detail.length){let h=new Map,d=new Map,p=new Map;n.result.detail.forEach((f,m)=>{(f.primary.name||f.primary.name_cn)&&!f.primary.exist&&!h.has(f.primary.name||f.primary.name_cn)&&(h.set(f.primary.name||f.primary.name_cn,!0),s.push({name:f.primary.name||f.primary.name_cn,type:t,user_uuid:i,order_no:0})),(f.primary.name||f.primary.name_cn)&&!f.primary.exist&&(f.secondary.name||f.secondary.name_cn)&&!f.secondary.exist&&d.get(f.secondary.name||f.secondary.name_cn)!==(f.primary.name||f.primary.name_cn)?(d.set(f.secondary.name||f.secondary.name_cn,f.primary.name||f.primary.name_cn),a.push({name:f.secondary.name||f.secondary.name_cn,type:t,user_uuid:i,uuid:f.secondary.uuid,order_no:0,parent_uuid:f.primary.uuid,parent_title:f.primary.name||f.primary.name_cn})):f.primary.exist&&(f.secondary.name||f.secondary.name_cn)&&!f.secondary.exist&&d.get(f.secondary.name||f.secondary.name_cn)!==(f.primary.name||f.primary.name_cn)&&(d.set(f.secondary.name||f.secondary.name_cn,f.primary.name||f.primary.name_cn),a.push({name:f.secondary.name||f.secondary.name_cn,type:t,user_uuid:i,uuid:f.secondary.uuid,order_no:0,parent_uuid:f.primary.uuid,parent_title:f.primary.name||f.primary.name_cn})),f.primary.exist&&!p.has(f.primary.uuid)&&(p.set(f.primary.uuid,f.primary.name||f.primary.name_cn),c.push({title:f.primary.name||f.primary.name_cn,uuid:f.primary.uuid,parent_uuid:""})),f.secondary.exist&&!p.has(f.secondary.uuid)&&(p.set(f.secondary.uuid,f.secondary.name||f.secondary.name_cn),c.push({title:f.secondary.name||f.secondary.name_cn,uuid:f.secondary.uuid,parent_uuid:f.primary.uuid}))})}if(!r&&s.length){let h=await ym(s);if(h.success&&h.result.successList.length&&(o=h.result.successList.map(d=>d.result),a.forEach(d=>{o.forEach(p=>{!d.parent_uuid&&d.parent_title===p.name&&(d.parent_uuid=p.uuid)})})),a.length){let d=await ym(a);d.success&&d.result.successList.length&&(l=d.result.successList.map(p=>p.result))}}else if(!r&&a.length){let h=await ym(a);h.success&&h.result.successList.length&&(l=h.result.successList.map(d=>d.result))}let u=[];return u=o.map(h=>({uuid:h.uuid,title:h.name,name:h.name,parent_uuid:h.parent_uuid})),u=u.concat(l.map(h=>({uuid:h.uuid,parent_uuid:h.parent_uuid,title:h.name,name:h.name}))),u=u.concat(c),u}async function $j(e,t){let i=[],r=[],n=async o=>{let{message:l}=await xt.messageBus.rpcCall(lh.TAG.DELETE,o);return l},s=null;try{for(let o=0;o<e.length;o++){let l=await n({...e[o],path:e[o].user_uuid});if(l.code===0&&l.success){let u={...l,message:"",result:{...e[o],path:e[o].user_uuid,...l.result[0]}};i.push(u),t&&t(u,o);continue}let c={...l,result:{...e[o]}};r.push(c)}return{code:0,success:!0,result:{successList:i,failList:r},message:""}}catch(o){s=o}let a=s?s.msg||s.message:"Del Categories Batch Error";return{code:s?s.code:it.ERR_CODE.NORMAL,success:!1,result:null,message:a}}async function Zj(e){let{uuid:t,path:i,types:r,ids:n}=e;return new Promise(async(s,a)=>{let o=await T0(t,i,r,void 0,!1);if(o.code!==0){s({...o,code:it.ERR_CODE.NORMAL,success:!1,result:null});return}let l={detail:[],arguments:e},{treeData:c}=o.result;for(let u=0;u<n.length;u++){let h=n[u].primary,d=n[u].secondary,p={primary:{name:"",name_cn:"string",uuid:h,exist:!1,undefine:!1},secondary:{name:"",name_cn:"string",uuid:d,exist:!1,undefine:!1}};if(typeof h>"u"){p.primary.exist=!1,p.primary.undefine=!0;continue}let f=Ga(c,"id",h);if(f.index<=-1){p.primary.exist=!1,p.secondary.exist=!1,l.detail.push(p);continue}if(p.primary.exist=!0,p.primary.name=f.data.title,p.primary.name_cn=f.data.titleAdditional||p.primary.name,typeof d>"u"){p.secondary.exist=!1,p.secondary.undefine=!0;continue}let m=Ga(f.data.children,"id",d);if(m.index<=-1){p.secondary.exist=!1,l.detail.push(p);continue}p.secondary.exist=!0,p.secondary.name=m.data.title,p.secondary.name_cn=m.data.titleAdditional||p.secondary.name,l.detail.push(p)}s({code:0,success:!0,result:l})})}var Qj=class{constructor(){this._actuatorMap=new Map}clearAll(){this._actuatorMap.clear()}async addActuator(e,t,i,r){let n=e.filter(h=>!!h),s=`${n[0]}_${t[0]||0}_${i}_${r}`,a=`${n[0]}_${n[1]}_${t[1]||t[0]||0}_${i}_${r}`;if(!n[1]){if(this._actuatorMap.has(s))return this._actuatorMap.get(s);let h=new Promise(async(d,p)=>{let f=await Ip({categories:[{parentName:n[0],parent_order_no:t[0]||0}],type:[r],uuid:i});d({uuids:f.allParentCreated.map(m=>m.uuid),titles:f.allParentCreated.map(m=>m.name)}),this._actuatorMap.delete(s)});return this._actuatorMap.set(s,h),h}let o=this._actuatorMap.get(s);o||(o=new Promise(async(h,d)=>{let p=await Ip({categories:[{parentName:n[0],parent_order_no:t[0]||0}],type:[r],uuid:i});h({uuids:p.allParentCreated.map(f=>f.uuid),titles:p.allParentCreated.map(f=>f.name)}),this._actuatorMap.delete(s)}),this._actuatorMap.set(s,o));let l=await o,c=this._actuatorMap.get(a);c||(c=new Promise(async(h,d)=>{let p=await Ip({categories:[{parentName:n[0],childName:n[1],parent_order_no:t[0]||0,child_order_no:t[1]||t[0]||0}],type:[r],uuid:i});h({uuids:p.allChildCreated.map(f=>f.uuid),titles:p.allChildCreated.map(f=>f.name)}),this._actuatorMap.delete(a)}),this._actuatorMap.set(a,c));let u=await c;return{uuids:[l.uuids[0],u.uuids[0]],titles:[l.titles[0],u.titles[0]]}}};async function ez(e,t){let i=[],r=[],n=async o=>{let{message:l}=await xt.messageBus.rpcCall(lh.TAG.UPDATE,o);return l},s=null;try{for(let o=0;o<e.length;o++){let l=await n({...e[o],path:e[o].user_uuid});if(l.code===0&&l.success){let u={...l,message:"",result:{...e[o],path:e[o].user_uuid,...l.result[0]}};i.push(u),t&&t(u,o);continue}let c={...l,result:{...e[o]}};r.push(c)}return{code:0,success:!0,result:{successList:i,failList:r},message:""}}catch(o){s=o}let a=s?s.msg||s.message:"Update Categories Batch Error";return{code:s?s.code:it.ERR_CODE.NORMAL,success:!1,result:null,message:a}}var As=class{};As.categoryAddtition=new Qj,As.fetchCategoryList=T0,As.fetchInternalCategoryList=qj,As.addCategoriesBatch=ym,As.deleteCategoriesBatch=$j,As.updateCategoriesBatch=ez,As.addCategoriesBatchByNameArray=Ip,As.queryCategoryBatchByNames=CI,As.queryCategoryBatchByIds=Zj,As.formatRepeatCategoryArr=Jj,As.bindAndCreateCategory=Kj,As.getCategoryNamesByTags=hh;async function hh(e,t,i){if(!e)return[];if(e instanceof Array)return e;let r=hd(e);if(r=r.filter(c=>!!c),!r.length)return[];let n=(await xt.messageBus.rpcCall("LocaleCurrFetch",{})).message||"en",s=await T0(t,t,i),a=s.result?s.result.sourceCategoryList:[],o=typeof r[1]<"u",l=[];for(let c=0;c<a.length;c++)if(a[c].name===r[0]||a[c].name_cn===r[0]){l.push(n=="en"?a[c].name:a[c].name_cn||a[c].name);break}if(o){for(let c=0;c<a.length;c++)if(a[c].name===r[1]||a[c].name_cn===r[1]){l.push(n=="en"?a[c].name:a[c].name_cn||a[c].name);break}}return l}async function CN(e,t,i){let r=null,n=null,s=[],a=[],o=!1,l,c;if(e)if("data"in e)r=e.data,r.tags&&(r.tags instanceof Array?a=r.tags:a=hd(r.tags));else{if(!e.uuid||!e.path)throw new he("PARAMETER_VERIFICATION","missing 3d-model uuid or path data.");l=e.uuid,c=e.path,n=await sn.getD3Model({isProject:e.isProject,uuid:e.uuid,path:e.path}),n&&(n.title=n.display_title,a=await hh(n.tags,e.path,[5]))}if(!i){let u=await As.categoryAddtition.addActuator(a,[0],t,5);s=u.uuids,a=u.titles}return{d3modelItemOriginUuid:l,d3modelItemOriginPath:c,d3modelItemIn:r,d3modelItemOut:n,d3modelTagIds:s,d3modelTagTitles:a}}function Am(e){return e?{uuid:e.uuid,nickname:e.nickname,username:e.username}:{}}function tz(e){return Array.isArray(e)?e:e?[e]:[]}function Cm(e){return e?{uuid:e.uuid,nickname:e.nickname,username:e.username}:{}}function Dm(e){return e?{uuid:e.uuid,nickname:e.nickname,username:e.username}:{}}function DN(e,t){return{title:t.title,description:t.description,images:tz(t.images),attributes:t.attributes,uuid:t.uuid,path:Sm(t)||e,ticket:t.ticket,updateTime:wa(t.updateTime),createTime:wa(t.createTime),display_title:t.display_title,creator:Am(t.creator),modifier:Cm(t.modifier),owner:Dm(t.owner),symbol_type:t.symbol_type}}function dd(e,t){return{...DN(e,t),isFavorite:t.isFavorite,tags:t.tags,produce_code:t.produce_code}}function Ex(e,t){return{...DN(e,t),custom_tags:t.custom_tags,source:t.source,version:t.version}}function _N(e,t){return{title:t.title,description:t.description,docType:t.docType,path:Sm(t)||e,uuid:t.uuid,ticket:t.ticket,updateTime:wa(t.updateTime),createTime:wa(t.createTime),display_title:t.display_title,creator:Am(t.creator),modifier:Cm(t.modifier),owner:Dm(t.owner)}}function pu(e,t){return{..._N(e,t),tags:t.tags,has_device:t.has_device,history_uuid:t.history_uuid,key:t.key,iv:t.iv,dataStrId:t.dataStrId,dataStr:t.dataStr,isFavorite:t.isFavorite}}function vT(e,t){return{..._N(e,t),custom_tags:t.custom_tags,source:t.source,version:t.version}}function PN(e,t){return{title:t.title,description:t.description,docType:t.docType,uuid:t.uuid,path:Sm(t)||e,ticket:t.ticket,updateTime:wa(t.updateTime),createTime:wa(t.createTime),display_title:t.display_title,creator:Am(t.creator),modifier:Cm(t.modifier),owner:Dm(t.owner)}}function fu(e,t){return{...PN(e,t),tags:t.tags,has_device:t.has_device,history_uuid:t.history_uuid,key:t.key,iv:t.iv,dataStrId:t.dataStrId,dataStr:t.dataStr,isFavorite:t.isFavorite}}function TT(e,t){return{...PN(e,t),custom_tags:t.custom_tags,source:t.source,version:t.version}}async function _m(e,t){return{title:t.title,description:t.description,path:Sm(t)||e,docType:t.docType,uuid:t.uuid,ticket:t.ticket,updateTime:wa(t.updateTime),createTime:wa(t.createTime),display_title:t.display_title,creator:Am(t.creator),modifier:Cm(t.modifier),owner:Dm(t.owner),tags:t.tags,dataStrId:t.dataStrId,dataStr:await E0(t)}}function Rp(e,t){return{title:t.title,description:t.description,path:Sm(t)||e,docType:t.docType,uuid:t.uuid,ticket:t.ticket,updateTime:wa(t.updateTime),createTime:wa(t.createTime),display_title:t.display_title,creator:Am(t.creator),modifier:Cm(t.modifier),owner:Dm(t.owner),tags:t.tags,history_uuid:t.history_uuid,key:t.key,iv:t.iv,dataStr:t.dataStr,dataStrId:t.dataStrId,isFavorite:t.isFavorite}}async function Np(e,t){return{title:t.title,path:Sm(t)||e,docType:t.docType,uuid:t.uuid,ticket:t.ticket,updateTime:wa(t.updateTime),createTime:wa(t.createTime),display_title:t.display_title,creator:Am(t.creator),modifier:Cm(t.modifier),owner:Dm(t.owner),tags:t.tags,history_uuid:t.history_uuid,key:t.key,iv:t.iv,dataStrId:t.dataStrId,dataStr:await E0(t)}}async function iz(e){let{d3modelItemIn:t,d3modelItemOut:i,d3modelTagIds:r,d3modelTagTitles:n}=await CN(e.d3model,e.path,e.isProject),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing 3d-model data.");gN(s.title),"path"in e.d3model&&e.d3model.override&&$s(s,e.d3model.override);let a=await Rt("POST",Lt.COMPONENT.CREATE,{...s,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;return await _m(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("D3MODEL_SAME_NAMA_EXISTS",o):rl(a.code)?new he("CREATE_D3MODEL_PERMISSIONS",o):new he("CREATE_D3MODEL",o)}async function Kx(e=!1,t,i,r,n,s){let a=t.toLocaleLowerCase(),o=s?!!s.forceAsSymbol:!1,l=[];try{if(o||r&&[2,18,19,20,21,22,25,31,7,32,6].indexOf(r)>=0){let c={isProject:e,path:i,titles:[a],docType:r};l=(await sn.getSymbolSearchList(c))[a]||[]}if(r===28){let c={isProject:e,path:i,titles:[a]};l=(await sn.getDeviceSearchList(c))[a]||[]}if(r===4){let c={isProject:e,path:i,titles:[a]};l=(await sn.getFootprintSearchList(c))[a]||[]}return r===16&&(l=(await sn.getD3ModelSearchList({isProject:e,uid:i,path:i,page:1,pageSize:void 0,wd:a})).lists),{code:0,success:!0,result:l,message:""}}catch(c){return console.error(c),{code:-1,success:!1,result:[],message:c instanceof he?`${String(c.action)}|${String(c.message)}`:c.message||"QueryComponentsByTitle call error."}}}function XL(e,t){return e.path==t}function WL(e){try{let t=JSON.parse(e);return{parentName:t[0],childName:t[1]}}catch{return{parentName:"",childName:""}}}function rz(e){let t={};return t["device-owner"]=e.userIdSelected,t["device-lib"]=e.userIdSelected,t["footprint-name"]=e.footprintItem?e.footprintItem.display_title:"",t["symbol-name"]=e.symbolItem?e.symbolItem.display_title:"",t["new-symbol"]=e.isNeedCreateSymbolAndAssocia,t}function LN(e,t){typeof e.footprintItemId<"u"&&(t.Footprint=e.footprintItemId),typeof e.symbolItemId<"u"&&(t.Symbol=e.symbolItemId)}async function ON(e,t){let i=rz(e),r=e.footprintItem,n=e.symbolItem,s={},a=async(E,S)=>{let w="",x="",I=!1,A=t==="zh-hans",O=E.parent_tag,R=E.child_tag;if(O&&O.uuid&&(I=!0,w=A&&O.name_cn||O.name),I&&R&&R.uuid){let M=A&&R.name_cn||R.name;w+=`:${M}`}if(w){let M=w.split(":")[0],F=w.split(":")[1],G=await Ip({categories:F?[{parentName:M,childName:F}]:[{parentName:M}],type:[+S],uuid:i["device-owner"]}),V=G.allParentCreated[0]?G.allParentCreated[0].uuid:void 0,q=G.allChildCreated[0]?G.allChildCreated[0].uuid:void 0;V&&(x=q?[V,q]:[V])}return x},o={"file-owner":i["device-owner"],"file-name":i["footprint-name"],"file-describe":"","file-category":await a((r==null?void 0:r.tags)||{},4),"file-lib":i["device-lib"],"file-customTags":[]};if(r&&r!=null&&r.custom_tags&&!(o!=null&&o["file-category"])){let{parentName:E,childName:S}=WL(r.custom_tags);if(E){let w=await Ip({categories:S?[{parentName:E,childName:S}]:[{parentName:E}],type:[4],uuid:i["device-owner"]}),x=w.allParentCreated[0]?w.allParentCreated[0].uuid:void 0,I=w.allChildCreated[0]?w.allChildCreated[0].uuid:void 0;x&&(o["file-customTags"]=I?[x,I]:[x])}}let l={"file-owner":i["device-owner"],"file-name":i["symbol-name"],"file-describe":"","file-category":await a((n==null?void 0:n.tags)||{},2),"file-lib":i["device-lib"],"file-customTags":[]};if(n&&n!=null&&n.custom_tags&&!l["file-category"]){let{parentName:E,childName:S}=WL(n.custom_tags);if(E){let w=await Ip({categories:S?[{parentName:E,childName:S}]:[{parentName:E}],type:[4],uuid:i["device-owner"]}),x=w.allParentCreated[0]?w.allParentCreated[0].uuid:void 0,I=w.allChildCreated[0]?w.allChildCreated[0].uuid:void 0;x&&(l["file-customTags"]=I?[x,I]:[x])}}let c,u,h,d,p=!1,f=!1,m=!1;async function g(){if(i["footprint-name"])if(XL(r,i["device-owner"]||i["device-lib"]))h=r,c=null;else{let E=await Kx(!1,o["file-name"],i["device-lib"],4);E.result.length<=0||(f=!0,h=r,c=E.result)}else h=null,c=null}async function b(){if(!i["new-symbol"]&&i["symbol-name"]&&n)if(XL(n,i["device-owner"]||i["device-lib"]))d=n,u=null;else{let E=await Kx(!1,l["file-name"],i["device-lib"],n.docType);E.result.length<=0||(p=!0,u=E.result,d=n)}else d=null,u=null}await g(),await b();let y={isNeedConfirm:!1,updateCache:s,formData:i,newFootPrint:c,oldFootPrint:h,newSymbol:u,oldSymbol:d,confirmRes:e};return!p&&!f&&!m?(y.isNeedConfirm=!1,y):(y.isNeedConfirm=!0,y)}async function DI(e,t,i,r){let n=null,s=null,a=[],o=[],l=!1,c,u;if(e)if("data"in e)e.data&&(n=e.data,n.tags&&(n.tags instanceof Array?o=n.tags:o=hd(n.tags)));else{if(!e.uuid||!e.path)throw new he("PARAMETER_VERIFICATION","missing footprint uuid or path data.");c=e.uuid,u=e.path,s=await sn.getFootprint({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await hh(s.tags,e.path,[4]))}if(!i){let h=await As.categoryAddtition.addActuator(o,[0],t,4);a=h.uuids,o=h.titles}return{footprintItemOriginUuid:c,footprintItemOriginPath:u,footprintItemIn:n,footprintItemOut:s,footprintTagIds:a,footprintTagTitles:o}}async function _I(e,t,i,r){let n=null,s=null,a=[],o=[],l=!1,c,u;if(e)if("data"in e)e.data&&(n=e.data,n.tags&&(n.tags instanceof Array?o=n.tags:o=hd(n.tags)));else{if(!e.uuid||!e.path)throw new he("PARAMETER_VERIFICATION","missing symbol uuid or path data.");c=e.uuid,u=e.path,s=await sn.getSymbol({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await hh(s.tags,e.path,[2])),l=e.isProject}if(!i){let h=await As.categoryAddtition.addActuator(o,[0],t,2);a=h.uuids,o=h.titles}return{symbolItemOriginUuid:c,symbolItemOriginPath:u,symbolItemIn:n,symbolItemOut:s,symbolTagIds:a,symbolTagTitles:o}}async function RN(e,t,i,r){let n=null,s=null,a=[],o=[],l=!1;if(e)if("data"in e)e.data&&(n=e.data,n.tags&&(n.tags instanceof Array?o=n.tags:o=hd(n.tags)));else{if(!e.uuid||!e.path)throw new he("PARAMETER_VERIFICATION","missing device uuid or path data.");s=await sn.getDevice({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await hh(s.tags,e.path,[3])),l=e.isProject}if(!i){let c=await As.categoryAddtition.addActuator(o,[0],t,3);a=c.uuids,o=c.titles}return{deviceItemIn:n,deviceItemOut:s,deviceTagIds:a,deviceTagTitles:o,isDeviceFromProject:l}}async function NN(e,t,i,r,n,s){let a=null,o=null,l=[],c=[],u,h;if(e){let{symbolItemIn:d,symbolItemOut:p,symbolTagIds:f,symbolTagTitles:m,symbolItemOriginUuid:g,symbolItemOriginPath:b}=await _I(e,i,r,"path"in e&&e.override&&Array.isArray(e.override.tags)?e.override.tags:void 0);a=d,o=p,l=f,c=m,u=g,h=b}else if(n)if(s){let d=await sn.getSymbol({isProject:t,uuid:n,path:s});if(u=n,h=s,d){d.title=d.display_title,o=d,c=await hh(d.tags,s,[2]);let p=await As.categoryAddtition.addActuator(c,[0],i,2);l=p.uuids,c=p.titles}}else{let d=null;try{d=await sn.getSymbol({isProject:t,uuid:n,path:i}),u=n,h=i}catch(p){d=null,u=n,h=i,console.warn(p)}d||console.warn("[NOSYMBOL_ON_TARGETPATH_BY_DEVICE_BOUND]: the symbol bound to this device does not exist in the target library.")}return{symbolItemOriginUuid:u,symbolItemOriginPath:h,symbolItemIn:a,symbolItemOut:o,symbolTagIds:l,symbolTagTitles:c}}async function MN(e,t,i,r,n,s){let a=null,o=null,l=[],c=[],u,h;if(e){let{footprintItemIn:d,footprintItemOut:p,footprintTagIds:f,footprintTagTitles:m,footprintItemOriginUuid:g,footprintItemOriginPath:b}=await DI(e,i,r,"path"in e&&e.override&&Array.isArray(e.override.tags)?e.override.tags:void 0);a=d,o=p,l=f,c=m,u=g,h=b}else if(n)if(s){let d=await sn.getFootprint({isProject:t,uuid:n,path:s});if(u=n,h=s,d){d.title=d.display_title,o=d,c=await hh(d.tags,s,[4]);let p=await As.categoryAddtition.addActuator(c,[0],i,4);l=p.uuids,c=p.titles}}else{let d=null;try{d=await sn.getFootprint({isProject:t,uuid:n,path:i}),u=n,h=i}catch(p){d=null,u=n,h=i,console.warn(p)}d||console.warn("[NOFOOTPRINT_ON_TARGETPATH_BY_DEVICE_BOUND]: the footprint bound to this device does not exist in the target library.")}return{footprintItemOriginUuid:u,footprintItemOriginPath:h,footprintItemIn:a,footprintItemOut:o,footprintTagIds:l,footprintTagTitles:c}}async function BN(e,t,i,r,n,s){if(!r)return;let a=null;if("data"in r)n.title&&(a=await sn.createSymbol({isProject:e,path:t,symbol:{data:{...n,tags:s},ignoreDuplicateNameCheck:r.ignoreDuplicateNameCheck}})),i.attributes&&a&&typeof a=="object"&&(i.attributes.Symbol=a.uuid);else{r.override&&$s(n,r.override);try{a=await sn.getSymbol({isProject:e,path:t,uuid:r.uuid})}catch{a=null}if(a&&typeof a=="object")i.attributes&&(i.attributes.Symbol=a.uuid);else if(n.title&&(a=await sn.createSymbol({isProject:e,path:t,symbol:{data:{...n,tags:s},ignoreDuplicateNameCheck:r.ignoreDuplicateNameCheck}})),i.attributes&&a&&typeof a=="object"){i.attributes.Symbol=a.uuid;let o=await ud({origin:{docType:n.docType,isProject:r.isProject,uuid:r.uuid,path:r.path},target:{docType:a.docType,isProject:e,uuid:a.uuid,path:a.path}});if(!o.success)throw new he("CREATE_SYMBOL_MIGRATE_CANVAS_ERROR",o.message||"migrate canvas error.")}}}async function kN(e,t,i,r,n,s){if(!r)return;let a=null;if("data"in r)n.title&&(a=await sn.createFootprint({isProject:e,path:t,footprint:{data:{...n,tags:s}}})),i.attributes&&a&&typeof a=="object"&&(i.attributes.Footprint=a.uuid);else{r.override&&$s(n,r.override);try{a=await sn.getFootprint({isProject:e,path:t,uuid:r.uuid})}catch{a=null}if(a&&typeof a=="object")i.attributes&&(i.attributes.Footprint=a.uuid);else if(n.title&&(a=await sn.createFootprint({isProject:e,path:t,footprint:{data:{...n,tags:s}}})),i.attributes&&a&&typeof a=="object"){i.attributes.Footprint=a.uuid;let o=await ud({origin:{docType:n.docType,isProject:r.isProject,uuid:r.uuid,path:r.path},target:{docType:a.docType,isProject:e,uuid:a.uuid,path:a.path}});if(!o.success)throw new he("CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",o.message||"migrate canvas error.")}}}async function nz(e){let{deviceItemIn:t,deviceItemOut:i,deviceTagIds:r,deviceTagTitles:n,isDeviceFromProject:s}=await RN(e.device,e.path,e.isProject,"path"in e.device&&e.device.override&&Array.isArray(e.device.override.tags)?e.device.override.tags:void 0),a=t||i;if(!a)throw new he("PARAMETER_VERIFICATION","missing device data.");a.title=e.device&&"path"in e.device&&e.device.override&&w0(e.device.override,"title")||a.title,dN(a.title);let{symbolItemIn:o,symbolItemOut:l,symbolTagIds:c,symbolTagTitles:u,symbolItemOriginUuid:h,symbolItemOriginPath:d}=await NN(e.symbol,s,e.path,e.isProject,a.attributes?a.attributes.Symbol:void 0,"data"in e.device?void 0:e.device.path),p=o||l,f=!!(e.symbol&&"data"in e.symbol);a.attributes&&l&&typeof l=="object"&&(a.attributes.Symbol=l.uuid),e.symbol&&"path"in e.symbol&&e.symbol.override&&$s(p,e.symbol.override);let{footprintItemIn:m,footprintItemOut:g,footprintTagIds:b,footprintTagTitles:y,footprintItemOriginUuid:E,footprintItemOriginPath:S}=await MN(e.footprint,s,e.path,e.isProject,a.attributes?a.attributes.Footprint:void 0,"data"in e.device?void 0:e.device.path),w=m||g;e.footprint&&"path"in e.footprint&&e.footprint.override&&$s(w,e.footprint.override),a.attributes&&g&&typeof g=="object"&&(a.attributes.Footprint=g.uuid);let x=!1,I=!1,A=await ON({symbolItem:p,footprintItem:w,userIdSelected:e.path,isNeedCreateSymbolAndAssocia:f},void 0);if(A.isNeedConfirm){let M=(await xt.messageBus.rpcCall("OpenSameNameSaveAsDlgService",{...A},31536e8)).message;if(!M){let F="an exception occurred while executing the cross-bind program.";throw new he("CROSS_BIND",F)}if(M.action==="cancel"||M.action==="close"){let F="quit operate while executing the cross-bind program.";throw new he("CROSS_BIND_EXIT",F)}A.updateCache=M.data,a.attributes&&Object.keys(A.updateCache).length&&(A.updateCache.symbolItemId&&(x=!0),A.updateCache.footprintItemId&&(I=!0),LN(A.updateCache,a.attributes))}!x&&p&&await BN(e.isProject,e.path,a,e.symbol,p,u),!I&&w&&await kN(e.isProject,e.path,a,e.footprint,w,y),"path"in e.device&&e.device.override&&(delete e.device.override.tags,$s(a,e.device.override));let O=await Rt("POST",Lt.DEVICE.CREATE,{...a,tags:r,owner:e.path,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(O.code===0&&O.success){let M=O.result;return dd(e.path,M)}let R=O.message||O.msg||"Request Error.";throw Ol(O.code)?new he("DEVICE_SAME_NAMA_EXISTS",R):rl(O.code)?new he("CREATE_DEVICE_PERMISSIONS",R):new he("CREATE_DEVICE",R)}async function sz(e){let{footprintItemIn:t,footprintItemOut:i,footprintTagIds:r,footprintTagTitles:n}=await DI(e.footprint,e.path,e.isProject,"path"in e.footprint&&e.footprint.override&&Array.isArray(e.footprint.override.tags)?e.footprint.override.tags:void 0),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing footprint data.");s.title="path"in e.footprint&&e.footprint.override&&w0(e.footprint.override,"title")||s.title,fN(s.title),"path"in e.footprint&&e.footprint.override&&(delete e.footprint.override.tags,$s(s,e.footprint.override));let a=await Rt("POST",Lt.COMPONENT.CREATE,{title:s.title,tags:r,docType:s.docType||4,description:s.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;if(!("data"in e.footprint)&&e.footprint.uuid&&e.footprint.path){let c=await ud({origin:{docType:s.docType,isProject:!!e.footprint.isProject,uuid:e.footprint.uuid,path:e.footprint.path},target:{docType:l.docType,isProject:!1,uuid:l.uuid,path:l.path}});if(!c.success)throw new he("CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return fu(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("FOOTPRINT_SAME_NAMA_EXISTS",o):rl(a.code)?new he("CREATE_FOOTPRINT_PERMISSIONS",o):new he("CREATE_FOOTPRINT",o)}async function FN(e,t,i,r){let n=null,s=null,a=[],o=[],l=!1,c,u;if(e)if("data"in e)n=e.data,n.tags&&(n.tags instanceof Array?o=n.tags:o=hd(n.tags));else{if(!e.uuid||!e.path)throw new he("PARAMETER_VERIFICATION","missing simModel uuid or path data.");c=e.uuid,u=e.path,s=await sn.getSimModel({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await hh(s.tags,e.path,[6]))}if(!i){let h=await As.categoryAddtition.addActuator(o,[0],t,6);a=h.uuids,o=h.titles}return{simModelItemOriginUuid:c,simModelItemOriginPath:u,simModelItemIn:n,simModelItemOut:s,simModelTagIds:a,simModelTagTitles:o}}async function az(e){let{simModelItemIn:t,simModelItemOut:i,simModelTagIds:r,simModelTagTitles:n}=await FN(e.simModel,e.path,e.isProject,"path"in e.simModel&&e.simModel.override&&Array.isArray(e.simModel.override.tags)?e.simModel.override.tags:void 0),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing sim-model data.");s.title="path"in e.simModel&&e.simModel.override&&w0(e.simModel.override,"title")||s.title,yN(s.title),"path"in e.simModel&&e.simModel.override&&(delete e.simModel.override.tags,$s(s,e.simModel.override));let a=await Rt("POST",Lt.COMPONENT.CREATE,{...s,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;return await Np(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("SIM_MODEL_SAME_NAMA_EXISTS",o):rl(a.code)?new he("CREATE_SIM_MODEL_PERMISSIONS",o):new he("CREATE_SIM_MODEL",o)}async function oz(e){let{symbolItemIn:t,symbolItemOut:i,symbolTagIds:r,symbolTagTitles:n}=await _I(e.symbol,e.path,e.isProject,"path"in e.symbol&&e.symbol.override&&Array.isArray(e.symbol.override.tags)?e.symbol.override.tags:void 0),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing symbol data.");s.title="path"in e.symbol&&e.symbol.override&&w0(e.symbol.override,"title")||s.title,pN(s.title),"path"in e.symbol&&e.symbol.override&&(delete e.symbol.override.tags,$s(s,e.symbol.override));let a=await Rt("POST",Lt.COMPONENT.CREATE,{title:s.title,tags:r,docType:s.docType,description:s.description,owner:e.path,ignoreDuplicateNameCheck:e.symbol.ignoreDuplicateNameCheck},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;if(!("data"in e.symbol)&&e.symbol.uuid&&e.symbol.path){let c=await ud({origin:{docType:s.docType,isProject:!!e.symbol.isProject,uuid:e.symbol.uuid,path:e.symbol.path},target:{docType:l.docType,isProject:!1,uuid:l.uuid,path:l.path}});if(!c.success)throw new he("CREATE_SYMBOL_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return pu(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("SYMBOL_SAME_NAMA_EXISTS",o):rl(a.code)?new he("CREATE_SYMBOL_PERMISSIONS",o):new he("CREATE_SYMBOL",o)}async function lz(e){let t=await Rt("GET",vr(Lt.DEVICE.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;if(typeof r.path<"u"&&r.path!==e.path)throw new he("GET_DEVICE_NOT_FOUND","data not found");return dd(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new he("GET_DEVICE",i)}async function cz(e){let t=await Rt("GET",vr(Lt.COMPONENT.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;if(typeof r.path<"u"&&r.path!==e.path)throw new he("GET_FOOTPRINT_NOT_FOUND","data not found");return fu(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new he("GET_FOOTPRINT",i)}async function uz(e){let t=await Rt("GET",vr(Lt.COMPONENT.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;return await Np(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new he("GET_SIM_MODEL",i)}function Tc(e={}){let t={},i=Object.keys(e);for(let r=0;r<i.length;r++)i[r]===""||String(i[r])==="undefined"||typeof e[i[r]]>"u"||e[i[r]]==null||(t[i[r]]=e[i[r]]);return t}async function hz(e){let t=await Rt("GET",Lt.COMPONENT.LIST,{...Tc(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:e.docType,tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,n=[];for(let s of r.lists)n.push(await Np(e.path,s));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:n}}let i=t.message||t.msg||"Request Error.";throw new he("GET_SIM_MODEL_LIST",i)}async function dz(e){let t=await Rt("GET",vr(Lt.COMPONENT.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;if(typeof r.path<"u"&&r.path!==e.path)throw new he("GET_SYMBOL_NOT_FOUND","data not found");return pu(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new he("GET_SYMBOL",i)}async function pz(e){let{deviceItemIn:t,deviceItemOut:i,deviceTagIds:r,deviceTagTitles:n,isDeviceFromProject:s}=await RN(e.device,e.path,e.isProject,"path"in e.device&&e.device.override&&Array.isArray(e.device.override.tags)?e.device.override.tags:void 0),a=t||i;if(!a)throw new he("PARAMETER_VERIFICATION","missing device data.");a.title!==void 0&&dN(a.title);let{symbolItemIn:o,symbolItemOut:l,symbolTagIds:c,symbolTagTitles:u,symbolItemOriginUuid:h,symbolItemOriginPath:d}=await NN(e.symbol,s,e.path,e.isProject,a.attributes?a.attributes.Symbol:void 0,"data"in e.device?void 0:e.device.path),p=o||l,f=!!(e.symbol&&"data"in e.symbol);e.symbol&&"path"in e.symbol&&e.symbol.override&&$s(p,e.symbol.override),a.attributes&&l&&typeof l=="object"&&(a.attributes.Symbol=l.uuid);let{footprintItemIn:m,footprintItemOut:g,footprintTagIds:b,footprintTagTitles:y,footprintItemOriginUuid:E,footprintItemOriginPath:S}=await MN(e.footprint,s,e.path,e.isProject,a.attributes?a.attributes.Footprint:void 0,"data"in e.device?void 0:e.device.path),w=m||g;e.footprint&&"path"in e.footprint&&e.footprint.override&&$s(w,e.footprint.override),a.attributes&&g&&typeof g=="object"&&(a.attributes.Footprint=g.uuid);let x=!1,I=!1,A=await ON({symbolItem:p,footprintItem:w,userIdSelected:e.path,isNeedCreateSymbolAndAssocia:f},void 0);if(A.isNeedConfirm){let M=(await xt.messageBus.rpcCall("OpenSameNameSaveAsDlgService",{...A},31536e8)).message;if(!M){let F="an exception occurred while executing the cross-bind program.";throw new he("CROSS_BIND",F)}if(M.action==="cancel"||M.action==="close"){let F="quit operate while executing the cross-bind program.";throw new he("CROSS_BIND_EXIT",F)}A.updateCache=M.data,a.attributes&&Object.keys(A.updateCache).length&&(A.updateCache.symbolItemId&&(x=!0),A.updateCache.footprintItemId&&(I=!0),LN(A.updateCache,a.attributes))}!x&&p&&await BN(e.isProject,e.path,a,e.symbol,p,u),!I&&w&&await kN(e.isProject,e.path,a,e.footprint,w,y),"path"in e.device&&e.device.override&&(delete e.device.override.tags,$s(a,e.device.override));let O=await Rt("POST",vr(Lt.DEVICE.UPDATE,{uuid:e.uuid}),{...a,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(O.code===0&&O.success&&O.result){let M=O.result;return dd(e.path,M)}let R=O.message||O.msg||"Request Error.";throw Ol(O.code)?new he("DEVICE_SAME_NAMA_EXISTS",R):rl(O.code)?new he("CREATE_DEVICE_PERMISSIONS",R):new he("UPDATE_DEVICE",R)}async function fz(e){let{footprintItemIn:t,footprintItemOut:i,footprintTagIds:r,footprintTagTitles:n}=await DI(e.footprint,e.path,e.isProject,"path"in e.footprint&&e.footprint.override&&Array.isArray(e.footprint.override.tags)?e.footprint.override.tags:void 0),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing footprint data.");s.title!==void 0&&fN(s.title),"path"in e.footprint&&e.footprint.override&&(delete e.footprint.override.tags,$s(s,e.footprint.override));let a=await Rt("POST",vr(Lt.COMPONENT.UPDATE,{uuid:e.uuid}),{title:s.title,tags:r,docType:s.docType||4,description:s.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;if(!("data"in e.footprint)&&e.footprint.uuid&&e.footprint.path){let c=await ud({origin:{docType:s.docType,isProject:e.footprint.isProject,uuid:e.footprint.uuid,path:e.footprint.path},target:{docType:l.docType,isProject:e.isProject,uuid:e.uuid,path:e.path}});if(!c.success)throw new he("UPDATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return fu(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("FOOTPRINT_SAME_NAMA_EXISTS",o):rl(a.code)?new he("UPDATE_FOOTPRINT_PERMISSIONS",o):new he("UPDATE_FOOTPRINT",o)}async function mz(e){let{simModelItemIn:t,simModelItemOut:i,simModelTagIds:r,simModelTagTitles:n}=await FN(e.simModel,e.path,e.isProject,"path"in e.simModel&&e.simModel.override&&Array.isArray(e.simModel.override.tags)?e.simModel.override.tags:void 0),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing simModel data.");s.title!==void 0&&yN(s.title),"path"in e.simModel&&e.simModel.override&&(delete e.simModel.override.tags,$s(s,e.simModel.override));let a=await Rt("POST",vr(Lt.COMPONENT.UPDATE,{uuid:e.uuid}),{...s,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!a.success){let l=a.message||a.msg||"Request Error.";throw new he("UPDATE_SIM_MODEL",l)}if(s.dataStr){let l=await Rt("POST",vr(Lt.COMPONENT.UPDATE_CANVAS,{uuid:e.uuid}),{...s,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!l.success){let c=l.message||l.msg||"Request Error.";throw new he("UPDATE_SIM_MODEL",c)}}if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;return await Np(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("SIM_MODEL_SAME_NAMA_EXISTS",o):rl(a.code)?new he("UPDATE_SIM_MODEL_PERMISSIONS",o):new he("UPDATE_SYMBOL",o)}async function gz(e){let{symbolItemIn:t,symbolItemOut:i,symbolTagIds:r,symbolTagTitles:n}=await _I(e.symbol,e.path,e.isProject,"path"in e.symbol&&e.symbol.override&&Array.isArray(e.symbol.override.tags)?e.symbol.override.tags:void 0),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing symbol data.");s.title!==void 0&&pN(s.title),"path"in e.symbol&&e.symbol.override&&(delete e.symbol.override.tags,$s(s,e.symbol.override));let a=await Rt("POST",vr(Lt.COMPONENT.UPDATE,{uuid:e.uuid}),{title:s.title,tags:r,docType:s.docType,description:s.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;if(!("data"in e.symbol)&&e.symbol.uuid&&e.symbol.path){let c=await ud({origin:{docType:s.docType,isProject:e.symbol.isProject,uuid:e.symbol.uuid,path:e.symbol.path},target:{docType:l.docType,isProject:e.isProject,uuid:e.uuid,path:e.path}});if(!c.success)throw new he("UPDATE_SYMBOL_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return pu(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("SYMBOL_SAME_NAMA_EXISTS",o):rl(a.code)?new he("UPDATE_SYMBOL_PERMISSIONS",o):new he("UPDATE_SYMBOL",o)}async function yz(e){let t=await Rt("GET",Lt.COMPONENT.LIST,{...e.query||{},path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:[16],tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,n=[];for(let s of r.lists)n.push(await _m(e.path,s));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:n}}let i=t.message||t.msg||"Request Error.";throw new he("GET_D3MODEL_LIST",i)}async function bz(e){let t=await Rt("GET",Lt.COMPONENT.LIST,{...Tc(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:[4],tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,n=[];for(let s of r.lists)n.push(fu(e.path,s));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:n}}let i=t.message||t.msg||"Request Error.";throw new he("GET_FOOTPRINT_LIST",i)}async function xz(e){let t=await Rt("GET",Lt.COMPONENT.LIST,{...Tc(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:e.docType,tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,n=[];for(let s of r.lists)n.push(pu(e.path,s));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:n}}let i=t.message||t.msg||"Request Error.";throw new he("GET_SYMBOL_LIST",i)}async function Ez(e){var t,i;let r=await Rt("GET",Lt.DEVICE.LIST,{...Tc(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(r.code===0&&r.success&&typeof r.result=="object"){let s=r.result,a=[];for(let o of s.lists){let l=dd(e.path,o);e.withPackage&&(t=o.symbol_info)!=null&&t.uuid&&(l.symbol=pu(e.path,o.symbol_info)),e.withPackage&&(i=o.footprint_info)!=null&&i.uuid&&(l.footprint=fu(e.path,o.footprint_info)),a.push(l)}return{count:s.count,page:s.page,pageSize:s.pageSize,totalPage:s.totalPage,lists:a}}let n=r.message||r.msg||"Request Error.";throw new he("GET_DEVICE_LIST",n)}async function Sz(e){return e.titles?await wz(e):e.uuids?await vz(e):await Tz(e)}async function wz(e){var t,i;let{path:r,titles:n,user_uuids:s}=e,a=await Rt("POST",Lt.DEVICE.GET_BY_USER_AND_TITLE,{type:"device",titles:n,user_uuids:s||[r],path:r},{headers:{"Content-Type":"application/json",path:r}});if(a.code===0&&a.success&&a.result){let l={};for(let c in a.result){l[c]=[];let u=a.result[c];for(let h of u){let d=dd(r,h);e.withPackage&&(t=h.symbol_info)!=null&&t.uuid&&(d.symbol=pu(r,h.symbol_info)),e.withPackage&&(i=h.footprint_info)!=null&&i.uuid&&(d.footprint=fu(r,h.footprint_info)),l[c].push(d)}}return l}let o=a.message||a.msg||"Request Error.";throw new he("GET_DEVICE_SEARCH_LIST",o)}async function vz(e){let{path:t,uuids:i}=e,r=await Rt("POST",Lt.DEVICE.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let s=[];for(let a of r.result){let o=dd(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new he("GET_DEVICE_SEARCH_UUIDS",n)}async function Tz(e){var t,i;let{path:r,query:n={},uid:s,page:a,pageSize:o,tags:l=[],wd:c}=e,u=await Rt("POST",Lt.DEVICE.SEARCH_LIST,{...Tc(n),path:r,uid:s,page:a,pageSize:o,tag:l,wd:c},{headers:{path:r},searchParams:!0});if(u.code===0&&u.success&&typeof u.result=="object"){let d=u.result,p=[],f=Object.keys(d.lists);for(let m=0;m<f.length;m++){let g=d.lists[f[m]];if(Array.isArray(g)&&g.length)for(let b=0;b<g.length;b++){let y=g[b],E=dd(r,y);e.withPackage&&(t=y.symbol_info)!=null&&t.uuid&&(E.symbol=pu(r,y.symbol_info)),e.withPackage&&(i=y.footprint_info)!=null&&i.uuid&&(E.footprint=fu(r,y.footprint_info)),p.push(E)}}return{count:d.count,page:d.page,pageSize:d.pageSize,totalPage:d.totalPage,lists:p,facets:d.facets}}let h=u.message||u.msg||"Request Error.";throw new he("GET_DEVICE_SEARCH_LIST",h)}async function Iz(e){return e.titles?await Az(e):e.uuids?await Cz(e):await Dz(e)}async function Az(e){let{path:t,titles:i,docType:r,user_uuids:n}=e,s=await Rt("POST",Lt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:r,titles:i,user_uuids:n||[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(s.code===0&&s.success&&s.result){let o={};for(let l in s.result){o[l]=[];let c=s.result[l];for(let u of c){let h=pu(t,u);o[l].push(h)}}return o}let a=s.message||s.msg||"Request Error.";throw new he("GET_SYMBOL_SEARCH_LIST",a)}async function Cz(e){let{path:t,uuids:i}=e,r=await Rt("POST",Lt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let s=[];for(let a of r.result){let o=pu(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new he("GET_SYMBOL_SEARCH_UUIDS",n)}async function Dz(e){let{path:t,query:i,uid:r,page:n,pageSize:s,tags:a=[],wd:o,docType:l}=e,c=await Rt("POST",Lt.COMPONENT.SEARCH_LIST,{...Tc(i||{}),path:t,uid:r,page:n,pageSize:s,docType:l,tag:a,wd:o},{headers:{path:t},searchParams:!0});if(c.code===0&&c.success&&typeof c.result=="object"){let h=c.result,d=[],p=Object.keys(h.lists);for(let f=0;f<p.length;f++){let m=h.lists[p[f]];if(Array.isArray(m)&&m.length)for(let g=0;g<m.length;g++){let b=m[g],y=pu(t,b);d.push(y)}}return{count:h.count,page:h.page,pageSize:h.pageSize,totalPage:h.totalPage,lists:d,facets:h.facets}}let u=c.message||c.msg||"Request Error.";throw new he("GET_SYMBOL_SEARCH_LIST",u)}async function _z(e){return e.titles?await Pz(e):e.uuids?await Lz(e):await Oz(e)}async function Pz(e){let{path:t,titles:i,user_uuids:r}=e,n=await Rt("POST",Lt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:4,titles:i,user_uuids:r||[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(n.code===0&&n.success&&n.result){let a={};for(let o in n.result){a[o]=[];let l=n.result[o];for(let c of l){let u=fu(t,c);a[o].push(u)}}return a}let s=n.message||n.msg||"Request Error.";throw new he("GET_FOOTPRINT_SEARCH_LIST",s)}async function Lz(e){let{path:t,uuids:i}=e,r=await Rt("POST",Lt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let s=[];for(let a of r.result){let o=fu(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new he("GET_FOOTPRINT_SEARCH_UUIDS",n)}async function Oz(e){let{path:t,query:i={},uid:r,page:n,pageSize:s,tags:a=[],wd:o}=e,l=await Rt("POST",Lt.COMPONENT.SEARCH_LIST,{...Tc(i),path:t,uid:r,page:n,pageSize:s,docType:[4],tag:a,wd:o},{headers:{path:t},searchParams:!0});if(l.code===0&&l.success&&typeof l.result=="object"){let u=l.result,h=[],d=Object.keys(u.lists);for(let p=0;p<d.length;p++){let f=u.lists[d[p]];if(Array.isArray(f)&&f.length)for(let m=0;m<f.length;m++){let g=f[m],b=fu(t,g);h.push(b)}}return{count:u.count,page:u.page,pageSize:u.pageSize,totalPage:u.totalPage,lists:h,facets:u.facets}}let c=l.message||l.msg||"Request Error.";throw new he("GET_FOOTPRINT_SEARCH_LIST",c)}async function Rz(e){return e.titles?await Nz(e):e.uuids?await Mz(e):await Bz(e)}async function Nz(e){let{path:t,docType:i,titles:r}=e,n=await Rt("POST",Lt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:i,titles:r,user_uuids:[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(n.code===0&&n.success&&n.result){let a={};for(let o in n.result){a[o]=[];let l=n.result[o];for(let c of l){let u=await Np(e.path,c);a[o].push(u)}}return a}let s=n.message||n.msg||"Request Error.";throw new he("GET_SIM_MODEL_SEARCH_LIST",s)}async function Mz(e){let{path:t,uuids:i}=e,r=await Rt("POST",Lt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let s=[];for(let a of r.result){let o=await Np(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new he("GET_SIM_MODEL_SEARCH_UUIDS",n)}async function Bz(e){let{path:t,query:i={},uid:r,page:n,pageSize:s,docType:a,tags:o=[],wd:l}=e,c=await Rt("POST",Lt.COMPONENT.SEARCH_LIST,{...Tc(i),path:t,uid:r,page:n,pageSize:s,docType:a,tag:o,wd:l},{headers:{path:t},searchParams:!0});if(c.code===0&&c.success&&typeof c.result=="object"){let h=c.result,d=[],p=Object.keys(h.lists);for(let f=0;f<p.length;f++){let m=h.lists[p[f]];if(Array.isArray(m)&&m.length)for(let g=0;g<m.length;g++){let b=m[g];d.push(await Np(e.path,b))}}return{count:h.count,page:h.page,pageSize:h.pageSize,totalPage:h.totalPage,lists:d,facets:h.facets}}let u=c.message||c.msg||"Request Error.";throw new he("GET_SIM_MODEL_SEARCH_LIST",u)}async function kz(e){if(e.attributes.Symbol){let s=await sn.getSymbol({isProject:e.isProject,uuid:e.attributes.Symbol,path:e.path})}if(e.attributes.Footprint){let s=await sn.getFootprint({isProject:e.isProject,uuid:e.attributes.Footprint,path:e.path})}let t=await sn.getDevice({isProject:e.isProject,uuid:e.uuid,path:e.path}),i=Object.keys(e.attributes||{});for(let s=0;s<i.length;s++)t.attributes[i[s]]=e.attributes[i[s]];let r=await Rt("POST",vr(Lt.DEVICE.UPDATE,{uuid:e.uuid}),{...t,title:t.display_title||t.title,tags:t.tags?qR(t.tags):[],owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(r.code===0&&r.success&&r.result){let s=r.result;return dd(e.path,s)}let n=r.message||r.msg||"Request Error.";throw rl(r.code)?new he("CREATE_DEVICE_PERMISSIONS",n):new he("UPDATE_DEVICE_ATTRIBUTES",n)}async function Fz(e){return e.titles?await Gz(e):e.uuids?await Uz(e):await Yz(e)}async function Gz(e){let{path:t,titles:i,user_uuids:r}=e;if(iO||Zy&&t!==it.SYSTEMLIB_UUID){let n=await Rt("POST",Lt.CLIENT.FIND_3DMODEL,{titles:i},{headers:{"Content-Type":"application/json",path:t}});if(n.code===0&&n.success&&n.result){let a={};for(let o in n.result){a[o]=[];let l=n.result[o];for(let c of l){let u={fileName:c.fileName,path:c.path,lib:c.lib};a[o].push(u)}}return a}let s=n.message||n.msg||"Request Error.";throw new he("GET_D3MODEL_SEARCH_LIST",s)}else{let n=await Rt("POST",Lt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:16,titles:i,user_uuids:r||[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(n.code===0&&n.success&&n.result){let a={};for(let o in n.result){a[o]=[];let l=n.result[o];for(let c of l){let u=await _m(e.path,c);a[o].push(u)}}return a}let s=n.message||n.msg||"Request Error.";throw new he("GET_D3MODEL_SEARCH_LIST",s)}}async function Uz(e){let{path:t,uuids:i}=e,r=await Rt("POST",Lt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let s=[];for(let a of r.result){let o=await _m(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new he("GET_D3MODEL_SEARCH_UUIDS",n)}async function Yz(e){let{path:t,query:i={},uid:r,page:n,pageSize:s,tags:a=[],wd:o}=e,l=await Rt("POST",Lt.COMPONENT.SEARCH_LIST,{...Tc(i),path:t,uid:r,page:n,pageSize:s,docType:[16],tag:a,wd:o},{headers:{path:t},searchParams:!0});if(l.code===0&&l.success&&typeof l.result=="object"){let u=l.result,h=[],d=Object.keys(u.lists);for(let p=0;p<d.length;p++){let f=u.lists[d[p]];if(Array.isArray(f)&&f.length)for(let m=0;m<f.length;m++){let g=f[m];h.push(await _m(e.path,g))}}return{count:u.count,page:u.page,pageSize:u.pageSize,totalPage:u.totalPage,lists:h,facets:u.facets}}let c=l.message||l.msg||"Request Error.";throw new he("GET_D3MODEL_SEARCH_LIST",c)}async function Vz(e){return e.titles?await Hz(e):e.uuids?await jz(e):await zz(e)}async function Hz(e){let{path:t,titles:i}=e,r=await Rt("POST",Lt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:29,titles:i,user_uuids:[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let s={};for(let a in r.result){s[a]=[];let o=r.result[a];for(let l of o){let c=Rp(e.path,l);s[a].push(c)}}return s}let n=r.message||r.msg||"Request Error.";throw new he("GET_PANEL_LIB_SEARCH_LIST",n)}async function jz(e){let{path:t,uuids:i}=e,r=await Rt("POST",Lt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let s=[];for(let a of r.result){let o=Rp(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new he("GET_PANEL_LIB_SEARCH_UUIDS",n)}async function zz(e){let{path:t,query:i={},uid:r,page:n,pageSize:s,tags:a=[],wd:o}=e,l=await Rt("POST",Lt.COMPONENT.SEARCH_LIST,{...Tc(i),path:t,uid:r,page:n,pageSize:s,docType:[29],tag:a,wd:o},{headers:{path:t},searchParams:!0});if(l.code===0&&l.success&&typeof l.result=="object"){let u=l.result,h=[],d=Object.keys(u.lists);for(let p=0;p<d.length;p++){let f=u.lists[d[p]];if(Array.isArray(f)&&f.length)for(let m=0;m<f.length;m++){let g=f[m];h.push(Rp(e.path,g))}}return{count:u.count,page:u.page,pageSize:u.pageSize,totalPage:u.totalPage,lists:h,facets:u.facets}}let c=l.message||l.msg||"Request Error.";throw new he("GET_PANEL_LIB_SEARCH_LIST",c)}async function Xz(e){let t=await Rt("GET",vr(Lt.COMPONENT.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;if(typeof r.path<"u"&&r.path!==e.path)throw new he("GET_PANEL_LIB_NOT_FOUND","data not found");return Rp(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new he("GET_PANEL_LIB",i)}async function GN(e,t,i,r){let n=null,s=null,a=[],o=[],l=!1,c,u;if(e)if("data"in e)n=e.data,n.tags&&(n.tags instanceof Array?o=n.tags:o=hd(n.tags));else{if(!e.uuid||!e.path)throw new he("PARAMETER_VERIFICATION","missing panelLib uuid or path data.");c=e.uuid,u=e.path,s=await sn.getPanelLib({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await hh(s.tags,e.path,[29]))}if(!i){let h=await As.categoryAddtition.addActuator(o,[0],t,29);a=h.uuids,o=h.titles}return{panelLibItemOriginUuid:c,panelLibItemOriginPath:u,panelLibItemIn:n,panelLibItemOut:s,panelLibTagIds:a,panelLibTagTitles:o}}async function Wz(e){let{panelLibItemIn:t,panelLibItemOut:i,panelLibTagIds:r,panelLibTagTitles:n}=await GN(e.panelLib,e.path,e.isProject,"path"in e.panelLib&&e.panelLib.override&&Array.isArray(e.panelLib.override.tags)?e.panelLib.override.tags:void 0),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing panelLib data.");s.title="path"in e.panelLib&&e.panelLib.override&&w0(e.panelLib.override,"title")||s.title,mN(s.title),"path"in e.panelLib&&e.panelLib.override&&(delete e.panelLib.override.tags,$s(s,e.panelLib.override));let a=await Rt("POST",Lt.COMPONENT.CREATE,{title:s.title,tags:r,docType:s.docType||29,description:s.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;if(!("data"in e.panelLib)&&e.panelLib.uuid&&e.panelLib.path){let c=await ud({origin:{docType:s.docType,isProject:!!e.panelLib.isProject,uuid:e.panelLib.uuid,path:e.panelLib.path},target:{docType:l.docType,isProject:!1,uuid:l.uuid,path:l.path}});if(!c.success)throw new he("CREATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return Rp(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("PANELLIB_SAME_NAMA_EXISTS",o):rl(a.code)?new he("CREATE_PANEL_LIB_PERMISSIONS",o):new he("CREATE_PANEL_LIB",o)}async function qz(e){let{panelLibItemIn:t,panelLibItemOut:i,panelLibTagIds:r,panelLibTagTitles:n}=await GN(e.panelLib,e.path,e.isProject,"path"in e.panelLib&&e.panelLib.override&&Array.isArray(e.panelLib.override.tags)?e.panelLib.override.tags:void 0),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing panelLib data.");s.title!==void 0&&mN(s.title),"path"in e.panelLib&&e.panelLib.override&&(delete e.panelLib.override.tags,$s(s,e.panelLib.override));let a=await Rt("POST",vr(Lt.COMPONENT.UPDATE,{uuid:e.uuid}),{title:s.title,tags:r,docType:29,description:s.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;if(!("data"in e.panelLib)&&e.panelLib.uuid&&e.panelLib.path){let c=await ud({origin:{docType:s.docType,isProject:e.panelLib.isProject,uuid:e.panelLib.uuid,path:e.panelLib.path},target:{docType:l.docType,isProject:e.isProject,uuid:e.uuid,path:e.path}});if(!c.success)throw new he("UPDATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return Rp(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("PANELLIB_SAME_NAMA_EXISTS",o):rl(a.code)?new he("UPDATE_PANEL_LIB_PERMISSIONS",o):new he("UPDATE_PANEL_LIB",o)}async function Jz(e){let t=await Rt("GET",Lt.COMPONENT.LIST,{...Tc(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:[29],tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,n=[];for(let s of r.lists)n.push(Rp(e.path,s));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:n}}let i=t.message||t.msg||"Request Error.";throw new he("GET_PANEL_LIB_LIST",i)}async function Kz(e){let{d3modelItemIn:t,d3modelItemOut:i,d3modelTagIds:r,d3modelTagTitles:n}=await CN(e.d3model,e.path,e.isProject),s=t||i;if(!s)throw new he("PARAMETER_VERIFICATION","missing d3Model data.");s.title!==void 0&&gN(s.title),"path"in e.d3model&&e.d3model.override&&$s(s,e.d3model.override);let a=await Rt("POST",vr(Lt.COMPONENT.UPDATE,{uuid:e.uuid}),{...s,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!a.success){let l=a.message||a.msg||"Request Error.";throw new he("UPDATE_D3MODEL",l)}if(s.dataStr){let l=await Rt("POST",vr(Lt.COMPONENT.UPDATE_CANVAS,{uuid:e.uuid}),{...s,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!l.success){let c=l.message||l.msg||"Request Error.";throw new he("UPDATE_D3MODEL",c)}}if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;return await _m(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Ol(a.code)?new he("D3MODEL_SAME_NAMA_EXISTS",o):rl(a.code)?new he("UPDATE_D3MODEL_PERMISSIONS",o):new he("UPDATE_SYMBOL",o)}async function $z(e){let t={uid:e.uid,path:e.path};if(e.tags){let{result:n}=await AN({uuid:e.uid,path:e.path,types:[3],names:e.tags});t.tag=n}let i=await Rt("POST",Lt.DEVICE.GET_ATTR_KEYS,t,{headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",path:e.path}});if(i.code===0&&i.success&&typeof i.result=="object")return i.result;let r=i.message||i.msg||"Request Error.";throw new he("GET_DEVICE_ATTRIBUTES_KEYS",r)}async function Zz(e){let t={uid:e.uid,path:e.path,key:e.key};if(e.tags){let{result:n}=await AN({uuid:e.uid,path:e.path,types:[3],names:e.tags});t.tag=n}let i=await Rt("POST",Lt.DEVICE.GET_ATTR_VALUE,t,{headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",path:e.path}});if(i.code===0&&i.success&&typeof i.result=="object")return i.result;let r=i.message||i.msg||"Request Error.";throw new he("GET_DEVICE_ATTRIBUTES_VALUES",r)}var Qz=class extends TI{async getDevice(e){return await lz(e)}async getDeviceAttributesKeys(e){return await $z(e)}async getDeviceAttributesValues(e){return Zz(e)}async getSymbol(e){return await dz(e)}async getFootprint(e){return await cz(e)}async getPanelLib(e){return await Xz(e)}async getD3Model(e){return await S0(e.uuid,e.path)}async getSimModel(e){return await uz(e)}async getDeviceList(e){return await Ez(e)}async getSymbolList(e){return await xz(e)}async getFootprintList(e){return await bz(e)}async getPanelLibList(e){return await Jz(e)}async getD3ModelList(e){return await yz(e)}async getSimModelList(e){return hz(e)}async getDeviceSearchList(e){return await Sz(e)}async getSymbolSearchList(e){return await Iz(e)}async getFootprintSearchList(e){return await _z(e)}async getPanelLibSearchList(e){return await Vz(e)}async getD3ModelSearchList(e){return await Fz(e)}async getSimModelSearchList(e){return Rz(e)}async createDevice(e){return await nz(e)}async createSymbol(e){return await oz(e)}async createFootprint(e){return await sz(e)}async createD3Model(e){return await iz(e)}async createPanelLib(e){return await Wz(e)}async createSimModel(e){return await az(e)}async updateDevice(e){return await pz(e)}async updateDeviceAttributes(e){return await kz(e)}async updateSymbol(e){return await gz(e)}async updateFootprint(e){return await fz(e)}async updatePanelLib(e){return await qz(e)}async updateD3Model(e){return await Kz(e)}async updateSimModel(e){return await mz(e)}async deleteDevice(e){let t=await Rt("POST",vr(Lt.DEVICE.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("DELETE_DEVICE",i)}}async deleteSymbol(e){let t=await Rt("POST",vr(Lt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("DELETE_SYMBOL",i)}}async deleteFootprint(e){let t=await Rt("POST",vr(Lt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("DELETE_FOOTPRINT",i)}}async deletePanelLib(e){let t=await Rt("POST",vr(Lt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("DELETE_PANEL_LIB",i)}}async deleteSimModel(e){let t=await Rt("POST",vr(Lt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("DELETE_SIM_MODEL",i)}}async delete3DModel(e){let t=await Rt("POST",vr(Lt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("DELETE_3DMODEL",i)}}async starDevice(e){let t=await Rt("POST",vr(Lt.DEVICE.STAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("STAR_DEVICE",i)}}async starSymbol(e){let t=await Rt("POST",vr(Lt.COMPONENT.STAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("STAR_SYMBOL",i)}}async starFootprint(e){let t=await Rt("POST",vr(Lt.COMPONENT.STAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("STAR_FOOTPRINT",i)}}async starPanelLib(e){let t=await Rt("POST",vr(Lt.COMPONENT.STAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("STAR_PANEL_LIB",i)}}async unstarDevice(e){let t=await Rt("POST",vr(Lt.DEVICE.UNSTAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("UNSTAR_DEVICE",i)}}async unstarSymbol(e){let t=await Rt("POST",vr(Lt.COMPONENT.UNSTAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("UNSTAR_SYMBOL",i)}}async unstarFootprint(e){let t=await Rt("POST",vr(Lt.COMPONENT.UNSTAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("UNSTAR_FOOTPRINT",i)}}async unstarPanelLib(e){let t=await Rt("POST",vr(Lt.COMPONENT.UNSTAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new he("UNSTAR_PANEL_LIB",i)}}},uh=class{static diffVersionDevice(e){let t=Object.keys(e);if(!t||!t.length)return;let i=[];for(let r of t)i.push(...e[r].map(n=>({device:n})));xt.messageBus.publish("logI18nLogView1",{type:"warn",msg:["Devices have not been added to the project library, project library has devices with different versions from the same source,",{text:"It is recommended to update the project library:",call:{cmd:"updateComponent",args:{uuids:i,needTipModal:!1}}},t.join("\u3001")],onlyTranslateText:!0})}static diffVersionSymbol(e){let t=Object.keys(e);if(!t||!t.length)return;let i=[];for(let r of t)i.push(...e[r].map(n=>({symbol:n})));xt.messageBus.publish("logI18nLogView1",{type:"warn",msg:["Symbols have not been added to the project library, project library has symbols with different versions from the same source,",{text:"It is recommended to update the project library:",call:{cmd:"updateComponent",args:{uuids:i,needTipModal:!1}}},t.join("\u3001")],onlyTranslateText:!0})}static diffVersionFootprint(e){let t=Object.keys(e);if(!t||!t.length)return;let i=[];for(let r of t)i.push(...e[r].map(n=>({footprint:n})));xt.messageBus.publish("logI18nLogView1",{type:"warn",msg:["Footprints have not been added to the project library, project library has footprints with different versions from the same source,",{text:"It is recommended to update the project library:",call:{cmd:"updateComponent",args:{uuids:i,needTipModal:!1}}},t.join("\u3001")],onlyTranslateText:!0})}static sameVersionDevice(e){}static sameVersionSymbol(e){}static sameVersionFootprint(e){}static renamedDevice(e){xt.messageBus.publish("logI18nLogView",{type:"warn",msg:["Devices are automatically renamed when they are added to the project library :",e.join("\u3001")]})}static renamedSymbol(e){xt.messageBus.publish("logI18nLogView",{type:"warn",msg:["Symbols are automatically renamed when they are added to the project library :",e.join("\u3001")]})}static renamedFootprint(e){xt.messageBus.publish("logI18nLogView",{type:"warn",msg:["Footprints are automatically renamed when they are added to the project library :",e.join("\u3001")]})}},eX=class{constructor(e){let{renameKey:t=!0}=e;this.renameKey=t}async rename(e,...t){if(await this.hack(e,...t))return{success:!0};let i=(await xt.messageBus.rpcCall("allowDuplicateNames",...t)).message;return this.renameKey||!i?this.renaming(e,...t):i?{success:!0}:this.isRename(e,...t)}async hack(e,...t){return!1}},tX=class extends eX{constructor(e){let{matchKey:t=!0,byUUID:i=!1,byVersion:r=!1,bySource:n=!1}=e;super(e),this.matchKey=t,this.byUUID=i,this.byVersion=r,this.bySource=n}async match(e){if(this.matchKey)return this.matching(e)}},PI=class extends tX{constructor(e){let{path:t,data:i}=e;super(e),this.origin={},this.path=t,this.data=i}async onAdd(e){let t=JSON.parse(JSON.stringify(e));return t.path||(t.path=this.path),await EH({data:t}),xT(t),t.project_uuid=t.path=this.path,t}async onUpdate(e){let t=JSON.parse(JSON.stringify(e));return xT(t),t}async getTemplate(e,t={}){let{uuid:i,path:r,updateTime:n}=e,s=`${i}${sd}${r}`,a=n==null?void 0:n.toString(),o=Object.assign(e,{path:r,source:s,version:a},t);return xT(o),o}},UN=class extends PI{async getOrigin(){var e;let{path:t,uuid:i,isProject:r}=this.data;if(Lp(this.data)){let{override:n}=this.data;if(n&&n.attributes)throw new he("CREATE_DEVICE_GET_ORIGIN","Api call error!");if(r){let{message:s}=await xt.messageBus.rpcCall("/pro-mgr/hasProject",[t]);if(s){let a=[i,t],o=(await xt.messageBus.rpcCall(ci.DEVICE.GET,a)).message;if(o){let l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,n)}else throw new he("CREATE_DEVICE_GET_ORIGIN","Device details data does not exist")}else throw new he("CREATE_DEVICE_GET_ORIGIN","Get project library data source Project is not open!")}else if(hs.getInstance().hasLib(t)){let s=hs.getInstance().getLib(t),a=await((e=s==null?void 0:s.device)==null?void 0:e.getTransformedDetail(i));if(a){let o=Object.assign(a,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(o,n)}else throw new he("CREATE_DEVICE_GET_ORIGIN","Device details data does not exist")}else{let s={path:t,uuid:i},{message:a}=await xt.messageBus.rpcCall(lh.DEVICE.GET,s);if(a.success){let o=a.result,l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,n)}else throw new he("CREATE_DEVICE_GET_ORIGIN",a.message||"Device details data does not exist")}}else{let n=this.data.data,s=Object.assign(n,{isProject:r});this.origin=await this.onHandle(s)}return{success:!0,result:this.origin}}async renaming(e){let t=e.display_title||e.title,i=[t,this.path],r=(await xt.messageBus.rpcCall(ci.DEVICE.TRY_RENAME,i)).message;return r&&(e.display_title=e.title=r),t!==r&&uh.renamedDevice([t]),{success:!0}}},iX=class extends UN{onHandle(e){return this.onAdd(e)}async matching(e){if(this.byUUID){let t=[e.uuid,this.path],i=await(await xt.messageBus.rpcCall(ci.DEVICE.GET,t)).message;if(e.ticket&&i!=null&&i.ticket&&(i==null?void 0:i.ticket)===e.ticket)return i}if(e.source){if(this.byVersion){let t=[e.source,e.version,this.path],i=(await xt.messageBus.rpcCall(ci.DEVICE.GET_BY_SOURCE_VERSION,t)).message;if(i)return uh.sameVersionDevice([e.display_title||e.title]),i}if(this.bySource){let t=[e.source,this.path],i=(await xt.messageBus.rpcCall(ci.DEVICE.GET_LAST,t)).message;if(i)return uh.diffVersionDevice({[i.display_title||i.title]:[i.uuid]}),i}}}async isRename(e){let t=[e.display_title||e.title,this.path];if((await xt.messageBus.rpcCall(ci.DEVICE.IS_RENAME,t)).message)throw new he("DEVICE_SAME_NAMA_EXISTS","Device duplicate name");return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new he("CREATE_DEVICE",e.message||"Creation of the device failed!");let t,i;if(this.origin){let r=await this.match(this.origin);if(r)t={success:!0,result:r};else{let n=await this.rename(this.origin,{path:this.path});if(!n.success)throw new he("CREATE_DEVICE",n.message||"Creation of the device failed!");i=this.origin}}return{success:!0,result:{respond:t,addData:i}}}},YN=class extends PI{async getOrigin(){var e;let{path:t,uuid:i,isProject:r}=this.data;if(Lp(this.data)){let{override:n}=this.data;if(r){let{message:s}=await xt.messageBus.rpcCall("/pro-mgr/hasProject",[t]);if(s){let a=[i,t],o=(await xt.messageBus.rpcCall(ci.FOOTPRINT.GET,a)).message;if(o){let l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,n)}else throw new he("CREATE_FOOTPRINT_GET_ORIGIN","Footprint details data does not exist")}else throw new he("CREATE_FOOTPRINT_GET_ORIGIN","Get project library data source Project is not open!")}else if(hs.getInstance().hasLib(t)){let s=hs.getInstance().getLib(t),a=await((e=s==null?void 0:s.footprint)==null?void 0:e.getTransformedDetail(i));if(a){let o=Object.assign(a,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(o,n)}else throw new he("CREATE_FOOTPRINT_GET_ORIGIN","Footprint details data does not exist")}else{let s={path:t,uuid:i},{message:a}=await xt.messageBus.rpcCall(lh.COMPONENT.GET,s);if(a.success){let o=a.result,l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,n)}else throw new he("CREATE_FOOTPRINT_GET_ORIGIN",a.message||"Footprint details data does not exist")}}else{let n=this.data.data,s=Object.assign(n,{isProject:r});this.origin=await this.onHandle(s)}return{success:!0,result:this.origin}}async renaming(e){let t=e.display_title||e.title,i=[t,this.path],r=(await xt.messageBus.rpcCall(ci.FOOTPRINT.TRY_RENAME,i)).message;return r&&(e.display_title=e.title=r),t!==r&&uh.renamedFootprint([t]),{success:!0}}},LI=class extends YN{onHandle(e){return this.onAdd(e)}async matching(e){if(this.byUUID){let t=[e.uuid,this.path],i=(await xt.messageBus.rpcCall(ci.FOOTPRINT.GET,t)).message;if(e.ticket&&i!=null&&i.ticket&&(i==null?void 0:i.ticket)===e.ticket)return i}if(e.source){if(this.byVersion){let t=[e.source,e.version,this.path],i=(await xt.messageBus.rpcCall(ci.FOOTPRINT.GET_BY_SOURCE_VERSION,t)).message;if(i)return uh.sameVersionFootprint([e.display_title||e.title]),i}if(this.bySource){let t=[e.source,this.path],i=(await xt.messageBus.rpcCall(ci.FOOTPRINT.GET_LAST,t)).message;if(i)return uh.diffVersionFootprint({[i.display_title||i.title]:[i.uuid]}),i}}}async isRename(e){let t=[e.display_title||e.title,this.path];if((await xt.messageBus.rpcCall(ci.FOOTPRINT.IS_RENAME,t)).message)throw new he("CREATE_FOOTPRINT","Library duplicate name");return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new he("CREATE_FOOTPRINT",e.message||"Creation of the footprint failed!");let t,i;if(this.origin){let r=await this.match(this.origin);if(r)t={success:!0,result:r};else{let n=await this.rename(this.origin,{path:this.path});if(!n.success)throw new he("CREATE_FOOTPRINT",n.message||"Creation of the footprint failed!");i=this.origin}}return{success:!0,result:{respond:t,addData:i}}}},VN=class extends PI{async getOrigin(){var e;let{path:t,uuid:i,isProject:r}=this.data;if(Lp(this.data)){let{override:n}=this.data;if(r){let{message:s}=await xt.messageBus.rpcCall("/pro-mgr/hasProject",[t]);if(s){let a=[i,t],o=(await xt.messageBus.rpcCall(ci.SYMBOL.GET,a)).message;if(o){let l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,n)}else throw new he("CREATE_SYMBOL_GET_ORIGIN","Symbol details data does not exist")}else throw new he("CREATE_SYMBOL_GET_ORIGIN","Get project library data source Project is not open!")}else if(hs.getInstance().hasLib(t)){let s=hs.getInstance().getLib(t),a=await((e=s==null?void 0:s.symbol)==null?void 0:e.getTransformedDetail(i));if(a){let o=Object.assign(a,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(o,n)}else throw new he("CREATE_SYMBOL_GET_ORIGIN","Symbol details data does not exist")}else{let s={path:t,uuid:i},{message:a}=await xt.messageBus.rpcCall(lh.COMPONENT.GET,s);if(a.success){let o=a.result,l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,n)}else throw new he("CREATE_SYMBOL_GET_ORIGIN",a.message||"Symbol details data does not exist")}}else{let n=this.data.data,s=Object.assign(n,{isProject:r});this.origin=await this.onHandle(s)}return{success:!0,result:this.origin}}async renaming(e){let t=e.display_title||e.title,i=[t,this.path],r=(await xt.messageBus.rpcCall(ci.SYMBOL.TRY_RENAME,i)).message;return r&&(e.display_title=e.title=r),t!==r&&uh.renamedSymbol([t]),{success:!0}}},OI=class extends VN{onHandle(e){return this.onAdd(e)}async matching(e){if(this.byUUID){let t=[e.uuid,this.path],i=(await xt.messageBus.rpcCall(ci.SYMBOL.GET,t)).message;if(e.ticket&&i!=null&&i.ticket&&(i==null?void 0:i.ticket)===e.ticket)return i}if(e.source){if(this.byVersion){let t=[e.source,e.version,this.path],i=(await xt.messageBus.rpcCall(ci.SYMBOL.GET_BY_SOURCE_VERSION,t)).message;if(i)return uh.sameVersionSymbol([e.display_title||e.title]),i}if(this.bySource){let t=[e.source,this.path],i=(await xt.messageBus.rpcCall(ci.SYMBOL.GET_LAST,t)).message;if(i)return uh.diffVersionSymbol({[i.display_title||i.title]:[i.uuid]}),i}}}async hack(e){let{docType:t}=e;return t===17}async isRename(e){let t=[e.display_title||e.title,this.path];if((await xt.messageBus.rpcCall(ci.SYMBOL.IS_RENAME,t)).message)throw new he("CREATE_SYMBOL","Library duplicate name");return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new he("CREATE_SYMBOL",e.message||"Creation of the symbol failed!");let t,i;if(this.origin){let r=await this.match(this.origin);if(r)t={success:!0,result:r};else{let n=await this.rename(this.origin,{path:this.path});if(!n.success)throw new he("CREATE_SYMBOL",n.message||"Creation of the symbol failed!");i=this.origin}}return{success:!0,result:{respond:t,addData:i}}}},Pm=class{constructor(e){this.path=e}async check(){let{message:{hasPermission:e,errMsg:t}}=await xt.messageBus.rpcCall("canAddLib",[this.path]);if(!e)throw new he("CREATE_DEVICE_PERMISSIONS",t||"You don't have permission!");return{success:!0}}},rX=class extends Pm{constructor(e){let{path:t,data:i,options:r={}}=e,{matchKey:n=!0,byUUID:s=!0,byVersion:a=!0,bySource:o=!1,renameKey:l=!1}=r;super(t),this.addData={},this.result={device:null,symbol:null,footprint:null},this.data=i,this.matchKey=n,this.byUUID=s,this.byVersion=a,this.bySource=o,this.renameKey=l}async start(){var e,t,i,r,n,s,a,o,l,c,u,h;try{await this.check(),await this.onbefore();let d={path:this.path,matchKey:this.matchKey,byUUID:this.byUUID,byVersion:this.byVersion,bySource:this.bySource,renameKey:this.renameKey};if(this.data.device){let m={...d,data:this.data.device},g=await new iX(m).start();if(g.success===!1)throw new he("CREATE_DEVICE",g.message||"Creation of the device failed!");let{respond:b,addData:y}=g.result;if(this.result.device=b,y&&(this.addData.device=y),this.getBind(),!this.addData.device&&(e=this.result.device)!=null&&e.success&&(t=this.result.device)!=null&&t.result){let{attributes:E}=this.result.device.result,{Symbol:S,Footprint:w}=E,x=S&&(await xt.messageBus.rpcCall(ci.SYMBOL.GET,[S,this.path])).message,I=w&&(await xt.messageBus.rpcCall(ci.FOOTPRINT.GET,[w,this.path])).message;this.result.symbol={success:!0,result:x},this.result.footprint={success:!0,result:I}}}if(this.data.symbol){let m={...d,data:this.data.symbol},g=await new OI(m).start();if(g.success===!1&&g.code===404){if(this.addData.device){this.addData.device.attributes.Symbol="";let{display_title:b,title:y}=this.addData.device,E=b||y;xt.messageBus.publish("logI18nLogView",{type:"warn",msg:["The following devices lose bound symbol data!",E]})}}else{if(g.success===!1)throw new he("CREATE_DEVICE",g.message||"Creation of the device failed!");{let{respond:b,addData:y}=g.result;if(this.result.symbol=b,y&&(this.addData.symbol=y),this.addData.device&&(i=this.result.symbol)!=null&&i.success&&(r=this.result.symbol)!=null&&r.result)this.addData.device.attributes.Symbol=this.result.symbol.result.uuid;else if((n=this.addData.device)!=null&&n.attributes.Symbol&&(s=this.result.symbol)!=null&&s.success&&!((a=this.result.symbol)!=null&&a.result)&&!this.addData.symbol){let E="The symbol associated with the device does not exist!";throw new he("CREATE_DEVICE",E)}}}}if(this.data.footprint){let m={...d,data:this.data.footprint},g=await new LI(m).start();if(g.success===!1&&g.code===404){if(this.addData.device){this.addData.device.attributes.Footprint="";let{display_title:b,title:y}=this.addData.device,E=b||y;xt.messageBus.publish("logI18nLogView",{type:"warn",msg:["The following devices lose bound footprint data!",E]})}}else{if(g.success===!1)throw new he("CREATE_DEVICE",g.message||"Creation of the device failed!");{let{respond:b,addData:y}=g.result;if(this.result.footprint=b,y&&(this.addData.footprint=y),this.addData.device&&(o=this.result.footprint)!=null&&o.success&&(l=this.result.footprint)!=null&&l.result)this.addData.device.attributes.Footprint=this.result.footprint.result.uuid;else if((c=this.addData.device)!=null&&c.attributes.Footprint&&(u=this.result.footprint)!=null&&u.success&&!((h=this.result.footprint)!=null&&h.result)&&!this.addData.footprint){let E="The footprint associated with the device does not exist!";throw new he("CREATE_DEVICE",E)}}}}let p=await this.create();if(!p.success)throw new he("CREATE_DEVICE",p.message||"Creation of the device failed!");let f=await this.updateBind();if(!f.success)throw new he("CREATE_DEVICE",f.message||"Creation of the device failed!");if(!this.result)throw new he("CREATE_DEVICE","Project library device added failed!");return await this.onsuccess(this.result),{success:!0,result:this.result}}catch(d){throw new he("CREATE_DEVICE",d.message||"Creation of the device failed!")}}getBind(){if(this.addData.device){let{attributes:e}=this.addData.device,{Symbol:t,Footprint:i}=e,{isProject:r}=this.data.device;if(r===void 0)!this.data.symbol&&t&&(this.data.symbol={isProject:!0,path:this.path,uuid:t}),!this.data.footprint&&i&&(this.data.footprint={isProject:!0,path:this.path,uuid:i});else{let[n,s]=this.addData.device.source.split(sd);!this.data.symbol&&t&&(this.data.symbol={isProject:r,path:s,uuid:t}),!this.data.footprint&&i&&(this.data.footprint={isProject:r,path:s,uuid:i})}}}onbeforeCreate(){var e,t,i,r;if((e=this.addData.symbol)!=null&&e.docType&&!rR((t=this.addData.symbol)==null?void 0:t.docType))throw new he("CREATE_DEVICE","invalid symbol docType");if((i=this.addData.footprint)!=null&&i.docType&&((r=this.addData.footprint)==null?void 0:r.docType)!==4)throw new he("CREATE_DEVICE","invalid footprint docType");if(this.addData.footprint&&(this.addData.footprint.isConnectDevice=!0),this.addData.device&&this.addData.device.attributes["3D Model"]){let n=this.addData.device.attributes["3D Model"];n.includes(sd)||(this.addData.device.attributes["3D Model"]=`${n}${sd}${this.addData.device.path}`)}return{success:!0}}async create(){if(Object.keys(this.addData).length>0){this.onbeforeCreate();let e=[this.addData,this.path],{message:t}=await xt.messageBus.rpcCall(ci.DEVICE.CREATE,e);if(!t.success)throw new he("CREATE_DEVICE",t.message||"Creation of the device failed!");let{device:i,symbol:r,footprint:n}=t.result;i&&(this.result.device={success:!0,result:i}),r&&(this.result.symbol={success:!0,result:r}),n&&(this.result.footprint={success:!0,result:n})}return{success:!0}}async updateBind(){let{device:e,symbol:t,footprint:i}=this.result,r=e!=null&&e.success?e==null?void 0:e.result:null,n=t!=null&&t.success?t==null?void 0:t.result:null,s=i!=null&&i.success?i==null?void 0:i.result:null;if(r){let a=!1;if(n!=null&&n.uuid&&r.attributes.Symbol&&n.uuid!==r.attributes.Symbol&&(r.attributes.Symbol=n.uuid,a=!0),s!=null&&s.uuid&&r.attributes.Footprint&&s.uuid!==r.attributes.Footprint&&(r.attributes.Footprint=s.uuid,a=!0),a){let o=(await xt.messageBus.rpcCall(ci.DEVICE.UPDATE,[r,this.path])).message;this.result.device={success:!!o,result:o}}}return{success:!0}}async onbefore(){}async onsuccess(e){e.symbol&&!e.symbol.success&&(e.symbol.message=Tp(e.symbol)||e.symbol.message),e.footprint&&!e.footprint.success&&(e.footprint.message=Tp(e.footprint)||e.footprint.message),e.device&&!e.device.success&&(e.device.message=Tp(e.device)||e.device.message)}},nX=class extends UN{constructor(e,t){super(t),this.uuid=e}onHandle(e){return this.onUpdate(e)}matching(e){throw new Error("Method not implemented.")}async isRename(e){return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new he("UPDATE_DEVICE",e.message||"Update of the device failed!");if(!this.origin)throw new he("UPDATE_DEVICE","Device details data does not exist");let t=this.origin.display_title||this.origin.title,i=[{uuid:this.uuid,title:t},this.path];if((await xt.messageBus.rpcCall(ci.DEVICE.IS_CHANGE,i)).message){let r=await this.rename(this.origin,{path:this.path});if(!r.success)throw new he("UPDATE_DEVICE",r.message||"Update of the device failed!")}return{success:!0,result:this.origin}}},sX=class extends Pm{constructor(e){let{path:t,uuid:i,data:r,options:n={}}=e,{matchKey:s=!0,byUUID:a=!0,bySource:o=!0,byVersion:l=!1,renameKey:c=!1}=n;super(t),this.addData={},this.map={},this.result={device:null,symbol:null,footprint:null,map:{}},this.uuid=i,this.data=r,this.matchKey=s,this.byUUID=a,this.bySource=o,this.byVersion=l,this.renameKey=c}async start(){var e,t,i,r,n,s,a,o,l,c;try{await this.check(),await this.onbefore();let u={path:this.path,matchKey:this.matchKey,byUUID:this.byUUID,bySource:this.bySource,byVersion:this.byVersion,renameKey:this.renameKey};if(this.data.device){let p={...u,data:this.data.device},f=await new nX(this.uuid,p).start();if(f.success){let m=f.result;m&&(this.updateData=m),this.getBind()}else throw new he("UPDATE_DEVICE",f.message||"Update of the device failed!")}if(this.data.symbol){let p={...u,data:this.data.symbol,renameKey:this.renameKey},f=await new OI(p).start();if(!f.success)throw new he("UPDATE_DEVICE",f.message||"Update of the device failed!");let{respond:m,addData:g}=f.result;if(this.result.symbol=m,g&&(this.addData.symbol=g),this.updateData&&this.addData.symbol)this.updateData.attributes.Symbol=this.addData.symbol.uuid;else if(this.updateData&&(e=this.result.symbol)!=null&&e.success&&this.result.symbol.result)this.updateData.attributes.Symbol=this.result.symbol.result.uuid;else if((t=this.updateData)!=null&&t.attributes.Symbol&&(i=this.result.symbol)!=null&&i.success&&!((r=this.result.symbol)!=null&&r.result)&&!this.addData.symbol){let b="The symbol associated with the device does not exist!";throw new he("UPDATE_DEVICE",b)}}if(this.data.footprint){let p={...u,data:this.data.footprint,renameKey:this.renameKey},f=await new LI(p).start();if(!f.success)throw new he("UPDATE_DEVICE",f.message||"Update of the device failed!");let{respond:m,addData:g}=f.result;if(this.result.footprint=m,g&&(this.addData.footprint=g),this.updateData&&this.addData.footprint)this.updateData.attributes.Footprint=this.addData.footprint.uuid;else if(this.updateData&&(n=this.result.footprint)!=null&&n.success&&this.result.footprint.result)this.updateData.attributes.Footprint=this.result.footprint.result.uuid;else if((s=this.updateData)!=null&&s.attributes.Footprint&&(a=this.result.footprint)!=null&&a.success&&!((o=this.result.footprint)!=null&&o.result)&&!this.addData.footprint){let b="The footprint associated with the device does not exist!";throw new he("UPDATE_DEVICE",b)}}let h=await this.create();if(!h.success)throw new he("UPDATE_DEVICE",h.message||"Update of the device failed!");let d=await this.update();if(!d.success)throw new he("UPDATE_DEVICE",d.message||"Update of the device failed!");if(!this.result){let p={text:"Failed to update project library device {title}!",args:{title:((l=this.updateData)==null?void 0:l.display_title)||((c=this.updateData)==null?void 0:c.title)||""}};throw new he("UPDATE_DEVICE",p)}return await this.onsuccess(this.result),{success:!0,result:Object.assign(this.result,{map:this.map})}}catch(u){throw new he("UPDATE_DEVICE",u.message||"Update of the device failed!")}}getBind(){if(this.updateData){let{attributes:e}=this.updateData,{Symbol:t,Footprint:i}=e||{},{isProject:r}=this.data.device;if(r===void 0)!this.data.symbol&&t&&(this.data.symbol={isProject:!0,path:this.path,uuid:t}),!this.data.footprint&&i&&(this.data.footprint={isProject:!0,path:this.path,uuid:i});else{let[n,s]=this.updateData.source.split(sd);!this.data.symbol&&t&&(this.data.symbol={isProject:r,path:s,uuid:t}),!this.data.footprint&&i&&(this.data.footprint={isProject:r,path:s,uuid:i})}}}onbeforeCreate(){var e,t,i,r;if((e=this.addData.symbol)!=null&&e.docType&&!rR((t=this.addData.symbol)==null?void 0:t.docType))throw new he("UPDATE_DEVICE","invalid symbol docType");if((i=this.addData.footprint)!=null&&i.docType&&((r=this.addData.footprint)==null?void 0:r.docType)!==4)throw new he("UPDATE_DEVICE","invalid footprint docType");return this.addData.footprint&&(this.addData.footprint.isConnectDevice=!0),{success:!0}}async create(){let{symbol:e,footprint:t}=this.addData;if(this.onbeforeCreate(),e){let i=(await xt.messageBus.rpcCall(ci.SYMBOL.CREATE,[e,this.path])).message;if(!i.success)throw new he("UPDATE_DEVICE",i.message||"Project library symbol added failed!");let r=i.result;this.result.symbol={success:!0,result:r},this.map[e.uuid]=r.uuid}if(t){let i=(await xt.messageBus.rpcCall(ci.FOOTPRINT.CREATE,[t,this.path])).message;if(!i.success)throw new he("UPDATE_DEVICE",i.message||"Project library footprint added failed!");let r=i.result;this.result.footprint={success:!0,result:r},this.map[t.uuid]=r.uuid}return{success:!0}}async update(){var e,t,i;let r=this.updateData;if(r){(e=this.result.symbol)!=null&&e.success&&this.result.symbol.result&&(r.attributes.Symbol=(t=this.result.symbol)==null?void 0:t.result.uuid),(i=this.result.footprint)!=null&&i.success&&this.result.footprint.result&&(r.attributes.Footprint=this.result.footprint.result.uuid);let n=[{...r,uuid:this.uuid,keepVersion:this.keepVersion},this.path],s=(await xt.messageBus.rpcCall(ci.DEVICE.UPDATE,n)).message;if(!s){let a=r.display_title||r.title||"";throw new he("UPDATE_DEVICE",`Update of the device failed! title: ${a}`)}this.result.device={success:!0,result:s}}return{success:!0}}async onbefore(){Lp(this.data.device)?(this.onlyIdentity=!0,this.keepVersion=!0):(this.onlyIdentity=!1,this.keepVersion=!1)}async onsuccess(e){e.symbol&&!e.symbol.success&&(e.symbol.message=Tp(e.symbol)||e.symbol.message),e.footprint&&!e.footprint.success&&(e.footprint.message=Tp(e.footprint)||e.footprint.message),e.device&&!e.device.success&&(e.device.message=Tp(e.device)||e.device.message)}},aX=class extends Pm{constructor(e){let{path:t,data:i,options:r={}}=e,{matchKey:n=!0,byUUID:s=!0,byVersion:a=!0,bySource:o=!1,renameKey:l=!1}=r;super(t),this.data=i,this.byUUID=s,this.byVersion=a,this.bySource=o,this.renameKey=l,this.matchKey=n}async start(){await this.check(),await this.onbefore();let e={path:this.path,byUUID:this.byUUID,byVersion:this.byVersion,bySource:this.bySource,renameKey:this.renameKey,matchKey:this.matchKey},t=await new OI({...e,data:this.data}).start();if(!t.success)throw new he("CREATE_SYMBOL",t.message||"Project library symbol added failed!");let{addData:i,respond:r}=t.result;if(r&&!r.success)throw new he("CREATE_SYMBOL",r.message||"Project library symbol added failed!");if(r&&r.success)this.result=r.result;else if(i){let n=(await xt.messageBus.rpcCall(ci.SYMBOL.CREATE,[i,this.path])).message;if(!n.success)throw new he("CREATE_SYMBOL","Project library symbol added failed!");this.result=n.result}if(!this.result)throw new he("CREATE_SYMBOL","Project library symbol added failed!");return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){}async onsuccess(e){}},oX=class extends Pm{constructor(e){let{path:t,data:i,options:r={}}=e,{matchKey:n=!0,byUUID:s=!0,byVersion:a=!0,bySource:o=!1,renameKey:l=!1}=r;super(t),this.data=i,this.byUUID=s,this.byVersion=a,this.bySource=o,this.renameKey=l,this.matchKey=n}async start(){await this.check(),await this.onbefore();let e={path:this.path,byUUID:this.byUUID,byVersion:this.byVersion,bySource:this.bySource,renameKey:this.renameKey,matchKey:this.matchKey},t=await new LI({...e,data:this.data}).start();if(!t.success)throw new he("CREATE_FOOTPRINT",t.message||"Creation of the footprint failed!");let{addData:i,respond:r}=t.result;if(r&&!r.success)throw new he("CREATE_FOOTPRINT",r.message||"Creation of the footprint failed!");if(r&&r.success)this.result=r.result;else if(i){let n=(await xt.messageBus.rpcCall(ci.FOOTPRINT.CREATE,[i,this.path])).message;if(!n.success)throw new he("CREATE_FOOTPRINT","Project library footprint added failed!");this.result=n.result}if(!this.result)throw new he("CREATE_FOOTPRINT","Project library footprint added failed!");return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){}async onsuccess(e){}},lX=class extends VN{constructor(e,t){super(t),this.uuid=e}onHandle(e){return this.onUpdate(e)}matching(e){throw new Error("Method not implemented.")}async hack(e){let{docType:t}=e;return t===17}async isRename(e){return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new he("UPDATE_SYMBOL",e.message||"Update of the symbol failed!");if(!this.origin)throw new he("UPDATE_SYMBOL","Symbol details data does not exist");let t=this.origin.display_title||this.origin.title,i=[{uuid:this.uuid,title:t},this.path];if((await xt.messageBus.rpcCall(ci.SYMBOL.IS_CHANGE,i)).message){let r=await this.rename(this.origin,{path:this.path});if(!r.success)throw new he("UPDATE_SYMBOL",r.message||"Update of the symbol failed!")}return{success:!0,result:this.origin}}},cX=class extends Pm{constructor(e){let{path:t,uuid:i,data:r,options:n={}}=e,{matchKey:s=!0,byUUID:a=!0,bySource:o=!0,byVersion:l=!1,renameKey:c=!1}=n;super(t),this.uuid=i,this.data=r,this.matchKey=s,this.byUUID=a,this.bySource=o,this.byVersion=l,this.renameKey=c}async start(){var e,t;await this.check(),await this.onbefore();let i={path:this.path,matchKey:this.matchKey,byUUID:this.byUUID,bySource:this.bySource,byVersion:this.byVersion,renameKey:this.renameKey,data:this.data},r=await new lX(this.uuid,i).start();if(!r.success)throw new he("UPDATE_SYMBOL",r.message||"Update of the symbol failed!");this.updateData=r.result;let n={uuid:this.uuid,data:this.updateData,overwriteCanvas:this.onlyIdentity,keepVersion:this.keepVersion},s=(await xt.messageBus.rpcCall(ci.SYMBOL.COVER,[n,this.path])).message;if(!s.success)throw new he("UPDATE_SYMBOL",s.message||"Update of the symbol failed!");if(this.result=s.result,!this.result){let a=((e=this.updateData)==null?void 0:e.display_title)||((t=this.updateData)==null?void 0:t.title)||"",o="Failed to update project library symbol {title}!";throw new he("UPDATE_SYMBOL",{text:o,args:{title:a}})}return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){Lp(this.data)?(this.onlyIdentity=!0,this.keepVersion=!0):(this.onlyIdentity=!1,this.keepVersion=!1)}async onsuccess(e){}},uX=class extends YN{constructor(e,t){super(t),this.uuid=e}onHandle(e){return this.onUpdate(e)}matching(e){throw new Error("Method not implemented.")}async isRename(e){return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new he("UPDATE_FOOTPRINT",e.message||"Update of the footprint failed!");if(!this.origin)throw new he("UPDATE_FOOTPRINT","Footprint details data does not exist");let t=this.origin.display_title||this.origin.title,i=[{uuid:this.uuid,title:t},this.path];if((await xt.messageBus.rpcCall(ci.FOOTPRINT.IS_CHANGE,i)).message){let r=await this.rename(this.origin,{path:this.path});if(!r.success)throw new he("UPDATE_FOOTPRINT",r.message||"Update of the footprint failed!")}return{success:!0,result:this.origin}}},hX=class extends Pm{constructor(e){let{path:t,uuid:i,data:r,options:n={}}=e,{matchKey:s=!0,byUUID:a=!0,bySource:o=!0,byVersion:l=!1,renameKey:c=!1}=n;super(t),this.uuid=i,this.data=r,this.matchKey=s,this.byUUID=a,this.bySource=o,this.byVersion=l,this.renameKey=c}async start(){var e,t;await this.check(),await this.onbefore();let i={path:this.path,matchKey:this.matchKey,byUUID:this.byUUID,bySource:this.bySource,byVersion:this.byVersion,renameKey:this.renameKey,data:this.data},r=await new uX(this.uuid,i).start();if(!r.success)throw new he("UPDATE_FOOTPRINT",r.message||"Update of the footprint failed!");this.updateData=r.result;let n={uuid:this.uuid,data:this.updateData,overwriteCanvas:this.onlyIdentity,keepVersion:this.keepVersion},s=(await xt.messageBus.rpcCall(ci.FOOTPRINT.COVER,[n,this.path])).message;if(!s.success)throw new he("UPDATE_FOOTPRINT",s.message||"Update of the footprint failed!");if(this.result=s.result,!this.result){let a={text:"Failed to update project library footprint {title}!",args:{title:((e=this.updateData)==null?void 0:e.display_title)||((t=this.updateData)==null?void 0:t.title)||""}};throw new he("UPDATE_FOOTPRINT",a)}return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){Lp(this.data)?(this.onlyIdentity=!0,this.keepVersion=!0):(this.onlyIdentity=!1,this.keepVersion=!1)}async onsuccess(e){}},dX=class extends TI{async getDevice(e){let t=[e.uuid,e.path],{message:i}=await xt.messageBus.rpcCall(ci.DEVICE.GET,t);if(!i)throw new he("GET_DEVICE","Device details data does not exist");return Ex(e.path,i)}async getDeviceAttributesKeys(e){let{message:t}=await xt.messageBus.rpcCall(ci.DEVICE.GET_ATTRIBUTES_KEYS,e);if(!t.success)throw new he("GET_DEVICE_ATTRIBUTES_KEYS",t.message);return t.result}async getDeviceAttributesValues(e){let{message:t}=await xt.messageBus.rpcCall(ci.DEVICE.GET_ATTRIBUTES_VALUES,e);if(!t.success)throw new he("GET_DEVICE_ATTRIBUTES_VALUES",t.message);return t.result}async getSymbol(e){let t=[e.uuid,e.path],{message:i}=await xt.messageBus.rpcCall(ci.SYMBOL.GET,t);if(!i)throw new he("GET_SYMBOL","Symbol details data does not exist");return vT(e.path,i)}async getFootprint(e){let t=[e.uuid,e.path],{message:i}=await xt.messageBus.rpcCall(ci.FOOTPRINT.GET,t);if(!i)throw new he("GET_FOOTPRINT","Footprint details data does not exist");return TT(e.path,i)}async createDevice(e){let{path:t,device:i,symbol:r,footprint:n}=e,s={path:t,data:{device:i,symbol:r,footprint:n}},a=await new rX(s).start();if(!a.success)throw new he("CREATE_DEVICE",a.message);let o=a.result.device;if(!(o!=null&&o.success))throw new he("CREATE_DEVICE",o==null?void 0:o.message);let l=o.result;return Ex(e.path,l)}async createSymbol(e){let{path:t,symbol:i}=e,r={path:t,data:i},n=await new aX(r).start();if(!n.success)throw new he("CREATE_SYMBOL",n.message);let s=n.result;return vT(e.path,s)}async createFootprint(e){let{path:t,footprint:i}=e,r={path:t,data:i},n=await new oX(r).start();if(!n.success)throw new he("CREATE_FOOTPRINT",n.message);let s=n.result;return TT(e.path,s)}async updateDevice(e){let{uuid:t,path:i,device:r,symbol:n,footprint:s}=e,a={path:i,uuid:t,data:{device:r,symbol:n,footprint:s}},o=await new sX(a).start();if(!o.success)throw new he("UPDATE_DEVICE",o.message);let l=o.result.device;if(!(l!=null&&l.success))throw new he("CREATE_DEVICE",l==null?void 0:l.message);let c=l.result;return Ex(e.path,c)}async updateDeviceAttributes(e){let t=(await xt.messageBus.rpcCall(ci.DEVICE.UPDATE,[e,e.path])).message;if(!t)throw new he("UPDATE_DEVICE_ATTRIBUTES",t.message);return Ex(e.path,t)}async updateSymbol(e){let{uuid:t,path:i,symbol:r}=e,n={path:i,uuid:t,data:r},s=await new cX(n).start();if(!s.success)throw new he("UPDATE_SYMBOL",s.message);let a=s.result;return vT(e.path,a)}async updateFootprint(e){let{uuid:t,path:i,footprint:r}=e,n={path:i,uuid:t,data:r},s=await new hX(n).start();if(!s.success)throw new he("UPDATE_FOOTPRINT",s.message);let a=s.result;return TT(e.path,a)}async deleteDevice(e){if(!(await xt.messageBus.rpcCall(ci.DEVICE.DEL,[e.uuid,e.path])).message)throw new he("DELETE_DEVICE","delete failed!")}async deleteSymbol(e){if(!(await xt.messageBus.rpcCall(ci.SYMBOL.DEL,[e.uuid,e.path])).message)throw new he("DELETE_SYMBOL","delete failed!")}async deleteFootprint(e){if(!(await xt.messageBus.rpcCall(ci.FOOTPRINT.DEL,[e.uuid,e.path])).message)throw new he("DELETE_FOOTPRINT","delete failed!")}async getDeviceList(e){let t=(await xt.messageBus.rpcCall(ci.DEVICE.GET_LIST,e)).message;if(!t.success)throw new he("GET_DEVICE_LIST",t.message);return t.result}async getDeviceSearchList(e){let t=(await xt.messageBus.rpcCall(ci.DEVICE.GET_LIST,e)).message;if(!t.success)throw new he("GET_DEVICE_LIST",t.message);return t.result}async getSymbolList(e){let t=(await xt.messageBus.rpcCall(ci.SYMBOL.GET_LIST,e)).message;if(!t.success)throw new he("GET_SYMBOL_LIST",t.message);return t.result}async getSymbolSearchList(e){let t=(await xt.messageBus.rpcCall(ci.SYMBOL.GET_LIST,e)).message;if(!t.success)throw new he("GET_SYMBOL_LIST",t.message);return t.result}async getFootprintList(e){let t=(await xt.messageBus.rpcCall(ci.FOOTPRINT.GET_LIST,e)).message;if(!t.success)throw new he("GET_FOOTPRINT_LIST",t.message);return t.result}async getFootprintSearchList(e){let t=(await xt.messageBus.rpcCall(ci.FOOTPRINT.GET_LIST,e)).message;if(!t.success)throw new he("GET_FOOTPRINT_LIST",t.message);return t.result}},pX=class extends TI{constructor(){super(...arguments),this._normalErrorMsg="Request Error.",this._extendLibManager=hs.getInstance()}async getDevice(e){var t;let i=await((t=this._extendLibManager.getLib(e.path))==null?void 0:t.getTransformedDetailInTab("device",e.uuid,e.path));if(i)return i;throw new he("GET_DEVICE",this._normalErrorMsg)}async getSymbol(e){var t;let i=await((t=this._extendLibManager.getLib(e.path))==null?void 0:t.getTransformedDetailInTab("symbol",e.uuid,e.path));if(i)return i;throw new he("GET_SYMBOL",this._normalErrorMsg)}async getFootprint(e){var t;let i=await((t=this._extendLibManager.getLib(e.path))==null?void 0:t.getTransformedDetailInTab("footprint",e.uuid,e.path));if(i)return i;throw new he("GET_FOOTPRINT",this._normalErrorMsg)}async getModel3D(e){var t;let i=await((t=this._extendLibManager.getLib(e.path))==null?void 0:t.getTransformedDetailInTab("model3D",e.uuid,e.path));if(i)return i;throw new he("GET_D3MODEL",this._normalErrorMsg)}async getDeviceList(e){var t,i,r,n,s,a,o,l;let c=await((l=this._extendLibManager.getLib(e.path))==null?void 0:l.getTransformedListInTab("device",{query:{attributes:(i=(t=e.query)==null?void 0:t.attributes)!=null?i:{},symbolType:(r=e.query)==null?void 0:r.symbol_type,classification:{primaryClassificationUuid:(s=(n=e.tags)==null?void 0:n[0])!=null?s:"",secondaryClassificationUuid:(o=(a=e.tags)==null?void 0:a[1])!=null?o:""}},page:e.page,pageSize:e.pageSize}));if(c)return c;throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getSymbolList(e){var t,i,r,n,s,a;let o=await((a=this._extendLibManager.getLib(e.path))==null?void 0:a.getTransformedListInTab("symbol",{query:{symbolType:(t=e.docType)==null?void 0:t[0],classification:{primaryClassificationUuid:(r=(i=e.tags)==null?void 0:i[0])!=null?r:"",secondaryClassificationUuid:(s=(n=e.tags)==null?void 0:n[1])!=null?s:""}},page:e.page,pageSize:e.pageSize}));if(o)return o;throw new he("GET_SYMBOL_LIST",this._normalErrorMsg)}async getFootprintList(e){var t,i,r,n,s;let a=await((s=this._extendLibManager.getLib(e.path))==null?void 0:s.getTransformedListInTab("footprint",{query:{classification:{primaryClassificationUuid:(i=(t=e.tags)==null?void 0:t[0])!=null?i:"",secondaryClassificationUuid:(n=(r=e.tags)==null?void 0:r[1])!=null?n:""}},page:e.page,pageSize:e.pageSize}));if(a)return a;throw new he("GET_FOOTPRINT_LIST",this._normalErrorMsg)}async getDeviceSearchList1(e){var t,i,r,n;let{path:s,wd:a,query:o,tags:l,page:c,pageSize:u}=e,h=await((n=this._extendLibManager.getLib(s))==null?void 0:n.getTransformedListInTab("device",{query:{wd:a,attributes:(t=o==null?void 0:o.attributes)!=null?t:{},symbolType:o==null?void 0:o.symbol_type,classification:{primaryClassificationUuid:(i=l==null?void 0:l[0])!=null?i:"",secondaryClassificationUuid:(r=l==null?void 0:l[1])!=null?r:""}},page:c,pageSize:u}));if(h)return{...h,facets:{[s]:h.count}};throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getDeviceSearchList2(e){var t;let{path:i,titles:r}=e,n=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("device",{query:{listByTitles:r},page:1,pageSize:1e8}));if(n)return n.lists.reduce((s,a)=>((s[a.display_title]||(s[a.display_title]=[])).push(a),s),{});throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getDeviceSearchList3(e){var t;let{path:i,uuids:r}=e,n=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("device",{query:{listByUuids:r},page:1,pageSize:1e8}));if(n)return n.lists;throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getDeviceSearchList(e){return e.titles?await this.getDeviceSearchList2(e):e.uuids?await this.getDeviceSearchList3(e):await this.getDeviceSearchList1(e)}async getSymbolSearchList1(e){var t,i,r,n;let{path:s,wd:a,query:o,tags:l,page:c,pageSize:u}=e,h=await((n=this._extendLibManager.getLib(s))==null?void 0:n.getTransformedListInTab("symbol",{query:{wd:a,symbolType:(t=e.docType)==null?void 0:t[0],classification:{primaryClassificationUuid:(i=l==null?void 0:l[0])!=null?i:"",secondaryClassificationUuid:(r=l==null?void 0:l[1])!=null?r:""}},page:c,pageSize:u}));if(h)return{...h,facets:{[s]:h.count}};throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getSymbolSearchList2(e){var t;let{path:i,titles:r}=e,n=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("symbol",{query:{listByTitles:r},page:1,pageSize:1e8}));if(n)return n.lists.reduce((s,a)=>((s[a.display_title]||(s[a.display_title]=[])).push(a),s),{});throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getSymbolSearchList3(e){var t;let{path:i,uuids:r}=e,n=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("symbol",{query:{listByUuids:r},page:1,pageSize:1e8}));if(n)return n.lists;throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getSymbolSearchList(e){return e.titles?await this.getSymbolSearchList2(e):e.uuids?await this.getSymbolSearchList3(e):await this.getSymbolSearchList1(e)}async getFootprintSearchList1(e){var t,i,r;let{path:n,wd:s,query:a,tags:o,page:l,pageSize:c}=e,u=await((r=this._extendLibManager.getLib(n))==null?void 0:r.getTransformedListInTab("footprint",{query:{wd:s,classification:{primaryClassificationUuid:(t=o==null?void 0:o[0])!=null?t:"",secondaryClassificationUuid:(i=o==null?void 0:o[1])!=null?i:""}},page:l,pageSize:c}));if(u)return{...u,facets:{[n]:u.count}};throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getFootprintSearchList2(e){var t;let{path:i,titles:r}=e,n=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("footprint",{query:{listByTitles:r},page:1,pageSize:1e8}));if(n)return n.lists.reduce((s,a)=>((s[a.display_title]||(s[a.display_title]=[])).push(a),s),{});throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getFootprintSearchList3(e){var t;let{path:i,uuids:r}=e,n=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("footprint",{query:{listByUuids:r},page:1,pageSize:1e8}));if(n)return n.lists;throw new he("GET_DEVICE_LIST",this._normalErrorMsg)}async getFootprintSearchList(e){return e.titles?await this.getFootprintSearchList2(e):e.uuids?await this.getFootprintSearchList3(e):await this.getFootprintSearchList1(e)}createDevice(e){throw new he("CREATE_DEVICE","Not Supported.")}createSymbol(e){throw new he("GET_SYMBOL","Not Supported.")}createFootprint(e){throw new he("CREATE_FOOTPRINT","Not Supported.")}updateDevice(e){throw new he("UPDATE_DEVICE","Not Supported.")}updateSymbol(e){throw new he("GET_SYMBOL","Not Supported.")}updateFootprint(e){throw new he("GET_SYMBOL","Not Supported.")}deleteDevice(e){throw new he("GET_SYMBOL","Not Supported.")}deleteSymbol(e){throw new he("GET_SYMBOL","Not Supported.")}deleteFootprint(e){throw new he("GET_SYMBOL","Not Supported.")}},fX=(e=>(e[e.CBB=1]="CBB",e[e.SYMBOL=2]="SYMBOL",e[e.DEVICE=3]="DEVICE",e[e.FOOTPRINT=4]="FOOTPRINT",e[e.MODEL3D=5]="MODEL3D",e[e.MODELSIM=6]="MODELSIM",e[e.PANEL_LIB=29]="PANEL_LIB",e))(fX||{}),mX=["title","description","tags","images"],xi=new Qz,us=new dX,nu=new pX,sn=class{static getDevice(e){return hs.getInstance().hasLib(e.path)?nu.getDevice(e):e.isProject?us.getDevice(e):xi.getDevice(e)}static getDeviceAttributesKeys(e){return e.isProject?us.getDeviceAttributesKeys(e):xi.getDeviceAttributesKeys(e)}static getDeviceAttributesValues(e){return e.isProject?us.getDeviceAttributesValues(e):xi.getDeviceAttributesValues(e)}static getSymbol(e){return hs.getInstance().hasLib(e.path)?nu.getSymbol(e):e.isProject?us.getSymbol(e):xi.getSymbol(e)}static getFootprint(e){return hs.getInstance().hasLib(e.path)?nu.getFootprint(e):e.isProject?us.getFootprint(e):xi.getFootprint(e)}static getPanelLib(e){if(e.isProject)throw new he("GET_PANEL_LIB","Api call error!");return xi.getPanelLib(e)}static getD3Model(e){return hs.getInstance().hasLib(e.path)?nu.getModel3D(e):e.isProject?null:xi.getD3Model(e)}static getSimModel(e){if(e.isProject)throw new he("GET_SIM_MODEL","Api call error!");return xi.getSimModel(e)}static getDeviceList(e){return hs.getInstance().hasLib(e.path)?nu.getDeviceList(e):e.isProject?us.getDeviceList(e):xi.getDeviceList(e)}static getSymbolList(e){return hs.getInstance().hasLib(e.path)?nu.getSymbolList(e):e.isProject?us.getSymbolList(e):xi.getSymbolList(e)}static getFootprintList(e){return hs.getInstance().hasLib(e.path)?nu.getFootprintList(e):e.isProject?us.getFootprintList(e):xi.getFootprintList(e)}static getPanelLibList(e){if(e.isProject)throw new he("GET_D3MODEL_LIST","Api call error!");return xi.getPanelLibList(e)}static getD3ModelList(e){if(e.isProject)throw new he("GET_D3MODEL_LIST","Api call error!");return xi.getD3ModelList(e)}static getSimModelList(e){if(e.isProject)throw new he("GET_SIM_MODEL_LIST","Api call error!");return xi.getSimModelList(e)}static getDeviceSearchList(e){return hs.getInstance().hasLib(e.path)?nu.getDeviceSearchList(e):e.isProject?us.getDeviceSearchList(e):xi.getDeviceSearchList(e)}static getSymbolSearchList(e){return hs.getInstance().hasLib(e.path)?nu.getSymbolSearchList(e):e.isProject?us.getSymbolSearchList(e):xi.getSymbolSearchList(e)}static getFootprintSearchList(e){return hs.getInstance().hasLib(e.path)?nu.getFootprintSearchList(e):e.isProject?us.getFootprintSearchList(e):xi.getFootprintSearchList(e)}static getPanelLibSearchList(e){if(e.isProject)throw new he("GET_PANEL_LIB_SEARCH_LIST","Api call error!");return xi.getPanelLibSearchList(e)}static getD3ModelSearchList(e){if(e.isProject)throw new he("GET_D3MODEL_SEARCH_LIST","Api call error!");return xi.getD3ModelSearchList(e)}static getSimModelSearchList(e){if(e.isProject)throw new he("GET_SIM_MODEL_SEARCH_LIST","Api call error!");return xi.getSimModelSearchList(e)}static createDevice(e){return e.isProject?us.createDevice(e):xi.createDevice(e)}static createSymbol(e){return e.isProject?us.createSymbol(e):xi.createSymbol(e)}static createFootprint(e){return e.isProject?us.createFootprint(e):xi.createFootprint(e)}static createD3Model(e){return e.isProject?null:xi.createD3Model(e)}static createPanelLib(e){if(e.isProject)throw new he("CREATE_PANEL_LIB","Api call error!");return xi.createPanelLib(e)}static createSimModel(e){if(e.isProject)throw new he("CREATE_SIM_MODEL","Api call error!");return xi.createSimModel(e)}static updateDevice(e){return e.isProject?us.updateDevice(e):xi.updateDevice(e)}static updateDeviceAttributes(e){return e.isProject?us.updateDeviceAttributes(e):xi.updateDeviceAttributes(e)}static updateSymbol(e){return e.isProject?us.updateSymbol(e):xi.updateSymbol(e)}static updateFootprint(e){return e.isProject?us.updateFootprint(e):xi.updateFootprint(e)}static updatePanelLib(e){if(e.isProject)throw new he("UPDATE_PANEL_LIB","Api call error!");return xi.updatePanelLib(e)}static updateD3Model(e){if(e.isProject)throw new he("UPDATE_D3MODEL","Api call error!");return xi.updateD3Model(e)}static updateSimModel(e){if(e.isProject)throw new he("UPDATE_SIM_MODEL","Api call error!");return xi.updateSimModel(e)}static deleteDevice(e){return e.isProject?us.deleteDevice(e):xi.deleteDevice(e)}static deleteSymbol(e){return e.isProject?us.deleteSymbol(e):xi.deleteSymbol(e)}static deleteFootprint(e){return e.isProject?us.deleteFootprint(e):xi.deleteFootprint(e)}static deletePanelLib(e){if(e.isProject)throw new he("DELETE_PANEL_LIB","Api call error!");return xi.deletePanelLib(e)}static deleteSimModel(e){if(e.isProject)throw new he("DELETE_SIM_MODEL","Api call error!");return xi.deleteSimModel(e)}static deleteD3Model(e){if(e.isProject)throw new he("DELETE_3DMODEL","Api call error!");return xi.delete3DModel(e)}static starDevice(e){if(e.isProject)throw new he("STAR_DEVICE","Api call error!");return xi.starDevice(e)}static starSymbol(e){if(e.isProject)throw new he("STAR_SYMBOL","Api call error!");return xi.starSymbol(e)}static starFootprint(e){if(e.isProject)throw new he("STAR_FOOTPRINT","Api call error!");return xi.starFootprint(e)}static starPanelLib(e){if(e.isProject)throw new he("STAR_PANEL_LIB","Api call error!");return xi.starPanelLib(e)}static unstarDevice(e){if(e.isProject)throw new he("UNSTAR_DEVICE","Api call error!");return xi.unstarDevice(e)}static unstarSymbol(e){if(e.isProject)throw new he("UNSTAR_SYMBOL","Api call error!");return xi.unstarSymbol(e)}static unstarFootprint(e){if(e.isProject)throw new he("UNSTAR_FOOTPRINT","Api call error!");return xi.unstarFootprint(e)}static unstarPanelLib(e){if(e.isProject)throw new he("UNSTAR_PANEL_LIB","Api call error!");return xi.unstarPanelLib(e)}};async function HN(e,t,i,r={}){r.eachProcessHook&&r.eachProcessHook(.01);let n=i||it.SYSTEMLIB_UUID,s=null;if(t)try{s=await sn.getDevice({isProject:e,path:i,uuid:t})}catch(u){console.warn(u)}r.eachProcessHook&&r.eachProcessHook(.25);let a=null,o={Footprint:!1,symbol:!1,d3DModel:!1};if(s){let u=(s.attributes||{}).Symbol;if(u){try{a=await sn.getSymbol({isProject:e,path:i,uuid:u})}catch(h){console.warn(h)}a||(o.symbol=!0)}}r.eachProcessHook&&r.eachProcessHook(.5);let l=null;if(s){let u=(s.attributes||{}).Footprint;if(u){try{l=await sn.getFootprint({isProject:e,path:i,uuid:u})}catch(h){console.warn(h)}l||(o.Footprint=!0)}}r.eachProcessHook&&r.eachProcessHook(.75);let c=null;if(s){let u=s.attributes||{},h=u["3D Model"],d=u["3D Model Title"],p=x0(h,!0),f=p.path||it.SYSTEMLIB_UUID||n;if(p.componentTitleOrId&&(p.isLocaleFilenameMode?c=(await wI(p.componentTitleOrId,f)).result:c=await S0(p.componentTitleOrId,f)),!c&&h&&d){if(r.isCheckD3ModelFileExist){let m=await hN(h);m.success&&m.result instanceof Blob?o.d3DModel=!1:o.d3DModel=!0}else o.d3DModel=!0;c=vI(h,d,p.path)}}return r.eachProcessHook&&r.eachProcessHook(1),{setPath:n,deviceItem:s,symbolItem:a,footprintItem:l,d3modelItem:c,hasIdButNotFound:o}}async function gX(e=!1,t,i,r,n){let s=n?!!n.forceAsSymbol:!1,a=n?!!n.ignoreDoctypeCheck:!1,o=n?!!n.isDevice:!1,l=n?!!n.isCheckD3ModelFileExist:!1;if(!a){if(r===28){let h=n?!!n.attachedDeviceBindingExtra:!1,d=n?n.eachProcessHook:null;try{let p=null;return h?p=await HN(e,t,i,{eachProcessHook:d,isCheckD3ModelFileExist:l}):p=await sn.getDevice({isProject:e,path:i,uuid:t}),{code:0,success:!0,result:p,message:""}}catch(p){return{code:-1,success:!1,result:null,message:p.message.toString()}}}if(r===4)try{return{code:0,success:!0,result:await sn.getFootprint({isProject:e,path:i,uuid:t}),message:""}}catch(h){return{code:-1,success:!1,result:null,message:h.message.toString()}}if(s||r&&[2,18,19,20,21,22,25,31,7,32,6].indexOf(r)>=0)try{return{code:0,success:!0,result:await sn.getSymbol({isProject:e,path:i,uuid:t}),message:""}}catch(h){return{code:-1,success:!1,result:null,message:h.message.toString()}}if(r===16)try{return{code:0,success:!0,result:await S0(t,i),message:""}}catch(h){return{code:-1,success:!1,result:null,message:h.message.toString()}}}let c=await Rt("GET",o?vr(Lt.DEVICE.GET,{uuid:t}):vr(Lt.COMPONENT.GET,{uuid:t}),{uuid:t,path:i},{headers:{"Content-Type":"application/json",path:i}});if(c.code===0&&c.success&&typeof c.result=="object")return{code:0,success:!0,result:c.result,message:""};let u=c.message||c.msg||"Request Error.";return{code:c.code||-1,success:!1,result:null,message:u}}function ZT(e,t){let i=e.owner||{},r=typeof e.updated_at=="string"?e.updated_at:typeof e.updated_at=="number"?ld(new Date(e.updated_at)):"",n=typeof e.updateTime=="string"?e.updateTime:typeof e.updateTime=="number"?ld(new Date(wa(e.updateTime))):"";return{...e,$id:String(t),numberIndex:t+1,ownerBelong:i.username,updateTimeString:r||n}}function yX(e,t,i){let r=[];for(let n=0;n<e.length;n++){let s=e[n][t]?e[n][t].toLocaleLowerCase():"",a=i?i.toLocaleLowerCase():"";s.indexOf(a)>=0&&r.push(e[n])}return r}async function bX(e,t,i,r){let n=await new Promise(a=>{fetch(gI.D3Model.client3DModelList+`?step_path=${e}`,{method:"GET"}).then(o=>{o.json().then(l=>{if(l){a(l);return}a(null)})})}),s={code:0,success:!0,result:{count:0,page:1,pageSize:r,totalPage:1,lists:[]},msg:""};return n&&n.success?(s.result.lists=(n.result||[]).map((a,o)=>{let l=ld(new Date(a.mtime*1e3)),c={uuid:`${a.fileName}|${t}`,rowFileTag:`${a.fileName}|${t}`,path:t,display_title:a.fileName,description:"",docType:16,isFavorite:!1,modifier:null,owner:null,tags:{child_tag:[],parent_tag:[]},title:a.fileName,updateTime:wa(a.mtime),updated_at:l,createTime:wa(a.mtime),created_at:l,creator:null,dataStr:"",public:void 0,type:16};return{...ZT(c,o)}}),s.result.count=n.result.length):(s.code=it.ERR_CODE.NORMAL,s.success=!1,s.msg=n.message||"Fetch local 3D model list error."),s}async function xX(e,t,i,r,n){let s={};for(let c=0;c<t.length;c++){let u=t[c].id,h=await new Promise(d=>{fetch(gI.D3Model.client3DModelList+`?step_path=${u}`,{method:"GET"}).then(p=>{p.json().then(f=>{if(f){d(f);return}d(null)})})});if(h&&h.success){s[u]={list:h.result.map((d,p)=>ZT(d,p))};continue}s[u]=null}let a={},o={},l={count:0};for(let c=0;c<t.length;c++){let u=t[c].id;if(s[u]){let h=yX(s[u].list,"fileName",r);if(!h.length){a[u]=0,o[u]=[];continue}a[u]=h.length,o[u]=h.map((d,p)=>{let f=ld(new Date(d.mtime*1e3)),m={uuid:`${d.fileName}|${d.path}`,path:d.path,rowFileTag:`${d.fileName}|${d.path}`,display_title:d.fileName,description:"",docType:16,isFavorite:!1,modifier:null,owner:null,tags:{child_tag:[],parent_tag:[]},title:d.fileName,updateTime:wa(d.mtime),updated_at:f,createTime:wa(d.mtime),created_at:f,creator:null,dataStr:"",public:void 0,source:void 0,std_uuid:void 0,ticket:0,type:16};return{...ZT(m,p)}}),l.count++;continue}a[u]=0,o[u]=[]}return{code:0,success:!0,result:{count:l.count,facets:a,lists:o[e]||[],uid:e,wd:r,page:1,pageSize:n,totalPage:1},msg:""}}function jN(e){let t=null;return t=RI(e.title),!t.success||(t=zN(e.description),!t.success)?t:{code:0,success:!0,message:"",key:"",result:null}}function EX(e){let t=null;return t=RI(e.name),!t.success||(t=SX(e.type),!t.success)||(t=wX(e.model),!t.success)?t:{code:0,success:!0,message:"",key:"",result:null}}function RI(e){let t={code:0,success:!0,message:"",key:"",result:null};return(!e||e.length<=0||e.length>128)&&(t.code=it.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}function zN(e){let t={code:0,success:!0,message:"",key:"",result:null};return e&&e.length>255&&(t.code=it.ERR_CODE.NORMAL,t.success=!1,t.message="Description should be no more than 255 letters"),t}function SX(e){let t={code:0,success:!0,message:"",key:"",result:null};return e||(t.code=it.ERR_CODE.NORMAL,t.success=!1,t.message="The 3D model type is incorrect!"),t}function wX(e){let t={code:0,success:!0,message:"",key:"",result:null};return e||(t.code=it.ERR_CODE.NORMAL,t.success=!1,t.message="The 3D model is incorrect!"),t}async function vX(e,t,i,r){if(!t||!i||!r)return{code:-1,success:!1,result:null,message:"missing uuid or path or detail data."};let n=jN({title:r.title,description:r.description});if(!n.success)return{code:n.code,success:!1,result:null,message:n.message};let s=await Rt("POST",vr(Lt.COMPONENT.UPDATE,{uuid:t}),{...r,owner:i},{headers:{"Content-Type":"application/json",path:i}});if(s.code===0&&s.success&&typeof s.result=="object")return{code:0,success:!0,result:s.result,message:""};let a=s.message||s.msg||"Request Error.";return{code:s.code||-1,success:!1,result:null,message:a}}async function TX(e){let t=EX(e);if(!t.success)return{code:t.code,success:!1,message:t.message};let i=new FormData;e.content&&i.append("src",new Blob([e.content]),e.name),i.append("mesh",new Blob([e.model]),"model.obj");let r=await Rt("POST",Lt.COMPONENT.UPLOAD_3DMODEL,i,{contentType:!1,gzipFormData:!0},!0);if(r.success)return{success:!0,result:r.result};let n=r.message||r.msg||"Request Error.";return{success:!1,code:r.code,message:n}}var xc=class{};xc.createDefaultD3modelItem=vI,xc.fetchD3ModelItemHandle=S0,xc.updateD3ModelItem=vX,xc.uploadD3ModelItem=TX,xc.d3modelInfoVerify=jN,xc.d3modelInfoTitleVerify=RI,xc.d3modelInfoDescriptionVerify=zN,xc.fetchD3ModelListOnLocaleFolder=bX,xc.fetchD3ModelListBySearchOnLocaleFolder=xX,xc.fetchD3ModelItemOnLocaleFolder=wI;function IX(e,t=void 0){let i=null;if(i=XN(e.title),!i.success||(i=WN(e.description),!i.success)||(i=qN(e.attributes),!i.success))return i;let r={code:0,success:!0,message:"",key:"",result:null};return typeof t<"u"&&(t.length<=0||t.length>128)&&(r.code=it.ERR_CODE.NORMAL,r.success=!1,r.message="The title length must be between 1~128 characters!"),r}function XN(e){let t={code:0,success:!0,message:"",key:"",result:null};return(!e||e.length<=0||e.length>128)&&(t.code=it.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}function WN(e){let t={code:0,success:!0,message:"",key:"",result:null};return e&&e.length>255&&(t.code=it.ERR_CODE.NORMAL,t.success=!1,t.message="Description should be no more than 255 letters"),t}function qN(e){let t={code:0,success:!0,message:"",key:"",result:null},i=Object.keys(e);for(let r=0;r<i.length;r++){let n=i[r],s=e[n];if(typeof s=="string"&&s.trim().length>255)return t.code=it.ERR_CODE.NORMAL,t.message="{0} should be no more than 255 letters",t.key=n,t}return t}var om=class{};om.deviceInfoVerify=IX,om.deviceInfoTitleVerify=XN,om.deviceInfoDescriptionVerify=WN,om.deviceInfoAttributesVerify=qN,om.fetchDeviceItem=HN;function AX(){return[["DOCTYPE","FOOTPRINT",""],["HEAD",{editorVersion:"dev",importFlag:0}],["CANVAS",0,0,"mm",5,5,5,5,5,5,2,2,5]].map(e=>JSON.stringify(e)).join(`
`)}function CX(e="",t="",i=""){let r=t||"[Empty Footprint Component Item]",n=new Date().getTime(),s=ld(new Date(n)),a={avatar:"",nickname:"",username:"",uuid:""};return{$emptyItem:!0,createTime:n,created_at:s,creator:{...a},dataStr:e,description:"",display_title:r,docType:4,modifier:{...a},owner:{...a},path:it.SYSTEMLIB_UUID,public:!1,source:"",std_uuid:"",tags:{child_tag:null,parent_tag:null},ticket:0,title:r,type:0,updateTime:n,updated_at:s,uuid:i||"",version:""}}function DX(e){let t=null;return t=_X(e.title),t.success?{code:0,success:!0,message:"",key:void 0,result:null}:t}function _X(e){let t={code:0,success:!0,message:"",key:void 0,result:null};return(!e||e.length<=0||e.length>128)&&(t.code=it.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}var Rx=class{};Rx.footprintInfoVerify=DX,Rx.createEmptyFootprintItem=CX,Rx.createEmptyFootprintDataStr=AX;function PX(e){let t=null;return t=LX(e.title),!t.success||(t=OX(e.docType),!t.success)?t:{code:0,success:!0,message:"",key:void 0,result:null}}function LX(e){let t={code:0,success:!0,message:"",key:void 0,result:null};return(!e||e.length<=0||e.length>128)&&(t.code=it.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}function OX(e){let t={code:0,success:!0,message:"",key:void 0,result:null};return(typeof e>"u"||!e)&&(t.code=it.ERR_CODE.NORMAL,t.success=!1,t.message="Document data abnormality"),t}var JN=class{};JN.symbolInfoVerify=PX;async function RX(e=!1,t,i,r,n=[]){let s={isDuplicate:!1,path:r,uuids:[]},a=i.toLocaleLowerCase(),o=await Kx(e,a,r,t,xt.loginedUserUuid);if(o.success&&o.result&&o.result.length){let l=[];for(let c=0;c<o.result.length;c++){if(n.indexOf(o.result[c].uuid)>=0)continue;let u=(o.result[c].title||o.result[c].display_title).toLocaleLowerCase();if(a===u&&o.result[c].path===r){if(typeof t>"u"||t===28){l.push(o.result[c]);continue}if(typeof o.result[c].docType>"u"){l.push(o.result[c]);continue}if(o.result[c].docType===t){l.push(o.result[c]);continue}}}for(let c=0;c<l.length;c++)s.uuids.push(l[c].uuid);s.isDuplicate=!!s.uuids.length}return s}var NX=(e=>(e.UNZIP="/pro-mgr/unzip",e.EXTRACT="/pro-mgr/unzip/extract",e.FLOW="/pro-mgr/unzip/flow",e.PARSE="/pro-mgr/unzip/parse",e.CHECK="/pro-mgr/unzip/check",e.GET_PROJECT_IN_CLOUD="/pro-mgr/getProjectInCloud",e.GET_PROJECT_IN_LOCAL="/pro-mgr/getProjectInLocal",e.GET_PROJECT_BY_IN_LOCAL="/pro-mgr/getProjectByInLocal",e.EXPORT_ZIP="/pro-mgr/export/zip",e.EXPORT_DOCUMENT="/pro-mgr/export/document",e.EXPORT_DEVICE="/pro-mgr/export/lib/device",e.EXPORT_SYMBOL="/pro-mgr/export/lib/symbol",e.EXPORT_FOOTPRIN="/pro-mgr/export/lib/footprint",e.EXPORT_PANEL_LIB="/pro-mgr/export/lib/panelLib",e.DOWNLOAD_PROJECT="/pro-mgr/export/download/project",e.DOWNLOAD_CBB="/pro-mgr/export/download/cbb",e.DOWNLOAD_DOCUMENT="/pro-mgr/export/download/document",e.BACKUP="/pro-mgr/backup",e.ARCHIVE="/pro-mgr/archive",e.LOAD_FILE="/pro-mgr/loadFile",e.CONVERT_PROJECT="/pro-mgr/convertProject/start",e.CONVERT_PROJECT_FLOWWIRTE="/pro-mgr/convertProject/flowWrite",e.CONVERT_PROJECT_FLOWREAD="/pro-mgr/convertProject/flowRead",e.IMPORT_NEW_PROJECT="/pro-mgr/importNewProject",e.PROJECT_AS_CLOUD="/pro-mgr/projectAsCloud",e.CBB_AS_CLOUD="/pro-mgr/cbbAsCloud",e.DOCUMENT_AS_CLOUD="/pro-mgr/documentAsCloud",e.COMPONENT_AS_CLOUD="/pro-mgr/componentAsCloud",e.IMPORT_TARGET_PROJECT="/pro-mgr/importTargetProject",e.UPDATE_BLOCK_SYMBOL_CONNECT="/pro-mgr/updateBlockSymbolConnect",e.IMPORT_SYMBOLS="/pro-mgr/importSymbols",e.IMPORT_FOOTPRINTS="/pro-mgr/importFootprints",e.IMPORT_DEVICES="/pro-mgr/importDevices",e.COPY_BOARD="/pro-mgr/copyBoards",e.COPY_SCHEMATIC="/pro-mgr/copySchematics",e.COPY_PAGE="/pro-mgr/copyPages",e.COPY_SIMULATION_CANVAS="/pro-mgr/copySimulationCanvas",e.COPY_SCH_CANVAS="/pro-mgr/copySchCanvas",e.COPY_PCB_CANVAS="/pro-mgr/copyPcbCanvas",e.COPY_PANEL_CANVAS="/pro-mgr/copyPanelCanvas",e.PASTE_BOARD="/pro-mgr/pasteBoards",e.PASTE_SCHEMATIC="/pro-mgr/pasteSchematics",e.PASTE_PAGE="/pro-mgr/pastePages",e.PASTE_SCH_TOP="/pro-mgr/pasteSchTop",e.PASTE_PCB="/pro-mgr/pastePcb",e.PASTE_PANEL="/pro-mgr/pastePanel",e.PASTE_SIMULATION="/pro-mgr/pasteSimulation",e.PASTE_SCH_BOTTOM="/pro-mgr/pasteSchBottom",e.BUILD_EXPORT="/pro-mgr/buildExport",e.BUILD_TARGET="/pro-mgr/buildTarget",e.PARSE_PROJECT="/pro-mgr/parseProject",e.COMPARE_LOCAL="/pro-mgr/compare/local",e.COMPARE_CLOUD="/pro-mgr/compare/cloud",e.COMPARE_DESTORY="/pro-mgr/compare/destory",e.UPDATE_REUSE_BLOCK="/pro-mgr/updateReuseBlock",e))(NX||{});async function KN(){let e=await new Promise(t=>{fetch("/api/client/config",{method:"GET"}).then(i=>{i.json().then(r=>{t(r)})})});if(e&&e.success&&e.result){let t=e.result,i=t.projectDir instanceof Array?t.projectDir:[t.projectDir];return{basePath:t.appBaseDir,cbbPath:t.reuseBlock,libPath:t.systemLib,projectPath:i,onlinePrjBackupPath:t.appOnlineBackupDir,appBaseDir:t.appBaseDir,autoCheckVersionUpdate:!!t.checkUpdate,activation:t.activation,appTmpBackupDir:t.appTmpBackupDir,cacheDir:t.cacheDir,proxy:t.proxy,log:t.log}}else return null}function lE(e,t){let i=[],r=[];u0?r=e:t&&t.length?r=t:r=e;let n=null;return r.forEach(s=>{s.uuid===it.SYSTEMLIB_UUID?n={title:s.nickname,id:s.uuid,key:it.LIB_SYSTEM_KEY}:i.push({title:s.nickname,id:s.uuid,key:it.LIB_PERSONAL_KEY})}),n&&i.unshift(n),i}async function cE(e,t){let i=lE(e,t)||[],r=[],n=null;return i.forEach((s,a)=>{s.id===it.SYSTEMLIB_UUID?n=a:r.push({title:s.title,id:s.id,key:s.key})}),(n||n===0)&&r.splice(0,0,{title:i[n].title,id:i[n].id,key:i[n].key}),r.splice(1,0,{title:"Project",id:"",key:it.LIB_PROJECT_KEY}),[...r]}async function MX(e,t){let i=await KN();if(!i)return await cE(e,t);let r=lE(e,t),n=Ga(r,"id",it.SYSTEMLIB_UUID),s=[];n.index>=0&&s.splice(0,0,{...n.data});let{projectPath:a,cbbPath:o,libPath:l=[],onlinePrjBackupPath:c,autoCheckVersionUpdate:u}=i;return l.forEach(h=>{s.push({title:$L(h),id:h,key:h})}),s.splice(1,0,{title:"Project",id:"",key:it.LIB_PROJECT_KEY}),[...s]}function BX(e,t,i,r){let n=[],s=[],a={},o=[];return e.forEach(l=>{switch(l.titleAdditional=l.title,l.title){case"Project":{if(!r||!i||!i.uuid)return;l.id=i.uuid,o.push(i.uuid);break}default:}l.id||(l.id="@"+a0(new Date().getTime())),typeof a[l.id]<"u"?(a[l.id]+=1,l.id=l.id+it.LIB_SPLIT_TAG+a[l.id]):a[l.id]=0,t&&t.indexOf(l.id)>=0&&s.push(l.id),n.push(l)}),{treeData:n,projectsIds:o,selectedIds:s}}async function $N(e,t){let i=lE(e,t)||[],r=[],n=null;return i.forEach((s,a)=>{s.id===it.SYSTEMLIB_UUID?n=a:r.push({title:s.title,id:s.id,key:s.key})}),(n||n===0)&&r.splice(0,0,{title:i[n].title,id:i[n].id,key:i[n].key}),r.splice(1,0,{title:"Project",id:"",key:it.LIB_PROJECT_KEY}),[...r]}async function kX(e,t){let i=await KN();if(!i)return await cE(e,t);let r=[],{projectPath:n,cbbPath:s,libPath:a=[],onlinePrjBackupPath:o,autoCheckVersionUpdate:l}=i;return a.forEach(c=>{r.push({title:$L(c),id:c,key:c})}),r.splice(1,0,{title:"Project",id:"",key:it.LIB_PROJECT_KEY}),[...r]}function FX(e,t,i,r){let n=[],s=[],a={},o=[];return e.forEach(l=>{switch(l.titleAdditional=l.title,l.title){case"Project":{if(!r||!i||!i.uuid)return;l.id=i.uuid,o.push(i.uuid);break}default:}l.id||(l.id="@"+a0(new Date().getTime())),typeof a[l.id]<"u"?(a[l.id]+=1,l.id=l.id+it.LIB_SPLIT_TAG+a[l.id]):a[l.id]=0,t&&t.indexOf(l.id)>=0&&s.push(l.id),n.push(l)}),{treeData:n,projectsIds:o,selectedIds:s}}function ZN(e,t){let i=[],r=[];return u0?r=e:t&&t.length?r=t:r=e,r.forEach(n=>{i.push({title:n.nickname,id:n.uuid,key:it.LIB_TEMAS_KEY})}),i}async function $x(e,t){let i=ZN(e,t);return[{title:"System",id:it.SYSTEMLIB_UUID,key:it.LIB_SYSTEM_KEY},{title:"Project",id:"",key:it.LIB_PROJECT_KEY},{title:"Personal",id:"",key:it.LIB_PERSONAL_KEY},{title:"Favorite",id:it.FAVORITELIB_UUID,key:it.LIB_FAVORITE_KEY},...i]}function QN(e,t,i,r,n){let s=[],a=[],o={},l=[];return e.forEach(c=>{switch(c.title){case"Project":{if(!n||!r||!r.uuid)return;c.id=r.uuid,l.push(r.uuid);break}case"Personal":{if(!i||!i.uuid)return;c.id=i.uuid;break}case"Public":{c.id=it.PUBLICLIB_ALIAS;break}default:}c.id||(c.id="@"+a0(new Date().getTime())),typeof o[c.id]<"u"?(o[c.id]+=1,c.id=c.id+it.LIB_SPLIT_TAG+o[c.id]):o[c.id]=0,t&&t.indexOf(c.id)>=0&&a.push(c.id),s.push(c)}),{treeData:s,projectsIds:l,selectedIds:a}}async function QT(e,t){return await $x(e,t)}function GX(e,t,i,r,n){return QN(e,t,i,r,n)}function e3(e,t,i,r,n,s,a){if(!Sc){let l=QN(e,i,r,n,typeof s<"u"?!!s:a);return Sx(l,t),wx(l)}if(Nx){let l=GX(e,i,r,n,typeof s<"u"?!!s:a);return Sx(l,t),wx(l)}if(Zy){let l=BX(e,i,n,typeof s<"u"?!!s:a);return Sx(l,t),wx(l)}let o=FX(e,i,n,typeof s<"u"?!!s:a);return Sx(o,t),wx(o)}function Sx(e,t){let i=Ga(e.treeData,"key",it.LIB_SYSTEM_KEY);i.index>=0&&e.treeData.splice(i.index,1);let r=Ga(e.treeData,"key",it.LIB_PERSONAL_KEY);r.index>=0&&e.treeData.splice(r.index,1);let n=Ga(e.treeData,"key","project");n.index>=0&&e.treeData.splice(n.index,1);let s=Ga(e.treeData,"key",it.LIB_FAVORITE_KEY);s.index>=0&&e.treeData.splice(s.index,1);let a=Ga(e.treeData,"key","selected");a.index>=0&&e.treeData.splice(a.index,1);let o=Ga(e.treeData,"key","oshwhub");o.index>=0&&e.treeData.splice(o.index,1),e.treeData.sort((l,c)=>(l.title||"").localeCompare(c.title||"")),s.index>=0&&e.treeData.unshift(s.data),n.index>=0&&e.treeData.unshift(n.data),t==="Personal"?u0||r.index>=0&&e.treeData.unshift(r.data):e.selectedIds=e.selectedIds.filter(l=>{var c;return l!==((c=r==null?void 0:r.data)==null?void 0:c.id)}),o.index>=0&&e.treeData.unshift(o.data),i.index>=0&&e.treeData.unshift(i.data),a.index>=0&&e.treeData.push(a.data)}function wx(e){return e.selectedIds.length?e.selectedIds:e.selectedIds.push(e.treeData[0].id),e}async function UX(e,t,i,r,n,s,a,o,l=!0,c=!0,u=!0){let h={username:s.username,uuid:s.uuid},{projectId:d,title:p,isCBB:f}=n,m={uuid:d,title:p,isCBB:f},g=await t3(t,a,o,e,i,l),b=e3(g,r,[],h,m,!l),y=[];for(let E=0;E<b.treeData.length;E++){let S=b.treeData[E];S.id===it.SYSTEMLIB_UUID&&c||S.id===it.FAVORITELIB_UUID&&u||(eE||tE||S.key===it.LIB_PERSONAL_KEY&&(S.title=S.titleAdditional=h.username),S.title&&y.push(S))}return y}var YX=(e=>(e.Normal="Normal",e.D3Model="D3Model",e.AssociateDeviceDialog="associateDeviceDialog",e.Cbb="Cbb",e))(YX||{}),eh=class{};eh.createInitLibList=t3,eh.createFixLibList=UX,eh.filterInitLibList=e3,eh.fetchTeamsLibsFromGVars=ZN,eh.fetchClientTeamsLibsFromGVars=lE,eh.createSourceLibListByWebMode=$x,eh.createSourceLibListByOnlineClientMode=QT,eh.createSourceLibListByOfflineClientMode=$N,eh.createSourceLibListByHalfofflineClientMode=cE;async function t3(e,t,i,r,n,s){let a=[];return e==="Normal"?Sc?Nx?(a=await QT(t,i),s&&vx(a),a):Zy?(a=await cE(t,i),s&&vx(a),a):(a=await $N(t,i),s&&vx(a),a):(a=await $x(t,i),s&&vx(a),a):e==="D3Model"?Sc?Nx?(a=await QT(t,i),a):Zy?(a=await MX(t,i),a):(a=await kX(t,i),a):(a=await $x(t,i),a):[]}function vx(e){let t=Ga(e,"key",it.LIB_PROJECT_KEY);t.index>=0&&e.splice(t.index,1)}var mne=o0(l0());var gne=o0(l0());var yne=o0(l0());var Qo=class{};Qo.D3Model=xc,Qo.Device=om,Qo.Footprint=Rx,Qo.Symbol=JN,Qo.deleteComponentItem=WR,Qo.deleteComponents=aj,Qo.fetchComponentItem=gX,Qo.queryComponentsByTitle=Kx,Qo.pickUpComponentTags2Ids=qR,Qo.pickUpComponentTags2Names=hd,Qo.getDataStrById=E0,Qo.duplicateNameDetection=RX;var qL=class Ep{static async getOldLibByNet(t){try{let{dataStrId:i,dataStr:r}=t;return i||r?{success:!0,result:await E0(t)||""}:{success:!1,message:"Failed to obtain the source code of the existing component library!"}}catch(i){return{success:!1,message:i.message}}}static transform(t,i){let{uuid:r,docType:n}=i,s="";if(n===4){let a=i.isConnectDevice;s=RV(r,t,a)}else n===29?s=GV(r,t,qy.PANEL_LIB):Xx(n)&&(s=BV(r,t).dataStr);return s}static async getOtherLibByNet(t){try{let{isProject:i,uuid:r,path:n,docType:s}=t;if(wH(t)){let c={ignoreDoctypeCheck:!0},u=(await Qo.fetchComponentItem(i,r,n,s,c)).result;t=Object.assign(t,u)}let{history_uuid:a,dataStrId:o,dataStr:l}=t;if(a){let c={path:n,uuid:r,historyUuid:a},u=(await xt.messageBus.rpcCall(lh.COMPONENT.GET_HISTORY,c)).message;if(!u.success){let h=["Conversion component format failed!",u.message];return{success:!1,code:u.code,message:h}}return{success:!0,result:(await xt.messageBus.rpcCall(lh.COMPONENT.GET_HISTORY_DATA,[u.result])).message}}else if(o||l){let c=await Ep.getOldLibByNet(t);if(!c.success){let d=["Conversion component format failed!",c.message];return{success:!1,code:c.code,message:d}}let u=c.result,h=Ep.transform(u,t);return h?{success:!0,result:h}:{success:!1,message:["Conversion component format failed!","Illegal docType!"]}}else return{success:!0,result:""}}catch(i){return{success:!1,message:i.message}}}static async getOtherLibByWorker(t){try{let i=ut();return{success:!0,result:await TR(`/${i._TAB_ID_}/libWorker`).rpcCall("/mgr/libWorker/getDataByType",t)}}catch(i){return{success:!1,message:i.message}}}static async getProjectLibByWorker(t){try{let{path:i,uuid:r,docType:n}=t,{message:s}=await xt.messageBus.rpcCall("/pro-mgr/hasProject",[i]);return s?n===4?{success:!0,result:(await xt.messageBus.rpcCall(ci.FOOTPRINT.GET_STR,[r,i])).message||""}:Xx(n)?{success:!0,result:(await xt.messageBus.rpcCall(ci.SYMBOL.GET_STR,[r,i])).message||""}:{success:!1,message:"Api call error! The api does not exist!"}:{success:!1,message:"Get project library data source Project is not open!"}}catch(i){return{success:!1,message:i.message}}}static async getExtendLib(t){var i,r;let{path:n,uuid:s,docType:a}=t,o=hs.getInstance().getLib(n),l;if(a===4?l=await((i=o==null?void 0:o.footprint)==null?void 0:i.getTransformedDetail(s)):l=await((r=o==null?void 0:o.symbol)==null?void 0:r.getTransformedDetail(s)),!(l!=null&&l.dataStr))return{success:!1,message:["Conversion component format failed!","Failed to obtain the source code of the existing component library!"]};let c;return l.dataStr.trim().startsWith("[")?c=Ep.transform(l.dataStr,t):c=l.dataStr,c?{success:!0,result:c}:{success:!1,message:["Conversion component format failed!","Illegal docType!"]}}static async getProLibSource(t){try{let{isProject:i,path:r}=t;return hs.getInstance().hasLib(r)?Ep.getExtendLib(t):i?Ep.getProjectLibByWorker(t):Ep.getOtherLibByWorker(t)}catch(i){return{success:!1,message:i.message}}}},i3=(e=>(e.INIT_DB="/CommonDB/initDB",e))(i3||{}),r3=(e=>(e.GET="/CommonDB/project/getData",e.GET_ALL="/CommonDB/project/getAllArrData",e))(r3||{}),n3=(e=>(e.GET="/CommonDB/copyAndPaste/getData",e.SET="/CommonDB/copyAndPaste/setData",e.IS_EXIST="/CommonDB/copyAndPaste/isExist",e.GET_DATA_FROM_PCB_CANVAS="/CommonDB/copyAndPaste/getDataFromPcbCanvas",e))(n3||{}),s3=(e=>(e.GET="/CommonDB/copyAndPasteTableCell/getData",e.SET="/CommonDB/copyAndPasteTableCell/setData",e.IS_EXIST="/CommonDB/copyAndPasteTableCell/isExist",e))(s3||{}),a3=(e=>(e.SET="/CommonDB/log/setData",e.DEL="/CommonDB/log/delData",e.DEL_LOTS="/CommonDB/log/delLotsData",e.GET_ALL="/CommonDB/log/getAllArrData",e))(a3||{}),o3=(e=>(e.SET="/CommonDB/Component/log/setData",e.DEL="/CommonDB/Component/log/delData",e.DEL_LOTS="/CommonDB/Component/log/delLotsData",e.GET_ALL="/CommonDB/Component/log/getAllArrData",e))(o3||{}),l3=(e=>(e.SET="/CommonDB/basicLibraryList/addData",e.GET="/CommonDB/basicLibraryList/getData",e.IS_EXIST="/CommonDB/basicLibraryList/isExist",e))(l3||{}),c3=(e=>(e.SET="/CommonDB/clipBoard/addData",e.GET="/CommonDB/clipBoard/getData",e.IS_EXIST="/CommonDB/clipBoard/isExist",e))(c3||{}),u3=(e=>(e.GET="/CommonDB/lockPrj/getData",e.READ_WRITE="/CommonDB/lockPrj/readwriteData",e))(u3||{}),h3=(e=>(e.GET="/CommonDB/prjCache/getData",e.SET="/CommonDB/prjCache/addData",e.DEL="/CommonDB/prjCache/delData",e.DEL_LOTS="/CommonDB/prjCache/delLotsData",e.GET_INDEXS="/CommonDB/prjCache/getAllIndexs",e.GET_COUNT="/CommonDB/prjCache/getCount",e.GET_EARLIEST="/CommonDB/prjCache/getEarliest",e))(h3||{}),I0={COMMON:i3,PROJECT:r3,COPYANDPASTE:n3,COPYANDPASTE_TABLE_CELL:s3,LOG:a3,COMPONENT_LOG:o3,LIB:l3,CLIP_BOARD:c3,LOCK_PROJECT:u3,PROJECT_CACHE:h3},VX=(e=>(e.CREATE="/pro-mg/cbb/create",e.DRAW="/pro-mg/cbb/draw",e.GET_EXPORT="/pro-mg/cbb/getExport",e.GET_TARGET="/pro-mg/cbb/getTarget",e.LIST="/pro-mg/cbb/list",e.SEARCH="/pro-mg/cbb/search",e.PLACE="/pro-mg/cbb/place",e))(VX||{}),HX=(e=>(e.GET="/pro-mg/thumb/get",e.UPLOAD="/pro-mg/thumb/upload",e.DELETE="/pro-mg/thumb/delete",e.LIST="/pro-mg/thumb/list",e))(HX||{}),jX=(e=>(e.CREATE="/pro-mgr/new/cloud/create",e.PROJECT="/pro-mgr/new/cloud/project",e.BOARD="/pro-mgr/new/cloud/board",e.SCHEMATIC="/pro-mgr/new/cloud/schematic",e.SHEET="/pro-mgr/new/cloud/sheet",e.SIMULATION="/pro-mgr/new/cloud/simulation",e.PCB="/pro-mgr/new/cloud/pcb",e.PANEL="/pro-mgr/new/cloud/panel",e))(jX||{}),zX=(e=>(e.BOARD="/pro-mgr/new/local/board",e.SCHEMATIC="/pro-mgr/new/local/schematic",e.SHEET="/pro-mgr/new/local/sheet",e.SIMULATION="/pro-mgr/new/local/simulation",e.PCB="/pro-mgr/new/local/pcb",e.PANEL="/pro-mgr/new/local/panel",e))(zX||{});var XX=(e=>(e.FORCE="/pro-mgr/project/updateData/force",e.SUSPEND="/pro-mgr/project/updateData/suspend",e.RESUME="/pro-mgr/project/updateData/resume",e.GET="/pro-mgr/project/updateData/getLastest",e.IS_PUBLIC="/pro-mgr/project/updateData/isPublic",e.UPDATE_TEAM="/pro-mgr/project/updateData/updateTeam",e))(XX||{}),WX=(e=>(e.UPDATE="/pro-mgr/project/updateData/schematic/update",e.GET="/pro-mgr/project/updateData/schematic/getData",e.MAP="/pro-mgr/project/updateData/schematic/map",e.NOTIFY="/pro-mgr/project/updateData/schematic/notify",e))(WX||{}),qX=(e=>(e.UPDATE="/pro-mgr/project/updateData/sheet/update",e.GET="/pro-mgr/project/updateData/sheet/getData",e.MAP="/pro-mgr/project/updateData/sheet/map",e.NOTIFY="/pro-mgr/project/updateData/sheet/notify",e))(qX||{}),JX=(e=>(e.UPDATE="/pro-mgr/project/updateData/pcb/update",e.GET="/pro-mgr/project/updateData/pcb/getData",e.MAP="/pro-mgr/project/updateData/pcb/map",e.NOTIFY="/pro-mgr/project/updateData/pcb/notify",e))(JX||{}),KX=(e=>(e.UPDATE="/pro-mgr/project/updateData/blockSymbol/update",e.GET="/pro-mgr/project/updateData/blockSymbol/getData",e.MAP="/pro-mgr/project/updateData/blockSymbol/map",e.NOTIFY="/pro-mgr/project/updateData/blockSymbol/notify",e))(KX||{}),$X=(e=>(e.UPDATE="/pro-mgr/project/updateData/symbol/update",e.GET="/pro-mgr/project/updateData/symbol/getData",e.MAP="/pro-mgr/project/updateData/symbol/map",e.NOTIFY="/pro-mgr/project/updateData/symbol/notify",e))($X||{}),ZX=(e=>(e.UPDATE="/pro-mgr/project/updateData/footprint/update",e.GET="/pro-mgr/project/updateData/footprint/getData",e.MAP="/pro-mgr/project/updateData/footprint/map",e.NOTIFY="/pro-mgr/project/updateData/footprint/notify",e))(ZX||{}),QX=(e=>(e.UPDATE="/pro-mgr/project/updateData/device/update",e.GET="/pro-mgr/project/updateData/device/getData",e.MAP="/pro-mgr/project/updateData/device/map",e.NOTIFY="/pro-mgr/project/updateData/device/notify",e))(QX||{});var eW=(e=>(e.PROGRESS="/pro-ui/progressUpdate",e.OPENED_PROJECT="/pro-ui/project/openedProject",e.HAS_UNSAVED="/pro-ui/project/hasUnsaved",e.OPEN="/pro-ui/project/open",e.CLOSE="/pro-ui/project/close",e.ON_OPENED="/pro-ui/project/onOpened",e.ON_FAILED="/pro-mgr/project/onFailed",e.ON_CLOSED="/pro-ui/project/onClosed",e.ADD_HASH="/pro-ui/hash/add/id",e.REMOVE_HASH="/pro-ui/hash/remove/id",e))(eW||{}),tW=(e=>(e.ON_UPDATE="/pro-mgr/project/project/onUpdate",e.UPLOAD_FAILED="/pro-mgr/project/upload/onfailed",e))(tW||{}),iW=(e=>(e.ON_UPDATE="/pro-mgr/project/config/onUpdate",e))(iW||{}),rW=(e=>(e.ON_ADD="/pro-mgr/project/board/onAdd",e.ON_DELETE="/pro-mgr/project/board/onDelete",e.ON_UPDATE="/pro-mgr/project/board/onUpdate",e))(rW||{}),nW=(e=>(e.ON_ADD="/pro-mgr/project/schematic/onAdd",e.ON_DELETE="/pro-mgr/project/schematic/onDelete",e.ON_UPDATE="/pro-mgr/project/schematic/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/schematic/onUpdateTime",e))(nW||{}),sW=(e=>(e.ON_ADD="/pro-mgr/project/sheet/onAdd",e.ON_DELETE="/pro-mgr/project/sheet/onDelete",e.ON_UPDATE="/pro-mgr/project/sheet/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/sheet/onUpdateTime",e))(sW||{}),aW=(e=>(e.ON_ADD="/pro-mgr/project/pcb/onAdd",e.ON_DELETE="/pro-mgr/project/pcb/onDelete",e.ON_UPDATE="/pro-mgr/project/pcb/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/pcb/onUpdateTime",e))(aW||{}),oW=(e=>(e.ON_ADD="/pro-mgr/project/panel/onAdd",e.ON_DELETE="/pro-mgr/project/panel/onDelete",e.ON_UPDATE="/pro-mgr/project/panel/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/panel/onUpdateTime",e))(oW||{}),lW=(e=>(e.ON_ADD="/pro-mgr/project/simulation/onAdd",e.ON_DELETE="/pro-mgr/project/simulation/onDelete",e.ON_UPDATE="/pro-mgr/project/simulation/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/simulation/onUpdateTime",e))(lW||{}),cW=(e=>(e.ON_ADD="/pro-mgr/project/device/onAdd",e.ON_DELETE="/pro-mgr/project/device/onDelete",e.ON_UPDATE="/pro-mgr/project/device/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/device/onUpdateTime",e))(cW||{}),uW=(e=>(e.ON_ADD="/pro-mgr/project/symbol/onAdd",e.ON_DELETE="/pro-mgr/project/symbol/onDelete",e.ON_UPDATE="/pro-mgr/project/symbol/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/symbol/onUpdateTime",e))(uW||{}),hW=(e=>(e.ON_ADD="/pro-mgr/project/footprint/onAdd",e.ON_DELETE="/pro-mgr/project/footprint/onDelete",e.ON_UPDATE="/pro-mgr/project/footprint/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/footprint/onUpdateTime",e))(hW||{}),dW=(e=>(e.ON_ADD="/pro-mgr/project/attr/onAdd",e.ON_DELETE="/pro-mgr/project/attr/onDelete",e.ON_UPDATE="/pro-mgr/project/attr/onUpdate",e))(dW||{}),pW=(e=>(e.ON_ADD="/pro-mgr/project/blob/onAdd",e.ON_DELETE="/pro-mgr/project/blob/onDelete",e.ON_UPDATE="/pro-mgr/project/blob/onUpdate",e))(pW||{}),fW=(e=>(e.ON_ADD="/pro-mgr/project/variant/onAdd",e.ON_DELETE="/pro-mgr/project/variant/onDelete",e.ON_UPDATE_TITLE="/pro-mgr/project/variant/onUpdatetitle",e.ON_UPDATE_NOT_GROUPED="/pro-mgr/project/variant/onUpdateNotGrouped",e.ON_UPDATE_ZINDEX="/pro-mgr/project/variant/onUpdateZIndex",e.ON_ADD_COMPONENT_GROUP="/pro-mgr/project/variant/onAddComponentGroup",e.ON_DELETE_COMPONENT_GROUP="/pro-mgr/project/variant/onDeleteComponentGroup",e.ON_UPDATE_COMPONENT_GROUP_TITLE="/pro-mgr/project/variant/onUpdateComponentGroupTitle",e.ON_UPDATE_COMPONENT_GROUP_ZINDEX="/pro-mgr/project/variant/onUpdateComponentGroupZIndex",e.ON_UPLOAD_COMPONENT_GROUP_INDEX_IN_VARIANT="/pro-mgr/project/variant/onUploadComponentGroupZIndexInVariant",e.ON_DELETE_COMPONENT_GROUP_INDEX_IN_VARIANT="/pro-mgr/project/variant/onDeleteComponentGroupZIndexInVariant",e.ON_UPLOAD_COMPONENT_GROUP_DATA="/pro-mgr/project/variant/onUploadComponentGroupData",e.ON_DELETE_COMPONENT_GROUP_DATA="/pro-mgr/project/variant/onDeleteComponentGroupData",e))(fW||{});var bne=new Error("list is empty");var mW=(e=>(e.ALL_VALUE="@all",e.ALL_TITLE="All",e.ComponentSymbol="2",e.NetflagSymbol="18",e.NetportSymbol="19",e.DrawingSymbol="20",e.NonElectronicSymbol="21",e.OffPageConnectorSymbol="25",e.DiffPairsFlagSymbol="31",e))(mW||{});var gW=class{};gW.syncLoginedUserInfo=e=>{xt.loginedUserUuid=e.uuid};var yW=(e=>(e.PROJECT="project.json",e.DEVICE="device.json",e.SYMBOL="symbol.json",e.FOOTPRINT="footprint.json",e.PANEL_LIB="panel-lib.json",e.PROJECT2="project2.json",e.DEVICE2="device2.json",e.SYMBOL2="symbol2.json",e.FOOTPRINT2="footprint2.json",e.PANEL_LIB2="panel-lib2.json",e))(yW||{});A9();var Ic=typeof window>"u"?!1:/\bpanelBoolDebug\b/.test(ut().location.search),Lm=class{onOriginSide(t){}onIntersect(t,i,r){}onSplitedSide(t){}getX(t,i){let r=t.getX(i);return Number.isNaN(r)?Math.abs(t.start.y-i)>Math.abs(t.end.y-i)?t.end.x:t.start.x:r}onSegment1(t,i,r){if(Ic){let n=new j(this.getX(t,r),r),s=new j(this.getX(i,r),r);this.onSegment(n,t,s,i)}else this.onSegment(t.start,t,i.end,i)}onSegment(t,i,r,n){}onSweep1(t,i,r){if(Ic){let n=new j(this.getX(t,r),r),s=new j(this.getX(i,r),r);this.onSweep(n,t,s,i)}else this.onSweep(t.start,t,i.end,i)}onSweep(t,i,r,n){}onScan(t,i,r,n,s,a){}onResultSide(t){}onDebugSide(t){}};var Ze=(y=>(y.text="text",y.group="group",y.cdot="cdot",y.arc="arc",y.rect="rect",y.circle="circle",y.ellipse="ellipse",y.dimension="dimension",y.dimensionLength="dimensionLength",y.dimensionAngle="dimensionAngle",y.dimensionRadius="dimensionRadius",y.auxiliaryLine="auxiliaryLine",y.auxiliaryPoint="auxiliaryPoint",y.combination="combination",y.obj="obj",y.canvas="canvas",y.unknown="",y.runtime="_runtime",y))(Ze||{}),Om=["combination","group","arc","ellipse","rect","text","obj","dimension","auxiliaryLine","auxiliaryPoint","dimensionLength","dimensionAngle","dimensionRadius"];var Xi=class{};Xi.text="Text",Xi.arc="Elliptical Arc",Xi.rect="Rect",Xi.ellipse="Ellipse",Xi.obj="Image",Xi.group="Shape",Xi.auxiliaryLine="Auxiliary Line",Xi.auxiliaryPoint="Auxiliary Point",Xi.dimension="Smart Dimension",Xi.dimensionLength="Dimension Length",Xi.dimensionAngle="Dimension Angle",Xi.dimensionRadius="Dimension Radius",Xi.combination="Group";var d3=["reference-point","attr-name","attr-locked","attr-fill-color-display","attr-stroke-color-display","attr-stroke-fill-swap","attr-font-style","attr-font-weight","attr-font-underline"];var Di={PANEL_OBJECT_ROOT_NODE:"201",PANEL_OBJECT_LAYER_NODE:"202",PANEL_OBJECT_NODE:"203",PANEL_COMBINATION_ROOT_NODE:"204",PANEL_COMBINATION_OBJECT_NODE:"205"};var p3={1:"Print Layer",2:"Opacity Control Layer",3:"Board Outline Layer",4:"Slot Hole Layer",5:"Glue Cutout Layer",6:"Lighting Simulation Layer"};var NI={3:"#ff0000",4:"#ff0000",5:"#009900",2:"#000000",7:"#000000"};var f3={"Material Boarder Layer":-1,"Print Layer":1,"Opacity Control Layer":2,"Board Outline Layer":3,"Slot Hole Layer":4,"Glue Cutout Layer":5,"Lighting Simulation Layer":6,"Bun Layer":7,"Assist Drawing Layer":8,[-1]:"Material Boarder Layer",1:"Print Layer",2:"Opacity Control Layer",3:"Board Outline Layer",4:"Slot Hole Layer",5:"Glue Cutout Layer",6:"Lighting Simulation Layer",7:"Bun Layer",8:"Assist Drawing Layer"};function m3(e){return/^(pixel|mil|mm|inch)$/i.test(e)}function Qs(e){return Yt(e,"pixel","mm")}function ea(e){return Yt(e,"mm","pixel")}function Yt(e,t,i){if(typeof e=="string"&&(console.error("Plz check code pass number, not string"),arguments.length==2?(i=t,t=e.replace(/^[-+.\d\s]+/,""),e=e.replace(/[^-+.\d\s]+$/,""),e=+e):e=parseFloat(e)),t==i)return e;switch((typeof e!="number"||!isFinite(e))&&console.error(arguments),t==="cm"&&(t="mm",e*=10),i=="cm"&&(i="mm",e*=.1),t+" > "+i){case"mil > pixel":return e*.1;case"mil > mm":return e*.0254;case"mil > inch":return e*.001;case"mm > pixel":return e/.254;case"mm > mil":return e/.0254;case"mm > inch":return e/25.4;case"pixel > mil":return e*10;case"pixel > mm":return e*.254;case"pixel > inch":return e*.01;case"inch > pixel":return e*100;case"inch > mil":return e*1e3;case"inch > mm":return e*25.4;default:throw new Error("err")}}var Ge={adsorbGrid:{visible:!0,gridSize:ea(10),enabled:!0,distanceX:10,distanceY:10,altSnapSize:5,gridType:"not",gridColor:"",bgColor:""},canvas:{originX:0,originY:0,strokeWidth:1,unit:"mm",bgColor:"#FFFFFF",gridColor:"#000000"}};function pd(e,t,i){Ge[e][t]=i}function Rl(e){return navigator.userAgent.indexOf(e)}var fd=Rl("Mac OS")>0,bW=Rl("chromeframe")>0||Rl("x-clock")>0,g3=(Rl("MSIE")>0||Rl("Trident")>=0)&&!bW,y3=Rl("Edge/")>0,Io=Rl("Opera/")===0,mu=Rl("Firefox/")>0,Zoe=mu&&navigator.userAgent.match(/Firefox\/(\d+(\.\d+)?)/)[1],Qoe=Rl("AppleWebKit")>0,A0=Rl("Chrome/")>0&&!g3&&!y3&&!Io&&!mu,ele=A0&&navigator.userAgent.match(/Chrome\/(\d+(\.\d+)?)/)[1],tle=Rl("Safari/")>-1&&!g3&&!y3&&!Io&&!mu&&!A0,ile=Rl("Electron/")>0;function $e(e={},t){return Object.hasOwnProperty.call(e,t)}function b3(e){return new Promise(t=>setTimeout(t,e))}function gu(...e){}function x3(e){if(e.indexOf("rgb")===-1)throw new Error("\u8BF7\u4EE5 rgb \u5F00\u5934");let t=e.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(","),i="#";for(let n=0;n<t.length;n++){var r=Number(t[n]).toString(16);r.length<2&&(r="0"+r),i+=r}return i.toUpperCase()}function E3(e){try{return JSON.parse(e)}catch{return console.error(`parseJSON failed:
`+e),null}}function nl(e,t=0,i){let r,n,s,a,o,l,c=0,u=!1,h=!1,d=!0;if(typeof e!="function")throw new TypeError("Expected a function");t=Number(t)||0,typeof i=="object"&&(u=!!i.leading,h="maxWait"in i,s=h?Math.max(Number(i.maxWait)||0,t):s,d="trailing"in i?!!i.trailing:d);function p(x){let I=r,A=n;return r=n=void 0,c=x,a=e.apply(A,I),a}function f(x){return c=x,o=setTimeout(b,t),u?p(x):a}function m(x){let I=x-l,A=x-c,O=t-I;return h?Math.min(O,s-A):O}function g(x){let I=x-l,A=x-c;return l===void 0||I>=t||I<0||h&&A>=s}function b(){let x=Date.now();if(g(x))return y(x);o=setTimeout(b,m(x))}function y(x){return o=void 0,d&&r?p(x):(r=n=void 0,a)}function E(){o!==void 0&&clearTimeout(o),c=0,r=l=n=o=void 0}function S(){return o===void 0?a:y(Date.now())}function w(){let x=Date.now(),I=g(x);if(r=arguments,n=this,l=x,I){if(o===void 0)return f(l);if(h)return o=setTimeout(b,t),p(l)}return o===void 0&&(o=setTimeout(b,t)),a}return w.cancel=E,w.flush=S,w}function S3(e,t,i){var r=!0,n=!0;if(typeof e!="function")throw new TypeError("Expected a function");return typeof i=="object"&&i&&(r="leading"in i?!!i.leading:r,n="trailing"in i?!!i.trailing:n),nl(e,t,{leading:r,maxWait:t,trailing:n})}function jt(e){if(typeof e!="object"||e===null||e instanceof Date||e instanceof ArrayBuffer)return e;if(Array.isArray(e))return e.map(jt);let t={};for(let i in e)$e(e,i)&&(t[i]=jt(e[i]));return t}var w3={camelize(e){let t=/-(\w)/g;return e.replace(t,(i,r)=>r.toUpperCase())},hyphenate(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}},v3=Object.prototype.toString;function Kn(e){return v3.call(e).slice(8,-1)==="Number"&&!Number.isNaN(e)}function Mt(e){return Ua(e)&&Object.keys(e).length===0}function D0(e){return Ua(e)&&Object.keys(e).length}function Ua(e){return v3.call(e)==="[object Object]"}function C0(e,t){if(Ua(e)){for(let i in e){let r=e[i];if(!C0(r,t==null?void 0:t[i]))return!1}return!0}if(!Array.isArray(e)||!Array.isArray(t))return Object.is(e,t);if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!C0(e[i],t[i]))return!1;return!0}function Vn(e){return e.nextElementSibling?e.nextElementSibling.id:e.parentNode?"<"+e.parentNode.id:""}function T3(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function Kr(...e){if(console.error(...e),xW())throw new Error("Plz Check code")}function xW(){return!1}var Mp={0:0,90:1,180:0,270:-1},MI={0:1,90:0,180:-1,270:0},uE=[1,10,100,1e3],I3="http://www.w3.org/2000/svg",A3="http://www.w3.org/1999/xlink",dh=(function(){var e={svg:I3,xlink:A3};return e[I3]="svg",e[A3]="xlink",e})(),hE=0,C3=1,BI=2,Ya=10,Nl=11,si=1,Ao=6,Ml=7,Co=16,Bl=17,Do=8,kl=9,_o=18,Fl=19,mn=4,Po=12,Gl=13,Ul=5,Lo=14,Yl=15,Dr=2,Vr=3,D3=0,ta={SCH:1,PART:2,PRJ:5,BLOCK_SYMBOL:17,NETFLAG:18,NETPORT:19,SHEET_SYMBOL:20,NONEELEC_SYMBOL:21,PANEL:26,PANEL_LIB:29,PANEL3D:27},dE=200;var pE=1e4,_3=0,ph=4,Sn={drag:"DragTool",draw:"DrawTool",paste:"PasteTool",arrayCopy:"ArrayCopyTool",highlight:"HighlightTool",delete:"Delete",rotate:"Rotate",duplicateTo:"DuplicateTo",lock:"LockControl",eleVisable:"EleVisibleMgr",pasteInPlace:"PasteInPlace"},P3="<...>";var fh="stop-iterate",fE="can-not-select-flag",kI={acrylic:{thickness:["0.8mm","1.0mm","1.5mm","2.0mm","2.5mm","3.0mm"],craft:["Transparent","Black Translucent"],coverColor:["white","black"]},PVC:{thickness:["0.175mm","0.2mm","0.3mm","0.4mm"],craft:["Glossy Transparent","Frosted Translucent"],coverColor:["white","black"]}};function lt(e,t=3,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=uE[t]||Math.pow(10,t)||10;if(i){var n=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(n+e)}else return Math.round(e*r+1e-10)/r}function FI(e=""){return e.replace(/[ ,]{2,}| /g,",").split(",").map(Number)}function mE(e,t){for(let i in t)if($e(t,i)&&e.indexOf(i)!==-1)return!0;return!1}function yu(e){let t={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;","&":"&amp;"};function i(r){return t[r]}return e==null?"":mE(e+"",t)?(e+"").replace(/[<>'"&]/g,i):e}function _0(e){if(!Ac(e))return e;let t={"&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&amp;":"&","&#039;":"'"};function i(r){return t[r]}return mE(e,t)?(e+"").replace(/&([^;]+);/g,i):e}function L3(e){if(typeof e!="string")return e;var t={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"};function i(r){return t[r]}return mE(e,t)?(e+"").replace(/[<>'"]/g,i):e}function Ac(e){return typeof e=="string"}function GI(e){return Ac(e)&&e.length!==0}function Cc(e){return e?e.trim?e.trim():e.replace(/^\s+|\s+$/g,""):""}function UI(e){return e.indexOf(".")>0?e.replace(/\.?0*$/,""):e}function YI(e){return e.indexOf(".")<0?e+"0":e.replace(/\.(\d)/,"$1.").replace(/^0+(?!\.)/,"").replace(/\.$/,"")}function VI(e){return e.indexOf(".")<0?e.replace(/\d$/,".$&").replace(/^\./,"0."):e.replace(/(\d)\./,".$1").replace(/^\./,"0.")}function te(e,t,i){if(!e)return null;var r=arguments.length,n,s,a,o;if(e.tagName){if(typeof t=="string")return r===2?e.getAttribute(t):(t.indexOf(":")>0?(s=t.substr(0,t.indexOf(":")),s in dh&&(a=t.substr(s.length+1),A0?e.setAttributeNS(dh[s],t,i):e.setAttributeNS(dh[s],a,i))):(e.setAttribute(t,i),(i===""||i===null||i===void 0)&&(t==="transform"&&e.setAttribute(t,""),e.removeAttribute(t))),e);for(n in t)$e(t,n)&&(n.indexOf(":")>0?(s=n.substr(0,n.indexOf(":")),s in dh&&(a=n.substr(s.length+1),t[n]===""?e.hasAttributeNS(dh[s],a)&&e.removeAttributeNS(dh[s],a):A0?e.setAttributeNS(dh[s],n,t[n]):e.setAttributeNS(dh[s],a,t[n]))):t[n]===""||t[n]==null?e.hasAttribute(n)&&(n==="transform"&&e.setAttribute(n,""),e.removeAttribute(n)):e.setAttribute(n,t[n]));return e}if(Array.isArray(e)||e instanceof NodeList||e instanceof HTMLCollection||Io&&typeof e.length=="number"){if(typeof t=="string"&&r==2)return e[0]?te(e[0],t):null;if(r==2)for(o=0;o<e.length;o++)te(e[o],t);else if(r>=3)for(o=0;o<e.length;o++)te(e[o],t,i);return e}}function Vs(e,t){if(!e)return!1;if(e.classList)return e.classList.contains(t);let i=typeof e.className=="object"?e.className.baseVal:e.className;return t&&i&&i.split(/\s+/).indexOf(t)>=0}function ia(e,t,i){if(!e||!t)return;let r=t?t.split(/\s+/):[],n=i?"add":i===!1?"remove":"toggle";if(e.classList&&e.classList.toggle){for(let l=0;l<r.length;l++)r[l]&&e.classList[n](r[l]);return}let s=typeof e.className=="object",a=s?e.className.baseVal:e.className,o=a?a.split(/\s+/):[];for(let l=0;l<r.length;l++)if(r[l]){let c=o.indexOf(r[l]);c<0?n!="remove"&&o.push(r[l]):n!="add"&&o.splice(c,1)}a=o.join(" "),s?e.className.baseVal=a:e.className=a}function bu(e,t){if(!e||!t)return;let i=t?t.split(/\s+/):[],r;if(e.classList)for(r=0;r<i.length;r++)i[r]&&e.classList.add(i[r]);else{let n=typeof e.className=="object",s=n?e.className.baseVal:e.className,a=s?s.trim().split(/\s+/):[];for(r=0;r<i.length;r++)i[r]&&a.indexOf(i[r])<0&&a.push(i[r]);s=a.join(" "),n?e.className.baseVal=s:e.className=s}}function Oo(e,t){let i=t?t.split(/\s+/):[];if(e.classList)for(let r=0;r<i.length;r++)i[r]&&e.classList.remove(i[r]);else{let r=typeof e.className=="object",n=r?e.className.baseVal:e.className,s=n?n.trim().split(/\s+/):[];for(let a=0;a<i.length;a++){let o=s.indexOf(i[a]);o>=0&&s.splice(o,1)}n=s.join(" "),r?e.className.baseVal=n:e.className=n}}function le(e){return!e||self.IN_WORKER?(console.error("no id",e,"Plz check code"),null):document.getElementById(e)}function Hr(e,t){if(!e||e=="#")return[];try{return(t||document).querySelectorAll(e)}catch{return[]}}function _r(e,t){if(!e||e=="#")return null;try{return(t||document).querySelector(e)}catch{return null}}function O3(e,t){var i=e&&e.cloneNode(t!==!1);return i}function HI(e,t){var i=+e;if(t=t!="-"?"+":"-",i<=0||isNaN(i))return"100";if(i<.1||i==.1&&t=="-")return"0.1";if(i>H.zoomRatio.max||i==H.zoomRatio.max&&t=="+")return H.zoomRatio.max+"";e=i<1?(10+i+"").substr(1):i+"",e=e.replace(/([1-9]\.?\d)(.*)/,function(l,c,u){return c+u.replace(/[1-9]/g,"0")}),e.match(/[1-9]$/)&&(e=e.indexOf(".")<0?e+".0":e+"0");var r=e.match(/([1-9])\.?(\d)/),n=r[1]+r[2],s="--,10,14,20,27,38,54,75,AA".split(","),a,o;for(fd&&(s="--,10,12,15,17,20,25,30,35,40,50,60,80,90,AA".split(",")),a=1;a<s.length;a++)if(n==s[a]){o=s[t=="+"?a+1:a-1];break}else if(n<s[a]){o=s[t=="+"?a:a-1];break}return o=="AA"?(o=s[1],e=e.replace(/([1-9])(\.?)(\d)/,o[0]+"$2"+o[1]),e=YI(e)):o=="--"?(o=s[s.length-2],e=e.replace(/([1-9])(\.?)(\d)/,o[0]+"$2"+o[1]),e=VI(e)):e=e.replace(/([1-9])(\.?)(\d)/,o[0]+"$2"+o[1]),UI(e)}function Et(e,t){let i=document.createElementNS("http://www.w3.org/2000/svg",e);return t&&te(i,t),i}var Vl="ignore-me";function R3(){let e=[],t=H.gCanvas.children;for(let i=0,r=t.length;i<r;i++){let n=t[i];if(n.nodeType===Node.ELEMENT_NODE&&n.id){if(Vs(n,Vl))continue;e.push(n.id)}}return e}var Ile=Math.PI*2,Ale=Math.PI/2,Cle=Math.sin(Math.PI/180),gE=class{constructor(t,i){this.x=+t||0,this.y=+i||0}toString(){return lt(this.x,4)+"_"+lt(this.y,4)}};function yE(e,t){if(!e||typeof e!="string")return"";var i=/\d+\.\d{12,}/g,r=uE[t]||Math.pow(10,t)||10;return e.replace(i,function(n){return(Math.round(parseFloat(n)*r+1e-10)/r).toString()})}function Dc(e,t,i){return e>=i.x&&e<=i.x+i.width&&t>=i.y&&t<=i.y+i.height}function Rm(e,t){return Dc(e.x,e.y,t)&&Dc(e.x+e.width,e.y,t)&&Dc(e.x,e.y+e.height,t)&&Dc(e.x+e.width,e.y+e.height,t)}function N3(e,t){var i=Math.max(e.x+e.width,t.x+t.width),r=Math.max(e.y+e.height,t.y+t.height),n=Math.min(e.x,t.x),s=Math.min(e.y,t.y);return{x:n,y:s,width:i-n,height:r-s}}function M3(e,t){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function B3(e,t){for(var i=e.points,r=i.length||i.numberOfItems,n=0;n<r;n++)if(Dc(i.getItem(n).x,i.getItem(n).y,t))return!0;var s={x1:t.x,y1:t.y,x2:t.x+t.width,y2:t.y+t.height},a,o,l,c,u,h,d,p;for(n=1;n<r;n++)if(a={x1:i.getItem(n-1).x,y1:i.getItem(n-1).y,x2:i.getItem(n).x,y2:i.getItem(n).y},o=a.x2-a.x1,l=a.y2-a.y1,c={},o>0?(c.x1=a.x1,c.x2=a.x2):(c.x1=a.x2,c.x2=a.x1),l>0?(c.y1=a.y1,c.y2=a.y2):(c.y1=a.y2,c.y2=a.y1),!(c.x1>s.x2||c.x2<s.x1||c.y1>s.y2||c.y2<s.y1)&&(u=l*(s.x1-a.x1)-o*(s.y1-a.y1),h=l*(s.x1-a.x1)-o*(s.y2-a.y1),d=l*(s.x2-a.x1)-o*(s.y1-a.y1),p=l*(s.x2-a.x1)-o*(s.y2-a.y1),!(u>0&&h>0&&d>0&&p>0)&&!(u<0&&h<0&&d<0&&p<0)))return!0;return!1}function Nm(e,t,i){var r=e.x,n=e.y,s=t.x,a=t.y,o=i.x,l=i.y,c=s-r,u=a-n,h=c*c+u*u;if(h===0)return(o-r)*(o-r)+(l-n)*(l-n);var d=((o-r)*c+(l-n)*u)/h,p=r+d*c,f=n+d*u,m=p-o,g=f-l;return m*m+g*g}function bE(e,t,i,r){var n=e.x,s=e.y,a=t.x,o=t.y,l=i.x,c=i.y,u=r.x,h=r.y,d=a-n,p=o-s,f=l-u,m=c-h,g=p*f-d*m;if(!g)return null;var b=(d*f*(c-s)-l*d*m+n*p*f)/g,y=(p*m*(l-n)-c*p*f+s*d*m)/-g;return{x:b,y}}function io(e,t,i,r,n,s){return Math.pow(i-e,2)/Math.pow(n,2)+Math.pow(r-t,2)/Math.pow(s,2)}function ra(e,t,i){var r,n=+t.x,s=+t.y,a=+i.x,o=+i.y,l=+e.x,c=+e.y,u=a-n,h=o-s,d=l-n,p=c-s,f,m,g,b,y,E;return u===0&&h===0?{d:Math.sqrt(d*d+p*p),point:{x:n,y:s}}:(r=(d*u+p*h)/(u*u+h*h),r<0?{d:Math.sqrt(d*d+p*p),point:{x:n,y:s}}:r>1?(f=l-a,m=c-o,{d:Math.sqrt(f*f+m*m),point:{x:a,y:o}}):(y=n+r*u,E=s+r*h,g=l-y,b=c-E,{d:Math.sqrt(g*g+b*b),point:{x:y,y:E}}))}function Ro(e,t,i,r){let n=e-i,s=t-r;return n*n+s*s}function Hl(e,t,i,r){return Math.sqrt(Ro(e,t,i,r))}function P0(e,t){return Hl(e.x,e.y,t.x,t.y)}function na(e,t,i,r){if(t=+t,i=+i,r=+r,t=tr(t),t===0)return e.slice(0);let n=e.map(d=>+d),s=n.length;$e(Mp,t)||(Mp[t]=Math.sin(t*Math.PI/180),MI[t]=Math.cos(t*Math.PI/180));var a=Mp[t],o=MI[t];for(let d=0;d<s;d+=2){var l=n[d],c=n[d+1],u=l-i,h=c-r;n[d]=i+o*u-a*h,n[d+1]=r+o*h+a*u}return n}function md(e,t,i){var r=Math.sin(i),n=Math.cos(i),s=e[0]-t[0],a=e[1]-t[1];return[s*n-a*r+t[0],a*n+s*r+t[1]]}function tr(e){return e<0?(360+e%360)%360:e>=360?e%360:e}function ni(e,t,i=10**-3){let r=e-t;return(r>0?r:-r)<i}function k3(e){return ni(e,0)?0:e}function sa(e,t){let i=e.x-t.x,r=e.y-t.y,n=.01;return Math.abs(i)<n&&Math.abs(r)<n}function xE(e,t,i){var r=e.x-t.x,n=e.y-t.y,s=i.x-t.x,a=i.y-t.y,o=r*a-n*s,l=r*s+n*a,c=Math.sqrt(r*r+n*n),u=Math.sqrt(s*s+a*a),h=l/(c*u);return h=h>1?1:h<-1?-1:h,Math.acos(h)}function sl(e,t,i,r,n){return Math.pow(e-i,2)+Math.pow(t-r,2)<=Math.pow(n,2)}function mh(e,t){typeof e=="string"&&(e={x:+e.split(" ")[0],y:+e.split(" ")[1]});for(var i=e.x,r=e.y,n=!1,s=0,a=t.length,o=a-1;s<a;o=s,s++){typeof t[s]=="string"&&(t[s]={x:+t[s].split(" ")[0],y:+t[s].split(" ")[1]});var l=t[s].x,c=t[s].y,u=t[o].x,h=t[o].y;if(l==i&&c==r||u==i&&h==r)return!0;if(c<r&&h>=r||c>=r&&h<r){var d=l+(r-c)*(u-l)/(h-c);if(d==i)return!0;d>i&&(n=!n)}}return n}function EW(e,t,i){var r=u(e)&&u(t)&&u(i);if(!r)return console.warn("Bad arguments"),null;var n=t.x-i.x>0?t.x:i.x,s=t.y-i.y>0?t.y:i.y,a=t.x-i.x>0?i.x:t.x,o=t.y-i.y>0?i.y:t.y,l=e.x,c=e.y;return l<=n+.001&&l>=a-.001&&c<=s+.001&&c>=o-.001;function u(h){return h?(h.x=Number(h.x),h.y=Number(h.y),isNaN(h.x)||isNaN(h.y)?(console.warn("Can not convert to Number, NaN found"),!1):!0):(console.warn("Empty input!"),!1)}}function jI(e,t){var i=Math.cos(t),r=Math.sin(t);return{x:e.x*i+e.y*r,y:e.y*i-e.x*r}}function SW(e,t){return{a:e.y-t.y,b:t.x-e.x,c:e.x*t.y-t.x*e.y}}function F3(e,t,i,r,n,s){let{a,b:o,c:l}=SW({x:i,y:r},{x:n,y:s});return{x:(o*o*e-a*o*t-a*l)/(a*a+o*o),y:(-a*o*e+a*a*t-o*l)/(a*a+o*o)}}function xu(e,t,i){for(var r=!1,n,s,a=0,o=t.length-1;a<t.length;o=a++){if(n=t[a],s=t[o],wW(e,n,s))return!i;n.y>e.y!=s.y>e.y&&e.x<(e.y-n.y)*(n.x-s.x)/(n.y-s.y)+n.x&&(r=!r)}return r}function wW(e,t,i){return EW(e,t,i)?ni((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}function G3(e,t){return Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))}function U3(e,t,i,r,n){n||(n=0);var s=(e.x-i.x)*(t.y-i.y)-(e.y-i.y)*(t.x-i.x),a=(e.x-r.x)*(t.y-r.y)-(e.y-r.y)*(t.x-r.x);if(s*a>=n)return!1;var o=(i.x-e.x)*(r.y-e.y)-(i.y-e.y)*(r.x-e.x),l=o+s-a;if(o*l>=n)return!1;var c=o/(a-s),u=c*(t.x-e.x),h=c*(t.y-e.y);return{x:e.x+u,y:e.y+h}}function Y3(e,t,i,r,n,s,a,o,l){var c=Math.PI*2,u=Math.sin(n),h=Math.cos(n),d=(e-o)/2,p=(t-l)/2,f=(e+o)/2,m=(t+l)/2,g=h*d+u*p,b=h*p-u*d,y=g*g/(i*i)+b*b/(r*r);y>1&&(i=i*Math.sqrt(y),r=r*Math.sqrt(y));var E=i*r,S=i*b,w=r*g,x=S*S+w*w;x||Kr("start point can not be same as end point");var I=Math.sqrt(Math.abs((E*E-x)/x));s==a&&(I=-I);var A=I*S/r,O=-I*w/i;let R=h*A-u*O+f,M=u*A+h*O+m;var F=(g-A)/i,G=(g+A)/i,V=(b-O)/r,q=(b+O)/r;let C=L(1,0,F,V),N=L(F,V,-G,-q);for(;N>c;)N-=c;for(;N<0;)N+=c;(a==!1||a==0)&&(N-=c);let T=C+N;for(;T>c;)T-=c;for(;T<0;)T+=c;function L(P,B,U,X){var J=P*U+B*X,ne=Math.sqrt((P*P+B*B)*(U*U+X*X)),fe=Math.acos(J/ne);return P*X-B*U<0&&(fe=-fe),fe}return{cx:R,cy:M,startAngle:C,deltaAngle:N,endAngle:T}}function V3(e){return e/180*Math.PI}function L0(e){if(e=e.trim(),e[0]!=="M")return null;let t=e.match(/[Ll]\s*(-?\d+(?:\.\d+)?(?:\s+|,)-?\d+(?:\.\d+)?)/);t&&(e=e.replace(t[0],"").replace("  "," ").replace("Z","").replace("z",""));var i=e.slice(1).split("A");if(i.length!==2)return console.warn("Cannot handle multi arc!"),null;var r=i[0].trim().split(",").reduce(function(a,o){return a.concat(o.trim().split(" "))},[]),n=i[1].trim().split(",").reduce(function(a,o){return a.concat(o.trim().split(" "))},[]);if(n.length!==7)return console.warn("Bad Arc arguments!"),null;let s={M:{x:Number(r[0]),y:Number(r[1])},A:{rx:Number(n[0]),ry:Number(n[1]),rotation:Number(n[2]),largeArc:Number(n[3]),clockwise:Number(n[4]),x:Number(n[5]),y:Number(n[6])}};if(t){let a=t[1].split(/[,\s]+/);s.L={x:Number(a[0]),y:Number(a[1])}}return s}function EE(e){typeof e=="string"&&(e=L0(e));var t=e.M,i=e.A,r=e.A.rx,n=Math.atan2(i.y-t.y,i.x-t.x),s=jI(t,n),a=jI(i,n),o=Hl(s.x,s.y,a.x,a.y)/2;r<o&&(r=o);var l=Math.sqrt(r*r-o*o),c=e.A.largeArc===e.A.clockwise?1:-1,u={x:s.x+o,y:s.y-l*c};return jI(u,-n)}function H3(e){for(var t=[],i=e.numberOfItems,r,n=0;n<i;n++)r=e.getItem(n),t[n]=new gE(r.x,r.y);return t}function O0(e){let t=[];if(!e)return t;let i=FI(e),r=i.length-1;for(let n=0;n<r;n+=2)t[n/2]=new gE(i[n],i[n+1]);return t}function j3(e,t){return e^=t,t^=e,e^=t,[e,t]}var R0=Object.freeze({});function N0(e){return Object.prototype.toString.call(e).slice(8,-1)==="Set"}function ft(e){return e==null}function Va(e){return e===void 0}function Bp(e){return typeof e=="function"}function ro(e,t){if(Array.isArray(e)){for(let i=0,r=e.length;i<r;i++)if(t(i,e[i],i)===!1)return}else if(typeof e=="object"&&e!==null){let i=0;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];if(t(r,n,i)===!1)return;i++}}}function SE(e,t=1){return t>0?e.reduce((i,r)=>i.concat(Array.isArray(r)?SE(r,t-1):r),[]):e.slice()}var zI=Object.freeze([]);function XI(e){return Array.isArray(e)||e&&typeof e=="object"&&Object.prototype.toString.call(e)!="[object String]"&&typeof e.length=="number"&&e.length>=0&&e.length<4294967296&&e.length%1===0}function jl(e){return Array.isArray(e)}var vW=Object.create,NM=Object.defineProperty,TW=Object.getOwnPropertyDescriptor,IW=Object.getOwnPropertyNames,AW=Object.getPrototypeOf,CW=Object.prototype.hasOwnProperty,z3=(e=>typeof xo<"u"?xo:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof xo<"u"?xo:t)[i]}):e)(function(e){if(typeof xo<"u")return xo.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),nr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),DW=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of IW(t))!CW.call(e,n)&&n!==i&&NM(e,n,{get:()=>t[n],enumerable:!(r=TW(t,n))||r.enumerable});return e},Qm=(e,t,i)=>(i=e!=null?vW(AW(e)):{},DW(t||!e||!e.__esModule?NM(i,"default",{value:e,enumerable:!0}):i,e)),i1=nr((e,t)=>{"use strict";var i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a=(D,z)=>{for(var $ in z)i(D,$,{get:z[$],enumerable:!0})},o=(D,z,$,K)=>{if(z&&typeof z=="object"||typeof z=="function")for(let ee of n(z))!s.call(D,ee)&&ee!==$&&i(D,ee,{get:()=>z[ee],enumerable:!(K=r(z,ee))||K.enumerable});return D},l=D=>o(i({},"__esModule",{value:!0}),D),c={};a(c,{BroadcastChannelMessageBus:()=>xe,MessageBus:()=>T,MessageBus2:()=>ne,MessageBusTask:()=>N,MessageBusTask2:()=>X,WindowMessageBridge:()=>C,WorkerMessageBridge:()=>q,createBroadcastP2PStream:()=>vt,createBufferedByteBufferStream:()=>je,createBufferedStream:()=>Ne,createBufferedStringStream:()=>nt,dropP2PStream:()=>Bt,flowRead:()=>ze,flowWrite:()=>Ti}),t.exports=l(c);var u=class{constructor(D=1.5){this.growthFactor=D,this.capacity=10,this.buffer=new Array(this.capacity),this.head=0,this.tail=0,this.count=0}enqueue(D){if(this.count===this.capacity){let z=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,z);let $=new Array(z);for(let K=0;K<this.count;K++)$[K]=this.buffer[(this.head+K)%this.capacity];this.buffer=$,this.head=0,this.tail=this.count,this.capacity=z}this.buffer[this.tail]=D,this.tail=(this.tail+1)%this.capacity,this.count++}dequeue(){if(this.isEmpty())return;let D=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,D}peek(){return this.buffer[this.head]}isEmpty(){return this.count===0}clear(){this.buffer.length=0,this.head=0,this.tail=0,this.count=0}},h=new ArrayBuffer(8),d=new Float64Array(h),p=new Uint32Array(h),f=new Uint16Array(h),m=ArrayBuffer;try{m=self.HTMLImageElement||m}catch{}var g=typeof SharedArrayBuffer<"u";function b(D){if(typeof D!="object"||D===null||D instanceof Date||D instanceof ArrayBuffer||g&&D instanceof SharedArrayBuffer||D instanceof Blob||D instanceof FormData||D instanceof Function||D instanceof Uint8ClampedArray||D instanceof m)return D;if(Array.isArray(D))return D.map(b);{let z={};for(let $ in D)Object.hasOwnProperty.call(D,$)&&(z[$]=b(D[$]));return z}}function y(D,z){return E(D,z,()=>[])}function E(D,z,$){let K=D[z];return K!==void 0||(K=$(z),D[z]=K),K}var S=class{constructor(D){this.maxResources=D,this.idle=new u,this.isClosed=!1,this.resources=D}acquire(D){this.isClosed?Promise.resolve(!1).then(D):this.resources>0?(this.resources--,Promise.resolve(!0).then(D)):this.idle.enqueue(D)}acquireSync(){return new Promise(D=>{this.acquire(D)})}release(){if(!this.isClosed){let D=this.idle.dequeue();D?Promise.resolve(!0).then(D):this.resources++}}close(){if(!this.isClosed)for(this.isClosed=!0;!this.idle.isEmpty();){let D=this.idle.dequeue();Promise.resolve(!1).then(D)}}};function w(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global}function x(D,z){let $=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===z&&(D.splice(ee,1),ee--,K--,$++);return $}var I=w(),A=I.WeakRef||(D=>D);function O(D){if(D!=null){if(typeof D=="object")return new A(D);console.error(D,D instanceof Object,typeof D);return}}function R(D){return D==null?void 0:D.deref()}var M="_MSG_BUS_RPC_",F=300*1e3,G=(D=>(D.PUBLISH="publish",D.SUBSCRIBE="subscribe",D.PUSH="push",D.PULL="pull",D))(G||{}),V=class{constructor(D){this.bus=D}processRemoteMessage(D,z){let $=O(z),K=D.topic,ee=D.type,pe=D.message;switch(ee){case"pull":this.bus.pull(K,ce=>{this.push(K,ce,R($))});break;case"subscribe":this.bus.subscribe(K,ce=>{this.publish(K,ce,R($))});break;case"publish":this.bus.publish(K,pe,this,R($));break;case"push":this.bus.push(K,pe,this,R($));break;default:console.debug("unknown message type "+ee)}}rpcCall(D,z,$,K=F){let ee=O($),pe=new Promise(ce=>{let Be=this.bus.uniqueRpcTopic(D);this.publish(D,{message:z,reply:Be},R(ee)),this.bus.pull(Be,(st,pt,tt)=>{ce({message:st,bridge:pt,source:O(tt)})})});return K>0?Promise.race([pe,new Promise((ce,Be)=>{setTimeout(Be,K)})]):pe}},q=class extends V{constructor(D,z){super(D),this.worker=z,z.onmessage=$=>{this.processRemoteMessage($.data,void 0)}}publish(D,z){this.postMessage(D,"publish",z)}subscribe(D){this.postMessage(D,"subscribe",null)}push(D,z){this.postMessage(D,"push",z)}pull(D){this.postMessage(D,"pull",null)}rpcCall(D,z,$=F){return super.rpcCall(D,z,void 0,$)}postMessage(D,z,$){let K={topic:D,type:z,message:$};this.worker.postMessage(K)}discard(){this.worker.terminate()}},C=class extends V{constructor(D){super(D),window.addEventListener("message",z=>{this.processRemoteMessage(z.data,z.source)},!1)}publish(D,z,$){this.postMessage(D,"publish",z,$)}subscribe(D,z){if(z===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(D,"subscribe",null,z)}push(D,z,$){this.postMessage(D,"push",z,$)}pull(D,z){if(z===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(D,"pull",null,z)}postMessage(D,z,$,K){let ee={topic:D,type:z,message:$};K&&K.postMessage(ee,"*")}},N=class{constructor(D){this.isRunning=!0,this.callback=D}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}execute(D,z,$,K){try{D=K?D:b(D),this.callback(D,z,$)}catch(ee){console.error(ee)}}},T=class{constructor(D=!1){this.subscribed={},this.pulled={},this.pushed={},this.uuid=crypto.randomUUID().replace(/-/g,""),this.rpcTicket=0,this.unsafe=D}uniqueRpcTopic(D){return`${M}-${D}-${this.uuid}-${this.rpcTicket++}`}publish(D,z,$,K){let ee=this.subscribed[D];if(ee){let pe;for(let ce of ee)ce.running()?ce.execute(z,$,K,this.unsafe):(pe=pe||new Array,pe.push(ce));if(pe)for(let ce of pe)x(ee,ce)}else console.debug("no sub on topic: "+D)}subscribe(D,z){let $=new N(z);return y(this.subscribed,D).push($),$}push(D,z,$,K){let ee=!1,pe=this.pulled[D];if(pe){for(;pe.length>0;){let ce=pe.shift();if(ce.running()){ce.execute(z,$,K,this.unsafe),ee=!0;break}}pe.length===0&&delete this.pulled[D]}ee||y(this.pushed,D).push({message:z,bridge:$,source:O(K)})}pull(D,z){let $=new N(z),K=this.pushed[D];if(K){let ee=K.shift();$.execute(ee.message,ee.bridge,R(ee.source),this.unsafe),K.length===0&&delete this.pushed[D]}else y(this.pulled,D).push($);return $}pullA(D){return new Promise(z=>{this.pull(D,($,K,ee)=>{z({message:$,bridge:K,source:O(ee)})})})}rpcService(D,z){this.subscribe(D,($,K,ee)=>{let{message:pe,reply:ce}=$;try{let Be=z(pe);if(Be instanceof Promise){let st=O(ee);Be.then(pt=>{this.rpcReply(pt,ce,K,R(st))},pt=>{console.error(pt),this.rpcReply(void 0,ce,K,R(st))})}else this.rpcReply(Be,ce,K,ee)}catch(Be){console.error(Be),this.rpcReply(void 0,ce,K,ee)}})}rpcCall(D,z,$=F){let K=new Promise(ee=>{let pe=this.uniqueRpcTopic(D);this.publish(D,{message:z,reply:pe}),this.pull(pe,(ce,Be,st)=>{ee({message:ce,bridge:Be,source:O(st)})})});return $>0?Promise.race([K,new Promise((ee,pe)=>{setTimeout(pe,$)})]):K}rpcReply(D,z,$,K){$?$.push(z,D,K):this.push(z,D)}},L="_MSG_BUS_RPC_";function P(D,z){let $=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===z&&(D.splice(ee,1),ee--,K--,$++);return $}function B(D,z){return U(D,z,()=>[])}function U(D,z,$){let K=D[z];return K!==void 0||(K=$(z),D[z]=K),K}var X=class{constructor(D,z){this.callback=D,this.unsafe=z,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(D){try{D=this.unsafe?D:b(D),this.callback(D)}catch(z){console.error(z)}}},J=class{constructor(D=crypto.randomUUID()){this.uuid=D,this.rpcTicket=0}subscribeOnce(D,z){let $=this.subscribe(D,K=>{$.cancel(),z(K)});return $}pullA(D){return new Promise(z=>{this.pull(D,z)})}rpcService(D,z){let $=K=>{try{let{message:ee,replyTopic:pe}=K;try{let ce=z(ee);ce instanceof Promise?ce.then(Be=>{this.publish(pe,{success:!0,result:Be})}).catch(Be=>{console.error(Be),this.publish(pe,{success:!1,err:String(Be)})}):this.publish(pe,{success:!0,result:ce})}catch(ce){this.publish(pe,{success:!1,err:String(ce)})}}finally{this.pull(D,$)}};this.pull(D,$)}rpcCall(D,z,$=0){let K=new Promise((ee,pe)=>{let ce=`${L}-${D}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(ce,Be=>{Be.success?ee(Be.result):pe(new Error(Be.err))}),this.push(D,{message:z,replyTopic:ce})});return $>0?Promise.race([K,new Promise((ee,pe)=>{setTimeout(pe,$)})]):K}},ne=class extends J{constructor(D=!1){super(),this.unsafe=D,this.subscribed={},this.pulled={},this.pushed={}}publish(D,z){let $=this.subscribed[D];if($){let K;for(let ee of $)ee.running()?ee.execute(z):(K=K||new Array,K.push(ee));if(K)for(let ee of K)P($,ee)}}subscribe(D,z){let $=new X(z,this.unsafe);return B(this.subscribed,D).push($),$}push(D,z){let $=!1,K=this.pulled[D];if(K){for(;K.length>0;){let ee=K.shift();if(ee&&ee.running()){ee.execute(z),$=!0;break}}K.length===0&&delete this.pulled[D]}$||B(this.pushed,D).push(z)}pull(D,z){let $=new X(z,this.unsafe);return this.repull(D,$),$}repull(D,z){let $=this.pushed[D];if($){let K=$.shift();K&&(z.execute(K),$.length===0&&delete this.pushed[D])}else B(this.pulled,D).push(z)}},fe=class extends J{constructor(D=crypto.randomUUID()){super(D),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(D,z){console.debug("BC",this.uuid,"PUBLISH",D,z),this.broadcastPublish(D,z)}subscribe(D,z){console.debug("BC",this.uuid,"SUBSCRIBE",D);let $=new X(z,!0);return B(this.subscribed,D).push($),$}push(D,z){let $=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",D,`(${$})`,z),B(this.pushed,D).push({id:$,message:z}),this.broadcastPushedHeadMessage(D)}pull(D,z){console.debug("BC",this.uuid,"PULL",D);let $=new X(z,!0);return B(this.pulled,D).push($),this.broadcastWhoHas(D),$}broadcastPushedHeadMessage(D){let z=this.pushed[D];z&&z[0]&&this.broadcastIHave(D,z[0].id)}onReceivedPublish(D,z,$){console.debug("BCMSG(",this.uuid,")","from",D,"PUBLISH",z,"message",$);let K=this.subscribed[z];if(K){let ee;for(let pe of K)pe.running()?pe.execute($):(ee=ee||new Array,ee.push(pe));if(ee)for(let pe of ee)P(K,pe);K.length===0&&delete this.subscribed[z]}}onReceivedWhoHas(D,z){console.debug("BCMSG(",this.uuid,")","from",D,"WHOHAS",z),this.broadcastPushedHeadMessage(z)}onReceivedIHave(D,z,$){console.debug("BCMSG(",this.uuid,")","from",D,"IHAVE",z,"id",$);let K=this.pulled[z];if(K){let ee;for(let pe of K)if(pe.running()){this.broadcastINeed(z,D,$);break}else ee=ee||new Array,ee.push(pe);if(ee)for(let pe of ee)P(K,pe);K.length===0&&delete this.pulled[z]}}onReceivedINeed(D,z,$,K){if(console.debug("BCMSG(",this.uuid,")","from",D,"INEED",z,"source",$,"id",K),this.uuid===$){let ee=this.pushed[z];if(ee&&ee[0]&&ee[0].id===K){let{message:pe}=ee.shift();this.broadcastIGive(z,K,D,pe),this.broadcastPushedHeadMessage(z),ee.length===0&&delete this.pushed[z]}}}onReceivedIGive(D,z,$,K,ee){console.debug("BCMSG(",this.uuid,")","from",D,"IGIVE",z,"id",$,"target",K,"message",ee);let pe=this.pulled[z];if(pe&&this.uuid===K){let ce=!1;for(;pe.length>0;){let Be=pe.shift();if(Be.running()){Be.execute(ee),ce=!0;break}}ce||this.push(z,ee),pe.length===0&&delete this.pulled[z]}}},xe=class extends fe{constructor(D,z=crypto.randomUUID()){super(z),this.bc=new BroadcastChannel(D),this.bc.onmessage=$=>{this.onMessage($.data)}}onMessage(D){let{type:z,uuid:$,topic:K}=D;switch(z){case"PUBLISH":{let{message:ee}=D;this.onReceivedPublish($,K,ee);break}case"WHOHAS":{this.onReceivedWhoHas($,K);break}case"IHAVE":{let{id:ee}=D;this.onReceivedIHave($,K,ee);break}case"INEED":{let{source:ee,id:pe}=D;this.onReceivedINeed($,K,ee,pe);break}case"IGIVE":{let{target:ee,id:pe,message:ce}=D;this.onReceivedIGive($,K,pe,ee,ce);break}default:console.warn("unsupported",D)}}broadcastPublish(D,z){this.post({type:"PUBLISH",uuid:this.uuid,topic:D,message:z})}broadcastWhoHas(D){this.post({type:"WHOHAS",uuid:this.uuid,topic:D})}broadcastIHave(D,z){this.post({type:"IHAVE",uuid:this.uuid,topic:D,id:z})}broadcastINeed(D,z,$){this.post({type:"INEED",uuid:this.uuid,topic:D,source:z,id:$})}broadcastIGive(D,z,$,K){this.post({type:"IGIVE",uuid:this.uuid,topic:D,id:z,target:$,message:K})}post(D){this.bc.postMessage(D),Promise.resolve().then(()=>{this.onMessage(D)})}},ve=Symbol("BLOCKING_QUEUE_RESET"),Fe=class{constructor(D,z=()=>1){if(this.maxSize=D,this.itemSizeOf=z,this.queue=new u,this.waitingConsumers=new u,this.waitingProducers=new u,this.queueSize=0,this.closePromise=null,this.closeResolve=null,D<=0)throw new Error("Max size must be greater than 0")}enqueue(D){return this.closePromise?!1:this.isFull()?(async()=>{console.debug("queue is full",this.queueSize,this.maxSize);let z=await new Promise($=>{this.waitingProducers.enqueue($)});return console.debug("queue is not full",this.size(),z),z?(this.innerEnqueue(D),!0):!1})():(this.innerEnqueue(D),!0)}innerEnqueue(D){if(this.waitingConsumers.isEmpty())this.queue.enqueue(D),this.queueSize+=this.itemSizeOf(D),console.debug("queue pushed",D,"size",this.queueSize);else{let z=this.waitingConsumers.dequeue();Promise.resolve(D).then(z),console.debug("queue direct",D,"size",this.queueSize)}}dequeue(){if(this.queue.isEmpty())if(this.closePromise){for(;!this.waitingConsumers.isEmpty();){let D=this.waitingConsumers.dequeue();Promise.resolve(ve).then(D)}return setTimeout(()=>this.closeResolve(),0),ve}else return new Promise(D=>{this.waitingConsumers.enqueue(D)});else{let D=this.queue.dequeue();if(this.queueSize-=this.itemSizeOf(D),!this.waitingProducers.isEmpty()){let z=this.waitingProducers.dequeue();Promise.resolve(!0).then(z)}return D}}size(){return this.queueSize}isEmpty(){return this.queueSize===0}isFull(){return this.queueSize>=this.maxSize}close(){return this.closePromise||(this.closePromise=new Promise(D=>{for(this.closeResolve=D;!this.waitingProducers.isEmpty();){let z=this.waitingProducers.dequeue();Promise.resolve(!1).then(z)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let z=this.waitingConsumers.dequeue();Promise.resolve(ve).then(z)}D()}})),this.closePromise}};function Ne(D,z,$=Number.MAX_SAFE_INTEGER){let K=new Fe($,z),ee=new ReadableStream({pull(ce){let Be=!0,st=(async()=>{let pt=new Array;do{let tt=K.dequeue();if(tt instanceof Promise){Be=!1;let li=await tt;li===ve?ce.close():pt.push(li)}else{let li=tt;li===ve?ce.close():pt.push(li)}}while(K.size()>0);if(pt.length>0){let tt=D(pt);ce.enqueue(tt)}})();if(!Be)return console.debug("read stream stucked --------------------------------------"),st},async cancel(){console.debug("buffered readable cancel"),await K.close()}}),pe=new WritableStream({write(ce,Be){let st=!0,pt=(async()=>{let tt=K.enqueue(ce);typeof tt=="boolean"?tt||Be.error(new Error("Write stream closed")):(st=!1,await tt||Be.error(new Error("Write stream closed")))})();if(!st)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),pt},async close(){console.debug("buffered writable closing",K.size()),await K.close(),console.debug("buffered writable closed",K.size())},async abort(){console.debug("buffered writable aborting",K.size()),await K.close(),console.debug("buffered writable aborted",K.size())}});return{readable:ee,writable:pe}}function nt(D=Number.MAX_SAFE_INTEGER){return Ne(z=>z.join(""),z=>z.length,D)}function je(D=Number.MAX_SAFE_INTEGER){return Ne(z=>{let $=new Uint8Array(z.reduce((ee,pe)=>ee+pe.byteLength,0)),K=0;return z.forEach(ee=>{$.set(ee,K),K+=ee.byteLength}),$},z=>z.byteLength,D)}function vt(D){return new Promise((z,$)=>{let K=new BroadcastChannel(D),ee=new Fe(1),pe=new S(1),ce=null,Be=!1,st=!1,pt=!1;K.onmessage=tt=>{let li=tt.data,{type:Ji}=li;if(console.debug("p2p",D,"type",Ji,"data",Ji==="DATA"&&li.data),Ji==="DATA")ee.enqueue(li.data);else if(Ji==="HI"){if(!ce){K.postMessage({type:"HI"});let Mr=0;ce={rs:new ReadableStream({async pull(Or){let Cn=await ee.dequeue();Cn===ve?(await Bi(),Or.close()):(Or.enqueue(Cn),K.postMessage({type:"ACK"}))},cancel(){return Bi()}}),ws:new WritableStream({async write(Or,Cn){await pe.acquireSync()?K.postMessage({type:"DATA",id:Mr++,data:Or}):(cr(),Cn.error(new Error("Write stream closed")))},close(){cr()},abort(){cr()}})},z(ce)}}else Ji==="REND"?ce?pe.close():An("REND1"):Ji==="WEND"?ce?ee.close():An("WEND1"):Ji==="ACK"&&pe.release();function cr(){Be||(Be=!0,console.debug(D,"p2p write stream closed"),pe.close(),K.postMessage({type:"WEND"}),st&&(console.debug(D,"p2p channel closed on ws"),K.close()))}async function Bi(){st||(st=!0,console.debug(D,"p2p read stream closed"),K.postMessage({type:"REND"}),await ee.close(),Be&&(console.debug(D,"p2p channel closed on rs"),K.close()))}async function An(Mr){pt||(pt=!0,console.debug(D,"p2p channel connection released on",Mr),pe.close(),ee.close(),ce?(ce.rs.locked||(console.debug(D,"p2p unlocked read stream direct cancel"),ce.rs.cancel()),ce.ws.locked||(console.debug(D,"p2p unlocked write stream direct close"),ce.ws.close())):(K.postMessage({type:"HI"}),K.close()),$(new Error("p2p channel connection released")))}},K.postMessage({type:"HI"})})}function Bt(D){return new Promise(z=>{let $=new BroadcastChannel(D);$.onmessage=K=>{let ee=K.data,{type:pe}=ee;pe==="HI"&&($.postMessage({type:"REND"}),$.close(),z())},$.postMessage({type:"REND"})})}async function Oi(D){try{return await vt(D)}catch(z){z.message!=="p2p channel connection released"&&console.error(z)}}async function Ti(D,z,$=10*1024*1024,K=!0){let ee=await Oi(D);if(!ee)return!1;let pe=!1;try{let ce,Be=st=>{if(!ce)if(!K)ce=ee.ws.getWriter();else if(typeof st=="string"){let pt=nt($);pt.readable.pipeTo(ee.ws),ce=pt.writable.getWriter()}else{let pt=je($);pt.readable.pipeTo(ee.ws),ce=pt.writable.getWriter()}return ce.write(st)};if(Array.isArray(z))for(let st of z)await Be(st);else await z({write:Be,get desiredSize(){return((ce==null?void 0:ce.desiredSize)||0)+10}});ce&&await ce.close(),pe=!0}catch(ce){console.error(ce)}finally{return ee.rs.cancel(),pe}}async function ze(D,z){var $,K;let ee=await Oi(D);if(ee)try{let pe=ee.rs.getReader();for(($=z.start)==null?void 0:$.call(z);;){let{value:ce,done:Be}=await pe.read();if(ce!==void 0){let st;if(z.update instanceof Promise?st=await z.update(ce):st=z.update(ce),st){await pe.cancel();break}}if(Be){(K=z.end)==null||K.call(z);break}}}catch(pe){console.error(pe)}finally{ee.ws.close()}}}),br=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r():typeof define=="function"&&define.amd?define([],r):i.CryptoJS=r()})(e,function(){var i=i||(function(r,n){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof global<"u"&&global.crypto&&(s=global.crypto),!s&&typeof z3=="function")try{s=z3("crypto")}catch{}var a=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||(function(){function E(){}return function(S){var w;return E.prototype=S,w=new E,E.prototype=null,w}})(),l={},c=l.lib={},u=c.Base=(function(){return{extend:function(E){var S=o(this);return E&&S.mixIn(E),(!S.hasOwnProperty("init")||this.init===S.init)&&(S.init=function(){S.$super.init.apply(this,arguments)}),S.init.prototype=S,S.$super=this,S},create:function(){var E=this.extend();return E.init.apply(E,arguments),E},init:function(){},mixIn:function(E){for(var S in E)E.hasOwnProperty(S)&&(this[S]=E[S]);E.hasOwnProperty("toString")&&(this.toString=E.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),h=c.WordArray=u.extend({init:function(E,S){E=this.words=E||[],S!=n?this.sigBytes=S:this.sigBytes=E.length*4},toString:function(E){return(E||p).stringify(this)},concat:function(E){var S=this.words,w=E.words,x=this.sigBytes,I=E.sigBytes;if(this.clamp(),x%4)for(var A=0;A<I;A++){var O=w[A>>>2]>>>24-A%4*8&255;S[x+A>>>2]|=O<<24-(x+A)%4*8}else for(var R=0;R<I;R+=4)S[x+R>>>2]=w[R>>>2];return this.sigBytes+=I,this},clamp:function(){var E=this.words,S=this.sigBytes;E[S>>>2]&=4294967295<<32-S%4*8,E.length=r.ceil(S/4)},clone:function(){var E=u.clone.call(this);return E.words=this.words.slice(0),E},random:function(E){for(var S=[],w=0;w<E;w+=4)S.push(a());return new h.init(S,E)}}),d=l.enc={},p=d.Hex={stringify:function(E){for(var S=E.words,w=E.sigBytes,x=[],I=0;I<w;I++){var A=S[I>>>2]>>>24-I%4*8&255;x.push((A>>>4).toString(16)),x.push((A&15).toString(16))}return x.join("")},parse:function(E){for(var S=E.length,w=[],x=0;x<S;x+=2)w[x>>>3]|=parseInt(E.substr(x,2),16)<<24-x%8*4;return new h.init(w,S/2)}},f=d.Latin1={stringify:function(E){for(var S=E.words,w=E.sigBytes,x=[],I=0;I<w;I++){var A=S[I>>>2]>>>24-I%4*8&255;x.push(String.fromCharCode(A))}return x.join("")},parse:function(E){for(var S=E.length,w=[],x=0;x<S;x++)w[x>>>2]|=(E.charCodeAt(x)&255)<<24-x%4*8;return new h.init(w,S)}},m=d.Utf8={stringify:function(E){try{return decodeURIComponent(escape(f.stringify(E)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(E){return f.parse(unescape(encodeURIComponent(E)))}},g=c.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(E){typeof E=="string"&&(E=m.parse(E)),this._data.concat(E),this._nDataBytes+=E.sigBytes},_process:function(E){var S,w=this._data,x=w.words,I=w.sigBytes,A=this.blockSize,O=A*4,R=I/O;E?R=r.ceil(R):R=r.max((R|0)-this._minBufferSize,0);var M=R*A,F=r.min(M*4,I);if(M){for(var G=0;G<M;G+=A)this._doProcessBlock(x,G);S=x.splice(0,M),w.sigBytes-=F}return new h.init(S,F)},clone:function(){var E=u.clone.call(this);return E._data=this._data.clone(),E},_minBufferSize:0}),b=c.Hasher=g.extend({cfg:u.extend(),init:function(E){this.cfg=this.cfg.extend(E),this.reset()},reset:function(){g.reset.call(this),this._doReset()},update:function(E){return this._append(E),this._process(),this},finalize:function(E){E&&this._append(E);var S=this._doFinalize();return S},blockSize:512/32,_createHelper:function(E){return function(S,w){return new E.init(w).finalize(S)}},_createHmacHelper:function(E){return function(S,w){return new y.HMAC.init(E,w).finalize(S)}}}),y=l.algo={};return l})(Math);return i})}),i2=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.Base,o=s.WordArray,l=n.x64={},c=l.Word=a.extend({init:function(h,d){this.high=h,this.low=d}}),u=l.WordArray=a.extend({init:function(h,d){h=this.words=h||[],d!=r?this.sigBytes=d:this.sigBytes=h.length*8},toX32:function(){for(var h=this.words,d=h.length,p=[],f=0;f<d;f++){var m=h[f];p.push(m.high),p.push(m.low)}return o.create(p,this.sigBytes)},clone:function(){for(var h=a.clone.call(this),d=h.words=this.words.slice(0),p=d.length,f=0;f<p;f++)d[f]=d[f].clone();return h}})})(),i})}),_W=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){if(typeof ArrayBuffer=="function"){var r=i,n=r.lib,s=n.WordArray,a=s.init,o=s.init=function(l){if(l instanceof ArrayBuffer&&(l=new Uint8Array(l)),(l instanceof Int8Array||typeof Uint8ClampedArray<"u"&&l instanceof Uint8ClampedArray||l instanceof Int16Array||l instanceof Uint16Array||l instanceof Int32Array||l instanceof Uint32Array||l instanceof Float32Array||l instanceof Float64Array)&&(l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength)),l instanceof Uint8Array){for(var c=l.byteLength,u=[],h=0;h<c;h++)u[h>>>2]|=l[h]<<24-h%4*8;a.call(this,u,c)}else a.apply(this,arguments)};o.prototype=s}})(),i.lib.WordArray})}),PW=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=r.enc,o=a.Utf16=a.Utf16BE={stringify:function(c){for(var u=c.words,h=c.sigBytes,d=[],p=0;p<h;p+=2){var f=u[p>>>2]>>>16-p%4*8&65535;d.push(String.fromCharCode(f))}return d.join("")},parse:function(c){for(var u=c.length,h=[],d=0;d<u;d++)h[d>>>1]|=c.charCodeAt(d)<<16-d%2*16;return s.create(h,u*2)}};a.Utf16LE={stringify:function(c){for(var u=c.words,h=c.sigBytes,d=[],p=0;p<h;p+=2){var f=l(u[p>>>2]>>>16-p%4*8&65535);d.push(String.fromCharCode(f))}return d.join("")},parse:function(c){for(var u=c.length,h=[],d=0;d<u;d++)h[d>>>1]|=l(c.charCodeAt(d)<<16-d%2*16);return s.create(h,u*2)}};function l(c){return c<<8&4278255360|c>>>8&16711935}})(),i.enc.Utf16})}),Wp=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=r.enc,o=a.Base64={stringify:function(c){var u=c.words,h=c.sigBytes,d=this._map;c.clamp();for(var p=[],f=0;f<h;f+=3)for(var m=u[f>>>2]>>>24-f%4*8&255,g=u[f+1>>>2]>>>24-(f+1)%4*8&255,b=u[f+2>>>2]>>>24-(f+2)%4*8&255,y=m<<16|g<<8|b,E=0;E<4&&f+E*.75<h;E++)p.push(d.charAt(y>>>6*(3-E)&63));var S=d.charAt(64);if(S)for(;p.length%4;)p.push(S);return p.join("")},parse:function(c){var u=c.length,h=this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var p=0;p<h.length;p++)d[h.charCodeAt(p)]=p}var f=h.charAt(64);if(f){var m=c.indexOf(f);m!==-1&&(u=m)}return l(c,u,d)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function l(c,u,h){for(var d=[],p=0,f=0;f<u;f++)if(f%4){var m=h[c.charCodeAt(f-1)]<<f%4*2,g=h[c.charCodeAt(f)]>>>6-f%4*2,b=m|g;d[p>>>2]|=b<<24-p%4*8,p++}return s.create(d,p)}})(),i.enc.Base64})}),LW=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=r.enc,o=a.Base64url={stringify:function(c,u){u===void 0&&(u=!0);var h=c.words,d=c.sigBytes,p=u?this._safe_map:this._map;c.clamp();for(var f=[],m=0;m<d;m+=3)for(var g=h[m>>>2]>>>24-m%4*8&255,b=h[m+1>>>2]>>>24-(m+1)%4*8&255,y=h[m+2>>>2]>>>24-(m+2)%4*8&255,E=g<<16|b<<8|y,S=0;S<4&&m+S*.75<d;S++)f.push(p.charAt(E>>>6*(3-S)&63));var w=p.charAt(64);if(w)for(;f.length%4;)f.push(w);return f.join("")},parse:function(c,u){u===void 0&&(u=!0);var h=c.length,d=u?this._safe_map:this._map,p=this._reverseMap;if(!p){p=this._reverseMap=[];for(var f=0;f<d.length;f++)p[d.charCodeAt(f)]=f}var m=d.charAt(64);if(m){var g=c.indexOf(m);g!==-1&&(h=g)}return l(c,h,p)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function l(c,u,h){for(var d=[],p=0,f=0;f<u;f++)if(f%4){var m=h[c.charCodeAt(f-1)]<<f%4*2,g=h[c.charCodeAt(f)]>>>6-f%4*2,b=m|g;d[p>>>2]|=b<<24-p%4*8,p++}return s.create(d,p)}})(),i.enc.Base64url})}),qp=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.WordArray,o=s.Hasher,l=n.algo,c=[];(function(){for(var m=0;m<64;m++)c[m]=r.abs(r.sin(m+1))*4294967296|0})();var u=l.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(m,g){for(var b=0;b<16;b++){var y=g+b,E=m[y];m[y]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360}var S=this._hash.words,w=m[g+0],x=m[g+1],I=m[g+2],A=m[g+3],O=m[g+4],R=m[g+5],M=m[g+6],F=m[g+7],G=m[g+8],V=m[g+9],q=m[g+10],C=m[g+11],N=m[g+12],T=m[g+13],L=m[g+14],P=m[g+15],B=S[0],U=S[1],X=S[2],J=S[3];B=h(B,U,X,J,w,7,c[0]),J=h(J,B,U,X,x,12,c[1]),X=h(X,J,B,U,I,17,c[2]),U=h(U,X,J,B,A,22,c[3]),B=h(B,U,X,J,O,7,c[4]),J=h(J,B,U,X,R,12,c[5]),X=h(X,J,B,U,M,17,c[6]),U=h(U,X,J,B,F,22,c[7]),B=h(B,U,X,J,G,7,c[8]),J=h(J,B,U,X,V,12,c[9]),X=h(X,J,B,U,q,17,c[10]),U=h(U,X,J,B,C,22,c[11]),B=h(B,U,X,J,N,7,c[12]),J=h(J,B,U,X,T,12,c[13]),X=h(X,J,B,U,L,17,c[14]),U=h(U,X,J,B,P,22,c[15]),B=d(B,U,X,J,x,5,c[16]),J=d(J,B,U,X,M,9,c[17]),X=d(X,J,B,U,C,14,c[18]),U=d(U,X,J,B,w,20,c[19]),B=d(B,U,X,J,R,5,c[20]),J=d(J,B,U,X,q,9,c[21]),X=d(X,J,B,U,P,14,c[22]),U=d(U,X,J,B,O,20,c[23]),B=d(B,U,X,J,V,5,c[24]),J=d(J,B,U,X,L,9,c[25]),X=d(X,J,B,U,A,14,c[26]),U=d(U,X,J,B,G,20,c[27]),B=d(B,U,X,J,T,5,c[28]),J=d(J,B,U,X,I,9,c[29]),X=d(X,J,B,U,F,14,c[30]),U=d(U,X,J,B,N,20,c[31]),B=p(B,U,X,J,R,4,c[32]),J=p(J,B,U,X,G,11,c[33]),X=p(X,J,B,U,C,16,c[34]),U=p(U,X,J,B,L,23,c[35]),B=p(B,U,X,J,x,4,c[36]),J=p(J,B,U,X,O,11,c[37]),X=p(X,J,B,U,F,16,c[38]),U=p(U,X,J,B,q,23,c[39]),B=p(B,U,X,J,T,4,c[40]),J=p(J,B,U,X,w,11,c[41]),X=p(X,J,B,U,A,16,c[42]),U=p(U,X,J,B,M,23,c[43]),B=p(B,U,X,J,V,4,c[44]),J=p(J,B,U,X,N,11,c[45]),X=p(X,J,B,U,P,16,c[46]),U=p(U,X,J,B,I,23,c[47]),B=f(B,U,X,J,w,6,c[48]),J=f(J,B,U,X,F,10,c[49]),X=f(X,J,B,U,L,15,c[50]),U=f(U,X,J,B,R,21,c[51]),B=f(B,U,X,J,N,6,c[52]),J=f(J,B,U,X,A,10,c[53]),X=f(X,J,B,U,q,15,c[54]),U=f(U,X,J,B,x,21,c[55]),B=f(B,U,X,J,G,6,c[56]),J=f(J,B,U,X,P,10,c[57]),X=f(X,J,B,U,M,15,c[58]),U=f(U,X,J,B,T,21,c[59]),B=f(B,U,X,J,O,6,c[60]),J=f(J,B,U,X,C,10,c[61]),X=f(X,J,B,U,I,15,c[62]),U=f(U,X,J,B,V,21,c[63]),S[0]=S[0]+B|0,S[1]=S[1]+U|0,S[2]=S[2]+X|0,S[3]=S[3]+J|0},_doFinalize:function(){var m=this._data,g=m.words,b=this._nDataBytes*8,y=m.sigBytes*8;g[y>>>5]|=128<<24-y%32;var E=r.floor(b/4294967296),S=b;g[(y+64>>>9<<4)+15]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,g[(y+64>>>9<<4)+14]=(S<<8|S>>>24)&16711935|(S<<24|S>>>8)&4278255360,m.sigBytes=(g.length+1)*4,this._process();for(var w=this._hash,x=w.words,I=0;I<4;I++){var A=x[I];x[I]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360}return w},clone:function(){var m=o.clone.call(this);return m._hash=this._hash.clone(),m}});function h(m,g,b,y,E,S,w){var x=m+(g&b|~g&y)+E+w;return(x<<S|x>>>32-S)+g}function d(m,g,b,y,E,S,w){var x=m+(g&y|b&~y)+E+w;return(x<<S|x>>>32-S)+g}function p(m,g,b,y,E,S,w){var x=m+(g^b^y)+E+w;return(x<<S|x>>>32-S)+g}function f(m,g,b,y,E,S,w){var x=m+(b^(g|~y))+E+w;return(x<<S|x>>>32-S)+g}n.MD5=o._createHelper(u),n.HmacMD5=o._createHmacHelper(u)})(Math),i.MD5})}),MM=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=n.Hasher,o=r.algo,l=[],c=o.SHA1=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(u,h){for(var d=this._hash.words,p=d[0],f=d[1],m=d[2],g=d[3],b=d[4],y=0;y<80;y++){if(y<16)l[y]=u[h+y]|0;else{var E=l[y-3]^l[y-8]^l[y-14]^l[y-16];l[y]=E<<1|E>>>31}var S=(p<<5|p>>>27)+b+l[y];y<20?S+=(f&m|~f&g)+1518500249:y<40?S+=(f^m^g)+1859775393:y<60?S+=(f&m|f&g|m&g)-1894007588:S+=(f^m^g)-899497514,b=g,g=m,m=f<<30|f>>>2,f=p,p=S}d[0]=d[0]+p|0,d[1]=d[1]+f|0,d[2]=d[2]+m|0,d[3]=d[3]+g|0,d[4]=d[4]+b|0},_doFinalize:function(){var u=this._data,h=u.words,d=this._nDataBytes*8,p=u.sigBytes*8;return h[p>>>5]|=128<<24-p%32,h[(p+64>>>9<<4)+14]=Math.floor(d/4294967296),h[(p+64>>>9<<4)+15]=d,u.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var u=a.clone.call(this);return u._hash=this._hash.clone(),u}});r.SHA1=a._createHelper(c),r.HmacSHA1=a._createHmacHelper(c)})(),i.SHA1})}),PA=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.WordArray,o=s.Hasher,l=n.algo,c=[],u=[];(function(){function p(b){for(var y=r.sqrt(b),E=2;E<=y;E++)if(!(b%E))return!1;return!0}function f(b){return(b-(b|0))*4294967296|0}for(var m=2,g=0;g<64;)p(m)&&(g<8&&(c[g]=f(r.pow(m,1/2))),u[g]=f(r.pow(m,1/3)),g++),m++})();var h=[],d=l.SHA256=o.extend({_doReset:function(){this._hash=new a.init(c.slice(0))},_doProcessBlock:function(p,f){for(var m=this._hash.words,g=m[0],b=m[1],y=m[2],E=m[3],S=m[4],w=m[5],x=m[6],I=m[7],A=0;A<64;A++){if(A<16)h[A]=p[f+A]|0;else{var O=h[A-15],R=(O<<25|O>>>7)^(O<<14|O>>>18)^O>>>3,M=h[A-2],F=(M<<15|M>>>17)^(M<<13|M>>>19)^M>>>10;h[A]=R+h[A-7]+F+h[A-16]}var G=S&w^~S&x,V=g&b^g&y^b&y,q=(g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22),C=(S<<26|S>>>6)^(S<<21|S>>>11)^(S<<7|S>>>25),N=I+C+G+u[A]+h[A],T=q+V;I=x,x=w,w=S,S=E+N|0,E=y,y=b,b=g,g=N+T|0}m[0]=m[0]+g|0,m[1]=m[1]+b|0,m[2]=m[2]+y|0,m[3]=m[3]+E|0,m[4]=m[4]+S|0,m[5]=m[5]+w|0,m[6]=m[6]+x|0,m[7]=m[7]+I|0},_doFinalize:function(){var p=this._data,f=p.words,m=this._nDataBytes*8,g=p.sigBytes*8;return f[g>>>5]|=128<<24-g%32,f[(g+64>>>9<<4)+14]=r.floor(m/4294967296),f[(g+64>>>9<<4)+15]=m,p.sigBytes=f.length*4,this._process(),this._hash},clone:function(){var p=o.clone.call(this);return p._hash=this._hash.clone(),p}});n.SHA256=o._createHelper(d),n.HmacSHA256=o._createHmacHelper(d)})(Math),i.SHA256})}),OW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),PA()):typeof define=="function"&&define.amd?define(["./core","./sha256"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=r.algo,o=a.SHA256,l=a.SHA224=o.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var c=o._doFinalize.call(this);return c.sigBytes-=4,c}});r.SHA224=o._createHelper(l),r.HmacSHA224=o._createHmacHelper(l)})(),i.SHA224})}),BM=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),i2()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.Hasher,a=r.x64,o=a.Word,l=a.WordArray,c=r.algo;function u(){return o.create.apply(o,arguments)}var h=[u(1116352408,3609767458),u(1899447441,602891725),u(3049323471,3964484399),u(3921009573,2173295548),u(961987163,4081628472),u(1508970993,3053834265),u(2453635748,2937671579),u(2870763221,3664609560),u(3624381080,2734883394),u(310598401,1164996542),u(607225278,1323610764),u(1426881987,3590304994),u(1925078388,4068182383),u(2162078206,991336113),u(2614888103,633803317),u(3248222580,3479774868),u(3835390401,2666613458),u(4022224774,944711139),u(264347078,2341262773),u(604807628,2007800933),u(770255983,1495990901),u(1249150122,1856431235),u(1555081692,3175218132),u(1996064986,2198950837),u(2554220882,3999719339),u(2821834349,766784016),u(2952996808,2566594879),u(3210313671,3203337956),u(3336571891,1034457026),u(3584528711,2466948901),u(113926993,3758326383),u(338241895,168717936),u(666307205,1188179964),u(773529912,1546045734),u(1294757372,1522805485),u(1396182291,2643833823),u(1695183700,2343527390),u(1986661051,1014477480),u(2177026350,1206759142),u(2456956037,344077627),u(2730485921,1290863460),u(2820302411,3158454273),u(3259730800,3505952657),u(3345764771,106217008),u(3516065817,3606008344),u(3600352804,1432725776),u(4094571909,1467031594),u(275423344,851169720),u(430227734,3100823752),u(506948616,1363258195),u(659060556,3750685593),u(883997877,3785050280),u(958139571,3318307427),u(1322822218,3812723403),u(1537002063,2003034995),u(1747873779,3602036899),u(1955562222,1575990012),u(2024104815,1125592928),u(2227730452,2716904306),u(2361852424,442776044),u(2428436474,593698344),u(2756734187,3733110249),u(3204031479,2999351573),u(3329325298,3815920427),u(3391569614,3928383900),u(3515267271,566280711),u(3940187606,3454069534),u(4118630271,4000239992),u(116418474,1914138554),u(174292421,2731055270),u(289380356,3203993006),u(460393269,320620315),u(685471733,587496836),u(852142971,1086792851),u(1017036298,365543100),u(1126000580,2618297676),u(1288033470,3409855158),u(1501505948,4234509866),u(1607167915,987167468),u(1816402316,1246189591)],d=[];(function(){for(var f=0;f<80;f++)d[f]=u()})();var p=c.SHA512=s.extend({_doReset:function(){this._hash=new l.init([new o.init(1779033703,4089235720),new o.init(3144134277,2227873595),new o.init(1013904242,4271175723),new o.init(2773480762,1595750129),new o.init(1359893119,2917565137),new o.init(2600822924,725511199),new o.init(528734635,4215389547),new o.init(1541459225,327033209)])},_doProcessBlock:function(f,m){for(var g=this._hash.words,b=g[0],y=g[1],E=g[2],S=g[3],w=g[4],x=g[5],I=g[6],A=g[7],O=b.high,R=b.low,M=y.high,F=y.low,G=E.high,V=E.low,q=S.high,C=S.low,N=w.high,T=w.low,L=x.high,P=x.low,B=I.high,U=I.low,X=A.high,J=A.low,ne=O,fe=R,xe=M,ve=F,Fe=G,Ne=V,nt=q,je=C,vt=N,Bt=T,Oi=L,Ti=P,ze=B,D=U,z=X,$=J,K=0;K<80;K++){var ee,pe,ce=d[K];if(K<16)pe=ce.high=f[m+K*2]|0,ee=ce.low=f[m+K*2+1]|0;else{var Be=d[K-15],st=Be.high,pt=Be.low,tt=(st>>>1|pt<<31)^(st>>>8|pt<<24)^st>>>7,li=(pt>>>1|st<<31)^(pt>>>8|st<<24)^(pt>>>7|st<<25),Ji=d[K-2],cr=Ji.high,Bi=Ji.low,An=(cr>>>19|Bi<<13)^(cr<<3|Bi>>>29)^cr>>>6,Mr=(Bi>>>19|cr<<13)^(Bi<<3|cr>>>29)^(Bi>>>6|cr<<26),Or=d[K-7],Cn=Or.high,ua=Or.low,Zt=d[K-16],Er=Zt.high,mt=Zt.low;ee=li+ua,pe=tt+Cn+(ee>>>0<li>>>0?1:0),ee=ee+Mr,pe=pe+An+(ee>>>0<Mr>>>0?1:0),ee=ee+mt,pe=pe+Er+(ee>>>0<mt>>>0?1:0),ce.high=pe,ce.low=ee}var dn=vt&Oi^~vt&ze,rs=Bt&Ti^~Bt&D,di=ne&xe^ne&Fe^xe&Fe,Ii=fe&ve^fe&Ne^ve&Ne,vn=(ne>>>28|fe<<4)^(ne<<30|fe>>>2)^(ne<<25|fe>>>7),ha=(fe>>>28|ne<<4)^(fe<<30|ne>>>2)^(fe<<25|ne>>>7),Yu=(vt>>>14|Bt<<18)^(vt>>>18|Bt<<14)^(vt<<23|Bt>>>9),Ef=(Bt>>>14|vt<<18)^(Bt>>>18|vt<<14)^(Bt<<23|vt>>>9),Gh=h[K],zc=Gh.high,El=Gh.low,Br=$+Ef,ns=z+Yu+(Br>>>0<$>>>0?1:0),Br=Br+rs,ns=ns+dn+(Br>>>0<rs>>>0?1:0),Br=Br+El,ns=ns+zc+(Br>>>0<El>>>0?1:0),Br=Br+ee,ns=ns+pe+(Br>>>0<ee>>>0?1:0),ep=ha+Ii,Qg=vn+di+(ep>>>0<ha>>>0?1:0);z=ze,$=D,ze=Oi,D=Ti,Oi=vt,Ti=Bt,Bt=je+Br|0,vt=nt+ns+(Bt>>>0<je>>>0?1:0)|0,nt=Fe,je=Ne,Fe=xe,Ne=ve,xe=ne,ve=fe,fe=Br+ep|0,ne=ns+Qg+(fe>>>0<Br>>>0?1:0)|0}R=b.low=R+fe,b.high=O+ne+(R>>>0<fe>>>0?1:0),F=y.low=F+ve,y.high=M+xe+(F>>>0<ve>>>0?1:0),V=E.low=V+Ne,E.high=G+Fe+(V>>>0<Ne>>>0?1:0),C=S.low=C+je,S.high=q+nt+(C>>>0<je>>>0?1:0),T=w.low=T+Bt,w.high=N+vt+(T>>>0<Bt>>>0?1:0),P=x.low=P+Ti,x.high=L+Oi+(P>>>0<Ti>>>0?1:0),U=I.low=U+D,I.high=B+ze+(U>>>0<D>>>0?1:0),J=A.low=J+$,A.high=X+z+(J>>>0<$>>>0?1:0)},_doFinalize:function(){var f=this._data,m=f.words,g=this._nDataBytes*8,b=f.sigBytes*8;m[b>>>5]|=128<<24-b%32,m[(b+128>>>10<<5)+30]=Math.floor(g/4294967296),m[(b+128>>>10<<5)+31]=g,f.sigBytes=m.length*4,this._process();var y=this._hash.toX32();return y},clone:function(){var f=s.clone.call(this);return f._hash=this._hash.clone(),f},blockSize:1024/32});r.SHA512=s._createHelper(p),r.HmacSHA512=s._createHmacHelper(p)})(),i.SHA512})}),RW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),i2(),BM()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./sha512"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.x64,s=n.Word,a=n.WordArray,o=r.algo,l=o.SHA512,c=o.SHA384=l.extend({_doReset:function(){this._hash=new a.init([new s.init(3418070365,3238371032),new s.init(1654270250,914150663),new s.init(2438529370,812702999),new s.init(355462360,4144912697),new s.init(1731405415,4290775857),new s.init(2394180231,1750603025),new s.init(3675008525,1694076839),new s.init(1203062813,3204075428)])},_doFinalize:function(){var u=l._doFinalize.call(this);return u.sigBytes-=16,u}});r.SHA384=l._createHelper(c),r.HmacSHA384=l._createHmacHelper(c)})(),i.SHA384})}),NW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),i2()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.WordArray,o=s.Hasher,l=n.x64,c=l.Word,u=n.algo,h=[],d=[],p=[];(function(){for(var g=1,b=0,y=0;y<24;y++){h[g+5*b]=(y+1)*(y+2)/2%64;var E=b%5,S=(2*g+3*b)%5;g=E,b=S}for(var g=0;g<5;g++)for(var b=0;b<5;b++)d[g+5*b]=b+(2*g+3*b)%5*5;for(var w=1,x=0;x<24;x++){for(var I=0,A=0,O=0;O<7;O++){if(w&1){var R=(1<<O)-1;R<32?A^=1<<R:I^=1<<R-32}w&128?w=w<<1^113:w<<=1}p[x]=c.create(I,A)}})();var f=[];(function(){for(var g=0;g<25;g++)f[g]=c.create()})();var m=u.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var g=this._state=[],b=0;b<25;b++)g[b]=new c.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(g,b){for(var y=this._state,E=this.blockSize/2,S=0;S<E;S++){var w=g[b+2*S],x=g[b+2*S+1];w=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360,x=(x<<8|x>>>24)&16711935|(x<<24|x>>>8)&4278255360;var I=y[S];I.high^=x,I.low^=w}for(var A=0;A<24;A++){for(var O=0;O<5;O++){for(var R=0,M=0,F=0;F<5;F++){var I=y[O+5*F];R^=I.high,M^=I.low}var G=f[O];G.high=R,G.low=M}for(var O=0;O<5;O++)for(var V=f[(O+4)%5],q=f[(O+1)%5],C=q.high,N=q.low,R=V.high^(C<<1|N>>>31),M=V.low^(N<<1|C>>>31),F=0;F<5;F++){var I=y[O+5*F];I.high^=R,I.low^=M}for(var T=1;T<25;T++){var R,M,I=y[T],L=I.high,P=I.low,B=h[T];B<32?(R=L<<B|P>>>32-B,M=P<<B|L>>>32-B):(R=P<<B-32|L>>>64-B,M=L<<B-32|P>>>64-B);var U=f[d[T]];U.high=R,U.low=M}var X=f[0],J=y[0];X.high=J.high,X.low=J.low;for(var O=0;O<5;O++)for(var F=0;F<5;F++){var T=O+5*F,I=y[T],ne=f[T],fe=f[(O+1)%5+5*F],xe=f[(O+2)%5+5*F];I.high=ne.high^~fe.high&xe.high,I.low=ne.low^~fe.low&xe.low}var I=y[0],ve=p[A];I.high^=ve.high,I.low^=ve.low}},_doFinalize:function(){var g=this._data,b=g.words,y=this._nDataBytes*8,E=g.sigBytes*8,S=this.blockSize*32;b[E>>>5]|=1<<24-E%32,b[(r.ceil((E+1)/S)*S>>>5)-1]|=128,g.sigBytes=b.length*4,this._process();for(var w=this._state,x=this.cfg.outputLength/8,I=x/8,A=[],O=0;O<I;O++){var R=w[O],M=R.high,F=R.low;M=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360,F=(F<<8|F>>>24)&16711935|(F<<24|F>>>8)&4278255360,A.push(F),A.push(M)}return new a.init(A,x)},clone:function(){for(var g=o.clone.call(this),b=g._state=this._state.slice(0),y=0;y<25;y++)b[y]=b[y].clone();return g}});n.SHA3=o._createHelper(m),n.HmacSHA3=o._createHmacHelper(m)})(Math),i.SHA3})}),MW=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.WordArray,o=s.Hasher,l=n.algo,c=a.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=a.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),h=a.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),d=a.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),p=a.create([0,1518500249,1859775393,2400959708,2840853838]),f=a.create([1352829926,1548603684,1836072691,2053994217,0]),m=l.RIPEMD160=o.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(x,I){for(var A=0;A<16;A++){var O=I+A,R=x[O];x[O]=(R<<8|R>>>24)&16711935|(R<<24|R>>>8)&4278255360}var M=this._hash.words,F=p.words,G=f.words,V=c.words,q=u.words,C=h.words,N=d.words,T,L,P,B,U,X,J,ne,fe,xe;X=T=M[0],J=L=M[1],ne=P=M[2],fe=B=M[3],xe=U=M[4];for(var ve,A=0;A<80;A+=1)ve=T+x[I+V[A]]|0,A<16?ve+=g(L,P,B)+F[0]:A<32?ve+=b(L,P,B)+F[1]:A<48?ve+=y(L,P,B)+F[2]:A<64?ve+=E(L,P,B)+F[3]:ve+=S(L,P,B)+F[4],ve=ve|0,ve=w(ve,C[A]),ve=ve+U|0,T=U,U=B,B=w(P,10),P=L,L=ve,ve=X+x[I+q[A]]|0,A<16?ve+=S(J,ne,fe)+G[0]:A<32?ve+=E(J,ne,fe)+G[1]:A<48?ve+=y(J,ne,fe)+G[2]:A<64?ve+=b(J,ne,fe)+G[3]:ve+=g(J,ne,fe)+G[4],ve=ve|0,ve=w(ve,N[A]),ve=ve+xe|0,X=xe,xe=fe,fe=w(ne,10),ne=J,J=ve;ve=M[1]+P+fe|0,M[1]=M[2]+B+xe|0,M[2]=M[3]+U+X|0,M[3]=M[4]+T+J|0,M[4]=M[0]+L+ne|0,M[0]=ve},_doFinalize:function(){var x=this._data,I=x.words,A=this._nDataBytes*8,O=x.sigBytes*8;I[O>>>5]|=128<<24-O%32,I[(O+64>>>9<<4)+14]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,x.sigBytes=(I.length+1)*4,this._process();for(var R=this._hash,M=R.words,F=0;F<5;F++){var G=M[F];M[F]=(G<<8|G>>>24)&16711935|(G<<24|G>>>8)&4278255360}return R},clone:function(){var x=o.clone.call(this);return x._hash=this._hash.clone(),x}});function g(x,I,A){return x^I^A}function b(x,I,A){return x&I|~x&A}function y(x,I,A){return(x|~I)^A}function E(x,I,A){return x&A|I&~A}function S(x,I,A){return x^(I|~A)}function w(x,I){return x<<I|x>>>32-I}n.RIPEMD160=o._createHelper(m),n.HmacRIPEMD160=o._createHmacHelper(m)})(Math),i.RIPEMD160})}),LA=nr((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(br()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){(function(){var r=i,n=r.lib,s=n.Base,a=r.enc,o=a.Utf8,l=r.algo,c=l.HMAC=s.extend({init:function(u,h){u=this._hasher=new u.init,typeof h=="string"&&(h=o.parse(h));var d=u.blockSize,p=d*4;h.sigBytes>p&&(h=u.finalize(h)),h.clamp();for(var f=this._oKey=h.clone(),m=this._iKey=h.clone(),g=f.words,b=m.words,y=0;y<d;y++)g[y]^=1549556828,b[y]^=909522486;f.sigBytes=m.sigBytes=p,this.reset()},reset:function(){var u=this._hasher;u.reset(),u.update(this._iKey)},update:function(u){return this._hasher.update(u),this},finalize:function(u){var h=this._hasher,d=h.finalize(u);h.reset();var p=h.finalize(this._oKey.clone().concat(d));return p}})})()})}),BW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),PA(),LA()):typeof define=="function"&&define.amd?define(["./core","./sha256","./hmac"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.Base,a=n.WordArray,o=r.algo,l=o.SHA256,c=o.HMAC,u=o.PBKDF2=s.extend({cfg:s.extend({keySize:128/32,hasher:l,iterations:25e4}),init:function(h){this.cfg=this.cfg.extend(h)},compute:function(h,d){for(var p=this.cfg,f=c.create(p.hasher,h),m=a.create(),g=a.create([1]),b=m.words,y=g.words,E=p.keySize,S=p.iterations;b.length<E;){var w=f.update(d).finalize(g);f.reset();for(var x=w.words,I=x.length,A=w,O=1;O<S;O++){A=f.finalize(A),f.reset();for(var R=A.words,M=0;M<I;M++)x[M]^=R[M]}m.concat(w),y[0]++}return m.sigBytes=E*4,m}});r.PBKDF2=function(h,d,p){return u.create(p).compute(h,d)}})(),i.PBKDF2})}),vd=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),MM(),LA()):typeof define=="function"&&define.amd?define(["./core","./sha1","./hmac"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.Base,a=n.WordArray,o=r.algo,l=o.MD5,c=o.EvpKDF=s.extend({cfg:s.extend({keySize:128/32,hasher:l,iterations:1}),init:function(u){this.cfg=this.cfg.extend(u)},compute:function(u,h){for(var d,p=this.cfg,f=p.hasher.create(),m=a.create(),g=m.words,b=p.keySize,y=p.iterations;g.length<b;){d&&f.update(d),d=f.update(u).finalize(h),f.reset();for(var E=1;E<y;E++)d=f.finalize(d),f.reset();m.concat(d)}return m.sigBytes=b*4,m}});r.EvpKDF=function(u,h,d){return c.create(d).compute(u,h)}})(),i.EvpKDF})}),la=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),vd()):typeof define=="function"&&define.amd?define(["./core","./evpkdf"],r):r(i.CryptoJS)})(e,function(i){i.lib.Cipher||(function(r){var n=i,s=n.lib,a=s.Base,o=s.WordArray,l=s.BufferedBlockAlgorithm,c=n.enc,u=c.Utf8,h=c.Base64,d=n.algo,p=d.EvpKDF,f=s.Cipher=l.extend({cfg:a.extend(),createEncryptor:function(G,V){return this.create(this._ENC_XFORM_MODE,G,V)},createDecryptor:function(G,V){return this.create(this._DEC_XFORM_MODE,G,V)},init:function(G,V,q){this.cfg=this.cfg.extend(q),this._xformMode=G,this._key=V,this.reset()},reset:function(){l.reset.call(this),this._doReset()},process:function(G){return this._append(G),this._process()},finalize:function(G){G&&this._append(G);var V=this._doFinalize();return V},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:(function(){function G(V){return typeof V=="string"?F:O}return function(V){return{encrypt:function(q,C,N){return G(C).encrypt(V,q,C,N)},decrypt:function(q,C,N){return G(C).decrypt(V,q,C,N)}}}})()}),m=s.StreamCipher=f.extend({_doFinalize:function(){var G=this._process(!0);return G},blockSize:1}),g=n.mode={},b=s.BlockCipherMode=a.extend({createEncryptor:function(G,V){return this.Encryptor.create(G,V)},createDecryptor:function(G,V){return this.Decryptor.create(G,V)},init:function(G,V){this._cipher=G,this._iv=V}}),y=g.CBC=(function(){var G=b.extend();G.Encryptor=G.extend({processBlock:function(q,C){var N=this._cipher,T=N.blockSize;V.call(this,q,C,T),N.encryptBlock(q,C),this._prevBlock=q.slice(C,C+T)}}),G.Decryptor=G.extend({processBlock:function(q,C){var N=this._cipher,T=N.blockSize,L=q.slice(C,C+T);N.decryptBlock(q,C),V.call(this,q,C,T),this._prevBlock=L}});function V(q,C,N){var T,L=this._iv;L?(T=L,this._iv=r):T=this._prevBlock;for(var P=0;P<N;P++)q[C+P]^=T[P]}return G})(),E=n.pad={},S=E.Pkcs7={pad:function(G,V){for(var q=V*4,C=q-G.sigBytes%q,N=C<<24|C<<16|C<<8|C,T=[],L=0;L<C;L+=4)T.push(N);var P=o.create(T,C);G.concat(P)},unpad:function(G){var V=G.words[G.sigBytes-1>>>2]&255;G.sigBytes-=V}},w=s.BlockCipher=f.extend({cfg:f.cfg.extend({mode:y,padding:S}),reset:function(){var G;f.reset.call(this);var V=this.cfg,q=V.iv,C=V.mode;this._xformMode==this._ENC_XFORM_MODE?G=C.createEncryptor:(G=C.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==G?this._mode.init(this,q&&q.words):(this._mode=G.call(C,this,q&&q.words),this._mode.__creator=G)},_doProcessBlock:function(G,V){this._mode.processBlock(G,V)},_doFinalize:function(){var G,V=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(V.pad(this._data,this.blockSize),G=this._process(!0)):(G=this._process(!0),V.unpad(G)),G},blockSize:128/32}),x=s.CipherParams=a.extend({init:function(G){this.mixIn(G)},toString:function(G){return(G||this.formatter).stringify(this)}}),I=n.format={},A=I.OpenSSL={stringify:function(G){var V,q=G.ciphertext,C=G.salt;return C?V=o.create([1398893684,1701076831]).concat(C).concat(q):V=q,V.toString(h)},parse:function(G){var V,q=h.parse(G),C=q.words;return C[0]==1398893684&&C[1]==1701076831&&(V=o.create(C.slice(2,4)),C.splice(0,4),q.sigBytes-=16),x.create({ciphertext:q,salt:V})}},O=s.SerializableCipher=a.extend({cfg:a.extend({format:A}),encrypt:function(G,V,q,C){C=this.cfg.extend(C);var N=G.createEncryptor(q,C),T=N.finalize(V),L=N.cfg;return x.create({ciphertext:T,key:q,iv:L.iv,algorithm:G,mode:L.mode,padding:L.padding,blockSize:G.blockSize,formatter:C.format})},decrypt:function(G,V,q,C){C=this.cfg.extend(C),V=this._parse(V,C.format);var N=G.createDecryptor(q,C).finalize(V.ciphertext);return N},_parse:function(G,V){return typeof G=="string"?V.parse(G,this):G}}),R=n.kdf={},M=R.OpenSSL={execute:function(G,V,q,C,N){if(C||(C=o.random(64/8)),N)var T=p.create({keySize:V+q,hasher:N}).compute(G,C);else var T=p.create({keySize:V+q}).compute(G,C);var L=o.create(T.words.slice(V),q*4);return T.sigBytes=V*4,x.create({key:T,iv:L,salt:C})}},F=s.PasswordBasedCipher=O.extend({cfg:O.cfg.extend({kdf:M}),encrypt:function(G,V,q,C){C=this.cfg.extend(C);var N=C.kdf.execute(q,G.keySize,G.ivSize,C.salt,C.hasher);C.iv=N.iv;var T=O.encrypt.call(this,G,V,N.key,C);return T.mixIn(N),T},decrypt:function(G,V,q,C){C=this.cfg.extend(C),V=this._parse(V,C.format);var N=C.kdf.execute(q,G.keySize,G.ivSize,V.salt,C.hasher);C.iv=N.iv;var T=O.decrypt.call(this,G,V,N.key,C);return T}})})()})}),kW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CFB=(function(){var r=i.lib.BlockCipherMode.extend();r.Encryptor=r.extend({processBlock:function(s,a){var o=this._cipher,l=o.blockSize;n.call(this,s,a,l,o),this._prevBlock=s.slice(a,a+l)}}),r.Decryptor=r.extend({processBlock:function(s,a){var o=this._cipher,l=o.blockSize,c=s.slice(a,a+l);n.call(this,s,a,l,o),this._prevBlock=c}});function n(s,a,o,l){var c,u=this._iv;u?(c=u.slice(0),this._iv=void 0):c=this._prevBlock,l.encryptBlock(c,0);for(var h=0;h<o;h++)s[a+h]^=c[h]}return r})(),i.mode.CFB})}),FW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CTR=(function(){var r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(s,a){var o=this._cipher,l=o.blockSize,c=this._iv,u=this._counter;c&&(u=this._counter=c.slice(0),this._iv=void 0);var h=u.slice(0);o.encryptBlock(h,0),u[l-1]=u[l-1]+1|0;for(var d=0;d<l;d++)s[a+d]^=h[d]}});return r.Decryptor=n,r})(),i.mode.CTR})}),GW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CTRGladman=(function(){var r=i.lib.BlockCipherMode.extend();function n(o){if((o>>24&255)===255){var l=o>>16&255,c=o>>8&255,u=o&255;l===255?(l=0,c===255?(c=0,u===255?u=0:++u):++c):++l,o=0,o+=l<<16,o+=c<<8,o+=u}else o+=1<<24;return o}function s(o){return(o[0]=n(o[0]))===0&&(o[1]=n(o[1])),o}var a=r.Encryptor=r.extend({processBlock:function(o,l){var c=this._cipher,u=c.blockSize,h=this._iv,d=this._counter;h&&(d=this._counter=h.slice(0),this._iv=void 0),s(d);var p=d.slice(0);c.encryptBlock(p,0);for(var f=0;f<u;f++)o[l+f]^=p[f]}});return r.Decryptor=a,r})(),i.mode.CTRGladman})}),UW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.OFB=(function(){var r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(s,a){var o=this._cipher,l=o.blockSize,c=this._iv,u=this._keystream;c&&(u=this._keystream=c.slice(0),this._iv=void 0),o.encryptBlock(u,0);for(var h=0;h<l;h++)s[a+h]^=u[h]}});return r.Decryptor=n,r})(),i.mode.OFB})}),YW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.ECB=(function(){var r=i.lib.BlockCipherMode.extend();return r.Encryptor=r.extend({processBlock:function(n,s){this._cipher.encryptBlock(n,s)}}),r.Decryptor=r.extend({processBlock:function(n,s){this._cipher.decryptBlock(n,s)}}),r})(),i.mode.ECB})}),VW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.AnsiX923={pad:function(r,n){var s=r.sigBytes,a=n*4,o=a-s%a,l=s+o-1;r.clamp(),r.words[l>>>2]|=o<<24-l%4*8,r.sigBytes+=o},unpad:function(r){var n=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=n}},i.pad.Ansix923})}),HW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.Iso10126={pad:function(r,n){var s=n*4,a=s-r.sigBytes%s;r.concat(i.lib.WordArray.random(a-1)).concat(i.lib.WordArray.create([a<<24],1))},unpad:function(r){var n=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=n}},i.pad.Iso10126})}),jW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.Iso97971={pad:function(r,n){r.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(r,n)},unpad:function(r){i.pad.ZeroPadding.unpad(r),r.sigBytes--}},i.pad.Iso97971})}),zW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.ZeroPadding={pad:function(r,n){var s=n*4;r.clamp(),r.sigBytes+=s-(r.sigBytes%s||s)},unpad:function(r){for(var n=r.words,s=r.sigBytes-1,s=r.sigBytes-1;s>=0;s--)if(n[s>>>2]>>>24-s%4*8&255){r.sigBytes=s+1;break}}},i.pad.ZeroPadding})}),XW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding})}),WW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),la()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var n=i,s=n.lib,a=s.CipherParams,o=n.enc,l=o.Hex,c=n.format,u=c.Hex={stringify:function(h){return h.ciphertext.toString(l)},parse:function(h){var d=l.parse(h);return a.create({ciphertext:d})}}})(),i.format.Hex})}),qW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),Wp(),qp(),vd(),la()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.BlockCipher,a=r.algo,o=[],l=[],c=[],u=[],h=[],d=[],p=[],f=[],m=[],g=[];(function(){for(var E=[],S=0;S<256;S++)S<128?E[S]=S<<1:E[S]=S<<1^283;for(var w=0,x=0,S=0;S<256;S++){var I=x^x<<1^x<<2^x<<3^x<<4;I=I>>>8^I&255^99,o[w]=I,l[I]=w;var A=E[w],O=E[A],R=E[O],M=E[I]*257^I*16843008;c[w]=M<<24|M>>>8,u[w]=M<<16|M>>>16,h[w]=M<<8|M>>>24,d[w]=M;var M=R*16843009^O*65537^A*257^w*16843008;p[I]=M<<24|M>>>8,f[I]=M<<16|M>>>16,m[I]=M<<8|M>>>24,g[I]=M,w?(w=A^E[E[E[R^A]]],x^=E[E[x]]):w=x=1}})();var b=[0,1,2,4,8,16,32,64,128,27,54],y=a.AES=s.extend({_doReset:function(){var E;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var S=this._keyPriorReset=this._key,w=S.words,x=S.sigBytes/4,I=this._nRounds=x+6,A=(I+1)*4,O=this._keySchedule=[],R=0;R<A;R++)R<x?O[R]=w[R]:(E=O[R-1],R%x?x>6&&R%x==4&&(E=o[E>>>24]<<24|o[E>>>16&255]<<16|o[E>>>8&255]<<8|o[E&255]):(E=E<<8|E>>>24,E=o[E>>>24]<<24|o[E>>>16&255]<<16|o[E>>>8&255]<<8|o[E&255],E^=b[R/x|0]<<24),O[R]=O[R-x]^E);for(var M=this._invKeySchedule=[],F=0;F<A;F++){var R=A-F;if(F%4)var E=O[R];else var E=O[R-4];F<4||R<=4?M[F]=E:M[F]=p[o[E>>>24]]^f[o[E>>>16&255]]^m[o[E>>>8&255]]^g[o[E&255]]}}},encryptBlock:function(E,S){this._doCryptBlock(E,S,this._keySchedule,c,u,h,d,o)},decryptBlock:function(E,S){var w=E[S+1];E[S+1]=E[S+3],E[S+3]=w,this._doCryptBlock(E,S,this._invKeySchedule,p,f,m,g,l);var w=E[S+1];E[S+1]=E[S+3],E[S+3]=w},_doCryptBlock:function(E,S,w,x,I,A,O,R){for(var M=this._nRounds,F=E[S]^w[0],G=E[S+1]^w[1],V=E[S+2]^w[2],q=E[S+3]^w[3],C=4,N=1;N<M;N++){var T=x[F>>>24]^I[G>>>16&255]^A[V>>>8&255]^O[q&255]^w[C++],L=x[G>>>24]^I[V>>>16&255]^A[q>>>8&255]^O[F&255]^w[C++],P=x[V>>>24]^I[q>>>16&255]^A[F>>>8&255]^O[G&255]^w[C++],B=x[q>>>24]^I[F>>>16&255]^A[G>>>8&255]^O[V&255]^w[C++];F=T,G=L,V=P,q=B}var T=(R[F>>>24]<<24|R[G>>>16&255]<<16|R[V>>>8&255]<<8|R[q&255])^w[C++],L=(R[G>>>24]<<24|R[V>>>16&255]<<16|R[q>>>8&255]<<8|R[F&255])^w[C++],P=(R[V>>>24]<<24|R[q>>>16&255]<<16|R[F>>>8&255]<<8|R[G&255])^w[C++],B=(R[q>>>24]<<24|R[F>>>16&255]<<16|R[G>>>8&255]<<8|R[V&255])^w[C++];E[S]=T,E[S+1]=L,E[S+2]=P,E[S+3]=B},keySize:256/32});r.AES=s._createHelper(y)})(),i.AES})}),JW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),Wp(),qp(),vd(),la()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.WordArray,a=n.BlockCipher,o=r.algo,l=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],c=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],h=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],d=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],p=o.DES=a.extend({_doReset:function(){for(var b=this._key,y=b.words,E=[],S=0;S<56;S++){var w=l[S]-1;E[S]=y[w>>>5]>>>31-w%32&1}for(var x=this._subKeys=[],I=0;I<16;I++){for(var A=x[I]=[],O=u[I],S=0;S<24;S++)A[S/6|0]|=E[(c[S]-1+O)%28]<<31-S%6,A[4+(S/6|0)]|=E[28+(c[S+24]-1+O)%28]<<31-S%6;A[0]=A[0]<<1|A[0]>>>31;for(var S=1;S<7;S++)A[S]=A[S]>>>(S-1)*4+3;A[7]=A[7]<<5|A[7]>>>27}for(var R=this._invSubKeys=[],S=0;S<16;S++)R[S]=x[15-S]},encryptBlock:function(b,y){this._doCryptBlock(b,y,this._subKeys)},decryptBlock:function(b,y){this._doCryptBlock(b,y,this._invSubKeys)},_doCryptBlock:function(b,y,E){this._lBlock=b[y],this._rBlock=b[y+1],f.call(this,4,252645135),f.call(this,16,65535),m.call(this,2,858993459),m.call(this,8,16711935),f.call(this,1,1431655765);for(var S=0;S<16;S++){for(var w=E[S],x=this._lBlock,I=this._rBlock,A=0,O=0;O<8;O++)A|=h[O][((I^w[O])&d[O])>>>0];this._lBlock=I,this._rBlock=x^A}var R=this._lBlock;this._lBlock=this._rBlock,this._rBlock=R,f.call(this,1,1431655765),m.call(this,8,16711935),m.call(this,2,858993459),f.call(this,16,65535),f.call(this,4,252645135),b[y]=this._lBlock,b[y+1]=this._rBlock},keySize:64/32,ivSize:64/32,blockSize:64/32});function f(b,y){var E=(this._lBlock>>>b^this._rBlock)&y;this._rBlock^=E,this._lBlock^=E<<b}function m(b,y){var E=(this._rBlock>>>b^this._lBlock)&y;this._lBlock^=E,this._rBlock^=E<<b}r.DES=a._createHelper(p);var g=o.TripleDES=a.extend({_doReset:function(){var b=this._key,y=b.words;if(y.length!==2&&y.length!==4&&y.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var E=y.slice(0,2),S=y.length<4?y.slice(0,2):y.slice(2,4),w=y.length<6?y.slice(0,2):y.slice(4,6);this._des1=p.createEncryptor(s.create(E)),this._des2=p.createEncryptor(s.create(S)),this._des3=p.createEncryptor(s.create(w))},encryptBlock:function(b,y){this._des1.encryptBlock(b,y),this._des2.decryptBlock(b,y),this._des3.encryptBlock(b,y)},decryptBlock:function(b,y){this._des3.decryptBlock(b,y),this._des2.encryptBlock(b,y),this._des1.decryptBlock(b,y)},keySize:192/32,ivSize:64/32,blockSize:64/32});r.TripleDES=a._createHelper(g)})(),i.TripleDES})}),KW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),Wp(),qp(),vd(),la()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.StreamCipher,a=r.algo,o=a.RC4=s.extend({_doReset:function(){for(var u=this._key,h=u.words,d=u.sigBytes,p=this._S=[],f=0;f<256;f++)p[f]=f;for(var f=0,m=0;f<256;f++){var g=f%d,b=h[g>>>2]>>>24-g%4*8&255;m=(m+p[f]+b)%256;var y=p[f];p[f]=p[m],p[m]=y}this._i=this._j=0},_doProcessBlock:function(u,h){u[h]^=l.call(this)},keySize:256/32,ivSize:0});function l(){for(var u=this._S,h=this._i,d=this._j,p=0,f=0;f<4;f++){h=(h+1)%256,d=(d+u[h])%256;var m=u[h];u[h]=u[d],u[d]=m,p|=u[(u[h]+u[d])%256]<<24-f*8}return this._i=h,this._j=d,p}r.RC4=s._createHelper(o);var c=a.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var u=this.cfg.drop;u>0;u--)l.call(this)}});r.RC4Drop=s._createHelper(c)})(),i.RC4})}),$W=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),Wp(),qp(),vd(),la()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.StreamCipher,a=r.algo,o=[],l=[],c=[],u=a.Rabbit=s.extend({_doReset:function(){for(var d=this._key.words,p=this.cfg.iv,f=0;f<4;f++)d[f]=(d[f]<<8|d[f]>>>24)&16711935|(d[f]<<24|d[f]>>>8)&4278255360;var m=this._X=[d[0],d[3]<<16|d[2]>>>16,d[1],d[0]<<16|d[3]>>>16,d[2],d[1]<<16|d[0]>>>16,d[3],d[2]<<16|d[1]>>>16],g=this._C=[d[2]<<16|d[2]>>>16,d[0]&4294901760|d[1]&65535,d[3]<<16|d[3]>>>16,d[1]&4294901760|d[2]&65535,d[0]<<16|d[0]>>>16,d[2]&4294901760|d[3]&65535,d[1]<<16|d[1]>>>16,d[3]&4294901760|d[0]&65535];this._b=0;for(var f=0;f<4;f++)h.call(this);for(var f=0;f<8;f++)g[f]^=m[f+4&7];if(p){var b=p.words,y=b[0],E=b[1],S=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360,w=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,x=S>>>16|w&4294901760,I=w<<16|S&65535;g[0]^=S,g[1]^=x,g[2]^=w,g[3]^=I,g[4]^=S,g[5]^=x,g[6]^=w,g[7]^=I;for(var f=0;f<4;f++)h.call(this)}},_doProcessBlock:function(d,p){var f=this._X;h.call(this),o[0]=f[0]^f[5]>>>16^f[3]<<16,o[1]=f[2]^f[7]>>>16^f[5]<<16,o[2]=f[4]^f[1]>>>16^f[7]<<16,o[3]=f[6]^f[3]>>>16^f[1]<<16;for(var m=0;m<4;m++)o[m]=(o[m]<<8|o[m]>>>24)&16711935|(o[m]<<24|o[m]>>>8)&4278255360,d[p+m]^=o[m]},blockSize:128/32,ivSize:64/32});function h(){for(var d=this._X,p=this._C,f=0;f<8;f++)l[f]=p[f];p[0]=p[0]+1295307597+this._b|0,p[1]=p[1]+3545052371+(p[0]>>>0<l[0]>>>0?1:0)|0,p[2]=p[2]+886263092+(p[1]>>>0<l[1]>>>0?1:0)|0,p[3]=p[3]+1295307597+(p[2]>>>0<l[2]>>>0?1:0)|0,p[4]=p[4]+3545052371+(p[3]>>>0<l[3]>>>0?1:0)|0,p[5]=p[5]+886263092+(p[4]>>>0<l[4]>>>0?1:0)|0,p[6]=p[6]+1295307597+(p[5]>>>0<l[5]>>>0?1:0)|0,p[7]=p[7]+3545052371+(p[6]>>>0<l[6]>>>0?1:0)|0,this._b=p[7]>>>0<l[7]>>>0?1:0;for(var f=0;f<8;f++){var m=d[f]+p[f],g=m&65535,b=m>>>16,y=((g*g>>>17)+g*b>>>15)+b*b,E=((m&4294901760)*m|0)+((m&65535)*m|0);c[f]=y^E}d[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,d[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,d[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,d[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,d[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,d[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,d[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,d[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}r.Rabbit=s._createHelper(u)})(),i.Rabbit})}),ZW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),Wp(),qp(),vd(),la()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.StreamCipher,a=r.algo,o=[],l=[],c=[],u=a.RabbitLegacy=s.extend({_doReset:function(){var d=this._key.words,p=this.cfg.iv,f=this._X=[d[0],d[3]<<16|d[2]>>>16,d[1],d[0]<<16|d[3]>>>16,d[2],d[1]<<16|d[0]>>>16,d[3],d[2]<<16|d[1]>>>16],m=this._C=[d[2]<<16|d[2]>>>16,d[0]&4294901760|d[1]&65535,d[3]<<16|d[3]>>>16,d[1]&4294901760|d[2]&65535,d[0]<<16|d[0]>>>16,d[2]&4294901760|d[3]&65535,d[1]<<16|d[1]>>>16,d[3]&4294901760|d[0]&65535];this._b=0;for(var g=0;g<4;g++)h.call(this);for(var g=0;g<8;g++)m[g]^=f[g+4&7];if(p){var b=p.words,y=b[0],E=b[1],S=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360,w=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,x=S>>>16|w&4294901760,I=w<<16|S&65535;m[0]^=S,m[1]^=x,m[2]^=w,m[3]^=I,m[4]^=S,m[5]^=x,m[6]^=w,m[7]^=I;for(var g=0;g<4;g++)h.call(this)}},_doProcessBlock:function(d,p){var f=this._X;h.call(this),o[0]=f[0]^f[5]>>>16^f[3]<<16,o[1]=f[2]^f[7]>>>16^f[5]<<16,o[2]=f[4]^f[1]>>>16^f[7]<<16,o[3]=f[6]^f[3]>>>16^f[1]<<16;for(var m=0;m<4;m++)o[m]=(o[m]<<8|o[m]>>>24)&16711935|(o[m]<<24|o[m]>>>8)&4278255360,d[p+m]^=o[m]},blockSize:128/32,ivSize:64/32});function h(){for(var d=this._X,p=this._C,f=0;f<8;f++)l[f]=p[f];p[0]=p[0]+1295307597+this._b|0,p[1]=p[1]+3545052371+(p[0]>>>0<l[0]>>>0?1:0)|0,p[2]=p[2]+886263092+(p[1]>>>0<l[1]>>>0?1:0)|0,p[3]=p[3]+1295307597+(p[2]>>>0<l[2]>>>0?1:0)|0,p[4]=p[4]+3545052371+(p[3]>>>0<l[3]>>>0?1:0)|0,p[5]=p[5]+886263092+(p[4]>>>0<l[4]>>>0?1:0)|0,p[6]=p[6]+1295307597+(p[5]>>>0<l[5]>>>0?1:0)|0,p[7]=p[7]+3545052371+(p[6]>>>0<l[6]>>>0?1:0)|0,this._b=p[7]>>>0<l[7]>>>0?1:0;for(var f=0;f<8;f++){var m=d[f]+p[f],g=m&65535,b=m>>>16,y=((g*g>>>17)+g*b>>>15)+b*b,E=((m&4294901760)*m|0)+((m&65535)*m|0);c[f]=y^E}d[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,d[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,d[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,d[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,d[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,d[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,d[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,d[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}r.RabbitLegacy=s._createHelper(u)})(),i.RabbitLegacy})}),QW=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),Wp(),qp(),vd(),la()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,n=r.lib,s=n.BlockCipher,a=r.algo;let o=16,l=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],c=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var u={pbox:[],sbox:[]};function h(g,b){let y=b>>24&255,E=b>>16&255,S=b>>8&255,w=b&255,x=g.sbox[0][y]+g.sbox[1][E];return x=x^g.sbox[2][S],x=x+g.sbox[3][w],x}function d(g,b,y){let E=b,S=y,w;for(let x=0;x<o;++x)E=E^g.pbox[x],S=h(g,E)^S,w=E,E=S,S=w;return w=E,E=S,S=w,S=S^g.pbox[o],E=E^g.pbox[o+1],{left:E,right:S}}function p(g,b,y){let E=b,S=y,w;for(let x=o+1;x>1;--x)E=E^g.pbox[x],S=h(g,E)^S,w=E,E=S,S=w;return w=E,E=S,S=w,S=S^g.pbox[1],E=E^g.pbox[0],{left:E,right:S}}function f(g,b,y){for(let I=0;I<4;I++){g.sbox[I]=[];for(let A=0;A<256;A++)g.sbox[I][A]=c[I][A]}let E=0;for(let I=0;I<o+2;I++)g.pbox[I]=l[I]^b[E],E++,E>=y&&(E=0);let S=0,w=0,x=0;for(let I=0;I<o+2;I+=2)x=d(g,S,w),S=x.left,w=x.right,g.pbox[I]=S,g.pbox[I+1]=w;for(let I=0;I<4;I++)for(let A=0;A<256;A+=2)x=d(g,S,w),S=x.left,w=x.right,g.sbox[I][A]=S,g.sbox[I][A+1]=w;return!0}var m=a.Blowfish=s.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var g=this._keyPriorReset=this._key,b=g.words,y=g.sigBytes/4;f(u,b,y)}},encryptBlock:function(g,b){var y=d(u,g[b],g[b+1]);g[b]=y.left,g[b+1]=y.right},decryptBlock:function(g,b){var y=p(u,g[b],g[b+1]);g[b]=y.left,g[b+1]=y.right},blockSize:64/32,keySize:128/32,ivSize:64/32});r.Blowfish=s._createHelper(m)})(),i.Blowfish})}),eq=nr((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(br(),i2(),_W(),PW(),Wp(),LW(),qp(),MM(),PA(),OW(),BM(),RW(),NW(),MW(),LA(),BW(),vd(),la(),kW(),FW(),GW(),UW(),YW(),VW(),HW(),jW(),zW(),XW(),WW(),qW(),JW(),KW(),$W(),ZW(),QW()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./lib-typedarrays","./enc-utf16","./enc-base64","./enc-base64url","./md5","./sha1","./sha256","./sha224","./sha512","./sha384","./sha3","./ripemd160","./hmac","./pbkdf2","./evpkdf","./cipher-core","./mode-cfb","./mode-ctr","./mode-ctr-gladman","./mode-ofb","./mode-ecb","./pad-ansix923","./pad-iso10126","./pad-iso97971","./pad-zeropadding","./pad-nopadding","./format-hex","./aes","./tripledes","./rc4","./rabbit","./rabbit-legacy","./blowfish"],r):i.CryptoJS=r(i.CryptoJS)})(e,function(i){return i})}),tq=(e=>(e.Device="Device",e.Symbol="Symbol",e.Footprint="Footprint",e.OBJ="OBJ",e.ModelID="3D Model",e.ModelName="3D Model Title",e.OriginModelName="Origin 3D Model Title",e.ModelTransform="3D Model Transform",e.OriginFootprint="Origin Footprint",e))(tq||{}),iq=(e=>(e.DOCHEAD="DOCHEAD",e.EDIT_HEAD="EDIT_HEAD",e.SCH="SCH",e.SCH_PAGE="SCH_PAGE",e.PCB="PCB",e.PANEL="PANEL",e.PANEL_LIB="PANEL_LIB",e.SYMBOL="SYMBOL",e.FOOTPRINT="FOOTPRINT",e.DEVICE="DEVICE",e.BLOB="BLOB",e.INSTANCE="INSTANCE",e.CONFIG="CONFIG",e.BOARD="BOARD",e.FONT="FONT",e.VARIANT="VARIANT",e.COMPONENT_GROUP="COMPONENT_GROUP",e.COMPONENT_GROUP_DATA="COMPONENT_GROUP_DATA",e.SIMULATION="SIMULATION",e))(iq||{}),rq=(e=>(e.META="META",e.META_SORT="META_SORT",e.META_CREATE="META_CREATE",e.META_MODIFY="META_MODIFY",e.FONT="FONT",e.BLOB="BLOB",e.MAX_NUM="MAX_NUM",e.INSTANCE_ATTR="INSTANCE_ATTR",e.DELETE_DOC="DELETE_DOC",e.META_Z_INDEX="META_Z_INDEX",e.VARIANT_GROUPED="VARIANT_GROUPED",e.GROUP_INDEX="GROUP_INDEX",e.GROUP_DATA="GROUP_DATA",e.RULE_TEMPLATE="RULE_TEMPLATE",e.RULE="RULE",e.RULE_SELECTOR="RULE_SELECTOR",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e.META_PLACEHOLDER="META_PLACEHOLDER",e))(rq||{});function J0(e,t,i){return e.slice(t,i)}function X3(e,t,i){let r=e.length,n=0;for(;n<r;){let s=e.indexOf(`|
`,n);if(s<0){if(i)return e.substring(n);s=r}let a=J0(e,n,s);try{if(a){let o=a.indexOf("||"),l=o>-1,c=l?J0(a,0,o):a,u=l?J0(a,o+2):"";if(t(c,u,a,l?n+o+2:n)===!1){a=null;break}a=null}}catch(o){console.error(o)}n=s+2}e=null}var nq=["SYMBOL","FOOTPRINT","BLOB","FONT","PANEL_LIB","DEVICE","BOARD","INSTANCE","CONFIG","VARIANT","COMPONENT_GROUP","COMPONENT_GROUP_DATA"];function K0(e,t){return nq.includes(t)?t:e}var OA=class{parseFull(e,t,i){let r=t,n=i,s,a=null;X3(e,(o,l,c)=>{let u=JSON.parse(o);if(u.type==="EDIT_HEAD")a=JSON.parse(l),this.onEditHead&&this.onEditHead(a);else if(u.type==="DOCHEAD"){let h=JSON.parse(l);n=h.docType,r=h.uuid,s=h.client,h.ticket=u.ticket,this.onDocHead(h,a,c)}else this.onLine(u.id,u.ticket,l,u.type,u.client||s,n,r,u.firstTicket,u.pend,a,u.num,c)}),this.onEnd(),e=null}flowParseFull(e={}){let{cache:t,chunkLength:i=100*1024*1024,idsData:r,history:n}=e,s="",a=null,o,l=null,c=!0,u="",h=0,d=!1,p={},f=t?{}:void 0,m=new Set,g=E=>{f[E]===void 0&&(f[E]=-1),t(E,++f[E],p[E].data.join(`|
`)),p[E].data.length=0,p[E].size=0,p[E].data.push(p[E].head),p[E].size+=p[E].head.length},b=E=>{if(m.add(s),!t)return;let S=K0(s,a);p[S].data.push(E),p[S].size+=(p[S].size?2:0)+E.length,p[S].size+E.length>i&&g(S)},y=(E,S)=>X3(E,(w,x,I,A)=>{var O,R,M,F,G,V,q,C;let N=JSON.parse(w);if(N.type==="EDIT_HEAD")l=JSON.parse(x),(O=this.onEditHead)==null||O.call(this,l),(R=e.onEditHead)==null||R.call(e,l),d=!0;else if(N.type==="DOCHEAD"){let T=JSON.parse(x);a=T.docType,s=T.uuid,o=T.client,T.ticket=N.ticket,d||(l={uuid:T.uuid,username:(M=T==null?void 0:T.user)==null?void 0:M.username,nickname:(F=T==null?void 0:T.user)==null?void 0:F.nickname,updateTime:T==null?void 0:T.updateTime},(G=e.onEditHead)==null||G.call(e,l),d=!0),this.onDocHead(T,l,I);let L=K0(s,a);t&&!p[L]&&(p[L]={size:0,data:[],head:""}),t&&(p[L].head=I),b(I)}else{let T=N.num,L=N.client||o;if(r){let P=(C=(q=(V=r.ids)==null?void 0:V[s])==null?void 0:q[L])==null?void 0:C[N.id];if(!P||P[0]!==N.ticket)return;T=P[1],r.size-=1,delete r.ids[s][L][N.id]}if(n){let P=K0(s,a);t&&(n.dNum=(f==null?void 0:f[P])===void 0?0:(f==null?void 0:f[P])+1),n.start=t?p[P].size+2+w.length+2:h+A}this.onLine(N.id,N.ticket,x,N.type,L,a,s,N.firstTicket,N.pend,l||(n==null?void 0:n.editHead),T,I,n),b(I)}},S);return{start:()=>{c=!0},end:()=>{if(u&&y(u,!1),t)for(let E in p)p[E].size&&p[E].data.length>1&&g(E),p[E]=null;c=!1,u="",s="",s=null,o="",l=null,this.onEnd()},update:E=>{if(!c)throw new Error("\u66F4\u65B0\u524D\u672A\u8C03\u7528 start \u65B9\u6CD5");let S=y(u+E,!0);h=h+u.length+E.length-((S==null?void 0:S.length)||0),u="",S&&(u=S)},docMap:f,getDocIds:()=>Array.from(m)}}parseLine(e,t,i){let r=e.indexOf("||"),n=r!==-1,s=n?J0(e,0,r):e,a=n?J0(e,r+2):"",o=JSON.parse(s);this.onLine(o.id,o.ticket,a,o.type,o.client,i,t,o.firstTicket,o.pend,void 0,o.num,e),e=null}onEditHead(e){}},WI=new Uint8Array(8);function Xl(){crypto.getRandomValues(WI);let e="";for(let t=0;t<WI.length;t++)e+=WI[t].toString(16).padStart(2,"0");return e}function qI(e,t,i,r,n,s,a){let o={docType:e,client:t,uuid:i};return(r||r===0)&&(o.updateTime=r),(n||o.updateTime||o.updateTime===0)&&(o.version=n||String(r)),s&&(o.user=s),`${JSON.stringify({type:"DOCHEAD",ticket:a})}||${JSON.stringify(o)}`}function Gp(e,t,i,r,n,s,a,o){let l={type:e,ticket:t,id:i};return s!==void 0&&(l.firstTicket=s),a!==void 0&&(l.pend=a),o!==void 0&&(l.num=o),n&&(l.client=n),`${JSON.stringify(l)}||${r}`}var RA=class extends OA{constructor(e){super(),this.unique=Xl(),this.maxTicket=0,this.isPendChange=!0,this.isLocalChange=!0,this.cbArr=[],this.tempLocalIds={},this.docMaxTicket={},this.client=e||Xl()}onLine(e,t,i,r,n,s,a,o,l,c,u){this.remoteChange(t,n,a,e,i,r,s,void 0,o,l,c,void 0,void 0,u)}getUnique(){return this.unique}setUnique(e){this.unique=e}setDocMaxTicket(e,t,i){i||(!this.docMaxTicket[e]||this.docMaxTicket[e]<t)&&(this.docMaxTicket[e]=t)}getDocMaxTicket(e){var t;return(t=this.docMaxTicket[e])!=null?t:0}onDocHead(e,t){}onEnd(){}setIsPendChange(e){this.isPendChange=e}getIsPendChange(){return this.isPendChange}getMaxTicket(){return this.maxTicket}setMaxTicket(e,t){e&&(t||this.maxTicket<e)&&(this.maxTicket=e)}setIsLocalChange(e){this.isLocalChange=e}getIsLocalChange(){return this.isLocalChange}revoke(e,t,i,r,n,s,a,o,l,c,u){var h;if(!((h=this.tempLocalIds[e])!=null&&h[t]))return u?u(t,n,i,a,`${r}-1`,e,s,void 0,void 0,!0,c):this.cbArr.forEach(d=>d(e,t,i,a,`${r}-1`,n,void 0,s,void 0,void 0,void 0,c)),!0}getRandomUuid(){return Xl()}getClient(){return this.client}onChange(e){this.cbArr.push(e)}localChange(e,t,i,r,n,s){let a=this.maxTicket+1;return this.tempLocalIds[e]||(this.tempLocalIds[e]={}),this.tempLocalIds[e][t]=[this.getClient(),a],this.remoteChange(a,this.client,e,t,i,r,n,!0,void 0,!0,void 0,this.unique,void 0,s),a}remoteChange(e,t,i,r,n,s,a,o,l,c,u,h,d,p){var f;this.setMaxTicket(e);let m=h===this.unique,g=o||m,b=(!g||g&&this.isLocalChange)&&(!d||d&&this.isPendChange),y=(f=this.tempLocalIds[i])==null?void 0:f[r];!o&&m?y?(b=!1,y[0]===t&&y[1]===e&&delete this.tempLocalIds[i][r]):b=!0:!o&&y&&(y[1]>e||y[1]===e&&y[0]>t?b=!1:delete this.tempLocalIds[i][r]),this.setDocMaxTicket(i,e,c),b&&this.cbArr.forEach(E=>E(i,r,n,s,t,e,l,c,void 0,d,h,p))}},sq=class{constructor(e){this.item=e,this.parent=null,this.left=null,this.right=null,this.height=1}getParent(){return this.parent}getLeft(){return this.left}getRight(){return this.right}getHeight(){return this.height}setLeft(e){if(this.left!==null)throw new Error("insert exists left is not permitted");if(e!==null){if(e.parent!==null)throw new Error("insert left with node has parent is not permitted");this.left=e,e.parent=this,this.updateHeight()}}setRight(e){if(this.right!==null)throw new Error("insert exists right is not permitted");if(e!==null){if(e.parent!==null)throw new Error("insert right with node has parent is not permitted");this.right=e,e.parent=this,this.updateHeight()}}removeLeft(){if(this.left===null)return null;{let e=this.left;return e.parent=null,this.left=null,this.updateHeight(),e}}removeRight(){if(this.right===null)return null;{let e=this.right;return e.parent=null,this.right=null,this.updateHeight(),e}}rotateRight(e){let t=this.removeLeft();if(this.setLeft(t.removeRight()),this.parent){let i=this.parent;i.getLeft()===this?(i.removeLeft(),i.setLeft(t)):(i.removeRight(),i.setRight(t)),t.setRight(this)}else t.setRight(this),e(t)}rotateLeft(e){let t=this.removeRight();if(this.setRight(t.removeLeft()),this.parent){let i=this.parent;i.getLeft()===this?(i.removeLeft(),i.setLeft(t)):(i.removeRight(),i.setRight(t)),t.setLeft(this)}else t.setLeft(this),e(t)}updateHeight(){var e,t;let i=this;for(;i!==null;)i.height=Math.max(((e=i.left)==null?void 0:e.height)||0,((t=i.right)==null?void 0:t.height)||0)+1,i=i.parent}},gA=class{constructor(e){this.comparator=e,this.root=null,this.minNode=null,this.maxNode=null,this.size=0}balance(e){var t,i;let r=((t=e.getLeft())==null?void 0:t.getHeight())||0,n=((i=e.getRight())==null?void 0:i.getHeight())||0,s=e.getParent();r>n?r-n>1?(e.rotateRight(a=>this.root=a),this.verify()):s!==null?s.getRight()===e&&(e.rotateRight(a=>this.root=a),this.verify()):(e.rotateRight(a=>this.root=a),this.verify()):n>r&&(n-r>1?(e.rotateLeft(a=>this.root=a),this.verify()):s!==null?s.getLeft()===e&&(e.rotateLeft(a=>this.root=a),this.verify()):(e.rotateLeft(a=>this.root=a),this.verify())),s&&this.balance(s)}forwardTraverse(e){let t=new Array(10),i=this.minNode;for(;i;)switch(t.pop()||2){case 1:i.getLeft()!==null?(t.push(2),t.push(1),i=i.getLeft()):t.push(2);break;case 2:if(!e(i.item))return;i.getRight()!==null?(t.push(3),t.push(1),i=i.getRight()):t.push(3);break;case 3:i=i.getParent();break;default:throw new Error("invalid status")}}backwardTraverse(e){let t=new Array(10),i=this.maxNode;for(;i;)switch(t.pop()||2){case 1:i.getRight()!==null?(t.push(2),t.push(1),i=i.getRight()):t.push(2);break;case 2:if(!e(i.item))return;i.getLeft()!==null?(t.push(3),t.push(1),i=i.getLeft()):t.push(3);break;case 3:i=i.getParent();break;default:throw new Error("invalid status")}}display(e=this.root,t=new Array,i=0){let r="| ".repeat(i);return t.push(r+`\u25CF(${e.item})
`),e.getLeft()?this.display(e.getLeft(),t,i+1):t.push(r+`| \u2609
`),e.getRight()?this.display(e.getRight(),t,i+1):t.push(r+`| \u2609
`),t}getHeight(){var e;return((e=this.root)==null?void 0:e.getHeight())||0}getSize(){return this.size}updateMinMax(e){this.minNode?this.comparator(e.item,this.minNode.item)<0&&(this.minNode=e):this.minNode=e,this.maxNode?this.comparator(e.item,this.maxNode.item)>0&&(this.maxNode=e):this.maxNode=e}insert(e){let t=new sq(e);if(this.root===null)return this.root=t,this.size++,this.updateMinMax(t),!0;{let i=this.root;for(;;){let r=this.comparator(e,i.item);if(r<0){if(i.getLeft()===null)return i.setLeft(t),this.size++,this.updateMinMax(t),this.verify(),this.balance(i),!0;i=i.getLeft()}else if(r>0){if(i.getRight()===null)return i.setRight(t),this.size++,this.updateMinMax(t),this.verify(),this.balance(i),!0;i=i.getRight()}else return!1}}}verify(){}remove(e){let t=this.root;for(this.verify();;){if(t===null)return!1;let i=this.comparator(e,t.item);if(i<0)t=t.getLeft();else if(i>0)t=t.getRight();else return this.minNode===t&&(t.getRight()?this.minNode=this.findMinChild(t.getRight()):this.minNode=t.getParent()),this.maxNode===t&&(t.getLeft()?this.maxNode=this.findMaxChild(t.getLeft()):this.maxNode=t.getParent()),this.removeNode(t),this.size--,this.verify(),!0}}removeNode(e){var t,i;let r=e.getParent();if(r===null)e.getLeft()===null&&e.getRight()===null?(this.root=null,this.minNode=null,this.maxNode=null):((((t=e.getLeft())==null?void 0:t.getHeight())||0)>(((i=e.getRight())==null?void 0:i.getHeight())||0)?(e.rotateRight(n=>this.root=n),this.verify()):(e.rotateLeft(n=>this.root=n),this.verify()),this.removeNode(e));else if(r.getLeft()===e){r.removeLeft();let n=this.combineNodes(e.removeLeft(),e.removeRight());r.setLeft(n),this.verify(),this.balance(r)}else{r.removeRight();let n=this.combineNodes(e.removeLeft(),e.removeRight());r.setRight(n),this.verify(),this.balance(r)}}combineNodes(e,t){if(e&&t)if(e.getHeight()>t.getHeight()){let i=this.findMaxChild(e);if(i){let r=i.getParent();return r.removeRight(),r.setRight(i.removeLeft()),i.setLeft(e),i.setRight(t),i}else return e.setRight(t),e}else{let i=this.findMinChild(t);if(i){let r=i.getParent();return r.removeLeft(),r.setLeft(i.removeRight()),i.setLeft(e),i.setRight(t),i}else return t.setLeft(e),t}else return e||t||null}findMinChild(e){let t=e;for(;;){if(t.getLeft()===null)return t!==e?t:null;t=t.getLeft()}}findMaxChild(e){let t=e;for(;;){if(t.getRight()===null)return t!==e?t:null;t=t.getRight()}}};function Hp(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var aq=(e=>(e.META="META",e.CANVAS="CANVAS",e.GROUP="GROUP",e.POLY="POLY",e.STRING="STRING",e.AUX_LINE="AUXLINE",e.DIMENSION="DIMENSION",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e))(aq||{}),oq=(e=>(e.META="META",e.CANVAS="CANVAS",e.LAYER="LAYER",e.LAYER_PHYS="LAYER_PHYS",e.ACTIVE_LAYER="ACTIVE_LAYER",e.PARTITION="PARTITION",e.NET="NET",e.PRIMITIVE="PRIMITIVE",e.GROUP="GROUP",e.SILK_OPTS="SILK_OPTS",e.PREFERENCE="PREFERENCE",e.VIA="VIA",e.PAD="PAD",e.LINE="LINE",e.ARC="ARC",e.OBJ="OBJ",e.EQLEN_GRP="EQLEN_GRP",e.POLY="POLY",e.FILL="FILL",e.LAYER_FILL="LAYER_FILL",e.REGION="REGION",e.POUR="POUR",e.POURED="POURED",e.IMAGE="IMAGE",e.TEARDROP="TEARDROP",e.FPC_FILL="FPC_FILL",e.SHELL="SHELL",e.CREASE="CREASE",e.SHELLCUT="SHELLCUT",e.SHELL_ENTITY="SHELL_ENTITY",e.BOSS="BOSS",e.STRING="STRING",e.ATTR="ATTR",e.DIMENSION="DIMENSION",e.COMPONENT="COMPONENT",e.PAD_NET="PAD_NET",e.RULE_TEMPLATE="RULE_TEMPLATE",e.RULE="RULE",e.RULE_SELECTOR="RULE_SELECTOR",e.PANELIZE="PANELIZE",e.BOARD="BOARD",e.X_SIGNALS_GROUP="X_SIGNAL_GROUP",e.X_SIGNALS="X_SIGNALS",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e))(oq||{}),lq=(e=>(e.META="META",e.CANVAS="CANVAS",e.GROUP="GROUP",e.ATTR="ATTR",e.LINE="LINE",e.WIRE="WIRE",e.BUS="BUS",e.TEXT="TEXT",e.POLY="POLY",e.CIRCLE="CIRCLE",e.ARC="ARC",e.BUSENTRY="BUSENTRY",e.RECT="RECT",e.MASK_REGION="MASK_REGION",e.PIN="PIN",e.OBJ="OBJ",e.COMPONENT="COMPONENT",e.PART="PART",e.ELLIPSE="ELLIPSE",e.BEZIER="BEZIER",e.TABLE="TABLE",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e.NG_SETTING="NG_SETTING",e))(lq||{});function W3(e,t){return e.ticket===t.ticket?e.client<t.client:e.ticket<t.ticket}var rr=class kM{static find(t,i){return t.last&&i(t.last)?t.last:t.list?t.list.find(i):null}static getFirstTicket(t){var i,r;if(!t)return 0;if(t.last.dataType==="META"){if(t.last.firstTicket!==void 0)return t.last.firstTicket;let n=t.last.ticket;if(t.list)for(let s=t.list.length-1;s>=0;--s){let a=t.list[s];if(a.firstTicket)return a.firstTicket;n=a.ticket}return n}else{let n=kM.getHead(t);return(r=(i=n==null?void 0:n.firstTicket)!=null?i:n==null?void 0:n.ticket)!=null?r:0}}static getHead(t){var i;return((i=t==null?void 0:t.list)==null?void 0:i[0])||t.last}static getPreNode(t,i){if(t.last===i)return t.list?t.list[t.list.length-1]:null;let r=t.list.findIndex(n=>n===i);return t.list[r-1]}static remove(t,i){var r;if(t.last===i)t.last=((r=t.list)==null?void 0:r.pop())||null;else if(t.list){let n=t.list.findIndex(s=>s===i);n>-1&&t.list.slice(n,1)}}static getLength(t){let i=0;return t&&(t.last&&(i+=1),t.list&&(i+=t.list.length)),i}static insert(t,i){if(!t.last){t.last=i;return}if(W3(t.last,i)){let s=t.last;t.last=i,i=s}if(!t.list){t.list=[i];return}let r=0,n=t.list.length;for(;r<n;){let s=Math.floor((r+n)/2);W3(t.list[s],i)?r=s+1:n=s}t.list.splice(r,0,i)}static preForEach(t,i){if(!(!t.last||i(t.last))&&t.list)for(let r=t.list.length-1;r>=0&&!i(t.list[r]);--r);}},FM=["GROUP","POLY","STRING","AUXLINE","DIMENSION"],cq=["PARTITION","VIA","PAD","LINE","ARC","OBJ","POLY","FILL","REGION","POUR","POURED","IMAGE","TEARDROP","FPC_FILL","SHELL","CREASE","SHELLCUT","SHELL_ENTITY","BOSS","STRING","ATTR","DIMENSION","COMPONENT"],uq=["ATTR","WIRE","BUS","TEXT","POLY","CIRCLE","ARC","BUSENTRY","RECT","PIN","OBJ","COMPONENT","PART","ELLIPSE","BEZIER","TABLE","MASK_REGION"],hq=["SCH_PAGE","SIMULATION"],q3=e=>e==="PCB"||e==="FOOTPRINT"?0:1,GM=e=>e==="PCB"||e==="FOOTPRINT"?cq:e==="PANEL"||e==="PANEL_LIB"?FM:e==="SCH_PAGE"||e==="SYMBOL"||e==="SIMULATION"?uq:[];function J3(e,t,i){var r,n;let s=e.get(t),a=e.get(i),o=rr.getHead(s),l=rr.getHead(a),c=(r=o.firstTicket)!=null?r:o.ticket,u=(n=l.firstTicket)!=null?n:l.ticket,h=o.client,d=l.client;return c===u?h===d?t===i?0:t<i?-1:1:h<d?-1:1:c<u?-1:1}var dq=class{constructor(e){this.numSets={},this.orderCbArr=[],this.wDocData=e}orderChange(e){this.orderCbArr.push(e)}setOrderNum(e,t,i,r,n,s){var a,o;let l=r.last.dataType,c=1;if(l==="ELE_PLACEHOLDER"){let f=JSON.parse(r.last.data);l=f.dataType,c=f.max}else if(!((o=(a=GM(t))==null?void 0:a.includes)!=null&&o.call(a,l)))return;if(c<1)throw new Error("step must be greater than 0");let u=Hp(this.numSets[e].orderLists,l,()=>new gA((f,m)=>J3(this.wDocData.get(e),f,m))),h=Hp(this.numSets[e].maxNum,l,()=>q3(t)-1),d=this.wDocData.get(e).get(i);if(s&&(u.remove(i),h-=d.step||1),!rr.getLength(d))return;d.num=0,c>1&&(d.step=c),u.insert(i),h+=c;let p=h;u.backwardTraverse(f=>{let m=this.wDocData.get(e).get(f);return m.num=p,n&&f!==i&&this.orderCbArr.forEach(g=>g(e,f,l,m.num)),p-=m.step||1,f!==i}),this.numSets[e].maxNum[l]=h}removeNode(e,t,i){let r=this.wDocData.get(e).get(i);if(r.num===void 0)return;let n=r.last.dataType,s=Hp(this.numSets[e].orderLists,n,()=>new gA((l,c)=>J3(this.wDocData.get(e),l,c))),a=Hp(this.numSets[e].maxNum,n,()=>q3(t)-1);a-=r.step||1;let o=a;s.backwardTraverse(l=>{if(l===i)return!0;let c=this.wDocData.get(e).get(l);return c.num=o,this.orderCbArr.forEach(u=>u(e,l,n,c.num)),o-=c.step||1,!1}),this.numSets[e].maxNum[n]=a,s.remove(i)}getOrderNum(e,t){var i,r,n;return(n=(r=(i=this.wDocData.get(e))==null?void 0:i.get)==null?void 0:r.call(i,t))==null?void 0:n.num}getMaxNum(e){var t;return((t=this.numSets[e])==null?void 0:t.maxNum)||{}}delete(e){this.numSets[e]&&delete this.numSets[e]}add(e){this.numSets[e]||(this.numSets[e]={orderLists:{},maxNum:{}})}has(e){return!!this.numSets[e]}},pq=Qm(i1()),Mc=(e=>(e.SOLID="SOLID",e.SHORT_DASH="SHORT_DASH",e.DOT="DOT",e.DOT_DASH="DOT_DASH",e))(Mc||{}),ll=(e=>(e.PRINT="PRINT",e.COVER="COVER",e.PRINT_AND_COVER="PRINT&COVER",e))(ll||{}),fq=(e=>(e.LEFT="LEFT",e.CENTER="CENTER",e.RIGHT="RIGHT",e))(fq||{}),mq=(e=>(e.TOP="TOP",e.MIDDLE="MIDDLE",e.BOTTOM="BOTTOM",e))(mq||{}),ds=(e=>(e.LEFT_BOTTOM="LEFT_BOTTOM",e.CENTER_BOTTOM="CENTER_BOTTOM",e.RIGHT_BOTTOM="RIGHT_BOTTOM",e.LEFT_MIDDLE="LEFT_MIDDLE",e.CENTER_MIDDLE="CENTER_MIDDLE",e.RIGHT_MIDDLE="RIGHT_MIDDLE",e.LEFT_TOP="LEFT_TOP",e.CENTER_TOP="CENTER_TOP",e.RIGHT_TOP="RIGHT_TOP",e))(ds||{}),gq=(e=>(e.NONE="NONE",e.SOLID="SOLID",e.GRID="GRID",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e.RHOMBIC="RHOMBIC",e.LEFT_SLASH_LINE="LEFT_SLASH_LINE",e.RIGHT_SLASH_LINE="RIGHT_SLASH_LINE",e))(gq||{}),yq=(e=>(e.NONE="NONE",e.CLOCK="CLOCK",e.INVERTED="INVERTED",e.INVERTED_CLOCK="INVERTED_CLOCK",e))(yq||{}),bq=(e=>(e.NONE="NONE",e.GRID="GRID",e.OUTLETS="OUTLETS",e))(bq||{}),xq=(e=>(e.NONE="NONE",e.PUSH="PUSH",e.SURROUND="SURROUND",e.OBSTRUCT="OBSTRUCT",e.SURROUND_AND_PUSH="SURROUND&PUSH",e))(xq||{}),Eq=(e=>(e.ELLIPSE="ELLIPSE",e.RECT="RECT",e.OVAL="OVAL",e.POLYGON="POLYGON",e))(Eq||{}),Sq=(e=>(e.ROUND="ROUND",e.RECT="RECT",e.SLOT="SLOT",e))(Sq||{}),wq=(e=>(e.SOLID="SOLID",e.GRID_LINE="GRID_LINE",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e))(wq||{}),vq=(e=>(e.ALL="ALL",e.PAD="PAD",e.VIA="VIA",e))(vq||{}),Tq=(e=>(e.NONE="NONE",e.SINGLE="SINGLE",e.ALL="ALL",e))(Tq||{}),Iq=(e=>(e.OPTIMIZA_OPEN="OPTIMIZA_OPEN",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(Iq||{}),Aq=(e=>(e.OPTIMIZA_STRONG="OPTIMIZA_STRONG",e.OPTIMIZA_WEAK="OPTIMIZA_WEAK",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(Aq||{}),Cq=(e=>(e.L45="L45",e.L90="L90",e.L="L",e.R45="R45",e.R90="R90",e.R="R",e))(Cq||{}),Dq=(e=>(e.NORMAL="NORMAL",e.BLIND="BLIND",e.SUTURE="SUTURE",e))(Dq||{}),_q=(e=>(e.NORMAL="NORMAL",e.TEST="TEST",e.MARKER="MARKER",e))(_q||{}),Pq=(e=>(e.DIVERGENCE="DIVERGENCE",e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(Pq||{}),Lq=(e=>(e.DOT="DOT",e.CENTER="CENT",e))(Lq||{}),Oq=(e=>(e.NORMAL="NORMAL",e.BOARD_OUTLINE="BOARD_OUTLINE",e))(Oq||{}),Rq=(e=>(e.SOLID="SOLID",e.GRID="GRID",e.PLANE="PLANE",e))(Rq||{}),Nq=(e=>(e.PROHIBIT="PROHIBIT",e.CONSTRAINT="CONSTRAINT",e))(Nq||{}),Mq=(e=>(e.COMPONENT="COMPONENT",e.VIA="VIA",e.TRACK="TRACK",e.FILL="FILL",e.COPPER="COPPER",e.PLANE="PLANE",e))(Mq||{}),Bq=(e=>(e.PI="Polyimide",e.FR4="FR4",e.STEEL_SHEET="Stainless Steel",e.M3_DOUBLE_SIDED_TAPE="3M Tape",e.EMI_SHIELDING_FILM="EMI Shielding Film",e))(Bq||{}),kq=(e=>(e.PUSH_COVER="DRAWER",e.UPPER_LOWER_SHELLS="T&B",e))(kq||{}),Fq=(e=>(e.X_AXIS_POSITIVE="X_AXIS_POSITIVE",e.X_AXIS_NEGATIVE="X_AXIS_NEGATIVE",e.Y_AXIS_POSITIVE="Y_AXIS_POSITIVE",e.Y_AXIS_NEGATIVE="Y_AXIS_NEGATIVE",e))(Fq||{}),Gq=(e=>(e.SLOT="SLOT",e.ENTITY="ENTITY",e))(Gq||{}),Uq=(e=>(e.AUTO="AUTO",e.UPPER_SHELLS="UPPER_SHELLS",e.LOWER_SHELLS="LOWER_SHELLS",e))(Uq||{}),Yq=(e=>(e.OUTLINE="OUTLINE",e.SCREW_PILLAR="SCREW_PILLAR",e.ENTITY="ENTITY",e))(Yq||{}),Vq=(e=>(e.M2="M2",e.M3="M3",e.M4="M4",e.M5="M5",e.M6="M6",e))(Vq||{}),Hq=(e=>(e.LENGTH="LENGTH",e.RADIUS="RADIUS",e.ANGLE="ANGLE",e))(Hq||{}),jq=(e=>(e.MIL="mil",e.INCH="inch",e.CM="cm",e.MM="mm",e))(jq||{}),zq=(e=>(e.SAFE="SAFE",e.OTHER="OTHER",e.TRACK="TRACK",e.BLIND="BLIND",e.RADIUS="RADIUS",e.PLANE="PLANE",e.COPPER="COPPER",e.PASTE="PASTE",e.SOLDER="SOLDER",e.DIFFER_ENTAIL="DIFFER_ENTAIL",e.NET_LENGTH="NET_LENGTH",e.AUTO_ROUTER="AUTO_ROUTER",e.NET_LENGTH_TOLERANCE="NET_LENGTH_TOLERANCE",e))(zq||{}),Xq=(e=>(e.NORMAL="NORMAL",e.DEFAULT="DEFAULT",e))(Xq||{}),Wq=(e=>(e.ALL="ALL",e.LAYERED="LAYERED",e))(Wq||{}),qq=(e=>(e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(qq||{}),Jq=(e=>(e.FORTY_FIVE="L45",e.NINETY="L90",e.NINETY_ARC="A90",e))(Jq||{}),Kq=(e=>(e.LESS="LESS",e.MID="MID",e.MORE="MORE",e))(Kq||{}),$q=(e=>(e.SPEED_FIRST="SPEED_FIRST",e.COMPLETION_FIRST="COMPLETION_FIRST",e))($q||{}),Zq=(e=>(e.DesignRule="DesignRule",e.Board="Board",e.SlotRegion="SlotRegion",e.ProhibitedRegion="ProhibitedRegion",e.ConstraintRegion="ConstraintRegion",e.Component="Component",e.Track="Track",e.TestPoint="TestPoint",e.Pad="Pad",e.Via="Via",e.SutureHole="SutureHole",e.Text="Text",e.ColorfulImage="ColorfulImage",e.Image="Image",e.FPCStiffener="FPCStiffener",e.Dimension="Dimension",e.CopperRegion="CopperRegion",e.FillRegion="Fill Region",e.Line="Line",e.Teardrop="Teardrop",e.D3Shell="D3Shell",e))(Zq||{}),Qq=Qm(eq());function eJ(e,t){return e.fontFamily==t.fontFamily&&t.text==e.text&&Math.abs(e.fontSize-t.fontSize)<1e-5&&e.reverse==t.reverse&&e.expansion==t.expansion&&e.bold==t.bold&&e.italic==t.italic}function Mm(e,t,i,r,n,s,a,o){return JSON.stringify([e||"",t||"",i,r,n?1:0,s?1:0,a?1:0,o])}function K3(e){let t=JSON.parse(e);return{text:t[0],fontFamily:t[1],fontSize:t[2],thickness:t[3],bold:!!t[4],italic:!!t[5],reverse:!!t[6],expansion:t[7]}}function UM(e){return Qq.default.SHA256(e).toString()}function M0(e,t,i,r){let n="";return i?r?n=e+":"+t:n=e:r?n=t:n="",n}function tJ(e,t){if(!e||!e.startsWith("="))return e;e=e.slice(1);let i=/\{([^\}]+)\}/g,r=[],n=[];for(;r=i.exec(e);)n.push(r[1]);for(let s=0;s<n.length;s++){let a=n[s],o=`{${a}!}`;t.has(a)&&(o=t.get(a)),e=e.replace(`{${a}}`,o)}return e}var _c=class{static getInitProps(){return{stringData:{},dData:{},oData:{},attrData:{},cData:{}}}static collectPcb(e,t,i,r,n){i==="STRING"&&(n.stringData[e]||(n.stringData[e]={}),n.stringData[e][t]=r),i==="DIMENSION"&&(n.dData[e]||(n.dData[e]={}),n.dData[e][t]=r),i==="ATTR"&&(n.attrData[e]||(n.attrData[e]={}),n.attrData[e][t]=r),i==="COMPONENT"&&(n.cData[e]||(n.cData[e]={}),n.cData[e][t]=r),i==="OBJ"&&(n.oData[e]||(n.oData[e]={}),n.oData[e][t]=r)}static collectFt(e,t,i,r,n){i==="STRING"&&(n.stringData[e]||(n.stringData[e]={}),n.stringData[e][t]=r),i==="DIMENSION"&&(n.dData[e]||(n.dData[e]={}),n.dData[e][t]=r),i==="ATTR"&&(n.attrData[e]||(n.attrData[e]={}),n.attrData[e][t]=r),i==="OBJ"&&(n.oData[e]||(n.oData[e]={}),n.oData[e][t]=r)}static collectPanel(e,t,i,r,n){i==="POLY"&&(n.oData[e]||(n.oData[e]={}),n.oData[e][t]=r)}static collectSheet(e,t,i,r,n){i==="OBJ"&&(n.oData[e]||(n.oData[e]={}),n.oData[e][t]=r),i==="ATTR"&&(n.attrData[e]||(n.attrData[e]={}),n.attrData[e][t]=r)}static collectSymbol(e,t,i,r,n){i==="OBJ"&&(n.oData[e]||(n.oData[e]={}),n.oData[e][t]=r)}static pcb(e={},t={},i={},r){var n,s,a,o;let l={devices:new Set,symbols:new Set,footprints:new Set,blobs:new Set,fonts:new Set},c={};for(let h in r.oData)for(let d in r.oData[h]){let p=r.oData[h][d];if(!p)continue;let f=JSON.parse(p);f.path&&f.path.startsWith("blob:")&&l.blobs.add(f.path.split("blob:").pop())}for(let h in r.stringData)for(let d in r.stringData[h]){let p=r.stringData[h][d];if(!p)continue;let f=JSON.parse(p);f.fontFamily==="default"||!f.text||l.fonts.add(Mm(f.text,f.fontFamily,f.fontSize/10,f.strokeWidth,f.bold,f.italic,f.reverse,f.expansion))}for(let h in r.dData)for(let d in r.dData[h]){let p=r.dData[h][d];if(!p)continue;let f=JSON.parse(p).text;f.fontFamily==="default"||!f.text||l.fonts.add(Mm(f.text,f.fontFamily,f.fontSize/10,f.strokeWidth,f.bold,f.italic,f.reverse,f.expansion))}let u={};for(let h in r.attrData)for(let d in r.attrData[h]){let p=r.attrData[h][d];if(!p)continue;let f=JSON.parse(p);u[h]||(u[h]={}),u[h][d]=f,f.key==="Device"&&(c[h]||(c[h]={}),c[h][f.parentId]=f.value)}for(let h in u)for(let d in u[h]){let p=u[h][d];if(!p)continue;let f=p;switch(f.key){case"Device":{f.value&&l.devices.add(f.value);break}case"Symbol":{f.value&&l.symbols.add(f.value);break}case"Footprint":{f.value&&l.footprints.add(f.value);break}}if(f.fontFamily==="default")continue;let m=f.value;if(f.key==="Device"){let g=e[m]||m;m=M0(f.key,g,f.keyVisible,f.valueVisible)}else if(f.key==="Footprint"){let g=t[m]||m;m=M0(f.key,g,f.keyVisible,f.valueVisible)}else if(f.key==="Name"){let g=new Map;if(f.parentId){g.set("ID",f.parentId);let b=(s=(n=r.cData)==null?void 0:n[h])==null?void 0:s[f.parentId];if(b){let y=JSON.parse(b);if(Object.entries(y.attrs).forEach(E=>g.set(E[0],E[1])),(a=c==null?void 0:c[h])!=null&&a[f.parentId]){let E=(o=c==null?void 0:c[h])==null?void 0:o[f.parentId],S=i[E];S&&Object.entries(S).forEach(w=>g.set(w[0],w[1]))}}}m=M0(f.key,tJ(m,g),f.keyVisible,f.valueVisible)}else m=M0(f.key,m,f.keyVisible,f.valueVisible);m&&l.fonts.add(Mm(m,f.fontFamily,f.fontSize/10,f.strokeWidth,f.bold,f.italic,f.reverse,f.expansion))}return l}static footprint(e){let t={blobs:new Set,fonts:new Set};for(let i in e.oData)for(let r in e.oData[i]){let n=e.oData[i][r];if(!n)continue;let s=JSON.parse(n);s.path&&s.path.startsWith("blob:")&&t.blobs.add(s.path.split("blob:").pop())}for(let i in e.stringData)for(let r in e.stringData[i]){let n=e.stringData[i][r];if(!n)continue;let s=JSON.parse(n);s.fontFamily==="default"||!s.text||t.fonts.add(Mm(s.text,s.fontFamily,s.fontSize/10,s.strokeWidth,s.bold,s.italic,s.reverse,s.expansion))}for(let i in e.dData)for(let r in e.dData[i]){let n=e.dData[i][r];if(!n)continue;let s=JSON.parse(n).text;s.fontFamily==="default"||!s.text||t.fonts.add(Mm(s.text,s.fontFamily,s.fontSize/10,s.strokeWidth,s.bold,s.italic,s.reverse,s.expansion))}for(let i in e.attrData)for(let r in e.attrData[i]){let n=e.attrData[i][r];if(!n)continue;let s=JSON.parse(n);if(s.fontFamily==="default"||!s.value)continue;let a=M0(s.key,s.value,s.keyVisible,s.valueVisible);t.fonts.add(Mm(a,s.fontFamily,s.fontSize/10,s.strokeWidth,s.bold,s.italic,s.reverse,s.expansion))}return t}static panel(e){let t={blobs:new Set};for(let i in e.oData)for(let r in e.oData[i]){let n=e.oData[i][r];if(!n)continue;let s=JSON.parse(n);s.fillColor&&s.fillColor.startsWith("blob:")&&t.blobs.add(s.fillColor.split("blob:").pop())}return t}static sheet(e,t){let i={devices:new Set,symbols:new Set,footprints:new Set,blobs:new Set};for(let r in e.oData)for(let n in e.oData[r]){let s=e.oData[r][n];if(!s)continue;let a=JSON.parse(s);a.content&&a.content.startsWith("blob:")&&i.blobs.add(a.content.split("blob:").pop())}for(let r in e.attrData)for(let n in e.attrData[r]){let s=e.attrData[r][n];if(!s)continue;let a=JSON.parse(s);if(a.value)switch(a.key){case"Device":{i.devices.add(a.value);break}case"Symbol":{i.symbols.add(a.value),t&&(t[a.value]=a.parentId);break}case"Footprint":{i.footprints.add(a.value),t&&(t[a.value]=a.parentId);break}}}return{dataSet:i,parentIds:t}}static symbol(e){let t={blobs:new Set};for(let i in e.oData)for(let r in e.oData[i]){let n=e.oData[i][r];if(!n)continue;let s=JSON.parse(n);s.content&&s.content.startsWith("blob:")&&t.blobs.add(s.content.split("blob:").pop())}return t}},iJ=Object.create(null),rJ=class extends RA{constructor(e){super(e),this.creators={},this.headCbArr=[],this.docHead={},this.uniqueIds={},this.cacheType=["META","DELETE_DOC","ELE_PLACEHOLDER","META_PLACEHOLDER","VARIANT_GROUPED"],this.historyMap={},this.clearTime=null,this.currentTime=0,this.wDocData=new Map,this.orderTree=new dq(this.wDocData)}onLine(e,t,i,r,n,s,a,o,l,c,u,h,d){this.remoteChange(t,n,a,e,i,r,s,void 0,o,l,c,void 0,void 0,void 0,d)}onDocHead(e,t){e.updateTime=e.updateTime||(t==null?void 0:t.updateTime),e.user=e.user||{uuid:t==null?void 0:t.uuid,username:t==null?void 0:t.username,nickname:t==null?void 0:t.nickname},this.setMaxTicket(e.ticket),this.docHead[e.uuid]?(!this.docHead[e.uuid].updateTime||this.docHead[e.uuid].updateTime<e.updateTime)&&(this.docHead[e.uuid].client=e.uuid,this.docHead[e.uuid].user=e.user,this.docHead[e.uuid].updateTime=e.updateTime,this.docHead[e.uuid].version=e.version,this.docHead[e.uuid].docType=e.docType,this.docHead[e.uuid].uuid=e.uuid,e.ticket&&e.ticket>this.docHead[e.uuid].ticket&&(this.docHead[e.uuid].ticket=e.ticket)):this.docHead[e.uuid]=e,this.creators[e.uuid]?this.creators[e.uuid].createTime>e.updateTime&&(this.creators[e.uuid].createTime=e.updateTime,this.creators[e.uuid].creator=e.user):this.creators[e.uuid]={createTime:e.updateTime,creator:e.user};for(let i of this.headCbArr)i(e,t)}onHeadChange(e){this.headCbArr.push(e)}setCacheData(e){this.getCache=e}setDoctype(e,t){this.docHead[e]?this.docHead[e].docType=t:this.docHead[e]={docType:t}}getDoctype(e){var t,i;return(i=(t=this.docHead)==null?void 0:t[e])==null?void 0:i.docType}getDataTicket(e,t){var i,r,n,s,a,o;return(o=(a=(s=(n=(r=(i=this.wDocData)==null?void 0:i.get)==null?void 0:r.call(i,e))==null?void 0:n.get)==null?void 0:s.call(n,t))==null?void 0:a.last)==null?void 0:o.ticket}getDataClient(e,t){var i,r,n,s,a,o;return(o=(a=(s=(n=(r=(i=this.wDocData)==null?void 0:i.get)==null?void 0:r.call(i,e))==null?void 0:n.get)==null?void 0:s.call(n,t))==null?void 0:a.last)==null?void 0:o.client}getAtomData(e,t){var i,r,n,s,a;return(a=(s=(n=(r=(i=this.wDocData)==null?void 0:i.get)==null?void 0:r.call(i,e))==null?void 0:n.get)==null?void 0:s.call(n,t))==null?void 0:a.last}getDataSize(e,t){var i,r,n,s;return rr.getLength((s=(n=(r=(i=this.wDocData)==null?void 0:i.get)==null?void 0:r.call(i,e))==null?void 0:n.get)==null?void 0:s.call(n,t))}getFirst(e,t){var i,r,n,s,a;let o=(s=(n=(r=(i=this.wDocData)==null?void 0:i.get)==null?void 0:r.call(i,e))==null?void 0:n.get)==null?void 0:s.call(n,t);return((a=o==null?void 0:o.list)==null?void 0:a[0])||o.last}getFirstTicket(e,t){var i,r;return rr.getFirstTicket((r=(i=this.wDocData.get(e))==null?void 0:i.get)==null?void 0:r.call(i,t))}getAllDataId(e){let t=[],i=e||this.wDocData.keys();for(let r of i){let n={doc:r,ids:[]},s=this.wDocData.get(r);if(s){for(let[a]of s)n.ids.push(a);n.ids.length&&t.push(n)}}return t}clear(){for(let[,e]of this.wDocData)e.clear();this.wDocData.clear(),this.creators={}}isHasData(e){if(e){if(this.uniqueIds[e]){for(let t in this.uniqueIds[e])if(this.uniqueIds[e][t].size)return!0}}else for(let[,t]of this.wDocData)for(let[,,]of t)return!0;return!1}delayClear(e=!0){this.clearTime||(this.clearTime=setTimeout(()=>{if(Date.now()-this.currentTime<5e3)this.clearTime=null,this.delayClear(!1);else{let t=!1;for(let i in this.historyMap)for(let r in this.historyMap[i])for(let n in this.historyMap[i][r])for(let s in this.historyMap[i][r][n])this.historyMap[i][r][n][s].promise?(this.clearTime=null,this.delayClear(!1),t=!0):(this.historyMap[i][r][n][s].cache.end(),this.historyMap[i][r][n][s].cache=null,delete this.historyMap[i][r][n][s]);!t&&(this.clearTime=null)}},5e3)),e&&(this.currentTime=Date.now())}getForeachKeys(e){let t=this.wDocData.keys(),i=[],r=[],n=[],s=[],a=[],o=[],l=[],c=[],u=[];for(let h of t)switch(this.getDoctype(h)){case"DEVICE":i.push(h);break;case"FOOTPRINT":n.push(h);break;case"SYMBOL":r.push(h);break;case"BOARD":s.push(h);break;case"SCH":a.push(h);break;case"SCH_PAGE":o.push(h);break;case"PCB":l.push(h);break;case"FONT":case"BLOB":u.push(h);break;default:c.push(h);break}return[...n,...r,...i,...s,...a,...o,...l,...c,...u]}getLastData(e,t,i){let r=this.wDocData.get(e);if(!r)return;let n=r.get(t);if(!n)return;let s=null;return rr.preForEach(n,a=>!!a.pend==!!i?(s=a,!0):!1),s}revoke(){return!1}getPublishRevoke(e){let t={},i=(s,a,o,l,c,u,h)=>{var d,p,f;let m;h.length&&rr.getLength(c)===h.length&&this.orderTree.has(s)&&(this.orderTree.removeNode(s,this.getDoctype(s),a),m=(f=(p=(d=this.orderTree.numSets)==null?void 0:d[s])==null?void 0:p.maxNum)==null?void 0:f[l.dataType],delete c.num),e&&e(s,a,u||"",o?o.client:l.client,o?o.ticket:l.ticket,l.client,l.ticket,o?o.pend:void 0,o?o.dataType:l.dataType,rr.getFirstTicket(c),m),h.forEach(g=>rr.remove(c,g))},r=(s,a,o,l,c,u)=>{var h;if(!this.getCache||!c||(h=c.data)!=null&&h.length||c.data===""||!c.hId)i(s,a,c,l,o,c==null?void 0:c.data,u);else{let d=c.dNum||0;t[c.hId]||(t[c.hId]={}),t[c.hId][c.hNum]||(t[c.hId][c.hNum]={}),t[c.hId][c.hNum][s]||(t[c.hId][c.hNum][s]=[]),t[c.hId][c.hNum][s][d]||(t[c.hId][c.hNum][s][d]=[]),t[c.hId][c.hNum][s][d].push([a,o,l,c,u])}},n=async(s,a,o,l,c)=>{let u=this.getCache(),h=K0(o,this.getDoctype(o));await u.init(s,a,h,l);for(let d of c){let[p,f,m,g,b]=d;if(f.last===m){let y=u.get(g.start);i(o,p,g,m,f,y,b)}else b.forEach(y=>rr.remove(f,y))}};return{update:r,end:()=>{if(this.getCache){for(let s in t)for(let a in t[s])for(let o in t[s][a])for(let l in t[s][a][o])n(s,a,o,l,t[s][a][o][l]);t=null}}}}handleRevoke(e,t,i,r,n,s){let a=[];rr.preForEach(i,o=>{if(o.pend&&(!n||o.client===n)){if(a.push(o),o===i.last){let l=rr.getPreNode(i,o);if(s)for(;l&&l.pend;)a.push(l),l=rr.getPreNode(i,l);r.update(e,t,i,o,l,a)}else a.forEach(l=>rr.remove(i,l));return!0}return!1}),rr.getLength(i)||this.wDocData.get(e).delete(t)}revokeOne(e,t,i){let r=this.wDocData.get(e);if(!r)return;let n=r.get(t);n&&this.handleRevoke(e,t,n,i)}foreachRevokeAll(e,t=this.getClient()){let i=this.getForeachKeys(),r=this.getPublishRevoke(e);for(let n of i){let s=this.wDocData.get(n);for(let[a,o]of s)this.handleRevoke(n,a,o,r,t,!0)}r.end()}getUniqueDocs(e,t={}){if(!this.uniqueIds[e])return t;for(let i in this.uniqueIds[e]){let r=t[i]||new Set;for(let n of this.uniqueIds[e][i])r.add(n);t[i]=r}return t}revokeByUnique(e,t,i){let r=this.uniqueIds[e];if(r)for(let n in r)this.revokeAll(n,t,Array.from(r[n]),i),r[n].clear()}revokeAll(e,t,i,r){let n=this.wDocData.get(e);if(!n)return;let s=this.getPublishRevoke(r);for(let a of i){let o=n.get(a);o&&this.handleRevoke(e,a,o,s,t)}s.end()}findPreDataByTime(e,t,i,r,n){let s=this.wDocData.get(e);if(!s)return null;let a=s.get(t);if(!a)return null;let o=null,l=0;return rr.preForEach(a,c=>{let u=n(c==null?void 0:c.hId,c==null?void 0:c.hNum);return u&&(u<i||u===i&&c.client<r)&&(o?(u>l||u===l&&c.client>o.client)&&(o=c,l=u):(o=c,l=u)),!1}),o}isFilterData(e,t,i){return!!(!e||t.ignoreType&&t.ignoreType.includes(e.dataType)||t.needType&&!t.needType.includes(e.dataType)||t.isPend&&!e.pend||i&&!t.needDelete&&t.needNum&&e.data==="")}getCanvasIds(e){var t;let i=0,r={},n={},s=[],a=[],o=10*1024*1024,l=0,c=(d,p,f)=>{var m;let g=f.last;if(g.pend||(m=g.data)!=null&&m.length){l+g.data.length>o&&(s.push(a),a=[]);let b=[d,p,g.ticket,g.client,g.dataType,g.data,g.pend];e.needNum&&b.push(f.num),a.push(b);return}r[d][g.client]||(r[d][g.client]={}),r[d][g.client][p]=[g.ticket],e.needNum&&r[d][g.client][p].push(f.num),i+=1},u=d=>{let p=d.last;return!!(e.ignoreType&&e.ignoreType.includes(p.dataType)||p.dataType==="ELE_PLACEHOLDER"||!e.needDelete&&p.data==="")};for(let d of e.doc){let p=(t=this.wDocData)==null?void 0:t.get(d);if(!p)continue;r[d]={};let f=this.getDoctype(d);if(e.needNum&&!["BLOB"].includes(f)&&!this.orderTree.has(d)){this.orderTree.add(d);let m=Array.from(p.keys()).sort((g,b)=>{let y=rr.getHead(p.get(g)),E=rr.getHead(p.get(b)),S=y.firstTicket||y.ticket,w=E.firstTicket||E.ticket;return S===w?y.client>E.client?1:-1:S-w});for(let g of m){let b=p.get(g);b&&(b.num&&(b.num=void 0),this.orderTree.setOrderNum(d,f,g,b,!1),!u(b)&&c(d,g,b))}}else for(let[m,g]of p)u(g)||c(d,m,g);n[d]=this.orderTree.getMaxNum(d)}a.length&&(s.push(a),a=null);let h;return s.length&&(h=Xl(),(0,pq.flowWrite)(h,async d=>{for(let p of s)await d.write(JSON.stringify(p)),p.length=0;s.length=0},void 0,void 0)),{ids:r,maxNum:n,size:i,channel:h}}async compress(e,t,i){var r,n,s,a,o,l,c,u,h,d,p,f,m,g,b,y,E,S,w,x,I,A,O,R,M,F,G,V,q,C,N,T,L,P,B,U,X,J,ne,fe,xe;let{updateTime:ve,versions:Fe,keepClient:Ne,keepFirst:nt,notDocHead:je,isPend:vt,user:Bt}=e,{headTicket:Oi,clearDelete:Ti,needNum:ze,uniqueId:D,client:z,extractData:$}=e,{removeBoard:K,eIds:ee,notChangePend:pe}=e,ce=e.docIds||(ee?[]:void 0),Be=Ti&&!!$;if(D&&this.uniqueIds[D]&&(ce=Object.keys(this.uniqueIds[D]),e.docIds&&(ce=ce.filter(tt=>e.docIds.includes(tt)))),ce||(ce=this.getForeachKeys(Be)),ee)for(let tt in ee)ce.some(li=>li===tt)||ce.push(tt);let st,pt;Be&&(st=new Set,pt=new Set);for(let tt of ce){let li=(r=this.wDocData)==null?void 0:r.get(tt);if(!li){ze&&!["FONT","BLOB"].includes(tt)&&!this.orderTree.has(tt)&&this.orderTree.add(tt);continue}let Ji=ve||((s=(n=this.docHead)==null?void 0:n[tt])==null?void 0:s.updateTime)||new Date().getTime(),cr=(Fe==null?void 0:Fe[tt])||((o=(a=this.docHead)==null?void 0:a[tt])==null?void 0:o.version)||String(Ji),Bi=this.getDoctype(tt);if(Ti){let Zt=li.get("DELETE_DOC");if(Zt&&Zt.last.data&&(l=JSON.parse(Zt.last.data))!=null&&l.isDelete){if(hq.includes(Bi)){let Er=li.get("META"),mt=Er?JSON.parse(Er.last.data):null,dn=!!mt;if(Bi==="SCH_PAGE"&&dn){let rs=(c=this.wDocData)==null?void 0:c.get(mt.schematic),di=(h=(u=rs.get("DELETE_DOC"))==null?void 0:u.last)==null?void 0:h.data;dn=rs&&(!di||di&&!((d=JSON.parse(di))!=null&&d.isDelete))}if(dn){let rs=qI(((f=(p=this.docHead)==null?void 0:p[tt])==null?void 0:f.docType)||this.mainDocType,z||this.getClient(),tt,Ji,cr,Bt||((g=(m=this.docHead)==null?void 0:m[tt])==null?void 0:g.user),Oi||((y=(b=this.docHead)==null?void 0:b[tt])==null?void 0:y.ticket));i(rs)?await t(rs,!0):t(rs,!0);let di=Gp("DELETE_DOC",rr.getFirstTicket(Zt),"DELETE_DOC",Zt.last.data);if(i(di)?await t(di):t(di),Er){if(Bi==="SCH_PAGE"){for(let[vn,ha]of li)if(ha.last.dataType==="META_PLACEHOLDER"&&ha.last.data){let Yu=Gp("META_PLACEHOLDER",rr.getFirstTicket(ha),mt.schematic,ha.last.data);i(Yu)?await t(Yu):t(Yu)}}let Ii=Gp("META",rr.getFirstTicket(Er),"META",Er.last.data);i(Ii)?await t(Ii):t(Ii)}}}continue}}let An;if(tt==="FONT"&&st){An=[];for(let Zt of st)An.push(K3(Zt))}if(!je){let Zt=qI(((S=(E=this.docHead)==null?void 0:E[tt])==null?void 0:S.docType)||this.mainDocType,z||this.getClient(),tt,Ji,cr,Bt||((x=(w=this.docHead)==null?void 0:w[tt])==null?void 0:x.user),Oi||((A=(I=this.docHead)==null?void 0:I[tt])==null?void 0:A.ticket));D&&this.onDocHead({docType:((R=(O=this.docHead)==null?void 0:O[tt])==null?void 0:R.docType)||this.mainDocType,uuid:tt,client:z||this.getClient(),updateTime:Ji,version:cr,user:Bt||((F=(M=this.docHead)==null?void 0:M[tt])==null?void 0:F.user),ticket:Oi||((V=(G=this.docHead)==null?void 0:G[tt])==null?void 0:V.ticket)}),i(Zt)?await t(Zt,!0):t(Zt,!0)}if(!je&&e.needCreator){let Zt=qI(((C=(q=this.docHead)==null?void 0:q[tt])==null?void 0:C.docType)||this.mainDocType,z||this.getClient(),tt,(T=(N=this.creators)==null?void 0:N[tt])==null?void 0:T.createTime,cr,(P=(L=this.creators)==null?void 0:L[tt])==null?void 0:P.creator,Oi||((U=(B=this.docHead)==null?void 0:B[tt])==null?void 0:U.ticket));i(Zt)?await t(Zt):t(Zt)}let Mr;if(D&&(Mr=Array.from(this.uniqueIds[D][tt]),this.uniqueIds[D][tt].clear(),delete this.uniqueIds[D][tt]),ee&&ee[tt]&&(Mr=ee[tt]),Mr||(Mr=ze||Ti?Array.from(li.keys()).sort((Zt,Er)=>{let mt=rr.getHead(li.get(Zt)),dn=rr.getHead(li.get(Er)),rs=mt.firstTicket||mt.ticket,di=dn.firstTicket||dn.ticket;return rs===di?mt.client>dn.client?1:-1:rs-di}):Array.from(li.keys())),ze&&!["FONT","BLOB"].includes(Bi)&&!this.orderTree.has(tt)){this.orderTree.add(tt);for(let Zt of Mr){let Er=li.get(Zt);Er&&(this.isFilterData(Er.last,e,!1)||(Er.num&&(Er.num=void 0),this.orderTree.setOrderNum(tt,Bi,Zt,Er,!1)))}}let Or={},Cn=0,ua=_c.getInitProps();for(let Zt of Mr){let Er=li.get(Zt);if(!Er)continue;let mt;if(D?rr.preForEach(Er,di=>di.unique===D?(mt=di,delete di.unique,pe||(delete di.pend,this.setDocMaxTicket(tt,di.ticket,di.pend),di===Er.last&&this.cbArr.forEach(Ii=>Ii(tt,Zt,di.data,di.dataType,di.client,di.ticket,rr.getFirstTicket(Er),void 0,void 0,!0,void 0))),!0):!1):mt=Er.last,this.isFilterData(mt,e,!0))continue;if(Be&&tt==="FONT"&&An){let di=K3(Zt);if(!An.some(Ii=>eJ(di,Ii)))continue}if(Be&&tt==="BLOB"&&!pt.has(Zt))continue;if(vt&&mt.pend&&!pe&&(delete mt.pend,this.setDocMaxTicket(tt,mt.ticket,!1),this.cbArr.forEach(di=>di(tt,Zt,mt.data,mt.dataType,mt.client,mt.ticket,rr.getFirstTicket(Er),void 0,void 0,!0,void 0))),Ti){if(mt.dataType==="ELE_PLACEHOLDER"){let Ii=JSON.parse(mt.data);Or[Ii.dataType]===void 0?Or[Ii.dataType]=Ii.max:Or[Ii.dataType]+=Ii.max;continue}let di=GM(Bi);if(di&&di.includes(mt.dataType))if(mt.data!==""){if(Or[mt.dataType]){let Ii={dataType:mt.dataType,max:Or[mt.dataType]},vn=Gp("ELE_PLACEHOLDER",rr.getFirstTicket(Er)-1,`placeholder${++Cn}`,JSON.stringify(Ii));i(vn)?await t(vn):t(vn),delete Or[mt.dataType]}}else{Or[mt.dataType]===void 0?Or[mt.dataType]=1:++Or[mt.dataType];continue}}let dn=mt.data;if(this.getCache&&mt.hId&&mt.data===void 0){let di=mt.dNum||0,Ii=K0(tt,Bi);if(!((xe=(fe=(ne=(J=(X=this.historyMap)==null?void 0:X[mt.hId])==null?void 0:J[mt.hNum])==null?void 0:ne[Ii])==null?void 0:fe[di])!=null&&xe.cache)){this.historyMap[mt.hId]||(this.historyMap[mt.hId]={}),this.historyMap[mt.hId][mt.hNum]||(this.historyMap[mt.hId][mt.hNum]={}),this.historyMap[mt.hId][mt.hNum][Ii]||(this.historyMap[mt.hId][mt.hNum][Ii]={}),this.historyMap[mt.hId][mt.hNum][Ii][di]||(this.historyMap[mt.hId][mt.hNum][Ii][di]={cache:null,promise:null});let vn=this.getCache();this.historyMap[mt.hId][mt.hNum][Ii][di].cache=vn;let ha=vn.init(mt.hId,mt.hNum,Ii,di);this.historyMap[mt.hId][mt.hNum][Ii][di].promise=ha,await ha,delete this.historyMap[mt.hId][mt.hNum][Ii][di].promise}this.historyMap[mt.hId][mt.hNum][Ii][di].promise&&await this.historyMap[mt.hId][mt.hNum][Ii][di].promise,dn=this.historyMap[mt.hId][mt.hNum][Ii][di].cache.get(mt.start)}if(mt.dataType==="META"&&K&&K.includes(tt)&&dn){let di=JSON.parse(dn);di.board&&(di.board="",dn=JSON.stringify(di))}let rs=Gp(mt.dataType,mt.ticket,Zt,dn,Ne?mt.client:void 0,nt&&mt.ticket!==rr.getFirstTicket(Er)?rr.getFirstTicket(Er):void 0,void 0,ze?Er.num:void 0);if(Be)switch(Bi){case"PCB":{_c.collectPcb(tt,Zt,mt.dataType,dn,ua);break}case"FOOTPRINT":{_c.collectFt(tt,Zt,mt.dataType,dn,ua);break}case"PANEL":{_c.collectPanel(tt,Zt,mt.dataType,dn,ua);break}case"SYMBOL":{_c.collectSymbol(tt,Zt,mt.dataType,dn,ua);break}case"SCH_PAGE":case"SIMULATION":{_c.collectSymbol(tt,Zt,mt.dataType,dn,ua);break}default:break}i(rs)?await t(rs):t(rs)}if(ze){let Zt=Gp("MAX_NUM",1,"MAX_NUM",JSON.stringify(this.orderTree.getMaxNum(tt)));i(Zt)?await t(Zt):t(Zt)}if(Be){let Zt;switch(Bi){case"PCB":{Zt=_c.pcb($.deviceNames,$.footprintNames,$.deviceAttrs,ua);break}case"FOOTPRINT":{Zt=_c.footprint(ua);break}case"PANEL":{Zt=_c.panel(ua);break}case"SYMBOL":{Zt=_c.symbol(ua);break}case"SCH_PAGE":case"SIMULATION":{Zt=_c.sheet(ua).dataSet;break}default:break}if(Zt!=null&&Zt.fonts)for(let Er of Zt.fonts)st.add(Er);if(Zt!=null&&Zt.blobs)for(let Er of Zt.blobs)pt.add(Er)}}}compressFull(e={}){if(this.getCache)throw new Error("\u6570\u636E\u5DF2\u7F13\u5B58\u5230 cacheStorage, \u4E0D\u5141\u8BB8\u540C\u6B65\u83B7\u53D6");let t=[],i=r=>{t.push(r)};return this.compress(e,i,()=>!1),t.join(`|
`)}async chunkCompressFull(e={}){let{chunkLength:t=20*1024*1024}=e,i=new Array,r=[],n=0,s="",a=l=>this.getCache?n+l.length>t:!1,o=async(l,c)=>{n+l.length>t&&(r.push(i.join(`|
`)),i.length=0,!c&&i.push(s),n=0),c&&(s=l),i.push(l),n+=l.length+2};return await this.compress(e,o,a),i.length>0&&(r.push(i.join(`|
`)),i.length=0,n=0),this.getCache&&this.delayClear(),r}async asyncCompressFull(e={}){let t=[],i=r=>{t.push(r)};return await this.compress(e,i,()=>!1),this.delayClear(),t.join(`|
`)}async flowCompressFull(e){let{writer:t,chunkLength:i=1e7}=e,r=new Array,n=0,s=o=>n+o.length>i,a=async o=>{n+o.length>i&&(await t(r.join(`|
`)),r.length=0,r.push(""),n=0),r.push(o),n+=o.length+2};await this.compress(e,a,s),r.length>0&&(await t(r.join(`|
`)),r.length=0,n=0),this.delayClear()}removeCache(e){if(e)for(let t=0;t<e.length;t++)this.wDocData.delete(e[t]);else this.wDocData.clear()}setMainDoctype(e){this.mainDocType=e}onChange(e){this.cbArr.push(e)}localChange(e,t,i,r,n){let s=this.getMaxTicket()+1;return this.remoteChange(s,this.getClient(),e,t,i,r,n,!0,void 0,!0,void 0,this.getUnique()),s}safeString(e){return e&&(e in iJ,e)}remoteChange(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f){var m,g,b,y,E;this.setMaxTicket(e),a&&this.setDoctype(i,a),o=o||h===this.getUnique();let S=(y=(b=(g=(m=this.wDocData)==null?void 0:m.get)==null?void 0:g.call(m,i))==null?void 0:b.get(r))==null?void 0:y.last;h&&(this.uniqueIds[h]||(this.uniqueIds[h]={}),this.uniqueIds[h][i]||(this.uniqueIds[h][i]=new Set),this.uniqueIds[h][i].add(r)),this.wDocData.get(i)||this.wDocData.set(i,new Map),this.wDocData.get(i).has(r)||this.wDocData.get(i).set(r,{last:null});let w=this.wDocData.get(i).get(r),x=S?rr.getFirstTicket(w):null,I=S&&S.ticket===e&&S.client===t&&!!S.pend!=!!c,A=s!=="ELE_PLACEHOLDER"&&(!o||o&&this.getIsLocalChange())&&(!I||I&&this.getIsPendChange()),O=rr.find(w,G=>G.client===t&&G.ticket===e);if(O){this.setDocMaxTicket(i,e,c),f&&(O.hId=f.uuid,O.hNum=f.num,O.start=f.start,f.dNum&&(O.dNum=f.dNum)),this.getCache&&!this.cacheType.includes(s)&&(E=O.data)!=null&&E.length&&O!=null&&O.hId&&delete O.data,O.pend&&!c&&(delete O.pend,A&&O===w.last&&this.cbArr.forEach(G=>G(i,r,n,s,t,e,rr.getFirstTicket(w),c,void 0,I,h)));return}let R=e;if(c){let G=[];rr.preForEach(w,V=>V.client===t&&V.pend&&V.ticket<e?(G.push(V),!0):!1),G.length&&G.length===rr.getLength(w)&&(R=x||e),G.forEach(V=>{rr.remove(w,V)})}let M={client:t,ticket:R,dataType:s};f&&(M.hId=f.uuid,M.hNum=f.num,M.start=f.start,f.dNum&&(M.dNum=f.dNum)),(!this.getCache||!M.hId||!n||this.cacheType.includes(s)||c)&&(M.data=c?n:this.safeString(n)),l!==void 0&&(M.firstTicket=l),c!==void 0&&(M.pend=c),h!==void 0&&(M.unique=h);let F=!S||S.ticket<e||S.ticket===e&&S.client<t;if(rr.insert(w,M),this.orderTree.has(i)&&(!S||x>e))try{this.orderTree.setOrderNum(i,this.getDoctype(i),r,w,!0,x&&x>e)}catch(G){console.error(G)}if(this.setDocMaxTicket(i,R,c),F){let G=rr.getFirstTicket(w);A&&this.cbArr.forEach(V=>V(i,r,n,s,t,e,G,c,void 0,I,h))}}};function nJ(e,t){return e.ticket===t.ticket?e.client===t.client?e.id===t.id?0:e.id<t.id?-1:1:e.client<t.client?-1:1:e.ticket<t.ticket?-1:1}var sJ=class{constructor(e=1){this.startNum=e,this.orderLists={},this.idOrderLists={},this.cbArr=new Array,this.maxNum={}}orderChange(e){this.cbArr.push(e)}setOrderNum(e,t,i,r,n=1){if(n<1)throw new Error("step must be greater than 0");let s=Hp(this.orderLists,t,()=>new gA(nJ)),a=Hp(this.maxNum,t,()=>this.startNum-1),o=Hp(this.idOrderLists,t,()=>new Map),l=o.get(e);if(l){if(l.ticket<=i)return;s.remove(l),a-=l.step}let c={id:e,ticket:i,num:0,client:r,step:n};o.set(e,c),s.insert(c),a+=n;let u=a,h=0;s.backwardTraverse(d=>(h++,d.num=u,this.cbArr.forEach(p=>p(d.id,t,d.num)),u-=d.step,d!==c)),this.maxNum[t]=a,h>1e4&&(console.log("------------------ notify --------",c,"height: ",s.getHeight(),"total: ",s.getSize(),"notifies: ",h),console.log("------------------ all --------"))}getOrderNum(e,t){var i,r,n,s;return(s=(n=(r=(i=this.idOrderLists)==null?void 0:i[t])==null?void 0:r.get)==null?void 0:n.call(r,e))==null?void 0:s.num}getMaxNum(e){var t;return((t=this.orderLists[e])==null?void 0:t.getSize())||0}clearNum(){for(let e in this.idOrderLists)this.idOrderLists[e].clear(),delete this.idOrderLists[e];for(let e in this.orderLists)delete this.orderLists[e]}},aJ=class{constructor(e,t=1,i=[]){this.consistencyManager=e,this.startNum=t,this.needOrderType=i,this.initIng=!1,this.allOrderNum={},this.maxNum={},this.consistencyManager.onChange((r,n,s,a,o,l,c,u,h,d,p,f)=>{try{if(this.calculation)if(a==="ELE_PLACEHOLDER"){let m=s?JSON.parse(s):null;m&&this.calculation.setOrderNum(n,m.dataType,c!=null?c:l,o,m.max)}else this.calculation.setOrderNum(n,a,c!=null?c:l,o);this.onParseLine(n,a,s?JSON.parse(s):null,o,l,u,f)}catch(m){console.error(m)}})}initCalculation(){this.calculation=new sJ(this.startNum)}setIsInit(e){this.initIng=e}setNeedNum(e){this.needNum=e}setOrderNum(e,t,i){this.needNum&&this.needOrderType&&this.needOrderType.includes(i)&&t!==void 0&&(this.allOrderNum[e]=t,this.setMaxNum(i,t))}deleteOrderNum(e){delete this.allOrderNum[e]}getOrderNum(e){return this.allOrderNum[e]}setMaxNum(e,t,i){(i||this.maxNum[e]===void 0||this.maxNum[e]<t)&&(this.maxNum[e]=t)}getMaxNum(e){return this.maxNum[e]===void 0&&(this.maxNum[e]=this.startNum-1),++this.maxNum[e]}};var oJ=Object.create,YM=Object.defineProperty,lJ=Object.getOwnPropertyDescriptor,cJ=Object.getOwnPropertyNames,uJ=Object.getPrototypeOf,hJ=Object.prototype.hasOwnProperty,dJ=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),pJ=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of cJ(t))!hJ.call(e,n)&&n!==i&&YM(e,n,{get:()=>t[n],enumerable:!(r=lJ(t,n))||r.enumerable});return e},fJ=(e,t,i)=>(i=e!=null?oJ(uJ(e)):{},pJ(t||!e||!e.__esModule?YM(i,"default",{value:e,enumerable:!0}):i,e)),mJ=dJ((e,t)=>{"use strict";t.exports=i,t.exports.default=i;function i(T,L,P){P=P||2;var B=L&&L.length,U=B?L[0]*P:T.length,X=r(T,0,U,P,!0),J=[];if(!X||X.next===X.prev)return J;var ne,fe,xe,ve,Fe,Ne,nt;if(B&&(X=u(T,L,X,P)),T.length>80*P){ne=xe=T[0],fe=ve=T[1];for(var je=P;je<U;je+=P)Fe=T[je],Ne=T[je+1],Fe<ne&&(ne=Fe),Ne<fe&&(fe=Ne),Fe>xe&&(xe=Fe),Ne>ve&&(ve=Ne);nt=Math.max(xe-ne,ve-fe),nt=nt!==0?32767/nt:0}return s(X,J,P,ne,fe,nt,0),J}function r(T,L,P,B,U){var X,J;if(U===N(T,L,P,B)>0)for(X=L;X<P;X+=B)J=V(X,T[X],T[X+1],J);else for(X=P-B;X>=L;X-=B)J=V(X,T[X],T[X+1],J);return J&&x(J,J.next)&&(q(J),J=J.next),J}function n(T,L){if(!T)return T;L||(L=T);var P=T,B;do if(B=!1,!P.steiner&&(x(P,P.next)||w(P.prev,P,P.next)===0)){if(q(P),P=L=P.prev,P===P.next)break;B=!0}else P=P.next;while(B||P!==L);return L}function s(T,L,P,B,U,X,J){if(T){!J&&X&&m(T,B,U,X);for(var ne=T,fe,xe;T.prev!==T.next;){if(fe=T.prev,xe=T.next,X?o(T,B,U,X):a(T)){L.push(fe.i/P|0),L.push(T.i/P|0),L.push(xe.i/P|0),q(T),T=xe.next,ne=xe.next;continue}if(T=xe,T===ne){J?J===1?(T=l(n(T),L,P),s(T,L,P,B,U,X,2)):J===2&&c(T,L,P,B,U,X):s(n(T),L,P,B,U,X,1);break}}}}function a(T){var L=T.prev,P=T,B=T.next;if(w(L,P,B)>=0)return!1;for(var U=L.x,X=P.x,J=B.x,ne=L.y,fe=P.y,xe=B.y,ve=U<X?U<J?U:J:X<J?X:J,Fe=ne<fe?ne<xe?ne:xe:fe<xe?fe:xe,Ne=U>X?U>J?U:J:X>J?X:J,nt=ne>fe?ne>xe?ne:xe:fe>xe?fe:xe,je=B.next;je!==L;){if(je.x>=ve&&je.x<=Ne&&je.y>=Fe&&je.y<=nt&&E(U,ne,X,fe,J,xe,je.x,je.y)&&w(je.prev,je,je.next)>=0)return!1;je=je.next}return!0}function o(T,L,P,B){var U=T.prev,X=T,J=T.next;if(w(U,X,J)>=0)return!1;for(var ne=U.x,fe=X.x,xe=J.x,ve=U.y,Fe=X.y,Ne=J.y,nt=ne<fe?ne<xe?ne:xe:fe<xe?fe:xe,je=ve<Fe?ve<Ne?ve:Ne:Fe<Ne?Fe:Ne,vt=ne>fe?ne>xe?ne:xe:fe>xe?fe:xe,Bt=ve>Fe?ve>Ne?ve:Ne:Fe>Ne?Fe:Ne,Oi=b(nt,je,L,P,B),Ti=b(vt,Bt,L,P,B),ze=T.prevZ,D=T.nextZ;ze&&ze.z>=Oi&&D&&D.z<=Ti;){if(ze.x>=nt&&ze.x<=vt&&ze.y>=je&&ze.y<=Bt&&ze!==U&&ze!==J&&E(ne,ve,fe,Fe,xe,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0||(ze=ze.prevZ,D.x>=nt&&D.x<=vt&&D.y>=je&&D.y<=Bt&&D!==U&&D!==J&&E(ne,ve,fe,Fe,xe,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0))return!1;D=D.nextZ}for(;ze&&ze.z>=Oi;){if(ze.x>=nt&&ze.x<=vt&&ze.y>=je&&ze.y<=Bt&&ze!==U&&ze!==J&&E(ne,ve,fe,Fe,xe,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0)return!1;ze=ze.prevZ}for(;D&&D.z<=Ti;){if(D.x>=nt&&D.x<=vt&&D.y>=je&&D.y<=Bt&&D!==U&&D!==J&&E(ne,ve,fe,Fe,xe,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0)return!1;D=D.nextZ}return!0}function l(T,L,P){var B=T;do{var U=B.prev,X=B.next.next;!x(U,X)&&I(U,B,B.next,X)&&M(U,X)&&M(X,U)&&(L.push(U.i/P|0),L.push(B.i/P|0),L.push(X.i/P|0),q(B),q(B.next),B=T=X),B=B.next}while(B!==T);return n(B)}function c(T,L,P,B,U,X){var J=T;do{for(var ne=J.next.next;ne!==J.prev;){if(J.i!==ne.i&&S(J,ne)){var fe=G(J,ne);J=n(J,J.next),fe=n(fe,fe.next),s(J,L,P,B,U,X,0),s(fe,L,P,B,U,X,0);return}ne=ne.next}J=J.next}while(J!==T)}function u(T,L,P,B){var U=[],X,J,ne,fe,xe;for(X=0,J=L.length;X<J;X++)ne=L[X]*B,fe=X<J-1?L[X+1]*B:T.length,xe=r(T,ne,fe,B,!1),xe===xe.next&&(xe.steiner=!0),U.push(y(xe));for(U.sort(h),X=0;X<U.length;X++)P=d(U[X],P);return P}function h(T,L){return T.x-L.x}function d(T,L){var P=p(T,L);if(!P)return L;var B=G(P,T);return n(B,B.next),n(P,P.next)}function p(T,L){var P=L,B=T.x,U=T.y,X=-1/0,J;do{if(U<=P.y&&U>=P.next.y&&P.next.y!==P.y){var ne=P.x+(U-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(ne<=B&&ne>X&&(X=ne,J=P.x<P.next.x?P:P.next,ne===B))return J}P=P.next}while(P!==L);if(!J)return null;var fe=J,xe=J.x,ve=J.y,Fe=1/0,Ne;P=J;do B>=P.x&&P.x>=xe&&B!==P.x&&E(U<ve?B:X,U,xe,ve,U<ve?X:B,U,P.x,P.y)&&(Ne=Math.abs(U-P.y)/(B-P.x),M(P,T)&&(Ne<Fe||Ne===Fe&&(P.x>J.x||P.x===J.x&&f(J,P)))&&(J=P,Fe=Ne)),P=P.next;while(P!==fe);return J}function f(T,L){return w(T.prev,T,L.prev)<0&&w(L.next,T,T.next)<0}function m(T,L,P,B){var U=T;do U.z===0&&(U.z=b(U.x,U.y,L,P,B)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==T);U.prevZ.nextZ=null,U.prevZ=null,g(U)}function g(T){var L,P,B,U,X,J,ne,fe,xe=1;do{for(P=T,T=null,X=null,J=0;P;){for(J++,B=P,ne=0,L=0;L<xe&&(ne++,B=B.nextZ,!!B);L++);for(fe=xe;ne>0||fe>0&&B;)ne!==0&&(fe===0||!B||P.z<=B.z)?(U=P,P=P.nextZ,ne--):(U=B,B=B.nextZ,fe--),X?X.nextZ=U:T=U,U.prevZ=X,X=U;P=B}X.nextZ=null,xe*=2}while(J>1);return T}function b(T,L,P,B,U){return T=(T-P)*U|0,L=(L-B)*U|0,T=(T|T<<8)&16711935,T=(T|T<<4)&252645135,T=(T|T<<2)&858993459,T=(T|T<<1)&1431655765,L=(L|L<<8)&16711935,L=(L|L<<4)&252645135,L=(L|L<<2)&858993459,L=(L|L<<1)&1431655765,T|L<<1}function y(T){var L=T,P=T;do(L.x<P.x||L.x===P.x&&L.y<P.y)&&(P=L),L=L.next;while(L!==T);return P}function E(T,L,P,B,U,X,J,ne){return(U-J)*(L-ne)>=(T-J)*(X-ne)&&(T-J)*(B-ne)>=(P-J)*(L-ne)&&(P-J)*(X-ne)>=(U-J)*(B-ne)}function S(T,L){return T.next.i!==L.i&&T.prev.i!==L.i&&!R(T,L)&&(M(T,L)&&M(L,T)&&F(T,L)&&(w(T.prev,T,L.prev)||w(T,L.prev,L))||x(T,L)&&w(T.prev,T,T.next)>0&&w(L.prev,L,L.next)>0)}function w(T,L,P){return(L.y-T.y)*(P.x-L.x)-(L.x-T.x)*(P.y-L.y)}function x(T,L){return T.x===L.x&&T.y===L.y}function I(T,L,P,B){var U=O(w(T,L,P)),X=O(w(T,L,B)),J=O(w(P,B,T)),ne=O(w(P,B,L));return!!(U!==X&&J!==ne||U===0&&A(T,P,L)||X===0&&A(T,B,L)||J===0&&A(P,T,B)||ne===0&&A(P,L,B))}function A(T,L,P){return L.x<=Math.max(T.x,P.x)&&L.x>=Math.min(T.x,P.x)&&L.y<=Math.max(T.y,P.y)&&L.y>=Math.min(T.y,P.y)}function O(T){return T>0?1:T<0?-1:0}function R(T,L){var P=T;do{if(P.i!==T.i&&P.next.i!==T.i&&P.i!==L.i&&P.next.i!==L.i&&I(P,P.next,T,L))return!0;P=P.next}while(P!==T);return!1}function M(T,L){return w(T.prev,T,T.next)<0?w(T,L,T.next)>=0&&w(T,T.prev,L)>=0:w(T,L,T.prev)<0||w(T,T.next,L)<0}function F(T,L){var P=T,B=!1,U=(T.x+L.x)/2,X=(T.y+L.y)/2;do P.y>X!=P.next.y>X&&P.next.y!==P.y&&U<(P.next.x-P.x)*(X-P.y)/(P.next.y-P.y)+P.x&&(B=!B),P=P.next;while(P!==T);return B}function G(T,L){var P=new C(T.i,T.x,T.y),B=new C(L.i,L.x,L.y),U=T.next,X=L.prev;return T.next=L,L.prev=T,P.next=U,U.prev=P,B.next=P,P.prev=B,X.next=B,B.prev=X,B}function V(T,L,P,B){var U=new C(T,L,P);return B?(U.next=B.next,U.prev=B,B.next.prev=U,B.next=U):(U.prev=U,U.next=U),U}function q(T){T.next.prev=T.prev,T.prev.next=T.next,T.prevZ&&(T.prevZ.nextZ=T.nextZ),T.nextZ&&(T.nextZ.prevZ=T.prevZ)}function C(T,L,P){this.i=T,this.x=L,this.y=P,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(T,L,P,B){var U=L&&L.length,X=U?L[0]*P:T.length,J=Math.abs(N(T,0,X,P));if(U)for(var ne=0,fe=L.length;ne<fe;ne++){var xe=L[ne]*P,ve=ne<fe-1?L[ne+1]*P:T.length;J-=Math.abs(N(T,xe,ve,P))}var Fe=0;for(ne=0;ne<B.length;ne+=3){var Ne=B[ne]*P,nt=B[ne+1]*P,je=B[ne+2]*P;Fe+=Math.abs((T[Ne]-T[je])*(T[nt+1]-T[Ne+1])-(T[Ne]-T[nt])*(T[je+1]-T[Ne+1]))}return J===0&&Fe===0?0:Math.abs((Fe-J)/J)};function N(T,L,P,B){for(var U=0,X=L,J=P-B;X<P;X+=B)U+=(T[J]-T[X])*(T[X+1]+T[J+1]),J=X;return U}i.flatten=function(T){for(var L=T[0][0].length,P={vertices:[],holes:[],dimensions:L},B=0,U=0;U<T.length;U++){for(var X=0;X<T[U].length;X++)for(var J=0;J<L;J++)P.vertices.push(T[U][X][J]);U>0&&(B+=T[U-1].length,P.holes.push(B))}return P}}),gJ=(e=>(e[e.MIL=1]="MIL",e[e.INCH=1e3]="INCH",e[e.FT=12e3]="FT",e[e.YARD=36e3]="YARD",e[e.MILE=6336e4]="MILE",e[e.KM=3937007874e-2]="KM",e[e.M=39370]="M",e[e.DM=3937]="DM",e[e.CM=393.7]="CM",e[e.MM=39.37]="MM",e[e.UM=.039]="UM",e[e.NM=394e-7]="NM",e[e.PT=13.88888888888889]="PT",e[e.PX72=13.88888888888889]="PX72",e[e.PX96=10.416666666666666]="PX96",e[e.PX100=10]="PX100",e[e.LTSPICE=6.25]="LTSPICE",e[e.PX1=.1]="PX1",e[e.PX001=.001]="PX001",e))(gJ||{}),yJ=(e=>(e.MIL="mil",e.INCH="inch",e.FT="ft",e.YARD="yard",e.MILE="mile",e.KM="km",e.M="m",e.DM="dm",e.CM="cm",e.MM="mm",e.UM="um",e.NM="nm",e.PT="pt",e.PX72="px(72)",e.PX96="px(96)",e.PX100="px(100)",e))(yJ||{}),$3={mil:1,inch:1e3,ft:12e3,yard:36e3,mile:6336e4,km:3937007874e-2,dm:3937,mm:39.37,um:.039,nm:394e-7,pt:13.88888888888889,"px(72)":13.88888888888889,"px(96)":10.416666666666666,"px(100)":10},Rle=(()=>{let e={};for(let t in $3)e[$3[t]]=t;return e})(),wE,Nle=(wE=class{constructor(e,t){this.ratio=e/t}wrap(e){return e*this.ratio}static convert(e,t,i){return e*t/i}},wE.ASIS=new wE(1,1),wE),vE=class{conversion(e,t,i){if(e===t)return i;let r=e+2+t;return this[r](i)}conversion1(e,t,i){let r=e+2+t,n=this[r](i);return t=="mil"?Math.round(n*10)/10:Math.round(n*1e3)/1e3}mil2mil(e){return e}mil2mm(e){return e*.0254}mil2cm(e){return e*.00254}mil2inch(e){return e/1e3}mm2mm(e){return e}mm2mil(e){let t=Math.pow(10,5);return Math.round(e*39.37007874015748*t)/t}mm2cm(e){return e/10}mm2inch(e){let t=Math.pow(10,8);return Math.round(e*.03937007874015748*t)/t}cm2mil(e){let t=Math.pow(10,6);return Math.round(e*393.7007874015748*t)/t}cm2mm(e){return e*10}cm2inch(e){let t=Math.pow(10,7);return Math.round(e*.3937007874015748*t)/t}inch2mil(e){return e*1e3}inch2mm(e){return e*25.4}inch2cm(e){return e*2.54}};vE.prototype["px(100)2mil"]=e=>e*10,vE.prototype["px(100)2mm"]=e=>e*.254,vE.prototype["mil2px(100)"]=e=>e/10,vE.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var TE=null,NA=new ArrayBuffer(8),JI=new Float64Array(NA),KI=new Uint32Array(NA),Z3=new Uint16Array(NA),Q3=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,n){if(e.length>=t+n&&i.length>=r+n)for(;n-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let n=0;n<t;n++){let s=e.charAt(n);if(r>=0){if(s===";"){let a=e.substring(r+1,n);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else s==="&"?r=n:i.push(s)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let n=0;n<r;n++)e[n]===t&&(e.splice(n,1),n--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!TE){let e=this.getUrlVars().version;e?TE="/analyzer/v"+e:TE="/analyzer"}return TE}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;JI[0]=new Date().getTime(),e.push(KI[1].toString(16)),JI[0]=Math.random(),e.push(Z3[3].toString(16));let t=Z3[2].toString(16);e.push("4"+t.substr(0,3)),JI[0]=performance.now();let i=KI[0].toString(16)+KI[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},VM=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(Wm.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(Wm.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(Wm.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(Wm.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},bJ=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(bJ||{}),xJ=/(\.?0+)$/,Wm=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,n=0,s,a=0,o=0;for(let l=0;l<e.length;l++){let c=e.charAt(l),u=c.charCodeAt(0);switch(r){case 0:u===37?r=1:i.push(c);break;case 1:switch(u){case 100:if(s=t[n++],typeof s=="number")i.push(s.toFixed(0)),r=0;else return l;break;case 102:if(s=t[n++],typeof s=="number")i.push(s.toString()),r=0;else return l;break;case 120:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16)),r=0;else return l;break;case 88:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:s=t[n++],i.push(s===null?"null":s.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(u){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(Q3.lpad((s|0).toString(16),"0",h)),r=0;else return l}else return l;break;case 88:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(Q3.lpad((s|0).toString(16).toUpperCase(),"0",h)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let n=e.exec(t);if(n!==null){let s=e.lastIndex-n[0].length;i.push(t.substring(r,s)),r=e.lastIndex}else{let s=t.substring(r);VM.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(xJ,"")}},EJ=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARNING=2]="WARNING",e[e.ERROR=3]="ERROR",e[e.DUMMY=4]="DUMMY",e))(EJ||{});function SJ(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var wJ=(e,t)=>{e===3?console.error(t):console.log(t)},vJ=(e,t)=>Wm.format("%s %s: %s",new Date,SJ(e),t),Bm,r2=(Bm=class{constructor(e,t=wJ,i=vJ){this.debug=!1,this.level=e,this.writer=t,this.fmt=i}static mix(...e){let t=4;for(let i of e)i.level<t&&(t=i.level);return new Bm(t,(i,r)=>{for(let n of e)n.write1(i,r)},(i,r)=>r)}wrap(e=null,t=null){let i=e===null?this.fmt:(n,s)=>(s=e(n,s),this.fmt(n,s)),r=t===null?this.writer:(n,s)=>{t(n,s),this.writer(n,s)};return new Bm(this.level,r,i)}chain(e){return e.wrap(this.fmt.bind(this),this.writer.bind(this))}include(e){return this.level<=e}write3(e,t,i){this.include(e)&&this.writer(e,this.fmt(e,Wm.format(t,...i)))}write2(e,t){this.include(e)&&(t instanceof Error?this.writer(e,this.fmt(e,t.stack)):this.writer(e,this.fmt(e,t.toString())))}write1(e,t){this.include(e)&&this.writer(e,this.fmt(e,t))}debug3(e,...t){this.write3(0,e,t)}debug2(e){this.write2(0,e)}debug1(e){this.write1(0,e)}info3(e,...t){this.write3(1,e,t)}info2(e){this.write2(1,e)}info1(e){this.write1(1,e)}warning3(e,...t){this.write3(2,e,t)}warning2(e){this.write2(2,e)}warning1(e){this.write1(2,e)}error3(e,...t){this.write3(3,e,t)}error2(e){this.write2(3,e)}error1(e){this.write1(3,e)}},Bm.DUMMY=new Bm(4),Bm),MA=new ArrayBuffer(8),$I=new Float64Array(MA),ZI=new Uint32Array(MA),eM=new Uint16Array(MA),tM=ArrayBuffer;try{tM=self.HTMLImageElement||tM}catch{}var IE=null;function zp(e,t,i=0,r=e.length){n(e,null,t,i,r);function n(a,o,l,c,u){let h,d,p,f;if(c<u-1){let m=u-c;if(m>50)o===null&&(o=new Array(m+1)),s(a,o,l,c,(c+u)/2|0,u);else{h=a[c],d=c,p=c,f=u;let g=d+1;for(;g<f;){if(p!=f){if(f=f+-1,l(h,a[f])<=0)continue;a[p]=a[f],p=f;continue}if(l(h,a[g])>=0){d=g,g=d+1;continue}a[p]=a[g],d=g,p=g,g=d+1}a[p]=h,n(a,o,l,c,p),n(a,o,l,p+1,u)}}}function s(a,o,l,c,u,h){n(a,o,l,c,u),n(a,o,l,u,h);for(var d=c,p=u,f=0,m=a[d],g=a[p];d<u&&p<h;){var b=l(m,g);isNaN(b)?(o[f++]=g,g=a[++p]):(b<=0&&(o[f++]=m,m=a[++d]),b>=0&&(o[f++]=g,g=a[++p]))}for(;d<u;d++)o[f++]=a[d];for(;p<h;p++)o[f++]=a[p];for(d=c,p=0;p<f;d++,p++)a[d]=o[p]}}var Ia=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,n){if(e.length>=t+n&&i.length>=r+n)for(;n-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let n=0;n<t;n++){let s=e.charAt(n);if(r>=0){if(s===";"){let a=e.substring(r+1,n);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else s==="&"?r=n:i.push(s)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let n=0;n<r;n++)e[n]===t&&(e.splice(n,1),n--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!IE){let e=this.getUrlVars().version;e?IE="/analyzer/v"+e:IE="/analyzer"}return IE}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;$I[0]=new Date().getTime(),e.push(ZI[1].toString(16)),$I[0]=Math.random(),e.push(eM[3].toString(16));let t=eM[2].toString(16);e.push("4"+t.substr(0,3)),$I[0]=performance.now();let i=ZI[0].toString(16)+ZI[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},TJ=[1,10,100,1e3],AE=0,kp=0;function iM(e,t,i){return AE=Math.abs(e-t),i>=5&&AE>1e-5||isNaN(i)&&AE>1e-8?!1:AE<1e-13?!0:(kp=Math.min(rM(e),rM(t)),kp<10&&(kp=10),isNaN(i)||(kp=Math.min(kp,i)),nM(e,kp)===nM(t,kp))}var CE=0,DE=0;function rM(e){return CE=0,DE=0,e>0?CE=e-Math.floor(e):CE=e-Math.ceil(e),DE=(CE.toString()||"").length,DE>2?DE-2:0}function nM(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=TJ[t]||Math.pow(10,t)||10;if(i){var n=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(n+e)}else return Math.round(e*r+1e-10)/r}var IJ=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(IJ||{}),AJ=/(\.?0+)$/,qm=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,n=0,s,a=0,o=0;for(let l=0;l<e.length;l++){let c=e.charAt(l),u=c.charCodeAt(0);switch(r){case 0:u===37?r=1:i.push(c);break;case 1:switch(u){case 100:if(s=t[n++],typeof s=="number")i.push(s.toFixed(0)),r=0;else return l;break;case 102:if(s=t[n++],typeof s=="number")i.push(s.toString()),r=0;else return l;break;case 120:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16)),r=0;else return l;break;case 88:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:s=t[n++],i.push(s===null?"null":s.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(u){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(Ia.lpad((s|0).toString(16),"0",h)),r=0;else return l}else return l;break;case 88:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(Ia.lpad((s|0).toString(16).toUpperCase(),"0",h)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let n=e.exec(t);if(n!==null){let s=e.lastIndex-n[0].length;i.push(t.substring(r,s)),r=e.lastIndex}else{let s=t.substring(r);an.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(AJ,"")}},an=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(qm.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(qm.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(qm.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(qm.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},_E,Re=(_E=class{static regular(e){return Math.round(e*this.precision)/this.precision}static eq(e,t){return Math.abs(e-t)<=this.eps}static neq(e,t){return Math.abs(e-t)>this.eps}static less(e,t){return e-t<-this.eps}static lesseq(e,t){return e-t<=this.eps}static greater(e,t){return e-t>this.eps}static greatereq(e,t){return e-t>=-this.eps}static sqrt(e){return Math.abs(e)<=1e-10?0:Math.sqrt(e)}static sortAsc(e,t){return e-t}static sortDesc(e,t){return t-e}},_E.eps=1e-8,_E.precision=1e8,_E);function Km(e,t){XE(e.iterator(),t)}function XE(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var CJ=class{constructor(e){this.idx=-1,this.lst=e}hasNext(){return this.idx<this.lst.length-1}next(){if(this.idx<this.lst.length-1)return this.idx++,this.lst[this.idx];throw new Error("bug")}};function yA(e){return new CJ(e)}var va,ti=(va=class{static toDegrees(e){return e*180/Math.PI}static toRadians(e){return e/180*Math.PI}static regularD(e){return e=e%360,e=e<0?360+e:e,e===360?0:e}static regular(e){return e=e%va.PIx2,e=e<0?va.PIx2+e:e,e===va.PIx2?0:e}static toQuarterBase(e){return va.regular((e+va.PI_4)/va.PI_2*va.PI_2)}static toQuarterBaseD(e){return va.regularD(((e+45)/90|0)*90)}static transformD(e,t){return va.toDegrees(va.transform(va.toRadians(e),t))}static transform(e,t){let i=Math.cos(e),r=Math.sin(e),n=new Ie(t.data[6],t.data[7]),s=new Ie(i,r).multiply3(t);return va.regular(s.angle(n))}},va.PIx2=Math.PI*2,va.PI_2=Math.PI/2,va.PI_4=Math.PI/4,va),Ln=class{static dotProd1(e,t,i,r){return e*i+t*r}static dotProd2(e,t,i,r,n,s){return this.dotProd1(i-e,r-t,n-i,s-r)}static dotProd3(e,t,i){return this.dotProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static crossProd1(e,t,i,r){return e*r-t*i}static crossProd2(e,t,i,r,n,s){return this.crossProd1(i-e,r-t,n-i,s-r)}static crossProd3(e,t,i){return this.crossProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static distance2(e,t,i,r){let n=i-e,s=r-t;return n*n+s*s}static distance1(e,t,i,r){return this.hypot(i-e,r-t)}static distance1p(e,t){return this.distance1(e.x,e.y,t.x,t.y)}static hypot(e,t){if(e=Math.abs(e),t=Math.abs(t),t>e){var i=t;t=e,e=i}if(e===0)return t;var r=t/e;return e*Math.sqrt(1+r*r)}},HM=new ArrayBuffer(16),sM=new Float64Array(HM),PE=new Int32Array(HM),ir,Ie=(ir=class{static sortByXAsc(e,t){return e.x-t.x}static sortByYAsc(e,t){return e.y-t.y}static sortByXYAsc(e,t){return e.x<t.x?-1:e.x>t.x?1:e.y-t.y}static caculateAngle(e,t){let i=Math.cos(e),r=Math.sin(e),n=i*t.data[0]+r*t.data[4],s=i*t.data[1]+r*t.data[5],a=new ir(n,s).normalize();return Math.atan2(a.y,a.x)}static normal(e,t,i){let r=t.sub(e),n=i.sub(t);return r.cross(n)}static getVector2(e){return new ir(Math.cos(e),Math.sin(e))}static getCrossPoint1(e,t,i,r){if(e.equals1(t)||i.equals1(r)||Re.eq(1,Math.abs(t.sub(e).normalize().dot(r.sub(i).normalize()))))return null;let n=t.y-e.y,s=e.x-t.x,a=t.x*e.y-e.x*t.y,o=r.y-i.y,l=i.x-r.x,c=r.x*i.y-i.x*r.y,u=n*l-o*s;return new ir((c*s-a*l)/u,(a*o-c*n)/u)}static getCrossPoint2(e,t,i,r){return this.getCrossPoint1(e,e.add(t),i,i.add(r))}constructor(e,t){this.x=an.normal(e),this.y=an.normal(t)}get hashed(){return this._hashed==null&&(sM[0]=this.x,sM[1]=this.y,this._hashed=PE[0]^PE[1]^PE[2]^PE[3]),this._hashed}dot(e){return this.x*e.x+this.y*e.y}length(){return Math.sqrt(this.dot(this))}getCos(){return this.x/this.length()}sub(e){var t=this.x-e.x,i=this.y-e.y;return new ir(t,i)}add(e){var t=this.x+e.x,i=this.y+e.y;return new ir(t,i)}div(e){return new ir(this.x/e,this.y/e)}add1(e,t){return new ir(this.x+e,this.y+t)}mul(e){return new ir(this.x*e,this.y*e)}cross(e){return this.x*e.y-this.y*e.x}getSin(){return this.y/this.length()}angle2(e){let t=this.y-e.y,i=this.x-e.x;return t=Math.abs(t-0)<10**-4?0:t,i=Math.abs(i-0)<10**-4?0:i,Math.atan2(t,i)}angleD2(e){return ti.toDegrees(this.angle2(e))}angle(e){return Math.atan2(this.y-e.y,this.x-e.x)}angleX(e=ir.ORIGIN){let t=this.angle(e);return t<0&&(t=Math.PI*2+t),t}angleD(e){return ti.toDegrees(this.angle(e))}distance1(e){let t=e.x-this.x,i=e.y-this.y;return Ln.hypot(t,i)}distance2(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i}rotateD(e,t){return this.rotate(e,ti.toRadians(t))}rotate(e,t){let i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,s=this.y-e.y,a=n*i+s*-r,o=n*r+s*i;return e.add1(a,o)}multiply3(e){let t=this.x*e.data[0]+this.y*e.data[3]+e.data[6],i=this.x*e.data[1]+this.y*e.data[4]+e.data[7];return new ir(t,i)}multiply4(e){let t=this.x*e.data[0]+this.y*e.data[4]+e.data[12],i=this.x*e.data[1]+this.y*e.data[5]+e.data[13];return new ir(t,i)}hashCode(){return this.hashed}equals(e,t){return e instanceof ir?iM(e.x,this.x,t)&&iM(e.y,this.y,t):!1}equals1(e){return e?Re.eq(this.x,e.x)&&Re.eq(this.y,e.y):!1}equals2(e,t){return e instanceof ir?Math.abs(this.x-e.x)<=t&&Math.abs(this.y-e.y)<=t:!1}similarEquals(e,t=.5){return Math.abs(this.x*.1-e.x*.1)<=t&&Math.abs(this.y*.1-e.y*.1)<=t}toString(){return"Vector [X="+this.x+", Y="+this.y+"]"}bbox(){let e=this.x,t=this.y;return new Ta(e,e,t,t)}normalize(){if(this.x===0&&this.y===0)return new ir(0,0);let e=this.x/this.length(),t=this.y/this.length();return new ir(e,t)}regular(e=1e-4){let t=Math.round(1/e);return new ir(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}round(e=4){let t=10**(e|0);return new ir(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}mirrorX(e=ir.ORIGIN){return new ir(this.x,2*e.y-this.y)}mirrorY(e=ir.ORIGIN){return new ir(2*e.x-this.x,this.y)}mirrorCenter(e=ir.ORIGIN){return new ir(2*e.x-this.x,2*e.y-this.y)}clone(){return new ir(this.x,this.y)}mirror(e=ir.ORIGIN){return new ir(2*e.x-this.x,2*e.y-this.y)}pointOnRays(e,t){let i=ti.toRadians(e);return new ir(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}pointOnRays2(e,t){let i=e.angle(this);return new ir(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}scale(e){return new ir(this.x*e,this.y*e)}},ir.ORIGIN=new ir(0,0),ir.X_UNIT_VECTOR=new ir(1,0),ir.Y_UNIT_VECTOR=new ir(0,1),ir),DJ=(e=>(e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT",e))(DJ||{}),_J=(e=>(e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM",e))(_J||{}),_s,gh=(_s=class{constructor(e,t){this.horizontal=e,this.vertical=t}},_s.LT=new _s(0,0),_s.LC=new _s(0,1),_s.LB=new _s(0,2),_s.CT=new _s(1,0),_s.CC=new _s(1,1),_s.CB=new _s(1,2),_s.RT=new _s(2,0),_s.RC=new _s(2,1),_s.RB=new _s(2,2),_s),PJ=(e=>(e[e.INNER=0]="INNER",e[e.OUTER=1]="OUTER",e[e.SEPARATED=2]="SEPARATED",e[e.INTERSECTED=3]="INTERSECTED",e[e.EQ=4]="EQ",e[e.INSIDE_TOUCHED=5]="INSIDE_TOUCHED",e[e.OUTSIDE_TOUCHED=6]="OUTSIDE_TOUCHED",e))(PJ||{}),Mo=class{constructor(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}ext1(e){return this.minX=Math.min(this.minX,e.minX),this.maxX=Math.max(this.maxX,e.maxX),this.minY=Math.min(this.minY,e.minY),this.maxY=Math.max(this.maxY,e.maxY),this}ext2(e){return this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y),this}ext3(e){for(let t=0;t<e.length;t++){let i=e[t];this.ext2(i)}return this}ext4(e){return Km(e,(t,i)=>(this.ext2(i),!0)),this}ext5(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,t),this.minY=Math.min(this.minY,i),this.maxY=Math.max(this.maxY,r),this}ext6(e,t){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t),this}ext7(e){if(e<0){let t=e*2;if(t<this.minX-this.maxX||t<this.minY-this.maxY)throw new Error("")}return this.minX-=e,this.maxX+=e,this.minY-=e,this.maxY+=e,this}ext8(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(new Ie(e[i],e[i+1]));return this.ext3(t)}ext9(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e+i),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t+r),this}ext10({x:e,y:t,width:i,height:r}){return this.ext9(e,t,i,r)}valid(){return isFinite(this.minX)&&isFinite(this.maxX)&&isFinite(this.minY)&&isFinite(this.maxY)}clear(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}build(){return new Ta(this.minX,this.maxX,this.minY,this.maxY)}build1(){return this.valid()?new Ta(this.minX,this.maxX,this.minY,this.maxY):new Ta(0,0,0,0)}},B0=new Float64Array(4),Ta=class zl{static extendRect({x:t,y:i,width:r,height:n}){return new zl(t,t+r,i,i+n)}static extend1(t,i){if(t===null)return new zl(i.x,i.x,i.y,i.y);{let r=Math.min(t.minX,i.x),n=Math.max(t.maxX,i.x),s=Math.min(t.minY,i.y),a=Math.max(t.maxY,i.y);return new zl(r,n,s,a)}}static extend2(t,i){if(t){let r=Math.min(t.minX,i.minX),n=Math.max(t.maxX,i.maxX),s=Math.min(t.minY,i.minY),a=Math.max(t.maxY,i.maxY);return new zl(r,n,s,a)}else return i}static extend3(t,i){let r=Math.min(t.x,i.x),n=Math.max(t.x,i.x),s=Math.min(t.y,i.y),a=Math.max(t.y,i.y);return new zl(r,n,s,a)}static extend4(t,i,r){return new zl(t.x-i/2,t.x+i/2,t.y-r/2,t.y+r/2)}constructor(t,i,r,n){if(this.minX=an.normal(t),this.maxX=an.normal(i),this.minY=an.normal(r),this.maxY=an.normal(n),t>i||r>n)throw new Error(`min > max is not permitted: [${t}, ${i}, ${r}, ${n}]`)}get data(){return B0[0]=this.minX,B0[1]=this.maxX,B0[2]=this.minY,B0[3]=this.maxY,B0}isContains(t){return this.isContains1(t.x,t.y)}points(){return[this.LL(),this.LR(),this.UR(),this.UL(),this.LL()]}isContains1(t,i){return this.isContainsX(t)&&this.isContainsY(i)}isContains2(t,i){return this.isContainsX1(t)&&this.isContainsY1(i)}isContainsX(t){return t>=this.minX&&t<=this.maxX}isContainsX1(t){return Re.greatereq(t,this.minX)&&Re.lesseq(t,this.maxX)}isContainsY(t){return t>=this.minY&&t<=this.maxY}isContainsY1(t){return Re.greatereq(t,this.minY)&&Re.lesseq(t,this.maxY)}isIntersect(t){return!(this.maxX<t.minX||this.minX>t.maxX||this.maxY<t.minY||this.minY>t.maxY)}extendOfSize(t){return an.positiveOr0(this.maxX-this.minX+t*2),an.positiveOr0(this.maxY-this.minY+t*2),new zl(this.minX-t,this.maxX+t,this.minY-t,this.maxY+t)}isInside(t){return this.minX>=t.minX&&this.maxX<=t.maxX&&this.minY>=t.minY&&this.maxY<=t.maxY}isContainsBBox(t){return this.maxX>=t.maxX&&this.minX<=t.minX&&this.maxY>=t.maxY&&this.minY<=t.minY}isContainsBBox1(t){return Re.greatereq(this.maxX,t.maxX)&&Re.lesseq(this.minX,t.minX)&&Re.greatereq(this.maxY,t.maxY)&&Re.lesseq(this.minY,t.minY)}intersect(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(i>r)return null;let n=Math.max(this.minY,t.minY),s=Math.min(this.maxY,t.maxY);return n>s?null:new zl(i,r,n,s)}intersection1(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(Re.greater(i,r))return null;i>r&&(r=i);let n=Math.max(this.minY,t.minY),s=Math.min(this.maxY,t.maxY);return Re.greater(n,s)?null:(n>s&&(s=n),new zl(i,r,n,s))}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}UL(){return new Ie(this.minX,this.maxY)}UR(){return new Ie(this.maxX,this.maxY)}LL(){return new Ie(this.minX,this.minY)}LR(){return new Ie(this.maxX,this.minY)}center(){return new Ie(this.maxX-(this.maxX-this.minX)/2,this.maxY-(this.maxY-this.minY)/2)}area(){return this.width()*this.height()}transform(t){let i=new Mo;return i.ext2(this.LL().multiply3(t)),i.ext2(this.LR().multiply3(t)),i.ext2(this.UR().multiply3(t)),i.ext2(this.UL().multiply3(t)),i.build()}transform4(t){let i=new Mo;return i.ext2(this.LL().multiply4(t)),i.ext2(this.LR().multiply4(t)),i.ext2(this.UR().multiply4(t)),i.ext2(this.UL().multiply4(t)),i.build()}isSeparated(t){if(t==null||t==null)return!1;let i;this.minX>=t.minX?i=this.minX:i=t.minX;let r;if(this.maxX<=t.maxX?r=this.maxX:r=t.maxX,i>r)return!0;{let n;this.minY>=t.minY?n=this.minY:n=t.minY;let s;return this.maxY<=t.maxY?s=this.maxY:s=t.maxY,n>s}}relation(t){let i=0,r=0,n;this.minX>t.minX?(i++,n=this.minX):this.minX===t.minX?n=this.minX:(r++,n=t.minX);let s;if(this.maxX<t.maxX?(i++,s=this.maxX):this.maxX===t.maxX?s=this.maxX:(r++,s=t.maxX),n>s)return 2;{let a;this.minY>t.minY?(i++,a=this.minY):this.minY===t.minY?a=this.minY:(r++,a=t.minY);let o;return this.maxY<t.maxY?(i++,o=this.maxY):this.maxY===t.maxY?o=this.maxY:(r++,o=t.maxY),a>o?2:i===4?0:r===4?1:i===0&&r===0?4:n===s||a===o?6:i!==r?5:3}}zoom(t){let i=this.width(),r=this.height(),n=this.center();return t!=0&&(i/=t/2,r/=t/2),new zl(n.x-i,n.x+i,n.y-i,n.y+i)}toString(){return"BBox [minX="+this.minX+", maxX="+this.maxX+", minY="+this.minY+", maxY="+this.maxY+"]"}equals(t){return this.minY==t.minY&&this.minX==t.minX&&this.maxX==t.maxX&&this.maxY==t.maxY}extendSize(t,i){return Object.is(void 0,i)&&(i=t),zl.extend4(this.center(),this.width()+t,this.height()+i)}positionOnBBox(t,i=0){let r=this.center(),n=this.width()*i/2,s=this.height()*i/2,a=t.x-r.x,o=t.y-r.y;return a>n?o>s?gh.RT:o<-s?gh.RB:gh.RC:a<-n?o>s?gh.LT:o<-s?gh.LB:gh.LC:o>s?gh.CT:o<-s?gh.CB:gh.CC}bbox(){return this}},WE=class Vi{static mul(t,i,r,n,s,a){let o=0,l=0;for(let c=0;c<t;c++){for(let u=0;u<r;u++){let h=u,d=0;for(let p=0;p<i;p++)d+=n[l+p]*s[h],h+=r;a[o++]=d}l+=i}}constructor(t,i,r){this.m=an.normal(t),this.n=an.normal(i);let n=t*i;if(r.length===n){for(let s=0;s<r.length;s++)an.normal(r[s]);this.data=r}else throw new Error("invalid matrix size")}mul(t){if(this.n===t.m){let i=new Array(this.m*t.n);return Vi.mul(this.m,this.n,t.n,this.data,t.data,i),new Vi(this.m,t.n,i)}else throw new Error("m !== p")}toString(){let t=[];t.push("Matrix ("),t.push(this.m.toString()),t.push(" x "),t.push(this.n.toString()),t.push(")");let i=0;for(let r=0;r<this.m;r++)for(let n=0;n<this.n;n++){let s=this.data[i++].toString();n===0?(t.push(`
`),t.push("	"),t.push(s)):(t.push(", "),t.push(s))}return t.join("")}static on(t,i,r){return t*i+r}initExpandMatrix(t){let i=this.m,r=this.n,n=r*2,s=new Array(i*n);for(let a=0;a<i;a++)for(let o=0;o<n;o++)o<r?s[Vi.on(n,a,o)]=t[Vi.on(r,a,o)]:o===i+a?s[Vi.on(n,a,o)]=1:s[Vi.on(n,a,o)]=0;return s}inverseMatrix(t,i,r){for(let n=0;n<i;n++){let s=t[Vi.on(r,n,n)];for(let a=0;a<r;a++)t[Vi.on(r,n,a)]/=s}return t}getMatrixRank(t,i,r){let n=Math.min(i,r);for(let s=0;s<i;s++){if(t[Vi.on(r,s,s)]===0){let a=new Array(r),o;for(o=s;o<i;o++)if(t[Vi.on(r,o,s)]!==0){Ia.arraycopy(t,Vi.on(r,o,0),a,0,r),Ia.arraycopy(t,Vi.on(r,s,0),t,Vi.on(r,o,0),r),Ia.arraycopy(a,0,t,Vi.on(r,s,0),r);break}o>=i&&(n-=1)}if(!(n<i))for(let a=0;a<i;a++){if(a===s)continue;let o=t[Vi.on(r,a,s)]/t[Vi.on(r,s,s)];for(let l=0;l<r;l++)t[Vi.on(r,a,l)]-=t[Vi.on(r,s,l)]*o}}return n}getInverseMatrix(){if(this.m!==this.n)throw new Error("The matrix is an "+this.m+"x"+this.n+" order matrix, non-square matrix, please check!");function t(a){return Re.lesseq(Math.abs(a),0)}let i=this.initExpandMatrix(this.data.slice(0)),r=this.n*2;function n(a,o){for(let l=0;l<r;l++){let c=i[Vi.on(r,a,l)];i[Vi.on(r,a,l)]=i[Vi.on(r,o,l)],i[Vi.on(r,o,l)]=c}}for(let a=0;a<this.m;a++){let o=Math.abs(i[Vi.on(r,a,a)]),l=a;if(t(i[Vi.on(r,a,a)]))for(let u=a+1;u<this.m;u++){if(t(i[Vi.on(r,u,a)])){Math.abs(i[Vi.on(r,u,a)])>o&&(o=Math.abs(i[Vi.on(r,u,a)]),l=u);continue}n(a,u);break}if(t(i[Vi.on(r,a,a)])){if(o===0)throw new Error("The matrix is a non-full rank matrix, please check!");console.warn("The matrix may be a non-full rank matrix, please check!"),l!==a&&n(a,l)}let c=1/i[Vi.on(r,a,a)];for(let u=0;u<r;u++)i[Vi.on(r,a,u)]*=c;for(let u=0;u<this.m;u++){if(a===u)continue;let h=i[Vi.on(r,u,a)];for(let d=a;d<r;d++)i[Vi.on(r,u,d)]-=i[Vi.on(r,a,d)]*h}}let s=[];for(let a=0;a<this.m;a++)for(let o=this.n;o<r;o++)s[Vi.on(this.n,a,o-this.n)]=i[Vi.on(r,a,o)];return new Vi(this.m,this.n,s)}getTransposeMatrix(){let t=new Array(this.data.length);for(let i=0;i<this.m;i++)for(let r=0;r<this.n;r++)t[r*this.n+i]=this.data[i*this.m+r];return new Vi(this.n,this.m,t)}hashCode(){let t=0;for(let i of this.data)t+=i;return t}equals(t){return this===t?!0:t===null?!1:t instanceof Vi?!(this.m!=t.m||this.n!=t.n||!Ia.equals(this.data,t.data)):!1}},LJ=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],gn,jM=(gn=class extends WE{static translate(e,t,i){return new gn([1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1])}static translate1(e){return new gn([1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,e.z,1])}static rotateX(e){let t=Math.cos(e),i=Math.sin(e);return new gn([1,0,0,0,0,t,i,0,0,-i,t,0,0,0,0,1])}static rotateY(e){let t=Math.cos(e),i=Math.sin(e);return new gn([t,0,-i,0,0,1,0,0,i,0,t,0,0,0,0,1])}static rotateZ(e){let t=Math.cos(e),i=Math.sin(e);return new gn([t,i,0,0,-i,t,0,0,0,0,1,0,0,0,0,1])}static rotateAxis(e,t){e=e.normalize();let i=e.x,r=e.y,n=e.z,s=Math.sin(t),a=Math.cos(t);return new gn([i*i*(1-a)+a,i*r*(1-a)+n*s,i*n*(1-a)-r*s,0,i*r*(1-a)-n*s,r*r*(1-a)+a,r*n*(1-a)+i*s,0,i*n*(1-a)+r*s,r*n*(1-a)-i*s,n*n*(1-a)+a,0,0,0,0,1])}static scale(e,t=e,i=e){return new gn([e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1])}static flipX(){return new gn([1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1])}static flipY(){return new gn([-1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}static rotateZForPoint(e,t){return e.equals1(Ie.ORIGIN)?gn.rotateZ(t):gn.translate(-e.x,-e.y,0).rotateZ(t).translate1(e.x,e.y,0)}static getMatrix4(e,t,i,r){let n=Math.cos(t),s=Math.sin(t),a=i*(e.x*n-e.y*s)+r.x,o=e.x*s+e.y*n+r.y,l=[i*n,s,0,0,-s*i,n,0,0,0,0,1,0,a,o,0,1];return new gn(l)}constructor(e=LJ){super(4,4,e)}translate(e){return this.multiply4(gn.translate1(e))}translate1(e,t,i){return this.multiply4(gn.translate(e,t,i))}rotateX(e){return this.multiply4(gn.rotateX(e))}rotateY(e){return this.multiply4(gn.rotateY(e))}rotateZ(e){return this.multiply4(gn.rotateZ(e))}scale(e,t=e,i=e){return this.multiply4(gn.scale(e,t,i))}scale1(e){return this.multiply4(gn.scale(e.x,e.y,e.z))}setOrigin(e,t,i){return gn.translate(-e,-t,-i).multiply4(this).translate1(e,t,i)}setOrigin1(e){return this.setOrigin(e.x,e.y,e.z)}multiply4(e){let t=new Array(16);return WE.mul(4,4,4,this.data,e.data,t),new gn(t)}getInverseMatrix(){let e=super.getInverseMatrix();return new gn(e.data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new gn(e.data)}inverse(){let e=this.getInverseMatrix();return new gn(e.data)}toMatrix3(){let e=this.data;return new Zn([e[0],e[1],0,e[4],e[5],0,e[12],e[13],1])}},gn.ORIGIN=new gn,gn);function k0(e){return VM.normal(parseFloat(e))}var OJ=[1,0,0,0,1,0,0,0,1],$r,Zn=($r=class extends WE{static translate(e,t){return new $r([1,0,0,0,1,0,e,t,1])}static translate1(e){return this.translate(e.x,e.y)}static rotate(e){let t=Math.cos(e),i=Math.sin(e);return new $r([t,i,0,-i,t,0,0,0,1])}static rotateD(e){return this.rotate(ti.toRadians(e))}static scale(e,t=e){return new $r([e,0,0,0,t,0,0,0,1])}static scale1(e,t){return new $r([e,0,0,0,t,0,0,0,1])}static toDOMMatrix(e){let[t,i,,r,n,,s,a]=e.data;return`matrix(${[t,i,r,n,s,a].join(",")})`}static svgTrasform(e){let t=e.split(" "),i=null;return t.forEach(r=>{r=r.trim();let n=r.trim().replace(")","").split("("),s=n[0],a=n[1].split(",");switch(s){case"translate":let o=k0(a[0]),l=k0(a[1]);i=i?i.translate(o,l):$r.translate(o,l);break;case"rotate":let c=k0(a[0]),u=k0(a[1]),h=k0(a[2]);i=i?i.setOrigin(u,h):$r.translate(u,h),i=i.rotateD(c);break;default:return}}),i}constructor(e=OJ){super(3,3,e);let t=e[0],i=e[3],r=e[1],n=e[4];this.iScale=Math.sqrt(t*t+r*r),this.jScale=Math.sqrt(i*i+n*n)}isMirrored(){return this.det()<0}multiply3(e){let t=new Array(9);return WE.mul(3,3,3,this.data,e.data,t),new $r(t)}translate(e,t){return this.multiply3($r.translate(e,t))}translate1(e){return this.multiply3($r.translate1(e))}scale(e,t=e){return this.multiply3($r.scale(e,t))}scale1(e,t){return this.multiply3($r.scale1(e,t))}det(){return this.data[0]*this.data[4]-this.data[3]*this.data[1]}invert(){let e=this.getInverseMatrix();return new $r(e.data)}rotateD(e){return this.multiply3($r.rotateD(e))}rotate(e){return this.multiply3($r.rotate(e))}resetOffset(){let e=this.data;return new $r([e[0],e[1],0,e[3],e[4],0,0,0,1])}setOrigin(e,t){return $r.translate(-e,-t).multiply3(this).translate(e,t)}setOrigin1(e){return this.setOrigin(e.x,e.y)}getInverseMatrix(){return new $r(super.getInverseMatrix().data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new $r(e.data)}toMatrix4(){let e=this.data;return new jM([e[0],e[1],0,e[2],e[3],e[4],0,e[5],0,0,1,0,e[6],e[7],0,e[8]])}scaleNum(e){return!e||isNaN(e)?e:e*this.iScale}},$r.ORIGIN=new $r,$r.MIRROR_Y=new $r([1,0,0,0,-1,0,0,0,1]),$r.MIRROR_X=new $r([-1,0,0,0,1,0,0,0,1]),$r.ROT_90=new $r([0,1,0,-1,0,0,0,0,1]),$r.ROT_N90=new $r([0,-1,0,1,0,0,0,0,1]),$r),RJ=(e=>(e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE",e))(RJ||{}),NJ=(e=>(e[e.CW=0]="CW",e[e.CCW=1]="CCW",e))(NJ||{}),r1=class{},bA=class V0{constructor(t,i,r){this.p1=t,this.p2=i,this.p3=r}barycentre(){return V0.barycentre(this.p1,this.p2,this.p3)}incentre(){return V0.incentre(this.p1,this.p2,this.p3)}static barycentre(t,i,r){let n=t.x+i.x+r.x,s=t.y+i.y+r.y;return new Ie(n/3,s/3)}static incentre(t,i,r){let n=i.sub(r).length(),s=t.sub(r).length(),a=t.sub(i).length(),o=n+s+a,l=n*t.x+s*i.x+a*r.x,c=n*t.y+s*i.y+a*r.y;return new Ie(l/o,c/o)}area(){return V0.area(this.p1,this.p2,this.p3)}static area(t,i,r){return this.area2(t.x,t.y,i.x,i.y,r.x,r.y)/2}static area2(t,i,r,n,s,a){return Math.abs(Ln.crossProd2(t,i,r,n,s,a))}scale(t,i){let r=Zn.translate(-t.x,-t.y).scale(i).translate1(t),n=this.p1.multiply3(r),s=this.p2.multiply3(r),a=this.p3.multiply3(r);return new V0(n,s,a)}scaleOnBarycentre(t){return this.scale(this.barycentre(),t)}scaleOnIncentre(t){return this.scale(this.incentre(),t)}extend(t){let i=this.incentre(),r=this.p1.add(this.p2).sub(i).scale(1/2),n=r.length(),s=Ie.ORIGIN.pointOnRays2(r,n+t).length()/n;return this.scaleOnIncentre(s)}container(t){let i=this.p3.sub(this.p1),r=this.p2.sub(this.p1),n=t.sub(this.p1),s=i.dot(i),a=i.dot(r),o=i.dot(n),l=r.dot(r),c=r.dot(n),u=1/(s*l-a*a),h=(l*o-a*c)*u;if(h<0||h>1)return!1;let d=(s*c-a*o)*u;return d<0||d>1?!1:h+d<=1}};function LE(){return{minDistance:Number.POSITIVE_INFINITY,start:null,end:null}}var Rc=class bd{static getMinDistanceWithoutCross(t,i){let r=LE();return bd.minLine(t,i,r),r.minDistance}static getMinDistance(t,i){return Wl(t,i)?0:this.getMinDistanceWithoutCross(t,i)}static getMinLineWithCross(t,i){let r=LE();return bd.minLine(t,i,r),new ye(r.start,r.end)}static getMinLine(t,i){return bd.intersection(t,i)||this.getMinLineWithCross(t,i)}static getMinDistanceFromPoint(t,i){let r=LE();if(i instanceof ye)this.point2LineMinLine(r,i,t);else if(i instanceof Le)this.point2ArcMinDistance(t,i,r);else throw new Error("not support");return r.minDistance}constructor(t,i){if(this.pt1=t,this.pt2=i,this.minline=bd.intersection(t,i),this.minline)this.minDistance=0;else{let r=LE();bd.minLine(t,i,r),this.minline=new ye(r.start,r.end),this.minDistance=r.minDistance}}getDistance(){return this.minDistance}getLine(){return this.minline}static intersection(t,i){let r=Wl(t,i);if(r===0)return;let n=new Array;for(let s=0;s<r;s+=2){let a=new Ie(oe[s],oe[s+1]);n.push(a)}return n.length>1?new ye(n[0],n[1]):new ye(n[0],n[0])}static minLine(t,i,r){if(t instanceof ye&&i instanceof ye)return this.minDistanceForLines(t,i,r);if(t instanceof Le&&i instanceof ye)return this.minDistanceForLineAndArc(t,i,r);if(t instanceof ye&&i instanceof Le)return this.minDistanceForLineAndArc(i,t,r);if(t instanceof Le&&i instanceof Le)return this.minDistanceForArcs(t,i,r);throw new Error("not support")}static minDistanceForLines(t,i,r){[t.start(),t.end(),i.start(),i.end()].forEach((n,s)=>{s<2?this.point2LineMinLine(r,i,n):this.point2LineMinLine(r,t,n)})}static minDistanceForLineAndArc(t,i,r){this.point2LineMinLine(r,i,t.start()),this.point2LineMinLine(r,i,t.svgEnd);let n=bd.foot(i,t.center);i.bbox().extendOfSize(1e-8).isContains(n)&&this.point2ArcMinLine(r,t,n),this.point2ArcMinLine(r,t,i.start()),this.point2ArcMinLine(r,t,i.end())}static minDistanceForArcs(t,i,r){this.concentricArc(t,i,r),this.point2ArcMinDistance(i.start(),t,r),this.point2ArcMinDistance(i.svgEnd,t,r),this.point2ArcMinDistance(t.start(),i,r),this.point2ArcMinDistance(t.svgEnd,i,r),(Pc(t,i.center)||Pc(i,t.center))&&this.shortestLineForArcs(t,i,r)}static minLineForArcAndLine(t,i,r){let n=t.pointOn(r.angleD(t.center)),s=t.pointOn(t.center.angleD(r));this.arcShortestLine(t,i,r,n),this.arcShortestLine(t,i,r,s)}static arcInnerLineFootSegment(t,i,r){let n=r.distance1(t.center);if(n!==0){let s=t.rx*(r.y-t.center.y)/n+t.center.y,a=t.rx*(r.x-t.center.x)/n+t.center.x;n=t.rx-n,n<i.minDistance&&(i.minDistance=n,i.start=new Ie(a,s),i.end=r)}else n=t.rx-n,n<i.minDistance&&(i.minDistance=n,i.start=t.start(),i.end=r)}static shortestLineForArcs(t,i,r){let n=t.center.angleD(i.center),s=i.center.angleD(t.center),a=t.pointOn(n),o=t.pointOn(s),l=i.pointOn(n),c=i.pointOn(s);Pc(t,a)&&(this.arcShortestLine(i,r,a,l),this.arcShortestLine(i,r,a,c)),Pc(t,o)&&(this.arcShortestLine(i,r,o,l),this.arcShortestLine(i,r,o,c)),this.shortestLineForArcs1(t,i,r)}static shortestLineForArcs1(t,i,r){let n=i.start().sub(t.center).normalize(),s=i.end().sub(t.center).normalize(),a=t.start().sub(i.center).normalize(),o=t.end().sub(i.center).normalize(),l=t.center.add(n.mul(t.rx)),c=t.center.add(s.mul(t.rx)),u=i.center.add(a.mul(i.rx)),h=i.center.add(o.mul(i.rx));Pc(t,l)&&Re.greater(i.start().distance2(t.center),0)&&this.arcShortestLine(t,r,i.start(),l),Pc(t,c)&&Re.greater(i.end().distance2(t.center),0)&&this.arcShortestLine(t,r,i.end(),c),Pc(i,u)&&Re.greater(t.start().distance2(i.center),0)&&this.arcShortestLine(i,r,t.start(),u),Pc(i,h)&&Re.greater(t.end().distance2(i.center),0)&&this.arcShortestLine(i,r,t.end(),h)}static concentricArc(t,i,r){if(!(t.center.distance1(i.center)<1e-5&&t.rx===i.rx&&t.ry===i.ry))return;let n=t.start().distance1(i.svgEnd);n<r.minDistance&&(r.minDistance=n,r.start=t.start(),r.end=i.svgEnd),n=i.start().distance1(t.svgEnd),n<r.minDistance&&(r.minDistance=n,r.start=i.start(),r.end=t.svgEnd)}static point2ArcMinDistance(t,i,r){if(Pc(i,t)){let n=i.pointOn(t.angleD(i.center)),s=i.pointOn(i.center.angleD(t));this.arcShortestLine(i,r,t,n),this.arcShortestLine(i,r,t,s)}else this.minLineSegment(r,i.start(),t),this.minLineSegment(r,i.svgEnd,t)}static point2ArcMinLine(t,i,r){if(Pc(i,r)){let n=r.distance1(i.center);n>i.rx||n>i.ry?this.minLineForArcAndLine(i,t,r):this.arcInnerLineFootSegment(i,t,r)}}static point2LineMinLine(t,i,r){let n=bd.foot(i,r);i.bbox().extendOfSize(1e-8).isContains(n)?this.minLineSegment(t,n,r):(this.minLineSegment(t,i.start(),r),this.minLineSegment(t,i.end(),r))}static minLineSegment(t,i,r){let n=i.distance1(r);n<t.minDistance&&(t.minDistance=n,t.start=i,t.end=r)}static arcShortestLine(t,i,r,n){if(!Pc(t,n))return;let s=r.distance1(n);s<i.minDistance&&(i.minDistance=s,i.start=r,i.end=n)}static foot(t,i){if(t.isPoint())return t.start();if(!Re.eq(t.b,0)&&!Re.eq(t.a,0)){let r=t.start(),n=t.direct,s=(i.x-r.x)*n.x+(i.y-r.y)*n.y;return new Ie(r.x+n.x*s,r.y+n.y*s)}else return Re.eq(t.b,0)&&!Re.eq(t.a,0)?new Ie(t.start().x,i.y):!Re.eq(t.b,0)&&Re.eq(t.a,0)?new Ie(i.x,t.start().y):i}};function Pc(e,t){if(Re.eq(e.sweepAngle,360))return!0;let i=ti.regularD(t.angleD(e.center));return e.sweepAngle>0?(Re.less(i,e.startAngle)&&(i+=360),Re.greatereq(e.endAngle(),i)):(Re.greater(i,e.startAngle)&&(i-=360),Re.lesseq(e.endAngle(),i))}var MJ=[1,10,100,1e3],aM="http://www.w3.org/2000/svg",oM="http://www.w3.org/1999/xlink",lM="http://www.w3.org/XML/1998/namespace",cM="https://easyeda.com/",Mle=(function(){var e={svg:aM,xlink:oM,xml:lM,c:cM};return e[aM]="svg",e[oM]="xlink",e[lM]="xml",e[cM]="c",e})(),$n=(function(){var e={RATLINES:9,MODEL3D:19,ALL:11,TOPSILKLAYER:3,TOPLAYER:1,TOPPASTERLAYER:5,TOPSOLDERLAYER:7,LIBBODY:99,PADSURFACE:100,BOARDOUTLINE:10,DOCUMENT:12,TOPASSEMBLY:13,MECHANICAL:15,TOPCOMPONENT:16,SUBSTRATE:18},t;for(t=21;t<53;t++)e["INNER"+(t-20)]=t;for(e.BOTTOMSILKLAYER=4,e.BOTTOMLAYER=2,e.BOTTOMPASTERLAYER=6,e.BOTTOMSOLDERLAYER=8,e.BOTTOMASSEMBLY=14,e.BOTTOMCOMPONENT=17,t=53;t<85;t++)e["BOARD"+(t-52)]=t;return e})(),Ble=(function(){var e={COPPERAREA:[1,2,21,22,23,24],PLANEZONE:[1,2,21,22,23,24],RECT:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,99],TRACK:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],PAD:[11,1,2],VIA:[11],HOLE:[11],TEXT:[3,4,1,2,7,8,12,13,14,15,21,22,23,24],ARC:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],ELLIPSE:[3,4,12,13,14,15],CIRCLE:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],DIMENSION:[3,4,12,13,14,15],FOOTPRINT:[1,2],SOLIDREGION:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,11,99,100],SVGNODE:[1,2,3,4,7,8,12,13,14,15],PROTRACTOR:[3,4,12,13,14,15],SHEET:[12,13,14,15]};e["3D"]=(function(){for(var n=[16,19,3,7,5,1],s=21;s<52;s++)n.push(s+32,s);return n.push(2,6,8,4,17),n})();var t,i,r;for(t in e)if(e.hasOwnProperty(t)&&(r=e[t],r.indexOf(21)>0&&r.indexOf(25)===-1))for(i=25;i<=52;i++)r.push(i);return e})(),Hs=(function(){var e={1:"TopLayer",2:"BottomLayer",3:"TopSilkLayer",4:"BottomSilkLayer",5:"TopPasteMaskLayer",6:"BottomPasteMaskLayer",7:"TopSolderMaskLayer",8:"BottomSolderMaskLayer",9:"Ratlines",10:"BoardOutLine",11:"Multi-Layer",12:"Document",13:"TopAssembly",14:"BottomAssembly",15:"Mechanical",16:"TopComponents",17:"BottomComponents",18:"Substrate",19:"3DModel",99:"ComponentShapeLayer",100:"LeadShapeLayer"},t;for(t=21;t<53;t++)e[t]="Inner"+(t-20);for(t=53;t<85;t++)e[t]="Substrate"+(t-52);return e})(),kle=(function(){var e=[],t=[];for(var i in $n)if($n.hasOwnProperty(i)){if(i.match(/^BOARD\d+/))continue;e.push($n[i])}e.sort(),t.sort();var r={},n,s={21:"#999966",22:"#008000",23:"#00FF00",24:"#BC8E00",25:"#70DBFA",26:"#00CC66",27:"#9966FF",28:"#800080",29:"#008080",30:"#15935F",31:"#000080",32:"#00B400",33:"#2E4756",34:"#99842F",35:"#FFFFAA",36:"#99842F",37:"#2E4756",38:"#3535FF",39:"#8000BC",40:"#43AE5F",41:"#C3ECCE",42:"#728978",43:"#39503F",44:"#0C715D",45:"#5A8A80",46:"#2B937E",47:"#23999D",48:"#45B4E3",49:"#215DA1",50:"#4564D7",51:"#6969E9",52:"#9069E9"};e.forEach(function(o){switch(o){case $n.TOPLAYER:n={name:Hs[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case $n.BOTTOMLAYER:n={name:Hs[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case $n.TOPSILKLAYER:n={name:Hs[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case $n.BOTTOMSILKLAYER:n={name:Hs[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case $n.TOPPASTERLAYER:n={name:Hs[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case $n.BOTTOMPASTERLAYER:n={name:Hs[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case $n.TOPSOLDERLAYER:n={name:Hs[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case $n.BOTTOMSOLDERLAYER:n={name:Hs[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case $n.RATLINES:n={name:Hs[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case $n.BOARDOUTLINE:n={name:Hs[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case $n.ALL:n={name:Hs[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case $n.DOCUMENT:n={name:Hs[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case $n.TOPASSEMBLY:n={name:Hs[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case $n.BOTTOMASSEMBLY:n={name:Hs[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case $n.MECHANICAL:n={name:Hs[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case $n.MODEL3D:n={name:Hs[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case $n.LIBBODY:n={name:Hs[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case $n.PADSURFACE:n={name:Hs[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=$n.INNER1&&o<=$n.INNER32?n={name:Hs[o],color:s[o],darkColor:a(s[o]),visible:!1,active:!1,config:!1}:n=null;break}n&&(r[o]=n)}),r.Hole={config:!0,name:"Hole",darkColor:"#222222",color:"#222222"},r.DRCError={config:!0,name:"DRCError",color:"#FAD609",darkColor:"#FAD609"};function a(o){if(typeof o!="string"||!o.match(/#?([\da-f]{6})/i))return o;var l=parseInt(RegExp.$1,16),c=.5,u=Math.min(255,Math.round((l>>16)*c)),h=Math.min(255,Math.round((l>>8&255)*c)),d=Math.min(255,Math.round((l&255)*c)),p=((u<<16)+(h<<8)+d).toString(16);return"#"+("00000"+p).substr(-6).toUpperCase()}return r})(),uM={BLANK:0,SCH:1,PART:2,PCB:3,FOOTPRINT:4,PRJ:5,SUBPART:6,SPICESYMBOL:7,SUBCKT:8,NETLIST:9,WAVEFORM:10,SCHLIB3D:11,PHOTOVIEW:12,SCHMODULE:13,PCBMODULE:14,VIEW3D:15,PCBLIB3D:16,BLOCK_SYMBOL:17,NETFLAG:18,NETPORT:19,SHEET_SYMBOL:20,NONEELEC_SYMBOL:21,SHORT_SYMBOL:22,FOOTPRINTVIEW:23,CNCPRINTVIEW:24,PCB2D:31,PCB3D:32},Fle=(function(){var e={};for(let t in uM)e[uM[t]]=t;return e})(),n2=Math.PI*2,qE=Math.PI/2,Gle=Math.sin(Math.PI/180);function BJ(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=MJ[t]||Math.pow(10,t)||10;if(i){var n=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(n+e)}else return Math.round(e*r+1e-10)/r}function zM(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function kJ(e,t,i){var r=u(e)&&u(t)&&u(i);if(!r)return console.warn("Bad arguments"),null;var n=t.x-i.x>0?t.x:i.x,s=t.y-i.y>0?t.y:i.y,a=t.x-i.x>0?i.x:t.x,o=t.y-i.y>0?i.y:t.y,l=e.x,c=e.y;return l<=n+.001&&l>=a-.001&&c<=s+.001&&c>=o-.001;function u(h){return h?(h.x=Number(h.x),h.y=Number(h.y),isNaN(h.x)||isNaN(h.y)?(console.warn("Can not convert to Number, NaN found"),!1):!0):(console.warn("Empty input!"),!1)}}function FJ(e,t,i,r,n,s){var a=(n-i)*(e-i)+(s-r)*(t-r),o=(n-i)*(n-i)+(s-r)*(s-r),l=a/o,c=i+(n-i)*l,u=r+(s-r)*l;return a<=0?Math.sqrt((e-i)*(e-i)+(t-r)*(t-r)):a>=o?Math.sqrt((e-n)*(e-n)+(t-s)*(t-s)):Math.sqrt((e-c)*(e-c)+(u-t)*(u-t))}function GJ(e,t,i){return kJ(e,t,i)?zM((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}var H0=1e-4,oe=new Float64Array(100);function Wl(e,t){if(e instanceof ye&&t instanceof ye)return Tu(e,t);if(e instanceof Le&&t instanceof ye)return xA(e,t);if(e instanceof ye&&t instanceof Le)return xA(t,e);if(e instanceof Le&&t instanceof Le)return WM(e,t);if(e instanceof gt&&t instanceof gt)return UE(e,t);if(e instanceof gt&&t instanceof ye)return UE(e,new gt([t.start(),t.end()]));if(e instanceof ye&&t instanceof gt)return UE(new gt([e.start(),e.end()]),t);if(e instanceof gt&&t instanceof Le)return yM(t,e);if(e instanceof Le&&t instanceof gt)return yM(e,t);throw new Error("not supported operation")}function UJ(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new ye(new Ie(i.minX-1,t),new Ie(i.maxX+1,t));return Tu(r,e)>0?1:0}else return 0}function YJ(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new ye(new Ie(i.minX-1,t),new Ie(i.maxX+1,t));return JE(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function hM(e,t){let i=e.bbox();return i.isContainsY1(t)&&UE(new gt([new Ie(i.minX-1,t),new Ie(i.maxX+1,t)]),e)>0?1:0}function dM(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function VJ(e,t){let i=t.length(),r=Ln.crossProd3(t.start(),t.end(),e.start())/i,n=Ln.crossProd3(t.start(),t.end(),e.end())/i;return Math.abs(r)<1e-8||Math.abs(n)<1e-8||r*n<0}function Tu(e,t){let i=e.bbox().intersection1(t.bbox());if(!i)return 0;if(e.isPoint())if(t.isPoint()){let r=i.center();return oe[0]=r.x,oe[1]=r.y,2}else return pM(t,e,i);else{if(t.isPoint())return pM(e,t,i);{let r=function(E,S){i.isContains2(E,S)&&(oe[y++]=E,oe[y++]=S)};if(!VJ(e,t))return 0;let n=e.start().x,s=e.start().y,a=e.end().x,o=e.end().y,l=t.start().x,c=t.start().y,u=t.end().x,h=t.end().y,d=t.length(),p=Ln.crossProd2(n,s,l,c,u,h)/d,f=Ln.crossProd2(a,o,l,c,u,h)/d;if(p*f>0&&!Re.eq(p,0)&&!Re.eq(f,0))return 0;let m=e.length(),g=Ln.crossProd2(l,c,n,s,a,o)/m,b=Ln.crossProd2(u,h,n,s,a,o)/m;if(g*b>0&&!Re.eq(g,0)&&!Re.eq(b,0))return 0;let y=0;if(Re.eq(p,0)&&Re.eq(f,0)){let E=i.UL(),S=i.UR(),w=i.LL(),x=i.LR();if(Re.eq(i.width(),0))Re.eq(i.height(),0)?(oe[y++]=E.x,oe[y++]=E.y):(oe[y++]=E.x,oe[y++]=E.y,oe[y++]=w.x,oe[y++]=w.y);else if(Re.eq(i.height(),0))oe[y++]=E.x,oe[y++]=E.y,oe[y++]=S.x,oe[y++]=S.y;else{let I=bA.area2(E.x,E.y,l,c,u,h),A=bA.area2(S.x,S.y,l,c,u,h);I<A?(oe[y++]=E.x,oe[y++]=E.y,oe[y++]=x.x,oe[y++]=x.y):(oe[y++]=S.x,oe[y++]=S.y,oe[y++]=w.x,oe[y++]=w.y)}}else if(Re.eq(p,0))r(n,s);else if(Re.eq(f,0))r(a,o);else{let E=Math.abs(p/(p-f));r(n+(a-n)*E,s+(o-s)*E)}return y}}}function pM(e,t,i){let r=t.start(),n=t.end(),s=Ln.crossProd3(e.start(),e.end(),t.start()),a=Ln.crossProd3(e.start(),e.end(),t.end());if(s*a<0){let o=i.center();return oe[0]=o.x,oe[1]=o.y,2}else if(Math.abs(s)<Math.abs(a)){if(Re.eq(s/e.length(),0))return oe[0]=r.x,oe[1]=r.y,2}else if(Re.eq(a/e.length(),0))return oe[0]=n.x,oe[1]=n.y,2;return 0}function JE(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(H0);let r=e.center.x,n=e.center.y,s=e.rx,a=e.rx2,o=t.start().x,l=t.start().y,c=t.end().x,u=t.end().y,h=e.center.distance1(t.start()),d=e.center.distance1(t.end()),p=Re.eq(h,s)?0:h>s?1:-1,f=Re.eq(d,s)?0:d>s?1:-1,m=0;if(p===-1&&f===-1)return 0;if(p===0&&f===0)oe[m++]=o,oe[m++]=l,oe[m++]=c,oe[m++]=u;else if(p===1&&f===1){let g=Rc.foot(t,e.center),b=g.distance1(e.center);if(Re.greater(b,s))return 0;if(Re.eq(b,s))Re.eq(t.distance2(e.start()),0)?(oe[m++]=e.start().x,oe[m++]=e.start().y,oe[m++]=e.start().x,oe[m++]=e.start().y):Re.eq(t.distance2(e.end()),0)?(oe[m++]=e.end().x,oe[m++]=e.end().y,oe[m++]=e.end().x,oe[m++]=e.end().y):(oe[m++]=g.x,oe[m++]=g.y,oe[m++]=g.x,oe[m++]=g.y);else{m=XM(r,n,o,l,c,u,m,g);let y=oe[m-2],E=oe[m-1];m-=2;let S=Ln.distance1(r,n,y,E);if(Re.eq(S,s))oe[m++]=y,oe[m++]=E,oe[m++]=y,oe[m++]=E;else if(S<s)m=aa(a,r,n,o,l,y,E,m),m=aa(a,r,n,y,E,c,u,m);else return 0}}else if(p===-1||f===-1)m=aa(a,r,n,o,l,c,u,m);else{let g=Rc.foot(t,e.center),b=g.distance1(e.center);if(Re.eq(b,s)){let y=function(w){return dM(i,w.x,w.y)&&jn(e,w)},E=e.start(),S=e.end();if(p===0){let w=t.start();if(y(w))return oe[m++]=w.x,oe[m++]=w.y,oe[m++]=w.x,oe[m++]=w.y,m;if(y(g))return oe[m++]=g.x,oe[m++]=g.y,oe[m++]=g.x,oe[m++]=g.y,m;if(Re.eq(t.distance2(E),0)&&y(E))return oe[m++]=E.x,oe[m++]=E.y,oe[m++]=E.x,oe[m++]=E.y,m;if(Re.eq(t.distance2(S),0)&&y(S))return oe[m++]=S.x,oe[m++]=S.y,oe[m++]=S.x,oe[m++]=S.y,m;if(h<=s)m=aa(a,r,n,g.x,g.y,c,u,m),m===2&&(oe[m++]=oe[0],oe[m++]=oe[1]);else if(b<s){if(m=aa(a,r,n,g.x,g.y,c,u,m),m===2&&y(new Ie(oe[0],oe[1])))return oe[m++]=oe[0],oe[m++]=oe[1],m;m=aa(a,r,n,g.x,g.y,o,l,0),m===2&&(oe[m++]=oe[0],oe[m++]=oe[1])}}else{let w=t.end();if(y(w))return oe[m++]=w.x,oe[m++]=w.y,oe[m++]=w.x,oe[m++]=w.y,m;if(y(g))return oe[m++]=g.x,oe[m++]=g.y,oe[m++]=g.x,oe[m++]=g.y,m;if(Re.eq(t.distance2(E),0)&&y(E))return oe[m++]=E.x,oe[m++]=E.y,oe[m++]=E.x,oe[m++]=E.y,m;if(Re.eq(t.distance2(S),0)&&y(S))return oe[m++]=S.x,oe[m++]=S.y,oe[m++]=S.x,oe[m++]=S.y,m;if(d<=s)m=aa(a,r,n,g.x,g.y,o,l,m),m===2&&(oe[m++]=oe[0],oe[m++]=oe[1]);else if(b<s){if(m=aa(a,r,n,g.x,g.y,o,l,m),m===2&&y(new Ie(oe[0],oe[1])))return oe[m++]=oe[0],oe[m++]=oe[1],m;m=aa(a,r,n,g.x,g.y,c,u,0),m===2&&(oe[m++]=oe[0],oe[m++]=oe[1])}}}else if(p===0){let y=t.start();oe[m++]=y.x,oe[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=aa(a,r,n,g.x,g.y,c,u,m))}else{let y=t.end();oe[m++]=y.x,oe[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=aa(a,r,n,g.x,g.y,o,l,m))}}if(m>0){let g=0;for(let b=0;b<m;b+=2){let y=oe[b],E=oe[b+1];isFinite(y)&&isFinite(E)&&dM(i,y,E)&&jn(e,new Ie(y,E))&&(oe[g++]=y,oe[g++]=E)}return g}else return 0}else return 0}function HJ(e,t){if(e.bbox()){let i=e.center.x,r=e.center.y,n=e.rx2,s=t.start().x,a=t.start().y,o=t.end().x,l=t.end().y,c=e.center.distance2(t.start()),u=e.center.distance2(t.end()),h=Re.eq(c,n)?0:c>n?1:-1,d=Re.eq(u,n)?0:u>n?1:-1,p=0;if(h===-1&&d===-1)return 0;if(h===0&&d===0)oe[p++]=s,oe[p++]=a,oe[p++]=o,oe[p++]=l;else if(h===1&&d===1){let f=Rc.foot(t,e.center),m=f.distance2(e.center);if(Re.greater(m,n))return 0;if(Re.eq(m,n)){let g=f.distance2(e.start()),b=f.distance2(e.end());Re.eq(g,0)?(oe[p++]=e.start().x,oe[p++]=e.start().y):Re.eq(b,0)?(oe[p++]=e.end().x,oe[p++]=e.end().y):(oe[p++]=f.x,oe[p++]=f.y)}else{p=XM(i,r,s,a,o,l,p,f);let g=oe[p-2],b=oe[p-1],y=Ln.distance2(i,r,g,b);if(p-=2,Re.eq(y,n))oe[p++]=g,oe[p++]=b;else if(y<n)p=aa(n,i,r,s,a,g,b,p),p=aa(n,i,r,g,b,o,l,p);else return 0}}else if(h===-1||d===-1)p=aa(n,i,r,s,a,o,l,p);else{let f=Rc.foot(t,e.center);h===0?(oe[p++]=t.start().x,oe[p++]=t.start().y,Re.neq(f.distance2(t.start()),0)&&(s-f.x)*(o-f.x)+(a-f.y)*(l-f.y)<0&&(p=aa(n,i,r,f.x,f.y,o,l,p))):(oe[p++]=t.end().x,oe[p++]=t.end().y,Re.neq(f.distance2(t.end()),0)&&(s-f.x)*(o-f.x)+(a-f.y)*(l-f.y)<0&&(p=aa(n,i,r,f.x,f.y,s,a,p)))}if(p>0){let f=0;for(let m=0;m<p;m+=2){let g=oe[m],b=oe[m+1];isFinite(g)&&isFinite(b)&&(oe[f++]=g,oe[f++]=b)}return f}else return 0}else return 0}function aa(e,t,i,r,n,s,a,o){if(n==a){let E=e-(n-i)*(n-i);if(Re.greater(E,0)){let S=Math.sqrt(E),w=t-S,x=t+S,I=Math.min(r,s),A=Math.max(r,s);return w>=I&&w<=A&&(oe[o++]=w,oe[o++]=n),x>=I&&x<=A&&(oe[o++]=x,oe[o++]=n),o}}let l=Ln.distance2(r,n,t,i)-e;if(l===0)return oe[o++]=r,oe[o++]=n,o;let c=Ln.distance2(s,a,t,i)-e;if(c===0)return oe[o++]=s,oe[o++]=a,o;let u=r,h=n,d=s,p=a,f=NaN,m=NaN,g=Number.POSITIVE_INFINITY,b=0;for(;g!==0;){b++;let E=Math.max(Math.min(Math.abs(l)/(Math.abs(l)+Math.abs(c)),.75),.25);if(f=u+(d-u)*E,m=h+(p-h)*E,u===f&&h===m||d===f&&p===m){Math.abs(l)>Math.abs(c)?(f=d,m=p,g=c):(f=u,m=h,g=l);break}else g=Ln.distance2(f,m,t,i)-e,g<0&&l>c||g>0&&l<c?(d=f,p=m,c=g):(u=f,h=m,l=g)}let y=Math.sqrt(e)-Ln.distance1(f,m,t,i);return(Re.eq(0,g)||Re.eq(0,y))&&(oe[o++]=f,oe[o++]=m),o}function XM(e,t,i,r,n,s,a,o){let l=Ln.dotProd2(i,r,n,s,e,t),c=Ln.dotProd2(n,s,i,r,e,t);if(l>=0)return oe[a++]=n,oe[a++]=s,a;if(c>=0)return oe[a++]=i,oe[a++]=r,a;if(Ln.crossProd2(i,r,n,s,e,t)==0)return oe[a++]=e,oe[a++]=t,a;{let u=NaN,h=NaN,d=i,p=r,f=n,m=s,g=Ln.distance2(i,r,e,t),b=Ln.distance2(n,s,e,t),y=Number.POSITIVE_INFINITY,E=0;for(;y>0&&(E++,u=d+(f-d)*.5,h=p+(m-p)*.5,!(g==b||d==u&&p==h||f==u&&m==h));){y=Ln.distance2(u,h,e,t);let S=Ln.dotProd2(d,p,u,h,e,t);if(S==0)break;S<0?(f=u,m=h,b=y):(d=u,p=h,g=y)}return Ln.distance2(u,h,e,t)<Ln.distance2(o.x,o.y,e,t)?(oe[a++]=u,oe[a++]=h):(oe[a++]=o.x,oe[a++]=o.y),a}}function xA(e,t){if(e.rx===e.ry)return JE(e,t);throw new Error("not supported")}function jJ(e,t){if(e.rx===e.ry)return HJ(e,t);throw new Error("not supported")}function WM(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return zJ(e,t);throw new Error("not supported operation")}return 0}function zJ(e,t){let i=e.center.x,r=e.center.y,n=t.center.x,s=t.center.y,a=e.rx,o=t.rx,l=e.rx2,c=t.rx2,u=e.center.distance1(t.center),h=Math.abs(a-o),d=a+o;if(Re.greater(u,d)||Re.less(u,h))return 0;if(Re.eq(h+u,0)){let p=0,f;return jn(e,t.start())&&(oe[p]=t.start().x,oe[p+1]=t.start().y,p+=2,f=t.start()),jn(e,t.end())&&(oe[p]=t.end().x,oe[p+1]=t.end().y,p+=2,f=t.end()),p===0?(jn(t,e.start())&&(oe[p]=e.start().x,oe[p+1]=e.start().y,p+=2),jn(t,e.end())&&(oe[p]=e.end().x,oe[p+1]=e.end().y,p+=2)):p===2&&(!f.equals1(e.start())&&jn(t,e.start())&&(oe[p]=e.start().x,oe[p+1]=e.start().y,p+=2),!f.equals1(e.end())&&jn(t,e.end())&&(oe[p]=e.end().x,oe[p+1]=e.end().y,p+=2)),p}else if(Re.eq(u,d)){if(fM(e,t))return 4;let p=new ye(e.center,t.center),f=JE(t,p);return f=mM(e,f),f!==0?f:(f=JE(e,p),mM(t,f))}else if(Re.eq(u,h)){if(fM(e,t))return 4;if(a>o){let p=(a-o)/a;return oe[0]=i+(n-i)/p,oe[1]=r+(s-r)/p,gM(e,t,2)}else{let p=(o-a)/o;return oe[0]=n+(i-n)/p,oe[1]=s+(r-s)/p,gM(e,t,2)}}else{let p=(e.center.distance2(t.center)-c+l)/(u*2)/u,f=(n-i)*p+i,m=(s-r)*p+r,g=n-i,b=s-r,y=Math.max(a,o),E,S,w,x;if(Math.abs(g)<Math.abs(b)){let R=g/-b,M=m-R*f;E=f-y,S=R*E+M,w=f+y,x=R*w+M}else{let R=b/-g,M=f-R*m;S=m-y,E=R*S+M,x=m+y,w=R*x+M}let I=aa(l,i,r,E,S,f,m,0);if(I=aa(l,i,r,f,m,w,x,I),I!==4)throw new Error("cnt !== 4");let A=new Ie(oe[0],oe[1]),O=new Ie(oe[2],oe[3]);if(jn(e,A)&&jn(t,A))return jn(e,O)&&jn(t,O)?4:gd(e.start(),t,O,A)?(oe[2]=e.start().x,oe[3]=e.start().y,4):gd(e.end(),t,O,A)?(oe[2]=e.end().x,oe[3]=e.end().y,4):gd(t.start(),e,O,A)?(oe[2]=t.start().x,oe[3]=t.start().y,4):gd(t.end(),e,O,A)?(oe[2]=t.end().x,oe[3]=t.end().y,4):2;if(jn(e,O)&&jn(t,O))return gd(e.start(),t,A,O)?(oe[0]=e.start().x,oe[1]=e.start().y,4):gd(e.end(),t,A,O)?(oe[0]=e.end().x,oe[1]=e.end().y,4):gd(t.start(),e,A,O)?(oe[0]=t.start().x,oe[1]=t.start().y,4):gd(t.end(),e,A,O)?(oe[0]=t.end().x,oe[1]=t.end().y,4):(oe[0]=oe[2],oe[1]=oe[3],2);{let R=function(V,q){if(Re.eq(V.distance1(q.center),q.rx)&&jn(q,V)){if(V.distance2(A)<V.distance2(O)){if(M)return;M=!0}else{if(F)return;F=!0}oe[G++]=V.x,oe[G++]=V.y}},M=!1,F=!1,G=0;return R(e.start(),t),R(e.end(),t),R(t.start(),e),R(t.end(),e),G}}}function gd(e,t,i,r){return Re.eq(e.distance1(t.center),t.rx)&&jn(t,e)&&e.distance2(i)<e.distance2(r)}function fM(e,t){return Re.eq(t.start().distance1(e.center),e.rx)&&jn(e,t.start())?(oe[0]=t.start().x,oe[1]=t.start().y,oe[2]=t.start().x,oe[3]=t.start().y,!0):Re.eq(t.end().distance1(e.center),e.rx)&&jn(e,t.end())?(oe[0]=t.end().x,oe[1]=t.end().y,oe[2]=t.end().x,oe[3]=t.end().y,!0):Re.eq(e.start().distance1(t.center),t.rx)&&jn(t,e.start())?(oe[0]=e.start().x,oe[1]=e.start().y,oe[2]=e.start().x,oe[3]=e.start().y,!0):Re.eq(e.end().distance1(t.center),t.rx)&&jn(t,e.end())?(oe[0]=e.end().x,oe[1]=e.end().y,oe[2]=e.end().x,oe[3]=e.end().y,!0):!1}function mM(e,t){if(t===0)return 0;let i=oe[0],r=oe[1];return jn(e,new Ie(i,r))?(oe[0]=i,oe[1]=r,oe[2]=i,oe[3]=r,4):0}function gM(e,t,i){if(i===0)return 0;let r=oe[0],n=oe[1],s=new Ie(r,n);return jn(e,s)&&jn(t,s)?(oe[0]=r,oe[1]=n,oe[2]=r,oe[3]=n,4):0}function km(e,t){return Math.abs(e-t)<=1e-6}function jn(e,t){let i=e.bbox();if(t.x-i.minX>-H0&&t.x-i.maxX<H0&&t.y-i.minY>-H0&&t.y-i.maxY<H0){let r=ti.regularD(t.angleD(e.center));return km(r,e.startAngle)||km(r,e.startAngle+360)||km(r,e.startAngle-360)||km(r,e.endAngle())||km(r,e.endAngle()+360)||km(r,e.endAngle()-360)?!0:e.sweepAngle>0?(Re.less(r,e.startAngle)&&(r+=360),Re.greatereq(e.endAngle(),r)):(Re.greater(r,e.startAngle)&&(r-=360),Re.lesseq(e.endAngle(),r))}else return!1}function XJ(e,t){let i=e[1].x-e[0].x,r=e[1].y-e[0].y,n=t[1].x-t[0].x,s=t[1].y-t[0].y;if(i===0&&n!==0||i!==0&&n===0)return!1;if(i===0&&n===0)return!0;let a=r/i,o=s/n;return zM(a,o,Math.sin(Math.PI/180))}function WJ(e,t,i){var r,n=+t.x,s=+t.y,a=+i.x,o=+i.y,l=+e.x,c=+e.y,u=a-n,h=o-s,d=l-n,p=c-s,f,m,g,b,y,E;return u===0&&h===0?{d:Math.sqrt(d*d+p*p),point:new Ie(n,s)}:(r=(d*u+p*h)/(u*u+h*h),r<0?{d:Math.sqrt(d*d+p*p),point:new Ie(n,s)}:r>1?(f=l-a,m=c-o,{d:Math.sqrt(f*f+m*m),point:new Ie(a,o)}):(y=n+r*u,E=s+r*h,g=l-y,b=c-E,{d:Math.sqrt(g*g+b*b),point:new Ie(y,E)}))}function Oc(e,t){if(!e||!t||e.length!=t.length)return!1;let i="equals1";return!e.some((r,n)=>{let s=t[n],a=!1;return r&&s&&typeof r=="object"&&typeof s=="object"?typeof r[i]=="function"&&JJ(r,s)?a=!r[i].call(r,s):a=!(r===s||r.toString()===s.toString()):typeof r=="number"&&typeof s=="number"?a=!(qJ(r,s)||Number.isNaN(r)&&Number.isNaN(s)):a=r!==s,a})}function qJ(e,t,i=5){return Math.abs(e-t)*Math.pow(10,i)<1}function JJ(e,t){return!e||!t||typeof e!="object"||typeof t!="object"?e===t:e.constructor===t.constructor}var yi=new Float64Array(100);function UE(e,t){if(e.bbox().extendOfSize(Re.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,n=0,s=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(C){M=Math.min(M,C),F=Math.max(F,C)},o=function(C,N){let T=Tu(C,N);if(T===0)throw new Error("cnt === 0");for(let L=0;L<T;L+=2)a(oe[L])};if(n>r){for(let C=n-2;C>=2;C-=2)for(let N=C-2;N>=0;N-=2)if(Re.eq(yi[C],yi[N])&&Re.eq(yi[C+1],yi[N+1])){yi[N]=(yi[C]+yi[N])/2,yi[N+1]=(yi[C+1]+yi[N+1])/2;for(let T=n-3;T>=C;T--)yi[T]=yi[T+2];n-=2;break}if(n>r){n=0;let C=t.start(),N=new Float64Array(8);e.getPercent(C)!==null&&(N[n++]=C.x,N[n++]=C.y);let T=t.end();e.getPercent(T)!==null&&(N[n++]=T.x,N[n++]=T.y);let L=e.start();t.getPercent(L)!==null&&(N[n++]=L.x,N[n++]=L.y);let P=e.end();return t.getPercent(P)!==null&&(N[n++]=P.x,N[n++]=P.y),oe.set(N),n}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let C=Tu(new ye(u[0],u[1]),new ye(h[0],h[1]));for(let N=0;N<C;N++)yi[n++]=oe[N];continue}let d=u[0],p=u[u.length-1];d.equals1(p)&&(p=d.add1(1,0));let f=p.y-d.y,m=d.x-p.x,g=-f*d.x-m*d.y,b=Math.sqrt(1/(f**2+m**2));f*=b,m*=b,g*=b;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(C=>{let N=f*C.x+m*C.y+g;N<y&&(y=N),N>E&&(E=N)}),Re.eq(y,E)){if(c.controls.length===2){let C=Tu(new ye(l.start(),l.end()),new ye(c.start(),c.end()));for(let N=0;N<C;N++)yi[n++]=oe[N];if(C!==0)continue}l=new gt([u[0],u[u.length-1]]),u=l.controls}let S=h.map(C=>{let N=f*C.x+m*C.y+g,T=Math.abs(N);return T<s&&(s=T),N}),w=0;for(let C of S){if(Re.less(C,y))w=w|1;else if(Re.greater(C,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let x=0,I=0,A=p.x-d.x,O=p.y-d.y,R=Math.sqrt(1/(A**2+O**2));A*=R,O*=R;for(let C=1;C<u.length;C++){let N=u[C],T=(N.x-d.x)*A+(N.y-d.y)*O;T<x?x=T:T>I&&(I=T)}w=0;for(let C of h){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(Re.less(N,x))w=w|1;else if(Re.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;s/=2,s<=Re.eps&&(s=Re.eps),y-=s,E+=s,S.forEach((C,N)=>{C>=y&&C<=E&&a(N/(S.length-1))});let G=new ye(new Ie(0,y),new Ie(1,y)),V=new ye(new Ie(0,E),new Ie(1,E));for(let C=0;C<S.length-1;C++){let N=new Ie(C/(S.length-1),S[C]),T=N.y<y?1:N.y>E?2:3;for(let L=0;L<S.length;L++){let P=new Ie(L/(S.length-1),S[L]),B=P.y<y?1:P.y>E?2:3;T!==B&&(T===1?B===2?(o(new ye(N,P),G),o(new ye(N,P),V)):o(new ye(N,P),G):T===2?B===1?(o(new ye(N,P),G),o(new ye(N,P),V)):o(new ye(N,P),V):B===1?o(new ye(N,P),G):o(new ye(N,P),V))}}M!==0&&(c=c.clip(M)[1]),F!==1&&(c=c.clip((F-M)/(1-M))[0]);let q=c.bbox();if(Re.eq(q.minX,q.maxX)&&Re.eq(q.minY,q.maxY)){w=0;for(let C of c.controls){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(Re.less(N,x))w=w|1;else if(Re.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let C=new Ie((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(C)&&(yi[n++]=C.x,yi[n++]=C.y)}continue}if(F-M>.8){let[C,N]=c.clip(.5);i.push([C,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)oe[a]=yi[a];return n}function KJ(e,t){if(e.bbox().extendOfSize(Re.eps).isSeparated(t.bbox()))return{cnt:0};let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,n=0,s=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(C){M=Math.min(M,C),F=Math.max(F,C)},o=function(C,N){let T=Tu(C,N);if(T===0)throw new Error("cnt === 0");for(let L=0;L<T;L+=2)a(oe[L])};if(n>r){for(let C=n-2;C>=2;C-=2)for(let N=C-2;N>=0;N-=2)if(Re.eq(yi[C],yi[N])&&Re.eq(yi[C+1],yi[N+1])){yi[N]=(yi[C]+yi[N])/2,yi[N+1]=(yi[C+1]+yi[N+1])/2;for(let T=n-3;T>=C;T--)yi[T]=yi[T+2];n-=2;break}if(n>r){n=0;let C=new Float64Array(8),N=t.end(),T=0;e.getPercent(N)!==null&&(C[n++]=N.x,C[n++]=N.y,T=2);let L=e.end();return t.getPercent(L)!==null&&(C[n++]=L.x,C[n++]=L.y,T=T===0?1:3),oe.set(C),{havOverlap:T,cnt:n}}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let C=Tu(new ye(u[0],u[1]),new ye(h[0],h[1]));for(let N=0;N<C;N++)yi[n++]=oe[N];continue}let d=u[0],p=u[u.length-1];d.equals1(p)&&(p=d.add1(1,0));let f=p.y-d.y,m=d.x-p.x,g=-f*d.x-m*d.y,b=Math.sqrt(1/(f**2+m**2));f*=b,m*=b,g*=b;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(C=>{let N=f*C.x+m*C.y+g;N<y&&(y=N),N>E&&(E=N)}),Re.eq(y,E)){if(c.controls.length===2){let C=Tu(new ye(l.start(),l.end()),new ye(c.start(),c.end()));for(let N=0;N<C;N++)yi[n++]=oe[N];if(C!==0)continue}l=new gt([u[0],u[u.length-1]]),u=l.controls}let S=h.map(C=>{let N=f*C.x+m*C.y+g,T=Math.abs(N);return T<s&&(s=T),N}),w=0;for(let C of S){if(Re.less(C,y))w=w|1;else if(Re.greater(C,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let x=0,I=0,A=p.x-d.x,O=p.y-d.y,R=Math.sqrt(1/(A**2+O**2));A*=R,O*=R;for(let C=1;C<u.length;C++){let N=u[C],T=(N.x-d.x)*A+(N.y-d.y)*O;T<x?x=T:T>I&&(I=T)}w=0;for(let C of h){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(Re.less(N,x))w=w|1;else if(Re.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;s/=2,s<=Re.eps&&(s=Re.eps),y-=s,E+=s,S.forEach((C,N)=>{C>=y&&C<=E&&a(N/(S.length-1))});let G=new ye(new Ie(0,y),new Ie(1,y)),V=new ye(new Ie(0,E),new Ie(1,E));for(let C=0;C<S.length-1;C++){let N=new Ie(C/(S.length-1),S[C]),T=N.y<y?1:N.y>E?2:3;for(let L=0;L<S.length;L++){let P=new Ie(L/(S.length-1),S[L]),B=P.y<y?1:P.y>E?2:3;T!==B&&(T===1?B===2?(o(new ye(N,P),G),o(new ye(N,P),V)):o(new ye(N,P),G):T===2?B===1?(o(new ye(N,P),G),o(new ye(N,P),V)):o(new ye(N,P),V):B===1?o(new ye(N,P),G):o(new ye(N,P),V))}}M!==0&&(c=c.clip(M)[1]),F!==1&&(c=c.clip((F-M)/(1-M))[0]);let q=c.bbox();if(Re.eq(q.minX,q.maxX)&&Re.eq(q.minY,q.maxY)){w=0;for(let C of c.controls){let N=(C.x-d.x)*A+(C.y-d.y)*O;if(Re.less(N,x))w=w|1;else if(Re.greater(N,I))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let C=new Ie((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(C)&&(yi[n++]=C.x,yi[n++]=C.y)}continue}if(F-M>.8){let[C,N]=c.clip(.5);i.push([C,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)oe[a]=yi[a];return{cnt:n}}var $J=class{constructor(e=Re.eps){this.eps=e}eq(e,t){return Math.abs(e-t)<=this.eps}setEps(e){this.eps=e}},F0=new $J;function yM(e,t){if(e.bbox().extendOfSize(Re.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(t.controls.length-1)*16,n=0;for(;i.length!==0;){if(n>r){let a=function(){for(let c=0;c<n;c+=2)for(let u=c+2;u<n;u+=2)if(!(F0.eq(yi[c],yi[u])&&F0.eq(yi[c+1],yi[u+1]))){l(yi[u],yi[u+1],o);break}function l(c,u,h){let d=!1;for(let p=0;p<h.length;p+=2)if(F0.eq(c,h[p])&&F0.eq(u,h[p+1])){d=!0;break}d||h.push(c,u)}},o=[yi[0],yi[1]];if(a(),o.length>=100&&(F0.setEps(.001),o=[yi[0],yi[1]],a(),o.length>=100))throw new Error("clearSamePoint()");n=o.length,o.forEach((l,c)=>yi[c]=l)}let s=i.pop();if(s[0]instanceof Le){let a=function(V){O=Math.min(O,V),R=Math.max(R,V)},o=function(V,q){let C=Tu(V,q);if(C===0)throw new Error("cnt === 0");for(let N=0;N<C;N+=2)a(oe[N])},[l,c]=s,u=c.controls;if(u.length===2){let V=xA(l,new ye(u[0],u[1]));for(let q=0;q<V;q++)yi[n++]=oe[q];continue}let h=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,p,f,m,g,b;if(Math.abs(l.sweepAngle)>359){let V=l.rx;p=l.center.add1(V,0),f=l.center.add1(-V,0),h=-V,d=V,m=0,g=1,b=-l.center.y}else{p=l.start(),f=l.end(),m=f.y-p.y,g=p.x-f.x,b=-m*p.x-g*p.y;let V=Math.sqrt(1/(m**2+g**2));m*=V,g*=V,b*=V;let q=m*l.center.x+g*l.center.y+b;l.isCCW?(d=l.rx+q,h=0):(h=q-l.rx,d=0)}let y=u.map(V=>m*V.x+g*V.y+b),E=0;for(let V of y){if(Re.less(V,h))E=E|1;else if(Re.greater(V,d))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let S=0,w=0,x=f.x-p.x,I=f.y-p.y,A=Math.sqrt(1/(x**2+I**2));if(x*=A,I*=A,Math.abs(l.sweepAngle)<=180)S=0,w=(f.x-p.x)*x+(f.y-p.y)*I;else throw new Error("not support");E=0;for(let V of u){let q=(V.x-p.x)*x+(V.y-p.y)*I;if(Re.less(q,S))E=E|1;else if(Re.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let O=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY;h-=Re.eps,d+=Re.eps,y.forEach((V,q)=>{V>=h&&V<=d&&a(q/(y.length-1))});let M=new ye(new Ie(0,h),new Ie(1,h)),F=new ye(new Ie(0,d),new Ie(1,d));for(let V=0;V<y.length-1;V++){let q=new Ie(V/(y.length-1),y[V]),C=q.y<h?1:q.y>d?2:3;for(let N=0;N<y.length;N++){let T=new Ie(N/(y.length-1),y[N]),L=T.y<h?1:T.y>d?2:3;C!==L&&(C===1?L===2?(o(new ye(q,T),M),o(new ye(q,T),F)):o(new ye(q,T),M):C===2?L===1?(o(new ye(q,T),M),o(new ye(q,T),F)):o(new ye(q,T),F):L===1?o(new ye(q,T),M):o(new ye(q,T),F))}}O!==0&&(c=c.clip(O)[1]),R!==1&&(c=c.clip((R-O)/(1-O))[0]);let G=c.bbox();if(Re.eq(G.minX,G.maxX)&&Re.eq(G.minY,G.maxY)){E=0;for(let V of c.controls){let q=(V.x-p.x)*x+(V.y-p.y)*I;if(Re.less(q,S))E=E|1;else if(Re.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}E===3&&(yi[n++]=(G.minX+G.maxX)/2,yi[n++]=(G.minY+G.maxY)/2);continue}R-O>.8?c.clip(.5).forEach(V=>i.push([V,l])):i.push([c,l])}else{let[a,o]=s;i.push([Le.build3(o.center,o.startAngle,o.sweepAngle/2,o.rx,o.ry),a]),i.push([Le.build3(o.center,o.startAngle+o.sweepAngle/2,o.sweepAngle/2,o.rx,o.ry),a])}}for(let s=0;s<n;s++)oe[s]=yi[s];return n}var ZJ=class{static getSweep(e){if(e.length>2){let t=0,i=e.length;for(let s=0;s<i-1;s++){let a=e[s],o=e[s+1];t+=(o.x+a.x)*(o.y-a.y)}let r=e[0],n=e[i-1];return t+=(r.x+n.x)*(r.y-n.y),t>0}else throw new Error("Unable to determine the direction of rotation!")}static isClose(e){return!!(e.primitives.length>0&&e.primitives[0].start().equals1(e.primitives[e.primitives.length-1].end()))}};function QJ(e){let t=e.primitives,i=t[0],r=i instanceof Le?i.sweepAngle%360:null;if(t.length===1&&i instanceof Le&&(Re.eq(r,0)||Re.eq(Math.abs(r),360)))return!!i.isCCW;let n=new Array;return e.points(.1,s=>{n.push(s)}),ZJ.getSweep(n)}var eK=class{static zoomCorner(e,t){let i=new Array,r=new Array,n=new Array;return this.getPanPrimitive(e,i,n,t),this.rearrange(i,n),this.processStart(i,n),this.getResult(i,n,r,t),r.length>0?Ci.build2(r):null}static zoomPolygon(e,t){let i=new Array,r=new Array,n=new Array;return QJ(e)&&(e=e.reverse().asClose()),this.getPanPrimitive(e,i,n,t),this.rearrange(i,n),this.processStart(i,n),this.getResult(i,n,r,t),r.length>0?Ci.build2(r):null}static zoomLines(e,t){return this.zoomPolygon(Ci.build2(e.primitives.concat(e.reverse().primitives)),t/2)}static getPanPrimitive(e,t,i,r){let n=e.primitives;for(let s of n){let a=this.panDistance(s,r);a!==void 0&&(t.push(a),i.push(s))}}static rearrange(e,t){let i=e.length,r=0;for(let a=0;a<i;a++){let o=t[a],l=e[a],c=a==i-1?e[0]:e[a+1];if(!(l instanceof Le&&c instanceof Le)&&!this.isCW(l.end(),c.start(),o.end())){if(Wl(l,c)!=0){r=a==i-1?0:a+1;break}}else{r=a;break}}let n=this.start4Index(t,r),s=this.start4Index(e,r);t.length=0,e.length=0,n.forEach(a=>{t.push(a)}),s.forEach(a=>{e.push(a)})}static processStart(e,t){let i=e.length;if(i>2){let r=e[i-1],n=e[0],s=t[i-1];if(!(r instanceof Le&&n instanceof Le)&&!this.isCW(r.end(),n.start(),s.end())){let a=Wl(r,n);for(let o=0;o<a;o+=2){let l=new Ie(oe[o],oe[o+1]);e[i-1]=this.generatePrimitive(r,r.start(),l),e[0]=this.generatePrimitive(n,l,n.end())}}}}static getResult(e,t,i,r){let n=e.length;for(let s=0;s<n;s++){let a=t[s],o=s===n-1?t[0]:t[s+1],l=s==n-1?0:s+1,c=l==n-1?t[0]:t[l+1],u=e[s],h=s==n-1?e[0]:e[s+1],d=l==n-1?e[0]:e[l+1];if(!(u instanceof Le&&h instanceof Le)&&!this.isCW(u.end(),h.start(),a.end())){let f=this.add(e,i,s,u,h,0);f=this.update(e,i,s,h,f);let m=this.generateArc(o,c,h,d,r);if(f=this.add(e,i,s,u,m,f),f=this.update(e,i,s,m,f),f>0)continue}i.push(u);let p=this.generateArc(a,o,u,h,r);p!==void 0&&i.push(p)}}static generateArc(e,t,i,r,n){if(n>0){let s=e.end(),a=t.start(),o=i.end(),l=r.start();if(o.distance2(l)>1e-8)if(s.equals(a)){let c=o.angleD(s),u=l.angleD(s);return Le.build2(s,c,u,n,n,0)}else{let c=o.angleD(s),u=l.angleD(s),h=o.angleD(a),d=l.angleD(a),p=Le.build2(s,c,u,n,n,0),f=Le.build2(a,h,d,n,n,0);return p.pointOn(p.endAngle()).equals1(l)?p:f.pointOn(f.endAngle()).equals1(l)?f:p}}}static updateNews(e,t,i,r){let n=e.length,s=t==n-1?0:t+1;e[s]=this.generatePrimitive(i,r,i.end())}static add(e,t,i,r,n,s){if(s>0)return s;if(r!=null&&n!=null){let a=Wl(r,n);for(let o=0;o<a;o+=2){let l=new Ie(oe[o],oe[o+1]);t.push(this.generatePrimitive(r,r.start(),l)),this.updateNews(e,i,n,l);break}return a}else return 0}static update(e,t,i,r,n){if(n>0)return n;let s=t.length;if(s>0&&r!=null){let a=t[s-1],o=Wl(a,r);for(let l=0;l<o;l+=2){let c=new Ie(oe[l],oe[l+1]);t[s-1]=this.generatePrimitive(a,a.start(),c),this.updateNews(e,i,r,c)}return o}else return 0}static generatePrimitive(e,t,i){if(e instanceof ye)return new ye(t,i);if(e instanceof Le){let r=e,n=t.angleD(r.center),s=i.angleD(r.center);return Le.build2(r.center,n,s,r.rx,r.ry,r.sweep())}else throw new Error("not supported operation")}static start4Index(e,t){let i=e.length,r=new Array;for(let n=t;n<i;n++)r.push(e[n]);for(let n=0;n<t;n++)r.push(e[n]);return r}static isCW(e,t,i){let r=new ye(i,e),n=new ye(i,t),s=r.end().x-r.start().x,a=r.end().y-r.start().y,o=n.end().x-n.start().x,l=n.end().y-n.start().y;return!(s*l-a*o>0)}static panDistance(e,t){if(e instanceof ye){if(e.isPoint())return;{let i=e.panDistance(t);return i.length()>1e-5?i:void 0}}else if(e instanceof Le){let i=e;if(i.sweepAngle>0){if(i.rx-t<=0||i.ry-t<=0)return}else if(i.sweepAngle<0&&(i.rx+t<=0||i.ry+t<=0))return;return i=i.panDistance(t),i.start().distance1(i.end())>1e-5||Re.eq(Math.abs(i.sweepAngle),360)?i:void 0}else throw new Error("not supported operation")}},Ht=.001,Ca=Ht**2;function Ct(e,t){return e.distance2(t)<Ca}function Iu(e,t){return Math.abs(e-t)<=1e-4}function tK(e,t){if(e instanceof ye)return new ye(e.start(),t);if(e instanceof Le){let i=t.angleD(e.center);return Iu(ti.regularD(e.startAngle),ti.regularD(i))?Le.build3(e.center,e.startAngle,0,e.rx,e.ry):Le.build2(e.center,e.startAngle,i,e.rx,e.ry,e.isCCW?1:0)}else{if(e instanceof gt)return e.clip(e.getPercent(t,Ht))[0];throw new Error("not supported operation")}}function Nc(e,t=ti.toRadians(e.startAngle)){return e.isCCW?t+=qE:t-=qE,new Ie(Math.cos(t),Math.sin(t))}function Q0(e,t=0){let i=e.controls;if(t===0){let r=i[0],n=i.slice(1).find(s=>!(s.x===r.x&&s.y===r.y));if(!n)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return n.sub(r)}else if(t===1){let r=i[i.length-1],n=i.slice(0,-1).reverse().find(s=>!(s.x===r.x&&s.y===r.y));if(!n)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return r.sub(n)}if(i.length===3){let[r,n,s]=i;return n.sub(r).mul(2*(1-t)).add(s.sub(n).mul(2*t)).normalize()}else{let[r,n,s,a]=i;return n.sub(r).mul(3*(1-t)**2).add(s.sub(n).mul(6*(1-t)*t)).add(a.sub(s).mul(3*t**2)).normalize()}}function Jm(e,t,i){let r=e.slice(1).findIndex(s=>!(s.x===t.x&&s.y===t.y)),n=e[r+1];if(i&&(i.getPercent(n,Ht)!==null||new ye(i.start(),i.end()).distance(n)<=Ht)&&(n=e[r+2]),!n)throw Error("getSecondPoint(controls: readonly Vector2[])");return n}function Vt(e,t){if(e instanceof ye)return e.end().sub(e.start()).normalize();if(e instanceof Le)return(t?Nc(e,t.angle(e.center)):Nc(e)).normalize();if(e instanceof gt)if(e.controls.length===2){let[i,r]=e.controls;if(Ct(i,r))throw Error("equalsPP(p0, p1)");return r.sub(i).normalize()}else return(t?Q0(e,e.getPercent(t,Ht)):Q0(e)).normalize();else throw new Error("not support")}function iK(e,t,i){let r=[],n=t**2-4*e*i;if(n>=0){let s=-t/(2*e),a=Math.sqrt(n)/(2*e),o=s+a;if(r.push(o),n>0){let l=s-a;r.push(l)}}return r}function rK(e,t,i,r,n=0,s=1){let a=[],o=e*Math.pow(n,3)+t*Math.pow(n,2)+i*n+r,l=e*Math.pow(s,3)+t*Math.pow(s,2)+i*s+r,c,u;if(o*l<0)for(;Math.abs(n-s)>Ht;)if(c=(n+s)/2,u=e*Math.pow(c,3)+t*Math.pow(c,2)+i*c+r,Math.abs(u)<Ht){a.push(c);break}else o*u<0?s=c:l*u<0&&(n=c);else o*l===0&&(o===0&&a.push(n),l===0&&a.push(s));return a}function QI(e,t,i){if(e instanceof ye||t.distance2(i)<=Ca)return new ye(t,i);if(e instanceof Le)return Le.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof gt){let r=e.getPercent(t,Ht),n=e.getPercent(i,Ht);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function EA(e){return Re.greater(e,0)&&Re.less(e,1)}function KE(e,t,i,r){let n=e[r]-2*t[r]+i[r],s=t[r]-e[r];if(n===0)return[];let a=-s/n,o=[];return EA(a)&&o.push(a),o}function $E(e,t,i,r,n){let s,a,o=-e[n]+3*t[n]-3*i[n]+r[n],l=2*(e[n]-2*t[n]+i[n]),c=t[n]-e[n],u=l**2-4*o*c;if(Re.lesseq(u,0))s=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;else{let d=Math.sqrt(u);s=(-l-d)/(2*o),a=(-l+d)/(2*o);let p=o*2;if(Re.lesseq(s,1)&&Re.greatereq(s,0)){let f=Number.NEGATIVE_INFINITY;for(;Re.neq(s,f);){f=s;let m=p*s+l;s=-(o*s**2+l*s+c-m*s)/m}}if(Re.lesseq(a,1)&&Re.greatereq(a,0)){let f=Number.NEGATIVE_INFINITY;for(;Re.neq(a,f);){f=a;let m=p*a+l;a=-(o*a**2+l*a+c-m*a)/m}}}let h=[];return EA(a)&&h.push(a),EA(s)&&h.push(s),h}function qM(e,t){if(e.controls.length===2){let[o,l]=e.controls;Ct(o,l)||t.push(new ye(o,l));return}let i,r;if(e.controls.length===3){let[o,l,c]=e.controls;i=KE(o,l,c,"x"),r=KE(o,l,c,"y")}else{let[o,l,c,u]=e.controls;i=$E(o,l,c,u,"x"),r=$E(o,l,c,u,"y")}i.sort((o,l)=>l-o),r.sort((o,l)=>l-o);let n=i.pop()||1,s=r.pop()||1,a=0;for(;n!==1||s!==1;)if(Re.eq(n,s))n=i.pop()||1,s=r.pop()||1;else if(n<s){let[o,l]=e.clip((n-a)/(1-a));a=n,t.push(o),e=l,n=i.pop()||1}else{let[o,l]=e.clip((s-a)/(1-a));a=s,t.push(o),e=l,s=r.pop()||1}t.push(e)}var nK=1e-5,BA=1,gt=class ja extends r1{constructor(t){if(super(),this._startToEndL=null,t.length<2)throw new Error("Bezier needs at least 2 endpoints");this.controls=t.slice()}get startToEndL(){return this._startToEndL===null&&(this._startToEndL=new ye(this.start(),this.end())),this._startToEndL}build1(t){let i=[];return Km(t,(r,n)=>(i.push(n),!0)),new ja(i)}start(){return this.controls[0]}end(){return this.controls[this.controls.length-1]}static pointOn(t,i){if(i.length<1)throw new Error("bezier must have at least 1 point");if(i.length===1)return i[0];{let r=new Array(i.length-1);for(let n=1;n<i.length;n++){let s=i[n-1],a=i[n],o=(a.x-s.x)*t,l=(a.y-s.y)*t;r[n-1]=s.add1(o,l)}return ja.pointOn(t,r)}}clip1(t,i,r,n){if(r.push(i[0]),n.push(i[i.length-1]),i.length<2)throw new Error("bezier clip must have at least 2 point");if(i.length===2){let s=i[0],a=i[1],o=(a.x-s.x)*t,l=(a.y-s.y)*t,c=s.add1(o,l);r.push(c),n.push(c)}else{let s=new Array(i.length-1);for(let a=1;a<i.length;a++){let o=i[a-1],l=i[a],c=(l.x-o.x)*t,u=(l.y-o.y)*t;s[a-1]=o.add1(c,u)}this.clip1(t,s,r,n)}}clip(t){let i=[],r=[];return this.clip1(t,this.controls,i,r),[new ja(i),new ja(r.reverse())]}greater(t,i,r){return t-i>r}less(t,i,r){return t-i<-r}eq(t,i,r){return Math.abs(t-i)<=r}eqPP(t,i,r){return!t||!i?!1:this.eq(t.x,i.x,r)&&this.eq(t.y,i.y,r)}isInRange(t,i=Re.eps){let r=this.controls.map(s=>s.y-t.y),n=0;for(let s of r){if(this.less(s,0,i))n=n|1;else if(this.greater(s,0,i))n=n|2;else{n=3;break}if(n===3)break}if(n!==3)return!1;n=0;for(let s of this.controls){let a=s.x-t.x;if(this.less(a,0,i))n=n|1;else if(this.greater(a,0,i))n=n|2;else{n=3;break}if(n===3)break}return n===3}getPercent(t,i=Re.eps){if(!this.isInRange(t,i))return null;let r=Number.POSITIVE_INFINITY,n=[[this,0,1]];for(;n.length!==0;){let s=function(g){u=Math.min(u,g),h=Math.max(h,g)},a=function(g,b){let y=Tu(g,b);if(y===0)throw new Error("cnt === 0");for(let E=0;E<y;E+=2)s(oe[E])},[o,l,c]=n.pop();if(this.eqPP(o.start(),t,i))return l;if(this.eqPP(o.end(),t,i))return c;let u=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,d=o.controls.map(g=>g.y-t.y);r=d.reduce((g,b)=>{let y=Math.abs(b);return y<g?y:g},r),r/=2,r<=i&&(r=i),d.forEach((g,b)=>{this.eq(g,0,i)&&s(b/(d.length-1))});let p=new ye(new Ie(0,-r),new Ie(1,-r)),f=new ye(new Ie(0,r),new Ie(1,r));for(let g=0;g<d.length-1;g++){let b=new Ie(g/(d.length-1),d[g]),y=this.less(b.y,0,i)?1:this.greater(b.y,0,i)?2:3;for(let E=0;E<d.length;E++){let S=new Ie(E/(d.length-1),d[E]),w=this.less(S.y,0,i)?1:this.greater(S.y,0,i)?2:3;y!==w&&(y===1?w===2?(a(new ye(b,S),p),a(new ye(b,S),f)):a(new ye(b,S),p):y===2?w===1?(a(new ye(b,S),p),a(new ye(b,S),f)):a(new ye(b,S),f):w===1?a(new ye(b,S),p):a(new ye(b,S),f))}}if(!isFinite(u)){if(Math.max(...d.map(g=>Math.abs(g)))<i*4)return(l+c)/2;continue}if(u!==0&&(o=o.clip(u)[1],l=(c-l)*u+l),h!==1){let g=(h-u)/(1-u);o=o.clip(g)[0],c=(c-l)*g+l}if(!o.isInRange(t,i))continue;let m=o.controls.reduce((g,b)=>g.ext2(b),new Mo).build1();if(this.eq(m.minX,m.maxX,i)&&this.eq(m.minY,m.maxY,i))return(l+c)/2;if(h-u>.8){let[g,b]=o.clip(.5);g.isInRange(t,i)?(n.push([g,l,(l+c)/2]),b.isInRange(t,i)&&n.push([b,(l+c)/2,c])):n.push([b,(l+c)/2,c])}else n.push([o,l,c])}return null}toBezier(){return this}toString(){return"Bezier ["+this.controls.join(" ")+"]"}bbox(){return this._bbox||(this._bbox=new Mo().ext3(this.points(.1)).build1()),this._bbox}bboxWithControls(){return this._bbox_controls||(this._bbox_controls=new Mo().ext3(this.controls).build()),this._bbox_controls}multiply3(t){let i=new Array(this.controls.length);for(let r=0;r<this.controls.length;r++){let n=this.controls[r];i[r]=n.multiply3(t)}return new ja(i)}stroke(t,i,r,n=BA){let s=eK.zoomLines(Ci.build4(this.points(n)),t);return r===0?s:s.reverse()}points(t){let i=[];return this.getBezierPoints(t,r=>i.push(r)),i}getBezierPoints(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=[this];for(i(this.start());r.length!==0;){let s=r.pop(),a=new ye(s.start(),s.end());if(n(s.controls,a)<=t)i(s.end());else{let[o,l]=s.clip(.5);r.push(l,o)}}function n(s,a){let o=a.start(),l=a.end();o.equals1(l)&&(l=o.add1(1,0));let c=l.y-o.y,u=o.x-l.x,h=-c*o.x-u*o.y,d=Math.sqrt(1/(c**2+u**2));c*=d,u*=d,h*=d;let p=s.map(f=>Math.abs(c*f.x+u*f.y+h));return Math.max(...p)}}getBezierPoints3(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=t*t,n=this.controls[0],s=.5;for(;s>nK&&!(n.distance2(ja.pointOn(s,this.controls))<=r);s*=.5);let a=Math.ceil(1/s);s=1/a,i(n);let o=0;for(let l=1;l<a;l++)o+=s,i(ja.pointOn(o,this.controls));i(this.end())}getPointsBySlope(t){if(this.controls.length===4)return this.getPointsBySlope4(t);throw new Error("Currently, only 4 control points are supported!")}getPointsBySlope4(t){let[i,r,n,s]=this.controls,a=-3*i.x+9*r.x-9*n.x+3*s.x,o=6*i.x-12*r.x+6*n.x,l=-3*i.x+3*r.x,c=[];if(Number.isFinite(t)){let u=-3*i.y+9*r.y-9*n.y+3*s.y,h=6*i.y-12*r.y+6*n.y,d=-3*i.y+3*r.y,p=u-a*t,f=h-o*t,m=d-l*t,g=-f/(2*p),b=Math.sqrt(f**2-4*p*m)/(2*p),y=g+b;y>=0&&y<=1&&c.push(ja.pointOn(y,this.controls));let E=g-b;E>=0&&E<=1&&c.push(ja.pointOn(E,this.controls))}else{let u=-o/(2*a),h=Math.sqrt(o**2-4*a*l)/(2*a),d=u+h;d>=0&&d<=1&&c.push(ja.pointOn(d,this.controls));let p=u-h;p>=0&&p<=1&&c.push(ja.pointOn(p,this.controls))}return c}buildConverxHull(t=Re.eps){let i=[...this.controls],r=[],n=i[0],s=1;do{let a=i[s%i.length];this.eqPP(n,a,t)||r.push(new ye(n,a)),n=a,s++}while(n!==i[0]);if(r.length===0)throw Error("buildConverxHull(diff = DoubleKit.eps)");return Ci.build7(r).asClose()}getExtremePoints(t){if(!t)return a(this.controls);let i=t.start(),r=t.end(),n=r.x-i.x,s=r.y-i.y;if(Math.abs(n)<=Re.eps||Math.abs(s)<=Re.eps)return a(this.controls);{let o=s/n;if(this.controls.length===3){i.equals1(r)&&(r=i.add1(1,0));let l=r.y-i.y,c=i.x-r.x,u=-l*i.x-c*i.y,h=Math.sqrt(1/(l**2+c**2));l*=h,c*=h,u*=h;let d=this.controls.map(m=>l*m.x+c*m.y+u),p=d[0]-2*d[1]+d[2],f=d[1]-d[0]-o/2;if(p!==0){let m=-f/p;if(Re.greater(m,0)&&Re.less(m,1))return[ja.pointOn(m,this.controls)]}}else if(this.controls.length===4)return this.getPointsBySlope(o)}return[];function a(o){let l,c;if(o.length===3){let[p,f,m]=o;l=KE(p,f,m,"x"),c=KE(p,f,m,"y")}else if(o.length===4){let[p,f,m,g]=o;l=$E(p,f,m,g,"x"),c=$E(p,f,m,g,"y")}l.sort((p,f)=>f-p),c.sort((p,f)=>f-p);let u=l.pop()||1,h=c.pop()||1,d=[];for(;u!==1||h!==1;)Re.eq(u,h)?(u=l.pop()||1,h=c.pop()||1):u<h?(d.push(ja.pointOn(u,o)),u=l.pop()||1):(d.push(ja.pointOn(h,o)),h=c.pop()||1);return d}}getToLineMaxDis2(t){let i=this.getExtremePoints(t),r=t.distance2(this.start()),n=t.distance2(this.end()),s=Math.max(r,n);return i.forEach(o=>a(t.distance2(o))),s;function a(o){s=Math.max(s,o)}}getToLineMinAndMaxDis_Controls(t){let i=t.start(),r=t.end();t.start().equals1(t.end())&&(r=i.add1(1,0));let n=r.y-i.y,s=i.x-r.x,a=-n*i.x-s*i.y,o=Math.sqrt(1/(n**2+s**2));n*=o,s*=o,a*=o;let l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;return this.controls.forEach(u=>{let h=n*u.x+s*u.y+a;h<l&&(l=h),h>c&&(c=h)}),{minDis:l,maxDis:c}}getPercentInLine(t){let i=[],r=[],n=this.controls,s=t.start(),a=t.end(),o=a.y-s.y,l=s.x-a.x,c=-o*s.x-l*s.y,u=Math.sqrt(1/(o**2+l**2));if(o*=u,l*=u,c*=u,o**2+l**2<=0)return i;if(n.length===3){let[h,d,p]=n,f=o*(h.x-2*d.x+p.x)+l*(h.y-2*d.y+p.y),m=2*(o*(d.x-h.x)+l*(d.y-h.y)),g=o*h.x+l*h.y+c;r=iK(f,m,g)}else if(n.length===4){let[h,d,p,f]=n,m=f.sub(p.mul(3)).add(d.mul(3)).sub(h),g=h.sub(d.mul(2)).add(p).mul(3),b=d.sub(h).mul(3),y=h,E=o*m.x+l*m.y,S=o*g.x+l*g.y,w=o*b.x+l*b.y,x=o*y.x+l*y.y+c,I=Math.sqrt(1/(E**2+S**2));E*=I,S*=I,w*=I,x*=I,r=rK(E,S,w,x)}else throw Error("not support getBeizerPointInLine");return r.forEach(h=>{h>=0&&h<=1&&i.push(h)}),i}reverse(){return new ja(this.controls.slice().reverse())}},Fp,JM=(Fp=class{constructor(){this.textCache=new Map,this.numCache=new Array(20),this.boxCache=new Array(4),this.textOffsetCache=new Array(9),this.BuildLineCache=new Array(7),this.BuildTrackCache=new Array(7),this.BuildViaCache=new Array(11),this.BuildBoxCache=new Array(10),this.BuildArcCache=new Array(10),this.BuildArcTrackCache=new Array(10),this.BuildTextCache=new Array(7),this.BuildPadStyleCache=new Array(4),this.BuildPadCache=new Array(12),this.ARRAY1=new Array(1),this.ARRAY2=new Array(2),this.ARRAY3=new Array(3),this.ARRAY4=new Array(4),this.ARRAY5=new Array(5),this.ARRAY6=new Array(6),this.ARRAY7=new Array(7),this.ARRAY8=new Array(8),this.ARRAY9=new Array(9),this.ARRAY10=new Array(10),this.ARRAY11=new Array(11),this.ARRAY12=new Array(12),this.textOffsetCache[0]=Ie.ORIGIN,this.textOffsetCache[1]=new Ie(0,-.5),this.textOffsetCache[2]=new Ie(0,-1),this.textOffsetCache[3]=new Ie(-.5,0),this.textOffsetCache[4]=new Ie(-.5,-.5),this.textOffsetCache[5]=new Ie(-.5,-1),this.textOffsetCache[6]=new Ie(-1,0),this.textOffsetCache[7]=new Ie(-1,-.5),this.textOffsetCache[8]=new Ie(-1,-1)}static getCache(){return Fp.instance==null&&(Fp.instance=new Fp),Fp.instance}},Fp.instance=null,Fp),ye=class Up extends r1{constructor(t,i){super(),this._a=null,this._b=null,this._c=null,this.__bbox=null,this._hashed=null,this._direct=null,this._start=t,this._end=i}get a(){return this._a===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._a}get b(){return this._b===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._b}get c(){return this._c===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._c}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}get direct(){return this._direct==null&&(this._direct=this._end.sub(this._start).normalize()),this._direct}cutLine(t){if(Re.eq(this.distance(t),0)){let i=new Up(this._start,t);return i._a=this._a,i._b=this._b,i._c=this._c,i}return new Up(this._start,t)}get midPoint(){return this._start.add(this._end).mul(.5)}toBezier(){return new gt([this._start,this._end])}_hashCode(){let t=31,i=1;return i=t*i+this._start.hashCode(),i=t*i+this._end.hashCode(),i}start(){return this._start}end(){return this._end}center(){let t=this.start(),i=this.end();return t.add(i).mul(.5)}panDistance(t){let i=this._end.x-this._start.x,r=this._end.y-this._start.y,n=this.length();i=i*t/n,r=-r*t/n;let s=new Ie(this._start.x+r,this._start.y+i),a=new Ie(this._end.x+r,this._end.y+i);return new Up(s,a)}isPoint(){return this._start.distance2(this._end)<=1e-8}length(){return this._start.distance1(this._end)}toString(){return"Line [start="+this._start+", end="+this._end+"]"}bbox(){if(this.__bbox==null){let t=JM.getCache().boxCache;t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.__bbox=new Ta(t[0],t[1],t[2],t[3])}return this.__bbox}multiply3(t){return new Up(this._start.multiply3(t),this._end.multiply3(t))}hashCode(){return this.hashed}equals(t){let i=t;return this.hashed===i.hashed&&this._start.equals(i._start)&&this._end.equals(i._end)}equals1(t){let i=t;return this.hashed===i.hashed&&this._start.equals1(i._start)&&this._end.equals1(i._end)}equals2(t){let i=[this.start(),this.end()],r=[t.start(),t.end()];return Oc(i,r)||Oc(i,r.reverse())}stroke(t,i,r){let n,s,a;this._end.x<this._start.x?(s=this._start.x-this._end.x,a=this._start.y-this._end.y,n=this._end):(s=this._end.x-this._start.x,a=this._end.y-this._start.y,n=this._start);let o=Math.sqrt(s*s+a*a),l=t/2,c,u,h;i===2?(u=-l,h=o+l):(u=0,h=o),i===0||i===2?r===0?c=Ci.build5([u,-l,u,l,h,l,h,-l]):c=Ci.build5([u,l,u,-l,h,-l,h,l]):r===0?c=Ci.build2([Le.build3(new Ie(u,0),-90,-180,l,l),Le.build3(new Ie(h,0),90,-180,l,l)]):c=Ci.build2([Le.build3(new Ie(u,0),90,180,l,l),Le.build3(new Ie(h,0),-90,180,l,l)]);let d=Math.atan2(a,s),p=Zn.rotate(d).translate1(n);return c.asClose().multiply3(p)}points(t){return[this._start,this._end]}mirrorY(t){return new Up(this.start().mirrorY(t),this.end().mirrorY(t))}reverse(){return new Up(this._end,this._start)}inArea(t,i,r){let n=t.x,s=t.y,a=this._start,o=this._end,l=r==1,c=n-a.x,u=s-a.y,h=n-o.x,d=s-o.y,p=o.x-a.x,f=o.y-a.y,m=new Ie(-f,p).normalize(),g=p+m.x*i/2,b=f+m.y*i/2,y=g*g+b*b,E=c*c+u*u,S=h*h+d*d,w=Math.abs(c*f-u*p)/2,x=Math.sqrt(p*p+f*f)*i/4;if(w<=x&&E<=y&&S<=y){if(l)return!0;{let I=new Ie(n,s).sub(o).normalize(),A=new Ie(n,s).sub(a).normalize(),O=new Ie(m.x,m.y).cross(I),R=new Ie(m.x,m.y).cross(A);return O>=0&&R<=0}}else if(l){let I=i/2;return E<=I*I?!0:S<=I*I}else return!1}isParallel(t,i=!1){let r=Re.eq(Math.abs(this.direct.cross(t.direct)),0),n=!i||Re.greatereq(this.direct.dot(t.direct),0);return r&&n}distance2(t){return(this.a*t.x+this.b*t.y+this.c)**2/(this.a**2+this.b**2)}distance2ForPP(t){let{x:i,y:r}=t,{x:n,y:s}=this.start(),{x:a,y:o}=this.end();return((i-n)*(o-s)-(r-s)*(a-n))**2/((o-s)**2+(a-n)**2)}distance(t){return Math.abs(this.a*t.x+this.b*t.y+this.c)/Math.sqrt(this.a**2+this.b**2)}};function sK(e,t=.05){if(e.length<3)return e.slice();let i=e.slice(0,1),r=(s,a,o)=>FJ(s.x,s.y,a.x,a.y,o.x,o.y);for(;;){i=e.slice(0,1);for(let s=1;s<e.length-1;s+=2)r(e[s],e[s-1],e[s+1])>t&&i.push(e[s]),i.push(e[s+1]);if(i.at(-1).equals1(e.at(-1))||i.push(e.at(-1)),e.length==i.length)break;e=i}let n=e[e.length-1];return i.push(n),i}var aK=fJ(mJ()),oK=class{constructor(){this.fac=new Mo,this.length=0,this.box=null,this.pt=null,this.i=0}calcBBox(e){for(this.fac.clear(),this.length=e.length,this.box=null,this.pt=null,this.i=0;this.i<this.length;this.i++)this.pt=e[this.i],this.box=this.pt.bbox(),this.fac.ext1(this.box);return this.fac.build1()}},lK=new oK,Ci=class Hn{constructor(t,i){this.__bbox=null,this.primitives=t,this.__bbox=i}static calcBBox(t){return lK.calcBBox(t)}static build1(t){let i=[],r=null;return XE(t,(n,s)=>{let a=s.start();return r!==null&&!a.equals(r)&&i.push(new ye(r,a)),i.push(s),r=s.end(),!0}),i.length===0&&r!=null&&i.push(new ye(r,r)),new Hn(i)}static build2(t){return Hn.build1(yA(t))}static build3(t){let i=[],r=null;return XE(t,(n,s)=>(r!==null&&i.push(new ye(r,s)),r=s,!0)),new Hn(i)}static build4(t){return this.build3(yA(t))}static build5(t){let i=[];for(let r=0;r<t.length;r+=2)i.push(new Ie(t[r],t[r+1]));return this.build4(i)}static build6(t){return Hn.build4([t.LL(),t.LR(),t.UR(),t.UL(),t.LL()])}static build7(t){return new Hn(t)}static build8(t){let i=new Ie(t[0],t[1]),r,n=[],s,a=(o,l)=>o.length==l&&o.every(c=>typeof c=="number");for(let o=2;o<t.length;)switch(typeof t[o]=="string"?s=t[o]:o-=1,s){case"ARC":{let l=t.slice(o+1,o+4);if(!a(l,3))throw new Error("invalid rawData");let c=l[0];r=new Ie(l[1],l[2]),n.push(Le.build5(i,r,c)),i=r,o+=4;break}case"L":{let l=t.slice(o+1,o+3);if(!a(l,2))throw new Error("invalid rawData");r=new Ie(l[0],l[1]),n.push(new ye(i,r)),i=r,o+=3;break}case"C":{let l=t.slice(o+1,o+7);if(!a(l,7))throw new Error("invalid rawData");let c=new Ie(l[0],l[1]),u=new Ie(l[2],l[3]);r=new Ie(l[4],l[5]),n.push(new gt([i,c,u,r])),i=r,o+=7;break}default:throw new Error("invalid rawData")}return Hn.build2(n)}static buildBBox(t,i=0){return i===1?Hn.build5([t.minX,t.minY,t.maxX,t.minY,t.maxX,t.maxY,t.minX,t.maxY,t.minX,t.minY]):Hn.build5([t.minX,t.minY,t.minX,t.maxY,t.maxX,t.maxY,t.maxX,t.minY,t.minX,t.minY])}static triangulate(t,i,r=1){if(t.length===1){let l=new Array;t[0].asClose().points2(r,d=>l.push(d));let c,u=l[0],h=[];for(let d=0;d<l.length-2;d+=2){let p=l[d+1],f=l[d+2],m=p.sub(u).normalize().cross(f.sub(u).normalize());if(Re.neq(m,0)){if(c===!0){if(m<0){h.length=0;break}}else if(c===!1){if(m>0){h.length=0;break}}else c=m>0;h.push(u),h.push(p),h.push(f)}l.push(u),u=f}if(h.length!==0){for(let d=0;d<h.length;d+=3)i(h[d],h[d+1],h[d+2]);return}}let n=[],s=[];t.forEach(l=>{n.length!==0&&s.push(n.length/2),l.asClose().points2(r,c=>n.push(c.x,c.y))});let a=aK.default(n,s),o=[];for(let l=1;l<n.length;l+=2)o.push(new Ie(n[l-1],n[l]));for(let l=0;l<a.length;l+=3)i(o[a[l]],o[a[l+1]],o[a[l+2]])}lines(t,i){let r=new Array;this.points(t,s=>r.push(s));let n=r[0];for(let s=1;s<r.length;s++){let a=r[s];i(n),i(a),n=a}}triangles(t,i){Hn.triangulate([this],(...r)=>{r.forEach(n=>i(n))},t)}mirror(){let t=[];return this.primitives.forEach(i=>{if(i instanceof ye)i=new ye(i.start().mirror(),i.end().mirror());else if(i instanceof Le)i=i.mirror();else if(i instanceof gt){let r=i.controls.map(n=>n.mirror());i=new gt(r)}else throw new Error("bug");t.push(i)}),new Hn(t,this.__bbox)}getPoints(t){let i=[];for(let r of this.primitives)for(let n of r.points(t))i.push(n);return i}round(t=4){let i=this.primitives.slice();for(let r=0;r<i.length;r++){let n=i[r];if(n instanceof ye){let s=n.start().round(t),a=n.end().round(t);i[r]=new ye(s,a)}else if(n instanceof gt){let s=n.controls.map(a=>a.round(t));i[r]=new gt(s)}else if(n instanceof Le){let s=n.start().round(t),a=n.end().round(t),o=n.sweepAngle;i[r]=Le.build5(s,a,o)}}return new Hn(i,this.__bbox)}simplify(t=.05){let i=[],r=!1,n=[],s=this.closed();if(this.primitives.length<=1)return Hn.build2(this.primitives);let a=()=>{if(n.length>2){let l=sK(n,t);for(let c=1;c<l.length;c++)i.push(new ye(l[c-1],l[c]))}else i.push(new ye(n[0],n[1]));n.length=0,r=!1};for(let l=0;l<this.primitives.length;l++){let c=this.primitives[l];c instanceof ye?(r?n.push(c.end()):(n.length=0,n.push(c.start(),c.end()),r=!0),l===this.primitives.length-1&&a()):(r&&a(),i.push(c))}let o=new Hn(i,this.__bbox);return s&&!o.closed()&&(o=o.asClose()),o}hasBackLine(){let{primitives:t}=this,i;for(let r=0;r<t.length;r++){let n=t[r];if(n instanceof ye){if(n.end().equals1(n.start()))continue;if(i&&(n.end().equals1(i.start())||GJ(n.end(),i.start(),i.end())))return!0;i=n}else i=null}return!1}area(t=.1){let i=0,r=this.end();return this.primitives.forEach(n=>{let s=n.start(),a=n.end();if(i+=(s.x+r.x)*(s.y-r.y),n instanceof ye)i+=(a.x+s.x)*(a.y-s.y);else if(n instanceof Le)i+=(a.x+s.x)*(a.y-s.y),i+=Math.PI*n.rx2*n.sweepAngle/180-Ie.normal(n.center,n.start(),n.end());else if(n instanceof gt){let o=s;n.points(t).forEach(l=>{i+=(l.x+o.x)*(l.y-o.y),o=l}),i+=(a.x+o.x)*(a.y-o.y)}r=a}),i/2}closed(t){return this.primitives.length===0?!1:this.start().equals(this.end(),t)}asClose(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),n=i.end();if(r.equals(n))return this;{let s=new Array;return Ia.addAll(s,this.primitives),s.push(new ye(n,r)),Hn.build2(s)}}closeEndpoint(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),n=i.end();if(r.equals1(n))return this;{let s=new Array;return Ia.addAll(s,this.primitives),s.push(new ye(n,r)),new Hn(s)}}reverse(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let n=this.primitives[r];if(n instanceof ye)n=new ye(n.end(),n.start());else if(n instanceof Le)n=n.exchangeSweep();else if(n instanceof gt)n=new gt(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new Hn(t,this.__bbox)}reverse1(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let n=this.primitives[r];if(n instanceof ye)n=new ye(n.end(),n.start());else if(n instanceof Le)n=n.exchangeSweep1();else if(n instanceof gt)n=new gt(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new Hn(t,this.__bbox)}mirrorY(t){let i=[];return this.primitives.forEach(r=>{if(r instanceof ye)r=r.mirrorY(t);else if(r instanceof Le)r=r.mirrorY(t);else if(r instanceof gt){let n=r.controls.map(s=>s.mirrorY(t));r=new gt(n)}else throw new Error("bug");i.push(r)}),new Hn(i,this.__bbox)}points(t,i){if(this.primitives.length!==0){for(let r=0;r<this.primitives.length-1;r++){let n=this.primitives[r].points(t);n.pop(),n.forEach(s=>i(s))}this.primitives[this.primitives.length-1].points(t).forEach(r=>i(r))}}points1(t,i){if(this.primitives.length===0)return;for(let n=0;n<this.primitives.length-1;n++){let s=this.primitives[n],a=s instanceof Le?s.points1(t):s.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Le?r.points1(t):r.points(t)).forEach(n=>i(n))}points2(t,i){if(this.primitives.length===0)return;for(let n=0;n<this.primitives.length-1;n++){let s=this.primitives[n],a=s instanceof Le?s.points2():s.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Le?r.points2():r.points(t)).forEach(n=>i(n))}multiply3(t){let i=new Array(this.primitives.length);for(let r=0;r<this.primitives.length;r++)i[r]=this.primitives[r].multiply3(t);return Hn.build7(i)}bbox(){return this.__bbox==null&&(this.__bbox=Hn.calcBBox(this.primitives)),this.__bbox}start(){return this.primitives.length!==0?this.primitives[0].start():null}end(){return this.primitives.length!==0?this.primitives[this.primitives.length-1].end():null}isClose(t){if(this.primitives.length<=1&&!(this.primitives[0]instanceof Le))return!1;{let i=this.primitives[0],r=this.primitives[this.primitives.length-1];return i.start().equals(r.end(),t)}}isEqual(t){if(t instanceof Hn&&t.primitives.length==this.primitives.length){let i=t.primitives.length;for(let r=0;r<i;r++){let n=t.primitives[r],s=this.primitives[r];if(JSON.stringify(n)!=JSON.stringify(s))return!1}return!0}return!1}equals(t){if(!t)return!1;let i=this.primitives,r=t.primitives;if(i.length!=r.length)return!1;if(t.isClose()){let n=0;for(;n<i.length;){let s=i.slice(n).concat(i.slice(0,n));if(Oc(s,r)||Oc(s.reverse(),r))return!0;n++}return!1}else return Oc(this.primitives,t.primitives)}clone(){return Hn.build2(this.primitives)}putItem(t,i){if(!t)return!1;if(t instanceof Hn)return this.mergePolyline(t,i);let r=this.start();if(!r){this.primitives.push(t),this.__bbox=t.bbox();return}let n=this.end();if(r.equals(n,i))return!1;let s=t.start(),a=t.end(),o=!1,l=!1;if(r.equals(s,i))o=!0,l=!1;else if(r.equals(a,i))o=!1,l=!1;else if(n.equals(s,i))o=!1,l=!0;else if(n.equals(a,i))o=!0,l=!0;else return!1;return l?this.primitives.push(o?t.reverse():t):this.primitives.unshift(o?t.reverse():t),this.__bbox=Ta.extend2(this.__bbox,t.bbox()),!0}mergePolyline(t,i,r=0){if(!t)return!1;let n=this.start();if(!n){this.primitives.push(...t.primitives),this.__bbox=t.bbox();return}let s=this.end();if(n.equals(s,i))return!1;let a=t.start(),o=t.end(),l=!1,c=!1;if(n.equals(a,i))l=!0,c=!1;else if(n.equals(o,i))l=!1,c=!1;else if(s.equals(a,i))l=!1,c=!0;else if(s.equals(o,i))l=!0,c=!0;else return!1;let u=l?t.reverse():t;return c?this.primitives.push(...u.primitives):this.primitives.unshift(...u.primitives),this.__bbox=Ta.extend2(this.__bbox,t.bbox()),!0}deDuplicationPoint(t){let i=this.primitives[this.primitives.length-1].start(),r=this.primitives[this.primitives.length-1].end(),n=t.primitives[0].start(),s=t.primitives[0].end();if(this.primitives[this.primitives.length-1]instanceof ye&&t.primitives[0]instanceof ye&&XJ([i,r],[n,s])){this.primitives.pop(),t.primitives.shift();let a=[];a.push(new ye(i,s)),this.primitives.push(...a)}}getMaxBBoxHeightByVec(t){let i=t.normalize(),r=-1/0,n=1/0;if(this.primitives.forEach(a=>{let o=a.start().dot(i),l=a.end().dot(i);if(s(o),s(l),a instanceof Le){let c=t.angleD(Ie.ORIGIN);if(a.angleIsInArc(c)){let u=a.pointOn(c).dot(i);s(u)}if(a.angleIsInArc(c+180)){let u=a.pointOn(c-180).dot(i);s(u)}}}),r-n<=0)throw new Error("getMaxBBoxHeightByVec");return r-n;function s(a){a>r&&(r=a),a<n&&(n=a)}}getWindingNum(t){let i=this.end(),r=0,{x:n,y:s}=t;for(let o of this.primitives){if(i.y>s?o.bbox().minY>s:o.bbox().maxY<=s){i=o.end();continue}if(o instanceof Le&&(o.isCCW?Math.floor(o.startAngle/90)+1!==Math.ceil(o.endAngle()/90):Math.ceil(o.startAngle/90)-1!==Math.floor(o.endAngle()/90))){let l=o.startAngle,c=o.endAngle();if(o.sweepAngle>0){let u=90;for(;u<=c;)u>l&&(a(Le.build3(o.center,l,u-l,o.rx,o.ry)),l=u),u+=90;l<c&&a(Le.build3(o.center,l,c-l,o.rx,o.ry))}else{let u=270;for(;u>=c;)u<l&&(a(Le.build3(o.center,l,u-l,o.rx,o.ry)),l=u),u-=90;l>c&&a(Le.build3(o.center,l,c-l,o.rx,o.ry))}}else if(o instanceof gt){let l=[];qM(o,l),l.forEach(c=>a(c))}else a(o)}return r;function a(o){let l=o.start(),c=o.end();if(i.y>s!=l.y>s&&(i.x>n?l.x>n?r+=l.y>i.y?1:-1:i.y>l.y?(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)<0&&r--:(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)>0&&r++:l.x>n&&(i.y>l.y?(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)<0&&r--:(i.x-n)*(l.y-s)-(i.y-s)*(l.x-n)>0&&r++)),l.y>s!=c.y>s){if(l.x>n)if(c.x>n)r+=c.y>l.y?1:-1;else if(o instanceof ye)l.y>c.y?(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)<0&&r--:(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)>0&&r++;else if(o instanceof Le){let{center:u,isCCW:h,rx2:d}=o,p=(u.x-n)**2+(u.y-s)**2;l.y>c.y?(h?p>d:p<d)&&r--:(h?p<d:p>d)&&r++}else if(o instanceof gt){if(hM(o,s)===0)throw new Error("no inters");oe[0]>n&&(r+=c.y>l.y?1:-1)}else throw new Error("not support!");else if(c.x>n)if(o instanceof ye)l.y>c.y?(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)<0&&r--:(l.x-n)*(c.y-s)-(l.y-s)*(c.x-n)>0&&r++;else if(o instanceof Le){let{center:u,isCCW:h,rx2:d}=o,p=(u.x-n)**2+(u.y-s)**2;l.y>c.y?(h?p>d:p<d)&&r--:(h?p<d:p>d)&&r++}else if(o instanceof gt){if(hM(o,s)===0)throw new Error("no inters");oe[0]>n&&(r+=c.y>l.y?1:-1)}else throw new Error("not support!")}i=c}}},OE=Math.PI*2,Ule=Math.PI/2,Yle=Math.sin(Math.PI/180),cK=4,Le=class zr extends r1{constructor(t,i,r,n,s){super(),this._rx2=null,this._ry2=null,this._svgEnd=null,this._hashed=null,this.__bbox=null,this.rx=t,this.ry=i,this.center=r,this.startAngle=n,this.sweepAngle=s,this._start=Ie.ORIGIN,this._end=Ie.ORIGIN,this._start=this.pointOn(n),this._end=this.pointOn(n+s)}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}hashCode(){return this.hashed}_hashCode(){let t=31,i=1;return i=t*i+new Ie(this.rx,this.rx).hashCode(),i=t*i+this.center.hashCode(),i=t*i+new Ie(this.startAngle,this.sweepAngle).hashCode(),i}get rx2(){return this._rx2==null&&(this._rx2=this.rx*this.rx),this._rx2}get ry2(){return this._ry2==null&&(this._ry2=this.ry*this.ry),this._ry2}get svgEnd(){return this._svgEnd==null&&(this._svgEnd=this.getSvgEnd(this.startAngle,this.sweepAngle,this._start,this._end)),this._svgEnd}getSvgEnd(t,i,r,n){let s=i>=0?-.01:.01,a=t+i;for(;(i>=0&&a>t||i<0&&a<t)&&r.distance2(n)<2e-4;)s*=2,a+=s,n=this.pointOn(a);return n}static build1(t,i,r,n,s,a){an.positive(r),an.positive(n);let o=t.equals(i);if(o)return new zr(r,n,t,0,s?360:0);{let l=t.x,c=-t.y,u=i.x,h=-i.y,d=a===0,p=(l-u)/2,f=(c-h)/2,m=Math.cos(0),g=Math.sin(0),b=m*p+g*f,y=-g*p+m*f;r=Math.abs(r),n=Math.abs(n);let E=r*r,S=n*n,w=b*b,x=y*y,I=s===d?-1:1,A=(E*S-E*x-S*w)/(E*x+S*w);A=A<0?0:A;let O=I*Math.sqrt(A),R=O*(r*y/n),M=O*-(n*b/r),F=(l+u)/2,G=(c+h)/2,V=F+(m*R-g*M),q=G+(g*R+m*M),C=(b-R)/r,N=(y-M)/n,T=(-b-R)/r,L=(-y-M)/n,P,B;B=Math.sqrt(C*C+N*N),P=C,I=N<0?-1:1;let U=ti.toDegrees(I*Math.acos(P/B));B=Math.sqrt((C*C+N*N)*(T*T+L*L)),P=C*T+N*L,I=C*L-N*T<0?-1:1;let X=P/B,J;X<-1?J=Math.acos(-1):X>1?J=Math.acos(1):J=Math.acos(X);let ne=ti.toDegrees(I*J);!d&&ne>0?ne-=360:d&&ne<0&&(ne+=360),an.normal(U),an.normal(ne);let fe=p*p/E+f*f/S,xe=t.distance1(i)/2;r<xe&&n<xe&&(r*=Math.sqrt(fe),n*=Math.sqrt(fe));let ve=o?0:ti.regularD(-U),Fe=o?s?360:0:-ne;return new zr(r,n,new Ie(V,-q),ve,Fe)}}static build2(t,i,r,n,s,a){an.positive(n),an.positive(s),an.normal(i),an.normal(r);let o;return i===r?(i=ti.regularD(i),r=ti.regularD(r),o=0):(i=ti.regularD(i),r=ti.regularD(r),a===1?r<=i&&(r+=360):r>=i&&(i+=360),o=r-i),new zr(n,s,t,ti.regularD(i),o)}static build3(t,i,r,n,s){return an.positive(n),an.positive(s),an.normal(r),new zr(n,s,t,ti.regularD(i),r)}static build4(t,i,r,n,s,a){let o=t.angleD(r),l=i.angleD(r);return zr.build2(r,o,l,n,s,a)}static build5(t,i,r){r=ti.toRadians(r);let n=i.sub(t),s=new Ie(-n.y,n.x).normalize(),a=Math.abs(r)/2,o;if(a!=0)o=n.length()/2/Math.sin(a);else throw new Error("Can't represent circle!!!");let l=s.rotate(Ie.ORIGIN,a),c,u;r>0?(c=1,u=i.add(l.scale(o))):(c=0,u=t.sub(l.scale(o)));let h=ti.toDegrees(t.angle(u)),d=ti.toDegrees(i.angle(u));return zr.build2(u,h,d,o,o,c)}static buildCircle(t,i,r=0){return zr.build2(t,0,360,i,i,r)}start(){return this._start}end(){return this._end}isLarge(){return Math.abs(this.sweepAngle)>180}sweep(){return this.sweepAngle>=0?1:0}get isCCW(){return this.sweepAngle>=0}endAngle(){return this.startAngle+this.sweepAngle}pointOn(t){t=ti.regularD(t);let i=this.rx,r=this.ry;if(t===0)return this.center.add1(i,0);if(t===90)return this.center.add1(0,r);if(t===180)return this.center.add1(-i,0);if(t===270)return this.center.add1(0,-r);{let n=this.rx2,s=this.ry2,a=Math.tan(ti.toRadians(t)),o=a*a,l=Math.sqrt(n*s/(n+s/o)),c=Math.sqrt(n*s/(s+n*o));return t>90&&t<270&&(c=-c),t>180&&t<360&&(l=-l),isNaN(c)&&(c=0),isNaN(l)&&(l=0),this.center.add1(c,l)}}exchangeSweep(){return zr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,this.rx,this.ry)}exchangeSweepAndStart(){return zr.build1(this.end(),this.start(),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}exchangeSweep1(){return zr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle+.01,this.rx,this.ry)}mirrorY(t){let i=this.start(),r=this.end();return i.equals(r)?zr.build3(this.center.mirrorY(),0,360,this.rx,this.ry):zr.build1(i.mirrorY(t),r.mirrorY(t),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}mirror(t=Ie.ORIGIN){let i=this.start(),r=this.end();return i.equals(r)?zr.build3(this.center.mirror(t),0,360,this.rx,this.ry):zr.build1(i.mirror(t),r.mirror(t),this.rx,this.ry,this.isLarge(),this.sweep())}sectorArea(){return Math.abs(this.sweepAngle)/360*Math.PI*this.rx*this.ry}area(){let t=bA.area(this.center,this._start,this.pointOn(this.endAngle()));return this.sectorArea()-t}multiply3(t){let i;t.isMirrored()?i=-this.sweepAngle:i=this.sweepAngle;let r;return t.equals(Zn.ROT_90)?r=ti.regularD(this.startAngle+90):t.equals(Zn.ROT_N90)?r=ti.regularD(this.startAngle-90):r=ti.transformD(this.startAngle,t),zr.build3(this.center.multiply3(t),r,i,t.iScale*this.rx,t.iScale*this.ry)}angleIsInArc(t){return t=ti.regularD(t),this.sweepAngle>0?(t<this.startAngle&&(t+=360),this.endAngle()>t):(t>this.startAngle&&(t-=360),this.endAngle()<t)}toBezier(){if(Math.abs(this.sweepAngle)>90)throw new Error("not support!");let t=this.start(),i=this.end(),r=ti.toRadians(this.sweepAngle)/2,n=4/3*(1-Math.cos(r))/Math.sin(r)*this.rx;return new gt([t,t.add(new Ie(n,0).multiply3(Zn.rotateD(this.startAngle+90))),i.add(new Ie(n,0).multiply3(Zn.rotateD(this.endAngle()-90))),i])}toBezier2(){let t=[];r(this,90);let i=[];return t.forEach(n=>i.push(n.toBezier())),i;function r(n,s){if(Math.abs(n.sweepAngle)>s){let a=n.sweepAngle/2;r(zr.build3(n.center,n.startAngle,a,n.rx,n.ry),s),r(zr.build3(n.center,n.startAngle+a,a,n.rx,n.ry),s)}else t.push(n)}}buildBBox(){let t=JM.getCache().boxCache,i=this.startAngle+this.sweepAngle;if(t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.sweepAngle>0){let r=0;for(;r<i;){if(r>this.startAngle){let n=this.pointOn(r);t[0]=Math.min(t[0],n.x),t[1]=Math.max(t[1],n.x),t[2]=Math.min(t[2],n.y),t[3]=Math.max(t[3],n.y)}r+=90}}else if(this.sweepAngle<0){let r=360;for(;r>i;){if(r<this.startAngle){let n=this.pointOn(r);t[0]=Math.min(t[0],n.x),t[1]=Math.max(t[1],n.x),t[2]=Math.min(t[2],n.y),t[3]=Math.max(t[3],n.y)}r-=90}}return new Ta(t[0],t[1],t[2],t[3])}bbox(){return this.__bbox==null&&(this.__bbox=this.buildBBox()),this.__bbox}length(){return Math.abs(this.rx*this.sweepAngle*Math.PI/180)}toString(){return qm.format("Arc [start=%s, end=%s, rx=%s, ry=%s, center=%s, startAngle=%s, sweepAngle=%s]",this._start,this._end,this.rx,this.ry,this.center,this.startAngle,this.sweepAngle)}stroke(t,i,r){let n=t/2,s=this.rx+n,a=this.ry+n,o=this.rx-n,l=this.ry-n,c=new Zn;o<0&&(o=-o,c=c.multiply3(Zn.MIRROR_Y)),l<0&&(l=-l,c=c.multiply3(Zn.MIRROR_X)),o===0&&(o=.001),l===0&&(l=.001),c=c.setOrigin1(this.center);let u,h;switch(r===this.sweep()?(u=zr.build3(this.center,this.startAngle,this.sweepAngle,s,a),h=zr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,o,l)):(u=zr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,s,a),h=zr.build3(this.center,this.startAngle,this.sweepAngle,o,l)),h=h.multiply3(c),i){case 1:{let d=r===1?180:-180,p=r===this.sweep()?this.pointOn(this.endAngle()):this.pointOn(this.startAngle),f=r===this.sweep()?this.pointOn(this.startAngle):this.pointOn(this.endAngle()),m=u.pointOn(u.endAngle()).angleD(p),g=h.pointOn(h.endAngle()).angleD(f);return Ci.build2([u,zr.build3(p,m,d,n,n),h,zr.build3(f,g,d,n,n)])}default:return Ci.build2([u,h])}}points2(){let t=Math.ceil(Math.abs(this.sweepAngle)/cK),i=this.sweepAngle/t,r=[this._start];for(let n=1;n<t;n++)r.push(this.pointOn(this.startAngle+i*n));return r.push(this._end),r}points1(t){let i=Math.max(this.rx,this.ry);if(i<=t)return[this.start(),this.svgEnd];let r=(i-t)/i,n=Math.ceil(Math.abs(this.sweepAngle/ti.toDegrees(Math.acos(r))/2)),s=new Array(n+1),a=this.sweepAngle/n,o=this.startAngle;for(let l=0;l<=n;l++,o+=a)s[l]=this.pointOn(o);return s}points(t){let i=Math.max(this.rx,this.ry);if(t=Math.abs(t),i<=t)return[this.start(),this.svgEnd];t=Math.max(t,i*1e-5),t=Math.min(t,i*(1-Math.SQRT1_2));let r=(i-t)/i,n=Math.ceil(Math.abs(this.sweepAngle/ti.toDegrees(Math.acos(r))/2));n=Math.max(n,2);let s=new Array(n+1),a=this.sweepAngle/n,o=this.startAngle+a;s[0]=this.start();for(let l=1;l<n;l++,o+=a)s[l]=this.pointOn(o);return s[n]=this.end(),s}panDistance(t){return this.sweepAngle>0?new zr(this.rx-t,this.ry-t,this.center,this.startAngle,this.sweepAngle):new zr(this.rx+t,this.ry+t,this.center,this.startAngle,this.sweepAngle)}panDistance1(t){if(this.sweepAngle>0){let i=this.rx-t;return i<0?(i=Math.abs(i),zr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new zr(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;return i<0?(i=Math.abs(i),zr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new zr(i,i,this.center,this.startAngle,this.sweepAngle)}}get bulge(){let t=Math.abs(BJ(this.sweepAngle,3))/180*Math.PI;return Math.tan(t/4)}get midPoint(){let t=ti.toRadians(this.startAngle),i=ti.toRadians(this.endAngle()),r=this.sweep(),n=this.center,s=this.rx;if(r==1)if(i>t){let a=(i-t)/2+t;return n.add(new Ie(Math.cos(a),Math.sin(a)).mul(s))}else{if(i==t)return n.add(new Ie(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(s));{let a=(i+OE-t)/2+t;return n.add(new Ie(Math.cos(a),Math.sin(a)).mul(s))}}else if(i>t){let a=(t+OE-i)/2+i;return n.add(new Ie(Math.cos(a),Math.sin(a)).mul(s))}else{if(i==t)return n.add(new Ie(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(s));{let a=(t-i)/2+i;return n.add(new Ie(Math.cos(a),Math.sin(a)).mul(s))}}}get svgPathData(){return[{type:"M",values:[this._start.x,this._start.y]},{type:"A",values:[this.rx,this.ry,0,this.isLarge()?1:0,this.isCCW,this._end.x,this._end.y]}]}equals(t){let i=ti.regularD(this.startAngle),r=ti.regularD(this.sweepAngle),n=ti.regularD(t.startAngle),s=ti.regularD(t.sweepAngle);return Oc([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(Oc([r,i],[s,n])||Oc([ti.regularD(i+r)],[n]))}equals1(t){let i=ti.regularD(this.startAngle),r=ti.regularD(this.sweepAngle),n=ti.regularD(t.startAngle),s=ti.regularD(t.sweepAngle);return Oc([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(Oc([r,i],[s,n])||Oc([ti.regularD(i+r)],[n]))}inArea(t,i){let r=t.x,n=t.y,s=this.center,a=this.rx,o=ti.toRadians(this.startAngle);this.sweep()==0&&(o=ti.toRadians(this.endAngle()));let l=ti.toRadians(this.endAngle());this.sweep()==0&&(l=ti.toRadians(this.startAngle));let c=a-i/2,u=a+i/2;var h=r-s.x,d=n-s.y,p=Math.atan2(d,h);if(p<0&&(p+=OE),o<=l&&p>=o&&p<=l||o>l&&(p>=o&&p<=OE||p>=0&&p<=l)||o==l){var f=Math.sqrt(h*h+d*d);return f<=u&&f>=c}else{var f=(u+c)/2,m=new Ie(s.x+Math.cos(o)*f,s.y+Math.sin(o)*f),g=new Ie(s.x+Math.cos(l)*f,s.y+Math.sin(l)*f),b=r-m.x,y=n-m.y,E=r-g.x,S=n-g.y;return b*b+y*y<=i*i/4?!0:E*E+S*S<=i*i/4}}isCircle(){return(Re.eq(Math.abs(this.sweepAngle),360)||this._start.equals1(this._end))&&this.rx==this.ry}reverse(){return zr.build3(this.center,this.endAngle(),-this.sweepAngle,this.rx,this.ry)}getAngle(){let t=Math.PI*2;return this.sweep()==1?(this.endAngle()-this.startAngle+t)%t:(this.startAngle-this.endAngle()+t)%t}isValid(){return this.rx>0&&this.ry>0}},KM=new ArrayBuffer(24),eA=new Float64Array(KM),Fm=new Int32Array(KM),js,Vle=(js=class{static normal(e,t,i){let r=t.sub(e),n=i.sub(t);return r.cross(n)}constructor(e,t,i){this.x=an.normal(e),this.y=an.normal(t),this.z=an.normal(i),eA[0]=e,eA[1]=t,eA[2]=i,this.hashed=Fm[0]^Fm[1]^Fm[2]^Fm[3]^Fm[4]^Fm[5]}isZeroVector(){return this.x===0&&this.y===0&&this.z===0}hashCode(){return this.hashed}equals(e){return e instanceof js?e.x===this.x&&e.y===this.y&&e.z===this.z:!1}cross(e){return new js(this.y*e.z-this.z*e.y,this.z*e.x-this.x*e.z,this.x*e.y-this.y*e.x)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){var e=this.length();return new js(this.x/e,this.y/e,this.z/e)}sub(e){return new js(this.x-e.x,this.y-e.y,this.z-e.z)}add(e){return new js(this.x+e.x,this.y+e.y,this.z+e.z)}scale(e){return new js(this.x*e,this.y*e,this.z*e)}neg(){return new js(-this.x,-this.y,-this.z)}multiply4(e){var t=this.x*e.data[0]+this.y*e.data[4]+this.z*e.data[8]+e.data[12],i=this.x*e.data[1]+this.y*e.data[5]+this.z*e.data[9]+e.data[13],r=this.x*e.data[2]+this.y*e.data[6]+this.z*e.data[10]+e.data[14],n=this.x*e.data[3]+this.y*e.data[7]+this.z*e.data[11]+e.data[15];return n!=0?new js(t/n,i/n,r/n):new js(t,i,r)}rotate(e,t){return this.multiply4(jM.rotateAxis(e,t))}toVector2(){return new Ie(this.x,this.y)}},js.ORIGIN=new js(0,0,0),js.X_UNIT_VECTOR=new js(1,0,0),js.Y_UNIT_VECTOR=new js(0,1,0),js.Z_UNIT_VECTOR=new js(0,0,1),js),On=class jm{static build(t){return t instanceof Ci?new jm([new os([t])]):t instanceof os?new jm([t]):t}static buildByPolygon(t){return t?new jm([t]):new jm([])}static buildByStroke(t,i,r=1,n){return this.buildByPolygon(os.buildByStroke(t,i,r,BA,n))}static buildCircle(t,i){return this.buildByPolygon(os.buildCircle(t,i))}static buildRect(t){return this.buildByPolygon(os.buildRect(t))}static buildBBox(t){return this.buildByPolygon(os.buildBBox(t))}constructor(t){this.items=t.slice()}multiply3(t){return new jm(this.items.map(i=>i.multiply3(t)))}bbox(){return this._bbox||(this._bbox=this.items.reduce((t,i)=>t.ext1(i.bbox()),new Mo).build1()),this._bbox}toPolylineGroups(){return this.items.map(t=>t.toPolylineGroup())}},jr,Wi=(jr=class{static isHexFormate(e){return!e||typeof e!="string"?!1:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)}static of1(e){return this.of2(e>>16&255,e>>8&255,e&255)}static of2(e,t,i,r=255){return new jr(e/255,t/255,i/255,r/255)}static of3(e){e.startsWith("#")&&(e=e.substr(1));let t=e.length;if(t==3)return new jr(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15);if(t==6)return new jr(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255);if(t==8)return new jr(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255,parseInt(e.substr(6,2),16)/255);throw new Error("invalid color string")}static of4(e){let t=parseInt(e.r*255+"").toString(16),i=parseInt(e.g*255+"").toString(16),r=parseInt(e.b*255+"").toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),("#"+t+i+r).toUpperCase()}static of5(e,t){if(e.startsWith("#")&&(e=e.substr(1)),e.length==3)return new jr(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15,t);if(e.length==6)return new jr(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255,t);throw new Error("invalid color string")}static of6(e,t){return new jr(e.r,e.g,e.b,t)}static of7(e){return e==null?null:jr.of3(e)}constructor(e,t,i,r=1){this.r=an.positiveOr0(e),this.g=an.positiveOr0(t),this.b=an.positiveOr0(i),this.alpha=r}hashCode(){return this.r+this.g+this.b+this.alpha}equals(e,t=!1){let i=this.r===e.r&&this.g===e.g&&this.b===e.b;return t?i:i&&this.alpha===e.alpha}add(e,t,i,r){return new jr(Math.max(0,Math.min(1,this.r+e)),Math.max(0,Math.min(1,this.g+t)),Math.max(0,Math.min(1,this.b+i)),Math.max(0,Math.min(1,this.alpha+r)))}mul(e){return new jr(Math.max(0,Math.min(1,this.r*e)),Math.max(0,Math.min(1,this.g*e)),Math.max(0,Math.min(1,this.b*e)),this.alpha)}mul1(e){return new jr(Math.max(0,this.r*e),Math.max(0,this.g*e),Math.max(0,this.b*e),this.alpha)}getData(){return[this.r,this.g,this.b,this.alpha]}toString(){let e=(this.r*255).toString(16),t=(this.g*255).toString(16),i=(this.b*255).toString(16);return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),"#"+e.substr(0,2)+t.substr(0,2)+i.substr(0,2)}toString1(){let e=(this.r*255).toString(16),t=(this.g*255).toString(16),i=(this.b*255).toString(16),r=(this.alpha*255).toString(16);return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),"#"+e.substr(0,2)+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)}toRGBA(){let e=this.r*255,t=this.g*255,i=this.b*255;return[e,t,i,this.alpha]}toRGBAString(){let e=this.r*255,t=this.g*255,i=this.b*255;return`rgba(${e},${t},${i},${this.alpha})`}isWHITE(){return this.r===1&&this.g===1&&this.b===1&&this.alpha===1}},jr.WHITE=new jr(1,1,1,1),jr.BLACK=new jr(0,0,0,1),jr.RED=new jr(1,0,0,1),jr.GREEN=new jr(0,1,0,1),jr.BLUE=new jr(0,0,1,1),jr.Gray=jr.of3("#9966ff"),jr.Silver=jr.of3("#D2D2D2"),jr.Golden=jr.of3("#DCAA14"),jr.Pink=jr.of3("#ffaec9"),jr),bM=!1,$M=class{onRTreeBBox(e){}onResultSide(e){}onOriginSide(e){}onSplitedSide(e){}onDebugSide(e){}onSweep(e,t,i,r,n,s){}onIntersect(e,t,i){}onSegment(e,t,i,r,n,s){}onSegment1(e,t,i){if(bM){let r=new Ie(e.getX(i),i),n=new Ie(t.getX(i),i);this.onSegment(r,e.weight,e,n,t.weight,t)}else this.onSegment(e.start,e.weight,e,t.end,t.weight,t)}onSweep1(e,t,i){if(bM){let r=new Ie(e.getX(i),i),n=new Ie(t.getX(i),i);this.onSweep(r,e.weight,e,n,t.weight,t)}else this.onSweep(e.start,e.weight,e,t.end,t.weight,t)}},$0=class extends $M{constructor(e){super(),this.plGrps=new Array,this.debug=e}onPolylineGroup(e,t){this.plGrps.push(e)}},n1=class{constructor(e){this.cache={},this.levels=e,this.result=new Array(e),this.weights=new Array(e),this.maxIdx=e-1,this.rule=this.decide.bind(this);let t=1;for(let i=0;i<e;i++)this.weights[i]=t,t*=50}weight(e){return this.weights[e]}decide(e){e=Math.abs(e);let t=this.cache[e];if(t===void 0){let i=e;for(let r=this.maxIdx;r>=0;r--){let n=this.weights[r],s=e/n|0,a=e%n;a>(n/2|0)?(e=n-a,s++):e=a,this.result[r]=s>0}t=this.decide1(this.result),this.cache[i]=t}return t}},uK=e=>e!==0,hK=new class extends n1{decide1(e){return e[0]||e[1]}}(2),YE=new class extends n1{decide1(e){return e[0]&&!e[1]}}(2),VE=new class extends n1{decide1(e){return e[0]&&e[1]}}(2),tA=new class extends n1{decide1(e){return e[0]&&!e[1]||!e[0]&&e[1]}}(2),dK=(e=>(e[e.UNMARKED=0]="UNMARKED",e[e.INSIDE=1]="INSIDE",e[e.OUTSIDE=2]="OUTSIDE",e[e.INVALID=3]="INVALID",e))(dK||{}),Zm=class zm{constructor(t,i,r,n,s,a,o){this.inters=[],this.connect=new Array,this.previous=null,this.next=null,this.finalGrp=-1,this.trans=NaN,this.outsideWeight=0,this.insideWeight=0,this.invalidWeight=0,this._confidence=0,this._confidence_y=NaN,this._x=NaN,this._x_y=NaN,this.status=0,this.bo=t,this.shape=i,this.baseWeight=r,n.y>s.y?this.weight=-r:n.y==s.y?this.weight=0:this.weight=r,this.start=n,this.end=s,this.polyGrp=a,this.polyIndex=o,this._bbox=new Mo().ext1(i.bbox()).ext2(n).ext2(s).build1(),this.inters.push(n),this.inters.push(s);let l=31,c=1;c=l*c+this.polyGrp,c=l*c+this.polyIndex,this._hashcode=c}static rebuild(t,i,r){if(t instanceof ye||i.distance2(r)<1e-6)return new ye(i,r);if(t instanceof Le){let n=t,s=t.bbox().center().x,a;i.y>r.y?a=s>n.center.x?0:1:a=s>n.center.x?1:0;let o=i.angleD(n.center),l=r.angleD(n.center);return Le.build2(n.center,o,l,n.rx,n.ry,a)}else throw new Error("not supported operation")}updateBbox(){this._bbox=new Mo().ext2(this.start).ext2(this.end).build1()}is(t,i){return t===this.polyGrp&&i===this.polyIndex}confidence(t){if(this._confidence_y!=t){let i=this._bbox.height();if(i!==0)if(Math.abs(t-this._bbox.maxY)>5e-4&&Math.abs(t-this._bbox.minY)>5e-4){let r=1-Math.abs(2*t-this._bbox.maxY-this._bbox.minY)/i;this._confidence=r*1e4|0}else this._confidence=0;else this._confidence=1;this._confidence_y=t}return this._confidence}needCountWeight(){return this.outsideWeight+this.insideWeight+this.invalidWeight<5e3}revokeOutside(t){let i=this.confidence(t);return this.outsideWeight-=i,this.invalidWeight+=i,i}revokeInside(t){let i=this.confidence(t);return this.insideWeight-=i,this.invalidWeight+=i,i}setOutside(t){let i=this.confidence(t);return this.outsideWeight+=i,i}setInside(t){let i=this.confidence(t);return this.insideWeight+=i,i}setInvalid(t){let i=this.confidence(t);return this.invalidWeight+=i,i}prevNot0(){let t=this.previous;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.previous}return null}nextNot0(){let t=this.next;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.next}return null}getX(t){if(this.bo!==null)return(this._x_y!=t||isNaN(this._x))&&(EK(this,t)>0?this._x=oe[0]:this._x=NaN,this._x_y=t),this._x;throw new Error("not supported operation")}voteStatus(){return this.outsideWeight>this.insideWeight&&this.outsideWeight>this.invalidWeight?2:this.insideWeight>this.outsideWeight&&this.insideWeight>this.invalidWeight?1:this.invalidWeight>this.outsideWeight&&this.invalidWeight>this.insideWeight?3:0}reverse(t){if(t===2)if(this.start.y>this.end.y){let i=zm.rebuild(this.shape,this.end,this.start),r=new zm(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return Ia.addAll(r.connect,this.connect),r}else return this;else if(t===1)if(this.start.y<this.end.y){let i=zm.rebuild(this.shape,this.end,this.start),r=new zm(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return Ia.addAll(r.connect,this.connect),r}else return this;return this}isNeedScan(t){return this.needCountWeight()&&this.confidence(t)>0}hashCode(){return this._hashcode}equals(t){return t instanceof zm?!(this.polyGrp!==t.polyGrp||this.polyIndex!==t.polyIndex):!1}bbox(){return this._bbox}toString(){return qm.format("(%d,%d,%d) (%d,%d,%d) %s %s",this.polyGrp,this.polyIndex,this.weight,this.outsideWeight,this.invalidWeight,this.insideWeight,this.start,this.end)}};function pK(e,t){let i=e.bbox(),r=t.bbox(),n=(i.minY+i.maxY)/2,s=(r.minY+r.maxY)/2;return n-s}function fK(e,t){let i=e.bbox(),r=t.bbox(),n=(i.minX+i.maxX)/2,s=(r.minX+r.maxX)/2;return n-s}var Gm=class{constructor(e){if(this.__bbox=null,typeof e<"u")if(e instanceof Array){this.__items=[];for(let t of e)this.add(t)}else this.__items=e,this.__bbox=e.bbox();else this.__items=[]}add(e){if(this.__items instanceof Array)this.__items.push(e),this.__bbox=Ta.extend2(this.__bbox,e.bbox());else throw new Error("can't insert multiple item into leaf node")}items(){return this.__items}bbox(){if(this.__bbox!==null)return this.__bbox;throw new Error("bug")}},e1=class{constructor(e){this.changed=!1,this.root=new Gm,this.capacity=e,this.capacity2=e*e,this.itemList=[]}size(){return this.itemList.length}items(){return this.flushWhenNeed(),this.itemList}add(e){this.itemList.push(e),this.changed=!0}remove(e){Ia.remove(this.itemList,e),this.changed=!0}clear(){this.changed=!1,this.root=new Gm,this.itemList.length=0}flushWhenNeed(){if(this.changed){let e=new Array;for(let t of this.itemList)e.push(new Gm(t));for(;;){let t=this.organize(e);if(t.length>1)e=t;else break}this.root=new Gm(e),this.changed=!1}}organize(e){zp(e,fK,0,e.length);let t=e.length,i=[];for(let r=0;r<t;)if(r+this.capacity2<=t){let n=r+this.capacity2;zp(e,pK,r,n);for(let s=r;s<n;s+=this.capacity){let a=new Gm(e.slice(s,s+this.capacity));i.push(a)}r=r+this.capacity*this.capacity}else{let n=new Gm(e.slice(r,r+this.capacity));i.push(n),r=r+this.capacity}return i}search(e){this.flushWhenNeed();let t=[],i=[];for(i.push(this.root);;){let r=i.shift();if(typeof r<"u"){let n=r.items();if(n instanceof Array){for(let s of n)if(!e.isSeparated(s.bbox())){let a=s.items();a instanceof Array?i.push(s):t.push(a)}}else e.isSeparated(r.bbox())||t.push(n)}else break}return t}walker(e){this.flushWhenNeed(),this._walker(this.root,0,e)}_walker(e,t,i){this.flushWhenNeed();let r=e.items();if(r instanceof Array)for(let n of r)this._walker(n,t+1,i);else i(r,t)}bbox(){return this.flushWhenNeed(),this.root.bbox()}};function iA(e,t){mK(e.iterator(),t)}function mK(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var RE=new Error("list is empty"),NE=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},gK=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},yK=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},Vp=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw RE;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw RE;return this.remove(e),e.item}addLast(e){return this.first===null||this.last===null?(this.first=new NE(this,e),this.last=this.first,this.cnt=1,this.first):this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new NE(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw RE;return this.first.item}getLast(){if(this.last===null)throw RE;return this.last.item}insertAfter(e,t){let i=new NE(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new NE(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new gK(this.first)}listIterator(){return new yK(this.first)}toArray(){let e=new Array(this.cnt),t=this.first,i=0;for(;t!=null;)e[i]=t.item,t=t.next,i++;return e}};function rA(e){throw new Error("")}var ME=class{constructor(e,t){this.node1=null,this.node2=null,this.key=e,this.value=t}},bK=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},xK=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},ZE=class{constructor(){this.innerList=new Vp,this.innerMap={}}replace(e,t){e.node1!==null&&(e.node1.set(t),t.node1=e.node1),e.node2!==null&&(e.node2.set(t),t.node2=e.node2)}clear(){this.innerList.clear();for(let e in this.innerMap)delete this.innerMap[e]}put(e,t){let i=e.hashCode(),r=new ME(e,t),n=this.innerMap[i];if(n===void 0)return r.node1=this.innerList.add(r),this.innerMap[i]=r,null;if(n instanceof ME){if(n.key.equals(e))return this.innerMap[i]=r,this.replace(n,r),n.value;{r.node1=this.innerList.add(r);let s=new Vp;return n.node2=s.add(n),r.node2=s.add(r),this.innerMap[i]=s,null}}if(n instanceof Vp){let s=null;return iA(n,(a,o)=>o.key.equals(e)?(this.replace(o,r),s=o.value,!1):!0),s===null?(r.node1=this.innerList.add(r),r.node2=n.push(r),null):s}return rA(n)}get(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof ME)return i.key.equals(e)?i.value:null;if(i instanceof Vp){let r=null;return iA(i,(n,s)=>s.key.equals(e)?(r=s.value,!1):!0),r}return rA(i)}containsKey(e){return this.get(e)!==null}delete(e){e.node1!==null&&e.node1.parent.remove(e.node1),e.node2===null?delete this.innerMap[e.key.hashCode()]:e.node2.parent.remove(e.node2)}remove(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof ME)return i.key.equals(e)?(this.delete(i),i.value):null;if(i instanceof Vp){let r=null;return iA(i,(n,s)=>s.key.equals(e)?(r=s.value,this.delete(s),!1):!0),r}return rA(i)}computeIfAbsent(e,t){let i=this.get(e);if(i===null){let r=t(e);return this.put(e,r),r}else return i}size(){return this.innerList.size()}isEmpty(){return this.innerList.size()===0}keys(){return new bK(this.innerList.iterator())}values(){return new xK(this.innerList.iterator())}entries(){return this.innerList.iterator()}},$m=class{constructor(){this.innerMap=new ZE}add(e){return this.innerMap.put(e,!0)!==!0}remove(e){this.innerMap.remove(e)}contains(e){return this.innerMap.get(e)===!0}iterator(){return this.innerMap.keys()}addAll(e){let t=e.iterator();for(;t.hasNext();)this.add(t.next())}size(){return this.innerMap.size()}clear(){let e=this.iterator();for(;e.hasNext();){let t=e.next();this.remove(t)}}},xM=Ia.funcCopy(zp);function EK(e,t){let i=0;if(Math.abs(e.start.y-t)<=1e-4)oe[i++]=e.start.x;else if(Math.abs(e.end.y-t)<=1e-4)oe[i++]=e.end.x;else if(e.shape instanceof ye)i=UJ(e.shape,t);else if(e.shape instanceof Le)i=YJ(e.shape,t);else throw new Error("not supported operation");return i}var HE=class{constructor(e,t,i,r){this.sides=new Array,this.loader=e,this.loader.bo=this,this.logger=i,this.rule=t,this.event=r}static sortByBBoxMinY(e,t){return e.bbox().minY-t.bbox().minY}static sortByBBoxAreaDesc(e,t){return t.bbox().area()-e.bbox().area()}addPolyline(e,t=1,i=.01,r=!0){for(let n of this.loader.buildGroup(e,t,i,r))this.sides.push(n),this.event.onOriginSide(n)}buildRTree(){let e=new e1(10);for(let t of this.sides)e.add(t);return e}fillValidSides(e,t,i){for(let r of t)isFinite(r.getX(i))&&e.push(r)}getSortedEndpointsLineAsc(e){let t=new Array;for(let n of e)n.needCountWeight()&&(t.push(n.start),t.push(n.end));xM(t,Ie.sortByYAsc,0,t.length);let i=new Array,r=Number.NEGATIVE_INFINITY;for(let n of t){let s=n.y;s>r&&(i.push(s),r=s)}return i}splitSides(e,t,i){let r=e.start,n=e.end,s=new Ie(n.x+(r.x-n.x)*2,n.y+(r.y-n.y)*2);xM(e.inters,(o,l)=>o.distance2(s)-l.distance2(s),0,e.inters.length);let a=null;for(let o of e.inters)if(a==null)o.equals(r)&&(a=o);else if(!o.equals(a)){let l=Zm.rebuild(e.shape,a,o);l instanceof Le&&Math.abs(l.sweepAngle)>190&&(l=new ye(a,o));let c=new Zm(this,l,e.baseWeight,a,o,e.polyGrp,i++);if(t.push(c),c.updateBbox(),o.equals(n))break;a=o}return i}splitSidesByInters(){let e=new Array;for(let t of this.sides)if(t.polyIndex==0){let i=0,r=null,n=null;do{let s=new Array;i=this.splitSides(t,s,i);for(let a of s)r!=null?(r.next=a,a.previous=r):n=a,r=a,this.event.onSplitedSide(a),e.push(a);if(t.next===null)throw new Error("not supported operation");t=t.next}while(t.polyIndex!==0);n!=null&&r!=null&&(n.previous=r,r.next=n)}this.sides.length=0;for(let t of e)this.sides.push(t)}seekIntersection(){if(this.sides.length>0){let e=this.buildRTree(),t=new $m;for(let i of this.sides){t.add(i);let r=i.bbox().extendOfSize(1e-5),n=i.shape instanceof ye;for(let s of e.search(r))if(!t.contains(s)){let a=s.shape instanceof ye;if(!(n&&a&&i.next!==null&&i.previous!==null&&(i.next.equals(s)||i.previous.equals(s)))){let o=Wl(i.shape,s.shape);for(let l=0;l<o;l+=2){let c=new Ie(oe[l],oe[l+1]);i.inters.push(c),s.inters.push(c),this.event.onIntersect(c,i,s)}}}}}}},SK=class ZM{constructor(t){this.sides=new $m,this.others=new $m,this.id=t}add(t){this.sides.add(t),t.finalGrp=this.id;for(let i of t.connect)this.others.add(i)}polyline(){let t=new Array;return Km(this.sides,(i,r)=>(t.push(r.shape),!0)),Ci.build2(t).asClose()}hashCode(){return this.id}equals(t){return t!=null&&t instanceof ZM?this.id===t.id:!1}},QM=class{constructor(e){this.bo=null,this.sides=new Array,this.polyGrp=0,this.polyIndex=0,this.prevSide=null,this.firstSide=null,this.noWeight0=e}completeGroup(e){this.prevSide!=null&&this.firstSide!=null&&!this.prevSide.end.equals(this.firstSide.start)&&this.addSide(new ye(this.prevSide.end,this.firstSide.start),e);let t=new Array,i=null,r=null;for(let n of this.sides)(!this.noWeight0||n.weight!==0)&&(i!=null?(i.next=n,n.previous=i):r=n,i=n,t.push(n));return i!=null&&r!=null&&(r.previous=i,i.next=r),this.polyGrp++,this.sides.length=0,this.prevSide=null,this.firstSide=null,this.polyIndex=0,t}buildGroup(e,t,i,r=!0){for(let n of e.primitives)if(n instanceof ye)this.addSide(n,t);else if(r&&n instanceof Le&&n.rx===n.ry)this.addArc(n,t);else{let s=null;for(let a of n.points(i))s!=null&&this.addSide(new ye(s,a),t),s=a}return this.completeGroup(t)}addArc(e,t){let i=e.sweepAngle,r=ti.regularD(e.startAngle),n=r+i;if(i>0){let s=90;for(;s<=n;)s>r&&(this.addSide(Le.build3(e.center,r,s-r,e.rx,e.ry),t),r=s),s+=90;r<n&&this.addSide(Le.build3(e.center,r,n-r,e.rx,e.ry),t)}else if(i<0){let s=270;for(;s>=n;)s<r&&(this.addSide(Le.build3(e.center,r,s-r,e.rx,e.ry),t),r=s),s-=90;r>n&&this.addSide(Le.build3(e.center,r,n-r,e.rx,e.ry),t)}}addSide(e,t){if(e.start().equals(e.end()))return;let i=e.start(),r;this.prevSide!=null?(this.prevSide.end.equals(i)||this.addSide(new ye(this.prevSide.end,i),t),r=new Zm(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++)):(r=new Zm(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++),this.firstSide=r),this.prevSide=r,this.sides.push(r)}},e4=class{constructor(e,t,i){this.eps=new Array,this.curWeight=0,this.start=null,this.last=null,this.prevStart=null,this.prevEnd=null,this.y=i,this.rule=e,this.bo=t,this.event=t.event}onEp(e){this.tuningWeight(e),this.start===null?this.rule(this.curWeight)?this.in(e):e.setInvalid(this.y):this.rule(this.curWeight)?e.setInvalid(this.y):this.out(e,this.start),this.last!==null&&this.event.onSweep1(this.last,e,this.y),this.last=e}in(e){this.prevEnd!=null&&this.onSameX(e,this.prevEnd)?(this.start=this.prevStart,this.prevStart=null,this.prevEnd.revokeInside(this.y),this.prevEnd=null):(this.start=e,this.start.setOutside(this.y))}out(e,t){if(this.onSameX(t,e))t.revokeOutside(this.y);else{if(e.setInside(this.y)>0&&t.confidence(this.y)>0){let i=t.voteStatus(),r=e.voteStatus();this.isValid(i)&&this.isValid(r)?i==2&&r==1&&(e.connect.push(t),t.connect.push(e)):(e.connect.push(t),t.connect.push(e))}this.event.onSegment1(t,e,this.y),this.eps.push(t),this.eps.push(e),this.prevStart=t,this.prevEnd=e}this.start=null}isValid(e){return e==1||e==2}onSameX(e,t){return e.bbox().isIntersect(t.bbox())&&Re.eq(e.getX(this.y),t.getX(this.y))}tuningWeight(e){this.curWeight+=e.weight;let t=e.nextNot0(),i=e.prevNot0();t!=null&&e.weight===t.weight&&t.trans===this.y&&(this.curWeight-=e.weight),i!=null&&e.weight===i.weight&&i.trans===this.y&&(this.curWeight-=e.weight),e.trans=this.y}},QE=new Error,EM=new class extends n1{decide1(e){return e[0]&&e[1]}}(2),wK=new class extends $M{onPolylineGroup(e,t){throw QE}onSegment(e,t,i,r,n,s){throw QE}},vK=class{constructor(e,t){this.rtree=e,this.level=t}},TK=class t4 extends HE{static isIntersect(t,i,r=r2.DUMMY){let n=new t4(r),s=n.createGroup1(t.items),a=n.createGroup2(i.items);return s.rtree.itemList.length==0||a.rtree.itemList.length==0?!1:n.isIntersect(s,a)}constructor(t){super(new QM(!1),EM.rule,t,wK)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=EM.weight(i);for(let s of t)this.addPolyline(s,r);let n=this.buildRTree();return this.sides.length=0,new vK(n,i)}isIntersect(t,i){if(t.level!==i.level){let r=t.rtree.bbox().intersection1(i.rtree.bbox());if(r!==null){try{this.inters(t,i);let n=(r.minY+r.maxY)/2;this.sweep(t,i,n)}catch(n){if(n===QE)return!0;throw n}return!1}else return!1}else throw new Error("inersection detection should not in same group")}inters(t,i){if(t.rtree.size()>i.rtree.size()){let r=t;t=i,i=r}for(let r of t.rtree.items()){r.trans=NaN;let n=r.bbox().extendOfSize(1e-5);for(let s of i.rtree.search(n))if(s.trans=NaN,Wl(r.shape,s.shape)>0)throw QE}}sweep(t,i,r){let n=Ta.extend2(t.rtree.bbox(),i.rtree.bbox()).extendOfSize(1e-5),s=new Array;this.fillValidSides(s,t.rtree.search(n),r),this.fillValidSides(s,i.rtree.search(n),r),zp(s,(o,l)=>o.getX(r)-l.getX(r),0,s.length);let a=new e4(this.rule,this,r);for(let o of s)a.onEp(o)}},kA=class yh{constructor(t){this.items=new Array(t.length),Ia.arraycopy(t,0,this.items,0,t.length),this.__bbox=this.calcBBox()}static build1(t){let i=[];return XE(t,(r,n)=>(i.push(n),!0)),new yh(i)}static build2(t){let i=t.map(r=>Ci.build8(r));return new yh(i)}static combinePolylineGroupArr(t){let i=[];for(let r of t)i=i.concat(r.items);return new yh(i)}calcBBox(){let t=new Mo;for(let i=0;i<this.items.length;i++)t.ext1(this.items[i].bbox());return t.build1()}multiply3(t){let i=new Array(this.items.length);for(let r=0;r<i.length;r++)i[r]=this.items[r].multiply3(t);return new yh(i)}bbox(){return this.__bbox}asClose(){return this.items.forEach(t=>t.asClose()),this}mirrorY(t){return this.items.forEach(i=>i.mirrorY(t)),this}closeEndpoint(){return this.items.forEach(t=>t.closeEndpoint()),this}get primitives(){return this.items.map(t=>t.primitives).flat(2)}isEqual(t){return t instanceof yh?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items.reduce((t,i)=>i.bbox().area()>t.bbox().area()?i:t,this.items[0])}getOutline(){let t=this.items;if(t.length===1)return{outline:t,hole:new Array};let i=new Set,r=new Set;for(let n=0,s=t.length;n<s;n++){let a=t[n];if(!i.has(a)&&!r.has(a)){n+1>=s&&i.add(a);for(let o=n+1;o<s;o++){let l=t[o];if(!i.has(l)&&!r.has(l)){if(!a.bbox().isInside(l.bbox().extendOfSize(1e-4))&&!l.bbox().isInside(a.bbox().extendOfSize(1e-4)))continue;TK.isIntersect(new yh([a]),new yh([l]))&&(a.bbox().area()>l.bbox().area()?(i.add(a),r.add(l)):(i.add(l),r.add(a)))}}!i.has(a)&&!r.has(a)&&i.add(a)}}return{outline:[...i],hole:[...r]}}round(t=4){let i=this.items.map(r=>r.round(t));return new yh(i)}},IK=Ia.funcCopy(zp),AK=Ia.funcCopy(zp),CK=Ia.funcCopy(zp);function DK(e){return new Array}function _K(e,t){let i=new $0(!1),r=new Z0(e,r2.DUMMY,i);for(let n of t)r.addPolyline(n);return r.simplify(),i.plGrps}var Z0=class extends HE{constructor(e,t,i){super(new QM(!1),e,t,i),this.finalSides=new Array,this.sideGroups={},this.vecSides=new Array,this.scanY=NaN,this.curNetIndex=0,this.curIndex=-1,this.scanLines=0}sweep(e,t,i){this.scanY=NaN,this.scanLines=0,IK(t,HE.sortByBBoxMinY,0,t.length);let r=new Vp;this.curNetIndex=0;let n=Number.POSITIVE_INFINITY;for(let s of e)s>n&&this.scan(r,(n+s)/2,t),n=s;this.getAllMarkPrimitive(i,t),this.logger.debug3("scan %s %d",i,this.scanLines)}simplify(){this.seekIntersection(),this.splitSidesByInters(),this.sweep(this.getSortedEndpointsLineAsc(this.sides),this.sides,!1),this.flipSides(),this.sweep(this.getSortedEndpointsLineAsc(this.vecSides),this.vecSides,!0),this.connectSides(),this.fillResult()}addPolyline(e,t=1,i=.01,r=!0){super.addPolyline(e,t,i,r)}scan(e,t,i){if(this.scanY==t)return;this.scanY=t;let r=!1,n=e.listIterator();for(;n.hasNext();){let s=n.next(),a=s.item;Re.less(a.bbox().maxY,t)?e.remove(s):!r&&a.isNeedScan(t)&&(r=!0)}for(;this.curNetIndex<i.length;){let s=i[this.curNetIndex];if(Re.less(s.bbox().minY,t))Re.greatereq(s.bbox().maxY,t)&&(this.add2AET(e,s),!r&&s.isNeedScan(t)&&(r=!0)),this.curNetIndex++;else break}if(r){this.scanLines++;let s=new e4(this.rule,this,t),a=e.iterator();for(;a.hasNext();){let o=a.next();s.onEp(o)}}}add2AET(e,t){let i=t.bbox().minX,r=t.bbox().maxX,n=t.bbox().minY,s=t.bbox().maxY,a=e.listIterator(),o=null;for(;a.hasNext();){let l,c=a.next(),u=c.item,h=u.bbox().minX,d=u.bbox().maxX;if(r<=h)l=-1;else if(d<=i)l=1;else{let f=u.bbox().minY,m=u.bbox().maxY,g=Math.max(n,f),b=Math.min(s,m);l=this.compareBySweep(t,u,(g+b)/2)}let p=u.shape;if(p instanceof ye&&p.length()<.001&&o==null&&l<0){o=c;continue}if(o!=null&&l<0){e.insertBefore(o,t);return}if(l<0){e.insertBefore(c,t);return}else o=null}e.add(t)}getLineAngle(e){let t=e.start().angle(e.end());return t<0&&(t+=Math.PI),t}getArcAngle(e,t){let i=Math.asin((t-e.center.y)/e.rx);return e.startAngle>90&&e.startAngle<270&&(i=-i),i<0&&(i+=Math.PI),(i+Math.PI/2)%Math.PI}compareArcLine(e,t,i){let r=this.getArcAngle(e,i),n=this.getLineAngle(t);return Re.eq(r,n)?-e.sweepAngle:n-r}compareBySweep(e,t,i){let r=e.getX(i);if(!isFinite(r))return 0;let n=t.getX(i);if(!isFinite(n))return 0;if(!Re.eq(r,n))return r-n;if(e.shape instanceof ye)return t.shape instanceof ye?this.getLineAngle(t.shape)-this.getLineAngle(e.shape):-this.compareArcLine(t.shape,e.shape,i);if(t.shape instanceof ye)return this.compareArcLine(e.shape,t.shape,i);{let s=e.shape,a=t.shape,o=this.getArcAngle(s,i),l=this.getArcAngle(a,i);return Re.eq(o,l)?s.sweepAngle*a.sweepAngle<=0?s.sweepAngle<=0?1:-1:s.sweepAngle>0?s.rx-a.rx:a.rx-s.rx:l-o}}getAllMarkPrimitive(e,t){for(let i of t)if(i.status===0&&i.bbox().height()!=0){let r=i.voteStatus();if(r===2||r===1){i.status=r;let n=i.reverse(r);if(e){this.event.onResultSide(n);let s=n.shape.multiply3(Zn.ROT_N90),a=n.start.multiply3(Zn.ROT_N90),o=n.end.multiply3(Zn.ROT_N90);n=new Zm(this,s,n.baseWeight,a,o,n.polyGrp,n.polyIndex)}this.finalSides.push(n),this.event.onResultSide(n)}}}flipSides(){for(let e of this.sides)if(e.polyIndex==0){let t=null,i=null;do{let r=e.shape.multiply3(Zn.ROT_90),n=e.start.multiply3(Zn.ROT_90),s=e.end.multiply3(Zn.ROT_90),a=new Zm(this,r,e.baseWeight,n,s,e.polyGrp,e.polyIndex);if(a.outsideWeight=e.outsideWeight,a.insideWeight=e.insideWeight,a.invalidWeight=e.invalidWeight,a.status=e.status,t!=null?(t.next=a,a.previous=t):i=a,this.vecSides.push(a),this.event.onSplitedSide(a),t=a,e.next!==null)e=e.next;else break}while(e.polyIndex!=0);i!=null&&(i.previous=t,t.next=i)}}canBeEnd(e,t){if(e.size()==1){let i=e.getFirst().shape;if(i instanceof Le){if(t&&i.rx<=t)return!1}else if(i instanceof ye&&t&&i.length()<=t)return!1}return!0}connectSides(){let e=new ZE,t=new e1(10);for(let s of this.finalSides)e.computeIfAbsent(s.start,DK).push(s),t.add(s.start);let i=0,r=new $m,n=new Array;for(let s of this.finalSides)if(!r.contains(s)){let a=new $m,o=s.start,l=new Vp;l.add(s),r.add(s);let c=s.end;for(;l.size()>0;)if(this.isStart(o,c)&&this.canBeEnd(l,.01)){l.size()>1&&this.fillSideGroups(l,i++);break}else{let u=e.get(c),h=this.findNext(r,u);if(h==null&&(c=this.findNeigber(c,a,t,.01),c!==null&&(u=e.get(c),h=this.findNext(r,u))),h!=null)l.add(h),r.add(h),c=h.end;else if(c!=null?a.add(c):(n.length==0&&l.size()>1&&this.logger.warning3("unable to connect at %s",l.getLast()),n.push(l.removeLast())),l.size()>0)c=l.getLast().end;else break}}}fillSideGroups(e,t){let i=new SK(t);Km(e,(r,n)=>(i.add(n),!0)),this.sideGroups[i.id]=i}isStart(e,t){return e.distance2(t)<=1e-4}findNext(e,t){if(t!=null){for(let i of t)if(!e.contains(i))return i}return null}fillResult(){let e=0,t=new ZE;for(let r in this.sideGroups){let n=this.sideGroups[r];Km(n.sides,(s,a)=>(a.polyGrp!=-2&&t.put(a,a),!0))}let i=new $m;for(let r in this.sideGroups){let n=this.sideGroups[r];if(i.add(n)){let s=0,a=new Array;for(a.push(n);s<a.length;){let l=a[s],c=new Array;Km(l.others,(h,d)=>{let p=t.get(d);return p!=null&&c.push(p.finalGrp),!0}),AK(c,Ia.sortAsc,0,c.length);let u=l.id;for(let h of c)if(h!=u&&h!=l.id){let d=this.sideGroups[h];i.add(d)&&a.push(d),u=h}s++}let o=new Array;for(let l of a)o.push(l.polyline());CK(o,HE.sortByBBoxAreaDesc,0,o.length),this.event.onPolylineGroup(new kA(o),e++)}}}findNeigber(e,t,i,r){let n=r*r,s=Number.MAX_VALUE,a=null;for(let o of i.search(e.bbox().extendOfSize(r)))if(!t.contains(o)){let l=e.distance2(o);l<s&&(s=l,a=o)}return s<n?a:null}},PK=class{constructor(){this.points=[],this.lines=[],this.arcs=[],this.beziers=[],this.listText=[],this.fonts=[]}addPt(e,t=!0){if(e instanceof ye)this.lines.push(e);else if(e instanceof Le)this.arcs.push(e);else if(e instanceof gt)this.beziers.push(e);else throw new Error("not support");t&&this.points.push(e.start())}addPoint(e){this.points.push(e)}addText(e,t,i=1,r=.1,n=!0){this.listText.push({pos:e,str:t,size:i,width:r}),n&&this.points.push(e)}addPly(e,t=!0){e.primitives.forEach(i=>this.addPt(i,t))}build(){let e=[],t=[],i=[],r=[],n=[],s=[];return this.points.forEach(a=>e.push(a.x,a.y)),this.lines.forEach(a=>t.push(a.start().x,a.start().y,a.end().x,a.end().y)),this.arcs.forEach(a=>i.push(a.center.x,a.center.y,a.rx,ti.toRadians(a.startAngle),ti.toRadians(a.endAngle()),a.sweep())),this.beziers.forEach(a=>{a.controls.forEach(o=>{r.push(o.x,o.y)}),r.push("end")}),this.listText.forEach(a=>n.push(a.pos.x,a.pos.y,a.str,a.width,a.size)),this.fonts.forEach(a=>s.push(a)),{points:e,lines:t,arcs:i,texts:n,beziers:r,fonts:s}}},G0,s1=(G0=class{constructor(e){this.map=new ZE,this.bus=e}initColor(e){return this.map.computeIfAbsent(e,()=>new PK)}draw(){let e={},t=this.map.entries();for(;t.hasNext();){let i=t.next();e[i.key.toString()]=i.value.build()}this.bus.publish("/debug/draw",e)}clear(){this.map.clear()}static init(e){if(!e)throw new Error("bus is undefined!");this.palette=new G0(e)}static initPalette(e){this.palette=e}static getDefaultColor(){for(let e of this.colorBuffersMap)if(e[0]!==null&&e[0])return e[0]=!1,e[1];return this.colorBuffersMap.forEach(e=>{if(e[0]===null){console.log(1);return}e[0]=!0}),this.getDefaultColor()}static clear(){this.palette.clear()}static auto(e,t=this.getDefaultColor()){if(Array.isArray(e))e.forEach(i=>{this.auto(i,t)});else if(e instanceof Ie)this.point(e,t);else if(e instanceof Ta)this.bbox(e,t);else if(e instanceof r1)this.primitive(e,t);else if(e instanceof Ci)this.polyline(e,t);else if(e instanceof os)this.polygon(e,t);else if(e instanceof On)this.group(e,t);else if(e instanceof kA)this.auto(e.items,t);else{debugger;throw new Error("No incoming type!")}}static text(e,t,i=.5,r=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");this.palette.initColor(r).addText(e,t,i,i/10),this.palette.draw()}static point(e,t=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let i=this.palette.initColor(t);Array.isArray(e)?e.forEach(r=>{this.point(r,t)}):i.addPoint(e),this.palette.draw()}static bbox(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.bbox(i,t)}):(this.primitive(new ye(new Ie(e.maxX,e.maxY),new Ie(e.maxX,e.minY)),t),this.primitive(new ye(new Ie(e.maxX,e.maxY),new Ie(e.minX,e.maxY)),t),this.primitive(new ye(new Ie(e.minX,e.minY),new Ie(e.maxX,e.minY)),t),this.primitive(new ye(new Ie(e.minX,e.minY),new Ie(e.minX,e.maxY)),t))}static primitive(e,t=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let i=this.palette.initColor(t);Array.isArray(e)?e.forEach(r=>{this.primitive(r,t)}):i.addPt(e),this.palette.draw()}static polyline(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.polyline(i,t)}):e.primitives.forEach(i=>{this.primitive(i,t)})}static polygon(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.polygon(i,t)}):e.items.forEach(i=>{this.polyline(i,t)})}static group(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.group(i,t)}):e.items.forEach(i=>{this.polygon(i,t)})}static async begin(){this.t1=performance.now()}static async end(e){console.log(e||"t1:",performance.now()-this.t1)}static async log(e){console.log(e||"==================")}},G0.colorBuffersMap=[[!0,Wi.BLUE],[!0,Wi.GREEN],[!0,Wi.WHITE],[!0,Wi.RED],[!0,Wi.Golden],[!0,Wi.Gray]],G0.t1=0,G0),LK=0,a1=class SA{constructor(t,i){this.inters=[],this.shape=t,this.start=t.start(),this.end=t.end(),this.judgeOverlapMap=new Map,i&&(this.id=LK++)}reverse(){this.shape=this.shape.reverse();let t=this.start;this.start=this.end,this.end=t}getCenterPoint(t=this.end){let{x:i,y:r}=this.start,{x:n,y:s}=t;if(this.shape instanceof Le){let a=this.shape.rx,o=new Ie((i+n)/2,(r+s)/2),l=this.shape.center,c;return o.x!==l.x||o.y!==l.y?(c=o.angle(l),Math.abs(this.shape.sweepAngle)>180&&(c+=c>=0?-180:180)):c=(this.shape.startAngle+this.shape.endAngle())/2,new Ie(l.x+Math.cos(c)*a,l.y+Math.sin(c)*a)}else{if(this.shape instanceof ye)return new Ie((i+n)/2,(r+s)/2);if(this.shape instanceof gt){let a=this.shape.getPercent(t,Ht);return gt.pointOn(a/2,this.shape.controls)}else throw Error("not support")}}static finalAngle(t,i,r){let n=t.cross(i)>0,s=Math.acos(Math.min(1,Math.max(-1,t.dot(i)/i.length())));return(r?!n:n)&&(s=n2-s),s}sortInters(){if(this.shape instanceof Le){let t=this.shape.center,i=this.shape.start().sub(t).normalize(),r=this.shape.isCCW;this.inters.sort((n,s)=>{let a=n.coord.sub(t),o=s.coord.sub(t);return SA.finalAngle(i,a,r)-SA.finalAngle(i,o,r)<=0?-1:1})}else if(this.shape instanceof ye){let t=this.start,i=this.end,r=new Ie(i.x+(t.x-i.x)*2,i.y+(t.y-i.y)*2);this.inters.sort((n,s)=>n.coord.distance2(r)-s.coord.distance2(r)<=0?-1:1)}else if(this.shape instanceof gt){let t=this.shape;this.inters.sort((i,r)=>t.getPercent(i.coord,Ht)-t.getPercent(r.coord,Ht)<=0?-1:1)}else throw Error("not support the primitive type");this.inters.forEach((t,i)=>t.setIndex(i))}getStart(){return this.start}getEnd(){return this.end}getShape(){return this.shape}connect(t){this.nextSide=t,t.prevSide=this}static returnPolygonList(t){let i=[];return t.forEach(r=>{let n=[];r.forEach((s,a)=>{let o=[];s.forEach(l=>{o.push(l.shape)}),n.push(Ci.build7(o))}),i.push(new os(n))}),i}addInter(t){this.inters.push(t)}static returnPolygonGroup(t){let i=[];return t.forEach(r=>{let n=[];r.forEach((s,a)=>{let o=[];s.forEach(l=>{o.push(l.shape)}),n.push(Ci.build7(o))}),i.push(new os(n))}),new On(i)}static rebuild(t,i,r){let n;if(t instanceof ye||i.distance2(r)<1e-6)n=new ye(i,r);else if(t instanceof Le)n=Le.build2(t.center,i.angleD(t.center),r.angleD(t.center),t.rx,t.ry,t.isCCW?1:0);else if(t instanceof gt){let s=t.getPercent(i,Ht),a=t.clip(s)[1];n=a.clip(a.getPercent(r,Ht))[0]}else throw new Error("not supported operation");return Vt(t,i).dot(Vt(n,i))<0?null:n}static returnPolyline(t){return Ci.build7(t.map(i=>i.shape))}bbox(){return this.shape.bbox()}},OK=(e=>(e[e.END1=0]="END1",e[e.END2=1]="END2",e[e.END12=2]="END12",e[e.LEFT1=3]="LEFT1",e[e.LEFT2=4]="LEFT2",e))(OK||{});function Aa(e,t,i){if(e instanceof Le&&t instanceof Le)return MK(e,t);if(e instanceof Le&&t instanceof ye)return vM(e,t);if(e instanceof ye&&t instanceof Le)return wM(e,t);if(e instanceof ye&&t instanceof ye)return jp(e,t);if(e instanceof gt&&t instanceof ye)return e.controls.length===2||Sh(e)?jp(new ye(e.start(),e.end()),t):i4(e,t);if(e instanceof ye&&t instanceof gt)return t.controls.length===2||Sh(t)?jp(e,new ye(t.start(),t.end())):wA(e,t);if(e instanceof Le&&t instanceof gt)return t.controls.length===2||Sh(t)?vM(e,new ye(t.start(),t.end())):RK(e,t);if(e instanceof gt&&t instanceof Le)return e.controls.length===2||Sh(e)?wM(new ye(e.start(),e.end()),t):NK(e,t);if(e instanceof gt&&t instanceof gt)return FA(e,t);throw new Error("not support")}function Um(e,t){return Vt(e,t.start()).dot(Vt(t,t.start()))<=0?!1:Aa(e,t).state<=2}function nA(e,t){let i=t.getPercent(e.end(),Ht);if(i===null)return!1;if(i===0)return!0;let r=t.clip(i)[0],n=e.buildConverxHull(Ht),s=r.buildConverxHull(Ht),a=c(n),o=c(s);return l(a,o);function l(u,h){let d=new Map([[0,1],[1,0],[2,2],[3,4],[4,3]]),p=u[0],f=h[0];if(!p||!f)throw Error("isAllOverlap(sides1: PackSide[], sides2: PackSide[])");let m=!0;do{let g=p.getShape(),b=f.getShape();if(g instanceof ye&&b instanceof ye){let y=m?jp(g,b).state:d.get(jp(b,g).state);if(y===0)p=p.nextSide,m=!1;else if(y===1)f=f.nextSide,m=!0;else if(y===2)p=p.nextSide,f=f.nextSide,m=!0;else return!1}else throw Error("not support")}while(p!==u[0].prevSide&&f!==h[0].prevSide);return!0}function c(u){let h=u.primitives.map(p=>new a1(p)),d=h[h.length-1];return h.forEach(p=>{d.connect(p),d=p}),h}}function SM(e,t){let i=e.end().distance2(t.center);if(i>(t.rx+Ht)**2||i<(t.rx-Ht)**2||!(Ct(e.end(),t.end())||GA(t,e.end())))return!1;if(e.center.equals1(t.center))return!0;let r=e.center.distance1(t.center),n=Math.abs(e.rx-t.rx);if(r>Math.min(e.rx,t.rx)){let s=e.center.angleD(t.center);return e.rx>t.rx?!(r+n>Ht&&Su(e,s))&&!(r-n>Ht&&e.rx+t.rx-r>Ht&&Su(e,s+180)):!(r-n>Ht&&Su(e,s))&&!(e.rx+t.rx-r>Ht&&Su(e,s+180))}else{if(r+n<=Ht)return!0;let s=e.rx>t.rx?e.center.angleD(t.center):t.center.angleD(e.center);return Su(e,s)?!1:r-n<=Ht?!0:!Su(e,s+180)}}function RK(e,t){let i=UA(e,t.start()).toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=FA(a,t).state,r!==0)break}return r===2&&n!==i.length-1?{state:1}:{state:r}}function NK(e,t){let i=t.toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=FA(e,a).state,r!==1)break}return r===2&&n!==i.length-1?{state:0}:{state:r}}function FA(e,t){if(e.controls.length===2||Sh(e))return t.controls.length===2||Sh(t)?jp(new ye(e.start(),t.end()),new ye(t.start(),t.end())):wA(new ye(t.start(),e.end()),t);if(t.controls.length===2||Sh(t))return i4(vA(e,t.start()),new ye(t.start(),t.end()));let i=vA(e,t.start());if(Sh(i))return wA(new ye(t.start(),e.end()),t);let r=nA(i,t),n=nA(t,i);if(!r&&!n){let s=KJ(i,t);if(s.havOverlap){let a=s.havOverlap!==2,o=s.havOverlap!==1;return wh(e,t,a,o)}else{let a=function(){for(let h=0;h<c;h+=2)oe[h]=u[h],oe[h+1]=u[h+1]},o,l,c=s.cnt,u=new Array(c).fill(0).map((h,d)=>oe[d]);for(let h=0;h<c;h+=2){let d=new Ie(oe[h],oe[h+1]),p=i.getPercent(d,Ht),f=t.getPercent(d,Ht);if(p===0||f===0)continue;let m=p===1?i:i.clip(p)[0],g=f===1?t:t.clip(f)[0];if(nA(m,g)){let b=Vt(e,d).cross(Vt(t,d));if(b===0){o=i.end(),l=t.end();break}return{state:b<0?3:4}}a()}return(!o||!l)&&(o=Jm(i.controls,i.controls[0],t),l=Jm(t.controls,i.controls[0],i)),{state:o.sub(i.controls[0]).cross(l.sub(i.controls[0]))>0?4:3}}}return wh(e,t,r,n)}function i4(e,t){let i=vA(e,t.start());if(Sh(i))return jp(new ye(i.start(),i.end()),t);let r=n4(i,t),{isIn:n,bezierIsInLeft:s}=r4(t,i);if(!r&&!n){if(s!==void 0)return{state:s?3:4};let a=null,o=e.getPercent(t.start(),Ht)+.01;for(let l=o>1?1:o;l<=1;){let c=gt.pointOn(l,e.controls);if(t1(t,c)>Ca){a=c;break}l+=.01,l>1&&(l=1)}if(!a)throw Error("!end1 && !end2 not result");return{state:t.direct.cross(a.sub(t.start()))<0?4:3}}return wh(i,t,r,n)}function wA(e,t){let{isIn:i,bezierIsInLeft:r}=r4(e,t),n=n4(t,e);if(!i&&!n){if(r!==void 0)return{state:r?4:3};let s=null;for(let a=.01;a<=1;){let o=gt.pointOn(a,t.controls);if(t1(e,o)>Ca){s=o;break}a+=.01,a>1&&(a=1)}if(!s)throw Error("!end1 && !end2 not result");return{state:e.direct.cross(s.sub(e.start()))<0?3:4}}return wh(t,e,i,n)}function MK(e,t){let i=SM(UA(e,t.start()),t),r=SM(t,e);if(!i&&!r){let n=Nc(t);if(e.center.sub(t.start()).dot(t.center.sub(t.start()))>0){if(e.rx===t.rx)return e.isCCW?{state:n.dot(e.center.sub(t.center))<0?3:4,exitIsInvalid:!1}:{state:n.dot(e.center.sub(t.center))>0?3:4,exitIsInvalid:!1};let s,a;return e.rx>t.rx?(s=e,a=t):(s=t,a=e),n.dot(a.center.sub(s.center))>0&&a.rx+a.center.distance1(s.center)-s.rx>Ht?e.isCCW?{state:e.rx>t.rx?3:4,exitIsInvalid:!1}:{state:e.rx<t.rx?3:4,exitIsInvalid:!1}:e.isCCW?{state:e.rx<t.rx?3:4,exitIsInvalid:!0}:{state:e.rx>t.rx?3:4,exitIsInvalid:!0}}else return e.rx+t.rx-e.center.distance1(t.center)>Ht&&n.dot(e.center.sub(t.center))>0?{state:t.isCCW?3:4,exitIsInvalid:!1}:{state:e.isCCW?3:4,exitIsInvalid:!0}}return wh(e,t,i,r)}function wM(e,t){let i=Rc.foot(e,t.center),r=e.end().distance2(t.center),n=e.end().sub(e.start()),s=(t.rx-Ht)**2,a=r<=(t.rx+Ht)**2&&r>=s&&(n.dot(i.sub(t.start()))<=0||e.start().distance2(e.end())<=e.start().distance2(i)||i.distance2(t.center)>=s)&&(Ct(e.end(),t.end())||GA(t,e.end())),o=s4(t,e);if(!a&&!o){let l=e.distance2(t.center);return l<=Ca?{state:n.cross(Nc(t))>0?4:3}:n.dot(i.sub(t.start()))>=0&&(r<s||e.start().distance2(t.center)<s||l<s)?{state:n.cross(t.center.sub(e.start()))<0?4:3}:{state:n.cross(t.center.sub(e.start()))>0?4:3}}return wh(t,e,a,o)}function Su(e,t){return t=ti.regularD(t),e.sweepAngle>0?(t<e.startAngle&&(t+=360),e.endAngle()>t):(t>e.startAngle&&(t-=360),e.endAngle()<t)}function GA(e,t){return Ct(e.end(),t)||Ct(e.start(),t)||Su(e,t.angleD(e.center))}function r4(e,t){let i=e.panDistance(Ht),r=e.panDistance(-Ht),n=TM(t,i),s=TM(t,r);if(!n.length&&!s.length)return{isIn:t.getPercent(e.end(),Ht)!==null};let a=[...n,...s].sort((u,h)=>u.t-h.t),o=new ye(r.start(),i.start()),l=[];for(let u=0,h=a.length;u<h;u++){let d=a[u];if(l.push(d),o.distance(d.interP)>e.length()+Ht)break;if(l.length===2){let p=(l[1].t*10+l.shift().t*10)/20,f=gt.pointOn(p,t.controls);if(e.distance2(f)>Ca)return{isIn:!1,bezierIsInLeft:e.direct.cross(f.sub(e.start()))>0}}}let c=l.length?o.distance(l[0].interP)>=e.length()+Ht:!0;return{isIn:c,bezierIsInLeft:c?void 0:e.direct.cross(l[0].interP.sub(e.start()))>0}}function n4(e,t){if(t1(t,e.end())>Ca||e.getToLineMaxDis2(t)>Ca)return!1;let i=kK(t,Ca);return e.getToLineMaxDis2(i)<=(t.length()+Ht)**2}function s4(e,t){let i=t.end().angleD(t.start()),r=BK(t,e.end());if(r>Ca)return!1;if(Su(e,i+90)){if(Rc.foot(t,e.center).distance1(e.pointOn(i+90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}if(Su(e,i-90)){if(Rc.foot(t,e.center).distance1(e.pointOn(i-90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}return r<=Ca&&(Ct(e.end(),t.end())||TA(t,e.end()))}var a4=(Ht*2)**2;function UA(e,t){if(Ct(e.end(),t))return Le.build3(e.center,e.endAngle(),0,e.rx,e.ry);if(e.start().distance2(t)<a4)return e;let i=ti.regularD(t.angleD(e.center));if(!Su(e,i))throw new Error("!angleIsInArc(arc, angle)");return Le.build2(e.center,i,e.endAngle(),e.rx,e.ry,e.isCCW?1:0)}function vA(e,t){if(Ct(e.end(),t))return new gt([t,t]);if(e.start().distance2(t)<a4)return e;let i=e.getPercent(t,Ht);if(i===null)throw new Error("!cutBezier(bezier: Bezier, p: Vector2)");return e.clip(i)[1]}function vM(e,t){let i=s4(UA(e,t.start()),t),r=t.end().distance2(e.center),n=t.end().sub(t.start()),s=Rc.foot(t,e.center),a=(e.rx-Ht)**2,o=r<=(e.rx+Ht)**2&&r>=a&&(n.dot(s.sub(t.start()))<=0||t.start().distance2(t.end())<=t.start().distance2(s)||s.distance2(e.center)>=a)&&(Ct(e.end(),t.end())||GA(e,t.end()));if(!i&&!o){let l=t.distance2(e.center);return l<=Ca?{state:n.cross(Nc(e,t.start().angle(e.center)))>0?3:4}:n.dot(s.sub(t.start()))>=0&&(r<a||t.start().distance2(e.center)<a||l<a)?{state:n.cross(e.center.sub(t.start()))>0?4:3}:{state:n.cross(e.center.sub(t.start()))<0?4:3}}return wh(t,e,i,o)}function jp(e,t){if(Ct(e.end(),t.end()))return wh(e,t,!0,!0);let i=t1(t,e.end())<=Ca&&TA(t,e.end()),r=t1(e,t.end())<=Ca&&TA(e,t.end());if(!i&&!r){let n=e.direct.x===0&&e.direct.y===0,s=t.direct.x===0&&t.direct.y===0;if(n&&s)throw Error("2LineAllIsPoint");return n?{state:t.direct.cross(e.end().sub(t.start()))>0?3:4}:{state:e.end().sub(e.start()).cross(t.end().sub(e.start()))>0?4:3}}return wh(e,t,i,r)}function TA(e,t){return Rc.foot(e,t).distance2(e.start())<e.end().distance2(e.start())}function wh(e,t,i,r){if(i)return r?Ct(e.end(),t.end())?{state:2}:{state:0}:{state:0};if(r)return{state:1};throw new Error("!end1 && !end2")}function t1(e,t){return(e.a*t.x+e.b*t.y+e.c)**2/(e.a**2+e.b**2)}function BK(e,t){return Math.min(e.distance2(t),Rc.foot(e,t).distance2(t))}function kK(e,t){let i=e.panDistance(t),r=e.panDistance(-t);return new ye(r.start(),i.start())}function Sh(e){let t=e.start(),i=e.end();t.equals1(i)&&(i=t.add1(1,0));let r=i.y-t.y,n=t.x-i.x,s=-r*t.x-n*t.y,a=Math.sqrt(1/(r**2+n**2));r*=a,n*=a,s*=a;let o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;return e.controls.forEach(c=>{let u=r*c.x+n*c.y+s;u<o&&(o=u),u>l&&(l=u)}),Iu(o,l)}function TM(e,t){let i=Wl(e,t),r=[],n=new Array(i).fill(0).map((a,o)=>oe[o]);for(let a=0;a<i;a+=2){let o=new Ie(oe[a],oe[a+1]),l=e.getPercent(o);r.push({interP:o,t:l}),s()}function s(){for(let a=0;a<i;a+=2)oe[a]=n[a],oe[a+1]=n[a+1]}return r}var Eu=.01,FK=270;function Sd(e){let t=Eu**2,i=e.end(),r=[],n=[];for(let p=0,f=e.primitives.length;p<f;p++){let m=function(R,M){return R instanceof ye&&M instanceof ye&&Math.abs(R.direct.cross(M.direct))<Re.eps&&R.direct.dot(M.direct)>0||R instanceof Le&&M instanceof Le&&Math.abs(R.rx-M.rx)<=Re.eps&&R.center.distance2(M.center)<Re.eps&&R.isCCW===M.isCCW},g=function(R){if(al(R,Eu))n.push(null);else{if(R instanceof ye)n.push(R);else if(R instanceof Le&&R.rx===R.ry)h(R,n);else if(R instanceof gt){let M=[];qM(R,M),M.forEach(F=>{let G=F.start(),V=F.end();u(G,V)||n.push(F)})}else throw new Error("not support!");i=S}},b=function(R){if(R instanceof ye)return R.direct.x===0&&R.direct.y===0;if(R instanceof Le)return R.sweepAngle===0;if(R instanceof gt){let M=new Set(R.controls.map(G=>G.x)),F=new Set(R.controls.map(G=>G.y));return M.size===1&&F.size===1}else throw new Error("not support")},y=e.primitives[p],E=y.start(),S=y.end();if(b(y))continue;u(i,E)||(n.push(new ye(i,E)),i=E);let w=(p+1)%f,x=e.primitives[w];for(;m(y,x)&&(w=(w+1)%f,x=e.primitives[w],x!==y););if(w===(p+1)%f){g(y);continue}if(x===y){if(!(y instanceof Le)){if(Math.abs(e.area(.1))<t)return null;throw new Error("simplifyPolyline not support")}let R=y instanceof Le?y.isCCW:e.area(.1)>0;n.length=0;let M=R?180:-180;n.push(Le.build3(y.center,y.startAngle,M,y.rx,y.ry),Le.build3(y.center,y.startAngle+M,M,y.rx,y.ry));break}let I=(()=>{if(y instanceof ye)return(R,M)=>{let F=new ye(R,M);return al(F,Eu)?null:[F]};if(y instanceof Le)return(R,M)=>{let F;if(R.equals1(M)?F=Le.build3(y.center,y.startAngle,y.sweep()===1?360:-360,y.rx,y.ry):F=Le.build4(R,M,y.center,y.rx,y.ry,y.sweep()),al(F,Eu))return null;let G=F.pointOn(F.startAngle+F.sweepAngle/2),V=Le.build4(F.start(),G,y.center,y.rx,y.ry,y.sweep()),q=Le.build4(G,F.end(),y.center,y.rx,y.ry,y.sweep());return al(V,Eu)||al(q,Eu)?[F]:[V,q]};throw new Error("not support")})(),A=w===0;if(w<p&&!A&&(A=!I(e.primitives[0].start(),e.primitives[w-1].end()),!A)){let R=I(y.start(),e.primitives[f-1].end());if(R)n.push(...R);else{let M=I(y.start(),n[0].end());if(M.length===1)n[0]=M[0];else if(M.length===2)n[0]=M[1],n.push(M[0]);else throw new Error("!!!generatorPt")}break}p=w===0?f-1:w-1,x=e.primitives[p];let O=I(y.start(),x.end());if(O?(O.forEach(R=>n.push(R)),i=x.end()):g(null),A)break}let s=n.length;if(n.forEach((p,f)=>{if(p)r.push(p);else{let m,g;f===s-1&&(m=r[0],g=r[r.length-1]);let b=(f+1)%s;if(m=m!=null?m:n[b],m){let y=f,E=!1;for(;g=g!=null?g:n[(--y+s)%s],g!==m;)if(g){E=!0;break}if(E){if(m.start().equals1(g.end()))return;if(Vt(g,g.end()).dot(Vt(m,m.start()))<0){if(!u(g.end(),m.start())){let I=new ye(g.end(),m.start());r.push(I);return}let{rebuildPrevPt:S,rebuildNextPt:w,rebuildLinkLine:x}=IM(n[(y-1+s)%s],g,new ye(g.end(),m.start()),m,n[(f+2)%s]);S&&w&&(S!==g?(n[(y+s)%s]=S,r[r.length-1]&&(r[r.length-1]=S)):w!==m&&(n[(f+1)%s]=w,r[0]===m&&(r[0]=w)),x&&r.push(x))}}}}}),r.length===0)return null;u(i,r[0].start())||r.push(new ye(i,r[0].start()));let a=r[r.length-1];if(r.length===1)return a instanceof Le?Ci.build7([Le.build2(a.center,0,180,a.rx,a.ry,a.sweep()),Le.build2(a.center,180,360,a.rx,a.ry,a.sweep())]):a instanceof gt?Ci.build7(a.clip(.5)):null;let o=r.map(p=>new GK(p)),l=o[o.length-1];for(o.forEach(p=>{p.connect(l),l=p});!l.isVisited;){let p=function(){l.next.connect(m),l=l.next,l.isConnected=!1,l.isVisited=!1},f=function(){l.connect(m.prev),l.isConnected=!1},m=l.prev;if(l===m)break;let g=l.pt,b=m.pt,y=b.end();if(!l.isConnected&&!y.equals(g.start())){let E=function(w){l.isConnected=!0,l.pt=g=w,l.next.isVisited=!1},S=function(w){l.isConnected=!0,m.pt=w,m.isVisited=!1,l=m};if(g instanceof ye)if(u(y,g.end())){p();continue}else E(new ye(y,g.end()));else if(b instanceof ye){u(b.start(),g.start())?f():S(new ye(b.start(),g.start()));continue}else if(g instanceof gt)if(u(y,g.end())&&!(g.controls.length!==2&&g.getToLineMaxDis2(g.startToEndL)>=t)){p();continue}else E(new gt([y,...g.controls.slice(1)]));else if(b instanceof gt)u(b.start(),g.start())&&!(b.controls.length!==2&&b.getToLineMaxDis2(b.startToEndL)>=t)?f():S(new gt([...b.controls.slice(0,-1),g.start()]));else if(g instanceof Le&&b instanceof Le)if(Math.abs(Math.abs(g.sweepAngle)-180)<Math.abs(Math.abs(b.sweepAngle)-180)){let w=Le.build5(y,g.end(),g.sweepAngle);if(u(w.start(),w.end())&&!(w.rx>=Eu&&Math.abs(w.sweepAngle)>180)){p();continue}else E(w)}else{let w=Le.build5(b.start(),g.start(),b.sweepAngle);u(w.start(),w.end())&&!(w.rx>=Eu&&Math.abs(w.sweepAngle)>180)?f():S(w);continue}else throw new Error("not support")}if(Vt(g,g.start()).dot(Vt(b,b.end()))<0){let E=function(x,I,A,O,R,M){if(l.next===m){l=null;return}let{rebuildLinkLine:F,rebuildPrevPt:G,rebuildNextPt:V}=IM(x,I,A,O,R);G&&V&&(G!==I&&(m.prev.pt=G),V!==O&&(l.next.pt=V),F?M.pt=F:p())},S=function(){l.next===m?l=null:(l.next.connect(m.prev),l=l.next,l.isConnected=!1,l.isVisited=!1)},w=Aa(b.reverse(),g).state;if(w===0){let x=AM(g,b.start(),g.end());if(d(x)){let I=m.prev.pt,A=l.next.pt;if(Vt(A,A.start()).dot(Vt(I,I.end()))>=0){if(S(),!l)break;continue}if(E(m.prev.prev.pt,I,x instanceof ye?x:new ye(x.start(),x.end()),A,l.next.next.pt,l),!l)break}else l.pt=x;f();continue}else if(w===1){let x=AM(b,b.start(),g.end());if(d(x)){let I=m.prev.pt,A=l.next.pt;if(Vt(A,A.start()).dot(Vt(I,I.end()))>=0){if(S(),!l)break;continue}if(E(m.prev.prev.pt,I,x instanceof ye?x:new ye(x.start(),x.end()),A,l.next.next.pt,m),!l)break}else m.pt=x;p();continue}else if(w===2){if(S(),!l)break;continue}}l.isVisited=!0,l=l.next}if(!l)return null;r.length=0;let c=l;for(r.push(l.pt),l=l.next;l!==c;)r.push(l.pt),l=l.next;if(r.length===1){let p=r[0];return p instanceof Le?(u(p.start(),p.end())?r[0]=Le.buildCircle(p.center,p.rx,p.sweep()):r.push(new ye(p.end(),p.start())),Ci.build7(r)):p instanceof gt?(u(p.start(),p.end())||r.push(new ye(p.end(),p.start())),Ci.build7(r)):null}if(e=Ci.build7(r),Math.abs(e.area(.1))<t)return null;return e;function u(p,f){return p.distance2(f)<t}function h(p,f){if(Math.abs(p.sweepAngle)>FK){let m=p.sweepAngle/2;h(Le.build3(p.center,p.startAngle,m,p.rx,p.ry),f),h(Le.build3(p.center,p.startAngle+m,m,p.rx,p.ry),f)}else f.push(p)}function d(p){return p.start().distance2(p.end())<t&&!(p instanceof Le&&p.rx>=Eu&&Math.abs(p.sweepAngle)>180||p instanceof gt&&p.controls.length!==2&&p.getToLineMaxDis2(new ye(p.start().add1(1,0),p.end()))>=t)}}function al(e,t){if(!e)return!0;let i=e.start(),r=e.end();if(i.distance2(r)<t**2)if(e instanceof Le){if(!(e.rx>=t&&Math.abs(e.sweepAngle)>180))return!0}else if(e instanceof gt){if(!(e.controls.length!==2&&e.getToLineMaxDis2(new ye(e.start().add1(1,0),e.end()))>=t))return!0}else return!0;return!1}function Ym(e){if(e.direct.x===0&&e.direct.y===0)throw Error("getEndOfExtendLine(line: Line, distance: number)");let t=Math.abs(Eu-e.length())+Re.eps,i={x:e.direct.normalize().x*t,y:e.direct.normalize().y*t},r=e.end();return new Ie(r.x+i.x,r.y+i.y)}function IM(e,t,i,r,n){if(!e)a();else if(!n)o();else{let l=Vt(e,e.end()),c=Vt(t,e.end()),u=l.dot(c);if(u>=0)a();else{let h=Vt(r,r.end()),d=Vt(n,r.end()),p=h.dot(d);if(p>=0)o();else if(Iu(u,-1)&&Iu(p,-1)){let f=i.center();s(f),i=null}else u>p?a():o()}}function s(l){let c;if(t instanceof ye)c=new ye(t.start(),l);else if(t instanceof gt)c=new gt([...t.controls.slice(0,-1),l]);else if(t instanceof Le)c=Le.build5(t.start(),l,t.sweepAngle);else throw new Error("not supported");t=al(c,Ht)?null:c;let u;if(r instanceof ye)u=new ye(l,r.end());else if(r instanceof gt)u=new gt([l,...r.controls.slice(1)]);else if(r instanceof Le)u=Le.build5(l,r.end(),r.sweepAngle);else throw new Error("supported");r=al(u,Ht)?null:u}function a(){if(t instanceof ye){let l=Ym(i.reverse());i=new ye(l,i.end());let c=new ye(t.start(),l);t=al(c,Ht)?null:c}else if(t instanceof gt){let l=Ym(i.reverse());i=new ye(l,i.end());let c=new gt([...t.controls.slice(0,-1),l]);t=al(c,Ht)?null:c}else if(t instanceof Le){let l=Ym(i.reverse());i=new ye(l,i.end());let c=Le.build5(t.start(),l,t.sweepAngle);t=al(c,Ht)?null:c}else throw new Error("not supported")}function o(){if(r instanceof ye){let l=Ym(i);i=new ye(i.start(),l);let c=new ye(l,r.end());r=al(c,Ht)?null:c}else if(r instanceof gt){let l=Ym(i);i=new ye(i.start(),l);let c=new gt([l,...r.controls.slice(1)]);r=al(c,Ht)?null:c}else if(r instanceof Le){let l=Ym(i);i=new ye(i.start(),l);let c=Le.build5(l,r.end(),r.sweepAngle);r=al(c,Ht)?null:c}else throw new Error("not supported")}return{rebuildPrevPt:t,rebuildNextPt:r,rebuildLinkLine:i}}function AM(e,t,i){if(e instanceof ye||t.distance2(i)<=Ca)return new ye(t,i);if(e instanceof Le)return Le.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof gt){let r=e.getPercent(t,Ht),n=e.getPercent(i,Ht);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}var GK=class{constructor(e){this.pt=e}connect(e){this.prev=e,e.next=this}};function e2(e){let t=o1(),i;if(e instanceof Ci){let r=Sd(e);if(r===null)return null;i=r}else if(e instanceof os){let r=e.items.map(n=>e2(n)).filter(n=>n!==null);if(r.length===0)return null;i=new os(r)}else{let r=e.items.map(n=>e2(n)).filter(n=>n!==null);if(r.length===0)return null;i=new On(r)}return vu.preprocessPolyline+=xd(t),i}var vu={addDocShapes2RTree:0,getPour:0,prepare:0,getSinglePourLayerPolyline:0,combindOutlines:0,mergeSameNet:0,run:0,end:0,deSelfIntersection:0,changeDirect:0,extend:0,preprocessPolyline:0,runBoolean:0,IntersectionSeeker:0,BooleanTools:0,totalBool:0};function o1(){return{timeIndex:Object.assign({},vu),start:performance.now()}}function CM(e){return Object.values(e).reduce((t,i)=>t+i,0)}function xd(e){return performance.now()-e.start-(CM(vu)-CM(e.timeIndex))}function Ps(e,t,i,r){let n=Wi.RED,s=Wi.Golden;function a(){if(!r)return;let d=r.initColor(Wi.Golden);d.addPt(o),d.addPoint(o.end()),r.initColor(Wi.RED).addPt(l),r.draw();debugger}let o=e.getShape(),l=i?t.getShape():t.getShape().reverse(),c=Vt(o,l.start()),u=Vt(l),h=c.cross(u);if(Iu(h,0))if(o instanceof ye)if(l instanceof ye){if(Re.eq(h,0)&&(c.dot(u)>0?!Ct(o.end(),l.start()):!Ct(o.start(),l.start())))throw a(),new Error("line and line");return h<0}else{if(l instanceof Le)return c.cross(l.center.sub(o.start()))<0;if(l instanceof gt){let d=l.getExtremePoints(o),p=d.length?d[0]:Jm(l.controls,o.start());return c.cross(p.sub(o.start()))<0}else throw new Error("not support")}else if(o instanceof Le){if(l instanceof ye)return o.isCCW;if(l instanceof Le){if(l.center.equals1(o.center)&&(c.dot(u)>0?!Ct(o.end(),l.start())&&o.end().sub(l.start()).dot(u)>0:!Ct(o.start(),l.start())&&o.start().sub(l.start()).dot(u)>0))throw a(),new Error("arc and arc");return l.rx>=o.rx||l.center.distance2(o.center)>o.rx2?o.isCCW:!o.isCCW}else throw new Error("not support")}else if(o instanceof gt)if(l instanceof ye){let d=o.getPercent(l.start(),Ht),p=o.clip(d)[1],f=p.getExtremePoints(l);return(f.length?f[0]:Jm(p.controls,l.start())).sub(l.start()).cross(u)<0}else if(l instanceof gt){let d=o.getPercent(l.start(),Ht),p=o.clip(d)[1],f=p.getExtremePoints(new ye(l.start(),l.end())),m=l.getExtremePoints(new ye(p.start(),p.end())),g=f.length?f[0]:Jm(p.controls,l.start()),b=m.length?m[0]:Jm(l.controls,l.start()),y=g.sub(l.start()),E=b.sub(l.start());return y.cross(E)<0}else throw Error("not support");else throw new Error("not support");else return h<0}function Xp(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Le?Nc(s,ti.toRadians(s.endAngle())):s instanceof gt?Q0(s,1):s.end().sub(s.start()).normalize(),l=Vt(a),c=o.dot(l);if(Iu(c,-1))return Ps(e,t,!0,n)?Ps(e,i,r,n)&&Ps(t,i,r,n):Ps(e,i,r,n)||Ps(t,i,r,n);{let u=o.scale(-1).angle(Ie.ORIGIN),h=l.angle(Ie.ORIGIN);u>h&&(u-=n2);let d=(u+h)/2,p=new Ie(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=Vt(f);return p.cross(m)<0?Ps(e,i,r,n):Ps(t,i,r,n)}}function sA(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Le?Nc(s,ti.toRadians(s.endAngle())):s instanceof gt?Q0(s,1):s.end().sub(s.start()).normalize(),l=Vt(a),c=o.dot(l);if(Iu(c,-1))return Ps(e,t,!0,n)?Ps(e,i,r,n)&&Ps(t,i,r,n):Ps(e,i,r,n)||Ps(t,i,r,n);{let u=o.scale(-1).angle(Ie.ORIGIN),h=l.angle(Ie.ORIGIN);u>h&&(u-=n2);let d=(u+h)/2,p=new Ie(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=Vt(f);if(p.cross(m)<0){let g=o.dot(m)<0,b=Aa(g?e.getShape().reverse():e.getShape(),f).state;return b!==3&&b!==4?Ps(e,i,r,n):b===(g?4:3)}else{let g=l.dot(m)<0,b=Aa(g?t.getShape().reverse():t.getShape(),f).state;return b!==3&&b!==4?Ps(t,i,r,n):b===(g?4:3)}}}var UK=(e=>(e[e.NOT_IN=0]="NOT_IN",e[e.IS_IN=1]="IS_IN",e[e.IS_OVERLAP=2]="IS_OVERLAP",e))(UK||{}),YK=(e=>(e[e.AllClear=0]="AllClear",e[e.MapClear=1]="MapClear",e))(YK||{}),wu,Ed=!1;function ol(e,t,i,r,n,s,a,o=i.side===t,l=!0,c){return wu=n,Ed=s,o4(l4(e,t,l,c,a,i,o,r),i,o,r,0)}function bh(e,t,i,r,n,s,a,o=r.side===i){wu=n,Ed=s;let l=c4(e,t,i,new Map,r,o,a),c=l instanceof Array?-1:1;return o4(l,r,o,a,c)}function o4(e,t,i,r,n){for(;e instanceof Array;)n++,e.length===4?e=c4(...e,t,i,r):e=l4(...e,t,i,r);return{...e,existOverlap:n>0}}function l4(e,t,i,r,n,s,a,o){if(t2===-1){o.initColor(Wi.RED).addPt(e.getShape()),o.initColor(Wi.Golden).addPt(t.getShape()),o.draw();debugger}let l=e.getShape(),c=a?t.getShape().reverse():t.getShape(),u=(l instanceof Le?Nc(l,i?c.start().angle(l.center):r?ti.toRadians(l.endAngle()):void 0):l instanceof gt?Vt(l,i?c.start():r?l.end():l.start()):l.end().sub(l.start())).normalize(),h=(c instanceof Le?Nc(c,i?void 0:(r?l.end():l.start()).angle(c.center)):c instanceof gt?Vt(c,i?void 0:r?l.end():l.start()):c.end().sub(c.start())).normalize();if(r===void 0){let f=u.dot(h);if(r=f<0,Iu(f,0))return{state:Ps(e,t,!a,o)?1:0,inter:xh(e,t,s,a,i,r,n)}}else if(r?u.dot(h)>0:u.dot(h)<0)if(i){let f,m=!0;if(l instanceof ye&&Ct(Rc.foot(l,c.start()),r?l.end():l.start()))m=!1;else if(l instanceof Le||l instanceof gt){let g=r?l.reverse():l,b=Aa(c,tK(g,c.start()).reverse()).state;(b===1||b===2)&&(m=!1)}if(m){let g=!r;f=Aa(g?l.reverse():l,c,o).state===(g?4:3)?1:0}else r?f=Xp(e,e.nextSide,t,!a,o)?1:0:f=Xp(e.prevSide,e,t,!a,o)?1:0;return{state:f,inter:xh(e,t,s,a,i,r,n)}}else return r?{state:Ps(e,e.nextSide,!0,o)?0:1,inter:xh(e,t,s,a,i,r,n),isReversed:!0}:{state:Ps(e.prevSide,e,!0,o)?0:1,inter:xh(e,t,s,a,i,r,n),isReversed:!0};let d,p=new Map([[3,4],[4,3],[0,1],[1,0],[2,2]]);if(i)if(e.judgeOverlapMap.has(t)&&!Ed){let f=e.judgeOverlapMap.get(t);d=r?p.get(f.state):f.state}else d=Aa(r?l.reverse():l,c).state,(d===3||d===4)&&e.judgeOverlapMap.set(t,{state:r?p.get(d):d});else{if(t.judgeOverlapMap.has(e)&&!Ed){let f=t.judgeOverlapMap.get(e);d=a?p.get(f.state):f.state}else d=Aa(c,r?l.reverse():l).state,(d===3||d===4)&&t.judgeOverlapMap.set(e,{state:a?p.get(d):d});d=p.get(d)}if(d===1||d===2){let f=a?t.prevSide:t,m=f.inters,g=f.getEnd();for(let b=m.length-1;b>=0;b--){let y=m[b];if(!(f.getShape()instanceof gt)&&!Ct(g,y.coord))break;if(y===s)return{state:2,inter:xh(e,t,s,a,i,r,n)}}}if(d===3||d===4)return{state:d===(r?4:3)?1:0,inter:xh(e,t,s,a,i,r,n)};if(n.has(e)?n.get(e).mapSideList.push(t):n.set(e,{sideIsReversed:r,mapSideList:[t]}),n.has(t)?n.get(t).mapSideList.push(e):n.set(t,{sideIsReversed:a,mapSideList:[e]}),d===2)return r?[e.prevSide,e,a?t.prevSide:t.nextSide,n]:[e,e.nextSide,a?t.prevSide:t.nextSide,n];if(d===0)return[r?e.prevSide:e.nextSide,t,!1,r,n];if(d===1)return[e,a?t.prevSide:t.nextSide,!0,r,n];throw Error("not support")}function xh(e,t,i,r,n,s,a){if(Ed)return null;let o=e.getShape(),l=r?t.getShape().reverse():t.getShape(),c=r;if(!n){let p=t;t=e,e=p,r=s,i=i.getBindedInter()}let u=p=>!(n?s:c)&&Ct(p,e.prevSide.getEnd())?e.prevSide:e;if(r){let p=t.inters;for(let f=0;f<p.length;f++){let m=p[f];if(m.isInvalid&&s===void 0)continue;if(m===i&&Ct(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,b=u(m.coord);if(g===b&&h(m))return d(m)}for(;;){t=t.nextSide;let f=t.inters;for(let m=0;m<f.length;m++){let g=f[m];if(g===i)return n?g:g.getBindedInter();if(a.has(t)){let b=g.getBindedInter().side;if(a.get(t).mapSideList.includes(b)||Ct(g.coord,b.getEnd())&&a.get(t).mapSideList.includes(b.nextSide))return d(g);if(a.has(b)){let y=t.getShape().reverse(),E=Vt(y,g.coord).dot(Vt(b.getShape(),g.coord))<0,S=E?b.getShape().reverse():b.getShape(),w=Aa(y,E?QI(S,g.coord,S.end()):QI(S,S.start(),g.coord)).state;if(w===1||w===2)return d(g)}else a.has(b.nextSide)}else if(g.side===i.side&&h(g))return d(g)}}}else{let p=t.inters;for(let f=p.length-1;f>=0;f--){let m=p[f];if(m.isInvalid&&s===void 0)continue;if(m===i&&Ct(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,b=u(m.coord);if(g===b&&h(m))return d(m)}for(;;){t=t.prevSide;let f=t.inters;for(let m=f.length-1;m>=0;m--){let g=f[m];if(g===i)return n?g:g.getBindedInter();if(a.has(t)){let b=g.getBindedInter().side;if(a.get(t).mapSideList.includes(b)||Ct(g.coord,g.getBindedInter().side.getEnd())&&a.get(t).mapSideList.includes(b.nextSide))return d(g);if(!a.has(b)&&a.has(b.prevSide)){let y=t.getShape().reverse(),E=Vt(y,g.coord).dot(Vt(b.getShape(),g.coord))<0;if(a.has(b.prevSide)){let S=E?b.getShape().reverse():b.getShape(),w=Aa(t.getShape(),QI(S,g.coord,S.end())).state;if(w===1||w===2)return d(g)}}}else if(g.side===i.side&&h(g))return d(g)}}}function h(p){if(p.isInvalid||p.getBindedInter().side!==(Ct(p.coord,e.prevSide.getEnd())?e.prevSide:e))return!1;let f;if(n){if(Ct(p.coord,l.start()))return!0;f=Aa(s?o.reverse():o,m(l)).state}else{if(Ct(p.coord,s?o.end():o.start()))return!0;f=Aa(l,m(s?o.reverse():o)).state}return f===2||f===1;function m(g){if(g instanceof ye)return Ct(p.coord,g.end())?g:g.cutLine(p.coord);if(g instanceof Le)return Le.build2(g.center,g.startAngle,p.coord.angleD(g.center),g.rx,g.ry,g.isCCW?1:0);if(g instanceof gt)return g.clip(g.getPercent(p.coord,Ht))[0];throw new Error("not supported operation")}}function d(p){let f=i.getBindedInter(),m=i.side,g=f.side,b=i===p,y=i;if(r){let E=i.getIndex()-1;for(;m;){let S=m.inters;for(;E>=0;E--)if(i=S[E],i===p){b||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(wu===0)!i.isInvalid&&(!Ct(i.coord,p.coord)||i.side===p.side&&i.getBindedInter().side===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(wu===1){if(i.isInvalid)continue;let w=i.getBindedInter().side;a.has(m)&&a.get(m).mapSideList.includes(w)&&(i.setIsInvalid(),i.isDealed(),y=i)}m=m==null?void 0:m.prevSide,E=(m==null?void 0:m.inters.length)-1}}else{let E=i.getIndex()+1;for(;m;){let S=m.inters;for(;E<S.length;E++){i=S[E];let w=i.getBindedInter();if(i===p){b||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(wu===0)!i.isInvalid&&(!Ct(i.coord,p.coord)||m===p.side&&(Ct(w.side.getEnd(),i.coord)?w.side.nextSide:w.side)===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(wu===1){let x=w.side;a.has(m)&&a.get(m).mapSideList.includes(x)&&(i.setIsInvalid(),i.isDealed(),y=i)}}m=m==null?void 0:m.nextSide,E=0}}if(wu===0&&!Ct(f.coord,p.coord))if(n?a.has(g)?a.get(g).sideIsReversed:s:c){let E=f.getIndex()-1;for(;g;){let S=a.has(g),w=g.inters;for(;E>=0;E--){if(f=w[E],f===p.getBindedInter()){g=null;break}f.isInvalid||!S||(!Ct(f.coord,p.getBindedInter().coord)||f.side===p.side&&f.getBindedInter().side===p.getBindedInter().side)&&(f.setIsInvalid(),f.isDealed())}g=g==null?void 0:g.prevSide,E=(g==null?void 0:g.inters.length)-1}}else{let E=f.getIndex()+1;for(;g;){let S=g.inters,w=a.has(g);for(;E<S.length;E++){if(f=S[E],f===p.getBindedInter()){g=null;break}let x=Ct(g.getEnd(),f.coord)?a.has(g.nextSide):!1;f.isInvalid||!(w||x)||(!Ct(f.coord,p.getBindedInter().coord)||f.side===p.side&&f.getBindedInter().side===p.getBindedInter().side)&&(f.setIsInvalid(),f.isDealed())}g=g==null?void 0:g.nextSide,E=0}}return n?y:y.getBindedInter()}}function c4(e,t,i,r,n,s,a){let o=e.getShape(),l=t.getShape(),c=s?i.getShape().reverse():i.getShape(),u=(o instanceof Le?Nc(o,c.start().angle(o.center)):o instanceof gt?Vt(o,c.start()):o.end().sub(o.start())).normalize(),h=(l instanceof Le?Nc(l,c.start().angle(l.center)):l instanceof gt?Vt(l,c.start()):l.end().sub(l.start())).normalize(),d=u.dot(h);if(Iu(d,-1)){let p=s?i.getShape().reverse():i.getShape(),f=Vt(p).normalize(),m=u.add(h.scale(-1)).normalize().dot(f),g=Aa(o.reverse(),l,a).state;if(m>-.9&&(g===3||g===4))return{state:g===4?0:1,inter:xh(t,i,n,s,!0,!1,r)};let b=ol(e,i,n,a,wu,Ed,r.size===0?new Map:r,s);return b.state===2?b:g===4?b.state===0||b.inter!==n?b:ol(t,i,n,a,wu,Ed,r.size===0?new Map:r,s):b.state===1||b.inter!==n?b:ol(t,i,n,a,wu,Ed,r.size===0?new Map:r,s)}else{let p=u.scale(-1).angle(Ie.ORIGIN),f=h.angle(Ie.ORIGIN);p>f&&(p-=n2);let m=(p+f)/2,g=new Ie(Math.cos(m),Math.sin(m)),b=Vt(c).normalize(),y=b.angle(Ie.ORIGIN),E=p<y&&y<f&&o instanceof ye&&l instanceof ye&&c instanceof ye;if(g.cross(b)<=0){if(u.scale(-1).dot(b)<0){let S;return n.coord.equals1(c.start())?S=Vt(o,n.coord).dot(Vt(c,n.coord))<0:c instanceof ye&&(S=Vt(o,o.end()).dot(c.direct)<0),{state:Xp(e,t,i,!s,a)?1:0,inter:xh(e,i,n,s,!0,S,r)}}return E&&o.distance2(c.start())>Ca?[t,i,!0,void 0,r]:[e,i,!0,void 0,r]}else return h.dot(b)<=0?{state:Xp(e,t,i,!s,a)?1:0,inter:xh(t,i,n,s,!0,void 0,r)}:E&&l.distance2(c.start())>Ca?[e,i,!0,void 0,r]:[t,i,!0,void 0,r]}}var t2=0;function VK(e,t,i,r){let n=t.getBindedInter(),s=t.side,a=n.side,o=s.getShape(),l=a.getShape();if(r&&(t2++,t2===-1)){r.initColor(Wi.RED).addPt(o),r.initColor(Wi.Golden).addPt(l),r.draw();debugger}let c=0,u=!1;if(e===-1){let I=bh(s,s.nextSide,a,n,c,u,r),A=I.state!==0;if(I.state===2){let R=Vt(o,t.coord).add(Vt(s.nextSide.getShape(),t.coord)).normalize(),M=Vt(l,t.coord).add(Vt(a.nextSide.getShape(),t.coord)).normalize();return x(A,R.dot(M)>0)}let O=bh(s,s.nextSide,a.nextSide,n,c,u,r);return I.state!==O.state?(w(I,O),1):x(A,I.state!==bh(a,a.nextSide,s,t,c,!0,r).state,I.inter,O.inter)}if(e===1){let I=ol(s,a,n,r,c,u,new Map),A=I.state!==0;if(I.state===2)return x(A,Vt(o,t.coord).dot(Vt(l,t.coord))>0);let O;if(I.isReversed&&I.existOverlap&&Ct(I.inter.coord,a.getEnd())&&I.inter.getBindedInter().side!==s){let F=I.inter.getBindedInter().side;if(F===s.nextSide)O={state:Xp(s,F,a.nextSide,!0,r)?1:0,inter:n};else if(F===s.prevSide){if(O={state:Xp(F,s,a.nextSide,!0,r)?1:0,inter:I.inter},I.state===O.state&&t!==I.inter){let G=Vt(l,t.coord),V=Vt(a.nextSide.getShape(),t.coord),q=Vt(F.getShape(),t.coord);return x(A,G.add(V).dot(q)>0,I.inter,O.inter)}}else O=ol(s,a.nextSide,n,r,c,u,new Map)}else O=ol(s,a.nextSide,n,r,c,u,new Map);if(I.state!==O.state)return w(I,O),1;let R=Vt(l,t.coord),M=Vt(a.nextSide.getShape(),t.coord);if(Iu(R.dot(M),-1)){let F=Ps(a,a.nextSide,!0,r);return x(A,I.state!==ol(a.nextSide,s,t,r,c,!0,new Map,F?!A:A,!1).state,I.inter,O.inter)}else{let F=Vt(o,t.coord);return x(A,R.add(M).dot(F)>0,I.inter,O.inter)}}if(!(o instanceof gt||l instanceof gt))return 1;let h=Vt(o,t.coord),d=Vt(l,t.coord),p,f;if(l instanceof ye)p=new ye(t.coord,l.start()),f=new ye(t.coord,l.end());else if(l instanceof Le){let I=t.coord.angleD(l.center);p=Le.build2(l.center,I,l.startAngle,l.rx,l.ry,l.isCCW?0:1),f=Le.build2(l.center,I,l.endAngle(),l.rx,l.ry,l.isCCW?1:0)}else if(l instanceof gt){let I=l.getPercent(t.coord,Ht);[p,f]=l.clip(I),p=p.reverse()}else throw new Error("not support");let m=h.dot(d)>0,g,b;m?(g=Aa(o.reverse(),p).state,b=Aa(o,f).state):(g=Aa(o,p).state,b=Aa(o.reverse(),f).state);let y;g===0?y=ol(m?s.prevSide:s.nextSide,a,n,r,c,u,new Map,!0,!1,m):g===1?y=ol(s,a.prevSide,n,r,c,u,new Map,!0,!0,m):g===2?m?y=bh(s.prevSide,s,a.prevSide,n,c,u,r,!0):y=bh(s,s.nextSide,a.prevSide,n,c,u,r,!0):m?g===3?y={inter:n,state:0}:y={inter:n,state:1}:g===3?y={inter:n,state:1}:y={inter:n,state:0};let E=y.state!==0;if(y.state===2)return x(E,m);let S;if(b===0?S=ol(m?s.nextSide:s.prevSide,a,n,r,c,u,new Map,!1,!1,!m):b===1?S=ol(s,a.nextSide,n,r,c,u,new Map,!1,!0,!m):b===2?m?S=bh(s,s.nextSide,a.nextSide,n,c,u,r,!1):S=bh(s.prevSide,s,a.nextSide,n,c,u,r,!1):m?b===3?S={inter:n,state:1}:S={inter:n,state:0}:b===3?S={inter:n,state:0}:S={inter:n,state:1},y.state===S.state)return y.inter===S.inter?(t.setIsInvalid(),0):x(E,m,y.inter,S.inter);return w(y,S),1;function w(I,A){let O=I.state!==0;if(I.inter===A.inter){t.setOutToIn(O);return}else Vm(I.inter,A.inter,!0),Vm(A.inter,I.inter,!1);let R=[];if(e===-1){let F=Vt(o,t.coord),G=Vt(s.nextSide.getShape(),t.coord),V=Vt(l,t.coord),q=Vt(a.nextSide.getShape(),t.coord);R.push(F.dot(V)),R.push(F.dot(q)),R.push(G.dot(V)),R.push(G.dot(q))}else{let F=Vt(o,t.coord);R.push(Vt(l,t.coord).dot(F)),R.push(Vt(a.nextSide.getShape(),t.coord).dot(F))}if(R.reduce((F,G)=>Math.abs(F)>Math.abs(G)?F:G,0)>0)if(i===1||i===0||i===2||i===3)t.setOutToIn(O);else throw new Error("not support");else if(i===1)M(!O);else if(i===0||i===2||i===3)M(O);else throw new Error("not support");function M(F){t.setIsInvalid();let G=(F?I:A).inter;delete G.isInvalid,delete G.getBindedInter().isInvalid,G.setOutToIn(!O)}}function x(I,A,O,R){if(O===R){if(t.side.outline.inters.find(G=>!G.isInvalid&&G!==t&&Ct(G.coord,t.coord)))return t.setIsInvalid(),0;let M=new Eh(t.coord,s,r),F=new Eh(t.coord,a,r);return M.bind(F),A?s.inters.splice(t.getIndex(),0,M):s.inters.splice(t.getIndex()+1,0,M),a.inters.splice(t.getBindedInter().getIndex(),0,F),M.setOutToIn(I),t.setOutToIn(!I),M.isDealed(),s.inters.forEach((G,V)=>G.setIndex(V)),a.inters.forEach((G,V)=>G.setIndex(V)),2}else{let M=function(){let F=O.getBindedInter(),G=R.getBindedInter();delete O.isInvalid,delete F.isInvalid,delete R.isInvalid,delete G.isInvalid,O.setOutToIn(!I),R.setOutToIn(I),Vm(O,R,!0),Vm(R,O,!1),Vm(F,G,A),Vm(G,F,!A)};if(t.setIsInvalid(),A){if(i===1||i===0||i===2||i===3)return M(),2;throw new Error("not support")}else{if(i===1)return I?0:(M(),2);if(i===0||i===2||i===3)return I?(M(),2):0;throw new Error("not support")}}}}function Vm(e,t,i){let{judge:r,changeNum:n}=a(),s=e.getIndex();for(let o=s+n,l=e.side.inters;r(o);o+=n){if(l[o].isInvalid)continue;if(!Ct(l[o].coord,e.coord))break;l[o].setIndex(s),l[s].setIndex(o);let c=l[o];l[o]=l[s],l[s]=c,s=o}function a(){let o=e.side===t.side;if(i){let l=o?t.getIndex():e.side.inters.length;return{judge:c=>c<l,changeNum:1}}else{let l=o?t.getIndex()+1:0;return{judge:c=>c>=l,changeNum:-1}}}}var DM=0,Eh=class{constructor(e,t,i){this.id=DM++,this.coord=e,this.side=t,i&&(this.id=DM++,this.drawDebug=i);let r=new Mo;r.ext2(e),this._bbox=r.build1()}bbox(){return this._bbox}resetVisitStatus(){this.visited=!1,this.bindedInter.visited=!1}isDealed(){this.dealed=!0,this.getBindedInter().dealed=!0}setOutToIn(e){this.outToIn=e,this.bindedInter.outToIn=!e}setIsInvalid(){this.isInvalid=!0,this.getBindedInter().isInvalid=!0}getBindedInter(){return this.bindedInter}bind(e){this.bindedInter=e,e.bindedInter=this}setIndex(e){this.index=e}isSorted(){return this.index!==void 0}getIndex(){return this.index}getVisited(){return this.visited}visitSelf(){this.visited=!0}visit(){this.visited=!0,this.bindedInter.visited=!0}getPrevPoint(){let e=this.getIndex(),t=this.side.getStart();return e&&(t=this.side.inters[e-1].coord),t}getTangent(){let e=this.side.getShape();if(e instanceof ye)return e.end().sub(e.start());if(e instanceof Le){let t=this.coord.angle(e.center);return e.isCCW?t+=qE:t-=qE,new Ie(Math.cos(t),Math.sin(t))}else{if(e instanceof gt)return Q0(e,e.getPercent(this.coord,Ht));throw new Error("not support")}}findStartInter(){return this.outToIn===void 0?this.getTangent().cross(this.bindedInter.getTangent())>0?this:this.bindedInter:this.outToIn?this:this.bindedInter}run(){let e=[],t=this,i;if(this.drawDebug){aA++;let r=aA===-1,n=this.drawDebug.initColor(Wi.RED);if(r){this.drawDebug.draw();debugger}i=s=>{if(e.push(s),r){n.addPt(e[e.length-1]),this.drawDebug.draw();debugger}}}else i=r=>e.push(r);for(;!t.visited;){let r=function(o,l){if(Re.eq(o.distance2(l),0))return;let c=a1.rebuild(s.getShape(),o,l);if(!c)return!0;i(c)};t.visit();let n=t.getIndex(),s=t.side,a=s.inters[n+1];for(;a!=null&&a.isInvalid;)a=s.inters[a.getIndex()+1];if(a)r(t.coord,a.coord),t=a.bindedInter;else{let o=r(t.coord,s.getEnd()),l=t.coord;for(s=s.nextSide,t=null;;){for(let c of s.inters)if(!c.isInvalid){t=c.bindedInter;break}if(t)break;o?(r(l,s.getEnd()),o=!1):i(s.getShape()),s=s.nextSide}o?(Re.eq(l.distance2(t.coord),0)?r(l,s.getEnd()):r(l,t.coord),o=!1):Re.eq(s.getEnd().distance2(t.coord),0)?i(s.getShape()):r(s.getStart(),t.coord)}}if(t!==this)throw this.drawDebug&&console.log(JSON.stringify({runId:aA,handleId:t2,boolId:z0})),new Error("inter !== this");return Sd(Ci.build7(e))}},aA=0,oA=class IA{constructor(t,i,r,n,s){this.inters=[],this.allInterIsInvalid=!0,this.isVisit=!1,this.sides=t,this.isGroup1=r,this.isOutside=n,this.finalIsOutside=n,this.polyline=i,s&&(this.polygon=s),t.forEach(a=>a.outline=this)}static build(t,i,r,n,s){let a=t.primitives.map(l=>new a1(l,n)),o=a[a.length-1];return a.forEach(l=>{o.connect(l),o=l}),s?new IA(a,t,i,r,s):new IA(a,t,i,r)}setFinalIsOutSide(t){this.finalIsOutside=t}startAndEndIsSameOutsideFlag(){return this.isOutside===this.finalIsOutside}get hasInter(){return!!this.interOutlines}isAllInterIsInvalid(){return this.allInterIsInvalid}setAllInterIsInvalidToFalse(){this.allInterIsInvalid=!1}resetVisited(){this.isVisit=!1}intersect(t,i){if(!(t.interOutlines&&t.interOutlines===this.interOutlines))if(t.interOutlines)if(this.interOutlines){let r,n;this.interOutlines.length>t.interOutlines.length?(r=this.interOutlines,n=t.interOutlines):(r=t.interOutlines,n=this.interOutlines),n.forEach(s=>{r.push(s),s.interOutlines=r}),i.delete(n)}else t.interOutlines.push(this),this.interOutlines=t.interOutlines;else this.interOutlines?(this.interOutlines.push(t),t.interOutlines=this.interOutlines):(t.interOutlines=this.interOutlines=[this,t],i.add(this.interOutlines))}isContain(t){if(!this.polyline.bbox().extendOfSize(Ht).isContainsBBox(t.polyline.bbox()))return!1;let i=t.polyline.primitives[0].start();if(t.hasInter&&t.isAllInterIsInvalid()){let r=t.inters[0];r.getBindedInter().side.outline!==this?i=r.side.getCenterPoint():i=r.side.getCenterPoint(r.coord)}return!!this.polyline.getWindingNum(i)}isInternally(t){return!!this.polyline.getWindingNum(t)}isEqual(t){return this.polyline===t.polyline}bbox(){return this.polyline.bbox()}reverse(){this.sides.reverse();let t=this.sides[this.sides.length-1];this.sides.forEach(i=>{i.reverse(),t.connect(i),t=i})}returnPolyline(){let t=this.sides.map(r=>r.getShape()),i=this.polyline.primitives;if(this.sides.length===i.length){let r=new Set(i);if(!t.some(n=>!r.has(n)))return this.polyline}return Ci.build7(t)}};function _M(e,t,i){let r=[];return e.forEach(n=>n.forEach(s=>{if(s.hasInter&&!s.isAllInterIsInvalid())return;let a=s.bbox(),o=t.search(a.extendOfSize(Ht)).filter(l=>l.bbox().extendOfSize(Ht).isContainsBBox(a)).sort((l,c)=>l.bbox().area()-c.bbox().area());for(let l of o)if(l.isContain(s)){let c=i(!s.isOutside,l.isOutside),u=i(s.isOutside,l.isOutside);c!==u&&(r.push(s),s.setFinalIsOutSide(!c));return}i(s.isOutside,!1)!==i(!s.isOutside,!1)&&r.push(s)})),r}function HK(e,t,i){let r;switch(i){case 0:r=(o,l)=>o&&l;break;case 1:r=(o,l)=>o||l;break;case 2:r=(o,l)=>o&&!l;break;case 3:r=(o,l)=>o&&!l||!o&&l;break;default:throw Error("not support the rule")}let n=new e1(10),s=new e1(10);e.forEach(o=>o.forEach(l=>n.add(l))),t.forEach(o=>o.forEach(l=>s.add(l)));let a=_M(e,s,r);return _M(t,n,(o,l)=>r(l,o)).forEach(o=>a.push(o)),a}var jK=class{constructor(e){this.roots=[],this.nodes=e.sort((t,i)=>t.bbox().minX-i.bbox().minX).map(t=>new zK(t)),this.nodes.forEach((t,i)=>{t.visit()&&(this.roots.push(t),this.build(i))})}build(e){let t=this.nodes[e];for(let i=e+1,r=this.nodes.length;i<r;i++){let n=this.nodes[i];if(t.key.bbox().maxX<n.key.bbox().minX)break;n.getIsVisit()||t.isContain(n)&&(n.visit(),t.addChild(n),this.build(i))}}getPolygons(){let e=[];return this.roots.forEach(t=>t.getPolygons().forEach(i=>e.push(i))),e}},zK=class{constructor(e){this.children=[],this.isVisit=!1,this.key=e}getIsVisit(){return this.isVisit}isContain(e){return this.key.isContain(e.key)}addChild(e){this.children.push(e)}getPolygons(){let e=[];return this.getPolylineList(e),e.map(t=>{let i=t[0].polygon;if(i&&i.items.length===t.length){let r=t.map(s=>s.returnPolyline()),n=new Set(i.items);return r.some(s=>!n.has(s))?new os(r):i}else return new os(t.map(r=>r.returnPolyline()))})}getPolylineList(e,t){t?(t.push(this.key),t=null):(t=[this.key],e.push(t)),this.children.forEach(i=>i.getPolylineList(e,t))}visit(){return this.isVisit?!1:(this.isVisit=!0,!0)}};function PM(e){let t="";return e.items.forEach((i,r)=>{let n="$";if(i.items.forEach((s,a)=>{let o="[";if(s.primitives.forEach((l,c)=>{let u="";if(l instanceof ye)u=`Line,${l.start().x},${l.start().y},${l.end().x},${l.end().y}`;else if(l instanceof Le)u=`Arc,${l.center.x},${l.center.y},${l.startAngle},${l.sweepAngle},${l.rx}`;else if(l instanceof gt)u=`Bezier,${l.controls.map(h=>`${h.x},${h.y}`).join(",")}`;else throw new Error("not supported");if(c===s.primitives.length-1){o+=`${u}]`;return}o+=`${u},`}),a===i.items.length-1){n+=`${o}$`;return}n+=`${o}_`}),r===e.items.length-1){t+=`${n}`;return}t+=`${n}^`}),console.log(t),t}function LM(e){let t=e.split("^"),i=[];return t.forEach(n=>{let s=/\$(.*?)\$/,a=n.match(s)[1].split("_"),o=[];a.forEach(c=>{let u=/\[(.*?)\]/,h=c.match(u)[1].split(","),d=[],p=[];for(let m=0;m<h.length;m++){let g=h[m];if(g==="Line"||g==="Arc"||g==="Bezier"){if(d.length){let b=r(d);p.push(b),d.length=0}d.push(g);continue}d.push(Number(g))}d.length&&(p.push(r(d)),d.length=0);let f=Ci.build7(p);o.push(f)});let l=new os(o);i.push(l)}),new On(i);function r(n){let s=n[0];if(s==="Line")return new ye(new Ie(n[1],n[2]),new Ie(n[3],n[4]));if(s==="Arc")return Le.build3(new Ie(n[1],n[2]),n[3],n[4],n[5],n[5]);if(s==="Bezier"){let a=[];for(let o=1;o<n.length;o+=2)a.push(new Ie(n[o],n[o+1]));return new gt(a)}else throw new Error("not support")}}var XK=class{constructor(e=1){this.group1Str="$[Line,20193.777980000017,4122.200439600661,20193.77082,4211.848760073709,Arc,20193.972672902382,4211.8487570980205,179.99915535323618,-89.99540000050294,0.2018529024026465,Line,20193.972659672283,4212.050609999989,20193.972660393258,4212.039610000013,Arc,20193.97217289501,4211.848257065248,89.85403133887164,89.99540000041924,0.19135355574930143,Line,20193.78082,4211.848759926291,20193.78897999998,4122.200440479205,Line,20193.78897999998,4122.200440479205,20193.777980000017,4122.200439600661]$",this.group2Str="$[Arc,20209.72784128151,4122.2007625157785,258.46768032837986,-75.66780748375947,4.138846238512183,Line,20205.593935808283,4121.998590004101,20193.97982992629,4121.998600000001,Arc,20193.97983290198,4122.2004529023825,269.9991553532362,-89.99540000050297,0.20185290240401074,Arc,20193.782979999996,4122.20044,180.00375535340328,-180.0000000000027,0.004999999999025513,Arc,20193.979332869207,4122.200952909754,180.15347936671733,89.99540000008247,0.19135355575111057,Line,20193.97983008845,4122.009599999999,20205.603694309226,4122.003828485546,Arc,20209.733142304296,4122.194577876843,182.64475341258483,75.73379999998886,4.133851239977064,Line,20208.900400396684,4118.145470939558,20208.902599535475,4118.156248870184,Arc,20206.972515961093,4108.700057667588,78.46393309088245,-78.46759999998636,9.65115405866796,Arc,20216.618669999996,4108.69944,359.99996825446135,-180,0.004999999999200412,Arc,20206.973015966745,4108.699445349495,359.99996822365375,78.46759999998409,9.640654033253735]$^$[Line,20193.997796883676,4095.399470032799,20205.596133314026,4095.4013992171836,Arc,20209.72470159858,4095.1923799234505,177.10172964919312,-75.64935037184974,4.133855965730166,Arc,20209.73000213952,4095.198565517174,101.5415133143569,75.7293000000185,4.128850963459707,Line,20205.605834328744,4095.395161923586,20193.997203529463,4095.389485743675,Arc,20193.994588809255,4095.197684525904,89.21896662213764,4.544099999999517,0.19181903946188483,Arc,20193.981499796217,4095.1977402038,89.85034659953621,89.9999999995926,0.19135044893494071,Arc,20193.78515,4095.19824,0,-180,0.005,Arc,20193.98200016982,4095.1982398301675,179.99995179248322,-89.99999999974185,0.20185016982129908,Arc,20193.981986624152,4095.198185381971,89.9961078637802,-4.487285276547311,0.2019046184835962]$",this.rule=e}getGroup1(){return LM(this.group1Str)}getGroup2(){return LM(this.group2Str)}},lA=new r2(2),j0=class{getUnion(e,t=!0){return t&&(e=e.map(i=>this.asSameSweep([i])[0])),_K(uK,e)}asSameSweep(e){let t=0;return e.forEach(i=>t+=i.area(.01)),t>0?e.map(i=>i.reverse()):e}getSubtraction(e,t){let i=new $0(!1),r=new Z0(YE.rule,lA,i);for(let n of e){let s=YE.weight(0);r.addPolyline(n,s)}for(let n of t){let s=YE.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getIntersection(e,t){let i=new $0(!1),r=new Z0(VE.rule,lA,i);for(let n of e){let s=VE.weight(0);r.addPolyline(n,s)}for(let n of t){let s=VE.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getMutuallyExclusive(e,t){let i=new $0(!1),r=new Z0(tA.rule,lA,i);for(let n of e){let s=tA.weight(0);r.addPolyline(n,s)}for(let n of t){let s=tA.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}},z0=0,cA=!1;function X0(e,t,i,r,n){let s=o1(),a=[],o=[],l=[],c=new Set,u;if(n){if(u=new s1(n),z0++,cA){debugger;cA=!1;let S=new XK;X0(S.rule,S.getGroup1(),S.getGroup2(),r,n)}if(z0===-1||cA){console.table({rule:e,group1:PM(t),group2:PM(i)}),u.clear();let S=u.initColor(Wi.GREEN),w=u.initColor(Wi.WHITE),x=u.initColor(Wi.BLUE),I=u.initColor(Wi.Gray);t.items.forEach(A=>A.items.forEach((O,R)=>{R>0?w.addPly(O):S.addPly(O)})),i.items.forEach(A=>A.items.forEach((O,R)=>{R>0?I.addPly(O):x.addPly(O)})),u.draw();debugger}}let h=t.items.length!==0&&i.items.length!==0?t.bbox().extendOfSize(Ht).intersection1(i.bbox().extendOfSize(Ht)):null;if(h){let S=[],w=[];switch(e){case 0:{for(let x of t.items)x.bbox().isIntersect(h)&&S.push(x);for(let x of i.items)x.bbox().isIntersect(h)&&w.push(x);break}case 1:case 3:{for(let x of t.items)x.bbox().isIntersect(h)?S.push(x):a.push(x);for(let x of i.items)x.bbox().isIntersect(h)?w.push(x):a.push(x);break}case 2:{for(let x of t.items)x.bbox().isIntersect(h)?S.push(x):a.push(x);for(let x of i.items)x.bbox().isIntersect(h)&&w.push(x);break}default:throw new Error("not support")}S.length!==t.items.length&&(t=new On(S)),w.length!==i.items.length&&(i=new On(w))}else{switch(e){case 0:break;case 1:case 3:{t.items.forEach(S=>a.push(S)),i.items.forEach(S=>a.push(S));break}case 2:{t.items.forEach(S=>a.push(S));break}default:throw new Error("not support")}t=new On([]),i=new On([])}y(t,o,!0),y(i,l,!1);let d=e===2||e===3?(S,w)=>Ct(S.getEnd(),w)?S.nextSide:S:(S,w)=>Ct(S.prevSide.getEnd(),w)?S.prevSide:S,p=(S,w,x)=>{if(Ct(S.getEnd(),x)){if(S.inters.findIndex(I=>I.getBindedInter().side===w&&Ct(I.coord,S.getEnd()))===-1)return new Eh(x,S,u)}else return new Eh(x,S,u)},f=e===2||e===3?(S,w,x)=>{if(Ct(S.getStart(),x)){if(S.inters.findIndex(I=>I.getBindedInter().side===w&&Ct(I.coord,S.getStart()))===-1)return new Eh(x,S,u)}else return new Eh(x,S,u)}:p;r.seek(t,i,(S,w,x,I,A,O)=>{let R=o[S][w],M=l[I][A],F=R.sides[x],G=M.sides[O],V=Wl(F.getShape(),G.getShape());if((F.getShape()instanceof gt||G.getShape()instanceof gt)&&V>=4){if(F.getShape()instanceof Le||G.getShape()instanceof Le){let C=function(T,L){let P=!1;for(let B=0;B<L.length;B+=2)Ct(new Ie(L[B],L[B+1]),T)&&(P=!0);P||L.push(T.x,T.y)},N=[oe[0],oe[1]];for(let T=0;T<V;T+=2){let L=new Ie(oe[T],oe[T+1]);for(let P=T+2;P<V;P+=2){let B=new Ie(oe[P],oe[P+1]);if(!Ct(L,B)){C(B,N);break}}}V=N.length,N.forEach((T,L)=>oe[L]=T)}else for(let C=V-2;C>=2;C-=2)for(let N=C-2;N>=0;N-=2)if(Ct(new Ie(oe[C],oe[C+1]),new Ie(oe[N],oe[N+1]))){oe[N]=(oe[C]+oe[N])/2,oe[N+1]=(oe[C+1]+oe[N+1])/2;for(let T=V-3;T>=C;T--)oe[T]=oe[T+2];V-=2;break}}let q=0;if(V===4){let C=function(L){return Ct(F.getEnd(),L)||Ct(F.prevSide.getEnd(),L)||Ct(G.prevSide.getEnd(),L)||Ct(G.getEnd(),L)},N=new Ie(oe[0],oe[1]),T=()=>{let L=new Eh(N,F,u),P=new Eh(N,G,u);L.bind(P),L.setIsInvalid(),L.isDealed(),R.inters.push(L),M.inters.push(P)};if(oe[0]===oe[2]&&oe[1]===oe[3])if(C(N))q=2;else{T();return}}for(;q<V;q+=2){let C=new Ie(oe[q],oe[q+1]),N=F,T=G;if(Ct(N.prevSide.getEnd(),C)&&(N=N.prevSide),T=d(T,C),F!==N&&G!==T){let P=e===2||e===3?G.getEnd():T.getEnd();N.getEnd().distance1(C)<P.distance1(C)?(C=N.getEnd(),Ct(P,C)||(T=G)):(C=P,Ct(N.getEnd(),C)||(N=F))}let L=p(N,T,C);if(L){let P=f(T,N,C);P&&(N.addInter(L),R.inters.push(L),T.addInter(P),M.inters.push(P),L.bind(P),R.intersect(M,c))}}return V},n);let m=E(),g=HK(o,l,e);g.forEach(S=>!S.startAndEndIsSameOutsideFlag()&&S.reverse()),new jK(m.concat(g)).getPolygons().forEach(S=>a.push(S));let b=new On(a);if(u){if(z0===-1){let S=u.initColor(Wi.RED),w=u.initColor(Wi.Golden);a.forEach(x=>{S.addPly(x.items[0]),x.items.slice(1).forEach(I=>w.addPly(I))}),u.draw();debugger;throw new Error}b.id=z0}return vu.BooleanTools+=xd(s),b;function y(S,w,x){S.items.forEach(I=>{let A=[];A.push(oA.build(I.items[0],x,!0,u,I)),I.items.slice(1).forEach(O=>{A.push(oA.build(O,x,!1,u))}),w.push(A)})}function E(){let S=[];return c.forEach(x=>{e===2||e===3?x.forEach(A=>{A.isGroup1||A.reverse(),A.sides.forEach(O=>O.sortInters())}):x.forEach(A=>A.sides.forEach(O=>O.sortInters())),x.map(A=>A.sides.filter(O=>O.inters.length)).flat(2).sort((A,O)=>{let R=A.inters,M=O.inters,F=Ct(R[R.length-1].coord,A.getEnd()),G=Ct(M[M.length-1].coord,O.getEnd());if(F&&G){let V=0,q=0;for(let C=R.length-2;C>=0&&Ct(R[C].coord,A.getEnd());C--)V++;for(let C=M.length-2;C>=0&&Ct(M[C].coord,O.getEnd());C--)q++;return q-V}else return F?-1:1}).forEach(A=>{A.inters.forEach(O=>{if(O.dealed)return;let R=O.side,M=O.getBindedInter().side,F;Ct(R.getEnd(),O.coord)&&Ct(M.getEnd(),O.coord)?F=-1:Ct(R.getEnd(),O.coord)?(F=1,O=O.getBindedInter()):Ct(M.getEnd(),O.coord)&&(F=1);let G=VK(F,O,e,u);O.isDealed(),G&&(R.outline.setAllInterIsInvalidToFalse(),M.outline.setAllInterIsInvalidToFalse())})}),I(x),e===3&&(x.forEach(A=>{A.reverse(),A.sides.forEach(O=>{O.sortInters(),O.inters.forEach(R=>{R.resetVisitStatus()})})}),I(x));function I(A){A.forEach(O=>{O.inters.forEach(R=>{if(R.isInvalid||R.getVisited())return;let M=R.findStartInter(),F=w(e)?M.run():M.getBindedInter().run(),G=O.polyline.primitives;if(F){if(G.length===F.primitives.length){let V=new Set(G);if(!F.primitives.some(q=>!V.has(q))){S.push(O);return}}S.push(oA.build(F,!0,!0,u))}})})}}),S;function w(x){switch(x){case 0:case 2:case 3:return!0;case 1:return!1;default:throw Error("not support the rule")}}}}var BE=/\bstablilizetion\b/.test(self.location.href)||!0,kE={intersect(e,t,i,r){try{return X0(0,e,t,i,r)}catch(n){if(BE){let s=new j0().getIntersection(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new On(s.map(a=>new os(a.items)))}throw n}},union(e,t,i,r){try{return X0(1,e,t,i,r)}catch(n){if(BE){let s=new j0,a=e.items.map(l=>l.items.map(c=>c)).flat(2);t.items.forEach(l=>l.items.forEach(c=>a.push(c)));let o=s.getUnion(a);return new On(o.map(l=>new os(l.items)))}throw n}},diff(e,t,i,r){try{return X0(2,e,t,i,r)}catch(n){if(BE){let s=new j0().getSubtraction(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new On(s.map(a=>new os(a.items)))}throw n}},xor(e,t,i,r){try{return X0(3,e,t,i,r)}catch(n){if(BE){let s=new j0().getMutuallyExclusive(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new On(s.map(a=>new os(a.items)))}throw n}}},WK=class extends Z0{constructor(e,t,i,r,n,s){super(e.rule,r2.DUMMY,t),this.sideGroup1=[],this.sideGroup2=[],this.group1=i,this.group2=r,this.seeker=n,this.addGroup(i,e.weight(0),this.sideGroup1),this.addGroup(r,e.weight(1),this.sideGroup2),this.bus=s}addGroup(e,t,i){if(!e)debugger;e.items.forEach(r=>{let n=[];r.items.forEach(s=>{let a=this.sides.length;this.addPolyline(s,t),n.push(this.sides.slice(a))}),i.push(n)})}seekIntersection(){this.seeker.seek(this.group1,this.group2,(e,t,i,r,n,s)=>{let a=this.sideGroup1[e][t][i],o=this.sideGroup2[r][n][s],l=Wl(a.shape,o.shape);for(let c=0;c<l;c+=2){let u=new Ie(oe[c],oe[c+1]);a.inters.push(u),o.inters.push(u),this.event.onIntersect(u,a,o)}return l},this.bus)}},qK=class extends $0{constructor(e){super(!!e),e&&(this.drawDebug=new s1(e),this.blueDrawing=this.drawDebug.initColor(Wi.BLUE),this.greenDrawing=this.drawDebug.initColor(Wi.GREEN),this.redDrawing=this.drawDebug.initColor(Wi.RED))}onOriginSide(e){super.onOriginSide(e),this.debug&&this.blueDrawing.addPt(e.shape)}onPolylineGroup(e,t){super.onPolylineGroup(e,t),this.debug&&e.items.forEach(i=>this.greenDrawing.addPly(i))}draw(){this.drawDebug.draw()}};function uA(e,t,i,r,n){let s=o1(),a=new qK(n);new WK(e,a,t,i,r,n).simplify();let o=[];a.plGrps.forEach(c=>{let u=c.items.map(h=>e2(h));u[0]&&o.push(new os(u.filter(h=>h)))});let l=new On(o);return vu.BooleanTools+=xd(s),l}var hA=!0,U0={intersect(e,t,i,r){try{return kE.intersect(e,t,i,r)}catch(n){if(hA)throw n;return console.error(n),uA(VE,e,t,i,r)}},union(e,t,i,r){try{return kE.union(e,t,i,r)}catch(n){if(hA)throw n;return console.error(n),uA(hK,e,t,i,r)}},diff(e,t,i,r){try{return kE.diff(e,t,i,r)}catch(n){if(hA)throw n;return console.error(n),uA(YE,e,t,i,r)}},xor(e,t,i,r){return kE.xor(e,t,i,r)}},JK=class{init(e){}seek(e,t,i,r){let n=e.bbox().extendOfSize(5e-6).intersection1(t.bbox().extendOfSize(5e-6));if(!n)return;let s=o1(),a=[];for(let d=0,p=e.items.length;d<p;d++){let f=e.items[d];if(n.isIntersect(f.bbox()))for(let m=0,g=f.items.length;m<g;m++){let b=f.items[m];if(n.isIntersect(b.bbox()))for(let y=0,E=b.primitives.length;y<E;y++){let S=b.primitives[y].bbox();n.isIntersect(S)&&a.push({bbox:S,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let o=a.length;if(o===0){vu.IntersectionSeeker+=xd(s);return}let l=[];for(let d=0,p=t.items.length;d<p;d++){let f=t.items[d];if(n.isIntersect(f.bbox()))for(let m=0,g=f.items.length;m<g;m++){let b=f.items[m];if(n.isIntersect(b.bbox()))for(let y=0,E=b.primitives.length;y<E;y++){let S=b.primitives[y].bbox();n.isIntersect(S)&&l.push({bbox:S,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let c=l.length;if(c===0){vu.IntersectionSeeker+=xd(s);return}if(o<5||c<5){for(let d=0,p=a.length;d<p;d++)for(let f=0,m=l.length;f<m;f++)if(a[d].bbox.isIntersect(l[f].bbox.extendOfSize(1e-5))){let g=a[d],b=l[f];i(g.polygonIndex,g.polylineIndex,g.ptIndex,b.polygonIndex,b.polylineIndex,b.ptIndex)}vu.IntersectionSeeker+=xd(s);return}a.sort((d,p)=>d.bbox.minX-p.bbox.minX),l.sort((d,p)=>d.bbox.minX-p.bbox.minX);let u=0,h=0;for(;u<o&&h<c;)if(a[u].bbox.minX<l[h].bbox.minX){let d=a[u],p=d.bbox;for(let f=h;f<c;f++){let m=l[f],g=m.bbox;if(g.minX>p.maxX+1e-5)break;(p.minY<g.minY?g.minY:p.minY)<(p.maxY<g.maxY?p.maxY:g.maxY)+1e-5&&i(d.polygonIndex,d.polylineIndex,d.ptIndex,m.polygonIndex,m.polylineIndex,m.ptIndex)}u++}else{let d=l[h],p=d.bbox;for(let f=u;f<o;f++){let m=a[f],g=m.bbox;if(g.minX>p.maxX+1e-5)break;(g.minY<p.minY?p.minY:g.minY)<(g.maxY<p.maxY?g.maxY:p.maxY)+1e-5&&i(m.polygonIndex,m.polylineIndex,m.ptIndex,d.polygonIndex,d.polylineIndex,d.ptIndex)}h++}vu.IntersectionSeeker+=xd(s)}},Ha,oa=(Ha=class{static getDebug(){return Ha.drawDebug||(Ha.drawDebug=new s1(Ha.curBus)),Ha.drawDebug}static getDrawing(e=Wi.GREEN){return this.getDebug().initColor(e)}static clearDrawing(){Ha.getDebug().clear()}static drawText(e,t,i=Wi.GREEN){Ha.getDrawing(i).addText(e,t,1.5,.1,!0)}static drawBBox(e,t=Wi.GREEN){if(!e)return;let i=Ha.getDrawing(t),r=new ye(e.UL(),e.UR()),n=new ye(e.UR(),e.LR()),s=new ye(e.LR(),e.LL()),a=new ye(e.LL(),e.UL());i.addPt(r),i.addPt(n),i.addPt(s),i.addPt(a)}static drawPolyType(e,t){let i=Ha.getDrawing(t);if(e instanceof Ci)i.addPly(e);else if(e instanceof os)for(let r of e.items)r instanceof Ci?i.addPly(r):this.drawPolyType(r,t);else if(e instanceof On)for(let r of e.items)this.drawPolyType(r,t)}static translate(e){switch(e){case 0:return"\u2229";case 2:return"-";case 1:return"U";case 3:return"X";default:break}}},Ha.UseRunArrange=!0,Ha.UseOptimizeSplit=!0,Ha.LocalBestThread=4,Ha.HandleDiff=!0,Ha.OcTreeSplitStep=4,Ha.PrintStart=new Ie(150,-200),Ha),Y0=class AA{static getPolyTypeLine(t){let i=[];if(t instanceof Ci)for(let r of t.primitives)i.push(r);else if(t instanceof os)for(let r of t.items)if(r instanceof Ci)for(let n of r.primitives)i.push(n);else{let n=this.getPolyTypeLine(r);for(let s of n)i.push(s)}else if(t instanceof On)for(let r of t.items){let n=this.getPolyTypeLine(r);for(let s of n)i.push(s)}return i}static getPolyTypePolyLine(t){let i=[];if(t instanceof Ci)i.push(t);else if(t instanceof os)for(let r of t.items)if(r instanceof Ci)i.push(r);else{let n=this.getPolyTypePolyLine(r);for(let s of n)i.push(s)}else if(t instanceof On)for(let r of t.items){let n=this.getPolyTypePolyLine(r);for(let s of n)i.push(s)}return i}static getListBBox(t){if(t.length<=0)return;let i=new Mo;for(let r of t){let n=AA.getSingleBBox(r);i.ext1(n)}return i.build1()}static getSingleBBox(t){if(t instanceof Array){let i=new Mo,r=AA.getListBBox(t.slice(1));return i.ext1(r),i.build1()}else return t.bbox()}static doDrawRule(t,i=oa.PrintStart){if(t.length<2)return[i,i,i];let r=5,n=10,s=t[0],a=oa.translate(s),o=[],l=i.y,c=i.x,u=i.x;i=i.add(new Ie(0,-n));for(let p=1;p<t.length;p++){let f=t[p];if(f instanceof Array){i=i.add(new Ie(r,0));let m=this.doDrawRule(f,i);o.push(m[0]),m[1].x<=c&&(c=m[1].x),m[2].x>=u&&(u=m[2].x),i=new Ie(m[2].x+r,i.y)}else o.push(i.clone()),i.x<=c&&(c=i.x),i.x>=u&&(u=i.x),oa.drawText(i,f.name),i=i.add(new Ie(r,0))}let h=0;for(let p of o)h+=p.x;let d=new Ie(h/o.length,i.y+n);oa.drawText(d,"N:"+a);for(let p of o){let f=new ye(p,d),m=new Array;m.push(f);let g=Ci.build1(yA(m));oa.drawPolyType(g,Wi.GREEN)}return[d,new Ie(c,l),new Ie(u,l)]}static drawRule(t,i=oa.PrintStart,r=!1,n){oa.clearDrawing(),this.doDrawRule(t,i),r&&this.doDrawRulePolygon(t,n),oa.getDebug().draw()}static doDrawRulePolygon(t,i){let r=t[0];for(let n=1;n<t.length;n++){let s=t[n];if(s instanceof Array)this.doDrawRulePolygon(s,i);else{let a=i;r===2&&n===1&&(a=Wi.RED),s.name&&oa.drawText(s.bbox().UL(),s.name,a),oa.drawPolyType(s,a)}}}static IsCenterBBoxPointInPolygonType(t,i){let r=t.center();for(let n of i.items)if(n.getOutMostPolyline().getWindingNum(r))return!0;return!1}static KeepBBoxPolygonGroup(t,i){let r=i.bbox().intersection1(t);if(!r)return!1;for(let n of i.items)if(n.bbox().isIntersect(r)){for(let s of n.items)if(s.bbox().isIntersect(r)){for(let a of s.primitives)if(r.isIntersect(a.bbox()))return!0}}return!!this.IsCenterBBoxPointInPolygonType(t,i)}},KK=class Xm{static createNode(t,i,r){let n=t.UL(),s=t.width()/i,a=t.height()/i,o=~~(r/i),l=r-o*i,c=n.x+l*s,u=n.y-(o+1)*a,h=c+s,d=u+a;return new Ta(c,h,u,d)}static ocTreeSplitNode(t,i,r,n,s=2){if(t.length<=r)return t;let a=[],o=s**2,l=new Array(o),c=new Array(o);for(let p=0;p<o;p++)l[p]=new Array(t.length),c[p]=0;let u=i.UL(),h=i.width()/s,d=i.height()/s;for(let p of t){let f=n(p).center(),m=~~((f.x-u.x)/h),g=~~((u.y-f.y)/d)*s+m;try{l[g][c[g]]=p,c[g]+=1}catch{a.push(p)}}for(let p=0;p<l.length;p++){let f=c[p];if(f<=0)continue;let m=l[p].slice(0,f);if(m.length===t.length)return t;let g=Xm.createNode(i,s,p),b=Xm.ocTreeSplitNode(m,g,r,n,s);if(b.length===t.length)return t;a.push(b)}return a}static ocTreeSplitNodeMinIntersect(t,i,r,n){let s=[];if(t.length<=r)return t;let a=3,o=i.LL(),l=i.UR(),c=i.width()/(a+1),u=i.height()/(a+1),h=-(2**32),d=[],p=[];for(let f=1;f<=a;f++)for(let m=1;m<=a;m++){let g=o.x+c*f,b=o.y+u*m,y=[[],[],[],[]],E=new Array(4),S=new Array(4);S[0]=new Ta(o.x,g,b,l.y),S[1]=new Ta(g,l.x,b,l.y),S[2]=new Ta(o.x,g,o.y,b),S[3]=new Ta(g,l.x,o.y,b);for(let A of t){let O=n(A).center(),R=-1,M=-1;O.x===g?R=Math.random()>=.5?1:-1:O.x>g?R=1:O.x<g&&(R=-1),O.y===b?M=Math.random()>=.5?1:-1:O.y>b?M=1:O.y<b&&(M=-1),R===1&&M===1?y[1].push(A):R===1&&M===-1?y[3].push(A):R===-1&&M===-1?y[2].push(A):R===-1&&M===1&&y[0].push(A)}for(let A=0;A<4;A++){let O=y[A];if(O.length<=0)continue;let R=new Mo;for(let M of O)R.ext1(n(M));E[A]=R.build1()}let w=0,x=0;for(let A of E)A&&(w+=A.area());x=w;let I=(A,O)=>{if(!E[A]||!E[O])return 0;let R=E[A].intersection1(E[O]);return R?R.area():0};x-=I(0,1),x-=I(0,2),x-=I(0,3),x-=I(1,2),x-=I(1,3),x-=I(2,3),x/w>=h&&(d=y,p=S)}for(let f=0;f<d.length;f++){let m=d[f];if(m.length<=0)continue;let g=p[f],b;if(m.length===t.length?b=Xm.ocTreeSplitNode(m,g,r,n):b=Xm.ocTreeSplitNodeMinIntersect(m,g,r,n),b.length===t.length)return t;s.push(b)}return s}static ocTreeSplit(t,i,r,n){return Xm.ocTreeSplitNode(t,i,r,n,oa.OcTreeSplitStep)}},$K=class u4{static simplifyRules(t,i){return oa.UseOptimizeSplit&&(t=this.optimizeSplit(t,i)),t}static OcTreeOptimizeSplit(t){let i=t[0];if(i!==1||t.length<=oa.LocalBestThread+1)return t;let r=t.slice(1),n=new Array(r.length);for(let c=1;c<t.length;c++)n[c-1]=c;let s=Y0.getListBBox(r),a=KK.ocTreeSplit(n,s,oa.LocalBestThread,c=>{let u=t[c];return Y0.getSingleBBox(u)}),o=(c,u)=>{if(!(c.length<=0))for(let h of c)if(Array.isArray(h)){let d=[u[0]];o(h,d),u.push(d)}else{let d=t[h];u.push(d)}},l=[i];return o(a,l),l}static optimizeSplit(t,i){let r=t[0];if(r===2){if(oa.HandleDiff){let s=t[1],a;if(Array.isArray(s)){let o=this.optimizeSplit(s,i);if(o.length<=1)return[2];a=CA(o,i)}else a=CA([2,s],i);if(t.length>3){let o;o=[1];for(let l=2;l<t.length;l++){let c=t[l];if(Array.isArray(c)){let u=Y0.getListBBox([...c.slice(1)]);Y0.KeepBBoxPolygonGroup(u,a)&&o.push(c)}else Y0.KeepBBoxPolygonGroup(c.bbox(),a)&&o.push(c)}return o.length<=1?[2,a]:(o=this.optimizeSplit(o,i),o.length>1?[2,a,...o.slice(1)]:[2,a])}else{let o=t[2];if(Array.isArray(o)&&o[0]===1&&o.length>2){let l=o.slice(1);return this.optimizeSplit([2,a,...l],i)}}}else if(t.slice(1).length>2){let s=t[1],a=t.slice(2),o=this.optimizeSplit([1,...a],i);return o.length>1?[2,s,...o.slice(1)]:s}}else if(r===1){if(t.length-1>oa.LocalBestThread){let s=!1;for(let a=1;a<t.length;a++){let o=t[a];if(!Array.isArray(o)){s=!0;break}}s&&(t=u4.OcTreeOptimizeSplit(t))}}else if(r===0&&t.length<=2)return[0];let n=[r];for(let s=1;s<t.length;s++){let a=t[s];if(Array.isArray(a)){let o=this.optimizeSplit(a,i);if(o.length<=1)continue;n.push(o)}else n.push(a)}return n}},ZK=(e=>(e[e.INTERSECT=0]="INTERSECT",e[e.UNION=1]="UNION",e[e.DIFF=2]="DIFF",e[e.XOR=3]="XOR",e))(ZK||{});function W0(e){let t=e[0],i=[t];switch(t){case 0:for(let n=1;n<e.length;n++){let s=e[n];if(Array.isArray(s)&&(s=W0(s),!s))return null;i.push(s)}break;case 1:case 3:for(let n=1;n<e.length;n++){let s=e[n];Array.isArray(s)&&(s=W0(s),!s)||i.push(s)}break;case 2:let r=e[1];if(Array.isArray(r)&&(r=W0(r)),!r)return null;i.push(r);for(let n=2;n<e.length;n++){let s=e[n];Array.isArray(s)&&(s=W0(s),!s)||i.push(s)}break;default:throw new Error("not support boolean rule!")}return i.length===1?null:i}function dA(e,t,i){return Array.isArray(e)?h4(e,t,i):e}function pA(e,t,i,r,n=!0){if(n)for(;e.length>1;){let s,a=[];for(e.length%2===1?(a.push(e[0]),s=1):s=0;s<e.length;s+=2)a.push(t(e[s],e[s+1],i,r));e=a}else for(;e.length>1;){if(e.length===2)return t(e[0],e[1],i,r);e=[t(e[0],e[1],i,r),...e.slice(2)]}return e[0]}function h4(e,t,i,r=!0){let n=new Array(e.length-1);for(let s=1;s<e.length;s++)n[s-1]=dA(e[s],t,i);switch(e[0]){case 0:return pA(n,U0.intersect,t,i);case 1:return pA(n,U0.union,t,i);case 2:let s=pA(n.slice(1),U0.union,t,i);return s?U0.diff(n[0],s,t,i):n[0];case 3:let a=dA(e[1],t,i);for(let o=2;o<e.length;o++)a=U0.xor(a,dA(e[o],t,i),t,i);return a;default:throw new Error("not support boolean rule! "+e[0])}}function d4(e){let t=[e[0]];for(let i=1;i<e.length;i++){let r=e[i];if(Array.isArray(r)){let n=d4(r);Array.isArray(n)?n.length>1&&t.push(n):t.push(n)}else{let n=e2(r);n!==null&&t.push(On.build(n))}}return t}function QK(e,t){oa.curBus=t,e=d4(e);let i;return oa.UseRunArrange?i=$K.simplifyRules(e,t):i=W0(e),i.length<=1?new On([]):CA(i,t)}function CA(e,t,i=!0){if(!e||e.length===1)return new On([]);let r=e,n=new JK,s=[];function a(o){for(let l=1;l<o.length;l++){let c=o[l];Array.isArray(c)?a(c):s.push(c)}}return a(r),n.init(s),h4(r,n,t,i)}var FE=new Error("list is empty"),GE=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},e$=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},t$=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},i$=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw FE;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw FE;return this.remove(e),e.item}addLast(e){if(this.first===null||this.last===null){let t=new GE(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new GE(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw FE;return this.first.item}getLast(){if(this.last===null)throw FE;return this.last.item}insertAfter(e,t){let i=new GE(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new GE(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new e$(this.first)}listIterator(){return new t$(this.first)}toArray(){let e=new Array,t=this.first;for(;t!=null;)e.push(t.item),t=t.next;return e}},jE=class{constructor(e){this.inters=[],e&&(this.inters=e)}addInter(e){this.inters.push(e),e.group=this}findInter(e){let t=this.inters.find(i=>Ct(i.coord,e.coord));return t&&this.inters.find(i=>i.side===e.side)&&e.visitSelf(),t}getOutInter(e){let t=this.inters.filter(i=>!i.getVisited());if(t.length!==0)return t.length===1?t[0]:t.reduce((i,r)=>{if(!i||i.side.getShape()===e)return r;if(r.side.getShape()===e)return i;let n=i.coord,s=Vt(e,n),a=Vt(i.side.getShape(),n),o=Vt(r.side.getShape(),n);return s.dot(a)>s.dot(o)?i:r},void 0)}getEntryInter(){}},fA=0;function p4(e,t){let i=e.primitives[0];if(e.primitives.length===1&&i instanceof Le&&Math.abs(i.sweepAngle)===360)return[e];let r=o1();fA++;let n,s=h$(e);if(s.length===0)return[];let a=s$(s);if(fA===-1){n=new s1(t);let u=n.initColor(Wi.BLUE);s.forEach(d=>u.addPt(d.getShape()));let h=n.initColor(Wi.GREEN);a.forEach(d=>h.addPoint(d.coord)),n.draw();debugger;throw new Error}if(a.length===0)return[Ci.build7(s.map(u=>u.getShape()))];a$(a);let o=[],l=!1;try{c$(a,n)}catch(u){u.customType==="IS_OVERLAP"?(l=!0,o=new j0().getUnion([e]).map(h=>h.items).flat(2)):console.error(u)}if(l)return o;let c=l$(a);if(!c.length)return[Ci.build7(s.map(u=>u.getShape()))];if(o=r$(c,n),o.length===0)return console.warn("=====deSelfIntersection=====",fA),[];if(n)throw o.forEach(u=>{n.initColor(Wi.WHITE).addPly(u),n.draw();debugger}),new Error;return vu.deSelfIntersection+=xd(r),o}function r$(e,t){let i=[];return e.forEach(r=>{let n=r;r.inters.forEach(s=>{if(s.getVisited())return;let a=[],o=[],l;if(t){debugger;let u=t.initColor(Wi.RED);l=h=>{a.push(h),u.addPt(a[a.length-1]),t.draw();debugger}}else l=u=>a.push(u);do{let u=function(m,g){Re.eq(m.distance2(g),0)||l(f4(p.getShape(),m,g))},h=o.findIndex(m=>m===s.group);if(h!==-1){let m=a.findIndex(y=>y===s.group),g=a.splice(m).filter(y=>!(y instanceof jE));if(g.length){let y=Sd(Ci.build7(g));y&&i.push(y)}let b=a.filter(y=>!(y instanceof jE));if(s=o[h].getOutInter(b[b.length-1]),o.splice(h),!s)throw Error("interGroup not hav inter!!!2");continue}s.visitSelf(),o.push(s.group),a.push(s.group);let d=s.getIndex(),p=s.side,f=p.inters[d+1];for(;f!=null&&f.isInvalid||f&&f.group===s.group;)f=p.inters[f.getIndex()+1];if(f){u(s.coord,f.coord);let m=f.getBindedInter();if(s=m.getVisited()?m.group.getOutInter(m.side.getShape()):m,!s){if(f.group===n)break;throw new Error("interGroup not hav inter!!!3")}}else{for(u(s.coord,p.getEnd()),p=p.nextSide,s=null;;){for(let m of p.inters)if(!m.isInvalid){let g=m.group.getOutInter(p.getShape());if(!g){if(m.group===n){s=m;break}else if(m.getBindedInter().group===n){s=m.getBindedInter();break}continue}s=g;break}if(s)break;l(p.getShape()),p=p.nextSide}Re.eq(p.getEnd().distance2(s.coord),0)?l(p.getShape()):u(p.getStart(),s.coord)}}while(s.group!==n);let c=Sd(Ci.build7(a.filter(u=>!(u instanceof jE))));c&&i.push(c)})}),i}function n$(e){return{next(){return e.hasNext()?{value:e.next()}:{done:!0,value:void 0}},[Symbol.iterator](){return this}}}function s$(e){let t=[],i=new i$;for(let r of e.slice().sort((n,s)=>n.bbox().minY-s.bbox().minY)){for(let n of n$(i.listIterator())){let s=n.item;if(s.bbox().maxY<r.bbox().minY)i.remove(n);else{let a=function(d,p){let f=new Eh(p,d,null);return d.inters.push(f),t.push(f),f},o=function(d,p){let f=d.getEnd(),m=new Ie(oe[0],oe[1]),g=new Ie(oe[2],oe[3]),b=f.distance2(m)>f.distance2(g)?m:g,y=d.prevSide;a(Ct(y.getEnd(),b)?y:d,b).bind(a(p,b))},l=s.getShape(),c=r.getShape(),u=Wl(l,c),h=u===4&&oe[0]===oe[2]&&oe[1]===oe[3];if(h&&(u-=2),s.nextSide===r)s.prevSide!==r&&u===4&&o(s,r);else if(s.prevSide===r)u===4&&o(r,s);else if(u!==0){let d=function(f,m){let g=f.prevSide;return a(Ct(g.getEnd(),m)?g:f,m)},p=new Ie(oe[0],oe[1]);if(h&&!Ct(p,s.prevSide.getEnd())&&!Ct(p,r.prevSide.getEnd())&&Vt(l,p).dot(Vt(c,p))>0)continue;for(let f=0;f<u;f+=2){let m=new Ie(oe[f],oe[f+1]);d(s,m).bind(d(r,m))}}}}i.add(r)}return t.forEach(r=>{r.getIndex()===void 0&&r.side.sortInters()}),t}function a$(e){e.forEach(t=>{let i=t.side.getEnd();if(t.isInvalid||!Ct(t.coord,i))return;let r=t.side.inters,n=t.getBindedInter().side;for(let s=r.length-1;s>=0;s--){let a=r[s];if(!Ct(a.coord,i))break;a!==t&&a.getBindedInter().side===n&&a.setIsInvalid()}})}function o$(e){let t=new e1(10);return e.forEach(i=>{i.isInvalid||t.add(i)}),t}function l$(e){let t=[],i=o$(e);return e.forEach(r=>{if(r.isInvalid||r.group)return;let n=i.search(r.bbox().extendOfSize(Re.eps)).filter(s=>!s.group);if(n.length){let s=new Set,a=new jE(n);n.forEach(o=>{o.group=a,s.has(o.side)&&o.visitSelf(),s.add(o.side)}),t.push(a)}}),t}function c$(e,t){e.forEach(i=>{if(i.isInvalid||i.dealed)return;let r=i.side,n=i.getBindedInter().side,s;Ct(r.getEnd(),i.coord)&&Ct(n.getEnd(),i.coord)?s=-1:Ct(r.getEnd(),i.coord)?r.nextSide!==n&&(s=1,i=i.getBindedInter()):Ct(n.getEnd(),i.coord)&&n.nextSide!==r&&(s=1),u$(s,i,t),i.isDealed()})}function u$(e,t,i){let r=t.getBindedInter(),n=t.side,s=r.side,a=n.getShape(),o=s.getShape(),l=1,c=!1;if(e===-1){if(Um(a.reverse(),o.reverse())||Um(n.nextSide.getShape(),s.nextSide.getShape())){let h=bh(n,n.nextSide,s,r,l,c,i);if(h.state===2){let p=new Error("info1.state === InState.IS_OVERLAP");throw p.customType="IS_OVERLAP",p}let d=bh(n,n.nextSide,s.nextSide,r,l,c,i);h.state===d.state&&u(h,d)}else if(!(Um(a.reverse(),s.nextSide.getShape())||Um(n.nextSide.getShape(),o.reverse()))){let h=sA(n,n.nextSide,s,!1,i);h===sA(n,n.nextSide,s.nextSide,!0,i)&&h!==sA(s,s.nextSide,n.nextSide,!0,i)&&t.setIsInvalid()}}else if(e===1){let h=function(d,p){return Vt(d,p.start()).dot(Vt(p,p.start()))>0};if(Um(a.reverse(),o.reverse())||Um(a,s.nextSide.getShape())){let d=ol(n,s,r,i,l,c,new Map);if(d.state===2){let f=new Error("info1.state === InState.IS_OVERLAP");throw f.customType="IS_OVERLAP",f}let p=ol(n,s.nextSide,r,i,l,c,new Map);d.state===p.state&&u(d,p)}else if(h(a.reverse(),o.reverse())&&h(a,s.nextSide.getShape())){let d=Ps(n,s,!1,i);d===Ps(n,s.nextSide,!0,i)&&d!==Xp(s,s.nextSide,new a1(f4(a,t.coord,a.end()),i),!0,i)&&t.setIsInvalid()}}function u(h,d){h.inter.setIsInvalid(),d.inter.setIsInvalid(),t.setIsInvalid()}}function f4(e,t,i){if(e instanceof ye||t.distance2(i)<1e-6)return new ye(t,i);if(e instanceof Le)return Le.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.sweep());if(e instanceof gt){let r=e.getPercent(t,Ht),n=e.getPercent(i,Ht);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function h$(e){let t=Sd(e);if(!t)return[];let i=t.primitives.map(n=>new a1(n,null)),r=i[i.length-1];return i.forEach(n=>{r.connect(n),r=n}),i}var Hm,d$=(Hm=class{static clearData(e){this.originalPrimitive=[],this.offsetPrimitive=[],this.rawOffsetPrimitive=[],this.offsetDistance=0,this.testI++,this.testI===0?this.drawDebug=new s1(e):delete this.drawDebug}static createRawOffsetEdge(){if(this.drawDebug){let e=this.drawDebug.initColor(Wi.WHITE);this.originalPrimitive.forEach(t=>e.addPt(t)),this.drawDebug.draw();debugger}for(let e=0;e<this.originalPrimitive.length;e+=1){let t=this.originalPrimitive[e];this.offsetPrimitive.push({index:e,offsetEdge:this.createOffsetEdge(t)})}if(this.drawDebug){let e=this.drawDebug.initColor(Wi.Golden);this.offsetPrimitive.forEach(t=>e.addPt(t.offsetEdge)),this.drawDebug.draw();debugger}if(this.offsetPrimitive.length>1)for(let e=0;e<this.offsetPrimitive.length;e+=1)if(e===this.offsetPrimitive.length-1){this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[0]);let t=this.rawOffsetPrimitive[0],i;t instanceof Le?i=Le.build4(this.offsetPrimitive[0].offsetEdge.start(),t.end(),t.center,t.rx,t.ry,t.sweep()):i=new ye(this.offsetPrimitive[0].offsetEdge.start(),t.end()),this.rawOffsetPrimitive.shift(),this.rawOffsetPrimitive.unshift(i)}else this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[e+1]);else this.rawOffsetPrimitive=[]}static createCirclePrimitive(e,t){let i=e.width()*.5,r=e.height()*.5,n=Math.sqrt(i**2+r**2)+t;return[Le.buildCircle(e.center(),n)]}static getExtendPolyLine(e,t,i=!0,r){var n,s;if(!((n=e==null?void 0:e.primitives)!=null&&n.length))return[];let a=Sd(e);if(!((s=a==null?void 0:a.primitives)!=null&&s.length)){if(this.isExpansion){let l=[1],c=t*2;e.primitives.forEach(h=>l.push(h.stroke(c,1,0)));let u=QK(l,r);if(u.items.length!==1)throw new Error("group.items.length !== 1 ");return[u.items[0].items[0]]}return[]}if(e=a,this.clearData(r),this.originalPrimitive=e.primitives,this.isExpansion=t>0,this.offsetDistance=t,this.createRawOffsetEdge(),this.drawDebug){let l=this.drawDebug.initColor(Wi.BLUE);this.rawOffsetPrimitive.forEach(c=>l.addPt(c)),this.drawDebug.draw();debugger}let o=i?this.createClippingEdge(r):[Ci.build2(this.rawOffsetPrimitive)];if(this.drawDebug){let l=this.drawDebug.initColor(Wi.RED);o.forEach(c=>l.addPly(c)),this.drawDebug.draw();debugger}if(o.length&&(!this.isExpansion||this.isExpansion&&o.length>1)&&(o=this.getValidityPrimitive(o)),this.drawDebug){let l=this.drawDebug.initColor(Wi.GREEN);o.forEach(c=>l.addPly(c)),this.drawDebug.draw();debugger;throw new Error}return o}static getValidityPrimitive(e){let t=[],i=Math.abs(this.offsetDistance);for(let r=0;r<e.length;r+=1){let n=!0,s=e[r].primitives;e:for(let a=0;a<s.length;a+=1){let o=s[a],l;if(o instanceof Le)l=o.midPoint;else if(o instanceof ye)l=o.start();else throw new Error("not support!");for(let c=0;c<this.originalPrimitive.length;c+=1){let u=this.originalPrimitive[c],h;if(u instanceof Le?h=this.pointArcClosest(l,u):h=WJ(l,u.start(),u.end()).d,i-h>.01){n=!1;break e}}}n&&t.push(e[r])}return t}static getInters(e){let t=[];for(let i=0;i<e;i+=2)t.push(new Ie(oe[i],oe[i+1]));return t}static pointArcClosest(e,t){let i=t.center;if(e.equals1(t.center))return t.rx;if(t.inArea(e,0)){let s=e.sub(i);return Math.abs(s.length()-t.rx)}let r=e.distance2(t.start()),n=e.distance2(t.end());return Re.less(r,n)?Math.sqrt(r):Math.sqrt(n)}static createClippingEdge(e){let t=[],i=[],r=p4(Ci.build2(this.rawOffsetPrimitive),e);r.forEach(s=>{let a=s.area(.01);t.push(a)});let n=Math.min(...t.filter(s=>s<0));for(let s=0;s<t.length;s+=1){let a=t[s];Re.eq(a,0)||(!this.isExpansion&&a<0||this.isExpansion&&(a<0&&t[s]===n||a>0))&&i.push(r[s])}return i}static createOffsetEdge(e){if(e instanceof Le)return e.panDistance1(this.offsetDistance);if(e instanceof ye)return e.panDistance(this.offsetDistance);throw new Error("not support!")}static connectPrimitive(e,t){e.offsetEdge instanceof ye&&t.offsetEdge instanceof ye?this.lineToLineConnect(e,t):e.offsetEdge instanceof Le&&t.offsetEdge instanceof Le?this.arcToArcConnect(e,t):e.offsetEdge instanceof ye&&t.offsetEdge instanceof Le?this.lineToArcConnect(e,t):this.arcToLineConnect(e,t)}static isFalseIntersection(e){return e>1||e<0}static lineToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=t.index,s=this.originalPrimitive[n].start();if(i.isParallel(r))i.bbox().intersection1(r.bbox())?this.rawOffsetPrimitive.push(i):this.lineToLineUseArcToConnect(s,i,r);else{let a=this.getLineToLineT(i,r),o=a[0],l=a[1];if(this.isFalseIntersection(o)||this.isFalseIntersection(l))o>1&&this.isFalseIntersection(l)?this.lineToLineUseArcToConnect(s,i,r):this.useLineToConnect(i,r);else if(!this.isFalseIntersection(o)&&!this.isFalseIntersection(l)){let c=i.end().sub(i.start()),u=i.start().add(c.mul(o)),h=new ye(i.start(),u);this.rawOffsetPrimitive.push(h);let d=new ye(u,r.end());this.updateNextOffsetPrimitive(n,d)}}}static updateNextOffsetPrimitive(e,t){this.offsetPrimitive[e].offsetEdge=t}static useLineToConnect(e,t){this.rawOffsetPrimitive.push(e);let i=new ye(e.end(),t.start());this.rawOffsetPrimitive.push(i)}static lineToLineUseArcToConnect(e,t,i){let r=this.getSweep(e,t),n=this.getSweepAngel(t.end(),i.start(),e,r);if(n===0){this.useLineToConnect(t,i);return}this.rawOffsetPrimitive.push(t);let s=Le.build5(t.end(),i.start(),n);this.rawOffsetPrimitive.push(s)}static getSweep(e,t,i){let r=null,n=i||i===0?this.originalPrimitive[i]:t;if(n instanceof Le){let s=n.center.sub(n.end()).normalize();n.isCCW?r=new Ie(s.y,-s.x):r=new Ie(-s.y,s.x)}else r=t.end().sub(t.start()).normalize();return e.sub(t.end()).normalize().cross(r)>0?0:1}static getLineToLineT(e,t){let i=e.end().sub(e.start()),r=t.end().sub(t.start()),n=i.cross(r),s=t.start().sub(e.start()),a=e.start().sub(t.start()),o=s.cross(r)/n,l=a.cross(i)/-n;return[o,l]}static lineToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=e.index,s=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(i,r),o=this.originalPrimitive[s].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,n);else if(a.intersectionNum===1){let l=a.points[0];this.lineAndArcConnectionDetail(i,r,a.t[0],l,o,n,s)}else if(a.intersectionNum===2){let l=a.points[0],c=a.points[1],u=l.distance2(o),h=c.distance2(o);this.lineAndArcConnectionDetail(i,r,u<h?a.t[0]:a.t[1],u<h?l:c,o,n,s)}}static lineAndArcConnectionDetail(e,t,i,r,n,s,a){let o=this.isTrueArcIntersection(t,r);if(!this.isFalseIntersection(i)&&o){let l=new ye(e.start(),r);this.rawOffsetPrimitive.push(l);let c;!t.center.equals1(r)||t.sweepAngle>1e-4?(c=Le.build4(r,t.end(),t.center,t.rx,t.ry,t.sweep()),c instanceof Le&&c.sweepAngle===0&&(c=new ye(c.start(),c.end()))):c=new ye(t.center,r),this.updateNextOffsetPrimitive(a,c)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(n,e,t,s)}static lineAndArcUseArcConnect(e,t,i,r){let n=this.getSweep(e,t,r),s=this.getSweepAngel(t.end(),i.start(),e,n);if(s===0){this.useLineToConnect(t,i);return}let a=Le.build5(t.end(),i.start(),s);this.rawOffsetPrimitive.push(t),this.rawOffsetPrimitive.push(a)}static arcToLineConnectionDetail(e,t,i,r,n,s,a){let o=this.isTrueArcIntersection(e,r);if(!this.isFalseIntersection(i)&&o){let l;e.center.equals1(r)?l=new ye(e.center,r):Math.abs(e.sweepAngle)<1e-4?l=new ye(e.start(),r):(l=Le.build4(e.start(),r,e.center,e.rx,e.ry,e.sweep()),l instanceof Le&&l.sweepAngle===0&&(l=new ye(l.start(),l.end()))),this.rawOffsetPrimitive.push(l);let c=new ye(r,t.end());this.updateNextOffsetPrimitive(a,c)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(n,e,t,s)}static isTrueArcIntersection(e,t){return jn(e,t)}static getSweepAngel(e,t,i,r){let n=e.angleD(i),s=t.angleD(i),a;return n===s?a=0:(n=ti.regularD(n),s=ti.regularD(s),r===1?s<=n&&(s+=360):s>=n&&(n+=360),a=s-n),a}static getLineJoinArcScalarAndIntersectionNum(e,t){let i={t:[],intersectionNum:0,points:[]},r=jJ(t,e);if(r){i.intersectionNum=r/2;for(let n=0;n<r-1;n+=2){let s=new Ie(oe[n],oe[n+1]);i.points.push(s),s.sub(e.start()).x<1e-4||s.sub(e.start()).y<1e-4?i.t.push(0):i.t.push(s.sub(e.start()).x/e.end().sub(e.start()).x)}}else i.intersectionNum=0;return i}static arcToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=e.index,s=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(r,i),o=this.originalPrimitive[s].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,n);else if(a.intersectionNum===1){let l=a.points[0];this.arcToLineConnectionDetail(i,r,a.t[0],l,o,n,s)}else if(a.intersectionNum===2){let l=a.points[0],c=a.points[1],u=l.distance2(o),h=c.distance2(o);this.arcToLineConnectionDetail(i,r,u<h?a.t[0]:a.t[1],u<h?l:c,o,n,s)}}static rxChangeStatus(e){return e===1?!this.isExpansion:this.isExpansion}static arcToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,n=WM(i,r);if(n){let s=this.getInters(n),a;if(s.length===2){let c=this.originalPrimitive[t.index].start(),u=s[0],h=s[1],d=u.distance2(c),p=h.distance2(c);d<p?a=u:a=h}else a=s[0];let o,l;a.equals1(i.center)?o=new ye(i.center,a):Math.abs(i.sweepAngle)<1e-4?o=new ye(i.start(),a):(o=Le.build4(i.start(),a,i.center,i.rx,i.ry,i.sweep()),o instanceof Le&&o.sweepAngle===0&&(o=new ye(o.start(),o.end()))),this.rawOffsetPrimitive.push(o),a.equals1(r.center)?l=new ye(a,r.center):Math.abs(r.sweepAngle)<1e-4?l=new ye(a,r.end()):(l=Le.build4(a,r.end(),r.center,r.rx,r.ry,r.sweep()),l instanceof Le&&l.sweepAngle===0&&(l=new ye(l.start(),l.end()))),this.updateNextOffsetPrimitive(t.index,l)}else{let s=this.originalPrimitive[e.index],a=this.originalPrimitive[t.index],o=this.rxChangeStatus(s.sweep()),l=this.rxChangeStatus(a.sweep()),c=this.originalPrimitive[t.index].start(),u=this.getSweep(c,i,e.index),h=Math.abs(this.offsetDistance),d=Le.build2(c,o?s.endAngle():s.endAngle()+180,l?a.startAngle:a.startAngle+180,h,h,u);this.rawOffsetPrimitive.push(i),this.rawOffsetPrimitive.push(d)}}},Hm.originalPrimitive=[],Hm.offsetPrimitive=[],Hm.rawOffsetPrimitive=[],Hm.testI=0,Hm),p$=class q0 extends r1{constructor(t,i,r,n,s,a){if(super(),i<0||r<0)throw new Error("The width and height of rect can't be less than 0!");this.leftUpPoint=t,this.width=i,this.height=r,this.angle=n,this.isCCW=s,this.radius=Math.min(Math.max(a,0),i/2,r/2)}get radiusRatio(){return this.radius/Math.min(this.width,this.height)}start(){return this.leftUpPoint.add(new Ie(this.radius,0).multiply3(Zn.rotateD(this.angle)))}end(){return this.start()}getLeftPoint(){return this.leftUpPoint.add(new Ie(0,-this.height/2).multiply3(Zn.rotateD(this.angle)))}getRightPoint(){return this.leftUpPoint.add(new Ie(this.width,-this.height/2).multiply3(Zn.rotateD(this.angle)))}extend(t){return new q0(this.leftUpPoint.add(new Ie(-t,t).rotateD(Ie.ORIGIN,this.angle)),this.width+t*2,this.height+t*2,this.angle,this.isCCW,this.radius+t)}bbox(){let t=Zn.rotateD(this.angle),{leftUpPoint:i,width:r,height:n,radius:s}=this,a=i.add(new Ie(s,-s).multiply3(t)),o=i.add(new Ie(s,s-n).multiply3(t)),l=i.add(new Ie(r-s,-s).multiply3(t)),c=i.add(new Ie(r-s,s-n).multiply3(t));return new Ta(Math.min(a.x,o.x,l.x,c.x)-s,Math.max(a.x,o.x,l.x,c.x)+s,Math.min(a.y,o.y,l.y,c.y)-s,Math.max(a.y,o.y,l.y,c.y)+s)}toPolyline(){let t=[],{leftUpPoint:i,width:r,height:n,radius:s}=this;if(s===0){let o=Ie.ORIGIN,l=new Ie(r,0),c=new Ie(r,-n),u=new Ie(0,-n);t.push(new ye(o,l),new ye(l,c),new ye(c,u),new ye(u,o))}else{let o=new Ie(0,-s),l=new Ie(s,0),c=new Ie(r-s,0),u=new Ie(r,-s),h=new Ie(r,s-n),d=new Ie(r-s,-n),p=new Ie(s,-n),f=new Ie(0,s-n);t.push(Le.build1(o,l,s,s,!1,0),new ye(l,c),Le.build1(c,u,s,s,!1,0),new ye(u,h),Le.build1(h,d,s,s,!1,0),new ye(d,p),Le.build1(p,f,s,s,!1,0),new ye(f,o))}t=t.filter(o=>!o.start().equals1(o.end())),this.isCCW&&(t.forEach((o,l)=>t[l]=o.reverse()),t.reverse());let a=Zn.rotateD(this.angle).translate1(i);return Ci.build2(t.map(o=>o.multiply3(a)))}center(){return this.leftUpPoint.add1(this.width/2,this.height/2).rotateD(this.leftUpPoint,this.angle)}multiply3(t){let i=this.leftUpPoint.multiply3(t),r=new Ie(this.width,0).multiply3(Zn.rotateD(this.angle)).multiply3(t),n=new Ie(0,-this.height).multiply3(Zn.rotateD(this.angle)).multiply3(t);return t.isMirrored()?new q0(i,n.length(),r.length(),n.angleD(Ie.ORIGIN),this.isCCW===1?0:1,this.radius*r.length()/this.width):new q0(i,r.length(),n.length(),r.angleD(Ie.ORIGIN),this.isCCW,this.radius*r.length()/this.width)}reverse(){return new q0(this.leftUpPoint,this.width,this.height,this.angle,this.isCCW===1?0:1,this.radius)}stroke(t,i,r){let n=this.stroke1(t,i,r);if(n.length===1)return n[0];{let[s,a]=n;return Ci.build2(s.primitives.concat(new ye(s.primitives[0].start(),a.primitives[0].start()),a.primitives,new ye(a.primitives[0].start(),s.primitives[0].start())))}}stroke1(t,i,r){let n=r===this.isCCW?this:this.reverse(),s=t/2,a=Math.min(n.width,n.height)/2,o=n.extend(s).toPolyline();return a<=s?[o]:[o,n.extend(-s).toPolyline().reverse()]}points(t){let i=this.toPolyline(),r=[];return i.points(t,n=>r.push(n)),r}toBezier(){throw new Error("Method not implemented.")}},f$=.01,os=class Lc{static simplify(t){return t=Sd(t),t?new Lc([t]):null}static buildByStroke(t,i,r=1,n=BA,s){if(t instanceof Le&&(t.rx<i/2+f$||Math.abs(t.sweepAngle)>180&&Re.lesseq(t.start().distance1(t.end()),i))){let o=p4(t.stroke(i,r,0),s);if(o.length===0)return null;if(o.length===1)return new Lc(o);let l=[null],c=Number.POSITIVE_INFINITY;return o.forEach(u=>{let h=u.area(.1);h<0?h<c&&(l[0]=u,c=h):l.push(u)}),new Lc(l)}else if(t instanceof p$){let o=t.stroke1(i,r,0).map(l=>Sd(l));return o[0]?o[1]?new Lc(o):new Lc([o[0]]):null}let a=t.stroke(i,r,0,n);return a?this.simplify(a):null}static buildCircle(t,i){return this.simplify(Ci.build7([Le.buildCircle(t,i,0)]))}static buildRect(t){return this.simplify(t.toPolyline())}static buildBBox(t){return this.simplify(Ci.buildBBox(t,0))}constructor(t){this.items=t.slice()}multiply3(t){return new Lc(this.items.map(i=>i.multiply3(t)))}bbox(){return this.items[0].bbox()}isEqual(t){return t instanceof Lc?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items[0]}extend(t,i){if(this.items.length!==1)throw new Error("this.items.length !== 1");if(t===0)return new On([this]);let r=this.items[0],n=[];for(let u of r.primitives)if(u instanceof ye)n.push(u);else if(u instanceof Le&&u.rx===u.ry)a(u);else if(u instanceof gt)s(u);else throw new Error("not support!");r=Ci.build7(n);function s(u){let h=u.points(.1);for(let d=0;d<h.length-1;d++){let p=h[d],f=h[d+1];n.push(new ye(p,f))}}function a(u){if(Math.abs(u.sweepAngle)>270){let h=u.sweepAngle/2;a(Le.build3(u.center,u.startAngle,h,u.rx,u.ry)),a(Le.build3(u.center,u.startAngle+h,h,u.rx,u.ry))}else n.push(u)}let o=[],l=[];d$.getExtendPolyLine(r,t,!0,i).forEach(u=>{(u.area(.1)>0?l:o).push(u)});let c;if(o.length===1)l.forEach(u=>o.push(u)),c=new On([new Lc(o)]);else if(o.length===0)console.warn("outlines.length === 0"),c=new On([]);else if(l.length===0)c=new On(o.map(u=>new Lc([u])));else{let u=o.map(h=>[h]);l.forEach(h=>{let d=[],p=h.bbox();if(u.forEach(f=>{f[0].bbox().isContainsBBox1(p)&&d.push(f)}),d.length===1)d[0].push(h);else{if(d.length===0)throw new Error("inPlsArr.length === 0");for(let f of d.sort((m,g)=>m[0].bbox().area()-g[0].bbox().area()))if(f[0].getWindingNum(h.start())===-1){f.push(h);break}}}),c=new On(u.map(h=>new Lc(h)))}return c}toPolylineGroup(){return new kA(this.items)}},m$=(e=>(e[e.POLYGON=1]="POLYGON",e[e.POLYLINE=2]="POLYLINE",e[e.LINE=3]="LINE",e[e.ARC=4]="ARC",e[e.BEZIER2=5]="BEZIER2",e[e.BEZIER3=6]="BEZIER3",e[e.BOOLEAN_OUTPUT=7]="BOOLEAN_OUTPUT",e[e.BOOLEAN_INTERSECTION=8]="BOOLEAN_INTERSECTION",e[e.BOOLEAN_UNION=9]="BOOLEAN_UNION",e[e.BOOLEAN_DIFF=10]="BOOLEAN_DIFF",e[e.BOOLEAN_RESULT=11]="BOOLEAN_RESULT",e[e.LINES=12]="LINES",e[e.ARCS=13]="ARCS",e[e.BEZIER2S=14]="BEZIER2S",e[e.BEZIER3S=15]="BEZIER3S",e[e.CIRCLE_CW=16]="CIRCLE_CW",e[e.CIRCLE_CCW=17]="CIRCLE_CCW",e[e.POLYGON_GROUP=18]="POLYGON_GROUP",e))(m$||{});var mA=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}},g$=/(\.?0+)$/,DA=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,n=0,s,a=0,o=0;for(let l=0;l<e.length;l++){let c=e.charAt(l),u=c.charCodeAt(0);switch(r){case 0:u===37?r=1:i.push(c);break;case 1:switch(u){case 100:if(s=t[n++],typeof s=="number")i.push(s.toFixed(0)),r=0;else return l;break;case 102:if(s=t[n++],typeof s=="number")i.push(s.toString()),r=0;else return l;break;case 120:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16)),r=0;else return l;break;case 88:if(s=t[n++],typeof s=="number")i.push((s|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:s=t[n++],i.push(s===null?"null":s.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(u){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 100:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(mA.lpad((s|0).toString(10),"0",h)),r=0;else return l}else return l;break;case 120:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(mA.lpad((s|0).toString(16),"0",h)),r=0;else return l}else return l;break;case 88:if(o>=a){let h=parseInt(e.substring(a,o+1));if(s=t[n++],typeof s=="number")i.push(mA.lpad((s|0).toString(16).toUpperCase(),"0",h)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static fmtNumber(e){return e.toFixed(5).replace(g$,"")}};function y$(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var b$=(e,t)=>{e===3?console.error(...t):e===2?console.warn(...t):console.log(...t)},x$=(e,t)=>[y$(e)].concat(t),OM=class _A{static mix(...t){return new _A(0,(i,r)=>{for(let n of t)n.write(i,r)},(i,r)=>r)}constructor(t,i=b$,r=x$){this.level=t,this.writer=i,this.fmt=r}setLevel(t){this.level=t}prepend(t=null,i=null){let r=t===null?this.fmt:(s,a)=>(a=t(s,a),this.fmt(s,a)),n=i===null?this.writer:(s,a)=>{i(s,a),this.writer(s,a)};return new _A(this.level,n,r)}chain(t){return t.prepend(this.fmt.bind(this),this.writer.bind(this))}include(t){return this.level<=t}formatWrite(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[DA.format(i,...r)]))}write(t,i){this.include(t)&&this.writer(t,this.fmt(t,i))}write3(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[DA.format(i,...r)]))}debug3(t,...i){this.write3(0,t,i)}warning3(t,...i){this.write3(2,t,i)}debugFmt(t,...i){this.formatWrite(0,t,i)}debug(...t){this.write(0,t)}infoFmt(t,...i){this.formatWrite(1,t,i)}info(...t){this.write(1,t)}warningFmt(t,...i){this.formatWrite(2,t,i)}warning(...t){this.write(2,t)}errorFmt(t,...i){this.formatWrite(3,t,i)}error(...t){this.write(3,t)}};OM.DUMMY=new OM(4);var Hle=String.fromCharCode;var E$=(e=>(e[e.UNKNOW=0]="UNKNOW",e[e.NUMBER_INTEGER=1]="NUMBER_INTEGER",e[e.NUMBER_DECIMAL=2]="NUMBER_DECIMAL",e[e.NUMBER_E=3]="NUMBER_E",e[e.NUMBER_E_SIGNED=4]="NUMBER_E_SIGNED",e))(E$||{}),S$=(e=>(e[e.UNKNOW=0]="UNKNOW",e[e.MOVE_X=1]="MOVE_X",e[e.MOVE_Y=2]="MOVE_Y",e[e.LINE_X=3]="LINE_X",e[e.LINE_Y=4]="LINE_Y",e[e.HORIZONTAL_X=5]="HORIZONTAL_X",e[e.VERTICAL_Y=6]="VERTICAL_Y",e[e.CUBIC_BEZIER_X1=7]="CUBIC_BEZIER_X1",e[e.CUBIC_BEZIER_Y1=8]="CUBIC_BEZIER_Y1",e[e.CUBIC_BEZIER_X2=9]="CUBIC_BEZIER_X2",e[e.CUBIC_BEZIER_Y2=10]="CUBIC_BEZIER_Y2",e[e.CUBIC_BEZIER_X=11]="CUBIC_BEZIER_X",e[e.CUBIC_BEZIER_Y=12]="CUBIC_BEZIER_Y",e[e.ARC_RX=13]="ARC_RX",e[e.ARC_RY=14]="ARC_RY",e[e.ARC_ROTATION=15]="ARC_ROTATION",e[e.ARC_LARGE=16]="ARC_LARGE",e[e.ARC_SWEEP=17]="ARC_SWEEP",e[e.ARC_X=18]="ARC_X",e[e.ARC_Y=19]="ARC_Y",e[e.SMOOTH_CUBIC_BEZIER_X2=20]="SMOOTH_CUBIC_BEZIER_X2",e[e.SMOOTH_CUBIC_BEZIER_Y2=21]="SMOOTH_CUBIC_BEZIER_Y2",e[e.SMOOTH_CUBIC_BEZIER_X=22]="SMOOTH_CUBIC_BEZIER_X",e[e.SMOOTH_CUBIC_BEZIER_Y=23]="SMOOTH_CUBIC_BEZIER_Y",e[e.QUADRATIC_BEZIER_X1=24]="QUADRATIC_BEZIER_X1",e[e.QUADRATIC_BEZIER_Y1=25]="QUADRATIC_BEZIER_Y1",e[e.QUADRATIC_BEZIER_X=26]="QUADRATIC_BEZIER_X",e[e.QUADRATIC_BEZIER_Y=27]="QUADRATIC_BEZIER_Y",e))(S$||{});var jle=DA.fmtNumber;var w$=class{constructor(){}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}encodeGroup(e,t){return{id:e,dataType:"GROUP",data:JSON.stringify(t)}}encodeAuxLine(e,t){return{id:e,dataType:"AUXLINE",data:JSON.stringify(t)}}encodeDimension(e,t){return{id:e,dataType:"DIMENSION",data:JSON.stringify(t)}}encodeString(e,t){return{id:e,dataType:"STRING",data:JSON.stringify(t)}}encodePoly(e,t){return{id:e,dataType:"POLY",data:JSON.stringify(t)}}};var v$=(e=>(e.UNIVERSAL="UNIVERSAL",e))(v$||{}),T$=(e=>(e.SINGLE="SINGLE",e.MULTIPLE="MULTIPLE",e))(T$||{}),I$=(e=>(e.NONE="NONE",e.NAME="NAME",e.NUMBER="NUMBER",e))(I$||{}),A$=(e=>(e.NONE="NONE",e.ZONE="ZONE",e))(A$||{});var C$=Qm(i1());function wd(){return self.EDITOR_TOP||self}function zE(e){return self[e]=self[e]||new C$.BroadcastChannelMessageBus(e)}var Yp=(e,t)=>{let i=/{([^}]*)}/gim,r=[...new Set(e.match(i))];for(let n=0;n<r.length;n++){let s=r[n],a=s.substring(1,s.length-1);t[a]&&(e=e.replace(s,t[a]))}return e};var D$=Qm(i1()),Xr={getTime:"/pro-mgr/serverTime/now",getUserL:"/pro-ui/loginUser/get",subMaxTick:"/pro-mgr/project/ticket",subBlob:"/pro-mgr/canvas/BLOB/update",subFont:"/pro-mgr/canvas/FONT/update",subRevoke:"/pro-mgr/{uuid}/revoke",pushPend:"/pro-mgr/worker/batchPendData",pushSync:"/pro-mgr/dataWorker/sync",pushRevoke:"/pro-mgr/worker/revoke",pullASync:"/pro-mgr/dataWorker/sync/{id}",personDestroy:"/mgr/libWorker/destroy",projectUpdate:"/pro-mgr/canvas/{uuid}/update",personUpdate:"/mgr/libWorker/component/{uuid}/update",personSave:"/mgr/libWorker/save",projectSave:"/mgr/projectWorker/setCanvas",canSavePend:"/mgr/projectWorker/canSavePend",hasSaveData:"/mgr/check/hasSaveData"},zle={projectUpdate:Xr.projectUpdate,personUpdate:Xr.personUpdate,projectCanSave:Xr.canSavePend,getProject:"/mgr/projectWorker/footprint/getCanvas",getPerson:"/mgr/libWorker/getFootprint",unwatch:"/mgr/projectWorker/footprint/unwatchCanvas"},Xle={projectUpdate:Xr.projectUpdate,projectCanSave:Xr.canSavePend,getProject:"/mgr/projectWorker/pcb/getCanvas",unwatch:"/mgr/projectWorker/pcb/unwatchCanvas"},Wle={projectUpdate:Xr.projectUpdate,projectCanSave:Xr.canSavePend,getProject:"/mgr/projectWorker/sheet/getCanvas",unwatch:"/mgr/projectWorker/sheet/unwatchCanvas"},qle={projectUpdate:Xr.projectUpdate,getProject:"/mgr/projectWorker/schematic/getCanvas",unwatch:"/mgr/projectWorker/schematic/unwatchCanvas"},Jle={projectUpdate:Xr.projectUpdate,projectCanSave:Xr.canSavePend,getProject:"/mgr/projectWorker/simulation/getCanvas",unwatch:"/mgr/projectWorker/simulation/unwatchCanvas"},Kle={projectUpdate:Xr.projectUpdate,personUpdate:Xr.personUpdate,projectCanSave:Xr.canSavePend,getProject:"/mgr/projectWorker/symbol/getCanvasOnCompiler",getPerson:"/mgr/libWorker/getSymbol",unwatch:"/mgr/projectWorker/symbol/unwatchCanvas"},_$={projectUpdate:Xr.projectUpdate,personUpdate:Xr.personUpdate,projectCanSave:Xr.canSavePend,getProject:"/mgr/projectWorker/panel/getCanvas",getPerson:"/mgr/libWorker/getPanelLib",unwatch:"/mgr/projectWorker/panel/unwatchCanvas"};var No={send:"/pro-mgr/notify/send",sendMsg:"/document/sendMsg/cooperation",unwatch:"/document/unwatch/cooperation",watch:"/document/watch/cooperation",message:"/pro-mgr/notify/message/{path}/{uuid}/cooperation",established:"/pro-mgr/notify/message/ws/established",getWsId:"/pro-mgr/notify/getWsId",disconnect:"/pro-mgr/notify/message/ws/disconnect"},eg=class{constructor(e=!0){this._lockerTicket=0,this.isPull=!1,this.compiler={},this.order={SYMBOL:1,FOOTPRINT:2,DEVICE:3,SCH_PAGE:4,PCB:5},this._locker=e?++this._lockerTicket:0}getOrder(e){return this.order[e]||6}publish(){if(!this.isPull){this.isPull=!0,this._temporaryUnlock=this._locker;try{let e=Object.keys(this.compiler).sort((i,r)=>this.getOrder(i)-this.getOrder(r)),t=!1;for(let i of e){for(let[,r]of this.compiler[i])if(t=r.publish(),t)break;if(t)break}}finally{this._temporaryUnlock=0,this.isPull=!1}}}canPush(){return!this._locker||this._locker===this._temporaryUnlock}addCompiler(e){this.compiler[e.headType]||(this.compiler[e.headType]=new Map),this.compiler[e.headType].set(e.uniqueId,e)}removeCompiler(e){var t,i,r;(r=(i=(t=this.compiler)==null?void 0:t[e.headType])==null?void 0:i.delete)==null||r.call(i,e.uniqueId)}pull(){if(!this._locker)throw Error("\u4E0D\u5141\u8BB8\u5728\u975E pause \u72B6\u6001\u4E0B\u62C9\u53D6\u6570\u636E");this.publish()}resume(){this._locker=0,this.publish()}pause(){this._locker=++this._lockerTicket}dispose(){for(let e in this.compiler)this.compiler[e].clear();this.compiler=null}},yd={publish:"publish",destroy:"destroy",init:"init",selected:"selected"},P$=class{constructor(e,t,i,r=(a=>(a=wd())==null?void 0:a._TAB_ID_)(),n,s){this.uuid=e,this.path=t,this.user=i,this.windowId=r,this.initIds={},this.sub=[];var a;this.wsBus=s||zE(`/${this.windowId}/notify`),this.dataBus=n||this.wsBus,this._client=(a=wd())==null?void 0:a._WS_ID_}get client(){return this._client}watch(){this.dataBus.publish(No.send,{topic:No.watch,uuid:this.uuid,path:this.path})}initPublish(){var e;this.dataBus.publish(No.send,{topic:No.sendMsg,uuid:this.uuid,path:this.path,msg:{type:yd.publish,user:this.user,client:this.client,data:((e=this.getSelect)==null?void 0:e.call(this))||""}})}async init(){if(!this.isInit){if(this.sub.push(this.wsBus.subscribe(No.established,e=>{this._client=e,this.watch(),this.initPublish()})),!this.client){let e=await this.wsBus.rpcCall(No.getWsId);if(!e||this.client)return;this._client=e}this.watch(),this.sub.push(this.wsBus.subscribe(No.disconnect,e=>{this.initIds[e]&&this.onDestroy(this.initIds[e],e)})),this.sub.push(this.dataBus.subscribe(Yp(No.message,{uuid:this.uuid,path:this.path}),e=>{if(e.type===1)e.connectId&&this.initIds[e.connectId]&&this.onDestroy(this.initIds[e.connectId],e.connectId);else if(e.msg){let t=e.msg;if(t.client===this.client)return;switch(t.type){case yd.destroy:this.onDestroy(t.userId,t.client),delete this.initIds[t.client];break;case yd.init:this.initIds[t.client]||(this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||""));break;case yd.selected:this.onSelected(t.user,t.client,t.data||"");break;case yd.publish:this.dataBus.publish(No.send,{topic:No.sendMsg,uuid:this.uuid,path:this.path,msg:{type:yd.init,user:this.user,client:this.client,data:this.getSelect()||""}}),this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||"");break;default:break}}})),this.initPublish(),this.isInit=!0}}publishSelected(e,t){this.dataBus.publish(No.send,{topic:No.sendMsg,uuid:this.uuid,path:this.path,msg:{type:yd.selected,user:this.user,client:this.client,data:e}}),t&&this.onSelected(this.user,this.client,e)}destroy(){if(this.isInit){this.isInit=!1,this.dataBus.publish(No.send,{topic:No.unwatch,uuid:this.uuid,path:this.path,msg:{type:yd.destroy,userId:this.user.uuid,client:this.client}});for(let e of this.sub)e.cancel();this.sub=[],this.initIds={}}}},RM=class extends P${constructor(e,t,i,r,n,s,a,o){super(e,t,o,i,n,s),this.channel=r,this.selectedProps=a,this.cache=new Map,this.deleteCache=new Map}rePublish(){var e,t,i,r;if(this.channel.canPush()){for(let[n,s]of this.cache)(t=(e=this.selectedProps)==null?void 0:e.onSelect)==null||t.call(e,s.user,n,s.data);for(let[n,s]of this.deleteCache)(r=(i=this.selectedProps)==null?void 0:i.onQuit)==null||r.call(i,s,n)}}getSelect(){var e,t;return((t=(e=this.selectedProps)==null?void 0:e.getSelect)==null?void 0:t.call(e))||""}onSelected(e,t,i){var r,n;this.channel.canPush()?!this.deleteCache.has(t)&&this.cache.set(t,{user:e,data:i}):(n=(r=this.selectedProps)==null?void 0:r.onSelect)==null||n.call(r,e,t,i)}onDestroy(e,t){var i,r;this.channel.canPush()?(this.deleteCache.set(t,e),this.cache.delete(t)):(r=(i=this.selectedProps)==null?void 0:i.onQuit)==null||r.call(i,e,t)}dispose(){this.destroy(),this.cache.clear(),this.deleteCache.clear()}publishSelected(e,t){super.publishSelected(e,t)}},L$=class{constructor(e,t,i,r=(b=>(b=wd())==null?void 0:b._TAB_ID_)(),n=new eg,s=null,a,o,l,c,u,h,d,p,f,m,g){this.uuid=e,this.path=t,this.isProject=i,this.windowId=r,this.channel=n,this.consistencyManager=s,this.selectedProps=l,this.setInit=c,this.onDocDetail=u,this.onUpdate=h,this.handleInit=d,this.onDelete=p,this.publishCache=f,this.onOrderNm=m,this.setMaxNum=g,this.isInit=!1,this.canSave=!0,this.sub=[],this.isInitIng=!1,this.cache={},this.deleteCache=new Map,this.pendTimer=null,this.pendPromise=null,this.pendCache={},this.pendCacheLength=0,this.wsBus=zE(`/${r}/notify`),s||(this._unique=Xl()),this._headType=a,this.busTopic=o}get uniqueId(){return this._unique||this.consistencyManager.getUnique()}get headType(){return this._headType}setIsInitIng(e){var t;(t=this.setInit)==null||t.call(this,e),this.isInitIng=e}consoleDebug(...e){console.debug("[lc-protocol]",this._headType,this.uuid,...e)}publishLine(e,t,i,r,n,s=this.uuid,a,o,l,c,u){if(this.channel.canPush())return this.consistencyManager.remoteChange(t,n,s,e,i,r,void 0,void 0,void 0,a,void 0,o,l,u),!1;this.cache[s]||(this.cache[s]=new Map);let h=this.cache[s].get(e);return(c||!h||h.ticket<t||h.ticket===t&&(h.client<n||h.client===n&&!!h.pend!=!!a))&&this.cache[s].set(e,{client:n,ticket:t,dataType:r,data:i,pend:a,unique:o,pChange:h?void 0:l,num:u}),!0}onDocHead(){}onEnd(){}setDocType(e,t){e===this.uuid&&(this._headType=t)}setBusTopic(e){this.busTopic=e}publish(){var e,t,i;if(this.publishCache)return this.publishCache();let r=!1;for(let[n,s]of this.deleteCache){if(this.channel.canPush()){(e=this.onDelete)==null||e.call(this,s),delete this.cache[n];continue}r=!0;break}if(r)return r;for(let n in this.cache){let s=this.cache[n].keys();for(let a of s){let o=this.cache[n].get(a);if(r=this.publishLine(a,o.ticket,o.data,o.dataType,o.client,n,o.pend,o.unique,o.pChange,!1,o.num),r)break;this.cache[n].delete(a)}if(r)break}return(i=(t=this.selectManager)==null?void 0:t.rePublish)==null||i.call(t),r}publishSelected(e,t){this.selectManager.publishSelected(e,t)}clear(){var e,t;for(let i of this.sub)i.cancel();this.sub.length=0,this.cache={},this.deleteCache.clear(),this.setIsInitIng(!1),this.channel.removeCompiler(this),(t=(e=this.selectManager)==null?void 0:e.dispose)==null||t.call(e),this.selectManager=null,this.isInit=!1,this.setIsInitIng(!1)}async init(e=!0,t=!0,i=!0,r,n,s,a){try{if(this.isInit)return{success:!0};if(this.isInitIng)throw new Error("\u6B63\u5728\u521D\u59CB\u5316\u4E2D");return this.isProject?await this.initProject(e,t,i,r,s,a):await this.initLib(i,r,n,s,a)}catch(o){throw this.clear(),new Error(`${this._headType}+'Compiler' ${this.uuid} init false: ${(o==null?void 0:o.message)||o||""}`,{cause:o})}finally{this.isInitIng=!1}}async flowRead(e){let t=this.consistencyManager.flowParseFull(),i=t.update,r=this;t.update=n=>{if(r.isDestroy)return!0;i(n)},await(0,D$.flowRead)(e,t)}pushOnLine(e,t){if(this.consistencyManager)for(let i of e)this.publishLine(i[0],i[1],i[2],i[3],i[4],t,i[5],i[6],i[7],!1,i[8])}async initProject(e,t,i,r,n,s){if(this.setIsInitIng(!0),this.channel.addCompiler(this),this.dataBus=zE(`/${this.windowId}/project/${this.path}`),n&&this.sub.push(this.dataBus.subscribe(`/pro-mgr/${this.uuid}/number/update`,l=>{if(this.onOrderNm)for(let c of l)this.onOrderNm(c[0],c[1],c[2])})),i&&this.busTopic.projectUpdate&&this.sub.push(this.dataBus.subscribe(Yp(this.busTopic.projectUpdate,{uuid:this.uuid}),l=>{this.onUpdate?this.onUpdate(l):this.pushOnLine(l,this.uuid)})),i&&this.busTopic.projectCanSave&&this.sub.push(this.dataBus.subscribe(this.busTopic.projectCanSave,l=>{this.canSave=l})),i&&this.busTopic.subDelete&&this.sub.push(this.dataBus.subscribe(this.busTopic.subDelete,l=>{var c;this.channel.canPush()?(c=this.onDelete)==null||c.call(this,l):this.deleteCache.set(l[0],l)})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(Xr.subMaxTick,l=>{this.consistencyManager.setMaxTicket(l.ticket,l.force)})),i&&t&&this.sub.push(this.dataBus.subscribe(Xr.subBlob,l=>{this.pushOnLine(l,"BLOB")})),i&&e&&this.sub.push(this.dataBus.subscribe(Xr.subFont,l=>{this.pushOnLine(l,"FONT")})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(Yp(Xr.subRevoke,{uuid:this.uuid}),l=>this.revoke(l))),!this.busTopic.getProject)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");this.isDestroy=!1;let a={doc:[this.uuid],watch:i,needNum:n,needDelete:s};t&&a.doc.push("BLOB"),e&&a.doc.push("FONT");let o=await this.dataBus.rpcCall(this.busTopic.getProject,a);if(this.isWatch=i,!this.isDestroy){if(!o.success)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01",o);if(this.canSave=!(o!=null&&o.readOnly),this.consoleDebug("init",o.result),o.maxTicket&&this.consistencyManager&&this.consistencyManager.setMaxTicket(o.maxTicket),o.data&&this.onDocDetail&&this.onDocDetail(o.client||Xl(),0,o.data,!1),o.channel&&await this.flowRead(o.channel),!this.isDestroy){if(this.handleInit?this.handleInit(o):o.result&&this.consistencyManager&&this.consistencyManager.parseFull(o.result,this.uuid,this._headType),r){let l=this.user=this.user||o.user||await this.wsBus.rpcCall(Xr.getUserL);this.selectManager=new RM(this.uuid,this.path,this.windowId,this.channel,this.dataBus,this.wsBus,this.selectedProps,l),await this.selectManager.init()}return this.isInit=!0,this.setIsInitIng(!1),{success:!0}}}}async initLib(e,t,i,r,n){if(this.setIsInitIng(!0),this.channel.addCompiler(this),this.dataBus=zE(`/${this.windowId}/libWorker`),!this.busTopic.getPerson)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");let s=i?Xl():"";this.isDestroy=!1;let a=await this.dataBus.rpcCall(this.busTopic.getPerson,{uuid:this.uuid,path:this.path,watch:e,channel:s,needNum:r,needDelete:n});if(this.isWatch=e,this.isDestroy)return;if(!a.success)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01",a);this.consoleDebug("init",a.dataStr);let o=a.data||a.result;if(o&&this.onDocDetail&&this.onDocDetail(a.client||Xl(),0,o,!1),r&&this.sub.push(this.dataBus.subscribe(`/pro-mgr/${this.uuid}/number/update`,l=>{if(this.onOrderNm)for(let c of l)this.onOrderNm(c[0],c[1],c[2])})),e&&this.busTopic.personUpdate&&this.sub.push(this.dataBus.subscribe(Yp(this.busTopic.personUpdate,{uuid:this.uuid}),l=>{this.pushOnLine(l,this.uuid)})),e&&this.sub.push(this.dataBus.subscribe(Yp(Yp(Xr.subRevoke,{uuid:this.uuid}),{uuid:this.uuid}),l=>this.revoke(l))),s&&await this.flowRead(s),!this.isDestroy){if(a.dataStr&&this.consistencyManager&&this.consistencyManager.parseFull(a.dataStr),t){let l=this.user=this.user||a.user||await this.wsBus.rpcCall(Xr.getUserL);this.selectManager=new RM(this.uuid,this.path,this.windowId,this.channel,this.wsBus,this.wsBus,this.selectedProps,l),await this.selectManager.init()}return this.isInit=!0,this.setIsInitIng(!1),{success:!0}}}revoke(e){for(let t of e)this.consistencyManager&&this.consistencyManager.revoke(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],(...i)=>this.publishLine(...i)),t[10]&&this.setMaxNum&&this.setMaxNum(t[6],t[10],t[1])}cachePendData(e,t,i,r,n,s){if(this.pendCache[e]||(this.pendCache[e]={type:s,pend:[]}),this.pendCache[e].pend.push([t,i,n,r]),this.pendCacheLength+=r.length+1,this.pendCacheLength>1e7&&this.publishPendData(),!this.pendTimer){let a;this.pendPromise=new Promise(o=>a=o),this.pendTimer=setTimeout(()=>{this.publishPendData(),a&&a(),this.pendTimer=null},0)}}publishPendData(){if(this.pendCacheLength){this.dataBus.publish(Xr.pushPend,[this.pendCache,this.consistencyManager.getClient(),this.uniqueId,this.uuid]);for(let e in this.pendCache)this.pendCache[e].pend.length=0;this.pendCache={},this.pendCacheLength=0}}localChange(e,t,i,r=this.uuid,n,s){if(!this.isInit||!this.canSave||!this.consistencyManager)return 0;if(t&&!t.startsWith("{"))return console.error("\u4E0A\u4F20\u7684\u683C\u5F0F\u4E0D\u6B63\u786E",e,i,t),0;let a=this.consistencyManager.localChange(r,e,t,i,n,s);return this.cachePendData(r,e,a,t,i,n||this.headType),a}async sync(){if(!this.isInit)throw new Error("\u6570\u636E\u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u540C\u6B65");let e=Xl();this.dataBus.publish(Xr.pushSync,e),await this.dataBus.pullA(Yp(Xr.pullASync,{id:e}))}async destroy(){return this.isDestroy?{success:!1}:(this.consistencyManager&&this.dataBus&&(this.pendPromise&&await this.pendPromise,this.dataBus.publish(Xr.pushRevoke,[this.uuid,this.uniqueId,this.consistencyManager.getClient()])),this.clear(),this.isDestroy=!0,this.isWatch&&this.dataBus&&!this.isProject&&this.dataBus.publish(Xr.personDestroy,{uuid:this.uuid,path:this.path}),this.isWatch&&this.dataBus&&this.busTopic.unwatch&&this.dataBus.publish(this.busTopic.unwatch,this.uuid),this.isWatch=!1,{success:!0})}async save(e=[this.uuid,"BLOB","FONT"]){try{if(!this.isInit)throw new Error("\u6570\u636E\u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u4FDD\u5B58");if(!this.consistencyManager)throw new Error("\u65E0\u6CD5\u652F\u6301\u4FDD\u5B58");let t=this.isProject?Xr.projectSave:Xr.personSave;if(!t)throw new Error("\u65E0\u6CD5\u652F\u6301\u4FDD\u5B58");this.pendPromise&&await this.pendPromise;let i=await this.dataBus.rpcCall(t,{uuid:this.uuid,path:this.path,docIds:e,uniqueId:this.uniqueId,client:this.consistencyManager.getClient()});return this.consoleDebug("save",i),i}catch(t){throw new Error(`${this._headType}+'Compiler' ${this.uuid} \u4FDD\u5B58\u5931\u8D25: ${(t==null?void 0:t.message)||t||""}`,{cause:t})}}async getBlob(e){return this.dataBus.rpcCall("/mgr/projectWorker/blob/getBlob",e)}async getFont(e,t,i,r,n,s,a,o){let l={text:e,fontFamily:t,fontSize:i,thickness:r,bold:n,italic:s,reverse:a,expansion:o},c=await this.dataBus.rpcCall("/mgr/projectWorker/font/get",l);return c.success?{success:!0,result:Object.assign(l,JSON.parse(c.result))}:c}async checkSave(){return this.pendPromise&&await this.pendPromise,await this.dataBus.rpcCall(Xr.hasSaveData,{uuid:this.uuid,uniqueId:this.uniqueId})}};var O$=(e=>(e.DIFFERENTIAL_PAIR="DIFFERENTIAL_PAIR",e.NET_CLASS="NET_CLASS",e.EQL_NET_GRP="EQL_NET_GRP",e))(O$||{});var R$=class extends aJ{constructor(e){let t=e||new RA;super(t,1,FM),this.cacheNum=null}onParseLine(e,t,i,r,n,s,a){switch(this.setOrderNum(e,a,t),this.cacheNum=a,t){case"MAX_NUM":if(i)for(let o in i)this.setMaxNum(o,i[o]);break;case"BLOB":i?this.onBlob(e,r,n,i,s):this.onDelBlob(e,r,n,s);case"DOCTYPE":i&&this.parseDocType(i,r,n,s);break;case"META":i&&this.parseDetail(i,r,n,s);break;case"ELE_PLACEHOLDER":break;case"CANVAS":i&&this.parseCanvas(i,r,n,s);break;case"GROUP":i?this.parseGroup(e,i,r,n,s):this.onDelGroup(e,r,n,s);break;case"POLY":i?this.parsePoly(e,i,r,n,s):this.onDelPoly(e,r,n,s);break;case"STRING":i?this.parseString(e,i,r,n,s):this.onDelString(e,r,n,s);break;case"AUXLINE":i?this.parseAuxLine(e,i,r,n,s):this.onDelAuxLine(e,r,n,s);break;case"DIMENSION":i?this.parseDimension(e,i,r,n,s):this.onDelDimension(e,r,n,s);break;default:console.warn("can not find hanlder with",i)}this.cacheNum=null}onOrderNum(e,t,i){switch(this.setOrderNum(e,i,t),t){case"GROUP":this.onPolyNum&&this.onPolyNum(e,i);break;case"POLY":this.onPolyNum&&this.onPolyNum(e,i);break;case"STRING":this.onStringNum&&this.onStringNum(e,i);break;case"AUXLINE":this.onAuxLineNum&&this.onAuxLineNum(e,i);break;case"DIMENSION":this.onDimensionNum&&this.onDimensionNum(e,i);break}}onParseEnd(){}parseDocType(e,t,i,r){let n=e.docType,s=e.version,a=e.meta}parseCanvas(e,t,i,r){this.onCanvas(t,i,e,r)}parseDetail(e,t,i,r){this.onDocDetail(t,i,e,r)}parseGroup(e,t,i,r,n){this.onGroup(e,this.cacheNum,i,r,t,n)}parsePoly(e,t,i,r,n){this.onPoly(e,this.cacheNum,i,r,t,n)}parseString(e,t,i,r,n){this.onString(e,this.cacheNum,i,r,t,n)}parseDimension(e,t,i,r,n){this.onDimension(e,this.cacheNum,i,r,t,n)}parseAuxLine(e,t,i,r,n){this.onAuxLine(e,this.cacheNum,i,r,t,n)}};var N$=class{constructor(e,t,i){this.uuid=e,this.maxTicket=0,this.encodeConsistency=new rJ(i),this.encodeConsistency.setDoctype(e,t),this.encodeConsistency.setDoctype("BLOB","BLOB"),this.encodeConsistency.setDoctype("FONT","FONT")}setFlowWriter(e){this.write=e}localChange(e,t,i,r=this.uuid){let n,s=typeof t=="string"?t:JSON.stringify(t);return this.write?(n=++this.maxTicket,this.write(r,this.encodeConsistency.getDoctype(r),Gp(i,n,e,s))):n=this.encodeConsistency.localChange(r,e,s,i),n}getDataStr(e=!0){return this.encodeConsistency.compressFull({notDocHead:!e})}removeDataStr(){this.encodeConsistency.removeCache()}uploadBlob(e,t){let i=UM(t),r={filename:e,content:t};return{success:!0,ticket:this.localChange(i,JSON.stringify(r),"BLOB","BLOB"),hash:i}}deleteBlob(e){return{success:!0,ticket:this.localChange(e,"","BLOB","BLOB")}}},m4=class extends N${constructor(e,t,i="PANEL"){super(e,i,t),this.uuid=e}uploadCanvas(e){return{success:!0,ticket:this.localChange("CANVAS",e,"CANVAS")}}uploadGroup(e,t){return{success:!0,ticket:this.localChange(e,t,"GROUP")}}deleteGroup(e){return{success:!0,ticket:this.localChange(e,"","GROUP")}}uploadAuxLine(e,t){return{success:!0,ticket:this.localChange(e,t,"AUXLINE")}}deleteAuxLine(e){return{success:!0,ticket:this.localChange(e,"","AUXLINE")}}uploadDimension(e,t){return{success:!0,ticket:this.localChange(e,t,"DIMENSION")}}deleteDimension(e){return{success:!0,ticket:this.localChange(e,"","DIMENSION")}}uploadString(e,t){return{success:!0,ticket:this.localChange(e,t,"STRING")}}deleteString(e){return{success:!0,ticket:this.localChange(e,"","STRING")}}uploadPoly(e,t){return{success:!0,ticket:this.localChange(e,t,"POLY")}}deletePoly(e){return{success:!0,ticket:this.localChange(e,"","POLY")}}};var $le=Qm(i1()),Zle=Qm(i1());var s2=class extends R${constructor(e,t,i,r,n=(s=>(s=wd())==null?void 0:s._TAB_ID_)()){let s=new RA(Xl());super(s),this.uuid=e,this.path=t,this.isProject=i,this.windowId=n,this.encode=new w$,this.base=new L$(e,t,i,n,r,s,i?"PANEL":"PANEL_LIB",_$,{getSelect:()=>{var a;return(a=this.canvasSelected)==null?void 0:a.call(this)},onSelect:(...a)=>{var o;return(o=this.onSelectChange)==null?void 0:o.call(this,a[0],a[1],a[2])},onQuit:(...a)=>{var o;return(o=this.onSelectQuit)==null?void 0:o.call(this,a[0],a[1])}},(...a)=>this.setIsInit(...a),(...a)=>this.onDocDetail(...a),void 0,void 0,void 0,void 0,(a,o,l)=>this.onOrderNum(a,o,l),(a,o,l)=>{this.setMaxNum(a,o,!0),this.deleteOrderNum(l)})}get dataBus(){return this.base.dataBus}set dataBus(e){this.base.dataBus=e}async init(e=!0,t=!0,i,r=!0,n){return this.setNeedNum(r),this.base.init(!1,e,t,i,!0,r,n)}publishSelected(e,t){this.base.publishSelected(e,t)}async sync(){return this.base.sync()}async destroy(){return this.base.destroy()}async save(){return this.base.save()}checkSave(){return this.base.checkSave()}localChange(e,t=this.uuid,i){var r,n;let s=this.getOrderNum(e.id);return(n=(r=this.needOrderType)==null?void 0:r.includes)!=null&&n.call(r,e.dataType)&&s===void 0&&(s=this.getMaxNum(e.dataType),this.setOrderNum(e.id,s,e.dataType),this.onOrderNum(e.id,e.dataType,s)),this.base.localChange(e.id,e.data,e.dataType,t,i,s)}uploadBlob(e,t){let i=UM(t),r={filename:e,content:t};return{success:!0,ticket:this.localChange({id:i,data:JSON.stringify(r),dataType:"BLOB"},"BLOB","BLOB"),hash:i}}deleteBlob(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"BLOB"},"BLOB","BLOB")}}uploadCanvas(e){return{success:!0,ticket:this.localChange(this.encode.encodeCanvas(e))}}uploadGroup(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeGroup(e,t))}}deleteGroup(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"GROUP"})}}uploadAuxLine(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeAuxLine(e,t))}}deleteAuxLine(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"AUXLINE"})}}uploadDimension(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeDimension(e,t))}}deleteDimension(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"DIMENSION"})}}uploadString(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeString(e,t))}}deleteString(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"STRING"})}}uploadPoly(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePoly(e,t))}}deletePoly(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"POLY"})}}};function Ot(){return"e"+Xl()}var YA;function Jp(e){if(YA)return $e(YA,String(e))?YA[e]:null;try{return localStorage.getItem(e)}catch{return null}}function zs(e,t){if(!e)return null;t=t===!0;try{let i=new DOMParser().parseFromString(e,"text/xml");return!i||i.querySelector("parsererror")?null:i}catch(i){return console.log("parseXML error",i),null}}function g4(e){let t,i=e;for(;i!=t;)t=i,i=t.replace(/~|\^\^|#@\$|`|#sheet#/gi,"");return i}function dt(e){if(e){if(e.length)return[].forEach.call(e,dt);if(e.parentNode)return e.parentNode.removeChild(e)}}function y4(e){for(let t of e)dt(le(t))}function VA(e,t){if(!e||!t)return e;if(e.removeAttribute)e.removeAttribute(t);else if(e.length)for(let i=0,r=e.length;i<r;i++)e[i]&&e[i].removeAttribute&&e[i].removeAttribute(t)}function a2(e){let[t,i]=e.split("|"),r=0;switch(t){case"start":r=0;break;case"middle":r=1;break;case"end":r=2;break;default:throw new Error("err")}return[r,+i]}function b4(e){let t=!1;return function(){t||(t=!0,e.apply(this,arguments))}}function Td(e,t){return t=t||H,t.decimalPlacesShow=t.decimalPlacesShow!==void 0?t.decimalPlacesShow:2,lt(e,t.decimalPlacesShow,t.fixedDecimal)}function Kp(e,t){return t=t&&typeof t.decimalPlaces=="number"?t:H,lt(e,t.decimalPlaces)}function HA(e,t,i){if(!t){console.error("\u4EE3\u7801\u51FA\u9519\uFF0C\u8BF7\u68C0\u67E5");return}e=e||H.gCanvas,typeof i=="string"&&(i=le(i)),i?e.insertBefore(t,i):e.appendChild(t)}function x4(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}function E4(e,t){return x4(e,t,()=>[])}function sr(e,t){return x4(e,t,()=>({}))}function jA(e){return t=>e.apply(e,Array.isArray(t)?t:[t])}function S4(){var e=H.globalVariableCookieData.userInfo;return e?e||{}:{}}function Bo(e,t={}){let i=document.createElement("span");i.classList.add("i18n"),i.innerText=e;let{context:r,attr:n,params:s}=t;return r&&i.setAttribute("data-i18n-context",r),n&&i.setAttribute("data-i18n-attr",n),s&&ro(s,(a,o)=>{i.setAttribute(`i18n-params-${a}`,o+"")}),i.outerHTML}function Id(e){let t=!0,i=!0,r;return function(...n){if(r=n,!!t){if(i)return i=!1,e.apply(null,r);t=!1,requestAnimationFrame(()=>{t=!0,e.apply(null,r)})}}}function no(){return 3/H.gZoom}function w4(e,t,i=!1){let r=[];for(let n=0;n<e.length;n++){let s=e[n],a=t(s);Va(a)||(r.push(a),i&&(e.splice(n,1),--n))}return r}function v4(e,t,i){let r=e?1:0,n=t?2:0,s=i?4:0;return r|n|s}function o2(e){if(window.frameElement)return H.windowBridge.publish("showMessager",[e],ut());H.messageBus.publish("showMessager",[e])}function T4(e,t){let i=document.createElement("a");i.download=t,i.href=URL.createObjectURL(e),i.click(),i=null}function $t(e){if(!e||!e.tagName||e==H.gCanvas||Vs(e,ko)||e.contains(H.gCanvas))return"";let t=te(e,"c_partid"),i=e.parentNode;return i&&i.id==="gControlDots"?"cdot":["ellipse","rect"].includes(e.tagName)?e.tagName:t==="part_text"?"text":t==="obj"?"obj":t==="group"?"group":t==="dimension"?"dimension":t==="auxiliaryLine"?"auxiliaryLine":t==="auxiliaryPoint"?"auxiliaryPoint":t||""}function I4(e){return e&&(/^(https?:)?\/\/[\w.-]+\/[^\s#?"]+\.(jpg|jpeg|png|gif|svg)$/i.test(e)||/^data:image\/(jpeg|png|gif|svg\+xml);base64,/.test(e)||/^\/assets\/static\/images\//.test(e))}function A4(e,t){return t=t||H,t.decimalPlacesShow=t.decimalPlacesShow!==void 0?t.decimalPlacesShow:2,lt(e,t.decimalPlacesShow,t.fixedDecimal)}function Zr(e,t){return t=t&&typeof t.decimalPlaces=="number"?t:H,lt(e,t.decimalPlaces)}var Qn={altKeyEnabled:!1,getSanpSize:function(e){return Qn.altKeyEnabled?+Ge.adsorbGrid.altSnapSize||1:+Ge.adsorbGrid["distance"+e]||1}};var Ve=class{static regular(t){return Math.round(t*this.precision)/this.precision}static eq(t,i){return Math.abs(t-i)<=this.eps}static neq(t,i){return Math.abs(t-i)>this.eps}static less(t,i){return t-i<-this.eps}static lesseq(t,i){return t-i<this.eps}static greater(t,i){return t-i>this.eps}static greatereq(t,i){return t-i>-this.eps}static sqrt(t){return Math.abs(t)<=1e-10?0:Math.sqrt(t)}static sortAsc(t,i){return t-i}static sortDesc(t,i){return i-t}};Ve.eps=1e-8,Ve.precision=1e8;function Ad(e,t,i,r,n,s,a,o,l){var c=Math.PI*2;function u(U,X,J,ne){var fe=U*J+X*ne,xe=Math.sqrt((U*U+X*X)*(J*J+ne*ne)),ve=Math.acos(fe/xe);return U*ne-X*J<0&&(ve=-ve),ve}function h(U){for(;U>=c;)U-=c;for(;U<0;)U+=c;return U}function d(U){return U.rx=a,U.ry=o,U.startAngle=U.theta1,U.endAngle=h(U.theta1+U.delta_theta),U}var p,f,m,g,b=1e-5;a<0&&(a=-a),o<0&&(o=-o),a==o&&(l=0);var y=Math.sin(l),E=Math.cos(l),S=(e-i)/2,w=(t-r)/2,x=(e+i)/2,I=(t+r)/2;if(a<b||o<b)return m=u(1,0,i-e,r-t),d({cx:x,cy:I,theta1:m,delta_theta:Math.PI});var A=E*S+y*w,O=E*w-y*S,R=A*A/(a*a)+O*O/(o*o);R>1&&(a=a*Math.sqrt(R),o=o*Math.sqrt(R));var M=a*o,F=a*O,G=o*A,V=F*F+G*G;if(!V)return d({cx:x,cy:I,theta1:0,delta_theta:0});var q=(M*M-V)/V;q=Math.sqrt(Math.abs(q)),n===s&&(q=-q);var C=q*F/o,N=-q*G/a;p=E*C-y*N+x,f=y*C+E*N+I;var T=(A-C)/a,L=(A+C)/a,P=(O-N)/o,B=(O+N)/o;for(m=u(1,0,T,P),g=u(T,P,-L,-B);g>c;)g-=c;for(;g<0;)g+=c;return s===0&&(g-=c),d({cx:p,cy:f,theta1:m,delta_theta:g})}function l2(e,t,i,r,n,s){var a=i-e,o=n-e,l=r-t,c=s-t,u=e*e,h=i*i,d=n*n,p=t*t,f=r*r,m=s*s,g=(l*(m-p+d-u)-c*(f-p+h-u))/(2*o*l-2*a*c),b=(a*(d-u+m-p)-o*(h-u+f-p))/(2*c*a-2*l*o);if(!isFinite(g)||!isFinite(b))return;var y=Math.sqrt((e-g)*(e-g)+(t-b)*(t-b)),E=[e-n,t-s],S=[i-n,r-s],w=E[0]*S[0]+E[1]*S[1],x=w<0?0:1;function I(F,G,V){var q=Math.acos(lt(F/V,3));return G>=0?q:Math.PI*2-q}var A=I(e-g,t-b,y),O=I(i-g,r-b,y),R=I(n-g,s-b,y),M=0;return R>A?(O>R||O<A)&&(M=1):O>R&&O<A&&(M=1),{angle:0,largeArcFlag:x,sweepFlag:M,x1:e,y1:t,x2:i,y2:r,cx:g,cy:b,r:y}}var et=class{static getRectBBox(t){let i=this.createMatrixFrom6(t),r=0,n=1,s=0,a=1,o=[[r,s],[n,s],[n,a],[r,a]],l=new ot;for(let u of o){let h=new j(u[0],u[1]).multiply3(i);l.ext2(h)}let c=l.build();return{x:c.minX,y:c.minY,width:c.width(),height:c.height()}}static expandRectMatrixByStrokeWidth(t,i,r=!0){let{width:n,height:s}=this.getRectShapeForAttr(t),a;if(r)a=de.scale((i+n)/n,(i+s)/s).setOrigin(.5,.5);else{if(n<i)throw new Error("Plz check code");if(s<i)throw new Error("Plz check code");a=de.scale((n-i)/n,(s-i)/s).setOrigin(.5,.5)}let o=a.multiply3(this.createMatrixFrom6(t));return this.getMatrix6FromMatrix(o)}static getRectShapeForAttr(t){let i=this.createMatrixFrom6(t),r=new j(0,0).multiply3(i),n=r.x,s=r.y,a=new j(1,0).multiply3(i),o=new j(0,1).multiply3(i),l=a.distance1(r),c=o.distance1(r);return{x:n,y:s,width:l,height:c,bottomLeft:o}}static rectShapeNoRadius(t){let i=this.createMatrixFrom6(t),r=0,n=1,s=0,a=1,o=[[r,s],[n,s],[n,a],[r,a]],l=[];for(let c of o){let u=new j(c[0],c[1]).multiply3(i);l.push(u)}return l}static calcuEllipse(t){let i=this.createMatrixFrom6(t),r=new de(i.getInverseMatrix().data),n=this.getMatrixabcdef(r),s=this.getEllABCDEF(n);return this.getElliShape(s)}static createMatrixFrom6([t,i,r,n,s,a]){return new de([t,i,0,r,n,0,s,a,1])}static getMatrix6FromMatrix(t){let[i,r,,n,s,,a,o]=t.data;return[i,r,n,s,a,o]}static getMatrixabcdef(t){let[i,r,,n,s,,a,o]=t.data;return{a:i,b:r,c:n,d:s,e:a,f:o}}static getEllABCDEF(t){let{a:i,b:r,c:n,d:s,e:a,f:o}=t,l=i**2+r**2,c=2*(r*s+i*n),u=s**2+n**2,h=2*(i*a+r*o),d=2*(s*o+n*a),p=a**2+o**2-1;return{A:l,B:c,C:u,D:h,E:d,F:p}}static getElliShape(t){let{A:i,B:r,C:n,D:s,E:a,F:o}=t,l=r**2-4*i*n,c=2*(i*a*a+n*s*s-r*s*a+(r*r-4*i*n)*o),u=i+n,h=Math.sqrt((i-n)**2+r**2),d=-Math.sqrt(c*(u+h))/l,p=-Math.sqrt(c*(u-h))/l,f=(2*n*s-r*a)/l,m=(2*i*a-r*s)/l,g=90;return r!==0?g=Math.atan((n-i-Math.sqrt((i-n)**2+r*r))/r)*180/Math.PI:i<n?g=0:g=90,Math.abs(d-p)<=.1**2&&(g=0),{a:d,b:p,cx:f,cy:m,degree:g}}};function zA(e,t=.05){if(e.length<3)return e.slice();let i=e[0],r=[i];for(let l=1;l<e.length;l++){let c=e[l];i.equals1(c)||r.push(c),i=c}if(i!==r[r.length-1]&&(r.length!==1&&r.pop(),r.push(i)),t<0)return r;let n=r[1],s=n.sub(r[0]).normalize(),a=0,o=[r[0]];for(let l=2;l<r.length;l++){let c=r[l],u=c.sub(n).normalize();a+=Math.acos(Math.min(1,Math.max(-1,s.dot(u)))),a>t&&(o.push(n),a=0),n=c,s=u}return o.push(n),o}var B$=.99,k$=50;function _4(e,t){let i=[],r=[],n=t**2;for(let s of e.primitives){if(s instanceof ie&&s.length()<k$){r.length===0?r.push(s.start(),s.end()):r.push(s.end());continue}r.length!==0&&(i.push(...D4(r,n).primitives),r.length=0),i.push(s)}return r.length!==0&&i.push(...D4(r,n).primitives),Tt.build2(i)}function XA(e,t,i){let r=e.sub(t),n=i.sub(t),s=r.length(),a=n.length(),o=r.scale(1/s).add(n.scale(1/a)).normalize(),c=Math.PI/2-Math.acos(Math.abs(o.dot(r.scale(1/s)))),u=r.angle(j.ORIGIN);return r.cross(n)<0?j.getVector2(u+c):j.getVector2(u-c)}function C4(e,t,i,r){let n=e.controls[0],s=e.controls[1],a=t.controls[0],o=t.controls[1],l=t.controls[t.controls.length-2],c=t.controls[t.controls.length-1],u=s.sub(n).normalize(),h=o.sub(a).normalize(),d=c.sub(l).normalize(),p=u.cross(h);if(!(Ve.greater(p*h.cross(d),0)&&Ve.greater(p*u.cross(d),0)))return null;let f=c.sub(n),m=Number.NEGATIVE_INFINITY;for(let S of i){let w=Math.abs(f.cross(S[0].sub(n)));w>m&&(m=w)}let g=j.getCrossPoint1(n,s,l,c)||n.add(c).scale(.5),b=Math.abs(g.sub(n).cross(f)),y=Math.min(1,m/b*4/3),E=new Ye([n,n.add(g.sub(n).scale(y)),c.add(g.sub(c).scale(y)),c]);for(let S of i){let[w,x]=S,I=E.getPointsBySlope(Ve.eq(x.x,0)?Number.POSITIVE_INFINITY:x.y/x.x);if(I.length!==1||w.distance2(I[0])>r)return null}return E}function D4(e,t){if(e.length<2)throw new Error("The length of outline can't be less than 2!");let i=zA(e,-1);if(i.length===2)return Tt.build2([new ie(i[0],i[1])]);let r=i[0].equals1(i[i.length-1]),n=[],s=r?i[i.length-2]:null,a=i[0],o=i[1];r?(n.push(XA(s,a,o)),s=a,a=o):(n.push(o.sub(a).scale(-1).normalize()),s=a,a=o);let l=zA(i),c=1;for(let m=1;m<i.length-1;m++)o=i[m+1],i[m]===l[c]&&(n.push(XA(s,a,o)),c++),s=a,a=o;r?(o=i[1],n.push(XA(s,a,o))):n.push(s.sub(a));let u=[],h=[],d=l[0],p=n[0],f=null;for(let m=1;m<l.length;m++){let g=l[m],b=n[m],y=d.sub(g);if(y.cross(p)*y.cross(b)>0)f=new ie(d,g),h.length=0,p=b;else if(Math.abs(b.dot(p))<B$){if(f instanceof Ye){let E=C4(f,new Ye([d,d,g]),h,t);E?(u.pop(),f=E):f=new ie(d,g)}else f=new ie(d,g);m!==l.length-1&&(p=g.sub(l[m+1]).normalize()),h.length=0}else{let E=new Ye([d,j.getCrossPoint2(d,p,g,b)||d.add(g).scale(.5),g]);if(f instanceof Ye){let S=C4(f,E,h,t);S?(u.pop(),E=S):h.length=0}f=E,h.push([g,b]),p=b}u.push(f),d=g}for(let m=0;m<u.length;m++){let g=u[m];if(g instanceof Ye)try{let b=g.controls,y=b[0],E=b[b.length-1].sub(y).normalize(),S=!0;for(let w=1;w<b.length-1;w++)if(!Ve.eq(1,b[w].sub(y).normalize().dot(E))){S=!1;break}S&&(u[m]=new ie(b[0],b[b.length-1]))}catch{}}return Tt.build2(u)}function tg(e,t){F$(e.iterator(),t)}function F$(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var WA=class{constructor(t){this.idx=-1;this.lst=t}hasNext(){return this.idx<this.lst.length-1}next(){if(this.idx<this.lst.length-1)return this.idx++,this.lst[this.idx];throw new Error("bug")}};function P4(e){return new WA(e)}function O4(e){return e===32||e===9||e===13||e===10}var c2=class{constructor(){this._line=1;this._col=0}line(){return this._line}col(){return this._col}_feed(t){return t===10?(this._col=0,this._line++):this._col++,this.feed(t)}parse(t){let i=t.length;for(let r=0;r<i;r++){let n=t.charCodeAt(r);if(!this._feed(n))return this}return this.finish(),this}};var R4=eval;var u2=null,KA=new ArrayBuffer(8),qA=new Float64Array(KA),JA=new Uint32Array(KA),N4=new Uint16Array(KA),G$=R4;function ql(e,t,i,r){n(e,null,t,i,r);function n(a,o,l,c,u){let h,d,p,f;if(c<u-1)if(u-c>50)o===null&&(o=new Array(u-c+1)),s(a,o,l,c,(c+u)/2|0,u);else{for(h=a[c],d=c,p=c,f=u;d+1<f;){if(p!=f){if(f=f+-1,l(h,a[f])<=0)continue;a[p]=a[f],p=f;continue}let m=d+1;if(l(h,a[m])>=0){d=m;continue}a[p]=a[m],d=m,p=m}a[p]=h,n(a,o,l,c,p),n(a,o,l,p+1,u)}}function s(a,o,l,c,u,h){n(a,o,l,c,u),n(a,o,l,u,h);for(var d=c,p=u,f=0,m=a[d],g=a[p];d<u&&p<h;){var b=l(m,g);isNaN(b)?(o[f++]=g,g=a[++p]):(b<=0&&(o[f++]=m,m=a[++d]),b>=0&&(o[f++]=g,g=a[++p]))}for(;d<u;d++)o[f++]=a[d];for(;p<h;p++)o[f++]=a[p];for(d=c,p=0;p<f;d++,p++)a[d]=o[p]}}var ps=class{static repeat(t,i){let r=new Array(i);for(;i-- >0;)r[i]=t;return r.join("")}static lpad(t,i,r){let n=r-t.length;return n>0?this.repeat(i,n)+t:t}static rpad(t,i,r){let n=r-t.length;return n>0?t+this.repeat(i,n):t}static strHashcode(t){if(t.length>0){let i=0;for(let r=0;r<t.length;r++)i=31*i+t.charCodeAt(r)|0;return i}else return 0}static arraycopy(t,i,r,n,s){if(t.length>=i+s&&r.length>=n+s)for(;s-- >0;)r[n++]=t[i++];else throw new Error("arraycopy out of range")}static undefAsNull(t){return null}static reverse(t,i){for(let r=0,n=t.length-1;n>=0;r++,n--)i[r]=t[n];return i}static sortAsc(t,i){return t-i}static xmlDecode(t){let i=t.length,r=new Array,n=-1;for(let s=0;s<i;s++){let a=t.charAt(s);if(n>=0){if(a===";"){let o=t.substring(n+1,s);switch(o){case"lt":r.push("<");break;case"gt":r.push(">");break;case"quot":r.push('"');break;case"apos":r.push("'");break;case"amp":r.push("&");break;default:if(o.charAt(0)==="#"){let l=parseInt(o.substring(1));r.push(String.fromCharCode(l))}else r.push("&"+o+";")}n=-1}}else a==="&"?n=s:r.push(a)}return n>=0&&r.push(t.substring(n)),r.join("")}static addAll(t,i){for(let r of i)t.push(r)}static contains(t,i){for(let r of t)if(r.equals(i))return!0;return!1}static equals(t,i){if(t.length==i.length){for(let r=0;r<t.length;r++)if(t[r]!==i[r])return!1;return!0}else return!1}static remove(t,i){let r=0,n=t.length;for(let s=0;s<n;s++)t[s]===i&&(t.splice(s,1),s--,n--,r++);return r}static getUrlVars(){for(var t={},i=location.href.slice(location.href.indexOf("?")+1).split("&"),r=0;r<i.length;r++){var n=i[r].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}static prefix(){if(!u2){let t=this.getUrlVars().version;t?u2="/analyzer/v"+t:u2="/analyzer"}return u2}static add2objS(t,i,r){if(i in t)return t[i];{let n=r(i);return t[i]=n,n}}static downloadFile(t,i){let r=document.createElement("a"),n=URL.createObjectURL(i);r.download=t,r.href=n,r.click(),URL.revokeObjectURL(n)}static uuid(){let t=new Array;qA[0]=new Date().getTime(),t.push(JA[1].toString(16)),qA[0]=Math.random(),t.push(N4[3].toString(16));let i=N4[2].toString(16);t.push("4"+i.substr(0,3)),qA[0]=performance.now();let r=JA[0].toString(16)+JA[1].toString(16);return t.push("0"+r.substr(0,3)),t.push(r.substr(3)),t.join("-")}static funcCopy(t){return G$("("+t.toString()+")")}static NVL(...t){for(let i of t)if(i!==null)return i;return null}};var Au=class{static rgb(t){if(0<=t&&t<=255)return t;throw new Error(Fo.format("RGB should not nagative and not over 255(0xFF): %X",t))}static normal(t){if(isFinite(t))return t;throw new Error(Fo.format("%f is not permitted",t))}static positiveOr0(t){if(t>=0)return t;throw new Error(Fo.format("%f must >= 0",t))}static positive(t){if(t>0)return t;throw new Error(Fo.format("%f must > 0",t))}static notnull(t){if(t!=null)return t;throw new Error("invalid null value")}static mustnull(t){if(t===null)return null;throw new Error("value must be null")}static notEmpty(t){if(t==null||t.length===0)throw new Error("invalid empty string");return t}static nullOrEmpty(t){return t==null||t.length===0}static notNullOrUndef(t){if(t!=null)return t;throw new Error("null or undefined is not permitted")}static isNumber(t){Kn(t)||Kr(t)}};var U$=/(\.?0+)$/,Fo=class{static format(t,...i){return this.format1(t,i)}static format1(t,i){let r=this._format(t,i);if(typeof r=="string")return r;throw new Error(this.format("Invalid state on (%d) %s",r,t))}static _format(t,i){let r=[],n=0,s=0,a,o=0,l=0;for(let c=0;c<t.length;c++){let u=t.charAt(c),h=u.charCodeAt(0);switch(n){case 0:h===37?n=1:r.push(u);break;case 1:switch(h){case 100:if(a=i[s++],typeof a=="number")r.push(a.toFixed(0)),n=0;else return c;break;case 102:if(a=i[s++],typeof a=="number")r.push(a.toString()),n=0;else return c;break;case 120:if(a=i[s++],typeof a=="number")r.push((a|0).toString(16)),n=0;else return c;break;case 88:if(a=i[s++],typeof a=="number")r.push((a|0).toString(16).toUpperCase()),n=0;else return c;break;case 115:case 99:a=i[s++],r.push(a===null?"null":a.toString()),n=0;break;case 48:o=c+1,l=-1,n=2;break;case 37:r.push("%"),n=0;break;default:return c}break;case 2:switch(h){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:l=c;break;case 100:if(l>=o){let d=parseInt(t.substring(o,l+1));if(a=i[s++],typeof a=="number")r.push(ps.lpad((a|0).toString(10),"0",d)),n=0;else return c}else return c;break;case 120:if(l>=o){let d=parseInt(t.substring(o,l+1));if(a=i[s++],typeof a=="number")r.push(ps.lpad((a|0).toString(16),"0",d)),n=0;else return c}else return c;break;case 88:if(l>=o){let d=parseInt(t.substring(o,l+1));if(a=i[s++],typeof a=="number")r.push(ps.lpad((a|0).toString(16).toUpperCase(),"0",d)),n=0;else return c}else return c;break;default:return c}break;default:return c}}return r.join("")}static startsWith(t,i){return t.length>=i.length?t.substring(0,i.length)===i:!1}static endsWith(t,i){return t.length>=i.length?t.substring(t.length-i.length)===i:!1}static split(t,i){let r=new Array,n=0;for(;;){let s=t.exec(i);if(s!==null){let a=t.lastIndex-s[0].length;r.push(i.substring(n,a)),n=t.lastIndex}else{let a=i.substring(n);Au.nullOrEmpty(a)||r.push(a);break}}return r}static fmtNumber(t){return t.toFixed(5).replace(U$,"")}};function Y$(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var V$=(e,t)=>{e===3?console.error(...t):e===2?console.warn(...t):console.log(...t)},H$=(e,t)=>[Y$(e)].concat(t),ig=class ig{static mix(...t){return new ig(0,(i,r)=>{for(let n of t)n.write(i,r)},(i,r)=>r)}constructor(t,i=V$,r=H$){this.level=t,this.writer=i,this.fmt=r}setLevel(t){this.level=t}prepend(t=null,i=null){let r=t===null?this.fmt:(s,a)=>(a=t(s,a),this.fmt(s,a)),n=i===null?this.writer:(s,a)=>{i(s,a),this.writer(s,a)};return new ig(this.level,n,r)}chain(t){return t.prepend(this.fmt.bind(this),this.writer.bind(this))}include(t){return this.level<=t}formatWrite(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[Fo.format(i,...r)]))}write(t,i){this.include(t)&&this.writer(t,this.fmt(t,i))}write3(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[Fo.format(i,...r)]))}debug3(t,...i){this.write3(0,t,i)}warning3(t,...i){this.write3(2,t,i)}debugFmt(t,...i){this.formatWrite(0,t,i)}debug(...t){this.write(0,t)}infoFmt(t,...i){this.formatWrite(1,t,i)}info(...t){this.write(1,t)}warningFmt(t,...i){this.formatWrite(2,t,i)}warning(...t){this.write(2,t)}errorFmt(t,...i){this.formatWrite(3,t,i)}error(...t){this.write(3,t)}};ig.DUMMY=new ig(4);var Bc=ig;var $A=500,M4=String.fromCharCode,h2=class{constructor(){this.buffer=new Array}size(){return this.buffer.length}isEOF(){return!1}write(t){return this.buffer.push(t),1}writen1(t){return this.writen2(t,0,t.length)}writen2(t,i,r){let n=this.buffer;for(let s=0,a=i;s<r;s++,a++)n.push(t[a]);return r}writeAsync(t,i){i(this.write(t))}writenAsync1(t,i){i(this.writen1(t))}writenAsync2(t,i,r,n){n(this.writen2(t,i,r))}writeStr(t){let i=t.length,r=new Array(i);for(let n=0;n<i;n++)r[n]=t.charCodeAt(n);return this.writen1(r)}clear(){this.buffer.length=0}toString(){let t=this.buffer,i=t.length;if(i<=$A)return M4.apply(null,t);{let r=new Array;for(let n=0;n<t.length;n+=$A){let s=Math.min(i-n,$A),a=M4.apply(null,t.slice(n,n+s));r.push(a)}return r.join("")}}};var k4=(s=>(s[s.UNKNOW=0]="UNKNOW",s[s.NUMBER_INTEGER=1]="NUMBER_INTEGER",s[s.NUMBER_DECIMAL=2]="NUMBER_DECIMAL",s[s.NUMBER_E=3]="NUMBER_E",s[s.NUMBER_E_SIGNED=4]="NUMBER_E_SIGNED",s))(k4||{}),F4=(F=>(F[F.UNKNOW=0]="UNKNOW",F[F.MOVE_X=1]="MOVE_X",F[F.MOVE_Y=2]="MOVE_Y",F[F.LINE_X=3]="LINE_X",F[F.LINE_Y=4]="LINE_Y",F[F.HORIZONTAL_X=5]="HORIZONTAL_X",F[F.VERTICAL_Y=6]="VERTICAL_Y",F[F.CUBIC_BEZIER_X1=7]="CUBIC_BEZIER_X1",F[F.CUBIC_BEZIER_Y1=8]="CUBIC_BEZIER_Y1",F[F.CUBIC_BEZIER_X2=9]="CUBIC_BEZIER_X2",F[F.CUBIC_BEZIER_Y2=10]="CUBIC_BEZIER_Y2",F[F.CUBIC_BEZIER_X=11]="CUBIC_BEZIER_X",F[F.CUBIC_BEZIER_Y=12]="CUBIC_BEZIER_Y",F[F.ARC_RX=13]="ARC_RX",F[F.ARC_RY=14]="ARC_RY",F[F.ARC_ROTATION=15]="ARC_ROTATION",F[F.ARC_LARGE=16]="ARC_LARGE",F[F.ARC_SWEEP=17]="ARC_SWEEP",F[F.ARC_X=18]="ARC_X",F[F.ARC_Y=19]="ARC_Y",F[F.SMOOTH_CUBIC_BEZIER_X2=20]="SMOOTH_CUBIC_BEZIER_X2",F[F.SMOOTH_CUBIC_BEZIER_Y2=21]="SMOOTH_CUBIC_BEZIER_Y2",F[F.SMOOTH_CUBIC_BEZIER_X=22]="SMOOTH_CUBIC_BEZIER_X",F[F.SMOOTH_CUBIC_BEZIER_Y=23]="SMOOTH_CUBIC_BEZIER_Y",F[F.QUADRATIC_BEZIER_X1=24]="QUADRATIC_BEZIER_X1",F[F.QUADRATIC_BEZIER_Y1=25]="QUADRATIC_BEZIER_Y1",F[F.QUADRATIC_BEZIER_X=26]="QUADRATIC_BEZIER_X",F[F.QUADRATIC_BEZIER_Y=27]="QUADRATIC_BEZIER_Y",F))(F4||{});function j$(e){return 97<=e&&e<=122||65<=e&&e<=90}function Ls(e){let t=parseFloat(e);if(isFinite(t))return t;throw new Error("expect number")}var so=class extends c2{constructor(i,r=!0,n=Bc.DUMMY){super();this.buffer=new h2;this.group=new Array;this.subPartStart=j.ORIGIN;this.curPoint=j.ORIGIN;this.lexState=0;this.parseState=0;this.isAbsolute=!1;this.isLargeArc=!1;this.x1=Number.NaN;this.y1=Number.NaN;this.x2=Number.NaN;this.y2=Number.NaN;this.x=Number.NaN;this.y=Number.NaN;this.rx=Number.NaN;this.ry=Number.NaN;this.rotation=Number.NaN;this.sweep=vs.CCW;this.prevBezierCtrl2=null;this.logger=n,this.cb=i,this.yAxis=r?-1:1}on(i){return this.cb(i)}feed(i){switch(this.logger.include(0)&&this.logger.debug3("L: %c(%s)|%s",i,String.fromCharCode(i),k4[this.lexState]),this.lexState){case 0:return O4(i)?!0:48<=i&&i<=57||i===45||i===43?(this.pushBuffer(i),this.lexState=1,!0):i===46?(this.pushBuffer(i),this.lexState=2,!0):j$(i)?this.feedS(String.fromCharCode(i)):(this.logger.warning3("unknow letter %c",i),!0);case 1:return 48<=i&&i<=57?(this.pushBuffer(i),!0):i===46?(this.pushBuffer(i),this.lexState=2,!0):i===101||i===69?(this.pushBuffer(i),this.lexState=3,!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(i)):!1;case 2:return 48<=i&&i<=57?(this.pushBuffer(i),!0):i===101||i===69?(this.pushBuffer(i),this.lexState=3,!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(i)):!1;case 3:return 48<=i&&i<=57?(this.pushBuffer(i),!0):i===45||i===43?(this.pushBuffer(i),this.lexState=4,!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(i)):!1;case 4:return 48<=i&&i<=57?(this.pushBuffer(i),!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(i)):!1;default:return!0}}finish(){this.feed(32),this.tryNotify()}feedS(i){switch(this.logger.include(0)&&this.logger.debug3("P: %s|%s|%s|%s",i,F4[this.parseState],this.curPoint,this.subPartStart),this.parseState){case 0:switch(i){case"M":this.isAbsolute=!0,this.parseState=1;break;case"m":this.isAbsolute=!1,this.parseState=1;break;case"L":this.isAbsolute=!0,this.parseState=3;break;case"l":this.isAbsolute=!1,this.parseState=3;break;case"H":this.isAbsolute=!0,this.parseState=5;break;case"h":this.isAbsolute=!1,this.parseState=5;break;case"V":this.isAbsolute=!0,this.parseState=6;break;case"v":this.isAbsolute=!1,this.parseState=6;break;case"z":case"Z":{this.group.push(new ie(this.curPoint,this.subPartStart));let s=this.tryNotify();return this.curPoint=this.subPartStart,s}case"C":this.isAbsolute=!0,this.parseState=7;break;case"c":this.isAbsolute=!1,this.parseState=7;break;case"S":this.isAbsolute=!0,this.parseState=20;break;case"s":this.isAbsolute=!1,this.parseState=20;break;case"A":this.isAbsolute=!0,this.parseState=13;break;case"a":this.isAbsolute=!1,this.parseState=13;break;case"Q":this.isAbsolute=!0,this.parseState=24;break;case"q":this.isAbsolute=!1,this.parseState=24;break;default:this.logger.warning3("unknow %s",i)}return!0;case 1:let r=this.tryNotify();return this.x=Ls(i),this.parseState=2,r;case 2:{this.y=this.yAxis*Ls(i);let s;return this.isAbsolute?s=new j(this.x,this.y):s=this.curPoint.add1(this.x,this.y),this.curPoint=s,this.subPartStart=s,this.parseState=3,!0}case 3:return this.x=parseFloat(i),isFinite(this.x)?(this.parseState=4,!0):(this.parseState=0,this.feedS(i));case 4:{this.y=this.yAxis*Ls(i);let s;return this.isAbsolute?s=new j(this.x,this.y):s=this.curPoint.add1(this.x,this.y),this.group.push(new ie(this.curPoint,s)),this.curPoint=s,this.parseState=3,!0}case 5:if(this.x=parseFloat(i),isFinite(this.x)){let s;return this.isAbsolute?s=new j(this.x,this.curPoint.y):s=this.curPoint.add1(this.x,0),this.group.push(new ie(this.curPoint,s)),this.curPoint=s,!0}else return this.parseState=0,this.feedS(i);case 6:if(this.y=parseFloat(i),isFinite(this.y)){this.y=this.yAxis*this.y;let s;return this.isAbsolute?s=new j(this.curPoint.x,this.y):s=this.curPoint.add1(0,this.y),this.group.push(new ie(this.curPoint,s)),this.curPoint=s,!0}else return this.parseState=0,this.feedS(i);case 7:let n=parseFloat(i);return isFinite(n)?(this.x1=n,this.parseState=8,!0):(i!=="s"&&i!=="S"&&(this.prevBezierCtrl2=null),this.parseState=0,this.feedS(i));case 8:return this.y1=this.yAxis*Ls(i),this.parseState=9,!0;case 9:return this.x2=Ls(i),this.parseState=10,!0;case 10:return this.y2=this.yAxis*Ls(i),this.parseState=11,!0;case 11:return this.x=Ls(i),this.parseState=12,!0;case 12:{this.y=this.yAxis*Ls(i);let s,a,o;return this.isAbsolute?(s=new j(this.x1,this.y1),a=new j(this.x2,this.y2),o=new j(this.x,this.y)):(s=this.curPoint.add1(this.x1,this.y1),a=this.curPoint.add1(this.x2,this.y2),o=this.curPoint.add1(this.x,this.y)),this.prevBezierCtrl2=a,this.group.push(new Ye([this.curPoint,s,a,o])),this.curPoint=o,this.parseState=7,!0}case 13:return this.rx=parseFloat(i),isFinite(this.rx)?(this.parseState=14,!0):(this.parseState=0,this.feedS(i));case 14:return this.ry=Ls(i),this.parseState=15,!0;case 15:return this.rotation=Ls(i),this.parseState=16,!0;case 16:return this.isLargeArc=Ls(i)===1,this.parseState=17,!0;case 17:return this.sweep=Ls(i)===1?vs.CW:vs.CCW,this.parseState=18,!0;case 18:return this.x=Ls(i),this.parseState=19,!0;case 19:{this.y=this.yAxis*Ls(i);let s;return this.isAbsolute?s=new j(this.x,this.y):s=this.curPoint.add1(this.x,this.y),this.rx&&this.ry&&this.group.push(Se.build1(this.curPoint,s,this.rx,this.ry,this.isLargeArc,this.sweep)),this.curPoint=s,this.parseState=13,!0}case 20:return this.x2=parseFloat(i),isFinite(this.x2)?(this.parseState=21,!0):(i!=="s"&&i!=="S"&&(this.prevBezierCtrl2=null),this.parseState=0,this.feedS(i));case 21:return this.y2=this.yAxis*Ls(i),this.parseState=22,!0;case 22:return this.x=Ls(i),this.parseState=23,!0;case 23:{this.y=this.yAxis*Ls(i);let s,a;this.isAbsolute?(s=new j(this.x2,this.y2),a=new j(this.x,this.y)):(s=this.curPoint.add1(this.x2,this.y2),a=this.curPoint.add1(this.x,this.y));let o;return this.prevBezierCtrl2?o=this.curPoint.add(this.curPoint.sub(this.prevBezierCtrl2)):o=this.curPoint,this.prevBezierCtrl2=s,this.group.push(new Ye([this.curPoint,o,s,a])),this.curPoint=a,this.parseState=20,!0}case 24:return this.x1=parseFloat(i),isFinite(this.x1)?(this.parseState=25,!0):(i!=="s"&&i!=="S"&&(this.prevBezierCtrl2=null),this.parseState=0,this.feedS(i));case 25:return this.y1=this.yAxis*Ls(i),this.parseState=26,!0;case 26:return this.x=Ls(i),this.parseState=27,!0;case 27:{this.y=this.yAxis*Ls(i);let s,a;return this.isAbsolute?(s=new j(this.x1,this.y1),a=new j(this.x,this.y)):(s=this.curPoint.add1(this.x1,this.y1),a=this.curPoint.add1(this.x,this.y)),this.prevBezierCtrl2=s,this.group.push(new Ye([this.curPoint,s,a])),this.curPoint=a,this.parseState=24,!0}default:return this.logger.warning3("unsupported parse state %s",this.parseState),!0}}pushBuffer(i){this.buffer.write(i)}getCleanBuffer(){let i=this.buffer.toString();return this.buffer.clear(),i}tryNotify(){if(this.group.length===0)return!0;{let i=Tt.build1(P4(this.group));return this.group.length=0,this.on(i)}}onException(i){throw i}};var Ade=Fo.fmtNumber,Da=class{constructor(t=!0){this.buffer=new Array;this.state=0;this.prev=null;this.yAxis=t?-1:1}encPl(t){for(let i of t.primitives)this.encPt(i);return this}encPt(t){if(t instanceof ie)this.encLine1(t);else if(t instanceof Se)this.encArc(t);else if(t instanceof Ye)this.encBezier(t);else throw new Error("");return this}encBezier(t){if(t.controls.length===3){let i=t.controls[0],r=t.controls[1],n=t.controls[2];this.state===0?this.buffer.push("M",i.x,this.yAxis*i.y,"Q",r.x,this.yAxis*r.y,n.x,this.yAxis*n.y):i.equals1(this.prev)?this.state!==4?this.buffer.push("Q",r.x,this.yAxis*r.y,n.x,this.yAxis*n.y):this.buffer.push(r.x,this.yAxis*r.y,n.x,this.yAxis*n.y):this.buffer.push("L",i.x,this.yAxis*i.y,"Q",r.x,this.yAxis*r.y,n.x,this.yAxis*n.y),this.prev=n,this.state=4}else if(t.controls.length===4){let i=t.controls[0],r=t.controls[1],n=t.controls[2],s=t.controls[3];this.state===0?this.buffer.push("M",i.x,this.yAxis*i.y,"C",r.x,this.yAxis*r.y,n.x,this.yAxis*n.y,s.x,this.yAxis*s.y):i.equals1(this.prev)?this.state!==3?this.buffer.push("C",r.x,this.yAxis*r.y,n.x,this.yAxis*n.y,s.x,this.yAxis*s.y):this.buffer.push(r.x,this.yAxis*r.y,n.x,this.yAxis*n.y,s.x,this.yAxis*s.y):this.buffer.push("L",i.x,this.yAxis*i.y,"C",r.x,this.yAxis*r.y,n.x,this.yAxis*n.y,s.x,this.yAxis*s.y),this.prev=s,this.state=3}else throw new Error("only bezier has 3 or 4 control points supported");return this}encArc(t){let i=t.svgEnd;return this.state===0?this.buffer.push("M",t.start().x,this.yAxis*t.start().y,"A",t.rx,t.ry,0,t.isLarge()?1:0,t.sweep()===vs.CCW?0:1,i.x,this.yAxis*i.y):t.start().equals1(this.prev)?this.state!==2?this.buffer.push("A",t.rx,t.ry,0,t.isLarge()?1:0,t.sweep()===vs.CCW?0:1,i.x,this.yAxis*i.y):this.buffer.push(t.rx,t.ry,0,t.isLarge()?1:0,t.sweep()===vs.CCW?0:1,i.x,this.yAxis*i.y):this.buffer.push("L",t.start().x,this.yAxis*t.start().y,"A",t.rx,t.ry,0,t.isLarge()?1:0,t.sweep()===vs.CCW?0:1,i.x,this.yAxis*i.y),this.prev=i,this.state=2,this}encLine1(t){return this.encLine2(t.start(),t.end()),this}encLine2(t,i){return this.state===0?this.buffer.push("M",t.x,this.yAxis*t.y,"L",i.x,this.yAxis*i.y):(this.state!==1&&this.buffer.push("L"),t.equals1(this.prev)?this.buffer.push(i.x,this.yAxis*i.y):this.buffer.push(t.x,this.yAxis*t.y,i.x,this.yAxis*i.y)),this.prev=i,this.state=1,this}close(t){return this.state!==0&&(t&&this.buffer.push("Z"),this.state=0,this.prev=null),this}fixNumber(t=4){return this.buffer.forEach((i,r,n)=>{typeof i=="number"&&(i|0)!==i&&(n[r]=+i.toFixed(t))}),this}toString(){return this.buffer.join(" ")}toArray(){return this.buffer}};function G4(e,t){let i=[],r=new so(s=>(i.push(s),!0),!1);r.parse(e),r.finish();let n=new Da(!1);for(let s of i){let a=_4(s,t),o=Math.max(0,Math.log10(10/t)|0);a=a.round(o),n.encPl(a),n.close(!1)}return n.toString()}function qi(e,t=!0){let i=new Array;return new so(r=>(i.push(r),!0),t).parse(e),i}function fs(e,t=!1,i=.01,r){let n=!0;r&&(n=r.reverseY);let s=Array();for(let a of e){let o=new Da(n);o.encPl(a);let l=o.fixNumber(4).toString();s.push(t?U4(l,i):l)}return s.join(" ")}function l1(e,t=!0,i=.01){let r=new Da;e.forEach((s,a)=>{r.encPl(s),r.close(a===e.length-1)});let n=r.toString();return[t?U4(n,i):n]}function U4(e,t=.01){let i=z$(e);try{let r=G4(e,t);return r=X$(r,i),r}catch(r){return console.warn("\u4F7F\u7528\u8D1D\u585E\u5C14\u66F2\u7EBF\u62DF\u5408\u6298\u7EBF\u6BB5\u5931\u8D25\uFF0C\u4F7F\u7528\u8F6C\u5316\u524Dd",r),e}}function z$(e){return e.split(/m/i).slice(1).map(i=>({isClose:/z\s*$/i.test(i)}))}function X$(e,t){let i=e.match(/m/gi),r=e.split(/m/i).slice(1);return r.length&&t.length===r.length?r.reduce((n,s,a)=>(n+=`${i[a]}${s.replace(/z*\s*$/i,t[a].isClose?" Z":" ")}`,n),""):(console.warn("\u672A\u7EA0\u6B63\u8DEF\u5F84\u95ED\u5408\u60C5\u51B5\uFF0C\u53C2\u8003\u6570\u636E\u4E0E\u8F6C\u5316\u540E\u7684\u6570\u636E\u7EC4\u6570\u91CF\u4E0D\u4E00\u81F4\u3002"),e)}function rg(e,t){if(t<0||t>15)return e;let i=/[^\d.e]\d*\.\d+/gi,r=/\.?0+$/,n=a=>{let l=(+a.slice(1)).toFixed(t).replace(r,"");return a[0]+l};return e.replace(/[MLACQSTHV][^MLACQSTHVZ]+/gi,a=>a.replace(i,n))}var za=class za{static toDegrees(t){return t*180/Math.PI}static toRadians(t){return t/180*Math.PI}static regularD(t){return t=t%360,t<0?360+t:t}static regular(t){return t=t%za.PIx2,t<0?za.PIx2+t:t}static toQuarterBase(t){return za.regular((t+za.PI_4)/za.PI_2*za.PI_2)}static toQuarterBaseD(t){return za.regularD(((t+45)/90|0)*90)}static transformD(t,i){return za.toDegrees(za.transform(za.toRadians(t),i))}static transform(t,i){let r=Math.cos(t),n=Math.sin(t),s=new j(i.data[6],i.data[7]),a=new j(r,n).multiply3(i);return za.regular(a.angle(s))}};za.PIx2=Math.PI*2,za.PI_2=Math.PI/2,za.PI_4=Math.PI/4;var _a=za;var Cd=class{constructor(t){this.data=t;let i=Y3(this.data.x1,this.data.y1,this.data.rx,this.data.ry,_a.toRadians(this.data.angle),this.data.large,this.data.sweep,this.data.x2,this.data.y2);this.cx=i.cx,this.cy=i.cy}getMatrix(){return de.scale(this.data.rx,this.data.ry).rotateD(this.data.angle).translate(this.cx,this.cy)}getInverseMatrix(){let t=this.getMatrix();return new de(t.getInverseMatrix().data)}vectorStart(){return new j(this.data.x1,this.data.y1)}vectorEnd(){return new j(this.data.x2,this.data.y2)}vectorCenter(){return new j(this.cx,this.cy)}startAngle(){return tr(-this.vectorStart().angleD2(this.vectorCenter()))}endAngle(){return tr(-this.vectorEnd().angleD2(this.vectorCenter()))}setAngle(t,i){let r=this.getMatrix(),n=_a.toRadians(t),s=this.vectorCenter(),a=Math.cos(n)*10,o=Math.sin(n)*10,l=this.getInverseMatrix(),u=new j(s.x+a,s.y+o).multiply3(l).angle2(j.ORIGIN),h=new j(Math.cos(u),Math.sin(u)).multiply3(r);i==="start"?(this.data.x1=h.x,this.data.y1=h.y):(this.data.x2=h.x,this.data.y2=h.y);let d=new j(this.data.x1,this.data.y1).sub(s),p=new j(this.data.x2,this.data.y2).sub(s),f=d.cross(p);return this.data.sweep===1?this.data.large=f>0?0:1:this.data.large=f<0?0:1,this}points(t=1){let i=this.getMatrix(),r=new de(i.getInverseMatrix().data),n=this.vectorStart().multiply3(r),s=n.angleD2(j.ORIGIN),a=this.vectorEnd().multiply3(r),o=this.data.sweep,l=[],c=0,u=xE(n,{x:0,y:0},a),h=_a.toDegrees(u);n.cross(a)>0?o===1?c=h:c=360-h:o===0?c=h:c=360-h,t||(t=.1);let{ceil:p,abs:f,round:m,max:g,min:b,cos:y,sin:E}=Math,S=p(f(c/t));S=g(2,b(m(c*10),S)),t=f(c/S)*(o===1?1:-1);let w=_a.toRadians(s),x=_a.toRadians(t);l.push(this.vectorStart());for(let I=1;I<S;I++)w+=x,l.push(new j(y(w),E(w)).multiply3(i));return l.push(this.vectorEnd()),l}setArcType(t){return this.data.type=t,this}bbox(){let t=this.points(2),i=new ot;for(let s of t)i.ext2(s);let r=i.build();return{x:r.minX,y:r.minY,width:r.width(),height:r.height()}}bboxEllipse(){let t=this.getMatrix(),i=et.getMatrix6FromMatrix(t);return vi({...this.data,matrix:i},"ellipse")}};function W$(e){let{matrix:t,tempMatrix:i}=e,[r,n,s,a,o,l]=i||t,c=Math.atan2(s,r),u=Math.atan2(a,n),h=Math.cos(c),d=Math.sin(c),p=Math.abs(r*h+s*d);h=Math.cos(u),d=Math.sin(u);let f=Math.abs(n*h+a*d);return{x:o-p,y:l-f,width:p*2,height:f*2}}function q$(e){let t=new Cd(e),i=t.getMatrix(),r=t.vectorStart(),n=t.vectorEnd(),[s,a,o,l,c,u]=et.getMatrix6FromMatrix(i),h=Math.atan2(o,s),d=Math.atan2(l,a),p=[];for(let m of[h,h+Math.PI,d,d+Math.PI]){let g=Math.cos(m),b=Math.sin(m),y=s*g+o*b+c,E=a*g+l*b+u;p.push(new j(y,E))}let f=new ot;f.ext2(r).ext2(n);for(let m of p){let g=r.sub(m).cross(n.sub(m));if(e.sweep===0){if(g<0)continue}else if(g>0)continue;f.ext2(m)}return kc(f.build())}function Y4(e){let{matrix:t,tempMatrix:i}=e,r=et.createMatrixFrom6(i||t),n=0,s=1,a=0,o=1,l=[[n,a],[s,a],[s,o],[n,o]],c=new ot;for(let h of l){let d=new j(h[0],h[1]).multiply3(r);c.ext6(d.x,d.y)}let u=c.build();return kc(u)}function J$(e){let t=qi(e.tempD||e.d,!1),i=new ot;for(let n of t)for(let s of n.primitives)s instanceof Ye?i.ext1(s.bboxWithControls()):i.ext1(s.bbox());let r=i.build();return kc(r)}function p2(e){let t=qi(e.tempD||e.d,!1),i=new ot;for(let n of t)for(let s of n.primitives)if(s instanceof Ye){let a=new ot;s.getBezierPoints(.5,l=>a.ext2(l));let o=a.build();i.ext1(o)}else i.ext1(s.bbox());let r=i.build();return{x:r.minX,y:r.minY,width:r.width(),height:r.height()}}function K$(e){let t=et.createMatrixFrom6(e.tempMatrix||e.matrix),i=new ot().ext6(0,0).ext6(e.cacheWidth,-e.cacheHeight).build().transform(t);return{x:i.minX,y:i.minY,width:i.width(),height:i.height()}}function $$(e){let t=new ot;t.ext6(e.measureX1,e.measureY1),t.ext6(e.measureX2,e.measureY2),t.ext6(e.x1,e.y1),t.ext6(e.x2,e.y2);let i=t.build();return{x:i.minX,y:i.minY,width:i.width(),height:i.height()}}function Z$(e){let t=new ot;t.ext6(e.x1,e.y1),t.ext6(e.x2,e.y2),t.ext6(e.angleX,e.angleY);let i=t.build();return{x:i.minX,y:i.minY,width:i.width(),height:i.height()}}function Q$(e){let t=new ot;t.ext6(e.x1,e.y1),t.ext6(e.x2,e.y2);let i=t.build();return{x:i.minX,y:i.minY,width:i.width(),height:i.height()}}function eZ(e){let t=new ot;t.ext6(e.x1,e.y1),t.ext6(e.x2,e.y2);let i=t.build();return{x:i.minX,y:i.minY,width:i.width(),height:i.height()}}function tZ(e){let t=new ot;t.ext6(e.x,e.y);let i=t.build();return{x:i.minX,y:i.minY,width:0,height:0}}function iZ(e){let t=new ot;t.ext2(e.start.primitivePoint),t.ext2(e.start.otherPoint),t.ext2(e.end.primitivePoint),t.ext2(e.end.otherPoint);let i=t.build();return{x:i.minX,y:i.minY,width:i.width(),height:i.height()}}var H4={text:e=>K$(e),obj:e=>Y4(e),ellipse:e=>W$(e),arc:e=>q$(e),rect:e=>Y4(e),group:e=>J$(e),dimensionLength:e=>$$(e),dimensionAngle:e=>Z$(e),dimensionRadius:e=>Q$(e),dimension:e=>iZ(e),auxiliaryLine:e=>eZ(e),auxiliaryPoint:e=>tZ(e),_runtime:e=>{switch(e.subCmdKey){case"select-box":return kc(St.extendRect(e));default:break}}},ZA=["text","obj","ellipse","rect","group","arc"];function f2(e,t){return St.extendRect(vi(e,t))}function vi(e,t){return t=t||e.cmdKey,H4[t](e)}function j4(){let e=new Map;return t=>{if(e.has(t.gId))return e.get(t.gId);{let i=vi(t);return e.set(t.gId,i),i}}}function sg(e){let t=new ot;for(let i of e)t.ext10(H4[i.cmdKey](i));return kc(t.build())}function kc(e){return{x:e.minX,y:e.minY,width:e.width(),height:e.height()}}async function z4(e,t={},i=k.gJsonCache){jl(e)||(e=[e]),i||(i=k.gJsonCache);let r=i;if(!Array.isArray(e))return i;for(let n of e){let s=t;if((!s||!Object.keys(s).length)&&console.error("update param error: "+JSON.stringify(s)),n.cmdKey==="canvas"){await Xt.modify_json(s,i);continue}let a=r[n.cmdKey][n.id];if(!a){console.error("Not Found Json in JsonCache!",t,"\u2764\u8BF7\u68C0\u67E5\u4EE3\u7801\u2764");continue}rZ(n.cmdKey,a,s)}return i}function rZ(e,t,i){for(let r in i){if(!$e(i,r))continue;let n=i[r];switch(r){case"attr-transparency-print":case"attr-transparency-white":if(+t.layer===2){let s=r.substring(5);s=w3.camelize(s),t[s]=+n;continue}break;case"attr-rotation":t.rotation=-n;break;default:break}r==="attr-name"?t.name=i[r]:r==="attr-locked"?t.locked=i[r]==="yes":r==="attr-hide"?t.hide=i[r]==="yes":r==="attr-transparency"?t.opacity=1-i[r]/100:r==="attr-cover"?t.cover=i[r]==="yes":r==="attr-scope"&&(t.scope=+i[r])}}var m2=nZ("3.2.130");function nZ(e){return e.split(".").slice(0,3).join(".")}var g2=class{constructor(){this.reactor=void 0;this.mouseX=void 0;this.mouseY=void 0;this.deltaX=void 0;this.deltaY=void 0;this.key=void 0;this.keyCode=void 0;this.detail=void 0}},Cu=class{constructor(){this.detached=!1}detach(){this.detached=!0}isDetached(){return this.detached}onAnyEventStart(t){}onAnyEventEnd(t){}onKeyDown(t){}onKeyUp(t){}onMouseLeftDown(t){}onMouseMidDown(t){}onMouseRightDown(t){}onMouseLeftUp(t){}onMouseMidUp(t){}onMouseRightUp(t){}onMouseMove(t){}onMouseOver(t){}onMouseOut(t){}onMouseWheel(t){}onDoubleClick(t){}onResize(t){}onCustom(t){}},y2=class{constructor(t,i){this.processors=new Array;this.onMouseMove=Id(t=>{let i=this.contextInitializer();i.mouseX=t.clientX,i.mouseY=t.clientY,i.originalEvent=t,this.processEvent(i,r=>r.onMouseMove(i))});this.element=t,this.contextInitializer=i}checkCanMouseDownUp(t){return!(t.target instanceof HTMLTextAreaElement)}addProcessor(t){this.processors.push(t)}processEvent(t,i){t.reactor=this;let r=this.processors.length,n;for(n=0;n<r;n++){let s=this.processors[n];if(!s.isDetached()&&(s.onAnyEventStart(t),i(s)===fh))break}for(n--;n>=0;n--){let s=this.processors[n];s.isDetached()||s.onAnyEventEnd(t)}for(n=0;n<this.processors.length;){let s=this.processors[n];s.isDetached()?ps.remove(this.processors,s):n++}}onKeyDown(t){let i=this.contextInitializer();i.key=t.key,i.keyCode=t.code,this.processEvent(i,r=>r.onKeyDown(i))}onKeyUp(t){let i=this.contextInitializer();i.key=t.key,i.keyCode=t.code,i.originalEvent=t,this.processEvent(i,r=>r.onKeyUp(i))}onMouseDown(t){if(!this.checkCanMouseDownUp(t))return;let i=this.contextInitializer();i.mouseX=t.clientX,i.mouseY=t.clientY,i.originalEvent=t,t.button===0?this.processEvent(i,r=>r.onMouseLeftDown(i)):t.button===1?this.processEvent(i,r=>r.onMouseMidDown(i)):t.button===2&&this.processEvent(i,r=>r.onMouseRightDown(i))}onMouseOver(t){let i=this.contextInitializer();i.mouseX=t.clientX,i.mouseY=t.clientY,i.originalEvent=t,this.processEvent(i,r=>r.onMouseOver(i))}onMouseOut(t){let i=this.contextInitializer();i.mouseX=t.clientX,i.mouseY=t.clientY,i.originalEvent=t,this.processEvent(i,r=>r.onMouseOut(i))}onMouseUp(t){if(!this.checkCanMouseDownUp(t))return;let i=this.contextInitializer();i.mouseX=t.clientX,i.mouseY=t.clientY,i.originalEvent=t,t.button===0?this.processEvent(i,r=>r.onMouseLeftUp(i)):t.button===1?this.processEvent(i,r=>r.onMouseMidUp(i)):t.button===2&&this.processEvent(i,r=>r.onMouseRightUp(i))}onMouseWheel(t){let i=this.contextInitializer();i.deltaX=t.deltaX,i.deltaY=t.deltaY,i.mouseX=t.clientX,i.mouseY=t.clientY,i.originalEvent=t,this.processEvent(i,r=>r.onMouseWheel(i))}onDoubleClick(t){if(!this.checkCanMouseDownUp(t))return;let i=this.contextInitializer();i.mouseX=t.clientX,i.mouseY=t.clientY,i.originalEvent=t,this.processEvent(i,r=>r.onDoubleClick(i))}onResize(){let t=this.contextInitializer();this.processEvent(t,i=>i.onResize(t))}onCustom(t){if(t instanceof CustomEvent){let i=this.contextInitializer();i.detail=t.detail,this.processEvent(i,r=>r.onCustom(i))}}install(){window.addEventListener("keydown",this.onKeyDown.bind(this),!1),window.addEventListener("keyup",this.onKeyUp.bind(this),!1),this.element.addEventListener("mousedown",this.onMouseDown.bind(this),!1),this.element.addEventListener("mouseup",this.onMouseUp.bind(this),!1),this.element.addEventListener("mousemove",this.onMouseMove.bind(this),!1),this.element.addEventListener("wheel",this.onMouseWheel.bind(this),!1),this.element.addEventListener("dblclick",this.onDoubleClick.bind(this),!1),this.element.addEventListener("custom",this.onCustom.bind(this),!1),window.addEventListener("resize",this.onResize.bind(this),!1),this.element.oncontextmenu=()=>!1}uninstall(){console.log("uninstall...")}getProcessors(){return this.processors}};var b2=class extends g2{constructor(){super(...arguments);this.canvasX=void 0;this.canvasY=void 0;this.ctrlKeyDown=void 0;this.shiftKeyDown=void 0;this.altKeyDown=void 0;this.mouseLeftMoving=void 0;this.mouseRightMoving=void 0;this.mouseMidMoving=void 0}};var x2=class extends Cu{constructor(){super(...arguments);this.mouseLeftStatus=0;this.mouseRightStatus=0;this.mouseMidStatus=0;this.ctrlKeyDown=!1;this.shiftKeyDown=!1;this.altKeyDown=!1}onAnyEventStart(i){if(i.mouseX!==void 0&&i.mouseY!==void 0){let r=vh({x:i.mouseX,y:i.mouseY});i.canvasX=r.x,i.canvasY=r.y}i.originalEvent&&(this.altKeyDown=i.originalEvent.altKey||!1),i.ctrlKeyDown=this.ctrlKeyDown,i.shiftKeyDown=this.shiftKeyDown,i.altKeyDown=this.altKeyDown,i.mouseLeftMoving=this.mouseLeftStatus===2,i.mouseRightMoving=this.mouseRightStatus===2,i.mouseMidMoving=this.mouseMidStatus===2}onKeyChange(i,r){i.key==="Control"&&(this.ctrlKeyDown=r,i.ctrlKeyDown=r),i.key==="Shift"&&(this.shiftKeyDown=r,i.shiftKeyDown=r),i.key==="Alt"&&(this.altKeyDown=r,i.altKeyDown=r)}onKeyDown(i){this.onKeyChange(i,!0)}onKeyUp(i){this.onKeyChange(i,!1)}onMouseRightDown(i){this.mouseRightStatus=1}onMouseRightUp(i){this.mouseRightStatus=0}onMouseLeftDown(i){this.mouseLeftStatus=1}onMouseLeftUp(i){this.mouseLeftStatus=0}onMouseMidDown(i){this.mouseMidStatus=1}onMouseMidUp(i){this.mouseMidStatus=0}onMouseMove(i){this.mouseRightStatus===1&&(this.mouseRightStatus=2),this.mouseLeftStatus===1&&(this.mouseLeftStatus=2),this.mouseMidStatus===1&&(this.mouseMidStatus=2)}};var ag=class extends b2{constructor(){super(...arguments);this.toolFinished=void 0;this.startX=void 0;this.startY=void 0;this.snapX=void 0;this.snapY=void 0}},yn=class extends Cu{},ii={drag_anchor_tool:Symbol.for("drag_anchor_tool"),drag_control_dot_tool:Symbol.for("drag_control_dot_tool"),drag_control_dot_arc_tool:Symbol.for("drag_control_dot_arc_tool"),highlight:Symbol.for("highlight"),drag_tool:Symbol.for("drag_tool"),rotate_by_anchor_tool:Symbol.for("rotate_by_anchor_tool"),adapt_view_tool:Symbol.for("adapt_view_tool"),drag_select_area_tool:Symbol.for("drag_select_area_tool"),draw:Symbol.for("draw"),place_lib_tool:Symbol.for("place_lib_tool"),paste_tool:Symbol.for("paste_tool"),referencePoint_tool:Symbol.for("referencePoint_tool"),rect_select_tool:Symbol.for("rect_select_tool")};var c1=!1,u1,ca=class ca extends yn{constructor(){super()}getSymbol(){return ii.adapt_view_tool}static setAdaptAreaSelectionView(t){c1!==t&&(c1=t,t||this.hideSelectBox())}static isAdaptAreaSelectionView(){return c1}install(){console.log(this.getSymbol(),"installed"),u1=O3(H.selectBox1),H.svgRoot.appendChild(u1)}uninstall(){console.log(this.getSymbol(),"uninstalled"),dt(u1)}onMouseLeftUp(t){if(!c1)return;ca.leftClickTimes++;let{originalEvent:i}=t,{x:r,y:n}=ui(i,!1);if(ca.leftClickTimes%2===1&&(ca.firstClickDot={x:r,y:n}),ca.leftClickTimes%2===0){let s={x:Math.min(ca.firstClickDot.x,r),y:Math.min(ca.firstClickDot.y,n),width:Math.abs(ca.firstClickDot.x-r),height:Math.abs(ca.firstClickDot.y-n)};Jl(s,1),ca.hideSelectBox(),document.dispatchEvent(new MouseEvent("mousemove",{clientX:t.mouseX,clientY:t.mouseY}))}}onMouseRightUp(t){ca.isAdaptAreaSelectionView()&&W4(),t.toolFinished=!0}onMouseMove(t){if(!c1||ca.leftClickTimes%2===0)return;let{x:i,y:r}=ca.firstClickDot,{originalEvent:n}=t,{x:s,y:a}=ui(n,!1),o=s-i,l=a-r;h1(ca.firstClickDot.x,ca.firstClickDot.y,o,l,{target:u1})}static hideSelectBox(){Du({target:u1}),ca.leftClickTimes=0}};ca.leftClickTimes=0;var Os=ca;function X4(){return Os.leftClickTimes%2===0?(W4(),!0):(Os.hideSelectBox(),Os.firstClickDot=null,!1)}function W4(){H.windowBridge.publish("toggleLinkbuttonActive",[["adaptAreaSelectionView"],!1],ut()),pr(),document.querySelector("#g1").classList.remove("none-events"),Os.setAdaptAreaSelectionView(!1)}var ri={renderer:null,history:null};var E2=class{constructor(t){this.id="selectBox1";this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}render(){return ri.renderer.attrs(this.id,{display:"",width:this.width,height:this.height,x:this.x,y:this.y,stroke:H.panelThemeCache.color.select,visible:"visible"}),this}updateData(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}unmount(){throw new Error("Method not implemented.")}toData(){let t={cmdKey:"_runtime",subCmdKey:"select-box",x:this.x,y:this.y,width:this.width,height:this.height},i=k.getRuntime(this.id)||{};return Object.assign(i,t)}setData(){k.setRuntime(this.id,this.toData())}multiply3(t){throw new Error("Method not implemented.")}rotateSelf(t,i){throw new Error("Method not implemented.")}};var fr=(e,t={create8Dots:!1})=>{if(Array.isArray(e)&&e.length){if(e.length===1){let i=t.create8Dots&&ms(e[0])||[],r=i.slice(0,8).concat(i[0],i[1]).join(" ");te(H.selectBox1,{display:"none"}),Th(r,"block"),["group"].includes($t(e[0]))&&wt.isAnchorMode(e[0].id)&&Th("","none")}else{let i=Rr(e,!0);h1(i.x,i.y,i.width,i.height),new E2(i).render().setData(),ms(H.selectBox1),Th("","none")}return}else console.error(e)};function Th(e,t=""){ri.renderer.attrs("ctrl-polyline",{points:e,display:t})}var QA=class{constructor(){this.controlDotArr=[];this.controlLineArr=[];this.bezierHandleArr=[];this.circleArr=[];this.handleInfo=[];this.anchorInfo=[];this.dotsInfo=[];this.addListener=b4(()=>{document.addEventListener("click",t=>{if(!H.doctype)return;let{target:i,ctrlKey:r}=t,{x:n,y:s}=ui(t);!r&&this.isClickedAnchor(i,n,s)&&this.clickHandler(t)})});window.frameElement&&(this.gControlDotsContainer=le("gControlDots"),this.gControlLinesContainer=le("gControlLines"),this.addListener())}isClickedAnchor(t,i,r){if($t(t)!=="cdot")return!1;let n=this.findControlDot(i,r);return n&&n.type==="anchor"?n:!1}findControlDot(t,i){let r=Number.MAX_SAFE_INTEGER,n;for(let s of[...this.anchorInfo,...this.handleInfo,...this.dotsInfo]){let a=Ro(t,i,s.x,s.y);a<r&&a<s.size**2&&(r=a,n=s)}return n}findControlDotByIndex(t){for(let i of[...this.anchorInfo,...this.handleInfo])if(i.index===t)return i}findControlDotById(t){for(let i of[...this.anchorInfo,...this.handleInfo,...this.dotsInfo])if(i.id===t)return i;return null}findCanRotateControlDotInfo(t,i){var l,c,u,h;if((c=(l=this.gControlDotsContainer)==null?void 0:l.classList)!=null&&c.contains("hide")||!(((h=(u=this.anchorInfo)==null?void 0:u[0])==null?void 0:h.type)==="bbox"))return null;let n=new j(t,i);if(mh(n,this.anchorInfo.slice(0,4)))return null;let a,o=(16/H.gZoom)**2;for(let d of this.anchorInfo){let p=Ro(t,i,d.x,d.y);p<o&&(o=p,a=d)}return a}anchorOrHandleHasSelected(){for(let t of[...this.anchorInfo,...this.handleInfo])if(t.selected)return t;return!1}selectAnchorOrHandle(t){for(let i of[...this.anchorInfo,...this.handleInfo]){let{id:r,selected:n}=i;if(n){let s=le(r);s&&s.classList.remove("selected"),i.selected=!1}r===t&&(le(t).classList.add("selected"),i.selected=!0)}this.selectedCdotId=t}clickHandler(t){let{target:i,ctrlKey:r}=t;i=i;let n=i.dataset.index;i.classList.add("selected"),r?wt.addOrRemoveHandle(+n):(this.hideAllHandle(),this.hideAllLines(),this.showAroundHandleByIndex(+n),this.showHelperLine(+n))}removeAllAnchor(){let t=[];for(let i of this.controlDotArr)i.dataset.type==="anchor"?ri.renderer.removeNode(i.id):t.push(i);return this.controlDotArr=t,this}hideAllHandle(){for(let t of this.bezierHandleArr)t.classList.add("hide");return this}hideAllLines(){for(let t of this.controlLineArr)t.classList.add("hide");return this}showHelperLine(t=0){let i=this.getNextDisplayAnchor(t);for(let r of this.controlLineArr){let n=+r.dataset.belong;i.includes(n)&&r.classList.remove("hide")}}getNextDisplayAnchor(t=0){let i=[t],r=this.anchorInfo.length,n=this.anchorInfo.findIndex(s=>t===s.index);return this.anchorInfo[n+1]?i.push(this.anchorInfo[n+1].index):i.push(this.anchorInfo[0].index),this.anchorInfo[n-1]?i.push(this.anchorInfo[n-1].index):i.push(this.anchorInfo[r-1].index),i}showAroundHandleByIndex(t){let i=this.getNextDisplayAnchor(t);for(let r of this.bezierHandleArr){let n=+r.dataset.belong||0;i.includes(n)&&Oo(r,"hide")}}showHandleOfIndexes(t){this.hideAll();for(let i of this.bezierHandleArr){let r=+i.dataset.belong||0;t.includes(r)&&Oo(i,"hide")}for(let i of this.controlLineArr){let r=+i.dataset.belong;t.includes(r)&&i.classList.remove("hide")}}emptyChildren(t,i){for(let r=t;r<i.length;r++){let n=i[r];dt(n)}return i.length=t,this}dataset(t,i={}){for(let r in i)t.dataset[r]=i[r]}createBezierHandle(t){let i=t.filter(n=>n.display),r=i.length;for(let n=0;n<r;n++){let{id:s,x:a,y:o,size:l,index:c,belong:u,type:h,selected:d}=i[n],p=this.bezierHandleArr[n];p?(p.id=s,this.dataset(p,{x:a,y:o,size:l,belong:u,index:c}),this.updateDotPosition(p,i[n])):(p=this.createCircleEle(i[n]),this.bezierHandleArr.push(p),this.gControlDotsContainer.appendChild(p),this.dataset(p,{belong:u,index:c,type:h}),p.classList.add("hide")),d?p.classList.add("selected"):p.classList.remove("selected")}this.emptyChildren(r,this.bezierHandleArr)}createHoverAnchor(t,i,r){let n=this.createRhombus(t,i,r);return this.gControlDotsContainer.appendChild(n),n}createAnchorDots(t){let i=t.length;for(let r=0;r<i;r++){let{id:n,x:s,y:a,size:o,index:l,belong:c,type:u,selected:h}=t[r],d=this.createRect(n,s,a,o);u==="anchor"&&(d=this.createRhombus(s,a,n)),this.controlDotArr.push(d),this.gControlDotsContainer.appendChild(d),this.dataset(d,{belong:c,index:l,type:u}),h?d.classList.add("selected"):d.classList.remove("selected")}}before(){let t=le("gControlDots"),i=le("gControlRects"),r=le("gControlLines"),n=[t,i,r];for(let s of n)s.classList.remove("hide")}create(t){for(let i of t)switch(i.type){case"solid-circle":let r=this.createCircleEle(i,{fill:"var(--selectColor)"});this.circleArr.push(r),this.gControlDotsContainer.appendChild(r),this.dataset(r,{type:"solid-circle"});break;default:break}}mainV2(t){let i=t.cmdkey,r=4/H.gZoom*2,n=[];if(this.anchorInfo=n,t.bbox){let a=t.bbox,o=a.length/2;for(let l=0;l<o;l++){let c=a[l*2],u=a[l*2+1],h="cdot"+l,d={id:h,x:c,y:u,size:r,degree:0,index:l,type:"bbox",selected:h===this.selectedCdotId,belongCmdKey:i};n.push(d)}}if(t.anchor){let a=t.anchor,o=a.length/2;for(let l=0;l<o;l++){let c=a[l*2],u=a[l*2+1],h="cdot-anchor-"+l,d={id:h,x:c,y:u,size:r,degree:45,index:l,type:"anchor",selected:h===this.selectedCdotId,belongCmdKey:i};n.push(d)}}let s=[];if(this.dotsInfo=s,t["solid-circle"]){let a=t["solid-circle"],o=a.length;for(let l=0;l<o;l++){let{x:c,y:u,type:h}=a[l],d="cdot-handle-"+l,p={id:d,x:c,y:u,size:r/2,degree:0,index:l,type:h,selected:d===this.selectedCdotId,belongCmdKey:i};s.push(p)}}this.emptyChildren(0,this.circleArr).create(s),this.emptyChildren(0,this.controlDotArr).createAnchorDots(n)}main(t){if(this.before(),Ua(t))return this.mainV2(t);let i=t.length/2,r=t.isModifyAnchor,n=t.handleIndexes||new Map,s=4/H.gZoom*2,a=[],o=[];for(let l=0;l<i;l++){let c=t[l*2],u=t[l*2+1],h="cdot"+l,d={id:h,x:c,y:u,size:s,degree:r?45:0,index:l,type:r?"anchor":"bbox",selected:h===this.selectedCdotId};if(n.get(l)){d.belong=n.get(l).belong,d.display=n.get(l).display,d.type="handle",d.size/=2,a.push(d);continue}o.push(d)}(!this.compareInfo(this.handleInfo,a)||!this.compareInfo(this.anchorInfo,o))&&(this.emptyChildren(0,this.controlDotArr),this.emptyChildren(0,this.circleArr),this.createAnchorDots(o),this.createBezierHandle(a),this.createLine(t),this.handleInfo=a,this.anchorInfo=o)}compareInfo(t,i){return t.length===i.length?t.every((r,n)=>{let s=i[n];for(let a in r)if(r[a]!==s[a])return!1;return!0}):!1}isNearBBoxEdge(t){let i=this.anchorInfo.filter(o=>o.type==="bbox").filter((o,l)=>l<4),r=i.length;if(r!==4)return-1;let n=new ot;for(let o of i)n.ext6(o.x,o.y);let s=n.build();if(ni(0,s.area()))return-1;let a=no();for(let o=0;o<r;o++){let l=o,c=o+1;l===r-1&&(c=0);let u=i[l],h=i[c],d=new ot;if(d.ext6(u.x,u.y).ext6(h.x,h.y).ext7(a),!d.build().isContains1(t.x,t.y))continue;if(ra(t,u,h).d<a){if(u.index===0&&h.index===1)return 4;if(u.index===1&&h.index===2)return 5;if(u.index===2&&h.index===3)return 6;if(u.index===3&&h.index===0)return 7}}return-1}createLine(t){let i=t.c_helper_lines;if(!i){this.gControlLinesContainer.classList.add("hide");return}let r=i.length;for(let n=0;n<r;n++){let{from:s,to:a,belong:o}=i[n],l={x:t[s*2],y:t[s*2+1]},c={x:t[a*2],y:t[a*2+1]},u=this.controlLineArr[n];ft(o)&&console.error("check code"),u?te(u,{x1:l.x,y1:l.y,x2:c.x,y2:c.y,"data-belong":o}):(u=this.createLineEle(l,c),u.dataset.belong=o,this.gControlLinesContainer.appendChild(u),this.controlLineArr.push(u))}this.emptyChildren(r,this.controlLineArr)}createLineEle(t,i){return Et("line",{class:"hide",x1:t.x,y1:t.y,x2:i.x,y2:i.y,"stroke-width":1,stroke:"var(--highlight)","stroke-dasharray":"3,3"})}createCircleEle(t,i={}){let{x:r,y:n,size:s}=t,a=de.scale(s,s).translate(r,n),o=et.getMatrix6FromMatrix(a);return Et("circle",{id:t.id,cx:0,cy:0,r:1,fill:"transparent",stroke:"var(--selectColor)",transform:`matrix(${o})`,c_partid:"cdot",class:"handle-dot","vector-effect":"non-scaling-stroke","data-cx":r,"data-cy":n,"data-size":s,...i})}createRhombus(t,i,r){let n=4/H.gZoom*2;return this.createRect(r,t,i,n,45)}createRect(t,i,r,n,s=0){let a=de.scale(n,n).rotateD(s).translate(i,r),o=et.getMatrix6FromMatrix(a);return Et("rect",{id:t,class:"control-dot",x:-.5,y:-.5,width:1,height:1,c_partid:"cdot","strok-width":1,stroke:"var(--selectColor)",fill:"transparent",transform:`matrix(${o})`,"vector-effect":"non-scaling-stroke","data-x":i,"data-y":r,"data-degree":s})}zoom(t){let i=this.gControlDotsContainer.children;for(let r of i){if(r.id=="insert-anchor"){let s={x:+te(r,"data-x"),y:+te(r,"data-y"),size:t,degree:+te(r,"data-degree")};this.updateDotPosition(r,s);continue}let n=this.findControlDotById(r.id);if(!n)return;n.size=r.nodeName.toLocaleLowerCase()==="circle"?t/2:t,this.updateDotPosition(r,n)}}updateDotPosition(t,i){let{x:r,y:n,size:s,degree:a}=i,o=de.scale(s,s).rotateD(a).translate(r,n),l=et.getMatrix6FromMatrix(o);ht.updateTransform(l,t)}hideAll(){return this.hideAllLines().hideAllHandle(),this.selectedCdotId=null,this}emptyData(){return this.anchorInfo=[],this}},ar=new QA;var eC=class{sync(t,i,r){let n=new _i(t),a=n.getMatrix().multiply3(i),o=et.getMatrix6FromMatrix(a),l=n.getInverseMatrix(),c=new j(t.x1,t.y1).multiply3(l).multiply3(a),u=new j(t.x2,t.y2).multiply3(l).multiply3(a),h=a.isMirrored()?t.sweep===1?0:1:t.sweep,d=et.calcuEllipse(o);t.temp={gId:t.gId,rx:d.a,ry:d.b,x1:c.x,y1:c.y,x2:u.x,y2:u.y,angle:d.degree,sweep:h,large:t.large,rotation:t.rotation},n.render(t.temp),r.updateD&&(Object.assign(t,t.temp),delete t.temp)}syncArc(t,i,r){let n=zt.checkOne("arc",t,i);n!==!1&&zt.addCallBack(()=>{var s;n(),this.sync(t,i,r),(s=r==null?void 0:r.fn)==null||s.call(r),_i.createHalfArc(t.gId)})}syncArcSize(t,i,r,n){let{x:s,y:a,width:o,height:l}=vi(t),c=1,u=1;if(ft(r)||(c=r/o),ft(n)||(u=n/l),c===0||u===0||c===1&&u===1)return;let h=de.scale(c,u).setOrigin1(i);this.syncArc(t,h,{updateD:!0})}get8Dots(t){let i=0,r=0,n=1,s=1,a=i-n,o=i+n,l=r-s,c=r+s,u=[[a,l],[o,l],[o,c],[a,c],[i,l],[o,r],[i,c],[a,r]],h=t.temp||t,{rotation:d,angle:p}=h,f=new _i(h).vectorCenter(),m=de.scale(h.rx,h.ry).rotateD(p||d).translate(f.x,f.y),g=[];for(let b of u){let y=new j(b[0],b[1]).multiply3(m);g.push(y.x,y.y)}return g}get8Dots2(t){let i=de.rotateD(-t.rotation).setOrigin(t.x1,t.y1),r=new _i(t),s=r.getMatrix().multiply3(i),a=et.getMatrix6FromMatrix(s),o=r.getInverseMatrix(),l=new j(t.x1,t.y1).multiply3(o).multiply3(s),c=new j(t.x2,t.y2).multiply3(o).multiply3(s),u=s.isMirrored()?t.sweep===1?0:1:t.sweep,h=et.calcuEllipse(a),d={rx:h.a,ry:h.b,x1:l.x,y1:l.y,x2:c.x,y2:c.y,angle:h.degree,sweep:u,large:t.large,rotation:t.rotation},{x:p,y:f,width:m,height:g}=vi(d,"arc"),b=[[p,f],[p+m,f],[p+m,f+g],[p,f+g],[p+m/2,f],[p+m,f+g/2],[p+m/2,f+g],[p,f+g/2]],y=[],E=de.rotateD(t.rotation).setOrigin(t.x1,t.y1);for(let[S,w]of b){let x=new j(S,w).multiply3(E);y.push(x.x,x.y)}return y}rotate(t,i,r){let n=this.getRotationMatrix(t,i,r);n&&this.syncArc(t,n,{updateD:!0,fn(){t.rotation=+i.toFixed(2)}})}getRotationMatrix(t,i,r){if(!r){let{x:n,y:s,width:a,height:o}=vi(t);r=new j(n+a/2,s+o/2)}return de.rotateD(i-t.rotation).setOrigin1(r)}},mr=new eC;var _u=class{async getPath(t,i){i=i||{},i.fontFamily=i.fontFamily||"Arial",i.fontSize=+i.fontSize||12,i.fontWeight=i.fontWeight||"normal",i.fontStyle=i.fontStyle||"normal",i.underline=i.underline||"none";let r=t.split(`
`),n=new Array,s=0,a=0,o=0,l=new Array,c=i.fontSize;for(let f=0,m=r.length;f<m;f++){let g=r[f];if(g.length==0){a+=c;continue}if(Ic){let b=(await H.windowBridge.rpcCall("/engine/extractFontBezier",[g,{"font-family":i.fontFamily,"font-size":i.fontSize,"font-weight":i.fontWeight,"font-style":i.fontStyle,"text-decoration":i.underline}],ut())).message,y=b[0],E=b[1],S=b[2];s=Math.max(s,E),o=a;let w=new so(x=>(l.push(x),!0),!1);y.forEach(x=>x.forEach(I=>w.parse(I))),a+=S}else{let b=(await H.windowBridge.rpcCall("/engine/extractFont",[g,{"font-family":i.fontFamily,"font-size":i.fontSize,"font-weight":i.fontWeight,"font-style":i.fontStyle,"text-decoration":i.underline}],ut())).message,y=b[0],E=b[1],S=b[2];c=S,s=Math.max(s,E),o=a,y.forEach(w=>{for(let x of w)for(let I=0,A=x.ys.length;I<A;I++)x.ys[I]-=o,i.x&&(x.xs[I]+=+i.x),i.y&&(x.ys[I]-=+i.y);n.push(w)}),a+=S}}let u=n.length;for(let f=0;f<u;f++)n[f].forEach(g=>{let b=g.xs.length,y=[];for(let S=0;S<b;S++){let w=new j(this.toFix(g.xs[S],5),this.toFix(g.ys[S],5));y.push(w)}let E=Tt.build4(y);l.push(E)});let h=de.translate(0,o);l=l.map(f=>f.multiply3(h));let d=fs(l,!1),p=new St(0,s,0,a);return{d,bbox:p}}toFix(t,i=1){let r=Math.pow(10,i);return Math.round(t*r)/r}};function q4(e={}){let t={title:"State",allKey:"all-state",lists:[{key:"all-state",title:"All"},{key:"visible",title:"Valid(Valid = Yes)",checked:!0,visible:!0},{key:"hide",title:"Not Valid(Valid = No)",checked:!0,visible:!0},{key:"lock",title:"Lock(Lock = Yes)",checked:!0,visible:!0},{key:"unlock",title:"Unlocked(Lock = No)",checked:!0,visible:!0}]};for(let i of t.lists)$e(e,i.key)&&Object.assign(i,e[i.key]);return t}function J4(){return{title:"The element type",allKey:"all-element-type",lists:[{key:"all-element-type",title:"All"},{key:"group",title:"Shape",checked:!0,visible:!0},{key:"rect",title:"Rect",checked:!0,visible:!0},{key:"ellipse",title:"Ellipse",checked:!0,visible:!0},{key:"arc",title:"Elliptical Arc",checked:!0,visible:!0},{key:"text",title:"Text",checked:!0,visible:!0},{key:"obj",title:"Image",checked:!0,visible:!0},{key:"auxiliaryLine",title:"Auxiliary",checked:!0,visible:!0},{key:"dimension",title:"Smart Dimension",checked:!0,visible:!0},{key:"dimensionLength",title:"Dimension",checked:!0,visible:!0}]}}var aZ={Common:[q4({lock:{checked:!1}}),J4()],"Hide inactive elements":[q4({hide:{visible:!1}}),J4()]},Kl={checked:!0,visible:!0},_fe={"all-state":{visible:{...Kl},hide:{...Kl},lock:{visible:!0,checked:!1},unlock:{...Kl}},"all-element-type":{obj:{...Kl},group:{...Kl},rect:{...Kl},ellipse:{...Kl},text:{...Kl},arc:{...Kl},auxiliaryLine:{...Kl},dimension:{...Kl},dimensionLength:{...Kl}}},S2={};for(let e of aZ.Common){let t=S2[e.allKey]={};for(let i of e.lists)t[i.key]={...i}}function Xa(){return S2}function d1(e){return{auxiliaryPoint:"auxiliaryLine",dimensionAngle:"dimensionLength",dimensionRadius:"dimensionLength"}[e]||e}var w2=class w2{static add(t){this.stack.push(t),this.stack.length>100&&this.stack.shift()}static get useable(){if(!this.stack.length)return!1;switch(this.stack[this.stack.length-1].type){case 4:case 2:case 3:case 10:case 5:return!!$l.invoke("selectCount");case 1:case 9:return!1;default:return!0}}static get(){return this.stack.length?this.stack[this.stack.length-1]:null}static getJsonCacheByJsonSnapshot(t){let i=t.getPrimitiveHistory(),r=Object();i.forEach(o=>{let[,l,{cmdKey:c},,u]=o;sr(r,c)[l]=jt(u)});let s=t.getCombHistory().map(o=>o[1]),a=new rt().getAllCombinationData(s);for(let o of a)sr(r,"combination")[o.gId]=jt(o);return r}static record(t,i){switch(t){case 0:{i(),w2.add({type:0,data:jt(k.getJsonCacheByIds(Ke.getLastRecordPrimitiveIds()))});break}}}};w2.stack=[];var Tr=w2,tC={[Sn.draw]:oZ,[Sn.drag]:lZ,[Sn.delete]:cZ,[Sn.rotate]:uZ,[Sn.paste]:dZ,[Sn.duplicateTo]:fZ,[Sn.lock]:pZ,[Sn.eleVisable]:hZ,[Sn.pasteInPlace]:mZ};function Pa(e){return function(t){var i;return(i=tC[e])==null||i.call(tC,t),t}}function oZ(e){let{next:t}=e;e.next=function(...i){if(!["draw(origin)"].includes(H.cmdToken)){if(["draw(polygon)","draw(polyline)"].includes(H.cmdToken))return t.call(this,...i);Tr.record(0,t.bind(this,...i))}}}function lZ(e){let{onMouseLeftUp:t}=e.prototype;return e.prototype.onMouseLeftUp=function(...i){t.call(this,...i),(this.accumulateX||this.accumulateY)&&Tr.add({type:2,movement:new j(this.accumulateX,this.accumulateY)})},e}function cZ(e){let{do:t}=e.prototype;e.prototype.do=function(...i){let r=t.call(this,...i);return Tr.add({type:4}),r}}function uZ(e){let{do:t}=e.prototype;e.prototype.do=function(...i){t.call(this,...i),this.success&&Tr.add({type:3,degree:this.degree})}}function hZ(e){let{toggleElementsDisplay:t,toggleVisible:i}=e;e.toggleElementsDisplay=function(...r){t.call(this,...r);let n=r[1];Tr.add({type:10,isVisable:n})},e.toggleVisible=function(...r){i.call(this,...r);let n=r[1];Tr.add({type:10,isVisable:n})}}function dZ(e){let{onMouseLeftDown:t}=e.prototype;e.prototype.onMouseLeftDown=function(...i){t.call(this,...i),["ctrl_drag_copy","ctrl_drag_copy2"].includes(this.type)?Tr.add({type:8,data:Tr.getJsonCacheByJsonSnapshot(this.jsonSnapshot),movement:this.accmulate}):Tr.add({type:6,data:Tr.getJsonCacheByJsonSnapshot(this.jsonSnapshot)})}}function pZ(e){let{unlockAll:t,setCombinationLockStatus:i,setLockStatus:r,setElementsLockStatus:n}=e.prototype;e.prototype.unlockAll=function(...s){t.call(this,...s),Tr.add({type:5,locked:!1})},e.prototype.setCombinationLockStatus=function(...s){let a=s[1];i.call(this,...s),Tr.add({type:5,locked:a})},e.prototype.setLockStatus=function(...s){let a=s[1];r.call(this,...s),Tr.add({type:5,locked:a})},e.prototype.setElementsLockStatus=function(...s){let a=s[1];n.call(this,...s),Tr.add({type:5,locked:a})}}function fZ(e){let{do:t}=e;e.do=async function(...i){let r=await t.call(this,...i);return Tr.add({type:7,data:jt(Tr.getJsonCacheByJsonSnapshot(e.snap)),movement:r.movement}),r}}function mZ(){Tr.add({type:11})}function ul(e){if(typeof e=="number")switch(lt(tr(e))){case 0:case 180:case 360:return"horizontal";case 90:case 270:return"vertical";default:return null}else switch(e){case"place_auxiliary(horizontalLine)":return"horizontal";case"place_auxiliary(verticalLine)":return"vertical";case"place_auxiliary(crossLine)":return"cross";default:return null}}function $p(e,t,i,r=pE){let n=new j(e,t),s=n.add1(1,0).rotateD(n,i),a=n.add1(-1,0).rotateD(n,i),o=a.sub(s).normalize();return s=n.sub(o.mul(r)),a=n.add(o.mul(r)),new ie(s,a)}function I2(e,t){if(e.length!==0)for(let i of e){let{data:r,view:n}=i;yZ(r,t),bZ(n,{x:r.x1,y:r.y1},{x:r.x2,y:r.y2})}}function yZ(e,t){let i={x:e.x1,y:e.y1},r={x:e.x2,y:e.y2},n=[[{x:t.minX,y:t.minY},{x:t.maxX,y:t.minY}],[{x:t.maxX,y:t.minY},{x:t.maxX,y:t.maxY}],[{x:t.minX,y:t.maxY},{x:t.maxX,y:t.maxY}],[{x:t.minX,y:t.minY},{x:t.minX,y:t.maxY}]],s=[];for(let a of n){let o=bE(i,r,a[0],a[1]);if(o&&s.push(o),s.length===2){e.x1=s[0].x,e.x2=s[1].x,e.y1=s[0].y,e.y2=s[1].y;return}}}function bZ(e,t,i){e==null||e.setAttribute("x1",String(t.x)),e==null||e.setAttribute("x2",String(i.x)),e==null||e.setAttribute("y1",String(t.y)),e==null||e.setAttribute("y2",String(i.y))}function A2(e){switch(ul(e)){case"horizontal":return"Horizontal Auxiliary Line";case"vertical":return"Vertical Auxiliary Line";default:return"Auxiliary Line"}}function og(e,t){e.setAttribute("r",String(t))}var Pu=class{constructor(){}renderLine(t,i,r){let n=this.extendLineAttr({id:r,x1:t.x,y1:t.y,x2:i.x,y2:i.y}),s=this.container?this.container.querySelector("#"+r):Et("line");if(!s)throw new Error("err");return te(s,n),s}getTextBBox(t){let i=Et("text",{x:0,y:0});i.textContent=t,parent.document.getElementById("svg-work-space").appendChild(i);let r=i.getBBox();return dt(i),r}getCircleCommonAttrs(){return{fill:"var(--selectColor)",stroke:"none",class:"key-point"}}renderCircle(t,i,r=this.getCircleCommonAttrs()){let n=this.extendLineAttr({id:i,cx:t.x,cy:t.y,r:4/H.gZoom,fill:"black",...r}),s=this.container?this.container.querySelector("#"+i):Et("circle");if(!s)throw new Error("err");return te(s,n),s}extendPoint(t,i,r){let n=new j(t.x,t.y),s=new j(i.x,i.y),a=s.angleD(n),o=s.rotateD(n,-a),l=new j(o.x+r,o.y).rotateD(n,a);return{x:l.x,y:l.y}}createTriangle(t,i,r,n){let s=t.map(o=>new j(o[0],o[1])).map(o=>o.rotateD(new j(0,0),i)).map(o=>o.add(r)).map(o=>[o.x,o.y]).flat().join(" "),a=this.container?this.container.querySelector("#"+n):Et("polyline");return te(a,this.extendLineAttr({points:s,id:n})),a}extendLineAttr(t){return Object.assign({"stroke-width":1,stroke:"black","vector-effect":"non-scaling-stroke",fill:"none",...t})}};var iC=class{sync(t,i,r){let s=qi(t.d,!1).map(o=>o.multiply3(i)),a=fs(s,!1,.01,{reverseY:!1});ri.renderer.attr(t.gId,"d",a),t.tempD=a,r.updateD&&(t.d=a)}syncGroup(t,i,r){let n=zt.checkOne("group",t,i);n!==!1&&zt.addCallBack(()=>{var s;Bp(n)&&n(),this.sync(t,i,r),(s=r==null?void 0:r.fn)==null||s.call(r)})}syncGroupWithRotation(t,i,r){let n=this.getRotationMatrix(t,i,r);n&&this.syncGroup(t,n,{updateD:!0,fn(){t.rotation=+i.toFixed(2)}})}getRotationMatrix(t,i,r){let{x:n,y:s,width:a,height:o}=vi(t,"group"),l={x:n+a/2,y:s+o/2};r&&(l.x=r.x,l.y=r.y);let c=t.rotation||0;return de.rotateD(i-c).setOrigin(l.x,l.y)}syncGroupSize(t,i,r,n){let{x:s,y:a,width:o,height:l}=es(le(t.gId));i=i||o,r=r||l;let c=i/o||1,u=r/l||1;if(c===1&&u===1||!Number.isFinite(c)||!Number.isFinite(u))return;let h=de.scale(c,u).setOrigin1(n);this.syncGroup(t,h,{updateD:!0})}getGroupBBox(t){let i=this.getGroup8Dots(t),r=new ot;for(let s=0;s<i.length;s+=2){let a=i[s],o=i[s+1];r.ext6(a,o)}let n=r.build();return{x:n.minX,y:n.minY,width:n.width(),height:n.height()}}getGroup8Dots(t){let{rotation:i}=t;i=i||0;let r=t.d,{x:n,y:s,width:a,height:o}=K4(t),l={x:n+a/2,y:s+o/2},c=de.rotateD(-(0-i)).setOrigin(l.x,-l.y),h=qi(r).map(y=>y.multiply3(c)),d=new ot;for(let y of h)for(let E of y.primitives)if(E instanceof Ye){let S=new ot;E.getBezierPoints(.5,x=>{S.ext2(x)});let w=S.build();d.ext1(w)}else d.ext1(E.bbox());let p=d.build(),f={x:p.minX,y:p.minY,width:p.width(),height:p.height()},m=de.rotateD(-i).setOrigin(l.x,-l.y),g=[[f.x,f.y+f.height],[f.x+f.width,f.y+f.height],[f.x+f.width,f.y],[f.x,f.y],[f.x+f.width/2,f.y+f.height],[f.x+f.width,f.y+f.height/2],[f.x+f.width/2,f.y],[f.x,f.y+f.height/2]],b=[];for(let y of g){let E=new j(y[0],y[1]).multiply3(m);b.push(E.x,-E.y)}return b}},zn=new iC;var Zl=class{constructor(t){this.data=t}getAuxiliaryLinePrimitive(t,i,r,n=pE){let s=new j(t,i),a=s.add1(1,0).rotateD(s,r),o=s.add1(-1,0).rotateD(s,r),l=o.sub(a).normalize();return a=s.sub(l.mul(n)),o=s.add(l.mul(n)),new ie(a,o)}calcX1Y1X2Y2(t){let i=this.getAuxiliaryLinePrimitive(t.x,t.y,t.rotation,100);t.x1=i.start().x,t.y1=i.start().y,t.x2=i.end().x,t.y2=i.end().y}updateAuxiliaryLineDataXY(t){let i={x:this.data.x1,y:this.data.y1},r={x:this.data.x2,y:this.data.y2},n=[[{x:t.minX,y:t.minY},{x:t.maxX,y:t.minY}],[{x:t.maxX,y:t.minY},{x:t.maxX,y:t.maxY}],[{x:t.minX,y:t.maxY},{x:t.maxX,y:t.maxY}],[{x:t.minX,y:t.minY},{x:t.minX,y:t.maxY}]],s=[];for(let a of n){let o=bE(i,r,a[0],a[1]);if(o&&s.push(o),s.length===2)return this.data.x1=s[0].x,this.data.x2=s[1].x,this.data.y1=s[0].y,this.data.y2=s[1].y,this}return this}getPath(){return["M",this.data.x1,this.data.y1,this.data.x2,this.data.y2].join(" ")}render(){var l;this.calcX1Y1X2Y2(this.data),this.updateAuxiliaryLineDataXY(St.extendRect((l=H.svgRoot)==null?void 0:l.viewBox.animVal));let{gId:t,x1:i,y1:r,x2:n,y2:s,strokeColor:a,strokeStyle:o}=this.data;ri.renderer.attrs(t,{x1:i,x2:n,y1:r,y2:s,stroke:a,"stroke-dasharray":Rn.lineStyle[o]})}toData(){}setData(){}unmount(){dt(le(this.data.gId))}multiply3(t){let i=new j(this.data.x1,this.data.y1),r=new j(this.data.x2,this.data.y2),{x:n,y:s}=i.multiply3(t),{x:a,y:o}=r.multiply3(t),l=lt(Math.abs(r.angleD(i)));if(![0,90,180,270].includes(l))return console.warn(`AuxiliaryLine: not support degree(${l}) line`);this.data.x=(n+a)/2,this.data.y=(s+o)/2,this.data.x1=n,this.data.y1=s,this.data.x2=a,this.data.y2=o,this.render()}rotateSelf(t,i){let r=de.rotateD(t).setOrigin1(i);this.multiply3(r)}flipH(t){let i=this.getMirror(t.x,void 0);this.multiply3(i)}flipV(t){let i=this.getMirror(void 0,t.y);this.multiply3(i)}getMirror(t,i){let r=new de;return Va(t)||(r=r.multiply3(de.MIRROR_X)),Va(i)||(r=r.multiply3(de.MIRROR_Y)),r.setOrigin(t||0,i||0)}};var bn=class e extends Pu{constructor(i){super();this.layer=8;this.locked=!1;this.visible=!0;this.rotation=0;this.startDotSelected=!1;this.endDotSelected=!1;this.textDotSelected=!1;this.angleDotSelected=!1;this.arcOffsetX=20;this.name=i.name,this.gId=i.gId,this.x1=i.x1,this.y1=i.y1,this.x2=i.x2,this.y2=i.y2,this.textX=i.textX,this.textY=i.textY,this.angleX=i.angleX,this.angleY=i.angleY,Va(i.visible)&&(i.visible=!0),this.visible=i.visible,Va(i.rotation)&&(i.rotation=0),this.rotation=i.rotation,this.container=i.gId&&document.getElementById(i.gId)}getContainer(){return this.render(),this.container}setAngle(i,r){return this.angleX=i,this.angleY=r,this.calcuTextDot(),this}vectorAngle(){return new j(this.angleX,this.angleY)}setStart(i,r){return this.x1=i,this.y1=r,this}vectorStart(){return new j(this.x1,this.y1)}getStartAngle(){let i=this.vectorStart().angleD2(this.vectorAngle());return tr(i)}getEndAngle(){let i=this.vectorEnd().angleD2(this.vectorAngle());return tr(i)}setEnd(i,r){return this.x2=i,this.y2=r,this}vectorEnd(){return new j(this.x2,this.y2)}setTextPosition(i,r){this.textX=i,this.textY=r}toData(){let i={gId:this.gId,cmdKey:"dimensionAngle",layer:this.layer,name:this.name,locked:this.locked,x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2,textX:this.textX,textY:this.textY,angleX:this.angleX,angleY:this.angleY,visible:this.visible,rotation:this.rotation},r=k.getDimensionAngle(this.gId);return Mt(r)?i:(Object.assign(r,i),r)}setData(){let i=this.toData();return k.setDimension(i.gId,i,"dimensionAngle"),this}translate(i,r){return this.x1+=i,this.y1+=r,this.x2+=i,this.y2+=r,this.angleX+=i,this.angleY+=r,this.calcuTextDot(),this}getBBox(){let i=new ot;i.ext2(this.vectorStart()),i.ext2(this.vectorEnd()),i.ext2(this.vectorAngle());let r=i.build();return{x:r.minX,y:r.minY,width:r.width(),height:r.height()}}rotateSelf(i,r){if(!r){let l=this.getBBox();r=new j(l.x+l.width/2,l.y+l.height/2)}let n=i-this.rotation;if(n===0)return;let s=this.vectorAngle().rotateD(r,n);this.setAngle(s.x,s.y);let a=this.vectorStart().rotateD(r,n);this.setStart(a.x,a.y);let o=this.vectorEnd().rotateD(r,n);return this.setEnd(o.x,o.y),this.rotation=i,this.calcuTextDot().setData().render(),this}flipH(i){if(ft(i)){let o=this.getBBox();i=new j(o.x+o.width/2,o.y+o.height/2)}let r=de.MIRROR_X.setOrigin(i.x,0),n=this.vectorAngle().multiply3(r);this.setAngle(n.x,n.y);let s=this.vectorStart().multiply3(r);this.setStart(s.x,s.y);let a=this.vectorEnd().multiply3(r);return this.setEnd(a.x,a.y),this.calcuTextDot().setData().render(),this}flipV(i){if(ft(i)){let o=this.getBBox();i=new j(o.x+o.width/2,o.y+o.height/2)}let r=de.MIRROR_Y.setOrigin(0,i.y),n=this.vectorAngle().multiply3(r);this.setAngle(n.x,n.y);let s=this.vectorStart().multiply3(r);this.setStart(s.x,s.y);let a=this.vectorEnd().multiply3(r);return this.setEnd(a.x,a.y),this.calcuTextDot().setData().render(),this}getPath(){let i=this.renderText(!0),r=this.renderStartLine(!0),n=this.renderEndLine(!0),s=this.renderArc(!0);return{line:r+n+s,text:i}}render(i=!1){let r=this.renderText(),n=this.renderStartLine(),s=this.renderEndLine(),a=this.renderArc(),o=this.renderAngleCircle(),l=this.renderStartCircle(),c=this.renderEndCircle(),u=this.renderTextCircle();if(!this.container){let h=Et("g",{id:this.gId,c_partid:"dimensionAngle",class:"dimensionAngle",layer:8,display:this.visible?"":"none"});this.container=h,i===!1&&Qe.appendTargetLayer(h,8,!0,{cmdKey:"dimensionAngle"}),h.appendChild(n),h.appendChild(s),h.appendChild(r),h.appendChild(a),h.appendChild(o),h.appendChild(l),h.appendChild(c),h.appendChild(u)}return this.container.outerHTML}nextTick(i){return Promise.resolve().then(()=>{i(this.container)}),this}getSvg(){return this.render(!0)}getCircleId(i){return{start:this.gId+"-start-circle",end:this.gId+"-end-circle",text:this.gId+"-text-circle",angle:this.gId+"-angle-circle"}[i]}renderStartCircle(){let i=this.getCircleId("start");return this.renderCircle(this.vectorStart(),i)}renderEndCircle(){let i=this.getCircleId("end");return this.renderCircle(this.vectorEnd(),i)}renderTextCircle(){let i=this.getCircleId("text");return this.renderCircle(this.vectorTextDot(),i)}renderAngleCircle(){let i=this.getCircleId("angle");return this.renderCircle(this.vectorAngle(),i)}unmount(){dt(this.container)}calcuAngle(){let i=xE(this.vectorStart(),this.vectorAngle(),this.vectorEnd())||0,r=_a.toDegrees(i);return lt(r,2)}setAngleDeg(i){let r=this.vectorEnd().rotateD(this.vectorAngle(),-this.getEndAngle()).rotateD(this.vectorAngle(),this.getStartAngle()+ +i);return this.setEnd(r.x,r.y),this.calcuTextDot(),this}calcuTextDot(){let i=this.arcOffsetX+10,r={x:this.angleX+i,y:this.angleY},n=(this.getEndAngle()+this.getStartAngle())/2;return Math.abs(this.getEndAngle()-this.getStartAngle())>180&&(n=n+180),r=new j(r.x,r.y).rotateD(this.vectorAngle(),n),this.textX=r.x,this.textY=r.y,this}getTextMatrix(){let i=this.calcuAngle(),r=this.container?this.container.querySelector("text"):Et("text",{x:0,y:0}),n=r.getBBox();return!n.width&&!n.height&&(n=this.getTextBBox(r.textContent)),r.textContent=i+"\xB0",{matrix:de.scale(.5,.5).translate(this.textX,this.textY),text:r,bbox:n}}getTextBBoxOutline(){let{matrix:i,bbox:r}=this.getTextMatrix(),n=St.extendRect(r),s=[];for(let a of[n.LL(),n.UL(),n.UR(),n.LR()])s.push(a.multiply3(i));return s}renderText(i=!1){let{text:r,matrix:n}=this.getTextMatrix(),s=et.getMatrix6FromMatrix(n);return i?{m3:n,textContent:r.textContent}:(ht.updateTransform(s,r),r)}renderStartLine(i=!1){let r=this.vectorStart(),n=this.vectorAngle();return i?["M",r.x,r.y,n.x,n.y].join(" "):this.renderLine(r,n,this.gId+"-start-line")}renderEndLine(i=!1){let r=this.vectorEnd(),n=this.vectorAngle();return i?["M",r.x,r.y,n.x,n.y].join(" "):this.renderLine(r,n,this.gId+"-end-line")}vectorTextDot(){return new j(this.textX,this.textY)}renderArc(i=!1){let r=this.arcOffsetX,n=["M"],s=new j(this.angleX+r,this.angleY),a=s.rotateD(this.vectorAngle(),this.getStartAngle()),o=s.rotateD(this.vectorAngle(),this.getEndAngle()),l=this.getEndAngle()-this.getStartAngle();l=tr(l);let c=0,u=l>0&&l<=180?1:0;if(n.push(a.x,a.y,"A",r,r,0,c,u,o.x,o.y),i)return n.join(" ");let h=this.extendLineAttr({id:this.gId+"-arc",d:n.join(" ")}),d=this.container?this.container.querySelector("path"):Et("path");return te(d,h),d}findContainsControlPoint(i,r){let n=5/H.gZoom;return sl(i,r,this.x1,this.y1,n)?this.getCircleId("start"):sl(i,r,this.x2,this.y2,n)?this.getCircleId("end"):sl(i,r,this.textX,this.textY,n)?this.getCircleId("text"):sl(i,r,this.angleX,this.angleY,n)?this.getCircleId("angle"):!1}setControlDotSelected(i){switch(i){case this.getCircleId("start"):this.startDotSelected=!0;break;case this.getCircleId("end"):this.endDotSelected=!0;break;case this.getCircleId("text"):this.textDotSelected=!0;break;case this.getCircleId("angle"):this.angleDotSelected=!0;break;default:break}return this}moveControlPoint(i,r){return this.startDotSelected&&(this.x1+=i,this.y1+=r,this.calcuTextDot()),this.endDotSelected&&(this.x2+=i,this.y2+=r,this.calcuTextDot()),this.textDotSelected&&(this.textX+=i,this.textY+=r),this.angleDotSelected&&(this.angleX+=i,this.angleY+=r,this.calcuTextDot()),this.setData(),this}static zoom(){k.iteratorDimensionAngle(i=>{let r=new e(i).render();r=null})}};var xn=class e extends Pu{constructor(i){super();this.startSelected=!1;this.endSelected=!1;this.textSelected=!1;this.layer=8;this.name="";this.locked=!1;this.visible=!0;this.rotation=0;this.measureStart={x:0,y:0};this.measureEnd={x:0,y:0};this.name=i.name,this.gId=i.gId,this.x1=i.x1,this.y1=i.y1,this.measureStart.x=i.measureX1,this.measureStart.y=i.measureY1,this.x2=i.x2,this.y2=i.y2,this.measureEnd.x=i.measureX2,this.measureEnd.y=i.measureY2,ft(i.measureX1)||this.initTextPosition(),this.direction=i.direction,this.container=i.gId&&document.getElementById(i.gId),Va(i.visible)&&(i.visible=!0),this.visible=i.visible,Va(i.rotation)&&(i.rotation=0),this.rotation=i.rotation}updateDirection(){this.measureStart.x==this.x1?this.direction="x":this.measureStart.y==this.y1?this.direction="y":this.direction="xy"}calcuDirection(){let i="xy",r=(this.textX-this.x1)*(this.textX-this.x2)<0,n=(this.textY-this.y1)*(this.textY-this.y2)<0;return r&&n?i="xy":r?i="x":n&&(i="y"),this.direction=i,this.calcuMeasurePoint(),this}calcuMeasurePoint(){let i=this.direction;if(i==="x")this.measureStart={x:this.x1,y:this.textY},this.measureEnd={x:this.x2,y:this.textY};else if(i==="y")this.measureStart={x:this.textX,y:this.y1},this.measureEnd={x:this.textX,y:this.y2};else if(i==="xy"){let{start:r,end:n}=ts.calcuPerpendicular(this.vectorStart(),this.vectorEnd(),{x:this.textX,y:this.textY});this.measureStart=r,this.measureEnd=n}return this.initTextPosition(),this}initTextPosition(){let{x:i,y:r}=this.getMidTextPoint();return this.textX=i,this.textY=r,this}toData(){let i={x1:this.x1,y1:this.y1,measureX1:this.measureStart.x,measureY1:this.measureStart.y,x2:this.x2,y2:this.y2,measureX2:this.measureEnd.x,measureY2:this.measureEnd.y,direction:this.direction,gId:this.gId,cmdKey:"dimensionLength",name:this.name,locked:this.locked,layer:this.layer,visible:this.visible,rotation:this.rotation},r=k.getDimensionLength(this.gId);return Mt(r)?i:(Object.assign(r,i),r)}setData(){return k.setDimension(this.gId,this.toData(),"dimensionLength"),this}setStart(i,r){return this.x1=i,this.y1=r,this}vectorStart(){return new j(this.x1,this.y1)}setEnd(i,r){return this.x2=i,this.y2=r,this}vectorEnd(){return new j(this.x2,this.y2)}setTextPosition(i,r){return this.textX=i,this.textY=r,this}unmount(){dt(this.container)}getContainer(){return this.render(),this.container}translate(i,r){return this.x1+=i,this.y1+=r,this.measureStart.x+=i,this.measureStart.y+=r,this.x2+=i,this.y2+=r,this.measureEnd.x+=i,this.measureEnd.y+=r,this}rotateSelf(i,r){let n=i-this.rotation;if(n===0)return;let s=na([this.x1,this.y1,this.x2,this.y2,this.measureStart.x,this.measureStart.y,this.measureEnd.x,this.measureEnd.y],n,r.x,r.y);return this.setStart(s[0],s[1]),this.setEnd(s[2],s[3]),this.measureStart={x:s[4],y:s[5]},this.measureEnd={x:s[6],y:s[7]},this.initTextPosition(),this.rotation=i,this.updateDirection(),this.setData().render(),this}multiply3(i){let r=this.vectorStart().multiply3(i);this.setStart(r.x,r.y);let n=this.vectorEnd().multiply3(i);this.setEnd(n.x,n.y);let s=new j(this.textX,this.textY).multiply3(i);return this.setTextPosition(s.x,s.y),this.calcuMeasurePoint(),this.setData().render(),this}updateMeasurePoint(i,r){if(this.direction==="y")this.measureStart.y=this.y1,this.measureEnd.y=this.y2,this.textSelected&&(this.measureStart.x+=i,this.measureEnd.x+=i);else if(this.direction==="x")this.measureStart.x=this.x1,this.measureEnd.x=this.x2,this.textSelected&&(this.measureStart.y+=r,this.measureEnd.y+=r);else if(this.direction==="xy"){let n=this.textX,s=this.textY,{start:a,end:o}=ts.calcuPerpendicular(this.vectorStart(),this.vectorEnd(),{x:n,y:s});this.measureStart=a,this.measureEnd=o}}moveControlPoint(i,r){return this.startSelected&&(this.x1+=i,this.y1+=r),this.endSelected&&(this.x2+=i,this.y2+=r),this.textSelected&&(this.textX+=i,this.textY+=r),this.updateMeasurePoint(i,r),this.setData(),this}getPath(){let i=this.renderTextLine(!0),r=this.renderStartLine(!0),n=this.renderEndLine(!0),s=this.createStartTriangle(!0),a=this.createEndTriangle(!0);return{line:i+r+n+s+a,text:this.renderText(!0)}}render(i=!1){let r=this.renderText(),n=this.renderTextLine(),s=this.renderStartLine(),a=this.renderEndLine(),o=this.createStartTriangle(),l=this.createEndTriangle(),c=this.createStartCircle(),u=this.createEndCircle(),h=this.createTextCircle();if(!this.container){let d=Et("g",{id:this.gId,class:"dimensionLength",c_partid:"dimensionLength",layer:8,display:this.visible?"":"none"});this.container=d,!i&&Qe.appendTargetLayer(d,8,!0,{cmdKey:"dimensionLength"}),d.appendChild(n),d.appendChild(s),d.appendChild(a),d.appendChild(r),d.appendChild(o),d.appendChild(l),d.appendChild(c),d.appendChild(u),d.appendChild(h)}if(i)return this.container.outerHTML}getSvg(){return this.render(!0)}getEndPoint(){return{x:this.x2,y:this.y2}}renderTextLine(i=!1){let r=this.measureStart,n=this.measureEnd;return i?["M",r.x,r.y,"L",n.x,n.y].join(" "):this.renderLine(r,n,this.gId+"-text-line")}createEndTriangle(i=!1){let r=new j(this.measureStart.x,this.measureStart.y),n=new j(this.measureEnd.x,this.measureEnd.y),s=n.angleD(r),a=this.createTriangle([[-5,-5],[0,0],[-5,5]],s,n,this.gId+"-end-triangle");return i?"M"+te(a,"points"):a}getMidTextPoint(){return{x:(this.measureStart.x+this.measureEnd.x)/2,y:(this.measureStart.y+this.measureEnd.y)/2}}setControlDotSelected(i){switch(i){case this.getKeyDotId("start"):this.startSelected=!0;break;case this.getKeyDotId("end"):this.endSelected=!0;break;case this.getKeyDotId("text"):this.textSelected=!0;break}}findContainsControlPoint(i,r){let n=5/H.gZoom,s=this.getMidTextPoint();return sl(i,r,s.x,s.y,n)?this.getKeyDotId("text"):sl(i,r,this.x1,this.y1,n)?this.getKeyDotId("start"):sl(i,r,this.x2,this.y2,n)?this.getKeyDotId("end"):!1}getKeyDotId(i){return{start:this.gId+"-start-circle",end:this.gId+"-end-circle",text:this.gId+"-text-circle"}[i]}createStartCircle(){return this.renderCircle(this.vectorStart(),this.getKeyDotId("start"))}createEndCircle(){return this.renderCircle(this.getEndPoint(),this.getKeyDotId("end"))}createTextCircle(){let i={x:(this.measureStart.x+this.measureEnd.x)/2,y:(this.measureStart.y+this.measureEnd.y)/2};return this.renderCircle(i,this.getKeyDotId("text"))}createStartTriangle(i=!1){let r=new j(this.measureStart.x,this.measureStart.y),s=new j(this.measureEnd.x,this.measureEnd.y).angleD(r),a=this.createTriangle([[5,-5],[0,0],[5,5]],s,r,this.gId+"-start-triangle");return i?"M"+te(a,"points"):a}renderStartLine(i=!1){let r=this.vectorStart(),n=this.measureStart;return sa(r,n)||(n=this.extendPoint(r,n,10)),i?["M",r.x,r.y,"L",n.x,n.y].join(" "):this.renderLine(r,n,this.gId+"-start-line")}renderEndLine(i=!1){let r=this.getEndPoint(),n=this.measureEnd;return sa(r,n)||(n=this.extendPoint(r,n,10)),i?["M",r.x,r.y,"L",n.x,n.y].join(" "):this.renderLine(r,n,this.gId+"-end-line")}calcLengthPixel(){return P0(this.measureStart,this.measureEnd)}getTextMatrix(){let i=this.container?this.container.querySelector("text"):Et("text",{x:0,y:0}),r=this.calcLengthPixel(),n=this.measureStart,s=this.measureEnd,a=lt(Qs(r),2);i.textContent=a+"mm";let o=i.getBBox();!o.width&&!o.height&&(o=this.getTextBBox(i.textContent));let l={x:(n.x+s.x)/2,y:(n.y+s.y)/2},c=new j(n.x,n.y),u=new j(s.x,s.y).angleD(c);s.x<n.x&&(c=new j(s.x,s.y),u=new j(n.x,n.y).angleD(c));let h=de.translate(l.x-o.width/2,l.y-o.height/2).rotateD(u).setOrigin(l.x,l.y);return h=h.multiply3(de.scale(.5,.5).setOrigin(l.x,l.y)),{text:i,matrix:h,bbox:o}}getTextBBoxOutline(){let{matrix:i,bbox:r}=this.getTextMatrix(),n=St.extendRect(r),s=[];for(let a of[n.LL(),n.UL(),n.UR(),n.LR()])s.push(a.multiply3(i));return s}renderText(i=!1){let{text:r,matrix:n}=this.getTextMatrix();if(i)return{m3:n,textContent:r.textContent};let s=et.getMatrix6FromMatrix(n);return ht.updateTransform(s,r),r}updateDistance(i){let r=new j(this.measureStart.x,this.measureStart.y),n=new j(this.measureEnd.x,this.measureEnd.y),s=n.angleD2(r);this.direction==="xy"&&s===0&&(s=new j(this.x1,this.y1).angleD2(r)+90);let a=new j(i+r.x,r.y).rotateD(r,s),o={dx:a.x-n.x,dy:a.y-n.y};return this.measureEnd.x+=o.dx,this.measureEnd.y+=o.dy,this.x2+=o.dx,this.y2+=o.dy,this}static zoom(){k.iteratorDimensionLength(i=>{let r=new e(i).render();r=null})}};var gs=class{static dotProd1(t,i,r,n){return t*r+i*n}static dotProd2(t,i,r,n,s,a){return this.dotProd1(r-t,n-i,s-r,a-n)}static dotProd3(t,i,r){return this.dotProd2(t.x,t.y,i.x,i.y,r.x,r.y)}static crossProd1(t,i,r,n){return t*n-i*r}static crossProd2(t,i,r,n,s,a){return this.crossProd1(r-t,n-i,s-r,a-n)}static crossProd3(t,i,r){return this.crossProd2(t.x,t.y,i.x,i.y,r.x,r.y)}static distance2(t,i,r,n){let s=r-t,a=n-i;return s*s+a*a}static distance1(t,i,r,n){return this.hypot(r-t,n-i)}static distance1p(t,i){return this.distance1(t.x,t.y,i.x,i.y)}static hypot(t,i){if(t=Math.abs(t),i=Math.abs(i),i>t){var r=i;i=t,t=r}if(t===0)return i;var n=i/t;return t*Math.sqrt(1+n*n)}};var m1=1e-4,ge=new Float64Array(100);function Gc(e,t){if(e instanceof ie&&t instanceof ie)return ug(e,t);if(e instanceof Se&&t instanceof ie)return rC(e,t);if(e instanceof ie&&t instanceof Se)return rC(t,e);if(e instanceof Se&&t instanceof Se)return SZ(e,t);if(e instanceof Ye&&t instanceof Ye)return C2(e,t);if(e instanceof Ye&&t instanceof ie)return C2(e,new Ye([t.start(),t.end()]));if(e instanceof ie&&t instanceof Ye)return C2(new Ye([e.start(),e.end()]),t);if(e instanceof Ye&&t instanceof Se)return iB(t,e);if(e instanceof Se&&t instanceof Ye)return iB(e,t);throw new Error("not supported operation")}function rB(e,t){let i=e.primitives,r=t.primitives,n=i.length>r.length?r:i,s=i.length>r.length?i:r,a=!1;return n.some(o=>(s.some(l=>(a=Gc(o,l)>0,a)),a)),a}function nB(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new ie(new j(i.minX-1,t),new j(i.maxX+1,t));return ug(r,e)>0?1:0}else return 0}function sB(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new ie(new j(i.minX-1,t),new j(i.maxX+1,t));return g1(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function aB(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new ie(new j(i.minX-1,t),new j(i.maxX+1,t)),n=g1(e,r);return n>0?n:0}else return 0}else throw new Error("not supported operation")}function y1(e,t){let i=e.bbox();return i.isContainsY1(t)&&C2(new Ye([new j(i.minX-1,t),new j(i.maxX+1,t)]),e)>0?1:0}function $4(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function xZ(e,t){let i=gs.crossProd3(t.start(),t.end(),e.start()),r=gs.crossProd3(t.start(),t.end(),e.end());return Math.abs(i)<1e-8||Math.abs(r)<1e-8||i*r<0}function ug(e,t){let i=e.bbox().intersection1(t.bbox());if(!i)return 0;if(e.isPoint())if(t.isPoint()){let r=i.center();return ge[0]=r.x,ge[1]=r.y,2}else return Z4(t,e,i);else{if(t.isPoint())return Z4(e,t,i);{let y=function(E,S){i.isContains2(E,S)&&(ge[b++]=E,ge[b++]=S)};if(!xZ(e,t))return 0;let r=e.start().x,n=e.start().y,s=e.end().x,a=e.end().y,o=t.start().x,l=t.start().y,c=t.end().x,u=t.end().y,h=t.length(),d=gs.crossProd2(r,n,o,l,c,u)/h,p=gs.crossProd2(s,a,o,l,c,u)/h;if(d*p>0&&!Ve.eq(d,0)&&!Ve.eq(p,0))return 0;let f=e.length(),m=gs.crossProd2(o,l,r,n,s,a)/f,g=gs.crossProd2(c,u,r,n,s,a)/f;if(m*g>0&&!Ve.eq(m,0)&&!Ve.eq(g,0))return 0;let b=0;if(Ve.eq(d,0)&&Ve.eq(p,0)){let E=i.UL(),S=i.UR(),w=i.LL(),x=i.LR();if(Ve.eq(i.width(),0))Ve.eq(i.height(),0)?(ge[b++]=E.x,ge[b++]=E.y):(ge[b++]=E.x,ge[b++]=E.y,ge[b++]=w.x,ge[b++]=w.y);else if(Ve.eq(i.height(),0))ge[b++]=E.x,ge[b++]=E.y,ge[b++]=S.x,ge[b++]=S.y;else{let I=Vf.area2(E.x,E.y,o,l,c,u),A=Vf.area2(S.x,S.y,o,l,c,u);I<A?(ge[b++]=E.x,ge[b++]=E.y,ge[b++]=x.x,ge[b++]=x.y):(ge[b++]=S.x,ge[b++]=S.y,ge[b++]=w.x,ge[b++]=w.y)}}else if(Ve.eq(d,0))y(r,n);else if(Ve.eq(p,0))y(s,a);else{let E=Math.abs(d/(d-p));y(r+(s-r)*E,n+(a-n)*E)}return b}}}function Z4(e,t,i){let r=t.start(),n=t.end(),s=e.a*r.x+e.b*r.y+e.c,a=e.a*n.x+e.b*n.y+e.c;if(s*a<0){let o=i.center();return ge[0]=o.x,ge[1]=o.y,2}else if(Math.abs(s)<Math.abs(a)){if(Ve.eq(s/Math.sqrt(e.a**2+e.b**2),0))return ge[0]=r.x,ge[1]=r.y,2}else if(Ve.eq(a/Math.sqrt(e.a**2+e.b**2),0))return ge[0]=n.x,ge[1]=n.y,2;return 0}function g1(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(m1);let r=e.center.x,n=e.center.y,s=e.rx,a=e.rx2,o=t.start().x,l=t.start().y,c=t.end().x,u=t.end().y,h=e.center.distance1(t.start()),d=e.center.distance1(t.end()),p=Ve.eq(h,s)?0:h>s?1:-1,f=Ve.eq(d,s)?0:d>s?1:-1,m=0;if(p===-1&&f===-1)return 0;if(p===0&&f===0)ge[m++]=o,ge[m++]=l,ge[m++]=c,ge[m++]=u;else if(p===1&&f===1){let g=Lu.foot(t,e.center),b=g.distance1(e.center);if(Ve.greater(b,s))return 0;if(Ve.eq(b,s))Ve.eq(t.distance2(e.start()),0)?(ge[m++]=e.start().x,ge[m++]=e.start().y,ge[m++]=e.start().x,ge[m++]=e.start().y):Ve.eq(t.distance2(e.end()),0)?(ge[m++]=e.end().x,ge[m++]=e.end().y,ge[m++]=e.end().x,ge[m++]=e.end().y):(ge[m++]=g.x,ge[m++]=g.y,ge[m++]=g.x,ge[m++]=g.y);else{m=EZ(r,n,o,l,c,u,m);let y=ge[m-2],E=ge[m-1],S=gs.distance1(r,n,y,E);if(m-=2,Ve.eq(S,s))ge[m++]=y,ge[m++]=E;else if(S<s)m=hl(a,r,n,o,l,y,E,m),m=hl(a,r,n,y,E,c,u,m);else return 0}}else if(p===-1||f===-1)m=hl(a,r,n,o,l,c,u,m);else{let g=Lu.foot(t,e.center),b=g.distance1(e.center);if(Ve.eq(b,s)){let S=function(w){return $4(i,w.x,w.y)&&Pr(e,w)},y=e.start(),E=e.end();if(p===0){let w=t.start();if(S(w))return ge[m++]=w.x,ge[m++]=w.y,ge[m++]=w.x,ge[m++]=w.y,m;if(S(g))return ge[m++]=g.x,ge[m++]=g.y,ge[m++]=g.x,ge[m++]=g.y,m;if(Ve.eq(t.distance2(y),0)&&S(y))return ge[m++]=y.x,ge[m++]=y.y,ge[m++]=y.x,ge[m++]=y.y,m;if(Ve.eq(t.distance2(E),0)&&S(E))return ge[m++]=E.x,ge[m++]=E.y,ge[m++]=E.x,ge[m++]=E.y,m;if(h<=s)m=hl(a,r,n,g.x,g.y,c,u,m),m===2&&(ge[m++]=ge[0],ge[m++]=ge[1]);else if(b<s){if(m=hl(a,r,n,g.x,g.y,c,u,m),m===2&&S(new j(ge[0],ge[1])))return ge[m++]=ge[0],ge[m++]=ge[1],m;m=hl(a,r,n,g.x,g.y,o,l,0),m===2&&(ge[m++]=ge[0],ge[m++]=ge[1])}}else{let w=t.end();if(S(w))return ge[m++]=w.x,ge[m++]=w.y,ge[m++]=w.x,ge[m++]=w.y,m;if(S(g))return ge[m++]=g.x,ge[m++]=g.y,ge[m++]=g.x,ge[m++]=g.y,m;if(Ve.eq(t.distance2(y),0)&&S(y))return ge[m++]=y.x,ge[m++]=y.y,ge[m++]=y.x,ge[m++]=y.y,m;if(Ve.eq(t.distance2(E),0)&&S(E))return ge[m++]=E.x,ge[m++]=E.y,ge[m++]=E.x,ge[m++]=E.y,m;if(d<=s)m=hl(a,r,n,g.x,g.y,o,l,m),m===2&&(ge[m++]=ge[0],ge[m++]=ge[1]);else if(b<s){if(m=hl(a,r,n,g.x,g.y,o,l,m),m===2&&S(new j(ge[0],ge[1])))return ge[m++]=ge[0],ge[m++]=ge[1],m;m=hl(a,r,n,g.x,g.y,c,u,0),m===2&&(ge[m++]=ge[0],ge[m++]=ge[1])}}}else if(p===0){let y=t.start();ge[m++]=y.x,ge[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=hl(a,r,n,g.x,g.y,c,u,m))}else{let y=t.end();ge[m++]=y.x,ge[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=hl(a,r,n,g.x,g.y,o,l,m))}}if(m>0){let g=0;for(let b=0;b<m;b+=2){let y=ge[b],E=ge[b+1];isFinite(y)&&isFinite(E)&&$4(i,y,E)&&Pr(e,new j(y,E))&&(ge[g++]=y,ge[g++]=E)}return g}else return 0}else return 0}function hl(e,t,i,r,n,s,a,o){if(n==a){let E=e-(n-i)*(n-i);if(Ve.greater(E,0)){let S=Math.sqrt(E),w=t-S,x=t+S,I=Math.min(r,s),A=Math.max(r,s);return w>=I&&w<=A&&(ge[o++]=w,ge[o++]=n),x>=I&&x<=A&&(ge[o++]=x,ge[o++]=n),o}}let l=gs.distance2(r,n,t,i)-e,c=gs.distance2(s,a,t,i)-e,u=r,h=n,d=s,p=a,f=NaN,m=NaN,g=Number.POSITIVE_INFINITY,b=0;for(;g!==0;){b++;let E=Math.max(Math.min(Math.abs(l)/(Math.abs(l)+Math.abs(c)),.75),.25);if(f=u+(d-u)*E,m=h+(p-h)*E,u===f&&h===m||d===f&&p===m){Math.abs(l)>Math.abs(c)?(f=d,m=p,g=c):(f=u,m=h,g=l);break}else g=gs.distance2(f,m,t,i)-e,g<0&&l>c||g>0&&l<c?(d=f,p=m,c=g):(u=f,h=m,l=g)}let y=Math.sqrt(e)-gs.distance1(f,m,t,i);return(Ve.eq(0,g)||Ve.eq(0,y))&&(ge[o++]=f,ge[o++]=m),o}function EZ(e,t,i,r,n,s,a){if(gs.crossProd2(i,r,n,s,e,t)==0){let l=gs.dotProd2(i,r,n,s,e,t),c=gs.dotProd2(n,s,i,r,e,t);return l<0&&c<0?(ge[a++]=e,ge[a++]=t,a):l>=0?(ge[a++]=n,ge[a++]=s,a):(ge[a++]=i,ge[a++]=r,a)}else{let l=NaN,c=NaN,u=i,h=r,d=n,p=s,f=gs.distance2(i,r,e,t),m=gs.distance2(n,s,e,t),g=Number.POSITIVE_INFINITY,b=0;for(;g>0&&(b++,l=u+(d-u)*.5,c=h+(p-h)*.5,!(f==m||u==l&&h==c||d==l&&p==c));){g=gs.distance2(l,c,e,t);let y=gs.dotProd2(u,h,l,c,e,t);if(y==0)break;y<0?(d=l,p=c,m=g):(u=l,h=c,f=g)}return ge[a++]=l,ge[a++]=c,a}}function rC(e,t){if(e.rx===e.ry)return g1(e,t);throw new Error("not supported")}function SZ(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return wZ(e,t);throw new Error("not supported operation")}return 0}function wZ(e,t){let i=e.center.x,r=e.center.y,n=t.center.x,s=t.center.y,a=e.rx,o=t.rx,l=e.rx2,c=t.rx2,u=e.center.distance1(t.center),h=Math.abs(a-o),d=a+o;if(Ve.greater(u,d)||Ve.less(u,h))return 0;if(Ve.eq(u,d)){if(Q4(e,t))return 4;let p=new ie(e.center,t.center),f=g1(t,p);return f=eB(e,f),f!==0?f:(f=g1(e,p),eB(t,f))}else if(Ve.greater(h,0)&&Ve.greater(u,0)&&Ve.eq(u,h)){if(Q4(e,t))return 4;if(a>o){let p=(a-o)/a;return ge[0]=i+(n-i)/p,ge[1]=r+(s-r)/p,tB(e,t,2)}else{let p=(o-a)/o;return ge[0]=n+(i-n)/p,ge[1]=s+(r-s)/p,tB(e,t,2)}}else if(Ve.eq(h,0)&&Ve.eq(u,0)){let p=0,f;return Pr(e,t.start())&&(ge[p]=t.start().x,ge[p+1]=t.start().y,p+=2,f=t.start()),Pr(e,t.end())&&(ge[p]=t.end().x,ge[p+1]=t.end().y,p+=2,f=t.end()),p===0?(Pr(t,e.start())&&(ge[p]=e.start().x,ge[p+1]=e.start().y,p+=2),Pr(t,e.end())&&(ge[p]=e.end().x,ge[p+1]=e.end().y,p+=2)):p===2&&(!f.equals1(e.start())&&Pr(t,e.start())&&(ge[p]=e.start().x,ge[p+1]=e.start().y,p+=2),!f.equals1(e.end())&&Pr(t,e.end())&&(ge[p]=e.end().x,ge[p+1]=e.end().y,p+=2)),p}else{let f=(e.center.distance2(t.center)-c+l)/(u*2)/u,m=(n-i)*f+i,g=(s-r)*f+r,b=n-i,y=s-r,E=Math.max(a,o),S,w,x,I;if(Math.abs(b)<Math.abs(y)){let M=b/-y,F=g-M*m;S=m-E,w=M*S+F,x=m+E,I=M*x+F}else{let M=y/-b,F=m-M*g;w=g-E,S=M*w+F,I=g+E,x=M*I+F}let A=hl(l,i,r,S,w,m,g,0);if(A=hl(l,i,r,m,g,x,I,A),A!==4)throw new Error("cnt !== 4");let O=new j(ge[0],ge[1]),R=new j(ge[2],ge[3]);if(Pr(e,O)&&Pr(t,O))return Pr(e,R)&&Pr(t,R)?4:Dd(e.start(),t,R,O)?(ge[2]=e.start().x,ge[3]=e.start().y,4):Dd(e.end(),t,R,O)?(ge[2]=e.end().x,ge[3]=e.end().y,4):Dd(t.start(),e,R,O)?(ge[2]=t.start().x,ge[3]=t.start().y,4):Dd(t.end(),e,R,O)?(ge[2]=t.end().x,ge[3]=t.end().y,4):2;if(Pr(e,R)&&Pr(t,R))return Dd(e.start(),t,O,R)?(ge[0]=e.start().x,ge[1]=e.start().y,4):Dd(e.end(),t,O,R)?(ge[0]=e.end().x,ge[1]=e.end().y,4):Dd(t.start(),e,O,R)?(ge[0]=t.start().x,ge[1]=t.start().y,4):Dd(t.end(),e,O,R)?(ge[0]=t.end().x,ge[1]=t.end().y,4):(ge[0]=ge[2],ge[1]=ge[3],2);{let V=function(q,C){if(Ve.eq(q.distance1(C.center),C.rx)&&Pr(C,q)){if(q.distance2(O)<q.distance2(R)){if(M)return;M=!0}else{if(F)return;F=!0}ge[G++]=q.x,ge[G++]=q.y}},M=!1,F=!1,G=0;return V(e.start(),t),V(e.end(),t),V(t.start(),e),V(t.end(),e),G}}}function Dd(e,t,i,r){return Ve.eq(e.distance1(t.center),t.rx)&&Pr(t,e)&&e.distance2(i)<e.distance2(r)}function Q4(e,t){return Ve.eq(t.start().distance1(e.center),e.rx)&&Pr(e,t.start())?(ge[0]=t.start().x,ge[1]=t.start().y,ge[2]=t.start().x,ge[3]=t.start().y,!0):Ve.eq(t.end().distance1(e.center),e.rx)&&Pr(e,t.end())?(ge[0]=t.end().x,ge[1]=t.end().y,ge[2]=t.end().x,ge[3]=t.end().y,!0):Ve.eq(e.start().distance1(t.center),t.rx)&&Pr(t,e.start())?(ge[0]=e.start().x,ge[1]=e.start().y,ge[2]=e.start().x,ge[3]=e.start().y,!0):Ve.eq(e.end().distance1(t.center),t.rx)&&Pr(t,e.end())?(ge[0]=e.end().x,ge[1]=e.end().y,ge[2]=e.end().x,ge[3]=e.end().y,!0):!1}function eB(e,t){if(t===0)return 0;let i=ge[0],r=ge[1];return Pr(e,new j(i,r))?(ge[0]=i,ge[1]=r,ge[2]=i,ge[3]=r,4):0}function tB(e,t,i){if(i===0)return 0;let r=ge[0],n=ge[1],s=new j(r,n);return Pr(e,s)&&Pr(t,s)?(ge[0]=r,ge[1]=n,ge[2]=r,ge[3]=n,4):0}function cg(e,t){return Math.abs(e-t)<=1e-6}function Pr(e,t){let i=e.bbox();if(t.x-i.minX>-m1&&t.x-i.maxX<m1&&t.y-i.minY>-m1&&t.y-i.maxY<m1){let r=_a.regularD(t.angleD(e.center));return cg(r,e.startAngle)||cg(r,e.startAngle+360)||cg(r,e.startAngle-360)||cg(r,e.endAngle())||cg(r,e.endAngle()+360)||cg(r,e.endAngle()-360)?!0:e.sweepAngle>0?(Ve.less(r,e.startAngle)&&(r+=360),Ve.greatereq(e.endAngle(),r)):(Ve.greater(r,e.startAngle)&&(r-=360),Ve.lesseq(e.endAngle(),r))}else return!1}var ys=new Float64Array(100);function C2(e,t){if(e.bbox().extendOfSize(Ve.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,n=0;for(;i.length!==0;){let R=function(q){A=Math.min(A,q),O=Math.max(O,q)},G=function(q,C){let N=ug(q,C);if(N===0)throw new Error("cnt === 0");for(let T=0;T<N;T+=2)R(ge[T])};if(n>r){for(let q=n-2;q>=2;q-=2)for(let C=q-2;C>=0;C-=2)if(Ve.eq(ys[q],ys[C])&&Ve.eq(ys[q+1],ys[C+1])){ys[C]=(ys[q]+ys[C])/2,ys[C+1]=(ys[q+1]+ys[C+1])/2;for(let N=n-3;N>=q;N--)ys[N]=ys[N+2];n-=2;break}if(n>r){n=0;let q=t.start(),C=new Float64Array(8);e.getPercent(q)!==null&&(C[n++]=q.x,C[n++]=q.y);let N=t.end();e.getPercent(N)!==null&&(C[n++]=N.x,C[n++]=N.y);let T=e.start();t.getPercent(T)!==null&&(C[n++]=T.x,C[n++]=T.y);let L=e.end();return t.getPercent(N)!==null&&(C[n++]=L.x,C[n++]=L.y),ge.set(C),n}}let[s,a]=i.pop(),o=s.controls,l=a.controls;if(o.length===2&&l.length===2){let q=ug(new ie(o[0],o[1]),new ie(l[0],l[1]));for(let C=0;C<q;C++)ys[n++]=ge[C];continue}let c=o[0],u=o[o.length-1];c.equals1(u)&&(u=c.add1(1,0));let h=u.y-c.y,d=c.x-u.x,p=-h*c.x-d*c.y,f=Math.sqrt(1/(h**2+d**2));h*=f,d*=f,p*=f;let m=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY;if(o.forEach(q=>{let C=h*q.x+d*q.y+p;C<m&&(m=C),C>g&&(g=C)}),Ve.eq(m,g)){if(a.controls.length===2){let q=ug(new ie(s.start(),s.end()),new ie(a.start(),a.end()));for(let C=0;C<q;C++)ys[n++]=ge[C];if(q!==0)continue}s=new Ye([o[0],o[o.length-1]]),o=s.controls}let b=l.map(q=>h*q.x+d*q.y+p),y=0;for(let q of b){if(Ve.less(q,m))y=y|1;else if(Ve.greater(q,g))y=y|2;else{y=3;break}if(y===3)break}if(y!==3)continue;let E=0,S=0,w=u.x-c.x,x=u.y-c.y,I=Math.sqrt(1/(w**2+x**2));w*=I,x*=I;for(let q=1;q<o.length;q++){let C=o[q],N=(C.x-c.x)*w+(C.y-c.y)*x;N<E?E=N:N>S&&(S=N)}y=0;for(let q of l){let C=(q.x-c.x)*w+(q.y-c.y)*x;if(Ve.less(C,E))y=y|1;else if(Ve.greater(C,S))y=y|2;else{y=3;break}if(y===3)break}if(y!==3)continue;let A=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;m-=Ve.eps,g+=Ve.eps,b.forEach((q,C)=>{q>=m&&q<=g&&R(C/(b.length-1))});let M=new ie(new j(0,m),new j(1,m)),F=new ie(new j(0,g),new j(1,g));for(let q=0;q<b.length-1;q++){let C=new j(q/(b.length-1),b[q]),N=C.y<m?1:C.y>g?2:3;for(let T=0;T<b.length;T++){let L=new j(T/(b.length-1),b[T]),P=L.y<m?1:L.y>g?2:3;N!==P&&(N===1?P===2?(G(new ie(C,L),M),G(new ie(C,L),F)):G(new ie(C,L),M):N===2?P===1?(G(new ie(C,L),M),G(new ie(C,L),F)):G(new ie(C,L),F):P===1?G(new ie(C,L),M):G(new ie(C,L),F))}}A!==0&&(a=a.clip(A)[1]),O!==1&&(a=a.clip((O-A)/(1-A))[0]);let V=a.bbox();if(Ve.eq(V.minX,V.maxX)&&Ve.eq(V.minY,V.maxY)){y=0;for(let q of a.controls){let C=(q.x-c.x)*w+(q.y-c.y)*x;if(Ve.less(C,E))y=y|1;else if(Ve.greater(C,S))y=y|2;else{y=3;break}if(y===3)break}y===3&&(ys[n++]=(V.minX+V.maxX)/2,ys[n++]=(V.minY+V.maxY)/2);continue}if(O-A>.8){let[q,C]=a.clip(.5);i.push([q,s]),i.push([C,s])}else i.push([a,s])}for(let s=0;s<n;s++)ge[s]=ys[s];return n}function iB(e,t){if(e.bbox().extendOfSize(Ve.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=0;for(;i.length!==0;){let n=i.pop();if(n[0]instanceof Se){let A=function(G){x=Math.min(x,G),I=Math.max(I,G)},M=function(G,V){let q=ug(G,V);if(q===0)throw new Error("cnt === 0");for(let C=0;C<q;C+=2)A(ge[C])},[s,a]=n,o=a.controls;if(o.length===2){let G=rC(s,new ie(o[0],o[1]));for(let V=0;V<G;V++)ys[r++]=ge[V];continue}let l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u,h,d,p,f;if(Math.abs(s.sweepAngle)>359){let G=s.rx;u=s.center.add1(G,0),h=s.center.add1(-G,0),l=-G,c=G,d=0,p=1,f=-s.center.y}else{u=s.start(),h=s.end(),d=h.y-u.y,p=u.x-h.x,f=-d*u.x-p*u.y;let G=Math.sqrt(1/(d**2+p**2));d*=G,p*=G,f*=G;let V=d*s.center.x+p*s.center.y+f;s.isCCW?(c=s.rx+V,l=0):(l=V-s.rx,c=0)}let m=o.map(G=>d*G.x+p*G.y+f),g=0;for(let G of m){if(Ve.less(G,l))g=g|1;else if(Ve.greater(G,c))g=g|2;else{g=3;break}if(g===3)break}if(g!==3)continue;let b=0,y=0,E=h.x-u.x,S=h.y-u.y,w=Math.sqrt(1/(E**2+S**2));if(E*=w,S*=w,Math.abs(s.sweepAngle)<=180)b=0,y=(h.x-u.x)*E+(h.y-u.y)*S;else throw new Error("not support");g=0;for(let G of o){let V=(G.x-u.x)*E+(G.y-u.y)*S;if(Ve.less(V,b))g=g|1;else if(Ve.greater(V,y))g=g|2;else{g=3;break}if(g===3)break}if(g!==3)continue;let x=Number.POSITIVE_INFINITY,I=Number.NEGATIVE_INFINITY;l-=Ve.eps,c+=Ve.eps,m.forEach((G,V)=>{G>=l&&G<=c&&A(V/(m.length-1))});let O=new ie(new j(0,l),new j(1,l)),R=new ie(new j(0,c),new j(1,c));for(let G=0;G<m.length-1;G++){let V=new j(G/(m.length-1),m[G]),q=V.y<l?1:V.y>c?2:3;for(let C=0;C<m.length;C++){let N=new j(C/(m.length-1),m[C]),T=N.y<l?1:N.y>c?2:3;q!==T&&(q===1?T===2?(M(new ie(V,N),O),M(new ie(V,N),R)):M(new ie(V,N),O):q===2?T===1?(M(new ie(V,N),O),M(new ie(V,N),R)):M(new ie(V,N),R):T===1?M(new ie(V,N),O):M(new ie(V,N),R))}}x!==0&&(a=a.clip(x)[1]),I!==1&&(a=a.clip((I-x)/(1-x))[0]);let F=a.bbox();if(Ve.eq(F.minX,F.maxX)&&Ve.eq(F.minY,F.maxY)){g=0;for(let G of a.controls){let V=(G.x-u.x)*E+(G.y-u.y)*S;if(Ve.less(V,b))g=g|1;else if(Ve.greater(V,y))g=g|2;else{g=3;break}if(g===3)break}g===3&&(ys[r++]=(F.minX+F.maxX)/2,ys[r++]=(F.minY+F.maxY)/2);continue}I-x>.8?a.clip(.5).forEach(G=>i.push([G,s])):i.push([a,s])}else{let[s,a]=n;i.push([Se.build3(a.center,a.startAngle,a.sweepAngle/2,a.rx,a.ry),s]),i.push([Se.build3(a.center,a.startAngle+a.sweepAngle/2,a.sweepAngle/2,a.rx,a.ry),s])}}for(let n=0;n<r;n++)ge[n]=ys[n];return r}var Lu=class e{constructor(t,i){this.minDistance=Number.MAX_VALUE;this.p=t,this.p1=i,this.intersection()?(this.minDistance=0,this.minline=new ie(j.ORIGIN,j.ORIGIN)):this.minline=this.minLine()}getDistance(){return this.minDistance}getLine(){return this.minline}intersection(){return Gc(this.p,this.p1)>0}minLine(){if(this.p instanceof ie&&this.p1 instanceof ie){let t=this.p,i=this.p1;return this.minDistanceForLines(t,i,this.minline)}else if(this.p instanceof Se&&this.p1 instanceof ie){let t=this.p,i=this.p1;return this.minDistanceForLineAndArc(t,i,this.minline)}else if(this.p instanceof ie&&this.p1 instanceof Se){let t=this.p1,i=this.p;return this.minDistanceForLineAndArc(t,i,this.minline)}else if(this.p instanceof Se&&this.p1 instanceof Se){let t=this.p,i=this.p1;return this.minDistanceForArcs(t,i,this.minline)}return this.minline}minDistanceForLines(t,i,r){let n=[t.start(),t.end(),i.start(),i.end()];for(let s=0;s<n.length;s++)s<2?r=this.point2LineMinLine(r,i,n[s]):r=this.point2LineMinLine(r,t,n[s]);return r}minDistanceForLineAndArc(t,i,r){r=this.point2LineMinLine(r,i,t.start()),r=this.point2LineMinLine(r,i,t.svgEnd);let n=e.foot(i,t.center);return i.bbox().isContains(n)&&(r=this.point2ArcMinLine(r,t,n)),r=this.point2ArcMinLine(r,t,i.start()),r=this.point2ArcMinLine(r,t,i.end()),r}minDistanceForArcs(t,i,r){return r=this.concentricArc(t,i,r),Pr(t,i.center)&&Pr(i,t.center)?r=this.shortestLineForArcs(t,i,r):(r=this.point2ArcMinDistance(i.start(),t,r),r=this.point2ArcMinDistance(i.svgEnd,t,r),r=this.point2ArcMinDistance(t.start(),i,r),r=this.point2ArcMinDistance(t.svgEnd,i,r)),r}minLineForArcAndLine(t,i,r){let n=t.pointOn(r.angleD(t.center)),s=t.pointOn(t.center.angleD(r));return i=this.arcShortestLine(t,i,r,n),i=this.arcShortestLine(t,i,r,s),i}arcInnerLineFootSegment(t,i,r){let n=r.distance1(t.center);if(n!==0){let s=t.rx*(r.y-t.center.y)/n+t.center.y,a=t.rx*(r.x-t.center.x)/n+t.center.x,o=new ie(new j(a,s),r);n=t.rx-n,n<this.minDistance&&(this.minDistance=n,i=o)}else{let s=new ie(t.start(),r);n=t.rx-n,n<this.minDistance&&(this.minDistance=n,i=s)}return i}shortestLineForArcs(t,i,r){let n=t.center.angleD(i.center),s=i.center.angleD(t.center),a=t.pointOn(n),o=t.pointOn(s),l=i.pointOn(n),c=i.pointOn(s);return Pr(t,a)&&(r=this.arcShortestLine(i,r,a,l),r=this.arcShortestLine(i,r,a,c)),Pr(t,o)&&(r=this.arcShortestLine(i,r,o,l),r=this.arcShortestLine(i,r,o,c)),r}concentricArc(t,i,r){if(t.center.distance1(i.center)<1e-5&&t.rx===i.rx&&t.ry===i.ry){let n=new ie(t.start(),i.svgEnd);n.length()<this.minDistance&&(this.minDistance=n.length(),r=n),n=new ie(i.start(),t.svgEnd),n.length()<this.minDistance&&(this.minDistance=n.length(),r=n)}return r}point2ArcMinDistance(t,i,r){if(Pr(i,t)){let n=i.pointOn(t.angleD(i.center)),s=i.pointOn(i.center.angleD(t));r=this.arcShortestLine(i,r,t,n),r=this.arcShortestLine(i,r,t,s)}else r=this.minLineSegment(r,i.start(),t),r=this.minLineSegment(r,i.svgEnd,t);return r}point2ArcMinLine(t,i,r){if(Pr(i,r)){let n=r.distance1(i.center);n>i.rx||n>i.ry?t=this.minLineForArcAndLine(i,t,r):t=this.arcInnerLineFootSegment(i,t,r)}return t}point2LineMinLine(t,i,r){let n=e.foot(i,r);return i.bbox().isContains(n)?t=this.minLineSegment(t,n,r):(t=this.minLineSegment(t,i.start(),r),t=this.minLineSegment(t,i.end(),r)),t}minLineSegment(t,i,r){let n=i.distance1(r);return n<this.minDistance&&(this.minDistance=n,t=new ie(i,r)),t}arcShortestLine(t,i,r,n){if(Pr(t,n)){let s=new ie(r,n),a=s.length();a<this.minDistance&&(this.minDistance=a,i=s)}return i}static foot(t,i){if(t.isPoint())return t.start();if(!Ve.eq(t.b,0)&&!Ve.eq(t.a,0)){let r=(t.b*t.b*i.x-t.a*t.b*i.y-t.a*t.c)/(t.b*t.b+t.a*t.a),n=(-t.a*t.b*i.x+t.a*t.a*i.y-t.b*t.c)/(t.b*t.b+t.a*t.a);return new j(r,n)}else return Ve.eq(t.b,0)&&!Ve.eq(t.a,0)?new j(t.start().x,i.y):!Ve.eq(t.b,0)&&Ve.eq(t.a,0)?new j(i.x,t.start().y):i}};var nC=class{constructor(t,i,r){this._start=null;this._previous=null;this.next=null;this.interInStart=!1;this.intersInEnd=!1;this.othersIntersCount=0;this.shape=t,this.group=i,this.index=r,this._end=t.end()}set previous(t){this._previous=t,this.previous!=null&&(this._start=this.previous.shape.end())}get previous(){return this._previous}get start(){return this._start}get end(){return this._end}getNext(){let t=null,i=this.intersInEnd,r=this.next;for(;i&&r!=this;)if(r.interInStart){t=r;break}else r=r.next;return t}getStartDirect(){if(this.shape instanceof ie)return this.shape.direct;if(this.shape instanceof Se){let t=this.start.sub(this.shape.center).normalize();return this.shape.sweep()==vs.CCW?new j(-t.y,t.x):new j(t.y,-t.x)}else return null}getEndDirect(){if(this.shape instanceof ie)return this.shape.direct;if(this.shape instanceof Se){let t=this.end.sub(this.shape.center).normalize();return this.shape.sweep()==vs.CCW?new j(-t.y,t.x):new j(t.y,-t.x)}else return null}},sC=class{pointInPolyline(t,i){if(!i.bbox().isContains(t))return!1;for(let s of i.primitives)if(this.inEdge(t,s))return!0;if(!this.isClose(i))return!1;let n=[];return i.points(.1,s=>{n.push(s)}),this.isSelect(t.x,t.y,n)}inEdge(t,i){if(i instanceof ie){let n=Lu.foot(i,t).distance1(t);return Ve.eq(n,0)?i.bbox().isContains(t):!1}else if(i instanceof Se){let r=t.distance1(i.center);return Ve.eq(r,i.rx)?Pr(i,t):!1}return!1}isSelect(t,i,r){let n=!1;for(let o=0,l=r.length-1;o<l;o++){let c=r[o],u=r[o+1];if(t==c.x&&i==c.y||t==u.x&&i==u.y)return!0;if(c.y<i&&u.y>=i||c.y>=i&&u.y<i){let h=c.x+(i-c.y)*(u.x-c.x)/(u.y-c.y);if(t==h)return!0;h>t&&(n=!n)}}let s=r[r.length-1],a=r[0];if(t==s.x&&i==s.y||t==a.x&&i==a.y)return!0;if(s.y<i&&a.y>=i||s.y>=i&&a.y<i){let o=s.x+(i-s.y)*(a.x-s.x)/(a.y-s.y);if(t==o)return!0;o>t&&(n=!n)}return n}isClose(t){return t.primitives.length>0&&t.primitives[0].start().distance2(t.primitives[t.primitives.length-1].end())<1e-8}map2Sides(t,i){let r=new Array,n=0,s=null;for(let a of t.primitives){let o=new nC(a,i,n);s!=null&&(s.next=o,o.previous=s),r.push(o),s=o,n++}return r[r.length-1].next=r[0],r[0].previous=r[r.length-1],r}inPolyline(t,i,r=0){if(!i.bbox().isContains1(t.x,t.y))return!1;let s=new j(1,0),a=this.map2Sides(i,r),{x:o,y:l}=t;for(let u of a){let h=u.shape.bbox();if(h.isContainsY1(l)&&Ve.greater(h.maxX,o)){let d=u.shape;if(d instanceof ie){let p=s.cross(d.direct);if(Ve.eq(p,0)){let f=!1;Ve.greatereq(u.start.x,o)&&(u.interInStart=!1,f=!f),Ve.greatereq(u.end.x,o)&&(u.intersInEnd=!1,f=!f),f&&(u.othersIntersCount=1);continue}else if(Ve.eq(u.start.y,l)&&Ve.greatereq(u.start.x,o))u.interInStart=!0;else if(Ve.eq(u.end.y,l)&&Ve.greatereq(u.end.x,o))u.intersInEnd=!0;else{let f=(u.end.x-u.start.x)/(u.end.y-u.start.y)*(l-u.start.y)+u.start.x;Ve.greatereq(f,o)&&(u.othersIntersCount=1)}}else if(d instanceof Se){let{center:p}=d,f=t.distance1(p);if(Ve.greatereq(Math.abs(d.sweepAngle),360)){Ve.lesseq(f,d.rx)&&(u.othersIntersCount=1);continue}let m=Math.abs(l-p.y);if(Ve.eq(m,d.rx)){Ve.greatereq(u.start.x,o)&&Ve.eq(u.start.y,l)&&(u.interInStart=!0),Ve.greatereq(u.end.x,o)&&Ve.eq(u.end.y,l)&&(u.intersInEnd=!0);continue}else{let g=aB(d,l);if(g>0){for(let b=0;b<g;b+=2)if(Ve.greatereq(ge[b],o)){let y=new j(ge[b],ge[b+1]);y.equals1(u.start)?u.interInStart=!0:y.equals1(u.end)?u.intersInEnd=!0:u.othersIntersCount++}}}}else throw new Error("not supported!")}}let c=0;for(let u of a)if(u.intersInEnd){let h=u.getNext();if(h!=null){let d=u.getEndDirect(),p=h.getStartDirect();d!=null&&p!=null&&Ve.greater(d.y*p.y,0)&&c++}}else c+=u.othersIntersCount;return c%2==1}inPolygon(t,i){let r=!1;for(let n of i)this.inPolyline(t,n)&&(r=!r);return r}},oB=new sC;function vZ(e,t){let i=e.bbox(),r=t.bbox(),n=(i.minY+i.maxY)/2,s=(r.minY+r.maxY)/2;return n-s}function TZ(e,t){let i=e.bbox(),r=t.bbox(),n=(i.minX+i.maxX)/2,s=(r.minX+r.maxX)/2;return n-s}var _d=class{constructor(t){this.__bbox=null;if(typeof t<"u")if(t instanceof Array){this.__items=[];for(let i of t)this.add(i)}else this.__items=t,this.__bbox=t.bbox();else this.__items=[]}add(t){if(this.__items instanceof Array)this.__items.push(t),this.__bbox=St.extend2(this.__bbox,t.bbox());else throw new Error("can't insert multiple item into leaf node")}items(){return this.__items}bbox(){if(this.__bbox!==null)return this.__bbox;throw new Error("bug")}},Pd=class{constructor(t){this.changed=!1;this.root=new _d,this.capacity=t,this.capacity2=t*t,this.itemList=[]}size(){return this.itemList.length}items(){return this.flushWhenNeed(),this.itemList}add(t){this.itemList.push(t),this.changed=!0}remove(t){ps.remove(this.itemList,t),this.changed=!0}clear(){this.changed=!1,this.root=new _d,this.itemList.length=0}flushWhenNeed(){if(this.changed){let t=new Array;for(let i of this.itemList)t.push(new _d(i));for(;;){let i=this.organize(t);if(i.length>1)t=i;else break}this.root=new _d(t),this.changed=!1}}organize(t){ql(t,TZ,0,t.length);let i=t.length,r=[];for(let n=0;n<i;)if(n+this.capacity2<=i){let s=n+this.capacity2;ql(t,vZ,n,s);for(let a=n;a<s;a+=this.capacity){let o=new _d(t.slice(a,a+this.capacity));r.push(o)}n=n+this.capacity*this.capacity}else{let s=new _d(t.slice(n,n+this.capacity));r.push(s),n=n+this.capacity}return r}search(t){this.flushWhenNeed();let i=[],r=[];for(r.push(this.root);;){let n=r.shift();if(typeof n<"u"){let s=n.items();if(s instanceof Array){for(let a of s)if(!t.isSeparated(a.bbox())){let o=a.items();o instanceof Array?r.push(a):i.push(o)}}else t.isSeparated(n.bbox())||i.push(s)}else break}return i}walker(t){this.flushWhenNeed(),this._walker(this.root,0,t)}_walker(t,i,r){this.flushWhenNeed();let n=t.items();if(n instanceof Array)for(let s of n)this._walker(s,i+1,r);else r(n,i)}bbox(){return this.flushWhenNeed(),this.root.bbox()}};var hg=class{constructor(t,i,r,n){this.sides=new Array;this.loader=t,this.logger=r,this.rule=i,this.event=n}addPolyline(t,i=1){let r=this.loader.buildGroup(t,i);for(let n of r)this.sides.push(n),this.event.onOriginSide(n);return r}buildRTree(){let t=new Pd(10);for(let i of this.sides)t.add(i);return t}};var Ih=class{constructor(t){this._status=2;this.sides=[];this.connect=[];this.keepWeight=0;this.reverseWeight=0;this.invalidWeight=0;this.weight=t}get status(){return this._status}get start(){return this.sides[0].start}get end(){return this.sides[this.sides.length-1].end}mark(){if(this._status===2){if(this.invalidWeight>this.keepWeight&&this.invalidWeight>this.reverseWeight){this._status=1;return}if(this.keepWeight>this.reverseWeight&&this.keepWeight>this.invalidWeight){this._status=0;return}if(this.reverseWeight>this.keepWeight&&this.reverseWeight>this.invalidWeight){this._status=0,this.needReverse=!0;return}}}reverse(){let t=this.reverseWeight;this.reverseWeight=this.keepWeight,this.keepWeight=t;let i=[];for(;this.sides.length!==0;)i.push(this.sides.pop().reverse());for(let n of i)this.sides.push(n);this.startNode&&(this.startNode.outChainSet.delete(this),this.startNode.inChainSet.add(this),this.endNode.inChainSet.delete(this),this.endNode.outChainSet.add(this));let r=this.startNode;this.startNode=this.endNode,this.endNode=r}bbox(){return this.sides.reduce((t,i)=>t.ext1(i.bbox()),new ot).build()}getWindingNum(t){let i=this.end,r=0,{x:n,y:s}=t;for(let a of this.sides){let{start:o,end:l,shape:c}=a;if(i.y>s!=o.y>s&&(i.x>n?o.x>n?r+=o.y>i.y?1:-1:i.y>o.y?(i.x-n)*(o.y-s)-(i.y-s)*(o.x-n)<0&&r--:(i.x-n)*(o.y-s)-(i.y-s)*(o.x-n)>0&&r++:o.x>n&&(i.y>o.y?(i.x-n)*(o.y-s)-(i.y-s)*(o.x-n)<0&&r--:(i.x-n)*(o.y-s)-(i.y-s)*(o.x-n)>0&&r++)),o.y>s!=l.y>s){if(o.x>n)if(l.x>n)r+=l.y>o.y?1:-1;else if(c instanceof ie)o.y>l.y?(o.x-n)*(l.y-s)-(o.y-s)*(l.x-n)<0&&r--:(o.x-n)*(l.y-s)-(o.y-s)*(l.x-n)>0&&r++;else if(c instanceof Se){let{center:u,isCCW:h,rx2:d}=c,p=(u.x-n)**2+(u.y-s)**2;o.y>l.y?(h?p>d:p<d)&&r--:(h?p<d:p>d)&&r++}else if(c instanceof Ye){if(y1(c,s)===0)throw new Error("no inters");ge[0]>n&&(r+=l.y>o.y?1:-1)}else throw new Error("not support!");else if(l.x>n)if(c instanceof ie)o.y>l.y?(o.x-n)*(l.y-s)-(o.y-s)*(l.x-n)<0&&r--:(o.x-n)*(l.y-s)-(o.y-s)*(l.x-n)>0&&r++;else if(c instanceof Se){let{center:u,isCCW:h,rx2:d}=c,p=(u.x-n)**2+(u.y-s)**2;o.y>l.y?(h?p>d:p<d)&&r--:(h?p<d:p>d)&&r++}else if(c instanceof Ye){if(y1(c,s)===0)throw new Error("no inters");ge[0]>n&&(r+=l.y>o.y?1:-1)}else throw new Error("not support!")}i=l}return r}};function D2(e,t){let i=0;if(Math.abs(e.start.y-t)<=1e-4)ge[i++]=e.start.x;else if(Math.abs(e.end.y-t)<=1e-4)ge[i++]=e.end.x;else if(e.shape instanceof ie)i=nB(e.shape,t);else if(e.shape instanceof Se)i=sB(e.shape,t);else if(e.shape instanceof Ye)i=y1(e.shape,t);else throw new Error("not supported operation");return i}var Ld=class{constructor(t,i,r,n,s,a){this.inters=[];this._confidence=0;this._confidence_y=NaN;this._x=NaN;this._x_y=NaN;this.trans=NaN;this.previous=null;this.next=null;this.shape=t,i.y>r.y?this.weight=-a.weight:i.y==r.y?this.weight=0:this.weight=a.weight,this.start=i,this.end=r,this.polyGrp=n,this.polyIndex=s,this._bbox=new ot().ext1(t.bbox()).ext2(i).ext2(r).build(),this.inters.push([i,null]),this.inters.push([r,null]),this.chain=a}updateBbox(){this._bbox=new ot().ext2(this.start).ext2(this.end).build()}confidence(t){if(this._confidence_y!=t){let i=this._bbox.height();i!==0?Math.abs(t-this._bbox.maxY)>5e-4&&Math.abs(t-this._bbox.minY)>5e-4?this._confidence=(1-Math.abs(2*t-this._bbox.maxY-this._bbox.minY)/i)*1e4|0:this._confidence=0:this._confidence=1,this._confidence_y=t}return this._confidence}revokeOutside(t){let i=this.confidence(t);return this.start.y>this.end.y?this.chain.reverseWeight-=i:this.chain.keepWeight-=i,this.chain.invalidWeight+=i,i}revokeInside(t){let i=this.confidence(t);return this.start.y<this.end.y?this.chain.reverseWeight-=i:this.chain.keepWeight-=i,this.chain.invalidWeight+=i,i}setOutside(t){let i=this.confidence(t);return this.start.y>this.end.y?this.chain.reverseWeight+=i:this.chain.keepWeight+=i,i}setInside(t){let i=this.confidence(t);return this.start.y<this.end.y?this.chain.reverseWeight+=i:this.chain.keepWeight+=i,i}setInvalid(t){let i=this.confidence(t);return this.chain.invalidWeight+=i,i}prevNot0(){let t=this.previous;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.previous}return null}nextNot0(){let t=this.next;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.next}return null}getX(t){return(this._x_y!=t||isNaN(this._x))&&(D2(this,t)>0?this._x=ge[0]:this._x=NaN,this._x_y=t),this._x}voteStatus(){let{keepWeight:t,reverseWeight:i,invalidWeight:r,status:n}=this.chain;return n===1?3:n===0?(this.chain.needReverse?!(this.end.y>this.start.y):this.end.y>this.start.y)?2:1:t>r&&t>i?this.end.y>this.start.y?2:1:r>t&&r>i?3:i>r&&i>t?this.end.y<this.start.y?2:1:0}reverse(){let t;if(this.shape instanceof ie)t=new ie(this.shape.end(),this.shape.start());else if(this.shape instanceof Se)t=Se.build3(this.shape.center,this.shape.endAngle(),-this.shape.sweepAngle,this.shape.rx,this.shape.ry);else if(this.shape instanceof Ye)t=new Ye(this.shape.controls.slice().reverse());else throw new Error("not supported operation");this.shape=t;let i=this.start;return this.start=this.end,this.end=i,this}isNeedScan(t){return this.chain.keepWeight+this.chain.reverseWeight+this.chain.invalidWeight<5e3&&this.confidence(t)>0&&this.chain.status===2}bbox(){return this._bbox}toString(){return Fo.format("(%d,%d,%d) (%d,%d,%d) %s %s",this.polyGrp,this.polyIndex,this.weight,this.chain.keepWeight,this.chain.reverseWeight,this.chain.invalidWeight,this.start,this.end)}};var Wa=class{constructor(t){this.cache={};this.levels=t,this.result=new Array(t),this.weights=new Array(t),this.maxIdx=t-1,this.rule=this.decide.bind(this);let i=1;for(let r=0;r<t;r++)this.weights[r]=i,i*=50}weight(t){return this.weights[t]}decide(t){t=Math.abs(t);let i=this.cache[t];if(i===void 0){let r=t;for(let n=this.maxIdx;n>=0;n--){let s=this.weights[n],a=Math.floor(t/s),o=t%s;o>Math.floor(s/2)?(t=s-o,a++):t=o,this.result[n]=a>0}i=this.decide1(this.result),this.cache[r]=i}return i}};var aC=new class extends Wa{decide1(t){return t[0]||t[1]}}(2),sye=[aC,new class extends Wa{decide1(t){return t[0]||t[1]||t[2]}}(3),new class extends Wa{decide1(t){return t[0]||t[1]||t[2]||t[3]}}(4),new class extends Wa{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]}}(5),new class extends Wa{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]||t[5]}}(6),new class extends Wa{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]}}(7),new class extends Wa{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7]}}(8),new class extends Wa{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7]||t[8]}}(9)],pye=new class extends Wa{decide1(t){return t[0]&&!t[1]}}(2),mye=new class extends Wa{decide1(t){return t[0]&&t[1]}}(2),yye=new class extends Wa{decide1(t){return t[0]&&!t[1]||!t[0]&&t[1]}}(2);var dg=class{constructor(t,i=!0){this.polyGrp=0;this.polyIndex=0;this.prevPoint=null;this.noWeight0=t,this.keepBezier=i}completeGroup(){this.prevPoint&&this.curSideChain.sides.length!==0&&!this.prevPoint.equals1(this.curSideChain.start)&&this.addSide(new ie(this.prevPoint,this.curSideChain.start),!1);let t,i=null,r=null;return this.noWeight0?t=this.curSideChain.sides.filter(n=>n.weight===0?!1:(i!=null?(i.next=n,n.previous=i):r=n,i=n,!0)):(t=this.curSideChain.sides,t.forEach(n=>{i!=null?(i.next=n,n.previous=i):r=n,i=n})),i!=null&&r!=null&&(r.previous=i,i.next=r),this.polyGrp++,this.curSideChain=null,this.prevPoint=null,this.polyIndex=0,t}buildGroup(t,i){this.curSideChain=new Ih(i);for(let r of t.primitives)if(r instanceof ie)this.addSide(r);else if(r instanceof Se&&r.rx===r.ry)this.addArc(r);else if(r instanceof Ye&&r.controls.length<=4&&this.keepBezier)this.addBezier(r);else{let n=null;for(let s of r.points(.01))n!=null&&this.addSide(new ie(n,s)),n=s}return this.completeGroup()}addArc(t){let i=t.sweepAngle,r=_a.regularD(t.startAngle),n=r+i;if(i>0){let s=90;for(;s<=n;)s>r&&(this.addSide(Se.build3(t.center,r,s-r,t.rx,t.ry)),r=s),s+=90;r<n&&this.addSide(Se.build3(t.center,r,n-r,t.rx,t.ry))}else if(i<0){let s=270;for(;s>=n;)s<r&&(this.addSide(Se.build3(t.center,r,s-r,t.rx,t.ry)),r=s),s-=90;r>n&&this.addSide(Se.build3(t.center,r,n-r,t.rx,t.ry))}}isInRange(t){return Ve.greater(t,0)&&Ve.less(t,1)}getT0(t,i,r,n){let s=t[n]-2*i[n]+r[n],a=i[n]-t[n];if(s===0)return[];let o=-a/s,l=[];return this.isInRange(o)&&l.push(o),l}getT10(t,i,r,n,s){let a,o,l=-t[s]+3*i[s]-3*r[s]+n[s],c=2*(t[s]-2*i[s]+r[s]),u=i[s]-t[s],h=c**2-4*l*u;if(Ve.lesseq(h,0))a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;else{let p=Math.sqrt(h);a=(-c-p)/(2*l),o=(-c+p)/(2*l);let f=l*2;if(Ve.lesseq(a,1)&&Ve.greatereq(a,0)){let m=Number.NEGATIVE_INFINITY;for(;Ve.neq(a,m);){m=a;let g=f*a+c;a=-(l*a**2+c*a+u-g*a)/g}}if(Ve.lesseq(o,1)&&Ve.greatereq(o,0)){let m=Number.NEGATIVE_INFINITY;for(;Ve.neq(o,m);){m=o;let g=f*o+c;o=-(l*o**2+c*o+u-g*o)/g}}}let d=[];return this.isInRange(o)&&d.push(o),this.isInRange(a)&&d.push(a),d}addBezier(t){if(t.controls.length===2){this.addSide(t);return}let i,r;if(t.controls.length===3){let[o,l,c]=t.controls;i=this.getT0(o,l,c,"x"),r=this.getT0(o,l,c,"y")}else{let[o,l,c,u]=t.controls;i=this.getT10(o,l,c,u,"x"),r=this.getT10(o,l,c,u,"y")}let n=i.pop()||1,s=r.pop()||1,a=0;for(;n!==1||s!==1;)if(Ve.eq(n,s))n=i.pop()||1,s=r.pop()||1;else if(n<s){let[o,l]=t.clip(n/(1-a));a=n,this.addSide(o),t=l,n=i.pop()||1}else{let[o,l]=t.clip(s/(1-a));a=s,this.addSide(o),t=l,s=r.pop()||1}this.addSide(t)}equals(t,i){return Math.abs(t.x-i.x)<=.1&&Math.abs(t.y-i.y)<=.1}addSide(t,i=!0){let r=t.start(),n=t.end();if(i){if(this.prevPoint){if(this.equals(this.prevPoint,n))return;this.prevPoint.equals1(r)||this.addSide(new ie(this.prevPoint,r),!1)}else if(this.equals(r,n)){this.prevPoint=r;return}}let s=new Ld(t,r,n,this.polyGrp,this.polyIndex++,this.curSideChain);this.curSideChain.sides.push(s),this.prevPoint=n}};var _2=new Error("list is empty"),pg=class{constructor(t,i){this.prev=null;this.next=null;this.parent=t,this.item=i}insertAfter(t){t.next=this.next,this.next=t,t.prev=this,t.next!==null&&(t.next.prev=t)}insertBefore(t){t.prev=this.prev,this.prev=t,t.next=this,t.prev!==null&&(t.prev.next=t)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(t){this.item=t}},oC=class{get value(){return this._next}constructor(t){this._next=t}hasNext(){return this._next!==null}next(){let t=this._next;if(t!==null)return this._next=t.next,t.item;throw new Error("iterator is null")}},lC=class{constructor(t){this._next=t}hasNext(){return this._next!==null}next(){let t=this._next;if(t!==null)return this._next=t.next,t;throw new Error("iterator is null")}},Uo=class{constructor(){this.first=null;this.last=null;this.cnt=0}add(t){return this.addLast(t)}push(t){return this.addLast(t)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let t=this.first;if(t===null)throw _2;return this.remove(t),t.item}removeLast(){let t=this.last;if(t===null)throw _2;return this.remove(t),t.item}addLast(t){if(this.first===null||this.last===null){let i=new pg(this,t);return this.first=i,this.last=i,this.cnt++,i}else return this.insertAfter(this.last,t)}addFirst(t){if(this.first===null||this.last===null){let i=new pg(this,t);return this.first=i,this.last=i,this.cnt++,i}else return this.insertBefore(this.first,t)}getFirst(){if(this.first===null)throw _2;return this.first.item}getLast(){if(this.last===null)throw _2;return this.last.item}insertAfter(t,i){let r=new pg(this,i);return t.insertAfter(r),t===this.last&&(this.last=r),this.cnt++,r}insertBefore(t,i){let r=new pg(this,i);return t.insertBefore(r),t===this.first&&(this.first=r),this.cnt++,r}remove(t){t.remove(),t===this.first&&(this.first=t.next),t===this.last&&(this.last=t.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new oC(this.first)}listIterator(){return new lC(this.first)}toArray(){let t=new Array,i=this.first;for(;i!=null;)t.push(i.item),i=i.next;return t}};var fg=class{constructor(t,i,r,n=0){this.start=null;this.prevStart=null;this.prevEnd=null;this.last=null;this.y=r,this.rule=t,this.event=i.event,this.curWeight=n,t(n)&&(this.start=void 0)}getCurWeight(){return this.curWeight}onEp(t){this.tuningWeight(t),this.start===null?this.rule(this.curWeight)?this.in(t):t.setInvalid(this.y):this.rule(this.curWeight)?t.setInvalid(this.y):this.out(t),this.last!==null&&this.event.onSweep1(this.last,t,this.y),this.last=t}in(t){this.prevEnd!=null&&this.onSameX(t,this.prevEnd)?(this.start=this.prevStart,this.prevStart=null,this.prevEnd.revokeInside(this.y),this.prevEnd=null):(this.start=t,this.start.setOutside(this.y))}connect(t){t.chain.connect.push(this.start.chain),this.start.chain.connect.push(t.chain)}out(t){if(this.start===void 0){t.setInside(this.y),this.start=null;return}if(this.onSameX(this.start,t))this.start.revokeOutside(this.y);else{if(t.setInside(this.y)>0&&this.start.confidence(this.y)>0){let i=this.start.voteStatus(),r=t.voteStatus();this.isValid(i)&&this.isValid(r)?i==2&&r==1&&this.connect(t):this.connect(t)}this.event.onSegment1(this.start,t,this.y),this.prevStart=this.start,this.prevEnd=t}this.start=null}isValid(t){return t==1||t==2}onSameX(t,i){return t.bbox().isIntersect(i.bbox())&&Ve.eq(t.getX(this.y),i.getX(this.y))}tuningWeight(t){this.curWeight+=t.weight;let i=t.nextNot0(),r=t.prevNot0();i!=null&&t.weight===i.weight&&i.trans===this.y&&(this.curWeight-=t.weight),r!=null&&t.weight===r.weight&&r.trans===this.y&&(this.curWeight-=t.weight),t.trans=this.y}};var IZ=!0,AZ=!1,CZ=!1,DZ=!0,_Z=!0,PZ=!0,LZ=!0,P2=class extends Lm{constructor(t){super(),this.debug=t}display(){}onPolylineGroup(t,i){this.debug}onSegment(t,i,r,n){this.debug}onIntersect(t,i,r){this.debug}onResultSide(t){this.debug}onOriginSide(t){this.debug}onSplitedSide(t){this.debug}onDebugSide(t){this.debug}onSweep(t,i,r,n){this.debug}};function L2(e){throw new Error("")}var mg=class{constructor(t,i){this.node1=null;this.node2=null;this.key=t,this.value=i}},cC=class{constructor(t){this.itors=t}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},uC=class{constructor(t){this.itors=t}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},O2=class{constructor(){this.innerList=new Uo;this.innerMap={}}replace(t,i){t.node1!==null&&(t.node1.set(i),i.node1=t.node1),t.node2!==null&&(t.node2.set(i),i.node2=t.node2)}clear(){this.innerList.clear();for(let t in this.innerMap)delete this.innerMap[t]}put(t,i){let r=t.hashCode(),n=new mg(t,i),s=this.innerMap[r];if(s===void 0)return n.node1=this.innerList.add(n),this.innerMap[r]=n,null;if(s instanceof mg){if(s.key.equals(t))return this.innerMap[r]=n,this.replace(s,n),s.value;{n.node1=this.innerList.add(n);let a=new Uo;return s.node2=a.add(s),n.node2=a.add(n),this.innerMap[r]=a,null}}if(s instanceof Uo){let a=null;return tg(s,(o,l)=>l.key.equals(t)?(this.replace(l,n),a=l.value,!1):!0),a===null?(n.node1=this.innerList.add(n),n.node2=s.push(n),null):a}return L2(s)}get(t){let i=t.hashCode(),r=this.innerMap[i];if(r===void 0)return null;if(r instanceof mg)return r.key.equals(t)?r.value:null;if(r instanceof Uo){let n=null;return tg(r,(s,a)=>a.key.equals(t)?(n=a.value,!1):!0),n}return L2(r)}containsKey(t){return this.get(t)!==null}delete(t){t.node1!==null&&t.node1.parent.remove(t.node1),t.node2===null?delete this.innerMap[t.key.hashCode()]:t.node2.parent.remove(t.node2)}remove(t){let i=t.hashCode(),r=this.innerMap[i];if(r===void 0)return null;if(r instanceof mg)return r.key.equals(t)?(this.delete(r),r.value):null;if(r instanceof Uo){let n=null;return tg(r,(s,a)=>a.key.equals(t)?(n=a.value,this.delete(a),!1):!0),n}return L2(r)}computeIfAbsent(t,i){let r=this.get(t);if(r===null){let n=i(t);return this.put(t,n),n}else return r}size(){return this.innerList.size()}isEmpty(){return this.innerList.size()===0}keys(){return new cC(this.innerList.iterator())}values(){return new uC(this.innerList.iterator())}entries(){return this.innerList.iterator()}};var hC=class{constructor(){this.points=[];this.lines=[];this.arcs=[];this.beziers=[];this.listText=[];this.fonts=[]}addPt(t,i=!0){if(t instanceof ie)this.lines.push(t);else if(t instanceof Se)this.arcs.push(t);else if(t instanceof Ye)this.beziers.push(t);else throw new Error("not support");i&&this.points.push(t.start())}addPoint(t){this.points.push(t)}addText(t,i,r=1,n=.1,s=!0){this.listText.push({pos:t,str:i,size:r,width:n}),s&&this.points.push(t)}addPly(t,i=!0){t.primitives.forEach(r=>this.addPt(r,i))}build(){let t=[],i=[],r=[],n=[],s=[],a=[];return this.points.forEach(o=>t.push(o.x,o.y)),this.lines.forEach(o=>i.push(o.start().x,o.start().y,o.end().x,o.end().y)),this.arcs.forEach(o=>r.push(o.center.x,o.center.y,o.rx,_a.toRadians(o.startAngle),_a.toRadians(o.endAngle()),o.sweep())),this.beziers.forEach(o=>{o.controls.forEach(l=>{n.push(l.x,l.y)}),n.push("end")}),this.listText.forEach(o=>s.push(o.pos.x,o.pos.y,o.str,o.width,o.size)),this.fonts.forEach(o=>a.push(o)),{points:t,lines:i,arcs:r,texts:s,beziers:n,fonts:a}}},R2=class{constructor(t){this.map=new O2;this.bus=t}initColor(t){return this.map.computeIfAbsent(t,()=>new hC)}draw(){let t={},i=this.map.entries();for(;i.hasNext();){let r=i.next();t[r.key.toString()]=r.value.build()}this.bus.publish("/debug/draw",t)}clear(){this.map.clear()}},ln=class ln{static isHexFormate(t){return!t||typeof t!="string"?!1:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}static of1(t){return this.of2(t>>16&255,t>>8&255,t&255)}static of2(t,i,r,n=255){return new ln(t/255,i/255,r/255,n/255)}static of3(t){t.startsWith("#")&&(t=t.substr(1));let i=t.length;if(i==3)return new ln(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15);if(i==6)return new ln(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255);if(i==8)return new ln(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255,parseInt(t.substr(6,2),16)/255);throw new Error("invalid color string")}static of4(t){let i=parseInt(t.r*255+"").toString(16),r=parseInt(t.g*255+"").toString(16),n=parseInt(t.b*255+"").toString(16);return i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),n.length<2&&(n="0"+n),("#"+i+r+n).toUpperCase()}static of5(t,i){if(t.startsWith("#")&&(t=t.substr(1)),t.length==3)return new ln(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15,i);if(t.length==6)return new ln(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255,i);throw new Error("invalid color string")}static of6(t,i){return new ln(t.r,t.g,t.b,i)}static of7(t){return t==null?null:ln.of3(t)}constructor(t,i,r,n=1){this.r=Au.positiveOr0(t),this.g=Au.positiveOr0(i),this.b=Au.positiveOr0(r),this.alpha=n}hashCode(){return this.r+this.g+this.b+this.alpha}equals(t,i=!1){let r=this.r===t.r&&this.g===t.g&&this.b===t.b;return i?r:r&&this.alpha===t.alpha}add(t,i,r,n){return new ln(Math.max(0,Math.min(1,this.r+t)),Math.max(0,Math.min(1,this.g+i)),Math.max(0,Math.min(1,this.b+r)),Math.max(0,Math.min(1,this.alpha+n)))}mul(t){return new ln(Math.max(0,Math.min(1,this.r*t)),Math.max(0,Math.min(1,this.g*t)),Math.max(0,Math.min(1,this.b*t)),this.alpha)}mul1(t){return new ln(Math.max(0,this.r*t),Math.max(0,this.g*t),Math.max(0,this.b*t),this.alpha)}getData(){return[this.r,this.g,this.b,this.alpha]}toString(){let t=(this.r*255).toString(16),i=(this.g*255).toString(16),r=(this.b*255).toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),"#"+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)}toString1(){let t=(this.r*255).toString(16),i=(this.g*255).toString(16),r=(this.b*255).toString(16),n=(this.alpha*255).toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),n.length<2&&(n="0"+n),"#"+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)+n.substr(0,2)}toRGBA(){let t=this.r*255,i=this.g*255,r=this.b*255;return[t,i,r,this.alpha]}toRGBAString(){let t=this.r*255,i=this.g*255,r=this.b*255;return`rgba(${t},${i},${r},${this.alpha})`}isWHITE(){return this.r===1&&this.g===1&&this.b===1&&this.alpha===1}};ln.WHITE=new ln(1,1,1,1),ln.BLACK=new ln(0,0,0,1),ln.RED=new ln(1,0,0,1),ln.GREEN=new ln(0,1,0,1),ln.BLUE=new ln(0,0,1,1),ln.Gray=ln.of3("#9966ff"),ln.Silver=ln.of3("#D2D2D2"),ln.Golden=ln.of3("#DCAA14");var Od=ln;var OZ=!0,RZ=!1,NZ=!1,MZ=!0,BZ=!0,cB=Od.RED,kZ=Od.GREEN,uB=Od.BLUE,dC=new Od(1,1,0),FZ=new Od(1,0,1),Zp=class extends P2{constructor(i,r=null){super(i);this.plGrps=new Array;r&&(this.drawDebug=new R2(r))}onPolylineGroup(i,r){super.onPolylineGroup(i,r),this.plGrps.push(i),!(!this.drawDebug||!BZ)&&i.items.forEach((n,s)=>n.primitives.forEach(a=>{this.drawDebug.initColor(s===0?kZ:FZ).addPt(a)}))}onOriginSide(i){super.onOriginSide(i),!(!this.drawDebug||!OZ)&&this.drawDebug.initColor(uB).addPt(i.shape)}onIntersect(i,r,n){super.onIntersect(i,r,n),!(!this.drawDebug||!RZ)&&this.drawDebug.initColor(cB).addPoint(i)}onScan(i,r,n,s,a,o){if(super.onScan(i,r,n,s,a,o),!this.drawDebug||!NZ)return;let l=r.getX(n);isNaN(l)&&(l=Math.abs(r.start.y-n)>Math.abs(r.end.y-n)?r.end.x:r.start.x);let c=i?new j(l,n).rotate(j.ORIGIN,-Math.PI/2):new j(l,n);this.drawDebug.initColor(uB).addText(c,`${a}=${o}${i?"=V":""}`)}onResultSide(i){if(super.onResultSide(i),!(!this.drawDebug||!MZ)&&this.lastResultChain!==i.chain&&(this.lastResultChain=i.chain,i.chain.status===0)){for(let r of i.chain.sides)this.drawDebug.initColor(dC).addPt(r.shape,!1);i.chain.startNode&&(this.drawDebug.initColor(dC).addPoint(i.chain.start),this.drawDebug.initColor(dC).addPoint(i.chain.end))}}onDebugSide(i){var r;super.onDebugSide(i),(r=this.drawDebug)==null||r.initColor(cB).addPt(i.shape)}onEnd(){var i;(i=this.drawDebug)==null||i.draw()}};var N2=class{constructor(){this._inChainSet=new Set;this._outChainSet=new Set;this._mergedNode=this}get mergedNode(){for(;!this._mergedNode._inChainSet;)this._mergedNode=this._mergedNode._mergedNode;return this._mergedNode}get inChainSet(){return this.mergedNode._inChainSet}get outChainSet(){return this.mergedNode._outChainSet}merge(t){if(!t)return this._mergedNode;let i=this.mergedNode,r=t.mergedNode;if(i===r)return i;for(let n of r._inChainSet)i._inChainSet.add(n);for(let n of r._outChainSet)i._outChainSet.add(n);return delete r._inChainSet,delete r._outChainSet,r._mergedNode=i,i}};var M2=class{constructor(){this.chain=new Ih(0);this.others=[]}add(t){this.chain.sides.push(...t.sides),t.finalRing=this;for(let i of t.connect)this.others.push(i)}get polyline(){if(!this._polyline){let t=new Array;for(let i of this.chain.sides)t.push(i.shape);this._polyline=Tt.build2(t).asClose()}return this._polyline}bbox(){return this.polyline.bbox()}};var B2=class{constructor(t,i){this.chains=t,this.originChains=i,t.forEach(r=>r.block=this),this._bbox=i.reduce((r,n)=>r.ext1(n.bbox()),new ot).build()}searchOriginChains(t){return this.originChainRTree||(this.originChainRTree=new Pd(10),this.originChains.forEach(i=>this.originChainRTree.add(i))),this.originChainRTree.search(t)}bbox(){return this._bbox}};var k2=class e{constructor(t){this.childs=new Array;this._bbox=null;this.parent=null;this.capacity=t}bbox(){return Au.notnull(this._bbox)}itor(t,i){for(let r of this.childs)r instanceof e?r.itor(t+1,i):i(r,t)}debug(t){for(let i of this.childs)console.log(t,i.bbox(),i instanceof e?"+":"-"),i instanceof e&&i.debug(t+" |--")}insert(t){let i=this.childs,r=t.bbox();for(let n=0;n<i.length;n++){let s=i[n];if(s instanceof e&&r.isInside(s.bbox())){s.insert(t),this._bbox=St.extend2(this._bbox,r);return}}t instanceof e&&(t.parent=this),i.length<=this.capacity?i.push(t):(i.push(t),this.splitNode()),this._bbox=St.extend2(this._bbox,r)}remove(t){if(t instanceof e&&t.childs.length>0)throw new Error;let i=this.childs,r=t.bbox(),n=new Array;for(let s=0;s<i.length;s++){let a=i[s];if(a===t)return i.splice(s,1),i.length>0?(this.updateBBox(),this.parent!==null&&this.parent.childs.length>0&&this.parent.updateBBox()):this.parent!==null?(this.parent.remove(this),this.parent!==null&&this.parent.childs.length>0&&this.parent.updateBBox()):this._bbox=null,1;a instanceof e&&r.isInside(a.bbox())&&n.push(a)}if(t instanceof e)throw new Error;for(let s of n){let a=s.remove(t);if(a===1)return this.childs.length>0&&this.updateBBox(),this.parent!==null&&this.parent.childs.length>0&&this.parent.updateBBox(),1;if(a!==0)throw new Error}return 0}recycle(){this.childs.length=0}updateBBox(){let t=new ot;for(let i of this.childs)t.ext1(i.bbox());this._bbox=t.build()}splitNode(){let t=this.childs,i=t.length,r=-1,n=-1,s=Number.NEGATIVE_INFINITY;for(let c=0;c<i;c++){let u=t[c];for(let h=c+1;h<i;h++){let d=t[h],p=St.extend2(u.bbox(),d.bbox()).area();p>s&&(s=p,r=c,n=h)}}let a=this.asNode(t[r]),o=this.asNode(t[n]);for(let c=0;c<i;c++)if(c!==r&&c!==n){let u=t[c],h=u.bbox(),d=St.extend2(a._bbox,h).area(),p=St.extend2(o._bbox,h).area();d<p?a.insert(u):o.insert(u)}t.length=0;let l=this.parent;l!==null&&l.childs.length<this.capacity?(a.parent=l,o.parent=l,l.childs.push(a),l.childs.push(o),l.remove(this),l.updateBBox()):(a.parent=this,o.parent=this,t.push(a),t.push(o),this.updateBBox()),this.childs.length>0&&this.updateBBox(),a.updateBBox(),o.updateBBox()}asNode(t){if(t instanceof e)return t;{let i=new e(this.capacity);return i.insert(t),i}}},F2=class{constructor(t){this.items=new Set;this.root=new k2(t)}itor(t){this.root.itor(0,t)}search(t){let i=[],r=[];for(r.push(this.root);;){let n=r.shift();if(n!==void 0)for(let s of n.childs)t.isSeparated(s.bbox())||(s instanceof k2?r.push(s):i.push(s));else break}return i}insert(t){this.items.add(t),this.root.insert(t)}remove(t){return this.items.delete(t),this.root.remove(t)}bbox(){return this.root.bbox()}debug(){this.root.debug("")}recycle(){this.items.clear(),this.root.recycle()}};var GZ=ps.funcCopy(ql),G2=class{constructor(t){this.parents=new Set;this.childrenRTree=new F2(10);this.marked=!1;this.markedChildNum=0;this.item=t}bbox(){return this.item.bbox()}};function hB(e){let t=e.map(r=>new G2(r));GZ(t,(r,n)=>n.bbox().area()-r.bbox().area(),0,t.length);let i=new G2(null);return t.forEach(r=>{let n=r.bbox(),s=[i],a=new Set;for(;s.length!==0;){let o=s.pop();if(a.has(o))continue;a.add(o);let l=o.childrenRTree.search(n),c=l.filter(u=>u.bbox().isContainsBBox(n));c.length===0?(l.filter(u=>n.isContainsBBox(u.bbox())).forEach(u=>{u.parents.delete(o),o.childrenRTree.remove(u),u.parents.add(r),r.childrenRTree.insert(u)}),o.childrenRTree.insert(r),r.parents.add(o)):s.push(...c)}}),i.childrenRTree.items.forEach(r=>r.parents.clear()),Array.from(i.childrenRTree.items)}var U2=.01,UZ=ps.funcCopy(ql),YZ=ps.funcCopy(ql),VZ=ps.funcCopy(ql),HZ=ps.funcCopy(ql);function jZ(e,t){return e.bbox().minY-t.bbox().minY}function zZ(e,t){return e.bbox().area()-t.bbox().area()}function XZ(e,t,i){if(e instanceof ie||t.distance2(i)<1e-6)return new ie(t,i);if(e instanceof Se){let r=e.bbox().center().x,n;t.y>i.y?n=r>e.center.x?vs.CW:vs.CCW:n=r>e.center.x?vs.CCW:vs.CW;let s=t.angleD(e.center),a=i.angleD(e.center);return Se.build2(e.center,s,a,e.rx,e.ry,n)}else if(e instanceof Ye){let r=function(n){let s=e.getPercent(n);if(typeof s!="number")throw new Error("typeof percent !== 'number'");return e.clip(s)};return e=r(t)[1],r(i)[0]}else throw new Error("not supported operation")}var pC,dB={};function pB(){return typeof performance<"u"?performance.now():Date.now()}function b1(e){dB[e]=(dB[e]||0)-pC+(pC=pB())}var WZ=0,qZ=0,JZ=0,KZ=0,$Z=0,ZZ=0,QZ=0,Y2=class e extends hg{constructor(i,r,n,s=!0){super(new dg(!1,s),i,r,n);this.outSideGroups=[];this.inSideGroups=[];this.scanY=NaN;this.curNetIndex=0;this.scanLines=0;this.blockOriginChainsIndex=[];this.blockChainsIndex=[];this.blocks=[];this.originPls=[];this.originWeights=[]}addPolyline(i,r=1){this.originPls.push(i),this.originWeights.push(r);let n=super.addPolyline(i,r);return n.length!==0&&(n[0].chain.blockIndex=this.blockOriginChainsIndex.length,this.blockOriginChainsIndex.push([n[0].chain])),n}sweep(i,r,n,s,a){this.scanY=NaN,this.scanLines=0,YZ(r,jZ,0,r.length);let o=new Uo;this.curNetIndex=0;let l=Number.POSITIVE_INFINITY;for(let c of i)c>l&&this.scan(o,(l+c)/2,r,n,s),l=c;for(let c of a)c.mark();QZ+=this.scanLines}simplify0(){ZZ++,WZ+=this.blockOriginChainsIndex.length,JZ+=this.sides.length,pC=pB(),this.seekIntersection(),b1("seekIntersection"),this.splitSidesByInters(),this.blockChainsIndex.forEach(i=>{qZ+=i.length,i.forEach(r=>KZ+=r.sides.length)}),b1("splitSidesByInters"),this.sweepBlocks(),$Z+=this.blocks.length,b1("sweepBlocks"),this.connectSides(),b1("connectSides"),this.fillResult(),b1("fillResult"),this.event instanceof Zp&&this.event.onEnd()}simplify(){try{this.simplify0()}catch{this.event instanceof Zp&&(this.event.plGrps.length=0);let r=new e(this.rule,this.logger,this.event,!1);for(let n=0;n<this.originPls.length;n++)r.addPolyline(this.originPls[n],this.originWeights[n]),r.originPls.length=0,r.originWeights.length=0;this.originPls.length=0,this.originWeights.length=0,r.simplify0()}}sweepBlocks(){this.blockChainsIndex.forEach((n,s)=>{let a=new B2(n,this.blockOriginChainsIndex[s]),o=a.bbox();o.width()<=U2||o.height()<=U2||this.blocks.push(a)});let i=hB(this.blocks),r=[];for(;i.length!==0;){let n=i.pop();n.childrenRTree.items.size===0?r.push(n):i.push(...n.childrenRTree.items)}for(;r.length!==0;){let n=r.pop();if(n.marked)continue;let s=new Uo;n.parents.forEach(u=>s.push(u));let a=n.item.chains[0].start,o=a.bbox(),l,c=0;for(;s.size()!==0&&!l;){let u=s.shift();for(let h of u.item.searchOriginChains(o)){let d=h.getWindingNum(a);d!==0&&(l=u,c-=d*h.weight)}u.parents.forEach(h=>s.push(h))}for(let u of n.parents)u.childrenRTree.remove(n),u.childrenRTree.items.size===u.markedChildNum&&r.push(u);n.parents.clear(),n.marked=!0,l?(n.item.startWeight=c,n.parents.add(l),l.childrenRTree.insert(n),l.markedChildNum++):(n.item.startWeight=0,i.push(n))}for(;i.length!==0;){let n=i.pop(),s=n.item.startWeight;for(let a of n.childrenRTree.items)a.item.startWeight+=s,i.push(a)}this.blocks.forEach((n,s)=>{let a=[];n.chains.forEach(o=>a.push(...o.sides)),this.sweep(this.getSortedEndpointsLineAsc(!1,n.chains),a,!1,n.startWeight,n.chains),this.sweep(this.getSortedEndpointsLineAsc(!0,n.chains),this.flipSides(a),!0,n.startWeight,n.chains)})}scan(i,r,n,s,a){if(this.scanY===r)return;this.scanY=r;let o=!1,l=i.listIterator();for(;l.hasNext();){let d=l.next(),p=d.item;Ve.less(p.bbox().maxY,r)?i.remove(d):!o&&p.isNeedScan(r)&&(o=!0)}for(;this.curNetIndex<n.length;){let d=n[this.curNetIndex];if(Ve.less(d.bbox().minY,r))Ve.greatereq(d.bbox().maxY,r)&&(this.add2AET(i,d),!o&&d.isNeedScan(r)&&(o=!0)),this.curNetIndex++;else break}if(!o)return;this.scanLines++;let c=new fg(this.rule,this,r,a),u=i.iterator(),h=0;for(;u.hasNext();){let d=u.next(),p=c.getCurWeight();c.onEp(d),this.event.onScan(s,d,r,h++,p,c.getCurWeight())}}add2AET(i,r){let n=r.bbox().minX,s=r.bbox().maxX,a=r.bbox().minY,o=r.bbox().maxY,l=i.listIterator(),c=null;for(;l.hasNext();){let u,h=l.next(),d=h.item,p=d.bbox().minX,f=d.bbox().maxX;if(s<=p)u=-1;else if(f<=n)u=1;else{let g=d.bbox().minY,b=d.bbox().maxY,y=Math.max(a,g),E=Math.min(o,b);u=this.compareBySweep(r,d,(y+E)/2)}let m=d.shape;if(m instanceof ie&&m.length()<.001&&c==null&&u<0){c=h;continue}if(c!=null&&u<0){i.insertBefore(c,r);return}if(u<0){i.insertBefore(h,r);return}else c=null}i.add(r)}angleToUp(i){return i<0?i+Math.PI:i}getLineAngle(i){return this.angleToUp(i.start().angle(i.end()))}getArcAngle(i,r){let n=Math.asin((r-i.center.y)/i.rx);return i.startAngle>90&&i.startAngle<270&&(n=-n),(this.angleToUp(n)+Math.PI/2)%Math.PI}compareArcLine(i,r,n){let s=this.getArcAngle(i,n),a=this.getLineAngle(r);return Ve.eq(s,a)?-i.sweepAngle:a-s}getAnotherP(i,r){let n=i.start,s=i.end;return Math.abs(n.y-r)<Math.abs(s.y-r)?s:n}compareSide(i,r,n,s,a){let o=this.getAnotherP(i,a),l=this.getAnotherP(r,a);if(o.y>a!=l.y>a)return n-s;if(a=o.equals1(l)?((Math.abs(a-o.y)<Math.abs(a-l.y)?o.y:l.y)+a)/2:Math.abs(a-o.y)<Math.abs(a-l.y)?o.y:l.y,D2(i,a)===0)throw new Error("intersY(s1, y) === 0");if(n=ge[0],D2(r,a)===0)throw new Error("intersY(s2, y) === 0");return s=ge[0],n-s}compareBySweep(i,r,n){let s=i.getX(n);if(!isFinite(s))return 0;let a=r.getX(n);if(!isFinite(a))return 0;if(!Ve.eq(s,a))return s-a;if(i.shape instanceof ie){if(r.shape instanceof ie)return this.getLineAngle(r.shape)-this.getLineAngle(i.shape);if(r.shape instanceof Se)return-this.compareArcLine(r.shape,i.shape,n);if(r.shape instanceof Ye)return this.compareSide(i,r,s,a,n);throw new Error("not support")}else if(i.shape instanceof Se){if(r.shape instanceof ie)return this.compareArcLine(i.shape,r.shape,n);if(r.shape instanceof Se){let o=i.shape,l=r.shape,c=this.getArcAngle(o,n),u=this.getArcAngle(l,n);return Ve.eq(c,u)?o.sweepAngle*l.sweepAngle<=0?o.sweepAngle<=0?1:-1:o.sweepAngle>0?o.rx-l.rx:l.rx-o.rx:u-c}else{if(r.shape instanceof Ye)return this.compareSide(i,r,s,a,n);throw new Error("not support")}}else if(i.shape instanceof Ye){if(r.shape instanceof ie)return this.compareSide(i,r,s,a,n);if(r.shape instanceof Se)return this.compareSide(i,r,s,a,n);if(r.shape instanceof Ye)return this.compareSide(i,r,s,a,n);throw new Error("not support")}else throw new Error("not support")}flipSides(i){let r=[];for(let n of i){if(n.polyIndex!==0)continue;let s=null,a=null;do{let o=n.shape.multiply3(de.ROT_90),l=n.start.multiply3(de.ROT_90),c=n.end.multiply3(de.ROT_90),u=new Ld(o,l,c,n.polyGrp,n.polyIndex,n.chain);if(u.updateBbox(),s!=null?(s.next=u,u.previous=s):a=u,r.push(u),this.event.onSplitedSide(u),s=u,n.next!==null)n=n.next;else break}while(n.polyIndex!=0);a!=null&&(a.previous=s,s.next=a)}return r}connectSides(){let i=[];this.blocks.forEach(r=>r.chains.forEach(n=>{if(n.needReverse===!0&&n.reverse(),n.sides.forEach(o=>this.event.onResultSide(o)),n.status===0?i.push(n):n.status===1&&n.startNode&&(n.startNode.outChainSet.delete(n),n.endNode.inChainSet.delete(n)),!n.startNode)return;let s=new ot,a=!0;for(let o of n.sides){s.ext1(o.bbox());let l=s.build();if(l.width()>U2||l.height()>U2){a=!1;break}}a&&(n.startNode.outChainSet.delete(n),n.endNode.inChainSet.delete(n),n.startNode.merge(n.endNode),n.status===0&&i.pop())}));for(let r of i){let n=new Uo;if(n.add(r),!r.startNode){this.fillSideGroups(n);continue}if(!r.startNode.outChainSet.has(r))continue;r.startNode.outChainSet.delete(r),r.endNode.inChainSet.delete(r);let s=r.startNode.outChainSet;for(;n.size()>0;){let a=n.getLast();if(a.endNode.outChainSet===s)break;let o=!1;for(let l of a.endNode.outChainSet)if(l.status===0){n.add(l),l.startNode.outChainSet.delete(l),l.endNode.inChainSet.delete(l),o=!0;break}o||n.removeLast()}n.size()>0&&this.fillSideGroups(n)}}fillSideGroups(i){let r=new M2;tg(i,(s,a)=>(r.add(a),!0));let n=r.polyline.area(.1);Math.abs(n)<1e-6||(n<0?this.outSideGroups.push(r):this.inSideGroups.push(r))}fillResult(){let i=0,r=new Pd(10),n=this.outSideGroups.map((s,a)=>{s.outIndex=a,r.add(s);let o=[];o.push(s);for(let l of o)if(l.isUsed!==!0){l.isUsed=!0;for(let c of l.others)c.finalRing&&o.push(c.finalRing)}return o.filter(l=>l.isUsed===!0?(l.isUsed=!1,!0):!1).map(l=>(l.isUsed=!0,l.polyline))});this.inSideGroups.map(s=>{if(s.isUsed===!0)return;let a=r.search(s.chain.start.bbox());HZ(a,zZ,0,a.length);for(let o of a)if(o.chain.getWindingNum(s.chain.start)!==0){n[o.outIndex].push(s.polyline);break}});for(let s of n)this.event.onPolylineGroup(new kr(s),i++)}getSortedEndpointsLineAsc(i,r){let n=i?"x":"y",s=new Set;for(let o of r){if(o.status!==2)continue;let l,c=Number.NEGATIVE_INFINITY;for(let u of o.sides)Math.abs(u.start[n]-u.end[n])>c&&(l=u,c=Math.abs(u.start[n]-u.end[n]));c!==0&&(s.add(l.start[n]),s.add(l.end[n]))}let a=Array.from(s);return VZ(a,ps.sortAsc,0,a.length),a}splitSides(i,r,n,s){if(i.inters.length===2){let u=new Ld(i.shape,i.start,i.end,i.polyGrp,n++,this.curChain);return u.updateBbox(),r.push(u),this.curChain.sides.push(u),n}let{start:a,end:o}=i,l=new j(o.x+(a.x-o.x)*2,o.y+(a.y-o.y)*2);UZ(i.inters,(u,h)=>u[0].distance2(l)-h[0].distance2(l),0,i.inters.length);let c=null;for(let[u,h]of i.inters){if(!c)u.equals1(a)&&(c=u);else if(!u.equals1(c)){let d=XZ(i.shape,c,u);d instanceof Se&&Math.abs(d.sweepAngle)>190&&(d=new ie(c,u));let p=new Ld(d,c,u,i.polyGrp,n++,this.curChain);p.updateBbox(),r.push(p),this.curChain.sides.push(p),u.equals1(o)?c=null:c=u}h&&(this.curChain.sides.length===0?this.prevChain&&(h.inChainSet.add(this.prevChain),this.prevChain.endNode=h.merge(this.prevChain.endNode)):(this.prevChain=this.curChain,h.inChainSet.add(this.prevChain),this.prevChain.endNode=h.merge(this.prevChain.endNode),this.curChain=new Ih(i.chain.weight),s.push(this.curChain)),h.outChainSet.add(this.curChain),this.curChain.startNode=h.merge(this.curChain.startNode))}return n}splitSidesByInters(){this.blockOriginChainsIndex.forEach((i,r)=>{let n=[];this.blockChainsIndex[r]=n;for(let s of i){this.curChain=new Ih(s.weight),n.push(this.curChain);let a=this.curChain;this.prevChain=null;let o=0,l,c;for(let u of s.sides){let h=new Array;o=this.splitSides(u,h,o,n);for(let d of h)l!=null?(l.next=d,d.previous=l):c=d,l=d,this.event.onSplitedSide(d)}if(c.previous=l,l.next=c,a.startNode)this.curChain.sides.length===0?(n.pop(),this.curChain.startNode.outChainSet.delete(this.curChain),this.curChain.startNode.merge(a.startNode)):(a.startNode.inChainSet.add(this.curChain),this.curChain.endNode=a.startNode);else{if(a===this.curChain)continue;n.pop();for(let h of this.curChain.sides)h.chain=a;let u=this.curChain.sides.concat(a.sides);a.sides.length=0;for(let h of u)a.sides.push(h);this.curChain.startNode.outChainSet.delete(this.curChain),this.curChain.startNode.outChainSet.add(a),a.startNode=this.curChain.startNode}}})}seekIntersection(){let i=this.buildRTree();for(let r of this.sides){r.seekedIntersection=!0;for(let n of i.search(r.bbox().extendOfSize(1e-5))){if(n.seekedIntersection===!0||n===r.next&&n===r.previous)continue;let s=Gc(r.shape,n.shape);if(s!==0){for(let a=s-2;a>=2;a-=2)for(let o=a-2;o>=0;o-=2)if(Ve.eq(ge[a],ge[o])&&Ve.eq(ge[a+1],ge[o+1])){ge[o]=(ge[a]+ge[o])/2,ge[o+1]=(ge[a+1]+ge[o+1])/2;for(let l=s-3;l>=a;l--)ge[l]=ge[l+2];s-=2;break}if(n===r.next){if(s<=2)continue;(ge[0]-n.start.x)**2+(ge[1]-n.start.y)**2<(ge[2]-n.start.x)**2+(ge[3]-n.start.y)**2&&(ge[0]=ge[2],ge[1]=ge[3]),s=2}else if(n===r.previous){if(s<=2)continue;(ge[0]-n.end.x)**2+(ge[1]-n.end.y)**2<(ge[2]-n.end.x)**2+(ge[3]-n.end.y)**2&&(ge[0]=ge[2],ge[1]=ge[3]),s=2}if(r.chain.blockIndex!==n.chain.blockIndex){let a,o;this.blockOriginChainsIndex[r.chain.blockIndex].length>this.blockOriginChainsIndex[n.chain.blockIndex].length?(a=r.chain.blockIndex,o=n.chain.blockIndex):(a=n.chain.blockIndex,o=r.chain.blockIndex);let l=this.blockOriginChainsIndex[a];for(let c of this.blockOriginChainsIndex[o])c.blockIndex=a,l.push(c);delete this.blockOriginChainsIndex[o]}for(let a=0;a<s;a+=2){let o=new j(ge[a],ge[a+1]),l=new N2;r.inters.push([o,l]),n.inters.push([o,l]),this.event.onIntersect(o,r,n)}}}}}};var x1=oy(gb());var V2;Ic&&(typeof window<"u"?V2=window._MSG_BUS_=window._MSG_BUS_||new x1.MessageBus:V2=new x1.WorkerMessageBridge(new x1.MessageBus,self));var Qp=class{extend(t,i){if(i===0)return t;{let r=Math.abs(i*2),n=new Array,s=new Array;for(let a of t){let o=[],l=[];a.points(.01,u=>{l.push(u)});let c=vP(l);c.length<l.length&&(a=Tt.build4(c));for(let u of a.primitives){let h=u.stroke(r,pp.ROUND,vs.CCW);n.push(h),o.push(h)}if(i>0){let u=this.getUnion([[a],o]);for(let h of u)s.push(h.items)}}if(i>0)return this.getUnion(s);if(i<0)return this.getSubtraction(t,n)}}getUnion(t){let i=t.map(r=>new kr(r));return i.length<=1?i:this.runBoolean(gc.UNION,t)}getUnion2(t){return this.run([gc.UNION,...t])}_union_polyline(t){return this.run([gc.UNION,...t])}_union_polygon(t){return this.run([gc.UNION,...t])}getSubtraction(t,i){return this.run([gc.DIFF,this.union(t),this.union(i)])}getSubtraction1(t){return this.runBoolean(gc.DIFF,t)}getSubtraction2(t,i){return this.run([gc.DIFF,t,i])}getIntersection(t){return this.runBoolean(gc.INTERSECT,t)}getMutuallyExclusive(t){return this.runBoolean(gc.XOR,t)}run(t){let i=fp(),r=zv(t,V2);return Il.runBoolean+=tu(i),r}runBoolean(t,i){let r=[t];return i.forEach(n=>r.push(this.union(n))),this.run(r).toPolylineGroups()}union(t){let i=new Zp(!1,V2&&null),r=new Y2(aC.rule,new Bc(1),i);for(let s of t)r.addPolyline(Al(s.asClose()));r.simplify();let n=[];return i.plGrps.forEach(s=>{let a=[Al(s.items[0])];if(a[0]){for(let o=1;o<s.items.length;o++){let l=Al(s.items[o]);l&&a.push(l)}n.push(new rn(a))}}),new wr(n)}};var E1=Math.PI*2,fC=({x:e,y:t},i,r,n,s,a,o)=>{e*=i,t*=r;let l=n*e-s*t,c=s*e+n*t;return{x:l+a,y:c+o}},eQ=(e,t)=>{let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),n=Math.sin(e),s=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-n*i,y:n+r*i},{x:s+a*i,y:a-s*i},{x:s,y:a}]},fB=(e,t,i,r)=>{let n=e*r-t*i<0?-1:1,s=e*i+t*r;return s>1&&(s=1),s<-1&&(s=-1),n*Math.acos(s)},tQ=(e,t,i,r,n,s,a,o,l,c,u,h)=>{Kn(o)||Kr(o);let d=Math.pow(n,2),p=Math.pow(s,2),f=Math.pow(u,2),m=Math.pow(h,2),g=d*p-d*m-p*f;g<0&&(g=0),g/=d*m+p*f,g=Math.sqrt(g)*(a===o?-1:1);let b=g*n/s*h,y=g*-s/n*u,E=c*b-l*y+(e+i)/2,S=l*b+c*y+(t+r)/2,w=(u-b)/n,x=(h-y)/s,I=(-u-b)/n,A=(-h-y)/s,O=fB(1,0,w,x),R=fB(w,x,I,A);return o===0&&R>0&&(R-=E1),o===1&&R<0&&(R+=E1),[E,S,O,R]},iQ=({px:e,py:t,cx:i,cy:r,rx:n,ry:s,xAxisRotation:a=0,largeArcFlag:o=0,sweepFlag:l=0})=>{let c=[];if(n===0||s===0)return[];let u=Math.sin(a*E1/360),h=Math.cos(a*E1/360),d=h*(e-i)/2+u*(t-r)/2,p=-u*(e-i)/2+h*(t-r)/2;if(d===0&&p===0)return[];n=Math.abs(n),s=Math.abs(s);let f=Math.pow(d,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(s,2);f>1&&(n*=Math.sqrt(f),s*=Math.sqrt(f));let[m,g,b,y]=tQ(e,t,i,r,n,s,o,l,u,h,d,p),E=Math.abs(y)/(E1/4);Math.abs(1-E)<1e-7&&(E=1);let S=Math.max(Math.ceil(E),1);y/=S;for(let w=0;w<S;w++)c.push(eQ(b,y)),b+=y;return c.map(w=>{let{x,y:I}=fC(w[0],n,s,h,u,m,g),{x:A,y:O}=fC(w[1],n,s,h,u,m,g),{x:R,y:M}=fC(w[2],n,s,h,u,m,g);return{x1:x,y1:I,x2:A,y2:O,x:R,y:M}})};function Rd(e){let t=iQ({px:e.x1,py:e.y1,cx:e.x2,cy:e.y2,xAxisRotation:e.angle,sweepFlag:e.sweep,largeArcFlag:e.large,rx:e.rx,ry:e.ry}),i=["M",e.x1,e.y1];for(let r of t)i.push("C",r.x1,r.y1,r.x2,r.y2,r.x,r.y);return i.map(r=>Kn(r)?k3(r):r).join(" ")}var S1=oy(gb());var H2;Ic&&(typeof window<"u"?H2=window._MSG_BUS_=window._MSG_BUS_||new S1.MessageBus:H2=new S1.WorkerMessageBridge(new S1.MessageBus,self));function rQ(e,t,i){if((i==null?void 0:i.fill)===!1){let s=!1,a=e.items.map(o=>o.hasBackLine()?(s=!0,o.primitives.map(c=>Tt.build2([c]))):[o]);s&&(e=new kr(a.flat()))}let r=new Qp;if(t===0)return e;let n=[];if(i!=null&&i.fill)r.union(e.items).items.forEach(a=>{let o=new rn([a.items[0]]).extend(t),l=[];a.items.slice(1).forEach(h=>{let d=new rn([h.reverse()]).extend(-t);l.push(d)});let c=r.getUnion2(l);r.getSubtraction2(o,c).toPolylineGroups().forEach(h=>{n.push(...h.items)})});else{let l=function(c){if(c instanceof ie)return c.direct.x===0&&c.direct.y===0;if(c instanceof Se)return c.sweepAngle===0;if(c instanceof Ye){let u=new Set(c.controls.map(d=>d.x)),h=new Set(c.controls.map(d=>d.y));return u.size===1&&h.size===1}else throw new Error("not support")};if(t<0)throw Error("offsetPolylineGroup: config.fill === false && offsetDistance < 0");let s=Math.abs(t*2),a=[];e.items.forEach(c=>{c.primitives.forEach(u=>{if(l(u))return;if(u instanceof Ye){let d=[];Qb(u,d),d.forEach(p=>{let f=rn.buildByStroke(p,s,pp.ROUND,.1,H2);f&&a.push(f)});return}let h=rn.buildByStroke(u,s,pp.ROUND,.1,H2);h&&a.push(h)})}),r._union_polygon(a).items.forEach(c=>{c.items.forEach(u=>{n.push(u)})})}return new kr(n)}function Ah(e,t,i){return rQ(e,t,i)}function nQ(e,t){if(!(e!=null&&e.length))return[];let i=[],r=[],n=new Qp;e.forEach(o=>{i.push(n.union(o.items))}),t.forEach(o=>{r.push(n.union(o.items))});let s=n.getUnion2(i),a=n.getUnion2(r);return n.getSubtraction2(s,a).toPolylineGroups()}function mB(e,t){return nQ(e,t)}function Yo(e,t={ccw:!1}){let i=(t==null?void 0:t.ccw)===!0,{x:r,y:n,endX:s,endY:a,rx:o,ry:l,rotation:c,isCCW:u,matrix:h}=e,d=V=>`${V.x} ${V.y}`;if(h){if(!o&&!l){let Ne=et.rectShapeNoRadius(h);return i&&Ne.reverse(),`M ${Ne.map(je=>je.x+" "+je.y).join(" L ")} Z`}let{width:V,height:q}=et.getRectShapeForAttr(h);if(o>=V/2&&l>=q/2){let Ne=et.createMatrixFrom6(h),nt=new j(1,1).multiply3(Ne),je=Ne.multiply3(de.scale(.5,.5).setOrigin1(nt));return h=et.getMatrix6FromMatrix(je),Ql({matrix:h},t)}let C=.551915024494,N=0,T=0,L=1,P=1;o=Math.min(o/V,.5),l=Math.min(l/q,.5);let B=[N,N+o*(1-C),N+o,L-o,L-o+o*C,L],U=[T,T+l*(1-C),T+l,P-l,P-l+l*C,P],X=[0,0,1,2,3,4,5,5,5,5,4,3,2,1,0,0],J=[2,1,0,0,0,0,1,2,3,4,5,5,5,5,4,3],ne=X.map((Ne,nt)=>new j(B[Ne],U[J[nt]])),fe=et.createMatrixFrom6(h),xe=ne.map(Ne=>Ne.multiply3(fe));i&&xe.reverse();let ve=Ne=>`${d(xe[Ne])} C ${d(xe[Ne+1])} ${d(xe[Ne+2])} ${d(xe[Ne+3])}`;return`M ${ve(0)} L ${ve(4)} L ${ve(8)} L ${ve(12)} Z`}let p=u?-c:+c,f=new j(r,a),m=V=>V.rotateD(f,p),g=V=>new j(V[0],V[1]);if(!+o||!+l||+o<=0||+l<=0){let q=[[r,n],[s,n],[s,a],[r,a]].map(g);return i&&q.reverse(),`M ${(p?q.map(m):q).map(d).join(" L ")} Z`}let b=(r+s)/2,y=(n+a)/2,E=Math.abs(s-r),S=Math.abs(a-n);if(o=Math.min(o,E/2),l=Math.min(l,S/2),o>=E/2&&l>=S/2)return Ql({cx:b,cy:y,rx:o,ry:l,rotation:c,isCCW:u},t);let w=.551915024494,x=[r,r+o*(1-w),r+o,s-o,s-o+o*w,s],I=[n,n+l*(1-w),n+l,a-l,a-l+l*w,a],A=[0,0,1,2,3,4,5,5,5,5,4,3,2,1,0,0],O=[2,1,0,0,0,0,1,2,3,4,5,5,5,5,4,3],R=A.map((V,q)=>g([x[V],I[O[q]]]));i&&R.reverse();let M=p?R.map(m):R,F=V=>`${d(M[V])} C ${d(M[V+1])} ${d(M[V+2])} ${d(M[V+3])}`;return`M ${F(0)} L ${F(4)} L ${F(8)} L ${F(12)} Z`}function Ql(e,t={ccw:!1}){let i=(t==null?void 0:t.ccw)===!0,{rx:r,ry:n,cx:s,cy:a,rotation:o,isCCW:l,matrix:c}=e;if(c){let E=et.calcuEllipse(c);r=E.a,n=E.b,s=E.cx,a=E.cy,o=E.degree}let u=.551915024494,h=[1,1,u,0,-u,-1,-1,-1,-u,0,u,1,1],d=[0,u,1,1,1,u,0,-u,-1,-1,-1,-u,0],p=l?-o:+o,f=new j(0,0),m=E=>{let S=new j(h[E]*r,d[E]*n);return p&&(S=S.rotateD(f,p)),`${S.x+s} ${S.y+a}`},g=E=>`M ${m(E)}`,b=E=>`C ${m(E)} ${m(E+1)} ${m(E+2)}`;return i&&d.reverse(),`${g(0)} ${b(1)} ${b(4)} ${b(7)} ${b(10)}`}function ef(e){switch(e.cmdKey){case"rect":return Yo(e);case"ellipse":return Ql(e);case"group":return e.d;case"obj":return mC(e);case"text":return sQ(e);case"arc":return Rd(e);default:Kr(e);break}}function mC(e){let t=et.rectShapeNoRadius(e.matrix);return`M ${t[0].x+" "+t[0].y} 
	L ${t.slice(1).map(r=>r.x+" "+r.y).join(" ")} Z`}function gB(e,t={ccw:!1}){let{cx:i,cy:r,r:n}=e;return Ql({cx:i,cy:r,rx:n,ry:n},t)}function sQ(e){let t=Ri.convertJsonCache2PolyLines({d:e.d},"group"),i=de.MIRROR_Y.multiply3(et.createMatrixFrom6(e.matrix).multiply3(de.MIRROR_Y)),r=t.multiply3(i).round(4);return fs(r.items,!1)}function yB(e,t){if(!t||t<0||!e.items.length)return[];let i=Ah(e,t/2,{fill:!1});return i?[i]:[]}var j2=class{constructor(){}parser(t,i){let r=t.tagName,n,s=t.id;switch(r){case"ellipse":n=Ql(i.ellipse[s]);break;case"rect":n=Yo(i.rect[s]);break;case"polyline":n=this.transferPolylineToPath(t);break;case"path":n=t.getAttribute("d");break;case"g":n=this.transferText(t,i);break;case"image":n=this.transferImageObj(i.obj[s]);break;default:throw new Error(r)}return n}jsonCacheParser(t,i){let r;switch(i){case"ellipse":r=this.transferEllipseObj(t);break;case"rect":r=this.transferRectObj(t);break;case"group":r=t.d;break;case"arc":r=Rd(t);break;case"text":{r=this.transferTextObj(t);break}case"obj":{r=this.transferImageObj(t);break}}return r}transferText(t,i){let r=de.MIRROR_Y.multiply3(et.createMatrixFrom6(i.text[t.id].matrix).multiply3(de.MIRROR_Y)),n=t.querySelector("path").getAttribute("d"),a=qi(n).map(l=>l.multiply3(r)),[o]=l1(a,!1);return o}transferPolylineToPath(t){let{points:i}=t,r=t.style.fill&&t.style.fill!="none",n=Array.from(i).reduce((a,o)=>(a+=` ${o.x} ${o.y}`,a),"");return`M ${i[0].x} ${i[0].y} L${n} ${r?"z":""}`}transferEllipseObj(t){return Ql(t)}transferRectObj(t){return Yo(t)}transferImageObj(t){return mC(t)}transferTextObj(t){let{cacheWidth:i,cacheHeight:r,hAlign:n,vAlign:s,rotation:a}=t,o=aQ(i,r,void 0,void 0,n,s,a,void 0,void 0,void 0),c=qi(t.d).map(h=>h.multiply3(o)),[u]=l1(c,!1);return u}},gC=class{constructor(){this.bool=new Qp}convertSvg2Polylines(t,i){let r=new j2,n=[];for(let s of t){let a=r.parser(s,i),o=qi(a);n.push(o)}return n}convertData2PolylineCached(){let t=new Map;return i=>{let r=[];for(let n of i)if(t.has(n.gId))r.push(t.get(n.gId));else{let s=this.convertData2Polyline([n]);r.push(s[0]),t.set(n.gId,s[0])}return r}}convertData2Polyline(t){let i=[];for(let r of t){let n=ef(r),s=qi(n);i.push(s)}return i}convertJsonCache2PolyLines(t,i){let n=new j2().jsonCacheParser(t,i),s=qi(n);return new kr(s)}convertPolylines2Svg(t,i=!1,r=!1,n=.01){let s=[];if(i)t.length&&s.push(...l1(SE(t.map(a=>a.items)),r,n));else for(let a of t)s.push(...l1(a.items,r,n));return s}boolExclusive(t){return this.bool.getMutuallyExclusive(t)}boolSubtraction(t,i){return t.length?mB([new kr(t)],i.length?[new kr(i)]:[]):[]}boolSubtraction1(t){return this.bool.getSubtraction1(t)}boolIntersection(t){return this.bool.getIntersection(t)}boolAggregate(t){return t.length===1&&(t=t[0].map(r=>[r])),this.bool.getUnion(t)}boolIsIntersection(t,i){return t.some(n=>i.some(s=>n.primitives.some(a=>s.primitives.some(o=>So(a,o)))))}extend(t,i){return i===0?[new kr(t)]:this.bool.extend(t,i)}},Ri=new gC;function aQ(e,t,i,r,n,s,a,o,l,c){let u=0;switch(n){case 1:u=-e/2;break;case 2:u=-e;break}let h=0;switch(s){case 1:h=-t/2;break;case 2:h=-t;break}let d=new de;return d=d.scale(1,-1),d=d.rotateD(a),o&&(d=d.multiply3(de.MIRROR_X)),l<0&&(d=de.MIRROR_X.multiply3(d),l=-l),c<0&&(d=de.MIRROR_Y.multiply3(d),c=-c),d=d.translate(i,-r),d=de.scale(l,-c).translate(u,-h).multiply3(d),d}var yC=class{showShapeControl(t,i){dl();let r=le(t);if(!r)throw new Error("");fr([r],{create8Dots:!0}),i==="click"&&(Ae.select(r),Ce("panel_updateAttrPanel"))}getData(t){let i=[];for(let r of t){let n=$t(r),s,a,o,l=r.id,c;switch(n){case"rect":{c=k.getRect(l);let f=et.getRectShapeForAttr(c.matrix),[m,g]=k.translateByOrigin(f.x,f.y+f.height);s=m,a=g;break}case"ellipse":{c=k.getEllipse(l);let{cx:f,cy:m}=Ei.getEllipseFromMatrix(c.matrix),[g,b]=k.translateByOrigin(f,m);s=g,a=b;break}case"obj":c=k.getObj(l);let u=Lr.getImageShapeForAttr(c.matrix),[h,d]=k.translateByOrigin(u.x,u.y+u.height);s=h,a=d;break;case"text":{c=k.getText(l);let{x:f,y:m}=xr.getTextForAttrs(c),[g,b]=k.translateByOrigin(f,m);s=g,a=b;break}case"arc":case"group":c=k.getById(l).json;let p=es(le(l));s=p.x,a=p.y+p.height;break;default:throw new Error(n)}o=p3[c.layer],s=Yt(s,"pixel","mm"),a=Yt(-a.toFixed(2),"pixel","mm"),s=+Number(s).toFixed(2)+"mm",a=+Number(a).toFixed(2)+"mm",i.push({cmd:n,position:{x:s,y:a},layerName:o,eid:l})}return i}},bC=new yC;function xC(e){let t=e.length,i=[];for(let r=0;r<t;r+=2)i.push({x:e[r],y:e[r+1]});return i}function bB(){let e=[],t=Ir.data.event,{x:i,y:r}=ui(t,!1),n=w1(i,r);e.push(...n);let s=Ch(i,r);e.push(...s.map(h=>le(h)));let a=gg(i,r);e.push(...a);let o=v1(i,r);e.push(...o);let l=tf(i,r);e.push(...l);let c=Uc(i,r);e.push(...c.map(h=>le(h))),e=Array.from(new Set(e));let u=bC.getData(e);console.log(u),Ce("panel/show-select-element",[{x:t.clientX,y:t.clientY},u])}function Nn(e){return["dimension","dimensionAngle","dimensionLength","dimensionRadius","auxiliaryLine","auxiliaryPoint"].includes(e)}var wn=document.getElementById.bind(document);function z2(e){let t=e.target;if(t==document||t==document.documentElement||t==document.body)return;let i=pl(t),r;Nd.isShowContextMenu(e)?r=t:i&&k.getById(i.id).json.layer!=7&&(r=i);let{x:n,y:s}=ui(e,!1);return r=r||SC(n,s)[0],r=r||EC(n,s)[0],r=r||w1(n,s).values().next().value,r=r||wn(Ch(n,s)[0]),r=r||wn(Uc(n,s)[0]),r=r||tf(n,s)[0],r=r||wC(n,s)[0],r=r||vC(n,s)[0],r=r||TC(n,s)[0],r=r||IC(n,s)[0],r=r||v1(n,s)[0],r}function Ch(e,t){let i=[];return k.iteratorEllipse(r=>{if(ai.eleIsHide(r))return;let n=et.createMatrixFrom6(r.matrix),s=new de(n.getInverseMatrix().data),a=new j(e,t).multiply3(s),o=Hl(a.x,a.y,0,0);if(Math.abs(o-1)<.01){i.push(r.gId);return}if(r.layer===4&&o<1){i.push(r.gId);return}![3,7].includes(r.layer)&&r.fillColor!=="none"&&r.displayFill&&io(0,0,a.x,a.y,1,1)<=1&&i.push(r.gId)}),i}function Uc(e,t,i){let r=[];return k.iteratorArc(n=>{if(ai.eleIsHide(n)||n.x1===n.x2&&n.y1===n.y2)return;let s=n.strokeWidth/2;i!=null&&i.around&&(s=i.around);let a=new ot().ext6(e,t).ext7(s).build(),o=new _i(n).points(1);for(let l of o)if(a.isContains(l)){r.push(n.gId);return}}),r}function w1(e,t){let i=new Set,r=Xa();if(!r["all-element-type"].rect.checked||!r["all-element-type"].rect.visible)return i;let n=k.getRect(),s=no();for(let a in n){let o=k.getRect(a);if(ai.eleIsHide(o))continue;let l=Yo(o),c=qi(l),u=[];for(let p of c)p.points(.5,f=>{u.push(new j(f.x,-f.y))});let h=Tt.build4(u);if(o.displayFill&&o.fillColor!=="none"&&![3,7].includes(o.layer)){let p=X2(e,t),{minX:f,maxX:m,minY:g,maxY:b}=p,y=[{x:f,y:g},{x:m,y:g},{x:m,y:b},{x:f,y:b}];for(let E of y)if(oB.inPolyline(new j(E.x,E.y),h)){i.add(wn(a));break}}else for(let p=1;p<u.length;p++){let f=u[p-1],m=u[p];if(ra({x:e,y:t},f,m).d<s){i.add(wn(a));break}}}return i}function v1(e,t){let i=X2(e,t),r=new Set,n=Xa();if(!n["all-element-type"].text.checked||!n["all-element-type"].text.visible)return Array.from(r);let s=k.getText();for(let a in s){if(ai.eleIsHide(k.getText(a)))continue;let o=wn(a),l=Fi.text.get(o,"multi").slice(0,8),c=new ot;for(let y=0;y<l.length;y+=2)c.ext6(l[y],l[y+1]);if(!c.build().intersection1(i))continue;let{minX:d,maxX:p,minY:f,maxY:m}=i,g=[{x:d,y:f},{x:p,y:f},{x:p,y:m},{x:d,y:m}],b=xC(l);for(let y of g)if(xu(y,b)){r.add(wn(a));continue}}return Array.from(r)}function EC(e,t){let i=k.getAuxiliaryLine(),r=[];for(let n in i){let s=i[n];switch(ul(s.rotation)){case"horizontal":{Math.abs(t-s.y)<no()&&r.push(wn(s.gId));break}case"vertical":{Math.abs(e-s.x)<no()&&r.push(wn(s.gId));break}}}return r}function SC(e,t){let i=k.getAuxiliaryPoint(),r=[],n=new j(e,t);for(let s in i){let a=i[s];new j(a.x,a.y).distance1(n)<no()&&r.push(wn(a.gId))}return r}function wC(e,t){let i=[],r=no(),n={x:e,y:t};return k.iteratorDimension(s=>{let a=ra(n,s.start.primitivePoint,s.start.otherPoint).d;if(a<r){i.push(wn(s.gId));return}if(a=ra(n,s.end.primitivePoint,s.end.otherPoint).d,a<r){i.push(wn(s.gId));return}if(a=ra(n,s.start.otherPoint,s.end.otherPoint).d,a<r){i.push(wn(s.gId));return}let o=new In(s).getTextBBoxOutline();if(mh(n,o)){i.push(wn(s.gId));return}}),i}function vC(e,t){let i=[],r={x:e,y:t},n=no();return k.iteratorDimensionLength(s=>{let a={x:s.measureX1,y:s.measureY1},o={x:s.measureX2,y:s.measureY2},l={x:s.x1,y:s.y1},c={x:s.x2,y:s.y2},u=ra(r,a,l).d;if(u<n){i.push(wn(s.gId));return}if(u=ra(r,o,c).d,u<n){i.push(wn(s.gId));return}if(u=ra(r,a,o).d,u<n){i.push(wn(s.gId));return}let h=new xn(s).getTextBBoxOutline();if(mh(r,h)){i.push(wn(s.gId));return}}),i}function TC(e,t){let i=[],r={x:e,y:t},n=no();return k.iteratorDimensionAngle(s=>{let a={x:s.angleX,y:s.angleY},o={x:s.x1,y:s.y1},l={x:s.x2,y:s.y2},c=ra(r,a,o).d;if(c<n){i.push(wn(s.gId));return}if(c=ra(r,a,l).d,c<n){i.push(wn(s.gId));return}let u=new bn(s).getTextBBoxOutline();if(mh(r,u)){i.push(wn(s.gId));return}}),i}function IC(e,t){let i=[],r={x:e,y:t},n=no();return k.iteratorDimensionRadius(s=>{if(ra(r,{x:s.x1,y:s.y1},{x:s.x2,y:s.y2}).d<n){i.push(wn(s.gId));return}let o=new cn(s).getTextBBoxOutline();if(mh(r,o)){i.push(wn(s.gId));return}}),i}function tf(e,t){let i=X2(e,t),r=new Set,n=no();return k.iteratorGroup(s=>{let a=s.gId;if(ai.eleIsHide(s))return;let o=es(wn(a));if(!new ot().ext6(o.x,o.y).ext6(o.x+o.width,o.y+o.height).build().intersection1(i))return;let u=s.fillColor!=="none"&&![3,7].includes(s.layer);s.layer===2&&(u=!0);let h=qi(s.d),d=[];for(let p of h)p.points(.5,f=>{d.push({x:f.x,y:-f.y})});if(u){let{minX:p,maxX:f,minY:m,maxY:g}=i,E="M "+[{x:p,y:m},{x:f,y:m},{x:f,y:g},{x:p,y:g}].map(x=>x.x+" "+x.y).join(" L ")+" z",S=qi(E);Ri.boolIntersection([S,h]).length&&r.add(wn(a))}else for(let p=1;p<d.length;p++){let f=d[p-1],m=d[p];if(ra({x:e,y:t},f,m).d<n){r.add(wn(a));break}}}),Array.from(r)}function gg(e,t){let i=new Set;if(!Xa()["all-element-type"].obj.checked)return[];let n=k.getObj(),s=X2(e,t);for(let a in n){if(ai.eleIsHide(k.getObj(a)))continue;let o=new ot,l=Fi.image.get(wn(a),"multi").slice(0,8);for(let b=0,y=l.length;b<y;b+=2)o.ext6(l[b],l[b+1]);if(!o.build().intersection1(s))continue;let{minX:h,maxX:d,minY:p,maxY:f}=s,m=[{x:h,y:p},{x:d,y:p},{x:d,y:f},{x:h,y:f}],g=xC(l);for(let b of m)if(xu(b,g)){i.add(wn(a));continue}}return Array.from(i)}function xB(e,t){let i=[];return k.iteratorDimensionAngle(r=>{let n=new bn(r).findContainsControlPoint(e,t);n&&i.push({parentId:r.gId,id:n})}),k.iteratorDimensionLength(r=>{let n=new xn(r).findContainsControlPoint(e,t);n&&i.push({parentId:r.gId,id:n})}),k.iteratorDimensionRadius(r=>{let n=new cn(r).findContainsControlPoint(e,t);n&&i.push({parentId:r.gId,id:n})}),i}function rf(e,t,i){if(i=i||Dh().filter(r=>!Nn(r.cmdKey)),i.length){let r=sg(i);if(St.extendRect(r).isContains2(e,t))return!0}return!1}function EB(e,t){let i,r=Tt.build6(St.extendRect(e));switch(t.cmdKey){case"dimension":let{start:n,end:s}=t;i=Tt.build7([new ie(new j(n.primitivePoint.x,n.primitivePoint.y),new j(n.otherPoint.x,n.otherPoint.y)),new ie(new j(s.primitivePoint.x,s.primitivePoint.y),new j(s.otherPoint.x,s.otherPoint.y)),new ie(new j(n.otherPoint.x,n.otherPoint.y),new j(s.otherPoint.x,s.otherPoint.y))]);break;case"dimensionLength":let{measureX1:a,measureY1:o,measureX2:l,measureY2:c}=t;i=Tt.build7([new ie(new j(a,o),new j(t.x1,t.y1)),new ie(new j(l,c),new j(t.x2,t.y2)),new ie(new j(a,o),new j(l,c))]);break;case"dimensionAngle":let{angleX:u,angleY:h}=t;i=Tt.build7([new ie(new j(u,h),new j(t.x1,t.y1)),new ie(new j(u,h),new j(t.x2,t.y2))]);break;case"dimensionRadius":i=Tt.build7([new ie(new j(t.x1,t.y1),new j(t.x2,t.y2))]);break;case"auxiliaryLine":case"auxiliaryPoint":let d=vi(t,t.cmdKey);return M3(e,d);default:break}for(let n of r.primitives)for(let s of i.primitives)if(Gc(n,s))return!0;return!1}function X2(e,t){let i=no();return new ot().ext6(e,t).ext7(i).build()}var T1=class T1 extends Pu{constructor(i){super();this.headSelected=!1;this.tailSelected=!1;this.textSelected=!1;this.layer=8;this.name="";this.locked=!1;this.visible=!0;this.rotation=0;this.textOffsetX=10;this.rememberedLineLength=0;this.name=i.name,this.gId=i.gId,this.x1=i.x1,this.y1=i.y1,this.x2=i.x2,this.y2=i.y2,this.textX=i.textX,this.textY=i.textY,this.measureId=i.ellipseId,this.visible=i.visible,this.rotation=i.rotation,this.container=i.gId&&le(i.gId)}getRxRyPixel(){let i=Ch(this.x1,this.y1),r=i[0];if(i.length===0){let n=Uc(this.x1,this.y1);if(n.length===0)return this.measureId=null,{rx:0,ry:0};r=n[0]}return this.setMeasureId(r),{rx:this.rx,ry:this.ry}}setMeasureId(i){this.measureId=i;let{json:r,cmdKey:n}=k.getById(i);if(Mt(r))return this;if(n==="ellipse"){let{cx:s,cy:a,rx:o,ry:l}=Ei.getEllipseFromMatrix(r.matrix);this.cx=s,this.cy=a,this.rx=o,this.ry=l}else if(n==="arc"){let a=new _i(r).vectorCenter();this.cx=a.x,this.cy=a.y,this.rx=r.rx,this.ry=r.ry}return this}setHeadFree(i,r){return this.x1=i,this.y1=r,this.measureId=null,this}setTailFree(i,r){return this.x2=i,this.y2=r,this}vectorEllipseCenter(){return new j(this.cx,this.cy)}getContainer(){return this.measureId&&this.setMeasureId(this.measureId),this.render(),this.container}setHead(i,r){let{json:n,cmdKey:s}=k.getById(this.measureId),a;s==="arc"?a=new _i(n).getMatrix():a=et.createMatrixFrom6(n.matrix);let o=new de(a.getInverseMatrix().data),l=new j(i,r).multiply3(o).angle(j.ORIGIN),c=Math.sin(l),u=Math.cos(l),h=new j(u,c).multiply3(a);if(s==="arc"){let d=new _i(n),p=new j(h.x,h.y),f=d.vectorStart().sub(p).cross(d.vectorEnd().sub(p));if(n.sweep===0){if(f<0)return this}else if(f>0)return this}return this.x1=h.x,this.y1=h.y,this}vectorHead(){return new j(this.x1,this.y1)}calcTail(i,r){let n=new j(i,r).angleD2(this.vectorEllipseCenter()),s=new j(i,r).rotateD(this.vectorEllipseCenter(),this.getHeadAngle()-n);return this.setTail(s),this}setTail(i){this.x2=i.x,this.y2=i.y}vectorTail(){return new j(this.x2,this.y2)}toData(){let i={gId:this.gId,cmdKey:"dimensionRadius",layer:this.layer,name:this.name,locked:this.locked,visible:this.visible,rotation:this.rotation,x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2,textX:this.textX,textY:this.textY,ellipseId:this.measureId},r=k.getDimensionRadius(this.gId);return Mt(r)?i:(Object.assign(r,i),r)}setData(){let i=this.toData();return k.setDimension(i.gId,i,"dimensionRadius"),this}getPath(){let i=this.renderTextLine(void 0,!0),r=this.renderText(!0),n=this.createStartTriangle();return{text:r,line:i+"M"+te(n,"points")}}render(i=!1){let r=this.renderTextLine(),n=this.renderText(),s=this.createStartTriangle(),a=this.renderCircle(this.vectorHead(),this.getId("head")),o=this.renderCircle(this.vectorTail(),this.getId("tail")),l=this.renderCircle({x:this.textX,y:this.textY},this.getId("text"));if(!this.container){let c=Et("g",{id:this.gId,class:"dimensionRadius",c_partid:"dimensionRadius",layer:this.layer,display:this.visible?"":"none"});!i&&Qe.appendTargetLayer(c,8,!0,{cmdKey:"dimensionRadius"}),this.container=c,c.appendChild(r),c.appendChild(n),c.appendChild(s),c.appendChild(a),c.appendChild(o),c.appendChild(l)}return this.container.outerHTML}getSvg(){return this.render(!0)}getId(i){return{head:this.gId+"-head-key-p",tail:this.gId+"-tail-key-p",text:this.gId+"-text-key-p"}[i]}createRect(i,r,n,s){let a=this.container?this.container.querySelector("#"+i):Et("rect"),o=this.extendLineAttr({id:i,class:r,x:-.5,y:-.5,width:1,height:1,fill:"#00FFFF",stroke:"none"});te(a,o);let l=4/H.gZoom*2,c=de.scale(l,l).translate(n,s),u=et.getMatrix6FromMatrix(c);return ht.updateTransform(u,a),a}translate(i,r){return this.x1+=i,this.y1+=r,this.x2+=i,this.y2+=r,this.calcTextPoint(),this}rotateSelf(i,r){let n=i-this.rotation;if(n===0)return;let s=na([this.x1,this.y1,this.x2,this.y2,this.textX,this.textY],n,r.x,r.y);return this.x1=s[0],this.y1=s[1],this.x2=s[2],this.y2=s[3],this.textX=s[4],this.textY=s[5],this.rotation=i,this.setData().render(),this}multiply3(i){let r=this.vectorHead().multiply3(i);this.x1=r.x,this.y1=r.y;let n=this.vectorTail().multiply3(i);this.setTail(n);let s=new j(this.textX,this.textY).multiply3(i);this.textX=s.x,this.textY=s.y,this.setData().render()}unmount(){dt(this.container)}renderTextLine(i,r=!1){let n=this.vectorHead();return i=i||this.vectorTail(),r?["M",n.x,n.y,i.x,i.y].join(" "):this.renderLine(n,i,this.gId+"-text-line")}lineAlignText(){let{width:i}=this.getTextBBox(this.container.querySelector("text").textContent);i/=2;let r=this.vectorHead().distance1(this.vectorTail());if(i<r)return this;let n=this.getLineRotation(),s=this.vectorHead().add1(i+this.textOffsetX,0).rotateD(this.vectorHead(),n);return this.renderTextLine(s),this.setTail(s),this}getHeadAngle(){let i=this.vectorHead().angleD2(this.vectorEllipseCenter());return tr(i)}getLineRotation(){return this.vectorTail().angleD2(this.vectorHead())}calcTextPoint(){let i=this.getLineRotation(),r=new j(this.textOffsetX,-10).rotateD(new j(0,0),i),n=this.vectorHead().add(r);return this.textX=n.x,this.textY=n.y,this}getTextMatrix(){let{rx:i,ry:r}=this.getRxRyPixel(),n=this.container?this.container.querySelector("text"):Et("text",{x:0,y:0});i=lt(Qs(i),2),r=lt(Qs(r),2),n.textContent="Rx"+i+"mm,Ry"+r+"mm";let s=this.vectorTail().angleD2(this.vectorHead()),a=de.translate(this.textX,this.textY),o=n.getBBox();!o.width&&!o.height&&(o=this.getTextBBox(n.textContent));let l=.5;return a=de.scale(l,l).rotateD(s).multiply3(a),{text:n,m3:a,bbox:o}}getTextBBoxOutline(){let{m3:i,bbox:r}=this.getTextMatrix(),n=St.extendRect(r),s=[];for(let a of[n.LL(),n.UL(),n.UR(),n.LR()])s.push(a.multiply3(i));return s}renderText(i=!1){let{text:r,m3:n}=this.getTextMatrix();if(i)return{textContent:r.textContent,m3:n};let s=et.getMatrix6FromMatrix(n);return ht.updateTransform(s,r),r}createStartTriangle(){let i=this.vectorHead(),r=this.vectorTail().angleD2(this.vectorHead());return this.createTriangle([[5,-5],[0,0],[5,5]],r,i,this.gId+"-start-triangle")}findContainsControlPoint(i,r){let n=5;if(sl(i,r,this.x1,this.y1,n))return this.getId("head");if(sl(i,r,this.x2,this.y2,n))return this.getId("tail");if(sl(i,r,this.textX,this.textY,n))return this.getId("text")}setControlDotSelected(i){switch(i){case this.getId("head"):this.headSelected=!0,this.rememberedLineLength=this.vectorHead().distance1(this.vectorTail());break;case this.getId("tail"):this.tailSelected=!0;break;case this.getId("text"):this.textSelected=!0;break}}makeTailHeadPointCenter(){let i=this.rememberedLineLength,r=this.vectorHead().angleD2(this.vectorEllipseCenter()),n=this.vectorHead().add1(i,0).rotateD(this.vectorHead(),r);return this.setTail(n),this}moveControlPoint(i,r){if(this.headSelected){if(this.measureId){let n=this.x1+i,s=this.y1+r;this.setHead(n,s).makeTailHeadPointCenter()}else this.x1+=i,this.y1+=r;this.calcTextPoint()}if(this.tailSelected){let n=F3(this.x2+i,this.y2+r,this.x1,this.y1,this.x2,this.y2);this.x2=n.x,this.y2=n.y,this.calcTextPoint()}return this.textSelected&&(this.textX+=i,this.textY+=r),this.setData(),this}static zoom(){k.iteratorDimensionRadius(i=>{let r=new T1(i).render();r=null})}};T1.updateMeasureValue=nl(T1.zoom);var cn=T1;var Xn={move(e,t,i){if(!t&&!i)return;let r=e.cmdKey;this[r]?this[r](e,t,i):Kr(r,e)},auxiliaryLine:(e,t,i)=>{e.x+=t,e.y+=i,new Zl(e).render()},auxiliaryPoint:(e,t,i)=>{e.x+=t,e.y+=i;let r=le(e.gId);tc.circle1(r,t,i)},dimension(e,t,i){let r=new In(e).translate(t,i).render();r=null},dimensionLength(e,t,i){let r=new xn(e);r.translate(t,i).render(),r.setData()},dimensionAngle(e,t,i){let r=new bn(e);r.translate(t,i).render(),r.setData()},dimensionRadius(e,t,i){let r=new cn(e);r.translate(t,i).render(),r.setData()},obj(e,t,i){let r=de.translate(t,i);Lr.syncImage(e,r)},text(e,t,i){let r=de.translate(t,i);xr.syncText(e,r,{updateMatrix:!0})},group(e,t,i){let r=de.translate(t,i);zn.syncGroup(e,r,{updateD:!0})},ellipse(e,t,i){let r=de.translate(t,i);Ei.syncEllipse(e,r,{updateMatrix:!0})},arc(e,t,i){let r=de.translate(t,i);mr.syncArc(e,r,{updateD:!0})},rect(e,t,i){let r=de.translate(t,i);Li.syncRect(e,r,{updateMatrix:!0})}};var Vo=class{constructor(){this.allDimensions=[];this.ignoreDimension=new Set;this.xNode=new Set;this.yNode=new Set;this.reset()}reset(){return this.allDimensions.length=0,k.iteratorDimension(t=>{this.allDimensions.push(new In(t))}),this}prepareHistory(t,i){t=t||this.xNode,i=i||this.yNode;let r=new Set;for(let s of t){r.add(s.id);let a=new rt().findAllEleByOneEle(s.id);for(let o of a)Ke.jsonSnap.addOne(k.getById(o).json);Ke.jsonSnap.addOne(k.getById(s.id).json)}for(let s of i){r.add(s.id);let a=new rt().findAllEleByOneEle(s.id);for(let o of a)Ke.jsonSnap.addOne(k.getById(o).json);Ke.jsonSnap.addOne(k.getById(s.id).json)}let n=this.findDimensionByPrimitiveId(r);for(let s of n)Ke.jsonSnap.addOne(k.getById(s).json);return this}removeXPrimitive(t=new Set([]),i){for(let r of t)i.delete(r);return i}removeYPrimitive(t=new Set([]),i){for(let r of t)i.delete(r);return i}movePrimitive(t,i,r,n){r=r||this.canMoveX,n=n||this.canMoveY;for(let s of r)Xn.move(k.getById(s).json,t,0);for(let s of n)Xn.move(k.getById(s).json,0,i);return this}moveDimension(t,i,r,n){if(r=r||this.xNode,n=n||this.yNode,!r.size&&!n.size)return this;for(let s of this.allDimensions)r.has(s.start)&&r.has(s.end)&&n.has(s.start)&&n.has(s.end)?s.translate(t,i).render():(r.has(s.start)&&s.incrementStartNode(t,0),r.has(s.end)&&s.incrementEndNode(t,0),n.has(s.start)&&s.incrementStartNode(0,i),n.has(s.end)&&s.incrementEndNode(0,i),r.has(s.start)&&r.has(s.end)&&s.updateOtherP(t,0),n.has(s.start)&&n.has(s.end)&&s.updateOtherP(0,i),s.updateOtherP(0,0)),k.setDimension(s.getId(),s.toJSON());return this}findDimensionByPrimitiveId(t){let i=new Set;for(let r of this.allDimensions){let n=r.start.id;t.has(n)&&i.add(r.getId());let s=r.end.id;t.has(s)&&i.add(r.getId())}return i}setIgnoreDimension(t){return this.ignoreDimension=t,this}getAllAffectedPrimitivesId(t,i,r=!0){t=t||this.xNode,i=i||this.yNode;let n=new Set,s=new Set,a=new rt;for(let l of t){n.add(l.id);let c=r?a.findAllEleByOneEle(l.id):[];for(let u of c)n.add(u)}for(let l of i){s.add(l.id);let c=r?a.findAllEleByOneEle(l.id):[];for(let u of c)s.add(u)}this.canMoveX=n,this.canMoveY=s;let o=new Set([...n,...s]);return{canMoveX:n,canMoveY:s,all:o,xNode:t,yNode:i}}getMoveIdsInCom(t,i,r){let{canMoveX:n,canMoveY:s}=this.getAllAffectedPrimitivesId(),a=new rt().getAllChildEles(r);for(let o of n)a.has(o)&&o!=i&&n.delete(o);for(let o of s)a.has(o)&&o!=i&&s.delete(o);return n.delete(t),s.delete(t),this.canMoveX=n,this.canMoveY=s,{canMoveX:n,canMoveY:s}}addNextTickTasks(t=[]){for(let i of this.allDimensions)i.makeOtherPointStatic(),i.addNextTickTasks(t)}setStillByEle(t){let i=[-1,0,1,2,3,4,5,6,7],r=new Set;for(let n of i){let s={dx:0,dy:0,id:t.id,index:n};r.add(s)}this.setNodeVisited(r)}setNodeVisited(t){for(let i of t){let{id:r,index:n,dx:s,dy:a}=i;for(let o of this.allDimensions)o.start.id===r&&n===o.start.index&&(o.startNextXMove=s,o.startNextYMove=a),o.end.id===r&&n===o.end.index&&(o.endNextXMove=s,o.endNextYMove=a)}return this}removeXNode(t,i){for(let r of t){let{id:n,index:s,dx:a,dy:o}=r;for(let l of i)l.id===n&&s===l.index&&i.delete(l)}return i}removeYNode(t,i){for(let r of t){let{id:n,index:s,dx:a,dy:o}=r;for(let l of i)l.id===n&&s===l.index&&i.delete(l)}return i}findDimensionNode(t){let i=[];for(let r of t){let{dx:n,dy:s,id:a}=r,o=this.findDimensionNodeByPrimitiveId(new Set([r.id]),n,s,new Set([r.index]));if(o===!1)return ts.toastMsg(),!1;let{xNode:l,yNode:c}=o;(l.size||c.size)&&i.push({id:a,dx:n,dy:s,xNode:l,yNode:c})}return i}findDimensionNodeByPrimitiveId(t,i=1,r=1,n=new Set([-1,0,1,2,3,4,5,6,7])){let s=[],a=[];for(let o of t){let l=this.getXMoved(o,i,n);if(l===!1)return!1;s.push(...Array.from(l));let c=this.getYMoved(o,r,n);if(c===!1)return!1;a.push(...Array.from(c))}for(let o of s)this.xNode.add(o);for(let o of a)this.yNode.add(o);return{xNode:new Set(s),yNode:new Set(a)}}appendCombinationEle(t,i){let r=new rt().findAllEleByOneEle(t);for(let n of r)i.add(n)}checkAbandonedBySelfDimensionInX(t){return t.start.id===t.end.id&&!ft(t.startNextXMove)&&!ft(t.endNextXMove)&&!ni(t.startNextXMove,t.endNextXMove)&&t.categoryIsConstraint()?(console.warn(t,"\u667A\u80FD\u5C3A\u5BF8\u6807\u6CE8\u5728\u81EA\u8EAB\uFF0C\u5F00\u59CB/\u7ED3\u675F\u8282\u70B9\u79FB\u52A8\u7684 x \u8DDD\u79BB\u4E0D\u540C",t.startNextXMove,t.endNextXMove),!0):!1}checkAbandonedBySelfDimensionInY(t){return t.start.id===t.end.id&&!ft(t.startNextYMove)&&!ft(t.endNextYMove)&&!ni(t.startNextYMove,t.endNextYMove)&&t.categoryIsConstraint()?(console.warn(t,"\u667A\u80FD\u5C3A\u5BF8\u6807\u6CE8\u5728\u81EA\u8EAB\uFF0C\u5F00\u59CB\u7ED3\u675F\u8282\u70B9\u79FB\u52A8\u7684 y \u8DDD\u79BB\u4E0D\u540C",t.startNextYMove,t.endNextYMove),!0):!1}getXMoved(t,i=1,r){let n=new Set,s=new Set([t]),a=c=>!!(c.getCategory()==="Annotation"||c.direction==="y"||this.ignoreDimension.has(c.getId())),o=1,l=new Set;for(;s.size;){let c=s.values().next().value;s.delete(c);for(let u of this.allDimensions)if([u.start.id].includes(c)&&(o===1&&r.has(u.start.index)||o!==1)){if(!ft(u.startNextXMove)&&u.startNextXMove!==i&&u.categoryIsConstraint())return console.warn(i,u.startNextXMove),!1;if(!ft(u.startNextXMove))continue;if(u.startNextXMove=i,this.checkAbandonedBySelfDimensionInX(u))return!1;if(n.add(u.start),a(u))continue;let h=u.end.id+"_"+u.end.index;if(l.has(h))continue;l.add(u.start.id+"_"+u.start.index),s.add(u.end.id),this.appendCombinationEle(u.end.id,s)}for(let u of this.allDimensions)if([u.end.id].includes(c)&&(r.has(u.end.index)&&o===1||o!=1)){if(!ft(u.endNextXMove)&&!ni(u.endNextXMove,i)&&u.getCategory()!=="Annotation")return console.warn(i,u.endNextXMove),!1;if(!ft(u.endNextXMove))continue;if(u.endNextXMove=i,this.checkAbandonedBySelfDimensionInX(u))return!1;if(n.add(u.end),a(u))continue;let h=u.start.id+"_"+u.start.index;if(l.has(h))continue;l.add(u.end.id+"_"+u.end.index),s.add(u.start.id),this.appendCombinationEle(u.start.id,s)}o++}return n}getYMoved(t,i=1,r=new Set([-1,0,1,2,3,4,5,6,7])){let n=new Set,s=new Set([t]),a=c=>!!(c.getCategory()==="Annotation"||c.direction==="x"||this.ignoreDimension.has(c.getId())),o=1,l=new Set;for(;s.size;){let c=s.values().next().value;s.delete(c);for(let u of this.allDimensions)if([u.start.id].includes(c)&&(r.has(u.start.index)&&o===1||o!==1)){if(!ft(u.startNextYMove)&&u.startNextYMove!==i&&u.categoryIsConstraint())return console.warn(i,u.startNextYMove),!1;if(!ft(u.startNextYMove))continue;if(u.startNextYMove=i,this.checkAbandonedBySelfDimensionInY(u))return!1;if(n.add(u.start),a(u))continue;let h=u.end.id+"_"+u.end.index;if(l.has(h))continue;l.add(u.start.id+"_"+u.start.index),s.add(u.end.id),this.appendCombinationEle(u.end.id,s)}for(let u of this.allDimensions)if([u.end.id].includes(c)&&(r.has(u.end.index)&&o===1||o!==1)){if(!ft(u.endNextYMove)&&u.endNextYMove!==i&&u.categoryIsConstraint())return console.warn(i,u.endNextYMove),!1;if(!ft(u.endNextYMove))continue;if(u.endNextYMove=i,this.checkAbandonedBySelfDimensionInY(u))return!1;if(n.add(u.end),a(u))continue;let h=u.start.id+"_"+u.start.index;if(l.has(h))continue;l.add(u.end.id+"_"+u.end.index),s.add(u.start.id),this.appendCombinationEle(u.start.id,s)}o++}return n}overDefined(t,i,r){let n=[];for(let l of this.xNode)l.id===t&&n.push(t),l.id===i&&n.push(i);let s=[];for(let l of this.yNode)l.id===t&&s.push(t),l.id===i&&s.push(i);let a=n.includes(t)&&n.includes(i);if(r==="x")return a;let o=s.includes(t)&&s.includes(i);return r==="y"?o:r==="xy"?a&&o:!1}overDefinedSelf(t,i){let r=this.findDimensionByPrimitiveId(new Set([t]));for(let n of r){let s=k.getDimension(n),a=new In(s);if(a.categoryIsConstraint()&&a.isSelfDimension()&&s.direction===i||a.categoryIsConstraint()&&a.isSelfDimension()&&s.direction==="xy")return!0}return!1}};var W2={scale(e,t,i,r){let{json:n,cmdKey:s}=k.getById(e),a=de.scale(t,i).setOrigin1(r);this[s]?this[s](n,a):Kr(s)},obj(e,t){Lr.syncImage(e,t,{updateMatrix:!0})},text(e,t){xr.syncText(e,t,{updateMatrix:!0})},group(e,t){zn.syncGroup(e,t,{updateD:!0})},ellipse(e,t){Ei.syncEllipse(e,t,{updateMatrix:!0})},arc(e,t){mr.syncArc(e,t,{updateD:!0})},rect(e,t){Li.syncRect(e,t,{updateMatrix:!0})}};var AC=class{constructor(){}storeFollow(t,i){this.lastFollowHandleX=t,this.lastFollowHandleY=i}storeDriving(t,i){this.lastDrivingHandleX=t,this.lastDrivingHandleY=i}exchangeFollow(){ft(this.lastFollowHandleX)||(this.followHandleX=this.lastFollowHandleX,this.followHandleY=this.lastFollowHandleY,this.lastFollowHandleX=null,this.lastFollowHandleY=null)}exchangeDriving(){ft(this.lastDrivingHandleX)||(this.drivingHandleX=this.lastDrivingHandleX,this.drivingHandleY=this.lastDrivingHandleY,this.lastDrivingHandleX=null,this.lastDrivingHandleY=null)}getFollowHandle(){return{x:this.followHandleX,y:this.followHandleY}}getDrivingHandle(){return{x:this.drivingHandleX,y:this.drivingHandleY}}flush(){this.followHandleX=null,this.followHandleY=null,this.lastFollowHandleX=null,this.lastDrivingHandleY=null,this.drivingHandleX=null,this.drivingHandleY=null,this.lastDrivingHandleX=null,this.lastDrivingHandleY=null}setPrevHandlePosition(t,i,r,n,s){let a=n.pathSegTypeAsLetter,o=new j(t.x1,t.y1),l=new j(t.x1+i,t.y1+r);if(this.storeDriving(t.x1+i,t.y1+r),a==="C")if(s.ctrl){this.exchangeFollow(),this.exchangeDriving();let{x:c,y:u}=this.getFollowHandle();ft(c)||(n.x2=c,n.y2=u)}else{let c=new j(n.x2,n.y2),{x:u,y:h}=this.getFollowHandle(),{x:d,y:p}=Xs.getDrivingHandle();ft(u)||(c=new j(u,h)),ft(d)||(o=new j(d,p));let f=wt.handleFollowHandle(new j(n.x,n.y),{oldP:o,newP:l},c);n.x2=f.x,n.y2=f.y,this.storeFollow(f.x,f.y)}}setNextHandlePosition(t,i,r,n,s){let a=n.pathSegTypeAsLetter,o=new j(t.x2,t.y2),l=new j(t.x2+i,t.y2+r);if(a==="C"){if(s.ctrl){this.exchangeFollow(),this.exchangeDriving();let{x:c,y:u}=Xs.getFollowHandle();ft(c)||(n.x1=c,n.y1=u)}else{let c=new j(n.x1,n.y1),{x:u,y:h}=this.getFollowHandle();ft(u)||(c=new j(u,h));let{x:d,y:p}=this.getDrivingHandle();ft(d)||(o=new j(d,p));let f=wt.handleFollowHandle(new j(t.x,t.y),{oldP:o,newP:l},c);n.x1=f.x,n.y1=f.y,this.storeFollow(f.x,f.y)}this.storeDriving(t.x2+i,t.y2+r)}}},Xs=new AC;var Mn={createPath8Dots:function(e){let t=Rr([e],!0),{x:i,y:r,width:n,height:s}=t;return[i,r,i+n,r,i+n,r+s,i,r+s,i+n/2,r,i+n,r+s/2,i+n/2,r+s,i,r+s/2]},get(e,t="multi"){switch(e.cmdKey){case"arc":return Mn.path_arc.get(e.gId);case"rect":return Mn.rect.get(e,t);case"obj":return Mn.image.get(e,t);case"ellipse":return Mn.ellipse.get(e);case"group":return Mn.path_group.get(e);case"text":return Mn.text.get(e,t);case"_runtime":{let i=e;switch(i.subCmdKey){case"select-box":return Mn.selectBox.get(i);default:break}break}default:break}},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=e.tagName;if(h=te(e,"id")=="selectBox1"?"selectbox":h,!Mn[h])throw new Error(h);Mn[h].set(e,t,i,r,n,s,a,o,l,c,u)},selectBox:{get:function(e){let{x:t,y:i,width:r,height:n}=e;return[t,i,t+r,i,t+r,i+n,t,i+n,(2*t+r)/2,i,t+r,(2*i+n)/2,(2*t+r)/2,i+n,t,(2*i+n)/2]},set:function(e,t,i,r,n,s,a,o){}},text:{get:function(e,t="multi"){let i=e.cacheWidth,r=e.cacheHeight,n=new Array,s=j.ORIGIN;n.push(s.add1(0,-r)),n.push(s.add1(i,-r)),n.push(s.add1(i,0)),n.push(s),n.push(s.add1(i/2,-r)),n.push(s.add1(i,-r/2)),n.push(s.add1(i/2,0)),n.push(s.add1(0,-r/2));let a=ht.createMatrixFrom6(e.tempMatrix||e.matrix);if(t==="multi")return n.reduce((l,c)=>(c=c.multiply3(a),l.push(c.x,c.y),l),new Array);let o=[];for(let l=0;l<4;l++){let c=n[l];o.push([c.x,c.y])}return ht.getMaxOuterBoundingBox(o,e)},set:function(e,t,i,r,n,s,a,o,l=!1,c,u={}){let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=k.getText(e.id);xr.syncText(d,h,{updateMatrix:!1})}},g:{get:function(e){if($t(e)==="text")return Mn.text.get.apply(e,arguments);let i=e.getBBox(),r=i.x,n=i.y,s=i.width,a=i.height;return[r,n,r+s,n,r,n+a,r+s,n+a]},set:function(e,t,i,r,n){if($t(e)==="text")return Mn.text.set.apply(e,arguments);tc.g(e,r,n)}},image:{get:function(e,t="multi"){let i=1,r=1,n=[[0,0],[i,0],[i,r],[0,r],[i/2,0],[i,r/2],[i/2,r],[0,r/2]];if(t==="multi"){let a=ht.createMatrixFrom6(e.tempMatrix||e.matrix),o=[];for(let[l,c]of n){let u=new j(l,c).multiply3(a);o.push(u.x,u.y)}return o}return ht.getMaxOuterBoundingBox(n.slice(0,4),e)},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=k.gJsonCache.obj[e.id];if(!h)return;let d=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u);Lr.syncImage(h,d,{updateMatrix:!1})}},rect:{get:function(e,t="multi"){let i=Ua(e)?e:k.getRect(e.id),{matrix:r,tempMatrix:n}=i,s=ht.createMatrixFrom6(n||r),a=0,o=1,l=0,c=1,u=[[a,l],[o,l],[o,c],[a,c],[.5,l],[o,.5],[.5,c],[a,.5]];if(t==="multi"){let h=[];for(let d of u){let p=new j(d[0],d[1]).multiply3(s);h.push(p.x,p.y)}return h}return ht.getMaxOuterBoundingBox(u.slice(0,4),i)},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=k.getRect(e.id);Li.syncRect(d,h,{updateMatrix:!1})}},circle:{get:function(e){let t=+te(e,"cx"),i=+te(e,"cy"),r=+te(e,"r"),n=[t-r,i-r,t+r,i-r,t+r,i+r,t-r,i+r];return[t,i,t,i-r,t,i+r,t-r,i,t+r,i].concat(n)},set:function(e,t,i,r,n){t||(t=Mn.circle.get(e));let s={cx:t[0],cy:t[1],r:t[1]-t[3]};i===0&&(s.cx+=r,s.cy+=n),i==1&&(s.r-=n/2,s.cy+=n/2),i==2&&(s.r+=n/2,s.cy+=n/2),i==3&&(s.r-=r/2,s.cx+=r/2),i==4&&(s.cx+=r/2,s.r+=r/2),i==5&&(s.r-=r),i==6&&(s.r+=r),i==7&&(s.r+=r),i==8&&(s.r+=r),s.r!==0&&(s.r<0&&(s.r=-s.r),!(s.r<10)&&(s.cx=parseInt(String(s.cx*10))/10,s.cy=parseInt(String(s.cy*10))/10,te(e,s)))}},ellipse:{get(e){let t=0,i=0,r=1,n=1,s=t-r,a=t+r,o=i-n,l=i+n,c=[[s,o],[a,o],[a,l],[s,l],[t,o],[a,i],[t,l],[s,i]],{tempMatrix:u,matrix:h,rotation:d}=e,p=et.createMatrixFrom6(u||h),f=[];for(let m of c){let g=new j(m[0],m[1]).multiply3(p);f.push(g.x,g.y)}return f},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=k.getEllipse(e.id);Ei.syncEllipse(d,h,{updateMatrix:!1})}},line:{get:function(e){return[+te(e,"x1"),+te(e,"y1"),+te(e,"x2"),+te(e,"y2")]},set:function(e,t,i,r,n){t||(t=Mn.line.get(e));let s={x1:t[0],y1:t[1],x2:t[2],y2:t[3]};i===0&&(s.x1+=r,s.y1+=n),i==1&&(s.x2+=r,s.y2+=n),te(e,s)}},polygon:{get:function(e){let t=Cc(te(e,"points")).split(/[\s\,]+/g),i;for(i=0;i<t.length;i++)t[i]=+t[i];for(i=t.length-2;i>=2;i-=2)t.splice(i,0,(t[i-2]+t[i])/2,(t[i-1]+t[i+1])/2);return i=t.length-2,t.push((t[0]+t[i])/2,(t[1]+t[i+1])/2),t.lightDots="odd",t},set:function(e,t,i,r,n){let s=t.slice(0),a,o=2*i;for(s[o]+=r,s[o+1]+=n,i==s.length/2-1?(!ni(s[o]*2,s[0]+s[o-2])||!ni(s[o+1]*2,s[1]+s[o-1]))&&s.splice(o,0,0,0):i%2&&(!ni(s[o]*2,s[o-2]+s[o+2])||!ni(s[o+1]*2,s[o-1]+s[o+3]))&&(s.splice(o+2,0,0,0),s.splice(o,0,0,0)),o=4,a=s.slice(0,2);o<s.length-1;o+=4)a.push(s[o],s[o+1]);let l={},c=[],u;for(let E=0;E<a.length-1&&c.length<4;E+=2)u=a[E]+"_"+a[E+1],l[u]||(l[u]=!0,c.push(E));if(c.length<=2)return;let h=!0,d,p,f,m,g,b;for(i=2;i<c.length;i++)if(d=a[c[0]],p=a[c[0]+1],f=a[c[1]],m=a[c[1]+1],g=a[c[i]],b=a[c[i]+1],!ni((d-f)*(b-m),(g-f)*(p-m))){h=!1;break}if(h)return;let y={points:yE(a.join(" "))};te(e,y)}},path:{get:function(e){let t=nf(e);if(t){let w=e.tagName+"_"+t;if(Mn[w]&&Mn[w].get)return Mn[w].get.apply(e,arguments)}let i=e.pathSegList,r=i.numberOfItems,n=0,s=0,a=[],o=0,l=0,c=[],u,h,d,p,f,m,g,b,y,E,S;for(u=0;u<r;u++)switch(d=i.getItem(u),p=d.pathSegType,u===0&&p!=Dr&&p!=Vr&&p!=si&&a.push(n,s),h=a.length/2-1,p){case si:n=o,s=l;break;case Dr:if(n=d.x,s=d.y,o=n,l=s,u+1==r||(g=i.getItem(u+1),m=g.pathSegType,m==Dr||m==Vr||m==si))break;a.push(n,s),m==mn&&a.push((n+g.x)/2,(s+g.y)/2);break;case mn:if(a.push(n=d.x,s=d.y),u+1==r)break;g=i.getItem(u+1),m=g.pathSegType,m==si&&(g=i.getItem(0)),(m==mn||m==si)&&a.push((n+g.x)/2,(s+g.y)/2);break;case Po:a.push(n=d.x,s);break;case Lo:a.push(n,s=d.y);break;case Ao:c.push({from:h,to:h+1},{from:h+2,to:h+3}),a.push(d.x1,d.y1,n=d.x2,s=d.y2,d.x,d.y);break;case Co:c.push({from:h+1,to:h+2}),a.push(d.x2,d.y2,n=d.x,s=d.y);break;case Do:c.push({from:h,to:h+1},{from:h+1,to:h+2}),a.push(d.x1,d.y1,n=d.x,s=d.y);break;case _o:case Ya:if(f=i.getItem(u-1),b=Ad(f.x,f.y,d.x,d.y,d.largeArcFlag?1:0,d.sweepFlag?1:0,d.r1,d.r2,d.angle),y=b.cx,S=b.cy,E=md([f.x,f.y],[y,S],b.delta_theta/2),a.push(E[0],E[1]),a.push(n=d.x,s=d.y),u+1==r)break;g=i.getItem(u+1),m=g.pathSegType,m==si&&(g=i.getItem(0)),(m==mn||m==si)&&a.push((n+g.x)/2,(s+g.y)/2);break;case Vr:if(n+=d.x,s+=d.y,o=n,l=s,u+1==r||(m=i.getItem(u+1).pathSegType,m==Dr||m==Vr||m==si))break;a.push(n,s);break;case Ul:a.push(n+=d.x,s+=d.y);break;case Gl:a.push(n+=d.x,s);break;case Yl:a.push(n,s+=d.y);break;case Ml:c.push({from:h,to:h+1},{from:h+2,to:h+3}),a.push(n+d.x1,s+d.y1,n+d.x2,s+d.y2,n+=d.x,s+=d.y);break;case Bl:c.push({from:h+1,to:h+2}),a.push(n+d.x2,s+d.y2,n+=d.x,s+=d.y);break;case kl:c.push({from:h+1,to:h+2}),a.push(n+d.x1,s+d.y1,n+=d.x,s+=d.y);break;case Fl:case Nl:a.push(n+=d.x,s+=d.y);break;default:break}if(te(e,"drag")!="self"){let w=Mn.createPath8Dots(e);return c.length?w.c_helper_lines=c:w.lightDots="odd",w}return c.length?a.c_helper_lines=c:a.lightDots="odd",a},set:function(e,t,i,r,n,s){if(r===0&&n===0){if(s)if($t(e)==="arc"&&te(e,"third-point")){let M=O0(t.join(" "));te(e,{d:s,"third-point":M[2].x+","+M[2].y})}else te(e,{d:s});return}let a=nf(e);if(a){let M=e.tagName+"_"+a;if(Mn[M]&&Mn[M].set){Mn[M].set.apply(e,arguments);return}}let o,l,c;if(/[^ahvqtsc]/i.test(s)){for(o=!0,l=t.slice(0),2*i+1<l.length&&(l[2*i]+=r,l[2*i+1]+=n),c=2;c<l.length-1;c+=2)if(l[c]!=l[0]||l[c+1]!=l[1]){o=!1;break}if(o)return}let u=e.pathSegList,h=u.numberOfItems,d=-1,p=i,f,m,g,b,y,E,S,w,x,I,A,O,R;if(s&&te(e,{d:s}),t.c_helper_lines||(i=i>>1),!t.c_helper_lines&&p%2){m=u.getItem(i+1),m.pathSegType==Ya?(g=u.getItem(i),y=t[p*2],E=t[p*2+1],S=Nm({x:g.x,y:g.y},{x:m.x,y:m.y},{x:y+r,y:E+n}),S<4&&(S=4),S=Math.sqrt(S),w=m.sweepFlag,x=m.r1,I=Ro(g.x,g.y,m.x,m.y),A=(m.x-g.x)*(E-g.y)-(y-g.x)*(m.y-g.y),O=(m.x-g.x)*(E+n-g.y)-(y+r-g.x)*(m.y-g.y),A*O<0&&(w^=1),x=I/(8*S)+S/2,R=x>S?0:1,x=Kp(x),m.r1=x,m.r2=x,m.largeArcFlag=R,m.sweepFlag=w):u.insertItemBefore(e.createSVGPathSegLinetoAbs(t[p*2]+r,t[p*2+1]+n),i+1);return}e:for(f=0;f<h;f++)switch(m=u.getItem(f),m.pathSegType){case si:break;case Dr:case Vr:if(f+1==h||(b=u.getItem(f+1).pathSegType,b==Dr||b==Vr||b==si))break;if(d++,d==i){m.x=lt(m.x+r,3),m.y=lt(m.y+n,3);break e}break;case mn:case Ul:if(d++,d==i){m.x=lt(m.x+r,3),m.y=lt(m.y+n,3);break e}break;case Po:case Gl:if(d++,d==i){m.x+=r;break e}break;case Lo:case Yl:if(d++,d==i){m.y+=n;break e}break;case Ao:case Ml:if(d++,d==i){m.x1+=r,m.y1+=n;break e}if(d++,d==i){m.x2+=r,m.y2+=n;break e}if(d++,d==i){m.x+=r,m.y+=n;break e}break;case Co:case Bl:if(d++,d==i){m.x2+=r,m.y2+=n;break e}if(d++,d==i){m.x+=r,m.y+=n;break e}break;case Do:case kl:if(d++,d==i){m.x1+=r,m.y1+=n;break e}if(d++,d==i){m.x+=r,m.y+=n;break e}break;case _o:case Fl:case Nl:if(d++,d==i){m.x+=r,m.y+=n;break e}break;case Ya:if(d++,d==i){m.x+=r,m.y+=n;break e}break;default:break}}},path_group:{get:function(e){if(wt.is8DotsMode(e.gId))return zn.getGroup8Dots({...e,d:e.tempD||e.d});let i=document.getElementById(e.gId).pathSegList,r=i.numberOfItems,n=0,s=0,a=[],o=0,l=0,c=[],u,h,d,p,f,m,g,b,y=new Map;for(let E=0;E<r;E++){u=i.getItem(E),h=u.pathSegType;let S=E-1>-1&&i.getItem(E-1);E===0&&h!=Dr&&h!=Vr&&h!=si&&a.push(n,s);let w=a.length/2-1;switch(h){case si:n=o,s=l;break;case Dr:if(n=u.x,s=u.y,o=n,l=s,E+1==r||(p=i.getItem(E+1),d=p.pathSegType,d==Dr||d==Vr||d==si))break;a.push(n,s),d==mn;break;case mn:if(a.push(n=u.x,s=u.y),E+1==r)break;p=i.getItem(E+1),d=p.pathSegType,d==si&&(p=i.getItem(0)),d==mn||d==si;break;case Po:a.push(n=u.x,s);break;case Lo:a.push(n,s=u.y);break;case Ao:c.push({from:w,to:w+1,belong:w},{from:w+2,to:w+3,belong:w+3});let x=S.x===u.x1&&S.y===u.y1,I=u.x2===u.x&&u.y2===u.y;y.set(w+1,{belong:w,display:!x}),y.set(w+2,{belong:w+3,display:!I}),a.push(u.x1,u.y1,n=u.x2,s=u.y2,u.x,u.y);break;case Co:c.push({from:w+1,to:w+2}),a.push(u.x2,u.y2,n=u.x,s=u.y);break;case Do:c.push({from:w,to:w+1,belong:w}),y.set(w+1,{belong:w,display:!0}),a.push(u.x1,u.y1,n=u.x,s=u.y);break;case _o:case Ya:if(S=i.getItem(E-1),f=Ad(S.x,S.y,u.x,u.y,u.largeArcFlag?1:0,u.sweepFlag?1:0,u.r1,u.r2,u.angle),m=f.cx,b=f.cy,g=md([S.x,S.y],[m,b],f.delta_theta/2),a.push(n=u.x,s=u.y),E+1==r)break;p=i.getItem(E+1),d=p.pathSegType,d==si&&(p=i.getItem(0)),d==mn||d==si;break;case Vr:if(n+=u.x,s+=u.y,o=n,l=s,E+1==r||(d=i.getItem(E+1).pathSegType,d==Dr||d==Vr||d==si))break;a.push(n,s);break;case Ul:a.push(n+=u.x,s+=u.y);break;case Gl:a.push(n+=u.x,s);break;case Yl:a.push(n,s+=u.y);break;case Ml:c.push({from:w,to:w+1},{from:w+2,to:w+3}),a.push(n+u.x1,s+u.y1,n+u.x2,s+u.y2,n+=u.x,s+=u.y);break;case Bl:c.push({from:w+1,to:w+2}),a.push(n+u.x2,s+u.y2,n+=u.x,s+=u.y);break;case kl:c.push({from:w+1,to:w+2}),a.push(n+u.x1,s+u.y1,n+=u.x,s+=u.y);break;case Fl:case Nl:a.push(n+=u.x,s+=u.y);break;default:break}}return c.length&&(a.c_helper_lines=c),a.isModifyAnchor=!0,a.handleIndexes=y,a},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u){if(wt.isAnchorMode(e.id)&&!l){if(/[^ahvqtsc]/i.test(s)){let b=!0,y=t.slice(0);2*i+1<y.length&&(y[2*i]+=r,y[2*i+1]+=n);for(let E=2;E<y.length-1;E+=2)if(y[E]!==y[0]||y[E+1]!==y[1]){b=!1;break}if(b)return}let d=e.pathSegList,p=d.numberOfItems,f=-1,m,g;s&&te(e,{d:s});e:for(let b=0;b<p;b++){let y=b-1>-1&&d.getItem(b-1),E=y.pathSegTypeAsLetter,S=d.getItem(b),w=b+1<p&&d.getItem(b+1),x=w.pathSegTypeAsLetter;switch(S.pathSegType){case si:break;case Dr:case Vr:if(m=S,b+1==p||(g=w.pathSegType,g==Dr||g==Vr||g==si))break;if(f++,f==i){let I=lt(S.x+r,3),A=lt(S.y+n,3);x==="C"&&w.x1===S.x&&w.y1===S.y&&(w.x1=I,w.y1=A),S.x=I,S.y=A;break e}break;case mn:case Ul:if(f++,f==i){S.x=lt(S.x+r,3),S.y=lt(S.y+n,3);break e}break;case Po:case Gl:if(f++,f==i){S.x+=r;break e}break;case Lo:case Yl:if(f++,f==i){S.y+=n;break e}break;case Ao:case Ml:if(f++,f==i){Xs.setPrevHandlePosition(S,r,n,y,u),S.x1+=r,S.y1+=n;break e}if(f++,f==i){Xs.setNextHandlePosition(S,r,n,w,u),S.x2+=r,S.y2+=n;break e}if(f++,f==i){S.x=lt(S.x+r,3),S.y=lt(S.y+n,3),S.x2=lt(S.x2+r),S.y2=lt(S.y2+n),x==="C"&&(w.x1+=r,w.x1=lt(w.x1),w.y1+=n,w.y1=lt(w.y1)),b!==p-1&&d.getItem(b+1).pathSegType===si&&(m.x=S.x,m.y=S.y);break e}break;case Co:case Bl:if(f++,f==i){S.x2+=r,S.y2+=n;break e}if(f++,f==i){S.x+=r,S.y+=n;break e}break;case Do:case kl:if(f++,f==i){S.x1+=r,S.y1+=n;break e}if(f++,f==i){S.x+=r,S.y+=n;break e}break;case _o:case Fl:case Nl:if(f++,f==i){S.x+=r,S.y+=n;break e}break;case Ya:if(f++,f==i){S.x+=r,S.y+=n;break e}break;default:break}}return}let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u);zn.syncGroup(k.getById(e.id).json,h,{updateD:!1})}},path_arc2:{get:function(e){let t=[],i,r=e.getPathData();for(i=0;i<r.length;i++)if(r[i].type=="A"){let n=r[i-1].values,s=r[i].values,a=Ad(n[0],n[1],s[5],s[6],s[3],s[4],s[0],s[1],s[2]),o=a.cx,l=a.cy,c=md([n[0],n[1]],[o,l],a.delta_theta/2),u=L0(te(e,"d")),h=EE(u);t.push(n[0],n[1],s[5],s[6],c[0],c[1],h.x,h.y);break}return t},set:function(e,t,i,r,n,s){if(r===0&&n===0){s&&te(e,{d:s});return}let a,o,l,c=t?t.slice(0):Mn.path_arc2.get(e);if(i===3&&(c[0]+=r,c[1]+=n,c[2]+=r,c[3]+=n),i===0&&ni(c[0]+r,c[2])&&ni(c[1]+n,c[3])||i===1&&ni(c[2]+r,c[0])&&ni(c[3]+n,c[1])||i===2&&ni((c[2]-c[0])*(c[5]+n-c[1]),(c[3]-c[1])*(c[4]+r-c[0])))return;if(i===2){if(a=Nm({x:c[0],y:c[1]},{x:c[2],y:c[3]},{x:c[4]+r,y:c[5]+n}),a<4)return;a=Math.sqrt(a)}s&&te(e,"d",s);let u=e.pathSegList.getItem(1),h=u.r1,d=+u.largeArcFlag,p=+u.sweepFlag,f=Ro(c[0],c[1],c[2],c[3]),m=h*h-f/4;i==2?(o=(c[2]-c[0])*(c[5]-c[1])-(c[4]-c[0])*(c[3]-c[1]),c[i*2]+=r,c[i*2+1]+=n,l=(c[2]-c[0])*(c[5]-c[1])-(c[4]-c[0])*(c[3]-c[1]),o*l<0&&(p^=1)):(a=h+(d?1:-1)*(m>0?Math.sqrt(m):0),c[i*2]+=r,c[i*2+1]+=n,f=Ro(c[0],c[1],c[2],c[3])),h=f/(8*a)+a/2,d=h>a?0:1,c[0]=Kp(c[0]),c[1]=Kp(c[1]),h=Kp(h),c[2]=Kp(c[2]),c[3]=Kp(c[3]),te(e,"d","M"+c[0]+","+c[1]+" A"+h+","+h+" 0 "+d+" "+p+" "+c[2]+","+c[3])}},path_arc:{get(e){let{json:t}=k.getById(e),i=t.temp||t,r=mr.get8Dots2(i),n=new _i(i),s=n.vectorCenter();if(wt.isAnchorMode(t.gId)){let a=n.getMiddleAnchor();return{cmdkey:"arc",anchor:[i.x1,i.y1,i.x2,i.y2,a.x,a.y],"solid-circle":[{x:s.x,y:s.y,type:"solid-circle"}]}}return{cmdkey:"arc",bbox:r}},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=k.getById(e.id).json;mr.syncArc(d,h,{updateD:!1})}}};var La=class{constructor(t,i,r,n){this.clicked=!1;this.primitiveId=t,this.position=i,this.cmdKey=r,this.index=n}setClicked(t){return this.clicked=t,t&&ri.renderer.attr(this.dom.id,"fill","var(--selectColor)"),this}getDistance(t){return new j(this.position[0],this.position[1]).distance1(t)}getPrimitiveId(){return this.primitiveId}getX(){return this.position[0]}getY(){return this.position[1]}getIndex(){return this.index}getCmdkey(){return this.cmdKey}mount(){if(this.dom)return;let t=Et("rect",{id:"label-point-"+this.primitiveId+"-"+this.index,x:-.5,y:-.5,width:1,height:1,c_partid:"cdot","strok-width":1,stroke:"var(--selectColor)",fill:"transparent","vector-effect":"non-scaling-stroke"});return H.svgRoot.appendChild(t),this.dom=t,this.zoom(),t}zoom(){let t=4/H.gZoom*2,i=de.scale(t,t).translate(this.position[0],this.position[1]),r=et.getMatrix6FromMatrix(i);ht.updateTransform(r,this.dom)}unmount(){this.clicked||this.dom&&(this.dom.remove(),this.dom=null)}};var I1=class{constructor(){this.data=[];this.primitiveBBox=[]}loadPointsOfRect(t){let i=Li.getDotsForAdsorp(t),r=[],n=i.pop();r.push(new La(t.gId,[n.x,n.y],"rect",-1));for(let s=0;s<4;s++)r.push(new La(t.gId,[i[s].x,i[s].y],"rect",s));return r}loadPointsOfEllipse(t){let i=Ei.getDotsForAdsorp(t.gId),r=[],n=i.pop();r.push(new La(t.gId,[n.x,n.y],"ellipse",-1));let s=i.length;for(let a=4;a<s;a++)r.push(new La(t.gId,[i[a].x,i[a].y],"ellipse",a));return r}loadPointsOfArc(t){let i=[],r=mr.get8Dots2(t),{x:n,y:s,width:a,height:o}=vi(t);i.push(new La(t.gId,[n+a/2,s+o/2],"arc",-1));let l=r.length/2;for(let c=0;c<l;c+=2)i.push(new La(t.gId,[r[c],r[c+1]],"arc",c/2));return i}loadPointsOfText(t){let i=[],{x:r,y:n,width:s,height:a}=sf(t);i.push(new La(t.gId,[r+s/2,n+a/2],"text",-1));let o=Fi.text.get(t),l=o.length/2;for(let c=0;c<l;c+=2)i.push(new La(t.gId,[o[c],o[c+1]],"text",c/2));return i}loadPointsOfImage(t){let i=[],r=Fi.image.get(t),n=new ot,s=r.length/2;for(let o=0;o<s;o+=2){let l=r[o],c=r[o+1];i.push(new La(t.gId,[l,c],"obj",o/2)),n.ext6(l,c)}let a=n.build();return i.push(new La(t.gId,[a.minX+a.width()/2,a.minY+a.height()/2],"obj",-1)),i}loadPointsOfGroup(t){let i=[],r=zn.getGroup8Dots(t),n=r.length/2,s=new ot;for(let o=0;o<n;o+=2){let l=r[o],c=r[o+1];i.push(new La(t.gId,[l,c],"group",o/2)),s.ext6(l,c)}let a=s.build();return i.push(new La(t.gId,[a.minX+a.width()/2,a.minY+a.height()/2],"group",-1)),i}loadPointsByData(t){let i;switch(t.cmdKey){case"rect":{i=this.loadPointsOfRect(t);break}case"ellipse":{i=this.loadPointsOfEllipse(t);break}case"arc":{i=this.loadPointsOfArc(t);break}case"text":{i=this.loadPointsOfText(t);break}case"obj":{i=this.loadPointsOfImage(t);break}case"group":{i=this.loadPointsOfGroup(t);break}case"combination":break;case"dimension":break;case"_runtime":break;default:Kr(t);break}return i}load(){this.data.length=0,this.primitiveBBox.length=0,k.iterator(t=>{if(Nn(t.cmdKey))return;let i=this.loadPointsByData(t);if(!i)return;let r=new ot;for(let n of i)r.ext6(n.getX(),n.getY());r.ext7(this.getToleranceDistance()),this.primitiveBBox.push({eleId:i[0].getPrimitiveId(),bbox:r.build()}),this.data.push(...i)})}zoom(){for(let t of this.data)t.zoom()}getTopLabelPoints(t){let i=[],r=k.getItemOrderSortMap(),n=-1/0,s="";for(let a of t){let o=a.getPrimitiveId(),l=r.get(o);k.getById(o).json.layer===3&&(l=-(r.size-l)),l>n&&(n=l,s=o)}for(let a of t)a.getPrimitiveId()===s&&i.push(a);return i}findNearbyPrimitiveLabelPoint(t,i){let n=new ot().ext6(t,i).ext7(this.getToleranceDistance()).build(),s=[{x:t,y:i},n.LL(),n.LR(),n.UL(),n.UR()],a=new Set;for(let{bbox:l,eleId:c}of this.primitiveBBox){if(!l.isContains1(t,i))continue;let{json:u,cmdKey:h}=k.getById(c),d=Mn.get(u);h==="arc"&&(d=d.bbox),d=d.slice(0,8);let p=[];for(let f=0;f<8;f+=2)p.push({x:d[f],y:d[f+1]});for(let f of s)if(xu(f,p)){a.add(c);break}}let o=[];for(let l of this.data)l.unmount(),a.has(l.getPrimitiveId())&&o.push(l);return o}findNearestLabelPoint(t,i){let r=null,n=1/0,s=this.getToleranceDistance(),a=i.length?i:this.data;for(let o of a){let l=o.getDistance(t);l<n&&l<s&&(n=l,r=o)}return r}getToleranceDistance(){return 4/H.gZoom*2}},ic=new I1;var yg=class{constructor(t){this.map=new Map;this.lastMap=new Map;this.oldLabelPoints=t}transform(t){let i=[];for(let r of this.oldLabelPoints){let n=r.getPrimitiveId(),s=r.getCmdkey(),a=r.getIndex(),o=new j(r.getX(),r.getY()).multiply3(t);i.push(new La(n,[o.x,o.y],s,a))}return this.newLabelPoints=i,this.createMap(),this}getTransformedNode(){let t=new Set,i=new Set,r=[-1,0,1,2,3,4,5,6,7];for(let n of r){let{dx:s,dy:a,primitiveId:o}=this.getOffsetByIndex(n);if(ft(s)&&ft(a))continue;let l={dx:s,dy:a,id:o,index:n};(s||a)&&t.add(l),s===0&&a===0&&i.add(l)}return{moveNode:t,stillNode:i}}createMap(){let t=this.oldLabelPoints.length;for(let i=0;i<t;i++){let r=this.oldLabelPoints[i],n=this.newLabelPoints[i],s=n.getX()-r.getX(),a=n.getY()-r.getY();ni(s,0)&&(s=0),ni(a,0)&&(a=0),this.map.set(r.getIndex(),{dx:s,dy:a,primitiveId:r.getPrimitiveId()})}}getOffsetByIndex(t){let i=this.map.get(t);if(!i)return{};let r=this.lastMap.get(t);return r||(r={dx:0,dy:0}),this.lastMap.set(t,i),{dx:i.dx-r.dx,dy:i.dy-r.dy,primitiveId:i.primitiveId}}};var A1=class{calcuPerpendicular(t,i,r){let n=new j(t.x,t.y),s=new j(i.x,i.y).angle(n),a=new j(i.x,i.y).rotate(n,-s),o=new j(r.x,r.y).rotate(n,-s),l=new j(t.x,o.y).rotate(n,s),c=new j(a.x,o.y).rotate(n,s);return{start:{x:l.x,y:l.y},end:{x:c.x,y:c.y}}}findDimensionByPrimitiveIds(t){let i=new Set;return k.iteratorDimension(r=>{(t.has(r.start.id)||t.has(r.end.id))&&i.add(r)}),Array.from(i)}excludeDimension(t){return k.iteratorDimension(i=>{t.has(i.gId)&&t.delete(i.gId)}),t}changeSelfDimensionSize(t,i){let r=k.getDimension(t),n=new In(r),{offset:{dx:s,dy:a},moveElementId:o,staticElementId:l}=n.updateDistance(i),c=r.start.id,u=n.getDistance(!0),h=i/u,d=h,p=h,f=r.start.primitivePoint,m=r.end.primitivePoint;m.x<f.x&&([f,m]=[m,f]),n.direction==="y"&&f.y<m.y&&([f,m]=[m,f]),n.direction==="x"&&(p=1),n.direction==="y"&&(d=1);let g=ic.loadPointsByData(k.getById(c).json),b=new yg(g),y=de.scale(d,p).setOrigin1(new j(f.x,f.y));b.transform(y);let{moveNode:E,stillNode:S}=b.getTransformedNode(),w=new Vo;w.setNodeVisited(new Set),w.setIgnoreDimension(new Set([t]));let x=w.findDimensionNode(E);if(x===!1)return!1;let I=zt.setSkipCheck(!0);for(let A of x){let{dx:O,dy:R,xNode:M,yNode:F}=A,{canMoveX:G,canMoveY:V}=w.getAllAffectedPrimitivesId(M,F);w.prepareHistory(M,F),M=w.removeXNode(S,M),F=w.removeYNode(S,F),G=w.removeXPrimitive(new Set([c]),G),V=w.removeYPrimitive(new Set([c]),V),w.movePrimitive(O,R,G,V).moveDimension(O,R,M,F)}W2.scale(c,d,p,new j(f.x,f.y)),I()}changeDimensionSize(t,i){let r=k.getDimension(t);if(r.category!=="Constraint")throw new Error("err");let n=new In(r),{offset:{dx:s,dy:a},moveElementId:o,staticElementId:l}=n.updateDistance(i),c=new rt,u=c.searchCombination(r.start.id),h=c.searchCombination(r.end.id),d=!(u&&h&&u===h),p=this.getSideLockedElements(t,o,d),f=this.getSideLockedElements(t,l,d);if(p.length&&f.length){this.toastBothLockMsg(p[0],f[0]);return}if(r.start.id===r.end.id){this.changeSelfDimensionSize(t,i);return}p.length&&(o=l,s*=-1,a*=-1);let m=r.end.id===o?r.start.id:r.end.id,g=new Vo;g.setIgnoreDimension(new Set([t])),g.findDimensionNodeByPrimitiveId(new Set([o]));let{all:b,canMoveX:y,canMoveY:E}=g.getAllAffectedPrimitivesId();b.add(t);let S=r.direction,w=new rt,x=w.searchCombination(m),I=w.searchCombination(o);if(x&&I&&x==I&&(y=g.getMoveIdsInCom(m,o,x).canMoveX,E=g.getMoveIdsInCom(m,o,x).canMoveY),S==="y"&&E.has(m)){this.toastMsg();return}if(S==="x"&&y.has(m)){this.toastMsg();return}if(S==="xy"&&b.has(m)){this.toastMsg();return}let A=zt.setSkipCheck(!0);g.prepareHistory().movePrimitive(s,a).moveDimension(s,a),A()}toastMsg(){H.windowBridge.publish("ui/toastMsg",{type:"warn",msg:"This change will lead to over definition or no solution, modification failed.",timer:3},ut())}updateCategory(t,i){te(le(t),"category",i)}getSideLockedElements(t,i,r=!0){let n=new Set([t]),s=new Vo;s.setIgnoreDimension(n).findDimensionNodeByPrimitiveId(new Set([i]));let{all:a}=s.getAllAffectedPrimitivesId(void 0,void 0,r),o=Oa(),l=new Map;for(let{elements:u,combinationId:h}of o)for(let d of u)if(h&&r){let p=k.getCombination(h).locked;l.set(d,{combinationId:h,id:d,cmdkey:"combination",locked:p})}else{let{cmdKey:p,json:f}=k.getById(d);l.set(d,{id:d,cmdkey:p,locked:f.locked})}let c=[];for(let u of a){let h=l.get(u);h.locked&&c.push(h)}return c}dimensionBothSideIsLocked(t){let i=this.dimensionInOneCombination(t),r=this.getSideLockedElements(t.gId,t.start.id,!i),n=this.getSideLockedElements(t.gId,t.end.id,!i);return{left:r,right:n}}dimensionInOneCombination(t){let i=k.getCombination(),{start:r,end:n}=t;return!!Object.values(i).find(({elements:s=[]})=>s.includes(r.id)&&s.includes(n.id))}toastBothLockMsg(t,i){let{json:r}=k.getById(t.id);if(t.cmdkey==="combination"&&i.cmdkey==="combination"&&t.id===i.id){ls({value:"{0} {a} are currently locked.Please unlock first.",options:{a:r.name,0:Xi[t.cmdkey]},translateOptionKeys:[0]},"warn");return}if(t.id===i.id&&t.cmdkey!=="combination"){let s=r.name;s&&(s=":"+s),ls({value:"{0} {a} are currently locked.Please unlock first.",options:{a:r.id.slice(1)+s,0:Xi[t.cmdkey]},translateOptionKeys:[0]},"warn");return}let n=k.getById(i.id).json;ls({value:"Both {0} {a} and {1} {b} are currently locked.Please unlock them first.",options:{a:t.cmdkey==="combination"?r.name:r.id.slice(1),b:i.cmdkey==="combination"?n.name:n.id.slice(1),0:Xi[t.cmdkey],1:Xi[i.cmdkey]},translateOptionKeys:[0,1]},"warn")}isInSameCombination(t){let r=new q2().getPrimitiveMapComb(),n=r.get(t.start.id).combinationId,s=r.get(t.end.id).combinationId;return!!(n&&s&&n===s)}dblclickHandler(t){if(t.category==="Annotation")return;let i=this.dimensionBothSideIsLocked(t),r=new rt,n=r.searchCombination(t.start.id),s=r.searchCombination(t.end.id);if(i.left.length&&i.right.length)if(n&&s&&n===s){let{cmdKey:c,json:u}=k.getById(t.start.id),{cmdKey:h,json:d}=k.getById(t.end.id);if(u.locked&&d.locked){this.toastBothLockMsg({id:t.start.id,cmdkey:c,locked:!0},{id:t.end.id,cmdkey:h,locked:!0});return}}else{this.toastBothLockMsg(i.left[0],i.right[0]);return}let a=Xa();if(a["all-element-type"].dimension.checked===!1||a["all-element-type"].dimension.visible===!1)return;let o=new In(t),l={name:"",object:{startId:t.start.id,endId:t.end.id},type:o.getCategory(),size:lt(o.getDistance(),2),overed:!1,hide:["name","obj","category"],id:t.gId,created:!1};k.compilerManager.pauseDateMerge(),Ce("panel/open-smart-dimension-dialog",[l])}updateDimensionData(t,i){$e(i,"attr-dimension")&&this.changeDimensionSize(t,i["attr-dimension"]);let r=k.getDimension(t);if($e(i,"attr-dimension-category")){let n=i["attr-dimension-category"];r.category=n,this.updateCategory(t,n)}$e(i,"attr-name")&&(r.name=i["attr-name"])}},ts=new A1;var In=class extends Pu{constructor(i){super();this.startNextXMove=void 0;this.startNextYMove=void 0;this.endNextXMove=void 0;this.endNextYMove=void 0;this.visible=!0;this.nextTickTasks=[];this.gId=i.gId,this.direction=i.direction,this.category=i.category,this.start=i.start,this.end=i.end,this.staticStart=structuredClone(this.start),this.staticEnd=structuredClone(this.end),this.container=le(i.gId);let r=this.start.otherPoint,n=this.end.otherPoint;this.visible=i.visible;let s=new j(r.x,r.y).distance1(new j(n.x,n.y));this.distancePixel=s,this.distance=Qs(s)}getId(){return this.gId}getDistance(i=!1){return i?this.distancePixel:this.distance}getCategory(){return this.category}isSelfDimension(){return this.start.id===this.end.id}categoryIsConstraint(){return this.category==="Constraint"}categoryIsAnnotation(){return this.category==="Annotation"}getDirection(){return this.direction}getPrimitiveType(){let{cmdKey:i}=this.end,{cmdKey:r}=this.start;return{primitiveTypeEnd:Xi[i],primitiveTypeStart:Xi[r]}}toJSON(){let i=k.getDimension(this.gId),r={name:"",gId:this.gId,layer:8,cmdKey:"dimension",direction:this.direction,category:this.category,start:structuredClone(this.start),end:structuredClone(this.end)};return Mt(i)?{...r,locked:!1,visible:!0}:(Object.assign(i,r),i)}canMoveX(){return this.direction==="x"||this.direction==="xy"}canMoveY(){return this.direction==="y"||this.direction==="xy"}getPath(){let i=this.renderNodeLine(this.start,this.gId+"-start-line",!0),r=this.renderNodeLine(this.end,this.gId+"-end-line",!0),n=this.renderTextLine(!0),s=this.createStartTriangle(),a=this.createEndTriangle(),o=this.renderText(!0);return{line:i+r+n+["M",te(s,"points")].join(" ")+["M",te(a,"points")].join(" "),text:o}}render(i=!1){let r=this.container,n=this.renderNodeLine(this.start,this.gId+"-start-line"),s=this.renderNodeLine(this.end,this.gId+"-end-line"),a=this.renderTextLine(),o=this.renderText(),l=this.createStartTriangle(),c=this.createEndTriangle();if(this.container||(r=Et("g",{id:this.gId,c_partid:"dimension",layer:8,category:this.category,display:this.visible?"":"none"}),this.container=r,!i&&Qe.appendTargetLayer(r,8),r.appendChild(n),r.appendChild(s),r.appendChild(a),r.appendChild(o),r.appendChild(l),r.appendChild(c)),this.nextTick(),i||ri.renderer.attr(this.gId,"category",this.category),i)return this.container.outerHTML}makeOtherPointStatic(){this.addNextTickTasks([()=>{this.start.otherPoint=structuredClone(this.staticStart.otherPoint),this.end.otherPoint=structuredClone(this.staticEnd.otherPoint)}])}addNextTickTasks(i){this.nextTickTasks.push(...i)}nextTick(){Promise.resolve().then(()=>{for(let i of this.nextTickTasks)i()})}getSvg(){return this.render(!0)}unmount(){return ri.renderer.removeNode(this.gId),this}translate(i,r){return this.incrementEndNode(i,r),this.incrementStartNode(i,r),this.start.otherPoint.x+=i,this.start.otherPoint.y+=r,this.end.otherPoint.x+=i,this.end.otherPoint.y+=r,this}updateOtherP(i,r){if(this.direction==="x")this.start.otherPoint.y+=r,this.start.otherPoint.x=this.start.primitivePoint.x,this.end.otherPoint.y+=r,this.end.otherPoint.x=this.end.primitivePoint.x;else if(this.direction==="y")this.start.otherPoint.x+=i,this.start.otherPoint.y=this.start.primitivePoint.y,this.end.otherPoint.x+=i,this.end.otherPoint.y=this.end.primitivePoint.y;else{let n=this.start.otherPoint.x+i,s=this.start.otherPoint.y+r,a=ts.calcuPerpendicular(this.start.primitivePoint,this.end.primitivePoint,{x:n,y:s});this.start.otherPoint=a.start,this.end.otherPoint=a.end}this.render()}incrementStartNode(i,r){return this.start.primitivePoint.x+=i,this.start.primitivePoint.y+=r,this}incrementEndNode(i,r){return this.end.primitivePoint.x+=i,this.end.primitivePoint.y+=r,this}updateStartNode(i){return this.start=i,this}updateEndNode(i){return this.end=i,this}updateType(i){return this.direction=i,this}renderNodeLine(i,r,n=!1){r=r!=null?r:i.id;let s=this.extendPoint(i.primitivePoint,i.otherPoint,10);return n?["M",s.x,s.y,i.primitivePoint.x,i.primitivePoint.y].join(" "):this.renderLine(s,i.primitivePoint,r)}renderTextLine(i=!1){let r=this.start.otherPoint,n=this.end.otherPoint;return i?["M",r.x,r.y,n.x,n.y].join(" "):this.renderLine(r,n,this.gId+"-text-line")}createEndTriangle(){let i=new j(this.start.otherPoint.x,this.start.otherPoint.y),r=new j(this.end.otherPoint.x,this.end.otherPoint.y),n=r.angleD(i);return this.createTriangle([[-5,-5],[0,0],[-5,5]],n,r,this.gId+"-end-triangle")}createStartTriangle(){let i=new j(this.start.otherPoint.x,this.start.otherPoint.y),n=new j(this.end.otherPoint.x,this.end.otherPoint.y).angleD(i);return this.createTriangle([[5,-5],[0,0],[5,5]],n,i,this.gId+"-start-triangle")}getTextMatrix(){let i=this.container?this.container.querySelector("text"):Et("text",{x:0,y:0}),r=this.start.otherPoint,n=this.end.otherPoint,s=new j(r.x,r.y).distance1(new j(n.x,n.y)),a=lt(Qs(s),2);this.distance=a,i.textContent=a+"mm";let o=i.getBBox();!o.width&&!o.height&&(o=this.getTextBBox(i.textContent));let l={x:(r.x+n.x)/2,y:(r.y+n.y)/2},c=new j(r.x,r.y),u=new j(n.x,n.y).angleD(c);n.x<r.x&&(c=new j(n.x,n.y),u=new j(r.x,r.y).angleD(c));let h=de.translate(l.x-o.width/2,l.y-o.height/2).rotateD(u).setOrigin(l.x,l.y);return h=h.multiply3(de.scale(.5,.5).setOrigin(l.x,l.y)),{bbox:o,matrix:h,text:i}}getTextBBoxOutline(){let{matrix:i,bbox:r}=this.getTextMatrix(),n=St.extendRect(r),s=[];for(let a of[n.LL(),n.UL(),n.UR(),n.LR()])s.push(a.multiply3(i));return s}renderText(i=!1){let{matrix:r,text:n}=this.getTextMatrix();if(i)return{textContent:n.textContent,m3:r};let s=et.getMatrix6FromMatrix(r);return ht.updateTransform(s,n),n}updateDistance(i){let r=new j(this.start.otherPoint.x,this.start.otherPoint.y),n=new j(this.end.otherPoint.x,this.end.otherPoint.y),s=this.end.id,a=this.start.id;if(this.end.otherPoint.x<this.start.otherPoint.x){let u=r;r=n,n=u,s=this.start.id,a=this.end.id}if(this.direction==="y"&&this.end.otherPoint.y>this.start.otherPoint.y){let u=r;r=n,n=u,s=this.start.id,a=this.end.id}let o=n.angleD2(r);this.direction==="xy"&&o===0&&(o=new j(this.start.primitivePoint.x,this.start.primitivePoint.y).angleD2(r)+90);let l=new j(i+r.x,r.y).rotateD(r,o);return{offset:{dx:l.x-n.x,dy:l.y-n.y},moveElementId:s,staticElementId:a}}};function bs(e,t,i){switch(i=t.gId||i,e){case"rect":return C1(t,i);case"group":return fl(t,i);case"ellipse":return D1(t,i);case"text":return bg(t,i);case"obj":return _1(t,i);case"dimension":return CC(t,i);case"auxiliaryLine":return P1(t,i);case"auxiliaryPoint":return af(t,i);case"dimensionLength":return oQ(t,i);case"dimensionAngle":return lQ(t,i);case"dimensionRadius":return cQ(t,i);case"arc":return _h(t,i);default:console.error(e);break}}function C1(e,t){if(!e||Mt(e)){dt(le(t)),k.setRect(t);return}let i=Rn.rect(e),r=Rs(i),n=le(t);return n?n.replaceWith(r):Qe.appendTargetLayer(r,e.layer),k.setRect(t,e),le(t)}function fl(e,t){if(t=t||e.gId,!e||Mt(e)){dt(le(t)),k.setGroup(t);return}let i=Rn.group(e),r=Rs(i),n=le(t);return n?n.replaceWith(r):Qe.appendTargetLayer(r,e.layer),k.setGroup(t,e),le(t)}function D1(e,t){if(!e||Mt(e)){dt(le(t)),k.setEllipse(t);return}let i=Rn.ellipse(e),r=Rs(i),n=le(t);return n?n.replaceWith(r):Qe.appendTargetLayer(r,e.layer),k.setEllipse(t,e),le(t)}function _h(e,t){if(t=e.gId||t,!e||Mt(e)){ri.renderer.removeNode(t),k.setArc(t);return}let i=Rn.arc(e),r=document.getElementById(t),n=Rs(i);return r?r.replaceWith(n):Qe.appendTargetLayer(n,e.layer),k.setArc(t,e),le(t)}function bg(e,t){if(!e||Mt(e)){dt(le(t)),k.setText(t);return}let i=Rn.text(e),r=Rs(i),n=le(t);return n?n.replaceWith(r):Qe.appendTargetLayer(r,e.layer),k.setText(t,e),le(t)}function _1(e,t){if(t=t||e.gId,!e||Mt(e)){dt(le(t)),k.setObj(t);return}let i=Rn.obj(e),r=Rs(i),n=le(t);return n?n.replaceWith(r):Qe.appendTargetLayer(r,e.layer),k.setObj(t,e),le(t)}function CC(e,t){if(t=t!=null?t:e.gId,!e||Mt(e)){dt(le(t)),k.setDimension(t);return}let i=Rn.dimension(e),r=Rs(i),n=le(t);n?n.replaceWith(r):Qe.appendTargetLayer(r,e.layer),k.setDimension(t,e);let s=new In(e).render();return s=null,le(t)}function oQ(e,t){if(t=t||e.gId,!e||Mt(e)){dt(le(t)),k.setDimension(t,{},"dimensionLength");return}let i=le(t),r=new xn(e).getContainer();return i?i.replaceWith(r):Qe.appendTargetLayer(r,e.layer,!0,{cmdKey:"dimensionLength"}),new xn(e).render(),k.setDimension(t,e,"dimensionLength"),r}function lQ(e,t){if(t=t||e.gId,!e||Mt(e)){dt(le(t)),k.setDimension(t,{},"dimensionAngle");return}let i=le(t),r=new bn(e).getContainer();return i?i.replaceWith(r):Qe.appendTargetLayer(r,e.layer,!0,{cmdKey:"dimensionAngle"}),k.setDimension(t,e,"dimensionAngle"),r}function cQ(e,t){if(t=t||e.gId,!e||Mt(e)){dt(le(t)),k.setDimension(t,{},"dimensionRadius");return}let i=le(t),r=new cn(e).getContainer();return i?i.replaceWith(r):Qe.appendTargetLayer(r,e.layer,!0,{cmdKey:"dimensionRadius"}),k.setDimension(t,e,"dimensionRadius"),r}function P1(e,t){if(t=t!=null?t:e.gId,!e||Mt(e)){dt(le(t)),k.setAuxiliaryLine(t);return}let i=Rn.auxiliaryLine(e),r=Rs(i),n=le(t);if(!n)Qe.appendTargetLayer(r,e.layer);else{let s=Ae.isSelected(n);n.replaceWith(r),s&&(Ae.unselect(n),Ae.select([r]))}return k.setAuxiliaryLine(t,e),I2([{data:e,view:le(t)}],St.extendRect(H.svgRoot.viewBox.animVal)),le(t)}function af(e,t){if(t=t!=null?t:e.gId,!e||Mt(e)){dt(le(t)),k.setAuxiliaryPoint(t);return}let i=Rn.auxiliaryPoint(e),r=Rs(i),n=le(t);if(!n)Qe.appendTargetLayer(r,e.layer);else{let s=Ae.isSelected(n);n.replaceWith(r),s&&(Ae.unselect(n),Ae.select([r]))}return k.setAuxiliaryPoint(t,e),og(le(t),ph/H.gZoom),le(t)}var ai=class{static hasVisible(t){for(let i of t){let r=k.getById(i).json;if(!this.eleIsHide(r))return!0}return!1}static hasHidden(t){for(let i of t){let r=k.getById(i).json;if(this.eleIsHide(r))return!0}return!1}static eleIsHide(t){var c;if(!t)return!1;let i=t.cmdKey;if(!t.visible)return!0;let r=new rt,n=r.searchCombination(t.gId);if(n&&r.findFamily(n).getAllParents().some(d=>k.getCombination(d).visible===!1)||((c=Qe.getCurrentScheme())==null?void 0:c.options.some(u=>+u.id==+t.layer&&!u.visible)))return!0;let a=Xa();if(a["all-element-type"][d1(i)].visible===!1)return!0;let{hide:o,locked:l}=t;return!!(a["all-state"].hide.visible===!1&&o||a["all-state"].visible.visible===!1&&!o||a["all-state"].lock.visible===!1&&l||a["all-state"].unlock.visible===!1&&!l)}static applyElementsVisible(t){let i=k.getById(t).json,r=this.eleIsHide(i);ri.renderer.attr(t,"display",r?"none":"")}static toggleElementsDisplay(t,i){let{elements:r,combinations:n}=new rt().getSelectedCombinations(t),s=new oi;for(let o of r)s.addOne(k.getById(o).json),k.getById(o).json.visible=i,this.applyElementsVisible(o);let a=new rt;for(let o of n){s.addOneCombineByComId(o);let l=k.getCombination(o);l.visible=i;let c=a.getAllElesfromTop(o).elements;for(let u of c)s.addOne(k.getById(u).json),this.applyElementsVisible(u)}s.updateAndSave()}static showAll(){let t=new oi;k.iteratorCombination(n=>{n.visible===!1&&(t.addOneCombineByComId(n.gId),n.visible=!0)});let i=jt(Qe.currentScheme);i.options.forEach(n=>{n.visible=!0}),Qe.apply(i),Ce("setFilterConfig"),Ce("syncActivePanelLayerContent"),k.getItemOrder().forEach(n=>{let{json:s,cmdKey:a}=k.getById(n),{visible:o}=s;o===!1&&(t.addOne(s),s.visible=!0,bs(a,s))}),t.updateAndSave()}static isEyeGray(t,i){var f;let{layer:r,gId:n,locked:s,hide:a}=t||{},o=new rt,l=o.searchCombination(n),c=!1,u=!1,h=!1,d=Xa();l&&(c=o.findFamily(l).getAllParents().some(g=>k.getCombination(g).visible===!1)),(f=Qe.getCurrentScheme())==null||f.options.forEach(m=>{m.id===r&&!m.visible&&(u=!0)}),h=!d["all-element-type"][d1(i)].visible;let p=!1;return d["all-state"].hide.visible===!1&&a&&(p=!0),d["all-state"].visible.visible===!1&&!a&&(p=!0),d["all-state"].lock.visible===!1&&s&&(p=!0),d["all-state"].unlock.visible===!1&&!s&&(p=!0),{combination:c,filter:h||p,layer:u}}static isCombinaionEyeGray(t){let r=new rt().findFamily(t).getAllParents();return r.shift(),{combination:r.some(s=>k.getCombination(s).visible===!1)}}static toggleVisible(t,i){var n;let r=k.getById(t).json;r.visible=i!=null?i:!r.visible,((n=pi.currentHoverEle)==null?void 0:n.id)===t&&(r.visible?pi.createHighlightStyle(pi.currentHoverEle):pi.removeHighlightStroke()),this.applyElementsVisible(t)}};ai=Ws([Pa(Sn.eleVisable)],ai);function SB(e){let{layer:t=1,scope:i=1,opacity:r=1,fontSize:n=12,strokeColor:s="",fontFamily:a="",underline:o="none",italic:l="normal",fontWeight:c="normal",d:u,gId:h,hide:d,name:p,cover:f,locked:m,hAlign:g,vAlign:b,rotation:y,cacheWidth:E,cacheHeight:S,isWhiteBackground:w}=e,x={layer:t,opacity:r,locked:m,rotation:y,id:h,transform:ht.getTransformStr(e.matrix),scope:i,hide:d?1:0,cover:f?1:0,white:w?1:0,c_partid:"part_text","h-align":g,"v-align":b,"font-style":l,"font-size":n,"font-family":a,"font-weight":+c==1?"bold":"normal","text-decoration":o,display:ai.eleIsHide(e)?"none":""};return t==2&&(r=of(+e.transparencyPrint*100,+e.transparencyWhite*100),x.opacity=r),`<g ${Object.entries(x).map(([A,O])=>`${A}="${yu(String(O))}"`).join(" ")}>
        <rect class="hitbox" stroke="none" fill="transparent" x="0" y="${-S}" width="${E}" height="${S}"></rect>
        <path class="primitive-text" d="${u}" stroke-width="0" stroke="none" fill="${s}"/>
    </g>`}var DC=class{constructor(t){this.elm=t;this.rectElm=_r("rect.hitbox",t),this.pathElm=_r("path",t),this.data=k.getText(t.id)}async name(t){if(t=_0(t),t.length>4096)return H.windowBridge.publish("ui/toastMsg",{type:"error",msg:"Text cannot be more than 4096 characters!",timer:3},ut());await this.syncTextFont({name:t}),this.data.name=t,this.data.key=t,fr([this.elm],{create8Dots:!0})}strokeColor(t){te(this.pathElm,{fill:t,stroke:t})}async fontFamily(t){await this.syncTextFont({fontFamily:t}),this.data.fontFamily=t}async fontWeight(t){await this.syncTextFont({fontWeight:t}),this.data.fontWeight=t==="bold"}async italic(t){await this.syncTextFont({fontStyle:t}),this.data.italic=t==="italic"}async fontSize(t){await this.syncTextFont({fontSize:t}),this.data.fontSize=t}async underline(t){let i=t==="underline"?"underline":"normal";await this.syncTextFont({underline:i}),this.data.underline=i==="underline"}async getTextPathInfo(t){let{underline:i,fontFamily:r,key:n,fontWeight:s,fontSize:a,italic:o}=this.data,l=t.text||t.name||n,h=Object.assign({fontFamily:r,fontSize:a,fontStyle:o?"italic":"normal",fontWeight:s?"bold":"normal",underline:i?"underline":"normal",x:0,y:0},t);return await new _u().getPath(l,h)}async syncTextFont(t){let{d:i,bbox:r}=await this.getTextPathInfo(t),n=r.height(),s=r.width();te(this.rectElm,{y:-n,width:s,height:n}),te(this.pathElm,"d",i),this.data.cacheWidth=s,this.data.cacheHeight=n,this.data.d=i}},J2=DC,_C=class{getTextPostion(t){let{matrix:i}=t,r=t.cacheWidth,n=t.cacheHeight,s=ht.createMatrixFrom6(i),{x:a,y:o}=this.getTextOrigin(t.gId),l=new j(-a,-o).multiply3(s),c=new j(0,-n).multiply3(s),h=new j(r,0).multiply3(s).distance1(l),d=c.distance1(l),p=sf(t);return{x:l.x,y:l.y,width:p.width,height:p.height,initWidth:r,initHeight:n,currentWidth:h,currentHeight:d}}getTextOrigin(t,i,r,n){n=n||k.getText(t),ft(i)&&(i=n.hAlign),ft(r)&&(r=n.vAlign);let s=n.cacheWidth,a=n.cacheHeight,o=0;switch(i){case 1:o=-s/2;break;case 2:o=-s;break}let l=a;switch(r){case 1:l=a/2;break;case 2:l=0;break}return{x:o,y:l}}syncTextWithOrigin(t,i,r){let n=this.getTextOrigin(t.gId),s=this.getTextOrigin(t.gId,i,r),a=s.x-n.x,o=s.y-n.y;if(a===0&&o===0)return;let l=de.translate(a,o);this.syncText(t,l,{updateMatrix:!0,reverse:!0})}syncTextWithRotation(t,i,r){let n=this.getRotationMatrix(t,i,r);n&&this.syncText(t,n,{updateMatrix:!0,fn(){t.rotation=+i.toFixed(2)}})}getRotationMatrix(t,i,r){let n=ht.createMatrixFrom6(t.matrix),{x:s,y:a}=this.getTextOrigin(t.gId),o=r||new j(-s,-a).multiply3(n),l=t.rotation||0,c=Math.round((i-l)*100)/100;if(c)return de.rotateD(c).setOrigin1(o)}sync(t,i,r){let n=ht.createMatrixFrom6(t.matrix),s=n.multiply3(i);r.reverse&&(s=i.multiply3(n));let a=et.getMatrix6FromMatrix(s);r.updateMatrix&&(t.matrix=a),t.tempMatrix=a,ht.updateTransform(a,le(t.gId))}syncText(t,i,r){let n=zt.checkOne("text",t,i);n!==!1&&zt.addCallBack(()=>{var s;Bp(n)&&n(),this.sync(t,i,r),(s=r==null?void 0:r.fn)==null||s.call(r)})}syncTextWidthScale(t,i,r){let n=t.id,s=k.getText(n),a=ht.createMatrixFrom6(s.matrix),o=this.getTextPostion(t),l=i*o.initWidth,c=r*o.initHeight,u=l/o.currentWidth,h=c/o.currentHeight;ft(i)&&(u=1),ft(r)&&(h=1);let d=this.getTextOrigin(n),p=new j(-d.x,-d.y).multiply3(a),f=de.scale(u,h).setOrigin1(p);this.syncText(t,f,{updateMatrix:!0})}syncTextSize(t,i,r,n){let{width:s,height:a}=this.getTextPostion(t),o=1,l=1;if(Kn(i)&&(o=i/s),Kn(r)&&(l=r/a),o===1&&l===1)return;if(!n){let{x:u,y:h}=this.getTextOrigin(t.gId),d=ht.createMatrixFrom6(t.matrix);n=new j(-u,-h).multiply3(d)}let c=de.scale(o,l).setOrigin1(n);this.syncText(t,c,{updateMatrix:!0})}resetText(t){let i=t.id,r=k.getText(i),{matrix:n,rotation:s}=r,a=et.createMatrixFrom6(n),{x:o,y:l}=this.getTextOrigin(i),c=new j(-o,-l).multiply3(a),u=de.translate(o,l).scale(1,1).rotateD(s).translate1(c),h=et.getMatrix6FromMatrix(u);r.matrix=h,delete r.tempMatrix,ht.updateTransform(h,t)}syncTextPosition(t,i,r){let{x:n,y:s}=vi(t,"text");i=Kn(i)?i:n,r=Kn(r)?r:s;let a=i-n,o=r-s;if(!a&&!o)return;let l=de.translate(a,o);this.syncText(t,l,{updateMatrix:!0})}getTextForAttrs(t){let{x:i,y:r,width:n,height:s}=this.getTextPostion(t);return{x:i,y:r,width:n,height:s}}},xr=new _C;var uQ=nl(()=>{new Ni().updateHole()}),K2=null,Ni=class{constructor(){this.container=le("combination-container")}setMask(t){K2=t}getMask(){return K2}removeMask(){dt(K2),K2=null,this.removeUseEle()}removeUseEle(){for(;this.container.firstChild;)dt(this.container.firstChild)}zoom(){this.getMask()&&this.updateHole()}hoistPrimitives(t){for(let i of k.getItemOrder())if(t.includes(i)){let r="use-"+i;if(!_r("#"+r,this.container)){let s=Et("use",{href:"#"+i,id:r});this.container.appendChild(s)}}}updateHole(t=!1){let i=wt.isEditingPath();if(i)return this.updateHoleForPath(i);if(!Wt.isEditing())return;let r=this.getMask()||this.createMask();this.setMask(r),t&&this.removeUseEle();let n=Wt.getCurrentEditingComId(),s=new rt,a=Array.from(s.getAllElesfromTop(n).elements),o=k.getAllAssistPrimitive();this.hoistPrimitives([...a,...o]);let l=a.map(u=>le(u)),c={x:0,y:0,width:0,height:0};l.length&&(c=Rr(l)),this.innerUpdateHole(c,r)}updateHoleForPath(t){let{json:i,cmdKey:r}=k.getById(t);if(Mt(i))return wt.endEditingPath();let{x:n,y:s,width:a,height:o}=vi(i,r);r==="arc"&&({x:n,y:s,width:a,height:o}=new Cd(i).bboxEllipse());let l=new ot().ext5(n,n+a,s,s+o).ext7(no()).build(),c=this.getMask()||this.createMask();this.setMask(c);let u=kc(l);this.innerUpdateHole(u,c),_i.createHalfArc(t);let h=k.getAllAssistPrimitive();this.hoistPrimitives(h)}innerUpdateHole(t,i){let{x:r,y:n,width:s,height:a}=es(H.svgRoot),o=[r,n,r+s,n,r+s,n+a,r,n+a],{x:l,y:c,width:u,height:h}=t,d=[{x:l,y:c},{x:l+u,y:c},{x:l+u,y:c+h},{x:l,y:c+h}],p=["M",r,n,"L"].join(" ")+o.join(" ")+["M",l,c,"L"].join(" ")+d.reverse().map(f=>[f.x,f.y]).flat().join(" ");te(i,"d",p)}createMask(){let t=Et("path",{id:"panel-mask",d:"",fill:"black",opacity:.2});return H.svgRoot.insertBefore(t,this.container),t}};Ni.updateHole=uQ;function PC(){var t,i,r,n;return((n=(r=(i=(t=H)==null?void 0:t.profileSetting)==null?void 0:i.commSystemSetting)==null?void 0:r.SYSTEM)==null?void 0:n.dragMiddleMouseButton)==="moveCanvas"}var lf=class lf extends Cu{constructor(){super(...arguments);this.start=!1;this.lastX=0;this.lastY=0;this.lastMove=0;this.startX=0;this.startY=0;this.afterMidUp=gu}static setViewBox(i,r){let n=H.gZoom,s=Xt.getViewBox();s[0]-=i/n,s[1]-=r/n,Xt.setViewBox(s)}startGrabCanvas(i){return this.lastX=i.mouseX,this.lastY=i.mouseY,this.helperCursorBefore=H.helperCursor,pr("grabbing"),()=>{pr(),this.start=!1}}onMouseMidDown(i){i.originalEvent.preventDefault(),PC()?this.afterMidUp=this.startGrabCanvas(i):(this.lastX=i.mouseX,this.lastY=i.mouseY,this.startX=i.mouseX,this.startY=i.mouseY)}onMouseMidUp(i){this.afterMidUp()}onMouseRightDown(i){this.startGrabCanvas(i)}onMouseRightUp(i){if(H.helperCursor=="grabbing"){let r=this.helperCursorBefore;r?this.rootcursor?pr(r,!0):pr(r):pr()}if(this.start)return this.start=!1,lf.dragpanning=!0,setTimeout(function(){lf.dragpanning=!1},5),fh}onMouseMove(i){if(this.moveCanvasCore(i),this.start)return fh}moveCanvasCore(i){(i.mouseRightMoving||i.mouseMidMoving&&PC())&&this.moveCanvas(i),i.mouseMidMoving&&!PC()&&this.zoomCanvas(i)}moveCanvas(i){let r=performance.now();if(r-this.lastMove>30){this.start=!0;let n=i.mouseX-this.lastX,s=i.mouseY-this.lastY;Ar.canStart=!1,lf.setViewBox(n,s),this.lastX=i.mouseX,this.lastY=i.mouseY,this.lastMove=r,new Ni().updateHole()}}zoomCanvas(i){let r=performance.now();if(r-this.lastMove>8){let n=i.mouseY-this.lastY,a=H.currZoom,o=n/document.documentElement.offsetHeight;n>0?a=a*(1-o*3):a=a*(-o*3+1);let l={clientX:this.startX,clientY:this.startY};rc(+a,l),this.lastMove=r,this.lastY=i.mouseY}}};lf.dragpanning=!1,lf.ready=!1;var ao=lf;var $2=class{constructor(t,i){this.position=t,this.angles=i}};var Ns=class{constructor(t,i,r,n){this.beLongId=n,this.position=t,this.type=r,this.angles=i}};var Yc=class{constructor(t){this.bbox=t}};var Eg=10,Z2=7,L1=9,wB=3,O1=8,Q2=1,vB="2 3 2",Sg="#FF0000",Ou="drawing",LC=["AuxiliaryPoint","AuxiliaryLineIntersect","BaseCross","Shape","AuxiliaryLine","ExtendLineIntersect","ExtendLine"];var OC=class{getLines(t,i,r){let n=new j(1,0),s=new j(0,1),a=new ie(t.sub(n.mul(r/2)),t.add(n.mul(r/2))),o=new ie(t.sub(s.mul(r/2)),t.add(s.mul(r/2))),l=[a,o];if(i!=null&&i.size)for(let c of i){if(!c)continue;let u=new ie(t.sub(t.add(n).rotate(t,c||0).sub(t).normalize().mul(r/2)),t.add(t.add(n).rotate(t,c||0).sub(t).normalize().mul(r/2))),h=new ie(t.sub(t.add(s).rotate(t,c||0).sub(t).normalize().mul(r/2)),t.add(t.add(s).rotate(t,c||0).sub(t).normalize().mul(r/2)));l.push(u,h)}return l}getOneLine(t,i,r){let n=new j(1,0);return new ie(t.sub(t.add(n).rotateD(t,i||0).sub(t).normalize().mul(r/2)),t.add(t.add(n).rotateD(t,i||0).sub(t).normalize().mul(r/2)))}getLinesIntersectPointInfo(t){let i=[];for(let n=0;n<t.length;n++)for(let s=n+1;s<t.length;s++){if(t[n].a/t[n].b===t[s].a/t[s].b)continue;let a=Gc(t[n],t[s]);for(let o=0;o<a;o+=2){let l=new j(ge[o],ge[o+1]),c=r(l);c?(c.lines[n]=t[n],c.lines[s]=t[s]):i.push({point:l,lines:{[n]:t[n],[s]:t[s]}})}}return i;function r(n){for(let s of i)if(s.point.equals1(n))return s;return null}}targetIdSortHandler(t,i){let r=LC.indexOf(t),n=LC.indexOf(i);return r-n}},cf=new OC;var eS=class{constructor(t,i,r,n){this.baseCrossFlagMgr=n,this.baseDotMgr=i,this.baseShapeMgr=r,this.excludeShapeIdMap=t}deal(t,i,r=Eg/H.gZoom,n){let s,a,o,l=[],c,u=new j(t,i);if([r,s,c]=this.auxPoint(u,r,s,c),s!=null)return{distance:r,position:s,adsorptionCrossFlag:a,adsorptionExtendLine:o,target:c};if([r,s,c,a]=this.shapeDots(n,u,r,s,c,a),[r,s,c,a,l]=this.baseCross(u,r,s,c,a,l),s==null){if([r,s,c,a]=this.auxLine(u,r,s,c,a),s!=null)return{distance:r,position:s,adsorptionCrossFlag:a,adsorptionExtendLine:o,target:c};for(let d of l){let p=Lu.foot(d,u),f=p.distance1(u);f<r&&(r=f,s=p,a=null,o=[d],c="ExtendLine")}let h=cf.getLinesIntersectPointInfo(l);for(let d of h){let p=d.point.distance1(u);p<Z2/H.gZoom&&o&&(r=p,s=d.point,a=null,o=Object.values(d.lines),c="ExtendLineIntersect")}}return{distance:r,position:s,adsorptionCrossFlag:a,adsorptionExtendLine:o,target:c}}auxPoint(t,i,r,n){var a;let s=k.getAuxiliaryPoint();for(let o in s){if((a=this.excludeShapeIdMap)!=null&&a.get(o))continue;let l=le(o);if(o!==Ou&&(!l||te(l,"display")==="none"))continue;let c=s[o],u=new j(c.x,c.y),h=u.distance1(t);h<i&&(i=h,r=u,n={id:o,type:"AuxiliaryPoint"})}return[i,r,n]}auxLine(t,i,r,n,s){var l;let a=k.getAuxiliaryLine(),o=[];for(let c in a){if((l=this.excludeShapeIdMap)!=null&&l.get(c))continue;let u=le(c);if(c!==Ou&&(!u||te(u,"display")==="none"))continue;let h=a[c],d=new j(h.x,h.y),p=d.add1(1,0).rotateD(d,h.rotation),f=new ie(d,p),m=Lu.foot(f,t),g=m.distance1(t);g<i&&(i=g,r=m,s=null,n={id:c,type:"AuxiliaryLine"}),g<Z2/H.gZoom&&o.push(cf.getOneLine(new j(m.x,m.y),h.rotation,(H.svgRoot.width.baseVal.value+H.svgRoot.height.baseVal.value)/H.gZoom))}if(o.length>1){let c=cf.getLinesIntersectPointInfo(o);for(let u of c){let h=u.point.distance1(t);h<Z2/H.gZoom&&(i=h,r=u.point,s=null,n={type:"AuxiliaryLineIntersect"})}}return[i,r,n,s]}shapeDots(t,i,r,n,s,a){var c;let o=new ot().ext6(i.x,i.y).ext7(Eg/H.gZoom).build(),l=this.baseDotMgr.map;for(let u in l){if((c=this.excludeShapeIdMap)!=null&&c.get(u))continue;let h=le(u);if(u!==Ou&&(!h||te(h,"display")==="none")||!o.intersection1(this.baseShapeMgr.getShapeBBox(u).extendOfSize(Eg/H.gZoom)))continue;let d=l[u];for(let p of d){if(t!=null&&t.includes(p.type))continue;let f=p.position.distance1(i);f<=r&&(r=f,n=p.position,s={id:u,type:"Shape"},f<r||!a?a=[{position:p.position,angles:p.angles}]:a.push({position:p.position,angles:p.angles}))}}return[r,n,s,a]}baseCross(t,i,r,n,s,a){for(let o of this.baseCrossFlagMgr.getAllItems()){let l=o.position.distance1(t);l<i&&(i=l,r=o.position,n={type:"BaseCross"},s=null),a.push(...cf.getLines(o.position,o.angles,(H.svgRoot.width.baseVal.value+H.svgRoot.height.baseVal.value)/H.gZoom))}return[i,r,n,s,a]}};var tS=class{constructor(){this.items=[]}getAllItems(){return this.items}add(t){let i=!1,r=this.getRepeatPositionFlag(t);if(r!=null)for(let n of t.angles)r.angles.add(n);else this.items.push(t),i=!0;return this.items.length>L1&&this.items.splice(0,1),i}clear(){this.items.length=0}getRepeatPositionFlag(t){for(let i of this.items)if(t.position.equals1(i.position))return i}};var iS=class{constructor(){this.belongIdMap={}}get map(){return this.belongIdMap}updateDots(t,i){this.belongIdMap[t]=i}removeDots(t){delete this.belongIdMap[t]}getDots(t){return this.belongIdMap[t]}clear(){this.belongIdMap={}}};var rS=class{constructor(){this.map={}}updateShape(t,i){this.map[t]=i}removeShape(t){delete this.map[t]}getShape(t){return this.map[t]}getShapeBBox(t){var i;return(i=this.map[t])==null?void 0:i.bbox}clear(){this.map={}}};var kd=class{};var nS=class extends kd{constructor(i,r){super();this.template=`<circle name="adsorption-point" class="adsorption"  cx="{x}" cy="{y}" r="${wB}" fill="${Sg}" stroke-width="0" transform="scale(${1/H.gZoom})" transform-origin="{x} {y}"></circle>`;this.x=0;this.y=0;this.x=i,this.y=r}getTemplate(){return Rs(this.template.replace(/\{\w+\}/g,i=>this[i.slice(1,i.length-1)]))}};var aS=class extends kd{constructor(i,r){super();this.template=`<path name="adsorption-cross-flag" class="adsorption" d="M {minX} {y} L {maxX} {y} M {x} {minY} L {x} {maxY}" stroke-width="${Q2}" stroke="${Sg}" transform="scale(${1/H.gZoom})" transform-origin="{x} {y}"></path>`;this.x=0;this.y=0;this.minX=0;this.minY=0;this.maxX=0;this.maxY=0;this.x=i,this.y=r,this.minX=i-O1,this.maxX=i+O1,this.minY=r-O1,this.maxY=r+O1}getTemplate(){return Rs(this.template.replace(/\{\w+\}/g,i=>this[i.slice(1,i.length-1)]))}};var oS=class extends kd{constructor(i,r){super();this.template=`<path name="adsorption-extend-line" class="adsorption" d="M {startX} {startY} L {endX} {endY}" stroke-width="${Q2}" stroke-dasharray="${vB}" stroke="${Sg}" transform="scale(${1/H.gZoom})" transform-origin="{x} {y}"></path>`;this.startX=0;this.startY=0;this.endX=0;this.endY=0;this.x=0;this.y=0;let n=r.sub(i).normalize().mul(H.svgRoot.width.baseVal.value+H.svgRoot.height.baseVal.value);i=i.sub(n),r=r.add(n),this.startX=i.x,this.endX=r.x,this.startY=i.y,this.endY=r.y,this.x=(i.x+r.x)/2,this.y=(i.y+r.y)/2}parse(i,r){let n=(H.svgRoot.width.baseVal.value+H.svgRoot.height.baseVal.value)/H.gZoom,a=i.add(new j(0,1)).rotate(i,r).sub(i).normalize(),o=i.sub(a.mul(n)),l=i.add(a.mul(n));this.startX=o.x,this.endX=l.x,this.startY=o.y,this.endY=l.y,this.x=(o.x+l.x)/2,this.y=(o.y+l.y)/2}getTemplate(){return Rs(this.template.replace(/\{\w+\}/g,i=>this[i.slice(1,i.length-1)]))}};var RC=class{json2BaseCache(t,i,r){switch(t){case"ellipse":{let n=Ei.getDotsForAdsorp(i),s=n.pop(),a=new ot;for(let u of n)a.ext2(u);let o=a.build(),l=new Yc(o);return{baseDots:n.map(u=>new Ns(u,new Set,0,i)).concat(new Ns(s,new Set,2,i)),baseShape:l}}case"arc":{let n=new _i(r),s=new ot;for(let c of n.points(1))s.ext2(c);let a=s.build(),o=new Yc(a);return{baseDots:this.getBoxPoints(a).map(c=>new Ns(c,new Set,0,i)).concat(new Ns(n.vectorCenter(),new Set,2,i)).concat(new Ns(n.vectorStart(),new Set,1,i)).concat(new Ns(n.vectorEnd(),new Set,1,i)),baseShape:o}}case"group":{let{d:n}=r,s=new kr(qi(n)),{minX:a,maxX:o,minY:l,maxY:c}=s.bbox(),u=new St(a,o,Math.min(-l,-c),Math.max(-l,-c)),h=new Yc(u),d=this.getBoxPoints(u),p=this.getGroupSelfPoints(i),f=u.center();return{baseDots:d.map(g=>new Ns(g,new Set,0,i)).concat(p.map(g=>new Ns(g.position,g.angles,1,i)),new Ns(f,new Set,2,i)),baseShape:h}}case"rect":{let n=Ph(le(i)),s=new Yc(new St(n.x,n.x+n.width,n.y,n.y+n.height)),a=Li.getDotsForAdsorp(r),o=a.pop();return{baseDots:a.map(c=>new Ns(c,new Set,0,i)).concat(new Ns(o,new Set,2,i)),baseShape:s}}case"text":{let{rotation:n}=r,s=this.getSelfPoints(i),a=new ot().ext3(s.map(u=>u.position)).build(),o=new Yc(a),l=a.center();return{baseDots:s.map(u=>new Ns(u.position,new Set([-((n||0)/180*Math.PI)]),0,i)).concat(new Ns(l,new Set([-((n||0)/180*Math.PI)]),2,i)),baseShape:o}}case"obj":{let{rotation:n}=r,s=this.getSelfPoints(i),a=s.length?new ot().ext3(s.map(u=>u.position)).build():new St(0,0,0,0),o=new Yc(a),l=a.center();return{baseDots:s.map(u=>new Ns(u.position,new Set([-((n||0)/180*Math.PI)]),0,i)).concat(new Ns(l,new Set([-((n||0)/180*Math.PI)]),2,i)),baseShape:o}}default:throw new Error(`Adsorption: Does not support the conversion of json data of type [${t}] to BaseDot/BaseShape`)}}getBoxPoints(t){let i=t.LL(),r=t.LR(),n=t.UR(),s=t.UL(),a=i.add(r).mul(1/2),o=r.add(n).mul(1/2),l=n.add(s).mul(1/2),c=s.add(i).mul(1/2);return[i,a,r,o,n,l,s,c]}getGroupSelfPoints(t){let i=le(t);if(!i)return console.error(`Adsorption: does not exist ${t} shape, can not get self dots`),[];let r=[],n=i.getPathData();for(let a=0;a<n.length;a++){let o=n[a-1],l=n[a+1],{type:c,values:u}=n[a],h=new Set;switch(c){case"A":case"C":case"L":case"Q":case"M":{let d=s(u);if(d.equals1(s(o==null?void 0:o.values)))break;if(c==="L"){let p=d.angle(s(o.values));p&&h.add(p)}if((l==null?void 0:l.type)==="L"){let p=d.angle(s(l.values));p&&h.add(p)}r.push({position:d,angles:h});break}case"Z":break;default:{console.warn(`Adsorption: can not get path data type:${c} of shape:${t}`);break}}}return r;function s(a=[]){return a.length<2?null:new j(a[a.length-2],a[a.length-1])}}getSelfPoints(t){let i=le(t);if(!i)return console.error(`Adsorption: does not exist ${t} shape, can not get self dots`),[];let r=[],n=Fi.get(i,"single"),s={};n.c_helper_lines&&n.c_helper_lines.forEach((a,o,l)=>{let c=l[o-1],{from:u,to:h}=a;!l[o+1]||u-(c==null?void 0:c.to)===1?(s[u*2]=!0,s[u*2+1]=!0):(s[h*2]=!0,s[h*2+1]=!0)});for(let a=0;a<n.length;a+=2){if(s[a])continue;let o=new j(n[a],n[a+1]),l=a<n.length-3&&new j(n[a+2],n[a+3]),c=a>1&&new j(n[a-2],n[a-1]),u=c&&o.angle(c),h=l&&o.angle(l),d=new Set;u&&d.add(u),h&&d.add(h),r.push({position:o,angles:d})}return r}},NC=new RC;var TB={0:"ADSORPTION",1:"UPDATE SHAPE",2:"REMOVE SHAPE",3:"BUILD ALL SHAPE",4:"DRAG ADSORPTION"},lS=class{constructor(){this.RECORD_MAX_SIZE=1e3;this._warnTimes=0;this._adsorptionRecords=[];this._updateRecords=[];this._removeRecords=[];this._setRecords=[];this._dragAdsorptionRecords=[]}get warnTimes(){return this._warnTimes}get adsorptionRecords(){return this._adsorptionRecords.length>this.RECORD_MAX_SIZE&&this._adsorptionRecords.shift(),this._adsorptionRecords}get updateRecords(){return this._updateRecords.length>this.RECORD_MAX_SIZE&&this._updateRecords.shift(),this._updateRecords}get removeRecords(){return this._removeRecords.length>this.RECORD_MAX_SIZE&&this._removeRecords.shift(),this._removeRecords}get setRecords(){return this._setRecords.length>this.RECORD_MAX_SIZE&&this._setRecords.shift(),this._setRecords}get dragAdsorptionRecords(){return this._dragAdsorptionRecords.length>this.RECORD_MAX_SIZE&&this._dragAdsorptionRecords.shift(),this._dragAdsorptionRecords}getRecords(t){switch(t){case 0:return this.adsorptionRecords;case 1:return this.updateRecords;case 2:return this.removeRecords;case 3:return this.setRecords;case 4:return this.dragAdsorptionRecords}}getWarnTime(t){switch(t){case 0:return 16;case 4:return 16;case 1:return 100;case 2:return 100;case 3:return 1e3}}log(t=0){console.log(TB[t]),console.table(this.getRecords(t).map(i=>i+"ms"))}recordStart(t=0){this.getRecords(t).push(new Date)}recordEnd(t=0){let i=this.getRecords(t),r=Number(new Date)-Number(i[i.length-1]);i[i.length-1]=r,r>this.getWarnTime(t)&&this.warn(t,r)}warn(t,i){console.warn(`Adsorption: The ${TB[t]} operate time is too long and it takes ${i}ms`),this._warnTimes++}};var MC=class{constructor(){this.FILTER_SHAPE_KEYS=["ellipse","group","rect","text","obj","arc"];this.baseDotMgr=new iS;this.baseCrossFlagMgr=new tS;this.baseShapeMgr=new rS;this.performanceMonitor=new lS;this._enabled=!0;this.excludeShapeIdMap=new Map;this._coreTool=new eS(this.excludeShapeIdMap,this.baseDotMgr,this.baseShapeMgr,this.baseCrossFlagMgr);this.adsorptionPoints=new Set}get enabled(){return this._enabled}set enabled(t){this._enabled=t,console.log(`PANEL Adsorption: ${t?"enable":"disable"}`)}get adsorptionPointInfo(){return this._adsorptionPointInfo?{...this._adsorptionPointInfo}:null}get currentAdsorptionShapeElement(){var i,r;let t=(r=(i=this._adsorptionPointInfo)==null?void 0:i.target)==null?void 0:r.id;return le(t)}addCrossFlag(t,i=new Set){let r=new $2(t,i);this.baseCrossFlagMgr.add(r)&&this.setCrossFlagHTML(t.x,t.y),this.removeExtraCrossFlagHTML()}updateShapeCache(t,i,r){if(!this.enabled||!this.FILTER_SHAPE_KEYS.includes(i))return;this.performanceMonitor.recordStart(1);let{baseShape:n,baseDots:s}=NC.json2BaseCache(i,t,r);this.baseDotMgr.updateDots(t,s),this.baseShapeMgr.updateShape(t,n),this.performanceMonitor.recordEnd(1)}updateDrawingShapeCache(t,i){if(this.enabled)if(t!=null&&t.length){let r=[];for(let n=0;n<t.length;n+=2){let s=new j(t[n],t[n+1]),a=n<t.length-3&&new j(t[n+2],t[n+3]),o=n>1&&new j(t[n-2],t[n-1]),l=o&&s.angle(o),c=a&&s.angle(a),u=new Set;l&&u.add(l),c&&u.add(c),r.push(new Ns(s,u,i,Ou))}this.baseDotMgr.updateDots(Ou,r),this.baseShapeMgr.updateShape(Ou,new Yc(new ot().ext3(r.map(n=>n.position)).build()))}else this.baseDotMgr.removeDots(Ou),this.baseShapeMgr.removeShape(Ou)}removeShapeCache(t){this.enabled&&(this.performanceMonitor.recordStart(2),this.baseDotMgr.removeDots(t),this.baseShapeMgr.removeShape(t),this.performanceMonitor.recordEnd(2))}setShapeCache(){this.enabled&&(this.performanceMonitor.recordStart(3),ro(k.gJsonCache,(t,i)=>{this.FILTER_SHAPE_KEYS.includes(t)&&ro(i,(r,n)=>{let{baseShape:s,baseDots:a}=NC.json2BaseCache(t,r,n);this.baseDotMgr.updateDots(r,a),this.baseShapeMgr.updateShape(r,s)})}),this.performanceMonitor.recordEnd(3))}clearShapeCache(){this.baseShapeMgr.clear(),this.baseDotMgr.clear()}clearCrossFlagCache(t=!0){this.baseCrossFlagMgr.clear(),t&&this.clearCrossFlagHTML()}adsorption(t,i){if(!this.enabled)return;this.performanceMonitor.recordStart(0),this.clearExtendLineHTML(),this.clearAdsorptionPointHTML();let r=this._adsorptionPointInfo=this.core(t,i),{position:n,adsorptionCrossFlag:s,adsorptionExtendLine:a}=r;if(n!=null){if(s!=null)for(let o of s)this.addCrossFlag(o.position,o.angles);if(a!=null)for(let o of a)this.setExtendLineHTML(o);return this.setAdsorptionPointHTML(n.x,n.y),this.performanceMonitor.recordEnd(0),n}return this.performanceMonitor.recordEnd(0),null}dragAdsorption(t,i,r){var p,f;if(!this.enabled)return;this.performanceMonitor.recordStart(4),this.clearExtendLineHTML(),this.clearAdsorptionPointHTML();let n,s,a,o,l,c=new Map,u=new Map;for(let m of r){let g=this.core(m.x,m.y,s,[1]);g.position!=null&&(g.adsorptionExtendLine?u:c).set(m,g)}let h=Array.from(c.size?c:u).sort((m,g)=>{var b,y;return cf.targetIdSortHandler(m[1].target.type,g[1].target.type)||(((b=g[1].adsorptionExtendLine)==null?void 0:b.length)||0)-(((y=m[1].adsorptionExtendLine)==null?void 0:y.length)||0)||m[1].distance-g[1].distance}),d=h[0];if(((p=d==null?void 0:d[1])==null?void 0:p.position)!=null){s=d[1].distance,a=[d[1].position],o=d[1].adsorptionCrossFlag||[],l=d[1].adsorptionExtendLine||[],n=new j(t,i).add(a[0].sub(d[0])),this._adsorptionPointInfo=d[1];let m=1;for(;((f=h[m])==null?void 0:f[1].distance)===s;)d[1].position.sub(d[0]).equals1(h[m][1].position.sub(h[m][0]))&&(a.push(h[m][1].position),o.push(...h[m][1].adsorptionCrossFlag||[]),l.push(...h[m][1].adsorptionExtendLine||[])),m++}if(a!=null){if(o!=null)for(let m of o)this.addCrossFlag(m.position,m.angles);if(l!=null)for(let m of l)this.setExtendLineHTML(m);for(let m of a)this.setAdsorptionPointHTML(m.x,m.y);return this.performanceMonitor.recordEnd(4),n}return this.performanceMonitor.recordEnd(4),null}core(t,i,r=Eg/H.gZoom,n){return this._coreTool.deal(t,i,r,n)}setAdsorptionPointHTML(t,i){let r=new nS(t,i).getTemplate();H.svgRoot.appendChild(r),this.adsorptionPoints.add(r)}setExtendLineHTML(t){H.svgRoot.appendChild(new oS(t.start(),t.end()).getTemplate())}setCrossFlagHTML(t,i){H.svgRoot.appendChild(new aS(t,i).getTemplate())}clearAdsorptionPointHTML(){for(let t of this.adsorptionPoints)dt(t)}clearExtendLineHTML(){for(let t of Hr('[name="adsorption-extend-line"]',H.svgRoot))t.parentNode.removeChild(t)}clearCrossFlagHTML(){for(let t of Hr('[name="adsorption-cross-flag"]',H.svgRoot))t.parentNode.removeChild(t)}clearAdsorptionHTML(){this.clearCrossFlagCache(),this.clearAdsorptionPointHTML(),this.clearExtendLineHTML()}removeExtraCrossFlagHTML(){let t=Hr('[name="adsorption-cross-flag"]',H.svgRoot);if(t.length>L1){let i=t.length-L1;for(let r=0;r<i;r++)t[r].parentNode.removeChild(t[r])}}boxCenterAddCrossFlag(t){if(this.excludeShapeIdMap.get(t))return;let i=this.baseShapeMgr.getShapeBBox(t);i!=null&&this.addCrossFlag(i.center())}adsorptionHTMLZoom(){Hr(".adsorption",H.svgRoot).forEach(t=>{te(t,"transform",`scale(${1/H.gZoom})`)})}setExcludeShapeIds(t=[]){return ro(t,(i,r)=>{this.excludeShapeIdMap.set(r,!0)}),this}clearExcludeShapeIds(){return this.excludeShapeIdMap.clear(),this}},IB,bt=IB=IB||new MC;var Mg=oy(CB());var uS=class{constructor(t){this.selectedObjs=[];this.selectedDimensionObjs=[];this.selectedIds=Object.create(null);this.drivingDimensions=new Set;this.affectedDimensions=new Set;this.horizontalAuxiliaryLines=new Set;this.verticalAuxiliaryLines=new Set;this.auxiliaryPoints=new Set;this.xMoveEles=new Set;this.yMoveEles=new Set;this.abandonMove=!1;this.dragDimensionDots=[];this.combinationMask=new Ni;for(let a of t.selectItems){if(a.parentId){console.warn(a);let{json:c,cmdKey:u}=k.getById(a.parentId);switch(u){case"dimensionAngle":{let h=new bn(c);h.setControlDotSelected(a.id),this.dragDimensionDots.push(h)}break;case"dimensionLength":{let h=new xn(c);h.setControlDotSelected(a.id),this.dragDimensionDots.push(h)}break;case"dimensionRadius":{let h=new cn(c);h.setControlDotSelected(a.id),this.dragDimensionDots.push(h)}break}continue}let{json:o,cmdKey:l}=k.getById(a.id);if(l==="dimension"?(this.drivingDimensions.add(o),this.selectedDimensionObjs.push(le(a.id))):this.selectedObjs.push(le(a.id)),l==="auxiliaryPoint")this.auxiliaryPoints.add(o);else if(l==="auxiliaryLine")switch(ul(o.rotation)){case"horizontal":this.horizontalAuxiliaryLines.add(o);break;case"vertical":this.verticalAuxiliaryLines.add(o);break}}let i=new Set(this.selectedObjs.map(a=>a.id)),r=this.dimensionMgr=new Vo,n=new Set(i);if(r.findDimensionNodeByPrimitiveId(i)===!1){this.abandonMove=!0;return}this.initXmoveYmoveEles(i,n),this.abandonedWhenIsLock(t),this.affectedDimensions=r.findDimensionByPrimitiveId(n),bt.setExcludeShapeIds(Array.from(n));for(let a of this.drivingDimensions)this.affectedDimensions.has(a.gId)&&this.drivingDimensions.delete(a)}abandonedWhenIsLock(t){let i=new Set,{startX:r,startY:n,snapX:s,snapY:a}=t,o=s-r,l=a-n,{canMoveX:c,canMoveY:u}=this.dimensionMgr.getAllAffectedPrimitivesId(),h=Oa(),d=new Map;for(let{elements:p,combinationId:f,selectable:m}of h)for(let g of p)d.set(g,f?!m:Gi.isLockedById(g));if(o!==0){for(let p of new Set([...c]))if(d.get(p)){this.abandonMove=!0;let{cmdKey:f,json:m}=k.getById(p),g=Xi[f];i.add(g+m.id.slice(1))}}if(l!==0){for(let p of new Set([...u]))if(d.get(p)){this.abandonMove=!0;let{cmdKey:f,json:m}=k.getById(p),g=Xi[f];i.add(g+m.id.slice(1))}}this.abandonMove&&ls({value:i.size>1?"Constraint associated object {0} are currently locked, please unlock them first.":"Constraint associated object {0} is currently locked, please unlock first.",options:{0:[...i]},translateOptionKeys:[0]})}initXmoveYmoveEles(t,i){let{canMoveX:r,canMoveY:n,all:s,xNode:a,yNode:o}=this.dimensionMgr.getAllAffectedPrimitivesId(),l=new rt;for(let c of t)r.delete(c),n.delete(c);for(let c of s)i.add(c);for(let c of r){let u=l.searchCombination(c);if(u&&u==Wt.getCurrentEditingComId()){let h=l.getAllElesfromTop(u);for(let d of h.elements)[...a].find(p=>p.id==d)||r.delete(d)}}for(let c of n){let u=l.searchCombination(c);if(u&&u==Wt.getCurrentEditingComId()){let h=l.getAllElesfromTop(u);for(let d of h.elements)[...o].find(p=>p.id==d)||n.delete(d)}}this.xMoveEles=new Set(Array.from(r).map(c=>le(c))),this.yMoveEles=new Set(Array.from(n).map(c=>le(c)))}};var R1=class{constructor(t){this.dragContext=t}onDrag(t,i){if(!this.dragContext.abandonMove){for(let r of this.dragContext.drivingDimensions){let n=new In(r).updateOtherP(t,i);n=null}for(let r of this.dragContext.selectedObjs)Xn.move(k.getById(r.id).json,t,i);this.dragContext.dimensionMgr.moveDimension(t,i);for(let r of this.dragContext.xMoveEles)Xn.move(k.getById(r.id).json,t,0);for(let r of this.dragContext.yMoveEles)Xn.move(k.getById(r.id).json,0,i);for(let r of this.dragContext.dragDimensionDots)r.moveControlPoint(t,i).render()}}};var DB=/^(Backspace|Space|F1|F6|F7|F8|Home|End|(?:Ctrl|Cmd|Shift)\+[\-+AOSFRDGNP])$/,Lh=pQ();function _B(e){var t={F3:!0,F4:!0,F7:!0,F9:!0,F10:!0,"Ctrl+Shift+R":!0,"Ctrl+Shift+O":!0,"Ctrl+Shift+B":!0,"Ctrl+Shift+G":!0,"Ctrl+L":!0,"Ctrl+Tab":function(){return!0},"Ctrl+Shift+H":!0,"Shift+Alt+H":!0,"Ctrl+Shift+E":!0,"Ctrl+Shift+C":!0,"Ctrl+Shift+T":!0,"Ctrl+Shift+M":!0,"Ctrl+Shift+X":!0,"Ctrl+J":!0,"Ctrl+N":!0,"Ctrl+G":!0,"Alt+T":!0};return e?typeof t[e]=="function"?t[e]():t[e]:!1}function pQ(){var e={Backspace:8,Tab:9,Enter:13,Shift:16,Ctrl:17,Alt:18,Esc:27,Space:32,"Page Up":33,"Page Down":34,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Delete:46,"`":192,"-":mu?173:189,"+":mu?61:187,"[":219,"]":221,"\\":220,";":mu?59:186,"'":222,",":188,".":190,"/":191,"*":106};for(let n=1;n<=12;n++)e["F"+n]=111+n;var t=Object.keys(e);for(let n=0;n<t.length;n++){var i=e[t[n]];$e(e,i)||(e[i]=t[n])}fd&&(mu?e[224]="Cmd":(e[91]="Cmd",e[93]="Cmd"),delete e.Backspace,e[8]="Delete",e.Delete=8);var r={107:"+107",109:"-109"};return Object.assign({},e,r)}function PB(e){var t=e.metaKey,i=e.ctrlKey,r=e.shiftKey,n=e.altKey,s=e.keyCode,a="",o=Lh[s];return t&&(a+="Cmd+"),i&&(a+="Ctrl+"),r&&(a+="Shift+"),n&&(a+="Alt+"),s>=48&&s<=57||s>=65&&s<=90?a+=String.fromCharCode(s):s>=96&&s<=105?a=o:o!="Cmd"&&o!="Ctrl"&&o!="Shift"&&o!="Alt"&&$e(Lh,s)&&(a+=Lh[s]),a&&/[^+]\+$/.test(a)&&(a=a.substring(0,a.length-1)),a}async function fQ(e){if(Qn.altKeyEnabled=e.altKey,e.target.tagName){var t=e.target.tagName.toUpperCase();if(t=="TEXTAREA"||t=="INPUT"&&e.target.type=="text")return}if(e.type!=="keydown")return;let i=PB(e);return(_B(i)||DB.test(i)||fd&&i=="Delete")&&(e.preventDefault(),e.stopPropagation()),i=="Alt"&&e.preventDefault(),H.windowBridge.publish("iframeHotkey",{event:{keyStr:i,keyCode:e.keyCode,target:{tagName:e.target.tagName}},fromDoctype:H.doctype},ut()),!1}function mQ(e){if(e.type==="keyup"){if(e.target.tagName){var t=e.target.tagName.toUpperCase();if(t=="TEXTAREA"||t=="INPUT"&&e.target.type=="text")return}var i=PB(e);(DB.test(i)||fd&&i=="Delete"||_B(i))&&e.preventDefault(),H.windowBridge.publish("iframeHotkeyup",{event:{type:e.type,key:e.key,keyCode:e.keyCode,metaKey:e.metaKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,target:{tagName:e.target.tagName}},fromDoctype:H.doctype},ut())}}function LB(){document.addEventListener("keydown",fQ,!0),document.addEventListener("keyup",mQ,!0)}var gQ={0:"ns-resize",1:"ew-resize",2:"nesw-resize",3:"nwse-resize",5:"move",6:"rotate-left-top",9:"rotate-left-bottom",7:"rotate-right-top",8:"rotate-right-bottom"},BC=class{getCursor(){return this._cursor}switch(t){if(t!=this._cursor){if(this._cursor=t,t===4){delete H.svgRoot.dataset.cursor;return}H.svgRoot.dataset.cursor=gQ[t]}}isBoxRotateCursor(){return[9,6,8,7].includes(this._cursor)}mouseMoveCursor(t,i,r,n=!0){if(H.cmdToken||oo())return;let s=t.target;if($t(s)==="cdot")return this.cDotCursor(s);let a=ar.isNearBBoxEdge(r);if(a>-1)return this.cDotCursor(le("cdot"+a));let o=pl(i||s);if(o&&Ae.isSelected(o)&&n)return this.switch(5);let l=ar.findCanRotateControlDotInfo(r.x,r.y);return l!=null?this.boxRotateCursor(l.index,this.getBoxCDotRotation()):rf(r.x,r.y)&&!wt.isEditingPath()?this.switch(5):this.switch(4)}cDotCursor(t){var a,o;let i=Mi(),r=i[0];if(!r)return;let n=(()=>{let l=0,c=t;for(;c=c.previousElementSibling;)l++;return l})(),s=360-((o=(a=k.gJsonCache[$t(r)])==null?void 0:a[r.id])==null?void 0:o.rotation)||0;if(i.length>1)return this.boxCDotResizeCursor(n,0);switch($t(r)){case"rect":case"obj":return this.boxCDotResizeCursor(n,s);case"ellipse":{let l=ni(r.rx.animVal.value,r.ry.animVal.value),c=s;return l?c=0:c=this.getBoxCDotRotation(),this.boxCDotResizeCursor(n,c)}default:wt.is8DotsMode(r.id)&&this.boxCDotResizeCursor(n,s);return}}boxRotateCursor(t,i=this.getBoxCDotRotation()){let r=[6,9,8,7],n=Math.floor((i+45)%360/90%4);switch(t){case 0:return this.switch(r[n]);case 1:return this.switch(r[(n+3)%4]);case 2:return this.switch(r[(n+2)%4]);case 3:return this.switch(r[(n+1)%4])}}boxRotateCursor1(t,i){let r=t.angle(i);return r<0&&(r+=Math.PI*2),r<Math.PI/2?this.switch(8):r<Math.PI?this.switch(9):r<3*Math.PI/2?this.switch(6):this.switch(7)}boxCDotResizeCursor(t,i){let r=[3,1,2,0],n=Math.floor((i+22.5)%360/45%4);switch(t){case 0:case 2:return this.switch(r[n]);case 1:case 3:return this.switch(r[(n+2)%4]);case 4:case 6:return this.switch(r[(n+3)%4]);case 5:case 7:return this.switch(r[(n+1)%4])}}getBoxCDotRotation(){let t=le("cdot0"),i=new j(Number(t.dataset.x),Number(t.dataset.y)),r=le("cdot1"),n=new j(Number(r.dataset.x),Number(r.dataset.y));return tr(-n.angleD(i))}},OB,nc=OB=OB||new BC;var uf=[],kC=0,RB=gu;async function NB(){let e=Date.now();for(;uf.length&&Date.now()-e<100;)await uf.shift()();let t=uf.length&&kC?1-uf.length/kC:1;RB(t),uf.length&&setTimeout(NB,0)}var Vc={addTask(e){return uf.push(e),Vc},run(){kC=uf.length,NB()},onProgress(e){return RB=e,Vc}};var FC=new WeakMap,un={on:!1,firstMove:!0,hasMoved:!1,clonedElements:[],previewItems:[],selectedObjs:[],bbox:null,row:1,column:1,lastMouseRightDownPosition:null,followCursor:!1,ready(e,t,i){if(!e){this.end();return}this.followCursor=i,this.row=e,this.column=t,document.addEventListener("mousemove",un.onMouseMove,!1),this.on||(document.addEventListener("mousedown",un.onMouseDown,!1),document.addEventListener("mouseup",un.onMouseUp,!1),un.selectedObjs=Mi(),this.bbox=this.outerBBox(this.selectedObjs),un.on=!0)},onMouseDown(e){let t=un,i=ui(e,!0),r=i.x,n=i.y;if(e.button==BI)t.lastMouseRightDownPosition={x:e.clientX,y:e.clientY},H.contextmenuDisableOnce=!0;else{let s=t.row<=1||!t.hasMoved?null:(n-t.bbox.y)/(t.row-1)+t.bbox.height,a=t.column<=1||!t.hasMoved?null:(r-t.bbox.x-t.bbox.width)/(t.column-1)-t.bbox.width;Ce("editArray",[{rowSpacing:s,columnSpacing:a,row:un.row,column:un.column}]),document.removeEventListener("mousemove",un.onMouseMove,!1)}t.hasMoved=!1},onMouseUp(e){e.preventDefault(),e.stopPropagation();let t=un,i={x:e.clientX,y:e.clientY};e.button==BI&&t.lastMouseRightDownPosition&&sa(i,t.lastMouseRightDownPosition)&&Ce("editArray",[])},onMouseMove(e){if(!un.followCursor)return;H.helperCursor=!0,un.hasMoved=!0;let t=ui(e,!1),i=t.x,r=t.y;un.moveByCursor(i,r)},end(){document.removeEventListener("mousedown",un.onMouseDown,!1),document.removeEventListener("mouseup",un.onMouseUp,!1),document.removeEventListener("mousemove",un.onMouseMove,!1),cs(!1),this.clearPreviewItem(),un.on=!1,this.bbox=null,this.firstMove=!0,this.selectedObjs=[],this.hasMoved=!1,this.lastMouseRightDownPosition=null,this.followCursor=!1,H.helperCursor=null},async initPreviewItem(e,t,i){this.clearPreviewItem();for(let r=0;r<e;r++)for(let n=0;n<t;n++)await this.cloneAndMove(r,n,e,t,i)},cloneAndMove(e,t,i,r,n){return new Promise(s=>{this.previewItems[e]||(this.previewItems[e]=[]),e===0&&t===0?this.previewItems[e][t]=null:(this.previewItems[e][t]=this.simpleClone(this.selectedObjs),n&&te(this.previewItems[e][t],"transform","translate("+n.columnOffset*t+","+n.rowOffset*e+")")),or("progressUpdate",[((e+1)*r+t+1)/(i*r),"Array"]),s(!0)})},clearPreviewItem(){for(let e=0;e<this.previewItems.length;e++)for(let t=0;t<this.previewItems[0].length;t++)if(!(e===0&&t===0)&&this.previewItems[e]){let i=this.previewItems[e][t];i&&dt(i);for(let r of i)FC.delete(r)}this.previewItems=[]},async preview({row:e,column:t,rowSpacing:i,columnSpacing:r}){this.on||this.ready(e,t,!1),await this.initPreviewItem(e,t,{rowOffset:i-this.bbox.height,columnOffset:r+this.bbox.width});let n=Math.round((i-this.bbox.height)/Ge.adsorbGrid.gridSize)*Ge.adsorbGrid.gridSize,s=Math.round((r+this.bbox.width)/Ge.adsorbGrid.gridSize)*Ge.adsorbGrid.gridSize;this.move(n,s),this.adaptAll(this.selectedObjs,e,t,n,s)},async moveByCursor(e,t){(this.firstMove||this.row!=this.previewItems.length||this.column!=this.previewItems[0].length)&&(await this.initPreviewItem(this.row,this.column),this.firstMove=!1);let i=this.row,r=this.column,n=i==1?0:((t-this.bbox.y)/(i-1)).toFixed(2),s=r==1?0:((e-this.bbox.x-this.bbox.width)/(r-1)).toFixed(2);this.move(n,s),cs(e,t)},move(e,t){for(let i=0;i<this.previewItems.length;i++)for(let r=0;r<this.previewItems[0].length;r++)if(!(i===0&&r===0))for(let n of this.previewItems[i][r]){let{json:{matrix:s},cmdKey:a}=k.getById(FC.get(n).id),o;switch(a){case"rect":o=Li.getRectFromMatrix(s).matrixArr;break;case"ellipse":o=Ei.getEllipseFromMatrix(s).matrixArr;break;case"arc":case"group":o=[1,0,0,1,0,0];break;case"obj":break;case"text":break;default:break}let l=o||s?ht.getTransformStr(o||s):"";te(n,"transform"," translate("+t*r+","+e*i+") "+l)}},simpleClone(e){let t=[];return e.forEach(i=>{let r=i.cloneNode(!0);FC.set(r,i),t.push(r),H.gCanvas.appendChild(r)}),t},outerBBox(e){return MB(e)},adaptAll(e,t,i,r,n){let s=Rr(e),a={x:s.x+(n<0?n*(i-1):0),y:s.y+(r<0?r*(t-1):0),width:Math.abs(n*(i-1))+s.width,height:Math.abs(r*(t-1))+s.height};Jl(a,1)},execute(e){if(un.end(),!e)return;let t=Mi(),i=un.outerBBox(t),{row:r,column:n,rowSpacing:s,columnSpacing:a,saveHistory:o}=e,l=s-i.height,c=a+i.width;if(r==1&&n==1)return;let u=[],h=new rt,d=new oi,p=[];for(let f=0;f<r;f++)for(let m=0;m<n;m++){if(f===0&&m===0)continue;let g=new Set,b=new Map,y=[];t.forEach(E=>{Vc.addTask(()=>{let{json:S,cmdKey:w}=k.getById(E.id),x=c*m,I=l*f,A,O=jt(S),R=Ot();O.gId=R,A=bs(w,O),Xn.move(O,x,I),u.push(A),b.set(E.id,R);let M=h.searchCombination(E.id);if(M&&!g.has(M)){g.add(M);let F=Ot(),G=jt(k.getCombination(M));G.gId=F,y.push(G),b.set(M,F)}})}),p.push({copiedCombination:y,oldIdMapNewId:b})}Vc.addTask(()=>{this.adaptAll(t,r,n,l,c),u.forEach(f=>Oo(f,"selected")),p.forEach(f=>h.pasteCombination(d,f.copiedCombination,f.oldIdMapNewId)),this.clonedElements=u,Ae.select(u),Ce("panel_updateAttrPanel")}),o&&Vc.addTask(function(){let f=u.map(g=>{let b=k.getRefId(g.id);return Qr(g.id,{cmdKey:$t(g),refId:b},{},k.getById(g.id).json)});d.update();let m=d.getCombHistory();Ke.save([...f,...m])}),Vc.onProgress(function(f){f=Math.min(1,Math.max(f,.01)),or("progressUpdate",[f,"Array"])}),Vc.run()}};var hS=class{constructor(t){this.elms=t;this.polymer=new Map;this.updatePolymer()}updatePolymer(){let{polymer:t}=this;this.elms.forEach(i=>{let r=$t(i);t.has(r)?t.get(r).add(i):t.set(r,new Set([i]))})}};var dS=class{constructor(t){this.elms=t;this.elmsClassified=new hS(new Set(t)).polymer}};function yQ(e){let{json:t,cmdKey:i}=k.getById(e.id),r=k.getShapeAttr(t,i);if($e(r,"attr-x"))return new j(+r["attr-x"],+r["attr-y"]);if($e(r,"attr-start-x"))return new j(+r["attr-start-x"],+r["attr-start-y"]);console.error(r,"Plz check code")}function GC(e){let t=yQ(e),i=Ra(t);return{moveX:lt(i.x,2)-t.x,moveY:lt(i.y,2)-t.y}}var pS=class e{constructor(t){this.elms=t;this.bboxMap=e.getAllBBox(this.elms)}static getByAlignCmd(t,i){let r=new e(t);return{bboxMap:r.bboxMap,...r[i]()}}static getAllBBox(t){let i=new WeakMap;for(let r of t){let n;N0(r)||Array.isArray(r)?n=Rr([...r],!0):n=Ph(r),i.set(r,n)}return i}get canEquidistantAlign(){return this.elms.size>2}get bboxs(){return w4([...this.elms],t=>this.bboxMap.get(t))}align_left(){return{edge:{left:this.bboxs.reduce((i,{x:r})=>Math.min(i,r),this.bboxs[0].x)}}}align_right(){return{edge:{right:this.bboxs.reduce((i,{x:r,width:n})=>Math.max(i,r+n),this.bboxs[0].x+this.bboxs[0].width)}}}align_top(){return{edge:{top:this.bboxs.reduce((i,{y:r})=>Math.min(i,r),this.bboxs[0].y)}}}align_bottom(){return{edge:{bottom:this.bboxs.reduce((i,{y:r,height:n})=>Math.max(i,r+n),this.bboxs[0].y+this.bboxs[0].height)}}}align_horizontal_center(){let t=this.bboxs.reduce((i,{x:r,width:n})=>(i.left=Math.min(i.left,r),i.right=Math.max(i.right,r+n),i),{left:this.bboxs[0].x,right:this.bboxs[0].x+this.bboxs[0].width});return{edge:{center:t.left+t.right>>1}}}align_vertical_center(){let t=this.bboxs.reduce((i,{y:r,height:n})=>(i.top=Math.min(i.top,r),i.bottom=Math.max(i.bottom,r+n),i),{top:this.bboxs[0].y,bottom:this.bboxs[0].y+this.bboxs[0].height});return{edge:{center:t.top+t.bottom>>1}}}align_horizontal_equidistant(){let t=this.bboxs.reduce((r,{x:n,width:s})=>(r.left=Math.min(r.left,n),r.right=Math.max(r.right,n+s),r),{left:this.bboxs[0].x,right:this.bboxs[0].x+this.bboxs[0].width}),i=0;return this.canEquidistantAlign&&(i=(t.right-t.left-this.bboxs.reduce((n,{width:s})=>n+s,0))/(this.bboxs.length-1)),{edge:t,spacing:i}}align_vertical_equidistant(){let t=this.bboxs.reduce((r,{y:n,height:s})=>(r.top=Math.min(r.top,n),r.bottom=Math.max(r.bottom,n+s),r),{top:this.bboxs[0].y,bottom:this.bboxs[0].y+this.bboxs[0].height}),i=0;return this.canEquidistantAlign&&(i=(t.bottom-t.top-this.bboxs.reduce((n,{height:s})=>n+s,0))/(this.bboxs.length-1)),{edge:t,spacing:i}}align_left_side_edge_equidistant(){let t=this.bboxs.reduce((i,{x:r})=>(i.left=Math.min(i.left,r),i.right=Math.max(i.right,r),i),{left:this.bboxs[0].x,right:this.bboxs[0].x});return{edge:t,spacing:Math.abs(t.right-t.left)/(this.elms.size-1)}}align_top_side_edge_equidistant(){let t=this.bboxs.reduce((i,{y:r})=>(i.top=Math.min(i.top,r),i.bottom=Math.max(i.bottom,r),i),{top:this.bboxs[0].y,bottom:this.bboxs[0].y});return{edge:t,spacing:Math.abs(t.bottom-t.top)/(this.elms.size-1)}}},fS=class e{constructor(t){this.params=t}static run(t,...i){return new e(...i)[t]()}align_left(){let{bbox:{x:t},edge:i}=this.params;return{moveX:i.left-t,moveY:0}}align_right(){let{bbox:{x:t,width:i},edge:r}=this.params;return{moveX:r.right-t-i,moveY:0}}align_top(){let{bbox:{y:t},edge:i}=this.params;return{moveX:0,moveY:i.top-t}}align_bottom(){let{bbox:{y:t,height:i},edge:r}=this.params;return{moveX:0,moveY:r.bottom-t-i}}align_horizontal_center(){let{bbox:{x:t,width:i},edge:r}=this.params;return{moveX:r.center-t-i/2,moveY:0}}align_vertical_center(){let{bbox:{y:t,height:i},edge:r}=this.params;return{moveX:0,moveY:r.center-t-i/2}}align_horizontal_equidistant(){let{bbox:{x:t,width:i},edge:r,spacing:n}=this.params,s={moveX:0,moveY:0};if(t+i===r.right)return s;let a=r.left-t;return s.moveX=a,r.left+=i+n,s}align_vertical_equidistant(){let{bbox:{x:t,y:i,height:r},edge:n,spacing:s}=this.params,a={moveX:0,moveY:0};if(t+r===n.bottom)return a;let o=n.top-i;return a.moveY=o,n.top+=r+s,a}align_left_side_edge_equidistant(){let{bbox:{x:t},edge:i,spacing:r}=this.params;try{return{moveX:Math.round(i.left-t),moveY:0}}finally{i.left+=r}}align_top_side_edge_equidistant(){let{bbox:{y:t},edge:i,spacing:r}=this.params;try{return{moveX:0,moveY:Math.round(i.top-t)}}finally{i.top+=r}}};function mS(...e){new YC(...e).do().afterDo()}var YC=class{constructor(t,i,r){this.elms=t;this.alignCmd=i;this.refObject=r;this.context=new dS(this.elms)}alignGrid(){let{context:t}=this,{elmsClassified:i}=t;for(let[,r]of i)for(let n of r)if(Array.isArray(n)){let s=GC(n[0]);if(s.moveX||s.moveY)for(let a of n)Ke.jsonSnap.addOne(k.getById(a.id).json),Xn.move(k.getById(a.id).json,s.moveX,s.moveY)}else{let s=GC(n);(s.moveX||s.moveY)&&(Ke.jsonSnap.addOne(k.getById(n.id).json),Xn.move(k.getById(n.id).json,s.moveX,s.moveY))}}rebuildAlignEdgeByCmdRefObject(t){if(!this.refObject)return;let i=Ph(this.refObject),r=St.extendRect(i);switch(this.alignCmd){case"align_left":t.left=r.minX;break;case"align_top":t.top=r.minY;break;case"align_right":t.right=r.maxX;break;case"align_bottom":t.bottom=r.maxY;break;case"align_vertical_center":t.center=r.center().y;break;case"align_horizontal_center":t.center=r.center().x;break}}alignCommon(){let t=this.alignCmd,i=this.elms,{bboxMap:r,edge:n,spacing:s}=pS.getByAlignCmd(new Set(i),t);this.rebuildAlignEdgeByCmdRefObject(n);let a=(()=>{if(t=="align_top_side_edge_equidistant"||t=="align_vertical_equidistant")return"y";if(t=="align_left_side_edge_equidistant"||t=="align_horizontal_equidistant")return"x"})(),o=a?[...i].sort((u,h)=>r.get(u)[a]-r.get(h)[a]):[...i],{gridSize:l}=Ge.adsorbGrid,c=[];for(let u of o){let h=r.get(u),{moveX:d,moveY:p}=fS.run(t,{bbox:h,edge:n,spacing:s,gridSize:l});N0(u)||(u=new Set([u]));for(let f of u)d===0&&p===0&&zt.self.dimensionMgr.setStillByEle(f),(d||p)&&c.push({elm:f,moveX:d,moveY:p})}for(let{elm:u,moveX:h,moveY:d}of c){let p=u;Array.isArray(u)||(p=[u]);for(let f of p)Ke.jsonSnap.addOne(k.getById(f.id).json),Xn.move(k.getById(f.id).json,h,d)}}align(){this.alignCmd==="align_grid"?this.alignGrid():this.alignCommon()}do(){let t=zt.createContext(!0);return this.align(),t(),this}afterDo(){let t=is(this.elms.flat(1/0));Ae.select(t),t.length&&fr(t,{create8Dots:!0}),pi.emptyLastHoverEle().emptySelectContainer().appendSelectStroke()}};var bQ={align_top:!0,align_left:!0,align_right:!0,align_bottom:!0,align_vertical_center:!1,align_horizontal_center:!1},xQ={align_top:!1,align_left:!1,align_right:!1,align_bottom:!1,align_vertical_center:!0,align_horizontal_center:!0},Oh=class Oh{constructor(t,i){this.cmd=t;this.elms=i;this.pointerUp=async t=>{if(t.button!==0||!t.target)return;let i=t.target;te(i,"name")==="adsorption-point"&&(i=bt.currentAdsorptionShapeElement);let r=pl(i);r&&(Ae.select(r),mS(this.elms,this.cmd,r),this.cancel())};this.pointerMove=t=>{this.updateContent()};this.keyUp=t=>{t.key==="ESC"&&this.cancel()};new.target.instance=this,this.textElm=le(`${new.target.textElmId}`)}static isSelectRefObjectCmd(t){return bQ[t]}static async needSelectRefobject(t){return(await Ho("isCheckedSelectAlignrefObject")).message&&this.isSelectRefObjectCmd(t)}static isSelectRefObjectCmdForCenters(t){return xQ[t]}static async needSelectRefobjectForCenters(t){return(await Ho("isCheckedSelectAlignrefObjectForCenters")).message&&this.isSelectRefObjectCmdForCenters(t)}async startSelect(){await this.init(),document.addEventListener("pointermove",this.pointerMove),document.addEventListener("mouseup",this.pointerUp),document.addEventListener("keyup",this.keyUp)}async init(){Rh(),Oh.running=!0,H.cmdToken=this.cmd,this.textElm.classList.remove("hide"),this.textElm.textContent=(await Ho("i18n",Oh.textContent)).message;let t=(await H.windowBridge.rpcCall("getThemeCssVariable",["--common-bg-color","--common-font-color"],wd())).message;this.textElm.style.backgroundColor=t["--common-bg-color"],this.textElm.style.color=t["--common-font-color"],this.updateContent()}getCursorTextPosition(t,i,r){let n=1/H.gZoom,s=n/2,a=t%n,o=i%n;t+=s-a,i+=s-o,t=Math.round(t*1e6)/1e6,i=Math.round(i*1e6)/1e6;let l=this.textElm.offsetHeight,c=24,u=6,h=H.gZoom,d=(t-r[0])*h+c,p=(i-r[1])*h-l-u;return{left:d,top:p}}updateTipPosition(t){let i=Xt.getViewBox(),{top:r,left:n}=this.getCursorTextPosition(t.x,t.y,i);this.textElm.style.left=n+"px",this.textElm.style.top=r+"px"}updateContent(){let{currAbsX:t,clientX:i,clientY:r,currAbsY:n}=Ir.data;pr("cross-red",t,n);let s=ui(new MouseEvent("mousemove",{clientX:i,clientY:r}));xs("",s),this.updateTipPosition(s)}clearContent(){pr(),xs(),this.textElm.textContent="",this.textElm.classList.add("hide")}end(){}cancel(){document.removeEventListener("pointermove",this.pointerMove),document.removeEventListener("mouseup",this.pointerUp),document.removeEventListener("keyup",this.keyUp),bt.clearAdsorptionHTML(),gS(),this.clearContent(),Oh.running=!1}};Oh.instance=null,Oh.running=!1,Oh.textElmId="cross-text",Oh.textContent="Please Select The Reference Object";var lo=Oh;var yS=class{constructor(t){this.middleware=[];this.context=Object.assign(t,{tool:this}),Reflect.defineProperty(this.context,"tool",{writable:!1,configurable:!1,enumerable:!0})}use(t){let{middleware:i}=this;return!i.includes(t)&&i.push(t.bind(this)),this}do(){return EQ(this.middleware)(this.context)}handle(t){for(let i=0;i<t.length;i++)this.use(t[i]);return this.do()}};function EQ(e){return function(t,i){let r=-1;return n(0);function n(s){if(s<=r)return Promise.reject(new Error("next() called mutiple times"));r=s;let a=e[s];if(s===e.length&&(a=i),!a)return Promise.resolve();try{return Promise.resolve(a(t,n.bind(null,s+1)))}catch(o){return Promise.reject(o)}}}}var Ru=SQ();function SQ(){let e={disable:!1,checkInHideFlag:!0,checkInDisableFlag:!0,checkOutHideFlag:!0,checkOutDisableFlag:!0};return{set(t){e=t},get(){return e},forbiddenDataChange(){let{disable:t}=e;return t}}}function BB(e,t){let{cmdKey:i,json:r}=e&&k.getById(e.id)||{};t.target.dataset.type=="handle"&&(e=t.target);let n=new yS({target:e,cmdKey:i,json:r,event:t});n.use(vQ),n.use(TQ),n.use(wQ),n.use(IQ),n.use(AQ),n.use(CQ),n.do()}function wQ({target:e,cmdKey:t,json:i},r){if(t==="dimension"){new A1().dblclickHandler(i);return}r()}function vQ({target:e,cmdKey:t},i){if(!e){if(wt.isEditingPath())return wt.endEditingPath();if(Wt.isEditing()){let r=Wt.getCurrentEditingComId();Wt.setEditing(null).selectCombinations([r])}return}i()}function TQ({target:e,cmdKey:t},i){let r=new rt,n=r.searchCombination(e.id);if(!n){i();return}if(Wt.isEditing()){let s=Wt.getCurrentEditingComId(),a=r.getAllElesfromTop(s).combinations;if(a.size===0)return i();qt();for(let o of r.findFamily(n,s).getAllParents().reverse())if(a.has(o))return Wt.setEditing(o);i()}else{let s=r.findFamily(n).peekParent();qt(),Wt.setEditing(s)}}function IQ({target:e,cmdKey:t},i){if(Wt.isEditing()){let r=new rt().findFamily(Wt.getCurrentEditingComId()).peekParent();if(!new rt().getAllElesfromTop(r).elements.has(e.id))return i()}if(["arc","group"].includes(t)&&!Ae.isUnselectAble(e.id)){wt.startEditPath(e.id),Ae.unselectAll().select([e]);return}e.dataset.type!="handle"&&i()}async function AQ({target:e,cmdKey:t,event:i},r){let n,s;if(t==="text"){if(Ru.forbiddenDataChange())return;s=(await H.windowBridge.rpcCall("i18n","Ctrl / Shift / Alt + Enter for new line",ut())).message,a(i);return}r();async function a(o){let l=!1,{locked:c,name:u}=k.getById(e.id).json,{checked:h}=S2["all-element-type"].text;if(c||!h)return;let d="text-input-box",p="textInputBox-container",f=le(d),m=le(p);if(k.compilerManager.pauseDateMerge(),!f){let R=function(){if(l)return;l=!0;let M=n,F=new oi([M]),G=f.value.trim();if(G==="")return jo([M]);G=L3(G),new J2(M).name(G).then(function(){F.updateAndSave(),Ce("panel_updateAttrPanel")})},I=["--bg-color-input","--border-color-input","--border-color-focus-input","--common-font-color","--bg-color-pop-up-content","--font-color-input"],A=(await H.windowBridge.rpcCall("getThemeCssVariable",I,ut())).message;m=document.createElement("div"),m.id=p,m.style.padding="0.2em",f=document.createElement("textarea"),f.id=d,f.style.width="300px",f.style.boxSizing="border-box",f.style.outline=A["--bg-color-input"],f.style.background=A["--bg-color-input"],f.style.color=A["--font-color-input"],f.onfocus=()=>{f.style.border=`1px solid ${A["--border-color-focus-input"]}`},m.appendChild(f);let O=document.createElement("div");O.setAttribute("class","i18n"),O.innerText=s,O.style.fontSize="12px",O.style.color=A["--common-font-color"],m.appendChild(O),document.body.appendChild(m),m.style.width="fit-content",m.style.position="absolute",m.style.boxShadow="0px 0px 20px 3px #333",m.style.background=A["--bg-color-pop-up-content"],f.addEventListener("change",R,!1),f.addEventListener("blur",function(){R(),setTimeout(()=>{dt(m),k.compilerManager.resumeDataMerge()},0)},!1),f.addEventListener("keydown",function(F){F.keyCode==13&&(F.preventDefault(),F.stopPropagation())}),f.addEventListener("keyup",function(M){let F=13,G=27,{keyCode:V}=M;if(M.keyCode==32&&M.stopPropagation(),V==G&&(M.stopPropagation(),setTimeout(()=>{dt(m)},0)),!M.ctrlKey&&!M.shiftKey&&!M.altKey&&V==F){if(f.value.trim().length>4096)return H.windowBridge.publish("ui/toastMsg",{type:"error",msg:"Text cannot be more than 4096 characters!",timer:3},ut());f.blur(),setTimeout(()=>{dt(m)},0);return}if(V===F&&M.preventDefault(),(M.ctrlKey||M.shiftKey||M.altKey)&&V==F){let T=le(te(f,"data-targetid"));if(!($t(T)=="text"&&T.parentNode==H.gCanvas))M.preventDefault(),M.stopPropagation();else{var q=M.currentTarget,C=q.selectionStart,N=q.selectionEnd;f.value=f.value.substring(0,C)+`
`+f.value.substring(N),q.selectionStart=C+1,q.selectionEnd=C+1}}},!1);var g=f.style.resize!==void 0;g||(function(M){var F=0,G=0,V=0,q=0,C=!1;function N(P){P.button===hE&&(C&&L(),P.offsetX>M.offsetWidth-16&&P.offsetY>M.offsetHeight-16&&(P.preventDefault(),M.style.cursor="nwse-resize",document.addEventListener("mousemove",T,!1),document.addEventListener("mouseup",L,!1),C=!0,F=P.pageX,G=P.pageY,V=parseInt(M.style.width,10),q=parseInt(M.style.height,10)))}function T(P){var B=V+P.pageX-F,U=q+P.pageY-G;M.style.width=Math.min(Math.max(B,100),1200)+"px",M.style.height=Math.min(Math.max(U,100),1e3)+"px"}function L(){C&&(M.style.cursor="",document.removeEventListener("mousemove",T,!1),document.removeEventListener("mouseup",L,!1),C=!1)}M.addEventListener("mousedown",N,!1),M.addEventListener("blur",L,!1)})(f)}let b=o.pageX,y=o.pageY;f.style.display="",m.style.display="inline-block",f.value=u,f.select(),f.focus(),n=e,te(f,"data-targetid",e.id),(function(I){let A=I.value.replace(/[^\x00-\xff]/g,"**").split(/\r\n|\r|\n/),O=A.length,R=0;for(let M=0;M<A.length;M++)R=Math.max(A[M].length,R);te(f,"rows",O),te(f,"cols",R),f.style.height="100px"})(f);let E=m.offsetWidth,S=m.offsetHeight,w=Math.max(y-5,5),x=Math.max(b-5,5);x+E>document.documentElement.offsetWidth&&(x-=E),w+S>document.documentElement.offsetHeight&&(w-=S),m.style.left=x+"px",m.style.top=w+"px"}}function CQ({target:e,cmdKey:t},i){let r=is([e]);if(r.length&&fr(r,{create8Dots:!0}),wt.isEditingPath())return wt.endEditingPath();if(Wt.isEditing()){let n=Wt.getCurrentEditingComId();Wt.setEditing(null).selectCombinations([n])}i()}var bS=new Bc(0);async function DQ(e){return new Promise((t,i)=>{let r=new Image;r.onload=async()=>{t(r)},r.onerror=n=>{r=null,i(n)},r.src=e})}async function xS(e,t){e.startsWith("data:")&&bS.info("initial bytes \u2248 "+((e.length-30)*.75|0));let r=await DQ(e);return await _Q(r,t)}function VC(e,t="image/png",i){if("convertToBlob"in e)return e.convertToBlob({type:t});if("toBlob"in e)return new Promise(r=>{e.toBlob(r,t,i)});throw"get blob failed"}async function _Q(e,t){let{bytesLimit:i=10<<20,maxWidth:r=1e3,maxHeight:n=1e3,minWidth:s=1,minHeight:a=1}=t,o=/^data:image\/jpeg;/.test(e.currentSrc||e.src),l=/^data:image\/svg\+xml;|\.svg$/i.test(e.currentSrc||e.src),{width:c,height:u,naturalWidth:h,naturalHeight:d}=e,p=h,f=d,m=1;l?p/f>r/n?(m=n/f,p=n*p/f,f=n):(m=r/p,f=r*f/p,p=r):p>r||f>n?(m=Math.min(r/p,n/f),p=Math.floor(p*m),f=Math.floor(f*m)):(p<s||f<a)&&(m=Math.max(s/p,a/f),p=Math.floor(p*m),f=Math.floor(f*m));let g=Math.max(p,s),b=Math.max(f,a),y=(M,F)=>{if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(M,F);{let G=document.createElement("canvas");return G.width=M,G.height=F,G}},E=y(g,b),S=g<p?p-g>>1:0,w=b<f?f-b>>1:0;E.getContext("2d").drawImage(e,S,w,p,f),p=g,f=b;let I=await VC(E),A=I.size;bS.info("scaled to bytes: "+A);let O=.8;for(;A>i&&p>64&&f>64;){m*=O,p=p*O|0,f=f*O|0;let M=y(p,f);M.getContext("2d").drawImage(E,0,0,p,f);let G=await VC(M,"image/png"),V=I.size;if(o){let q=await VC(M,"image/jpeg",.8),C=q.size;I=V<=C?G:q,A=V<=C?V:C}else I=G,A=V;bS.info("scaled to bytes: "+A)}return bS.info("final bytes: ",{size:A,width:p,height:f}),{dataURL:await PQ(I,"DataURL"),width:p,height:f,bytes:A}}async function PQ(e,t,i){return new Promise((r,n)=>{var s=new FileReader;if(t=="DataURL")s.readAsDataURL(e);else if(t=="ArrayBuffer")s.readAsArrayBuffer(e);else if(t=="Text")s.readAsText(e,i);else{n(new Error("invalid type"));return}s.onload=a=>r(s.result),s.onerror=a=>n(a)})}function kB(e){if(typeof e!="string")return!1;let t=e.match(/^data:([^;,]+)?(?:;[^,]*?)?;base64,/);if(!t)return!1;let i=e.slice(t[0].length,t[0].length+32),r;try{r=atob(i)}catch{return!1}return r.length<12?!1:r.slice(0,4)==="RIFF"&&r.slice(8,12)==="WEBP"}async function FB(e){var a;if(typeof e!="string")throw new Error("webpDataUrl must be a string");if(!/^data:image\/webp(?:;[^,]*)?,/.test(e))throw new Error("Not a image/webp dataURL");let t=await LQ(e),i=await createImageBitmap(t),r=new OffscreenCanvas(i.width,i.height),n=r.getContext("2d");if(!n)throw new Error("2D context not available");n.drawImage(i,0,0),(a=i.close)==null||a.call(i);let s=await r.convertToBlob({type:"image/png",quality:.9});return await OQ(s)}function LQ(e){let t=e.indexOf(",");if(t===-1)throw new Error("Invalid dataURL: missing comma");let i=e.slice(0,t),r=e.slice(t+1),n=/;base64/i.test(i),s=i.match(/^data:([^;]+)/i),a=s?s[1]:"application/octet-stream";if(n){let o=atob(r),l=o.length,c=new Uint8Array(l);for(let u=0;u<l;u++)c[u]=o.charCodeAt(u);return new Blob([c],{type:a})}else{let o=decodeURIComponent(r);return new Blob([o],{type:a})}}function OQ(e){if(typeof FileReader!="object"){let t=RQ(e);return Promise.resolve(t)}return new Promise((t,i)=>{let r=new FileReader;r.onerror=()=>i(new Error("FileReader failed")),r.onload=()=>t(r.result),r.readAsDataURL(e)})}async function RQ(e){let t=await e.arrayBuffer(),i=new Uint8Array(t),r="",n=32768;for(let a=0;a<i.length;a+=n)r+=String.fromCharCode(...i.subarray(a,a+n));let s=btoa(r);return`data:${e.type||"application/octet-stream"};base64,${s}`}async function GB(e){let t=e&&e.text;if(!t)return e;let i=new _u;for(let r in t){let n=t[r],{d:s,bbox:a}=await i.getPath(n.name,{fontFamily:n.fontFamily,fontSize:n.fontSize,fontWeight:n.fontWeight?"bold":"normal",fontStyle:n.italic?"italic":"normal",underline:n.fontUnderline?"underline":"none",value:n.name});n.d||(n.d=s),n.cacheHeight=a.height(),n.cacheWidth=a.width();let{x:o,y:l,rotation:c,mirror:u,widthPercent:h,heightPercent:d}=n;if(ft(d))continue;let{x:p,y:f}=xr.getTextOrigin(void 0,void 0,void 0,n),m=de.translate(p,f).scale(h,d).rotateD(-c);u&&(m=m.multiply3(de.MIRROR_X)),m=m.translate(o,l),n.matrix=et.getMatrix6FromMatrix(m),delete n.x,delete n.y,delete n.widthPercent,delete n.heightPercent,delete n.mirror}return e}var ml=function(e){this._pathElement=e,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)};ml.prototype.classname="SVGPathSegList";Object.defineProperty(ml.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0});ml.prototype._checkPathSynchronizedToList=function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())};ml.prototype._updateListFromPathMutations=function(e){if(this._pathElement){var t=!1;e.forEach(function(i){i.attributeName=="d"&&(t=!0)}),t&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}};ml.prototype.segmentChanged=function(e){this._writeListToPath()};ml.prototype.clear=function(){this._checkPathSynchronizedToList(),this._list.forEach(function(e){e._owningPathSegList=null}),this._list=[],this._writeListToPath()};ml.prototype.initialize=function(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e};ml.prototype._checkValidIndex=function(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw"INDEX_SIZE_ERR"};ml.prototype.getItem=function(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]};ml.prototype.insertItemBefore=function(e,t){return this._checkPathSynchronizedToList(),t>this.numberOfItems&&(t=this.numberOfItems),e._owningPathSegList&&(e=e.clone()),this._list.splice(t,0,e),e._owningPathSegList=this,this._writeListToPath(),e};ml.prototype.replaceItem=function(e,t){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._checkValidIndex(t),this._list[t]=e,e._owningPathSegList=this,this._writeListToPath(),e};ml.prototype.removeItem=function(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);var t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t};ml.prototype.appendItem=function(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e};var Pt={};Pt.PATHSEG_UNKNOWN=0;Pt.PATHSEG_CLOSEPATH=1;Pt.PATHSEG_MOVETO_ABS=2;Pt.PATHSEG_MOVETO_REL=3;Pt.PATHSEG_LINETO_ABS=4;Pt.PATHSEG_LINETO_REL=5;Pt.PATHSEG_CURVETO_CUBIC_ABS=6;Pt.PATHSEG_CURVETO_CUBIC_REL=7;Pt.PATHSEG_CURVETO_QUADRATIC_ABS=8;Pt.PATHSEG_CURVETO_QUADRATIC_REL=9;Pt.PATHSEG_ARC_ABS=10;Pt.PATHSEG_ARC_REL=11;Pt.PATHSEG_LINETO_HORIZONTAL_ABS=12;Pt.PATHSEG_LINETO_HORIZONTAL_REL=13;Pt.PATHSEG_LINETO_VERTICAL_ABS=14;Pt.PATHSEG_LINETO_VERTICAL_REL=15;Pt.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16;Pt.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17;Pt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18;Pt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19;var ES="not implement",sc=function(e){this._string=e,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=Pt.PATHSEG_UNKNOWN,this._skipOptionalSpaces()};sc.prototype._isCurrentSpace=function(){var e=this._string[this._currentIndex];return e<=" "&&(e==" "||e==`
`||e=="	"||e=="\r"||e=="\f")};sc.prototype._skipOptionalSpaces=function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex};sc.prototype._skipOptionalSpacesOrDelimiter=function(){return this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&this._string.charAt(this._currentIndex)!=","?!1:(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)==","&&(this._currentIndex++,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)};sc.prototype.hasMoreData=function(){return this._currentIndex<this._endIndex};sc.prototype.peekSegmentType=function(){var e=this._string[this._currentIndex];return this._pathSegTypeFromChar(e)};sc.prototype._pathSegTypeFromChar=function(e){switch(e){case"Z":case"z":return Pt.PATHSEG_CLOSEPATH;case"M":return Pt.PATHSEG_MOVETO_ABS;case"m":return Pt.PATHSEG_MOVETO_REL;case"L":return Pt.PATHSEG_LINETO_ABS;case"l":return Pt.PATHSEG_LINETO_REL;case"C":return Pt.PATHSEG_CURVETO_CUBIC_ABS;case"c":return Pt.PATHSEG_CURVETO_CUBIC_REL;case"Q":return Pt.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return Pt.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return Pt.PATHSEG_ARC_ABS;case"a":return Pt.PATHSEG_ARC_REL;case"H":return Pt.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return Pt.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return Pt.PATHSEG_LINETO_VERTICAL_ABS;case"v":return Pt.PATHSEG_LINETO_VERTICAL_REL;case"S":return Pt.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return Pt.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return Pt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return Pt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return Pt.PATHSEG_UNKNOWN}};sc.prototype._nextCommandHelper=function(e,t){return(e=="+"||e=="-"||e=="."||e>="0"&&e<="9")&&t!=Pt.PATHSEG_CLOSEPATH?t==Pt.PATHSEG_MOVETO_ABS?Pt.PATHSEG_LINETO_ABS:t==Pt.PATHSEG_MOVETO_REL?Pt.PATHSEG_LINETO_REL:t:Pt.PATHSEG_UNKNOWN};sc.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return!0;var e=this.peekSegmentType();return e==Pt.PATHSEG_MOVETO_ABS||e==Pt.PATHSEG_MOVETO_REL};sc.prototype._parseNumber=function(){var e=0,t=0,i=1,r=0,n=1,s=1,a=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)=="+"?this._currentIndex++:this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)=="-"&&(this._currentIndex++,n=-1),!(this._currentIndex==this._endIndex||(this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")&&this._string.charAt(this._currentIndex)!=".")){for(var o=this._currentIndex;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!=o)for(var l=this._currentIndex-1,c=1;l>=o;)t+=c*(this._string.charAt(l--)-"0"),c*=10;if(this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)=="."){if(this._currentIndex++,this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)i*=10,r+=(this._string.charAt(this._currentIndex)-"0")/i,this._currentIndex+=1}if(this._currentIndex!=a&&this._currentIndex+1<this._endIndex&&(this._string.charAt(this._currentIndex)=="e"||this._string.charAt(this._currentIndex)=="E")&&this._string.charAt(this._currentIndex+1)!="x"&&this._string.charAt(this._currentIndex+1)!="m"){if(this._currentIndex++,this._string.charAt(this._currentIndex)=="+"?this._currentIndex++:this._string.charAt(this._currentIndex)=="-"&&(this._currentIndex++,s=-1),this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)e*=10,e+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var u=t+r;if(u*=n,e&&(u*=Math.pow(10,s*e)),a!=this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),u}};sc.prototype._parseArcFlag=function(){if(!(this._currentIndex>=this._endIndex)){var e=!1,t=this._string.charAt(this._currentIndex++);if(t=="0")e=!1;else if(t=="1")e=!0;else return;return this._skipOptionalSpacesOrDelimiter(),e}};sc.prototype.parseSegment=function(){var e=this._string[this._currentIndex],t=this._pathSegTypeFromChar(e);if(t==Pt.PATHSEG_UNKNOWN){if(this._previousCommand==Pt.PATHSEG_UNKNOWN||(t=this._nextCommandHelper(e,this._previousCommand),t==Pt.PATHSEG_UNKNOWN))return null}else this._currentIndex++;switch(this._previousCommand=t,t){case Pt.PATHSEG_MOVETO_REL:return["m",this._parseNumber(),this._parseNumber()];case Pt.PATHSEG_MOVETO_ABS:return["M",this._parseNumber(),this._parseNumber()];case Pt.PATHSEG_LINETO_REL:return["l",this._parseNumber(),this._parseNumber()];case Pt.PATHSEG_LINETO_ABS:return["L",this._parseNumber(),this._parseNumber()];case Pt.PATHSEG_LINETO_HORIZONTAL_REL:return["h",this._parseNumber()];case Pt.PATHSEG_LINETO_HORIZONTAL_ABS:return["H",this._parseNumber()];case Pt.PATHSEG_LINETO_VERTICAL_REL:return["v",this._parseNumber()];case Pt.PATHSEG_LINETO_VERTICAL_ABS:return["V",this._parseNumber()];case Pt.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),["Z"];case Pt.PATHSEG_CURVETO_CUBIC_REL:{let i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return["c",i.x1,i.y1,i.x2,i.y2,i.x,i.y]}case Pt.PATHSEG_CURVETO_CUBIC_ABS:{let i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return["C",i.x1,i.y1,i.x2,i.y2,i.x,i.y]}case Pt.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:{let i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return["s",i.x2,i.y2,i.x,i.y]}case Pt.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:{let i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return["S",i.x2,i.y2,i.x,i.y]}case Pt.PATHSEG_CURVETO_QUADRATIC_REL:{let i={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return[ES,i.x,i.y,i.x1,i.y1]}case Pt.PATHSEG_CURVETO_QUADRATIC_ABS:{let i={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return["Q",i.x,i.y,i.x1,i.y1]}case Pt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return[ES,this._parseNumber(),this._parseNumber()];case Pt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return[ES,this._parseNumber(),this._parseNumber()];case Pt.PATHSEG_ARC_REL:{let i={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return[ES,i.x,i.y,i.x1,i.y1,i.arcAngle,i.arcLarge,i.arcSweep]}case Pt.PATHSEG_ARC_ABS:{let i={rx:this._parseNumber(),ry:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return["A",i]}default:throw"Unknown path seg type."}};var UB=function(e){if(!e||e.length==0)return[];let t=[],i=new sc(e);if(!i.initialCommandIsMoveTo())return[];for(;i.hasMoreData();){let r=i.parseSegment();if(!r)return[];t.push(r)}return t};function YB(e){let t=[],i=0,r=0,n;for(let s of e){let a=s[0];switch(a){case"m":{t.push({op:"m",c:[i+s[1],r+s[2]]}),i=i+s[1],r=r+s[2];break}case"M":t.push({op:"m",c:s.slice(1)}),i=s[1],r=s[2];break;case"L":t.push({op:"l",c:s.slice(1)}),i=s[1],r=s[2];break;case"l":t.push({op:"l",c:[s[1]+i,s[2]+r]}),i=i+s[1],r=r+s[2];break;case"h":t.push({op:"l",c:[s[1]+i,r]}),i=i+s[1];break;case"v":t.push({op:"l",c:[i,s[1]+r]}),r=r+s[1];break;case"C":t.push({op:"c",c:s.slice(1)}),i=s[5],r=s[6];break;case"c":t.push({op:"c",c:[i+s[1],r+s[2],i+s[3],r+s[4],i+s[5],r+s[6]]}),i=i+s[5],r=r+s[6];break;case"S":Kr(a,s);break;case"s":{let o=i,l=r;["C","S"].includes(n[0])?(o=i-n.at(-2)+i,l=r-n.at(-1)+r):["c","s"].includes(n[0])&&(o=i+n.at(-2),l=r+n.at(-1)),t.push({op:"c",c:[o,l,i+s[1],r+s[2],i+s[3],r+s[4]]}),i=i+s[3],r=r+s[4];break}case"Q":{t.push({op:"c",c:[i,r,s[1],s[2],s[3],s[4]]}),i=s[3],r=s[4];break}case"A":{let o=Rd({x1:i,y1:r,x2:s[1].x,y2:s[1].y,rx:s[1].rx,ry:s[1].ry,angle:s[1].arcAngle,sweep:s[1].arcSweep?1:0,large:s[1].arcLarge?1:0}),l=UB(o);l.shift(),t.push(...YB(l)),i=s[1].x,r=s[1].y;break}case"Z":t.push({op:"h",c:[]});break;default:Kr(a,s,"Plz check code");break}n=s}return t}function SS(e){if(!e.includes("A"))return e;let t=UB(e),i=YB(t),r=[];for(let n of i)switch(n.op){case"m":r.push("M",...n.c);break;case"c":r.push("C",...n.c);break;case"l":r.push("L",...n.c);break;default:Kr(n);break}return r.join(" ")}function Fd(e){let t=typeof e=="string"?e.replace(/\s+/g,""):e;return t==="6,6"||+t==1?{key:1,text:"dashed",value:"6,6",i18nText:"dashed"}:t==="3,10"||+t==2?{key:2,text:"dotted",value:"3,10",i18nText:"dotted"}:t==="4,2,1,2"||+t==3?{key:3,text:"dotdashed",value:"4,2,1,2",i18nText:"dotdashed"}:{key:0,text:"solid",value:"0",i18nText:"solid"}}function VB(){let e=["0","6,6","3,10","4,2,1,2"],t=[];for(let i of e)t.push(Fd(i));return t}function HC(e){let{color:t,fillColor:i,shape:r}=e;return`:root {
		--highlight: ${t.highlight};
		--selectColor: ${t.select};
		--auxiliaryLineColor: ${t.auxiliaryLine};
		--auxiliaryLineDashArray: ${r.auxiliaryLine.dash};
		--auxiliaryPointFillColor: ${i.auxiliaryPoint};
		--dimensionLabelColor: ${t.dimensionLabel};
		--dimensionConstraintColor: ${t.dimensionConstraint};
		--gridColor: ${t.grid};
		--normalDimensionColor: ${t.normalDimension};
	}`}var Wn=class{static decHead(t){return{...t}}static decDetail(t){let{title:i,docType:r=c0.PANEL,description:n,display_title:s}=t;return{title:i,display_title:s||i,docType:r,desc:n,name:s||i}}static decPoly(t,i){let r,{ploys:n}=i;if(n.length===1){let s=n[0];switch(s[0]){case"R":r=this.decRect(t,i);break;case"ELLIPSE":r=this.decEllipse(t,i);break;case"M":s[3]==="A"||s[3]==="CA"?r=this.decArc(t,i):r=this.decPolyGroup(t,i);break;default:r=this.decPolyGroup(t,i)}}else r=this.decPolyGroup(t,i);return r}static decEllipse(t,i){let{layer:r,rotation:n,strokeColor:s,strokeWidth:a,fillColor:o,opacity:l,displayFill:c,displayStroke:u,strokeStyle:h,groupId:d}=i,{locked:p,visible:f,name:m,valid:g,cover:b,transScope:y}=i,E=this.decTransform(i.matrix),{transparencyPrint:S,transparencyWhite:w}=this.getTransparencyPrintAndTransparencyWhite(i),x={gId:t,layer:r,rotation:n,strokeWidth:a,strokeStyle:this.getStrokeStyleNumber(h),strokeColor:s,fillColor:o,opacity:l,displayFill:c,displayStroke:u,matrix:E,zIndex:this.getZIndexOrDefault(i),cover:!!b,hide:!g,scope:this.getScope(y),isWhiteBackground:!1,transparencyPrint:S,transparencyWhite:w,cmdKey:"ellipse",name:m,locked:p,visible:f};return this.fixedShape(x,d),x}static getScope(t){let i=1;switch(t){case ll.PRINT_AND_COVER:i=1;break;case ll.PRINT:i=2;break;case ll.COVER:i=3;break;default:}return i}static getTransparencyPrintAndTransparencyWhite(t){let i=0,r=0,{transScope:n,transPrint:s,transWhite:a,opacity:o}=t;switch(n){case ll.PRINT_AND_COVER:i=1-(s!==void 0?s:o),r=1-(a!==void 0?a:1);break;case ll.PRINT:i=1-(s!==void 0?s:1),r=1-(a!==void 0?a:o);break;case ll.COVER:i=1-(s!==void 0?s:o),r=1-(a!==void 0?a:o);break;default:}return{transparencyPrint:i,transparencyWhite:r}}static decArc(t,i){let{layer:r,rotation:n,strokeColor:s,strokeWidth:a,fillColor:o,opacity:l,displayFill:c,displayStroke:u,strokeStyle:h,groupId:d,ploys:p}=i,{valid:f,locked:m,visible:g,name:b,cover:y,transScope:E}=i,[,S,w,x,I,A,O,R,M,F,G]=p[0],V=this.decTransform(i.matrix),{transparencyPrint:q,transparencyWhite:C}=this.getTransparencyPrintAndTransparencyWhite(i),N={layer:r,rotation:-n,strokeWidth:a,strokeStyle:this.getStrokeStyleNumber(h),strokeColor:s,fillColor:o,opacity:l,displayFill:c,displayStroke:u,x1:S,y1:-w,rx:I,ry:A,angle:O,large:R,sweep:M,x2:F,y2:-G,cover:!!y,type:x==="CA"?1:2,matrix:V,hide:!f,gId:t,locked:m,visible:g,zIndex:this.getZIndexOrDefault(i),scope:this.getScope(E),isWhiteBackground:!1,transparencyPrint:q,transparencyWhite:C,cmdKey:"arc",name:b};return this.fixedShape(N,d),N}static decRect(t,i){let{layer:r,rotation:n,strokeColor:s,strokeWidth:a,fillColor:o,opacity:l,displayFill:c,displayStroke:u,strokeStyle:h,groupId:d,ploys:p}=i,{cover:f,valid:m,visible:g,locked:b,transScope:y,name:E}=i;if(o.startsWith("data:")||o.startsWith("blob:")||o.length>20)return this.decObj(t,i);{let{transparencyPrint:S,transparencyWhite:w}=this.getTransparencyPrintAndTransparencyWhite(i),x=this.decTransform(i.matrix),I=p[0],A={gId:t,name:E,layer:r,rotation:-n,strokeWidth:a,strokeStyle:this.getStrokeStyleNumber(h),strokeColor:s,fillColor:o,opacity:l,rx:I[5],ry:I[6],displayFill:c,displayStroke:u,matrix:x,cover:!!f,hide:!m,locked:b,visible:g,transparencyPrint:S,transparencyWhite:w,zIndex:this.getZIndexOrDefault(i),scope:this.getScope(y),isWhiteBackground:!1,cmdKey:"rect"};return this.fixedShape(A,d),A}}static handleBlobUrl(t){return/^blob:(.+)$/.exec(t)}static decObj(t,i){var n;let{fillColor:r}=i;if(r){let s=(n=this.handleBlobUrl(r))==null?void 0:n[1];if(s)return(async()=>{var l;this.imageHashMap.set(t,s);let a=this.imageDataMap.get(s),o=a||((l=(await H.windowBridge.rpcCall(ci.BLOB.GET,[s,H.currentProject.projectId],ut())).message)==null?void 0:l.content);return o&&!a&&(o=await this.resize(o),this.imageDataMap.set(s,o)),this.decodeObjSync(t,i,o)})();if(r.startsWith("data:"))return(async()=>{let a=await this.resize(r);return this.decodeObjSync(t,i,a)})();if(r.length>20){this.imageHashMap.set(t,r);let a=this.imageDataMap.get(r)||r;return this.decodeObjSync(t,i,a)}}}static decPolyGroup(t,i){let{layer:r,rotation:n,strokeColor:s,strokeWidth:a,fillColor:o,opacity:l,displayFill:c,displayStroke:u,strokeStyle:h,groupId:d,ploys:p}=i,{cover:f,valid:m,visible:g,locked:b,name:y,transScope:E}=i,S=this.decTransform(i.matrix),w=this.decMultiPoly(p).d,{transparencyPrint:x,transparencyWhite:I}=this.getTransparencyPrintAndTransparencyWhite(i),A={layer:r,rotation:-n,strokeWidth:a,strokeStyle:this.getStrokeStyleNumber(h),strokeColor:s,fillColor:o,opacity:l,d:SS(w),displayFill:c,displayStroke:u,matrix:S,hide:!m,gId:t,locked:b,visible:g,zIndex:this.getZIndexOrDefault(i),cover:!!f,scope:this.getScope(E),isWhiteBackground:!1,transparencyPrint:x,transparencyWhite:I,cmdKey:"group",name:y};return this.fixedShape(A,d),A}static decString(t,i){return(async()=>{let{layer:n,rotation:s,fontFamily:a,fontSize:o,fontWeight:l,italic:c,underline:u,strikeout:h,strokeColor:d,align:p,opacity:f,value:m,groupId:g,cover:b,transScope:y}=i,{valid:E,locked:S,visible:w,path:x}=i,I=this.decTransform(i.matrix),A=x?this.decFontCache(x):{},{vAlign:O,hAlign:R}=this.getAlign(p),{transparencyPrint:M,transparencyWhite:F}=this.getTransparencyPrintAndTransparencyWhite(i),G={layer:n,rotation:-s,key:m,name:m,fontFamily:a,fontSize:o,fontWeight:!!l,italic:c,underline:u,vAlign:O,hAlign:R,strokeColor:d,opacity:f,d:"",cacheHeight:0,cacheWidth:0,matrix:I,cover:!!b,hide:!E,gId:t,locked:S,visible:w,...A,zIndex:this.getZIndexOrDefault(i),scope:this.getScope(y),isWhiteBackground:!1,transparencyPrint:M,transparencyWhite:F,cmdKey:"text"};return await this.fixStringPath(G),this.fixedShape(G,g),G})()}static decDimension(t,i){let{layer:r,dimensionType:n,relationIds:s,controlDot:a,locked:o,visible:l,name:c,rotation:u}=i,h=new Array,d=a;for(let m=0;m<d.length-1;m+=2)h.push(new j(d[m],d[m+1]));let p=s,f;switch(n){case"LENGTH-CONSTRAINT":case"LENGTH-MEASUREMENT":{let[m,g,b,y]=h,E=m.x===g.x?"x":m.y===g.y?"y":"xy",S=this.getDimCategory(n);f={name:c,gId:t,cmdKey:"dimension",layer:r,category:S,direction:E,start:{id:p[0],index:0,cmdKey:"",primitivePoint:{x:m.x,y:-m.y},otherPoint:{x:g.x,y:-g.y}},end:{id:p[1],index:0,cmdKey:"",otherPoint:{x:b.x,y:-b.y},primitivePoint:{x:y.x,y:-y.y}},visible:l,locked:o,rotation:u,zIndex:this.getZIndexOrDefault(i)};break}case"RADIUS-MEASUREMENT":{let[m,g,b]=h;f={name:c,gId:t,cmdKey:"dimensionRadius",layer:r,x1:m.x,y1:-m.y,x2:g.x,y2:-g.y,textX:b.x,textY:-b.y,locked:o,visible:l,ellipseId:p[0],rotation:u,zIndex:this.getZIndexOrDefault(i)};break}case"ANGLE":{let[m,g,b,y]=h;f={name:c,gId:t,cmdKey:"dimensionAngle",layer:r,x1:m.x,y1:-m.y,angleX:g.x,angleY:-g.y,x2:b.x,y2:-b.y,textX:y.x,textY:-y.y,locked:o,visible:l,rotation:u,zIndex:this.getZIndexOrDefault(i)};break}case"LENGTH":{let[m,g,b,y]=h,E=m.x===g.x?"x":m.y===g.y?"y":"xy";f={name:c,gId:t,cmdKey:"dimensionLength",layer:r,x1:m.x,y1:-m.y,measureX1:g.x,measureY1:-g.y,measureX2:b.x,measureY2:-b.y,x2:y.x,y2:-y.y,direction:E,locked:o,visible:l,rotation:u,zIndex:this.getZIndexOrDefault(i)};break}}return this.fixedShape(f),f}static decBlob(t,i){let{content:r}=i;this.imageDataMap.set(t,r)}static decAuxLine(t,i){let r=8,{visible:n,locked:s,name:a,x:o,y:l,rotation:c,strokeStyle:u,strokeWidth:h,color:d,groupId:p,length:f}=i,m;return f===0?m={gId:t,cmdKey:"auxiliaryPoint",visible:n,name:a,layer:r,x:o,y:-l,fillColor:this.decAuxColor(d),locked:s,zIndex:this.getZIndexOrDefault(i)}:(m={gId:t,name:a,cmdKey:"auxiliaryLine",layer:r,x:o,y:-l,rotation:c,strokeStyle:this.getStrokeStyleNumber(u),strokeColor:this.decAuxColor(d),locked:s,visible:n,x1:0,x2:0,y1:0,y2:0,zIndex:this.getZIndexOrDefault(i)},this.prepareX1Y1ForAuxiliaryLine(m)),this.fixedShape(m,p),m}static decGroup(t,i){let{parentId:r,title:n,visible:s,locked:a}=i,o=t,l=r,c=n,u=r!="0"&&r,h={gId:o,name:c,locked:a,visible:s,cmdKey:"combination",parent:u?l:null,combinations:[],elements:[]};return this.fixedShape(h),h}static decAuxColor(t){if(t!==null)return t===""?null:t}static getDimCategory(t){switch(t){case"LENGTH-MEASUREMENT":return"Annotation";case"LENGTH-CONSTRAINT":return"Constraint";default:throw new Error(`unknown dimension type ${JSON.stringify(t)}`)}}static decFontCache(t){let{bbox:i,d:r}=this.decMultiPoly(t);return{d:r,cacheWidth:i.width(),cacheHeight:i.height()}}static decMultiPoly(t){let i=new ot,r=t.map(n=>{let s="";return new so(a=>(i.ext1(a.bbox()),s=new Da().encPl(a).toString(),!1),!0).parse("M"+n.join(" ")),s}).join(" ");return{bbox:i.build(),d:r}}static prepareX1Y1ForAuxiliaryLine(t){let i=$p(t.x,t.y,t.rotation);t.x1=i.start().x,t.y1=i.start().y,t.x2=i.end().x,t.y2=i.end().y}static async fixStringPath(t){let{d:i,bbox:r}=await this.lf.getPath(t.name,{fontFamily:t.fontFamily,fontSize:t.fontSize,fontWeight:t.fontWeight?"bold":"normal",fontStyle:t.italic?"italic":"normal",underline:t.underline?"underline":"none",value:t.name});t.d||(t.d=i),t.cacheHeight=r.height(),t.cacheWidth=r.width();let{x:n,y:s,rotation:a,mirror:o,widthPercent:l,heightPercent:c}=t;if(ft(c))return;let{x:u,y:h}=xr.getTextOrigin(void 0,void 0,void 0,t),d=de.translate(u,h).scale(l,c).rotateD(-a);o&&(d=d.multiply3(de.MIRROR_X)),d=d.translate(n,s),t.matrix=et.getMatrix6FromMatrix(d),delete t.x,delete t.y,delete t.widthPercent,delete t.heightPercent,delete t.mirror}static fixedShape(t,i){let{cmdKey:r,gId:n}=t;r!=="combination"&&(typeof t.hide!="boolean"&&(t.hide=!1),typeof t.visible!="boolean"&&(t.visible=!0),typeof t.locked!="boolean"&&(t.locked=!1),typeof t.layer!="number"&&(t.layer=1),typeof t.opacity!="number"&&(t.opacity=1),typeof t.cover!="boolean"&&(t.cover=!1),typeof t.scope!="number"&&(t.scope=1),typeof t.name!="string"&&(t.name=""),!t.matrix&&!["group","arc","dimensionLength","dimensionAngle"].includes(r)&&(t.matrix=[1,0,0,0,1,0]))}static decTransform(t){let[i,r,n,s,a,o]=t||[1,0,0,0,1,0],l=new de([i,s,0,r,a,0,n,o,1]);return l=de.MIRROR_Y.multiply3(l).multiply3(de.MIRROR_Y),this.matrix2svg(l)}static resize(t){let i=H.uploadSvgFileMaxMB*1048576;if(!(a=>(a.length-30)*.75>i)(t))return t;let n=!(typeof window=="object"&&typeof document=="object")&&typeof importScripts=="function",s={bytesLimit:i,maxWidth:2160,maxHeight:2160};return(async()=>n?(await H.messageBus.rpcCall("/panel/resizeImageFromURL",[t,s])).message.dataURL:(await xS(t,s)).dataURL)()}static decodeObjSync(t,i,r){let{layer:n,rotation:s,opacity:a,locked:o,valid:l,groupId:c,visible:u,name:h,cover:d}=i,p=this.decTransform(i.matrix),f={gId:t,layer:n,rotation:-s,content:r,opacity:a,locked:o,matrix:p,cover:!!d,hide:!l,cmdKey:"obj",name:h,visible:u,zIndex:this.getZIndexOrDefault(i)};return this.fixedShape(f,c),f}static matrix2svg(t){let[i,r,n,s,a,o,l,c,u]=t.data;return[i,r,s,a,l,c]}static getZIndexOrDefault(t){return t.zIndex||0}static getStrokeStyleNumber(t){switch(t){case Mc.SOLID:return 0;case Mc.SHORT_DASH:return 1;case Mc.DOT:return 2;case Mc.DOT_DASH:return 3}}static getAlign(t){let i={hAlign:0,vAlign:2};switch(t){case ds.LEFT_TOP:i.hAlign=0,i.vAlign=0;break;case ds.CENTER_TOP:i.hAlign=1,i.vAlign=0;break;case ds.RIGHT_TOP:i.hAlign=2,i.vAlign=0;break;case ds.LEFT_MIDDLE:i.hAlign=0,i.vAlign=1;break;case ds.CENTER_MIDDLE:i.hAlign=1,i.vAlign=1;break;case ds.RIGHT_MIDDLE:i.hAlign=2,i.vAlign=1;break;case ds.LEFT_BOTTOM:i.hAlign=0,i.vAlign=2;break;case ds.CENTER_BOTTOM:i.hAlign=1,i.vAlign=2;break;case ds.RIGHT_BOTTOM:i.hAlign=2,i.vAlign=2;break}return i}};Wn.lf=new _u,Wn.imageHashMap=new Map,Wn.imageDataMap=new Map;var zo=class{static uploadDeleteById(t,i){switch(i||(i=k.getById(t).cmdKey),i){case"auxiliaryLine":case"auxiliaryPoint":{k.compilerManager.deleteAuxLine(t);break}case"text":k.compilerManager.deleteString(t);break;case"combination":k.compilerManager.deleteGroup(t);break;case"dimension":case"dimensionAngle":case"dimensionLength":case"dimensionRadius":k.compilerManager.deleteDimension(t);break;case"arc":case"obj":case"rect":case"group":case"ellipse":{k.compilerManager.deletePoly(t);break}}}static applyRemoteDelete(t){t.forEach(n=>this.beUploadDeleteMap.set(n,k.getById(n).json));let i=t.map(n=>le(n)).filter(n=>n);if(!i.length)return;jo(i,!0).forEach(n=>{t.includes(n.gId)||this.uploadDeleteById(n.gId,n.cmdKey)})}static updateRecord(t,i){let r=t.at(-1),n=t.at(-2),s=k.getById(t[1]).json,a=this.beUploadDeleteMap.get(t[1]);return(Mt(s)||!s)&&!Mt(r)&&!Mt(n)&&a&&(t=[...t],i==="undo"?(t[t.length-1]={},t[t.length-2]={...a,...n}):(t[t.length-1]={...a,...r},t[t.length-2]={})),t}};zo.beUploadDeleteMap=new Map;var Nu=class{static uploadData(t,i,r=k.compilerManager){var s;switch(t==="canvas"?"canvas":(i==null?void 0:i.cmdKey)||k.getById(t).cmdKey){case"canvas":{let a=this.getCanvasData(i);a&&r.uploadCanvas(a);break}case"auxiliaryLine":case"auxiliaryPoint":{let a=this.getAuxLineData(t,i);a&&r.uploadAuxLine(t,a);break}case"obj":i=this.uploadObjContent(t,r,i);case"arc":case"rect":case"group":case"ellipse":{let a=this.getPolyData(t,i);a&&r.uploadPoly(t,a);break}case"text":{let a=this.getStringData(t,i);a&&r.uploadString(t,a);break}case"combination":{i||(i=k.getCombination(t)),(s=i.elements)==null||s.forEach(o=>this.uploadData(o));let a=this.getGroup(t,i);r.uploadGroup(t,a);break}case"dimension":case"dimensionAngle":case"dimensionLength":case"dimensionRadius":{let a=this.getDimensionData(t,i);a&&r.uploadDimension(t,a);break}}}static uploadJsonCache(t,i){let r=k.exchangeJsonCache(i);if(this.uploadData("canvas",i.head,t),k.iterator(n=>{let s=n.gId;this.uploadData(s,n,t)}),r(),t instanceof s2)return t.save()}static uploadJsonCache2(t){let i=k.gJsonCache,r=new Map;wS(i.head,t.head)||r.set("canvas",t.head),Om.forEach(s=>{let a=[];Object.keys(i[s]).forEach(o=>{var l,c;wS((l=t[s])==null?void 0:l[o],(c=i[s])==null?void 0:c[o])?a.push(o):r.set(o,s)}),Object.keys(t[s]||{}).forEach(o=>{a.includes(o)||r.set(o,t[s][o])})});let n=k.exchangeJsonCache(t);r.forEach((s,a)=>{typeof s=="object"?this.uploadData(a,s):zo.uploadDeleteById(a,s)}),n()}static uploadObjContent(t,i,r){r||(r=jt(k.getById(t).json));let{content:n,gId:s}=r,a=Wn.imageHashMap.get(t);if(a)r.content="blob:"+a;else if(n.startsWith("data:")){let o=i.uploadBlob("",n);o.success&&(r.content="blob:"+o.hash)}return r}static getAuxLineData(t,i){let{json:r}=k.getById(t);if(i&&(r=i),Mt(r))return;let{layer:n,x:s,y:a,rotation:o=0,strokeColor:l,fillColor:c,strokeStyle:u,locked:h,visible:d,name:p,zIndex:f}=r;return{groupId:this.getCombinationId(t),layer:n,x:s,y:-a,rotation:o,strokeWidth:0,strokeStyle:this.getStrokeStyle(u),color:NQ(l||c),length:r.cmdKey==="auxiliaryPoint"?0:100,locked:h,visible:d,cover:0,name:p,zIndex:f}}static uploadCombination(t,i){(t.name!==i.name||t.parent!==i.parent||t.locked!==i.locked||t.visible!==i.visible)&&this.uploadData(t.gId),this.getArrayDifference(t.elements,i.elements).forEach(s=>{this.uploadData(s)}),this.getArrayDifference(t.combinations,i.combinations).forEach(s=>this.uploadData(s))}static getArrayDifference(t=[],i=[]){return t.sort().join(",")!==i.sort().join(",")?[...new Set(t.concat(i))].filter(n=>!t.includes(n)||!i.includes(n)):[]}static getCanvasData(t){let i=t||k.gJsonCache.head,{name:r,material:n,thickness:s,print:a,craft:o,desc:l,coverColor:c,backgroundColor:u,width:h,height:d,originX:p,originY:f}=i,{width:m,height:g}=k.getProductWidthHeight();return{material:n,thickness:s,print:a,craft:o,desc:l,coverColor:c,backgroundColor:u,width:h,height:d,originX:p,originY:f,orderWidth:m,orderHeight:g}}static getPolyData(t,i){let r=k.getById(t).json;if(i&&(r=i),Mt(r))return;let{layer:n,rotation:s,strokeWidth:a,strokeColor:o,strokeStyle:l,opacity:c,locked:u,hide:h,cmdKey:d,zIndex:p}=r,{visible:f,cover:m,name:g,transparencyPrint:b,transparencyWhite:y,matrix:E,displayFill:S,displayStroke:w,scope:x}=r,{fillColor:I}=r,A;switch(d){case"rect":A=[["R",0,0,1,1,r.rx,r.ry,0,0]];break;case"arc":let{x1:R,y1:M,type:F,rx:G,ry:V,angle:q,large:C,sweep:N,x2:T,y2:L}=r,P="A";F===1&&(P="CA"),A=[["M",R,-M,P,G,V,q,C,N,T,-L]];break;case"ellipse":A=[["ELLIPSE",0,0,1,1,0,0]];break;case"group":A=HB(r.d);break;case"obj":let{content:B}=r;A=[["R",0,0,1,1,0,0,0,0]];let U=Wn.imageHashMap.get(t);I=U?"blob:"+U:B}return{groupId:this.getCombinationId(t),layer:n,rotation:-s,strokeWidth:a,strokeStyle:this.getStrokeStyle(l),strokeColor:o,fillColor:I,opacity:c,autoClose:!1,ploys:A,displayFill:S,displayStroke:w,locked:u,zIndex:p,valid:!h,visible:f,cover:Number(m),name:g,transScope:this.getScope(x),transPrint:1-b,transWhite:1-y,matrix:jB(E)}}static getStringData(t,i){let r=k.getText(t);if(i&&(r=i),Mt(r))return;let{layer:n,rotation:s,fontFamily:a,fontSize:o,fontWeight:l,italic:c,underline:u,hAlign:h,vAlign:d,strokeColor:p,zIndex:f}=r,{opacity:m,locked:g,hide:b,visible:y,cover:E,transparencyPrint:S,transparencyWhite:w,matrix:x,name:I,d:A,scope:O}=r;return{groupId:this.getCombinationId(t),layer:n,rotation:-s,value:I,fontFamily:a,fontSize:o,fontWeight:Number(l),italic:c,underline:u,strikeout:!1,align:this.getAlign(h,d),strokeColor:p,opacity:m,locked:g,zIndex:f,valid:!b,visible:y,cover:Number(E),name:I,transScope:this.getScope(O),transPrint:1-S,transWhite:1-w,matrix:jB(x),strokes:!1,path:HB(A)}}static getGroup(t,i){let r=k.getCombination(t);if(i&&(r=i),Mt(r))return;let{parent:n,name:s,visible:a,locked:o}=r;return{parentId:n||"0",title:s,visible:a,locked:o}}static getDimensionData(t,i){let{json:r}=k.getById(t);i&&(r=i);let n,s,a;switch(r.cmdKey){case"dimension":{let{start:m,end:g}=r,b=m.primitivePoint,y=m.otherPoint,E=g.otherPoint,S=g.primitivePoint;s=[m.id,g.id],a=MQ(r),n=[b.x,-b.y,y.x,-y.y,E.x,-E.y,S.x,-S.y];break}case"dimensionAngle":{s=[],a="ANGLE",n=[r.x1,-r.y1,r.angleX,-r.angleY,r.x2,-r.y2,r.textX,-r.textY];break}case"dimensionLength":{s=[],a="LENGTH",n=[r.x1,-r.y1,r.measureX1,-r.measureY1,r.measureX2,-r.measureY2,r.x2,-r.y2];break}case"dimensionRadius":{s=[r.ellipseId],a="RADIUS-MEASUREMENT",n=[r.x1,-r.y1,r.x2,-r.y2,r.textX,-r.textY];break}}let{layer:o,locked:l,visible:c,name:u,zIndex:h,hide:d,rotation:p}=r;return Mt(r)?void 0:{layer:o,dimensionType:a,unit:"",strokeWidth:0,accuracy:0,controlDot:n,relationIds:s,locked:l,zIndex:h,visible:c,cover:0,name:u,valid:!d,rotation:p}}static getCombinationId(t){let i=Object.values(k.gJsonCache.combination).find(r=>r.elements.includes(t));return i?i.gId:"0"}static getStrokeStyle(t){switch(t){case 0:return Mc.SOLID;case 1:return Mc.SHORT_DASH;case 2:return Mc.DOT;case 3:return Mc.DOT_DASH}}static getAlign(t,i){switch(`${t}${i}`){case"00":return ds.LEFT_TOP;case"10":return ds.CENTER_TOP;case"20":return ds.RIGHT_TOP;case"01":return ds.LEFT_MIDDLE;case"11":return ds.CENTER_MIDDLE;case"21":return ds.RIGHT_MIDDLE;case"02":return ds.LEFT_BOTTOM;case"12":return ds.CENTER_BOTTOM;case"22":return ds.RIGHT_BOTTOM}}static getScope(t){let i=ll.PRINT_AND_COVER;switch(t){case 1:i=ll.PRINT_AND_COVER;break;case 2:i=ll.PRINT;break;case 3:i=ll.COVER;break;default:}return i}};function HB(e){let t=new Array;return new so(i=>(t.push(new Da(!0).encPl(i).toArray().slice(1)),!0),!0).parse(e),t}function jB(e){if(!e)return[1,0,0,0,1,0];let[t,i,r,n,s,a]=e,o=new de([t,i,0,r,n,0,s,a,1]);o=de.MIRROR_Y.multiply3(o).multiply3(de.MIRROR_Y);let[l,c,u,h,d,p,f,m,g]=o.data;return[l,h,f,c,d,m]}function NQ(e){return typeof e=="string"?String(e):e}function MQ(e){switch(e.category){case"Annotation":return"LENGTH-MEASUREMENT";case"Constraint":return"LENGTH-CONSTRAINT";default:throw new Error(`dimension category ${JSON.stringify(e.category)} not supported`)}}function wS(e,t){if(e===t||Number.isNaN(e)&&Number.isNaN(t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return e===t;if(e.constructor!==t.constructor)return!1;if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!wS(e[n],t[n]))return!1;return!0}let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n of i)if(!r.includes(n)||!wS(e[n],t[n]))return!1;return!0}var Mu=class{static getInitMetaData(t){let i={gId:"",cmdKey:t,visible:!0,name:"",layer:1,locked:!1,zIndex:this.getDefaultZIndex()};return t==="combination"&&delete i.layer,i}static getInitCommonData(){return{matrix:[1,0,0,1,0,0],cover:!0,hide:!1,opacity:1,rotation:0,scope:1,isWhiteBackground:!1,transparencyPrint:1,transparencyWhite:1}}static getDefaultZIndex(){return this.maxZIndex++,this.maxZIndex}static getInitStrokeStyle(){return{strokeColor:"#000000",strokeStyle:0,strokeWidth:0,fillColor:"none",displayStroke:!0,displayFill:!0}}static getInitialRectData(t){return{rx:0,ry:0,...this.getInitMetaData("rect"),...this.getInitCommonData(),...this.getInitStrokeStyle(),...t}}static getInitialTextData(t){return{cacheHeight:39.37007874015748,cacheWidth:137.79527559055117,d:"",fontSize:0,key:"",hAlign:0,vAlign:0,strokeColor:"#000000",underline:!1,italic:!1,fontWeight:!1,fontFamily:"\u9ED1\u4F53",...this.getInitMetaData("text"),...this.getInitCommonData(),...t}}static getInitialImageData(t){return{x:0,y:0,width:1,height:1,content:"",...this.getInitMetaData("obj"),...this.getInitCommonData(),...t}}static getInitialEllipseData(t){return{...this.getInitMetaData("ellipse"),...this.getInitCommonData(),...this.getInitStrokeStyle(),...t}}static getInitialGroupData(t){return{d:"",...this.getInitMetaData("group"),...this.getInitCommonData(),...this.getInitStrokeStyle(),...t}}static getInitialArcData(t){return{...this.getInitMetaData("arc"),...this.getInitCommonData(),...this.getInitStrokeStyle(),type:2,x1:0,y1:0,rx:0,ry:0,angle:0,large:1,sweep:1,x2:0,y2:0,...t}}static getInitialAuxiliaryLineData(t){return{...this.getInitMetaData("auxiliaryLine"),rotation:0,x1:0,x2:0,y1:0,y2:0,x:0,y:0,strokeColor:void 0,strokeStyle:null,layer:8,...t}}static getInitialAuxiliaryPointData(t){return{x:0,y:0,fillColor:void 0,visible:!0,...this.getInitMetaData("auxiliaryPoint"),layer:8,...t}}static getInitialCombinationData(t){return{...this.getInitMetaData("combination"),parent:null,combinations:[],elements:[],name:"",...t}}};Mu.maxZIndex=0;var Ud=class{static ready(){Je.started=!0}static draw(t,i,r){let n=Je;r&&(this.setOrigin(t,i),n.dots.length=0,n.restart())}static setOrigin(t,i,r=!0){let n=t-Ge.canvas.originX,s=i-Ge.canvas.originY;Wr().setOriginXY({x:t,y:i}),r&&Ke.save(["originXY","set.origin",{offsetX:n,offsetY:s}])}static end(){xs()}};var N1={maxId:0,name:"name",material:"acrylic",thickness:"0.8mm",craft:"Transparent",desc:"",width:"393mm",height:"579mm",title:"",display_title:"",coverColor:"white",print:"Bottom Side"},vS=class{constructor(){this.canMergeData=!0;this.task=[];this.groupElementsMap=new Map;this.fixDimensionMap=new Map;this.groupCombinationMap=new Map;this.mergeDataMap=new Map;this.jsonCache=k.getDefaultGJsonCache()}addTask(t){this.task.push(t),this.task.length===1&&(this.decodeStatus=this.decoderTask())}async decoderTask(){try{for(await this.awaitTime();this.task.length>0;){let t=this.task[0],{data:i,id:r,number:n}=t;if(i)try{await this.onChange(t)}catch(s){console.error(t,s)}else n?this.onChangeNum(r,n):this.onDelete(r);this.task.shift()}this.mergeDataToJsonCache()}catch(t){console.log(t)}finally{return Promise.resolve()}}awaitTime(){return this.awaitTime=function(){return new Promise(t=>setTimeout(()=>t(void 0)))},new Promise(t=>t(void 0))}async onChange(t){let{type:i,id:r,data:n,client:s,number:a,hash:o}=t;if(i==="detail"){let l=Wn.decDetail(n);this.addMergeData("detail",l)}else if(i==="canvas"){let l=Wn.decHead(n);this.addMergeData("canvas",l)}else i==="group"?this.handleGroupData(t):await this.handleShapeData(t)}mergeDataToJsonCache(){if(!this.mergeDataMap.size||!this.canMergeData)return;let t=this.jsonCache===k.gJsonCache;this.exchangeMgrJsonCache(()=>{let i=[],r=[];this.mergeDataMap.forEach((n,s)=>{if(!this.verifyData(n)){let a=this.groupElementsMap.get(s);if(this.onDelete(s),a){let o=this.getGroupData(a);this.mergeDataMap.set(a,o)}}}),this.mergeDataMap.forEach((n,s)=>{let a=this.getOldData(s);if(!n)i.push(s);else if(this.isDifferObject(n,a)){let o=n.cmdKey?n.cmdKey:s;r.push({cmdKey:o,data:n}),this.addDataToJsonCache(o,n)}}),this.mergeDataMap.clear(),this.setItemOrderArr(),t&&(r.forEach(({cmdKey:n,data:s})=>{this.renderData(n,s)}),this.handleDeleteStroke(i),zo.applyRemoteDelete(i),this.refreshSelected(r),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)),this.deleteJsonCacheData(i)})}async handleShapeData(t){let{type:i,id:r,data:n,client:s,number:a,hash:o}=t,l;switch(i){case"dimension":l=Wn.decDimension(r,n);break;case"string":l=await Wn.decString(r,n);break;case"poly":l=await Wn.decPoly(r,n);break;case"auxLine":l=Wn.decAuxLine(r,n);break;case"blob":this.handleBlob(o,n);return}l.id=this.numberToId(a),Mu.maxZIndex=Math.max(l.zIndex,Mu.maxZIndex);let c=n.groupId=="0"?void 0:n.groupId,u=this.groupElementsMap.get(r);if(u!=c){n.groupId?this.groupElementsMap.set(r,c):this.groupElementsMap.delete(r);let h=this.getGroupData(c);h&&this.addMergeData(c,h);let d=this.getGroupData(u);d&&this.addMergeData(u,d)}this.addMergeData(r,l)}handleGroupData(t){let{type:i,id:r,data:n,client:s,number:a,hash:o}=t,l=Wn.decGroup(r,n),{gId:c,cmdKey:u,parent:h}=l;this.groupCombinationMap.forEach((p,f)=>{p===r&&l.combinations.push(f)}),this.groupElementsMap.forEach((p,f)=>{p===r&&l.elements.push(f)}),l.id=this.numberToId(a);let d=this.groupCombinationMap.get(r);if(d!=h){parent?this.groupCombinationMap.set(r,h):this.groupCombinationMap.delete(r);let p=this.getGroupData(h);p&&this.addMergeData(h,p);let f=this.getGroupData(d);f&&this.addMergeData(f,f)}this.addMergeData(r,l)}quickSortItemOrder(t){let i=[],r=[],n=[];if(t.length<=1)return t;let s=Math.floor(t.length/2),a=t[s],{zIndex:o,layer:l}=k.getById(a).json;for(let c of t){let{zIndex:u,layer:h}=k.getById(c).json;l<h||u<o?i.push(c):l>h||u>o?r.push(c):n.push(c)}return[...this.quickSortItemOrder(i),...n,...this.quickSortItemOrder(r)]}addDataToJsonCache(t,i){if(["canvas","detail"].includes(t))Object.assign(this.jsonCache.head,i);else if(Ze[t]){let{gId:r}=i;if(this.isIllegal(i))return;if(sr(this.jsonCache,t)[r]=i,t!=="combination"&&Om.includes(t)&&!this.jsonCache.itemOrder.includes(r)&&this.jsonCache.itemOrder.push(r),t==="dimension"){let n=k.getById(i.start.id).json;n?Nh(n.cmdKey,i.start,n):this.fixDimensionMap.set(i.start.id,i.start),n=k.getById(i.end.id).json,n?Nh(n.cmdKey,i.end,n):this.fixDimensionMap.set(i.end.id,i.end)}else{let n=this.fixDimensionMap.get(r);n&&(this.fixDimensionMap.delete(r),Nh(t,n,i))}}}renderData(t,i){if(t==="detail")H.windowBridge.publish("setTitle",[H.tabId,i.display_title],ut());else if(t==="canvas"){let r=Xt.getCanvasAttrs();Ud.setOrigin(i.originX,i.originY,!1),Xt.setCanvasWidthHeight(i.width,i.height,r["attr-direction"],!1)}else if(t==="combination")i.elements.forEach(r=>ai.applyElementsVisible(r));else if(Ze[t]){let r=bs(t,i),n=Qe.getNextEleById(i.gId);n?H.gCanvas.insertBefore(r,n):Qe.switchLayer(r,i.layer)}}setItemOrderArr(){let t=TS();this.jsonCache.itemOrder.sort((i,r)=>{let{zIndex:n,layer:s}=k.getById(i).json,{zIndex:a,layer:o}=k.getById(r).json;if(s!==o){let l=t.get(s),c=t.get(o);return l-c}return n-a})}refreshSelected(t){var s;Ae.getIds().filter(a=>t.some(({data:o})=>o.gId===a)).forEach(a=>le(a).classList.add(wg));let r=new Map,n=((s=k.selectedRepeater)==null?void 0:s.getSelectMap())||new Map;t.forEach(({data:a})=>{let o=n.get(a.gId);o&&r.set(a.gId,o)}),pi.appendSelectStroke(r,!0),ac(void 0,hf())}deleteJsonCacheData(t){t.forEach(i=>{var n;let r=this.getJsonById(i);r&&((n=this.jsonCache[r.cmdKey])==null||delete n[r.gId])})}async getJsonCacheByMergeDataMap(){await this.decodeStatus;let t=k.getDefaultGJsonCache();return this.mergeDataMap.forEach((i,r)=>{if(i){let n=i.cmdKey?i.cmdKey:r;if(["canvas","detail"].includes(n))Object.assign(t.head,i);else if(Ze[n]){let{gId:s}=i;if(this.isIllegal(i))return;if(sr(t,n)[s]=i,n==="dimension"){let a=k.getById(i.start.id).json;a?Nh(a.cmdKey,i.start,a):this.fixDimensionMap.set(i.start.id,i.start),a=k.getById(i.end.id).json,a?Nh(a.cmdKey,i.end,a):this.fixDimensionMap.set(i.end.id,i.end)}else{let a=this.fixDimensionMap.get(s);a&&(this.fixDimensionMap.delete(s),Nh(n,a,i))}}}}),this.mergeDataMap.clear(),t}handleBlob(t,i){Wn.decBlob(t,i),Wn.imageHashMap.forEach((r,n)=>{if(r===t){let s=this.getJsonById(n);s&&(s.content=i.content,this.addMergeData(n,{...s}))}})}getJsonById(t){return this.mergeDataMap.get(t)||k.getById(t).json}onChangeNum(t,i){let r=this.mergeDataMap.get(t)||k.getById(t).json;r&&(r.id=this.numberToId(i))}numberToId(t){return"e"+t}onDelete(t){if(Wn.imageDataMap.get(t)){Wn.imageDataMap.delete(t);for(let[r,n]of Wn.imageHashMap.entries())if(n===t)return Wn.imageHashMap.delete(r)}this.mergeDataMap.set(t,null),this.groupElementsMap.delete(t);let i=this.groupCombinationMap.get(t)||this.groupElementsMap.get(t);if(i){this.groupElementsMap.delete(t),this.groupCombinationMap.delete(t);let r=this.getGroupData(i);this.mergeDataMap.set(i,r)}}addMergeData(t,i){this.mergeDataMap.set(t,i)}getOldData(t){let i=this.mergeDataMap.get(t);"detail","canvas";{let n={};for(let s in i)n[s]=this.jsonCache.head[s];return n}}handleDeleteStroke(t){t.forEach(i=>{var n;let r="#select-for-"+i;(n=Hr(r))==null||n.forEach(s=>s.remove())})}isDifferObject(t={},i={}){let r=JSON.stringify(t),n=JSON.stringify(i);return r!==n}getGroupData(t){var r;let i=this.mergeDataMap.get(t)||((r=this.jsonCache.combination)==null?void 0:r[t]);if(i){let n={...i};return n.elements=[],n.combinations=[],this.groupElementsMap.forEach((s,a)=>{t==s&&n.elements.push(a)}),this.groupCombinationMap.forEach((s,a)=>{t==s&&n.combinations.push(a)}),n}}getJsonCache(){return this.jsonCache}exchangeMgrJsonCache(t){let i=k.exchangeJsonCache(this.jsonCache);try{t()}finally{i()}}verifyData(t){return!((t==null?void 0:t.cmdKey)==="obj"&&!(t!=null&&t.content))}isIllegal(t){switch(t.cmdkey){case"group":{let{x:s,y:a,width:o,height:l}=vi(t);if(ni(o,0)&&ni(l,0))return!0}break;case"rect":let i=t,{width:r,height:n}=Li.getRectFromMatrix(i.matrix);if(ni(r,0)||ni(n,0))return!0;break;case"arc":{let s=t;if(sa({x:s.x1,y:s.y1},{x:s.x2,y:s.y2}))return!0}break;default:break}return!1}};var df=class e extends s2{constructor(i,r,n,s=new eg(!1)){super(i,r,n,s);this.decoders=new vS;this.channel=s}static async getJsonCache(i,r){let n=(await H.windowBridge.rpcCall("getActiveProject",null,ut())).message,s=r===n,a=new e(i,r,s,new eg(!0));if(!(await a.init(!0,!0,!1,!1)).success)return{};let l=await a.getJsonCache();return a.destroy(),l}async init(i=!0,r=!0,n=!0,s=!0){let a=await super.init(i,r,n);return s&&this.resetZIndex(),a}async resetZIndex(){let i=await this.getJsonCache(),r=k.exchangeJsonCache(i),n=i.itemOrder.map(s=>{var a;return(a=k.getById(s).json)==null?void 0:a.zIndex});n.length!==new Set(n).size&&(i.itemOrder.forEach((s,a)=>{let o=k.getById(s).json;o&&(o.zIndex=a+1,this.uploadData(s,o))}),this.save()),r()}async getJsonCache(){try{await this.decoders.decodeStatus}catch{}finally{return this.decoders.getJsonCache()}}async save(){let i=await this.getJsonCache();return Nu.uploadData("canvas",i.head,this),super.save()}async getMergeDataJsonCache(){return await this.decoders.getJsonCacheByMergeDataMap()}uploadData(i,r){Nu.uploadData(i,r,this)}uploadHistoryData(i){jl(i[0])||(i=[i]),this.setHistoryDataDefaultZIndex(i),i.forEach(r=>{let n=r[0];if(n==="elePosition")return;if(n==="originXY")return this.uploadData("canvas");let s=r[1],a=k.getById(s).cmdKey;(a==="combination"?Mt(r[3]||{}):Mt(r[4]||{}))?zo.uploadDeleteById(s,a):n==="combine-json"?Nu.uploadCombination(r[3],r[2]):n==="json"&&this.uploadData(s)})}setHistoryDataDefaultZIndex(i){let r=new Map;i.filter(n=>{var s;return n[0]==="json"&&!Mt(n[4])&&((s=k.getById(n[1]).json)==null?void 0:s.zIndex)===void 0}).forEach(n=>r.set(n[1],n[4])),r.size&&k.getItemOrder().forEach(n=>{let s=r.get(n);if(s){let a=k.getById(n).json;a.zIndex=s.zIndex=++k.maxZIndex}})}pauseDateMerge(){this.channel.pause(),this.decoders.canMergeData=!1}async resumeDataMerge(){this.decoders.canMergeData=!0,this.channel.resume(),await this.getJsonCache(),this.decoders.mergeDataToJsonCache()}onDocDetail(i,r,n){this.decoders.addTask({type:"detail",client:i,ticket:r,data:n})}onDimension(i,r,n,s,a){this.decoders.addTask({type:"dimension",id:i,number:r,client:n,ticket:s,data:a})}onString(i,r,n,s,a){this.decoders.addTask({type:"string",id:i,number:r,client:n,ticket:s,data:a})}onPoly(i,r,n,s,a){this.decoders.addTask({type:"poly",id:i,number:r,client:n,ticket:s,data:a})}onGroup(i,r,n,s,a){this.decoders.addTask({type:"group",id:i,number:r,client:n,ticket:s,data:a})}onCanvas(i,r,n){this.decoders.addTask({type:"canvas",client:i,ticket:r,data:n})}onAuxLine(i,r,n,s,a){this.decoders.addTask({type:"auxLine",id:i,number:r,client:n,ticket:s,data:a})}onBlob(i,r,n,s,a){this.decoders.addTask({type:"blob",hash:i,client:r,ticket:n,data:s,pending:a})}onDelBlob(i,r,n,s){this.decoders.addTask({id:i})}onDelAuxLine(i){this.decoders.addTask({id:i})}onDelGroup(i){this.decoders.addTask({id:i})}onDelPoly(i){this.decoders.addTask({id:i})}onDelString(i){this.decoders.addTask({id:i})}onDelDimension(i){this.decoders.addTask({id:i})}onAuxLineNum(i,r){this.decoders.addTask({id:i,number:r})}onDimensionNum(i,r){this.decoders.addTask({id:i,number:r})}onStringNum(i,r){this.decoders.addTask({id:i,number:r})}onPolyNum(i,r){this.decoders.addTask({id:i,number:r})}onGroupNum(i,r){this.decoders.addTask({id:i,number:r})}canvasSelected(){return k.selectedRepeater.getSelect()}onSelectChange(i,r,n){k.selectedRepeater.changeSelect(i,r,n)}onSelectQuit(i,r){k.selectedRepeater.onDestroy(i,r)}};function IS(e){let t=k.exchangeJsonCache(e),i=new Map;k.iterator((r,n,s)=>{i.set(s,{...r,cmd:n,gId:s})}),k.iteratorDimension(r=>{let n=i.get(r.start.id);n&&Nh(n.cmd,r.start,n),n=i.get(r.end.id),n&&Nh(n.cmd,r.end,n)}),t()}function Nh(e,t,i){let r=new I1;switch(e){case"rect":{let n=r.loadPointsOfRect(i);vg(n,t);break}case"ellipse":{let n=r.loadPointsOfEllipse(i);vg(n,t);break}case"obj":{let n=r.loadPointsOfImage(i);vg(n,t);break}case"text":{let n=r.loadPointsOfText(i);vg(n,t);break}case"group":{let n=r.loadPointsOfGroup(i);vg(n,t);break}case"arc":{let n=r.loadPointsOfArc(i);vg(n,t);break}default:console.error(e,"Plz check code");break}}function vg(e,t){for(let i of e)if(sa(t.primitivePoint,{x:i.getX(),y:i.getY()})){t.index=i.getIndex(),t.cmdKey=i.getCmdkey();return}console.error("not matched, check code")}async function zB(e){await GB(e),FQ(e),GQ(e),IS(e),kQ(e)}function kQ(e){let t=k.exchangeJsonCache(e),i=new Set([]);k.iterator((r,n,s)=>{switch(n){case"group":{let{x:c,y:u,width:h,height:d}=vi(r);ni(h,0)&&ni(d,0)&&i.add(s)}break;case"rect":let a=r,{width:o,height:l}=Li.getRectFromMatrix(a.matrix);(ni(o,0)||ni(l,0))&&i.add(s);break;case"arc":{let c=r;sa({x:c.x1,y:c.y1},{x:c.x2,y:c.y2})&&i.add(s)}break;default:break}});for(let r of i)k.removeOne({id:r});k.removeItemOrder(i),t()}function FQ(e){let t=e.auxiliaryLine||{};for(let i in t){let r=t[i],n=$p(r.x,r.y,r.rotation);r.x1=n.start().x,r.y1=n.start().y,r.x2=n.end().x,r.y2=n.end().y}}function GQ(e){let t=k.exchangeJsonCache(e);k.iterator((i,r,n)=>{i.cmdKey=r,i.gId=n,["dimensionAngle","dimensionLength","dimensionRadius"].includes(r)&&(i.rotation=0),i.cmdKey==="group"&&(i.d=SS(i.d))}),t()}function UQ(e){let t=e.length,i=0;return()=>{for(;i<t;){let r=e.indexOf(`
`,i);r<0&&(r=t);let n=e.substring(i,r);if(i=r+1,n)try{return JSON.parse(n)}catch(s){console.error(s)}}}}function M1(e){let[t,i,r,n,s,a,o,l,c]=e.data;return[t,i,n,s,o,l]}function AS(e){let t=H.uploadSvgFileMaxMB*1048576;if(!(s=>(s.length-30)*.75>t)(e))return e;let r=!(typeof window=="object"&&typeof document=="object")&&typeof importScripts=="function",n={bytesLimit:t,maxWidth:2160,maxHeight:2160};return(async()=>r?(await H.messageBus.rpcCall("/panel/resizeImageFromURL",[e,n])).message.dataURL:(await xS(e,n)).dataURL)()}async function XB(e,t=!1){console.debug("decompressing...",e);let{dataStr:i,json:r,docType:n,title:s,display_title:a}=e;if(n!==ta.PANEL&&n!==ta.PANEL_LIB)throw new Error(`invalid doctype(${JSON.stringify(n)}), need panel(${ta.PANEL})`);n===ta.PANEL_LIB&&(t=!0);let o={DOCTYPE:d},l={head:{title:s,display_title:a,docType:n,maxId:0,version:m2,name:"name",material:"PVC",thickness:"0.2mm",craft:"Transparent",desc:"xxxxx",width:787,height:1181}},c=0,u=UQ(i||r);for(;;){let f=u();if(f)try{await h(f[0])(f)}catch(m){console.error(m)}else break}return o.__POST_PROCESS__&&o.__POST_PROCESS__(),p(),console.debug("decompressed",l),await zB(l),l;function h(f){let m=o[f];return m||(console.warn(`unsupported command ${f}`),()=>{})}function d(f){c=parseFloat(f[2]);let m={decoders:o,jsonCache:l,docVersion:c,sync:t};c>=2?VQ(m):HQ(m)}function p(){let f={decoders:o,jsonCache:l,docVersion:c,sync:t};c<=1&&YQ(f)}}function YQ(e){let{jsonCache:t}=e,i={group:r,text:n,obj:s,rect:a,ellipse:o};for(let l in t){let c=i[l];if(c){let u=t[l];for(let h in u)c(h,u[h])}}function r(l,c){c.rotation=0,c.displayFill=!0,c.displayStroke=!0,c.visible=!0}function n(l,c){let{x:u,y:h,rotation:d,mirror:p,widthPercent:f,heightPercent:m,cacheHeight:g,cacheWidth:b,hAlign:y,vAlign:E}=c;g=g||0,b=b||0;let S=0;switch(y){case 1:S=-b/2;break;case 2:S=-b;break}let w=0;switch(E){case 1:w=g/2;break;case 0:w=g;break}let x=de.translate(S,w).scale(f,m).rotateD(-d);p&&(x=x.multiply3(de.MIRROR_X)),x=x.translate(u,h),c.matrix=M1(x),c.visible=!0}function s(l,c){let{x:u,y:h,width:d,height:p,rotation:f,mirror:m}=c,g=de.scale(d,p).rotateD(-f);m&&(g=g.multiply3(de.MIRROR_X)),g=g.translate(u,-h),c.matrix=M1(g),c.visible=!0,delete c.x,delete c.y,delete c.width,delete c.height,delete c.mirror}function a(l,c){let{x:u,y:h,endX:d,endY:p,rotation:f,isCCW:m}=c,g=de.scale(d-u,p-h).rotateD(-f);m&&(g=g.multiply3(de.MIRROR_X)),g=g.translate(u,h),c.matrix=M1(g),c.displayFill=!0,c.displayStroke=!0,c.visible=!0,delete c.x,delete c.y,delete c.endX,delete c.endY,delete c.isCCW}function o(l,c){let{cx:u,cy:h,rx:d,ry:p,rotation:f,isCCW:m}=c,g=de.scale(d,p).rotateD(-f);m&&(g=g.multiply3(de.MIRROR_X)),g=g.translate(u,h),c.matrix=M1(g),c.displayFill=!0,c.displayStroke=!0,c.visible=!0,delete c.cx,delete c.cy,delete c.rx,delete c.ry,delete c.isCCW}}function VQ(e){let{decoders:t,jsonCache:i,sync:r}=e;Object.assign(t,{HEAD:a,LOCK:o,HIDE:u,INVISIBLE:c,COVER:l,TRN_CTRL:b,COMMENT:y,POLY:E,STRING:R,FONT_CACHE:F,TRANSFORM:h,AUXLINE:g,DIMENSION:p,GROUP:d,__POST_PROCESS__:V});let n={},s=new Array;i.itemOrder=s;function a(C){Object.assign(i.head,C[1]),i.head.originY=-(i.head.originY||0)}function o(C){let N=C[1];for(let T of N)T in n?n[T].locked=!0:console.warn(`LOCK ${T} not found`)}function l(C){let N=C[1],T=C[2];N in n?n[N].cover=!!T:console.warn(`COVER ${N} not found`)}function c(C){let N=C[1];for(let T of N)T in n?n[T].visible=!1:console.warn(`INVISIBLE ${T} not found`)}function u(C){let N=C[1];for(let T of N)T in n?n[T].hide=!0:console.warn(`HIDE ${T} not found`)}function h(C){let N=C[1];if(N in n){let[T,L,P,B,U,X]=C[2],J=new de([T,B,0,L,U,0,P,X,1]);J=de.MIRROR_Y.multiply3(J).multiply3(de.MIRROR_Y),n[N].matrix=M1(J)}else console.warn(`TRANSFORM ${N} not found`)}function d(C){let N=`e${C[1]}`,T=`e${C[2]}`,L=C[3],P=!!C[4],B=!!C[5],U={gId:N,name:L,locked:B,visible:P,cmdKey:"combination",parent:C[2]===0?null:T,combinations:[],elements:[]};n[N]=U,sr(i,"combination")[N]=U}function p(C){let N=new Array,T=C[7];for(let P=0;P<T.length-1;P+=2)N.push(new j(T[P],T[P+1]));let L=C[8];switch(C[3]){case"LENGTH-CONSTRAINT":case"LENGTH-MEASUREMENT":{let[P,B,U,X]=N,J=P.x===B.x?"x":P.y===B.y?"y":"xy",ne=f(C[3]),fe={name:"",gId:C[1],cmdKey:"dimension",layer:C[2],category:ne,direction:J,start:{id:L[0],index:0,cmdKey:"",primitivePoint:{x:P.x,y:-P.y},otherPoint:{x:B.x,y:-B.y}},end:{id:L[1],index:0,cmdKey:"",otherPoint:{x:U.x,y:-U.y},primitivePoint:{x:X.x,y:-X.y}},visible:!0,locked:!1};M("dimension",C[1],0,fe);break}case"RADIUS-MEASUREMENT":{let[P,B,U]=N,X={name:"",gId:C[1],cmdKey:"dimensionRadius",layer:C[2],x1:P.x,y1:-P.y,x2:B.x,y2:-B.y,textX:U.x,textY:-U.y,locked:!1,visible:!0,ellipseId:L[0]};M("dimensionRadius",C[1],0,X);break}case"ANGLE":{let[P,B,U,X]=N,J={name:"",gId:C[1],cmdKey:"dimensionAngle",layer:C[2],x1:P.x,y1:-P.y,angleX:B.x,angleY:-B.y,x2:U.x,y2:-U.y,textX:X.x,textY:-X.y,locked:!1,visible:!0};M("dimensionAngle",C[1],0,J);break}case"LENGTH":{let[P,B,U,X]=N,J=P.x===B.x?"x":P.y===B.y?"y":"xy",ne={name:"",gId:C[1],cmdKey:"dimensionLength",layer:C[2],x1:P.x,y1:-P.y,measureX1:B.x,measureY1:-B.y,measureX2:U.x,measureY2:-U.y,x2:X.x,y2:-X.y,direction:J,locked:!1,visible:!0,rotation:0};M("dimensionLength",C[1],0,ne);break}}}function f(C){switch(C){case"LENGTH-MEASUREMENT":return"Annotation";case"LENGTH-CONSTRAINT":return"Constraint";default:throw new Error(`unknown dimension type ${JSON.stringify(C)}`)}}function m(C){if(C!==null)return C===""?null:C}function g(C){if(C[10]===0){let N={gId:C[1],cmdKey:"auxiliaryPoint",visible:!0,name:"",layer:C[3],x:C[4],y:-C[5],fillColor:m(C[9]),locked:!1};M("auxiliaryPoint",C[1],C[2],N)}else{let N={gId:C[1],name:"",layer:C[3],x:C[4],y:-C[5],rotation:C[6],strokeStyle:C[8],strokeColor:m(C[9]),locked:!1};M("auxiliaryLine",C[1],C[2],N)}}function b(C){let N=C[1],T=C[2],L=C[3],P=C[4];if(N in n){let B=n[N];switch(T){case 1:B.transparencyPrint=1-(L!==void 0?L:B.opacity),B.transparencyWhite=1-(P!==void 0?P:1);break;case 2:B.transparencyPrint=1-(L!==void 0?L:1),B.transparencyWhite=1-(P!==void 0?P:B.opacity);break;case 3:B.transparencyPrint=1-(L!==void 0?L:B.opacity),B.transparencyWhite=1-(P!==void 0?P:B.opacity);break;default:}}else console.warn(`TRN_CTRL ${N} not found`)}function y(C){let N=C[1],T=C[2];N in n?n[N].name=T:console.warn(`COMMENT ${N} not found`)}function E(C){let N=!!(C[12]||C[12]===void 0),T=!!(C[13]||C[13]===void 0);if(C[11].length===1){let L=C[11][0];switch(L[0]){case"R":return x(C,N,T);case"ELLIPSE":return S(C,N,T);case"M":return L[3]==="A"||L[3]==="CA"?w(C,N,T):O(C,N,T);default:return O(C,N,T)}}else return O(C,N,T)}function S(C,N,T){let L={layer:C[3],rotation:-C[4],strokeWidth:C[5],strokeStyle:C[6],strokeColor:C[7],fillColor:C[8],opacity:C[9],displayFill:N,displayStroke:T};M("ellipse",C[1],C[2],L)}function w(C,N,T){let[,L,P,B,U,X,J,ne,fe,xe,ve]=C[11][0],Fe={layer:C[3],rotation:-C[4],strokeWidth:C[5],strokeStyle:C[6],strokeColor:C[7],fillColor:C[8],opacity:C[9],displayFill:N,displayStroke:T,x1:L,y1:-P,rx:U,ry:X,angle:J,large:ne,sweep:fe,x2:xe,y2:-ve,type:B==="CA"?1:2};M("arc",C[1],C[2],Fe)}function x(C,N,T){let L=C[8];if(L.startsWith("data:")||L.startsWith("blob:"))return I(C,L);{let P=C[11][0],B={layer:C[3],rotation:-C[4],strokeWidth:C[5],strokeStyle:C[6],strokeColor:C[7],fillColor:L,opacity:C[9],rx:P[5],ry:P[6],displayFill:N,displayStroke:T};M("rect",C[1],C[2],B)}}function I(C,N){if(N){let T=/^blob:(.+)$/.exec(N);return T?(async()=>{let L=T[1],{dataUrl:P}=(await H.messageBus.rpcCall("/pro-mgr/getBlob",{hash:L})).message;P&&(P=await AS(P),A(C,P))})():(async()=>{let L=await AS(N);A(C,L)})()}}function A(C,N){let T={gId:C[1],layer:C[3],rotation:-C[4],content:N,opacity:C[9],locked:!1};M("obj",C[1],C[2],T)}function O(C,N,T){let L=G(C[11]).d,P={layer:C[3],rotation:-C[4],strokeWidth:C[5],strokeStyle:C[6],strokeColor:C[7],fillColor:C[8],opacity:C[9],d:L,displayFill:N,displayStroke:T};M("group",C[1],C[2],P)}function R(C){let N={layer:C[3],rotation:-C[4],key:C[5],name:C[5],fontFamily:C[6],fontSize:C[7],fontWeight:C[8],italic:C[9]===1,underline:C[10]===1,strikeout:C[11]===1,vAlign:-(C[12]/3|0)+2,hAlign:C[12]%3,strokeColor:C[13],opacity:C[14]};M("text",C[1],C[2],N)}function M(C,N,T,L){var P;if(n[N]=L,s.push(N),L.zIndex=s.length+1,typeof L.hide!="boolean"&&(L.hide=!1),typeof L.visible!="boolean"&&(L.visible=!0),typeof L.locked!="boolean"&&(L.locked=!1),typeof L.layer!="number"&&(L.layer=1),typeof L.opacity!="number"&&(L.opacity=1),typeof L.cover!="boolean"&&(L.cover=!1),typeof L.scope!="number"&&(L.scope=1),typeof L.name!="string"&&(L.name=""),!L.matrix&&!["group","arc","dimensionLength","dimensionAngle"].includes(C)&&(L.matrix=[1,0,0,1,0,0]),sr(i,C)[N]=L,T>0){let B=`e${T}`,U=(P=i.combination)==null?void 0:P[B];U?U.elements.push(N):console.warn("GROUP",T,"not found")}}function F(C){let{bbox:N,d:T}=G(C[2]),L=n[C[1]];L.d=T,L.cacheWidth=N.width(),L.cacheHeight=N.height()}function G(C){let N=new ot,T=C.map(L=>{let P="";return new so(B=>(N.ext1(B.bbox()),P=new Da().encPl(B).toString(),!1),!0).parse("M"+L.join(" ")),P}).join(" ");return{bbox:N.build(),d:T}}function V(){q()}function q(){ro(i.combination,(C,N)=>{if(N.parent){let T=n[N.parent];T?T.combinations.push(C):(console.warn("parent combination",N.parent,"not found"),N.parent=null)}})}}function HQ(e){let{decoders:t,jsonCache:i,sync:r}=e;Object.assign(t,{HEAD:a,LOCK:o,HIDE:l,COVER:c,TRN_CTRL:u,COMMENT:h,POLY:d,STRING:y,FONT_CACHE:S});let n={},s=new Array;i.itemOrder=s;function a(x){Object.assign(i.head,x[1]),i.head.originY=-(i.head.originY||0),i.head.print==="AHead Side"&&(i.head.print="Ahead Side")}function o(x){let I=x[1];for(let A of I)A in n?n[A].locked=!0:console.warn(`LOCK ${A} not found`)}function l(x){let I=x[1];for(let A of I)A in n?n[A].hide=!0:console.warn(`HIDE ${A} not found`)}function c(x){let I=x[1],A=x[2];I in n?n[I].cover=!!A:console.warn(`COVER ${I} not found`)}function u(x){let I=x[1],A=x[2],O=x[3],R=x[4];if(I in n){let M=n[I];switch(A){case 1:M.transparencyPrint=1-(O!==void 0?O:M.opacity),M.transparencyWhite=1-(R!==void 0?R:1);break;case 2:M.transparencyPrint=1-(O!==void 0?O:1),M.transparencyWhite=1-(R!==void 0?R:M.opacity);break;case 3:M.transparencyPrint=1-(O!==void 0?O:M.opacity),M.transparencyWhite=1-(R!==void 0?R:M.opacity);break;default:}}else console.warn(`TRN_CTRL ${I} not found`)}function h(x){let I=x[1],A=x[2];I in n?n[I].name=A:console.warn(`COMMENT ${I} not found`)}async function d(x){if(x[11].length===1)switch(x[11][0][0]){case"R":return await f(x);case"ELLIPSE":return p(x);default:return b(x)}else return b(x)}function p(x){let I=x[11][0],A={layer:x[3],strokeWidth:x[4],strokeStyle:x[5],strokeColor:x[6],fillColor:x[7],opacity:x[8],cx:I[1],cy:-I[2],rx:I[3],ry:I[4],rotation:+I[5],isCCW:+I[6],name:x[12]};E("ellipse",x[1],A)}async function f(x){let I=x[7];if(I.startsWith("data:")||I.startsWith("blob:"))await m(x,I);else{let A=x[11][0],O={layer:x[3],strokeWidth:x[4],strokeStyle:x[5],strokeColor:x[6],fillColor:I,opacity:x[8],x:A[1],y:-A[2],endX:A[1]+A[3],endY:-A[2]+A[4],rx:A[5],ry:A[6],rotation:+A[7],isCCW:+A[8],name:x[12]};E("rect",x[1],O)}}async function m(x,I){if(I){let A=/^blob:(.+)$/.exec(I);return A?(async()=>{let O=A[1],{dataUrl:R}=(await H.messageBus.rpcCall("/pro-mgr/getBlob",{hash:O})).message;R&&(R=await AS(R),g(x,R))})():(async()=>{let O=await AS(I);g(x,O)})()}}function g(x,I){let[A,O,R,M,F,G,V,q,C]=x[11][0],N=de.rotateD(q);C&&(N=N.multiply3(de.MIRROR_X));let T;C?T=new ie(new j(0,0),new j(0,-F)).multiply3(N):T=new ie(new j(0,0),new j(M,0)).multiply3(N);let L={gId:x[1],layer:x[3],content:I,opacity:x[8],mirror:C===1,width:C===1?F:M,height:C===1?M:F,rotation:T.end().angleD(T.start()),x:O,y:R,locked:!1,name:x[12]};E("obj",x[1],L)}function b(x){let I=w(x[11]).d,A={layer:x[3],strokeWidth:x[4],strokeStyle:x[5],strokeColor:x[6],fillColor:x[7],opacity:x[8],d:I,name:x[12]};E("group",x[1],A)}function y(x){let I={layer:x[3],x:x[4],y:-x[5],rotation:x[6],mirror:x[7]===1,key:x[8],name:x[8],fontFamily:x[9],fontSize:x[10],fontWeight:x[11],italic:x[12]===1,underline:x[13]===1,strikeout:x[14]===1,vAlign:-(x[15]/3|0)+2,hAlign:x[15]%3,strokeColor:x[16],opacity:x[17],widthPercent:x[18]||1,heightPercent:x[19]||1};E("text",x[1],I)}function E(x,I,A){n[I]=A,s.push(I),A.zIndex=s.length+1,typeof A.hide!="boolean"&&(A.hide=!1),typeof A.locked!="boolean"&&(A.locked=!1),typeof A.layer!="number"&&(A.layer=1),typeof A.opacity!="number"&&(A.opacity=1),typeof A.cover!="boolean"&&(A.cover=!1),typeof A.scope!="number"&&(A.scope=1),typeof A.name!="string"&&(A.name=""),sr(i,x)[I]=A}function S(x){let{bbox:I,d:A}=w(x[2]),O=n[x[1]];O.d=A,O.cacheWidth=I.width(),O.cacheHeight=I.height()}function w(x){let I=new ot,A=x.map(O=>{let R="";return new so(M=>(I.ext1(M.bbox()),R=new Da().encPl(M).toString(),!1),!1).parse("M"+O.join(" ")),R}).join(" ");return{bbox:I.build(),d:A}}}var{IS_CLIENT:WB,IS_EASYEDA:$_e,IS_PRIVATE:Z_e,IS_ONLINE:Q_e,IS_HALF_OFFLINE:ePe,IS_OFFLINE:tPe}=tI;var Tg=class{constructor(t,i=R0){this.options=i;this.hasLocked=!1;this.success=!1;this.degree=0;this.objs=t.filter(r=>{let n=Gi.isLockedById(r.id);return this.hasLocked=n,!n}).filter(r=>$t(r)!=="dimension")}do(t){let{hasLocked:i}=this;if(i){qa();return}if(!this.objs.length)return;if(this.degree=tr(this.degree+t),this.options.notSaveHistory){Hc(this.objs,t),fr(this.objs,{create8Dots:!1});return}let r=zt.createContext(!0);this.objs=co(this.objs).filter(s=>k.getById(s.id).cmdKey!=="auxiliaryLine");for(let s of this.objs){let{cmdKey:a,json:o}=k.getById(s.id);Nn(a)&&Ke.jsonSnap.addOne(o)}Hc(this.objs,t),r();let n=is(this.objs);n.length&&fr(n,{create8Dots:!0}),new Ni().updateHole(),this.success=!0}};Tg=Ws([Pa(Sn.rotate)],Tg);function Ig(e,t=.01){return e.closed()?!1:e.primitives.length===1&&e.primitives[0]instanceof ie?!0:!(e.end().distance2(e.start())<=t*t)}function Ag(e,t=.01){let i=e.map((o,l)=>({polyline:o,index:l,op:0})),r={removedItems:[],updatedItems:[],noChangeItems:i},n=[],s=[];if(i.forEach(o=>{let{polyline:l}=o;Ig(l)?s.push(o):n.push(o)}),s.length<2)return r;let a=s;for(let o=0;o<a.length;o++){let l=a[o],c=l.polyline,u,h=o+1;for(;h<a.length;h++){let d=a[h],p=d.polyline,f=[c.start(),c.end(),p.start(),p.end()],m=f[0].distance1(f[2]),g=f[0].distance1(f[3]),b=f[1].distance1(f[2]),y=f[1].distance1(f[3]),E=Math.min(m,g,b,y);if(!(E>=t)){if(g==E)[c,p]=[p,c];else if(m==E)c=c.reverse();else if(y==E)p=p.reverse();else if(b!=E)continue;if(u=Tt.build2(c.primitives.concat(p.primitives)),c=u,l.polylineNew=u,l.op=1,d.op=2,a.splice(h,1),h=o,!Ig(u))break}}}return r={removedItems:i.filter(o=>o.op==2),updatedItems:i.filter(o=>o.op==1),noChangeItems:i.filter(o=>o.op==0)},r}var CS=new Error,qB=new class extends Wa{decide1(t){return t[0]&&t[1]}}(2),jQ=new class extends Lm{onPolylineGroup(){throw CS}onSegment(){throw CS}},jC=class{constructor(t,i){this.rtree=t,this.level=i}},DS=class e extends hg{static isIntersect(t,i,r=Bc.DUMMY){let n=new e(r),s=n.createGroup1(t.items),a=n.createGroup2(i.items);if(s.rtree.itemList.length==0||a.rtree.itemList.length==0)return!1;let o=[];return ps.addAll(o,e.getInterY(t.items)),ps.addAll(o,e.getInterY(i.items)),n.isIntersect(s,a,o)}static getInterY(t){let i=[];for(let r of t){let n=r.bbox(),s=(n.minY+n.maxY)/2;i.push(s)}return i}constructor(t){super(new dg(!1),qB.rule,t,jQ)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=qB.weight(i);for(let s of t)this.addPolyline(s,r);let n=this.buildRTree();return this.sides.length=0,new jC(n,i)}isIntersect(t,i,r){if(t.level!==i.level){let n=t.rtree.bbox().intersection1(i.rtree.bbox());if(n!==null){try{this.inters(t,i);let s=(n.minY+n.maxY)/2;this.sweep(t,i,s);for(let a of r)this.sweep(t,i,a)}catch(s){if(s===CS)return!0;throw s}return!1}else return!1}else throw new Error("inersection detection should not in same group")}inters(t,i){if(t.rtree.size()>i.rtree.size()){let r=t;t=i,i=r}for(let r of t.rtree.items()){r.trans=NaN;let n=r.bbox().extendOfSize(1e-5);for(let s of i.rtree.search(n))if(s.trans=NaN,Gc(r.shape,s.shape)>0)throw CS}}fillValidSides(t,i,r){for(let n of i)isFinite(n.getX(r))&&t.push(n)}sweep(t,i,r){let n=St.extend2(t.rtree.bbox(),i.rtree.bbox()).extendOfSize(1e-5),s=new Array;this.fillValidSides(s,t.rtree.search(n),r),this.fillValidSides(s,i.rtree.search(n),r),ql(s,(o,l)=>o.getX(r)-l.getX(r),0,s.length);let a=new fg(this.rule,this,r);for(let o of s)a.onEp(o)}};function JB(e){let t=["substrate_transparent_acrylic","substrate_black_transparent_acrylic","substrate_glossy_transparent_pvc","substrate_frosted_transparent_pvc","substrate_glossy_transparent_pet","substrate_frosted_transparent_pet"],{material:i,craft:r}=e,n={acrylic:["Transparent","Black Translucent"],PVC:["Glossy Transparent","Frosted Translucent"],PET:["Glossy Transparent","Frosted Translucent"]},s="";if($e(n,i)){let a=n[i],o=a.indexOf(r);o>=0&&(s="substrate_"+a[o]+"_"+i,s=s.toLocaleLowerCase())}return t.includes(s)?s:t[0]}function KB(e){var i;return(i=/url\(#(.*)\)/.exec(e))==null?void 0:i[1]}var zC=47,zQ=47,_S="three-m",XC=` 
<pattern id="${_S}" patternUnits="userSpaceOnUse" x="0" y="0" width="${zC}" height="${zQ}">
    <rect x="0" y="0" width="${zC}" height="${zC}" fill="white" />

    <path d="m16.4 9.9 l 0.3-2.3s3.53-0.379 5.05 2.09c1.37 2.25 0.98 4.36-0.2 5.33-2.01 1.64-3.85 0.68-3.85 0.68s1.13 2.05-0.23 3.97c-1.16 1.65-3.43 2.82-6.27 0.74-3.13-2.3-2.5-5.41-2.5-5.41l2.2-0.4s0.1 2.4 1.1 3.4 2.66 1.56 3.72-0.34c0.69-1.24-1.52-3.76-1.52-3.76l1.5-1.5s1.31 1.75 2.3 1.6c2.41-0.37 2.09-2.28 1.09-3.28-1-1-2.69-0.82-2.69-0.82z M16 25 l 10.3-10.3 2.1 2.2-4.3 9 8.8-4.5 2.1 2.2-10.1 10.4-1.8-1.8 7.8-7.6-9 4.5-1.1-1.1 4.4-9.2-7.5 8z" fill="#a54949"/>
</pattern>
`;function XQ(e){let i={[_S]:XC}[e];return i||Kr("Not exists exact pattern: ",e),i}function $B(e,t,i,r,n,s){return`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${r}" viewBox="${e} ${t} ${i} ${r}">
        <defs>
            ${XQ(s)}
        </defs>

        ${n}
        </svg>
    `}var KQ=4,QB=0,e5=0;async function t5(e,t){let{width:i,height:r,coverColor:n,material:s,craft:a,print:o,thickness:l}=t,c=[],u=['["DOCTYPE", "BLOB", "1.0"]'],h=[],d={},p=10,f=3.937;QB=0,e5=0,A(["DOCTYPE","PREVIEW","1.0"]),A(["HEAD",{scale:p}]);let m=o=="Bottom Side"?2:1;A(["PRINT_METHOD",m]);let g=3;A(["LAYER",7,"BUN_LAYER","Bun Layer",g,"",.5,"",.3]),A(["LAYER",1,"PRINT_LAYER","Print Layer",g,"",.5,"",.3]),A(["LAYER",2,"WHITE_COVER_LAYER","White Cover Layer",g,"",.5,"",.3]),A(["LAYER",3,"BLACK_COVER_LAYER","Black Cover Layer",g,"",.5,"",.3]),A(["LAYER",4,"BOARD_LAYER","Board Outline Layer",g,"",.5,"",.3]),A(["LAYER",5,"GLUE_LAYER","Glue Cutout Layer",1,"",.5,"",.3]),A(["LAYER",6,"LIGHT_LAYER","Lighting Simulation Layer",g,"",.5,"",.3]);let b=JB({material:s,craft:a}),y=(parseFloat(l)||1)*f;A(["LAYER_PHYS",4,b,y,0,0]),A(["SILK_OPTS",7,"#000000","#ffffff"]),A(["SILK_OPTS",1,"#000000","#ffffff"]),A(["SILK_OPTS",2,"#000000","#ffffff"]),A(["SILK_OPTS",3,"#000000","#ffffff"]),A(["SILK_OPTS",5,"#000000","#ffffff"]),A(["SILK_OPTS",6,"#000000","#ffffff"]),A(["ITEM_ORDER",[]]);let E=c.length-1;await x(7),await x(1),await x(2),await x(3),await x(4),await x(8),await x(6),c[E]=ZB(["ITEM_ORDER",h]);let S=c.join(`
`);return{blobStr:u.join(`
`),dataStr:S};async function x(R){let M=e[R];for(let F=M.length-1;F>=0;F--){let G=M[F];await I(G,R)}}async function I(R,M){let{polylineGroup:F,fillColor:G,strokeColor:V,strokeWidth:q,strokeStyle:C,opacity:N,content:T,data:L}=R,P=ZQ(F);if(!(N<=0)){if(G.startsWith("url(#")){let B=KB(G),U=F.bbox(),X=[U.LL(),U.UL(),U.UR(),U.LR()].map(Ne=>[Ne.x,Ne.y]).flat(1),J=fs(F.multiply3(de.MIRROR_Y.setOrigin1(U.center())).items,!1,.01,{reverseY:!1}),ne=`<path d="M ${X} Z"
			 fill="url(#${B})" stroke-width="1" stroke="none" opacity="1"></path>`,fe=$B(U.minX,U.minY,U.width(),U.height(),ne,B),xe="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(fe))),ve=O(xe),Fe=PS();A(["TEXTURE",Fe,0,ve,5,X,0,P,N]),h.push(Fe);return}if(T&&L){let B=O(T),U=et.createMatrixFrom6(L.matrix),X=0,J=1,ne=0,fe=1,xe=[[X,fe],[X,ne],[J,ne],[J,fe]],ve=[];for(let nt of xe){let je=new j(nt[0],nt[1]).multiply3(U);ve.push(je.x,-je.y)}let Fe=P,Ne=PS();A(["TEXTURE",Ne,0,B,M,ve,0,Fe,N]),h.push(Ne)}else{let B=M==4;if(B&&(G="#ffffff",V="none"),G&&G!="none"){let U=PS();A(["FILL",U,0,"",M,0,0,P,0]),B||A(["PROP",U,G,N]),h.push(U)}if(V&&V!="none"&&q>0)for(let U of P){let X=PS();A(["POLY",X,0,"",M,q,U,0]),A(["PROP",X,V,N]),h.push(X)}}}}function A(R){c.push(ZB(R))}function O(R){if(d[R])return"blob:"+d[R];let M=$Q();return u.push(JSON.stringify(["BLOB",M,"",R])),d[R]=M,"blob:"+M}}function PS(){return"e"+ ++QB}function $Q(){return"b"+ ++e5}function ZB(e){return e=e.map(t=>typeof t=="boolean"?t?1:0:t),JSON.stringify(e)}function ZQ(e){return e.items.map(QQ)}function QQ(e){return tee(e).map(eee)}function eee(e){return typeof e=="number"&&e&&(e|0)!==e?+e.toFixed(KQ):e}function tee(e){let t=0;return e.primitives.reduce((i,r)=>(r instanceof ie||r instanceof Se&&r.rx===r.ry?i.push(r):r.points(.1).reduce((n,s)=>(s.equals1(n)||i.push(new ie(n,s)),s)),i),[]).reduce((i,r)=>{if(r instanceof ie){switch(t){case 0:i.push(r.start().x,r.start().y,"L",r.end().x,r.end().y);break;case 1:i.push(r.end().x,r.end().y);break;default:i.push("L",r.end().x,r.end().y)}t=1}else if(r instanceof Se){if(e.primitives.length>1||Math.abs(r.sweepAngle)<360)switch(t){case 0:i.push(r.start().x,r.start().y,"ARC",r.sweepAngle,r.end().x,r.end().y);break;case 2:i.push(r.sweepAngle,r.end().x,r.end().y);break;default:i.push("ARC",r.sweepAngle,r.end().x,r.end().y)}else i.push("CIRCLE",r.center.x,r.center.y,r.rx);t=2}return i},[])}function iee(e,t){let i=e-1;for(let r=0;r<i;r++)t.markRemove(r);i=t.size-1;for(let r=e-1;r<i;r+=e)t.markRemove(r);i=t.size-e;for(let r=t.size-1;r>i;r--)t.markRemove(r);i=0;for(let r=t.size-e;r>i;r-=e)t.markRemove(r)}function ree(e,t,i){let r=t[0]%e,n=t[0]/e|0,s=r,a=n,o=[new j(s,a)],l=0,c=0,u=new Set;for(let h=1;h<t.length;h++){let d=t[h]%e,p=t[h]/e|0;if(d===r&&p===n)continue;d>s?u.add("R"):d<s&&u.add("L"),p>a?u.add("U"):p<a&&u.add("D");let f=d-r,m=p-n,g=u.size===4;if(!g){let b=Math.sqrt(f**2+m**2),y=f/b,E=m/b;g=Math.abs(y*c-E*l)>i}if(g){if(u.clear(),o.length>1){let b=o[o.length-1],y=o[o.length-2];(b.x-s)*(y.y-a)+(b.y-a)*(y.x-s)===0&&o.pop()}o.push(new j(s,a)),r=s,n=a,l=c=0,f=d-r,m=p-n}l+=f,c+=m,s=d,a=p}if(o.length>1){let h=o[o.length-1],d=o[o.length-2];(h.x-s)*(d.y-a)+(h.y-a)*(d.x-s)===0&&o.pop()}if(o.length>2){let h=new j(s,a);return o[o.length-1].sub(h).cross(o[1].sub(h))===0?o[0]=o[o.length-1]:o.push(h),o}return[]}function r5(e,t,i=2,r=2){iee(e,t);let n=see(t,e),s=new Array;n.forEach(o=>{let l=new Array;o.forEach(c=>{let u=ree(e,c,i);u.length!==0&&l.push(u)}),s.push(l)});let a=[];for(let o of s){let l=[];a.push(l);for(let c of o)l.push(nee(c,r))}return a}function nee(e,t){if(e.length<2)throw new Error("The length of outline can't be less than 2!");if(!e[0].equals1(e[e.length-1]))throw new Error("The outline isn't closed!");let i=[],r=e[0];for(let s=1;s<e.length;s++){let a=e[s];i.push(a.add(r).scale(.5)),r=a}r=i[i.length-1];let n=[];for(let s=0;s<i.length;s++){let a=i[s],o=e[s],l=a.sub(r);if(Math.abs(l.cross(o.sub(r)))/l.length()>t){if(n[n.length-1]instanceof ie){let u=n.pop();n.push(new ie(u.start(),o))}else n.push(new ie(r,o));n.push(new ie(o,a))}else n.push(new Ye([r,o,a]));r=a}return Tt.build2(n)}function i5(e,t,i,r,n,s,a){let o=n===1?f=>{r[f]===0&&(r[f]=n)}:f=>r[f]=n,l=[t],c=t;r[e]=n,o(c);let u=!0,h=e;for(let f=0;f<7;f++)if(h=s(h,c),i.isUsed(h)){u=!1;break}if(u){h=e;for(let f=0;f<7;f++)h=s(h,c),r[h]=n;return l}let d=e,p=s(e,c);for(;p!==t;)i.isUsed(p)?(a(c,p,l),c=p,o(c),l.push(c)):(r[p]=n,d=p),p=s(d,c);return l.push(t),l}function see(e,t){let i=new Uint16Array(e.size),r=new Map;r.set(-t,-t+1),r.set(-t+1,1),r.set(1,t+1),r.set(t+1,t),r.set(t,t-1),r.set(t-1,-1),r.set(-1,-t-1),r.set(-t-1,-t);let n=(l,c)=>{let u=c+r.get(l-c);if(isFinite(u))return u;throw new Error("is not finit")},s=(l,c,u)=>{let h=l%t,d=c%t;if(h===d)return;let p=l/t|0,f=c/t|0;p!==f&&(e.isUsed(p*t+d)?u.push(p*t+d):e.isUsed(f*t+h)&&u.push(f*t+h))},a=[],o=e.size/t-1;for(let l=1;l<o;l++){let c=!0,u=new Array,h=(l+1)*t;for(let d=l*t;d<h;d++){if(d%32===0){let f=e.getChunk(d/32);if(c){if(f===0){d+=31;continue}}else if(f===2**32-1){d+=31;continue}}let p=e.isUsed(d);c?p&&(c=!1,i[d]===0&&a.push([i5(d-1,d,e,i,a.length+2,n,s)]),i[d]!==1&&u.push(i[d])):p||(c=!0,i[d]===0&&a[u[u.length-1]-2].push(i5(d,d-1,e,i,1,n,s)),i[d-1]===u[u.length-1]&&i[d]!==1&&u.pop())}}return a}function aee(e){let t=e.toString(2),i=32-t.length;return i>0?"0".repeat(i)+t:t}var LS=class{constructor(t,i=null,r=!0){this.marked=0;if(this.size=t,i)this.index=i;else{if(this.index=new Uint32Array(Math.ceil(t/32)),!r)return;for(let n=0;n<t;n++)this.isUsed(n)&&this.marked++}}isEmpty(){return this.marked===0}getMarked(){return this.marked}getChunk(t){return this.index[t]}isUsed(t){let i=t/32|0,r=this.index[i];return r===4294967295?!0:r===0?!1:(r>>31-t&1)===1}markUsed(t){let i=t/32|0,r=this.index[i],n=1<<31-t;(r&n)===0&&(this.index[i]=r|n,this.marked++)}markRemove(t){let i=t/32|0,r=this.index[i],n=1<<31-t;(r&n)!==0&&(this.index[i]=r&(4294967295^n),this.marked--)}reset(){let t=this.index;for(let i=0;i<t.length;i++)t[i]=0;this.marked=0}findEmpty(t=1){if(this.size-this.marked<t)return-1;let i=this.index,r=-1;for(let n=0;n<i.length;n++){let s=i[n];if(s===0){if(r===-1){if(r=n*32,t<=32)return r}else if((n+1)*32-r>=t)return r}else if(s!==4294967295)for(let a=31;a>=0;a--)if((s>>a&1)===0){let o=n*32+31-a;if(r===-1&&(r=o),o-r+1>=t)return r}else r=-1;else r=-1}return-1}hasNEmpty(t=1){return!(this.size-this.marked<t)}findNEmpty(t=1){let i=[];if(this.size-this.marked<t)return i;let r=this.index;for(let n=0;n<r.length;n++){let s=r[n];if(s===0){let a=n*32;if(i.indexOf(a)==-1){if(i.push(a),i.length>=t)return i;{let o=t-i.length;if(o<32){for(let l=0;l<o;l++)i.push(a+l+1);return i}else for(let l=0;l<31;l++)i.push(a+l+1)}}}else if(s!==4294967295){for(let a=31;a>=0;a--)if((s>>a&1)===0){let o=n*32+31-a;if(i.indexOf(o)==-1&&(i.push(o),i.length==t))return i}}}return[]}debug(){let t=[],i=this.index;for(let r=0;r<i.length;r++)t.push(aee(i[r]));console.log(t.join(" "))}};function oee(e,t,i,r){switch(t){case"ImageBitmap":case"OffscreenCanvas":case"FileBlob":return e;case"PixelDataBuffer":return new ImageData(new Uint8ClampedArray(e),i,r);case"FileBuffer":return new Blob([e]);case"DataURL":return lee(e);default:return null}}function lee(e){var t=e.split(","),i=t[0].match(/:(.*?);/)[1],r=uee(t[1]);return new Blob([r],{type:i})}function cee(e){return e>64&&e<91?e-65:e>96&&e<123?e-71:e>47&&e<58?e+4:e===43?62:e===47?63:0}function uee(e,t=1){for(var i=e.replace(/[^A-Za-z0-9\+\/]/g,""),r=i.length,n=r&3,s=(r>>>2)*3+(n==2?1:n==3?2:0),a=new Uint8Array(s),o,l,c=0,u=0,h=0;h<r;h++)if(l=h&3,c|=cee(i.charCodeAt(h))<<18-6*l,l===3||r-h===1){for(o=0;o<3&&u<s;o++,u++)a[u]=c>>>(16>>>o&24)&255;c=0}return a}async function n5(e){let{source:t,type:i,width:r=100,height:n=100,alphaLimit:s=15}=e,a=oee(t,i,r,n);if(!a)throw new Error("Image source is required");let o=1e3,l=1e3,c=100,u=100,h=1;(r>o||n>l)&&(h=Math.min(o/r,l/n)),(r<c||n<u)&&(h=h*Math.max(c/r,u/n)),r=Math.round(r*h),n=Math.round(n*h);let d,f=new OffscreenCanvas(r+3,n+3).getContext("2d");try{let y=await createImageBitmap(a,{resizeWidth:r,resizeHeight:n});f.drawImage(y,1,1,r+1,n+1),d=f.getImageData(0,0,r+3,n+3),y.close()}catch(y){throw console.error(y),new Error("Load image failed")}r+=3,n+=3;let m=new LS(r*n);for(let y=0;y<n;y++)for(let E=0;E<r;E++)d.data[((n-y-1)*r+E)*4+3]>s&&m.markUsed(y*r+E);let g=r5(r,m);return g=g.map(y=>y.map(E=>E.multiply3(de.translate(-1,-1)))),h!==1&&(g=g.map(y=>y.map(E=>E.multiply3(de.scale(1/h))))),new kr(g.flat())}var B1=class B1 extends Worker{constructor(t,i){t.startsWith("//")&&(t=self.location.protocol+t);let r=t;if(/^[\w-]+:/.test(t)&&self.location.origin!=new URL(t).origin&&(r=B1.proxyMap[t],!r)){let n=`importScripts('${t}');`;r=URL.createObjectURL(new Blob([n],{type:"application/javascript"})),B1.proxyMap[t]=r}super(r,i)}};B1.proxyMap={};var OS=B1;var RS=class{constructor(){this._workers=[];this._workerTaskId=[];this._tasks={};this._queueIds=[];this._runningIds=[];this._completedIds=[];this._promises=[];this._started=!1}init({url:t,workersCount:i=16,name:r="worker-pool"}){this._workers.length&&this.destroy();let n=(s,a,o)=>{if(!this._workers.length)return;let l=this._workerTaskId[s],c=this._tasks[l],u=this._runningIds.indexOf(l);u>=0&&this._runningIds.splice(u,1),c&&(c.endAt=new Date),this._completedIds.push(l),this._queueIds.length&&this.runNext(s),o?c.reject(o):c.resolve(a)};for(let s=0;s<i;s++){let a=this.createWorker(t,s,n,r);this._workers.push(a)}}addTask(t){let i=("_"+Math.random()).replace(/\W+/g,""),r={id:i,data:t,state:{started:!1,completed:!1,startAt:null,endAt:null},resolve:null,reject:null};this._tasks[i]=r,this._queueIds.push(i);let n=new Promise((s,a)=>{Object.assign(r,{resolve:s,reject:a})});return this._promises.push(n),n}all(){return Promise.all(this._promises)}get isStarted(){return this._started}start(){if(!this._started){this._started=!0;for(let t=0,i=Math.min(this._queueIds.length,this._workers.length);t<i;t++)this.runNext(t)}}createWorker(t,i,r,n){let s=new OS(t,{name:n}),a=!0;return s.onmessage=o=>{a=!0,r(i,o.data,null)},s.onerror=o=>{a=!0,r(i,null,o.message||"worker onerror")},s.onmessageerror=o=>{console.error("worker onmessageerror")},{index:i,isIdle:()=>a,postMessage:(...o)=>{a=!1,s.postMessage.apply(s,o)},terminate:()=>s.terminate()}}runNext(t){let i=this._queueIds.shift();if(i===void 0)return;let r=this._tasks[i],{state:n,data:s}=r,{started:a,completed:o}=n;a||o||this._workers[t].isIdle()&&(this._workers[t].postMessage(s),this._workerTaskId[t]=i,this._runningIds.push(i),Object.assign(n,{started:!0,startAt:new Date}))}destroy(){this._workers.forEach(t=>t.terminate()),this._workers.length=0,this._workerTaskId.length=0,this._tasks={},this._queueIds.length=0,this._runningIds.length=0,this._completedIds.length=0,this._promises.length=0,this._started=!1}};function NS(){return"_r"+(Math.random()*1e6|0)}function hee(e){let t=e.indexOf("{"),i=e.lastIndexOf("}"),r=e.substring(0,t).trim(),s=e.substring(t+1,i).match(/\b[\w\-]+:[^;]+/g)||[],a={selector:r,properties:{}};for(let o of s){let[l,c]=o.split(":");l=l.trim(),c=c.trim(),a.properties[l]=c}return a}function dee(e){let t={},i=[],r=[],n=[];e=e.replace(/(\s(?:class="))([^"]+)(?=")/g,(a,o,l)=>{l=l.trim().split(/\s+/);let c=[];for(let u of l){let h;i.includes(u)?h=t[u]:(h=NS(),t[u]=h,i.push(u),r.push(h)),c.push(h)}return o+c.join(" ")}),e=e.replace(/<style(?:\s|>).+?<\/style>/gs,a=>{let o=a.replace(/<style\b.*?>|<\/style>/gs,""),l=Array.from(o.match(/\.[\w$-]+\s*\{.*?\}/gs)||[]);for(let u of l){let h=hee(u),{selector:d,properties:p}=h,f=d.replace(".","");i.includes(f)&&(d="."+t[f],n.push({selector:d,properties:p}))}return`<style>
${o.replace(/(\.)([\w$-]+)(?=[^{}]*\{)/gs,(u,h,d)=>i.includes(d)?h+t[d]:u).trim()}
</style>`});let s=["fill","stroke","stroke-width","opacity","fill-opacity","stroke-opacity","visibility"];for(let a of n){let{selector:o,properties:l}=a,c=o.replace(".","");if(!r.includes(c))continue;let u=new RegExp(`<[\\w-]+\\s+([^\\s>]+\\s+)*?(?:class="${c}").*?>`,"gs");e=e.replace(u,h=>{for(let d of s){let p=l[d];if(!p)break;if(!h.includes(` ${d}="`))h=h.replace(/\/?>/,` ${d}="${p}"$&`);else{let f=new RegExp(` ${d}=".*?"`);h=h.replace(f,` ${d}="${p}"`)}}return h})}return e}function pee(e){let t={},i=[];return e=e.replace(/(\s(?:id="))([^"]+)/g,(r,n,s)=>(i.includes(s)||(i.push(s),t[s]=NS()),n+t[s])),e=e.replace(/\b(url\("?#)([^")?#]+)/g,(r,n,s)=>i.includes(s)?n+t[s]:r),e=e.replace(/\b((?:xlink:)?href="#)([^"]+)/g,(r,n,s)=>i.includes(s)?n+t[s]:r),e=e.replace(/<style(?:\s|>).+?<\/style>/gs,r=>e.includes("#")?r.replace(/(#)([\w$-]+)(?=[^{}]*\{)/g,(s,a,o)=>i.includes(o)?a+t[o]:s):r),e}function WC(e){e=pee(e),e=dee(e),e=e.replace(/\s(href=")/g," xlink:$1");let t=/<image [^>]*?(?:xlink:)?href="data:image\/svg\+xml;base64,([^"]+)"(?:[^>]*\/>|<\/image>)/g;return t.test(e)&&(e=e.replace(t,(i,r)=>{let n=Array.from(i.match(/\s([\w:]+)="([^"]+)/g)||[]),s={};for(let E of n){let[S,w]=E.trim().split('="');s[S]=w}let{x:a,y:o,width:l,height:c,transform:u,opacity:h,visibility:d,preserveAspectRatio:p}=s;a=a||0,o=o||0,l=l||1,c=c||1,u=u||"",d=d||"",p=p||"";let f=decodeURIComponent(escape(atob(r)));(f.includes("<script")||f.includes("<foreignObject"))&&(f=f.replace(/<(script|foreignObject)(?=>|\s).*?(\/>|<\/\1>)/gs,"")),f=f.substring(f.indexOf("<svg"));let m=f.indexOf(">"),g=f.substring(0,m+1),b=f.substring(m+1);return g=g.replace(/\s(x|y|width|height|transform|xmlns|xmlns:xlink|xml:space|version|style|id)=".*?"/g,""),g=g.replace(/<svg\s/,`<svg x="${a}" y="${o}" width="${l}" height="${c}" preserveAspectRatio="none" `),g.match(/\s+viewBox=".*?"/)||(g=g.replace(/<svg\s/,`<svg viewBox="0 0 ${l} ${c}" `)),f=g+b,f=WC(f),`<g transform="${u||""}" opacity="${h||1}">
${f}
</g>`})),e}var k1=4,F1=class e{constructor(){this.borderSpace=2.5;this.FILTER_LAYER_KEYS=["ellipse","group","rect","text","obj","arc"];this._head=null;this._docBBox=null;this._autoSizeEnabled=!1;this._outlineEnabled=!0;this._markerEnabled=!1;this._layerJsonArr={};this._layerSvgJsonArr={};this._transparency={};this._boardGroup={};this._jsonCacheList=null}setImageLoader(t){this._imageLoader=t}async getImageOutlineOfJsonItem(t){let[i]=this.toSvgJson(t,!1);return await this.getImageOutline(i)}async getImageOutline(t){let{content:i,data:r,polylineGroup:n}=t,s=/^data:image\/(?:png|gif|jpeg|webp)/.test(i);if(!s&&!this._imageLoader)return n;let{matrix:a}=r,{width:o,height:l}=et.getRectBBox(a);try{let c,u=1;/^data:image\/svg\+xml/.test(i)&&((o>1e3||l>1e3)&&(u=Math.min(1e3/o,1e3/l)),(o<100||l<100)&&(u=u*Math.max(100/o,100/l)),o*=u,l*=u),s?c={source:i,type:"DataURL",width:o,height:l}:(c=await this._imageLoader.load(i,Math.round(o),Math.round(l)),c.width=o,c.height=l),c.alphaLimit=15;let d=await n5(c);if(d){let p=et.createMatrixFrom6(a),f=de.translate(0,l).scale(1/o,1/l).multiply3(p);return d=d.multiply3(de.MIRROR_Y).multiply3(f).multiply3(de.MIRROR_Y),d}else return console.error("getImageOutline failed"),n}catch(c){return console.error("getImageOutline failed",{dataURL:i,error:c}),n}}makeProgressPercent(t,i,r){return n=>t(i+(r-i)*n)}makeProgressForward(t,i,r,n){if(typeof t!="function")return()=>{};let s=(r-i)/n,a=i;return()=>t(a+=s)}svgSpecifications(){let{width:t,height:i}=this._head,r=parseFloat(t),n=parseFloat(i);return{outlineWidth:r,outlineHeight:n,inlineWidth:r-this.borderSpace*2,inlineHeight:n-this.borderSpace*2,realWidth:r+this.borderSpace*2,realHeight:n+this.borderSpace*2,borderSpace:this.borderSpace}}getOutlineInnerSVG(t){if(!this._outlineEnabled)return"";let{width:i,height:r}=this.getOutlineSize(!0),{width:n,height:s}=this.getInlineSize(!0),a=`<rect id="outline-1" width="${i}" height="${r}" x="0" y="${-r}" fill="none" stroke="#000000" stroke-width="1"/>`,o=(i-n)/2,l=(r-s)/2,c=`<rect id="outline-2" width="${n}" height="${s}" x="${o}" y="${-l-s}" fill="none" stroke="#000000" stroke-width="1"/>`,u=`${a}
${c}`;return t&&(u=`<g id="${t}">
${u}
</g>`),u}getOutlineSize(t=!1){let{outlineWidth:i,outlineHeight:r}=this.svgSpecifications(),n=Yt(i,"mm","pixel"),s=Yt(r,"mm","pixel");return t===!0&&(n=Math.round(n),s=Math.round(s)),{width:n,height:s}}getInlineSize(t=!1){let{inlineWidth:i,inlineHeight:r}=this.svgSpecifications(),n=Yt(i,"mm","pixel"),s=Yt(r,"mm","pixel");return t===!0&&(n=Math.round(n),s=Math.round(s)),{width:n,height:s}}async json2InnerSVG(t,i="",r="",n=!1,s=""){let{outlineHeight:a,outlineWidth:o,realWidth:l,realHeight:c}=this.svgSpecifications(),u=Yt((o-l)/2,"mm","pixel"),h=Yt(-a-(c-a)/2,"mm","pixel"),d="";for(let p of t){let{polylineGroup:f,fillColor:m,strokeColor:g,strokeWidth:b,opacity:y,content:E,data:S}=p,w=fs(f.items,!1);if(w=rg(w,k1),E&&S){let x=`matrix(${S.matrix})`,I=E.startsWith("data:image/svg+xml;base64,"),A;if(I){let G=E.slice(E.indexOf(",")+1),V=decodeURIComponent(escape(atob(G)));if(V.includes("<script")||V.includes("<foreignObject"))continue;V=V.slice(V.indexOf("<svg"));let q=V.indexOf(">"),C=V.slice(0,q+1),N=V.slice(q+1),T=(B,U)=>{var ne;let X=new RegExp(`\\s+${U}="([^"]*)"`);return((ne=B.match(X))==null?void 0:ne[1])||""},L=B=>{var J;B=B.toLowerCase(),B=B.replace(/px/,"").trim();let U=(J=B.match(/[a-z]+$/i))==null?void 0:J[0],X=parseFloat(B);return X&&m3(U)&&(X=Yt(X,U,"pixel")),X||0},P=T(C,"viewBox");if(!P){let B=T(C,"width"),U=T(C,"height");if(B&&U){let X=L(B),J=L(U);P=`0 0 ${X} ${J}`}else P=`0 0 ${S.width} ${S.height}`}C=C.replace(/\s(x|y|width|height|transform|xmlns|xmlns:xlink|xml:space|version|style|id|preserveAspectRatio|opacity|viewBox)=".*?"/g,""),C=C.replace(/<svg(\s|>)/,`<svg x="0" y="0" width="1" height="1" preserveAspectRatio="none" opacity="${y}" viewBox="${P}"$1`),V=C+N,V=WC(V),A=`<g data-origin-id="${S.gId}" transform="${x}">
${V}
</g>`}else kB(E)&&(E=await FB(E)),A=`<image x="0" y="0" width="1" height="1" opacity="${y}" transform="${x}" preserveAspectRatio="none" xlink:href="${E}"/>`;let O=`<path d="${w}" fill="#ffffff" stroke="none"/>`,R=NS(),M=`<defs><mask id="${R}" maskUnits="userSpaceOnUse" x="${u}" y="${h}">${O}</mask></defs>`,F=`mask="url(#${R})"`;d+=`
${M}
<g ${F}>
${A}
</g>
`}else{m===void 0&&(m="none"),b===void 0&&(b=0),g===void 0&&(g="none"),y===void 0&&(y=1);let x=`<path d="${w}" fill="${m}" stroke-width="${b}" stroke="${g}" opacity="${y}" ${s}/>`;d+=n?`
<g>${x}</g>`:`
${x}`}}return r&&(d+=`
`+r),i?`<g id="${i}">
${d}
</g>`:d}async json2PrintInnerSVG(t,i,r=!1){let n=[],s=[];if(r){let h=`<pattern id="gridPattern" patternUnits="userSpaceOnUse" x="0" y="0" width="20" height="20">
<rect width="10" height="10" x="0" y="0" stroke-width="0" stroke="none" fill="#ddd"></rect>
<rect width="10" height="10" x="10" y="10" stroke-width="0" stroke="none" fill="#ddd"></rect>
</pattern>`,{width:d,height:p}=this.getOutlineSize(!0),f=`<rect width="${d}" height="${p}" x="0" y="${-p}" stroke="none" fill="url(#gridPattern)"/>`;n.unshift(h),s.unshift(f)}let a=this._markerEnabled?this.getMarkSvg(2):"",o=n.length?`<defs>
${n.join(`
`)}
</defs>`:"",l=s.join(`
`),c=await this.json2InnerSVG(t,""),u=`
${o}
${l}
${c}
${a}
`;return i?`<g id="${i}">
${u}
</g>`:u}inner2OuterSVG(t){let{realWidth:i,realHeight:r,borderSpace:n}=this.svgSpecifications(),s=Yt(i,"mm","pixel"),a=Yt(r,"mm","pixel"),o=Yt(-n,"mm","pixel"),l=Yt(-r+n,"mm","pixel"),c=rg(`M${o} ${l} ${s} ${a}`,k1).slice(1);if(t=`<defs><style>#\u9F13\u5305\u5C42 > path {vector-effect: non-scaling-stroke;}</style>
			${XC}
		</defs>`+t,this._autoSizeEnabled){let{width:d,height:p}=this.getOutlineSize(),{x:f,y:m,width:g,height:b}=this._docBBox,y=50,E=Math.max(g+y*2,d),S=Math.max(b+y*2,p),w=f+g/2-E/2,x=m+b/2-S/2;i=Yt(E,"pixel","mm"),r=Yt(S,"pixel","mm"),c=rg(`M${w} ${x} ${E} ${S}`,k1).slice(1)}return`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="stroke-linecap:round;stroke-linejoin:round;" width="${i}mm" height="${r}mm" viewBox="${c}">${t}</svg>`}getMarkSvg(t){if(!this._markerEnabled)return"";let i=gee(t,this._head);return i=rg(i,k1),`<path layer="99" fill="#000000" stroke="none" d="${i}"/>`}getDefaultBoardLayerSvgJson(){let{width:t,height:i}=this.getOutlineSize(),r=`M 0 0 L ${t} 0 L ${t} ${-i} L 0 ${-i} Z`;if(this._autoSizeEnabled){let{x:s,y:a,width:o,height:l}=this._docBBox,c=50,u=Math.max(o+c*2,t),h=Math.max(l+c*2,i),d=s+o/2-u/2,p=a+l/2-h/2,f=d+u,m=p+h;r=`M ${d} ${p} L ${f} ${p} L ${f} ${m} L ${d} ${m} Z`}return r=rg(r,k1),[{polylineGroup:new kr(qi(r)),layer:3,opacity:1,hide:!1,cover:!1,scope:void 0,strokeColor:"#000000",strokeWidth:1,strokeStyle:0,fillColor:"none"}]}getOpacityMergeValue(t,i,r){return r==2?1-(1-t)*(1-i):t*i}mergeOpacitySvgJson(t,i){if(t.length<2)return t;let r=[],n=[];for(let c of t){let{opacity:u}=c,h=r.indexOf(u);h<0?(r.push(u),n.push([c])):n[h].push(c)}let s=n.map(c=>this.mergeSvgJson(c)).flat(),a=[],o=c=>c.length>0&&kr.combinePolylineGroupArr(c);for(let c of s){let u=c.polylineGroup,h=c.opacity,d=u.items,p=[],f=!1;for(let m of a){if(!d.length)break;if(!m.polylineGroup.items.length)continue;let g=m.polylineGroup,b=m.opacity;if(!DS.isIntersect(g,u))continue;let y=g.items,E=Ri.boolIntersection([y,d]);if(!E.length)continue;f=!0;let S=this.getOpacityMergeValue(h,b,i);if(S==h&&S==b){let w=Ri.boolAggregate([y,d]),x=o(w);g.items.length=0,x?d=x.items:d.length=0;continue}else if(S==h){let w=Ri.boolSubtraction(y,d),x=o(w);x?m.polylineGroup=x:g.items.length=0;continue}else if(S==b){let w=Ri.boolSubtraction(d,y),x=o(w);x?d=x.items:d.length=0;continue}else{let w=Ri.boolSubtraction(y,d),x=Ri.boolSubtraction(d,y),I=o(w),A=o(x),O=o(E),R={...m,polylineGroup:O,opacity:S};I?(m.polylineGroup=I,a.push(R)):(m.polylineGroup=O,m.opacity=S),A?d=A.items:d.length=0;continue}}p.length&&a.push(...p),d.length&&(f&&(c.polylineGroup=new kr(d)),a.push(c))}return a.filter(c=>c.polylineGroup.items.length>0)}mergeSvgJson(t,i=!0){if(!t.length)return[];let r=t.map(s=>s.polylineGroup),n=this.unionPolylineGroup(r);if(n.length){let s=o=>({...t[0],content:"",data:null,polylineGroup:o});return(i?[kr.combinePolylineGroupArr(n)]:n).map(s)}else return[]}unionPolylineGroup(t){if(!t.length)return[];let i=[],r=t.slice(),n=!0;for(;r.length;){let o=r.shift(),l=o.bbox();for(let c=0;c<i.length;c++)if(!i[c].bbox().isSeparated(l)){n=!1;break}if(n)i.push(o);else break}if(n)return i;let s=t.map(o=>o.items);return Ri.boolAggregate(s)}subSvgJson(t,i,r=!1){let n=[],s=i.map(a=>a.polylineGroup.items);for(let a=0;a<t.length;a++){let o=t[a];if(!o.polylineGroup.items.length||this.isSingleLinePolylineGroup(o.polylineGroup))continue;let l=Ri.boolSubtraction1([o.polylineGroup.items].concat(s));if(l.length){let u=(r?[kr.combinePolylineGroupArr(l)]:l).map(h=>({...o,polylineGroup:h}));n.push(...u)}}return n}isSingleLinePolylineGroup(t){if(t.items.length===1){let i=t.items[0];if(i.primitives.length===1&&i.primitives[0]instanceof ie)return!0}return!1}intersectSvgJson(t,i,r){let n=[],s=o=>o.polylineGroup.items.reduce((l,c)=>l+c.primitives.length,0),a=o=>o.polylineGroup.items.length>1&&s(o)>50;for(let o=0;o<t.length;o++){let l=t[o],c=l.polylineGroup,u=c.items,h=c.bbox(),d=a(l);for(let p=0;p<i.length;p++){let f=i[p],m=f.polylineGroup,g=m.items,b=m.bbox(),y=a(f);if(h.isSeparated(b))continue;let E=r?this.getOpacityMergeValue(l.opacity,f.opacity,r):l.opacity;if(h.isInside(b)&&!y){let w=s5(h);if(!Ri.boolSubtraction([w],g).length){n.push({...l,opacity:E});continue}}if(b.isInside(h)&&!d){let w=s5(b);if(!Ri.boolSubtraction([w],u).length){n.push({...l,polylineGroup:m,opacity:E});continue}}let S=Ri.boolIntersection([u,g]);if(S.length){let w=kr.combinePolylineGroupArr(S);n.push({...l,polylineGroup:w,opacity:E})}}}return n}extendSvgJson(t,i){var n,s;let r=[];for(let a of t){let{polylineGroup:o}=a,l=((s=(n=o==null?void 0:o.items)==null?void 0:n[0])==null?void 0:s.closed())||!1,c=Ah(o,i,{fill:l});c&&r.push({...a,polylineGroup:c})}return r}jsonObjToPolylineGroup(t,i){if(i=="text"){if(!t.d)return null;let s=Ri.convertJsonCache2PolyLines({d:t.d},"group"),a=de.MIRROR_Y.multiply3(et.createMatrixFrom6(t.matrix).multiply3(de.MIRROR_Y));return s.multiply3(a).round(4)}return Ri.convertJsonCache2PolyLines(t,i)}getCloseSvgJson(t,i=.01){let r=[],n=[];if(t.forEach(o=>{let{polylineGroup:l}=o,c=l.items;if(c.length===1)Ig(c[0],i)?r.push(c[0]):(c[0].closed()||(c[0]=c[0].asClose()),n.push(o));else if(c.length>1){let u=Ag(c,i);u.updatedItems.concat(u.noChangeItems).map(d=>d.polylineNew||d.polyline).forEach(d=>{n.push({...t[0],polylineGroup:new kr([d])})})}}),r.length<1)return n;if(r.length===1)return r[0]=r[0].asClose(),n.push({...t[0],polylineGroup:new kr(r)}),n;let s=Ag(r,i);s.noChangeItems.forEach(o=>o.polyline=o.polyline.asClose());let a=s.updatedItems.concat(s.noChangeItems).map(o=>({...t[0],polylineGroup:new kr([o.polylineNew||o.polyline])}));return n=n.concat(a),n}init(t,i=!0){let r=t.head.docType==ta.PANEL_LIB;this._head=null,this._autoSizeEnabled=r,this._outlineEnabled=!r,this._markerEnabled=!1,this._layerJsonArr={},this._layerSvgJsonArr={},this._transparency={},this._boardGroup={},this._jsonCacheList=null;let n=jt(t);t=null,this._head=n.head,this._docBBox=n.BBox,i&&this.sortOriginJson(n)}sortOriginJson(t){let i={},r={},n=(o,l,c)=>{o[c]?o[c].push(l):o[c]=[l]},s=t.itemOrder,a={};for(let o=0;o<s.length;o++)a[s[o]]=o;for(let o of this.FILTER_LAYER_KEYS){let l=t[o];l&&ro(l,(c,u)=>{let{layer:h,hide:d,transparencyWhite:p,transparencyPrint:f}=u;if(d)return;let m=a[c];n(i,m,h),n(r,u,h),h===2&&(this._transparency[c]=[p||0,f||0]),Va(m)&&Kr(u,"\u6CE8\u610F\uFF1A\u5B58\u5728\u65E0\u6392\u5E8F\u4FE1\u606F\u5F97\u56FE\u5143")})}ro(i,(o,l)=>{let c=l.map((u,h)=>[h,u]);c.sort((u,h)=>{let d=u[1],p=h[1];return d==p?0:d>=0&&d<p?-1:1}),r[o]=c.map(([u])=>r[o][u])}),this._layerJsonArr=r}allToSvgJson(){let t=this._layerJsonArr;Object.keys(t).reduce((r,n)=>r+t[n].length,0)&&ro(t,(r,n)=>{if(!this._layerSvgJsonArr[r]){let s=n.map(a=>this.toSvgJson(a,!1)).flat();this._layerSvgJsonArr[r]=s}})}toSvgJson(t,i=!1){let{layer:r,opacity:n,hide:s,cover:a,scope:o,strokeColor:l,strokeWidth:c,strokeStyle:u,fillColor:h,displayFill:d,displayStroke:p,content:f,cmdKey:m}=t,g=1,b=1,y=r==1,E=r==6,S=r==5,w=r==2,x=r==7,I=r==3||r==4,A=m=="obj"&&!!f&&f.startsWith("data:image/"),O=m=="text";if((y||E)&&n<.001)return[];if(m==="obj"&&!A)return[];c=c||0,d===!1&&(h="none"),p===!1&&(l="none"),O&&(h=h||l||"#000000",l="none"),h=h||"none",l=l||"none",S&&(h="none",l=NI[r],c=1,n=1),I&&(h="none",l="#000000",c=1,n=1),i&&y&&(h!="none"&&(h="#000000"),l!="none"&&(l="#000000")),w&&(h="#000000",l="none",c=0,g=1-t.transparencyPrint||0,b=1-t.transparencyWhite||0,n=i?b:g),r==7&&(h="none",l="#ff00ff",c=1,n=1),Object.assign(t,{fillColor:h,strokeColor:l,strokeWidth:c,opacity:n});let R={jsonKey:m,gId:t.gId,polylineGroup:this.jsonObjToPolylineGroup(t,m),layer:r,opacity:n,opacityCover:b,hide:s,cover:a,scope:o,strokeColor:l,strokeWidth:c,strokeStyle:u,fillColor:h,content:A?f:void 0,data:A?t:void 0};if((S||w||x)&&m==="group"){let{polylineGroup:M}=R;return mee(M),Ri.boolSubtraction(M.items,[]).map(V=>({...R,polylineGroup:V}))}return y&&!A||E?this.buildSvgJsonFillStroke(R):[R]}getLayerSvgJson(t,i=!1){let r=this._layerSvgJsonArr[t]||[];if(r.length&&t==2)for(let n of r){let{gId:s}=n,[a,o]=this._transparency[s],l=1-o||0,c=1-a||0;Object.assign(n,{fillColor:"#000000",strokeColor:"none",strokeWidth:0,opacity:i?c:l,opacityCover:c})}return r}async buildBoardGroup({forPreview:t=!1,forcedSingleGroup:i=!1,progressCallback:r=n=>{}}={}){let n=[],s=[],a=[],o=[],l=[],c=[],u=[],h=[],d=.01;console.time("build"),n=this.getLayerSvgJson(3),n=this.getCloseSvgJson(n,d),n=this.mergeSvgJson(n,!1),a=this.getLayerSvgJson(4),a=this.getCloseSvgJson(a,d),a=this.mergeSvgJson(a,!1);let p=this.getDefaultBoardLayerSvgJson();n.length?n=this.intersectSvgJson(n,p):n=p,n.length||(n=p),r(0);let f=(S,w)=>S.filter(x=>w.includes(x.scope)),m=async S=>{let w=[];for(let x of S){let{content:I,data:A}=x;if(!!(I&&A)){let{polylineGroup:R}=x,M=await this.getImageOutline({polylineGroup:R,content:I,data:A}),F={...x,polylineGroup:M,content:"",data:null};w.push(F)}else w.push(x)}return w},g=this.makeProgressForward(r,0,1,n.length+1),b={4:a,5:this.getLayerSvgJson(5),2:this.getLayerSvgJson(2),1:this.getLayerSvgJson(1),6:this.getLayerSvgJson(6),7:this.getLayerSvgJson(7)};g();let y=[4,5,2,1,6,7],E=i||n.length<=1;for(let S=0,w=E?1:n.length;S<w;S++){console.time("build 1.2 "+(S+1)+"/"+w);let x=E?null:n[S].polylineGroup.bbox(),I={};for(let R of y){if(E){I[R]=b[R];continue}I[R]=[];let M=b[R];for(let F of M)F.polylineGroup.bbox().isIntersect(x)&&I[R].push(F)}let A=E?n:[n[S]],O=I[4]||[];{let R=I[1]||[];R=this.intersectSvgJson(R,A);let M=R.slice(),F=I[2]||[],G=F;G=f(G,[2,1]),G=G.filter(q=>q.opacity<1),G=this.getOpacitySvgJson(A,G),console.time("build 2.3"),R=this.intersectSvgJson(R,G,1),console.timeEnd("build 2.3"),t&&(R=this.subSvgJson(R,O,!1)),R=R.filter(q=>q.opacity>=.001),o=o.concat(R);let V=F.map(q=>({...q,opacity:q.opacityCover}));V=f(V,[3,1]),V=V.filter(q=>q.opacity<1),V=this.getOpacitySvgJson(A,V),M=M.map(q=>{let{fillColor:C,strokeColor:N,content:T,data:L,jsonKey:P}=q;return C!="none"&&(C="#ffffff"),N!="none"&&(N="#ffffff"),(!!(T&&L)||P=="obj")&&(C="#ffffff",N="none"),{...q,fillColor:C,strokeColor:N}}),M=await m(M),M=this.purifyCoverData(M),M=this.intersectSvgJson(M,V,1),t&&(M=this.subSvgJson(M,O,!1)),M=M.filter(q=>q.opacity>=.001),h=h.concat(M)}{let R=I[2]||[];R=this.applyGlueStroke(R,2),R=this.mergeSvgJson(R,!1),R=this.extendSvgJson(R,Yt(0,"mm","pixel")),R=this.intersectSvgJson(R,A);let M=I[7]||[];M=this.applyGlueStroke(M,7),M=this.mergeSvgJson(M,!1),M=this.extendSvgJson(M,Yt(0,"mm","pixel")),M=this.intersectSvgJson(M,A);let F=I[5]||[];F=this.mergeSvgJson(F,!1),F=this.applyGlueStroke(F,5),F=this.extendSvgJson(F,Yt(0,"mm","pixel")),F=this.intersectSvgJson(F,A);let G=this.subSvgJson(A,O,!1);G=this.applyGlueStroke(G,3);for(let N of G)N.polylineGroup.items.shift();let V=Yt(0,"mm","pixel");G=this.extendSvgJson(G,V);let q=this.mergeSvgJson([...G,...F,...R,...M]),C=this.createEntireGlue(A,q);this._boardGroup[8]=C,l=l.concat(G,F,R,M)}{let R=this.subSvgJson(A,O,!1);s=s.concat(R)}{let R=I[7]||[];R=this.intersectSvgJson(R,A),R=this.subSvgJson(R,O,!1),u=u.concat(R)}{let R=I[6]||[];c=c.concat(R)}g(),console.timeEnd("build 1.2 "+(S+1)+"/"+w)}return console.timeEnd("build"),r(1),this._boardGroup={...this._boardGroup,7:u,4:o,3:h,1:s,2:l,6:c},this._boardGroup}createEntireGlue(t,i){let r=this.subSvgJson(t,i);for(let n of r)n.fillColor="url(#"+_S+")",n.strokeColor="none";return r}applyGlueStroke(t,i){return t.map(r=>({...r,opacity:1,fillColor:"none",strokeColor:NI[i],strokeWidth:1}))}createJsonCache(t){let i={...t};for(let r of ZA)i[r]={};return i.itemOrder=[],i}createBoardId(t,i){let r=`b${i}`,n=r,s=0,a="jabcdefghi";for(;t[n]===!0;)n=r+s.toString(10).replace(/\d/g,o=>a[o]),s++;return n}createBoardJsonItem(t,i){let r={gId:i,cmdKey:"group",matrix:void 0,tempMatrix:void 0,cover:!0,hide:!1,layer:3,locked:!1,name:"",opacity:1,rotation:0,scope:2,isWhiteBackground:!1,transparencyPrint:1,transparencyWhite:1,visible:!0},n={strokeColor:"#000000",strokeStyle:0,strokeWidth:1,fillColor:"none",displayStroke:!0,displayFill:!1};return{d:fs(t.polylineGroup.items,!1),...r,...n}}async buildJsonCacheGroup(t,i){let r=[],n=[],s=t.itemOrder,a=0,o={},l={},c=[3,4,5,2,1,6,7];for(let y of this.FILTER_LAYER_KEYS){let E=t[y];ro(E,(S,w)=>{let{layer:x,hide:I}=w;I||c.includes(+x)&&(x==3?r.push(w):x==4&&n.push(w),ZA.includes(y)&&(o[S]=f2(w,y),l[S]=w),s.includes(S)||a++)})}a>0&&console.warn("\u6CE8\u610F\uFF1A\u5B58\u5728\u65E0\u6392\u5E8F\u4FE1\u606F\u5F97\u56FE\u5143: "+a),i(.2);let u=r.map(y=>this.toSvgJson(y,!1)).flat();u=this.getCloseSvgJson(u,.01),u=this.mergeSvgJson(u,!1);let h=this.getDefaultBoardLayerSvgJson();u.length?(u=this.intersectSvgJson(u,h),u.length||(u=h)):u=h,i(.3);let d=u.map((y,E)=>E),p=u.map(y=>y.polylineGroup.bbox().transform(de.MIRROR_Y));d.sort((y,E)=>{let S=p[y].minY-p[E].minY,w=p[y].minX-p[E].minX;return Math.abs(S)<5&&Math.abs(w)>5?w:Math.abs(S)>5&&Math.abs(w)<5?S:S||w});let f=u.length,m=Array(f),g=.3,b=.7/f;for(let y of d){let E=p[y],S=this.createJsonCache(t),{minX:w,minY:x,maxX:I,maxY:A}=E;S.BBox={x:w,y:x,width:I-w,height:A-x},m[y]=S;let O={};ro(o,(F,G)=>{let V=l[F],{layer:q,cmdKey:C}=V;q!=3&&G.isIntersect(E)&&(S[C][F]=V,O[F]=!0)}),S.itemOrder=s.filter(F=>O[F]===!0);let R=this.createBoardId(O,y);S.itemOrder.unshift(R);let M=this.createBoardJsonItem(u[y],R);S.group[R]=M,i(g+=b)}return m}getMergeCloseBoardSvgJson(t,i){this.init(t,!0),this.allToSvgJson();let r=this.getLayerSvgJson(i);return r=this.getCloseSvgJson(r,.01),r=this.mergeSvgJson(r,!1),r}purifyCoverData(t){let i=t.filter(u=>u.polylineGroup.items.length>1),r=t.filter(u=>u.polylineGroup.items.length<2),n=r.filter(u=>u.opacity===1),s=r.filter(u=>u.opacity<1).concat(i);n=this.mergeSvgJson(n,!1);let a=u=>Tt.build4([u.UL(),u.UR(),u.LR(),u.LL(),u.UL()]),o=u=>{let h=u.polylineGroup.bbox(),d=a(h);for(let p of n){let f=p.polylineGroup,m=f.bbox();if(h.isInside(m)&&!Ri.boolSubtraction([d],f.items).length)return!1}return!0},l=s.filter(o);return n.concat(l)}getOpacitySvgJson(t,i){let r=t,n=[];if(i.length){r=this.subSvgJson(t,i,!1),n=this.intersectSvgJson(i,t);let s=1;n=this.mergeOpacitySvgJson(n,s)}return r.concat(n)}buildSvgJsonFillStroke(t){let{polylineGroup:i,strokeColor:r,strokeWidth:n,fillColor:s}=t,a=!!s&&s!="none"&&!this.isSingleLinePolylineGroup(i),o=n>0&&r!="none",l={strokeColor:"none",strokeWidth:0},c=o&&Ah(i,n/2,{fill:!1}),u=c&&{...t,...l,polylineGroup:c,fillColor:r},h=a&&{...t,...l};if(h&&u){if(s==r)return this.mergeSvgJson([h,u],!0);{let d=this.subSvgJson([h],[u],!0);return[u,...d]}}else{if(h)return[h];if(u)return[u]}return[]}getPreviewSVG(t){let i=this.getMarkSvg(1),r=this.getMarkSvg(2),n=[];return n.push(this.wrapIdAndMark(t[8],"\u80CC\u80F6\u5C42","",'display="none"')),this._head.coverColor=="black"&&n.push(this.wrapIdAndMark(t[3],"\u9ED1\u8272\u906E\u76D6\u5C42",i)),n.push(this.wrapIdAndMark(t[2],"\u767D\u8272\u906E\u76D6\u5C42",i)),n.push(this.wrapIdAndMark(t[1],"\u6253\u5370\u5C42","")),n.push(this.wrapIdAndMark(t[7],"\u9F13\u5305\u5C42","")),n.push(this.wrapIdAndMark(t[4],"\u677F\u6846\u5C42",r)),n.push(this.getOutlineInnerSVG("\u8FB9\u7EBF")),this.inner2OuterSVG(n.join(`
`))}getProductionSVG(t){let i=this.getMarkSvg(1),r=this.getMarkSvg(2),n=[];return n.push(this.wrapIdAndMark(t[5],"\u80CC\u80F6\u5C42","")),this._head.coverColor=="black"&&n.push(this.wrapIdAndMark(t[3],"\u9ED1\u8272\u906E\u76D6\u5C42",i)),n.push(this.wrapIdAndMark(t[2],"\u767D\u8272\u906E\u76D6\u5C42",i)),n.push(this.wrapIdAndMark(t[1],"\u6253\u5370\u5C42","")),n.push(this.wrapIdAndMark(t[7],"\u9F13\u5305\u5C42","")),n.push(this.wrapIdAndMark(t[4],"\u677F\u6846\u5C42",r)),n.push(this.getOutlineInnerSVG("\u8FB9\u7EBF")),this.inner2OuterSVG(n.join(`
`))}mergedSvgDataFactory(){let t=[7,1,3,2,4,5,8,6],i={};for(let r of t)i[r]=[];return{get(){return i},set(r){for(let n of t)i[n].push(r[n]||"")}}}async productionSvgNew(t,{forPreview:i=!1,progressCallback:r=gu}={}){r(0),this.init(t,!1);let n=this.makeProgressPercent(r,.3,.5),s=await this.buildJsonCacheGroup(t,n);if(this._jsonCacheList=s,!s.length)throw new Error("empty JsonCache Group");this._boardGroup={};let o=s.map(p=>St.extendRect(p.BBox)).reduce((p,f)=>St.extend2(p,f)),l={x:o.minX,y:o.minY,width:o.maxX-o.minX,height:o.maxY-o.minY};s.forEach(p=>p.BBox=l);let c=this.mergedSvgDataFactory(),u=s.length;if(u>=3){let p=this.makeProgressForward(r,.5,.85,u),f=new RS;f.init({url:`editor?entry=panel-sub-worker.js&cll=${self.PRO_LOG_LEVEL||""}`,workersCount:Math.min(16,u),name:"panel-sub-worker"});let m=0,g=b=>{let y=b.result;c.set(y),p(),console.log(`task complete: ${++m} / ${u}`)};for(let b of s)f.addTask({op:"generateSvgData",args:[{jsonCache:b,forPreview:i}]}).then(g);f.start(),await f.all().finally(()=>f.destroy()),await b3(100)}else for(let p of s){let m=await new e().generateSvgData(p,{forPreview:i,progressCallback:r,boardGroupCallback:g=>{for(let b of[7,4,3,1,2,8,6])this._boardGroup[b]=g[b].concat(this._boardGroup[b]||[])}});c.set(m)}return r(.9),{mergedSvgData:c.get()}}wrapIdAndMark(t,i,r="",n=""){return r&&t.push(r),i&&(t.unshift(`<g id="${i}" ${n}>`),t.push("</g>")),t.join(`
`)}async generateSvgData(t,{forPreview:i=!1,progressCallback:r=gu,boardGroupCallback:n=gu}={}){r(0),this.init(t),this.allToSvgJson();let s=this.makeProgressPercent(r,.3,.8),a=await this.buildBoardGroup({forPreview:i,progressCallback:s,forcedSingleGroup:!0}),o=a[7],l=a[4],c=a[3],u=a[1],h=a[2],d=a[8],p={};p[8]=await this.json2InnerSVG(d,"","",!1),p[5]=await this.json2InnerSVG(h,"","",!1),r(.81),this._head.coverColor=="black"&&(c=c.map(m=>({...m,fillColor:"#000000"})),p[3]=await this.json2InnerSVG(c,"","",!0),r(.83)),c=c.map(m=>({...m,fillColor:"#ffffff"})),p[2]=await this.json2InnerSVG(c,"","",!0),r(.85),p[1]=await this.json2PrintInnerSVG(l,""),r(.9);let f=i?' stroke-dasharray="12 4 2 4"':"";return p[7]=await this.json2InnerSVG(o,"","",!1,f),r(.95),p[4]=await this.json2InnerSVG(u,"","",!1,'vector-effect="non-scaling-stroke"'),r(1),n(a),p}async generate3d(t,{progressCallback:i}={}){let n=this.makeProgressPercent(i,0,.6),{mergedSvgData:s}=await this.productionSvgNew(t,{forPreview:!0,progressCallback:n}),a=this._boardGroup;if(!a[4]&&this._jsonCacheList){let u=d=>{[7,4,3,1,2,6,8].forEach(p=>{this._boardGroup[p]=d[p].concat(this._boardGroup[p]||[])})},h=this.makeProgressPercent(i,.6,.9);for(let d of this._jsonCacheList){let p=new e;p.init(d),p.allToSvgJson();let f=await p.buildBoardGroup({forPreview:!0,forcedSingleGroup:!0,progressCallback:h});u(f)}}i(.9);let o={7:a[7],1:a[4],2:a[3],3:[],4:a[1],5:a[2],8:a[8],6:a[6]};o[3]=o[2].map(u=>({...u,fillColor:"#000000"}));let{blobStr:l,dataStr:c}=await t5(o,this._head);return i(1),{blobStr:l,dataStr:c,productionSvg:this.getProductionSVG(s)}}};function s5(e){return Tt.build4([e.UL(),e.UR(),e.LR(),e.LL(),e.UL()])}function mee(e){e.items.map((t,i)=>(t.closed()||(e.items[i]=t.asClose()),t))}var a5=new F1;function gee(e,{width:t,height:i}){let r=Yt(10,"mm","pixel"),n=Yt(2.5,"mm","pixel"),s=Yt(t,"mm","pixel"),a=Yt(i,"mm","pixel"),o=Yt(10,"mm","pixel")/2,l=[{x:r+n,y:-r-n},{x:s-r-n,y:-r-n},{x:s-r-n,y:-a+r+n},{x:r+n,y:-a+r+n}],c="";for(let u=0;u<l.length;u++){let{x:h,y:d}=l[u];e==2?c+=`M ${h-n} ${d} A ${n} ${n} 0 1 1 ${h+n} ${d} A ${n} ${n} 0 1 1 ${h-n} ${d} `:e==1&&(c+=`M ${h-o} ${d+o} L ${h-o} ${d-o} ${h+o} ${d-o} ${h+o} ${d+o} Z `)}return c.trim()}function pf(e,t){return e.map(i=>{let r=i.id,{json:n,cmdKey:s}=k.getById(i.id);return t.includes(s)?{gId:r,jsonObj:n,element:i}:null}).filter(i=>i&&!!i.jsonObj)}function MS(e){let t=[];for(let i in e.ellipse||{}){let r=Ot(),n=e.ellipse[i];n.gId=r;let s=D1(n,r);t.push(s)}for(let i in e.rect||{}){let r=e.rect[i],n=Ot();r.gId=n;let s=C1(r,n);t.push(s)}for(let i in e.group||{}){let r=e.group[i],n=Ot();r.gId=n;let s=fl(r,n);t.push(s)}for(let i in e.text||{}){let r=e.text[i],n=Ot();r.gId=n;let s=bg(r,n);t.push(s)}for(let i in e.obj||{}){let r=e.obj[i],n=Ot();r.gId=n;let s=_1(r,n);t.push(s)}for(let i in e.arc||{}){let r=e.arc[i],n=Ot();r.gId=n;let s=_h(r,n);t.push(s)}for(let i in e.auxiliaryLine||{}){let r=e.auxiliaryLine[i],n=Ot();r.gId=n;let s=P1(r,n);t.push(s)}for(let i in e.auxiliaryPoint||{}){let r=e.auxiliaryPoint[i],n=Ot();r.gId=n;let s=af(r,n);t.push(s)}return t}function yee(e,t){if(e==t)return 0;let i=e.compareDocumentPosition(t);return i&Node.DOCUMENT_POSITION_DISCONNECTED?0:i&Node.DOCUMENT_POSITION_PRECEDING?1:-1}function bee(e){let i=qi(e).map(n=>n.reverse()).reverse();return fs(i,!1)}function xee(e){let t=qi(e),i=.05,r=t.map(s=>s.simplify(i));return fs(r,!1)}function Eee(e){let[t,i,r,n,s,a]=e,o=new de([t,i,0,r,n,0,s,a,1]),l=new j(0,0).multiply3(o),{x:c,y:u}=l,h=new j(1,0).multiply3(o),d=new j(0,1).multiply3(o),p=h.distance1(l),f=d.distance1(l);return{cx:c,cy:u,rx:p,ry:f}}function o5(){let e=Ae.get(),t=["rect","ellipse","text","arc"],i=pf(e,t);if(!i.length)return;let r=[],n=[];i.forEach(s=>{let{gId:a,jsonObj:o,element:l}=s,c=ef(o),u=Ot(),h=k.getInitialGroupData({gId:u,layer:o.layer});h.d=c,h.cover=o.cover,h.scope=o.scope,h.opacity=o.opacity,h.fillColor=o.fillColor,h.strokeWidth=o.strokeWidth,h.strokeColor=o.strokeColor,o.cmdKey=="text"&&(h.fillColor=o.strokeColor,h.strokeColor="none",h.strokeWidth=0);let d=fl(h,u);H.gCanvas.insertBefore(d,l),r.push(Qr(a,{cmdKey:o.cmdKey,refId:Vn(l)},o,{})),k.removeOne(l),r.push(Qr(u,{cmdKey:"group",refId:Vn(d)},"",h)),n.push(d)}),r.length&&Ke.save(r),qt(),Ae.unselectAll(),Ae.select(n),n.length===1&&ms(n[0]),Ce("panel_updateAttrPanel")}function l5(){let e=Ae.get(),t=["ellipse","group","rect","arc"],i=pf(e,t);if(!i.length)return;let r=[],n=[];i.map(s=>{let{gId:a,jsonObj:o,element:l}=s;if(!(o.strokeColor!="none"&&o.strokeWidth>0))return;let u;if(o.cmdKey==="rect"){let{matrix:b,strokeWidth:y,displayStroke:E,rx:S,ry:w}=o;if(!E)return;let x=et.expandRectMatrixByStrokeWidth(b,y,!0);u=Yo({...o,rx:S+y/2,ry:w+y/2,matrix:x});try{let A=et.expandRectMatrixByStrokeWidth(b,y,!1),O=Yo({...o,rx:Math.max(0,S-y/2),ry:Math.max(0,w-y/2),matrix:A},{ccw:!0});u+=O}catch(A){console.error(A)}}else if(o.cmdKey==="ellipse"){let{strokeWidth:b,matrix:y}=o,E=b/2,S=Eee(y),{cx:w,cy:x}=S,I=et.calcuEllipse(y);if(u=Ql({rotation:I.degree,cx:w,cy:x,rx:I.a+E,ry:I.b+E},{ccw:!1}),E<I.a&&E<I.b){let O=Ql({rotation:I.degree,cx:w,cy:x,rx:I.a-E,ry:I.b-E},{ccw:!0});u+=O}}else{let b=Ri.convertJsonCache2PolyLines(o,o.cmdKey),y=yB(b,o.strokeWidth);if(!y.length)return;u=y.map(E=>fs(E.items,!1)).join(" ")}let h=[o.strokeColor,o.fillColor,"#000000"].find(b=>b&&b!="none"),{json:d,cmdKey:p}=k.getById(l.id),f=k.getInitialGroupData({gId:Ot(),layer:d.layer});f.d=u,f.fillColor=h,f.strokeColor="none",f.strokeWidth=0;let m=fl(f);if(H.gCanvas.insertBefore(m,l.nextSibling),r.push(Qr(m.id,{cmdKey:"group",refId:Vn(m)},"",f)),o.fillColor&&o.fillColor!=="none"){te(l,"stroke-width",0),te(l,"stroke","none");let b=jt(d);b.strokeWidth=0,b.strokeColor="none",r.push(Qr(l.id,{cmdKey:p,refId:Vn(l)},d,b)),o.strokeWidth=0,o.strokeColor="none"}else r.push(Qr(l.id,{cmdKey:p,refId:Vn(l)},d,"")),k.removeOne(l);n.push(m)}),r.length&&(r.length&&Ke.save(r),qt(),Ae.unselectAll(),Ae.select(n),n.length===1&&ms(n[0]),Ce("panel_updateAttrPanel"))}function c5(){let e=Ae.get().sort(yee),t=["rect","ellipse","group","arc"],i=pf(e,t);if(!i.length)return;let r=[],n=[],s=[];if(i.forEach(c=>{let{jsonObj:u,element:h}=c;if(u.cmdKey==="group"){n.push(h),s.push(u.d.trim());return}let d=ef(u);s.push(d.trim()),n.push(h)}),!s.length)return;qt();let a=i.slice(-1)[0].element,{json:o}=k.getById(a.id),l=k.getInitialGroupData({gId:Ot(),layer:o.layer,d:s.join(" "),strokeWidth:o.strokeWidth,strokeColor:o.strokeColor,strokeStyle:o.strokeStyle,fillColor:o.fillColor});ri.renderer.insertBefore(l,a.id),r.push(Qr(l.gId,{cmdKey:"group",refId:a.id},"",l));for(let c of n){let{cmdKey:u,json:h}=k.getById(c.id);r.push(Qr(c.id,{cmdKey:u,refId:Vn(c)},h,"")),k.removeOne(c)}Ke.save(r),Ae.select([{id:l.gId}])}function u5(){let e=Ae.get(),t=["group"],i=pf(e,t);if(!i.length)return;qt();let r=[],n=[];i.forEach(s=>{let{gId:a,jsonObj:o,element:l}=s,u=o.d.split(/(?=M)/i);for(let h of u){if(h=h.trim(),!h)continue;let d=Object.assign({},o,{d:h,gId:Ot()}),p=fl(d);H.gCanvas.insertBefore(p,l),r.push(Qr(p.id,{cmdKey:"group",refId:l.id},"",d)),n.push(p)}r.push(Qr(a,{cmdKey:"group",refId:Vn(l)},o,"")),k.removeOne(l)}),r.length&&Ke.save(r),Ae.select(n)}async function h5(e={warnSvg:!1}){var c;let t=Ae.get(),i=["obj"],r=pf(t,i);if(!r.length)return;let n=[],s=[],a=new F1,o=Mu.getInitialGroupData({});Object.assign(o,{strokeWidth:3.937,displayFill:!1});let l=!1;for(let u of r){if(u.jsonObj.content.startsWith("data:image/svg+xml;base64,")){l=!0;continue}let d=await a.getImageOutlineOfJsonItem(u.jsonObj),p=fs(d.items,!1),f=Object.assign({},o,{d:p,gId:Ot()}),m=fl(f);n.push(Qr(m.id,{cmdKey:"group",refId:(c=m.nextElementSibling)==null?void 0:c.id},"",f)),s.push(m)}l&&(e!=null&&e.warnSvg)&&!n.length&&o2({type:"warn",message:"This file type is not currently supported"}),n.length&&(ls({value:"Outline has been generated."},"success"),n.length&&Ke.save(n),qt(),Ae.select(s))}function d5(e){e=e||Ae.get();let i=["group","arc"],r=pf(e,i);if(!r.length)return;let n=r.map(u=>{if(u.jsonObj.cmdKey=="arc"){let d=u.jsonObj.matrix&&et.createMatrixFrom6(u.jsonObj.matrix),p=Rd(u.jsonObj),f=qi(p);return d&&(f=f.map(m=>m.multiply3(d))),{...u,polylines:f}}let h=qi(u.jsonObj.d);return{...u,polylines:h}});n=n.filter(u=>u.polylines.some(h=>Ig(h)));let s=[],a=[],o=[];n.forEach(u=>{let{gId:h,jsonObj:d,element:p,polylines:f}=u;if(f.length>1){let m=Ag(f,.01);if(m.updatedItems.length){let g=m.updatedItems.map(y=>y.polylineNew),b=fs(g,!1);s.push(Qr(h,{refId:Vn(p),cmdKey:"group"},d,{...d,d:b})),te(p,"d",b),d.d=b,a.push(p)}return}o.push(u)});let l=o.map(u=>u.polylines[0]),c=Ag(l,.01);c.removedItems.forEach(u=>{let h=o[u.index],{gId:d,element:p}=h,{cmdKey:f,json:m}=k.getById(p.id);s.push(Qr(d,{cmdKey:f,refId:Vn(p)},m,"")),k.removeOne(p)}),c.updatedItems.forEach(u=>{let h=o[u.index],{gId:d,jsonObj:p,element:f}=h,m=fs([u.polylineNew],!1);s.push(Qr(d,{refId:Vn(f),cmdKey:"group"},p,{...p,d:m})),te(f,"d",m),p.d=m,a.push(f)}),s.length&&(Ke.save(s),qt(),Ae.select(a))}function p5(e,t){t=t||Ae.get();let i=["group"],r=pf(t,i);if(!r.length)return;let n=[],s=[];r.forEach(a=>{let{gId:o,jsonObj:l,element:c}=a,u=l.d;if(!u)return;let h=e(u);h!=u&&(te(c,"d",h),n.push(Qr(o,{cmdKey:"group",refId:Vn(c)},jt(l),jt(l).d=h)),l.d=h,s.push(c))}),n.length&&(Ke.save(n),qt(),Ae.select(s))}function f5(e){p5(bee,e)}function m5(e){p5(xee,e)}function qC(e){let t=e.style;for(let i=0;i<t.length;i++){let r=t[i],n=t[r];n=n.replace(/px/g,""),te(e,r,n)}}function BS(){let t=zs(new XMLSerializer().serializeToString(H.gCanvas)).getElementById("g1"),i=t.children;for(let y of Array.from(i))te(y,"hide")==1?t.removeChild(y):qC(y);let r;for(;r=_r(".hitbox",t);)dt(r);let n=le("panelFrameSheet").cloneNode(!0);t.insertBefore(n,t.firstElementChild);let s=H.gCanvas.parentNode.querySelectorAll("defs"),a=Array.from(s).map(y=>new XMLSerializer().serializeToString(y)).join(""),o=10,{x:l,y:c,width:u,height:h}=es(t),d=document.body.style.backgroundColor,p=Qs(u+2*o),f=Qs(h+2*o),m=`${l-o} ${c-o} ${u+2*o} ${h+2*o}`,g=new XMLSerializer().serializeToString(t),b=Array.from(document.styleSheets).reduce((y,E)=>{if(E instanceof CSSStyleSheet&&!E.href&&!E.disabled)try{y+=Array.from(E.cssRules).map(S=>yu(S.cssText)).join("")}catch(S){console.warn("ERROR",S)}return y},"");return`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="background-color:${d};stroke-linecap:round;stroke-linejoin:round;" width="${p}mm" height="${f}mm" viewBox="${m}"><style>${b}</style>${a}${g}</svg>`}var JC={text:"Text",obj:"Image",rect:"Rect",ellipse:"Ellipse",group:"Shape",dimension:"Dimension",auxiliaryPoint:"Auxiliary Point",auxiliaryLine:"Auxiliary Line",dimensionLength:"Dimension Length",dimensionRadius:"Dimension Radius",dimensionAngle:"Dimension Angle",arc:"Elliptical Arc"};function See(e){return e.map(wee).filter(Tee)}function wee(e){let{cmdKey:t,json:i}=k.getById(e);if(!t)return;let r=JC[t];if(!r||!i||!Object.keys(i).length)return;let s={id:i.gId,name:i.name||"",layer:+i.layer,type:r,text:i.id||i.gId,dataURL:"",visible:i.visible,eyeGrayType:ai.isEyeGray(i,t),lock:i.locked};if(r==="Dimension"){let a;i.direction==="x"?a="Horizontal Dimension":i.direction==="y"?a="Vertical Dimension":a="Dimension";let o={category:i.category,dimensionType:a};Object.assign(s,o)}return r==="Auxiliary Line"&&(s.type=A2(i.rotation)),s}function vee(e){return!!e}function Tee(e){return vee(e)}var Cg=class{static set all(t){this._all=t;for(let i in this.layer)this.layer[i]=t}static get all(){return this._all}static setLayer(t,i){this.layer[t]=i,this._all=!Object.values(this.layer).some(r=>!r)}};Cg.layer={4:!0,2:!0,1:!0,3:!0,5:!0,6:!0,7:!0,8:!0},Cg._all=!0;function g5(){let e=See([...k.getItemOrder()].reverse()),t=[8,4,3,7,2,1,5,6].reduce((n,s)=>(n.set(s,[]),n),new Map);e.forEach(n=>t.get(n.layer).push(n));let i=[...t.keys()].map(n=>{let s=t.get(n);return{layer:n,i18n:!0,name:f3[n],list:s,iconColor:"orange",type:"PanelLayer",visible:Cg.layer[n]}});return[{name:or("getActiveFileTitle"),type:"Panel",iconColor:H.doctype===ta.PANEL_LIB?"":"primaryBlue",visible:Cg.all,list:i}]}var Iee=["ellipse","group","polyline","rect","text","obj","canvas","arc","dimension","auxiliary"];function Aee(e){let t={};return Iee.forEach(i=>{Object.assign(t,e[i]?e[i]:{})}),t}var y5={"print-layer":1,"transparent-control":2,"plate-and-frame-layer":3,"plate-and-frame-hollowed-out":4,"glue-hollowed-out-back":5,"the-light-layer":6},G1={visible:!1,hide:!0,lock:!0,unlock:!1},KC={"fully-transparent":0,translucence:.5,opacification:1},$C={"have-white-background":!0,"no-white-background":!1};function Cee(e){if(Array.isArray(e)||!e)return[];if(Object.keys(e).length===0)return[];let t=Object.keys(e)[0],i=e[t].checked,r=e[t].visible,n=i!==void 0,s=r!==void 0,a=k.gJsonCache,o=Xa(),l=[],c=o[t]?Object.keys(o[t]):[t],u=Aee(a);for(let h=0;h<c.length;h+=1){let d=c[h],p=[];if($e(o["all-element-type"],d)&&(n&&(o["all-element-type"][d].checked=i),s&&(o["all-element-type"][d].visible=r)),$e(a,d)&&(p=Object.keys(a[d])),d==="dimension"&&(p=Object.keys(k.getDimension())),d==="dimensionLength"){let f=k.getDimensionAngle(),m=k.getDimensionLength(),g=k.getDimensionRadius();p=[...Object.keys(f),...Object.keys(m),...Object.keys(g)]}if(d==="auxiliaryLine"){let f=k.getAuxiliaryLine(),m=k.getAuxiliaryPoint();p=[...Object.keys(f),...Object.keys(m)]}if(y5[d]){$e(o["all-layer"],d)&&(n&&(o["all-layer"][d].checked=i),s&&(o["all-layer"][d].visible=r));for(let f in u)u[f].layer==y5[d]&&p.push(f)}if(G1[d]!=null){$e(o["all-state"],d)&&(n&&(o["all-state"][d].checked=i),s&&(o["all-state"][d].visible=r));for(let f in u)switch(d){case"visible":u[f].hide==G1[d]&&p.push(f);break;case"hide":u[f].hide==G1[d]&&p.push(f);break;case"lock":u[f].locked==G1[d]&&p.push(f);break;case"unlock":u[f].locked==G1[d]&&p.push(f);break}}if(KC[d]!==void 0){$e(o["all-pellucidity"],d)&&(n&&(o["all-pellucidity"][d].checked=i),s&&(o["all-pellucidity"][d].visible=r));for(let f in u)switch(d){case"fully-transparent":u[f].opacity==KC[d]&&p.push(f);break;case"translucence":u[f].opacity>0&&u[f].opacity<1&&p.push(f);break;case"opacification":u[f].opacity==KC[d]&&p.push(f);break}}if($C[d]!==void 0){$e(o["all-white-background"],d)&&(n&&(o["all-white-background"][d].checked=i),s&&(o["all-white-background"][d].visible=r));for(let f in u)switch(d){case"have-white-background":u[f].cover===$C[d]&&p.push(f);break;case"no-white-background":u[f].cover==$C[d]&&p.push(f);break}}if(d=="boundary"){let f=o["all-layer"][d];$e(o["all-layer"],d)&&(n&&(f.checked=i),s&&(f.visible=r)),ia(le("panelFrameSheet"),"hide",f.visible)}l.push(...p)}for(let h of l)ai.applyElementsVisible(h)}function b5(e){let t={rectangle:"rect",circle:"ellipse"};for(let i in e){let r=t[i]||i;r!==i&&(e[r]=e[i],delete e[i])}Cee(e)}function uo(e){if(e){for(let i=0;i<e.length;i++){let r=e[i].lists;for(let n=0;n<r.length;n++){if(r[n].title=="All")continue;let s={};s[r[n].key]={checked:r[n].checked,visible:r[n].visible},b5(s)}}return}let t=Xa();for(let i in t)for(let r in t[i]){let n=jt(t[i][r]),s={[r]:n};n.checked===!0&&delete n.checked,n.visible===!0&&delete n.visible,Object.keys(n).length!==0&&b5(s)}}var Ja=class{constructor(){this.id="panelFrameSheet"}init(t){let i=t.docType===ta.PANEL_LIB?"none":"";this.isHidden()&&(i="none"),ri.renderer.removeNode(this.id);let r=Et("path",{id:this.id,fill:"none",stroke:"red","stroke-width":"1","pointer-events":"none","vector-effect":"non-scaling-stroke",display:i});return H.gCanvas.parentNode.insertBefore(r,H.gCanvas.nextElementSibling),this.update(),r}update(){ri.renderer.attr(this.id,"d",this.getPanelMarkPathDForDesign())}getPanelMarkPathDForDesign(){let{w:t,h:i}=this.getMaterialFrameSize(),r=this.getMarkSize(),n={x:0,y:0},s={x:t,y:0},a={x:t,y:-i},o={x:0,y:-i},l=`M 0 0 H ${t} V ${-i} H 0 Z `;return l+=`M ${n.x} ${n.y} l ${r} ${-r} l ${-r} 0 l ${r} ${r} l 0 ${-r}`,l+=`M ${s.x} ${s.y} l ${-r} ${-r} l 0 ${r} l ${r} ${-r} l ${-r} 0`,l+=`M ${a.x} ${a.y} l ${-r} ${r} l 0 ${-r} l ${r} ${r} l ${-r} 0`,l+=`M ${o.x} ${o.y} l ${r} ${r} l 0 ${-r} l ${-r} ${r} l ${r} 0`,l.trim()}getBBox(){let t=new ot;for(let n of this.getMarksBBox())t.ext10(n);let i=t.build();return{x:i.minX,y:i.minY,width:i.width(),height:i.height()}}getAllInfo(){return{BBox:this.getBBox(),isHidden:this.isHidden(),path:this.getPanelMarkPathDForDesign()}}display(t){ri.renderer.attr(this.id,"display",t?"":"none")}isHidden(){var i;let t=(i=Qe.getCurrentScheme())==null?void 0:i.options.find(r=>r.id===-1);return(t==null?void 0:t.visible)===!1}getMarkSize(){let t=Yt(10,"mm","pixel"),i=Yt(2.5,"mm","pixel"),r=Yt(10,"mm","pixel");return t+i+r/2}getMarksBBox(){let t=[],{w:i,h:r}=this.getMaterialFrameSize(),n=this.getMarkSize();return t.push({x:0,y:-n,width:n,height:n}),t.push({x:0,y:-r,width:n,height:n}),t.push({x:i-n,y:-n,width:n,height:n}),t.push({x:i-n,y:-r,width:n,height:n}),t}getMaterialFrameSize(){let{width:t,height:i}=k.getHead(),r=Yt(parseFloat(t),"mm","pixel"),n=Yt(parseFloat(i),"mm","pixel");return{w:r,h:n}}};var Dg=class Dg{static refreshCanvas(t){let i={},r=!1,n=Xt.getCanvasAttrs();n["attr-canvas-bgcolor"]!==t.background&&(i["attr-canvas-bgcolor"]=t.background,r=!0),n["attr-canvas-grid-color"]!==t.grid&&(i["attr-canvas-grid-color"]=t.grid,r=!0),r&&Xt.modify_canvas(i)}static updateGlobalTheme(t){let r=document.getElementById("themeStyle").sheet,n=Dg.getRootRuleIndex(r);n!=-1&&r.deleteRule(n);let s=HC(t);return r.insertRule(s),r}static getRootRuleIndex(t,i=":root"){let r=t.cssRules||t.rules,n=-1;for(let s=0,a=r.length;s<a;s++)if(r[s].selectorText===i){n=s;break}return n}static setTheme(t=H.profileSetting.commSystemSetting.PANEL_THEME){let i=t||H.panelThemeCache;this.rebuildPanelThemeCache(t);let{color:r}=i;this.refreshCanvas(r),this.updateGlobalTheme(i)}static rebuildPanelThemeCache(t){H.panelThemeCache=t}};Dg.customizeKey="customize",Dg.blackKey="black",Dg.whiteKey="white";var _g=Dg;function x5(e){let t={key:0,text:"No",value:"inherit"};return(e=="underline"||e=="1")&&(t={key:0,text:"Yes",value:"underline"}),(e=="inherit"||e=="0")&&(t={key:1,text:"No",value:"inherit"}),t}var ZC={text:"text",arc:"arc",rect:"rect",polyline:"line",group:"line",circle:"circle",line:"line",ellipse:"ellipse",auxiliaryPoint:"auxiliaryPoint",auxiliaryLine:"auxiliaryLine"};var E5="--selectColor",kS=class{constructor(t){this.panelCompiler=t;this.canPublishSelect=!0;this._notPublishOnce=!1;this.userSelectMap=new Map;this.lastSelectMap=new Map}async init(){this.user=(await Ho("getUserInfoFromCache")).message;let t=(await H.windowBridge.rpcCall("getActiveProject",null,ut())).message;this.canPublishSelect=(await H.windowBridge.rpcCall("ui/hasDocCreatePermission",{projectId:t,showMsg:!1},ut())).message}getSelect(){let t=Ae.getIds().slice(0,1e3).map(i=>({cmdKey:k.getById(i).cmdKey,uuid:i}));return JSON.stringify({data:t,updateTime:+new Date})}onDestroy(t,i){this.userSelectMap.delete(t),pi.appendSelectStroke(this.getChangeMap(),!1)}async changeSelect(t,i,r){var l;if(t.uuid===this.user.uuid)return;let s=JSON.parse(r),a=s.updateTime,o=((l=this.userSelectMap.get(t.uuid))==null?void 0:l.selectColor)||(await H.windowBridge.rpcCall("getUserColor",t.uuid,ut())).message;this.userSelectMap.set(t.uuid,{user:t,selected:s.data,updateTime:a,selectColor:o}),pi.appendSelectStroke(this.getChangeMap(),!1)}getSelectMap(){let t=new Map;return[...this.userSelectMap.keys()].sort((r,n)=>{let s=this.userSelectMap.get(r).updateTime,a=this.userSelectMap.get(n).updateTime;return s-a}).forEach(r=>{let{selected:n,selectColor:s}=this.userSelectMap.get(r);n.forEach(a=>t.set(a.uuid,{...a,color:s}))}),Ae.getIds().forEach(r=>{let n=k.getById(r).cmdKey;t.set(r,{cmdKey:n,color:E5,uuid:r})}),t}getSelfSelectMap(){let t=new Map;return Ae.getIds().forEach(i=>{let r=k.getById(i).cmdKey;t.set(i,{cmdKey:r,color:E5,uuid:i})}),t}getChangeMap(){let t=new Map,i=this.getSelectMap();return this.lastSelectMap.forEach((r,n)=>{let s=i.get(n);r.color!==(s==null?void 0:s.color)&&t.set(n,{...r,color:s==null?void 0:s.color})}),i.forEach((r,n)=>{let s=this.lastSelectMap.get(n);(s==null?void 0:s.color)!==r.color&&t.set(n,r)}),this.lastSelectMap=i,t}notPublishOnce(){this._notPublishOnce=!0}updateChange(){let t=this.getSelect();!this.canPublishSelect||this._notPublishOnce?(this._notPublishOnce=!1,this.changeSelect(this.user,void 0,t)):this.panelCompiler.publishSelected(t,!0)}};async function QC(e,t,i){FS(0);let r=(await H.windowBridge.rpcCall("getActiveProject",null,ut())).message,n=t===r,s=k.compilerManager;if(!k.compilerManager){let d=c0.PANEL_LIB===i.docType,p=new eg(d);if(s=new df(e,t,n,p),k.selectedRepeater=new kS(s),await k.selectedRepeater.init(),!(await s.init()).success)return}let a=await s.getJsonCache();if(!a){console.error("no jsonCache, Plz check code");return}let{width:o,height:l}=a.head;(Number(o)<=0||Number(l)<=0)&&(s.uploadData("canvas",N1),await s.save()),FS(.5),s.pauseDateMerge(),k.compilerManager=s,Xt.clear(),w5(a),Wr().setOriginXY(),Xt.initCanvasSize(i),await S5();let c=await Rn.toSVG(a);i.docType&&(H.doctype=i.docType,k.gJsonCache.head.docType=i.docType);let u=zs(c);if(!u){console.error("Invalid Xml",c);return}let h=document.importNode(u.documentElement,!0);if(!h){o2({type:"error",message:"import node failure"});return}if(FS(.8),_g.setTheme(),GS(),new Ja().init(i),h=_r("g",h),h){let d=document.createDocumentFragment();for(;h.firstChild;)d.appendChild(h.firstChild);H.gCanvas.appendChild(d),d=null}FS(1),bt.setShapeCache(),Ke.clear({saved:i.saved}),Wr().fitview(),s.resumeDataMerge(),Ce("switchGridSizeBtn",{value:Qs(Ge.adsorbGrid.gridSize)}),Ce("setTopMenuItemsChecked",{"unit(mm)":!0}),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel_updateAttrPanel")}function FS(e){or("progressUpdate",[e,"Open Panel","OpenPanel"])}var US=class{constructor(t){this.encoder=new m4(t)}uploadJsonCache(t){Nu.uploadJsonCache(this.encoder,t)}getDataStr(){return this.encoder.getDataStr()}};var Dee={CANVAS:"onCanvas",POLY:"onPoly",GROUP:"onGroup",STRING:"onString",DIMENSION:"onDimension",AUXLINE:"onAuxLine",BLOB:"onBlob"},Pg=class extends OA{constructor(i=k.compilerManager){super();this.compiler=i;this.success=!1}async decodeDataStr(i){let r=k.exchangeJsonCache(k.getDefaultGJsonCache());this.success=!0,this.compiler.pauseDateMerge(),this.parseFull(i);let n=await this.compiler.getMergeDataJsonCache();return r(),this.compiler.resumeDataMerge(),{jsonCache:n,success:this.success}}onLine(i,r,n,s,a,o,l,c,u,h){let d=JSON.parse(n),p=Dee[s];p?s==="CANVAS"?this.compiler.onCanvas(a,r,d):this.compiler[p](i,r,a,c,d):this.success=!1}onDocHead(i,r){this.compiler.onDocDetail("",0,i)}onEnd(){}};function v5(){let e=H.profileSetting&&H.profileSetting.commSystemSetting&&H.profileSetting.commSystemSetting.PANEL_CANVAS.cursor;return(H.profileSetting&&H.profileSetting.commSystemSetting&&H.profileSetting.commSystemSetting.PANEL_CANVAS.schAlwaysDisplayCursor)===!0&&e!=="None"}function T5(){v5()&&(H.helperCursor="cross-red")}function I5(){let e=v5();H.helperCursor=e?"cross-red":H.cmdToken?H.helperCursor:""}function A5(){return H.profileSetting.commSystemSetting.PANEL_CANVAS.cursor==="Small"}function Wr(){return{openDocComplete:()=>{H.openDocComplete=!0},getOpenDocComplete(){return H.openDocComplete},fitview:YS,"color-exchange"(){R5()},duplicateToCursor(){if(Ae.getIds().length==0){H.windowBridge.publish("panelMessage",{type:"show",timeout:3e3,title:"Information",msg:"Nothing selected",showType:"slide"},ut());return}lr.exit(),H.frameHelper.getToolProcessor().switchToPasteTool("duplicate")},projectPermission(){return Ru.forbiddenDataChange()},decodeNewJsonStr:async e=>{let t=new Pg,{jsonCache:i,success:r}=await t.decodeDataStr(e);return r?i:!1},uploadJsonCache2:async(e,t)=>(Nu.uploadJsonCache2(e),Ke.clear({saved:t.saved}),await k.compilerManager.getJsonCache()),importDocEdit:QC,"-syncImportDocEdit":async e=>{let{uuid:t,path:i,options:r}=e;await QC(t,i,r)},closeDoc(){var e;(e=k.compilerManager)==null||e.destroy()},duplicatePaste:async()=>{if(!Ae.getIds().length){H.windowBridge.publish("panelMessage",{type:"show",timeout:3e3,title:"Information",msg:"Nothing selected",showType:"slide"},ut());return}D5(),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),H.windowBridge.publish("panelMessage",{type:"show",timeout:3e3,title:"Information",msg:"\u91CD\u590D\u5230\u539F\u4F4D\u7F6E\uFF1A\u64CD\u4F5C\u6210\u529F\uFF01",showType:"slide"},ut())},"panel/save"(){return k.compilerManager.save()},"panel/resumeDataMerge"(){k.compilerManager.resumeDataMerge()},unlockAll(){Gi.unlockAll(),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},showAll(){ai.showAll(),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},hide(){let e=Ae.getIds();ai.toggleElementsDisplay(e,!1),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},unhide(){let e=Ae.getIds();ai.toggleElementsDisplay(e,!0),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},showRuler(){Ce("changeRulerVisible",[window.frameElement.classList.contains("un_ruler"),H.tabId])},modifyCanvas:Xt.modify_canvas,setTabId:function(e){console.warn("you may not have to setTabId, because tabId already exist",H.tabId),e&&(H.tabId=e)},updateSystemConfig:function(e){H.profileSetting=e,H.topMenuStatus.sync(),Ar.updateConfig(),I5(),H.helperCursor||cs(!1)},rotate(e){let i=oo(),r,n,s=arguments[0];if(typeof s=="number")e=s;else if(typeof s=="string")isNaN(+s)||(e=+s);else if(typeof s=="object"&&s.ids&&(n=s.ids,e=s.degree,!Array.isArray(n)))return;if(e===void 0&&(e=270),n){if(r=n.map(function(c){return le(c)}),r=r.filter(function(c){return c&&Vs(c.parentNode,ko)}),r.length){let c=new oi(r);Hc(r,e),fr(r),!i&&c.updateAndSave(),Ce("panel_updateAttrPanel")}return}let a=H.frameHelper.getToolProcessorCurrentTool(),o=a==null?void 0:a.getSymbol();if([ii.drag_tool,ii.paste_tool,ii.place_lib_tool,ii.draw].includes(o)){a.rotate(e),Ce("panel_updateAttrPanel");return}if([ii.rotate_by_anchor_tool,ii.drag_control_dot_tool].includes(o))return;let l=new Tg(Mi(),{notSaveHistory:i});return l.do(e),Ce("panel_updateAttrPanel"),pi.debouncedAppendSelectStroke(),l.success},delete(){jo(),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},"delete-all":function(){HS(),jo(),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},duplicateTo:function(...e){Lg.do(...e)},storeImageData:function(e){H.defaultImage=e},forceReleaseToken:function(){Rh()},getJsonCache(e={getPath:!1}){return k.getGJsonCache(e.getPath)},getActiveCompressStr(){let e=new US(H.tabId.split("@")[0]);return e.uploadJsonCache(k.gJsonCache),e.getDataStr()},getProductWidthHeight:()=>k.getProductWidthHeight(),setToolbarCmd:function(){return ku.apply(null,arguments)},zoom:rc,getViewStatus:function(){return Og()},getFrameInfo(){return new Ja().getAllInfo()},updateSaveIndex:function(){Ke.savedIndex=Ke.index.value},getSG(){return{S:{value:H.gZoom},G:{value:Ge.adsorbGrid.gridSize,unit:Ge.canvas.unit}}},undo:function(){Je.started||Je.dots.length||Je.target||oo()||Ke.go(-1)},redo:function(){Je.started&&Je.dots.length||oo()||Ke.go(1)},cut:async function(){H.frameHelper.getToolProcessor().switchToReferencePointTool();let e=Mi();e.length&&(lr.referenceIsSelectedReferencePoint?lr.enterCutStart(H.tabId,e):(H.windowBridge.publish("setReferencePosition",void 0,ut()),Yd()))},async copy(e,t=!0){try{let n=await navigator.clipboard.read();if(n.length>0){let s=n[0].types[0];(!s||s.startsWith("image/"))&&await navigator.clipboard.writeText("eda image copy occupy")}}catch{}H.frameHelper.getToolProcessor().switchToReferencePointTool();let i=Mi();return Array.isArray(e)&&(i=e),i.filter(n=>{let{cmdKey:s}=k.getById(n.id);return s!=="dimension"}).length?(t&&lr.referenceIsSelectedReferencePoint?(pr("cross-red",void 0,void 0,"\u8BF7\u9009\u62E9\u53C2\u8003\u70B9"),lr.enterCopyStart(i||Mi())):(H.windowBridge.publish("setReferencePosition",void 0,ut()),await Vd(i)),t?Promise.resolve(lr.referenceIsSelectedReferencePoint):!1):Promise.resolve(lr.referenceIsSelectedReferencePoint)},async paste(e){try{let t=await window.top.navigator.clipboard.read();if(t.length>0&&!t[0].types[0])return}catch{}H.frameHelper.getToolProcessor().switchToPasteTool(Ac(e)?e:"")},async pasteInPlace(){await C5(),Ce("panel_updateAttrPanel"),Ce("updateMenuByDocStatus"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},abortReferencePointMode:function(){lr.abortReferencePointMode()},abortReferencePointModeAndCancelPaste(){lr.abortReferencePointMode()},clone:function(){var e=arguments[0];if(typeof e=="object"&&e.ids){var t=e.ids;if(!Array.isArray(t))return;var i=t.map(function(r){return le(r)});i=i.filter(function(r){return r&&Vs(r.parentNode,ko)})}},distribute_vertical_equidistant(e){ho("align_vertical_equidistant",e)},distribute_horizontal_equidistant(e){ho("align_horizontal_equidistant",e)},endEditingPath(){wt.endEditingPath()},select_none(){qt(),Wt.setEditing(null)},selectById(e,t){let{notReleaseActive:i}=t;i||Ae.unselectAll();let r=e.map(n=>le(n)).filter(n=>n);Ae.select(r)},highlightById:function(e){let t=le(e);t&&(ai.eleIsHide(k.getById(e).json)||pi.createHighlightStyle(le(e)),Ae.highlight(t))},unhighlightById:function(e){le(e)&&Ae.unhighlight(le(e)),pi.shouldRemoveHighlight(e)},highlightCombination:function(e){let t=new rt,{elements:i}=t.getAllElesfromTop(e);[...i].forEach(r=>{let n=le(r);n&&(ai.eleIsHide(k.getById(r).json)||pi.createHighlightStyle(n,!0),Ae.highlight(n))})},unhighlightCombination:function(e){let t=new rt,{elements:i}=t.getAllElesfromTop(e);[...i].forEach(r=>{ai.eleIsHide(k.getById(r).json)||Wr().unhighlightById(r)}),pi.removeCombinationElmsHighlightStroke()},unSelectById:function(e){Array.isArray(e)||(e=[e]),e.forEach(t=>{le(t)&&Ae.unselect(le(t))})},select:function(){var e=arguments[0];if(typeof e=="object"&&e.ids){var t=e.ids;if(!Array.isArray(t))return;var i=t.map(function(r){return le(r)});if(i=i.filter(function(r){return r&&Vs(r.parentNode,ko)}),i.length)return Ae.select(i)}else typeof e=="string"?Ae.select(le(e)):Ae.select(e)},bring_to_front:function(e){_5(e),new Ni().updateHole(!0),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},send_to_back:function(e){P5(e),new Ni().updateHole(!0),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},raise_one_level:function(e){L5(e),new Ni().updateHole(!0),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},lower_one_level:function(e){O5(e),new Ni().updateHole(!0),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},rotate_left:function(){var e=arguments[0];typeof e=="object"&&e.ids||Wr().rotate(270)},endCutState:function(e){lr.endCutState(e)},rotate_right:function(){var e=arguments[0];typeof e=="object"&&e.ids||Wr().rotate(90)},fliph(){let e=H.frameHelper.getToolProcessorCurrentTool(),t=e==null?void 0:e.getSymbol();[ii.drag_tool,ii.paste_tool,ii.place_lib_tool].includes(t)?e.flipH():eD(1),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel_updateAttrPanel")},flipv(){let e=H.frameHelper.getToolProcessorCurrentTool(),t=e==null?void 0:e.getSymbol();[ii.drag_tool,ii.paste_tool,ii.place_lib_tool].includes(t)?e.flipV():eD(0),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel_updateAttrPanel")},lock(e){e=e||Ae.getIds(),Gi.setLockStatus(e,!0),uo(),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel_updateAttrPanel")},lockElements(e){e=e||Ae.getIds(),Gi.setElementsLockStatus(e,!0),uo()},unlockElements(e){e=e||Ae.getIds(),Gi.setElementsLockStatus(e,!1),uo()},unlock(e){e=e||Ae.getIds(),Gi.setLockStatus(e,!1),uo(),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel_updateAttrPanel")},isLocked(e){let t=le(e);return t&&Gi.isLockedById(t.id)},lockCombination:e=>{Gi.setCombinationLockStatus(e,!0),Ce("panel_updateAttrPanel")},unlockCombination:e=>{Gi.setCombinationLockStatus(e,!1),Ce("panel_updateAttrPanel")},isEleInCombination:function(e){return{eleInCombination:new rt().searchCombination(e)}},canvas_config:function(){return jt(Ge.canvas)},getEleAttrParams(){let e=Ae.get();return e.length?Y1(e):[{cmdKey:"canvas"}]},attrGetData(e){return Hd(e,H.tabId)},currZoom:function(){return H.currZoom},getSelected:function(){return Mi()},pasteFromDataStr:async function(e){let t=await XB(e);H.frameHelper.getToolProcessor().switchToPasteTool("paste_dxf",await MS(t),e.origin?void 0:"center")},releaseActive:function(e){return qt(e)},setOrigin:function({originX:e,originY:t}){Ud.setOrigin(e,t)},setOriginXY:function(e){e||(e={x:k.gJsonCache.head.originX||0,y:k.gJsonCache.head.originY||0}),e.x=isFinite(e.x)&&e.x!==null?+e.x:Ge.canvas.originX,e.y=isFinite(e.y)&&e.y!==null?+e.y:Ge.canvas.originY,e.x=Zr(e.x),e.y=Zr(e.y),Ge.canvas.originX=e.x,Ge.canvas.originY=e.y;var t=.5/H.gZoom;te(le("gridOH"),{y1:e.y+t,y2:e.y+t}),te(le("gridOV"),{x1:e.x+t,x2:e.x+t}),te(le("gridPattern"),{x:e.x,y:e.y}),k.gJsonCache.head.originX=e.x,k.gJsonCache.head.originY=e.y,ac()},snap_grid:function(){Ge.adsorbGrid.enabled=!Ge.adsorbGrid.enabled},visible_grid:function(){var e=te(le("gridBg"),"display")||"";e=e=="none"?"":"none",te(le("gridBg"),{display:e}),Ge.adsorbGrid.visible=!e},deleteObjs:function(e){if(typeof e=="string")e=le(e);else if(typeof e=="object"&&e.ids){let t=e.ids;if(!Array.isArray(t))return;e=t.map(function(i){return le(i)})}jo(e)},adaptAreaSelectionView(){Rh(),pr("cross-red"),H.contextmenuDisableOnce=!0,document.querySelector("#g1").classList.add("none-events"),Os.setAdaptAreaSelectionView(!0)},adaptSelectionView:VS,highlightItems:function(e,t={scrollElementsIntoView:!0}){let i;function r(l,c=!0){c&&(Bu(l.x,l.y),cs(l.x,l.y,{strokeWidth:"2",strokeLinecap:"square"})),clearTimeout(i),i=setTimeout(()=>{te(le("gMarkError"),"visibility","hidden"),cs(!1),H.helperCursor=void 0},1e3)}let{scrollElementsIntoView:n}=t,s=[];for(let l of e)le(l)&&s.push(le(l));let a=Rr(s,!0),o=new j(a.x+a.width/2,a.y+a.height/2);n?Jl(a,1,!0):Jl(a,0),r(o,!0),new Ni().updateHole()},convertStrokeToShape(){return l5()},convertBaseShapeToPath:function(){return o5()},combineShapes:function(){c5(),Ce("updateMenuByDocStatus"),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel/updateTreeActiveElements")},generateImageOutline:async function(){await h5({warnSvg:!0}),Ce("updateMenuByDocStatus"),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel/updateTreeActiveElements")},breakShapeApart(){u5(),Ce("updateMenuByDocStatus"),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel/updateTreeActiveElements")},joinPath(){d5(),Ce("updateMenuByDocStatus"),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel/updateTreeActiveElements")},reversePath:function(){return f5()},simplifyPath:function(){return m5()},deleteEmptyCombination(e){new rt().deleteEmptyCombination(e)},groupSelected(){new rt().combine(),Ce("updateMenuByDocStatus"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},ungroupSelected(){new rt().unCombine(),Ce("updateMenuByDocStatus"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},ungroupAllEmpty(){new rt().unCombineAllEmpty(),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},ungroupAll(){new rt().unCombineAll(),Ce("panel_updateAttrPanel"),Ce("updateMenuByDocStatus"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},enterGroup(){let e=new rt,t=Ae.getIds(),i=e.searchCombination(t[0]);if(!i)return;let r=e.findFamily(i).peekParent();Wt.setEditing(r),Ce("panel/updateTreeActiveElements"),Ce("panel_updateAttrPanel")},removeFromGroup(e){new rt().removeFromGroup(e),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},joinGroup(e){if(!e)return;new rt().joinGroup(e),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},exportPanelSVG:function(e){let t=BS();if(WB)return H.windowBridge.publish("exportFileClientWay",{data:{fileData:t,fileTitle:`${e}.svg`,extension:"svg"}},ut());T4(new Blob([t]),`${e}.svg`)},PanelLayerMaster:()=>Qe,getSelectedObjsInfoInTreeNode(){let e=Ae.getIds(),t=[];if(e.length>0){let{combinations:i,elements:r}=new rt().getSelectedCombinations(e);i.forEach(n=>{t.push({type:"CombinationGroup",id:n})}),r.forEach(n=>{let s=le(n);switch($t(s)){case"auxiliaryLine":t.push({type:A2(k.getAuxiliaryLine(s.id).rotation),id:s.id});default:t.push({type:JC[$t(s)],id:s.id})}})}return t},selectCount:()=>Ae.count(),repeat:()=>{var r;let{useable:e}=Tr,t=Tr.get();if(!e||!t)return;let i={4:n=>{Wr().delete()},3:n=>{Wr().rotate(n.degree)},2:n=>{U1(Mi(),n.movement)},0:async n=>{Wr().duplicateTo(n.data)},7:async n=>{Wr().duplicateTo(n.data,n.movement)},6:async n=>{Wr().duplicateTo(n.data)},8:n=>{Wr().duplicateTo(n.data,n.movement)},5:n=>{let s=Ae.getIds();n.locked?Wr().lock(s):Wr().unlock(s)},10:n=>{n.isVisable?Wr().unhide():Wr().hide()},11:()=>{Wr().pasteInPlace()}};Ce("panel_updateAttrPanel"),(r=i[t.type])==null||r.call(i,t)}}}var _ee="clickedCanvas",jd=class jd extends yn{constructor(){super();this.ctrl=!1;this.isDragCopy=!1;this.oldCanvansDot={x:0,y:0}}handleTarget(i){let r=i.originalEvent;this.event=r;let n=r.target,s=r.metaKey||r.ctrlKey,o=Rg()==="continuousSelection";if(this.ctrl=s||o,this.eventTarget=n,[document,document.documentElement,document.body].includes(n))return;let l=H.svgRoot===n?void 0:z2(r);this.target=l}onMouseLeftDown(i){var a;jd.elementsForDrag=[];let{canvasX:r,canvasY:n}=i;if(this.oldCanvansDot.x=r,this.oldCanvansDot.y=n,this.hasMouseLeftDownBeforeUp=!0,H.windowBridge.publish(_ee,[{mouseButton:"left",mouseMotion:"down"}],ut()),this.handleTarget(i),!this.eventTarget)return;if(rf(r,n)&&!wt.isEditingPath()&&!this.ctrl){jd.elementsForDrag=Ae.getIds().map(o=>({id:o}));return}if(!this.target&&!this.ctrl&&this.eventTarget&&this.eventTarget.tagName!="TEXTAREA"&&!un.on&&nc.getCursor()==4&&qt(),this.ctrl)this.target&&((a=H.profileSetting)!=null&&a.commSystemSetting.PANEL_CANVAS.is_ctrl_drag_to_drag)&&(this.isDragCopy=!0,this.leftDownForDragCopyEle=this.target);else if(this.target){let o=xB(r,n);if(o.length){jd.elementsForDrag=o;return}if(Ae.getIds().includes(this.target.id)){jd.elementsForDrag=Ae.getIds().map(c=>({id:c}));return}let l=Wt.getSelectDependMaskMode(this.target.id);jd.elementsForDrag=l}}onMouseLeftUp(i){if(un.on||lo.running)return;this.isDragCopy=!1;let{canvasX:r,canvasY:n}=i,{x:s,y:a}=this.oldCanvansDot,o=rf(r,n)&&!wt.isEditingPath();!this.target&&o&&r==s&&n==a&&(nc.switch(4),qt()),this.ctrl?this.target&&Ae.toggle([this.target]):this.loopSelect(i.originalEvent),this.hasMouseLeftDownBeforeUp&&Ce("panel_updateAttrPanel"),this.hasMouseLeftDownBeforeUp=!1;let{x:l,y:c}=ui(i.originalEvent,!1);wt.clickShowSegmentHandle(this.target,l,c),Ce("panel/updateTreeActiveElements"),Ce("updateMenuByDocStatus")}loopSelect(i){let r=Pee(i),n=k.getItemOrderSortMap();if(r.size<1){qt(),this.target&&Ae.select([this.target]);return}let s=[];for(let c of r){let u=n.get(c.id);s.push({index:u,ele:c})}s.sort((c,u)=>{let h=+te(c.ele,"layer"),d=+te(u.ele,"layer");return[h,d].includes(8)&&h!==d?d-h:u.index-c.index});let a=0;for(let c=0;c<s.length;c++){let u=s[c];if(Ae.isSelected(u.ele)){a=c+1,!this.ctrl&&Ae.unselect(u.ele);break}}a=a===s.length?0:a,!this.ctrl&&a===0&&qt();let o=0,l;for(let c of s){if(o===a){l=c.ele;break}o++}Ae.select([l])}onMouseRightDown(i){this.handleTarget(i)}isCtrlDargMove(i){return i.mouseLeftMoving&&i.originalEvent.ctrlKey&&this.isDragCopy}onMouseMove(i){var a;if(Ae.unhighlight(this.hoverNearByTarget),this.handleTarget(i),Ae.highlight(this.target),this.hoverNearByTarget=this.target,!i.originalEvent.altKey&&H.cmdToken){let o=pl(i.originalEvent.target);o&&o!==H.svgRoot&&bt.boxCenterAddCrossFlag(o.id)}if(this.isCtrlDargMove(i)){let o="ctrl_drag_copy2";Ae.getIds().includes(this.leftDownForDragCopyEle.id)||Ae.unselectAll(),Ae.select([this.leftDownForDragCopyEle]);let l=Wr();l.copy(void 0,!1).then(c=>{!c&&l.paste(o)}),this.isDragCopy=!1,this.leftDownForDragCopyEle=null;return}pi.createHighlightStyle(this.hoverNearByTarget);let r=!0;!((a=H.profileSetting)!=null&&a.commSystemSetting.PANEL_CANVAS.is_ctrl_drag_to_drag)&&i.ctrlKeyDown&&(r=!1),nc.mouseMoveCursor(i.originalEvent,this.target,new j(i.canvasX,i.canvasY),r);let{x:n,y:s}=ui(i.originalEvent,!1);wt.createHoverAnchor(this.target,n,s)}onDoubleClick(i){var n;this.handleTarget(i);let r=k.getById((n=this.target)==null?void 0:n.id).json;r&&r.locked||(BB(this.target,i.originalEvent),Ce("panel_updateAttrPanel"),Ce("panel/updateTreeActiveElements"))}onMouseRightUp(i){if(!ao.dragpanning&&lo.running){lo.instance.cancel();return}if(un.on||(this.handleTarget(i),this.ctrl))return;let r=this.eventTarget.classList.contains("hitbox");if(r&&!H.gCanvas.contains(this.eventTarget))return;let n=this.eventTarget==H.svgRoot,s=this.target==H.svgRoot;if($t(this.target)!=="cdot"){this.target&&!Ae.isSelected(this.target)&&!s&&(qt(),Ae.select([this.target]));let o=pl(this.eventTarget);!r&&o&&!Ae.isSelected(o)&&!n&&qt()}M5(this.event,this.target),Ce("panel_updateAttrPanel"),Ce("panel/updateTreeActiveElements"),Ce("updateMenuByDocStatus")}install(){console.log(this.getSymbol(),"installed")}uninstall(){console.log(this.getSymbol(),"uninstalled")}getSymbol(){return ii.highlight}};jd.elementsForDrag=[];var Fu=jd;function Pee(e){let t=ui(e,!1),{x:i,y:r}=t,n=new Set,s=EC(i,r);if(s.length)for(let b of s)n.add(b);let a=SC(i,r);if(a.length)for(let b of a)n.add(b);let o=wC(i,r);for(let b of o)n.add(b);let l=vC(i,r);for(let b of l)n.add(b);let c=TC(i,r);for(let b of c)n.add(b);let u=IC(i,r);for(let b of u)n.add(b);let h=w1(i,r);if(h.size)for(let b of h)n.add(b);let d=Ch(i,r);if(d.length)for(let b of d)n.add(le(b));let p=Uc(i,r);if(p.length)for(let b of p)n.add(le(b));let f=tf(i,r);if(f.length)for(let b of f)n.add(b);let m=gg(i,r);if(m.length)for(let b of m)n.add(b);let g=v1(i,r);for(let b of g)n.add(b);return n}var Na=class Na{static rotate(t,i,r,n){if(XI(t))if(Xo){let s=+te(Xo,"c_rotate")||0;return te(Xo,{c_rotate:tr(s+i)}),Na.rotateOne(Xo,i,r,n)}else{let s;return t.forEach(function(a){s=Na.rotateOne(a,i,r,n)}),s}else return Na.rotateOne(t,i,r,n)}static rotateOne(t,i,r,n){if(r===void 0||n===void 0){let s=te(t,"c_origin"),a=te(t,"c_partid");if(a==="part_text")[r,n]=s.split(",").map(parseFloat);else if(a==="part"){let o=ec(t.querySelector(".hitbox"));r=o.x+o.width/2,n=o.y+o.height/2}else if(s){let o=s.split(",");r=+o[0],n=+o[1]}else{let o=ec(t);r=o.x+o.width/2,n=o.y+o.height/2}}return Na[t.tagName]&&Na[t.tagName](t,i,r,n),{rotateCenterX:r,rotateCenterY:n}}static groupRotate(t,i,r,n){let s,a=t.length,o,l,c;if(!a)return;if(a<2){Na.rotate(t[0],i,r,n);return}if(r!==void 0&&n!==void 0){for(s=0;s<a;s++)Na.rotate(t[s],i,r,n);return}function u(d){try{return d.getBBox()}catch{}}function h(d){if(d){let p=d.split(",");return{x:+p[0],y:+p[1]}}}for(s=0;s<a;s++)if(t[s].tagName!="text"&&!te(t[s],"c_origin")){o=!0;break}if(o)for(s=0;s<a;s++)c=u(t[s]),c&&(l?(l.x=Math.min(l.x,c.x),l.y=Math.min(l.y,c.y),l.x2=Math.max(l.x2,c.x+c.width),l.y2=Math.max(l.y2,c.y+c.height)):l={x:c.x,y:c.y,x2:c.x+c.width,y2:c.y+c.height});else for(s=0;s<a;s++)c=h(te(t[s],"c_origin")),!c&&t[s].tagName=="text"&&(c={x:+te(t[s],"x"),y:+te(t[s],"y")}),c&&(l?(l.x=Math.min(l.x,c.x),l.y=Math.min(l.y,c.y),l.x2=Math.max(l.x2,c.x),l.y2=Math.max(l.y2,c.y)):l={x:c.x,y:c.y,x2:c.x,y2:c.y});if(l)for(r=lt((l.x+l.x2)/2,3),n=lt((l.y+l.y2)/2,3),s=0;s<a;s++)Na.rotate(t[s],i,r,n)}static g(t,i,r,n){if(i===void 0&&(i=270),i%360===0)return;let s=te(t,"c_origin"),a,o,l,c=s&&s.split(",");if(r===void 0||n===void 0?c?(r=+c[0],n=+c[1]):(a=t.getBBox(),r=a.x+a.width/2|0,n=a.y+a.height/2|0):c&&(o=[+c[0],+c[1]],o=na(o,i,r,n),te(t,"c_origin",o.join(","))),s&&(l=tr(+(te(t,"rotation")||0)),l=tr(l-i),te(t,"rotation",l)),$t(t)==="text"){let d=de.rotateD(i).setOrigin(r,n);console.error("err")}else{let d=t.children||t.childNodes,p=d.length,f;for(f=0;f<p;f++)Na.rotate(d[f],i,r,n)}}static svg(t,i,r,n){let s=te(t,"x"),a=te(t,"y");if(r===void 0||n===void 0)Na.rotate(t,i,+s,+a);else if(s===null||a===null){let o=t.children||t.childNodes,l=o.length;for(let c=0;c<l;c++)Na.hasOwnProperty(o[c].tagName)&&Na.rotate(o[c],i,r,n)}else s!==null&&a!==null&&Na.image(t,i,r,n)}static rect(t,i,r,n){let s=k.getById(t.id).json;Li.syncRectByRotation(i,s,new j(r,n))}static image(t,i,r,n){if(i===0||!te(t,"xlink:href"))return;if(r===void 0||n===void 0){let o=ec(t);r=lt(o.x+o.width/2,3),n=lt(o.y+o.height/2,3)}let a=de.rotateD(-i).setOrigin(r,-n);Lr.syncImage(k.gJsonCache.obj[t.id],a)}static circle(t,i,r,n){let s=[+te(t,"cx"),+te(t,"cy")];s=na(s,i,r,n),te(t,{cx:s[0],cy:s[1]})}static ellipse(t,i,r,n){let s=[+te(t,"cx"),+te(t,"cy")];if(s=na(s,i,r,n),te(t,{cx:s[0],cy:s[1]}),i%90){H.windowBridge.publish("message",{type:"error",message:"Rectangle and Ellipse do not support non-90 degree rotation. Please convert to path before rotating."},ut());return}if(i%180&&!(i%90)){let a=te(t,"rx"),o=te(t,"ry");te(t,{rx:o,ry:a})}}static line(t,i,r,n){let s=[+te(t,"x1"),+te(t,"y1"),+te(t,"x2"),+te(t,"y2")];s=na(s,i,r,n),te(t,{x1:s[0],y1:s[1],x2:s[2],y2:s[3]})}static polyline(t,i,r,n){i===void 0&&(i=270);let s=Cc(te(t,"points")).split(/[\s\,]+/);s=na(s,i,r,n),te(t,{points:s.join(" ")})}static polygon(t,i,r,n){Na.polyline(t,i,r,n)}static path(t,i,r,n){if(i%360===0)return;if(te(t,"c_partid")==="arc"){let b=XS(t);b=na(b,i,r,n),te(t,{"third-point":b[4]+","+b[5]})}i=tr(i);let s=Io,a=t.pathSegList,o=a.numberOfItems,l,c,u,h,d,p,f,m,g;for(let b=0;b<o;b++)if(l=null,c=a.getItem(b),u=c.pathSegType,g=u%2===0,!(u==D3||u==si)){switch(g?(h=u,d=r,p=n):(h=u-1,d=0,p=0),c._owningPathSegList=null,h){case Dr:l=na([c.x,c.y],i,d,p),c.x=l[0],c.y=l[1];break;case mn:l=na([c.x,c.y],i,d,p),c.x=l[0],c.y=l[1];break;case Ao:l=na([c.x,c.y,c.x1,c.y1,c.x2,c.y2],i,d,p),c.x=l[0],c.y=l[1],c.x1=l[2],c.y1=l[3],c.x2=l[4],c.y2=l[5];break;case Do:l=na([c.x,c.y,c.x1,c.y1],i,d,p),c.x=l[0],c.y=l[1],c.x1=l[2],c.y1=l[3];break;case Ya:l=na([c.x,c.y],i,d,p),c.x=l[0],c.y=l[1],c.r1!=c.r2?c.angle=tr(c.angle+i):c.angle=0;break;case Po:i==180?c.x=g?r+r-c.x:-c.x:(f=Mp[i],g?m=t.createSVGPathSegLinetoVerticalAbs((c.x-r)*f+n):m=t.createSVGPathSegLinetoVerticalRel(c.x*f),a.replaceItem(m,b));break;case Lo:i==180?c.y=g?n+n-c.y:-c.y:(f=Mp[i],g?m=t.createSVGPathSegLinetoHorizontalAbs(r-(c.y-n)*f):m=t.createSVGPathSegLinetoHorizontalRel(-c.y*f),a.replaceItem(m,b));break;case Co:l=na([c.x,c.y,c.x2,c.y2],i,d,p),c.x=l[0],c.y=l[1],c.x2=l[2],c.y2=l[3];break;case _o:l=na([c.x,c.y],i,d,p),c.x=l[0],c.y=l[1];break;default:break}c._owningPathSegList=a}a.segmentChanged()}};Na.pinTextNeedInvert=!1;var zS=Na;var po={point:function(e,t,i){return t!==null&&(e.x=2*t-e.x),i!==null&&(e.y=2*i-e.y),e},element:function(e,t,i){e.tagName&&po[e.tagName](e,t,i)},elementsFlipH:function(e,t){if(e.length===0)return;let i,r;if(t==null){let n=Number.MAX_VALUE,s=-Number.MAX_VALUE;for(i=0,r=e.length;i<r;i++)try{let a=e[i].getBBox();a.x<n&&(n=a.x),a.x+a.width>s&&(s=a.x+a.width)}catch{let o=te(e[i],"c_origin");if(o){let l=+o.split(",")[0];l<n?n=l:l>s&&(s=l)}}t=(n+s)/2}for(i=0,r=e.length;i<r;i++)po[e[i].tagName](e[i],t,null);return t},elementsFlipV:function(e,t){if(!e.length)return;let i,r;if(t==null){let n=Number.MAX_VALUE,s=-Number.MAX_VALUE;for(i=0,r=e.length;i<r;i++)try{let a=e[i].getBBox();a.y<n&&(n=a.y),a.y+a.height>s&&(s=a.y+a.height)}catch{let o=te(e[i],"c_origin");if(o){let l=+o.split(",")[1];l<n?n=l:l>s&&(s=l)}}t=(n+s)/2}for(i=0,r=e.length;i<r;i++){let n=e[i].tagName;po[n](e[i],null,t)}return t},flipH:function(e,t){return e instanceof NodeList||Array.isArray(e)?po.elementsFlipH(e,t):po.elementsFlipH([e],t)},flipV:function(e,t){return e instanceof NodeList||Array.isArray(e)?po.elementsFlipV(e,t):po.elementsFlipV([e],t)},g:function(e,t,i){if($t(e)==="text"){let n;t!==null?n=de.MIRROR_X.setOrigin(t,0):n=de.MIRROR_Y.setOrigin(0,i),xr.syncText(k.getById(e.id).json,n,{updateMatrix:!0})}else{let n=te(e,"c_origin"),s,a,o,l;n&&(s=n.split(","),l={x:+s[0],y:+s[1]},po.point(l,t,i),te(e,"c_origin",l.x+","+l.y));let c=tr(+(te(e,"rotation")||0));t!==null&&c%180===0&&(c=tr(c+180)),i!==null&&c%180!==0&&(c=tr(c+180)),te(e,"rotation",c);let u=e.children||e.childNodes;for(o=u.length,a=0;a<o;a++){let h=u[a].tagName;h&&$e(zS,h)&&po[h](u[a],t,i)}}},rect:function(e,t,i){let r=k.getRect(e.id);if(t!==null){let n=de.MIRROR_X.setOrigin(t,0);Li.syncRect(r,n,{updateMatrix:!0})}if(i!==null){let n=de.MIRROR_Y.setOrigin(0,i);Li.syncRect(r,n,{updateMatrix:!0})}},image(e,t,i){let r=k.gJsonCache.obj[e.id];if(!ft(t)){let n=de.MIRROR_X.setOrigin(t,0);Lr.syncImage(r,n)}if(!ft(i)){let n=de.MIRROR_Y.setOrigin(0,i);Lr.syncImage(r,n)}},obj:function(e,t,i){let r=k.gJsonCache.obj[e.id];if(t!==null){let n=de.MIRROR_X.setOrigin(t,0);Lr.syncImage(r,n)}if(i!==null){let n=de.MIRROR_Y.setOrigin(0,i);Lr.syncImage(r,n)}},circle:function(e,t,i){let r=k.getEllipse(e.id);if(t!==null){let n=de.MIRROR_X.setOrigin(t,0);Ei.syncEllipse(r,n,{updateMatrix:!0})}if(i!==null){let n=de.MIRROR_Y.setOrigin(0,i);Ei.syncEllipse(r,n,{updateMatrix:!0})}},ellipse:function(e,t,i){po.circle(e,t,i)},line:function(e,t,i){t!==null&&(te(e,"x1",2*t-te(e,"x1")),te(e,"x2",2*t-te(e,"x2"))),i!==null&&(te(e,"y1",2*i-te(e,"y1")),te(e,"y2",2*i-te(e,"y2")))},polyline:function(e,t,i){let r=Cc(te(e,"points")).split(/[\s\,]+/),n,s;if(t!==null){let a=2*t;for(n=0,s=r.length-1;n<s;n+=2)r[n]=a-r[n]}if(i!==null){let a=2*i;for(n=0,s=r.length-1;n<s;n+=2)r[n+1]=a-r[n+1]}te(e,{points:r.join(" ")})},polygon:function(e,t,i){po.polyline(e,t,i)},arc(e,t,i){let r=de.MIRROR_X.setOrigin(t,0);ft(i)||(r=de.MIRROR_Y.setOrigin(0,i)),mr.syncArc(e,r,{updateD:!0})},path(e,t,i){let{cmdKey:r,json:n}=k.getById(e.id);if(r==="arc")return po.arc(n,t,i);let s;Io&&(s=!0);let a=e.pathSegList,o=a.numberOfItems,l,c=2*t,u=2*i,h,d,p,f;if(t!==null){for(f=0;f<o;f++)switch(l=a.getItem(f),l.pathSegType){case SVGPathSeg.PATHSEG_MOVETO_ABS:case SVGPathSeg.PATHSEG_LINETO_ABS:case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:l.x=c-l.x;break;case SVGPathSeg.PATHSEG_MOVETO_REL:case SVGPathSeg.PATHSEG_LINETO_REL:case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:l.x=-l.x;break;case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:l.x=c-l.x,l.x1=c-l.x1,l.x2=c-l.x2;break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:l.x=-l.x,l.x1=-l.x1,l.x2=-l.x2;break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:l.x=c-l.x,l.x2=c-l.x2;break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:l.x=-l.x,l.x2=-l.x2;break;case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:l.x=c-l.x,l.x1=c-l.x1;break;case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:l.x=-l.x,l.x1=-l.x1;break;case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:l.x=c-l.x;break;case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:l.x=-l.x;break;case SVGPathSeg.PATHSEG_ARC_ABS:l.x=c-l.x,l.sweepFlag=1-l.sweepFlag;break;case SVGPathSeg.PATHSEG_ARC_REL:l.x=-l.x,l.sweepFlag=1-l.sweepFlag;break;default:break}if(h=te(e,"c_helper_dots"),h){for(d=h.split(/[\s\,]+/),f=0,o=d.length-1;f<o;f+=2)d[f]=c-d[f];p=d.splice(4,2),d.push(p[0],p[1]),te(e,"c_helper_dots",d.join(","))}}if(i!==null){for(f=0;f<o;f++)switch(l=a.getItem(f),l.pathSegType){case SVGPathSeg.PATHSEG_MOVETO_ABS:case SVGPathSeg.PATHSEG_LINETO_ABS:case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:l.y=u-l.y;break;case SVGPathSeg.PATHSEG_MOVETO_REL:case SVGPathSeg.PATHSEG_LINETO_REL:case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:l.y=-l.y;break;case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:l.y=u-l.y,l.y1=u-l.y1,l.y2=u-l.y2;break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:l.y=-l.y,l.y1=-l.y1,l.y2=-l.y2;break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:l.y=u-l.y,l.y2=u-l.y2;break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:l.y=-l.y,l.y2=-l.y2;break;case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:l.y=u-l.y,l.y1=u-l.y1;break;case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:l.y=-l.y,l.y1=-l.y1;break;case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:l.y=u-l.y;break;case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:l.y=-l.y;break;case SVGPathSeg.PATHSEG_ARC_ABS:l.y=u-l.y,l.sweepFlag=1-l.sweepFlag;break;case SVGPathSeg.PATHSEG_ARC_REL:l.y=-l.y,l.sweepFlag=1-l.sweepFlag;break;default:break}if(h=te(e,"c_helper_dots"),h){for(d=h.split(/[\s\,]+/),f=0,o=d.length-1;f<o;f+=2)d[f+1]=u-d[f+1];p=d.splice(4,2),d.push(p[0],p[1]),te(e,"c_helper_dots",d.join(","))}}if(te(e,"c_partid")==="arc"&&te(e,"third-point")){let m=te(e,"third-point").split(",");t!==null?te(e,{"third-point":c-m[0]+","+m[1]}):i!==null&&te(e,{"third-point":m[0]+","+(u-m[1])})}n.d=te(e,"d"),k.changedJsoncache(n.gId,r)}};var Ng=class{constructor(t){this.data=t}toData(){}setData(){}render(){let{gId:t,x:i,y:r}=this.data,n=le(t);n==null||n.setAttribute("cx",String(i)),n==null||n.setAttribute("cy",String(r))}unmount(){dt(le(this.data.gId))}multiply3(t){let i=new j(this.data.x,this.data.y),{x:r,y:n}=i.multiply3(t);this.data.x=r,this.data.y=n,this.render()}rotateSelf(t,i){let r=de.rotateD(t).setOrigin1(i);this.multiply3(r)}flipH(t){let i=(t.x-this.data.x)*2,r=de.translate(i,0);this.multiply3(r)}flipV(t){let i=(t.y-this.data.y)*2,r=de.translate(0,i);this.multiply3(r)}};var gl=class{constructor(t){this.eles=t}mirror(t,i){this.isH=t,this.center=i;for(let r of this.eles){let{json:n,cmdKey:s}=k.getById(r.id);switch(s){case"dimensionAngle":this.mirrorDimensionAngle(n,i,t);break;case"dimensionLength":this.mirrorDimensionLength(n);break;case"dimensionRadius":this.mirrorDimensionRadius(n);break;case"auxiliaryLine":this.mirrorAuxiliaryLine(n);break;case"auxiliaryPoint":this.mirrorAuxiliaryPoint(n);break;case"group":this.mirrorGroup(n);break;default:t?po.flipH([r],i.x):po.flipV([r],i.y);break}}}mirrorGroup(t,i=this.center,r=this.isH){let n=de.MIRROR_Y.setOrigin(0,i.y);r&&(n=de.MIRROR_X.setOrigin(i.x,0)),zn.syncGroup(t,n,{updateD:!0,fn(){r?t.rotation=-tr(360+t.rotation):t.rotation=-tr(t.rotation+360)}})}mirrorDimensionRadius(t,i=this.center,r=this.isH){let n=new cn(t),s=de.MIRROR_Y.setOrigin(0,i.y);r&&(s=de.MIRROR_X.setOrigin(i.x,0)),n.multiply3(s)}mirrorDimensionLength(t,i=this.center,r=this.isH){let n=new xn(t),s=de.MIRROR_Y.setOrigin(0,i.y);r&&(s=de.MIRROR_X.setOrigin(i.x,0)),n.multiply3(s)}mirrorDimensionAngle(t,i,r){let n=new bn(t);r?n.flipH(i):n.flipV(i)}mirrorAuxiliaryLine(t,i=this.center,r=this.isH){let n=new Zl(t);r?n.flipH(i):n.flipV(i)}mirrorAuxiliaryPoint(t,i=this.center,r=this.isH){let n=new Ng(t);r?n.flipH(i):n.flipV(i)}};var Ka=class extends yn{constructor(){super();this.lastX=void 0;this.lastY=void 0;this.accumulateX=0;this.accumulateY=0;this.dashedBoxForPerf=null;this.updateRightPanel=S3(()=>{this.dragContext.selectedObjs.length!==0&&Ce("panel_updateAttrPanel")},100);this.auxiliaryLineId="drag-auxiliary-line";this.shiftKeyDown=!1}static canSwitchMe(i){if(!i.mouseLeftMoving)return!1;let r=Fu.elementsForDrag.filter(o=>!Ae.isUnselectAble(o.parentId||o.id));if(!r.length)return!1;let n=[];for(let o of r)n.push(o.parentId||o.id);let{combinations:s,elements:a}=new rt().getSelectedCombinations(n);for(let o of s)if(k.getCombination(o).locked)return qa(n),!1;for(let o of a)if(Gi.isLockedById(o))return qa(n),!1;return i.selectItems=r,!0}getSymbol(){return ii.drag_tool}install(i){this.startX=i.startX,this.startY=i.startY,this.lastX=i.startX,this.lastY=i.startY,this.dragContext=new uS(i),this.dragElements=new R1(this.dragContext),this.onDragStart(),this.checkShouldCreateSelectionBox(),Ae.unselectAll();for(let r of i.selectItems)Ae.select([{id:r.parentId||r.id}]);console.log(this.getSymbol(),"installed")}uninstall(i){Ka.isDragging=!1,console.log(this.getSymbol(),"uninstalled")}checkShouldCreateSelectionBox(){let{selectedObjs:i}=this.dragContext;if(i.length>dE){let n=Rr(i);this.dashedBoxForPerf=tD(n,{"stroke-dasharray":"6, 6",class:Vl,stroke:H.panelThemeCache.color.select});for(let s of i)bu(s,"hidden")}}onDragStart(){Ke.startBatch(),Ka.isDragging=!0;let i=this.dragContext.selectedObjs.filter(o=>!["auxiliaryLine","auxiliaryPoint"].includes($t(o))),r=Rr(i);this.startBBox=St.extendRect(r),this._radian=0,dl(),Du(),bt.setExcludeShapeIds(this.dragContext.selectedObjs.map(o=>o.id));let n=Array.from(this.dragContext.affectedDimensions).map(o=>le(o)).concat(Array.from(this.dragContext.drivingDimensions).map(o=>le(o.gId))).concat(Array.from(this.dragContext.xMoveEles)).concat(Array.from(this.dragContext.yMoveEles)),s=this.dragContext.dragDimensionDots.map(o=>o.getContainer());for(let o of[...this.dragContext.selectedObjs,...n,...s])Ke.jsonSnap.addOne(k.getById(o.id).json);let a=()=>{pi.emptyLastHoverEle().emptySelectContainer().removeHighlightStroke(),wt.removeMiddleAnchor()};a(),setTimeout(a,0)}onDrag(i,r){if(this.dashedBoxForPerf)return tc.svg(this.dashedBoxForPerf,i,r);!this.dashedBoxForPerf&&this.dragElements.onDrag(i,r),nc.switch(5);let n=is(this.dragContext.selectedObjs);n.length&&fr(n,{create8Dots:!1}),this.dragContext.combinationMask.updateHole(),this.updateRightPanel(),zd()}handleSelectionBox(){if(!this.dashedBoxForPerf)return;dt(this.dashedBoxForPerf),this.dashedBoxForPerf=null;let{selectedObjs:i}=this.dragContext;for(let r of i)Oo(r,"hidden");this.onDrag(this.accumulateX,this.accumulateY)}onComplete(){this.onEnd(),Ce("panel_updateAttrPanel"),Ce("updateMenuByDocStatus"),Ce("panel/updateTreeActiveElements"),this.freshBoundingBox(),pi.debouncedAppendSelectStroke()}freshBoundingBox(){let i=is(this.dragContext.selectedObjs);i.length&&fr(i,{create8Dots:!0})}onEnd(){Ar.cancel(),this._radian=0,this.handleSelectionBox(),this.removeAuxiliaryLine(),Ke.saveBatch(),bt.clearAdsorptionHTML(),bt.clearExcludeShapeIds(),nc.switch(4)}onMouseMove(i){this.dragContext.abandonedWhenIsLock(i);let{mouseLeftMoving:r,originalEvent:n,canvasX:s,canvasY:a}=i;n=n;let{altKey:o,shiftKey:l,clientX:c,clientY:u}=n;if(this.lastClient={clientX:c,clientY:u},!r)return;Ar.tryStart(i);let h=i.snapX-this.lastX,d=i.snapY-this.lastY;if(l){let p=Math.abs(i.snapX-this.startX),f=Math.abs(i.snapY-this.startY);p>f?d=-this.accumulateY:h=-this.accumulateX}else if(!o){let p={x:s,y:a},f=this.getAdsorbPoints(p),m=B5(p,f);h=m.x-this.lastX,d=m.y-this.lastY}if((h!==0||d!==0)&&(this.onDrag(h,d),this.lastX+=h,this.lastY+=d,this.accumulateX+=h,this.accumulateY+=d,l&&this.createAuxiliaryLine({x:this.startX,y:this.startY},{x:this.lastX,y:this.lastY})),H.helperCursor==="cross-red"){let{x:p,y:f}=ui(n,!0);cs(p,f)}this.freshBoundingBox(),pi.emptySelectContainer()}createAuxiliaryLine(i,r){let n=this.auxiliaryLineId,s=document.getElementById(n),a=[i.x,i.y,r.x,r.y].join(" ");s?te(s,{points:a}):(s=Et("polyline",{id:n,points:a,"vector-effect":"non-scaling-stroke",stroke:H.panelThemeCache.color.select}),H.gCanvas.appendChild(s))}removeAuxiliaryLine(){dt(document.getElementById(this.auxiliaryLineId)),this.shiftKeyDown=!1}onKeyDown(i){let{shiftKeyDown:r}=i;if(r&&!this.shiftKeyDown){let n=new MouseEvent("mousemove",this.lastClient);document.dispatchEvent(n),this.shiftKeyDown=!0}else i.keyCode==="Delete"&&(this.cancel(!1),i.toolFinished=!0);this.handleDirectionKeydown(i)}handleDirectionKeydown(i){let r=s();if(!r)return;let n={...this.lastClient};n.clientX+=Ge.adsorbGrid.gridSize*r[0],n.clientY+=Ge.adsorbGrid.gridSize*r[1],i.reactor.element.dispatchEvent(new MouseEvent("mousemove",n));function s(){switch(i.keyCode){case"ArrowLeft":return[-1,0];case"ArrowRight":return[1,0];case"ArrowDown":return[0,1];case"ArrowUp":return[0,-1]}}}cancel(i=!0){if(Ka.isDragging){if(Ar.cancel(),Ke.jsonSnap.recovery(i),Ke.cancelSaveBatch(),i){let r=Fu.elementsForDrag.map(s=>le(s.parentId||s.id)),n=is(r);n.length&&fr(n,{create8Dots:!0})}Fu.elementsForDrag.length=0,bt.clearAdsorptionHTML()}}onKeyUp(i){let{originalEvent:r}=i;r=r;let{keyCode:n}=r;switch(n){case Lh.Space:break;case Lh.Shift:let s=new MouseEvent("mousemove",this.lastClient);document.dispatchEvent(s),this.removeAuxiliaryLine();break;case Lh.Esc:{i.toolFinished=!0,this.cancel();break}default:break}}onMouseLeftUp(i){i.toolFinished=!0,this.onComplete()}onMouseRightUp(i){ao.dragpanning||(i.toolFinished=!0,this.cancel())}rotate(i){zt.createContext();let r=(360-i)*Math.PI/180;this._radian+=r,this._radian%=Math.PI*2;let n=this.dragContext.selectedObjs.concat(this.dragContext.selectedDimensionObjs).filter(s=>k.getById(s.id).cmdKey!=="auxiliaryLine");Hc(co(n),i),zt.runTask()}flipH(){zt.createContext();let i=co(this.dragContext.selectedObjs.concat(this.dragContext.selectedDimensionObjs)),r=fo(i,!0,{ignoreSnap:!0});new gl(i).mirror(!0,r),zt.runTask(),this.freshBoundingBox()}flipV(){zt.createContext();let i=co(this.dragContext.selectedObjs.concat(this.dragContext.selectedDimensionObjs)),r=fo(i,!0,{ignoreSnap:!0});new gl(i).mirror(!1,r),zt.runTask(),this.freshBoundingBox()}getCurrentBBox(i){let r=this.startBBox.width(),n=this.startBBox.height(),s=this.startBBox.minX,a=this.startBBox.minY,o=de.translate(-s-r/2,-a-n/2).multiply3(de.rotate(this._radian)).translate(s+r/2,a+n/2).translate(i.x-this.startX,i.y-this.startY);return this.startBBox.transform(o)}getAdsorbPoints(i){let r={},n=this.getCurrentBBox(i);if(n.height()&&n.width()){let l=n.LL(),c=n.LR(),u=n.UR(),h=n.UL(),d=l.add(c).mul(1/2),p=c.add(u).mul(1/2),f=u.add(h).mul(1/2),m=h.add(l).mul(1/2),g=n.center();o(l,c,u,h,d,p,f,m,g)}let s=i.x-this.lastX||0,a=i.y-this.lastY||0;for(let l of this.dragContext.auxiliaryPoints)o(new j(l.x+s,l.y+a));for(let l of this.dragContext.horizontalAuxiliaryLines)o(new j(i.x,l.y+a));for(let l of this.dragContext.verticalAuxiliaryLines)o(new j(l.x+s,i.y));return Object.values(r);function o(...l){for(let c of l)r[`${c.x}_${c.y}`]=c}}};Ka.isDragging=!1,Ka=Ws([Pa(Sn.drag)],Ka);var Es=class Es extends yn{static exit(){this.ready=!1}static enterCutStart(t,i){this.tabId=t,this.ready=!0,this.cutStart=!0,this.clipboard=Mi(),this.objs=i,this.referencePosition=void 0,this.pasteFrom="cut",or("setIsCutPasteFinish",[!1]),H.windowBridge.rpcCall("i18n",this.content,ut()).then(n=>{this.i18nText=n.message,this.showHelpCursor()})}static enterCopyStart(t){this.objs=t,this.ready=!0,this.cutStart=!1,this.referencePosition=void 0,this.pasteFrom="copy",H.windowBridge.rpcCall("i18n",this.content,ut()).then(r=>{this.i18nText=r.message,this.showHelpCursor()})}static showReferencePointAndText(t,i,r="",n=!1){if(!this.referenceIsSelectedReferencePoint){xs();return}this.setContent(r);let{top:s,left:a}=this.getCursorTextPosition(t,i);(n||this.ready||this.pasteFrom==="cut"&&!this.referencePosition)&&(0,Mg.default)(`#${this.id}`).css({left:a+Es.offsetPosition.x,top:s+Es.offsetPosition.y}),this.updateReferencePointText(n)}static async showReferText(t){if(this.ready){this.setContent(this.content);let{currAbsX:i,currAbsY:r}=t||Ir.data,{top:n,left:s}=this.getCursorTextPosition(i,r);(0,Mg.default)(`#${this.id}`).css({left:s+Es.offsetPosition.x,top:n+Es.offsetPosition.y}),this.updateReferencePointText(!0)}else this.showOrHideText(!1)}static abortReferencePointMode(t=!0){this.ready&&xs(),this.ready=!1,this.cutStart=!1,bt.clearAdsorptionHTML(),t?pr(!1):this.showOrHideText(!1)}static setContent(t){if(!t)return!1;this.content=t}static showOrHideText(t=!0){let i=(0,Mg.default)(`#${this.id}`);t?i.removeClass("hide"):i.addClass("hide")}static updateReferencePointText(t){let i=(0,Mg.default)(`#${this.id}`);this.ready||t||this.pasteFrom==="cut"&&!this.referencePosition?(i.text(this.i18nText),this.showOrHideText()):this.showOrHideText(!1)}static getCursorTextPosition(t,i,r=Xt.getViewBox()){let s=(0,Mg.default)(`#${this.id}`).height(),a=6,o=16,l=H.gZoom,c=(t-r[0])*l+a,u=(i-r[1])*l-s-o;return{left:c,top:u}}static async updateReferencePointPosition(t,i){if(!this.referencePosition){if(this.ready||this.cutStart){let r=k5({x:t,y:i}),n=r.x,s=r.y;this.referencePosition={offX:n,offY:s},H.windowBridge.publish("setReferencePosition",{offX:n,offY:s},ut()),this.ready=!1,bt.clearAdsorptionHTML(),pr(!1),xs(),this.cutStart?(this.cutStart=!1,!Ka.isDragging&&Yd()):Vd(this.objs,this.cutStart)}Ce("updateMenuByDocStatus")}}static pasteAfterCut(){return this.pasteFrom==="cut"&&!this.ready&&!this.referencePosition}static getTabId(){return Es.tabId}static async showHelpCursor(){let{currAbsX:t,clientX:i,clientY:r,currAbsY:n}=Ir.data;pr(this.cursor,t,n),xs("",{x:t,y:n}),this.showReferText({currAbsX:t,currAbsY:n})}static endCutState(t){Es.getTabId()===t&&or("getIsCutPasteFinish")&&(Yd(!0),Es.abortReferencePointMode())}static async saveSelectObjs(){await Vd(this.objs)}install(){console.log(this.getSymbol(),"installed")}uninstall(){console.log(this.getSymbol(),"uninstalled")}getSymbol(){return ii.referencePoint_tool}onMouseLeftDown(t){t.toolFinished=!0;let{canvasX:i,canvasY:r}=t;Es.updateReferencePointPosition(i,r),qt()}onMouseRightUp(t){t.toolFinished=!0,Es.ready&&Es.abortReferencePointMode()}static canSwitchMe(){var i;let t=((i=H.profileSetting)==null?void 0:i.commSystemSetting.PANEL_CANVAS.referencePointPanelSelectMethod)==="select";return Es.referenceIsSelectedReferencePoint=t,!!Es.referenceIsSelectedReferencePoint}};Es.content="Please select a reference point",Es.id="cross-text",Es.ready=!1,Es.pasteFrom="copy",Es.cursor="cross-red",Es.referenceIsSelectedReferencePoint=!0,Es.offsetPosition={x:18,y:4};var lr=Es;var F5="panel-copy-json";async function Yd(e=!1){let t=Mi();lr.referenceIsSelectedReferencePoint&&lr.clipboard&&(t=lr.clipboard);let r=[...ts.findDimensionByPrimitiveIds(new Set(t.map(o=>o.id))).map(o=>le(o.gId)),...t],{combinations:n,elements:s}=new rt().getSelectedCombinations(r.map(o=>o.id));if(Gi.hasEleLocked(s)||Gi.hasEleLocked(n)){qa();return}!e&&await Vd(r,!0);let a=new oi(r);for(let o of n)k.deleteCombInParent(o).setCombination(o);k.removeMultiData(r),pi.removeCombinationElmsHighlightStroke(),a.updateAndSave(),Ce("panel_updateAttrPanel"),Ce("updateMenuByDocStatus")}async function Vd(e,t){let i=e.map(n=>k.getById(n.id).json);await G5(i)&&Ce("ui/toastMsg",{type:"success",msg:t?"Cut Success!":"Copy Success!",timer:3})}async function G5(e){let t=(await H.windowBridge.rpcCall("getActiveProject",null,ut())).message,i=Et("g",{doctype:H.doctype,projectId:t}),r=k.getItemOrderSortMap();e.sort((l,c)=>r.get(l.id)-r.get(c.id));let n=new Set,s=new rt;for(let l of e){let c=s.searchCombination(l.gId);if(c){let h=Wt.getCurrentEditingComId(),d=s.findFamily(c,h).getAllParents();for(let p of d){if(Wt.getCurrentEditingComId()===p||n.has(p))continue;n.add(p);let f=k.getCombination(p),m=Et("g",{c_partid:"combination",jsonCache:JSON.stringify(f)});i.appendChild(m)}}let u=Et("g",{c_partid:l.cmdKey,jsonCache:JSON.stringify(l)});Ae.unselect(u),Ae.unhighlight(u),i.appendChild(u)}let a=new XMLSerializer().serializeToString(i),{message:o}=await Ho(I0.CLIP_BOARD.SET,[F5,a]);return Ce("updateMenuByDocStatus"),o}async function Xd(){return(await Ho(I0.CLIP_BOARD.GET,[F5])).message}async function iD(e){let t=await U5(e);await G5([t]),H.frameHelper.getToolProcessor().switchToPasteTool("")}async function U5(e,t=j.ORIGIN){let i=(await H.windowBridge.rpcCall("/pro-ui/getImageInfoByFilesForSch",[[e]],ut())).message[0],r=Ot();bt.setExcludeShapeIds([r]);let n=de.scale(i.width,i.height).translate1(t),s=et.getMatrix6FromMatrix(n);return k.getInitialImageData({gId:r,matrix:s,content:i.src,layer:Qe.getTargetPlaceLayer("obj")})}function rD(e,t){if(!e||!e.length)return;let i=e.length;qt();for(let d=-1;++d<i;){let p=+te(e[d],"layer");Qe.appendTargetLayer(e[d],p),bt.setExcludeShapeIds([e[d].id])}let r=Rr(e);if(!t||Object.keys(t).length===0||t==="center"){let d=r.x,p=r.y+r.height;if(t==="center"&&(d=r.x+r.width/2,p=r.y+r.height/2),i===1&&$t(e[0])==="text"){let{x:f,y:m}=xr.getTextOrigin(e[0].id);d-=f,p-=m}t={offX:d,offY:p}}var n=Og(),s=Ir.data.clientX||n.clientWidth/2,a=Ir.data.clientY||n.clientHeight/2;let o=vh({x:s,y:a}),l={x:t.offX,y:t.offY},c=Ra({x:o.x,y:o.y}),u=c.x-l.x,h=c.y-l.y;return Mh(e,u,h),l&&pr("cross-red",l.x+u,l.y+h,{enforceEnterRefPoint:!0}),{targets:e,...c}}async function C5(){let e=new oi,t=[],i=new Map,r=[],n=await Xd(),s=zs(n),o=[...document.importNode(s.documentElement,!0).childNodes],l=[];for(let c of o){let u=WS(c),h=u.gId,d=u.cmdKey;if(u.gId=Ot(),i.set(h,u.gId),d==="combination")t.push(u);else if(d==="dimension")r.push(u);else{let p=bs(d,u);e.addOne(u,{},d),l.push(p)}}for(let c of r){let u=c.start.id,h=c.end.id,d=i.get(u),p=i.get(h);if(d&&p){c.start.id=d,c.end.id=p;let f=bs("dimension",c);l.push(f)}}new rt().pasteCombination(e,t,i),e.updateAndSave(),Ae.unselectAll(),Ae.select(l),Pa(Sn.pasteInPlace)(null)}function D5(){let e=Ae.get().slice();if(!e.length)return;qt(),Ae.unselectAll();let t=new oi,{oldIdMapNewId:i,copiedCombination:r}=new rt().getAffectedCombinations(e.map(n=>n.id));e.map(n=>{let{json:s,cmdKey:a}=k.getById(n.id),o=jt(s);o.gId=Ot(),ri.renderer.insertBefore(o,k.getRefId(n.id)),i.set(s.gId,o.gId),t.addOne(o,{},a),Ae.select([{id:o.gId}])}),new rt().pasteCombination(t,r,i),t.updateAndSave(),uo()}var Lg=class{static async do(t,i=null){let r=new Map,n=[],s=[],a=[];this.snap=new oi;for(let o in t)for(let l in t[o]){let c=jt(t[o][l]),u=Ot();if(r.set(c.gId,u),c.gId=u,c.visible=!0,o==="combination")n.push(c);else if(o==="dimension")s.push(c);else{o==="text"&&/\d$/.test(c.key)&&(c.key=c.name=c.key.replace(/(\d$)/,d=>++d),c.d="",await Wn.fixStringPath(c));let h=bs(o,c);a.push(h),this.snap.addOne(c,{},o)}}return i=i||new j(0,Rr(a).height||Ge.adsorbGrid.gridSize),U1(a,i,{saveHistory:!1}),new rt().pasteCombination(this.snap,n,r),this.snap.updateAndSave(),nD(),Ae.select(a),{nodes:a,movement:i}}};Lg=Ws([Pa(Sn.duplicateTo)],Lg);async function Lee(e){let t=e.dataTransfer.files[0];if(t.type.indexOf("image")!==-1){event.preventDefault();let{x:i,y:r}=ui(e,!0),n=await U5(t,new j(i,r)),s=bs(n.cmdKey,n),a=new oi;a.addOne(n,{}),a.updateAndSave(),Ae.unselectAll(),Ae.select([s])}}window.frameElement&&(document.addEventListener("paste",async e=>{let t=e.clipboardData.items;if(t[0].type.indexOf("image")!==-1){e.preventDefault();let i=t[0].getAsFile();i.name.toLocaleLowerCase().endsWith(".svg")?H.windowBridge.publish("/pro-ui/setImage",[i],ut()):await iD(i)}}),document.addEventListener("drop",Lee));var Bh=class extends yn{constructor(i,r,n){super();this.prepareFinish=!1;this.accmulate=new j(0,0);this.jsonSnapshot=new oi;this.copiedCombination=[];this.oldIdMapNewId=new Map;this.type=i,this.nodes=r,this.reference=n}static async canSwitchMe(i){if(oo())return!1;if(!i){let r=await Xd();if(!r)return!1;let n=zs(r),a=[...document.importNode(n.documentElement,!0).childNodes];return a.length?a.some(l=>{let c=WS(l);return!c.start&&!c.end}):!1}return!0}install(i){console.log(this.getSymbol(),"installed"),this.prepare(i)}uninstall(i){console.log(this.getSymbol()," uninstalled"),Ar.cancel(),this.removeCopiedNodes()}getSymbol(){return ii.paste_tool}async prepare(i){this.prepareFinish=!1,Ke.startBatch();let r;this.type==="paste_dxf"?r=rD(this.nodes,this.reference):r=await this.pasteFromGlobalClipboard(this.type)||{};let{targets:n,x:s,y:a}=r;this.nodes=n,this.lastX=s,this.lastY=a,this.prepareFinish=!0}rotate(i){zt.createContext();let r=co(this.nodes).filter(n=>k.getById(n.id).cmdKey!=="auxiliaryLine");Hc(r,i),zt.runTask()}flipH(){zt.createContext();let i=co(this.nodes),r=fo(i,!0,{ignoreSnap:!0});new gl(i).mirror(!0,r),zt.runTask()}flipV(){zt.createContext();let i=co(this.nodes),r=fo(i,!0,{ignoreSnap:!0});new gl(i).mirror(!1,r),zt.runTask()}onMouseMove(i){if(!this.prepareFinish)return;if(!this.nodes)return Ke.cancelSaveBatch(),i.toolFinished=!0;Ar.tryStart(i);let{originalEvent:r}=i;Qn.altKeyEnabled=i.altKeyDown;let{x:n,y:s}=ui(r,!0),a=n-this.lastX,o=s-this.lastY;(a||o)&&(Mh(this.nodes,a,o),this.lastX+=a,this.lastY+=o,this.accmulate=this.accmulate.add1(a,o))}onMouseLeftDown(i){if(!this.prepareFinish)return;i.toolFinished=!0,$a(this.nodes),Ae.unselectAll().select(this.nodes);let r=this.jsonSnapshot;new rt().pasteCombination(r,this.copiedCombination,this.oldIdMapNewId,this.nodes),Ke.saveBatch(),new Ni().updateHole(),r.updateAndSave(),pr(),this.nodes=[],bt.clearAdsorptionHTML(),bt.clearExcludeShapeIds(),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel/updateTreeActiveElements"),Ce("panel_updateAttrPanel"),H.doctype===ta.PANEL&&H.windowBridge.rpcCall(I0.LOG.SET,[{type:iI.PRIMITIVE_PASTE_ACROSS_PROJECT,content:[{"Panel Name":k.gJsonCache.head.display_title}],project_uuid:H.currentProject.projectId}],ut())}onMouseLeftUp(i){this.type==="ctrl_drag_copy2"&&this.onMouseLeftDown(i)}onMouseRightUp(i){this.prepareFinish&&(ao.dragpanning||(i.toolFinished=!0,this.cancelPaste()))}onKeyUp(i){if(!this.prepareFinish)return;let{keyCode:r}=i;switch(r){case"Escape":i.toolFinished=!0,this.cancelPaste();break;default:break}}async pasteFromGlobalClipboard(i){var h;let r,n,s;if(i)s=[...Ae.get()];else{((h=H.profileSetting)==null?void 0:h.commSystemSetting.PANEL_CANVAS.referencePointPanelSelectMethod)==="select"&&lr.ready&&(H.windowBridge.publish("setReferencePosition",void 0,ut()),lr.pasteAfterCut()?await Yd():await Vd(Mi())),r={offX:0,offY:0};let p=await Xd(),f=zs(p);n=document.importNode(f.documentElement,!0),s=[...n.childNodes];let m=te(n,"projectId"),{message:g}=await H.windowBridge.rpcCall("getActiveProject",null,ut());g!==m?Jp("referencePosition")&&Jp("referencePosition")!=="undefined"?r=JSON.parse(Jp("referencePosition")):r=void 0:r=(await H.windowBridge.rpcCall("getReferencePosition",null,ut())).message}let a=[],o=[],l=[],c=new Map;this.copiedCombination=l,this.oldIdMapNewId=c;for(let d=0,p=s.length;d<p;d++){let f=s[d],m=$t(f),g=WS(f)||jt(k.gJsonCache[m][f.id]),b=Ot();if(c.set(g.gId,b),g.gId=b,g.visible=!0,m==="combination")l.push(g);else if(m==="dimension")o.push(g);else{let y=bs(m,g);a.push(y)}}for(let d of o){let p=d.start.id,f=d.end.id,m=c.get(p),g=c.get(f);if(m&&g){d.start.id=m,d.end.id=g;let b=bs("dimension",d);a.push(b)}}let u=rD(a,r);return or("setIsCutPasteFinish",[!0]),lr.abortReferencePointMode(!1),lr.pasteAfterCut()&&Yd(!0),u}removeCopiedNodes(){var i;(i=this.nodes)!=null&&i.length&&(k.removeMultiData(this.nodes),Ae.unselect(this.nodes))}cancelPaste(){$a(this.nodes,"cancel"),this.removeCopiedNodes(),pr(),bt.clearExcludeShapeIds(),bt.clearAdsorptionHTML(),Ke.cancelSaveBatch()}};Bh=Ws([Pa(Sn.paste)],Bh);function WS(e){return JSON.parse(te(e,"jsonCache"))}var ff=class ff extends yn{constructor(){super(...arguments);this.nodes=[]}getSymbol(){return ii.place_lib_tool}static canSwitchMe(){return!!this.data}install(i){console.log(this.getSymbol()," installed"),this.lastX=i.canvasX,this.lastY=i.canvasY,this.prepareNodes(i),pr("cross-red",this.lastX,this.lastY,{enforceEnterRefPoint:!0})}prepareNodes(i){let r=k.gJsonCache,n=jt(ff.data.jsonCache),s=k.exchangeJsonCache(n),a=new Map,o=new Map,l=new Set;this.copiedCombination=[],this.oldIdMapNewId=new Map,k.iterator((h,d,p)=>{a.set(p,h),o.set(p,d),this.oldIdMapNewId.set(p,""),d==="dimension"&&l.add(p)}),k.iteratorCombination((h,d,p)=>{a.set(p,h),o.set(p,d);let f=Ot();h.gId=f,this.oldIdMapNewId.set(p,f),this.copiedCombination.push(h)}),s();let c=[],{itemOrder:u}=n;for(let h of u){if(l.has(h))continue;let d=a.get(h);if(!d)continue;let p=o.get(h),f=Ot();d.gId=f,this.oldIdMapNewId.set(h,f),p==="dimensionRadius"&&(d.ellipseId=this.oldIdMapNewId.get(d.ellipseId));let m=bs(p,d,f);c.push(m)}this.prepareDimensions(l,a,this.oldIdMapNewId,c),bt.clearExcludeShapeIds().setExcludeShapeIds(c.map(h=>h.id)),this.nodes=c;for(let h of c)bu(h,Vl);if(c.length){let{x:h,y:d,width:p,height:f}=Y5(c);Mh(c,i.canvasX-h,i.canvasY-(d+f))}return c}prepareDimensions(i,r,n,s){for(let a of i){let o=r.get(a),l=o.start.id,c=o.end.id,u=n.get(l),h=n.get(c);if(u&&h){o.start.id=u,o.end.id=h;let d=Ot();o.gId=d,n.set(a,d);let p=bs("dimension",o);s.push(p)}}}uninstall(i){Ar.cancel(),console.log(this.getSymbol()," uninstalled")}rotate(i){let r=co(this.nodes).filter(n=>k.getById(n.id).cmdKey!=="auxiliaryLine");Hc(r,i)}flipH(){let i=co(this.nodes),r=fo(i,!0,{ignoreSnap:!0});new gl(i).mirror(!0,r)}flipV(){let i=co(this.nodes),r=fo(i,!0,{ignoreSnap:!0});new gl(i).mirror(!1,r)}onMouseLeftUp(i){qt(),Ae.select(this.nodes),$a(this.nodes);let r=new oi;new rt().pasteCombination(r,this.copiedCombination,this.oldIdMapNewId,this.nodes);for(let n of this.nodes){Oo(n,Vl);let{json:s,cmdKey:a}=k.getById(n.id);r.addOne(s,{},a),bt.updateShapeCache(s.gId,a,s)}r.updateAndSave(),this.prepareNodes(i),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),this.uploadPlacePanelLibLog()}onMouseRightUp(i){$a(this.nodes,"cancel"),i.toolFinished=!0,ff.data=null,k.removeMultiData(this.nodes),pr(!1),bt.clearAdsorptionHTML(),Ce("openPlaceClosedBottomBar")}onMouseMove(i){let{originalEvent:r}=i,{x:n,y:s}=ui(r,!r.altKey),a=n-this.lastX,o=s-this.lastY;Ar.tryStart(i),Mh(this.nodes,a,o),this.lastX=n,this.lastY=s}static async setPlacingStatus(i){if(i.jsonCache=await df.getJsonCache(i.uuid,i.path),this.resetPanelLibItemOrder(i.jsonCache),i.jsonCache.itemOrder.length===0){ls("Placement failed, panel library has no content","warn"),Ce("openPlaceClosedBottomBar");return}let r=H.frameHelper.getToolProcessor();if(r.currentToolIs(ii.place_lib_tool)){let n=r.getCtx();r.currentTool.onMouseRightUp(n),r.switchToHighlightTool()}else if(r.currentToolIs(ii.draw)){let n=r.getCtx();r.currentTool.uninstall(n),r.switchToHighlightTool()}i.svgStr=Rn.toSVG(i.jsonCache),this.isPlacing=!0,this.data=i}static resetPanelLibItemOrder(i){let r=k.exchangeJsonCache(i);i.itemOrder.forEach(n=>{let s=k.getById(n).json;s&&(s.zIndex=void 0)}),r()}uploadPlacePanelLibLog(){var i;H.windowBridge.publish("addUploadPlaceLibLog",{uuid:ff.data.uuid,lib_type:6,path:(i=ff.data.owner)==null?void 0:i.uuid},ut())}};ff.isPlacing=!1;var Gu=ff;var sD=class{constructor(){this.edgeRangeSize=65;this.altKeyDown=!1;this.isRunning=!1;this.config={type:0,speed:50,step:30,altStep:100};this._canStart=!0;this.pointData={horizontal:0,vertical:0};this.speedRange=[2,30]}set canStart(t){t||this.cancel(!1),this._canStart=t}get canStart(){return this._canStart}tryStart(t){if(this.config.type===0)return;this.ctx=t,this.updatePointData(t);let{horizontal:i,vertical:r}=this.pointData;if(i||r){if(!this.isRunning)this._canStart=!1;else if(!this.startTimer&&this.canStart){let n=this.speedRange[0]+this.config.speed/100*(this.speedRange[1]-this.speedRange[0]);this.startTimer=setTimeout(()=>{this.runningInterval=setInterval(()=>{this.do()},1e3/n)},150)}}else this.cancel(!1);this.isRunning=!0}do(){let t=H.frameHelper.getToolProcessorCurrentTool(),{horizontal:i,vertical:r}=this.pointData,n=this.altKeyDown?this.config.altStep:this.config.step,s=n*i,a=n*r;ao.setViewBox(-s,-a),this.updateCtx(),t.onMouseMove(this.ctx),Ir(this.ctx.originalEvent),(t instanceof Bh||t instanceof Gu)&&qS(this.ctx.originalEvent)}updateCtx(){let t=this.ctx,i=vh({x:t.mouseX,y:t.mouseY});t.canvasX=i.x,t.canvasY=i.y}cancel(t=!0){this.canStart=!0,this.pointData.horizontal=0,this.pointData.vertical=0,t&&(this.isRunning=!1),this.startTimer=clearTimeout(this.startTimer),this.runningInterval=clearInterval(this.runningInterval)}updatePointData(t){let{x:i,y:r}=vh({x:t.mouseX,y:t.mouseY}),[n,s,a,o]=Xt.getViewBox();this.ctx.canvasX=i,this.ctx.canvasY=r;let l=i-n,c=r-s,u=this.edgeRangeSize/H.gZoom,h=this.config.type===1,d=this.pointData;d.horizontal=0,d.vertical=0,l>=0&&l<a&&(l<=u?d.horizontal=h?-1:(l-u)/u:a-l<=u&&(d.horizontal=h?1:(u+l-a)/u)),c>=0&&c<o&&(c<=u?d.vertical=h?-1:(c-u)/u:o-c<=u&&(d.vertical=h?1:(u+c-o)/u))}async updateConfig(){var r,n,s,a,o,l;let i=(await H.windowBridge.rpcCall("getProfileSetting","",wd())).message.commSystemSetting.SYSTEM.autoPanning;if(i){switch(i.type.value){case"uniformTranslation":this.config.type=1;break;case"variableSpeedTranslation":this.config.type=2;break;default:this.config.type=0;break}Kn((r=i.step)==null?void 0:r.value)&&(this.config.step=(n=i.step)==null?void 0:n.value),Kn((s=i.speed)==null?void 0:s.value)&&(this.config.speed=(a=i.speed)==null?void 0:a.value),Kn((o=i.altStep)==null?void 0:o.value)&&(this.config.altStep=(l=i.altStep)==null?void 0:l.value)}}},Ar=new sD;window.document.addEventListener("mouseleave",e=>{document.contains(e.relatedTarget)||(Ar.canStart=!1)});window.document.addEventListener("mouseenter",e=>{var t,i;(i=(t=e.relatedTarget)==null?void 0:t.id)!=null&&i.includes("cdot")||(Ar.canStart=!0,Ar.isRunning=!0)});window.top.addEventListener("keydown",e=>{Ar.altKeyDown=e.altKey});window.top.addEventListener("keyup",e=>{Ar.altKeyDown=e.altKey});window.addEventListener("keydown",e=>{Ar.altKeyDown=e.altKey});window.addEventListener("keyup",e=>{Ar.altKeyDown=e.altKey});async function S5(){let e=(await H.windowBridge.rpcCall("getProfileSetting","",ut())).message,t=(await Ho("getPanelFilterConfigDetail",[H.tabId])).message;uo(t);let i=+e.commSystemSetting.PANEL_CANVAS.panel_gridSize;i=ea(i);let r=+e.commSystemSetting.PANEL_CANVAS.panelAltSnapGridSize;r=ea(r),pd("adsorbGrid","distanceX",i),pd("adsorbGrid","distanceY",i),pd("adsorbGrid","gridSize",i),pd("adsorbGrid","altSnapSize",r),await Ar.updateConfig(),$e(e,"commSystemSetting")?H.profileSetting=e||{}:(H.profileSetting||(H.profileSetting={}),H.profileSetting.commSystemSetting=e);let n=H.profileSetting,s=n.commSystemSetting.OBJECT;if(s){let a=s.theme.activeTheme||"color";s.theme[a]&&(Ge.canvas.bgColor=s.theme[a].color.background,Ge.canvas.gridColor=s.theme[a].color.grid)}n.commSystemSetting.PANEL_CANVAS.gridStyle&&(n.commSystemSetting.PANEL_CANVAS.gridStyle==="not"?Ge.adsorbGrid.visible=!1:(Ge.adsorbGrid.visible=!0,Ge.adsorbGrid.gridType=n.commSystemSetting.PANEL_CANVAS.gridStyle)),n.commSystemSetting.PANEL_CANVAS.gridSize&&(Ge.adsorbGrid.gridSize=n.commSystemSetting.PANEL_CANVAS.gridSize),H.windowBridge.publish("tabChange",{tabId:H.tabId,docType:H.doctype},ut())}function V5(){return H.profileSetting.commSystemSetting.SYSTEM.canvasZoomType||"roller"}function Bg(){return"rightClickEnd"}var JS=class{static ready(){}static onKeyUp(t){let i=Je,{keyCode:r}=t;switch(r){case"Enter":if(!i.dots.length)return;let n={clientX:Ir.data.clientX,clientY:Ir.data.clientY,button:hE,ctrlKey:!0},s=new MouseEvent("mousedown",n);document.dispatchEvent(s),s=new MouseEvent("mouseup",n),document.dispatchEvent(s);break}}static mouseupLeft(t,i,r){let n=Bg()==="rightClickEnd",{ctrlKey:s}=t;s&&(n=!1);let a=Je;if(ft(i)&&ft(r)){let l=ui(t,!0);i=l.x,r=l.y}switch(a.dots.length){case 0:a.draw(i,r,!0);break;default:n?a.draw(i,r,!0):(a.next(i,r),En.handlePolylineSelection());break}return a.STATUSEXIT}static mouseupRight(t){let i=Bg()==="rightClickEnd",r=Je,{x:n,y:s}=ui(t,!0);return r.dots.length===0?(Je.restart(),r.STATUSEXIT):(i?(["lineTouched"].includes(En.selectionMode)&&r.next(n,s,!0),En.handlePolylineSelection(),Ce("panel_updateAttrPanel"),Ce("panel/updateTreeActiveElements")):r.draw(n,s,!0),r.STATUSEXIT)}static draw(t,i,r){let n=Je,s=n.dots.slice();if(s.length<2)return;if(!r&&!sa({x:t,y:i},{x:s[s.length-2],y:s[s.length-1]})&&s.push(t,i),En.selectionMode==="lineTouched"){En.showSelectPolyline(s.join(" "));return}let o=s.slice(2).join(" "),l=`M ${s[0]} ${s[1]} ${o?"L "+o:""}`;n.target?(te(n.target,{d:l}),n.dots.length>=4&&bt.updateDrawingShapeCache(n.dots)):(n.target=Et("path",{d:l,fill:"none",c_partid:"group",locked:0,layer:Qe.getTargetPlaceLayer("group"),opacity:1,hide:0,scope:1,cover:1,rotation:0,name:""}),Qe.appendTargetLayer(n.target))}static next(t,i){var r=Je,n=r.dots,s=t!==void 0&&i!==void 0;s&&n.length>1&&t==n[n.length-2]&&i==n[n.length-1]&&(s=!1),s&&r.draw(t,i,!0);let a=r.target;if(r.started&&a)if(n.length<4)dt(r.target);else if(r.target.getPathData().length<2)dt(r.target);else{Qe.appendTargetLayer(r.target);let o=Vn(a);Ke.save(Qr(a.id,{cmdKey:"group",refId:o},{},k.getById(a.id).json))}r.started=!1}static end(t){var i=Je;k.removeOne(i.target),dt(i.target)}};var V1=class{static ready(){this.data=null,Je.dots.length=0}static draw(t,i,r){var n=Je,s=r?n.dots.length-2>0?n.dots.slice(0,n.dots.length-2):[]:n.dots;let a=s.length;if(s.length>=2){let o=Math.min(t,s[a-2]),l=Math.min(i,s[a-1]),c=Math.max(t,s[a-2])-o,u=Math.max(i,s[a-1])-l;(c===0||u===0)&&(c=u=Math.max(c,u));let h=!1;if(c===0&&u===0)return;if(!this.data){let b=Ot();this.data=k.getInitialRectData({gId:b,layer:Qe.getTargetPlaceLayer("rect")});let y=H.panelThemeCache.fillColor.rect,E=H.panelThemeCache.shape.rect.width;E=Yt(E,"mm","pixel");let S=H.panelThemeCache.color.rect;this.data.fillColor=y,this.data.strokeWidth=E,this.data.strokeColor=S,n.target=Et("rect",{id:b,x:0,y:0,width:1,height:1,"stroke-width":E,"stroke-color":S,c_partid:"rect",fill:y,opacity:.3,rx:0,ry:0}),h=!0}let d=de.scale(c,u).translate(o,l),p=et.getMatrix6FromMatrix(d);this.data.matrix=p;let{width:f,height:m,matrixArr:g}=Li.getRectFromMatrix(p);te(n.target,{width:f,height:m}),ht.updateTransform(g,n.target),h&&Qe.appendTargetLayer(n.target),r&&n.next()}}static mouseupRight(t){let i=Je,r=i.dots;if(r.length<4&&r.length>0)return setTimeout(()=>{i.restart(),i.dots.length=0}),i.STATUSEXIT}static next(t,i){var r=Je,n=r.dots,s=t!==void 0&&i!==void 0;s&&n.length>1&&t==n[n.length-2]&&i==n[n.length-1]&&(s=!1),s&&r.draw(t,i,!0);let a=r.target;r.started&&a&&(n.length<4?dt(a):(a=C1(this.data,a.id),Za([a]),Qe.appendTargetLayer(a),qt(),Ae.select(a),ms(a),this.ready())),r.started=!1}static end(){var i;let t=(i=this.data)==null?void 0:i.gId;t&&k.removeMultiData([{id:t}]),this.ready()}};V1.data=null;var KS=class{static ready(){}static mouseupLeft(t){let i=Bg()==="rightClickEnd",r=Je,{x:n,y:s}=ui(t,!0);switch(r.dots.length){case 0:r.draw(n,s,!0);break;default:i?r.draw(n,s,!0):(r.next(n,s),aD());break}return r.STATUSEXIT}static mouseupRight(t){let i=Bg()==="rightClickEnd",r=Je,{x:n,y:s}=ui(t,!0);return r.dots.length===0?(Je.restart(),r.STATUSEXIT):(i?(r.next(n,s,!0),aD(),Ce("panel_updateAttrPanel"),Ce("panel/updateTreeActiveElements")):r.draw(n,s,!0),r.STATUSEXIT)}static draw(t,i,r){var n=Je;let s=n.dots.slice();if(s.length<2)return;r||s.push(t,i);let a=s.join(" "),o=En.selectionMode;if(["polygonInside","polygonOutside"].includes(o)){oD(a);return}n.target?te(n.target,{points:a}):(n.target=Et("polygon",{points:a,fill:"none",c_partid:"line",class:Ae.unselectableClass,"stroke-dasharray":"3, 3","vector-effect":"non-scaling-stroke","stroke-width":"1px",locked:0,layerid:Qe.getTargetPlaceLayer("group")}),Qe.appendTargetLayer(n.target))}static next(t,i){var r=Je,n=r.dots,s=t!==void 0&&i!==void 0;s&&n.length>1&&t==n[n.length-2]&&i==n[n.length-1]&&(s=!1),s&&r.draw(t,i,!0),r.started&&r.target&&(n.length<4?dt(r.target):r.target.points.numberOfItems<2&&dt(r.target)),r.started=!1}static end(t){var i=Je;i.target&&(k.removeOne(i.target),dt(i.target))}};var H5="drag-auxiliary-line",mo=class{constructor(t,i){this.auxiliaryLineId=H5;this.update(t,i)}static update(t,i){let r=new this(t,i);r=null}update(t,i){if(!t||!i)return;let r=this.auxiliaryLineId,n=document.getElementById(r),s=[t.x,t.y,i.x,i.y].join(" ");n?te(n,{points:s}):(n=Et("polyline",{id:r,points:s,"vector-effect":"non-scaling-stroke",stroke:H.panelThemeCache.color.select}),H.gCanvas.appendChild(n))}static removeAuxiliaryLine(){dt(document.getElementById(this.auxiliaryLineId))}static overrideXY(t,i,r,n){if(t&&i){let s=new j(i.x,i.y),a=new j(r,n),o=a.angleD(s);o=o<0?o+360:o;let l=Math.floor(o/45)*45,c=o-l>22.5?l+45:l,u=a.multiply3(de.rotateD(c-o).setOrigin1(s));r=u.x,n=u.y,this.update(i,{x:r,y:n})}else this.removeAuxiliaryLine();return{x:r,y:n}}};mo.auxiliaryLineId=H5;var H1=class{static ready(){this.data=null,Je.dots.length=0}static draw(t,i,r){let n=Je,s=r?n.dots.length-2>0?n.dots.slice(0,n.dots.length-2):[]:n.dots,a=s.length;if(a>=2){let o=s[a-2],l=s[a-1],c=lt(Hl(t,i,o,l));if(c===0)return;let u=!1;if(!this.data){let g=Ot();this.data=k.getInitialEllipseData({gId:g,layer:Qe.getTargetPlaceLayer("ellipse")});let b=H.panelThemeCache.fillColor.circle,y=H.panelThemeCache.shape.circle.width;y=Yt(y,"mm","pixel");let E=H.panelThemeCache.color.circle;this.data.fillColor=b,this.data.strokeWidth=y,this.data.strokeColor=E,n.target=Et("ellipse",{id:g,cx:0,cy:0,rx:1,ry:1,fill:b,"stroke-color":E,"stroke-width":y,c_partid:"ellipse",opacity:.3}),u=!0}let h=de.scale(c,c).translate(o,l),d=et.getMatrix6FromMatrix(h);this.data.matrix=d;let{rx:p,ry:f,matrixArr:m}=Ei.getEllipseFromMatrix(d);te(n.target,{rx:p,ry:f}),ht.updateTransform(m,n.target),u&&Qe.appendTargetLayer(n.target),r&&n.next()}}static mouseupRight(t){let i=Je;if(i.target)return setTimeout(()=>{i.restart(),this.ready()}),i.STATUSEXIT}static next(t,i){let r=Je,n=r.dots,s=t!==void 0&&i!==void 0;s&&n.length>1&&t==n[n.length-2]&&i==n[n.length-1]&&(s=!1),s&&r.draw(t,i,!0);let a=r.target;r.started&&this.data&&(n.length<4?dt(r.target):(a=D1(this.data,a.id),Za([a]),Qe.appendTargetLayer(a),this.ready())),r.started=!1,qt(),Ae.select(a),ms(a)}static end(t){var r;let i=(r=this.data)==null?void 0:r.gId;i&&k.removeMultiData([{id:i}]),this.ready()}};var $S=class{};var kg=class extends $S{static getTextNode(){return Rs(`
	<g id="" visibility="hidden" name="Text" c_partid="part_text"  opacity="1"  transform="translate(0,0)">
		
	</g>`)}static async ready({value:t,attrs:i}){this.rotation=0,this.text=_0(t),this.attrs=i||{},await this.cloneTemplate(),Je.started=!0}static rotate(t){this.rotation+=t,this.draw(this.lastPosition.x,this.lastPosition.y,!1)}static async cloneTemplate(){this.template=this.getTextNode();let t=this.template.cloneNode(!0),i=Ot();t.id=i,this.data=k.getInitialTextData({gId:i});let r=H.panelThemeCache.fontStyle.text,n=this.attrs["attr-font-color"]||H.panelThemeCache.color.text,s=this.attrs["attr-font-weight"]||(Number(r.fontWeight)?"bold":"normal"),a=this.attrs["attr-font-style"]||(Number(r.fontItalic)?"italic":"normal"),o=this.attrs["attr-font-underline"]||(Number(r.fontUnderline)?"underline":"inherit"),l=Yt(this.attrs["attr-font-size"]||r.fontSize,"mm","pixel"),c=this.attrs["attr-font-family"]||r.fontFamily,[u,h]=a2(this.attrs["attr-origin"]);this.data.vAlign=+h,this.data.hAlign=u;let d=new _u,{d:p,bbox:f}=await d.getPath(this.text,{fontFamily:c,fontSize:l,fontWeight:s,fontStyle:a,underline:o,value:this.text}),m=f.height(),g=f.width();this.data.cacheHeight=m,this.data.cacheWidth=g,this.data.fontSize=l,this.data.underline=o!=="inherit",this.data.fontFamily=c,this.data.strokeColor=n,this.data.italic=a!=="normal",this.data.fontWeight=s!=="normal",this.data.d=p,this.data.key=this.data.name=this.text;let b=Et("path",{d:p,fill:n}),y=Et("rect",{width:g,height:m,x:0,class:"hitbox",y:-m,stroke:"none",fill:"transparent"});t.appendChild(y),t.appendChild(b),t=bg(this.data,this.data.gId),t.classList.add(Vl),Xn.text(this.data,Ir.data.currAbsX,Ir.data.currAbsY),Qe.appendTargetLayer(t),Je.target=t,bt.setExcludeShapeIds([t.id])}static next(t,i,r){this.cloneTemplate()}static draw(t,i,r){this.lastPosition={x:t,y:i};let{target:n}=Je;if(!n)return;let s=n;VA(s,"visibility"),s.classList.remove("hide");let{x:a,y:o}=xr.getTextOrigin("",this.data.hAlign,this.data.vAlign,this.data),l=de.translate(t+a,i+o).rotateD(this.rotation).setOrigin(t,i),c=et.getMatrix6FromMatrix(l);return ht.updateTransform(c,s),r&&(bt.clearExcludeShapeIds(),VA(s,"pointer-events"),this.data.matrix=c,s=bg(this.data,this.data.gId),Tr.record(0,()=>{Za([s])}),Qe.appendTargetLayer(s),Je.next()),s}static end(t){Je.target&&Je.target.parentNode&&!t&&k.removeOne(Je.target),this.template=null,H.windowBridge.publish("openForceClosedBottomBar",null,ut())}};kg.rotation=0;var ZS=class{constructor(t={}){this.path=Et("path",{...t}),Qe.appendTargetLayer(this.path)}render(t){return te(this.path,"d",t),this}remove(){dt(this.path)}getPath(){return this.path}},QS=class{constructor(t){this.anchorInfo=[];this.isPressingMouseLeftDown=!1;this.handlePoints=[];this.lastLeftMouseDownTime=Date.now();this.hasMoved=!1;this.panelDraw=t}ready(){this.anchorInfo=[],this.handlePoints=[],this.data=null,this.panelDraw.dots.length=0}beforeStepBack(){let t=Je;if(this.anchorInfo.length>1){let i=this.anchorInfo.pop();switch(i.type){case"C":this.handlePoints.length>1&&(this.handlePoints.pop(),this.handlePoints.pop(),this.handlePoints.push(i.x1,i.y1));break;case"L":break;default:console.error(i);break}this.draw(t.mockX,t.mockY)}}createNewAnchor(t,i,r){let n={};switch(t.type){case"M":n.type="C",n.x1=this.handlePoints[0],n.y1=this.handlePoints[1],n.x2=i,n.y2=r,n.x=i,n.y=r,n.d=["C",n.x1,n.y1,n.x2,n.y2,n.x,n.y].join(" "),n.index=t.index+3;break;case"C":n.type="C",n.x1=this.handlePoints[0],n.y1=this.handlePoints[1],n.x2=i,n.y2=r,n.x=i,n.y=r,n.d=["C",n.x1,n.y1,n.x2,n.y2,n.x,n.y].join(" "),n.index=t.index+3;break;case"L":n.type="C",n.x1=t.x,n.y1=t.y,n.x2=this.handlePoints[0],n.y2=this.handlePoints[1],n.d=["C",n.x1,n.y1,n.x2,n.y2,i,r].join(" "),n.index=t.index+3;break;default:console.error(t);break}return n}mousedownLeft(t,{x:i,y:r}){this.lastLeftMouseDownTime=Date.now(),this.hasMoved=!1;let n=this.anchorInfo.length,s=this.anchorInfo[n-1],a={x:i,y:r,type:"M",d:["M",i,r].join(" "),index:0};n&&(this.handlePoints.length?(a=this.createNewAnchor(s,i,r),this.handlePoints=[]):(a.type="L",a.d=["L",i,r].join(" "),a.index=s.index+1)),this.anchorInfo.push(a),this.draw(i,r),this.isPressingMouseLeftDown=!0,Xs.flush()}mouseupLeft(t,i,r){this.isPressingMouseLeftDown&&this.hasMoved&&this.handlePoints.push(i,r),this.isPressingMouseLeftDown=!1}getFollowHandle(t,i,r,n,s){if(Xs.storeDriving(t,i),s!=null&&s.ctrl){Xs.exchangeFollow(),Xs.exchangeDriving();let{x:a,y:o}=Xs.getFollowHandle();ft(a)||(n.x=a,n.y=o)}else{let a=new j(n.x,n.y),{x:o,y:l}=Xs.getFollowHandle(),{x:c,y:u}=Xs.getDrivingHandle();ft(o)||(a=new j(o,l));let h=new j(t,i);ft(c)||(h=new j(c,u));let d=wt.handleFollowHandle(new j(r.x,r.y),{oldP:h,newP:new j(t,i)},a);n.x=d.x,n.y=d.y,Xs.storeFollow(d.x,d.y)}return n}draw(t,i,r,n){let s=Je,a=this.anchorInfo.length;if(a===0)return;let o=a-2>-1&&this.anchorInfo[a-2],l=this.anchorInfo[a-1],c=G3(l,{x:t,y:i});if(Date.now()-this.lastLeftMouseDownTime<100||c<.02)return;this.isPressingMouseLeftDown&&(this.hasMoved=!0);let h={type:"L",index:this.anchorInfo.length,x:t,y:i,d:["L",t,i].join(" ")};if(this.handlePoints.length&&(h.d=["C",this.handlePoints[0],this.handlePoints[1],t,i,t,i].join(" ")),this.isPressingMouseLeftDown){let m=wt.getMirrorPoint(l,{x:t,y:i});if(m=this.getFollowHandle(t,i,l,m,n),a===1)h={x:t,y:i,index:l.index+2,type:"C",x1:l.x,y1:l.y,x2:t,y2:i,d:["C",l.x,l.y,t,i,t,i].join(" ")};else{switch(l.type){case"C":l.d=["C",l.x1,l.y1,m.x,m.y,l.x,l.y].join(" "),l.x2=m.x,l.y2=m.y;break;case"L":l.type="C",l.x1=o.x,l.y1=o.y,l.x2=m.x,l.y2=m.y,l.index=o.index+3,l.d=["C",l.x1,l.y1,l.x2,l.y2,l.x,l.y].join(" ");break;default:console.error(l);break}h.d=["C",l.x,l.y,t,i,t,i].join(" ")}}let d=[...this.anchorInfo,h],p=wt.getPathD(d);if(this.data){te(s.target,{d:p});let m=this.anchorInfo.length,g=this.anchorInfo[m-1],b={type:"M",x:g.x,y:g.y,d:["M",g.x,g.y].join(" "),index:0},y=wt.getPathD([b,h]);this.virtualLine.render(y);let E="";m>1&&(E=wt.getPathD(this.anchorInfo)),this.realityLine.render(E),d.pop(),bt.updateDrawingShapeCache(wt.getPoints(d))}else{let m=Qe.getTargetPlaceLayer("group"),g=Ot();this.data=k.getInitialGroupData({gId:g,layer:m});let b=H.panelThemeCache.shape.line.width,y=H.panelThemeCache.color.line;b=Yt(b,"mm","pixel"),this.data.strokeWidth=b,this.data.strokeColor=y;let E=H.panelThemeCache.fillColor.line||"none";this.data.fillColor=E;let S={opacity:1,"stroke-width":b,stroke:y,fill:E,c_partid:"group"};this.realityLine=new ZS(S),S.opacity=.3,this.virtualLine=new ZS(S).render(p),s.target=Et("path",{id:g,d:p,opacity:1,strokeWidth:b,strokeColor:y,fill:"none",c_partid:"group"}),Qe.appendTargetLayer(s.target),te(s.target,{display:"none"}),wt.toggleMode(s.target.id)}Th("","none"),ms(s.target);let f=o?[o.index,l.index]:[l.index];ar.showHandleOfIndexes(f)}next(){var r,n;let i=Je.target;if(this.anchorInfo.length>1&&i){let s=wt.getPathD(this.anchorInfo);this.data.d=s,i=fl(this.data,i.id),Za([i]),Qe.appendTargetLayer(i)}this.anchorInfo.length<2?(dt(i),ar.hideAll().removeAllAnchor(),i=null):(wt.toggleMode(i.id),Ae.select(i),ms(i)),(r=this.realityLine)==null||r.remove(),(n=this.virtualLine)==null||n.remove(),this.ready()}end(){this.data&&k.removeMultiData([{id:this.data.gId}]),this.ready(),ar.hideAll().removeAllAnchor(),this.realityLine&&(this.realityLine.remove(),this.virtualLine.remove())}};var mf=class{static ready(t=ul(H.cmdToken)){Je.started=!0,this.buildLine(t),this._type=t,H.helperCursor=""}static buildLine(t){switch(t){case"cross":{this.lines=[new Fg(k.getInitialAuxiliaryLineData({gId:Ot()})),new Fg(k.getInitialAuxiliaryLineData({gId:Ot(),rotation:90}))];break}case"horizontal":{this.lines=[new Fg(k.getInitialAuxiliaryLineData({gId:Ot()}))];break}case"vertical":{this.lines=[new Fg(k.getInitialAuxiliaryLineData({gId:Ot(),rotation:90}))];break}default:throw Je.end(),new Error(`PlaceAuxiliaryLine: invalid type(${t}) auxiliary line`)}}static draw(t,i,r){for(let n of this.lines)n.x=t,n.y=i,le(n.gId)?new Zl(n.toJSON()).render():Qe.appendTargetLayer(n.svg,8);zd(),r&&Tr.record(0,()=>{Je.next()})}static next(){let t=[];for(let i of this.lines){let r=P1(i.toJSON());Qe.appendTargetLayer(r,8);let n=Vn(r);t.push(Qr(i.gId,{cmdKey:"auxiliaryLine",refId:n},{},i.toJSON())),Ae.select([r])}this.buildLine(this._type),t.length&&Ke.save(t)}static end(){for(let t of this.lines)dt(le(t.gId));this.lines.length=0,this._type=null,zd()}static getRulerAuxiliaryXY(){let t={x:[],y:[]},{x:i,y:r}=this.lines[0]||{};if(i==null&&r==null)return t;let n=["cross","vertical"].includes(this._type)?lt(Yt(i,"pixel",Ge.canvas.unit),2):null,s=["cross","horizontal"].includes(this._type)?lt(Yt(-r,"pixel",Ge.canvas.unit),2):null,a=Gg({x:i,y:r});return n!=null&&t.x.push({position:a.clientX,content:String(n)}),s!=null&&t.y.push({position:a.clientY,content:String(s)}),t}static mouseWheel(t){for(let i of this.lines)i.updateSVG()}};mf.lines=[];var Fg=class{constructor(t){this.svg=Et("line",{c_partid:"auxiliaryLine"});for(let i in t)this[i]=t[i]}get gId(){return this._gId}set gId(t){this._gId=t,this.svg.id=t}get x(){return this._x}set x(t){this._x=t,this.updateSVG()}get y(){return this._y}set y(t){this._y=t,this.updateSVG()}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this.updateSVG()}get type(){return ul(this.rotation)}updateSVG(){if(this.x==null||this.y==null||this.rotation==null)return;let t=H.svgRoot.viewBox.animVal,i=Math.max(t.width,t.height),r=$p(this.x,this.y,this.rotation,i);this.svg.setAttribute("x1",String(r.start().x)),this.svg.setAttribute("y1",String(r.start().y)),this.svg.setAttribute("x2",String(r.end().x)),this.svg.setAttribute("y2",String(r.end().y))}toJSON(){let t=$p(this.x,this.y,this.rotation),{x:i,y:r}=t.start(),{x:n,y:s}=t.end();return{gId:this.gId,x:this.x,y:this.y,strokeColor:this.strokeColor,strokeStyle:this.strokeStyle,layer:this.layer,locked:this.locked,rotation:this.rotation,name:this.name,visible:!0,cmdKey:"auxiliaryLine",x1:i,y1:r,x2:n,y2:s}}};var ew=class{constructor(t){this.panelDraw=t}ready(){Je.started=!0,this.point=new tw(k.getInitialAuxiliaryPointData({gId:Ot()}))}draw(t,i,r){this.point.x=t,this.point.y=i,le(this.point.gId)||Qe.appendTargetLayer(this.point.svg,8),zd(),r&&Tr.record(0,()=>{this.panelDraw.next()})}next(){Ke.startBatch();let t=af(this.point.toJSON());Qe.appendTargetLayer(t,8);let i=Vn(t);Ke.save(Qr(this.point.gId,{cmdKey:"auxiliaryPoint",refId:i},{},this.point.toJSON())),this.point.destroy(),Ae.select([t]),Ke.saveBatch(),this.point=new tw(k.getInitialAuxiliaryPointData({gId:Ot()}))}end(){var t,i;dt(le((t=this.point)==null?void 0:t.gId)),(i=this.point)==null||i.destroy(),this.point=null,zd()}getRulerAuxiliaryXY(){let t={x:[],y:[]},{x:i,y:r}=this.point||{};if(i==null&&r==null)return t;let n=lt(Yt(i,"pixel",Ge.canvas.unit),2),s=lt(Yt(-r,"pixel",Ge.canvas.unit),2),a=Gg({x:i,y:r});return t.x.push({position:a.clientX,content:String(n)}),t.y.push({position:a.clientY,content:String(s)}),t}},tw=class{constructor(t){this.cmdKey="auxiliaryPoint";this.svg=Et("circle",{c_partid:"auxiliaryPoint",r:ph});for(let i in t)this[i]=t[i];og(this.svg,ph/H.gZoom)}get gId(){return this._gId}set gId(t){this._gId=t,this.svg.id=t}get x(){return this._x}set x(t){this._x=t,this.svg.setAttribute("cx",String(t))}get y(){return this._y}set y(t){this._y=t,this.svg.setAttribute("cy",String(t))}toJSON(){return{gId:this.gId,x:this.x,y:this.y,fillColor:this.fillColor,layer:this.layer,locked:this.locked,name:this.name,visible:!0,cmdKey:"auxiliaryPoint"}}destroy(){for(let t in this)this[t]=void 0}};var Wd=class Wd{static ready(){let t=H.cmdToken.includes("xy")?"xy":H.cmdToken.includes("x")?"x":"y";this.addingRuler=!0,this.currentDirection=t,ic.load(),bt.enabled=!1,qt(),Je.started=!0,window.focus()}static placeDimension(t){Je.dots.length=0;let{name:i,size:r,type:n,cancel:s,id:a,created:o}=t;if(!o){if(s)return;let d=k.getDimension(a);this.currentDimension=new In(d)}let l=this.currentDimension.toJSON();if(s){this.currentDimension.unmount(),this.currentDimension=null;return}let c=this.currentDimension.getDistance(),u=!ni(c,+r);r=ea(+r),l.category=n,l.name=i;let h=CC(l);Ke.startBatch(),o&&Ke.jsonSnap.addOne(l,{}),n==="Constraint"&&u&&(ts.changeDimensionSize(this.currentDimension.getId(),r),ic.load()),Ke.saveBatch(),Ae.select([h]),Ce("panel_updateAttrPanel"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),this.currentDimension=null,k.compilerManager.resumeDataMerge()}static getCurrentDirection(){return Wd.currentDirection}static lockCurrentDirection(){this.lockedDirection=!this.lockedDirection}static unLockCurrentDirection(){this.lockedDirection=!1}static mousedownLeft(t){let{canvasX:i,canvasY:r}=t;if(k.compilerManager.pauseDateMerge(),this.clickedLabelDots.length===2){for(let h of this.clickedLabelDots)h.setClicked(!1).unmount();this.clickedLabelDots.length=0,this.unLockCurrentDirection();let s=this.currentDimension.start.id,a=this.currentDimension.end.id,o=this.currentDimension.getDirection(),l=new Vo,c=!1;s===a?c=l.overDefinedSelf(s,o):(l.findDimensionNodeByPrimitiveId(new Set([s])),c=l.overDefined(s,a,o));let u={name:"",object:{start:k.getById(s).json,end:k.getById(a).json,...this.currentDimension.getPrimitiveType()},type:this.currentDimension.getCategory(),size:this.currentDimension.getDistance(),overed:c,created:!0};Ce("panel/open-smart-dimension-dialog",[u]);return}let n=ic.findNearestLabelPoint(new j(i,r),this.hoveLabelDots);n&&(this.clickedLabelDots.length===1&&n===this.clickedLabelDots[0]||(n.setClicked(!0).mount(),this.clickedLabelDots.push(n),this.clickedLabelDots.length===2&&this.draw(Je.lastX,Je.lastY)))}static draw(t,i){if(this.clickedLabelDots.length<2){let f=ic.findNearbyPrimitiveLabelPoint(t,i);this.hoveLabelDots=this.lockTargetLabelDots.get()||ic.getTopLabelPoints(f);for(let m of this.hoveLabelDots)m.mount()}if(this.clickedLabelDots.length!==2)return;for(let f of this.hoveLabelDots)f.unmount();let[r,n]=this.clickedLabelDots,s=r.getX(),a=r.getY(),o=n.getX(),l=n.getY(),c=this.getCurrentDirection(),u=(t-s)*(t-o)<0,h=(i-a)*(i-l)<0;this.lockedDirection&&(c=this.dynamicDirection),!this.lockedDirection&&c==="xy"&&(u&&h?c="xy":u?c="x":h&&(c="y"),this.dynamicDirection=c);let d={id:r.getPrimitiveId(),index:r.getIndex(),cmdKey:r.getCmdkey(),primitivePoint:{x:s,y:a},otherPoint:{x:s,y:i}},p={id:n.getPrimitiveId(),index:n.getIndex(),cmdKey:n.getCmdkey(),primitivePoint:{x:o,y:l},otherPoint:{x:o,y:i}};if(c==="y"&&(d.otherPoint.x=t,d.otherPoint.y=a,p.otherPoint.x=t,p.otherPoint.y=l),c==="xy"){let f=ts.calcuPerpendicular({x:s,y:a},{x:o,y:l},{x:t,y:i});d.otherPoint=f.start,p.otherPoint=f.end}if(this.currentDimension)this.currentDimension.updateStartNode(d).updateEndNode(p).updateType(c).render();else{let f=Ot();this.currentDimension=new In({name:"",layer:8,gId:f,start:d,end:p,category:"Constraint",direction:"x",visible:!0})}}static next(){for(let t of this.hoveLabelDots)t.setClicked(!1).unmount();for(let t of this.clickedLabelDots)t.setClicked(!1).unmount();this.clickedLabelDots.length=0,this.unLockCurrentDirection(),this.currentDimension&&(this.currentDimension.unmount(),this.currentDimension=null),this.lockTargetLabelDots.lockToggle([]),k.compilerManager.resumeDataMerge()}static onKeyUp(t){let{keyCode:i}=t;switch(i){case"Backspace":if(this.clickedLabelDots.length===0)return;this.clickedLabelDots.pop().setClicked(!1).unmount(),this.currentDimension&&(this.currentDimension.unmount(),this.currentDimension=null);break;case"Space":this.clickedLabelDots.length===2?this.lockCurrentDirection():this.lockTargetLabelDots.lockToggle(this.hoveLabelDots);break;default:break}}static end(){this.clickedLabelDots.length||(bt.enabled=!0),this.next()}};Wd.addingRuler=!1,Wd.lockedDirection=!1,Wd.clickedLabelDots=[],Wd.hoveLabelDots=[],Wd.lockTargetLabelDots=(()=>{let t=[];return{lockToggle(i){t.length?t=[]:t=i},get(){return t.length?t:void 0}}})();var Ug=Wd;var iw=class{constructor(t){this.clickedTwice=!1;this.draw=(t,i,r)=>{if(!this.current&&r){this.current=this.createDimensionLength(),this.current.setStart(t,i).setEnd(t,i).setTextPosition(t,i).calcuDirection().render();return}this.current&&(this.clickedTwice?(this.current.setTextPosition(t,i).calcuDirection().render(),r&&this.panelDraw.next()):(this.current.setEnd(t,i).setTextPosition(t,i).calcuDirection().render(),r&&(this.clickedTwice=!0)))};this.panelDraw=t}createDimensionLength(){let t=Ot();return new xn({gId:t})}ready(){qt(),this.panelDraw.dots.length=0}beforeStepBack(){this.clickedTwice=!1}next(){if(this.current){let t=this.current.getContainer(),i=new oi,r=this.current.toData();k.setDimension(r.gId,r,"dimensionLength"),i.addOne(k.getById(t.id).json,{},"dimensionLength"),i.updateAndSave(),this.panelDraw.target=t}this.current=null,this.clickedTwice=!1}end(){this.current&&(this.current.unmount(),this.current=null),this.clickedTwice=!1,this.ready()}mouseupRight(){return Je.restart(),Je.STATUSEXIT}};var rw=class{constructor(t){this.clickedTwice=!1;this.panelDraw=t}ready(){this.current=null,this.clickedTwice=!1,this.panelDraw.dots.length=0}draw(t,i,r){if(r&&!this.current){let n=Ot();this.current=new bn({gId:n}),this.current.setStart(t,i).setEnd(t,i).setAngle(t,i).nextTick(s=>{s.querySelector("text").classList.add("hide")}).render();return}this.current&&(this.clickedTwice?(this.current.setEnd(t,i).calcuTextDot().nextTick(n=>{n.querySelector("text").classList.remove("hide")}).render(),r&&Je.next()):(this.current.setStart(t,i).setEnd(t,i).calcuTextDot().render(),r&&(this.clickedTwice=!0)))}next(){if(this.current&&this.clickedTwice){let t=new oi,i=this.current.getContainer();this.current.setData(),t.addOne(k.getById(i.id).json,{},"dimensionAngle"),t.updateAndSave(),Ae.select([i]),Ce("panel_updateAttrPanel")}else this.current&&this.current.unmount();this.ready()}end(){this.current&&this.current.unmount(),this.ready()}beforeStepBack(){this.clickedTwice=!1}mouseupRight(){return Je.restart(),Je.STATUSEXIT}};var nw=class{constructor(t){this.panelDraw=t}ready(){this.current=null,Je.dots.length=0}draw(t,i,r){if(!this.current&&r){let n=Ch(t,i),s=n[0];if(n.length===0){let o=Uc(t,i);if(o.length===0)return;s=o[0]}let a=Ot();this.current=new cn({gId:a,visible:!0,rotation:0}),this.current.setMeasureId(s).setHead(t,i).calcTail(t,i).calcTextPoint().render(),this.current.lineAlignText();return}if(this.current&&(this.current.setHead(t,i).calcTail(t,i).calcTextPoint().render(),this.current.lineAlignText(),r)){let n=this.panelDraw.dots;n.length===2&&n.push(t,i),Je.next(t,i)}}next(){let t=this.panelDraw.dots;if(this.current&&t.length>2){qt();let i=this.current.toData(),{x1:r,y1:n,x2:s,y2:a}=i;if(r===s&&n===a)return t.splice(2,2);let o=new oi,l=this.current.getContainer();o.addOne(i,{},"dimensionRadius"),k.setDimension(i.gId,i,"dimensionRadius"),o.updateAndSave(),this.panelDraw.target=l}else this.restart();this.ready()}restart(){this.panelDraw.restart(),this.panelDraw.dots.length=0}end(){this.current&&this.current.unmount(),this.ready()}};var sw=class{constructor(t){this.panelDraw=t}createLine(t,i){this.helpLine=Et("line",{fill:H.panelThemeCache.fillColor.arc,stroke:H.panelThemeCache.color.arc,"stroke-width":Yt(H.panelThemeCache.shape.arc.width||1,"mm","pixel"),opacity:.5,x1:t,y1:i,x2:t,y2:i}),H.svgRoot.appendChild(this.helpLine)}ready(){this.data=null,dt(this.helpLine)}draw(t,i,r){let n=this.panelDraw.dots,s=this.panelDraw.dots.length;if(!(s<2)&&(s===2&&(this.ready(),this.createLine(n[0],n[1])),!(t==n[0]&&i==n[1]))){if(s===4&&r&&dt(this.helpLine),s===2)te(this.helpLine,{x1:n[0],y1:n[1],x2:t,y2:i});else if(s>=4){if(n[3]===t&&n[4]===i)return;let a=[n[0],n[1],n[2],n[3],t,i],o=l2.apply(null,a);if(!o)return;if(!this.data){let l=Ot();this.data=k.getInitialArcData({gId:l,layer:Qe.activeLayer||1,type:2,fillColor:H.panelThemeCache.fillColor.arc,strokeColor:H.panelThemeCache.color.arc,strokeWidth:Yt(H.panelThemeCache.shape.arc.width||1,"mm","pixel")}),bt.enabled=!1,this.panelDraw.target=_h(this.data),bt.enabled=!0}this.data.x1=o.x1,this.data.y1=o.y1,this.data.x2=o.x2,this.data.y2=o.y2,this.data.rx=this.data.ry=o.r,this.data.large=o.largeArcFlag,this.data.sweep=o.sweepFlag,te(this.panelDraw.target,"d",_i.getD(this.data)),r&&this.panelDraw.next()}}}next(t,i){let r=Je,n=r.dots,s=r.target;r.started&&s&&(n.length<6?k.removeOne(s):(Za([s]),qt(),Ae.select([s]))),r.started=!1,this.ready()}beforeStepBack(){let t=Je;this.ready(),k.removeOne(t.target),t.target=null}end(){let t=this.panelDraw.target;t&&k.removeOne(t),this.panelDraw.dots.length=0,this.ready()}};var aw=class{constructor(t){this.panelDraw=t}ready(){this.panelDraw.dots.length=0,this.data=null}draw(t,i,r){let n=Je;if(!n.dots.length)return;let s=n.dots[0],a=n.dots[1],o=new j(s,a).distance1(new j(t,i))/2,l=["M"+s+","+a,"A"+o+","+o,0,1,1,t+","+i].join(" ");if(!this.data){let c=Ot();this.data=k.getInitialArcData({gId:c,layer:Qe.activeLayer||1,type:2,x1:s,y1:a,fillColor:H.panelThemeCache.fillColor.arc,strokeColor:H.panelThemeCache.color.arc,strokeWidth:Yt(H.panelThemeCache.shape.arc.width||1,"mm","pixel")}),bt.enabled=!1,n.target=_h(this.data),bt.enabled=!0}this.data.x2=t,this.data.y2=i,this.data.rx=this.data.ry=o,ri.renderer.attr(this.data.gId,"d",l),r&&n.dots.length===4&&n.next()}next(t,i,r){let n=this.panelDraw.target;this.data&&(this.panelDraw.dots.length===4?(Za([n]),qt(),Ae.select(n),this.ready()):this.end())}end(){this.data&&k.removeMultiData([{id:this.data.gId}]),this.ready()}};var ow=class{constructor(t){this.opacityCircleId="opacityCircleId";this.panelDraw=t}createCircle(t,i){this.opacityCircle=Et("circle",{cx:t,cy:i,r:0,id:this.opacityCircleId,fill:H.panelThemeCache.fillColor.arc||"none",stroke:H.panelThemeCache.color.arc||"black",opacity:.5,"stroke-width":Yt(H.panelThemeCache.shape.arc.width||1,"mm","pixel")}),H.svgRoot.appendChild(this.opacityCircle)}ready(){this.panelDraw.dots.length=0}draw(t,i,r){let n=this.panelDraw.dots,s=n.length;if(s===0)return;let a=new j(n[0],n[1]);s===2&&r&&this.createCircle(a.x,a.y);let o=Hl(n[0],n[1],t,i);if(s===4){o=Hl(n[0],n[1],n[2],n[3]),r&&(ri.renderer.removeNode(this.opacityCircleId),this.data=k.getInitialArcData({gId:Ot(),layer:Qe.activeLayer||1,type:1,rx:o,ry:o,x1:n[2],y1:n[3],x2:n[2],y2:n[3],fillColor:H.panelThemeCache.fillColor.arc,strokeColor:H.panelThemeCache.color.arc,strokeWidth:Yt(H.panelThemeCache.shape.arc.width||1,"mm","pixel")}),bt.enabled=!1,this.panelDraw.target=_h(this.data),bt.enabled=!0);let l=new j(t,i).angle2(a);this.data.x2=a.x+Math.cos(l)*o,this.data.y2=a.y+Math.sin(l)*o;let c=new j(this.data.x1,this.data.y1).sub(a),u=new j(this.data.x2,this.data.y2).sub(a),h=c.cross(u);this.data.large=h>0?0:1,te(this.panelDraw.target,{d:_i.getD(this.data)});return}if(s===6){this.panelDraw.next();return}te(this.opacityCircle,{r:o})}next(t,i,r){let n=this.panelDraw.dots.length,s=this.panelDraw.target;n===6?(Za([s]),qt(),Ae.select([s])):n>2&&(ri.renderer.removeNode(this.data.gId),k.removeMultiData([{id:this.data.gId}])),ri.renderer.removeNode(this.opacityCircleId)}beforeStepBack(){let t=this.panelDraw.target;k.removeOne(t);let[i,r]=this.panelDraw.dots;this.createCircle(i,r)}end(){let t=this.panelDraw.target;t&&k.removeOne(t),ri.renderer.removeNode(this.opacityCircleId),this.ready()}};var Je=class extends yn{constructor(t,i){super(),H.cmdToken=t,Je.ready(i),t!=="place_part(text)"&&Ce("setTopBarItemChecked",[t])}getSymbol(){return ii.draw}uninstall(){console.log(this.getSymbol(),"uninstalled"),Je.end(),Ar.cancel(),qd(),xs()}install(){console.log(this.getSymbol(),"installed"),qt(),nc.switch(4)}static canSwitchMe(t){return H.cmdToken==="place_part(text)"?!0:H.cmdToken!==t}static ready(t){if(this.readyed)return;this.readyed=!0,ia(H.gCanvas,"events-none",!0);let{currAbsX:i,currAbsY:r}=Ir.data;["place_auxiliary(crossLine)","place_auxiliary(horizontalLine)","place_auxiliary(verticalLine)"].includes(H.cmdToken)||pr("cross-red",i,r),xs(void 0,{x:i,y:r}),this.drawers(H.cmdToken).ready(t),wt.endEditingPath()}static drawers(t=H.cmdToken){if(this.activeDrawer)return this.activeDrawer;switch(t){case"draw(measure-length)":return this.activeDrawer=new iw(this);case"draw(measure-angle)":return this.activeDrawer=new rw(this);case"draw(measure-radius)":return this.activeDrawer=new nw(this);case"draw(arc)":return this.activeDrawer=new sw(this);case"draw(arcCenter)":return this.activeDrawer=new ow(this);case"draw(arc2)":return this.activeDrawer=new aw(this);case"draw(pen)":return this.activeDrawer=new QS(this);case"draw(dimension-xy)":case"draw(dimension-x)":case"draw(dimension-y)":return Ug;case"draw(circle)":return H1;case"place_part(text)":return kg;case"draw(ellipse)":return H1;case"draw(image)":return Yg;case"draw(polyline)":return JS;case"draw(polygon)":return KS;case"draw(rect)":return V1;case"draw(origin)":return Ud;case"place_auxiliary(point)":return this.activeDrawer=new ew(this),this.activeDrawer;case"place_auxiliary(crossLine)":case"place_auxiliary(verticalLine)":case"place_auxiliary(horizontalLine)":return mf;default:break}}onKeyDown(t){let i=Je,{key:r}=t;switch(r){case"Shift":i.lastToolContext.shiftKeyDown||(i.lastToolContext.shiftKeyDown=!0,this.onMouseMove(i.lastToolContext,!0));break}if(!i.readyed)return;let n=H.cmdToken,s=i.drawers(n);s&&s.onKeyDown&&s.onKeyDown(t)}onKeyUp(t){let{key:i}=t,r=Je;switch(i){case"Shift":mo.removeAuxiliaryLine(),r.lastToolContext.shiftKeyDown=!1,this.onMouseMove(r.lastToolContext,!1);break}if(!r.readyed)return;let n=H.cmdToken,s=r.drawers(n);s&&typeof s.onKeyUp=="function"&&s.onKeyUp(t)}onMouseLeftDown(t){let i=Je;if(!i.readyed)return;let{shiftKey:r}=t.originalEvent,n=H.cmdToken,s=i.drawers(n),{lastClickPoint:a}=i,{x:o,y:l}=ui(t.originalEvent,!0),c=mo.overrideXY(r,a,o,l);o=c.x,l=c.y,s&&typeof s.mousedownLeft=="function"&&s.mousedownLeft(t,{x:o,y:l}),i.started=!0}onMouseLeftUp(t){if(!Je.readyed)return;let{originalEvent:i}=t,r=i.shiftKey,n=Je,{lastClickPoint:s}=n;if(!Io&&(i.target==document.documentElement||i.target==document.body))return;var a=n.dots;let o=ui(i,!0),l=o.x,c=o.y,u=mo.overrideXY(r,s,l,c);if(l=u.x,c=u.y,n.started||(n.started=!0,a.length=0),n.drawers(H.cmdToken)&&typeof n.drawers(H.cmdToken).mouseupLeft=="function"){var h=n.drawers(H.cmdToken).mouseupLeft(i,l,c);if(h===n.STATUSEXIT)return}n.draw(l,c,!0)}onMouseRightUp(t){if(!Je.readyed)return;let i=t.originalEvent,r=Je;if(H.contextmenuDisableOnce=!0,setTimeout(function(){H.contextmenuDisableOnce=!1},5),!Io&&(i.target==document.documentElement||i.target==document.body))return;let n=ui(i,!0),s=n.x,a=n.y,o=r.drawers(H.cmdToken),l=o==null?void 0:o.mouseupRight;Bp(l)&&l.call(o,i,t)===r.STATUSEXIT||(!H.cmdToken||!r.started||H.cmdToken.indexOf("place_part")===0||H.cmdToken==="draw(image)"||H.cmdToken.startsWith("place_auxiliary")||r.dots.length===0?t.toolFinished=!0:r.next(s,a))}onMouseMove(t,i,r=!1){let{altKeyDown:n,originalEvent:s,ctrlKeyDown:a}=t,o=i!==void 0?i:s.shiftKey;!r&&Ar.tryStart(t);let l=Je,c=Je;c.lastToolContext=t;let{lastClickPoint:u}=c;c.readyed||(t.toolFinished=!0),s.altKey!==n&&(t.altKeyDown=n=s.altKey),Qn.altKeyEnabled=n;var h,d;if(Ge.adsorbGrid.enabled||(h=Object.assign({},Ge.adsorbGrid),Object.assign(Ge.adsorbGrid,{distanceX:1,distanceY:1,enabled:!0}),d=function(){Object.assign(Ge.adsorbGrid,h)}),!Io&&(s.target==document.documentElement||s.target==document.body)){d&&d();return}if(c.drawers(H.cmdToken)&&typeof c.drawers(H.cmdToken).mousemove=="function"){var p=c.drawers(H.cmdToken).mousemove(s);if(p===c.STATUSEXIT){d&&d();return}}var f=l.dots;let{x:m,y:g}=ui(s,!0),{cmdToken:b}=H;["draw(dimension-xy)"].includes(b)&&(o=!1);let y=mo.overrideXY(o,u,m,g);if(m=y.x,g=y.y,o&&!["draw(polyline)","draw(polygon)"].includes(b)&&mo.update(u,{x:m,y:g}),f.length>0&&l.mockX==m&&l.mockY==g){d&&d();return}["place_auxiliary(crossLine)","place_auxiliary(horizontalLine)","place_auxiliary(verticalLine)"].includes(b)||cs(m,g),xs("",{x:m,y:g}),l.draw(m,g,!1,{ctrl:a}),l.mockX=m,l.mockY=g,l.mouseX=t.mouseX,l.mouseY=t.mouseY,d&&d()}onMouseWheel(t){this.onMouseMove(t);let i=Je.drawers(H.cmdToken);typeof(i==null?void 0:i.mouseWheel)=="function"&&i.mouseWheel(t)}rotate(t){let i=Je;switch(H.cmdToken){case"draw(image)":Yg.rotate(t);break;case"place_part(text)":kg.rotate(t);break;default:console.trace(H.cmdToken,t);break}}static draw(t,i,r,n){var l;let s=this.dots,a=s.length;this.lastX=t,this.lastY=i,(t!==s[a-2]||i!==s[a-1])&&r&&this.dots.push(t,i);let o=H.cmdToken;typeof((l=this.drawers(o))==null?void 0:l.draw)=="function"&&this.drawers(o).draw(t,i,r,n),r&&(this.lastClickPoint={x:t,y:i})}static next(t,i,r){!r&&qt(),this.drawers(H.cmdToken).next(t,i),this.target&&Ae.select([this.target]),this.target=null,this.dots.length=0,this.mockX=null,this.mockY=null,Ree(H.cmdToken),Ce("panel_updateAttrPanel"),Ce("panel/updateTreeActiveElements"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)}static end(t){var i;(i=this.drawers(H.cmdToken))==null||i.end(t),this.mockX=null,this.mockY=null,this.target=null,this.started=!1,this.dots.length=0,this.readyed=!1,Ce("setTopBarItemChecked"),Ce("updateMenuByDocStatus"),pr(),mo.removeAuxiliaryLine(),bt.clearAdsorptionHTML(),bt.updateDrawingShapeCache(null),uo(),this.activeDrawer=null,gS(),xs()}static restart(){var i;!this.started||!this.dots.length?this.end(27):H.cmdToken==="draw(pen)"?this.next():(i=this.drawers(H.cmdToken))==null||i.end()}static canBackStep(){return this.started&&this.dots.length>=4}static stepBack(){var t;this.canBackStep()&&((t=this.activeDrawer)==null||t.beforeStepBack(),this.dots.length-=2,this.draw(this.lastX,this.lastY))}};Je.readyed=!1,Je.dots=[],Je.line=null,Je.mockX=null,Je.mockY=null,Je.STATUSEXIT=1,Je.lastClickPoint=null,Je=Ws([Pa(Sn.draw)],Je);function Ree(e){let t=Qe.currentScheme.options.some(r=>r.actived===!0),i=!1;e==="place_part(text)"?Qe.activeLayer!==1&&Qe.activeLayer!==2&&(i=!0):e==="draw(image)"&&(i=!0),(!t||i)&&H.windowBridge.rpcCall("switchActiveLayer",[1,{notSaveHistory:!0}],ut())}function Za(e){let t=new oi;if(Wt.isEditing()){let i=Wt.getCurrentEditingComId();t.addOneCombineByComId(i),k.getCombination(i).elements.push(...e.map(n=>n.id)),new Ni().updateHole()}e.forEach(i=>{t.addOne(k.getById(i.id).json,{})}),t.updateAndSave()}function Nee(e){let t=n=>te(e,n)||"",i=n=>n.map(t).map(Number),r=n=>n.replace(/,/g," ").trim().split(/\s+/);switch(e.tagName){case"path":return t("d");case"circle":{let[n,s,a]=i(["cx","cy","r"]);return gB({cx:n,cy:s,r:a})}case"ellipse":{let[n,s,a,o]=i(["cx","cy","rx","ry"]);return Ql({cx:n,cy:s,rx:a,ry:o})}case"line":{let[n,s,a,o]=i(["x1","y1","x2","y2"]);return`M ${n} ${s} L ${a} ${o}`}case"polygon":{let n=t("points"),s=r(n);return s.length<6?"":(s.length%2&&(s.length-=1),`M ${s[0]} ${s[1]} L ${s.slice(2).join(" ")} Z`)}case"polyline":{let n=t("points"),s=r(n);return s.length<4?"":(s.length%2&&(s.length-=1),`M ${s[0]} ${s[1]} L ${s.slice(2).join(" ")}`)}case"rect":{let n=+te(e,"x")||0,s=+te(e,"y")||0,a=parseInt(window.getComputedStyle(e).height,10),o=parseInt(window.getComputedStyle(e).width,10),l=de.scale(o,a).translate(n,s),c=et.getMatrix6FromMatrix(l);return Yo({matrix:c})}default:break}return""}function j5(e){return/^#[\da-f]+$|^\w+$/i.test(e)}function Mee(e,t,i){for(;t.parentNode!==i;){if(e.includes(t.parentNode.tagName))return!0;t=t.parentNode}return!1}function z5(e,t,i,r,n,s){let a=zs(e),o=[];if(!a)return console.error("Invalid Xml",e),o;let l=document.importNode(a.documentElement,!0),c=["defs","style","clipPath","mask","linearGradient","radialGradient","pattern","use","text"],u=S=>Array.from(l.querySelectorAll(S)),h=l.viewBox.baseVal,d=s.rotation||0,p=r/(h.width||r),f=n/(h.height||n),m=t-h.x,g=i-h.y,b=de.scale(p,f).setOrigin(t,i).translate(m*p,g*f),y=de.rotateD(d).setOrigin(t,i);H.gCanvas.appendChild(l);let E=u("path,circle,ellipse,line,polygon,polyline,rect");return o=Array.from(E).map(S=>{if(Mee([...c],S,l))return null;let x=Nee(S);if(!x)return null;let I=Bee(S,b,H.gCanvas),O=qi(x,!1).map(L=>L.multiply3(I).multiply3(y)),R=fs(O,!1,.01,{reverseY:!1});if(!R)return null;let M=window.getComputedStyle(S).fill,F="";M.startsWith("rgb")&&(F=x3(M));let G=F||te(S,"fill")||M,V=te(S,"stroke")||"none",q=te(S,"stroke-width")||"1";G=j5(G)||G=="none"?G:"#000000",V=j5(V)?V:"none",q=Math.max(0,parseFloat(q)||0);let C=G!="none";!(V!="none"&&q>0)&&!C&&(V="#000000",q=1);let T=k.getInitialGroupData({gId:Ot(),layer:Qe.getTargetPlaceLayer("group")});return T.d=R,T.fillColor=G,T.strokeColor=V,T.strokeWidth=q,T}),H.gCanvas.removeChild(l),o.filter(Boolean)}function Bee(e,t,i){function r(a){let o=a.transform.baseVal,l=o.numberOfItems>0?o.consolidate().matrix:new DOMMatrixReadOnly,{a:c,b:u,c:h,d,e:p,f}=l,m=[c,u,h,d,p,f];return ht.createMatrixFrom6(m)}function n(a,o){let l=r(a);for(;a!=o&&o.contains(a);)a=a.parentElement,l=l.multiply3(r(a));return l}return n(e,i||H.svgRoot).multiply3(t)}var Yg=class{static ready(){Je.started=!0,this.rotation=0}static rotate(t){this.rotation+=t,this.draw(this.lastPosition.x,this.lastPosition.y,!1)}static draw(t,i,r){this.lastPosition={x:t,y:i};let n=Je,s=H.defaultImage.userW,a=H.defaultImage.userH,o=de.scale(s,a).rotateD(this.rotation).translate(t,i),l=et.getMatrix6FromMatrix(o);if(r)this.data.matrix=l,n.next(t,i),bt.clearExcludeShapeIds();else if(!r)if(n.target)ht.updateTransform(l,n.target);else{let c=Ot();bt.setExcludeShapeIds([c]);let u=k.getInitialImageData({gId:c,layer:Qe.getTargetPlaceLayer("obj")});u.content=H.defaultImage.src,this.data=u,this.data.gId=c,this.data.height=a,this.data.width=s,n.target=Et("image",{id:c,class:Vl,preserveAspectRatio:"none",c_partid:"obj","xlink:href":u.content,x:0,y:0,width:1,height:1}),Qe.appendTargetLayer(n.target,1)}}static next(t,i){let{target:r,started:n}=Je,s=Je;if(n&&r){let a=this.data;if(a.content.startsWith("data:image/svg+xml;base64,")&&H.defaultImage.insertSvgAsPath){let l=a.content.slice(26),c;try{c=decodeURIComponent(escape(atob(l)))}catch(h){console.error(h);return}let u=z5(c,t,i,H.defaultImage.userW,H.defaultImage.userH,{rotation:this.rotation});if(u.length){qt(),k.removeOne(r),s.target=null;let h=[];for(let p of u){let f=fl(p);Qe.appendTargetLayer(f),h.push(f.id)}let d=[];for(let p of h){let f=le(p),m=Vn(f),g=Qr(p,{cmdKey:"group",refId:m},Object.create(null),k.getById(f.id).json);d.push(g),Ae.select([f])}Ke.save(d)}else Ce("ui/toastMsg",{type:"success",msg:"No svg shapes",timer:3}),dt(s.target),s.target=null;return}r=_1(this.data),Za([r]),Qe.appendTargetLayer(r),qt(),Ae.select([r]),bt.updateShapeCache(r.id,"obj",this.data),Ce("panel_updateAttrPanel"),dt(s.target)}Je.started=!0}static end(t){var i=Je;i.target&&k.removeOne(i.target)}};Yg.rotation=0;function X5(e){if(!e.startsWith("data:image/svg+xml;base64,"))return e;let t=e.substring(0,26),i=decodeURIComponent(escape(atob(e.substring(26)))),r=zs(i),n=document.importNode(r.documentElement,!0),s=Object.values(n.attributes),a=["http://www.w3.org/2000/svg","http://www.w3.org/1999/xlink"],o=[];for(let l of s){let c=l.nodeName,u=l.nodeValue,[h,d]=c.split(":");h==="xmlns"&&d&&!a.includes(u)&&o.push(d)}for(let l of o)W5(n,l+":");return i=new XMLSerializer().serializeToString(n),t+btoa(unescape(encodeURIComponent(i)))}function W5(e,t){let i=e.tagName.toLocaleLowerCase();if(t=t.toLocaleLowerCase(),i.startsWith(t)){dt(e);return}let r=Object.values(e.attributes);for(let n of r)n.nodeName.startsWith(t)&&e.removeAttributeNode(n);for(let n of Array.from(e.children))W5(n,t)}var Wo=class Wo{static getJsonkeysArr(){return["rect","obj","ellipse","text","group","arc","auxiliaryLine","auxiliaryPoint","dimension","dimensionAngle","dimensionLength","dimensionRadius"]}static getLayerOrderContainer(){let t=Vg(),i=new Map;for(let r of t)i.set(r,[]);return i}static toSVG(t,i){t.itemOrder=t.itemOrder||[];let n=['<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" '+(i!=null&&i.viewBox?['viewBox="',i.viewBox,'"'].join(""):"")+">"],s=Object.create(null),a=Wo.getJsonkeysArr();i!=null&&i.before&&i.before(n);let o=Wo.convertAll(a,t,s);n.push('<g xmlns="http://www.w3.org/2000/svg" id="g1">'),n.push(Wo.joinJsonInOrderStr(s,t.itemOrder,o)),n.push("</g>"),n.push("</svg>");let l=n.join("").replace(/[^\x00-\x7f]/gu,function(c){return"&#x"+(c.codePointAt?c.codePointAt(0):c.charCodeAt(0)).toString(16)+";"});return l=l.replace(/&(?![a-z]+\d{0,2};|#\d+;|#x[\da-f]+;)/gi,"&amp;"),l}static joinJsonInOrderStr(t,i,r){let n=this.getLayerOrderContainer();for(let a of i)if($e(t,a)){let o=r.get(a),l=n.get(o);l.push(t[a]),n.set(o,l),delete t[a]}for(let a in t){let o=r.get(a),l=n.get(o);l.push(t[a]),n.set(o,l)}return Array.from(n.values()).flat(1).join(" ")}static convertAll(t,i,r){let n=new Map;for(let s of t)if(i[s]){for(let a in i[s])if($e(i[s],a))try{let o=i[s][a];r[a]=Wo[s](o),n.set(a,o.layer)}catch(o){console.error(o,s)}}return n}static getLineStyleKeys(){return Object.keys(this.lineStyle).map(t=>+t)}static generateCustomizeStr(t,i=[]){if(!t)return" ";let r=[],n=[],s=t.strokeWidth;typeof s=="number"&&n.push(`stroke-width="${s}"`);let a=t.displayStroke===!1?"":t.strokeColor;a&&n.push(`stroke="${a}"`),this.getLineStyleKeys().includes(t.strokeStyle)&&n.push(`stroke-dasharray="${Wo.lineStyle[t.strokeStyle]}"`);let o=t.displayFill===!1?"none":t.fillColor;o!==void 0&&(typeof o=="string"&&o.indexOf("#")!=-1?n.push(`fill="${o}"`):n.push('fill="none"'));let l=t.layer||1,c=t.cover?1:0,u=t.scope===void 0?"":t.scope,h=typeof t.opacity=="number"?t.opacity:1;l==2&&(h=of(+t.transparencyPrint*100,+t.transparencyWhite*100));let d=t.hide?1:0,p=t.locked?1:0,f=ai.eleIsHide(t)?"none":"",m=yu(t.name||"");return n.push(`layer="${l}" cover="${c}" scope="${u}" opacity="${h}" hide="${d}" locked="${p}" name="${m}" display="${f}"`),(n?n.join(" "):" ")+` style="${i.join(";")}" `+(r?` class="${r.join(" ")}" `:" ")}static rect(t){let{width:i,height:r,matrixArr:n}=Li.getRectFromMatrix(t.matrix),a=`transform="${ht.getTransformStr(n)}"`,o=Wo.generateCustomizeStr(t);return`<rect id="${t.gId}" ${o} c_partid="rect" x="0" y="0" width="${i}" height="${r}" rx="${t.rx||0}" ry="${t.ry||0}"  ${a} />`}static obj(t){return kee(t)}static dimension(t){return new In(t).getSvg()}static dimensionLength(t){return new xn(t).getSvg()}static dimensionAngle(t){return new bn(t).getSvg()}static dimensionRadius(t){return new cn(t).getSvg()}static auxiliaryLine(t){let i=Wo.generateCustomizeStr(t);return`<line c_partid="auxiliaryLine" id="${t.gId}"  ${i} x1="${t.x1}" y1="${t.y1}" x2="${t.x2}" y2="${t.y2}" />`}static auxiliaryPoint(t){let i=Wo.generateCustomizeStr(t);return`<circle c_partid="auxiliaryPoint" id="${t.gId}" cx="${t.x}" cy="${t.y}" r="${ph}" ${i}/>`}static ellipse(t){let{rx:i,ry:r,matrixArr:n}=Ei.getEllipseFromMatrix(t.matrix),a=`transform="${ht.getTransformStr(n)}"`,o=Wo.generateCustomizeStr(t);return`<ellipse id="${t.gId}" ${o}  c_partid="ellipse" cx="0" cy="0" rx="${i}" ry="${r}" ${a} />`}static arc(t){let i=_i.getD(t);return`<path ${Wo.generateCustomizeStr(t,["stroke-linecap: round"])} d="${i}" c_partid="arc" id="${t.gId}" />`}static group(t){let i=Wo.generateCustomizeStr(t,["stroke-linecap: round"]);return`<path id="${t.gId}" ${i} c_partid="group" d="${t.d}"/>`}static text(t){return SB(t)}};Wo.lineStyle={0:"0",1:"6,6",2:"3,10",3:"4,2,1,2"};var Rn=Wo;function kee(e){let t=e.layer||"1",i=e.cover?1:0,r=e.scope===void 0?"":e.scope,n=typeof e.opacity=="number"?e.opacity:1,s=e.hide?1:0,a=e.locked?1:0,o=e.name||"",l=ht.getTransformStr(e.matrix);e.content=X5(e.content);let c={id:e.gId,layer:t,cover:i,scope:r,opacity:n,hide:s,locked:a,name:o,preserveAspectRatio:"none",c_partid:"obj","xlink:href":e.content,x:0,y:0,width:1,height:1,display:ai.eleIsHide(e)?"none":"",transform:l};return`<image ${Object.entries(c).map(([h,d])=>`${h}="${yu(String(d))}"`).join(" ")}></image>`}var _i=class e extends Cd{constructor(i){super(i);this.startAnchorSelected=!1;this.endAnchorSelected=!1;this.middleAnchorSelected=!1;this.centerSelected=!1}getMatrix(){return de.scale(this.data.rx,this.data.ry).rotateD(this.data.angle).translate(this.cx,this.cy)}getInverseMatrix(){let i=this.getMatrix();return new de(i.getInverseMatrix().data)}setControlDotSelected(i,r){return sa({x:i,y:r},this.vectorStart())?(this.startAnchorSelected=!0,!0):sa({x:i,y:r},this.vectorEnd())?(this.endAnchorSelected=!0,!0):sa({x:i,y:r},this.vectorCenter())?(this.centerSelected=!0,!0):sa({x:i,y:r},this.getMiddleAnchor())?(this.middleAnchorSelected=!0,!0):!1}getMiddleAnchor(){if(this.middleVector)return this.middleVector;let i=this.vectorStart(),n=this.vectorEnd().angleD2(i),s=de.rotateD(-n).setOrigin1(i),a=this.getMatrix().multiply3(s),{a:o,b:l,c,d:u,e:h,f:d}=et.getMatrixabcdef(a),p=Math.atan2(u,l);if(this.data.sweep===1){let f=Math.cos(p+Math.PI),m=Math.sin(p+Math.PI),g=o*f+c*m+h,b=l*f+u*m+d,y=new j(g,b).rotateD(i,n);return this.middleVector=y,y}else{let f=Math.cos(p),m=Math.sin(p),g=o*f+c*m+h,b=l*f+u*m+d,y=new j(g,b).rotateD(i,n);return this.middleVector=y,y}}moveMiddleAnchor2(i,r,n){let s=this.vectorStart(),o=this.vectorEnd().angleD2(s),l=this.getMiddleAnchor(),c=l.add1(i,r),u=de.translate(-s.x,-s.y).rotateD(-o),h=c.multiply3(u).y/l.multiply3(u).y,d=1;n.keepRatio&&(d=h);let p=u.scale(d,h).rotateD(o).translate1(s);mr.syncArc(this.data,p,{updateD:!1})}moveMiddleAnchor(i,r,n){if(n.alt)return this.moveMiddleAnchor2(i,r,n);let s=this.vectorStart(),a=this.vectorEnd(),l=this.getMiddleAnchor().add1(i,r),c=[s.x,s.y,a.x,a.y,l.x,l.y],u=l2.apply(null,c);if(!u)return;let h={gId:this.data.gId,x1:u.x1,y1:u.y1,x2:u.x2,y2:u.y2,rx:u.r,ry:u.r,large:u.largeArcFlag,sweep:u.sweepFlag,angle:0,rotation:0};this.data.temp=h,this.render(h)}forTwoArc(i,r,n){let s=this.vectorStart(),a=this.vectorEnd();if(this.startAnchorSelected){let g=s;s=a,a=g}let o=a.angleD2(s),l=a.add1(i,r),c=l.angleD2(s),u=de.translate(-s.x,-s.y).rotateD(-o),h=l.distance1(s),d=a.distance1(s);Ve.eq(h,0)&&(h=1),Ve.eq(d,0)&&(d=1);let p=h/d,f=1;n.keepRatio&&(f=p);let m=u.scale(p,f).rotateD(c).translate1(s);mr.syncArc(this.data,m,{updateD:n.updateD||!1})}forCenterArc(i,r,n){let s=new j(i,r),a=this.getMatrix(),o=new de(a.getInverseMatrix().data),l,c,u,h;if(this.startAnchorSelected){let f=this.vectorStart().add(s).multiply3(o).angle2(j.ORIGIN);u=new j(Math.cos(f),Math.sin(f)).multiply3(a),h={x1:u.x,y1:u.y},c=this.vectorEnd().sub(this.vectorCenter()),l=new j(u.x,u.y).sub(this.vectorCenter())}else if(this.endAnchorSelected){let f=this.vectorEnd().add(s).multiply3(o).angle2(j.ORIGIN);u=new j(Math.cos(f),Math.sin(f)).multiply3(a),h={x2:u.x,y2:u.y},c=new j(u.x,u.y).sub(this.vectorCenter()),l=this.vectorStart().sub(this.vectorCenter())}let p=l.cross(c)>0?0:1;delete this.data.temp,this.data.temp={...this.data,large:p,...h},this.render(this.data.temp)}moveControlPoint(i,r,n){let s=this.data.type;if(this.centerSelected){let a=de.translate(i,r);mr.syncArc(k.getArc(this.data.gId),a,{updateD:n.updateD||!1});return}if(this.middleAnchorSelected)return this.moveMiddleAnchor(i,r,n);if(n.ctrl){s===1?this.forTwoArc(i,r,n):this.forCenterArc(i,r,n);return}2===s?this.forTwoArc(i,r,n):this.forCenterArc(i,r,n)}vectorCenter(){return new j(this.cx,this.cy)}startAngle(){return tr(-this.vectorStart().angleD2(this.vectorCenter()))}endAngle(){return tr(-this.vectorEnd().angleD2(this.vectorCenter()))}setArcType(i){return this.data.type=i,this}setStart(i,r){return this.startAnchorSelected=!0,this.forTwoArc(i-this.data.x1,r-this.data.y1,{updateD:!0}),this}setEnd(i,r){return this.endAnchorSelected=!0,this.forTwoArc(i-this.data.x2,r-this.data.y2,{updateD:!0}),this}setRadius(i,r,n){i=i||this.data.rx,r=r||this.data.ry;let s=de.rotateD(-this.data.angle).scale(i/this.data.rx,r/this.data.ry).rotateD(this.data.angle).setOrigin1(n||this.vectorCenter());return mr.syncArc(this.data,s,{updateD:!0}),this}setData(){return k.setArc(this.data.gId,this.data),this}render(i){i=i||this.data,ri.renderer.attr(i.gId,"d",e.getD(i))}static getLoverArcId(i){return i+"-lover"}static removeHalfArc(i){i=this.getLoverArcId(i),y4([i])}static createHalfArc(i){if(wt.isEditingPath()!==i)return;let{json:r,cmdKey:n}=k.getById(i);if(n!=="arc")return;let s=jt(r.temp||r);s={...r,...s},s.sweep=s.sweep===0?1:0,s.large=s.large===1?0:1,s.opacity=.3,s.gId=this.getLoverArcId(i);let a=Rn.arc(s);ri.renderer.removeNode(s.gId);let o=Rs(a);H.gCanvas.appendChild(o),ri.renderer.attr(s.gId,"pointer-events","none"),o.classList.add(Vl)}static getD(i){return["M",i.x1,i.y1,"A",i.rx,i.ry,i.angle,i.large,i.sweep,i.x2,i.y2].join(" ")}};var lD=class{constructor(){this.id="highlight-ele";this.containerId="container-for-create-stroke";this.currentHoverEle=null;this.debouncedAppendSelectStroke=nl(()=>{var i;let t=(i=k.selectedRepeater)==null?void 0:i.getSelfSelectMap();this.appendSelectStroke(t).emptyLastHoverEle().removeHighlightStroke()},0)}appendSelectStroke(t=k.selectedRepeater.getChangeMap(),i=!0){let r=le(this.containerId),n=document.createDocumentFragment(),s=this;return t.forEach((u,h)=>{let{cmdKey:d,color:p}=u,f=le(h);if(f)switch(p!=null&&p.startsWith("--")&&(p=`var(${p})`),d){case"text":let m=f.querySelector(".primitive-text");p||(p=k.getById(h).json.strokeColor),l(m,"fill",p);break;case"auxiliaryPoint":p||(p=k.getAuxiliaryPoint(h).fillColor),l(f,"fill",p);break;case"auxiliaryLine":p||(p=k.getAuxiliaryLine(h).strokeColor),l(f,"stroke",p);break;case"dimension":p!=null&&p.startsWith("var")&&(p=""),o(f,"--dimensionConstraintColor",p);break;case"dimensionLength":case"dimensionAngle":case"dimensionRadius":p!=null&&p.startsWith("var")&&(p=""),o(f,"--normalDimensionColor",p);break;case"arc":case"obj":case"rect":case"group":case"circle":case"ellipse":a(h,p);break}}),r.appendChild(n),this;function a(u,h){let d="select-for-"+u,p=le(d);if(i&&(c("#"+d),p=null),h&&p)p.setAttribute("stroke",h);else if(h){let f=le(u);if(!f)return;let m=s.createOneStroke(f,h);m.id=d,n.appendChild(m)}else p&&c("#"+d)}function o(u,h,d){u&&d?u.style.setProperty(h,d):u&&u.style.removeProperty(h)}function l(u,h,d){u&&d?u.setAttribute(h,d):u&&u.removeAttribute(h)}function c(u){Hr(u).forEach(h=>h.remove())}}removeHighlightStroke(){return dt(_r(`[id^="${this.id}"]`)),this}removeCombinationElmsHighlightStroke(){return dt(Hr(`[id^="${this.id}"]`)),this}refreshHighlightStroke(){let t=Hr(`[id^="${this.id}"]`);this.emptyLastHoverEle(),this.removeCombinationElmsHighlightStroke(),t.forEach(i=>{let r=i.id.replace(`${this.id}-`,""),n=le(r);n&&this.createHighlightStyle(n)})}emptyLastHoverEle(){return this.currentHoverEle=null,this}removeHighlightById(t){Hr(`[id$="${t}"]`).forEach(r=>r.remove())}emptySelectContainer(){return Mi().forEach(t=>{var r;let{cmdKey:i}=k.getById(t.id);if(!["text","auxiliaryLine","auxiliaryPoint","dimension","dimensionLength","dimensionAngle","dimensionRadius"].includes(i)){let n="select-for-"+t.id;(r=le(n))==null||r.remove()}}),this}createOneStroke(t,i="--selectColor"){let{json:r,cmdKey:n}=k.getById(t.id),{matrix:s}=r;i.startsWith("--")&&(i=`var(${i})`),s=s||[1,0,0,1,0,0];let a={id:`${this.id}-${t.id}`,fill:"none","stroke-width":2,"pointer-events":"none",stroke:i,"vector-effect":"non-scaling-stroke",transform:`matrix(${s.join(",")})`},o;switch(n){case"ellipse":{o=Et("ellipse",{cx:0,cy:0,rx:1,ry:1,...a});break}case"obj":{o=Et("rect",{x:0,y:0,width:1,height:1,...a});break}case"rect":{let{width:l,height:c,matrixArr:u}=Li.getRectFromMatrix(s);o=Et("rect",{x:0,y:0,width:l,height:c,rx:r.rx,ry:r.ry,...a,transform:`matrix(${u})`});break}case"group":{let l=r.d;delete a.transform,o=Et("path",{d:l,...a});break}case"arc":{let l=_i.getD(r);delete a.transform,o=Et("path",{d:l,...a});break}default:return}return o.style.pointerEvents="none",o}createHighlightStyle(t,i=!1){if(t===this.currentHoverEle||(this.currentHoverEle=t,i||this.removeHighlightStroke(),!t))return;let r=this.createOneStroke(t,"--highlight");if(!r)return;le(this.containerId).appendChild(r),_r}shouldRemoveHighlight(t){this.currentHoverEle&&this.currentHoverEle.id===t&&this.removeHighlightStroke().emptyLastHoverEle()}removeCombinationHighLight(){this.removeCombinationElmsHighlightStroke().emptyLastHoverEle()}},pi=new lD;var lw=class{constructor(t){this.objs=t;this.deleted=!1}do(t=!1){let i=ar.anchorOrHandleHasSelected();if(i&&i.type!=="bbox"){let u=le(i.id);Nd.deletePathNode(u,i),dl();return}let r=this.objs,n=ts.findDimensionByPrimitiveIds(new Set(r.map(u=>u.id))).map(u=>le(u.gId));if(r.push(...n),!r.length)return;let s=r.map(u=>u.id),{combinations:a,elements:o}=new rt().getSelectedCombinations(s);if(Gi.hasCombinationLocked(a)||Gi.hasEleLocked(o)){qa();return}let l=new oi(r),c=[];for(let u=0;u<r.length;u++){let h=r[u];c.push(k.getById(h.id).json),h&&k.removeOne(h)}for(let u of a)c.push(k.getById(u).json),k.deleteCombInParent(u),this.deleteCombinationAndChild(u);return t?(l.update(),k.freshItemOrder()):l.updateAndSave(),this.deleted=!0,c}isDeletedSuccess(){return this.deleted}deleteCombinationAndChild(t){let{combinations:i}=k.getCombination(t);k.setCombination(t);for(let r of i)this.deleteCombinationAndChild(r)}},j1=class extends lw{};j1=Ws([Pa(Sn.delete)],j1);function jo(e,t=!1){e=e||Mi();let i=e.map(u=>u.id),r=new rt,{combinations:n}=r.getSelectedCombinations(i),s=[],a=new Set(i);for(let u of n){let{elements:h,name:d,id:p}=k.getCombination(u);s.push(p+(d?":"+d:""));for(let f of h)a.add(f)}let o=Array.from(a).map(u=>le(u)),l=t?new lw(o):new j1(o),c=l.do(t);return l.isDeletedSuccess()&&r.deleteCombinationToast(s),c.forEach(u=>pi.removeHighlightById(u.gId)),c}var cw=null,cD=class{constructor(){}getSelectDependMaskMode(t){if(!wt.isEleCanSelect(t))return Nn(k.getById(t).cmdKey)?[{id:t}]:[];let i=new rt,r=i.searchCombination(t);if(this.isEditing()){if(!r)return Nn(k.getById(t).cmdKey)?[{id:t}]:[];let s=this.getCurrentEditingComId();if(s===r)return[le(t)];if(!i.findFamily(r).getAllParents().includes(s))return[];let a=i.findFamily(r,s).peekParent();return[...i.getAllElesfromTop(a).elements].map(l=>le(l))}if(r){let s=i.findFamily(r).peekParent();if(!this.isCombCanSelect(s))return[]}return[...i.findAllEleByOneEle(t)].map(s=>le(s))}findCombinationElementsById(t){let i=new rt,r=i.searchCombination(t);if(!r)return[];let n=this.getCurrentEditingComId();if(r===n)return[];if(n&&!i.findFamily(r).getAllParents().includes(n))return[];let s=i.findFamily(r,n).peekParent();return this.isCombCanSelect(s)?i.getAllElesfromTop(s).elements:fE}isCombCanSelect(t){let i=k.getCombination(t);return!(!Xa()["all-state"].lock.checked&&i.locked)}isEditing(){return!!cw}setEditing(t){return t?(cw=t,new Ni().updateHole()):(cw=null,new Ni().removeMask()),this}deleteCombinations(t){let i=this.selectCombinations(t);if(i.length===0){let r=new oi;for(let n of t)k.deleteCombInParent(n),r.addOneCombineByComId(n),k.setCombination(n);r.updateAndSave();return}jo(i)}selectCombinations(t){let i=new Set,r=new rt;for(let s of t){let a=r.getAllElesfromTop(s).elements;for(let o of a)i.add(o)}let n=Array.from(i).map(s=>le(s));return Ae.select(n),fr(n,{create8Dots:!0}),n}getCurrentEditingComId(){return cw}isEleCanSelect(t){if(!this.isEditing())return!0;let i=this.getCurrentEditingComId();return new rt().getAllElesfromTop(i).elements.has(t)}},Wt=new cD;var uD=class{constructor(){this.currentRecords=new Map;this.currentEditingPath=null;this.insertAnchorIndex=-1;this.insertAnchorId="insert-anchor"}toggleMode(t){let i=this.currentRecords.get(t);this.currentRecords.set(t,i==="self"?"box":"self"),this.currentRecords.get(t)==="box"&&ar.hideAll()}startEditPath(t){this.toggleMode(t),this.currentRecords.get(t)==="box"?this.endEditingPath():(this.setCurrentEditingPath(t),_i.createHalfArc(t))}setCurrentEditingPath(t){this.currentEditingPath=t,new Ni().updateHoleForPath(t)}isEleCanSelect(t){let i=this.isEditingPath();return i?i===t:!0}isEditingPath(){return this.currentEditingPath}endEditingPath(){if(this.currentEditingPath&&this.currentRecords.set(this.currentEditingPath,"box"),_i.removeHalfArc(this.currentEditingPath),this.currentEditingPath=null,new Ni().removeMask(),Wt.isEditing()){let t=Wt.getCurrentEditingComId();Wt.setEditing(t)}}isAnchorMode(t){return this.currentRecords.get(t)==="self"}is8DotsMode(t){let i=this.currentRecords.get(t);return i==="box"||!i}addOrRemoveHandle(t){let i=Mi()[0],r=this.getAnchorInfo(i),n=r.length,{json:s}=k.getById(i.id),a=jt(s),o=Vn(i),l=!1;for(let c=1;c<n;c++){let u=r[c-1],h=r[c];if(t===u.index){if(u.type==="M")switch(h.type){case"C":{h.d="C "+u.x+" "+u.y+" "+h.x2+" "+h.y2+" "+h.x+" "+h.y;let d=this.getPathD(r);te(i,"d",d),s.d=d,l=!0;break}default:console.error(h.type);break}else if(u.type==="C")switch(h.type){case"C":u.d="C "+u.x1+" "+u.y1+" "+u.x+" "+u.y+" "+u.x+" "+u.y,h.d="C "+u.x+" "+u.y+" "+h.x2+" "+h.y2+" "+h.x+" "+h.y;let d=this.getPathD(r);te(i,"d",d),s.d=d,l=!0;break;default:console.error(u);break}else console.error(u.type);if(l){let d=Qr(i.id,{cmdKey:"group",refId:o},a,s);ms(i),Ke.save(d);break}}}pi.removeHighlightStroke().emptyLastHoverEle().emptySelectContainer()}getPathSegment(t){function i(n){for(let s of n)if(Number.isNaN(s)||ft(s)){console.error(s);debugger}return n}let r=[];switch(t.type){case"M":r.push("M",t.x,t.y);break;case"L":r.push("L",t.x,t.y);break;case"C":r.push("C",t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;default:console.error(t);break}return i(r).join(" ")}getPathD(t,i,r){let n="";for(let s=0;s<t.length;s++){let a=t[s];n=n+" "+a.d,this.getPathSegment(a),s===i&&(n=n+" "+r.d)}return n}getPoints(t){let i=[];for(let r of t)switch(r.type){case"M":case"L":i.push(r.x,r.y);break;case"C":i.push(r.x1,r.y1,r.x2,r.y2,r.x,r.y);break;default:console.error(r);break}return i}removeMiddleAnchor(){return dt(this.hoverCreatedAnchorEle),this.insertAnchorIndex=-1,this}updateD(){let t=this.lastHoverGroup;return te(t,"d",this.hoveredD),ms(t),this.insertAnchorIndex}createHoverAnchor(t,i,r){if(!t){this.insertAnchorIndex>-1&&this.removeMiddleAnchor();return}if(this.is8DotsMode(t.id)||k.getById(t.id).cmdKey!=="group")return;this.lastHoverGroup=t;let{start:n,end:s,anchorInfo:a}=this.findWhichSegment(t,i,r),o=a[n],l=a[s],c=l.type;switch(c){case"L":{if(o.index+1===this.insertAnchorIndex)return;this.removeMiddleAnchor();let u=(o.x+l.x)/2,h=(o.y+l.y)/2,d=ar.createHoverAnchor(u,h,this.insertAnchorId);this.hoverCreatedAnchorEle=d;let p=this.getPathD(a,n,{x:u,y:h,type:"",d:`L ${u} ${h} `,index:-1});this.hoveredD=p,this.insertAnchorIndex=o.index+1;break}case"C":{if(o.index+3===this.insertAnchorIndex)return;this.removeMiddleAnchor();let u="M "+o.x+" "+o.y+" "+l.d,p=qi(u)[0].primitives[0].clip(.5),f=p[0].controls,m=p[1].controls,g=ar.createHoverAnchor(f[3].x,-f[3].y,this.insertAnchorId);this.hoverCreatedAnchorEle=g,this.insertAnchorIndex=o.index+3,l.d="C "+f[1].x+" "+-f[1].y+" "+f[2].x+" "+-f[2].y+" "+f[3].x+" "+-f[3].y,l.d+=" "+m[1].x+" "+-m[1].y+" "+m[2].x+" "+-m[2].y+" "+m[3].x+" "+-m[3].y;let b=this.getPathD(a);this.hoveredD=b;break}case"Q":{if(o.index+2===this.insertAnchorIndex)return;this.removeMiddleAnchor();let h=new Ye([new j(o.x,o.y),new j(l.x1,l.y1),new j(l.x,l.y)]).clip(.5),d=h[0].controls,p=h[1].controls,f=ar.createHoverAnchor(d[2].x,d[2].y,this.insertAnchorId);this.hoverCreatedAnchorEle=f,this.insertAnchorIndex=o.index+2,l.d=" Q  "+d[1].x+" "+d[1].y+" "+d[2].x+" "+d[2].y,l.d+=" Q "+p[1].x+" "+p[1].y+" "+p[2].x+" "+p[2].y;let m=this.getPathD(a);this.hoveredD=m;break}default:console.error(c,"check code");break}}findWhichSegment(t,i,r){let n=this.getAnchorInfo(t),s=n.length,a=Number.MAX_SAFE_INTEGER,o=1;for(let l=1;l<s;l++){let c=n[l-1],u=n[l],h;switch(u.type){case"L":h=ra({x:i,y:r},c,u).d;break;case"M":break;case"C":case"Q":{let d="M "+c.x+" "+c.y+" "+u.d,f=qi(d)[0].primitives[0],m=[];f.getBezierPoints(1,function(g){m.push(g)}),h=a;for(let g of m){let b=Ro(i,r,g.x,-g.y);h=Math.min(h,b)}}break;default:console.error("plz check "+u.type);break}h<a&&(a=h,o=l)}return{start:o-1,end:o,anchorInfo:n}}clickShowSegmentHandle(t,i,r){if(!t||this.is8DotsMode(t.id)||k.getById(t.id).cmdKey!=="group")return;let{start:n,end:s,anchorInfo:a}=this.findWhichSegment(t,i,r),o=[a[n].index,a[s].index];ar.showHandleOfIndexes(o)}getMirrorPoint(t,i){let r=i.x-t.x,n=i.y-t.y;return{x:t.x-r,y:t.y-n}}handleFollowHandle(t,i,r){let n=i.newP.distance1(t)/i.oldP.distance1(t),s=i.newP.angleD(t)-i.oldP.angleD(t),a=r.angleD(t),o=de.translate(-t.x,-t.y).rotateD(-a);return r.multiply3(o).multiply3(de.scale(n,1).rotateD(s+a).translate1(t))}getAnchorInfo(t){let i=t.pathSegList,r=i.numberOfItems,n=0,s=0,a=0,o=0,l=[],c,u,h=new Map,d=[],p=[],f=0;for(let m=0;m<r;m++){let g=i.getItem(m),b=g.pathSegType;m===0&&b!=Dr&&b!=Vr&&b!=si&&(console.warn(g,b),d.push({x:n,y:s,index:f,type:""}));let y=d.length-1;switch(b){case si:n=a,s=o;break;case Dr:{if(n=g.x,s=g.y,a=n,o=s,m+1==r||(u=i.getItem(m+1),c=u.pathSegType,c==Dr||c==Vr||c==si))break;let S=`M ${n} ${s} `;d.push({x:n,y:s,index:f++,type:"M",d:S});break}case Vr:if(n+=g.x,s+=g.y,a=n,o=s,m+1==r||(c=i.getItem(m+1).pathSegType,c==Dr||c==Vr||c==si))break;p.push(n,s);break;case mn:{if(d.push({x:g.x,y:g.y,index:f++,type:"L",d:` L ${g.x} ${g.y} `}),m+1==r)break;u=i.getItem(m+1),c=u.pathSegType,c==si&&(u=i.getItem(0)),c==mn||c==si;break}case Po:d.push({x:g.x,y:s,index:++f,type:""});break;case Lo:d.push({x:n,y:g.y,index:++f,type:""});break;case Ao:l.push({from:y,to:y+1,belong:y},{from:y+2,to:y+3,belong:y+3}),h.set(y+1,{belong:y}),h.set(y+2,{belong:y+3}),++f,++f;let E=" C "+[g.x1,g.y1,g.x2,g.y2,g.x,g.y].join(" ");d.push({x:g.x,y:g.y,x1:g.x1,y1:g.y1,x2:g.x2,y2:g.y2,index:f++,type:"C",d:E});break;case Co:l.push({from:y+1,to:y+2}),p.push(g.x2,g.y2,n=g.x,s=g.y);break;case Do:{l.push({from:y,to:y+1,belong:y},{from:y+1,to:y+2,belong:y+2}),h.set(y+1,{belong:[y,y+2]}),p.push(g.x1,g.y1,n=g.x,s=g.y),++f;let S=" Q "+g.x1+" "+g.y1+" "+g.x+" "+g.y+" ";d.push({x:g.x,y:g.y,x1:g.x1,y1:g.y1,index:f++,type:"Q",d:S});break}case _o:case Ya:if(p.push(n=g.x,s=g.y),m+1==r)break;u=i.getItem(m+1),c=u.pathSegType,c==si&&(u=i.getItem(0)),c==mn||c==si;break;case Ul:p.push(n+=g.x,s+=g.y);break;case Gl:p.push(n+=g.x,s);break;case Yl:p.push(n,s+=g.y);break;case Ml:l.push({from:y,to:y+1},{from:y+2,to:y+3}),p.push(n+g.x1,s+g.y1,n+g.x2,s+g.y2,n+=g.x,s+=g.y);break;case Bl:l.push({from:y+1,to:y+2}),p.push(n+g.x2,s+g.y2,n+=g.x,s+=g.y);break;case kl:l.push({from:y+1,to:y+2}),p.push(n+g.x1,s+g.y1,n+=g.x,s+=g.y);break;case Fl:case Nl:p.push(n+=g.x,s+=g.y);break;default:break}}return d}},wt=new uD;var rt=class{constructor(){}modifyCombination(t){let i=new oi;for(let r of t){let n=r.combId;i.addOneCombineByComId(n);let s=k.getCombination(n);Va(r.parent)||(s.parent=r.parent);let a=new Set([...s.elements,...r.add||[]]);for(let l of r.remove||[])a.delete(l);s.elements=Array.from(a);let o=new Set([...s.combinations,...r.addComb||[]]);for(let l of r.removeComb||[])o.delete(l);s.combinations=Array.from(o);for(let l of s.combinations)i.addOneCombineByComId(l),k.getCombination(l).parent=n}i.updateAndSave()}removeFromGroup(t){let i="",r="";Array.isArray(t)||(t=Ae.getIds());let n=new oi;for(let s of t){let a=this.searchCombination(s);if(!a)continue;n.addOneCombineByComId(a);let o=k.getCombination(a);r=o.id||o.gId,i=o.name;let l=o.elements.indexOf(s);o.elements.splice(l,1),Ae.unselect(le(s))}n.updateAndSave(),qt(),new Ni().updateHole(),or("updateAttrPanel"),ls({value:"{0} element removed from the group:group{idWithName}",options:{0:t.length,idWithName:r.replace("e","")+(i?`:${i}`:"")}},"success")}getSelectedCombinations(t){let i=Oa(),r=new Map;for(let a of i)if(a.combinationId)for(let o of a.elements)r.set(o,a.combinationId);let n=new Set,s=new Set;for(let a of t)r.has(a)?s.add(r.get(a)):n.add(a);return{combinations:s,elements:n}}getSelectedCombinations2(t){let i=Oa(),r=new Map;for(let a of i)if(a.combinationId)for(let o of a.elements)r.set(o,a.combinationId);let n=new Set,s=new Set;for(let a of t)r.has(a)&&s.add(r.get(a)),n.add(a);return{combinations:s,elements:n}}combineWhenEditComb(t){let{combinations:i,elements:r}=this.getSelectedCombinations(t),n=Ot(),s=Wt.getCurrentEditingComId(),a=k.getInitialCombinationData({gId:n,elements:Array.from(r),combinations:Array.from(i),parent:s}),o=new oi;o.addOneCombineByComId(n,{}),o.addOneCombineByComId(s),k.setCombination(n,a);let l=k.getCombination(s);for(let c of r)l.elements.splice(l.elements.indexOf(c),1);for(let c of i){let u=k.getCombination(c);u.parent=n,l.combinations.splice(l.combinations.indexOf(c),1)}l.combinations.push(n);for(let c of r)o.addOneCombine(c);o.updateAndSave(),this.afterCombine(r.size+i.size)}combine(){let t=is(Mi()).map(o=>o.id);if(!t.length)return;if(Wt.isEditing())return this.combineWhenEditComb(t);let i=new Set,r=new Set;for(let o of t){let l=this.searchCombination(o);if(!l)i.add(o);else{let c=this.findFamily(l).peekParent();r.add(c)}}let n=Ot(),s=k.getInitialCombinationData({gId:n,elements:Array.from(i),combinations:Array.from(r)});k.setCombination(n,s);let a=new oi;a.addOneCombineByComId(n,{});for(let o of r){a.addOneCombineByComId(o);let l=k.getCombination(o);l.parent=n}a.updateAndSave(),this.afterCombine(i.size+r.size)}afterCombine(t){t!==0&&(ls({value:"{0} objects grouped successfully",options:{0:t}},"success"),Ce("panel_updateAttrPanel"))}deleteCombinationToast(t){t.length!==0&&ls({value:"Group {0} deleted grouped successfully",options:{0:t.join("\u3001")}},"success")}deleteEmptyCombination(t){let i=new oi;for(let r of t)i.addOneCombineByComId(r),k.setCombination(r);i.updateAndSave()}unCombine(){let t=new Set,i=Ae.getIds(),r=new oi,n=new Set,s=[];for(let o of i){let l=this.searchCombination(o);if(l){let c=Wt.getCurrentEditingComId(),u=this.findFamily(l,c).peekParent();if(u===c)continue;n.add(u),r.addOneCombineByComId(u)}}if(n.size===0)return;for(let o of n){let l=k.getCombination(o);t.add(o);let c=this.findParent(o);c&&(c.combinations.splice(c.combinations.indexOf(o),1),c.elements.push(...l.elements),c.combinations.push(...l.combinations));for(let h of l.combinations)k.getCombination(h).parent=c?c.id:null;let u=k.getCombination();delete u[o],s.push("Combination"+l.id.replace("e","")+(l.name?`:${l.name}`:""))}r.updateAndSave();let a=Array.from(t);ls({value:"{num} Ungrouped successfully:{groupIdWithNames}",options:{num:a.length,groupIdWithNames:s},translateOptionKeys:["groupIdWithNames"],translateIndexOfArray:"all"},"success"),Ce("panel_updateAttrPanel"),Ni.updateHole()}unCombineAllEmpty(){let t=this.getAllEmptyCombinations();this.deleteEmptyCombination(t),ls({value:"Successfully cancel all empty group"},"success")}unCombineAll(){let t=!1,i=new oi;k.iteratorCombination(r=>{t=!0,i.addOneCombineByComId(r.gId),k.setCombination(r.gId)}),t&&(i.updateAndSave(),ls({value:"Successfully cancel all group"},"success"),Wt.setEditing(null),wt.endEditingPath())}joinGroup(t){let i=k.getCombination(t).name,r=Ae.getIds();r=is(r.map(l=>le(l))).map(l=>l.id);let{elements:n,combinations:s}=this.getSelectedCombinations(r),a=[],o=k.getCombination(t).id||t;for(let l of n){let c=this.searchCombination(l);c!==t&&(c&&a.push({combId:c,remove:[l]}),a.push({combId:t,add:[l]}))}for(let l of s){let c=k.getCombination(l);t!==c.parent&&t!==l&&(this.findFamily(t).getAllParents().includes(l)||(c.parent&&a.push({combId:c.parent,removeComb:[l]}),a.push({combId:l,parent:t},{combId:t,addComb:[l]})))}a.length!==0&&(this.modifyCombination(a),Ae.unselectAll(),Ae.select(r.map(l=>({id:l}))),ls({value:"{0} objects join group successfully:group{idWithName}",options:{0:n.size+s.size,idWithName:o.replace("e","")+(i?`:${i}`:"")}},"success"),Wt.isEditing()&&(new Ni().updateHole(),qt()))}peekParent(){return this.parent.at(-1)}findFamily(t,i=null){let r=k.getCombination(t),n=[t];for(;r.parent&&r.parent!==i;)r=k.getCombination(r.parent),n.push(r.gId);return this.parent=n.filter(s=>s),this}getAllParents(){return this.parent}findParent(t){let i=k.getCombination(t);return i.parent?k.getCombination(i.parent):null}searchCombination(t){let i;return k.iteratorCombination(r=>{if(r.elements.includes(t))return i=r.gId,fh}),i}findAllEleByOneEle(t){let i=new Set([t]),r=this.searchCombination(t);if(!r)return i;let n=this.findFamily(r).peekParent(),s=this.getAllElesfromTop(n).elements;for(let a of s)i.add(a);return i}getAllElesfromTop(t){let i=new Set,r=new Set,n=k.getCombination(t);if(Object.keys(n).length===0)throw new Error("Cannot find combinationData!");for(let s of n.elements)i.add(s);for(let s of n.combinations){r.add(s);let{elements:a,combinations:o}=this.getAllElesfromTop(s);for(let l of a)i.add(l);for(let l of o)r.add(l)}return{elements:i,combinations:r}}getAllChildEles(t,i=new Set){let{elements:r,combinations:n}=k.getCombination(t);for(let s of r)i.add(s);if(n.length>0)for(let s of n)this.getAllChildEles(s,i);return i}pasteCombination(t,i,r,n=[]){for(let a of i){t.addOneCombineByComId(a.gId,{});let o=[];for(let c of a.combinations)r.has(c)&&o.push(r.get(c));a.combinations=o;let l=[];for(let c of a.elements)r.has(c)&&l.push(r.get(c));a.elements=l,a.parent&&(a.parent=r.get(a.parent)||null),k.setCombination(a.gId,a)}let s=[];for(let a of n){t.addOne(k.getById(a.id).json,{});let o=Wt.getCurrentEditingComId();if(o){let l=k.getCombination(o);t.addOneCombineByComId(o);let c=this.searchCombination(a.id);if(c){let u=this.findFamily(c).peekParent();l.combinations=[...new Set(l.combinations).add(u)],s.push([u,o])}else l.elements.push(a.id)}}for(let[a,o]of s)k.getCombination(a).parent=o}getAllCombinationData(t){let i=new Set,r=[];for(let n of t){let s=Wt.getCurrentEditingComId(),a=this.findFamily(n,s).getAllParents();for(let o of a){if(i.has(o))continue;i.add(o);let l=k.getCombination(o);r.push(l)}}return r}getAffectedCombinations(t){let i=new Map,r=[],n=new Set;for(let a of t){let o=this.searchCombination(a);if(o){let l=Wt.getCurrentEditingComId(),c=this.findFamily(o,l).getAllParents();for(let u of c)n.has(u)||(n.add(u),r.push(k.getCombination(u)))}}let s=[];for(let a of r){let o=structuredClone(a);o.gId=Ot(),s.push(o),i.set(a.gId,o.gId)}return{oldIdMapNewId:i,copiedCombination:s}}getAllEmptyCombinations(){let t=[];return k.iteratorCombination(({gId:i})=>{!this.getAllChildEles(i).size&&t.push(i)}),[...t]}};var hD=class{constructor(){}getTree(t=null){let i=[];return k.iteratorCombination(r=>{r.parent===t&&i.push({id:r.gId,displayId:r.id,name:r.name,children:this.getTree(r.gId),elements:r.elements})}),i}};function z1(e=null){return new hD().getTree(e)}function q5(){function e(r){let n=k.getItemOrder();r.forEach(s=>{let a=k.getCombination(s.id);s.type="CombinationGroup",s.visible=a.visible,s.eyeGrayType=ai.isCombinaionEyeGray(s.id),s.lock=a.locked,s.text=a.id||a.gId;let o=[],l=[];n.forEach(c=>{s.elements.includes(c)&&l.push(c)}),l.reverse().forEach(c=>{let u=k.getById(c),h=u.cmdKey;h==="group"&&(h="shape"),h==="arc"&&(h="elliptical Arc"),h==="obj"&&(h="image");let d={id:c,type:h.slice(0,1).toUpperCase()+h.slice(1),visible:u.json.visible,lock:u.json.locked,text:u.json.id||u.json.gId,eyeGrayType:ai.isEyeGray(u.json,u.cmdKey),name:u.json.name};o.push(d)}),s.elesData=o,s.children.length>0&&e(s.children)})}let t=z1();return e(t),{name:"Combination",type:"Combination",visible:!0,list:t,iconColor:"",i18n:!0}}function Oa(){let e=new rt,t=Wt.getCurrentEditingComId(),i=z1(t),r=new Set,n=[];for(let a of i){let o=e.getAllElesfromTop(a.id).elements;for(let c of o)r.add(c);let l=k.getCombination(a.id);n.push({elements:Array.from(o),combinationId:a.id,selectable:!l.locked})}let s=k.getItemOrder();for(let a of s)r.has(a)||n.push({elements:[a]});return n}var q2=class{constructor(){this.allCombLevelElements=Oa()}getAllCombLevelElements(){return this.allCombLevelElements}getPrimitiveMapComb(){let t=new Map;for(let{elements:i,combinationId:r}of this.allCombLevelElements)for(let n of i){let{cmdKey:s}=k.getById(n);t.set(n,{id:n,cmdKey:s,combinationId:r})}return t}};function Du(e){te((e==null?void 0:e.target)||H.selectBox1,{display:"none"})}function h1(e,t,i,r,n){te((n==null?void 0:n.target)||H.selectBox1,{display:"",width:Math.abs(i),height:Math.abs(r),x:Math.min(e,e+i),y:Math.min(t,t+r),stroke:H.panelThemeCache.color.select,visible:"visible"})}function oD(e,t=""){let i=le("selection-polygon");te(i,{points:e,class:Ae.unselectableClass,display:t,stroke:H.panelThemeCache.color.select})}function aD(){let e=En.selectionMode;if(!["polygonInside","polygonOutside"].includes(e))return;let i=le("selection-polygon"),r=H3(i.points);oD("","none");let n=e==="polygonOutside",s=Oa();for(let a of s){let o=!1;for(let l of a.elements){let c=ec(le(l)),{x:u,y:h,width:d,height:p}=c,f=[{x:u,y:h},{x:u,y:h+p},{x:u+d,y:h},{x:u+d,y:h+p}];if(o=Fee(f,r),o)break}o=n?!o:o;for(let l of a.elements)En.selectElement(le(l),o,!0)}}function Fee(e,t){let i=0;for(let r of e)mh(r,t)&&i++;return e.length===i}var yl=class yl extends yn{constructor(){super();this.start=!1}getSymbol(){return ii.drag_select_area_tool}static canSwitchMe(i){var u;let{canvasX:r,canvasY:n,originalEvent:s}=i,a=z2(s);!((u=H.profileSetting)!=null&&u.commSystemSetting.PANEL_CANVAS.is_ctrl_drag_to_drag)&&i.ctrlKeyDown&&(a=void 0);let l=!a;return rf(r,n)&&(l=!1),this.clickedCanvas=l,l}install(i){console.log(this.getSymbol(),"installed");let r=i.originalEvent;if($t(r.target)!=="cdot"&&!Os.isAdaptAreaSelectionView()){var n=ui(r,!1);yl.ready=!0,this.x0=n.x,this.y0=n.y,this.dx=0,this.dy=0,this.x1=this.x0,this.y1=this.y0,dl()}}uninstall(){console.log(this.getSymbol(),"uninstalled")}ondrag(i,r){if(r.dx===0||r.dy===0){Du();return}h1(r.x0,r.y0,r.dx,r.dy)}static handlePolylineSelection(){let i=yl.selectionMode;if(!["lineTouched"].includes(i))return;let n=le("selection-polyline");if(n.points.numberOfItems<2)return;let s=Oa();for(let a of s){let o;for(let l of a.elements){let c=ec(le(l));if(o=B3(n,c),o)break}for(let l of a.elements)yl.selectElement(le(l),o,!0)}yl.showSelectPolyline("","none")}static showSelectPolyline(i,r=""){let n=le("selection-polyline");return te(n,{points:i,class:Ae.unselectableClass,display:r}),n}static selectElement(i,r,n){Ae.isSelected(i)!==r&&(n?r&&Ae.select([i]):Ae.toggle([i],r))}ondragend(i,r){if(Du(),Ar.cancel(),!this.start)return;let n=yl.selectionMode==="rectangleOutside",s={x:Math.min(r.x0,r.x0+r.dx),y:Math.min(r.y0,r.y0+r.dy),width:Math.abs(r.dx),height:Math.abs(r.dy)},a=qi(Yo({matrix:[s.width,0,0,s.height,s.x,s.y]})),o=Oa();for(let l of o){if(l.combinationId&&k.getCombination(l.combinationId).visible===!1)continue;let c;for(let u of l.elements){let{cmdKey:h,json:d}=k.getById(u),p=vi(d);if(r.dx>0)c=Rm(p,s);else{if(Nn(h))c=EB(s,d);else{let f;h==="text"?f=qi(Yo({matrix:[p.width,0,0,p.height,p.x,p.y]})):f=Ri.convertData2Polyline([d])[0],f.some(g=>a.some(b=>rB(g,b)))&&(c=!0)}c=c||Rm(p,s)}if(c)break}c=n?!c:c;for(let u of l.elements)yl.selectElement(le(u),c,i.ctrlKey)}}onMouseLeftUp(i){if(i.toolFinished=!0,yl.clickedCanvas=!1,!yl.ready)return;let r=i.originalEvent;this.ondragend(r,this),this.start=!1,setTimeout(()=>{yl.ready=!1}),Ce("panel_updateAttrPanel"),Ce("updateMenuByDocStatus"),Ce("panel/updateTreeActiveElements")}onMouseMove(i){let r=i.originalEvent;var n=this;if(yl.ready){Ar.tryStart(i);var s=ui(r,!1),a=s.x,o=s.y,l=a-n.x0,c=o-n.y0;if(!n.start){if((l*l+c*c)*H.gZoom*H.gZoom<9)return;n.start=!0}n.x1=a,n.y1=o,n.dx=l,n.dy=c,this.ondrag(r,this)}}};yl.ready=!1;var En=yl;function qd(e="",t){if(En.selectionMode!==e){switch(En.selectionMode=e,e){case"polygonInside":case"polygonOutside":{ku("draw(polygon)");break}case"lineTouched":{ku("draw(polyline)",t);break}case"rectangleInside":case"rectangleOutside":return H.frameHelper.getToolProcessor().switchToRectSelectTool();case"continuousSelection":{pr("cross-red"),xs();return}case"":{pr(),xs();return}default:throw new Error(`DragSelectAreaTool: Unknown SelectionMode ${e}`)}En.selectionMode=e}}function Rg(){return En.selectionMode}function uw(e,t,i,r,n=""){let s=le("selection-rect");te(s,{x:e,y:t,width:i,height:r,display:n})}function J5(){let e=En.selectionMode;if(!["rectangleOutside","rectangleInside"].includes(e))return;let r=le("selection-rect").getBBox();uw(0,0,0,0,"none");let n=e==="rectangleOutside",s=Oa();for(let a of s){let o=!1;for(let l of a.elements){let c=ec(le(l));if(Rm(c,r)){o=!0;break}}o=n?!o:o;for(let l of a.elements){let c=le(l);En.selectElement(c,o,!0)}}}var hn=10,X1=1,K5=.8,$5=.4,dD=class{getGridPointRadius(t){return X1/t}getGridPointSVGHTML(t=Ge.adsorbGrid.gridSize||5,i=X1){return`<path type="dot" opacity="${$5}" d="${this.getGridPointPathDFor1(t,i)}"/><path type="dot" opacity="${K5}" d="${this.getGridPointPathDFor10(t,i)}"/>`}getGridLineSVGHTML(t=Ge.adsorbGrid.gridSize||5){return`<path type="line" opacity="${$5}" d="${this.getGridLinePathDFor1(t)}"/><path type="line" opacity="${K5}" d="${this.getGridLinePathDFor10(t)}"/>`}getGridPointPathDFor10(t=Ge.adsorbGrid.gridSize||5,i=X1){return[this.getGridPointDByXY(-i,-i,i),this.getGridPointDByXY(-i+t*hn,-i,i),this.getGridPointDByXY(-i,-i+t*hn,i),this.getGridPointDByXY(-i+t*hn,-i+t*hn,i)].join(" ")}getGridPointPathDFor1(t=Ge.adsorbGrid.gridSize||5,i=X1){let r=[];for(let n=0;n<hn+1;n++)for(let s=0;s<hn+1;s++)(n===0||n===hn)&&(s===0||s===hn)||r.push(this.getGridPointDByXY(t*n-i,t*s-i,i));return r.join(" ")}getGridPointDByXY(t,i,r=X1){let n=2*r;return`M ${t} ${i} L ${t+n} ${i} ${t+n} ${i+n} ${t} ${i+n} ${t} ${i}`}getGridLinePathDFor10(t=Ge.adsorbGrid.gridSize||5){return`M 0 0 L 0 ${t*hn} M 0 0 L ${t*hn} 0 M 0 ${t*hn} L ${t*hn} ${t*hn} M ${t*hn} 0 L ${t*hn} ${t*hn}`}getGridLinePathDFor1(t=Ge.adsorbGrid.gridSize||5){let i=[];for(let r=1;r<hn;r++)i.push(`M 0 ${t*r} L ${hn*t} ${t*r} M ${t*r} 0 L ${t*r} ${t*hn}`);return i.join(" ")}},qo=new dD;var fD=(i=>(i.Portrait="Portrait",i.Landscape="Landscape",i))(fD||{}),Gee=["393mmx579mm"],pD=class{static getBBoxAttr(){return{title:"Overall Transformation",attr:this.selectBBox}}static checkSelectBBoxAttr(t){for(let i in this.selectBBox)if(t[i])return!0;return!1}};pD.selectBBox={"attr-bbox-x":{componentType:"text-input",title:"X Location"},"attr-bbox-y":{componentType:"text-input",title:"Y Location"},"attr-bbox-width-height-pair":{componentType:"width-height-pair",widthTitle:"Width",heightTitle:"Height"},"attr-bbox-rotation":{componentType:"text-input",title:"Rotation",calcu:!0}};var Uee={"attr-x-y":{componentType:"point",title:"X/Y",calcu:!0}},Yee={"reference-point":{componentType:"nine-grid",title:"Reference Point"}},Uu={"attr-rotation":{componentType:"text-input",title:"Rotate",calcu:!0}},Jd={"attr-conceal":{componentType:"select",title:"Hide",options:[{text:"Yes",value:"yes"},{text:"No",value:"no"}]}},gf={"attr-locked":{componentType:"select",title:"Locked",options:[{text:"Yes",value:"yes"},{text:"No",value:"no"}]}},Kd=(e={})=>({"attr-name":{componentType:"text-input",type:"text-input",title:"Name",...e}}),$d={"attr-id":{componentType:"text-input",type:"text-input",title:"ID"}},Z5={"attr-hide":{componentType:"select",title:"Valid",options:[{text:"Yes",value:"no"},{text:"No (The production file is not output)",value:"yes"}]}},hw={"attr-start":{componentType:"point",type:"number-input-xy-row",title:"StartPosition X/Y",calcu:!0}},dw={"attr-end":{componentType:"point",title:"EndPosition X/Y",calcu:!0}},Vee={"attr-dimension-object":{componentType:"text-area",type:"text-area-dimension",title:"Object"}},Hee={"attr-length":{componentType:"text-input",type:"text-input",title:"Length"}},jee={"attr-radius":{componentType:"text-input",calcu:!0,type:"number-input",title:"Round Angle"}},zee={"attr-width-height-pair":{componentType:"width-height-pair",widthTitle:"Width",heightTitle:"Height"}},Hg={"attr-obb-width-height-pair":{componentType:"width-height-pair",widthTitle:"Width",heightTitle:"Height"}},yf={...Yee,...Uee,...zee},Zd=(e={})=>({"attr-layer":{componentType:"select",type:"layer",title:"Layer",...e}}),Q5={"attr-scope":{type:"scope",title:"Scope",options:["Print and White Background","Print Layer","White Background"]}},W1={...Kd(),...$d,...Zd(),"attr-cover":{componentType:"select",type:"yes-no",title:"Cover",options:[{text:"Yes",value:"yes"},{text:"No",value:"no"}]},...Q5,"attr-transparency":{componentType:"text-input",type:"text-input",title:"Transparency(Print,White)"},...Z5,...Jd,...gf},ek={...Kd(),...$d,...Zd(),...Jd,...gf},Xee={...Kd(),...$d,...Zd(),...Jd,...gf},Wee={"attr-fill-stroke-pair":{componentType:"fill-stroke-pair",fillTitle:"Fill Color",strokeTitle:"Stroke Color"}},qee={"attr-stroke-width":{componentType:"text-input",type:"number-input",title:"Line Width",calcu:!0}},pw={...Wee,...qee},Jee=[{title:"Basic Info",attr:W1},{title:"Transformation",attr:yf},{title:"Style",attr:{...Hg,...Uu,...pw}}],Kee=[{title:"Basic Info",attr:W1},{title:"Transformation",attr:yf},{title:"Style",attr:{...Hg,"attr-short-long-radius":{componentType:"width-height-pair",widthTitle:"ShortRadius",heightTitle:"LongRadius"},...Uu,...pw}}],$ee=[{title:"Basic Info",attr:W1},{title:"Transformation",attr:yf},{title:"Style",attr:{...Hg,...jee,...Uu,...pw}}],Zee=[{title:"Basic Info",attr:{...Kd(),...$d,...Zd({disabled:!1}),...Jd,"attr-dimension-category":{componentType:"select",title:"Types",options:["Annotation","Constraint"]}}},{title:"Style",attr:{...Vee,"attr-dimension":{componentType:"text-input",calcu:!0,title:"Length"}}}],Qee=[{title:"Basic Info",attr:Xee},{title:"Style",attr:{...hw,...dw,...Uu,...Hee}}],ete={"attr-angle":{componentType:"text-input",title:"Angle"}},tte={"attr-dimension-angle":{componentType:"point",title:"AnglePoint X/Y",calcu:!0}},ite=[{title:"Basic Info",attr:ek},{title:"Style",attr:{...tte,...hw,...dw,...Uu,...ete}}],rte=[{title:"Basic Info",attr:ek},{title:"Style",attr:{...hw,...dw,"attr-short-radius":{type:"text-input",title:"ShortRadius",disabled:!0},"attr-long-radius":{type:"text-input",title:"LongRadius",disabled:!0},...Uu}}],nte={"attr-arc-type":{type:"select",title:"Arc Type",options:["Center Arc","Two Points Arc"]}},ste={"attr-circle-center":{componentType:"point",title:"CircleCenter X/Y",calcu:!0},...hw,...dw,...Hg,"attr-short-long-radius":{componentType:"width-height-pair",widthTitle:"ShortRadius",heightTitle:"LongRadius"},"attr-start-angle":{componentType:"text-input",title:"Start Arc Angle"},"attr-end-angle":{componentType:"text-input",title:"End Arc Angle"},...Uu},ate=[{title:"Basic Info",attr:{...W1,...nte}},{title:"Transformation",attr:yf},{title:"Style",attr:{...ste,...pw}}],tk={"attr-x":{componentType:"text-input",type:"number-input",title:"X Location"}},ik={"attr-y":{componentType:"text-input",type:"number-input",title:"Y Location"}},rk={"attr-stroke-style":{componentType:"select",title:"Line Style",options:VB()}},nk={"attr-color":{componentType:"color",resetColor:!0,title:"Color"}},ote=[{title:"Basic Info",attr:{...Kd(),...$d,...Zd(),...Jd,...gf}},{title:"Style",attr:{...tk,...ik,...nk,...rk}}],lte=[{title:"Basic Info",attr:{...Kd(),...$d,...Zd(),...Jd,...gf}},{title:"Style",attr:{...tk,...ik,...nk,...rk}}],cte=[{title:"Basic Info",attr:{"attr-textarea":{type:"text-area",title:"Text"},...$d,...Zd(),...Q5,"attr-transparency":{type:"text-input",title:"Transparency(Print,White)"},...Z5,...Jd,...gf}},{title:"Transformation",attr:yf},{title:"Style",attr:{...Hg,...Uu,"attr-font-color":{componentType:"color",title:"Font Color"},"attr-font-family":{componentType:"select",type:"font-family",title:"Font"},"attr-font-size":{componentType:"text-input",type:"number-input",title:"Font Size"},"attr-font-style":{type:"style",title:"Style"},"attr-origin":{componentType:"nine-grid",title:"Origin"}}}],ute=[{title:"Basic Info",attr:W1},{title:"Transformation",attr:yf},{title:"Style",attr:{...Hg,...Uu}}],hte=[{title:"Basic Info",attr:{...Kd(),...$d,...Jd,...gf}},{title:"Transformation",attr:yf},{title:"Style",attr:{...Uu}}],wYe={canvas:[{title:"Page",attr:{...Kd({disabled:!0}),"attr-background-color":{type:"color",title:"Background Color"},"attr-material":{type:"select",title:"Material",options:["acrylic","PVC"]},"attr-thickness":{type:"select",title:"Thickness",options:["0.8mm","1.0mm","1.5mm","2.0mm","2.5mm","3.0mm"]},"attr-craft":{type:"select",title:"Surface Technology",options:["Transparent","Black Translucent"]},"attr-print":{type:"select",title:"Print Type",options:["Bottom Side","Ahead Side"]},"attr-cover-color":{type:"select",title:"Cover",options:["white","black"]},...Zd({disabled:!0}),"attr-direction":{type:"select",title:"Direction",options:Object.values(fD)},"attr-widthxheight":{type:"select",title:"Width X Height",options:Gee},"attr-remark":{type:"text-input",title:"Remark"}}}],obj:ute,group:Jee,text:cte,arc:ate,rect:$ee,ellipse:Kee,auxiliaryLine:ote,auxiliaryPoint:lte,combination:hte,dimension:Zee,dimensionLength:Qee,dimensionAngle:ite,dimensionRadius:rte};var sk={line:{modifyProp:"stroke"},dot:{modifyProp:"fill"}};function jg(e,t,i){if(!ft(t)){t=t%360;for(let r of e)switch(r.cmdKey){case"rect":Li.syncRectByRotation(t,r,i);break;case"ellipse":Ei.syncEllipseByRotation(t,r,i);break;case"arc":mr.rotate(r,t,i);break;case"group":zn.syncGroupWithRotation(r,t,i);break;case"text":xr.syncTextWithRotation(r,t,i);break;case"obj":Lr.syncImageByRotation(t,r,i);break;case"dimensionAngle":new bn(r).rotateSelf(t,i);break;case"dimensionLength":new xn(r).rotateSelf(t,i);break;case"dimensionRadius":new cn(r).rotateSelf(t,i);break;case"auxiliaryPoint":new Ng(r).rotateSelf(t,i);break;default:console.error(r);break}}}function is(e){return e.filter(t=>{let{cmdKey:i}=k.getById(t.id);return!Nn(i)})}function oo(){return Ka.isDragging||En.ready}function rc(e,t,i){let r=i?.1:H.zoomRatio.min;if(e=Math.max(e,r),e=Math.min(e,H.zoomRatio.max),H.currZoom===e)return;let n=H.gZoom;H.currZoom=e,H.gZoom=e/100;var s=Xt.getViewBox(),a=+te(H.svgRoot,"width"),o=+te(H.svgRoot,"height");if(t=t||{},!$e(t,"clientX")){var l=es(H.gCanvas);let h={x:l.width?l.x+l.width/2:l.x||s[0]+s[2]/2,y:l.height?l.y+l.height/2:l.y||s[1]+s[3]/2};t.clientX=(h.x-s[0])*a/s[2],t.clientY=h.y*o/s[1]}let c=1/n-1/H.gZoom,u=[s[0]+t.clientX*c,s[1]+t.clientY*c,a/H.gZoom,o/H.gZoom];return Ar.canStart=!1,Xt.setViewBox(u),pte(e,u),mw(u)}function mw(e){let[t,i,r,n]=e;return St.extendRect({x:t,y:i,width:r,height:n})}var pte=nl(function(e,t){ac(),H.windowBridge.publish("ui/canvasInfo",{tabId:H.tabId,scaleValue:+(H.gZoom*100||0).toFixed(2),unitValue:"unit(mm)"},ut()),new Ni().zoom();var i=H.gZoom===1?1:lt(100/e+1e-5,5),r=.5/H.gZoom,n=function(d){return d/H.gZoom};let s=gw(),a=le("gridCell");if(te(a,{transform:de.toDOMMatrix(de.scale(s/Ge.adsorbGrid.gridSize))}),te(le("gridPattern"),{width:s*hn,height:s*hn,x:Ge.canvas.originX,y:Ge.canvas.originY}),Ge.adsorbGrid.gridType==="dot"){let d=s/Ge.adsorbGrid.gridSize*H.gZoom,p=qo.getGridPointRadius(d),[f,m]=Hr("path",a);te(f,{d:qo.getGridPointPathDFor1(void 0,p)}),te(m,{d:qo.getGridPointPathDFor10(void 0,p)})}te(le("gridOH"),{"stroke-width":i,y1:Ge.canvas.originY+r,y2:Ge.canvas.originY+r}),te(le("gridOV"),{"stroke-width":i,x1:Ge.canvas.originX+r,x2:Ge.canvas.originX+r});var o=Math.max(i*4,1);o=Math.min(o,2);var l;for(l=0;l<ak.length;l++)te(ak[l],{r:4*i});ar.zoom(4*i*2),ic.zoom(),xn.zoom(),bn.zoom(),cn.zoom(),(function(d,p){if(d){var f=d.sheet.cssRules[0];f&&(f.style.strokeWidth=p)}})(le("px1Style"),i);let c=Hr("#gCursors>image");for(l=0;l<c.length;l++){var u=H.helperCursorConfig[c[l].id];if(u&&u.trs){var h=H.gZoom==1?u.trs:u.trs.replace(/-?[\d.]+/g,n);te(c[l],{width:u.width/H.gZoom,height:u.height/H.gZoom,transform:h})}}window.frameElement&&window.frameElement.setAttribute("winzoom",String(e)),bt.clearCrossFlagCache(),bt.adsorptionHTMLZoom(),Hr('[c_partid="auxiliaryPoint"]',H.gCanvas).forEach(d=>og(d,ph/H.gZoom))}),fw=-1;function gw(e){let t=e||+Ge.adsorbGrid.gridSize;for(;t*H.gZoom<10;)t*H.gZoom*2>=10?t*=2:t*H.gZoom*5>=10?t*=5:t*=10;if(H.gZoom<1){let i=Ge.adsorbGrid.gridSize;fw===15/.254?fw=20/.254:fw=15/.254,t=Math.max(1,Math.floor(fw/H.gZoom/i))*i}return t}function pl(e){if(e==document)return null;for(;e&&e.parentNode!=H.gCanvas;)e=e.parentNode;return e}function qa(e){H.windowBridge.publish("openPanelDialog",{ids:e,whichDialog:"drag-warn"},ut())}function U1(e,t,{saveHistory:i=!0}=R0){if(oo())return;let r=Gi.hasEleLocked(e.map(a=>a.id));if(r){qa([r]);return}e=e.filter(function(a){let{cmdKey:o}=k.getById(a.id);return!(Gi.isLockedById(a.id)||o==="dimension")});let n=()=>{Mh(e,t.x,t.y),$a(e)};i?zt.wrapDo(n):n();let s=is(e);return s.length&&fr(s,{create8Dots:!0}),pi.appendSelectStroke(),!0}function ok(e,t){let i=Qn.getSanpSize("X"),r=Qn.getSanpSize("Y"),n=Mi();U1(n,new j(i*e,r*t))}function eD(e){let t=co(Mi());if(t.length===0)return;let i=zt.createContext(!0);for(let n of t)Ke.jsonSnap.addOne(k.getById(n.id).json);let r=fo(t,!0,{ignoreSnap:!0});new gl(t).mirror(!!+e,r),i(),t=is(t),t.length&&fr(t,{create8Dots:!0}),pi.appendSelectStroke()}function Hc(e,t){if(!e.length){console.error(e,t);return}let i=t||-90;i=i>0?i-360:i,pi.emptyLastHoverEle().emptySelectContainer().removeHighlightStroke();let r=e.filter(s=>{let{cmdKey:a}=k.getById(s.id);return a!=="dimension"}),n=fo(r,!1,{ignoreSnap:!0});for(let s of e){let{json:a}=k.getById(s.id);jg([a],i+(a.rotation||0),new j(n.x,n.y))}}function _5(e){let t;e[0]instanceof Element?t=e:t=zg({ids:e});let i=t.length;if(!i)return;let r=[];for(let n=i-1;n>=0;n--){let s=t[n],a=s.parentNode;if(s!=a.lastChild){let o=k.getRefId(s.id),l=Qe.getLastEleByLayerId(te(s,"layer"));if(!l||l===s)continue;let c=l.nextSibling,u=k.getById(s.id).json,h=u.zIndex,d=k.getById(l.id).json;u.zIndex=d.zIndex+1,a.insertBefore(s,c);let p=c==null?void 0:c.id;r.push(["elePosition",s.id,o,p]),r.push(["json",s.id,{cmdKey:u.cmdKey,refId:p},{zIndex:h},{zIndex:u.zIndex}])}}r.length&&Ke.save(r)}function P5(e){let t=zg({ids:e}),i=t.length;if(!i)return;let r=[];for(let n=i-1;n>=0;n--){let s=t[n],a=s.parentNode;if(s!=a.firstChild){let o=k.getRefId(s.id),l=Qe.getFirstEleByLayerId(te(s,"layer"));if(!l||l===s)continue;let c=k.getById(s.id).json,u=c.zIndex,h=k.getById(l.id).json;c.zIndex=h.zIndex-1,a.insertBefore(s,l);let d=l.id;r.push(["elePosition",s.id,o,l.id]),r.push(["json",s.id,{cmdKey:c.cmdKey,refId:d},{zIndex:u},{zIndex:c.zIndex}])}}r.length&&Ke.save(r)}function fte(e,t){if(e==t)return 0;let i=e.compareDocumentPosition(t);return i&Node.DOCUMENT_POSITION_DISCONNECTED?0:i&Node.DOCUMENT_POSITION_PRECEDING?1:-1}function zg(e){let{ids:t,includeLocked:i,reverse:r}=e||{};t&&typeof t!="string"&&!Array.isArray(t)&&(t=void 0);let n=Array.isArray(t)?t:t?[t]:[],a=t?(o=>Array.from(Hr("#"+o.join(",#"),H.gCanvas)))(n):Mi();return a=a.filter(o=>!!o),i||(a=a.filter(function(o){return!Gi.isLockedById(o.id)})),t||a.sort(fte),r&&a.reverse(),a}function L5(e){let t=zg({ids:e,reverse:!0}),i=[];for(let r of t){let n=Qe.getNextSameLayerNode(r);if(n&&!t.includes(n)){let s=n.id||"",a=Qe.getNextSameLayerNode(n),o=(a==null?void 0:a.id)||"",l=k.getById(r.id).json,c=l.zIndex,{zIndex:u}=k.getById(s).json||{},{zIndex:h=u+2}=k.getById(o).json||{};l.zIndex=(u+h)/2,c===l.zIndex?lk(l,r,i,"raise"):i.push(["json",r.id,{cmdKey:l.cmdKey,refId:o},{zIndex:c},{zIndex:l.zIndex}]);let d=k.getItemOrder().find(f=>{let m=k.getById(f).json;return f!==l.gId&&l.zIndex<m.zIndex}),p=_r(`#${d}`);r.parentNode.insertBefore(r,p||a),i.push(["elePosition",r.id,s,o])}}i.length&&Ke.save(i)}function O5(e){let t=zg({ids:e}),i=[];for(let r of t){let n=Qe.getPrevSameLayerNode(r);if(n&&!t.includes(n)){let s=r.nextElementSibling,a=(s==null?void 0:s.id)||"",o=n.id||"",l=Qe.getPrevSameLayerNode(n),c=k.getById(r.id).json,u=c.zIndex,{zIndex:h}=k.getById(o).json||{},{zIndex:d=h-2}=k.getById(l==null?void 0:l.id).json||{};c.zIndex=(h+d)/2,u===c.zIndex?lk(c,r,i,"lower"):i.push(["json",r.id,{cmdKey:c.cmdKey,refId:o},{zIndex:u},{zIndex:c.zIndex}]),r.parentNode.insertBefore(r,n),i.push(["elePosition",r.id,a,o])}}i.length&&Ke.save(i)}function lk(e,t,i,r){let n=r==="raise"?1:-1,{zIndex:s}=e,a=Qe.getZIndexMap(),o=a.get(s),l=o.findIndex(p=>p===e.gId);o.splice(l+n,0,o.splice(l,1)[0]);let c=[...a.keys()].sort((p,f)=>p-f),u=c.find((p,f)=>c[f+1]===s)||s-1,d=((c.find(p=>p>s)||s+1)-u)/(o.length+1);o.forEach((p,f)=>{var b;let m=k.getById(p).json;m.zIndex=u+d*(f+1);let g=o[f+1]||((b=Qe.getNextSameLayerNode(_r(`#${p}`)))==null?void 0:b.id);i.push(["json",p,{cmdKey:m.cmdKey,refId:g||""},{zIndex:s},{zIndex:m.zIndex}])})}var ak=[];function w5(e){e.head.version=m2,k.gJsonCache=e,te(window.frameElement,"jsonCacheReady",!0)}var Nd=class{static isShowContextMenu({target:t,type:i,button:r}){return this.canDeleteDot(t)&&$t(t)==="cdot"&&i==="mouseup"&&r===2}static canDeleteDot(t){return te(t,"class")!=="light"}static deletePathNode(t,i){let r=t.id;if(!r)return;let n=Ae.get()[0],s,a;if(Gi.isLockedById(n.id)||!n||!Vs(n.parentNode,ko)||!t||t.parentNode!=H.gControlDots||te(t,"class")=="light"||n.tagName!="path"&&n.tagName!="polyline"&&n.tagName!="polygon")return;let o=+r.substr(4);if(s=H.gControlDots.children[1],s&&(te(s,"class")=="light"||te(s,"visibility")=="hidden")&&(o=o>>1),(d=>d.tagName==="path")(n)){if(i&&i.type==="anchor"&&n.pathSegList.numberOfItems<=2)return;let d=Vn(n),p=Qr(n.id,{cmdKey:"group",refId:d},k.getById(n.id).json);if(ck(n,o),n.getTotalLength()<.01)jo([n]);else{ms(n);let f=k.getById(n.id).json;f.d=te(n,"d"),p[4]=jt(f),Ke.save(p)}return}var c=n,u=c.points,h=u.numberOfItems;h<=2||o>=0&&o<h&&(a=["attr",c.id,{points:te(c,"points")}],u.removeItem(o),ms(c),a[3]={points:te(c,"points")},Ke.save(a))}};function co(e){let t=[];for(let i of e){let r=k.getById(i.id).cmdKey;if(r=="dimension"&&k.getDimension(i.id).category=="Constraint")return ts.toastMsg(),[];["dimension","auxiliaryLine","auxiliaryPoint"].includes(r)||t.push(i)}if(!t.length)return[];if(e.length>1){let i=new Vo().findDimensionByPrimitiveId(new Set(e.map(r=>r.id)));for(let r of i)if(k.getDimension(r).category=="Constraint")return ts.toastMsg(),[]}return e}var kh=class kh{static bringObjsToFront(t){let i;t[0]instanceof Element?i=t:i=zg({ids:t});let r=i.length,n=[],s=this.getFirstEleByLayerId(8);if(r)for(let a=r-1;a>=0;a--){let o=i[a],l=o.parentNode;if(o!=l.lastChild){let c=o.nextElementSibling?o.nextElementSibling.id:"";l.insertBefore(o,s),n.push(["elePosition",o.id,c,""])}}return n}static getCurrentScheme(){return this.currentScheme}static async init({docType:t,tabId:i}){let r=(await Ho("getActiveLayerSetting",[{docType:t,tabId:i}])).message;this.apply(r)}static switch(t){this.currentScheme=t}static get activeLayer(){return this._activeLayer}static setActiveLayer(t){this._activeLayer=t}static apply(t,i){this.patch(t),this.switch(t),this.applyActive(i),this.applyLocked(),this.applyVisible()}static resetDefaultScheme(){this.removeActived()}static getLayerPreviousLayer(t){var s;let i=new Uo;Vg().reverse().forEach(a=>{i.addLast(a)});let n=i.iterator();do{let{value:a}=n;if(a.item===t)return(s=a.prev)==null?void 0:s.item;n.next()}while(n.hasNext())}static makeLayerHoming(t){let i=this._activeLayer?this._activeLayer:8;if(t===i)return zI;let r=this,n=[],s=new DocumentFragment;Hr(`[layer="${t}"]`,H.gCanvas).forEach(h=>{var p;let d=((p=h.nextSibling)==null?void 0:p.id)||"";n.push(["elePosition",h.id,d,""]),s.append(h)});let o,l;c(t);function c(h){o=r.getLayerPreviousLayer(h),o&&(o===i||!(l=_r(`[layer="${o}"]`,H.gCanvas)))&&c(o)}l||(l=_r(`[layer="${i}"]`,H.gCanvas));let u=l?h=>{l.before(h)}:h=>{H.gCanvas.append(h)};return[...s.children].forEach(u),n}static applyActive(t){let{actived:i}=this.recorder,r=this.activeLayer;for(let n in i){if(i[n]){this.setActiveLayer(+n),this.removeActived();let s=this.getFirstEleByLayerId(8);k.getItemOrder().forEach(a=>{var l;if(((l=k.getById(a).json)==null?void 0:l.layer)===this._activeLayer){let c=_r(`#${a}`);H.gCanvas.insertBefore(c,s)}});break}if(Object.keys(i).length===1&&!i[n]){this.setActiveLayer(null);break}}}static removeActived(){let t=k.getItemOrder(),i=null;for(let r=t.length-1;r>=0;r--){let n=_r(`#${t[r]}`);n&&(H.gCanvas.insertBefore(n,i),i=n)}}static applyLocked(){let{locked:t}=this.recorder;for(let i in t){let r=[...Hr(`[layer="${i}"]`,H.gCanvas)],n=t[i];r.forEach(s=>ia(s,Ae.unselectableClass,n))}}static applyVisible(){let{visible:t}=this.recorder;for(let i in t)+i===-1&&new Ja().display(t[i]);k.iterator(i=>{ft(i.layer)||ai.applyElementsVisible(i.gId)})}static patch(t){let{recorder:i}=this;i.actived=Object.create(null),i.locked=Object.create(null),i.visible=Object.create(null);let{options:r}=t;for(let{visible:n,locked:s,actived:a,id:o}of r)i.visible[o]=n,i.locked[o]=s,a&&(i.actived[o]=a)}static appendTargetLayer(t,i=kh.activeLayer,r=!0,n={}){var l;let s=n.cmdKey||$t(t);q1[s].includes(+i)||(r&&H.windowBridge.publish("ui/toastMsg",{type:"warn",msg:mte[s],timer:3},ut()),i=1),this.switchLayer(t,i);let{visible:a,locked:o}=((l=this.currentScheme)==null?void 0:l.options.find(({id:c})=>+i==+c))||{};ia(t,Ae.unselectableClass,o)}static getTargetPlaceLayer(t){return q1[t].includes(kh.activeLayer)?kh.activeLayer:1}static switchLayer(t,i){var l,c;let r=[],n=((l=t==null?void 0:t.nextElementSibling)==null?void 0:l.id)||"",s="",a=Vg(),o=kh.getLastEleByLayerId(i);if(o)s=(c=o.nextElementSibling)==null?void 0:c.id,H.gCanvas.insertBefore(t,o.nextElementSibling);else{let u=a.indexOf(i);for(let h=u+1;h<a.length;h++){let d=this.getFirstEleByLayerId(a[h]);if(d){o=d,s=d.id;break}}i===8&&!o||o||(o=kh.getFirstEleByLayerId(this.activeLayer),s=o==null?void 0:o.id),H.gCanvas.insertBefore(t,o)}return r.push(Ke.createElePosition(t.id,n,s)),r}static getZIndexMap(){let t=k.getItemOrder(),i={};t.forEach(n=>{let{zIndex:s}=k.getById(n).json;E4(i,s).push(n)});let r=new Map;return Object.keys(i).forEach(n=>r.set(Number(n),i[n])),r}static getFirstEleByLayerId(t){let r=H.gCanvas.firstChild;for(;;){if(!r)return null;if(+te(r,"layer")==+t)return r;r=r.nextSibling}}static getLastEleByLayerId(t){let r=H.gCanvas.lastChild;if(!r)return null;for(;;){if(+te(r,"layer")==+t)return r;if(r=r.previousSibling,!r)return null}}static getNextEleById(t){let i=k.getItemOrder(),r=TS(),{layer:n,zIndex:s}=k.getById(t).json,a=this._activeLayer===n,o=i.find(l=>{let{layer:c,zIndex:u}=k.getById(l).json;if(c===n)return u>s&&_r(`#${l}`);if(!a&&n!==8){let h=r.get(c),d=r.get(n);return h>d&&_r(`#${l}`)}});return o?_r(`#${o}`):null}static getNodeLayer(t){return+te(t,"layer")}static getNextSameLayerNode(t){let i=this.getNodeLayer(t),r=t.nextSibling;if(!r)return null;for(;;){if(this.getNodeLayer(r)===+i)return r;if(r=r.nextSibling,!r)return null}}static getPrevSameLayerNode(t){let i=this.getNodeLayer(t),r=t.previousSibling;if(!r)return null;for(;;){if(this.getNodeLayer(r)===+i)return r;if(r=r.previousSibling,!r)return null}}};kh._activeLayer=null,kh.recorder=Object.create(null);var Qe=kh,mte={obj:"Images can only be placed on the print layer",text:"Texts can only be placed on the print layer or the opacity layer"};var wg="selected",mD="highlight",uk="object-unselectable",hk=nl(()=>{var e;(e=k.selectedRepeater)==null||e.updateChange(),pi.appendSelectStroke(),ac(void 0,hf())},0);function gte(e){let t=e.id;if(!Ae.isUnselectAble(t))return go.select(t),ia(le(t),wg,!0),hk(),!0}function yw(e){go.unselect(e.id),ia(e,wg,!1),hk()}function bw(e){Vs(e,uk)||ia(e,mD,!0)}function xw(e){ia(e,mD,!1)}var Ae=class{static isUnselectAble(t){let i=Xa(),{json:r,cmdKey:n}=k.getById(t);if(!r)return!0;let s=wt.isEditingPath();if(s&&t!==s&&!Nn(n))return!0;let{layer:a,hide:o,gId:l,locked:c}=r;if(i["all-element-type"][d1(n)].checked===!1||ai.eleIsHide(r)||i["all-state"].hide.checked===!1&&o||i["all-state"].visible.checked===!1&&!o||i["all-state"].lock.checked===!1&&c||i["all-state"].unlock.checked===!1&&!c)return!0;let{options:u}=Qe.getCurrentScheme();for(let h of u)if(+h.id==+a&&h.locked)return!0;return!1}static count(){return go.get().size}static select(t){for(let i=0,r=t.length;i<r;i++){let n=t[i];this.isSelected(n)||this.combinationSelectById(n.id)}}static combinationSelectById(t){if(!Wt.isEleCanSelect(t)&&!Nn(k.getById(t).cmdKey)||!wt.isEleCanSelect(t)&&!Nn(k.getById(t).cmdKey))return;let i=Wt.findCombinationElementsById(t);if(i!==fE){for(let r of i)ia(le(r),wg,!0),go.select(r);gte({id:t})}}static unselect(t){if(t){if(t.nodeType==1)yw(t);else if(t.length)for(var i=0,r=t.length;i<r;i++)yw(t[i])}}static unSelectById(t){go.unselect(t)}static highlight(t){if(t){if(t.nodeType==1)bw(t);else if(t.length)for(var i=0,r=t.length;i<r;i++)bw(t[i])}}static unhighlight(t){if(t){if(t.nodeType==1)xw(t);else if(t.length)for(var i=0,r=t.length;i<r;i++)xw(t[i])}}static toggleHighlight(t,i){if(t){if(t.nodeType==1)i===!0?bw(t):i===!1&&xw(t);else if(t.length)for(var r=0,n=t.length;r<n;r++)i===!0?bw(t[r]):i===!1&&xw(t[r])}}static isSelected(t){return ai.eleIsHide(k.getById(t.id).json)?!1:go.isSelect(t.id)}static toggle(t,i){for(let r=0,n=t.length;r<n;r++)i===!0?this.select([t[r]]):i===!1?yw(t[r]):i===void 0&&(go.isSelect(t[r].id)?yw(t[r]):this.select([t[r]]))}static unselectAll(){return go.get().clear(),this}static get(){let t=go.get(),i=[];for(let r of t){let n=_r("#"+r,H.gCanvas);n?i.push(n):(console.error("no dom, Plz check code",r),go.unselect(r))}return i}static getIds(){return[...go.get()]}};Ae.highlightClass=mD,Ae.selectClass=wg,Ae.unselectableClass=uk;var Ew=class{constructor(){this.selectIds=new Set}select(t){if(!Ac(t))throw new Error(t);this.selectIds.add(t)}unselect(t){if(!Ac(t))throw new Error(t);this.selectIds.delete(t)}isSelect(t){if(!Ac(t))throw new Error(t);return this.selectIds.has(t)}get(){return this.selectIds}getIds(){return[...this.selectIds]}clear(){this.selectIds.clear()}},go=new Ew,Xg=new Ew;function dk(e,t){let i=new _i(e),r=i.vectorCenter(),n=vi(e,"arc"),s=fi.transferXYByReference(n),a=new j(s[0],s[1]);for(let[o,l]of Object.entries(t))switch(o){case"attr-width":mr.syncArcSize(e,a,l,null);break;case"attr-height":mr.syncArcSize(e,a,null,l);break;case"attr-arc-type":i.setArcType(l==="Two Points Arc"?2:1).render();break;case"attr-start-x":i.setStart(l,e.y1);break;case"attr-start-y":i.setStart(e.x1,l);break;case"attr-end-x":i.setEnd(l,e.y2);break;case"attr-end-y":i.setEnd(e.x2,l);break;case"attr-short-radius":i.setRadius(void 0,l,a).render();break;case"attr-long-radius":i.setRadius(l,void 0,a).render();break;case"attr-circle-center-x":{let c=de.translate(l-r.x,0);mr.syncArc(e,c,{updateD:!0})}break;case"attr-circle-center-y":{let c=de.translate(0,l-r.y);mr.syncArc(e,c,{updateD:!0})}break;case"attr-start-angle":i.setAngle(-l,"start").render();break;case"attr-end-angle":i.setAngle(-l,"end").render();break;case"attr-rotation":{mr.rotate(e,-l,a);break}case"attr-x":{let c=de.translate(l-s[0],0);mr.syncArc(e,c,{updateD:!0})}break;case"attr-y":{let c=de.translate(0,l-s[1]);mr.syncArc(e,c,{updateD:!0})}break;default:console.error(o,"Plz check code");break}}function pk(e,t){let i=new cn(e),r=fo([le(e.gId)],!0,{ignoreSnap:!0});for(let[n,s]of Object.entries(t))switch(n){case"attr-start-x":i.setHeadFree(s,e.y1);break;case"attr-start-y":i.setHeadFree(e.x1,s);break;case"attr-end-x":i.setTailFree(s,e.y2);break;case"attr-end-y":i.setTailFree(e.x2,s);break;case"attr-rotation":i.rotateSelf(-t[n],new j(r.x,r.y));break}i.setData().render()}function fk(e,t){let i=new bn(e);Object.keys(t).forEach(r=>{let n=t[r];switch(r){case"attr-start-x":i.setStart(n,e.y1);break;case"attr-start-y":i.setStart(e.x1,n);break;case"attr-end-x":i.setEnd(n,e.y2);break;case"attr-end-y":i.setEnd(e.x2,n);break;case"attr-dimension-angle-x":i.setAngle(n,e.angleY);break;case"attr-dimension-angle-y":i.setAngle(e.angleX,n);break;case"attr-angle":i.setAngleDeg(n);break;case"attr-rotation":i.rotateSelf(-t[r],null);break;default:break}}),i.setData().render()}function mk(e,t){let i=new xn(e),r=fo([le(e.gId)],!0,{ignoreSnap:!0});for(let n of Object.keys(t))switch(n){case"attr-start-x":i.setStart(t[n],e.y1);break;case"attr-start-y":i.setStart(e.x1,t[n]);break;case"attr-end-x":i.setEnd(t[n],e.y2);break;case"attr-end-y":i.setEnd(e.x2,t[n]);break;case"attr-length":i.updateDistance(t[n]);break;case"attr-rotation":i.rotateSelf(-t[n],new j(r.x,r.y));return}i.calcuMeasurePoint().setData().render()}function gk(e,t){let i=vi(t,"ellipse"),r=fi.transferXYByReference({...i,x:e["attr-x"]||i.x,y:e["attr-y"]||i.y}),n=new j(r[0],r[1]);if($e(e,"attr-x")||$e(e,"attr-y")){let s=fi.transferXYByReference({...i,x:e["attr-x"],y:e["attr-y"]},!0);Ei.syncEllipsePosition(t,s[0],s[1])}if(($e(e,"attr-width")||$e(e,"attr-height"))&&Ei.syncEllipseSize(t,e["attr-width"],e["attr-height"],n),$e(e,"attr-rotation")){let s=fi.transferXYByReference(i),a=new j(s[0],s[1]),o=e["attr-rotation"];Ei.syncEllipseByRotation(-o,t,a,{beautify:!0})}($e(e,"attr-short-radius")||$e(e,"attr-long-radius"))&&Ei.syncEllipseRadius(t,e["attr-short-radius"],e["attr-long-radius"],n)}async function yk(e,t){let i=le(t.gId),r=new J2(i),n=sf(t),s=fi.transferXYByReference({...n,x:e["attr-x"],y:e["attr-y"]},!0);xr.syncTextPosition(t,s[0],s[1]);let a=fi.transferXYByReference({...n}),o=new j(a[0],a[1]);($e(e,"attr-width")||$e(e,"attr-height"))&&xr.syncTextSize(t,e["attr-width"],e["attr-height"],o);for(let l in e){let c=e[l];switch(l){case"attr-textarea":if(c)await r.name(c);else{jo([i]);return}break;case"attr-font-color":t.strokeColor=c,r.strokeColor(c);break;case"attr-font-family":await r.fontFamily(c);break;case"attr-origin":let[u,h]=a2(c);xr.syncTextWithOrigin(t,u,h),t.hAlign=u,t.vAlign=h;break;case"attr-font-weight":await r.fontWeight(c);break;case"attr-font-style":await r.italic(c);break;case"attr-font-underline":await r.underline(c);break;case"attr-font-size":await r.fontSize(c);break;case"attr-reset-text":xr.resetText(i);break;case"attr-rotation":xr.syncTextWithRotation(t,-c,o);break;case"attr-width":case"attr-height":case"attr-obb-width":case"attr-obb-height":break;default:break}}}function bk(e,t){for(let i in t)switch(i){case"attr-name":{e.name=t[i];break}case"attr-layer":{e.layer=t[i];break}case"attr-locked":{e.locked=t[i];break}case"attr-x":{e.x=t[i];break}case"attr-y":{e.y=t[i];break}case"attr-color":{e.fillColor=t[i];break}case"attr-reset-color":e.fillColor=H.panelThemeCache.fillColor.auxiliaryPoint;case"attr-conceal":{e.visible=t[i]!=="yes";break}default:console.error(`AuxiliaryLine: can not update attr(${i}) on auxiliaryLine`)}}function xk(e,t){for(let i in t){let r=t[i];switch(i){case"attr-name":{e.name=r;break}case"attr-layer":{e.layer=r;break}case"attr-locked":{e.locked=r;break}case"attr-x":{e.x=r;break}case"attr-y":{e.y=r;break}case"attr-color":{e.strokeColor=r;break}case"attr-reset-color":{e.strokeColor=H.panelThemeCache.color.auxiliaryLine;break}case"attr-stroke-style":{e.strokeStyle=Fd(r).key;break}default:console.warn(`AuxiliaryLine: can not update attr(${i}) on auxiliaryLine`)}}new Zl(e).render()}var Sw=class{static getCacheObj(t){var i,r=E3(Jp("preferences")||Jp("preferences")||"{}");return r?r[t]:i}static getValueFromCacheUser(t){var i=S4();return i&&$e(i,t)?i[t]:""}};var gD=!1;function yte(e,t){if(gD)return Promise.resolve();gD=!0;let i=zt.createContext(!0),r=[];return new Promise(function(n){for(let s=0;s<e.length;s++)Vc.addTask(async function(){let a=await xD(e[s],t);Array.isArray(a)&&r.push(...a)});Vc.addTask(function(){i();for(let l of r)l();let s=new rt,a=new Set;for(let l of e)if(l.cmdKey==="combination"){let c=s.getAllElesfromTop(l.id).elements;for(let u of c)a.add(le(u))}else l.id&&a.add(le(l.id));let o=Array.from(a).filter(l=>l&&Ae.isSelected(l));o=is(o),o.length&&fr(o,{create8Dots:!0}),pi.appendSelectStroke(),n(void 0)}).onProgress(function(s){or("progressUpdate",[s,"Update Attribute"])}).run()})}function bte(e){e["attr-rotation"]?Tr.add({type:3,degree:-e["attr-rotation"]}):e["attr-conceal"]==="yes"?Tr.add({type:10}):e["attr-locked"]&&Tr.add({type:5,locked:e["attr-locked"]==="yes"})}function xte(e,t){let i=zt.createContext(!0),r=[];for(let o of e){if(o.cmdKey==="combination"){r.push(...k.getCombination(o.id).elements.map(l=>le(l)));continue}!["dimension","auxiliaryPoint","auxiliaryLine"].includes(o.cmdKey)&&r.push(le(o.id))}let n=Y1(r),s=Hd(n,H.tabId);t=fi.widthHeightKeepSameRatio(t,s);for(let{id:o}of r)Ke.jsonSnap.addOne(k.getById(o).json);let a=yD(t,r);i();for(let o of a)o();fr(r,{create8Dots:!0}),pi.appendSelectStroke()}function yD(e,t){let{x:i,y:r,width:n,height:s}=Rr(t),a=[],o=1,l=1,c=fi.transferXYByReference({x:i,y:r,width:n,height:s}),u=new j(c[0],c[1]),h=0,d=0,p=0;for(let f in e){let m=+e[f];switch(f){case"attr-width":case"attr-bbox-width":o=(e["attr-bbox-width"]||e["attr-width"])/n;break;case"attr-height":case"attr-bbox-height":l=(e["attr-bbox-height"]||e["attr-height"])/s;break;case"attr-x":case"attr-bbox-x":d=fi.transferXYByReference({x:m,y:r,width:n,height:s},!0)[0]-i;break;case"attr-y":case"attr-bbox-y":p=fi.transferXYByReference({x:i,y:m,width:n,height:s},!0)[1]-r;break;case"attr-rotation":case"attr-bbox-rotation":h=m;break}}for(let f of t){let{cmdKey:m,json:g}=k.getById(f.id);jg([g],-h+g.rotation,u),Xn.move(g,d,p);let b=vi(g);Ete(m,g,o*b.width,l*b.height,u),a.push(()=>{Array.isArray(g.tempMatrix)&&k.updatePrimitiveJson(g.gId,"matrix",g.tempMatrix)})}return a}function Ete(e,t,i,r,n){switch(e){case"group":zn.syncGroupSize(t,i,r,n);break;case"obj":Lr.syncImageSize(t,n,i,r);break;case"text":xr.syncTextSize(t,i,r,n);break;case"ellipse":Ei.syncEllipseSize(t,i,r,n);break;case"arc":mr.syncArcSize(t,n,i,r);break;case"rect":Li.syncRectSize(t,n,i,r);break;default:console.error(e)}}function Ste(e,t){console.warn(e,t);let i=[],r=e.id,s=new rt().getAllElesfromTop(r).elements;for(let c of s)i.push(le(c));let a=Hd([e],H.tabId);t=fi.widthHeightKeepSameRatio(t,a);for(let c of i)Ke.jsonSnap.addOne(k.getById(c.id).json);Ke.jsonSnap.addOneCombineByComId(r);let o=[],l=k.getCombination(r);e:for(let c in t)switch(c){case"attr-name":{let u=t[c];l.name=u}break;case"attr-locked":{let u=t[c]!=="no";l.locked=u}break;case"attr-conceal":{let u=t[c]==="no";l.visible=u}break;case"attr-width":case"attr-height":{o.push(...yD(t,i));break e}default:o.push(...yD(t,i));break}return o}function wk(e,t){return new RegExp("(-width|-height|-size|-radius|-x|-y|-length|-dx|-dy|-r|-distance|-dimension)$").test(e)&&(t=ea(t)),t}function vk(e,t){let i=Ge.canvas;return/-x$/.test(e)?t+=i.originX:/-y$/.test(e)&&(t+=i.originY),t}function Tk(e,t){let i=Sw.getCacheObj("Coordinates")!=="SVG";return/-y$/.test(e)&&i&&(t*=-1),t}async function Ik(e,t){return $e(t,"attr-bbox-x")||$e(t,"attr-bbox-y")||$e(t,"attr-bbox-width")||$e(t,"attr-bbox-height")||$e(t,"attr-bbox-rotation")?xte(e,t):yte(e,t).then(()=>{bte(t),uo()}).catch(i=>{console.error(i)}).finally(()=>{gD=!1})}async function xD(e,t){var m,g,b;t=jt(t);let i=[];if(e.cmdKey==="canvas")return Xt.modify_canvas(t);let{cmdKey:r,id:n}=e,s=le(n);if("combination"===r)return Ste(e,t);let a=Y1([s]),o=Hd(a,H.tabId,{notCreate8Dots:!0});t=fi.widthHeightKeepSameRatio(t,o);let l=(g=(m=k.gJsonCache[r])==null?void 0:m[s.id])==null?void 0:g.layer,c=+t["attr-layer"],u=k.getById(n).json;if(Cte(u,t),$e(t,"attr-layer")&&(c==l?delete t["attr-layer"]:(t["attr-transparency-print"]=1,t["attr-transparency-white"]=1,te(s,"opacity",1),u.transparencyPrint=1,u.transparencyWhite=1)),t=fi.filterModifyAttrs(t,o),$e(t,"attr-rotation")&&!wte(t["attr-rotation"],u,r)&&delete t["attr-rotation"],Object.keys(t).length===0)return;if(Ke.jsonSnap.addOne(u),console.log(e,t),$e(t,"attr-rotation")){let y=tr(t["attr-rotation"]);t["attr-rotation"]=y}switch(($e(t,"attr-obb-width")||$e(t,"attr-obb-height"))&&new Qd().syncSelfObbSize(u,t["attr-obb-width"],t["attr-obb-height"]),r){case"obj":let y=t["attr-href"];if(y!==void 0&&!I4(y)||y!==void 0&&g4(y)!=y||c&&c!==1)return;Ite(t,u);break;case"rect":vte(t,u);break;case"ellipse":gk(t,u);break;case"group":Tte(t,u);break;case"text":await yk(t,u);break;case"auxiliaryLine":{xk(u,t);break}case"auxiliaryPoint":{bk(u,t),af(u,s.id);break}case"dimension":{ts.updateDimensionData(e.id,t);break}case"dimensionLength":{mk(u,t);break}case"dimensionAngle":{fk(u,t);break}case"dimensionRadius":{pk(u,t);break}case"arc":{dk(u,t);break}default:console.error(r);break}if($e(t,"attr-locked")&&(u.locked=t["attr-locked"]==="yes"),$e(t,"attr-conceal")&&(u.visible=t["attr-conceal"]!=="yes",ai.applyElementsVisible(n)),$e(t,"attr-layer")){let y=((b=k.gJsonCache[r])==null?void 0:b[s.id])||{},E={layer:y.layer,cover:"cover"in y?y.cover:te(s,"cover")=="1",scope:y.scope},S={layer:c,cover:E.cover,scope:E.scope},w=q1[r];if(!w||w.includes(S.layer)){S.layer==1&&(S.cover=E.cover,y.cover=!0),S.layer==2&&(S.scope=E.scope||1,te(s,"scope",S.scope),y.scope=S.scope);let x=Qe.switchLayer(s,c);i.push(...x),te(s,"layer",c),y.layer=c;let I=jt(Qe.getCurrentScheme());for(let A of I.options)A.actived===!0&&(A.actived=!1),+A.id==+c&&(A.actived=!0);Qe.apply(I),Ce("panel/active-layer",[c,H.tabId,{updateUI:!0}])}}if($e(t,"attr-cover")&&te(s,"cover",t["attr-cover"]==="yes"?1:0),$e(t,"attr-scope")&&te(s,"scope",t["attr-scope"]),$e(t,"attr-name")&&te(s,"name",t["attr-name"]),$e(t,"attr-hide")&&te(s,"hide",t["attr-hide"]==="yes"?"1":"0"),$e(t,"attr-transparency-print")&&[+c,+l].includes(2)){let y=of(+t["attr-transparency-print"]*100,+t["attr-transparency-white"]*100);te(s,"opacity",y),te(s,"transparency-print",t["attr-transparency-print"]),te(s,"transparency-white",t["attr-transparency-white"])}let h=r==="text",d=["auxiliaryLine","auxiliaryPoint","dimension","dimensionAngle","dimensionLength","dimensionRadius"].includes(r),p=$e(t,"attr-stroke-color"),f=$e(t,"attr-stroke-width");if(!h&&!d&&p!==f){let y=t["attr-stroke-color"],E=t["attr-stroke-width"];if(E<0)return;let S=u.strokeColor,w=u.strokeWidth;p?y==="none"?t["attr-stroke-width"]=0:w||(t["attr-stroke-width"]=3.937):E===0?t["attr-stroke-color"]="none":S==="none"&&(t["attr-stroke-color"]="#000000")}if("attr-stroke-fill-swap"in t&&(t["attr-stroke-color"]=u.fillColor,t["attr-fill-color"]=u.strokeColor,u.fillColor=t["attr-fill-color"],u.strokeColor=t["attr-stroke-color"]),"attr-stroke-color-display"in t){let y=t["attr-stroke-color-display"];u.displayStroke=y,J1(s,r,u)}if("attr-fill-color-display"in t){let y=t["attr-fill-color-display"];u.displayFill=y,K1(u)}if($e(t,"attr-stroke-width")){let y=t["attr-stroke-width"];u.strokeWidth=y,ED(s,r,y)}if(!ft(u.displayStroke)&&$e(t,"attr-stroke-color")){let y=t["attr-stroke-color"];u.strokeColor=y,J1(s,r,u)}if(!ft(u.displayFill)&&$e(t,"attr-fill-color")){let y=t["attr-fill-color"];u.fillColor=y,K1(u)}i.length&&Ke.save(i),t&&Reflect.ownKeys(t).length&&z4(e,t)}function wte(e,t,i){if(!["obj","rect","ellipse","group","text","arc"].includes(i))return!0;let r=$1(t),n=fi.transferXYByReference(r),s=new j(n[0],n[1]),a;switch(i){case"obj":a=Lr.getRotationMatrix(e,t,s);break;case"rect":a=Li.getRotationMatrix(-e,t,s);break;case"ellipse":a=Ei.getRotationMatrix(-e,t,s,{beautify:!0});break;case"group":a=zn.getRotationMatrix(t,-e,s);break;case"text":a=xr.getRotationMatrix(t,-e,s);break;case"arc":{a=mr.getRotationMatrix(t,-e,s);break}default:return!0}return zt.checkOne(i,t,a)}function J1(e,t,i){let r=i.strokeColor||"none";t==="text"&&te(_r("path",e),{stroke:r,fill:r}),i.displayStroke===!1&&(r="none"),te(e,{stroke:r})}function K1(e){let t=e.fillColor||"none";e.displayFill===!1&&(t="none"),ri.renderer.attr(e.gId,"fill",t)}function ED(e,t,i){switch(t){case"text":te(_r("path",e),{"stroke-width":i});break;default:te(e,{"stroke-width":i});break}}function Y1(e){let t=new Map,i=Oa();for(let s of i)if(s.combinationId)for(let a of s.elements)t.set(a,s.combinationId);let r=[],n=new Set;for(let s of e){if(t.has(s.id)){let o=t.get(s.id);if(n.has(o))continue;n.add(o),r.push({id:o,cmdKey:"combination"});continue}let{cmdKey:a}=k.getById(s.id);r.push({id:s.id,cmdKey:a})}return r}function SD(e){Array.isArray(e)||(e=[e]);let t=Y1(e);return Hd(t,H.tabId)}function Ek(e){let t=Et("image",{"xlink:href":e.content});H.gCanvas.appendChild(t);let i=t.getBBox();return dt(t),i}function of(e,t){let{point:i}=ra({x:e,y:t},{x:0,y:0},{x:100,y:100}),r=P0({x:0,y:0},{x:100,y:100});return 1-P0({x:i.x,y:i.y},{x:100,y:100})/r}var Ak=(c=>(c[c.top_left=0]="top_left",c[c.top_middle=1]="top_middle",c[c.top_right=2]="top_right",c[c.middle_left=3]="middle_left",c[c.middle_middle=4]="middle_middle",c[c.middle_right=5]="middle_right",c[c.bottom_left=6]="bottom_left",c[c.bottom_middle=7]="bottom_middle",c[c.bottom_right=8]="bottom_right",c))(Ak||{}),bD=class{constructor(){this.referencePointKey="reference-point";this.getReferencePoint()}getReferencePoint(){let t=localStorage.getItem(this.referencePointKey),i=ft(t)?6:+t;return Object.values(Ak).filter(r=>isFinite(r)).includes(i)||(i=6),this.referencePoint=i}setReferencePoint(t){this.referencePoint=t,localStorage.setItem(this.referencePointKey,t+"")}transferXYByReference(t,i=!1){let r=~~(this.referencePoint/3),n=this.referencePoint%3,{x:s,y:a,height:o,width:l}=t,c=l/2*n,u=o/2*r;return i&&(c*=-1,u*=-1),[s+c,a+u]}getReference(){let t=~~(this.referencePoint/3),i=this.referencePoint%3;return[t,i]}shouldHideAttrStyle(t){return!![3,4,5,2,7].includes(+t)}filterAttrByLayer(t,i){this.shouldHideAttrStyle(i)&&(Reflect.deleteProperty(t,"attr-stroke-color"),Reflect.deleteProperty(t,"attr-fill-color"),Reflect.deleteProperty(t,"attr-stroke-width"))}filterModifyAttrs(t,i){let r=jt(t);return i["attr-stroke-color"]||delete r["attr-stroke-color"],i["attr-fill-color"]||delete r["attr-fill-color"],i["attr-stroke-width"]||delete r["attr-stroke-width"],r["attr-radius"]<0&&delete r["attr-radius"],r["attr-obb-width"]<0&&delete r["attr-obb-width"],r["attr-obb-height"]<0&&delete r["attr-obb-height"],r["attr-width"]<=0&&delete r["attr-width"],r["attr-height"]<=0&&delete r["attr-height"],r["attr-short-radius"]<0&&delete r["attr-short-radius"],r["attr-long-radius"]<0&&delete r["attr-long-radius"],i.cmdKey==="dimension"&&r["attr-locked"]==="yes"&&delete r["attr-locked"],r}widthHeightKeepSameRatio(t,i){if(!t["ratio-height-weight"])return t;let r="attr-width",n="attr-height",s="attr-bbox-width",a="attr-bbox-height";return $e(t,r)&&$e(t,n)?t:$e(t,r)?(t[n]=+(+t[r]/i[r]*i[n]).toFixed(2),t):$e(t,n)?(t[r]=+(t[n]/i[n]*i[r]).toFixed(2),t):$e(t,s)&&$e(t,a)?t:$e(t,s)?(t[a]=+(+t[s]/i[s]*i[a]).toFixed(2),t):($e(t,a)&&(t[s]=+(t[a]/i[a]*i[s]).toFixed(2)),t)}},fi=new bD;function vte(e,t){let i=$1(t),r=fi.transferXYByReference(i),n=new j(r[0],r[1]);if($e(e,"attr-x")||$e(e,"attr-y")){let s=fi.transferXYByReference({x:e["attr-x"],y:e["attr-y"],width:i.width,height:i.height},!0);Li.syncRectPosition(t,s[0],s[1])}if(($e(e,"attr-width")||$e(e,"attr-height"))&&Li.syncRectSize(t,n,e["attr-width"],e["attr-height"]),"attr-rotation"in e){let s=+e["attr-rotation"];Li.syncRectByRotation(-s,t,n)}if($e(e,"attr-radius")){let s=e["attr-radius"];te(le(t.gId),{rx:s,ry:s}),t.rx=s,t.ry=s}}function Tte(e,t){let i=zn.getGroupBBox(t),r=fi.transferXYByReference(i),n=new j(r[0],r[1]);if($e(e,"attr-rotation")){let s=e["attr-rotation"];zn.syncGroupWithRotation(t,-s,n)}if("attr-x"in e){let s=fi.transferXYByReference({...i,x:e["attr-x"]},!0);Xn.move(t,s[0]-i.x,0)}if("attr-y"in e){let s=fi.transferXYByReference({...i,y:e["attr-y"]},!0);Xn.move(t,0,s[1]-i.y)}zn.syncGroupSize(t,e["attr-width"],e["attr-height"],n)}function Ite(e,t){let i=le(t.gId),r=$1(t),n=fi.transferXYByReference(r),s=new j(n[0],n[1]);if(("attr-width"in e||"attr-height"in e)&&Lr.syncImageSize(t,s,e["attr-width"],e["attr-height"]),"attr-x"in e||"attr-y"in e){let a=fi.transferXYByReference({x:e["attr-x"],y:e["attr-y"],width:r.width,height:r.height},!0);Lr.syncImagePosition(i,a[0],a[1])}for(let a in e){let o=e[a];switch(a){case"attr-href":t.content=o,te(i,{"xlink:href":o});break;case"attr-transparency":o=Math.min(Math.max(+o,0),100),t.opacity=1-o/100;let l=$e(e,"attr-layer")?+e["attr-layer"]:t.layer;te(i,"opacity",l==2?1-t.opacity:t.opacity);break;case"attr-rotation":Lr.syncImageByRotation(-o,t,s);break;case"attr-reset-image-width":{let{width:c,height:u}=Ek(t),h=Lr.getImageShapeForAttr(t.matrix),d=et.createMatrixFrom6(t.matrix).getInverseMatrix(),p=de.scale(c/u*h.height,h.height).rotateD(t.rotation).translate(h.x,h.y),f=new de(d.data);Lr.syncImage(t,f.multiply3(p));break}case"attr-reset-image-height":{let{width:c,height:u}=Ek(t),h=Lr.getImageShapeForAttr(t.matrix),d=et.createMatrixFrom6(t.matrix).getInverseMatrix(),p=de.scale(h.width,u/c*h.width).rotateD(t.rotation).translate(h.x,h.y),f=new de(d.data);Lr.syncImage(t,f.multiply3(p));break}default:console.error("image attr",a);break}}}function R5(){let e=Ae.get(),t=new oi(e);for(let i of e){let{json:r,cmdKey:n}=k.getById(i.id);if(!r.fillColor||!r.strokeColor)continue;let s=r.strokeColor;r.strokeColor=r.fillColor,r.fillColor=s,J1(i,n,r),K1(r)}t.updateAndSave(),Ce("panel_updateAttrPanel")}function Ck(e){let t=[];for(let i of e){let{cmdKey:r}=k.getById(i);t.push({id:i,cmdKey:r})}return t}function Hd(e,t,i={}){let r=k.gJsonCache,n=e.every(o=>o.cmdKey===e[0].cmdKey)?e[0].cmdKey:"",s={"attr-selected-count":0,docType:r.head.docType,target:{[t]:{}},cmdKey:n,"filter-object":""},a=new Set;for(let o of e)if(!["dimension","dimensionLength","dimensionAngle","dimensionRadius","auxiliaryLine","auxiliaryPoint"].includes(o.cmdKey)){if("combination"===o.cmdKey){let l=new rt().getAllElesfromTop(o.id).elements;for(let c of l)a.add(le(c));continue}o.id&&a.add(le(o.id))}!i.notCreate8Dots&&a.size&&fr([...a],{create8Dots:!0}),a.size===0&&(dl(),Du(),Th("","none"));for(let o of e){let l=o.cmdKey;if(l==="canvas"){s.target[t].canvas=o,s=Sk(s,Xt.getCanvasAttrs());continue}s.target[t][o.id]=o;let c=r[l];if(!c)throw new Error(l);if(!c[o.id])throw new Error(o.id);c[o.id].gId||(c[o.id].gId=o.id,c[o.id]._addGId=!0),o.cmdKey==="text"&&(c[o.id].type=c[o.id].key||"Text"),o.cmdKey==="obj"&&(c[o.id].type="image");let u=k.getShapeAttr(c[o.id],o.cmdKey);s=Sk(s,u),c[o.id]._addGId&&(c[o.id].head?delete c[o.id].head.gId:delete c[o.id].gId,delete c[o.id]._addGId)}return s=Ate(e.filter(o=>!Nn(o.cmdKey)),s),s}function Ate(e,t){if(e.length<2)return t;let i=[];for(let r of e)r.cmdKey==="combination"?k.getCombination(r.id).elements.forEach(n=>{i.push(le(n))}):i.push(le(r.id));return wD(i,t)}function wD(e,t){let i=Rr(e),r=fi.transferXYByReference(i),[n,s]=k.translateByOrigin(r[0],r[1]);return{"attr-bbox-x":n,"attr-bbox-y":s,"attr-bbox-width":i.width,"attr-bbox-height":i.height,"attr-bbox-rotation":0,...t}}function Sk(e,t){let i="attr-selected-count";t.cmdKey!=="canvas"&&e[i]++;for(let n in t){if(!$e(t,n)||n===i||n==="docType"){t.docType&&!e.docType&&(e.docType=t.docType);continue}if(!$e(e,n)){e[n]=t[n];continue}if(n==="target"){e.target||(e.target={}),t.target||(t.target={});for(let s in t[n])$e(t[n],s)&&(e[n][s]?e[n][s]=Object.assign(e[n][s],t[n][s]):e[n][s]=t[n][s])}else{if(n==="type"&&Nn(e.type)&&Nn(t.type))continue;e[n]!==t[n]&&n!=="cmdKeys"&&n!=="attr-topic"&&n!=="attr-text-key"&&n!="attr-dimension-object"&&n!=="attr-primitive-type"&&(e[n]=P3),r(n)}}function r(n){n==="attr-dimension-object"&&e[i]>0&&(e["attr-dimension-object"]=e["attr-dimension-object"].concat(t["attr-dimension-object"])),n==="attr-primitive-type"&&e[i]>0&&(e["attr-primitive-type"]=e["attr-primitive-type"].concat(t["attr-primitive-type"]))}return e}function Cte(e,t){if(e.locked)for(let i in t)d3.includes(i)||delete t[i];return t}var vD=class{constructor(){this.polyline=[]}async run(t){this.type=t;let i=Dh().filter(r=>!Nn(r.cmdKey));if(!i.length){Kr("\u5F53\u524D\u753B\u5E03\u4E2D\u6CA1\u6709\u9009\u4E2D\u7684\u5143\u7D20");return}if(t=="boolSubtraction"){let r=k.getItemOrderMap();i.sort((n,s)=>r.get(n.gId)-r.get(s.gId))}this.selectedObjs=i,ri.history.startBatch(),i=await Promise.all(i.map(async r=>{let n=vi(r),{x:s,y:a,height:o,width:l}=n,c=fi.getReferencePoint();fi.setReferencePoint(0);let u=a,h=s,d=s+l,p=a+o,f=Qs(u),m=Qs(h),g=Qs(d),b=Qs(p),y=ea(Td(f)),E=ea(Td(m)),S=ea(Td(g)),w=ea(Td(b)),x=u-y,I=h-E,A=S-E,O=w-y;return Xn.move(r,-I,-x),await xD({id:r.gId,cmdKey:r.cmdKey},{"attr-width":A,"attr-height":O}),fi.setReferencePoint(c),r})),this.polyline=Ri.convertData2Polyline(i),this.operate(),ri.history.saveBatch()}operate(){let t;switch(this.type){case"boolAggregate":t=Ri.boolAggregate(this.polyline);break;case"boolIntersection":t=Ri.boolIntersection(this.polyline);break;case"boolSubtraction":if(t=Ri.boolSubtraction1(this.polyline),!t.length&&this.polyline.length==2){let n=[this.polyline[1],this.polyline[0]];t=Ri.boolSubtraction1(n)}break;case"boolExclusive":t=Ri.boolExclusive(this.polyline);break}t=t.map(n=>n.round(4));let i=["boolAggregate","boolSubtraction"].includes(this.type),r=Ri.convertPolylines2Svg(t,i,!1);r.length&&(qt(),this.removeSelectedObjs(),this.createNewShape(r))}removeSelectedObjs(){let t=[...this.selectedObjs],i=ts.findDimensionByPrimitiveIds(new Set(t.map(r=>r.gId)));for(let r of i)ri.history.jsonSnap.addOne(k.getById(r.gId).json),k.removeOne({id:r.gId});for(let r of t)ri.history.jsonSnap.addOne(r),k.removeOne({id:r.gId})}createNewShape(t){let i=this.selectedObjs.at(0);i.cmdKey==="text"&&(i.fillColor=i.strokeColor,i.strokeColor="none");for(let r of t){if(!r)continue;let n=Ot(),s=k.getInitialGroupData({gId:n,layer:i.layer,d:r,fillColor:i.fillColor,strokeColor:i.strokeColor,strokeWidth:i.strokeWidth});fl(s),Ae.select([{id:s.gId}]),ri.history.jsonSnap.addOne(s,{},"group")}}};async function Dk(e){let t=new vD;await t.run(e),t=null,Ce("panel_updateAttrPanel")}var ww=class{constructor(){this.BBoxCached=j4();this.PolylineCached=Ri.convertData2PolylineCached()}hasObjOutBoard(){let t=[],i=[];if(k.iterator((a,o,l)=>{if(!a.hide){if(a.layer===3){t.push(l);return}+a.layer!=8&&o!=="combination"&&o!=="_runtime"&&i.push({cmd:o,id:l})}}),!t.length)return[];let r=new Map,n=a5.getMergeCloseBoardSvgJson(k.gJsonCache,3);n.forEach(a=>{let l=a.polylineGroup.multiply3(de.MIRROR_Y).bbox();r.set(a,l)});let s=[];for(let a of i){let{cmd:o,id:l}=a,{json:c}=k.getById(l),u=0,h=this.BBoxCached(c);for(let d of n){let p=r.get(d);if(St.extendRect(h).isSeparated(p)){u++;continue}if(p.isContainsBBox1(St.extendRect(h)))break;let f=this.PolylineCached([c]);if(Ri.boolIntersection([f[0],d.polylineGroup.items]).length)break;u++}u===n.length&&s.push({id:l,cmd:Xi[o]})}return s}boardGapCheck(t,i){let r=[],n=[],s=new Ja,a=k.getInitialGroupData({d:s.getPanelMarkPathDForDesign(),gId:"frame-sheet",cmdKey:"group",matrix:et.getMatrix6FromMatrix(de.ORIGIN)});k.iterator((o,l,c)=>{if(!o.hide&&l!=="combination"&&o.layer===t){let u=this.PolylineCached([k.getById(c).json,a]);Ri.boolIsIntersection(u[0],u[1])&&r.push({data:o,cmd:l,id:c})}});for(let o=0;o<r.length-1;o++){let l=jt(k.gJsonCache),c=r[o],{data:u,cmd:h,id:d}=c,p=this.BBoxCached(u),f=p.x+p.width/2,m=p.y+p.height/2,g=kc(St.extendRect(p).extendOfSize(i)),b=g.width/p.width,y=g.height/p.height,E,S,w;for(let x=o+1;x<r.length;x++){let I=r[x],A=I.data,O=I.cmd,R=I.id,M=this.BBoxCached(A);if(St.extendRect(g).isSeparated(St.extendRect(M)))continue;switch(h){case"rect":w=et.createMatrixFrom6(u.matrix).multiply3(de.scale(b,y).setOrigin(f,m)),l[h][d].matrix=et.getMatrix6FromMatrix(w);break;case"ellipse":w=et.createMatrixFrom6(u.matrix).multiply3(de.scale(b,y).setOrigin(f,m)),l[h][d].matrix=et.getMatrix6FromMatrix(w);break;case"arc":u.displayFill=!0,u.fillColor="#000000",E=Ri.convertJsonCache2PolyLines(u,"arc"),S=Ah(E,i);break;case"group":E=Ri.convertJsonCache2PolyLines(u,"group"),S=Ah(E,i);break}let F=this.PolylineCached([k.getById(d).json,k.getById(R).json]),G=Ah(new kr(F[0]),i),V=["group","arc"].includes(h)?Ri.boolIntersection([S.items,F[1]]):Ri.boolIntersection([G.items,F[1]]);if(V.length){let q=[{id:d,cmd:Xi[h]},{id:R,cmd:Xi[O]}],C=new ot().ext1(V[0].__bbox).build();C.width()>.13&&C.height()>.13&&n.push(q)}}}return n}hasObjInMark(){let t=[],i=[],r=_k();return k.iterator((n,s,a)=>{n.hide||n.layer===4&&s!="combination"&&i.push({data:n,cmd:s,id:a})}),k.iterator((n,s,a)=>{if(n.hide||n.layer===8||n.layer===4||s==="combination"||ai.eleIsHide(n))return;let o=this.BBoxCached(n);if(n.strokeWidth&&n.displayStroke){let l=n.strokeWidth;s==="group"?r=_k(l):(o.x-=l/2,o.y-=l/2,o.width+=l,o.height+=l)}for(let l of r){let c=Object.values(l).length/8,u={x:l.x0,y:l.y0,width:l[`x${c*3}`]-l.x0,height:l[`y${c}`]-l.y0};if(!St.extendRect(o).isSeparated(St.extendRect(u))){for(let h of i){let d=this.PolylineCached([k.getById(a).json,k.getById(h.id).json]),p=d[1];if(Ri.boolIntersection(d).length){let f=[];for(let m of p)m.points(.5,g=>{f.push({x:g.x,y:-g.y})});if(xu({x:l.x0,y:l.y0},f)&&xu({x:l.x100,y:l.y100},f)&&xu({x:l.x200,y:l.y200},f)&&xu({x:l.x300,y:l.y300},f))return}}Rm(o,u)&&t.push(a);for(let h=0;h<400;h++){let d=l[`x${h}`],p=l[`y${h}`];switch(s){case"rect":(Dc(d,p,o)||Dte(d,p,n))&&t.push(a);break;case"ellipse":let{cx:f,cy:m,rx:g,ry:b}=Ei.getEllipseFromMatrix(n.matrix);(io(f,m,d,p,g,b)<=1||_te(d,p,n))&&t.push(a);break;case"arc":let y=Uc(d,p);y.length&&y.forEach(w=>{t.push(w)}),Pte(d,p,n)&&t.push(a);break;case"text":Lte(u,n)&&t.push(a);break;case"group":let E=tf(d,p);E.length&&E.forEach(w=>{t.push(w.id)});break;case"obj":let S=gg(d,p);S.length&&S.forEach(w=>{t.push(w.id)});break}}}}}),[...new Set(t)]}hasObjOutMaterialFrame(){let t=[],{w:i,h:r}=new Ja().getMaterialFrameSize();return k.iterator((n,s,a)=>{if(n.layer!==3)return;let{x:o,y:l,width:c,height:u}=s==="group"?p2(n):vi(n);(o<0||-l>r||o+c>i||-l-u<0)&&t.push({displayId:n.id,gId:n.gId})}),t}};function _k(e=0){let t=[];return new Ja().getMarksBBox().forEach(r=>{let{x:n,y:s,width:a,height:o}=r,l={};n-=e/2,s-=e/2,a+=e,o+=e;let c=a/100;for(let u=0;u<400;u++)switch(Math.floor(u/100)){case 0:l[`x${u}`]=n,l[`y${u}`]=s+c*(u%100);break;case 1:l[`x${u}`]=n+c*(u%100),l[`y${u}`]=s+o;break;case 2:l[`x${u}`]=n+a,l[`y${u}`]=s+o-c*(u%100);break;case 3:l[`x${u}`]=n+a-c*(u%100),l[`y${u}`]=s;break}t.push(l)}),t}function Dte(e,t,i){if(i.strokeWidth&&i.displayStroke){let r=i.strokeWidth/2,n=vi(i,"rect"),s=jt(n);s.x+=r,s.y+=r,s.width-=r*2,s.height-=r*2;let a=jt(n),o=jt(n);a.x-=r,a.width+=r*2,o.y-=r,o.height+=r*2;let l=n.x,c=n.y,u=n.x+n.width,h=n.y,d=n.x,p=n.y+n.height,f=n.x+n.width,m=n.y+n.height,g=io(l,c,e,t,r,r)<=1||io(u,h,e,t,r,r)<=1||io(d,p,e,t,r,r)<=1||io(f,m,e,t,r,r)<=1;if(!Dc(e,t,s)&&(Dc(e,t,a)||Dc(e,t,o)||g))return!0}return!1}function _te(e,t,i){if(i.strokeWidth&&i.displayStroke){let{cx:r,cy:n,rx:s,ry:a}=Ei.getEllipseFromMatrix(i.matrix),o=s-i.strokeWidth/2,l=a-i.strokeWidth/2,c=s+i.strokeWidth/2,u=a+i.strokeWidth/2,h=io(r,n,e,t,o,l),d=io(r,n,e,t,c,u);if(h>=1&&d<=1)return!0}return!1}function Pte(e,t,i){let r=(i.x1+i.x2)/2,n=(i.y1+i.y2)/2,s=new j(i.x1-i.x2,i.y1-i.y2),a=new j(i.x1-e,i.y1-t),o=s.cross(a);if(i.strokeWidth&&i.displayStroke){let l=i.rx-i.strokeWidth,c=i.ry-i.strokeWidth,u=i.rx+i.strokeWidth,h=i.ry+i.strokeWidth,d=io(r,n,e,t,l,c),p=io(r,n,e,t,u,h),f=io(i.x1,i.y1,e,t,i.strokeWidth/2,i.strokeWidth),m=io(i.x2,i.y2,e,t,i.strokeWidth/2,i.strokeWidth);if(d>=1&&p<=1&&o<=0||f<=1||m<=1)return!0}return!!(i.displayFill&&i.fillColor!=="none"&&io(r,n,e,t,i.rx,i.ry)<=1&&o<=0)}function Lte(e,t){let i=ht.createMatrixFrom6(t.matrix),r=qi(t.d,!1),n=[];for(let s of r)s.points(.5,a=>{n.push(a.multiply3(i))});for(let s of n)if(Dc(s.x,s.y,e))return!0;return!1}var Z1={3:["No Board Outline Layer, that used to define the shape of the panel.","Draw it"],1:["No Print Layer, that used to define the need to display the contents of the panel.","Draw it"],4:["No Slot Hole Layer, that used to define the need hollow out part of the panel.","Draw it"],2:["No Opacity Control Layer, that used to define needs transparent area of the panel.","Draw it"],5:["No Glue Cutout Layer, that used to define the area within the board layer that does not need to be glued except for the board hole.","Draw it"],6:["No Lighting Simulation Layer, that used for simulating panel lights.","Draw it"],outBoard:["Objects that only in assist drawing layer or board outline layer are allowed to exist independently outside the board outline. If you need a note, please fill it in on the order page. Please check: "],inMark:["To avoid the overall cutting offset caused by inaccurate positioning, do not draw objects within the four vertex rectangles of the material bounding box: "],inGap:["A certain distance should be maintained between the board outline layer objects, and the recommended minimum spacing is 2mm. To adjust: "],start:["Start Design Rule Checking."],finish:["Finish Design Rule Checking.Fatal Error: {1}, Error: {2}, Waring: {3}, Info: {4}."],outMaterial:["Objects in the board outline layer should be drawn within the material boarder box. To adjust:"]},TD=class{constructor(){this.busTopic="panel/design-check";this.logTopic="panel/design-check-show-log"}check(){this.drc=new ww;let t=this.getExistsLayer(),i=this.generateInfoMsg(t);this.startCheck(i),this.checkIfEleNotInAnyBoard(i),this.checkGapOfBoards(i),this.checkIfEleInAnyMark(i),this.checkBorderObjectInMaterialBorder(i);let r=this.analysisMsg(i);return this.finishCheck(i,r),this.showMsg(i),r}startCheck(t){let i={type:"info",tabType:"panelDrcLog",openTab:!0,msg:[Bo(Z1.start[0])]};t.unshift(i)}finishCheck(t,i){let{fatalErrorCount:r,errorCount:n,warnCount:s,infoCount:a}=i,o={type:"info",tabType:"panelDrcLog",openTab:!0,msg:[Bo(Z1.finish[0],{params:{1:r,2:n,3:s,4:a}})]};t.push(o)}showExportMsg(t){let{type:i,fileName:r,errorCount:n,fatalErrorCount:s,warnCount:a,infoCount:o}=t;if(i==="fail"){let l=[Bo("Generate {0} fabrication file failed! Fatal Error: {1}, Error: {2}, Warning: {3}, Info: {4}.",{params:{0:r,1:s,2:n,3:a,4:o}})];H.windowBridge.publish("bottomBarLog",{type:"info",tabType:"panelDrcLog",openTab:!0,msg:l},ut())}else{let l=[Bo("Generate {0} fabrication file successfully! Error: {1}, Warning: {2}, Info: {3}.",{params:{0:r,1:n,2:a,3:o}})];H.windowBridge.publish("bottomBarLog",{type:"info",tabType:"panelDrcLog",openTab:!0,msg:l},ut())}Ce("bottomBarLogGroupEnd","panelDrcLog")}analysisMsg(t){let i=0,r=0,n=0,s=0;for(let a of t)switch(a.type){case"error":i++;break;case"fatalError":r++;break;case"warn":n++;break;case"info":s++;break}return{errorCount:i,fatalErrorCount:r,warnCount:n,infoCount:s}}getBottomInfo(t,i,r="panelDrcLog"){return{type:t,tabType:r,openTab:!0,msg:[Bo(Z1[i][0]),{text:Bo(Z1[i][1]),call:{topic:"panel/active-layer",args:[i,H.tabId]}}]}}getBottomWarn(t,i,r,n="panelDrcLog"){return{type:t,tabType:n,openTab:!0,msg:[Bo(Z1[i][0]),...r]}}generateInfoMsg(t){let i=[];return t.has(3)||i.push(this.getBottomInfo("fatalError",3)),t.has(1)||i.push(this.getBottomInfo("error",1)),t.has(4)||i.push(this.getBottomInfo("info",4)),t.has(2)||i.push(this.getBottomInfo("info",2)),t.has(5)||i.push(this.getBottomInfo("info",5)),t.has(6)||i.push(this.getBottomInfo("info",6)),i}getExistsLayer(){let t=new Set;return k.iterator(i=>{i.layer&&t.add(+i.layer)}),t}checkIfEleNotInAnyBoard(t){let i=this.drc.hasObjOutBoard();if(i.length){let r=[],n=new rt;i.forEach((s,a)=>{let o=n.searchCombination(s.id)||"",{id:l}=k.getById(s.id).json;r.push({text:Bo(s.cmd)+l.replace(/^e/,"")+(a==i.length-1?"":","),attr:{panelid:H.tabId,id:s.id,comId:o}})}),t.push(this.getBottomWarn("warn","outBoard",r))}}checkGapOfBoards(t){let i=ea(2),r=this.drc.boardGapCheck(3,i);if(r.length){let n=[],s=new rt;r.forEach((a,o)=>{let l=s.searchCombination(a[0].id)||"",c=s.searchCombination(a[1].id)||"",{id:u}=k.getById(a[0].id).json,{id:h}=k.getById(a[1].id).json;n.push({text:Bo(a[0].cmd)+u.replace(/^e/,""),attr:{panelid:H.tabId,id:a[0].id,comId:l}},Bo("And"),{text:Bo(a[1].cmd)+h.replace(/^e/,""),attr:{panelid:H.tabId,id:a[1].id,comId:c}},o==r.length-1?"":"\uFF0C")}),t.push(this.getBottomWarn("warn","inGap",n))}}checkIfEleInAnyMark(t){let i=this.drc.hasObjInMark();if(i.length){let r=[],n=new rt;i.forEach((s,a)=>{let o=k.getById(s).json,l=o.id,c=n.searchCombination(s)||"",u=Xi[o.cmdKey];r.push({text:Bo(u)+l.replace(/^e/,""),attr:{panelid:H.tabId,id:s,comId:c}},a===i.length-1?"":"\uFF0C")}),t.push(this.getBottomWarn("warn","inMark",r))}}checkBorderObjectInMaterialBorder(t){let i=this.drc.hasObjOutMaterialFrame();if(i.length){let r=[],n=new rt;i.forEach(({displayId:s,gId:a},o)=>{let l=n.searchCombination(a)||"",c=Xi[k.getById(a).cmdKey];r.push({text:Bo(c)+s.replace(/^e/,""),attr:{panelid:H.tabId,id:a,comId:l}},o===i.length-1?"":",")}),t.push(this.getBottomWarn("error","outMaterial",r))}}showMsg(t){Ce("logClear","panelDrcLog"),Ce("bottomBarLogGroupStart","panelDrcLog");for(let i of t)Ce("bottomBarLog",i)}},bf=new TD;var Pk={["-"+bf.busTopic]:bf.check.bind(bf),"-panel/get-combine-data":z1,"-panel/edit-combination"(e){Wt.setEditing(e)},"-panel/get-edit-combination-id"(){return Wt.getCurrentEditingComId()},"-panel/get-editingPath"(){return wt.isEditingPath()},"-panel/select-combination"(e){Wt.selectCombinations(e)},"-panel/modify-combination"(e){new rt().modifyCombination(e)},"-panel/get-allCombinationAndElesFromTop"(e){let{elements:t,combinations:i}=new rt().getAllElesfromTop(e);return{elements:[...t],combinations:[...i]}},"-/panel/getObjectTreeData":g5,"-getPanelInfo":async()=>{let e=H.doctype,[t,i]=(window.frameElement.id||"").replace("frame_","").split("@");return{docType:e,path:i,uuid:t}},changeSelectionMode:qd,applyFilter:uo,"panel/BoolOperation":Dk,"panel/select-overlap":bB,"panel/show-element-control":bC.showShapeControl,"main2iframe/trigger-event":Lk,[bf.logTopic]:bf.showExportMsg.bind(bf),"/panel/place_lib":Gu.setPlacingStatus.bind(Gu),"panel/place-dimension":e=>{Ug.placeDimension(e)},"panel/delete-combination"(e){Wt.deleteCombinations(e)},"-panel/update-reference-point"(e){fi.setReferencePoint(e)},"panel/set-project-permission":Ru.set};async function Ok(){let e=!!Ae.count(),t=Ae.getIds()||[],i=Array.from(ts.excludeDimension(new Set(t)).values()).map(S=>le(S)).length>1,r=e,n=e,s=e,a=e,o=e,l=e,c=e,u=e,h=!0,d=!1,p=Ae.count();p<2&&(o=l=!1),!e&&p<1&&(h=!1),[void 0,1,2,3,4,26].includes(H.doctype)&&(d=!0);let f=new rt,m=f.getSelectedCombinations(t).combinations.size,g=await Xd(),b=is(Mi()).length===0,y=Wt.getCurrentEditingComId(),E=f.getAllEmptyCombinations().length;return{duplicateToCursor:c,duplicatePaste:u,doctype:H.doctype,joinGroupDisabled:b,groupSelectedDisabled:b,selectedCombinationCount:m,selected:t.length,isEditingPath:wt.isEditingPath(),currentEditingComId:y,isPasting:H.frameHelper.getToolProcessor().currentToolIs(ii.paste_tool),isLibPlacing:H.frameHelper.getToolProcessor().currentToolIs(ii.place_lib_tool),isDragging:oo(),canUndo:Ke.canUndo(),canRedo:Ke.canRedo(),canPaste:g,zoom:H.currZoom,visible_grid:Ge.adsorbGrid.visible,snap_grid:Ge.adsorbGrid.enabled,combinationCount:Object.keys(k.getCombination()).length,emptyCombinationCount:E,canCut:n,canCopy:r,canRotate:s,canFlip:a,canEqualDistant:o,canAlign:l,canEditArray:h,canFilterAttr:d,canRepeat:Tr.useable,cmdToken:H.cmdToken,adaptAreaSelectionView:Os.isAdaptAreaSelectionView(),selectionMode:Rg(),canEditGraphicBool:i,isFocusOnCanvas:ut().document.activeElement===window.frameElement}}var bl=class{static async createJsonCache(t){let r=await new Pg().decodeDataStr(t);r.success&&r.jsonCache&&(this.jsonCache=r.jsonCache)}static panelChangeUpdateJsonCache(t){let i=k.exchangeJsonCache(this.jsonCache);t.forEach(r=>{let{shapeIds:n,layerId:s,isVisible:a}=r;n.forEach(o=>{var c;let l=(c=k.getById(o))==null?void 0:c.json;if(l){let{layer:u,visible:h}=l;u!==s&&(l.layer=s),h!==a&&(l.visible=a)}})}),i()}static createSvg(){let t=k.exchangeJsonCache(this.jsonCache),i=k.getBBox(),r=50,n=i.width(),s=i.height();n=(r/n+1)*n,s=(r/s+1)*s;let a=[i.minX-r/2,i.minY-r/2,n,s].join(" ");return t(),Rn.toSVG(this.jsonCache,{viewBox:a,before:()=>{}})}static updateStrokeWidth(t){if(!this.jsonCache)return;let i=k.exchangeJsonCache(this.jsonCache);k.iterator(r=>{Reflect.has(r,"strokeWidth")&&r.strokeWidth!==t&&(r.strokeWidth=t)}),i()}static updateScale(t){if(!this.jsonCache||!(t>0))return;let i=k.exchangeJsonCache(this.jsonCache),r=de.scale(t);k.iterator(n=>{let{cmdKey:s}=n;W2[s](n,r)}),i()}static async import(t){if(!this.jsonCache)return;let i=k.exchangeJsonCache(this.jsonCache);if(k.iterator(n=>{if(!n.visible){let{gId:s,cmdKey:a}=n,o=k.gJsonCache[a];o&&o[s]&&delete o[s]}}),k.getBBox().area()===0){i(),ls("No Data!","warn");return}i();let r=await MS(this.jsonCache);H.frameHelper.getToolProcessor().switchToPasteTool("paste_dxf",r,t?"center":void 0)}static dispose(){this.jsonCache=null}};bl.jsonCache=null;function Rk(){let e=Rte();for(let t of Object.keys(e)){let i=e[t];t.startsWith("-")?H.messageBus.rpcService(t.substring(1),jA(i)):H.messageBus.subscribe(t,jA(i))}}function Rte(){return{...Wr(),async"-/panel/getCombinationData"(){return await q5()},setCanvas:GS,updatePanelCanvasName:function(e){k.gJsonCache.head.title=e.toLowerCase(),k.gJsonCache.head.display_title=e,k.gJsonCache.head.name=e,Ce("panel_updateAttrPanel")},saveHistory:function(e){Ke.save(e)},"-getSVG":async function(e){function t(){if(typeof XMLSerializer<"u"){var h=new XMLSerializer().serializeToString(H.gCanvas);h.search(/[^\x00-\x7f]/)>=0&&(h=h.replace(/[^\x00-\x7f]/g,function(m){return"&#"+m.charCodeAt(0)+";"})),h=h.replace(/<circle [^>]*class="pindot[^>]*(?:\/>|><\/circle>)/g,"").replace(/<rect [^>]*class="hitbox"[^>]*(?:\/>|><\/rect>)/g,"").replace(/<g(\s[^>]*)?\/>/g,"").replace(/ xmlns="http:\/\/www\.w3\.org\/2000\/svg"/g,"").replace(/ xmlns:xlink="http:\/\/www\.w3\.org\/1999\/xlink"/g,"");for(var d=["id","class","title","net","number","c_\\w+"],p=0;p<d.length;p++)for(var f=new RegExp("(<\\w+[^>]*)\\s"+d[p]+'=\\"[^\\"]*\\"',"g");f.test(h);)h=h.replace(f,"$1");return h=h.replace(/<g\s*>\s*<\/g>/g,""),h=h.replace(/( xlink:href=")(\/\/)/g,"$1"+location.protocol+"$2"),h=h.replace(/( xlink:href=")(\/[^\/"][^"]*)/g,"$1"+location.protocol+"//"+location.host+"$2"),h}else return"gCanvasToXML error! "}var i=Ge.canvas.bgColor,r=$l.invoke("getBBox"),n=e||50,s=r.x-n|0,a=r.y-n|0,o=Math.max(r.width+n*2,100)|0,l=Math.max(r.height+n*2,100)|0,c=(await H.windowBridge.rpcCall("getTitle",null,ut())).message,u='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+o+'" height="'+l+'" viewBox="'+s+" "+a+" "+o+" "+l+'"><title>'+yu(c)+`</title><style type="text/css">
path, polyline, polygon {stroke-linejoin:round;}
path, polyline, polygon, line {stroke-linecap:round;}
</style>
<rect x="`+s+'" y="'+a+'" width="'+o+'" height="'+l+'" fill="'+i+'" stroke="none"/>'+t()+"</svg>";return u},undoDraw(){Je.stepBack()},"-panelFitView":YS,"-panelAdaptSelectionView":VS,"-panelZoomToRegion":function(e){Jl(e,1,!1,0)},uninstallCurrentTool:function(){H.frameHelper.getToolProcessorCurrentTool().uninstall(new ag)},"-panelZoomTo":function({x:e,y:t,scaleRatio:i}){Bu(e,t);let{width:r,height:n}=H.svgRoot.getBoundingClientRect();return rc(i,{clientX:r/2,clientY:n/2})},storeImageData:function(e){H.defaultImage=e},findShape:function(e){if(e)return pl(le(e))},moveSelected(e){var i;let t=((i=H.frameHelper.getToolProcessorCurrentTool())==null?void 0:i.getSymbol())||ii.highlight;[ii.highlight].includes(t)&&ok(e.args[0],e.args[1])},moveCanvas:function(e){var t={Up:[0,-1],Down:[0,1],Left:[-1,0],Right:[1,0]},i=Xt.getViewBox(),r=10/H.gZoom;i[0]+=r*t[e.direction][0],i[1]+=r*t[e.direction][1],Xt.setViewBox(i)},"-getGridStyle":function(){var e;return Ge.adsorbGrid.visible?Ge.adsorbGrid.gridType:((e=H.profileSetting)==null?void 0:e.commSystemSetting.CANVAS.gridStyle)||"not"},"-panel/panelLayerSchemeChange":function(e,t){Qe.apply(e,t)},"-panel/resetDefaultScheme":function(){Qe.resetDefaultScheme()},"-panel/activePanelLayerScheme":function(){return Qe.currentScheme},"-panel/panelLayerPrimitiveVisibilityChange":function(e){let t=new oi(e.map(i=>le(i)));for(let i of e)ai.toggleVisible(i);t.updateAndSave(),Ce("panel_updateAttrPanel"),Ce("updateMenuByDocStatus")},"-toggleElmsVisible":function(e){e.forEach(t=>{ai.applyElementsVisible(t)})},"-panel/panelCombinationElesVisChange":(e,t)=>{e.forEach(i=>{let r=new rt,n=r.searchCombination(i),s=r.findFamily(n).getAllParents();if(t){let a=s.every(l=>k.getCombination(l).visible),o=k.getById(i).json.visible;a&&o&&ai.applyElementsVisible(i)}else ai.applyElementsVisible(i)})},"-panel/panelCombinationVisibleChange":function(e,t){let i=new oi;i.addOneCombineByComId(e);let r=k.getCombination(e);r.visible=t,i.updateAndSave(),Ce("panel_updateAttrPanel")},"-panel/cancelAllParentCombinationHidden":function(e,t){let i=new oi,r=new rt,n=t==="objectNode"?r.searchCombination(e):e,s=r.findFamily(n).peekParent(),{elements:a,combinations:o}=r.getAllElesfromTop(s);r.findFamily(n).getAllParents().forEach(c=>{i.addOneCombineByComId(c);let u=k.getCombination(c);u.visible=!0}),a.forEach(c=>{let{visible:u}=k.getById(c).json;u&&ai.applyElementsVisible(c)}),o.forEach(c=>{let u=k.getCombination(c);u.visible||u.elements.forEach(h=>{ai.applyElementsVisible(e)})}),i.updateAndSave()},"-panel/cancelLayerPanelHidden":function(e){let t=k.getById(e).json.layer,i=jt(Qe.currentScheme);i.options.forEach(r=>{r.id===t&&(r.visible=!0)}),Qe.apply(i)},"-getEleFilterStatus":function(e){let{json:t}=k.getById(e);return{hide:t.hide,lock:t.locked}},"panel/adsorption/updateShapeCache":function(e,t,i){bt.updateShapeCache(e,t,i)},"-isSelectedGroupDeleteByCDot":function(){let e=Ae.get()[0];if(e&&$t(e)==="group")return e.pathSegList.numberOfItems>2},"-getTabIdAndDocType":function(){return{tabId:H.tabId,docType:H.doctype}},...Pk,SET_PANEL_THEME:e=>{_g.setTheme(e)},"-getCanvasParam":function(){return{origin:{x:k.gJsonCache.head.originX,y:k.gJsonCache.head.originY}}},"-panel/getPanelCanvasImg":async function({width:e,height:t}){let i="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(BS()))),n=zs(new XMLSerializer().serializeToString(H.gCanvas)).getElementById("g1"),s=n.children;for(let p of Array.from(s))te(p,"hide")==1?n.removeChild(p):qC(p);let a;for(;a=_r(".hitbox",n);)dt(a);let o=le("panelFrameSheet").cloneNode(!0);n.insertBefore(o,n.firstElementChild);let l=es(n),c=e/l.width,u=t*c,h;(u<t||c>1)&&(h=Math.ceil(l.width*t/l.height),u=t,h>e&&(c=t/l.height,h=e,u=Math.ceil(l.height*e/l.width)));let d=H.panelThemeCache.color.background==="none"?"rgba(255, 255, 255, 0)":H.panelThemeCache.color.background;return{canvasW:e,canvasH:t,imgW:h,imgH:u,pngSrc:i,themeBgColor:d}},"-getPanelSvgRootImg":async function(){H.svgRoot.style.backgroundImage=document.body.style.backgroundImage,H.svgRoot.style.backgroundColor=document.body.style.backgroundColor;let t=new XMLSerializer().serializeToString(H.svgRoot);return H.svgRoot.style.backgroundImage="",H.svgRoot.style.backgroundColor="","data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(t)))},setToolbarCmd:function(){return ku.apply(null,arguments)},pasteImage:async function(e){iD(e)},zoom:function(){return rc.apply(null,arguments)},"-panel/getDocStatus":async function(){return await Ok()},"-panel/getViewStatus":function(){return Og()},"-getReferencePoint":async function(){return(await H.windowBridge.rpcCall("getReferencePosition",null,ut())).message||void 0},"-getReferencePointToolStatus":function(){return lr.referencePosition},"-panel/getCanvasGridSetting":e=>({gridSize:Ge.adsorbGrid.gridSize,gridType:Ge.adsorbGrid.gridType}),getBBox:function(){var e,t;try{e=H.gCanvas.getBBox()}catch{if(t=window.frameElement.parentNode,t.style.display=="none"){t.style.display="";try{e=H.gCanvas.getBBox()}catch(r){console.error(r)}t.style.display="none"}else throw"getBBox error"}if(e&&e.x===0&&e.y===0&&e.width===0&&e.height===0&&(t=window.frameElement.parentNode,t.style.display=="none")){t.style.display="";try{e=H.gCanvas.getBBox()}catch(i){console.error(i)}t.style.display="none"}if(e)return{x:lt(e.x,1),y:lt(e.y,1),width:lt(e.width,1),height:lt(e.height,1)}},undo:function(){Je.started&&Je.dots.length||oo()||Ke.go(-1)},redo:function(){Je.started&&Je.dots.length||oo()||Ke.go(1)},settingCommonSetting:function(e){H.profileSetting=e},clone:function(){var e=arguments[0];if(typeof e=="object"&&e.ids){var t=e.ids;if(!Array.isArray(t))return;var i=t.map(function(r){return le(r)});i=i.filter(function(r){return r&&Vs(r.parentNode,ko)})}},centerViewByCursor:async function(){Bu(Ir.data.currAbsX,Ir.data.currAbsY)},select_all(){!oo()&&HS(),Ce("panel/updateTreeActiveElements")},select_none:function(){qt()},select:function(){var e=arguments[0];if(typeof e=="object"&&e.ids){qt();var t=e.ids;if(!Array.isArray(t))return;var i=t.map(function(r){return le(r)});if(i=i.filter(function(r){return r&&Vs(r.parentNode,ko)}),i.length)return Ae.select(i)}else typeof e=="string"?Ae.select(le(e)):Ae.select(e)},align_left:function(e){ho("align_left",e)},align_right:function(e){ho("align_right",e)},align_top:function(e){ho("align_top",e)},align_bottom:function(e){ho("align_bottom",e)},align_horizontal_center:function(e){ho("align_horizontal_center",e)},align_vertical_center:function(e){ho("align_vertical_center",e)},align_horizontal_equidistant:function(e){ho("align_horizontal_equidistant",e)},align_vertical_equidistant:function(e){ho("align_vertical_equidistant",e)},align_left_side_edge_equidistant:function(e){ho("align_left_side_edge_equidistant",e)},align_top_side_edge_equidistant:function(e){ho("align_top_side_edge_equidistant",e)},align_grid:function(e){ho("align_grid",e)},rotate_left:function(){var e=arguments[0];typeof e=="object"&&e!==null&&e.ids?$l.invoke("rotate",[{ids:e.ids,degree:270}]):Wr().rotate(270)},rotate_right:function(){var e=arguments[0];typeof e=="object"&&e.ids?$l.invoke("rotate",[{ids:e.ids,degree:90}]):$l.invoke("rotate",[90])},draw(e){H.windowBridge.publish("setTopBarItemChecked",[e],ut()),ku(e)},cross_cursor:function(e){e===!1&&cs(!1)},canvas_config:function(){return jt(Ge.canvas)},config:function(){return Ge},async"-panel/panel_attrpanel_apply"(e,t){console.log("-panel/panel_attrpanel_apply",e,t);for(let i in t)t[i]=Tk(i,t[i]),t[i]=wk(i,t[i]),t[i]=vk(i,t[i]);await Ik(e,t),($e(t,"attr-name")||$e(t,"attr-layer")||$e(t,"attr-dimension-category"))&&Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel_updateAttrPanel",{keepSelectFilter:!0})},"-getElemAttr":function(e){let{eles:t,useIds:i}=e||{};if(t&&t.length&&i){let r=[];return t.forEach(n=>{r.push(le(n))}),SD(t)}return SD(t)},getCanvasAttr:function(){return Xt.getCanvasAttrs()},size:function(){return{width:+te(H.svgRoot,"width"),height:+te(H.svgRoot,"height")}},currZoom:function(){return H.currZoom},"-panel/alignItemsInArray":function(e){un.execute(e),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},"-panel/adjustArraySpacingByCursor":function(e){return un.ready(e.row,e.column,!0),!0},"-panel/arrayCopyCancel":function(){un.ready(!1,!1,!0),k.compilerManager.resumeDataMerge()},resumeDataMerge:function(){k.compilerManager.resumeDataMerge()},"panel/pauseDateMerge":function(){k.compilerManager.pauseDateMerge()},"-panel/preview":function(e){return un.preview(e),!1},scrollOriginToViewCenter:function(){Bu(k.gJsonCache.head.originX||0,k.gJsonCache.head.originY||0)},scrollElementsIntoView:function(e){let t=[];jl(e)?e.forEach(function(i){t.push(le(i))}):t.push(le(e)),Nk(t)},scrollXYIntoViewCenter:function(e,t){Bu(e,t)},setOriginXY:function(e){e||(e={x:k.gJsonCache.head.originX||0,y:k.gJsonCache.head.originY||0}),e.x=isFinite(e.x)&&e.x!==null?+e.x:Ge.canvas.originX,e.y=isFinite(e.y)&&e.y!==null?+e.y:Ge.canvas.originY,e.x=Zr(e.x),e.y=Zr(e.y),Ge.canvas.originX=e.x,Ge.canvas.originY=e.y;var t=.5/H.gZoom;te(le("gridOH"),{y1:e.y+t,y2:e.y+t}),te(le("gridOV"),{x1:e.x+t,x2:e.x+t}),te(le("gridPattern"),{x:e.x,y:e.y}),ac()},snap_grid:function(){Ge.adsorbGrid.enabled=!Ge.adsorbGrid.enabled},visible_grid:function(){var e=te(le("gridBg"),"display")||"";e=e=="none"?"":"none",te(le("gridBg"),{display:e}),Ge.adsorbGrid.visible=!e},"-gJsonCache":function(e){if(e&&(e.id||e.gId)){var t=le(e.id||e.gId);if(!t)return;var i=e.cmdKey||$t(t),r=k.gJsonCache[i],n=r&&r[e.id];return n?jt(n):null}return jt(k.gJsonCache)},"zoom(in)":function(){or("zoom(in)",[Ir.data])},"zoom(out)":function(){or("zoom(out)",[Ir.data])},draw_end(){let e=!1;if(H.cmdToken.indexOf("place_part(")===0)Je.end(Lh.ESC),e=!0;else if(H.cmdToken)Je.restart(),e=!1;else if(Os.isAdaptAreaSelectionView())e=X4();else if(un.on)Ce("editArray",[]);else if(wt.isEditingPath())wt.endEditingPath();else if(Wt.isEditing()){let t=Wt.getCurrentEditingComId();Wt.setEditing(null).selectCombinations([t])}return e&&lr.abortReferencePointMode(),e},showTextDialog:function(){Ce("showDrawingAttrDlg",["text"])},adaptAreaSelectionView:function(){pr("crosshair"),H.contextmenuDisableOnce=!0,document.querySelector("#g1").classList.add("none-events"),Os.setAdaptAreaSelectionView(!0)},adaptSelectionView:function(){let e=Ae.get(),t=Rr(e,!0);Jl(t,1)},"-getCurCmdToken":function(){return H.cmdToken},nextGGEID:function(){return Ot()},"-panel/getMouseRecorder":function(){let e=Ir.data;return{clientX:e.clientX,clientY:e.clientY}},"-panel/dxf/initPreview":async e=>{let{dataStr:t}=e;return await bl.createJsonCache(t),bl.createSvg()},"-panel/dxf/previewForLatestParam":()=>bl.createSvg(),"-panel/dxf/layerDataChange":e=>{let{panelBatchUpdateShapeStateOptsArr:t}=e;return bl.panelChangeUpdateJsonCache(t),bl.createSvg()},"-panel/dxf/updateParameter":e=>{try{let{scale:t,strokeWidth:i}=e;return!ft(t)&&bl.updateScale(t),!ft(i)&&bl.updateStrokeWidth(i),!0}catch{return!1}},"panel/dxf/import":async e=>{let{origin:t}=e;await bl.import(t)},"panel/dxf/close":()=>{bl.dispose()}}}function Ce(e,t=""){H.windowBridge.publish(e,t,ut())}function ls(e,t="warn"){Ce("ui/toastMsg",{type:t,msg:e,timer:3})}var zt=class{constructor(){this.tasks=[];this.noSolution=!1;this.isRunningTask=!1;this.ignorePrimitiveIds=new Set;this.labelPointTransformMap=new Map;this.dimensionMgr=new Vo}static setSkipCheck(t){return this.skipCheck=t,()=>{this.skipCheck=!t}}static createContext(t=!1){return this.self=new this,t&&Ke.startBatch(),()=>{this.runTask(),t&&Ke.saveBatch(),IS(k.getGJsonCache())}}static wrapDo(t){let i=this.createContext(!0);try{return t()}finally{i()}}static checkOne(t,i,r){return!this.self||this.self.isRunningTask||this.skipCheck?gu:this.self.beforeMatrixChange(i,r)}static runTask(t=!1){this.self.isRunningTask=!0;let i=this.self.noSolution;if(i===!1)for(;this.self.tasks.length;)this.self.tasks.pop()();return t?(this.self.dimensionMgr.reset(),this.self.isRunningTask=!1):this.emptyContext(),i}static emptyContext(){this.self=null}static addCallBack(t){this.self?this.self.tasks.push(t):t()}getDotsTransform(t){let i=this.labelPointTransformMap.get(t.gId);if(i)return i;let r=ic.loadPointsByData(t);return i=new yg(r),this.labelPointTransformMap.set(t.gId,i),i}beforeMatrixChange(t,i){if(this.noSolution||this.isRunningTask)return!1;let r=this.getDotsTransform(t);r.transform(i);let{moveNode:n,stillNode:s}=r.getTransformedNode(),a=this.dimensionMgr.setNodeVisited(s).findDimensionNode(n);if(a===!1)return this.noSolution=!0,!1;let o=!1,l=new Set;for(let c of a){let{dx:u,dy:h,xNode:d,yNode:p}=c,{canMoveX:f,canMoveY:m}=this.dimensionMgr.getAllAffectedPrimitivesId(d,p);if(u!==0){for(let g of new Set([...f]))if(Gi.isLockedById(g)){let b=Xi[k.getById(g).cmdKey];o=!0;let y=k.getById(g).json;l.add(b+(y==null?void 0:y.id.slice(1)))}}if(h!==0){for(let g of new Set([...m]))if(Gi.isLockedById(g)){let b=Xi[k.getById(g).cmdKey];o=!0;let y=k.getById(g).json;l.add(b+(y==null?void 0:y.id.slice(1)))}}}return o&&(ls({value:l.size>1?"Constraint associated object {0} are currently locked, please unlock them first.":"Constraint associated object {0} is currently locked, please unlock first.",options:{0:[...l]},translateOptionKeys:[0]}),this.noSolution=!0),this.noSolution?!1:(this.ignorePrimitiveIds.add(t.gId),Ke.jsonSnap.addOne(t),()=>{for(let c of a){let{dx:u,dy:h,xNode:d,yNode:p}=c,{canMoveX:f,canMoveY:m}=this.dimensionMgr.getAllAffectedPrimitivesId(d,p);for(let g of f)this.ignorePrimitiveIds.has(g)&&f.delete(g);for(let g of m)this.ignorePrimitiveIds.has(g)&&m.delete(g);this.dimensionMgr.prepareHistory(d,p).movePrimitive(u,h,f,m).moveDimension(u,h,d,p)}})}};zt.skipCheck=!1;var ID=class{constructor(){this.center={x:0,y:0};this.unitRx={x:1,y:0};this.unitRy={x:0,y:1}}getDotsForAdsorp(t){let i=0,r=0,n=1,s=1,a=i-n,o=i+n,l=r-s,c=r+s,u=[[a,l],[o,l],[o,c],[a,c],[i,l],[o,r],[i,c],[a,r],[i,r]],{tempMatrix:h,matrix:d}=k.getEllipse(t),p=ht.createMatrixFrom6(h||d),f=[];for(let m of u){let g=new j(m[0],m[1]).multiply3(p);f.push(g)}return f}sync(t,i,r){let s=ht.createMatrixFrom6(t.matrix).multiply3(i),a=et.getMatrix6FromMatrix(s);r.updateMatrix&&(t.matrix=a),t.tempMatrix=a,this.updateEllipseShape(le(t.gId),t)}syncEllipse(t,i,r){let n=zt.checkOne("ellipse",t,i);n!==!1&&zt.addCallBack(()=>{var s;n(),this.sync(t,i,r),(s=r==null?void 0:r.fn)==null||s.call(r)})}syncEllipseByRotation(t,i,r,n){let s=this.getRotationMatrix(t,i,r,n);s&&this.syncEllipse(i,s,{updateMatrix:!0,fn(){i.rotation=+t.toFixed(2)}})}getRotationMatrix(t,i,r,n){if(!Kn(t))return;let{matrix:s,rotation:a}=i,o=a||0,l=ht.createMatrixFrom6(s),c=r||new j(this.center.x,this.center.y).multiply3(l);return de.rotateD(t-o).setOrigin1(c)}syncEllipseRadius(t,i,r,n){let{cx:s,cy:a,rx:o,ry:l}=this.getEllipseFromMatrix(t.matrix);i=i||l,r=r||o;let[c,u]=fi.getReference(),h=new j(1-u,1-c),d=et.createMatrixFrom6(t.matrix).getInverseMatrix(),p=de.translate1(h).scale(r,i).rotateD(t.rotation).translate1(n);this.syncEllipse(t,d.multiply3(p),{updateMatrix:!0})}syncEllipsePosition(t,i,r){let{x:n,y:s}=vi(t,"ellipse");i=Kn(i)?i:n,r=Kn(r)?r:s;let a=i-n,o=r-s;if(!a&&!o)return;let l=de.translate(a,o);this.syncEllipse(t,l,{updateMatrix:!0})}syncEllipseSize(t,i,r,n){if(!n){let{cx:h,cy:d}=this.getEllipseFromMatrix(t.matrix);n=new j(h,d)}let s=AD(t),a=s.width,o=s.height,l=1,c=1;if(ft(i)||(l=i/a),ft(r)||(c=r/o),l===0||c===0||l===1&&c===1)return;let u=de.scale(l,c).setOrigin(n.x,n.y);this.syncEllipse(t,u,{updateMatrix:!0})}updateEllipseShape(t,i){let{rx:r,ry:n,matrixArr:s}=this.getEllipseFromMatrix(i.tempMatrix||i.matrix);te(t,{rx:r,ry:n}),ht.updateTransform(s,t)}getEllipseFromMatrix(t){let i=ht.createMatrixFrom6(t),r=new j(this.center.x,this.center.y).multiply3(i),n=new j(this.unitRx.x,this.unitRx.y).multiply3(i),s=new j(this.unitRy.x,this.unitRy.y).multiply3(i),a=n.distance1(r),o=s.distance1(r),c=de.scale(1/a,1/o).multiply3(i),u=et.getMatrix6FromMatrix(c);return{cx:r.x,cy:r.y,rx:a,ry:o,matrixArr:u}}},Ei=new ID;function Fh(e){let t=e.cmdKey=="arc"?mr.get8Dots2(e):Fi.get(le(e.gId),"single"),i=Hl(t[0],t[1],t[2],t[3]),r=Hl(t[0],t[1],t[6],t[7]);return{obbWidth:i,obbHeight:r}}function vw(e){let t=new _i(e),i=vi(e,"arc"),r=t.vectorCenter(),[n,s]=k.translateByOrigin(r.x,r.y),[a,o]=k.translateByOrigin(e.x1,e.y1),[l,c]=k.translateByOrigin(e.x2,e.y2),u=fi.transferXYByReference(i),[h,d]=k.translateByOrigin(u[0],u[1]),{obbWidth:p,obbHeight:f}=Fh(e);return{"attr-width":i.width,"attr-height":i.height,"attr-obb-width":p,"attr-obb-height":f,"attr-x":+h.toFixed(2),"attr-y":+d.toFixed(2),"reference-point":fi.getReferencePoint(),"attr-circle-center-x":n,"attr-circle-center-y":s,"attr-start-x":a,"attr-start-y":o,"attr-end-x":l,"attr-end-y":c,"attr-long-radius":e.rx,"attr-short-radius":e.ry,"attr-start-angle":Td(t.startAngle()),"attr-end-angle":Td(t.endAngle()),"attr-arc-type":e.type===1?"Center Arc":"Two Points Arc","attr-rotation":Math.abs(e.rotation||0)}}function Mk(e){let t=vi(e),{obbWidth:i,obbHeight:r}=Fh(e),n=fi.transferXYByReference(t),[s,a]=k.translateByOrigin(n[0],n[1]),{rx:o,ry:l}=Ei.getEllipseFromMatrix(e.matrix);return{"reference-point":fi.getReferencePoint(),"attr-width":t.width,"attr-height":t.height,"attr-obb-width":i,"attr-obb-height":r,"attr-long-radius":o,"attr-short-radius":l,"attr-x":ni(s,0)?0:s,"attr-y":ni(a,0)?0:a,"attr-rotation":Math.abs(e.rotation||0)}}function Bk(e){let t=new In(e);return{"attr-dimension-object":[{start:k.getById(e.start.id).json,end:k.getById(e.end.id).json}],"attr-dimension-category":e.category,"attr-dimension":t.getDistance(!0),"attr-dimension-direction":e.direction,"attr-primitive-type":[t.getPrimitiveType()]}}function kk(e){let t=Lr.getRectBBox(e.matrix),{obbWidth:i,obbHeight:r}=Fh(e),n=fi.transferXYByReference(t),[s,a]=k.translateByOrigin(n[0],n[1]);return{"reference-point":fi.getReferencePoint(),"attr-x":+s.toFixed(2),"attr-y":+a.toFixed(2),"attr-width":+t.width.toFixed(2),"attr-height":+t.height.toFixed(2),"attr-obb-width":+i.toFixed(2),"attr-obb-height":+r.toFixed(2),"attr-rotation":Math.abs(e.rotation||0)}}function Fk(e){let t=vi(e,"text"),i=fi.transferXYByReference(t),[r,n]=k.translateByOrigin(i[0],i[1]),{obbWidth:s,obbHeight:a}=Fh(e);return{"reference-point":fi.getReferencePoint(),"attr-textarea":e.name||"","attr-x":ni(r,0)?0:r,"attr-y":ni(n,0)?0:n,"attr-width":t.width,"attr-height":t.height,"attr-obb-width":s,"attr-obb-height":a,"attr-rotation":Math.abs(e.rotation||0)}}function Gk(e){let[t,i]=k.translateByOrigin(e.x1,e.y1),[r,n]=k.translateByOrigin(e.x2,e.y2),[s,a]=k.translateByOrigin(e.angleX,e.angleY);return{"attr-angle":new bn(e).calcuAngle(),"attr-dimension-angle-x":s,"attr-dimension-angle-y":a,"attr-start-x":t,"attr-start-y":i,"attr-end-x":r,"attr-end-y":n,"attr-rotation":Math.abs(e.rotation||0)}}function Uk(e){let[t,i]=k.translateByOrigin(e.x1,e.y1),[r,n]=k.translateByOrigin(e.x2,e.y2);return{"attr-start-x":t,"attr-start-y":i,"attr-end-x":r,"attr-end-y":n,"attr-rotation":Math.abs(e.rotation||0),"attr-length":new xn(e).calcLengthPixel()}}function Yk(e,t,i){let[r,n]=k.translateByOrigin(e.x,e.y),s=ft(e.strokeStyle)?t.auxiliaryLine.dash:e.strokeStyle,a={"attr-color":e.strokeColor||`${i.auxiliaryLine}`,"attr-stroke-style":Fd(s).value};switch(ul(e.rotation)){case"horizontal":a["attr-y"]=+n.toFixed(2);break;case"vertical":a["attr-x"]=+r.toFixed(2);break}return a}var Qd=class{getRectBBox(t){return et.getRectBBox(t)}syncSelfObbSize(t,i,r){let n=le(t.gId),s=1,a=1,o=Math.round(t.rotation*100)/100*(Math.PI/180),{obbWidth:l,obbHeight:c}=Fh(t),u=Ph(n),h=fi.transferXYByReference(u),d=new j(h[0],h[1]);if(ft(i)||(s=i/l),ft(r)||(a=r/c),s===0||a===0||s===1&&a===1)return;let p=et.createMatrixFrom6(t.tempMatrix||t.matrix),m=p.getInverseMatrix().scale(s,a).multiply3(p);switch(t.cmdKey){case"rect":Li.syncRect(t,m,{updateMatrix:!0});break;case"ellipse":Ei.syncEllipse(t,m,{updateMatrix:!0});break;case"arc":mr.syncArc(t,m,{updateD:!0});break;case"obj":Lr.syncImage(t,m,{updateMatrix:!0});break;case"text":xr.syncText(t,m,{updateMatrix:!0});break;case"group":zn.syncGroup(t,m,{updateD:!0});break}}};var Q1=class extends Qd{constructor(){super();this.start={x:0,y:0};this.unitWidth={x:1,y:0};this.unitHeight={x:0,y:1}}getDotsForAdsorp(i){let{matrix:r,tempMatrix:n}=i,s=ht.createMatrixFrom6(n||r),a=0,o=1,l=0,c=1,u=[[a,l],[o,l],[o,c],[a,c],[.5,l],[o,.5],[.5,c],[a,.5],[.5,.5]],h=[];for(let d of u){let p=new j(d[0],d[1]).multiply3(s);h.push(p)}return h}sync(i,r,n){let a=ht.createMatrixFrom6(i.matrix).multiply3(r),o=et.getMatrix6FromMatrix(a);n.updateMatrix&&(i.matrix=o),i.tempMatrix=o,this.updateRectShape(le(i.gId),i)}syncRect(i,r,n){let s=zt.checkOne("rect",i,r);s!==!1&&zt.addCallBack(()=>{var a;s(),this.sync(i,r,n),(a=n==null?void 0:n.fn)==null||a.call(n)})}updateRectShape(i,r){let{width:n,height:s,matrixArr:a}=this.getRectFromMatrix(r.tempMatrix||r.matrix);ri.renderer.attrs(r.gId,{width:n,height:s}),ht.updateTransform(a,i)}syncRectByRotation(i,r,n){let s=this.getRotationMatrix(i,r,n);s&&this.syncRect(r,s,{updateMatrix:!0,fn(){r.rotation=+i.toFixed(2)}})}getRotationMatrix(i,r,n){let s=r.rotation,a=Math.round((i-s)*100)/100;if(a!==0)return de.rotateD(a).setOrigin1(n)}getRectFromMatrix(i){let r=ht.createMatrixFrom6(i),n=new j(this.start.x,this.start.y).multiply3(r),s=new j(this.unitWidth.x,this.unitWidth.y).multiply3(r),a=new j(this.unitHeight.x,this.unitHeight.y).multiply3(r),o=s.distance1(n),l=a.distance1(n),u=de.scale(o?1/o:1,l?1/l:1).multiply3(r),h=et.getMatrix6FromMatrix(u);return{x:n.x,y:n.y,width:o,height:l,matrixArr:h}}syncRectPosition(i,r,n){let{x:s,y:a,width:o,height:l}=this.getRectBBox(i.matrix);r=ft(r)||Number.isNaN(r)?s:r,n=ft(n)||Number.isNaN(n)?a:n;let c=r-s,u=n-a;if(!c&&!u)return;let h=de.translate(c,u);this.syncRect(i,h,{updateMatrix:!0})}syncRectSize(i,r,n,s){let{x:a,y:o,width:l,height:c}=this.getRectBBox(i.matrix),u=1,h=1;if(ft(n)||(u=n/l),ft(s)||(h=s/c),u===0||h===0||u===1&&h===1)return;let d=de.scale(u,h).setOrigin1(r);this.syncRect(i,d,{updateMatrix:!0})}},Li=new Q1;var Fi={createPath8Dots:function(e){let t=Rr([e],!0),{x:i,y:r,width:n,height:s}=t;return[i,r,i+n,r,i+n,r+s,i,r+s,i+n/2,r,i+n,r+s/2,i+n/2,r+s,i,r+s/2]},get(e,t="multi"){if(!e)throw new Error("err");let i=e.tagName,r=e.id;if(r==="selectBox1")return Fi.selectbox.get(e);switch($t(e)){case"arc":return Fi.path_arc.get(r);default:break}return Fi[i]?Fi[i].get(e,t):[]},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=e.tagName;if(h=te(e,"id")=="selectBox1"?"selectbox":h,!Fi[h])throw new Error(h);Fi[h].set(e,t,i,r,n,s,a,o,l,c,u)},selectbox:{get:function(e){let t=+te(e,"x"),i=+te(e,"y"),r=+te(e,"width"),n=+te(e,"height");return[t,i,t+r,i,t+r,i+n,t,i+n,(2*t+r)/2,i,t+r,(2*i+n)/2,(2*t+r)/2,i+n,t,(2*i+n)/2]},set:function(e,t,i,r,n,s,a,o){}},text:{get:function(e,t="multi"){let i=Ua(e)?e:k.getText(e.id),r=i.cacheWidth,n=i.cacheHeight,s=new Array,a=j.ORIGIN;s.push(a.add1(0,-n)),s.push(a.add1(r,-n)),s.push(a.add1(r,0)),s.push(a),s.push(a.add1(r/2,-n)),s.push(a.add1(r,-n/2)),s.push(a.add1(r/2,0)),s.push(a.add1(0,-n/2));let o=ht.createMatrixFrom6(i.tempMatrix||i.matrix);if(t==="multi")return s.reduce((c,u)=>(u=u.multiply3(o),c.push(u.x,u.y),c),new Array);let l=[];for(let c=0;c<4;c++){let u=s[c];l.push([u.x,u.y])}return ht.getMaxOuterBoundingBox(l,i)},set:function(e,t,i,r,n,s,a,o,l=!1,c,u={}){let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=k.getText(e.id);xr.syncText(d,h,{updateMatrix:!1})}},g:{get:function(e){if($t(e)==="text")return Fi.text.get.apply(e,arguments);let i=e.getBBox(),r=i.x,n=i.y,s=i.width,a=i.height;return[r,n,r+s,n,r,n+a,r+s,n+a]},set:function(e,t,i,r,n){if($t(e)==="text")return Fi.text.set.apply(e,arguments);tc.g(e,r,n)}},svg:{get:function(e){return Fi.rect.get(e)},set:function(e,t,i,r,n){return Fi.rect.set(e,t,i,r,n)}},image:{get:function(e,t="multi"){let i=Ua(e)?e:k.gJsonCache.obj[e.id],r=1,n=1,s=[[0,0],[r,0],[r,n],[0,n],[r/2,0],[r,n/2],[r/2,n],[0,n/2]];if(t==="multi"){let o=ht.createMatrixFrom6(i.tempMatrix||i.matrix),l=[];for(let[c,u]of s){let h=new j(c,u).multiply3(o);l.push(h.x,h.y)}return l}return ht.getMaxOuterBoundingBox(s.slice(0,4),i)},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=k.gJsonCache.obj[e.id];if(!h)return;let d=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u);Lr.syncImage(h,d,{updateMatrix:!1})}},rect:{get:function(e,t="multi"){let i=Ua(e)?e:k.getRect(e.id),{matrix:r,tempMatrix:n}=i,s=ht.createMatrixFrom6(n||r),a=0,o=1,l=0,c=1,u=[[a,l],[o,l],[o,c],[a,c],[.5,l],[o,.5],[.5,c],[a,.5]];if(t==="multi"){let h=[];for(let d of u){let p=new j(d[0],d[1]).multiply3(s);h.push(p.x,p.y)}return h}return ht.getMaxOuterBoundingBox(u.slice(0,4),i)},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=k.getRect(e.id);Li.syncRect(d,h,{updateMatrix:!1})}},circle:{get:function(e){let t=+te(e,"cx"),i=+te(e,"cy"),r=+te(e,"r"),n=[t-r,i-r,t+r,i-r,t+r,i+r,t-r,i+r];return[t,i,t,i-r,t,i+r,t-r,i,t+r,i].concat(n)},set:function(e,t,i,r,n){t||(t=Fi.circle.get(e));let s={cx:t[0],cy:t[1],r:t[1]-t[3]};i===0&&(s.cx+=r,s.cy+=n),i==1&&(s.r-=n/2,s.cy+=n/2),i==2&&(s.r+=n/2,s.cy+=n/2),i==3&&(s.r-=r/2,s.cx+=r/2),i==4&&(s.cx+=r/2,s.r+=r/2),i==5&&(s.r-=r),i==6&&(s.r+=r),i==7&&(s.r+=r),i==8&&(s.r+=r),s.r!==0&&(s.r<0&&(s.r=-s.r),!(s.r<10)&&(s.cx=parseInt(String(s.cx*10))/10,s.cy=parseInt(String(s.cy*10))/10,te(e,s)))}},ellipse:{get(e,t){let i=0,r=0,n=1,s=1,a=i-n,o=i+n,l=r-s,c=r+s,u=[[a,l],[o,l],[o,c],[a,c],[i,l],[o,r],[i,c],[a,r]],h=Ua(e)?e:k.getEllipse(e.id),{tempMatrix:d,matrix:p,rotation:f}=h,m=et.createMatrixFrom6(d||p),g=[];for(let b of u){let y=new j(b[0],b[1]).multiply3(m);g.push(y.x,y.y)}return g},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=k.getEllipse(e.id);Ei.syncEllipse(d,h,{updateMatrix:!1})}},line:{get:function(e){return[+te(e,"x1"),+te(e,"y1"),+te(e,"x2"),+te(e,"y2")]},set:function(e,t,i,r,n){t||(t=Fi.line.get(e));let s={x1:t[0],y1:t[1],x2:t[2],y2:t[3]};i===0&&(s.x1+=r,s.y1+=n),i==1&&(s.x2+=r,s.y2+=n),te(e,s)}},polygon:{get:function(e){let t=Cc(te(e,"points")).split(/[\s\,]+/g),i;for(i=0;i<t.length;i++)t[i]=+t[i];for(i=t.length-2;i>=2;i-=2)t.splice(i,0,(t[i-2]+t[i])/2,(t[i-1]+t[i+1])/2);return i=t.length-2,t.push((t[0]+t[i])/2,(t[1]+t[i+1])/2),t.lightDots="odd",t},set:function(e,t,i,r,n){let s=t.slice(0),a,o=2*i;for(s[o]+=r,s[o+1]+=n,i==s.length/2-1?(!ni(s[o]*2,s[0]+s[o-2])||!ni(s[o+1]*2,s[1]+s[o-1]))&&s.splice(o,0,0,0):i%2&&(!ni(s[o]*2,s[o-2]+s[o+2])||!ni(s[o+1]*2,s[o-1]+s[o+3]))&&(s.splice(o+2,0,0,0),s.splice(o,0,0,0)),o=4,a=s.slice(0,2);o<s.length-1;o+=4)a.push(s[o],s[o+1]);let l={},c=[],u;for(let E=0;E<a.length-1&&c.length<4;E+=2)u=a[E]+"_"+a[E+1],l[u]||(l[u]=!0,c.push(E));if(c.length<=2)return;let h=!0,d,p,f,m,g,b;for(i=2;i<c.length;i++)if(d=a[c[0]],p=a[c[0]+1],f=a[c[1]],m=a[c[1]+1],g=a[c[i]],b=a[c[i]+1],!ni((d-f)*(b-m),(g-f)*(p-m))){h=!1;break}if(h)return;let y={points:yE(a.join(" "))};te(e,y)}},path:{get:function(e){let t=nf(e);if(t){let w=e.tagName+"_"+t;if(Fi[w]&&Fi[w].get)return Fi[w].get.apply(e,arguments)}let i=e.pathSegList,r=i.numberOfItems,n=0,s=0,a=[],o=0,l=0,c=[],u,h,d,p,f,m,g,b,y,E,S;for(u=0;u<r;u++)switch(d=i.getItem(u),p=d.pathSegType,u===0&&p!=Dr&&p!=Vr&&p!=si&&a.push(n,s),h=a.length/2-1,p){case si:n=o,s=l;break;case Dr:if(n=d.x,s=d.y,o=n,l=s,u+1==r||(g=i.getItem(u+1),m=g.pathSegType,m==Dr||m==Vr||m==si))break;a.push(n,s),m==mn&&a.push((n+g.x)/2,(s+g.y)/2);break;case mn:if(a.push(n=d.x,s=d.y),u+1==r)break;g=i.getItem(u+1),m=g.pathSegType,m==si&&(g=i.getItem(0)),(m==mn||m==si)&&a.push((n+g.x)/2,(s+g.y)/2);break;case Po:a.push(n=d.x,s);break;case Lo:a.push(n,s=d.y);break;case Ao:c.push({from:h,to:h+1},{from:h+2,to:h+3}),a.push(d.x1,d.y1,n=d.x2,s=d.y2,d.x,d.y);break;case Co:c.push({from:h+1,to:h+2}),a.push(d.x2,d.y2,n=d.x,s=d.y);break;case Do:c.push({from:h,to:h+1},{from:h+1,to:h+2}),a.push(d.x1,d.y1,n=d.x,s=d.y);break;case _o:case Ya:if(f=i.getItem(u-1),b=Ad(f.x,f.y,d.x,d.y,d.largeArcFlag?1:0,d.sweepFlag?1:0,d.r1,d.r2,d.angle),y=b.cx,S=b.cy,E=md([f.x,f.y],[y,S],b.delta_theta/2),a.push(E[0],E[1]),a.push(n=d.x,s=d.y),u+1==r)break;g=i.getItem(u+1),m=g.pathSegType,m==si&&(g=i.getItem(0)),(m==mn||m==si)&&a.push((n+g.x)/2,(s+g.y)/2);break;case Vr:if(n+=d.x,s+=d.y,o=n,l=s,u+1==r||(m=i.getItem(u+1).pathSegType,m==Dr||m==Vr||m==si))break;a.push(n,s);break;case Ul:a.push(n+=d.x,s+=d.y);break;case Gl:a.push(n+=d.x,s);break;case Yl:a.push(n,s+=d.y);break;case Ml:c.push({from:h,to:h+1},{from:h+2,to:h+3}),a.push(n+d.x1,s+d.y1,n+d.x2,s+d.y2,n+=d.x,s+=d.y);break;case Bl:c.push({from:h+1,to:h+2}),a.push(n+d.x2,s+d.y2,n+=d.x,s+=d.y);break;case kl:c.push({from:h+1,to:h+2}),a.push(n+d.x1,s+d.y1,n+=d.x,s+=d.y);break;case Fl:case Nl:a.push(n+=d.x,s+=d.y);break;default:break}if(te(e,"drag")!="self"){let w=Fi.createPath8Dots(e);return c.length?w.c_helper_lines=c:w.lightDots="odd",w}return c.length?a.c_helper_lines=c:a.lightDots="odd",a},set:function(e,t,i,r,n,s){if(r===0&&n===0){if(s)if($t(e)==="arc"&&te(e,"third-point")){let M=O0(t.join(" "));te(e,{d:s,"third-point":M[2].x+","+M[2].y})}else te(e,{d:s});return}let a=nf(e);if(a){let M=e.tagName+"_"+a;if(Fi[M]&&Fi[M].set){Fi[M].set.apply(e,arguments);return}}let o,l,c;if(/[^ahvqtsc]/i.test(s)){for(o=!0,l=t.slice(0),2*i+1<l.length&&(l[2*i]+=r,l[2*i+1]+=n),c=2;c<l.length-1;c+=2)if(l[c]!=l[0]||l[c+1]!=l[1]){o=!1;break}if(o)return}let u=e.pathSegList,h=u.numberOfItems,d=-1,p=i,f,m,g,b,y,E,S,w,x,I,A,O,R;if(s&&te(e,{d:s}),t.c_helper_lines||(i=i>>1),!t.c_helper_lines&&p%2){m=u.getItem(i+1),m.pathSegType==Ya?(g=u.getItem(i),y=t[p*2],E=t[p*2+1],S=Nm({x:g.x,y:g.y},{x:m.x,y:m.y},{x:y+r,y:E+n}),S<4&&(S=4),S=Math.sqrt(S),w=m.sweepFlag,x=m.r1,I=Ro(g.x,g.y,m.x,m.y),A=(m.x-g.x)*(E-g.y)-(y-g.x)*(m.y-g.y),O=(m.x-g.x)*(E+n-g.y)-(y+r-g.x)*(m.y-g.y),A*O<0&&(w^=1),x=I/(8*S)+S/2,R=x>S?0:1,x=Zr(x),m.r1=x,m.r2=x,m.largeArcFlag=R,m.sweepFlag=w):u.insertItemBefore(e.createSVGPathSegLinetoAbs(t[p*2]+r,t[p*2+1]+n),i+1);return}e:for(f=0;f<h;f++)switch(m=u.getItem(f),m.pathSegType){case si:break;case Dr:case Vr:if(f+1==h||(b=u.getItem(f+1).pathSegType,b==Dr||b==Vr||b==si))break;if(d++,d==i){m.x=lt(m.x+r,3),m.y=lt(m.y+n,3);break e}break;case mn:case Ul:if(d++,d==i){m.x=lt(m.x+r,3),m.y=lt(m.y+n,3);break e}break;case Po:case Gl:if(d++,d==i){m.x+=r;break e}break;case Lo:case Yl:if(d++,d==i){m.y+=n;break e}break;case Ao:case Ml:if(d++,d==i){m.x1+=r,m.y1+=n;break e}if(d++,d==i){m.x2+=r,m.y2+=n;break e}if(d++,d==i){m.x+=r,m.y+=n;break e}break;case Co:case Bl:if(d++,d==i){m.x2+=r,m.y2+=n;break e}if(d++,d==i){m.x+=r,m.y+=n;break e}break;case Do:case kl:if(d++,d==i){m.x1+=r,m.y1+=n;break e}if(d++,d==i){m.x+=r,m.y+=n;break e}break;case _o:case Fl:case Nl:if(d++,d==i){m.x+=r,m.y+=n;break e}break;case Ya:if(d++,d==i){m.x+=r,m.y+=n;break e}break;default:break}}},path_group:{get:function(e,t){if(wt.is8DotsMode(e.id)){let{json:E}=k.getById(e.id);return zn.getGroup8Dots({...E,d:te(e,"d")})}let i=e.pathSegList,r=i.numberOfItems,n=0,s=0,a=[],o=0,l=0,c=[],u,h,d,p,f,m,g,b,y=new Map;for(let E=0;E<r;E++){u=i.getItem(E),h=u.pathSegType;let S=E-1>-1&&i.getItem(E-1);E===0&&h!=Dr&&h!=Vr&&h!=si&&a.push(n,s);let w=a.length/2-1;switch(h){case si:n=o,s=l;break;case Dr:if(n=u.x,s=u.y,o=n,l=s,E+1==r||(p=i.getItem(E+1),d=p.pathSegType,d==Dr||d==Vr||d==si))break;a.push(n,s),d==mn;break;case mn:if(a.push(n=u.x,s=u.y),E+1==r)break;p=i.getItem(E+1),d=p.pathSegType,d==si&&(p=i.getItem(0)),d==mn||d==si;break;case Po:a.push(n=u.x,s);break;case Lo:a.push(n,s=u.y);break;case Ao:c.push({from:w,to:w+1,belong:w},{from:w+2,to:w+3,belong:w+3});let x=S.x===u.x1&&S.y===u.y1,I=u.x2===u.x&&u.y2===u.y;y.set(w+1,{belong:w,display:!x}),y.set(w+2,{belong:w+3,display:!I}),a.push(u.x1,u.y1,n=u.x2,s=u.y2,u.x,u.y);break;case Co:c.push({from:w+1,to:w+2}),a.push(u.x2,u.y2,n=u.x,s=u.y);break;case Do:c.push({from:w,to:w+1,belong:w}),y.set(w+1,{belong:w,display:!0}),a.push(u.x1,u.y1,n=u.x,s=u.y);break;case _o:case Ya:if(S=i.getItem(E-1),f=Ad(S.x,S.y,u.x,u.y,u.largeArcFlag?1:0,u.sweepFlag?1:0,u.r1,u.r2,u.angle),m=f.cx,b=f.cy,g=md([S.x,S.y],[m,b],f.delta_theta/2),a.push(n=u.x,s=u.y),E+1==r)break;p=i.getItem(E+1),d=p.pathSegType,d==si&&(p=i.getItem(0)),d==mn||d==si;break;case Vr:if(n+=u.x,s+=u.y,o=n,l=s,E+1==r||(d=i.getItem(E+1).pathSegType,d==Dr||d==Vr||d==si))break;a.push(n,s);break;case Ul:a.push(n+=u.x,s+=u.y);break;case Gl:a.push(n+=u.x,s);break;case Yl:a.push(n,s+=u.y);break;case Ml:c.push({from:w,to:w+1},{from:w+2,to:w+3}),a.push(n+u.x1,s+u.y1,n+u.x2,s+u.y2,n+=u.x,s+=u.y);break;case Bl:c.push({from:w+1,to:w+2}),a.push(n+u.x2,s+u.y2,n+=u.x,s+=u.y);break;case kl:c.push({from:w+1,to:w+2}),a.push(n+u.x1,s+u.y1,n+=u.x,s+=u.y);break;case Fl:case Nl:a.push(n+=u.x,s+=u.y);break;default:break}}return c.length&&(a.c_helper_lines=c),a.isModifyAnchor=!0,a.handleIndexes=y,a},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u){if(wt.isAnchorMode(e.id)&&!l){if(/[^ahvqtsc]/i.test(s)){let b=!0,y=t.slice(0);2*i+1<y.length&&(y[2*i]+=r,y[2*i+1]+=n);for(let E=2;E<y.length-1;E+=2)if(y[E]!==y[0]||y[E+1]!==y[1]){b=!1;break}if(b)return}let d=e.pathSegList,p=d.numberOfItems,f=-1,m,g;s&&te(e,{d:s});e:for(let b=0;b<p;b++){let y=b-1>-1&&d.getItem(b-1),E=y.pathSegTypeAsLetter,S=d.getItem(b),w=b+1<p&&d.getItem(b+1),x=w.pathSegTypeAsLetter;switch(S.pathSegType){case si:break;case Dr:case Vr:if(m=S,b+1==p||(g=w.pathSegType,g==Dr||g==Vr||g==si))break;if(f++,f==i){let I=lt(S.x+r,3),A=lt(S.y+n,3);x==="C"&&w.x1===S.x&&w.y1===S.y&&(w.x1=I,w.y1=A),S.x=I,S.y=A;break e}break;case mn:case Ul:if(f++,f==i){S.x=lt(S.x+r,3),S.y=lt(S.y+n,3);break e}break;case Po:case Gl:if(f++,f==i){S.x+=r;break e}break;case Lo:case Yl:if(f++,f==i){S.y+=n;break e}break;case Ao:case Ml:if(f++,f==i){Xs.setPrevHandlePosition(S,r,n,y,u),S.x1+=r,S.y1+=n;break e}if(f++,f==i){Xs.setNextHandlePosition(S,r,n,w,u),S.x2+=r,S.y2+=n;break e}if(f++,f==i){S.x=lt(S.x+r,3),S.y=lt(S.y+n,3),S.x2=lt(S.x2+r),S.y2=lt(S.y2+n),x==="C"&&(w.x1+=r,w.x1=lt(w.x1),w.y1+=n,w.y1=lt(w.y1)),b!==p-1&&d.getItem(b+1).pathSegType===si&&(m.x=S.x,m.y=S.y);break e}break;case Co:case Bl:if(f++,f==i){S.x2+=r,S.y2+=n;break e}if(f++,f==i){S.x+=r,S.y+=n;break e}break;case Do:case kl:if(f++,f==i){S.x1+=r,S.y1+=n;break e}if(f++,f==i){S.x+=r,S.y+=n;break e}break;case _o:case Fl:case Nl:if(f++,f==i){S.x+=r,S.y+=n;break e}break;case Ya:if(f++,f==i){S.x+=r,S.y+=n;break e}break;default:break}}return}let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u);zn.syncGroup(k.getById(e.id).json,h,{updateD:!1})}},path_arc2:{get:function(e){let t=[],i,r=e.getPathData();for(i=0;i<r.length;i++)if(r[i].type=="A"){let n=r[i-1].values,s=r[i].values,a=Ad(n[0],n[1],s[5],s[6],s[3],s[4],s[0],s[1],s[2]),o=a.cx,l=a.cy,c=md([n[0],n[1]],[o,l],a.delta_theta/2),u=L0(te(e,"d")),h=EE(u);t.push(n[0],n[1],s[5],s[6],c[0],c[1],h.x,h.y);break}return t},set:function(e,t,i,r,n,s){if(r===0&&n===0){s&&te(e,{d:s});return}let a,o,l,c=t?t.slice(0):Fi.path_arc2.get(e);if(i===3&&(c[0]+=r,c[1]+=n,c[2]+=r,c[3]+=n),i===0&&ni(c[0]+r,c[2])&&ni(c[1]+n,c[3])||i===1&&ni(c[2]+r,c[0])&&ni(c[3]+n,c[1])||i===2&&ni((c[2]-c[0])*(c[5]+n-c[1]),(c[3]-c[1])*(c[4]+r-c[0])))return;if(i===2){if(a=Nm({x:c[0],y:c[1]},{x:c[2],y:c[3]},{x:c[4]+r,y:c[5]+n}),a<4)return;a=Math.sqrt(a)}s&&te(e,"d",s);let u=e.pathSegList.getItem(1),h=u.r1,d=+u.largeArcFlag,p=+u.sweepFlag,f=Ro(c[0],c[1],c[2],c[3]),m=h*h-f/4;i==2?(o=(c[2]-c[0])*(c[5]-c[1])-(c[4]-c[0])*(c[3]-c[1]),c[i*2]+=r,c[i*2+1]+=n,l=(c[2]-c[0])*(c[5]-c[1])-(c[4]-c[0])*(c[3]-c[1]),o*l<0&&(p^=1)):(a=h+(d?1:-1)*(m>0?Math.sqrt(m):0),c[i*2]+=r,c[i*2+1]+=n,f=Ro(c[0],c[1],c[2],c[3])),h=f/(8*a)+a/2,d=h>a?0:1,c[0]=Zr(c[0]),c[1]=Zr(c[1]),h=Zr(h),c[2]=Zr(c[2]),c[3]=Zr(c[3]),te(e,"d","M"+c[0]+","+c[1]+" A"+h+","+h+" 0 "+d+" "+p+" "+c[2]+","+c[3])}},path_arc:{get(e){let{json:t}=k.getById(e),i=t.temp||t,r=mr.get8Dots2(i),n=new _i(i),s=n.vectorCenter();if(wt.isAnchorMode(t.gId)){let a=n.getMiddleAnchor();return{cmdkey:"arc",anchor:[i.x1,i.y1,i.x2,i.y2,a.x,a.y],"solid-circle":[{x:s.x,y:s.y,type:"solid-circle"}]}}return{cmdkey:"arc",bbox:r}},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=ht.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=k.getById(e.id).json;mr.syncArc(d,h,{updateD:!1})}}};function Vk(e,t,i){let r=Math.abs(e),n=Math.abs(t),s=e/r,a=t/n;return[4,6].includes(i)?[s*n,a*n]:[s*r,a*r]}function Nte(e,t,i,r,n,s={}){let a=r[0],o=r[1],l=r[4],c=r[5],u=(a+l)/2,h=(o+c)/2,d=l-a,p=c-o;[1,5,2].includes(i)&&(e=-e),[2,6,3].includes(i)&&(t=-t);let f=s.ctrl?Math.abs(e)*2/d:Math.abs(e)/d,m=s.ctrl?Math.abs(t)*2/p:Math.abs(t)/p;if(f=e>0?1-f:1+f,m=t>0?1-m:1+m,d===0&&(f=1),p===0&&(m=1),n){let[E,S]=Vk(f,m,i);m=S,f=E}let g=0,b=0;switch(i){case 0:g=l,b=c;break;case 1:g=a,b=c;break;case 2:g=a,b=o;break;case 3:g=l,b=o;break;case 4:g=(a+l)/2,b=c;break;case 5:g=a,b=(o+c)/2;break;case 6:g=(a+l)/2,b=o;break;case 7:g=l,b=(o+c)/2;break}let y=de.scale(f,m);return y=s.ctrl?y.setOrigin(u,h):y.setOrigin(g,b),y}var ht=class e{static createMatrixFrom6([t,i,r,n,s,a]){return new de([t,i,0,r,n,0,s,a,1])}static createMatrix3FromDOMMatrix(t){let{a:i,b:r,c:n,d:s,e:a,f:o}=t;return new de([i,-r,0,-n,s,0,a,-o,1])}static getMatrixFromDOMMatrix(t){if(t.transform.baseVal.length){let i=t.transform.baseVal.getItem(0).matrix,{a:r,b:n,c:s,d:a,e:o,f:l}=i;return[r,n,s,a,o,l]}return et.getMatrix6FromMatrix(new de)}static getTransformStr(t){return`matrix(${t.join(",")})`}static updateTransform(t,i){let r=this.getTransformStr(t);te(i,"transform",r)}static getEightControlMatrix3(t,i,r,n,s=!1,a=!1,o,l={}){if(a)return[7,5].includes(i)&&(n=0),[4,6].includes(i)&&(r=0),Nte(r,n,i,o,s,l);let c={0:2,1:3,2:0,3:1,4:6,5:7,6:4,7:5},u=t[i*2],h=t[i*2+1],d=c[i],p=t[d*2],f=t[d*2+1],m=(p+u)/2,g=(f+h)/2,b=l.ctrl?new j(m,g):new j(p,f),y=Math.atan2(t[1]-t[3],t[0]-t[2]),E=new j(u,h),S=new j(r,n),w=de.translate(-b.x,-b.y).rotate(-y),x=E.multiply3(w),I=E.add(S).multiply3(w),A=1,O=1;if(Ve.neq(x.x,0)&&Ve.neq(I.x,0)&&(A=I.x/x.x),Ve.neq(x.y,0)&&Ve.neq(I.y,0)&&(O=I.y/x.y),s){let M=Vk(A,O,i);A=M[0],O=M[1]}return w.scale(A,O).rotate(y).translate(b.x,b.y)}static rotateDots(t,i,r,n){let s=V3(i),a=de.rotate(s).setOrigin(r,n),o=[];for(let l of t){let c=new j(l[0],l[1]).multiply3(a);o.push(c.x,c.y)}return o}static getMaxOuterBoundingBox(t,i){let r=[],n=e.createMatrixFrom6(i.tempMatrix||i.matrix);for(let g of t){let b=new j(g[0],g[1]).multiply3(n);r.push(b)}let s=r[0].distance1(r[2]),a=r[1].distance1(r[3]),o=r[1],l=i.rotation;Ve.greatereq(s,a)&&(o=r[0]);let c=de.rotateD(-l).setOrigin1(o),u=new ot;for(let g of r)u=u.ext2(g.multiply3(c));let h=u.build(),d={x:h.minX,y:h.minY,width:h.width(),height:h.height()},p=[[d.x,d.y],[d.x+d.width,d.y],[d.x+d.width,d.y+d.height],[d.x,d.y+d.height],[d.x+d.width/2,d.y],[d.x+d.width,d.y+d.height/2],[d.x+d.width/2,d.y+d.height],[d.x,d.y+d.height/2]],f=[],m=de.rotateD(l).setOrigin1(o);for(let g of p){let b=new j(g[0],g[1]).multiply3(m);f.push(b.x,b.y)}return f}};function DD(e,t,i={updateMatrix:!0}){let r=ht.createMatrixFrom6(e.matrix);t&&(r=r.multiply3(t));let n=et.getMatrix6FromMatrix(r);i.updateMatrix&&(e.matrix=n),e.tempMatrix=n,ht.updateTransform(n,le(e.gId)),Mte(e)}var CD=class extends Qd{constructor(){super();this.start={x:0,y:0};this.center={x:.5,y:.5};this.unitWidth={x:1,y:0};this.unitHeight={x:0,y:1}}syncImage(i,r,n={updateMatrix:!0}){let s=zt.checkOne("obj",i,r);s!==!1&&zt.addCallBack(()=>{var a;s(),DD(i,r,n),(a=n.fn)==null||a.call(n)})}syncImageByRotation(i,r,n,s){let a=this.getRotationMatrix(i,r,n,s);a&&this.syncImage(r,a,{updateMatrix:!0,fn(){r.rotation=+i.toFixed(2)}})}getRotationMatrix(i,r,n,s){let{matrix:a}=r;ft(s)&&(s=r.rotation);let o=ht.createMatrixFrom6(a),l=n||new j(this.center.x,this.center.y).multiply3(o),c=Math.round((i-s)*100)/100;if(c)return de.rotateD(c).setOrigin1(l)}getImageShapeForAttr(i){let r=ht.createMatrixFrom6(i),n=new j(this.start.x,this.start.y).multiply3(r),s=n.x,a=n.y,o=new j(this.unitWidth.x,this.unitWidth.y).multiply3(r),l=new j(this.unitHeight.x,this.unitHeight.y).multiply3(r),c=o.distance1(n),u=l.distance1(n);return{x:s,y:a,width:c,height:u}}syncImagePosition(i,r,n){let s=k.getObj(i.id),{x:a,y:o,width:l,height:c}=this.getRectBBox(s.matrix);r=Kn(r)?r:a,n=Kn(n)?n:o;let u=r-a,h=n-o;if(!u&&!h)return;let d=de.translate(u,h);this.syncImage(s,d,{updateMatrix:!0})}syncImageSize(i,r,n,s){let{x:a,y:o,width:l,height:c}=this.getRectBBox(i.matrix),u=1,h=1;if(ft(n)||(u=n/l),ft(s)||(h=s/c),u===0||h===0||u===1&&h===1)return;let d=de.scale(u,h).setOrigin1(r);this.syncImage(i,d,{updateMatrix:!0})}},Lr=new CD,Mte=nl(e=>{H.messageBus.publish("panel/adsorption/updateShapeCache",[e.gId,"obj",e])},100);var tc=class e{static g(t,i,r){if(isFinite(i)||(i=0),isFinite(r)||(r=0),!t||i===0&&r===0)return;if($t(t)==="text"){let o=de.translate(i,r);xr.syncText(k.getById(t.id).json,o,{updateMatrix:!0});return}let s=t.children,a=s.length;for(let o=0;o<a;o++)$e(e,s[o].tagName)&&e[s[o].tagName](s[o],i,r)}static svg(t,i,r){isFinite(i)||(i=0),isFinite(r)||(r=0),!(!t||i===0&&r===0)&&(i!==0&&te(t,{x:+(te(t,"x")||0)+i}),r!==0&&te(t,{y:+(te(t,"y")||0)+r}))}static rect(t,i,r){if(isFinite(i)||(i=0),isFinite(r)||(r=0),!t||i===0&&r===0)return;let n=de.translate(i,r),s=new Q1,a=k.getRect(t.id);s.sync(a,n,{updateMatrix:!0})}static text(t,i,r){isFinite(i)||(i=0),isFinite(r)||(r=0)}static image(t,i,r){if(isFinite(i)||(i=0),isFinite(r)||(r=0),!t||i===0&&r===0)return;let n=de.translate(i,r);DD(k.gJsonCache.obj[t.id],n)}static circle1(t,i,r){isFinite(i)||(i=0),isFinite(r)||(r=0),!(!t||i===0&&r===0)&&te(t,{cx:+te(t,"cx")+i,cy:+te(t,"cy")+r})}static circle(t,i,r){if(isFinite(i)||(i=0),isFinite(r)||(r=0),!t||i===0&&r===0)return;let n=de.translate(i,r),s=k.getEllipse(t.id);Ei.syncEllipse(s,n,{updateMatrix:!0})}static ellipse(t,i,r){e.circle(t,i,r)}static line(t,i,r){isFinite(i)||(i=0),isFinite(r)||(r=0),!(!t||i===0&&r===0)&&te(t,{x1:+te(t,"x1")+i,x2:+te(t,"x2")+i,y1:+te(t,"y1")+r,y2:+te(t,"y2")+r})}static polyline(t,i,r){if(isFinite(i)||(i=0),isFinite(r)||(r=0),!t||i===0&&r===0)return;let n=Cc(te(t,"points")).split(/[\s\,]+/g);for(let s=0;s<n.length-1;s+=2)n[s]=lt(+n[s]+i,4),n[s+1]=lt(+n[s+1]+r,4);te(t,{points:n.join(" ")})}static polygon(t,i,r){e.polyline(t,i,r)}static path(t,i,r){if(isFinite(i)||(i=0),isFinite(r)||(r=0),!t||i===0&&r===0)return;(function(a,o){function l(h,d,p){h[d]=lt(h[d]+p,4)}if(te(t,"c_partid")==="arc"){let h=XS(t);h=h.map((d,p)=>p%2===0?+d+a:+d+o),te(t,{"third-point":h[4]+","+h[5]})}let c=t.getPathData(),u=c.length;for(let h=0;h<u;h++){let d=c[h],p=d.type,f=d.values;switch(p){case"M":case"L":case"T":l(f,0,a),l(f,1,o);break;case"H":l(f,0,a);break;case"V":l(f,0,o);break;case"C":l(f,0,a),l(f,1,o),l(f,2,a),l(f,3,o),l(f,4,a),l(f,5,o);break;case"S":case"Q":l(f,0,a),l(f,1,o),l(f,2,a),l(f,3,o);break;case"A":l(f,5,a),l(f,6,o);break;default:break}}t.setPathData(c)})(i,r);let n=te(t,"d"),s=k.getGroup(t.id);s.d=n}};function Rs(e){if(e){e='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">'+e.trim()+"</svg>";let t=zs(e);if(t){let i=document.importNode(t.documentElement,!0);return i.removeChild(i.childNodes[0])}}console.warn(`parse fail. invalid svg.
`+e)}function tD(e,t){let i=+e.x+e.width/2+","+(+e.y+e.height/2);return H.gCanvas.insertBefore(Et("rect",{x:e.x,y:e.y,c_start:i,width:e.width,height:e.height,"stroke-width":1,fill:"none",stroke:"red","stroke-dasharray":"4 1","vector-effect":"non-scaling-stroke",id:"selectionBox",...t}),H.gCanvas.firstChild)}function Ra(e){let t=Ge.canvas.originX,i=Ge.canvas.originY,r=Qn.getSanpSize("X"),n=Qn.getSanpSize("Y"),s=Math.round((e.x-t)/r)*r+t,a=Math.round((e.y-i)/n)*n+i;return{x:Zr(s),y:Zr(a)}}var Xo;function Mh(e,t,i){if(e.length>=dE){if(!Xo){let r=Rr(e);Xo=tD(r),$a.x=0,$a.y=0;for(let n of e)bu(n,"hidden")}tc.svg(Xo,t,i)}else for(let r=0;r<e.length;r++)Xn.move(k.getById(e[r].id).json,t,i);return $a.x+=t,$a.y+=i,!0}function Bte(){dt(Xo),Xo=null}$a.x=0;$a.y=0;function $a(e,t){if(!(!e||!e.length||!Xo)){if(Bte(),t!="cancel"){e.forEach(function(n){Oo(n,"hidden")});let i=$a.x,r=$a.y;for(let n=0;n<e.length;n++){let s=k.getById(e[n].id||e[n].gId).json;Xn.move(s,i,r)}}dl()}}function kte(e){if(!e||!e.length)return;let t=H.gZoom,i,r,n,s,a=Xt.getViewBox(),o="getBoundingClientRect";for(i=0;i<e.length;i++)if(r=e[i],!!r){if(r[o]){if(n=r[o](),!n.width&&!n.height)continue;n=[a[0]+n.left/t,a[1]+n.top/t,a[0]+n.right/t,a[1]+n.bottom/t]}else{if(n=es(r),!n.width&&!n.height)continue;n=[n.x,n.y,n.x+n.width,n.y+n.height]}s?s=[Math.min(s[0],n[0]),Math.min(s[1],n[1]),Math.max(s[2],n[2]),Math.max(s[3],n[3])]:s=n.slice(0,4)}return s?{x:s[0],y:s[1],width:s[2]-s[0],height:s[3]-s[1]}:void 0}function YS(){let e=new Ja,t=k.getBBox(),i=new ot;if(i.ext1(t),!e.isHidden()){let n=e.getBBox();i.ext10(n)}let r=i.build();if(r.area()===0)return Bu(Ge.canvas.originX,Ge.canvas.originY);{let n=kc(r);return Jl(n)}}function VS(e=1){let t=Ae.get()||[],[i,r]=t.reduce((s,a)=>($t(a)==="auxiliaryLine"?s[0].push(a):s[1].push(a),s),[[],[]]);if(i.length===t.length)return jk(i);let n=Rr(r,!0);return Jl(n,e)}function Jl(e,t=1,i=!1,r=20){if(!e||!e.x&&!e.y&&!e.width&&!e.height)return;let n=H.gZoom;t&&!e.width&&!e.height&&(t=void 0);let s=e.x+e.width/2,a=e.y+e.height/2,o=document.body.clientWidth||9,l=document.body.clientHeight||9,c=t?Math.min((o-r)/e.width,(l-r)/e.height):n,u=t&&isFinite(c)?c*100:n*100,h=u/100;u<.1?(u=.1,h=u/100):u>H.zoomRatio.max&&(u=H.zoomRatio.max,h=u/100);let d=h!=n,p=Xt.getViewBox();if(p[0]=s-p[2]/2,p[1]=a-p[3]/2,Xt.setViewBox(p),d){let f={clientX:(s-p[0])*n,clientY:(a-p[1])*n};return i&&(u=u>180?180:u),rc(u,f,!0)}return mw(p)}function Bu(e,t){let i=Xt.getViewBox();return i[0]+=e-(i[0]+i[2]/2),i[1]+=t-(i[1]+i[3]/2),Xt.setViewBox(i),mw(i)}function Nk(e,t){let i=kte(e);i&&Fte(i,t)}function Fte(e,t){let i=H.gZoom,r=e.x,n=e.y,s=r+e.width,a=n+e.height,o=Xt.getViewBox();t=isFinite(t)?t/i:20/i,r-=t,n-=t,s+=t,a+=t;let l,c;r<=o[0]==s>=o[0]+o[2]?l=0:r<=o[0]?l=r-o[0]:l=s-o[0]-o[2],n<=o[1]==a>=o[1]+o[3]?c=0:n<=o[1]?c=n-o[1]:c=a-o[1]-o[3],(l||c)&&(o[0]+=l,o[1]+=c,Xt.setViewBox(o))}function vh(e){let t=Xt.getViewBox(),i=H.gZoom;return{x:t[0]+e.x/i,y:t[1]+e.y/i}}function Gg(e){let t=Xt.getViewBox(),i=H.gZoom,r=(e.x-t[0])*i,n=(e.y-t[1])*i;return{clientX:r,clientY:n}}function k5(e,t=Ge.adsorbGrid.gridSize,i){i=i||{x:Ge.canvas.originX,y:Ge.canvas.originY};let r={x:+e.x,y:+e.y},n=t,s=t,a=(e.x-i.x)%n,o=(e.y-i.y)%s;return a&&(a<0&&(a+=n),r.x+=-a+(a<n/2?0:n)),o&&(o<0&&(o+=s),r.y+=-o+(o<s/2?0:s)),r.x=lt(r.x,2),r.y=lt(r.y,2),r}function Gte(e,t){return{x:e.x*t.a+e.y*t.c+t.e,y:e.x*t.b+e.y*t.d+t.f}}function Ute(e,t){let i=[e.x,e.x+e.width,e.x,e.x+e.width],r=[e.y,e.y,e.y+e.height,e.y+e.height];for(let l=0,c;l<4;l++)c=Gte({x:i[l],y:r[l]},t),i[l]=c.x,r[l]=c.y;let n=Math.min.apply(0,i),s=Math.min.apply(0,r),a=Math.max.apply(0,i),o=Math.max.apply(0,r);return{x:n,y:s,width:a-n,height:o-s}}function MB(e){let t=[],i=new Map;e.forEach(n=>{t.push(...Hr('[c_partid="auxiliaryLine"]',n)),t.forEach(function(s){s.style.display!=="none"&&(i.set(s,s.style.display),s.style.display="none")})});let r=Rr(e);return i.size&&i.forEach((n,s)=>{s.style.display=n,i.delete(s)}),r}function Hk(e){let t=Hr('[c_partid="auxiliaryLine"]',e),i=new Map;t.forEach(function(n){n.style.display!=="none"&&(i.set(n,n.style.display),n.style.display="none")});let r=es(e);return i.size&&i.forEach((n,s)=>{s.style.display=n,i.delete(s)}),r}function zk(e){let t,i;try{i=e.cloneNode(!0),H.gCanvas.appendChild(i),i.style.display="inline";let r=i.getBBox();i.style.display="",t={x:r.x,y:r.y,width:r.width,height:r.height},dt(i)}catch{i&&(i.style.display="",dt(i)),t={x:0,y:0,width:0,height:0}}return t}function es(e){let t,i;try{let r=()=>{},n=e.getAttribute("display");n==="none"&&(e.removeAttribute("display"),r=()=>e.setAttribute("display",n)),i=e.getBBox(),t={x:i.x,y:i.y,width:i.width,height:i.height},r()}catch{t=zk(e)}try{!t.x&&!t.y&&!t.width&&!t.height&&le("root").compareDocumentPosition(e)!=20&&(t=zk(e))}catch(r){console.log(r)}return t}function Rr(e,t){let i={x:0,y:0,width:0,height:0};if(!e||!e.length)return console.error(e),i;let r;for(let n=0;n<e.length;n++){if(!e[n])continue;let s=ec(e[n],t);(s.x||s.y||s.width||s.height)&&(r?(r.width=Math.max(s.x+s.width,r.x+r.width)-Math.min(s.x,r.x),r.height=Math.max(s.y+s.height,r.y+r.height)-Math.min(s.y,r.y),r.x=Math.min(s.x,r.x),r.y=Math.min(s.y,r.y)):r=s)}return r||i}function Y5(e,t){let i={x:0,y:0,width:0,height:0};if(!e||!e.length)return console.error(e),i;let r=e.filter(a=>te(a,"c_partid")!=="auxiliaryLine"),n=e.filter(a=>te(a,"c_partid")==="auxiliaryLine"),s;for(let a=0;a<r.length;a++){if(!r[a])continue;let o=ec(r[a],t);te(r[a],"c_partid")==="auxiliaryLine"&&(o.width=0,o.height=0),(o.x||o.y||o.width||o.height)&&(s?(s.width=Math.max(o.x+o.width,s.x+s.width)-Math.min(o.x,s.x),s.height=Math.max(o.y+o.height,s.y+s.height)-Math.min(o.y,s.y),s.x=Math.min(o.x,s.x),s.y=Math.min(o.y,s.y)):s=o)}for(let a=0;a<n.length;a++){if(!n[a])continue;let{rotation:o}=k.getAuxiliaryLine(n[a].id),l=ec(n[a],t);l.width=0,l.height=0,(l.x||l.y||l.width||l.height)&&(s?o?(s.width=Math.max(l.x+l.width,s.x+s.width)-Math.min(l.x,s.x),s.x=Math.min(l.x,s.x)):(s.height=Math.max(l.y+l.height,s.y+s.height)-Math.min(l.y,s.y),s.y=Math.min(l.y,s.y)):s=l)}return s||i}function fo(e,t,i){if(!e||!e[0])return{x:0,y:0};if(Xo){let s=Xo.getBBox();return{x:s.x+s.width/2,y:s.y+s.height/2}}let r=Rr(e,t),n={x:Zr(r.x+r.width/2),y:Zr(r.y+r.height/2)};return(!i||!i.ignoreSnap)&&(n=Ra(n)),n}function AD(e){let{matrix:t,tempMatrix:i}=e,[r,n,s,a,o,l]=i||t,c=Math.atan2(s,r),u=Math.atan2(a,n),h=Math.cos(c),d=Math.sin(c),p=Math.abs(r*h+s*d);h=Math.cos(u),d=Math.sin(u);let f=Math.abs(n*h+a*d);return{x:o-p,y:l-f,width:p*2,height:f*2}}function $1(e){let{matrix:t,tempMatrix:i}=e,r=ht.createMatrixFrom6(i||t),n=0,s=1,a=0,o=1,l=[[n,a],[s,a],[s,o],[n,o]],c=new ot;for(let h of l){let d=new j(h[0],h[1]).multiply3(r);c.ext6(d.x,d.y)}let u=c.build();return{x:u.minX,y:u.minY,width:u.width(),height:u.height()}}function K4(e){let t=qi(e.d),i=new ot;for(let n of t)i.ext1(n.multiply3(de.MIRROR_Y).bbox());let r=i.build();return{x:r.minX,y:r.minY,width:r.width(),height:r.height()}}function sf(e){let t=ht.createMatrixFrom6(e.tempMatrix||e.matrix),i=new ot().ext6(0,0).ext6(e.cacheWidth,-e.cacheHeight).build().transform(t);return{x:i.minX,y:i.minY,width:i.width(),height:i.height()}}function Ph(e){let t,{cmdKey:i,json:r}=k.getById(e.id);switch(i){case"ellipse":return AD(r);case"arc":return new _i(r.temp||r).bbox();case"obj":case"rect":return $1(r);case"group":return es(e)||p2(r);case"text":return sf(r);case"dimensionLength":case"dimensionAngle":case"dimensionRadius":case"auxiliaryPoint":case"auxiliaryLine":return vi(r,i)}if(e.tagName!="g"){let a=e.style.display;return e.style.display="inline !important",e.tagName=="path"?t=Xk(e):t=es(e),e.style.display=a,t}else t=es(e);if(!t.width&&!t.height||t.x||t.y)return t;function n(a){let o=window.getComputedStyle&&getComputedStyle(a);return!o||o.display=="none"}function s(a){let o=a.children||[].filter.call(a.childNodes,function(c){return c.nodeType===1}),l;for(let c=0,u,h=o.length,d;c<h;c++)if(d=o[c],!(te(d,"display")=="none"||d.style.display=="none"||n(d))){try{if(u=d.getBBox(),!u.width&&!u.height&&!u.x&&!u.y)continue}catch{continue}if(d.tagName=="g"?u=s(d):d.tagName=="path"&&(u=Xk(d)),u&&(u.width||u.height)){if(te(d,"transform"))try{let p=d.getTransformToElement(a);u=Ute(u,p)}catch{}l=l?N3(l,u):u}}return l||{x:0,y:0,width:0,height:0}}return t=s(e),!t.width&&!t.height&&(t=Hk(e)),t}function Xk(e,t){let i=es(e),r,n;return!i.width&&!i.height&&!i.x&&!i.y?te(e,"d")?(r=e.getPointAtLength(0),{x:r.x,y:r.y,width:0,height:0}):{x:0,y:0,width:0,height:0}:i}function ec(e,t){let i=Ph(e);return i.x=Zr(i.x),i.y=Zr(i.y),i.width=Zr(i.width),i.height=Zr(i.height),i}function nf(e){if(!e||e.tagName!="path")return;if(te(e,"c_partid")==="group")return"group";let t=e.pathSegList,i=t.numberOfItems,r="";for(let n=0;n<i&&n<5;n++)r+=t.getItem(n).pathSegTypeAsLetter;if(r=="MA"){if(te(e,"c_partid")==="arc")return"arc";if(te(e,"c_partid")==="earc")return"earc"}else if(/^(?:MALZ|MLAZ|MLLAZ?)$/.test(r))return"pie"}function XS(e){if(te(e,"c_partid")==="arc"&&te(e,"third-point")){let t=e.getPathData(),i=te(e,"third-point").split(",");return[].concat(t[0].values,t[1].values.slice(-2),+i[0],+i[1])}console.error("Invalid input, e needs to be arc!")}function _D(e){return e.pathSegTypeAsLetter}function Wk(e){return{M:1,L:1,H:1,V:1,A:1,T:1,S:2,Q:2,C:3,Z:0}[e.toUpperCase()]||0}function Yte(e,t,i){let r=e.numberOfItems;for(let n=i;n<r;n++){let s=_D(e.getItem(n));if(s=="M"||s=="m")return n>i?-1:n;if(s==t)return n}return-1}function ck(e,t){if(!e||e.tagName!="path"||isNaN(t)||t<0||!nf(e))return;let r=Fi.get(e),n=e.pathSegList,s=n.numberOfItems,a=-1;for(let o=0;o<s;o++){let l=o-1>-1?n.getItem(o-1):"",c=n.getItem(o),u=_D(c),h,d=o+1<s?n.getItem(o+1):"",p=o+1<s?_D(d):"",f,m=Wk(u),g=p?Wk(p):0;if(!(u.toUpperCase()=="M"&&(!p||p.toUpperCase()=="M"||p=="Z"))&&(a+=m,!(a<t)))switch(u.toUpperCase()){case"M":f=a+g,u=="M"?(c.x=r[f*2],c.y=r[f*2+1]):(c.x+=r[f*2]-r[a*2],c.y+=r[f*2+1]-r[a*2+1]);let b=Yte(n,"Z",o+1);b>=0&&(h=e.createSVGPathSegLinetoAbs(r[a*2],r[a*2+1]),n.replaceItem(h,b)),n.removeItem(o+1);return;case"L":case"H":case"V":case"T":case"A":n.removeItem(o);return;case"S":case"Q":n.removeItem(o);return;case"C":switch(u+p){case"C":{if(a===t){n.removeItem(o);return}if(a-1===t){c.x2=c.x,c.y2=c.y;return}if(a-2===t){c.x1=l.x,c.y1=l.y;return}break}case"CC":{if(a===t){d.x1=l.x,d.y1=l.y,n.removeItem(o);return}if(a-1===t){c.x2=c.x,c.y2=c.y;return}if(a-2===t){c.x1=l.x,c.y1=l.y;return}break}case"CL":{if(a-2===t){c.x1=l.x,c.y1=l.y;return}if(a-1===t){c.x2=c.x,c.y2=c.y;return}if(a===t){n.removeItem(o);return}break}case"CS":c.x2=r[(a+1)*2],c.y2=r[(a+1)*2+1],n.removeItem(o+1);return;case"Cc":d=n.getItem(o+1),d.x1=r[(a-2)*2]-r[(a-3)*2],d.y1=r[(a-2)*2+1]-r[(a-3)*2+1],d.x2=r[(a+2)*2]-r[(a-3)*2],d.y2=r[(a+2)*2+1]-r[(a-3)*2+1],d.x=r[(a+3)*2]-r[(a-3)*2],d.y=r[(a+3)*2+1]-r[(a-3)*2+1],n.removeItem(o);return;case"Cs":h=e.createSVGPathSegCurvetoCubicRel(r[f*2-2],r[f*2-1],void 0,void 0,void 0,void 0),h.x1=r[(a-2)*2]-r[(a-3)*2],h.y1=r[(a-2)*2+1]-r[(a-3)*2+1],h.x2=r[(a+2)*2]-r[(a-3)*2],h.y2=r[(a+2)*2+1]-r[(a-3)*2+1],h.x=r[(a+3)*2]-r[(a-3)*2],h.y=r[(a+3)*2+1]-r[(a-3)*2+1],n.replaceItem(h,o),n.removeItem(o+1);return;case"cC":case"cS":case"cc":case"cs":n.removeItem(o);break;default:n.removeItem(o);break}return;default:return}}}var Nt=class Nt extends Mu{static getDefaultGJsonCache(){return{head:{originX:0,originY:0,title:"",display_title:"",name:"",docType:ta.PANEL,layer:1,width:"",height:"",desc:"",maxId:0,material:"PVC"},itemOrder:[],BBox:{x:0,y:0,width:0,height:0},group:{},obj:{},rect:{},text:{},ellipse:{},arc:{},auxiliaryLine:{},auxiliaryPoint:{},combination:{},_runtime:{}}}static getBBox(){let t=new ot;return Nt.iterator((i,r,n)=>{if(!["combination","auxiliaryLine","_runtime"].includes(r))try{let s=vi(i,r);t.ext1(St.extendRect(s))}catch(s){console.log(s,r)}}),t.valid()||t.ext1(new St(0,0,0,0)),Nt.iteratorAuxiliaryLine(i=>{let r=t.build();i.rotation===90&&!r.isContainsX(i.x)&&t.ext6(i.x,r.maxY),i.rotation===0&&!r.isContainsY(i.y)&&t.ext6(r.minX,i.y)}),t.build()}static getGJsonCache(t=!1){t&&this.iterator((r,n)=>{if(n!=="combination")switch(r.displayVisible=!ai.eleIsHide(r),r.cmdKey){case"text":break;default:r.d=ef(r);break}});let i=this.getBBox();return this.gJsonCache.BBox={x:i.minX,y:i.minY,width:i.width(),height:i.height()},this.gJsonCache}static getHead(){return this.gJsonCache.head}static setHead({width:t,height:i}){return this.gJsonCache.head.width=t,this.gJsonCache.head.height=i,this}static exchangeJsonCache(t){let i=this.gJsonCache;this.gJsonCache=t,this.id2cmd.clear();let r=setTimeout(()=>{Kr("you need exchange back")},1e3);return()=>{this.gJsonCache=i,clearTimeout(r)}}static buildId2CmdData(){this.iterator((t,i,r)=>{this.id2cmd.set(t.gId||r,i)})}static getById(t){let i=this.id2cmd.get(t);return!i&&(this.buildId2CmdData(),i=this.id2cmd.get(t),!i)?(console.error(t,i,"Plz check code."),{json:null,cmdKey:""}):{json:this.CmdKeyMethodMap[i](t),cmdKey:i}}static getJsonCacheByIds(t){let i=new Set,r=new rt,n=Object();for(let a of t){let o=r.searchCombination(a);o&&i.add(o)}let s=new rt().getAllCombinationData([...i]);for(let a of s)sr(n,"combination")[a.gId]=a;return t.forEach(a=>{let{json:o,cmdKey:l}=Nt.getById(a);sr(n,l)[a]=o}),n}static updatePrimitiveJson(t,i,r){let{json:n,cmdKey:s}=this.getById(t);n[i]=r,this.changedJsoncache(t,s)}static getDimension(t){let i=sr(Nt.gJsonCache,"dimension");return t?i[t]||{}:i}static getDimensionLength(t){let i=sr(Nt.gJsonCache,"dimensionLength");return t?i[t]||{}:i}static getDimensionRadius(t){let i=sr(Nt.gJsonCache,"dimensionRadius");return t?i[t]||{}:i}static getDimensionAngle(t){let i=sr(Nt.gJsonCache,"dimensionAngle");return t?i[t]||{}:i}static getRect(t){let i=sr(Nt.gJsonCache,"rect");return t?i[t]||{}:i}static insertOneData(t,i,r){switch(i){case"obj":Nt.setObj(t,r);break;case"group":Nt.setGroup(t,r);break;case"ellipse":Nt.setEllipse(t,r);break;case"rect":Nt.setRect(t,r);break;case"text":Nt.setText(t,r);break;case"auxiliaryLine":Nt.setAuxiliaryLine(t,r);break;case"auxiliaryPoint":Nt.setAuxiliaryPoint(t,r);break;case"arc":this.setArc(t,r);break;case"dimensionLength":case"dimensionRadius":case"dimensionAngle":this.setDimension(t,r,i);break;default:console.error(i,"check code");break}return this}static setRect(t,i){let r=sr(Nt.gJsonCache,"rect");if(!i||Mt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"rect");return}return r[t]=i,this.changedJsoncache(t,"rect"),i}static getArc(t){let i=sr(Nt.gJsonCache,"arc");return t?i[t]||Object.create(null):i}static setArc(t,i){let r=sr(Nt.gJsonCache,"arc");return!i||Mt(i)?delete r[t]:r[t]=i,this.changedJsoncache(t,"arc"),this}static getEllipse(t){let i=sr(Nt.gJsonCache,"ellipse");return t?i[t]||Object.create(null):i}static setEllipse(t,i){let r=sr(Nt.gJsonCache,"ellipse");if(!i||Mt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"ellipse");return}return r[t]=i,this.changedJsoncache(t,"ellipse"),i}static setDimension(t,i,r="dimension"){let n=sr(Nt.gJsonCache,r);return!i||Mt(i)?Reflect.deleteProperty(n,t):n[t]=i,this.changedJsoncache(t,r),this}static getCombination(t){let i=sr(Nt.gJsonCache,"combination");return t?i[t]||Object.create(null):i}static deleteCombInParent(t){let r=new rt().findParent(t);return r&&r.combinations.splice(r.combinations.indexOf(t),1),this}static setCombination(t,i){let r=sr(Nt.gJsonCache,"combination");if(!i||Mt(i)){Reflect.deleteProperty(r,t);return}r[t]=i}static getAuxiliaryLine(t){let i=sr(Nt.gJsonCache,"auxiliaryLine");return t?i[t]||Object.create(null):i}static setAuxiliaryLine(t,i){let r=sr(Nt.gJsonCache,"auxiliaryLine");if(!i||Mt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"auxiliaryLine");return}return r[t]=i,this.changedJsoncache(t,"auxiliaryLine"),i}static getAuxiliaryPoint(t){let i=sr(Nt.gJsonCache,"auxiliaryPoint");return t?i[t]||Object.create(null):i}static setAuxiliaryPoint(t,i){let r=sr(Nt.gJsonCache,"auxiliaryPoint");if(!i||Mt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"auxiliaryPoint");return}return r[t]=i,this.changedJsoncache(t,"auxiliaryPoint"),i}static getRuntime(t){let i=sr(Nt.gJsonCache,"_runtime");return t?i[t]||{}:i}static setRuntime(t,i){let r=sr(Nt.gJsonCache,"_runtime");if(!i||Mt(i)){Reflect.deleteProperty(r,t);return}return r[t]=i,i}static getText(t){let i=sr(Nt.gJsonCache,"text");return t?i[t]||{}:i}static setText(t,i){let r=sr(Nt.gJsonCache,"text");if(!i||Mt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"text");return}return r[t]=i,this.changedJsoncache(t,"text"),i}static getObj(t){let i=sr(Nt.gJsonCache,"obj");return t?i[t]||{}:i}static setObj(t,i){let r=sr(Nt.gJsonCache,"obj");if(!i||Mt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"obj");return}return this.changedJsoncache(t,"obj"),r[t]=i,i}static getGroup(t){let{group:i={}}=Nt.gJsonCache;return t?i[t]||{}:i}static setGroup(t,i){let r=sr(Nt.gJsonCache,"group");if(!i||Mt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"group");return}return r[t]=i,this.changedJsoncache(t,"group"),i}static removeMultiData(t){let i=new Set;for(let r of t){let n=r.id;i.add(n),this.removeOne({id:n})}this.removeItemOrder(i)}static removeOne(t){var o;if(!t){console.error("Plz check code");return}let i=t.id,r=this.getById(i).cmdKey,s=new rt().searchCombination(i);if(s){let l=Nt.getCombination(s);l.elements.splice(l.elements.indexOf(i),1)}let a=Nt.gJsonCache[r];a&&a[i]&&(delete a[i],this.changedJsoncache(i,r)),(o=ri.renderer)==null||o.removeNode(i),bt.removeShapeCache(i)}static freshItemOrder(){let t=R3().filter(i=>Nt.getById(i).json);return Nt.gJsonCache.itemOrder=t,this}static removeItemOrder(t){let i=[];for(let r of this.getItemOrder())t.has(r)||i.push(r);this.gJsonCache.itemOrder=i}static getItemOrder(){let t=Nt.gJsonCache.itemOrder;return jt(t)}static getItemOrderMap(){let t=0,i=new Map;for(let r of this.gJsonCache.itemOrder)i.set(r,t++);return i}static getItemOrderSortMap(){let t=this.getItemOrder(),i=new Map;for(let r=0;r<t.length;r++)i.set(t[r],r);return i}static changedJsoncache(t,i){let r=Nt.gJsonCache[i][t];!r||Mt(r)?bt.removeShapeCache(t):bt.updateShapeCache(t,i,r),Ni.updateHole(),cn.updateMeasureValue()}static iterator(t){this.iteratorEllipse(t),this.iteratorArc(t),this.iteratorRect(t),this.iteratorGroup(t),this.iteratorObj(t),this.iteratorText(t),this.iteratorAuxiliaryLine(t),this.iteratorAuxiliaryPoint(t),this.iteratorDimension(t),this.iteratorDimensionLength(t),this.iteratorDimensionAngle(t),this.iteratorDimensionRadius(t),this.iteratorCombination(t),this.iteratorRuntime(t)}static iteratorRuntime(t){let i=this.getRuntime();for(let r in i)t(i[r],"_runtime",r)}static iteratorText(t){let i=this.getText();for(let r in i)t(i[r],"text",r)}static iteratorObj(t){let i=this.getObj();for(let r in i)t(i[r],"obj",r)}static iteratorRect(t){let i=this.getRect();for(let r in i)t(i[r],"rect",r)}static iteratorArc(t){let i=this.getArc();for(let r in i)t(i[r],"arc",r)}static iteratorEllipse(t){let i=this.getEllipse();for(let r in i)t(i[r],"ellipse",r)}static iteratorAuxiliaryPoint(t){let i=this.getAuxiliaryPoint();for(let r in i)t(i[r],"auxiliaryPoint",r)}static iteratorGroup(t){let i=this.getGroup();for(let r in i)t(i[r],"group",r)}static iteratorAuxiliaryLine(t){let i=this.getAuxiliaryLine();for(let r in i)t(i[r],"auxiliaryLine",r)}static iteratorDimension(t){let i=this.getDimension();for(let r in i)t(i[r],"dimension",r)}static iteratorDimensionLength(t){let i=this.getDimensionLength();for(let r in i)t(i[r],"dimensionLength",r)}static iteratorDimensionRadius(t){let i=this.getDimensionRadius();for(let r in i)t(i[r],"dimensionRadius",r)}static iteratorDimensionAngle(t){let i=this.getDimensionAngle();for(let r in i)t(i[r],"dimensionAngle",r)}static iteratorCombination(t){let i=this.getCombination();for(let r in i)if(t(i[r],"combination",r)===fh)break}static getAllAssistPrimitive(){let t={};for(let r of["auxiliaryLine","auxiliaryPoint","dimension","dimensionAngle","dimensionLength","dimensionRadius"])t[r]=!0;let i=[];return Nt.iterator(r=>{t[r.cmdKey]&&i.push(r.gId)}),i}static getRefId(t){let i=this.freshItemOrder().getItemOrder(),r=i.length;for(let n=0;n<r;n++)if(t===i[n])return i[n+1]||""}static translateByOrigin(t,i){let{originX:r,originY:n}=Nt.gJsonCache.head,[s,a]=[+t-(r||0),+i-(n||0)];return[ni(s,0)?0:+s,ni(a,0)?0:+a]}static getShapeAttr(t,i){let r=H.panelThemeCache.color,n=H.panelThemeCache.shape,s=H.panelThemeCache.fontStyle,a=H.panelThemeCache.fillColor,o={type:i,"attr-topic":Xi[i],"attr-id":"$"+t.id,"attr-name":t.name||"","attr-layer":t.layer};if($e(t,"locked")&&(o["attr-locked"]=t.locked===!0?"yes":"no"),$e(t,"hide")&&(o["attr-hide"]=t.hide===!0?"yes":"no"),$e(t,"visible")&&(o["attr-conceal"]=t.visible===!0?"no":"yes"),+t.layer===2){let h=Math.round(t.transparencyPrint*100),d=Math.round(t.transparencyWhite*100);o["attr-transparency"]=h+"%,"+d+"%"}let l={};switch(i){case"text":{t.type="text";let h=Fk(t);delete o["attr-name"],Object.assign(o,h,c(t)),+t.layer===2&&delete o["attr-font-color"];break}case"rect":{let{x:h,y:d,width:p,height:f}=Li.getRectBBox(t.matrix),{obbWidth:m,obbHeight:g}=Fh(t),b=fi.transferXYByReference({x:h,y:d,width:p,height:f}),[y,E]=this.translateByOrigin(b[0],b[1]),S=Tw(t,n,i);Object.assign(o,{"reference-point":fi.getReferencePoint(),"attr-width":p,"attr-height":f,"attr-obb-width":m,"attr-obb-height":g,"attr-x":y,"attr-y":E,"attr-radius":t.rx||0,"attr-rotation":Math.abs(t.rotation||0)},S)}break;case"ellipse":{Object.assign(o,Mk(t),Tw(t,n,i));break}case"group":{let h=es(le(t.gId)),{obbWidth:d,obbHeight:p}=Fh(t),f=fi.transferXYByReference(h),[m,g]=Nt.translateByOrigin(f[0],f[1]);Object.assign(o,{"reference-point":fi.getReferencePoint(),"attr-width":h.width,"attr-height":h.height,"attr-obb-width":d,"attr-obb-height":p,"attr-x":+m.toFixed(2),"attr-y":+g.toFixed(2),"attr-rotation":Math.abs(t.rotation||0)},Tw(t,n,i));break}case"obj":{l=kk(t);break}case"dimension":l=Bk(t);break;case"auxiliaryLine":{l=Yk(t,n,r);break}case"auxiliaryPoint":{let[h,d]=Nt.translateByOrigin(t.x,t.y),p=ZC[i];l={"attr-color":t.fillColor||`${a[p]}`,"attr-x":+h.toFixed(2),"attr-y":+d.toFixed(2)};break}case"combination":{let h=t,d=new rt().getAllElesfromTop(h.gId).elements,p=Array.from(d).map(y=>le(y)),f=Rr(p),m=fi.transferXYByReference(f),[g,b]=Nt.translateByOrigin(m[0],m[1]);l={"reference-point":fi.getReferencePoint(),"attr-name":h.name,"attr-x":g,"attr-y":b,"attr-width":f.width,"attr-height":f.height,"attr-rotation":0};break}case"dimensionLength":{l=Uk(t);break}case"dimensionAngle":{l=Gk(t);break}case"dimensionRadius":{let h=t,[d,p]=Nt.translateByOrigin(h.x1,h.y1),[f,m]=Nt.translateByOrigin(h.x2,h.y2),{rx:g,ry:b}=new cn(h).getRxRyPixel();l={"attr-start-x":d,"attr-start-y":p,"attr-end-x":f,"attr-end-y":m,"attr-long-radius":g,"attr-short-radius":b,"attr-rotation":Math.abs(h.rotation||0)};break}case"arc":{l=vw(t),Object.assign(l,Tw(t,n,i));break}default:console.error(i);break}function c(h){let d=h.type,p=s[d];return{"attr-font-color":h.strokeColor||h.fillColor,"attr-font-family":h.fontFamily,"attr-font-weight":h.fontWeight?"bold":"normal","attr-font-size":h.fontSize,"attr-font-style":h.italic==null?`${Fd(p.fontItalic).text}`:h.italic?"italic":"normal","attr-font-underline":h.underline==null?`${x5(p.fontUnderline).text}`:h.underline?"underline":"inherit","attr-origin":u(h)}}function u(h){let d=!1;$e(h,"hAlign")||(h.hAlign=0),$e(h,"vAlign")||(h.vAlign=2),$e(h,"vAlign")&&h.vAlign===null&&(d=!0);let p=h.hAlign+""+(d?0:h.vAlign),f="";switch(p){case"00":f="start|0";break;case"01":f="start|1";break;case"02":f="start|2";break;case"10":f="middle|0";break;case"11":f="middle|1";break;case"12":f="middle|2";break;case"20":f="end|0";break;case"21":f="end|1";break;case"22":f="end|2";break}return d&&f==="start|0"&&f||f}return Object.assign(o,l)}static getProductWidthHeight(){let{width:t,height:i,originX:r,originY:n}=this.gJsonCache.head;t||(t=N1.width),i||(t=N1.height);try{let a=[],o=Yt(t,"pixel"),l=Yt(i,"pixel"),c=St.extendRect({x:0,y:-l,width:o,height:l});Nt.iterator((m,g)=>{m.layer===3&&c.isIntersect(f2(m,g))&&a.push(m)});let u=sg(a),h=St.extendRect(u),d=c.intersection1(h),p=Yt(d.width(),"pixel","mm"),f=Yt(d.height(),"pixel","mm");return{width:s(p),height:s(f)}}catch{return{width:t,height:i}}function s(a){return Math.round(a*100)/100+"mm"}}};Nt.gJsonCache={head:{originX:0,originY:0,title:"",display_title:"",name:"",docType:ta.PANEL,layer:1,width:"",height:"",desc:"",maxId:0,material:"PVC"},itemOrder:[],BBox:{x:0,y:0,width:0,height:0},group:{},obj:{},rect:{},text:{},ellipse:{},arc:{},auxiliaryLine:{},auxiliaryPoint:{},combination:{},_runtime:{}},Nt.id2cmd=new Map,Nt.CmdKeyMethodMap={text:t=>Nt.getText(t),obj:t=>Nt.getObj(t),rect:t=>Nt.getRect(t),group:t=>Nt.getGroup(t),ellipse:t=>Nt.getEllipse(t),arc:t=>Nt.getArc(t),combination:t=>Nt.getCombination(t),dimension:t=>Nt.getDimension(t),dimensionLength:t=>Nt.getDimensionLength(t),dimensionRadius:t=>Nt.getDimensionRadius(t),dimensionAngle:t=>Nt.getDimensionAngle(t),auxiliaryLine:t=>Nt.getAuxiliaryLine(t),auxiliaryPoint:t=>Nt.getAuxiliaryPoint(t),_runtime:t=>Nt.getRuntime(t)};var k=Nt;function Tw(e,t,i){let r=ZC[i];r="ellipse"===r||"group"===r?"circle":r;let n=e.strokeStyle==null?t[r].dash:e.strokeStyle,s=e.strokeWidth==null?t[r].width:e.strokeWidth,a={"attr-stroke-color":e.strokeColor||"none","attr-fill-color":e.fillColor||"none","attr-stroke-width":`${s||0}`,"attr-stroke-style":Fd(n).value,type:r,"attr-fill-color-display":e.displayFill,"attr-stroke-color-display":e.displayStroke};return fi.filterAttrByLayer(a,e.layer),a}window.frameElement&&window.addEventListener("unload",()=>{var e;(e=k.compilerManager)==null||e.destroy()});var PD=class{constructor(){this.taskQueue=[];this.timeId=null}run(t,i,r){this.taskQueue.push(this.createTask(t,i,r)),clearTimeout(this.timeId),this.timeId=setTimeout(()=>{this.walker()},0)}createTask(t,i,r){return()=>{let n=le(i),s=k.getById(i).json;for(let a in t){let o=t[a];switch(k.updatePrimitiveJson(i,a,o),a){case"matrix":this.updateMatrix(n,r,o);break;case"cacheHeight":case"cacheWidth":case"name":case"key":case"tempMatrix":case"rotation":break;case"d":this.updateD(n,r,o);break;case"start":case"end":{let l=k.getDimension(i),c=new In(l).render();c=null}break;case"x":{this.updateX(n,r,o);break}case"y":{this.updateY(n,r,o);break}case"rx":te(n,"rx",o);break;case"ry":te(n,"ry",o);break;case"layer":te(n,"layer",o);break;case"category":this.updateCategory(n,r,o);break;case"cover":break;case"hide":te(n,"hide",o?"1":"0");break;case"locked":break;case"opacity":break;case"scope":break;case"fillColor":case"displayFill":K1(s);break;case"displayStroke":case"strokeColor":J1(n,r,s);break;case"strokeWidth":ED(n,r,o);break;case"transparencyWhite":case"transparencyPrint":{let l=k.getById(n.id).json,c=+t["attr-transparency-print"]||l.transparencyPrint,u=+t["attr-transparency-white"]||l.transparencyWhite,h=of(c*100,u*100);te(n,"opacity",h);break}case"x1":case"y1":case"x2":case"y2":case"measureX1":case"measureX2":case"measureY1":case"measureY2":this.updateX1(n.id);break;case"textX":case"textY":case"angleX":case"angleY":this.updateTextX(n.id);break;case"visible":ai.applyElementsVisible(i);break;case"tempD":break;case"strokeStyle":this.updateStrokeStyle(s);break;default:console.error(a);break}}r==="auxiliaryLine"?new Zl(s).render():r==="arc"&&new _i(s).render(),k.compilerManager.uploadData(i)}}updateStrokeStyle(t){switch(t.cmdKey){case"auxiliaryLine":ri.renderer.attr(t.gId,"stroke-dasharray",Rn.lineStyle[t.strokeStyle]);break;default:console.error(t.cmdKey,t);break}}updateMatrix(t,i,r){switch(i){case"ellipse":{let{rx:o,ry:l,matrixArr:c}=Ei.getEllipseFromMatrix(r);te(t,{rx:o,ry:l}),ht.updateTransform(c,t)}break;case"rect":let{width:n,height:s,matrixArr:a}=Li.getRectFromMatrix(r);te(t,{width:n,height:s}),ht.updateTransform(a,t);break;case"obj":case"text":ht.updateTransform(r,t);break;case"dimension":case"group":case"dimensionRadius":break;default:throw console.error(t,i),new Error(t);break}}updateD(t,i,r){switch(i){case"text":t=t.querySelector("path"),te(t,"d",r);break;case"group":te(t,"d",r);break;default:console.error("err");break}}updateX1(t){let{json:i,cmdKey:r}=k.getById(t);switch(r){case"dimensionLength":new xn(i).render();break;case"dimensionAngle":new bn(i).render();break;case"dimensionRadius":new cn(i).render();break;case"arc":new _i(i).render();break;default:console.error(r,"not handle x1");break}}updateTextX(t){let{json:i,cmdKey:r}=k.getById(t);switch(r){case"dimensionAngle":new bn(i).render();break;case"dimensionRadius":new cn(i).render();break;default:throw new Error(r)}}updateX(t,i,r){switch(i){case"auxiliaryLine":{let n=t.x1.animVal.value,s=t.x2.animVal.value,a=r-(n+s)/2;t.setAttribute("x1",String(n+a)),t.setAttribute("x2",String(s+a));break}case"auxiliaryPoint":{t.setAttribute("cx",String(r));break}default:console.error(t,i,r)}}updateY(t,i,r){switch(i){case"auxiliaryLine":{let n=t.y1.animVal.value,s=t.y2.animVal.value,a=r-(n+s)/2;t.setAttribute("y1",String(n+a)),t.setAttribute("y2",String(s+a));break}case"auxiliaryPoint":{t.setAttribute("cy",String(r));break}default:throw new Error("err")}}updateCategory(t,i,r){switch(i){case"dimension":te(t,"category",r);break;default:throw new Error("err")}}diff(t,i){let r=Object.create(null);for(let n in i){let s=i[n];C0(s,t[n])||(r[n]=s)}for(let n in t){let s=i[n];C0(s,t[n])||(r[n]=s)}return r}walker(){let t=500;for(;this.taskQueue.length&&t;)this.taskQueue.shift()(),t--,t===0&&setTimeout(this.walker.bind(this),17)}},Wg=new PD;var LD=0,Jt=class Jt{static checkBatchStateIsCorrect(){this.batchState!==LD&&Kr(LD,this.batchState)}static save(t){if(!Array.isArray(t)||t.length===0)throw Ce("reportError",[new Error("History.save :: first argument is not an array")]),console.error(t),new Error("err");if(Jt.batchState){Array.isArray(t)&&Array.isArray(t[0])?[].push.apply(Jt.queueBatchRecords,t):Jt.queueBatchRecords.push(t);return}Jt.index.value>=Jt.maxLength-1?(Jt.records.shift(),Jt.savedIndex>-1&&(Jt.savedIndex-=1)):Jt.index.value++,Jt.timestamps[Jt.index.value]=Date.now(),k.freshItemOrder(),this.handleSelected("redo",t),k.compilerManager.resumeDataMerge(),k.compilerManager.uploadHistoryData(t),Jt.records[Jt.index.value]=t,Jt.records.length=Jt.index.value+1,or("triggerEvent",["history_change",{tabId:H.tabId},Jt.records.length,Jt.index.value,!0])}static startBatch(){return this.checkBatchStateIsCorrect(),this.batchState++,this.jsonSnap=new oi,this.cancelSaveBatch.bind(this)}static cancelSaveBatch(){this.batchState--}static saveBatch(){this.jsonSnap.updateAndSave(),this.cancelSaveBatch(),this.checkBatchStateIsCorrect(),this.queueBatchRecords.length&&(this.save(structuredClone(this.queueBatchRecords)),this.queueBatchRecords.length=0)}static clear(t){var i=t&&t.saved===!1;Jt.timestamps.length=0,Jt.records.length=0,Jt.index.value=-1,Jt.savedIndex=i?-2:Jt.index.value,Jt.batchState=0,or("triggerEvent",["history_change",{tabId:H.tabId},Jt.records.length,Jt.index.value,i])}static goTo(t){if(t>=-1&&t!==Jt.index.value&&t<Jt.records.length){if(t>Jt.index.value)for(let i=Jt.index.value+1;i<=t;i++)Jt.doCmdBatch("redo",Jt.records[i]);else for(let i=Jt.index.value;i>t;i--)Jt.doCmdBatch("undo",Jt.records[i]);Jt.index.value=t,or("triggerEvent",["history_change",{tabId:H.tabId},Jt.records.length,Jt.index.value,!0]),k.freshItemOrder(),Ce("panel_updateAttrPanel"),Ce("updateMenuByDocStatus"),Ce("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),Ce("panel/updateTreeActiveElements");return}console.log("history.goTo("+t+") not available")}static go(t){Jt.goTo(Jt.index.value+t)}static doCmdBatch(t,i){OD(),t=="redo"?Jt.redoOne(i):Jt.undoOne(i),this.handleSelected(t,i),this.upLoadBatch(i,t)}static handleSelected(t,i){var s;let r=go.getIds(),n=Xg.getIds();i.forEach(a=>{var u;if(!Om.includes((u=a[2])==null?void 0:u.cmdKey))return;let o=a[1],l=!1,c=!1;t==="redo"?(l=Mt(a[4]),c=Mt(a[3])):(l=Mt(a[3]),c=Mt(a[4])),l&&r.includes(o)?(Xg.select(o),go.unselect(o)):c&&n.includes(o)&&(go.select(o),Xg.unselect(o))}),(s=k.selectedRepeater)==null||s.updateChange()}static upLoadBatch(t,i){jl(t[0])||(t=[t]),t.forEach(r=>{let n=r[0];["json","combine-json"].includes(n)?this.uploadDeleteOrCreate(r,i):n==="originXY"&&k.compilerManager.uploadData("canvas")})}static defineUndoRedo(t,i){Jt.undoRedoHandlers[t]=i}static undoOne(t){if(Array.isArray(t[0])){let r=t.length;for(let n=r-1;n>=0;n--)Jt.undoOne(t[n]);return}let i=Jt.undoRedoHandlers[t[0]];t=zo.updateRecord(t,"undo"),i.undo&&i.undo(t)}static redoOne(t){if(jl(t[0])){let r=t.length;for(let n=r-1;n>=0;n--)Jt.redoOne(t[n]);return}let i=Jt.undoRedoHandlers[t[0]];t=zo.updateRecord(t,"redo"),i&&i.redo&&i.redo(t)}static uploadDeleteOrCreate(t,i){let r=t.at(-1),n=t.at(-2);if(Mt(r)||Mt(n)||!r||!n){let s=t.at(1),a=(r==null?void 0:r.cmdKey)||(n==null?void 0:n.cmdKey);i==="redo"?Mt(r)||!r?zo.uploadDeleteById(s,a):k.compilerManager.uploadData(s,r):Mt(n)||!n?zo.uploadDeleteById(s,a):k.compilerManager.uploadData(s,n)}}static canRedo(){return Jt.index.value<Jt.records.length-1}static canUndo(){return Jt.index.value>=0}static createElePosition(t,i,r){return["elePosition",t,i,r]}static getLastRecordPrimitiveIds(){let t=Jt.records[Jt.records.length-1];return t?(Array.isArray(t[0])?t:[t]).reduce((r,[n,s])=>(n==="json"&&r.push(s),r),[]):[]}};Jt.records=[],Jt.timestamps=[],Jt.queueBatchRecords=[],Jt.maxLength=50,Jt.index={value:-1},Jt.savedIndex=-1,Jt.batchState=LD,Jt.undoRedoHandlers=[];var Ke=Jt;Ke.defineUndoRedo("originXY",{undo:function(e){var t=e[2];if(!(!t.offsetX&&t.offsetX!=0||!t.offsetY&&t.offsetY!=0)){var i={};i.x=Ge.canvas.originX-t.offsetX,i.y=Ge.canvas.originY-t.offsetY,Wr().setOriginXY({x:i.x,y:i.y})}},redo:function(e){var t=e[2];if(!(!t.offsetX&&t.offsetX!=0||!t.offsetY&&t.offsetY!=0)){var i={};i.x=Ge.canvas.originX+t.offsetX,i.y=Ge.canvas.originY+t.offsetY,Wr().setOriginXY({x:i.x,y:i.y})}}});Ke.defineUndoRedo("elePosition",{undo:function(e){let t=e[0],i=e[1].split(","),r=e[2].split(",");for(let n=i.length;--n>=0;){let s=le(i[n]);s&&HA(s.parentNode,s,r[n])}},redo:function(e){var t=e[0];let i=e[1].split(","),n=(e[3]||"").split(",");for(let s=i.length;--s>=0;){let a=le(i[s]);a&&HA(a.parentNode,a,n[s])}}});Ke.defineUndoRedo("combine-json",{undo(e){let[,t,i,r]=e;k.setCombination(t,i),new Ni().updateHole()},redo(e){let[,t,i,r]=e;k.setCombination(t,r),new Ni().updateHole()}});Ke.defineUndoRedo("json",{undo(e){let[t,i,r,n,s]=e,{cmdKey:a,refId:o}=r;if(D0(n)&&D0(s))return Wg.run(n,i,a)},redo(e){let[t,i,r,n,s]=e,{cmdKey:a,refId:o}=r;if(D0(n)&&D0(s))return Wg.run(s,i,a)}});function Qr(e,{cmdKey:t,refId:i},r,n){return["json",e,{cmdKey:t,refId:i},jt(r),jt(n)]}var oi=class{constructor(t=[]){this.hist=[];this.histCombine=[];this.nodes=[];this.uniqueIds=new Set;this.uniqueCombineIds=new Set;for(let i of t)this.addOne(k.getById(i.gId||i.id).json)}createCombineJsonHistory(t,i,r){return i=i||k.getCombination(t),["combine-json",t,jt(i),jt(r)]}addOneCombine(t,i){let n=new rt().searchCombination(t);this.addOneCombineByComId(n,i)}addOneCombineByComId(t,i){if(!t||this.uniqueCombineIds.has(t))return;this.uniqueCombineIds.add(t);let n=new rt().findParent(t);n&&(this.uniqueCombineIds.add(n.gId),this.histCombine.push(this.createCombineJsonHistory(n.gId,n))),i=i||k.getCombination(t);for(let s of i.combinations||[])this.uniqueCombineIds.add(s),this.histCombine.push(this.createCombineJsonHistory(s));this.histCombine.push(this.createCombineJsonHistory(t,i))}addOne(t,i,r){if(this.uniqueIds.has(t.gId))return this;let n=r||t.cmdKey,s=k.getRefId(t.gId),a=i||t,o=Qr(t.gId,{cmdKey:n,refId:s},a);return this.hist.push(o),this.nodes.push(t),this.uniqueIds.add(t.gId),this.addOneCombine(t.gId),k.compilerManager.pauseDateMerge(),this}add(t){for(let i of t)this.addOne(i)}update(){let t=this.hist,i=this.nodes,r=[];for(let n=0,s=i.length;n<s;n++){let a=k.getById(i[n].gId).json,o=t[n][3];delete a.tempMatrix,delete a.tempD;let l=Wg.diff(o,a);if(Mt(l))continue;k.changedJsoncache(o.gId||a.gId,o.cmdKey||a.cmdKey);let c=Mt(o),u=Mt(a);t[n][3]=Wg.diff(a,o),t[n][4]=l,c&&(t[n][3]={}),u&&(t[n][4]={}),r.push(t[n])}this.hist=r,this.updateCombine(),k.compilerManager.resumeDataMerge()}updateCombine(){let t=[];for(let i of this.histCombine){let[,r,n]=i,s=k.getCombination(r),a=Wg.diff(n,s);Mt(a)||(i.pop(),i.push(jt(s)),t.push(i))}this.histCombine=t}out(){return this.update(),this.getHistory()}getHistory(){return[...this.histCombine,...this.hist]}getPrimitiveHistory(){return[...this.hist]}getCombHistory(){return this.histCombine}updateAndSave(){this.update(),this.getHistory().length&&Ke.save(this.getHistory()),this.nodes.length=0}recovery(t=!0){let i=this.getPrimitiveHistory();for(let r of i){let[,,{cmdKey:n},s]=r;t?bs(n,s):k.insertOneData(s.gId,n,s)}return this}};var eb=class{constructor(){}isLockedById(t){let{locked:i}=k.getById(t).json;return i}hasEleLocked(t){for(let i of t)if(this.isLockedById(i))return i;return!1}hasUnLockedObjs(t=[]){for(let i of t)if(!this.isLockedById(i.id))return!0;return!1}unlockAll(){let t=new oi;k.iteratorCombination(r=>{r.locked===!0&&(t.addOneCombineByComId(r.gId),r.locked=!1)}),k.getItemOrder().forEach(r=>{let{json:n,cmdKey:s}=k.getById(r),{locked:a}=n;a===!0&&(t.addOne(n),n.locked=!1)}),t.updateAndSave()}setLockStatus(t,i){let r=new rt,{elements:n,combinations:s}=r.getSelectedCombinations2(t),a=new oi(t.map(o=>({id:o})));for(let o of s){a.addOneCombineByComId(o);let l=k.getCombination(o);l.locked=i}for(let o of n){let{json:l,cmdKey:c}=k.getById(o);c!=="dimension"&&(l.locked=i)}a.updateAndSave()}setCombinationLockStatus(t,i){let r=new oi;r.addOneCombineByComId(t);let n=k.getCombination(t);n.locked=i,r.updateAndSave()}hasCombinationLocked(t){for(let i of t)if(this.isCombinationLocked(i))return!0;return!1}isCombinationLocked(t){return k.getCombination(t).locked}setElementsLockStatus(t,i){let r=new oi(t.map(n=>({id:n})));for(let n of t){let{json:s}=k.getById(n);s.locked=i}r.updateAndSave(),Ce("panel_updateAttrPanel")}toggleLockStatus(t){Ke.startBatch(),t.forEach(i=>{let r=k.getCombination(i);if(!Mt(r))this.setCombinationLockStatus(i,!r.locked);else{let{json:s}=k.getById(i);this.setLockStatus([i],!s.locked)}}),Ke.saveBatch()}};eb=Ws([Pa(Sn.lock)],eb);var Gi=new eb;function Ho(e,t="",i=ut()){return H.windowBridge.rpcCall(e,t,i)}function or(e,t,i){var r=parent;if(r!=window){var n=t||[],s=[{args:n,uuid:i,func:e}];return r.panelCallByEditor.apply(window,s)}}function Ir(e){Ir.data.event=e;var t=6;if([2,4].includes(e.buttons)||[1,2].includes(e.button))return;var i=ui(e,!1),r=e.target,n=Ge.canvas,s=Ir.data;let{clientX:a,clientY:o}=e;s.clientX=a,s.clientY=o,s.lastUpX===null&&(s.lastUpX=n.originX,s.lastUpY=n.originY);var l=i.x,c=i.y;e.type=="mousedown"&&(r==H.svgRoot||Vs(r,ko)||H.gCanvas.contains(r))&&(s.lastUpX=l,s.lastUpY=c);var u=l-s.lastUpX,h=c-s.lastUpY;e.type=="mouseup"&&(r==H.svgRoot||Vs(r,ko)||H.gCanvas.contains(r))&&(s.lastUpX=l,s.lastUpY=c,s.uplock=!(s.clientX>0&&s.clientY>0&&s.clientX<e.view.innerWidth&&s.clientY<e.view.innerHeight));let d=n.unit!="pixel"&&n.unit||"",f={...Ra(i)};f.x-=n.originX,f.y-=n.originY,f.x=m(f.x),f.y=m(f.y),s.uplock&&e.type=="mousemove"&&(Math.abs(u)*H.gZoom>t||Math.abs(h)*H.gZoom>t)&&(s.uplock=!1),s.uplock||(f.dx=m(u),f.dy=m(h)),s.currAbsX=f.absX=i.x,s.currAbsY=f.absY=i.y,or("updateMouseXY",[f]),le("mouse-x-for-test").value=i.x,le("mouse-y-for-test").value=-i.y;function m(g){return g=d?Yt(+g,"pixel",d):+g,g=A4(g),d?g+d:g}}Ir.data={clientX:null,clientY:null,lastUpX:null,lastUpY:null,uplock:!1,currAbsX:0,currAbsY:0,event:null};function ui(e,t){let i=vh({x:e.clientX,y:e.clientY}),{x:r,y:n}=i;return t===!0&&!e.altKey?tb(i):t!==!1&&Ge.adsorbGrid.enabled?Ra(i):{x:Zr(r),y:Zr(n)}}function tb(e){let t=bt.adsorption(e.x,e.y);return t!=null?t:Ge.adsorbGrid.enabled?Ra(e):e}function B5(e,t){let i=bt.dragAdsorption(e.x,e.y,t);return i!=null?{x:Zr(i.x),y:Zr(i.y)}:Ge.adsorbGrid.enabled?Ra(e):{x:Zr(e.x),y:Zr(e.y)}}function dl(){let e=le("gControlDots"),t=le("gControlRects"),i=le("gControlLines"),r=[e,t,i];for(let n of r)n.classList.add("hide");ar.hideAll().emptyData()}function ms(e,t="single"){let i=k.getById(e.id||e.gId).json||Object(),r=Mn.get(i,t)||Fi.get(e);return ar.main(r),Ua(r)?r.bbox:r}async function M5(e,t){let i=t||e.target,r=i==H.svgRoot,n=$t(i);i.parentNode===H.gControlDots?n="cdot":i=pl(i);let s=n==="cdot",a=Mi();(!s&&!r&&i&&i.tagName!="TEXTAREA"&&(!i||!Ae.isSelected(i))||r)&&!a&&qt(),!s&&i&&(Ae.select([i]),["auxiliaryLine","auxiliaryPoint","dimension"].includes(n)||fr([i]));let o=[n],{x:l,y:c}=ui(e,!1),u=ar.findControlDot(l,c);u&&u.belongCmdKey==="arc"&&(o=[u.belongCmdKey]),(u||s)&&ar.selectAnchorOrHandle((u==null?void 0:u.id)||(i==null?void 0:i.id)),(r||(u==null?void 0:u.type)==="bbox"||Ae.getIds().length===0)&&(o="canvas");let h=i==null?void 0:i.id,d=Ae.getIds(),{combinations:p}=new rt().getSelectedCombinations(d);if(!wt.isEditingPath())for(let w of d){let{cmdKey:x,json:I}=k.getById(w),A=vi(I,x);St.extendRect(A).isContains1(l,c)&&(o=[x])}let f=(await Ho("getPanelFilterConfig",[H.tabId])).message,{checkInDisableFlag:m,checkInHideFlag:g,checkOutDisableFlag:b,checkOutHideFlag:y}=Ru.get(),E=!await Xd(),S={filterConfig:f,tabId:H.tabId,target:o,targetId:h,docType:H.doctype,cmdKey:n,clientX:e.clientX,clientY:e.clientY,x:l,y:c,hasLocked:Gi.hasEleLocked(d),hasUnLocked:Gi.hasUnLockedObjs(a),hasVisible:ai.hasVisible(d),hasHidden:ai.hasHidden(d),selectsCount:a.length,combinationCount:Object.keys(k.getCombination()).length,isEditCombine:Wt.isEditing(),isClipboardEmpty:E,aboveCombination:Array.from(p),checkInDisableFlag:m,checkInHideFlag:g,checkOutDisableFlag:b,checkOutHideFlag:y};H.contextmenuDisableOnce||H.windowBridge.publish("showEditorContextMenu",[S],ut())}function Mi(){return Ae.get()}function Dh(){let e=Ae.getIds(),t=[];for(let i of e)t.push(k.getById(i).json);return t}function qt(e){OD(),nD(e),Du()}function OD(){let e=Hr("#g1 ."+Ae.highlightClass);for(var t=e.length-1;t>=0;t--)Ae.unhighlight(e[t])}function nD(e){var t=e||Mi(),i=t.length;if(i>0)for(var r=i;--r>=0;)Ae.unselect(t[r]);Xg.clear(),dl(),Th("","none");var n=Hr("."+Ae.selectClass,H.gCanvas);return Ae.unselect(n),i}function HS(){var i;let e=Oa(),t=new rt;(i=k.selectedRepeater)==null||i.notPublishOnce();for(let r of e)if(r.combinationId){let n=t.getAllElesfromTop(r.combinationId).elements,s=Array.from(n).map(a=>le(a)).filter(a=>a);Ae.select(s)}else Ae.select([le(r.elements[0])]);Ce("panel_updateAttrPanel"),Ce("updateMenuByDocStatus")}function ac(e=Xt.getViewBox(),t={}){or("updateRuler",[{zoom:H.gZoom,unit:Ge.canvas.unit,vbX:e[0],vbY:e[1],originX:Ge.canvas.originX,originY:Ge.canvas.originY,...t}],H.tabId)}function qk(e){let t={clientX:e.clientX,clientY:e.clientY};or("updateRuler",[t],H.tabId)}function zd(){or("updateRuler",[hf()],H.tabId)}function hf(e=Xt.getViewBox(),t=H.gZoom){let i=[],r=[];switch(H.cmdToken){case"place_auxiliary(crossLine)":case"place_auxiliary(verticalLine)":case"place_auxiliary(horizontalLine)":{let n=mf.getRulerAuxiliaryXY();i.push(...n.x),r.push(...n.y);break}case"place_auxiliary(point)":{let n=Je.activeDrawer.getRulerAuxiliaryXY();i.push(...n.x),r.push(...n.y);break}}return Ae.getIds().forEach(n=>{let s=k.getAuxiliaryLine(n);if(s!=null)switch(ul(s.rotation)){case"vertical":{i.push({position:(s.x-e[0])*t,content:String(lt(Yt(s.x,"pixel",Ge.canvas.unit),2))});break}case"horizontal":{r.push({position:(s.y-e[1])*t,content:String(lt(Yt(-s.y,"pixel",Ge.canvas.unit),2))});break}}}),{auxiliaryX:i,auxiliaryY:r}}function Og(){var e=document.body,t=document.documentElement;return{zoom:H.currZoom,scrollLeft:Math.max(e.scrollLeft,t.scrollLeft),scrollTop:Math.max(e.scrollTop,t.scrollTop),scrollWidth:Math.max(e.scrollWidth,t.scrollWidth),scrollHeight:Math.max(e.scrollHeight,t.scrollHeight),clientWidth:t.clientWidth,clientHeight:t.clientHeight,width:Math.max(e.scrollWidth,t.scrollWidth),height:Math.max(e.scrollHeight,t.scrollHeight),canvasWidth:+te(H.svgRoot,"width"),canvasHeight:+te(H.svgRoot,"height"),viewBox:te(H.svgRoot,"viewBox"),unit:Ge.canvas.unit}}function Jk(e){e.preventDefault();let t=e.target.tagName;t=="TEXTAREA"||t=="INPUT"||H.cmdToken===""&&(ao.dragpanning||(H.contextmenuDisableOnce&&(H.contextmenuDisableOnce=!1),qd("")))}var Vte={x:0,y:0,lastFire:0,lastRealHandle:0};function Kk(e){var h;if(e.target.tagName=="TEXTAREA"||fd&&ao.dragpanning||(e.preventDefault(),!e.detail&&!e.deltaX&&!e.deltaY))return;var t=e.deltaMode===1;let i=100,r=e.deltaX||e.wheelDeltaX/-3||0,n=e.deltaY||e.wheelDeltaY/-3||0;e.detail&&!r&&!n&&(n=e.detail),t&&(i=3);var s=Vte,a=Date.now();a-s.lastFire>500&&(s.x=0,s.y=0);let o=1;switch(e.deltaMode){case 1:o=40;break;case 2:o=100;break}if(s.x+=r*o,s.y+=n*o,s.lastFire=a,Math.abs(s.x)<i&&Math.abs(s.y)<i)return;s.lastRealHandle=a;let l=Math.abs(s.x)>Math.abs(s.y),c;l?(c=s.x>0,s.x+=s.x>0?-i:i,s.y=0):(c=s.y>0,s.y+=s.y>0?-i:i,s.x=0),V5()==="roller"?Hte(e,l,c):jte(e,l,c),qS(e),(h=lo.instance)==null||h.updateTipPosition(ui(e))}function Hte(e,t,i){if(e.shiftKey||e.ctrlKey||e.metaKey||t){var r,n=t||e.shiftKey;n?r=i?[1,0]:[-1,0]:r=i?[0,1]:[0,-1];var s=Xt.getViewBox(),a=20/H.gZoom;s[0]+=a*r[0],s[1]+=a*r[1],Xt.setViewBox(s);return}var o=HI(H.currZoom,i?"-":"+");rc(o,{clientX:e.clientX,clientY:e.clientY}),or("setZoomText",[o+"%"])}function jte(e,t,i){if(e.ctrlKey||e.altKey||e.metaKey)try{var r=HI(H.currZoom,i?"-":"+");rc(r,{clientX:e.clientX,clientY:e.clientY}),or("setZoomText",[r+"%"])}catch(l){console.log("wheelHandler err ",l)}else if(e.shiftKey||!e.altKey){var n,s=t||e.shiftKey;s?n=i?[1,0]:[-1,0]:n=i?[0,1]:[0,-1];var a=Xt.getViewBox(),o=20/H.gZoom;a[0]+=o*n[0],a[1]+=o*n[1],Xt.setViewBox(a)}}function $k(){let e=le("gCursors").childNodes,t=e.length;for(let i=0,r;i<t;i++)(r=e[i].id)&&(H.helperCursorConfig[r]={trs:te(e[i],"transform")||"",width:te(e[i],"width"),height:te(e[i],"height")});document.addEventListener("mousemove",i=>{(!Je.readyed||i.buttons===2)&&qS(i)},!1)}function pr(e,t,i,r){let n=/^(grab|grabbing|row-resize|col-resize|crosshair)$/;if(H.helperCursor&&e!=="grabbing"&&(H.helperCursor=="cross-red"?cs(!1):n.test(H.helperCursor)?Oo(H.svgRoot,"cursor-"+H.helperCursor):te(le(H.helperCursor),{display:"none"})),e&&n.test(e)){bu(H.svgRoot,"cursor-"+e),H.helperCursor=e;return}let s=!1;e&&H.helperCursorConfig[e]?e=="cross-red"?or("panel/getCrossCursor")===!1?(cs(!1),s=!0):arguments.length>=3?(cs(t,i),s=!0):H.helperCursor&&t===!0?cs(!1):(r!==void 0?cs(!1,void 0,{content:r}):cs(!1),s=!0):arguments.length>=3&&t!==void 0&&i!==void 0?te(le(e),{x:t,y:i,display:""}):H.helperCursor&&t===!0?te(le(e),{display:""}):(te(le(e),{x:-1e5,y:-1e5,display:""}),s=!0):s=!0,ia(H.svgRoot,"cursor-none",!s),H.helperCursor=e||"",!e&&cs(!1)}function cs(e,t,i){let r=or("panel/getCrossCursor");if(r==="None"&&(e=!1),e!==!1&&(!isFinite(e)||!isFinite(t)))return;var n=le("cross-x"),s=le("cross-y"),a=le("cross-text");!lr.ready&&!lo.running&&bu(a,"hide");let o=Xt.getViewBox();if(o=[o[0]-o[2],o[1]-o[3],o[2]*3,o[3]*3],e===!1||r===!1){te(n,"d","M0 0"),te(s,"d","M0 0"),H.cmdToken!==""?lr.exit():(e||!e&&r==="None")&&lr.showReferText();return}if(A5()){let u=60;u=u/H.gZoom,o=[e-u/2,t-u/2,u,u]}te(n,"d","M"+e+" "+o[1]+" v"+o[3]),te(s,"d","M"+o[0]+" "+t+" h"+o[2]),n.classList.remove("hide"),s.classList.remove("hide");let l=i&&i.content||"",c=i&&i.enforceEnterRefPoint||!1;lr.ready&&lr.showReferencePointAndText(e,t,l,c),i&&i.stroke?(te(n,"stroke",i.stroke),te(s,"stroke",i.stroke)):(te(n,"stroke","red"),te(s,"stroke","red")),i&&i.strokeWidth?(te(n,"stroke-width",i.strokeWidth),te(s,"stroke-width",i.strokeWidth),te(n,"stroke-dasharray",i.strokeWidth*2+","+i.strokeWidth*2),te(s,"stroke-dasharray",i.strokeWidth*2+","+i.strokeWidth*2),i.strokeLinecap&&(n.style.strokeLinecap=i.strokeLinecap,s.style.strokeLinecap=i.strokeLinecap)):(te(n,"stroke-width","1"),te(s,"stroke-width","1"),te(n,"stroke-dasharray","2, 2"),te(s,"stroke-dasharray","2, 2"),n.style.strokeLinecap="round",s.style.strokeLinecap="round")}function qS(e){if(!H.helperCursor&&T5(),!H.helperCursor||e.shiftKey)return;if(ia(le("cross-x"),"hide",!H.helperCursor),ia(le("cross-y"),"hide",!H.helperCursor),xs(e),(e.target==document.documentElement||e.target==document.body)&&!Io){H.helperCursor=="cross-red"?cs(!1):te(le(H.helperCursor),{display:"none"});return}var t,i;Ge.adsorbGrid.enabled||(t=Object.assign({},Ge.adsorbGrid),Object.assign(Ge.adsorbGrid,{distanceX:1,distanceY:1,enabled:!0}),i=function(){Object.assign(Ge.adsorbGrid,t)});let r,n;if(Ge.adsorbGrid.enabled&&H.helperCursor!="cursor-hand"&&H.helperCursor!="cursor-grab"&&H.helperCursor!="cursor-freedraw"){Qn.altKeyEnabled=e.altKey;let a=Os.isAdaptAreaSelectionView()||H.helperCursor==="grabbing",o=ui(e,!a);r=o.x,n=o.y}else{var s=ui(e,!1);r=s.x,n=s.y}H.helperCursor=="cross-red"?(xs("",{x:r,y:n}),cs(r,n)):te(le(H.helperCursor),{x:r,y:n,display:""}),i&&i()}async function ho(e,t){if(t=(t==null?void 0:t.ids)||t,jl(t)||(t=Ae.get()),t.some(s=>Gi.isLockedById(s.id)))return qa();let r=t.map(s=>Ac(s)?le(s):s.gId?le(s.gId):s);r=r.filter(s=>{let a=$t(s);return"dimension"!==a});let n=zte(r);if(await lo.needSelectRefobject(e)||await lo.needSelectRefobjectForCenters(e)){await new lo(e,n).startSelect();return}mS(n,e),Ce("panel_updateAttrPanel")}function zte(e){let t=e.map(a=>a.id),{combinations:i,elements:r}=new rt().getSelectedCombinations(t),n=[];for(let a of r)n.push(le(a));let s=new rt;for(let a of i){let o=s.getAllElesfromTop(a).elements,l=[];for(let c of o)l.push(le(c));n.push(l)}return n}function jk(e,t=20){let i=[],r=[];for(let d of e){let p=k.getAuxiliaryLine(d.id),f=ul(p.rotation);f==="horizontal"?r.push(p.y):f==="vertical"?i.push(p.x):(i.push(d.x1.animVal.value,d.x2.animVal.value),r.push(d.y1.animVal.value,d.y2.animVal.value))}i.sort((d,p)=>d-p),r.sort((d,p)=>d-p);let[n,s,a,o]=[i[0],i[i.length-1],r[0],r[r.length-1]],l=Xt.getViewBox(),c=i.length?(n+s)/2:l[0]+l[2]/2,u=r.length?(a+o)/2:l[1]+l[3]/2;Bu(c,u);let h=St.extendRect(H.svgRoot.viewBox.animVal);if(h.minX>n-t||h.maxX<s+t||h.minY>a-t||h.maxY<o+t){let d=Xt.getViewBox(),p=document.body.clientWidth,f=document.body.clientHeight,m=Math.min((p-t)/(s-n)||1/0,(f-t)/(o-a)||1/0),g=m*100;g<.1?(g=.1,m=g/100):g>H.zoomRatio.max&&(g=H.zoomRatio.max,m=g/100);let b={clientX:(c-d[0])*H.gZoom,clientY:(u-d[1])*H.gZoom};or("zoom",[g,window.frameElement,b,!0])}}var Zk,Qk,e6,Xt=class e{static init(){Zk=le("gridBg"),Qk=le("gridOH"),e6=le("gridOV"),H.selectBox1=le("selectBox1"),H.gControlDots=le("gControlDots"),H.gControlRects=le("gControlRects"),H.gControlLines=le("gControlLines"),H.gCanvas=le("g1")}static clear(){Rh(),qt(),T3(H.gCanvas)}static initCanvasSize(t){let i=document.documentElement.clientWidth,r=document.documentElement.clientHeight,n=Ge.canvas.originX,s=Ge.canvas.originY;te(H.svgRoot,{width:i,height:r,viewBox:[n-i/2,s-r/2,i,r].join(" ")}),t.tabId&&(H.tabId=t.tabId)}static getCanvasAttrs(){let t=k.gJsonCache,{display_title:i,layer:r="",width:n="",height:s="",desc:a=""}=t.head;return{cmdKey:"canvas","attr-topic":"Page","attr-name":i,"attr-layer":r,get"attr-direction"(){return parseFloat(n)>=parseFloat(s)?"Landscape":"Portrait"},get"attr-widthxheight"(){let l=parseFloat(n),c=parseFloat(s);return`${Math.min(l,c)}mmx${Math.max(l,c)}mm`}}}static modify_canvas(t={}){var o;let i=k.gJsonCache,r=!1,n=e.getCanvasAttrs(),{gridType:s}=Ge.adsorbGrid,{head:a}=i;for(let[l,c]of Object.entries(t)){if(l==="attr-topic")return;switch(l){case"attr-name":a.name=c,r=!0;break;case"attr-material":a.material=c,a.thickness=kI[c].thickness[0],a.craft=kI[c].craft[0],r=!0;break;case"attr-background-color":a.backgroundColor=c,r=!0;break;case"attr-thickness":a.thickness=c,r=!0;break;case"attr-craft":a.craft=c,r=!0;break;case"attr-print":a.print=c,r=!0;break;case"attr-cover-color":a.coverColor=c,r=!0;break;case"attr-layer":a.layer=c,r=!0;break;case"attr-widthxheight":{let[h,d]=String(c).split("x");e.setCanvasWidthHeight(h,d,n["attr-direction"]),r=!0;break}case"attr-canvas-bgcolor":if(GI(c)){c=c.toUpperCase();let h="url(data:image/gif;base64,R0lGODlhEAAQAIAAAP///9/f3yH5BAAHAP8ALAAAAAAQABAAAAIfjG+gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7)";c!=="NONE"?(document.body.style.backgroundColor=c,document.body.style.backgroundImage="unset"):document.body.style.backgroundImage=h,Ge.canvas.bgColor=c}break;case"attr-canvas-grid-visible":let u=c&&c!=="none";Ge.adsorbGrid.visible=u,te(le("gridBg"),"display",u?"":"none");break;case"attr-canvas-grid-color":{let h=le("gridCell"),d=le("gridOH"),p=le("gridOV"),f=(o=sk[s])==null?void 0:o.modifyProp;f&&te(h,{[f]:c}),te(d,"stroke",c),te(p,"stroke",c),Ge.canvas.gridColor=c;break}case"attr-canvas-grid-size":{let h=le("gridPattern"),d=le("gridCell"),p=gw(+c),f={width:p*hn,height:p*hn};te(h,f),te(d,{transform:de.toDOMMatrix(de.scale(p/+c))});let[m,g]=Hr("path",d);if(s==="line")te(m,{d:qo.getGridLinePathDFor1(+c)}),te(g,{d:qo.getGridLinePathDFor10(+c)});else{let b=p/+c*H.gZoom;te(m,{d:qo.getGridPointPathDFor1(+c,qo.getGridPointRadius(b))}),te(g,{d:qo.getGridPointPathDFor10(+c,qo.getGridPointRadius(b))})}Ge.adsorbGrid.gridSize=+c;break}case"attr-canvas-snap-size":pd("adsorbGrid","distanceX",+c),pd("adsorbGrid","distanceY",+c),$e(t,"attr-canvas-snap")||(Ge.adsorbGrid.enabled=+c>1e-4);break;case"attr-canvas-snap":Ge.adsorbGrid.enabled=c=="yes";break;case"attr-canvas-alt-snap-size":Ge.adsorbGrid.altSnapSize=+c||1;break;case"attr-canvas-grid-style":{let h={gridColor:"#FFFFFF"};if(Ge.adsorbGrid.gridType=c,c==="not")break;let d=le("gridCell"),p=Ge.canvas.gridColor||h.gridColor,f=gw();if(te(d,{transform:de.toDOMMatrix(de.scale(f/Ge.adsorbGrid.gridSize)),width:f*hn,height:f*hn,fill:p,type:"dot"}),c==="dot"){let m=f/Ge.adsorbGrid.gridSize*H.gZoom;d.innerHTML=qo.getGridPointSVGHTML(void 0,qo.getGridPointRadius(m))}else d.innerHTML=qo.getGridLineSVGHTML();te(le("gridPattern"),{width:f*hn,height:f*hn}),te(le("gridBg"),"fill","url(#gridPattern)");break}case"attr-direction":{e.setCanvasWidthHeight(a.width,a.height,c);break}default:break}}r&&(k.compilerManager.uploadData("canvas"),or("triggerEvent",["history_change",{tabId:H.tabId},Ke.records.length,Ke.index.value,!0])),H.windowBridge.publish("ui/canvasInfo",{tabId:H.tabId,scaleValue:+(H.gZoom*100||0).toFixed(2),unitValue:"unit(mm)"},ut())}static setCanvasWidthHeight(t,i,r,n=!0){let s=parseFloat(t),a=parseFloat(i),o=s>a?"Landscape":"Portrait";if(r!==o){let l=j3(s,a);[s,a]=l,[t,i]=l.map(c=>`${c}mm`)}k.setHead({width:t,height:i}),new Ja().update(),n&&Wr().fitview()}static async modify_json(t,i){for(let r in t){if(!$e(t,r))continue;let n=t[r];switch(r){case"attr-canvas-name":i.head.title=n;break;default:break}}}static getViewBox(){return te(H.svgRoot,"viewBox").split(" ").map(parseFloat)}static setViewBox([t,i,r,n]){te(H.svgRoot,"viewBox",[t,i,r,n].join(" ")),te(Zk,{x:t,y:i,width:r,height:n}),te(Qk,{x1:t,x2:t+r}),te(e6,{y1:i,y2:i+n}),ac([t,i,r,n],hf()),I2(Object.values(k.getAuxiliaryLine()).map(s=>({data:s,view:le(s.gId)})),new St(t,t+r,i,i+n).extendOfSize(_3))}};function GS(){let e={"attr-canvas-width":1e3,"attr-canvas-height":1e3,"attr-canvas-bgcolor":H.panelThemeCache.color.background,"attr-canvas-grid-visible":Ge.adsorbGrid.visible,"attr-canvas-grid-color":H.panelThemeCache.color.grid,"attr-canvas-grid-size":Ge.adsorbGrid.gridSize||ea(10),"attr-canvas-grid-style":Ge.adsorbGrid.gridType,"attr-canvas-snap-size":Ge.adsorbGrid.distanceX,"attr-canvas-alt-snap-size":Ge.adsorbGrid.altSnapSize};Xt.modify_canvas(e)}function Lk({type:e,button:t}){if(t!==C3)return;let i=new MouseEvent(e,{button:t});document.dispatchEvent(i)}var Iw=class{get gridType(){return Ge.adsorbGrid.gridType||H.profileSetting.commSystemSetting.PANEL_CANVAS.gridStyle||"not"}sync(){let t={};this.gridType==="not"?(t["attr-canvas-grid-style"]="not",t["attr-canvas-grid-visible"]="none"):this.gridType==="dot"?(t["attr-canvas-grid-style"]="dot",t["attr-canvas-grid-visible"]="yes"):this.gridType==="line"&&(t["attr-canvas-grid-style"]="line",t["attr-canvas-grid-visible"]="yes"),Xt.modify_canvas(t)}};var H={openDocComplete:!1,topMenuStatus:new Iw,profileSetting:void 0,worker:void 0,messageBus:void 0,windowBridge:void 0,containerId:void 0,tabId:void 0,selectBox1:void 0,gControlDots:void 0,gControlRects:void 0,gControlLines:void 0,gCanvas:void 0,doctype:void 0,cmdToken:"",gZoom:1,zoomRatio:{min:Ic?Number.NEGATIVE_INFINITY:5,max:Ic?Number.POSITIVE_INFINITY:1e5},currZoom:100,svgRoot:void 0,helperCursor:void 0,defaultImage:{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA1MCA0MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB4PSIxIiB5PSIxIiB3aWR0aD0iNDgiIGhlaWdodD0iMzgiIGZpbGw9IiNGRkYiIHN0cm9rZT0iI0NDQyIgc3Ryb2tlLXdpZHRoPSIyIi8+PHBvbHlsaW5lIHBvaW50cz0iMS41LDIzLDE2LDEzLDM0LDI2LDQ4LjUsMjAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI0NDQyIgc3Ryb2tlLXdpZHRoPSIyIi8+PGNpcmNsZSBjeD0iMzUiIGN5PSIxMiIgcj0iNCIgZmlsbD0iI0NDQyIgc3Ryb2tlPSJub25lIi8+PC9zdmc+",width:50,height:40,insertSvgAsPath:!1,userW:0,userH:0},emojiReg:/[^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\nμ]/g,normalCodeReg:/[\u4e00-\u9fa50-9A-Za-z]/,loading:void 0,isMouseOnEditFrame:!1,contextmenuDisableOnce:void 0,helperCursorConfig:{"cross-red":{},"cursor-hand":{},"cursor-grab":{}},autoGzipAjaxPostSize:1e4,globalVariableCookieData:{},isCutPasteFinish:!1,referencePosition:{},apis:{others:{panelOrder:"/api/panel_order"}},currentProject:{projectId:void 0,title:void 0},panelThemeCache:void 0,uploadSvgFileMaxMB:1,frameHelper:void 0,isProjectReadOnly:!1},ko="shapeBox",Aw=[1,2,3,4,5,6,7],q1={text:[1,2],rect:Aw,ellipse:Aw,group:Aw,arc:Aw,obj:[1],dimension:[8],dimensionLength:[8],dimensionAngle:[8],dimensionRadius:[8],auxiliaryLine:[8],auxiliaryPoint:[8]};function Vg(){return[6,5,1,2,7,3,4,8,-1]}function TS(){let e=new Map;return Vg().forEach((i,r)=>{e.set(i,r)}),e}var t6;Object.defineProperty(H,"helperCursor",{set(e){return console.warn("helperCursor",e),t6=e,!0},get(){return t6}});function ku(e,t=Object()){e||Kr(e),!En.ready&&(bt.clearAdsorptionHTML(),bt.updateDrawingShapeCache(null),H.frameHelper.getToolProcessor().switchToDrawTool(e,t))}function gS(){H.cmdToken=""}function Rh(){lo.running?lo.instance.cancel():H.cmdToken&&Je.end()}var xs=Id((e,t)=>{var l,c,u;let i;e&&(i=ui(e,!1)),!t&&i&&(t=Ra(i));let r=t?Gg(t):{clientX:0,clientY:0},n=window.frameElement.getBoundingClientRect(),s={left:n.left,top:n.top},a=H.cmdToken==="draw(arc)"?"draw(arc3)":H.cmdToken,o={left:r.clientX+s.left,top:r.clientY+s.top,cmdToken:a,selectionMode:Rg(),color:(u=(c=(l=H)==null?void 0:l.panelThemeCache)==null?void 0:c.color)==null?void 0:u.select,copyType:lr.ready?lr.pasteFrom:void 0};Ce("updateCursorIcon",[o])});var xl=class xl{static invoke(t,i){if(xl.hooks[t])return i?xl.hooks[t].apply(null,i):xl.hooks[t].apply();if(t.indexOf("draw(")===0||t.indexOf("place_")===0)return ku(t),!0;{let r=xl.wildcardHooks;for(let n in r)if(new RegExp(n).test(t))return r[n](t,i);console.error(arguments,"Plz check code")}return!1}};xl.hooks={},xl.wildcardHooks={},xl.registerHook=function(t,i){if(typeof t=="string")if(t.indexOf("*")>=0){let r="^"+t.replace(/\*/g,".*")+"$";xl.wildcardHooks[r]=i}else xl.hooks[t]=i;else if(t instanceof RegExp)xl.wildcardHooks[t]=i;else for(let r of Object.keys(t))xl.registerHook(r,t[r])};var $l=xl;var qg=class qg extends yn{constructor(){super();this.startP={x:0,y:0};this.anchors=[];this.modifiedGroup=!1;this.hasFirstMove=!1;this.shouldSwap=!1}install(i){console.log(this.getSymbol(),"installed"),this.hasFirstMove=!1,this.shouldSwap=!1;let{canvasX:r,canvasY:n}=i;this.startP.x=r,this.startP.y=n,this.editPathData=Dh()[0];let s=wt.getAnchorInfo(Mi()[0]);this.anchors=jt(s),this.history=new oi([this.editPathData]),pi.removeHighlightStroke().emptyLastHoverEle().emptySelectContainer(),wt.removeMiddleAnchor()}getSymbol(){return ii.drag_anchor_tool}static canSwitchMe(i){if(H.cmdToken)return!1;let{canvasX:r,canvasY:n,originalEvent:s}=i;if(!s.ctrlKey)return!1;let a=i.originalEvent.target,o=ar.isClickedAnchor(a,r,n);if(!o||o.type!=="anchor"||o.belongCmdKey==="arc")return!1;this.clickIndex=o.index;let l=Dh()[0];return!(!l||!wt.isAnchorMode(l.gId))}onMouseMove(i){let r=jt(this.anchors),n=r.length,s=qg.clickIndex,{canvasX:a,canvasY:o}=i;if(!this.hasFirstMove&&new j(a,o).distance1(new j(this.startP.x,this.startP.y))<10)return;let l=wt.getMirrorPoint(this.startP,{x:a,y:o}),c=0;for(let h=0;h<n;h++){let d=r[h-1],p=r[h],f=r[h+1];if(s!==p.index)continue;let m={x:a,y:o};if(!this.hasFirstMove&&d&&f&&(this.hasFirstMove=!0,U3(d,l,m,f)&&(this.shouldSwap=!0)),this.shouldSwap){let g=l;l=m,m=g}switch(p.type){case"M":this.whenHandleIsM(f,a,o);break;case"C":this.whenHandleIsC(p,f,l,m);break;case"L":c=this.whenHandleIsL(d,p,f,l,m);break;default:console.error(p);break}}let u=wt.getPathD(r);this.editPathData.tempD=u,ri.renderer.attr(this.editPathData.gId,"d",u),ms({id:this.editPathData.gId}),ar.showHandleOfIndexes([qg.clickIndex+c]),this.modifiedGroup=!0}onMouseLeftUp(i){if(this.modifiedGroup){for(let r of this.history.nodes)k.updatePrimitiveJson(r.gId,"d",this.editPathData.tempD);this.history.updateAndSave(),qg.clickIndex=-1,i.toolFinished=!0}}whenHandleIsL(i,r,n,s,a){if(!n){switch(i.type){case"M":case"L":return r.d=["C",i.x,i.y,a.x,a.y,r.x,r.y].join(" "),2;case"C":r.d=["C",r.x1,r.y1,a.x,a.y,r.x,r.y].join(" ");break;default:console.error(i);break}return}switch(n.type){case"C":case"L":return r.d=["C",i.x,i.y,s.x,s.y,r.x,r.y].join(" "),n.d=["C",a.x,a.y,n.x,n.y,n.x,n.y].join(" "),2;break;default:console.error(n);break}}whenHandleIsC(i,r,n,s){if(!r){i.d=["C",i.x1,i.y1,s.x,s.y,i.x,i.y].join(" ");return}switch(r.type){case"C":i.d=["C",i.x1,i.y1,n.x,n.y,i.x,i.y].join(" "),r.d=["C",s.x,s.y,r.x2,r.y2,r.x,r.y].join(" ");break;case"L":i.d=["C",i.x1,i.y1,n.x,n.y,i.x,i.y].join(" "),r.d=["C",s.x,s.y,r.x,r.y,r.x,r.y].join(" ");break;default:console.error(r);break}}whenHandleIsM(i,r,n){switch(i.type){case"C":{i.d=["C",r,n,i.x2,i.y2,i.x,i.y].join(" ");break}case"L":i.d=["C",r,n,i.x,i.y,i.x,i.y].join(" ");break;default:console.error(i.type);break}}uninstall(i){console.log(this.getSymbol()," uninstalled")}};qg.clickIndex=-1;var ib=qg;var rb=class extends yn{constructor(){super(...arguments);this._startSelectObjsAngleMap=new Map;this.rotateDisabledByDimension=!1;this.elementsCanRotate=[];this.updateRightPanel=Id((i,r)=>{let n=i.map(l=>l.gId),s=Ck(n),a=Hd(s,"",{notCreate8Dots:!0});r=r<0?Math.abs(r):360-r;let o={"attr-rotation":lt(a["attr-rotation"],2),"attr-x":a["attr-x"],"attr-y":a["attr-y"],"attr-width":a["attr-width"],"attr-height":a["attr-height"],"attr-bbox-rotation":lt(tr(r),2),"attr-bbox-x":a["attr-bbox-x"],"attr-bbox-y":a["attr-bbox-y"],"attr-bbox-width":a["attr-bbox-width"],"attr-bbox-height":a["attr-bbox-height"]};for(let l in o){let c=o[l];Kn(c)||delete o[l]}Ce("/panel/updatePanelValue",o)})}static canSwitchMe(i){let r=nc.isBoxRotateCursor(),n=Ae.getIds(),{combinations:s,elements:a}=new rt().getSelectedCombinations(n);return Gi.hasCombinationLocked(s)||Gi.hasEleLocked(a)?!1:r}install(i){console.log(this.getSymbol(),"installed");let r=Dh();Ke.startBatch(),Ke.jsonSnap.add(r);let n=this.elementsCanRotate=r.filter(a=>!Nn(a.cmdKey)),s=sg(n);this._rotateReferPoint=new j(s.x+s.width/2,s.y+s.height/2),this._startMouseAngle=new j(i.canvasX,i.canvasY).angleD(this._rotateReferPoint);for(let a of n)this._startSelectObjsAngleMap.set(a.gId,a.rotation||0);pi.emptyLastHoverEle().emptySelectContainer().removeHighlightStroke()}uninstall(i){console.log(this.getSymbol(),"uninstalled")}getSymbol(){return ii.rotate_by_anchor_tool}onMouseMove(i){if(this.rotateDisabledByDimension)return;zt.createContext(),zt.self.dimensionMgr.addNextTickTasks();let r=this.elementsCanRotate,n=new j(i.canvasX,i.canvasY).angleD(this._rotateReferPoint)-this._startMouseAngle;if(v4(i.originalEvent.ctrlKey,i.originalEvent.shiftKey,i.originalEvent.altKey)===2){let o=Math.floor(n/45)*45;n=n-o>45/2?o+45:o}for(let o of r){let l=tr(this._startSelectObjsAngleMap.get(o.gId)+n);jg([o],l>0?l-360:l,this._rotateReferPoint)}this.updateRightPanel(r,n),nc.boxRotateCursor1(new j(i.canvasX,i.canvasY),this._rotateReferPoint);let a=zt.runTask();this.rotateDisabledByDimension=a,r.length&&fr(r.map(o=>le(o.gId)),{create8Dots:!0}),new Ni().updateHole()}onMouseLeftUp(i){i.toolFinished=!0,Ke.saveBatch()}};var Jg=class Jg extends yn{constructor(){super(...arguments);this.clonedSvgElements=new Map;this.movedX=0;this.movedY=0;this.oldMoveX=0;this.oldMoveY=0;this.ready=!1;this.isMultiSelect=!1;this.isDragOneOf8Dot=!1}install(i){var d;console.log(this.getSymbol(),"installed"),Ke.startBatch();let{originalEvent:r}=i,n=r.target,s=Jg.bboxEdgeIndex;s!==-1&&!n.id.includes("cdot")&&(n=le("cdot"+s));let a=Mi();for(let p of a)Ke.jsonSnap.addOne(k.getById(p.id).json);this.selectedObjs=is(a),this.isMultiSelect=this.selectedObjs.length>1;let o=a[0];if(this.isMultiSelect&&te(H.selectBox1,"visible")=="visible"&&(o=H.selectBox1,this.multiBoundingBox=Fi.get(o)),!o)return;let l,c=ui(r,!1);if(n.id===wt.insertAnchorId)l=wt.updateD(),ar.showHandleOfIndexes([l]);else if(((d=ar.findControlDot(c.x,c.y))==null?void 0:d.type)=="anchor"){let p=ar.getNextDisplayAnchor(+te(n,"id").substr(4));ar.showHandleOfIndexes(p)}wt.removeMiddleAnchor(),this.ready=!0,this.hasFirstMove=!1,this.target=o,this.mouseDownX=c.x,this.mouseDownY=c.y,this.dotIndex=ft(l)?+n.id.substr(4):l;let u=ar.findControlDot(c.x,c.y);if(!u&&(u=ar.findControlDotByIndex(s),!u))return;this.isDragOneOf8Dot=u.type==="bbox",s===-1&&ar.selectAnchorOrHandle(u.id),this.targetX0=u.x,this.targetY0=u.y;let h=Fi.get(o,"single");this.BBoxDots8=Ua(h)?h.bbox:h,this.BBoxDots8Arr=a.map(p=>Fi.get(p)),this.pathD0=te(o,"d")||void 0;for(let p of this.selectedObjs)this.clonedSvgElements.set(p.id,p.cloneNode(!0));Xs.flush()}uninstall(i){console.log(this.getSymbol(),"uninstalled"),Jg.bboxEdgeIndex=-1,zt.emptyContext(),mo.removeAuxiliaryLine()}getSymbol(){return ii.drag_control_dot_tool}static canSwitchMe(i){let n=$t(i.originalEvent.target)==="cdot",s=ar.isNearBBoxEdge({x:i.canvasX,y:i.canvasY});if(n||s!==-1){if(Mi().length===0)return!1;let o=Ae.getIds(),{combinations:l,elements:c}=new rt().getSelectedCombinations(o),u=new Set;for(let h of l){let d=k.getCombination(h);d.locked&&u.add(d.gId)}for(let h of c)Gi.isLockedById(h)&&u.add(h);return u.size?(qa([...u]),!1):(Jg.bboxEdgeIndex=s,!0)}return!1}ondragstart(){for(let i of this.selectedObjs)Ke.jsonSnap.addOne(k.getById(i.id).json);this.target.id.startsWith("selectBox")?bt.setExcludeShapeIds(Ae.getIds()):bt.setExcludeShapeIds([this.target.id]),pi.emptySelectContainer().emptyLastHoverEle().removeHighlightStroke(),zt.createContext()}onMouseMove(i){let{originalEvent:r}=i,n=this.target;Qn.altKeyEnabled=r.altKey;let s=r.shiftKey,a=ui(r,!1);this.isDragOneOf8Dot||(a=mo.overrideXY(s,{x:this.mouseDownX,y:this.mouseDownY},a.x,a.y));let o=a.x-this.mouseDownX,l=a.y-this.mouseDownY;if(!this.hasFirstMove&&(o*o+l*l)*H.gZoom*H.gZoom<9)return;this.hasFirstMove||(this.hasFirstMove=!0,this.ondragstart());let c=o,u=l;if(Ge.adsorbGrid.enabled){let m={x:o+this.targetX0,y:l+this.targetY0},g=Ra(m);r.altKey?(c=g.x-this.targetX0,u=g.y-this.targetY0):(g=tb(a),c=g.x-this.targetX0,u=g.y-this.targetY0)}n.tagName!="path"?(c=Math.round(c+this.targetX0)-this.targetX0,u=Math.round(u+this.targetY0)-this.targetY0):(c=+(c+this.targetX0).toFixed(2)-this.targetX0,u=+(u+this.targetY0).toFixed(2)-this.targetY0);let h=c-this.movedX,d=u-this.movedY;if(!h&&!d)return;Ar.tryStart(i),this.movedX=c,this.movedY=u;let p=this.selectedObjs.length,f={ctrl:r.ctrlKey,keepRatio:s,multiBoundingBox:this.multiBoundingBox,BBoxDots8:this.BBoxDots8};if(Fi.set(n,this.BBoxDots8,this.dotIndex,this.movedX,this.movedY,this.pathD0,a.x,a.y,!1,s,f),this.isMultiSelect&&p!=1){let m=this.selectedObjs,g=!0;for(let b=0;b<m.length;b++)f=Object.assign({},f,{beforeDragPath:this.clonedSvgElements.get(m[b].id)}),Fi.set(m[b],this.BBoxDots8Arr[b],this.dotIndex,this.movedX,this.movedY,this.pathD0||this.multiBoundingBox,a.x,a.y,g,s,f)}this.oldMoveX=this.movedX,this.oldMoveY=this.movedY,this.updateRightPanel(),zt.runTask(!0),fr(this.selectedObjs,{create8Dots:!0})}updateRightPanel(){if(!this.isMultiSelect){let{json:r,cmdKey:n}=k.getById(this.target.id),s=r.matrix;r.matrix=r.tempMatrix||s;let a=k.getShapeAttr(r,n);r.matrix=s,Ce("/panel/updatePanelValue",{"attr-x":a["attr-x"],"attr-y":a["attr-y"],"attr-width":a["attr-width"],"attr-height":a["attr-height"]});return}let i=wD(this.selectedObjs,{});Ce("/panel/updatePanelValue",{"attr-bbox-x":i["attr-bbox-x"],"attr-bbox-y":i["attr-bbox-y"],"attr-bbox-width":i["attr-bbox-width"],"attr-bbox-height":i["attr-bbox-height"]})}onMouseLeftUp(i){i.toolFinished=!0,Ar.cancel();for(let r of this.selectedObjs){let{json:n,cmdKey:s}=k.getById(r.id);switch(n.tempMatrix&&(n.matrix=n.tempMatrix,Reflect.deleteProperty(n,"tempMatrix")),s){case"group":n.d=te(r,"d"),delete n.tempD;break;case"arc":Object.assign(n,n.temp),delete n.temp;break;default:break}}Ke.saveBatch(),bt.clearExcludeShapeIds(),bt.clearAdsorptionHTML(),Ce("panel_updateAttrPanel"),pi.appendSelectStroke(),fr(this.selectedObjs,{create8Dots:!0})}};Jg.bboxEdgeIndex=-1;var Kg=Jg;var $g=class extends yn{constructor(){super(...arguments);this.movedX=0;this.movedY=0;this.oldMoveX=0;this.oldMoveY=0;this.ready=!1;this.anchorDrager=[]}install(i){console.log(this.getSymbol(),"installed");let{originalEvent:r}=i,n=Mi();this.selectedObjs=is(n);let s=n[0];if(!s)return;var a=ui(r,!1);this.ready=!0,this.hasFirstMove=!1,this.target=s,this.mouseDownX=a.x,this.mouseDownY=a.y;let o=ar.findControlDot(a.x,a.y),l=new _i(k.getArc(s.id));l.setControlDotSelected(o.x,o.y)&&this.anchorDrager.push(l),this.targetX0=o.x,this.targetY0=o.y}uninstall(i){console.log(this.getSymbol(),"uninstalled"),zt.emptyContext(),mo.removeAuxiliaryLine()}getSymbol(){return ii.drag_control_dot_arc_tool}static canSwitchMe(i){let{canvasX:r,canvasY:n}=i,s=ar.findControlDot(r,n);return!s||s.type==="bbox"?!1:Gi.isLockedById(Ae.getIds().at(0))?(qa(),!1):s.belongCmdKey==="arc"}ondragstart(){Ke.startBatch();for(let i of this.selectedObjs)Ke.jsonSnap.addOne(k.getById(i.id).json);this.target.id.startsWith("selectBox")?bt.setExcludeShapeIds(Ae.getIds()):bt.setExcludeShapeIds([this.target.id]),pi.emptySelectContainer().emptyLastHoverEle().removeHighlightStroke(),zt.createContext()}onMouseMove(i){let{originalEvent:r}=i;Qn.altKeyEnabled=r.altKey;let n=r.shiftKey,s=ui(r,!1),a=s.x-this.mouseDownX,o=s.y-this.mouseDownY;if(!this.hasFirstMove&&(a*a+o*o)*H.gZoom*H.gZoom<9)return;this.hasFirstMove||(this.hasFirstMove=!0,this.ondragstart());let l=a,c=o;if(Ge.adsorbGrid.enabled){let p={x:a+this.targetX0,y:o+this.targetY0},f=Ra(p);r.altKey?(l=f.x-this.targetX0,c=f.y-this.targetY0):(f=tb(s),l=f.x-this.targetX0,c=f.y-this.targetY0)}l=+(l+this.targetX0).toFixed(2)-this.targetX0,c=+(c+this.targetY0).toFixed(2)-this.targetY0;let u=l-this.movedX,h=c-this.movedY;if(!u&&!h)return;this.movedX=l,this.movedY=c;let d={ctrl:r.ctrlKey,alt:r.altKey,keepRatio:n};for(let p of this.anchorDrager)p.moveControlPoint(this.movedX,this.movedY,d),_i.createHalfArc(p.data.gId);this.oldMoveX=this.movedX,this.oldMoveY=this.movedY,zt.runTask(!0),this.updateRightPanel(),fr(this.selectedObjs,{create8Dots:!0})}updateRightPanel(){let{json:i}=k.getById(this.target.id),r=vw(i.temp||i);Ce("/panel/updatePanelValue",{"attr-start-x":r["attr-start-x"],"attr-start-y":r["attr-start-y"],"attr-circle-center-x":r["attr-circle-center-x"],"attr-circle-center-y":r["attr-circle-center-y"],"attr-end-x":r["attr-end-x"],"attr-end-y":r["attr-end-y"],"attr-long-radius":r["attr-long-radius"],"attr-short-radius":r["attr-short-radius"],"attr-start-angle":r["attr-start-angle"],"attr-end-angle":r["attr-end-angle"]})}onMouseLeftUp(i){if(i.toolFinished=!0,!!this.hasFirstMove){for(let r of this.selectedObjs){let{json:n,cmdKey:s}=k.getById(r.id);switch(s){case"arc":Object.assign(n,n.temp),delete n.temp;break;default:console.error("Plz check code,",s);break}}Ke.saveBatch(),bt.clearExcludeShapeIds(),bt.clearAdsorptionHTML(),Ce("panel_updateAttrPanel"),pi.appendSelectStroke(),fr(this.selectedObjs,{create8Dots:!0})}}};$g.bboxEdgeIndex=-1;var nb=class extends yn{constructor(){super();this.dots=[]}install(i){console.log(this.getSymbol(),"installed"),pr("cross-red")}uninstall(i){console.log(this.getSymbol(),"uninstalled"),qd()}getSymbol(){return ii.rect_select_tool}static canSwitchMe(){return!0}onMouseLeftDown(i){let{canvasX:r,canvasY:n}=i;this.dots.push(r,n),this.dots.length===4&&(J5(),this.dots.length=0,Ce("panel_updateAttrPanel"),Ce("panel/updateTreeActiveElements"))}onMouseMove(i){let{canvasX:r,canvasY:n}=i;if(!this.dots.length)return;let s=new ot;s.ext6(this.dots[0],this.dots[1]),s.ext6(r,n);let a=s.build();uw(a.minX,a.minY,a.width(),a.height())}onMouseRightUp(i){uw(0,0,0,0,"none"),i.toolFinished=!0}onKeyUp(i){i.originalEvent.code==="Escape"&&(i.toolFinished=!0)}};var xf=class extends Cu{constructor(){super(...arguments);this.currentTool=null;this.startX=void 0;this.startY=void 0;this.endX=void 0;this.endY=void 0}currentToolIs(i){var r;return((r=this.currentTool)==null?void 0:r.getSymbol())===i}getCtx(){return this.ctx}switchToPasteTool(i,r,n){this.currentToolIs(ii.paste_tool)||Bh.canSwitchMe(i).then(s=>{s&&this.switchTool(this.ctx,new Bh(i,r,n))})}switchToRectSelectTool(){nb.canSwitchMe()&&this.switchTool(this.ctx,new nb)}switchToDrawTool(i,r){if(this.currentToolIs(ii.place_lib_tool)){let n=this.getCtx();this.currentTool.onMouseRightUp(n)}if(Je.canSwitchMe(i))return this.uninstallCurTool(this.ctx).switchTool(this.ctx,new Je(i,r))}switchToReferencePointTool(){return lr.canSwitchMe()?this.switchTool(this.ctx,new lr):!1}switchToHighlightTool(){this.ctx.toolFinished=!1,this.switchTool(this.ctx,new Fu)}onAnyEventStart(i){this.ctx=i,i.toolFinished=!1,Qn.altKeyEnabled=i.altKeyDown;let[r,n]=[Qn.getSanpSize("X"),Qn.getSanpSize("Y")];i.canvasX!==void 0&&(i.snapX=Math.round(i.canvasX/r)*r),i.canvasY!==void 0&&(i.snapY=Math.round(i.canvasY/n)*n),i.startX=this.startX,i.startY=this.startY,this.switchToDefaultTool(i)}switchToDefaultTool(i=this.ctx){this.currentTool===null&&this.switchTool(i,new Fu)}onAnyEventEnd(i){i.toolFinished&&this.uninstallCurTool(i)}onMouseLeftDown(i){if(this.startX=i.snapX,this.startY=i.snapY,i.startX=i.snapX,i.startY=i.snapY,!!this.currentToolIs(ii.highlight)){if(ib.canSwitchMe(i)){this.switchTool(i,new ib);return}if($g.canSwitchMe(i)){this.switchTool(i,new $g);return}if(Kg.canSwitchMe(i)){this.switchTool(i,new Kg);return}if(rb.canSwitchMe(i))return this.switchTool(i,new rb);En.canSwitchMe(i)}}onMouseLeftUp(i){this.endX=i.snapX,this.endY=i.snapY,En.clickedCanvas=!1}onMouseMove(i){if(this.currentToolIs(ii.highlight)){if(Os.isAdaptAreaSelectionView())return this.switchTool(i,new Os);if(En.clickedCanvas)return this.switchTool(i,new En);if(Gu.canSwitchMe())return this.switchTool(i,new Gu)}let{originalEvent:r,ctrlKeyDown:n}=i;n&&r.ctrlKey||this.currentToolIs(ii.highlight)&&Ka.canSwitchMe(i)&&this.switchTool(i,new Ka)}onDoubleClick(i){Kg.canSwitchMe(i)&&this.endX==this.startX&&this.endY==this.startY&&new Fu().onDoubleClick(i)}switchTool(i,r){this.uninstallCurTool(i),r.install(i),i.reactor.addProcessor(r),this.currentTool=r}uninstallCurTool(i){return this.currentTool!==null&&(this.currentTool.uninstall(i),this.currentTool.detach(),this.currentTool=null),this}};Ws([Xte],xf.prototype,"switchTool",1);function Xte(e,t,i){let r=e[t];return e[t]=async function(n,s){if(Ru.forbiddenDataChange()){let a=En.selectionMode,o=s.getSymbol();if(!([ii.highlight,ii.drag_select_area_tool,ii.rect_select_tool].includes(o)||o===ii.draw&&["polygonInside","polygonOutside","lineTouched"].includes(a))){this.currentTool.uninstall(n),Rh();return}}return r.apply(this,arguments)},e}function i6(){let e=new y2(document,()=>new ag);return e.addProcessor(new x2),e.addProcessor(new ao),e.addProcessor(new xf),e.install(),e}var Cw=class{constructor(t){this._rector=t}getToolProcessor(){let t=this._rector.getProcessors();for(let i of t)if(i instanceof xf)return i}getToolProcessorCurrentTool(){var t;return(t=this.getToolProcessor())==null?void 0:t.currentTool}};var Dw=class{constructor(t){this.gCanvas=t.gCanvas}};var _w=class extends Dw{constructor(t){super(t)}insertBefore(t,i){let r=bs(t.cmdKey,t);this.gCanvas.insertBefore(r,le(i)||null)}removeNode(t){dt(le(t))}attr(t,i,r){return te(le(t),i,r)}attrs(t,i){for(let r in i)this.attr(t,r,i[r])}};H.messageBus=window._MSG_BUS_=window._MSG_BUS_||new Lw.MessageBus;H.windowBridge=new Lw.WindowMessageBridge(H.messageBus);$l.registerHook(Wr());Rk();function Wte(e,t){let i=e.parentElement.querySelector(".rulerh");if(i){let n=t.width+"px";i.getAttribute("width")!==n&&i.setAttribute("width",n)}let r=e.parentElement.querySelector(".rulerv");if(r){let n=t.height+"px";r.getAttribute("height")!==n&&r.setAttribute("height",n)}}var Pw,r6=Id(function(){if(!H.tabId)return;let e=or("getTabIFrame",H.tabId);if(!e)return;let t=e.getBoundingClientRect();Wte(e,t);let i=0,r=0;Pw&&(i=t.left-Pw.left,r=t.top-Pw.top),Pw=t;let{gZoom:n}=H,s=document.documentElement.clientWidth||9,a=document.documentElement.clientHeight||9,o=Xt.getViewBox(),l=[o[0]+i/n,o[1]+r/n,s/n,a/n];te(H.svgRoot,{width:s,height:a}),Xt.setViewBox(l),Ni.updateHole()});window.addEventListener("resize",r6,!1);window.addEventListener("beforeResize",r6);window.addEventListener("load",function(){Xt.init(),ri.renderer=new _w({gCanvas:H.gCanvas}),ri.history=Ke,H.svgRoot=document.getElementById("root"),H.doctype=Number(window.frameElement.getAttribute("c_doctype"));let e=te(window.frameElement,"c_dbid");document.addEventListener("contextmenu",Jk,!1),document.addEventListener(mu&&!("onwheel"in document)?"MozMousePixelScroll":"wheel",Kk,{passive:!1}),document.addEventListener("mousemove",t=>{qk(t)},!1),document.addEventListener("mousemove",Ir,!1),document.addEventListener("mouseup",Ir,!1),document.addEventListener("mousedown",Ir,!1),document.addEventListener("mouseout",function(){Ir.data.uplock=!0},!1),$k(),H.frameHelper=new Cw(i6()),LB(),window.loaded=!0,or("triggerEvent",["editor_load"],e)},!1);(function(){document.addEventListener("dblclick",async function(i){if(i.target.parentNode==H.gControlDots){e(i);return}},!1);function e(i){var r=i.target,n=i.ctrlKey||i.altKey||i.shiftKey;n||(Nd.deletePathNode(r),pi.emptyLastHoverEle().emptySelectContainer().removeHighlightStroke())}let t=["dragenter","dragover"];for(let i of t)document.addEventListener(i,r=>{r.preventDefault()})})();document.addEventListener("click",function(e){H.windowBridge.publish("triggerClick",e&&e.type,ut())},!1);window.callCommand=$l;var Zg=[];H.messageBus.subscribe("/debug/draw",e=>{Zg.forEach(t=>t.remove()),Zg.length=0;for(let t in e){let i=e[t],r=new Da,{lines:n}=i;if(n)for(let p=0;p<n.length;p+=4)r.encPt(new ie(new j(n[p],n[p+1]),new j(n[p+2],n[p+3]))),r.close(!1);let{arcs:s}=i;if(s)for(let p=0;p<s.length;p+=6)r.encPt(Se.build2(new j(s[p],s[p+1]),s[p+3],s[p+4],s[p+2],s[p+2],s[p+5])),r.close(!1);let{beziers:a}=i,o=[];if(a)for(let p=0;p<a.length;)typeof a[p]=="number"?(o.push(new j(a[p],a[p+1])),p+=2):(r.encPt(new Ye(o)),r.close(!1),o=[],p++);Zg.push(Et("path",{"stroke-width":"2px","vector-effect":"non-scaling-stroke",d:r.toString(),fill:"none",stroke:t}));let{points:l,size:c,isTriangle:u}=i,h=new Da;if(l){for(let p=0;p<l.length;p+=2){let f=new j(l[p],l[p+1]);h.encPt(new ie(f,f)),h.close(!1)}Zg.push(Et("path",{"stroke-width":c/2,"vector-effect":"non-scaling-stroke",d:h.toString(),fill:"none",stroke:t}))}let{fonts:d}=i;if(d)for(let p=0;p<d.length;p+=3){let f=Et("g");Zg.push(f);let m=Et("title");m.innerHTML=d[p],f.append(m),f.append(Et("path",{"stroke-width":16,"vector-effect":"non-scaling-stroke",d:`M ${d[p+1]} ${-d[p+2]} L ${d[p+1]} ${-d[p+2]}`,stroke:"red"}))}}Zg.forEach(t=>H.svgRoot.append(t))});function Bn(){}self.assert=Bn;self.assert_eq=Bn;self.assert_ne=Bn;self.assert_gt=Bn;self.assert_gte=Bn;self.assert_lt=Bn;self.assert_lte=Bn;self.assert_def=Bn;self.assert_notnull=Bn;self.assert_undef=Bn;self.assert_number=Bn;self.assert_string=Bn;self.assert_boolean=Bn;self.assert_string=Bn;self.assert_null=Bn;self.assert_finite=Bn;self.assert_regex=Bn;self.assert_line_style=Bn;self.assert_text_style=Bn;self.assert_not_key=Bn;self.assert_string_or_null=Bn;self.assert_number_or_null=Bn;self.assert_boolean_or_null=Bn;self.assert_point_arr=Bn;self.assert_group_type=Bn;var jc={};jc.PANELGVars=H;jc.History=Ke;jc.$$$=Hr;jc.$$$1=_r;jc.$$=le;jc.jsonMgr=k;jc.Config=Ge;jc.DOCTYPE=ta;jc.parseXML=zs;jc.adsorptionTool=bt;window.PANEL=jc;})();
/*! Bundled license information:

jquery/dist/jquery.js:
  (*!
   * jQuery JavaScript Library v3.7.1
   * https://jquery.com/
   *
   * Copyright OpenJS Foundation and other contributors
   * Released under the MIT license
   * https://jquery.org/license
   *
   * Date: 2023-08-28T13:37Z
   *)

path-data-polyfill/path-data-polyfill.js:
  (* @license *)

lc-editor-common/dist/index.js:
  (*! Bundled license information:
  
  lc-protocol/dist/index.js:
    (*! Bundled license information:
    
    crypto-js/ripemd160.js:
      (** @preserve
      	(c) 2012 by Cédric Mesnil. All rights reserved.
      
      	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
      
      	    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
      	    - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
      
      	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      	*)
    
    crypto-js/mode-ctr-gladman.js:
      (** @preserve
       * Counter block mode compatible with  Dr Brian Gladman fileenc.c
       * derived from CryptoJS.mode.CTR
       * Jan Hruby jhruby.web@gmail.com
       *)
    *)
  *)

lc-protocol/dist/index.js:
  (*! Bundled license information:
  
  crypto-js/ripemd160.js:
    (** @preserve
    	(c) 2012 by Cédric Mesnil. All rights reserved.
    
    	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    
    	    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    	    - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    
    	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    	*)
  
  crypto-js/mode-ctr-gladman.js:
    (** @preserve
     * Counter block mode compatible with  Dr Brian Gladman fileenc.c
     * derived from CryptoJS.mode.CTR
     * Jan Hruby jhruby.web@gmail.com
     *)
  *)
*/
//# sourceMappingURL=https://modules.lceda.cn/pro-panel/3.2.130.8384746b/js/panel.js.map
