(()=>{var Yk=Object.create;var vw=Object.defineProperty;var _D=Object.getOwnPropertyDescriptor;var Hk=Object.getOwnPropertyNames;var jk=Object.getPrototypeOf,Vk=Object.prototype.hasOwnProperty;var oo=(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 Iw=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var zk=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Hk(t))!Vk.call(e,n)&&n!==i&&vw(e,n,{get:()=>t[n],enumerable:!(r=_D(t,n))||r.enumerable});return e};var Ug=(e,t,i)=>(i=e!=null?Yk(jk(e)):{},zk(t||!e||!e.__esModule?vw(i,"default",{value:e,enumerable:!0}):i,e));var La=(e,t,i,r)=>{for(var n=r>1?void 0:r?_D(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&&vw(t,i,n),n};var RD=Iw((Gee,OD)=>{var LD=[];LD.push(`<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<title>Panel3DView</title>
		<style>
			* {
				box-sizing: border-box;
				padding: 0px;
				margin: 0px;
			}

			body {
				overflow: hidden;
			}

			#canvas {
				position: absolute;
				width: 100vw;
				height: 100vh;
				z-index: 1;
				left: 0;
				top: 0;
			}

			body {
				background-color: #aaa;
			}
		</style>
	</head>

	<body>
		<canvas id="canvas" tabindex="0"></canvas>

		<script>
			document.addEventListener('mousedown', e => {
				// \u9F20\u6807\u53F3\u952E
				if (e.button === 2) {
					document.body.style.cursor = 'grabbing';
				}
			});

			document.addEventListener('mouseup', e => {
				document.body.style.cursor = 'auto';
			});
		<\/script>
	</body>
</html>
`);OD.exports=LD.join("")});var ib=Iw((Wee,KD)=>{"use strict";var Rw=Object.defineProperty,Wk=Object.getOwnPropertyDescriptor,qk=Object.getOwnPropertyNames,Jk=Object.prototype.hasOwnProperty,Kk=(e,t)=>{for(var i in t)Rw(e,i,{get:t[i],enumerable:!0})},$k=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of qk(t))!Jk.call(e,n)&&n!==i&&Rw(e,n,{get:()=>t[n],enumerable:!(r=Wk(t,n))||r.enumerable});return e},Zk=e=>$k(Rw({},"__esModule",{value:!0}),e),HD={};Kk(HD,{BroadcastChannelMessageBus:()=>m6,MessageBus:()=>u6,MessageBus2:()=>p6,MessageBusTask:()=>Lw,MessageBusTask2:()=>Yg,WindowMessageBridge:()=>c6,WorkerMessageBridge:()=>l6,createBroadcastP2PStream:()=>qD,createBufferedByteBufferStream:()=>WD,createBufferedStream:()=>Bw,createBufferedStringStream:()=>XD,dropP2PStream:()=>g6,flowRead:()=>b6,flowWrite:()=>y6});KD.exports=Zk(HD);var eb=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}},Nw=new ArrayBuffer(8),Vee=new Float64Array(Nw),zee=new Uint32Array(Nw),Xee=new Uint16Array(Nw),_w=ArrayBuffer;try{_w=self.HTMLImageElement||_w}catch{}var Qk=typeof SharedArrayBuffer<"u";function tb(e){if(typeof e!="object"||e===null||e instanceof Date||e instanceof ArrayBuffer||Qk&&e instanceof SharedArrayBuffer||e instanceof Blob||e instanceof FormData||e instanceof Function||e instanceof Uint8ClampedArray||e instanceof _w)return e;if(Array.isArray(e))return e.map(tb);{let t={};for(let i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=tb(e[i]));return t}}function Pw(e,t){return e6(e,t,()=>[])}function e6(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var t6=class{constructor(e){this.maxResources=e,this.idle=new eb,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 i6(){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 r6(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 n6=i6(),s6=n6.WeakRef||(e=>e);function Hd(e){if(e!=null){if(typeof e=="object")return new s6(e);console.error(e,e instanceof Object,typeof e);return}}function Ph(e){return e==null?void 0:e.deref()}var a6="_MSG_BUS_RPC_",Mw=300*1e3,o6=(e=>(e.PUBLISH="publish",e.SUBSCRIBE="subscribe",e.PUSH="push",e.PULL="pull",e))(o6||{}),jD=class{constructor(e){this.bus=e}processRemoteMessage(e,t){let i=Hd(t),r=e.topic,n=e.type,s=e.message;switch(n){case"pull":this.bus.pull(r,a=>{this.push(r,a,Ph(i))});break;case"subscribe":this.bus.subscribe(r,a=>{this.publish(r,a,Ph(i))});break;case"publish":this.bus.publish(r,s,this,Ph(i));break;case"push":this.bus.push(r,s,this,Ph(i));break;default:console.debug("unknown message type "+n)}}rpcCall(e,t,i,r=Mw){let n=Hd(i),s=new Promise(a=>{let o=this.bus.uniqueRpcTopic(e);this.publish(e,{message:t,reply:o},Ph(n)),this.bus.pull(o,(l,c,u)=>{a({message:l,bridge:c,source:Hd(u)})})});return r>0?Promise.race([s,new Promise((a,o)=>{setTimeout(o,r)})]):s}},l6=class extends jD{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=Mw){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()}},c6=class extends jD{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,"*")}},Lw=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:tb(e),this.callback(e,t,i)}catch(n){console.error(n)}}},u6=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`${a6}-${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)r6(n,a)}else console.debug("no sub on topic: "+e)}subscribe(e,t){let i=new Lw(t);return Pw(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||Pw(this.pushed,e).push({message:t,bridge:i,source:Hd(r)})}pull(e,t){let i=new Lw(t),r=this.pushed[e];if(r){let n=r.shift();i.execute(n.message,n.bridge,Ph(n.source),this.unsafe),r.length===0&&delete this.pushed[e]}else Pw(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:Hd(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=Hd(n);o.then(c=>{this.rpcReply(c,a,r,Ph(l))},c=>{console.error(c),this.rpcReply(void 0,a,r,Ph(l))})}else this.rpcReply(o,a,r,n)}catch(o){console.error(o),this.rpcReply(void 0,a,r,n)}})}rpcCall(e,t,i=Mw){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:Hd(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)}},h6="_MSG_BUS_RPC_";function Ow(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 hf(e,t){return d6(e,t,()=>[])}function d6(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var Yg=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:tb(e),this.callback(e)}catch(t){console.error(t)}}},VD=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=`${h6}-${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}},p6=class extends VD{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)Ow(i,n)}}subscribe(e,t){let i=new Yg(t,this.unsafe);return hf(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||hf(this.pushed,e).push(t)}pull(e,t){let i=new Yg(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 hf(this.pulled,e).push(t)}},f6=class extends VD{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 Yg(t,!0);return hf(this.subscribed,e).push(i),i}push(e,t){let i=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",e,`(${i})`,t),hf(this.pushed,e).push({id:i,message:t}),this.broadcastPushedHeadMessage(e)}pull(e,t){console.debug("BC",this.uuid,"PULL",e);let i=new Yg(t,!0);return hf(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)Ow(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)Ow(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]}}},m6=class extends f6{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)})}},df=Symbol("BLOCKING_QUEUE_RESET"),zD=class{constructor(e,t=()=>1){if(this.maxSize=e,this.itemSizeOf=t,this.queue=new eb,this.waitingConsumers=new eb,this.waitingProducers=new eb,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(df).then(e)}return setTimeout(()=>this.closeResolve(),0),df}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(df).then(t)}e()}})),this.closePromise}};function Bw(e,t,i=Number.MAX_SAFE_INTEGER){let r=new zD(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===df?a.close():c.push(h)}else{let h=u;h===df?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 XD(e=Number.MAX_SAFE_INTEGER){return Bw(t=>t.join(""),t=>t.length,e)}function WD(e=Number.MAX_SAFE_INTEGER){return Bw(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 qD(e){return new Promise((t,i)=>{let r=new BroadcastChannel(e),n=new zD(1),s=new t6(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(x){let y=await n.dequeue();y===df?(await f(),x.close()):(x.enqueue(y),r.postMessage({type:"ACK"}))},cancel(){return f()}}),ws:new WritableStream({async write(x,y){await s.acquireSync()?r.postMessage({type:"DATA",id:g++,data:x}):(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 g6(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 JD(e){try{return await qD(e)}catch(t){t.message!=="p2p channel connection released"&&console.error(t)}}async function y6(e,t,i=10*1024*1024,r=!0){let n=await JD(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=XD(i);c.readable.pipeTo(n.ws),a=c.writable.getWriter()}else{let c=WD(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 b6(e,t){var r,n;let i=await JD(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 q4=Iw((W4,q2)=>{(function(e,t){"use strict";typeof q2=="object"&&typeof q2.exports=="object"?q2.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:W4,function(e,t){"use strict";var i=[],r=Object.getPrototypeOf,n=i.slice,s=i.flat?function(S){return i.flat.call(S)}:function(S){return i.concat.apply([],S)},a=i.push,o=i.indexOf,l={},c=l.toString,u=l.hasOwnProperty,h=u.toString,d=h.call(Object),p={},f=function(P){return typeof P=="function"&&typeof P.nodeType!="number"&&typeof P.item!="function"},m=function(P){return P!=null&&P===P.window},g=e.document,x={type:!0,src:!0,nonce:!0,noModule:!0};function y(S,P,Y){Y=Y||g;var X,$,Q=Y.createElement("script");if(Q.text=S,P)for(X in x)$=P[X]||P.getAttribute&&P.getAttribute(X),$&&Q.setAttribute(X,$);Y.head.appendChild(Q).parentNode.removeChild(Q)}function E(S){return S==null?S+"":typeof S=="object"||typeof S=="function"?l[c.call(S)]||"object":typeof S}var T="3.7.1",w=/HTML$/i,b=function(S,P){return new b.fn.init(S,P)};b.fn=b.prototype={jquery:T,constructor:b,length:0,toArray:function(){return n.call(this)},get:function(S){return S==null?n.call(this):S<0?this[S+this.length]:this[S]},pushStack:function(S){var P=b.merge(this.constructor(),S);return P.prevObject=this,P},each:function(S){return b.each(this,S)},map:function(S){return this.pushStack(b.map(this,function(P,Y){return S.call(P,Y,P)}))},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(b.grep(this,function(S,P){return(P+1)%2}))},odd:function(){return this.pushStack(b.grep(this,function(S,P){return P%2}))},eq:function(S){var P=this.length,Y=+S+(S<0?P:0);return this.pushStack(Y>=0&&Y<P?[this[Y]]:[])},end:function(){return this.prevObject||this.constructor()},push:a,sort:i.sort,splice:i.splice},b.extend=b.fn.extend=function(){var S,P,Y,X,$,Q,ie=arguments[0]||{},xe=1,be=arguments.length,Ae=!1;for(typeof ie=="boolean"&&(Ae=ie,ie=arguments[xe]||{},xe++),typeof ie!="object"&&!f(ie)&&(ie={}),xe===be&&(ie=this,xe--);xe<be;xe++)if((S=arguments[xe])!=null)for(P in S)X=S[P],!(P==="__proto__"||ie===X)&&(Ae&&X&&(b.isPlainObject(X)||($=Array.isArray(X)))?(Y=ie[P],$&&!Array.isArray(Y)?Q=[]:!$&&!b.isPlainObject(Y)?Q={}:Q=Y,$=!1,ie[P]=b.extend(Ae,Q,X)):X!==void 0&&(ie[P]=X));return ie},b.extend({expando:"jQuery"+(T+Math.random()).replace(/\D/g,""),isReady:!0,error:function(S){throw new Error(S)},noop:function(){},isPlainObject:function(S){var P,Y;return!S||c.call(S)!=="[object Object]"?!1:(P=r(S),P?(Y=u.call(P,"constructor")&&P.constructor,typeof Y=="function"&&h.call(Y)===d):!0)},isEmptyObject:function(S){var P;for(P in S)return!1;return!0},globalEval:function(S,P,Y){y(S,{nonce:P&&P.nonce},Y)},each:function(S,P){var Y,X=0;if(C(S))for(Y=S.length;X<Y&&P.call(S[X],X,S[X])!==!1;X++);else for(X in S)if(P.call(S[X],X,S[X])===!1)break;return S},text:function(S){var P,Y="",X=0,$=S.nodeType;if(!$)for(;P=S[X++];)Y+=b.text(P);return $===1||$===11?S.textContent:$===9?S.documentElement.textContent:$===3||$===4?S.nodeValue:Y},makeArray:function(S,P){var Y=P||[];return S!=null&&(C(Object(S))?b.merge(Y,typeof S=="string"?[S]:S):a.call(Y,S)),Y},inArray:function(S,P,Y){return P==null?-1:o.call(P,S,Y)},isXMLDoc:function(S){var P=S&&S.namespaceURI,Y=S&&(S.ownerDocument||S).documentElement;return!w.test(P||Y&&Y.nodeName||"HTML")},merge:function(S,P){for(var Y=+P.length,X=0,$=S.length;X<Y;X++)S[$++]=P[X];return S.length=$,S},grep:function(S,P,Y){for(var X,$=[],Q=0,ie=S.length,xe=!Y;Q<ie;Q++)X=!P(S[Q],Q),X!==xe&&$.push(S[Q]);return $},map:function(S,P,Y){var X,$,Q=0,ie=[];if(C(S))for(X=S.length;Q<X;Q++)$=P(S[Q],Q,Y),$!=null&&ie.push($);else for(Q in S)$=P(S[Q],Q,Y),$!=null&&ie.push($);return s(ie)},guid:1,support:p}),typeof Symbol=="function"&&(b.fn[Symbol.iterator]=i[Symbol.iterator]),b.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(S,P){l["[object "+P+"]"]=P.toLowerCase()});function C(S){var P=!!S&&"length"in S&&S.length,Y=E(S);return f(S)||m(S)?!1:Y==="array"||P===0||typeof P=="number"&&P>0&&P-1 in S}function A(S,P){return S.nodeName&&S.nodeName.toLowerCase()===P.toLowerCase()}var R=i.pop,O=i.sort,M=i.splice,k="[\\x20\\t\\r\\n\\f]",G=new RegExp("^"+k+"+|((?:^|[^\\\\])(?:\\\\.)*)"+k+"+$","g");b.contains=function(S,P){var Y=P&&P.parentNode;return S===Y||!!(Y&&Y.nodeType===1&&(S.contains?S.contains(Y):S.compareDocumentPosition&&S.compareDocumentPosition(Y)&16))};var H=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function q(S,P){return P?S==="\0"?"\uFFFD":S.slice(0,-1)+"\\"+S.charCodeAt(S.length-1).toString(16)+" ":"\\"+S}b.escapeSelector=function(S){return(S+"").replace(H,q)};var I=g,N=a;(function(){var S,P,Y,X,$,Q=N,ie,xe,be,Ae,He,qe=b.expando,Be=0,nt=0,bi=z1(),hr=z1(),Oi=z1(),aa=z1(),Os=function(ce,ve){return ce===ve&&($=!0),0},Gc="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",Uc="(?:\\\\[\\da-fA-F]{1,6}"+k+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",ir="\\["+k+"*("+Uc+")(?:"+k+"*([*^$|!~]?=)"+k+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+Uc+"))|)"+k+"*\\]",Gd=":("+Uc+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+ir+")*)|.*)\\)|)",gr=new RegExp(k+"+","g"),Qn=new RegExp("^"+k+"*,"+k+"*"),kg=new RegExp("^"+k+"*([>+~]|"+k+")"+k+"*"),yw=new RegExp(k+"|>"),Yc=new RegExp(Gd),Fg=new RegExp("^"+Uc+"$"),Hc={ID:new RegExp("^#("+Uc+")"),CLASS:new RegExp("^\\.("+Uc+")"),TAG:new RegExp("^("+Uc+"|[*])"),ATTR:new RegExp("^"+ir),PSEUDO:new RegExp("^"+Gd),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+k+"*(even|odd|(([+-]|)(\\d*)n|)"+k+"*(?:([+-]|)"+k+"*(\\d+)|))"+k+"*\\)|)","i"),bool:new RegExp("^(?:"+Gc+")$","i"),needsContext:new RegExp("^"+k+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+k+"*((?:-\\d)?\\d*)"+k+"*\\)|)(?=[^-]|$)","i")},Ih=/^(?:input|select|textarea|button)$/i,Ah=/^h\d$/i,pl=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,bw=/[+~]/,_u=new RegExp("\\\\[\\da-fA-F]{1,6}"+k+"?|\\\\([^\\r\\n\\f])","g"),Lu=function(ce,ve){var Me="0x"+ce.slice(1)-65536;return ve||(Me<0?String.fromCharCode(Me+65536):String.fromCharCode(Me>>10|55296,Me&1023|56320))},Nk=function(){Ch()},Mk=W1(function(ce){return ce.disabled===!0&&A(ce,"fieldset")},{dir:"parentNode",next:"legend"});function Bk(){try{return ie.activeElement}catch{}}try{Q.apply(i=n.call(I.childNodes),I.childNodes),i[I.childNodes.length].nodeType}catch{Q={apply:function(ve,Me){N.apply(ve,n.call(Me))},call:function(ve){N.apply(ve,n.call(arguments,1))}}}function Wr(ce,ve,Me,Ge){var We,yt,At,zt,Ct,Vi,di,Si=ve&&ve.ownerDocument,zi=ve?ve.nodeType:9;if(Me=Me||[],typeof ce!="string"||!ce||zi!==1&&zi!==9&&zi!==11)return Me;if(!Ge&&(Ch(ve),ve=ve||ie,be)){if(zi!==11&&(Ct=pl.exec(ce)))if(We=Ct[1]){if(zi===9)if(At=ve.getElementById(We)){if(At.id===We)return Q.call(Me,At),Me}else return Me;else if(Si&&(At=Si.getElementById(We))&&Wr.contains(ve,At)&&At.id===We)return Q.call(Me,At),Me}else{if(Ct[2])return Q.apply(Me,ve.getElementsByTagName(ce)),Me;if((We=Ct[3])&&ve.getElementsByClassName)return Q.apply(Me,ve.getElementsByClassName(We)),Me}if(!aa[ce+" "]&&(!Ae||!Ae.test(ce))){if(di=ce,Si=ve,zi===1&&(yw.test(ce)||kg.test(ce))){for(Si=bw.test(ce)&&xw(ve.parentNode)||ve,(Si!=ve||!p.scope)&&((zt=ve.getAttribute("id"))?zt=b.escapeSelector(zt):ve.setAttribute("id",zt=qe)),Vi=Gg(ce),yt=Vi.length;yt--;)Vi[yt]=(zt?"#"+zt:":scope")+" "+X1(Vi[yt]);di=Vi.join(",")}try{return Q.apply(Me,Si.querySelectorAll(di)),Me}catch{aa(ce,!0)}finally{zt===qe&&ve.removeAttribute("id")}}}return PD(ce.replace(G,"$1"),ve,Me,Ge)}function z1(){var ce=[];function ve(Me,Ge){return ce.push(Me+" ")>P.cacheLength&&delete ve[ce.shift()],ve[Me+" "]=Ge}return ve}function $l(ce){return ce[qe]=!0,ce}function lf(ce){var ve=ie.createElement("fieldset");try{return!!ce(ve)}catch{return!1}finally{ve.parentNode&&ve.parentNode.removeChild(ve),ve=null}}function kk(ce){return function(ve){return A(ve,"input")&&ve.type===ce}}function Fk(ce){return function(ve){return(A(ve,"input")||A(ve,"button"))&&ve.type===ce}}function CD(ce){return function(ve){return"form"in ve?ve.parentNode&&ve.disabled===!1?"label"in ve?"label"in ve.parentNode?ve.parentNode.disabled===ce:ve.disabled===ce:ve.isDisabled===ce||ve.isDisabled!==!ce&&Mk(ve)===ce:ve.disabled===ce:"label"in ve?ve.disabled===ce:!1}}function Ud(ce){return $l(function(ve){return ve=+ve,$l(function(Me,Ge){for(var We,yt=ce([],Me.length,ve),At=yt.length;At--;)Me[We=yt[At]]&&(Me[We]=!(Ge[We]=Me[We]))})})}function xw(ce){return ce&&typeof ce.getElementsByTagName<"u"&&ce}function Ch(ce){var ve,Me=ce?ce.ownerDocument||ce:I;return Me==ie||Me.nodeType!==9||!Me.documentElement||(ie=Me,xe=ie.documentElement,be=!b.isXMLDoc(ie),He=xe.matches||xe.webkitMatchesSelector||xe.msMatchesSelector,xe.msMatchesSelector&&I!=ie&&(ve=ie.defaultView)&&ve.top!==ve&&ve.addEventListener("unload",Nk),p.getById=lf(function(Ge){return xe.appendChild(Ge).id=b.expando,!ie.getElementsByName||!ie.getElementsByName(b.expando).length}),p.disconnectedMatch=lf(function(Ge){return He.call(Ge,"*")}),p.scope=lf(function(){return ie.querySelectorAll(":scope")}),p.cssHas=lf(function(){try{return ie.querySelector(":has(*,:jqfake)"),!1}catch{return!0}}),p.getById?(P.filter.ID=function(Ge){var We=Ge.replace(_u,Lu);return function(yt){return yt.getAttribute("id")===We}},P.find.ID=function(Ge,We){if(typeof We.getElementById<"u"&&be){var yt=We.getElementById(Ge);return yt?[yt]:[]}}):(P.filter.ID=function(Ge){var We=Ge.replace(_u,Lu);return function(yt){var At=typeof yt.getAttributeNode<"u"&&yt.getAttributeNode("id");return At&&At.value===We}},P.find.ID=function(Ge,We){if(typeof We.getElementById<"u"&&be){var yt,At,zt,Ct=We.getElementById(Ge);if(Ct){if(yt=Ct.getAttributeNode("id"),yt&&yt.value===Ge)return[Ct];for(zt=We.getElementsByName(Ge),At=0;Ct=zt[At++];)if(yt=Ct.getAttributeNode("id"),yt&&yt.value===Ge)return[Ct]}return[]}}),P.find.TAG=function(Ge,We){return typeof We.getElementsByTagName<"u"?We.getElementsByTagName(Ge):We.querySelectorAll(Ge)},P.find.CLASS=function(Ge,We){if(typeof We.getElementsByClassName<"u"&&be)return We.getElementsByClassName(Ge)},Ae=[],lf(function(Ge){var We;xe.appendChild(Ge).innerHTML="<a id='"+qe+"' href='' disabled='disabled'></a><select id='"+qe+"-\r\\' disabled='disabled'><option selected=''></option></select>",Ge.querySelectorAll("[selected]").length||Ae.push("\\["+k+"*(?:value|"+Gc+")"),Ge.querySelectorAll("[id~="+qe+"-]").length||Ae.push("~="),Ge.querySelectorAll("a#"+qe+"+*").length||Ae.push(".#.+[+~]"),Ge.querySelectorAll(":checked").length||Ae.push(":checked"),We=ie.createElement("input"),We.setAttribute("type","hidden"),Ge.appendChild(We).setAttribute("name","D"),xe.appendChild(Ge).disabled=!0,Ge.querySelectorAll(":disabled").length!==2&&Ae.push(":enabled",":disabled"),We=ie.createElement("input"),We.setAttribute("name",""),Ge.appendChild(We),Ge.querySelectorAll("[name='']").length||Ae.push("\\["+k+"*name"+k+"*="+k+`*(?:''|"")`)}),p.cssHas||Ae.push(":has"),Ae=Ae.length&&new RegExp(Ae.join("|")),Os=function(Ge,We){if(Ge===We)return $=!0,0;var yt=!Ge.compareDocumentPosition-!We.compareDocumentPosition;return yt||(yt=(Ge.ownerDocument||Ge)==(We.ownerDocument||We)?Ge.compareDocumentPosition(We):1,yt&1||!p.sortDetached&&We.compareDocumentPosition(Ge)===yt?Ge===ie||Ge.ownerDocument==I&&Wr.contains(I,Ge)?-1:We===ie||We.ownerDocument==I&&Wr.contains(I,We)?1:X?o.call(X,Ge)-o.call(X,We):0:yt&4?-1:1)}),ie}Wr.matches=function(ce,ve){return Wr(ce,null,null,ve)},Wr.matchesSelector=function(ce,ve){if(Ch(ce),be&&!aa[ve+" "]&&(!Ae||!Ae.test(ve)))try{var Me=He.call(ce,ve);if(Me||p.disconnectedMatch||ce.document&&ce.document.nodeType!==11)return Me}catch{aa(ve,!0)}return Wr(ve,ie,null,[ce]).length>0},Wr.contains=function(ce,ve){return(ce.ownerDocument||ce)!=ie&&Ch(ce),b.contains(ce,ve)},Wr.attr=function(ce,ve){(ce.ownerDocument||ce)!=ie&&Ch(ce);var Me=P.attrHandle[ve.toLowerCase()],Ge=Me&&u.call(P.attrHandle,ve.toLowerCase())?Me(ce,ve,!be):void 0;return Ge!==void 0?Ge:ce.getAttribute(ve)},Wr.error=function(ce){throw new Error("Syntax error, unrecognized expression: "+ce)},b.uniqueSort=function(ce){var ve,Me=[],Ge=0,We=0;if($=!p.sortStable,X=!p.sortStable&&n.call(ce,0),O.call(ce,Os),$){for(;ve=ce[We++];)ve===ce[We]&&(Ge=Me.push(We));for(;Ge--;)M.call(ce,Me[Ge],1)}return X=null,ce},b.fn.uniqueSort=function(){return this.pushStack(b.uniqueSort(n.apply(this)))},P=b.expr={cacheLength:50,createPseudo:$l,match:Hc,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(ce){return ce[1]=ce[1].replace(_u,Lu),ce[3]=(ce[3]||ce[4]||ce[5]||"").replace(_u,Lu),ce[2]==="~="&&(ce[3]=" "+ce[3]+" "),ce.slice(0,4)},CHILD:function(ce){return ce[1]=ce[1].toLowerCase(),ce[1].slice(0,3)==="nth"?(ce[3]||Wr.error(ce[0]),ce[4]=+(ce[4]?ce[5]+(ce[6]||1):2*(ce[3]==="even"||ce[3]==="odd")),ce[5]=+(ce[7]+ce[8]||ce[3]==="odd")):ce[3]&&Wr.error(ce[0]),ce},PSEUDO:function(ce){var ve,Me=!ce[6]&&ce[2];return Hc.CHILD.test(ce[0])?null:(ce[3]?ce[2]=ce[4]||ce[5]||"":Me&&Yc.test(Me)&&(ve=Gg(Me,!0))&&(ve=Me.indexOf(")",Me.length-ve)-Me.length)&&(ce[0]=ce[0].slice(0,ve),ce[2]=Me.slice(0,ve)),ce.slice(0,3))}},filter:{TAG:function(ce){var ve=ce.replace(_u,Lu).toLowerCase();return ce==="*"?function(){return!0}:function(Me){return A(Me,ve)}},CLASS:function(ce){var ve=bi[ce+" "];return ve||(ve=new RegExp("(^|"+k+")"+ce+"("+k+"|$)"))&&bi(ce,function(Me){return ve.test(typeof Me.className=="string"&&Me.className||typeof Me.getAttribute<"u"&&Me.getAttribute("class")||"")})},ATTR:function(ce,ve,Me){return function(Ge){var We=Wr.attr(Ge,ce);return We==null?ve==="!=":ve?(We+="",ve==="="?We===Me:ve==="!="?We!==Me:ve==="^="?Me&&We.indexOf(Me)===0:ve==="*="?Me&&We.indexOf(Me)>-1:ve==="$="?Me&&We.slice(-Me.length)===Me:ve==="~="?(" "+We.replace(gr," ")+" ").indexOf(Me)>-1:ve==="|="?We===Me||We.slice(0,Me.length+1)===Me+"-":!1):!0}},CHILD:function(ce,ve,Me,Ge,We){var yt=ce.slice(0,3)!=="nth",At=ce.slice(-4)!=="last",zt=ve==="of-type";return Ge===1&&We===0?function(Ct){return!!Ct.parentNode}:function(Ct,Vi,di){var Si,zi,ri,En,ao,_a=yt!==At?"nextSibling":"previousSibling",fl=Ct.parentNode,jc=zt&&Ct.nodeName.toLowerCase(),cf=!di&&!zt,qa=!1;if(fl){if(yt){for(;_a;){for(ri=Ct;ri=ri[_a];)if(zt?A(ri,jc):ri.nodeType===1)return!1;ao=_a=ce==="only"&&!ao&&"nextSibling"}return!0}if(ao=[At?fl.firstChild:fl.lastChild],At&&cf){for(zi=fl[qe]||(fl[qe]={}),Si=zi[ce]||[],En=Si[0]===Be&&Si[1],qa=En&&Si[2],ri=En&&fl.childNodes[En];ri=++En&&ri&&ri[_a]||(qa=En=0)||ao.pop();)if(ri.nodeType===1&&++qa&&ri===Ct){zi[ce]=[Be,En,qa];break}}else if(cf&&(zi=Ct[qe]||(Ct[qe]={}),Si=zi[ce]||[],En=Si[0]===Be&&Si[1],qa=En),qa===!1)for(;(ri=++En&&ri&&ri[_a]||(qa=En=0)||ao.pop())&&!((zt?A(ri,jc):ri.nodeType===1)&&++qa&&(cf&&(zi=ri[qe]||(ri[qe]={}),zi[ce]=[Be,qa]),ri===Ct)););return qa-=We,qa===Ge||qa%Ge===0&&qa/Ge>=0}}},PSEUDO:function(ce,ve){var Me,Ge=P.pseudos[ce]||P.setFilters[ce.toLowerCase()]||Wr.error("unsupported pseudo: "+ce);return Ge[qe]?Ge(ve):Ge.length>1?(Me=[ce,ce,"",ve],P.setFilters.hasOwnProperty(ce.toLowerCase())?$l(function(We,yt){for(var At,zt=Ge(We,ve),Ct=zt.length;Ct--;)At=o.call(We,zt[Ct]),We[At]=!(yt[At]=zt[Ct])}):function(We){return Ge(We,0,Me)}):Ge}},pseudos:{not:$l(function(ce){var ve=[],Me=[],Ge=Sw(ce.replace(G,"$1"));return Ge[qe]?$l(function(We,yt,At,zt){for(var Ct,Vi=Ge(We,null,zt,[]),di=We.length;di--;)(Ct=Vi[di])&&(We[di]=!(yt[di]=Ct))}):function(We,yt,At){return ve[0]=We,Ge(ve,null,At,Me),ve[0]=null,!Me.pop()}}),has:$l(function(ce){return function(ve){return Wr(ce,ve).length>0}}),contains:$l(function(ce){return ce=ce.replace(_u,Lu),function(ve){return(ve.textContent||b.text(ve)).indexOf(ce)>-1}}),lang:$l(function(ce){return Fg.test(ce||"")||Wr.error("unsupported lang: "+ce),ce=ce.replace(_u,Lu).toLowerCase(),function(ve){var Me;do if(Me=be?ve.lang:ve.getAttribute("xml:lang")||ve.getAttribute("lang"))return Me=Me.toLowerCase(),Me===ce||Me.indexOf(ce+"-")===0;while((ve=ve.parentNode)&&ve.nodeType===1);return!1}}),target:function(ce){var ve=e.location&&e.location.hash;return ve&&ve.slice(1)===ce.id},root:function(ce){return ce===xe},focus:function(ce){return ce===Bk()&&ie.hasFocus()&&!!(ce.type||ce.href||~ce.tabIndex)},enabled:CD(!1),disabled:CD(!0),checked:function(ce){return A(ce,"input")&&!!ce.checked||A(ce,"option")&&!!ce.selected},selected:function(ce){return ce.parentNode&&ce.parentNode.selectedIndex,ce.selected===!0},empty:function(ce){for(ce=ce.firstChild;ce;ce=ce.nextSibling)if(ce.nodeType<6)return!1;return!0},parent:function(ce){return!P.pseudos.empty(ce)},header:function(ce){return Ah.test(ce.nodeName)},input:function(ce){return Ih.test(ce.nodeName)},button:function(ce){return A(ce,"input")&&ce.type==="button"||A(ce,"button")},text:function(ce){var ve;return A(ce,"input")&&ce.type==="text"&&((ve=ce.getAttribute("type"))==null||ve.toLowerCase()==="text")},first:Ud(function(){return[0]}),last:Ud(function(ce,ve){return[ve-1]}),eq:Ud(function(ce,ve,Me){return[Me<0?Me+ve:Me]}),even:Ud(function(ce,ve){for(var Me=0;Me<ve;Me+=2)ce.push(Me);return ce}),odd:Ud(function(ce,ve){for(var Me=1;Me<ve;Me+=2)ce.push(Me);return ce}),lt:Ud(function(ce,ve,Me){var Ge;for(Me<0?Ge=Me+ve:Me>ve?Ge=ve:Ge=Me;--Ge>=0;)ce.push(Ge);return ce}),gt:Ud(function(ce,ve,Me){for(var Ge=Me<0?Me+ve:Me;++Ge<ve;)ce.push(Ge);return ce})}},P.pseudos.nth=P.pseudos.eq;for(S in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})P.pseudos[S]=kk(S);for(S in{submit:!0,reset:!0})P.pseudos[S]=Fk(S);function DD(){}DD.prototype=P.filters=P.pseudos,P.setFilters=new DD;function Gg(ce,ve){var Me,Ge,We,yt,At,zt,Ct,Vi=hr[ce+" "];if(Vi)return ve?0:Vi.slice(0);for(At=ce,zt=[],Ct=P.preFilter;At;){(!Me||(Ge=Qn.exec(At)))&&(Ge&&(At=At.slice(Ge[0].length)||At),zt.push(We=[])),Me=!1,(Ge=kg.exec(At))&&(Me=Ge.shift(),We.push({value:Me,type:Ge[0].replace(G," ")}),At=At.slice(Me.length));for(yt in P.filter)(Ge=Hc[yt].exec(At))&&(!Ct[yt]||(Ge=Ct[yt](Ge)))&&(Me=Ge.shift(),We.push({value:Me,type:yt,matches:Ge}),At=At.slice(Me.length));if(!Me)break}return ve?At.length:At?Wr.error(ce):hr(ce,zt).slice(0)}function X1(ce){for(var ve=0,Me=ce.length,Ge="";ve<Me;ve++)Ge+=ce[ve].value;return Ge}function W1(ce,ve,Me){var Ge=ve.dir,We=ve.next,yt=We||Ge,At=Me&&yt==="parentNode",zt=nt++;return ve.first?function(Ct,Vi,di){for(;Ct=Ct[Ge];)if(Ct.nodeType===1||At)return ce(Ct,Vi,di);return!1}:function(Ct,Vi,di){var Si,zi,ri=[Be,zt];if(di){for(;Ct=Ct[Ge];)if((Ct.nodeType===1||At)&&ce(Ct,Vi,di))return!0}else for(;Ct=Ct[Ge];)if(Ct.nodeType===1||At)if(zi=Ct[qe]||(Ct[qe]={}),We&&A(Ct,We))Ct=Ct[Ge]||Ct;else{if((Si=zi[yt])&&Si[0]===Be&&Si[1]===zt)return ri[2]=Si[2];if(zi[yt]=ri,ri[2]=ce(Ct,Vi,di))return!0}return!1}}function Ew(ce){return ce.length>1?function(ve,Me,Ge){for(var We=ce.length;We--;)if(!ce[We](ve,Me,Ge))return!1;return!0}:ce[0]}function Gk(ce,ve,Me){for(var Ge=0,We=ve.length;Ge<We;Ge++)Wr(ce,ve[Ge],Me);return Me}function q1(ce,ve,Me,Ge,We){for(var yt,At=[],zt=0,Ct=ce.length,Vi=ve!=null;zt<Ct;zt++)(yt=ce[zt])&&(!Me||Me(yt,Ge,We))&&(At.push(yt),Vi&&ve.push(zt));return At}function Tw(ce,ve,Me,Ge,We,yt){return Ge&&!Ge[qe]&&(Ge=Tw(Ge)),We&&!We[qe]&&(We=Tw(We,yt)),$l(function(At,zt,Ct,Vi){var di,Si,zi,ri,En=[],ao=[],_a=zt.length,fl=At||Gk(ve||"*",Ct.nodeType?[Ct]:Ct,[]),jc=ce&&(At||!ve)?q1(fl,En,ce,Ct,Vi):fl;if(Me?(ri=We||(At?ce:_a||Ge)?[]:zt,Me(jc,ri,Ct,Vi)):ri=jc,Ge)for(di=q1(ri,ao),Ge(di,[],Ct,Vi),Si=di.length;Si--;)(zi=di[Si])&&(ri[ao[Si]]=!(jc[ao[Si]]=zi));if(At){if(We||ce){if(We){for(di=[],Si=ri.length;Si--;)(zi=ri[Si])&&di.push(jc[Si]=zi);We(null,ri=[],di,Vi)}for(Si=ri.length;Si--;)(zi=ri[Si])&&(di=We?o.call(At,zi):En[Si])>-1&&(At[di]=!(zt[di]=zi))}}else ri=q1(ri===zt?ri.splice(_a,ri.length):ri),We?We(null,zt,ri,Vi):Q.apply(zt,ri)})}function ww(ce){for(var ve,Me,Ge,We=ce.length,yt=P.relative[ce[0].type],At=yt||P.relative[" "],zt=yt?1:0,Ct=W1(function(Si){return Si===ve},At,!0),Vi=W1(function(Si){return o.call(ve,Si)>-1},At,!0),di=[function(Si,zi,ri){var En=!yt&&(ri||zi!=Y)||((ve=zi).nodeType?Ct(Si,zi,ri):Vi(Si,zi,ri));return ve=null,En}];zt<We;zt++)if(Me=P.relative[ce[zt].type])di=[W1(Ew(di),Me)];else{if(Me=P.filter[ce[zt].type].apply(null,ce[zt].matches),Me[qe]){for(Ge=++zt;Ge<We&&!P.relative[ce[Ge].type];Ge++);return Tw(zt>1&&Ew(di),zt>1&&X1(ce.slice(0,zt-1).concat({value:ce[zt-2].type===" "?"*":""})).replace(G,"$1"),Me,zt<Ge&&ww(ce.slice(zt,Ge)),Ge<We&&ww(ce=ce.slice(Ge)),Ge<We&&X1(ce))}di.push(Me)}return Ew(di)}function Uk(ce,ve){var Me=ve.length>0,Ge=ce.length>0,We=function(yt,At,zt,Ct,Vi){var di,Si,zi,ri=0,En="0",ao=yt&&[],_a=[],fl=Y,jc=yt||Ge&&P.find.TAG("*",Vi),cf=Be+=fl==null?1:Math.random()||.1,qa=jc.length;for(Vi&&(Y=At==ie||At||Vi);En!==qa&&(di=jc[En])!=null;En++){if(Ge&&di){for(Si=0,!At&&di.ownerDocument!=ie&&(Ch(di),zt=!be);zi=ce[Si++];)if(zi(di,At||ie,zt)){Q.call(Ct,di);break}Vi&&(Be=cf)}Me&&((di=!zi&&di)&&ri--,yt&&ao.push(di))}if(ri+=En,Me&&En!==ri){for(Si=0;zi=ve[Si++];)zi(ao,_a,At,zt);if(yt){if(ri>0)for(;En--;)ao[En]||_a[En]||(_a[En]=R.call(Ct));_a=q1(_a)}Q.apply(Ct,_a),Vi&&!yt&&_a.length>0&&ri+ve.length>1&&b.uniqueSort(Ct)}return Vi&&(Be=cf,Y=fl),ao};return Me?$l(We):We}function Sw(ce,ve){var Me,Ge=[],We=[],yt=Oi[ce+" "];if(!yt){for(ve||(ve=Gg(ce)),Me=ve.length;Me--;)yt=ww(ve[Me]),yt[qe]?Ge.push(yt):We.push(yt);yt=Oi(ce,Uk(We,Ge)),yt.selector=ce}return yt}function PD(ce,ve,Me,Ge){var We,yt,At,zt,Ct,Vi=typeof ce=="function"&&ce,di=!Ge&&Gg(ce=Vi.selector||ce);if(Me=Me||[],di.length===1){if(yt=di[0]=di[0].slice(0),yt.length>2&&(At=yt[0]).type==="ID"&&ve.nodeType===9&&be&&P.relative[yt[1].type]){if(ve=(P.find.ID(At.matches[0].replace(_u,Lu),ve)||[])[0],ve)Vi&&(ve=ve.parentNode);else return Me;ce=ce.slice(yt.shift().value.length)}for(We=Hc.needsContext.test(ce)?0:yt.length;We--&&(At=yt[We],!P.relative[zt=At.type]);)if((Ct=P.find[zt])&&(Ge=Ct(At.matches[0].replace(_u,Lu),bw.test(yt[0].type)&&xw(ve.parentNode)||ve))){if(yt.splice(We,1),ce=Ge.length&&X1(yt),!ce)return Q.apply(Me,Ge),Me;break}}return(Vi||Sw(ce,di))(Ge,ve,!be,Me,!ve||bw.test(ce)&&xw(ve.parentNode)||ve),Me}p.sortStable=qe.split("").sort(Os).join("")===qe,Ch(),p.sortDetached=lf(function(ce){return ce.compareDocumentPosition(ie.createElement("fieldset"))&1}),b.find=Wr,b.expr[":"]=b.expr.pseudos,b.unique=b.uniqueSort,Wr.compile=Sw,Wr.select=PD,Wr.setDocument=Ch,Wr.tokenize=Gg,Wr.escape=b.escapeSelector,Wr.getText=b.text,Wr.isXML=b.isXMLDoc,Wr.selectors=b.expr,Wr.support=b.support,Wr.uniqueSort=b.uniqueSort})();var v=function(S,P,Y){for(var X=[],$=Y!==void 0;(S=S[P])&&S.nodeType!==9;)if(S.nodeType===1){if($&&b(S).is(Y))break;X.push(S)}return X},L=function(S,P){for(var Y=[];S;S=S.nextSibling)S.nodeType===1&&S!==P&&Y.push(S);return Y},_=b.expr.match.needsContext,B=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function U(S,P,Y){return f(P)?b.grep(S,function(X,$){return!!P.call(X,$,X)!==Y}):P.nodeType?b.grep(S,function(X){return X===P!==Y}):typeof P!="string"?b.grep(S,function(X){return o.call(P,X)>-1!==Y}):b.filter(P,S,Y)}b.filter=function(S,P,Y){var X=P[0];return Y&&(S=":not("+S+")"),P.length===1&&X.nodeType===1?b.find.matchesSelector(X,S)?[X]:[]:b.find.matches(S,b.grep(P,function($){return $.nodeType===1}))},b.fn.extend({find:function(S){var P,Y,X=this.length,$=this;if(typeof S!="string")return this.pushStack(b(S).filter(function(){for(P=0;P<X;P++)if(b.contains($[P],this))return!0}));for(Y=this.pushStack([]),P=0;P<X;P++)b.find(S,$[P],Y);return X>1?b.uniqueSort(Y):Y},filter:function(S){return this.pushStack(U(this,S||[],!1))},not:function(S){return this.pushStack(U(this,S||[],!0))},is:function(S){return!!U(this,typeof S=="string"&&_.test(S)?b(S):S||[],!1).length}});var z,W=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,ne=b.fn.init=function(S,P,Y){var X,$;if(!S)return this;if(Y=Y||z,typeof S=="string")if(S[0]==="<"&&S[S.length-1]===">"&&S.length>=3?X=[null,S,null]:X=W.exec(S),X&&(X[1]||!P))if(X[1]){if(P=P instanceof b?P[0]:P,b.merge(this,b.parseHTML(X[1],P&&P.nodeType?P.ownerDocument||P:g,!0)),B.test(X[1])&&b.isPlainObject(P))for(X in P)f(this[X])?this[X](P[X]):this.attr(X,P[X]);return this}else return $=g.getElementById(X[2]),$&&(this[0]=$,this.length=1),this;else return!P||P.jquery?(P||Y).find(S):this.constructor(P).find(S);else{if(S.nodeType)return this[0]=S,this.length=1,this;if(f(S))return Y.ready!==void 0?Y.ready(S):S(b)}return b.makeArray(S,this)};ne.prototype=b.fn,z=b(g);var me=/^(?:parents|prev(?:Until|All))/,Ee={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({has:function(S){var P=b(S,this),Y=P.length;return this.filter(function(){for(var X=0;X<Y;X++)if(b.contains(this,P[X]))return!0})},closest:function(S,P){var Y,X=0,$=this.length,Q=[],ie=typeof S!="string"&&b(S);if(!_.test(S)){for(;X<$;X++)for(Y=this[X];Y&&Y!==P;Y=Y.parentNode)if(Y.nodeType<11&&(ie?ie.index(Y)>-1:Y.nodeType===1&&b.find.matchesSelector(Y,S))){Q.push(Y);break}}return this.pushStack(Q.length>1?b.uniqueSort(Q):Q)},index:function(S){return S?typeof S=="string"?o.call(b(S),this[0]):o.call(this,S.jquery?S[0]:S):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(S,P){return this.pushStack(b.uniqueSort(b.merge(this.get(),b(S,P))))},addBack:function(S){return this.add(S==null?this.prevObject:this.prevObject.filter(S))}});function Se(S,P){for(;(S=S[P])&&S.nodeType!==1;);return S}b.each({parent:function(S){var P=S.parentNode;return P&&P.nodeType!==11?P:null},parents:function(S){return v(S,"parentNode")},parentsUntil:function(S,P,Y){return v(S,"parentNode",Y)},next:function(S){return Se(S,"nextSibling")},prev:function(S){return Se(S,"previousSibling")},nextAll:function(S){return v(S,"nextSibling")},prevAll:function(S){return v(S,"previousSibling")},nextUntil:function(S,P,Y){return v(S,"nextSibling",Y)},prevUntil:function(S,P,Y){return v(S,"previousSibling",Y)},siblings:function(S){return L((S.parentNode||{}).firstChild,S)},children:function(S){return L(S.firstChild)},contents:function(S){return S.contentDocument!=null&&r(S.contentDocument)?S.contentDocument:(A(S,"template")&&(S=S.content||S),b.merge([],S.childNodes))}},function(S,P){b.fn[S]=function(Y,X){var $=b.map(this,P,Y);return S.slice(-5)!=="Until"&&(X=Y),X&&typeof X=="string"&&($=b.filter(X,$)),this.length>1&&(Ee[S]||b.uniqueSort($),me.test(S)&&$.reverse()),this.pushStack($)}});var Fe=/[^\x20\t\r\n\f]+/g;function Ne(S){var P={};return b.each(S.match(Fe)||[],function(Y,X){P[X]=!0}),P}b.Callbacks=function(S){S=typeof S=="string"?Ne(S):b.extend({},S);var P,Y,X,$,Q=[],ie=[],xe=-1,be=function(){for($=$||S.once,X=P=!0;ie.length;xe=-1)for(Y=ie.shift();++xe<Q.length;)Q[xe].apply(Y[0],Y[1])===!1&&S.stopOnFalse&&(xe=Q.length,Y=!1);S.memory||(Y=!1),P=!1,$&&(Y?Q=[]:Q="")},Ae={add:function(){return Q&&(Y&&!P&&(xe=Q.length-1,ie.push(Y)),(function He(qe){b.each(qe,function(Be,nt){f(nt)?(!S.unique||!Ae.has(nt))&&Q.push(nt):nt&&nt.length&&E(nt)!=="string"&&He(nt)})})(arguments),Y&&!P&&be()),this},remove:function(){return b.each(arguments,function(He,qe){for(var Be;(Be=b.inArray(qe,Q,Be))>-1;)Q.splice(Be,1),Be<=xe&&xe--}),this},has:function(He){return He?b.inArray(He,Q)>-1:Q.length>0},empty:function(){return Q&&(Q=[]),this},disable:function(){return $=ie=[],Q=Y="",this},disabled:function(){return!Q},lock:function(){return $=ie=[],!Y&&!P&&(Q=Y=""),this},locked:function(){return!!$},fireWith:function(He,qe){return $||(qe=qe||[],qe=[He,qe.slice?qe.slice():qe],ie.push(qe),P||be()),this},fire:function(){return Ae.fireWith(this,arguments),this},fired:function(){return!!X}};return Ae};function it(S){return S}function je(S){throw S}function It(S,P,Y,X){var $;try{S&&f($=S.promise)?$.call(S).done(P).fail(Y):S&&f($=S.then)?$.call(S,P,Y):P.apply(void 0,[S].slice(X))}catch(Q){Y.apply(void 0,[Q])}}b.extend({Deferred:function(S){var P=[["notify","progress",b.Callbacks("memory"),b.Callbacks("memory"),2],["resolve","done",b.Callbacks("once memory"),b.Callbacks("once memory"),0,"resolved"],["reject","fail",b.Callbacks("once memory"),b.Callbacks("once memory"),1,"rejected"]],Y="pending",X={state:function(){return Y},always:function(){return $.done(arguments).fail(arguments),this},catch:function(Q){return X.then(null,Q)},pipe:function(){var Q=arguments;return b.Deferred(function(ie){b.each(P,function(xe,be){var Ae=f(Q[be[4]])&&Q[be[4]];$[be[1]](function(){var He=Ae&&Ae.apply(this,arguments);He&&f(He.promise)?He.promise().progress(ie.notify).done(ie.resolve).fail(ie.reject):ie[be[0]+"With"](this,Ae?[He]:arguments)})}),Q=null}).promise()},then:function(Q,ie,xe){var be=0;function Ae(He,qe,Be,nt){return function(){var bi=this,hr=arguments,Oi=function(){var Os,Gc;if(!(He<be)){if(Os=Be.apply(bi,hr),Os===qe.promise())throw new TypeError("Thenable self-resolution");Gc=Os&&(typeof Os=="object"||typeof Os=="function")&&Os.then,f(Gc)?nt?Gc.call(Os,Ae(be,qe,it,nt),Ae(be,qe,je,nt)):(be++,Gc.call(Os,Ae(be,qe,it,nt),Ae(be,qe,je,nt),Ae(be,qe,it,qe.notifyWith))):(Be!==it&&(bi=void 0,hr=[Os]),(nt||qe.resolveWith)(bi,hr))}},aa=nt?Oi:function(){try{Oi()}catch(Os){b.Deferred.exceptionHook&&b.Deferred.exceptionHook(Os,aa.error),He+1>=be&&(Be!==je&&(bi=void 0,hr=[Os]),qe.rejectWith(bi,hr))}};He?aa():(b.Deferred.getErrorHook?aa.error=b.Deferred.getErrorHook():b.Deferred.getStackHook&&(aa.error=b.Deferred.getStackHook()),e.setTimeout(aa))}}return b.Deferred(function(He){P[0][3].add(Ae(0,He,f(xe)?xe:it,He.notifyWith)),P[1][3].add(Ae(0,He,f(Q)?Q:it)),P[2][3].add(Ae(0,He,f(ie)?ie:je))}).promise()},promise:function(Q){return Q!=null?b.extend(Q,X):X}},$={};return b.each(P,function(Q,ie){var xe=ie[2],be=ie[5];X[ie[1]]=xe.add,be&&xe.add(function(){Y=be},P[3-Q][2].disable,P[3-Q][3].disable,P[0][2].lock,P[0][3].lock),xe.add(ie[3].fire),$[ie[0]]=function(){return $[ie[0]+"With"](this===$?void 0:this,arguments),this},$[ie[0]+"With"]=xe.fireWith}),X.promise($),S&&S.call($,$),$},when:function(S){var P=arguments.length,Y=P,X=Array(Y),$=n.call(arguments),Q=b.Deferred(),ie=function(xe){return function(be){X[xe]=this,$[xe]=arguments.length>1?n.call(arguments):be,--P||Q.resolveWith(X,$)}};if(P<=1&&(It(S,Q.done(ie(Y)).resolve,Q.reject,!P),Q.state()==="pending"||f($[Y]&&$[Y].then)))return Q.then();for(;Y--;)It($[Y],ie(Y),Q.reject);return Q.promise()}});var Ht=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;b.Deferred.exceptionHook=function(S,P){e.console&&e.console.warn&&S&&Ht.test(S.name)&&e.console.warn("jQuery.Deferred exception: "+S.message,S.stack,P)},b.readyException=function(S){e.setTimeout(function(){throw S})};var Ri=b.Deferred();b.fn.ready=function(S){return Ri.then(S).catch(function(P){b.readyException(P)}),this},b.extend({isReady:!1,readyWait:1,ready:function(S){(S===!0?--b.readyWait:b.isReady)||(b.isReady=!0,!(S!==!0&&--b.readyWait>0)&&Ri.resolveWith(g,[b]))}}),b.ready.then=Ri.then;function Ci(){g.removeEventListener("DOMContentLoaded",Ci),e.removeEventListener("load",Ci),b.ready()}g.readyState==="complete"||g.readyState!=="loading"&&!g.documentElement.doScroll?e.setTimeout(b.ready):(g.addEventListener("DOMContentLoaded",Ci),e.addEventListener("load",Ci));var ze=function(S,P,Y,X,$,Q,ie){var xe=0,be=S.length,Ae=Y==null;if(E(Y)==="object"){$=!0;for(xe in Y)ze(S,P,xe,Y[xe],!0,Q,ie)}else if(X!==void 0&&($=!0,f(X)||(ie=!0),Ae&&(ie?(P.call(S,X),P=null):(Ae=P,P=function(He,qe,Be){return Ae.call(b(He),Be)})),P))for(;xe<be;xe++)P(S[xe],Y,ie?X:X.call(S[xe],xe,P(S[xe],Y)));return $?S:Ae?P.call(S):be?P(S[0],Y):Q},D=/^-ms-/,j=/-([a-z])/g;function Z(S,P){return P.toUpperCase()}function K(S){return S.replace(D,"ms-").replace(j,Z)}var ee=function(S){return S.nodeType===1||S.nodeType===9||!+S.nodeType};function ge(){this.expando=b.expando+ge.uid++}ge.uid=1,ge.prototype={cache:function(S){var P=S[this.expando];return P||(P={},ee(S)&&(S.nodeType?S[this.expando]=P:Object.defineProperty(S,this.expando,{value:P,configurable:!0}))),P},set:function(S,P,Y){var X,$=this.cache(S);if(typeof P=="string")$[K(P)]=Y;else for(X in P)$[K(X)]=P[X];return $},get:function(S,P){return P===void 0?this.cache(S):S[this.expando]&&S[this.expando][K(P)]},access:function(S,P,Y){return P===void 0||P&&typeof P=="string"&&Y===void 0?this.get(S,P):(this.set(S,P,Y),Y!==void 0?Y:P)},remove:function(S,P){var Y,X=S[this.expando];if(X!==void 0){if(P!==void 0)for(Array.isArray(P)?P=P.map(K):(P=K(P),P=P in X?[P]:P.match(Fe)||[]),Y=P.length;Y--;)delete X[P[Y]];(P===void 0||b.isEmptyObject(X))&&(S.nodeType?S[this.expando]=void 0:delete S[this.expando])}},hasData:function(S){var P=S[this.expando];return P!==void 0&&!b.isEmptyObject(P)}};var le=new ge,ke=new ge,rt=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,gt=/[A-Z]/g;function et(S){return S==="true"?!0:S==="false"?!1:S==="null"?null:S===+S+""?+S:rt.test(S)?JSON.parse(S):S}function si(S,P,Y){var X;if(Y===void 0&&S.nodeType===1)if(X="data-"+P.replace(gt,"-$&").toLowerCase(),Y=S.getAttribute(X),typeof Y=="string"){try{Y=et(Y)}catch{}ke.set(S,P,Y)}else Y=void 0;return Y}b.extend({hasData:function(S){return ke.hasData(S)||le.hasData(S)},data:function(S,P,Y){return ke.access(S,P,Y)},removeData:function(S,P){ke.remove(S,P)},_data:function(S,P,Y){return le.access(S,P,Y)},_removeData:function(S,P){le.remove(S,P)}}),b.fn.extend({data:function(S,P){var Y,X,$,Q=this[0],ie=Q&&Q.attributes;if(S===void 0){if(this.length&&($=ke.get(Q),Q.nodeType===1&&!le.get(Q,"hasDataAttrs"))){for(Y=ie.length;Y--;)ie[Y]&&(X=ie[Y].name,X.indexOf("data-")===0&&(X=K(X.slice(5)),si(Q,X,$[X])));le.set(Q,"hasDataAttrs",!0)}return $}return typeof S=="object"?this.each(function(){ke.set(this,S)}):ze(this,function(xe){var be;if(Q&&xe===void 0)return be=ke.get(Q,S),be!==void 0||(be=si(Q,S),be!==void 0)?be:void 0;this.each(function(){ke.set(this,S,xe)})},null,P,arguments.length>1,null,!0)},removeData:function(S){return this.each(function(){ke.remove(this,S)})}}),b.extend({queue:function(S,P,Y){var X;if(S)return P=(P||"fx")+"queue",X=le.get(S,P),Y&&(!X||Array.isArray(Y)?X=le.access(S,P,b.makeArray(Y)):X.push(Y)),X||[]},dequeue:function(S,P){P=P||"fx";var Y=b.queue(S,P),X=Y.length,$=Y.shift(),Q=b._queueHooks(S,P),ie=function(){b.dequeue(S,P)};$==="inprogress"&&($=Y.shift(),X--),$&&(P==="fx"&&Y.unshift("inprogress"),delete Q.stop,$.call(S,ie,Q)),!X&&Q&&Q.empty.fire()},_queueHooks:function(S,P){var Y=P+"queueHooks";return le.get(S,Y)||le.access(S,Y,{empty:b.Callbacks("once memory").add(function(){le.remove(S,[P+"queue",Y])})})}}),b.fn.extend({queue:function(S,P){var Y=2;return typeof S!="string"&&(P=S,S="fx",Y--),arguments.length<Y?b.queue(this[0],S):P===void 0?this:this.each(function(){var X=b.queue(this,S,P);b._queueHooks(this,S),S==="fx"&&X[0]!=="inprogress"&&b.dequeue(this,S)})},dequeue:function(S){return this.each(function(){b.dequeue(this,S)})},clearQueue:function(S){return this.queue(S||"fx",[])},promise:function(S,P){var Y,X=1,$=b.Deferred(),Q=this,ie=this.length,xe=function(){--X||$.resolveWith(Q,[Q])};for(typeof S!="string"&&(P=S,S=void 0),S=S||"fx";ie--;)Y=le.get(Q[ie],S+"queueHooks"),Y&&Y.empty&&(X++,Y.empty.add(xe));return xe(),$.promise(P)}});var ji=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,tr=new RegExp("^(?:([+-])=|)("+ji+")([a-z%]*)$","i"),Li=["Top","Right","Bottom","Left"],Sn=g.documentElement,Ar=function(S){return b.contains(S.ownerDocument,S)},Sr={composed:!0};Sn.getRootNode&&(Ar=function(S){return b.contains(S.ownerDocument,S)||S.getRootNode(Sr)===S.ownerDocument});var vn=function(S,P){return S=P||S,S.style.display==="none"||S.style.display===""&&Ar(S)&&b.css(S,"display")==="none"};function na(S,P,Y,X){var $,Q,ie=20,xe=X?function(){return X.cur()}:function(){return b.css(S,P,"")},be=xe(),Ae=Y&&Y[3]||(b.cssNumber[P]?"":"px"),He=S.nodeType&&(b.cssNumber[P]||Ae!=="px"&&+be)&&tr.exec(b.css(S,P));if(He&&He[3]!==Ae){for(be=be/2,Ae=Ae||He[3],He=+be||1;ie--;)b.style(S,P,He+Ae),(1-Q)*(1-(Q=xe()/be||.5))<=0&&(ie=0),He=He/Q;He=He*2,b.style(S,P,He+Ae),Y=Y||[]}return Y&&(He=+He||+be||0,$=Y[1]?He+(Y[1]+1)*Y[2]:+Y[2],X&&(X.unit=Ae,X.start=He,X.end=$)),$}var Wt={};function ur(S){var P,Y=S.ownerDocument,X=S.nodeName,$=Wt[X];return $||(P=Y.body.appendChild(Y.createElement(X)),$=b.css(P,"display"),P.parentNode.removeChild(P),$==="none"&&($="block"),Wt[X]=$,$)}function ht(S,P){for(var Y,X,$=[],Q=0,ie=S.length;Q<ie;Q++)X=S[Q],X.style&&(Y=X.style.display,P?(Y==="none"&&($[Q]=le.get(X,"display")||null,$[Q]||(X.style.display="")),X.style.display===""&&vn(X)&&($[Q]=ur(X))):Y!=="none"&&($[Q]="none",le.set(X,"display",Y)));for(Q=0;Q<ie;Q++)$[Q]!=null&&(S[Q].style.display=$[Q]);return S}b.fn.extend({show:function(){return ht(this,!0)},hide:function(){return ht(this)},toggle:function(S){return typeof S=="boolean"?S?this.show():this.hide():this.each(function(){vn(this)?b(this).show():b(this).hide()})}});var an=/^(?:checkbox|radio)$/i,$n=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,ai=/^$|^module$|\/(?:java|ecma)script/i;(function(){var S=g.createDocumentFragment(),P=S.appendChild(g.createElement("div")),Y=g.createElement("input");Y.setAttribute("type","radio"),Y.setAttribute("checked","checked"),Y.setAttribute("name","t"),P.appendChild(Y),p.checkClone=P.cloneNode(!0).cloneNode(!0).lastChild.checked,P.innerHTML="<textarea>x</textarea>",p.noCloneChecked=!!P.cloneNode(!0).lastChild.defaultValue,P.innerHTML="<option></option>",p.option=!!P.lastChild})();var wi={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,"",""]};wi.tbody=wi.tfoot=wi.colgroup=wi.caption=wi.thead,wi.th=wi.td,p.option||(wi.optgroup=wi.option=[1,"<select multiple='multiple'>","</select>"]);function xn(S,P){var Y;return typeof S.getElementsByTagName<"u"?Y=S.getElementsByTagName(P||"*"):typeof S.querySelectorAll<"u"?Y=S.querySelectorAll(P||"*"):Y=[],P===void 0||P&&A(S,P)?b.merge([S],Y):Y}function sa(S,P){for(var Y=0,X=S.length;Y<X;Y++)le.set(S[Y],"globalEval",!P||le.get(P[Y],"globalEval"))}var Pu=/<|&#?\w+;/;function sf(S,P,Y,X,$){for(var Q,ie,xe,be,Ae,He,qe=P.createDocumentFragment(),Be=[],nt=0,bi=S.length;nt<bi;nt++)if(Q=S[nt],Q||Q===0)if(E(Q)==="object")b.merge(Be,Q.nodeType?[Q]:Q);else if(!Pu.test(Q))Be.push(P.createTextNode(Q));else{for(ie=ie||qe.appendChild(P.createElement("div")),xe=($n.exec(Q)||["",""])[1].toLowerCase(),be=wi[xe]||wi._default,ie.innerHTML=be[1]+b.htmlPrefilter(Q)+be[2],He=be[0];He--;)ie=ie.lastChild;b.merge(Be,ie.childNodes),ie=qe.firstChild,ie.textContent=""}for(qe.textContent="",nt=0;Q=Be[nt++];){if(X&&b.inArray(Q,X)>-1){$&&$.push(Q);continue}if(Ae=Ar(Q),ie=xn(qe.appendChild(Q),"script"),Ae&&sa(ie),Y)for(He=0;Q=ie[He++];)ai.test(Q.type||"")&&Y.push(Q)}return qe}var vh=/^([^.]*)(?:\.(.+)|)/;function Fc(){return!0}function dl(){return!1}function Cr(S,P,Y,X,$,Q){var ie,xe;if(typeof P=="object"){typeof Y!="string"&&(X=X||Y,Y=void 0);for(xe in P)Cr(S,xe,Y,X,P[xe],Q);return S}if(X==null&&$==null?($=Y,X=Y=void 0):$==null&&(typeof Y=="string"?($=X,X=void 0):($=X,X=Y,Y=void 0)),$===!1)$=dl;else if(!$)return S;return Q===1&&(ie=$,$=function(be){return b().off(be),ie.apply(this,arguments)},$.guid=ie.guid||(ie.guid=b.guid++)),S.each(function(){b.event.add(this,P,$,X,Y)})}b.event={global:{},add:function(S,P,Y,X,$){var Q,ie,xe,be,Ae,He,qe,Be,nt,bi,hr,Oi=le.get(S);if(ee(S))for(Y.handler&&(Q=Y,Y=Q.handler,$=Q.selector),$&&b.find.matchesSelector(Sn,$),Y.guid||(Y.guid=b.guid++),(be=Oi.events)||(be=Oi.events=Object.create(null)),(ie=Oi.handle)||(ie=Oi.handle=function(aa){return typeof b<"u"&&b.event.triggered!==aa.type?b.event.dispatch.apply(S,arguments):void 0}),P=(P||"").match(Fe)||[""],Ae=P.length;Ae--;)xe=vh.exec(P[Ae])||[],nt=hr=xe[1],bi=(xe[2]||"").split(".").sort(),nt&&(qe=b.event.special[nt]||{},nt=($?qe.delegateType:qe.bindType)||nt,qe=b.event.special[nt]||{},He=b.extend({type:nt,origType:hr,data:X,handler:Y,guid:Y.guid,selector:$,needsContext:$&&b.expr.match.needsContext.test($),namespace:bi.join(".")},Q),(Be=be[nt])||(Be=be[nt]=[],Be.delegateCount=0,(!qe.setup||qe.setup.call(S,X,bi,ie)===!1)&&S.addEventListener&&S.addEventListener(nt,ie)),qe.add&&(qe.add.call(S,He),He.handler.guid||(He.handler.guid=Y.guid)),$?Be.splice(Be.delegateCount++,0,He):Be.push(He),b.event.global[nt]=!0)},remove:function(S,P,Y,X,$){var Q,ie,xe,be,Ae,He,qe,Be,nt,bi,hr,Oi=le.hasData(S)&&le.get(S);if(!(!Oi||!(be=Oi.events))){for(P=(P||"").match(Fe)||[""],Ae=P.length;Ae--;){if(xe=vh.exec(P[Ae])||[],nt=hr=xe[1],bi=(xe[2]||"").split(".").sort(),!nt){for(nt in be)b.event.remove(S,nt+P[Ae],Y,X,!0);continue}for(qe=b.event.special[nt]||{},nt=(X?qe.delegateType:qe.bindType)||nt,Be=be[nt]||[],xe=xe[2]&&new RegExp("(^|\\.)"+bi.join("\\.(?:.*\\.|)")+"(\\.|$)"),ie=Q=Be.length;Q--;)He=Be[Q],($||hr===He.origType)&&(!Y||Y.guid===He.guid)&&(!xe||xe.test(He.namespace))&&(!X||X===He.selector||X==="**"&&He.selector)&&(Be.splice(Q,1),He.selector&&Be.delegateCount--,qe.remove&&qe.remove.call(S,He));ie&&!Be.length&&((!qe.teardown||qe.teardown.call(S,bi,Oi.handle)===!1)&&b.removeEvent(S,nt,Oi.handle),delete be[nt])}b.isEmptyObject(be)&&le.remove(S,"handle events")}},dispatch:function(S){var P,Y,X,$,Q,ie,xe=new Array(arguments.length),be=b.event.fix(S),Ae=(le.get(this,"events")||Object.create(null))[be.type]||[],He=b.event.special[be.type]||{};for(xe[0]=be,P=1;P<arguments.length;P++)xe[P]=arguments[P];if(be.delegateTarget=this,!(He.preDispatch&&He.preDispatch.call(this,be)===!1)){for(ie=b.event.handlers.call(this,be,Ae),P=0;($=ie[P++])&&!be.isPropagationStopped();)for(be.currentTarget=$.elem,Y=0;(Q=$.handlers[Y++])&&!be.isImmediatePropagationStopped();)(!be.rnamespace||Q.namespace===!1||be.rnamespace.test(Q.namespace))&&(be.handleObj=Q,be.data=Q.data,X=((b.event.special[Q.origType]||{}).handle||Q.handler).apply($.elem,xe),X!==void 0&&(be.result=X)===!1&&(be.preventDefault(),be.stopPropagation()));return He.postDispatch&&He.postDispatch.call(this,be),be.result}},handlers:function(S,P){var Y,X,$,Q,ie,xe=[],be=P.delegateCount,Ae=S.target;if(be&&Ae.nodeType&&!(S.type==="click"&&S.button>=1)){for(;Ae!==this;Ae=Ae.parentNode||this)if(Ae.nodeType===1&&!(S.type==="click"&&Ae.disabled===!0)){for(Q=[],ie={},Y=0;Y<be;Y++)X=P[Y],$=X.selector+" ",ie[$]===void 0&&(ie[$]=X.needsContext?b($,this).index(Ae)>-1:b.find($,this,null,[Ae]).length),ie[$]&&Q.push(X);Q.length&&xe.push({elem:Ae,handlers:Q})}}return Ae=this,be<P.length&&xe.push({elem:Ae,handlers:P.slice(be)}),xe},addProp:function(S,P){Object.defineProperty(b.Event.prototype,S,{enumerable:!0,configurable:!0,get:f(P)?function(){if(this.originalEvent)return P(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[S]},set:function(Y){Object.defineProperty(this,S,{enumerable:!0,configurable:!0,writable:!0,value:Y})}})},fix:function(S){return S[b.expando]?S:new b.Event(S)},special:{load:{noBubble:!0},click:{setup:function(S){var P=this||S;return an.test(P.type)&&P.click&&A(P,"input")&&Zn(P,"click",!0),!1},trigger:function(S){var P=this||S;return an.test(P.type)&&P.click&&A(P,"input")&&Zn(P,"click"),!0},_default:function(S){var P=S.target;return an.test(P.type)&&P.click&&A(P,"input")&&le.get(P,"click")||A(P,"a")}},beforeunload:{postDispatch:function(S){S.result!==void 0&&S.originalEvent&&(S.originalEvent.returnValue=S.result)}}}};function Zn(S,P,Y){if(!Y){le.get(S,P)===void 0&&b.event.add(S,P,Fc);return}le.set(S,P,!1),b.event.add(S,P,{namespace:!1,handler:function(X){var $,Q=le.get(this,P);if(X.isTrigger&1&&this[P]){if(Q)(b.event.special[P]||{}).delegateType&&X.stopPropagation();else if(Q=n.call(arguments),le.set(this,P,Q),this[P](),$=le.get(this,P),le.set(this,P,!1),Q!==$)return X.stopImmediatePropagation(),X.preventDefault(),$}else Q&&(le.set(this,P,b.event.trigger(Q[0],Q.slice(1),this)),X.stopPropagation(),X.isImmediatePropagationStopped=Fc)}})}b.removeEvent=function(S,P,Y){S.removeEventListener&&S.removeEventListener(P,Y)},b.Event=function(S,P){if(!(this instanceof b.Event))return new b.Event(S,P);S&&S.type?(this.originalEvent=S,this.type=S.type,this.isDefaultPrevented=S.defaultPrevented||S.defaultPrevented===void 0&&S.returnValue===!1?Fc:dl,this.target=S.target&&S.target.nodeType===3?S.target.parentNode:S.target,this.currentTarget=S.currentTarget,this.relatedTarget=S.relatedTarget):this.type=S,P&&b.extend(this,P),this.timeStamp=S&&S.timeStamp||Date.now(),this[b.expando]=!0},b.Event.prototype={constructor:b.Event,isDefaultPrevented:dl,isPropagationStopped:dl,isImmediatePropagationStopped:dl,isSimulated:!1,preventDefault:function(){var S=this.originalEvent;this.isDefaultPrevented=Fc,S&&!this.isSimulated&&S.preventDefault()},stopPropagation:function(){var S=this.originalEvent;this.isPropagationStopped=Fc,S&&!this.isSimulated&&S.stopPropagation()},stopImmediatePropagation:function(){var S=this.originalEvent;this.isImmediatePropagationStopped=Fc,S&&!this.isSimulated&&S.stopImmediatePropagation(),this.stopPropagation()}},b.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},b.event.addProp),b.each({focus:"focusin",blur:"focusout"},function(S,P){function Y(X){if(g.documentMode){var $=le.get(this,"handle"),Q=b.event.fix(X);Q.type=X.type==="focusin"?"focus":"blur",Q.isSimulated=!0,$(X),Q.target===Q.currentTarget&&$(Q)}else b.event.simulate(P,X.target,b.event.fix(X))}b.event.special[S]={setup:function(){var X;if(Zn(this,S,!0),g.documentMode)X=le.get(this,P),X||this.addEventListener(P,Y),le.set(this,P,(X||0)+1);else return!1},trigger:function(){return Zn(this,S),!0},teardown:function(){var X;if(g.documentMode)X=le.get(this,P)-1,X?le.set(this,P,X):(this.removeEventListener(P,Y),le.remove(this,P));else return!1},_default:function(X){return le.get(X.target,S)},delegateType:P},b.event.special[P]={setup:function(){var X=this.ownerDocument||this.document||this,$=g.documentMode?this:X,Q=le.get($,P);Q||(g.documentMode?this.addEventListener(P,Y):X.addEventListener(S,Y,!0)),le.set($,P,(Q||0)+1)},teardown:function(){var X=this.ownerDocument||this.document||this,$=g.documentMode?this:X,Q=le.get($,P)-1;Q?le.set($,P,Q):(g.documentMode?this.removeEventListener(P,Y):X.removeEventListener(S,Y,!0),le.remove($,P))}}}),b.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(S,P){b.event.special[S]={delegateType:P,bindType:P,handle:function(Y){var X,$=this,Q=Y.relatedTarget,ie=Y.handleObj;return(!Q||Q!==$&&!b.contains($,Q))&&(Y.type=ie.origType,X=ie.handler.apply(this,arguments),Y.type=P),X}}}),b.fn.extend({on:function(S,P,Y,X){return Cr(this,S,P,Y,X)},one:function(S,P,Y,X){return Cr(this,S,P,Y,X,1)},off:function(S,P,Y){var X,$;if(S&&S.preventDefault&&S.handleObj)return X=S.handleObj,b(S.delegateTarget).off(X.namespace?X.origType+"."+X.namespace:X.origType,X.selector,X.handler),this;if(typeof S=="object"){for($ in S)this.off($,P,S[$]);return this}return(P===!1||typeof P=="function")&&(Y=P,P=void 0),Y===!1&&(Y=dl),this.each(function(){b.event.remove(this,S,Y,P)})}});var Bd=/<script|<style|<link/i,Og=/checked\s*(?:[^=]|=\s*.checked.)/i,rk=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function nD(S,P){return A(S,"table")&&A(P.nodeType!==11?P:P.firstChild,"tr")&&b(S).children("tbody")[0]||S}function nk(S){return S.type=(S.getAttribute("type")!==null)+"/"+S.type,S}function sk(S){return(S.type||"").slice(0,5)==="true/"?S.type=S.type.slice(5):S.removeAttribute("type"),S}function sD(S,P){var Y,X,$,Q,ie,xe,be;if(P.nodeType===1){if(le.hasData(S)&&(Q=le.get(S),be=Q.events,be)){le.remove(P,"handle events");for($ in be)for(Y=0,X=be[$].length;Y<X;Y++)b.event.add(P,$,be[$][Y])}ke.hasData(S)&&(ie=ke.access(S),xe=b.extend({},ie),ke.set(P,xe))}}function ak(S,P){var Y=P.nodeName.toLowerCase();Y==="input"&&an.test(S.type)?P.checked=S.checked:(Y==="input"||Y==="textarea")&&(P.defaultValue=S.defaultValue)}function af(S,P,Y,X){P=s(P);var $,Q,ie,xe,be,Ae,He=0,qe=S.length,Be=qe-1,nt=P[0],bi=f(nt);if(bi||qe>1&&typeof nt=="string"&&!p.checkClone&&Og.test(nt))return S.each(function(hr){var Oi=S.eq(hr);bi&&(P[0]=nt.call(this,hr,Oi.html())),af(Oi,P,Y,X)});if(qe&&($=sf(P,S[0].ownerDocument,!1,S,X),Q=$.firstChild,$.childNodes.length===1&&($=Q),Q||X)){for(ie=b.map(xn($,"script"),nk),xe=ie.length;He<qe;He++)be=$,He!==Be&&(be=b.clone(be,!0,!0),xe&&b.merge(ie,xn(be,"script"))),Y.call(S[He],be,He);if(xe)for(Ae=ie[ie.length-1].ownerDocument,b.map(ie,sk),He=0;He<xe;He++)be=ie[He],ai.test(be.type||"")&&!le.access(be,"globalEval")&&b.contains(Ae,be)&&(be.src&&(be.type||"").toLowerCase()!=="module"?b._evalUrl&&!be.noModule&&b._evalUrl(be.src,{nonce:be.nonce||be.getAttribute("nonce")},Ae):y(be.textContent.replace(rk,""),be,Ae))}return S}function aD(S,P,Y){for(var X,$=P?b.filter(P,S):S,Q=0;(X=$[Q])!=null;Q++)!Y&&X.nodeType===1&&b.cleanData(xn(X)),X.parentNode&&(Y&&Ar(X)&&sa(xn(X,"script")),X.parentNode.removeChild(X));return S}b.extend({htmlPrefilter:function(S){return S},clone:function(S,P,Y){var X,$,Q,ie,xe=S.cloneNode(!0),be=Ar(S);if(!p.noCloneChecked&&(S.nodeType===1||S.nodeType===11)&&!b.isXMLDoc(S))for(ie=xn(xe),Q=xn(S),X=0,$=Q.length;X<$;X++)ak(Q[X],ie[X]);if(P)if(Y)for(Q=Q||xn(S),ie=ie||xn(xe),X=0,$=Q.length;X<$;X++)sD(Q[X],ie[X]);else sD(S,xe);return ie=xn(xe,"script"),ie.length>0&&sa(ie,!be&&xn(S,"script")),xe},cleanData:function(S){for(var P,Y,X,$=b.event.special,Q=0;(Y=S[Q])!==void 0;Q++)if(ee(Y)){if(P=Y[le.expando]){if(P.events)for(X in P.events)$[X]?b.event.remove(Y,X):b.removeEvent(Y,X,P.handle);Y[le.expando]=void 0}Y[ke.expando]&&(Y[ke.expando]=void 0)}}}),b.fn.extend({detach:function(S){return aD(this,S,!0)},remove:function(S){return aD(this,S)},text:function(S){return ze(this,function(P){return P===void 0?b.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=P)})},null,S,arguments.length)},append:function(){return af(this,arguments,function(S){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var P=nD(this,S);P.appendChild(S)}})},prepend:function(){return af(this,arguments,function(S){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var P=nD(this,S);P.insertBefore(S,P.firstChild)}})},before:function(){return af(this,arguments,function(S){this.parentNode&&this.parentNode.insertBefore(S,this)})},after:function(){return af(this,arguments,function(S){this.parentNode&&this.parentNode.insertBefore(S,this.nextSibling)})},empty:function(){for(var S,P=0;(S=this[P])!=null;P++)S.nodeType===1&&(b.cleanData(xn(S,!1)),S.textContent="");return this},clone:function(S,P){return S=S==null?!1:S,P=P==null?S:P,this.map(function(){return b.clone(this,S,P)})},html:function(S){return ze(this,function(P){var Y=this[0]||{},X=0,$=this.length;if(P===void 0&&Y.nodeType===1)return Y.innerHTML;if(typeof P=="string"&&!Bd.test(P)&&!wi[($n.exec(P)||["",""])[1].toLowerCase()]){P=b.htmlPrefilter(P);try{for(;X<$;X++)Y=this[X]||{},Y.nodeType===1&&(b.cleanData(xn(Y,!1)),Y.innerHTML=P);Y=0}catch{}}Y&&this.empty().append(P)},null,S,arguments.length)},replaceWith:function(){var S=[];return af(this,arguments,function(P){var Y=this.parentNode;b.inArray(this,S)<0&&(b.cleanData(xn(this)),Y&&Y.replaceChild(P,this))},S)}}),b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(S,P){b.fn[S]=function(Y){for(var X,$=[],Q=b(Y),ie=Q.length-1,xe=0;xe<=ie;xe++)X=xe===ie?this:this.clone(!0),b(Q[xe])[P](X),a.apply($,X.get());return this.pushStack($)}});var sw=new RegExp("^("+ji+")(?!px)[a-z%]+$","i"),aw=/^--/,H1=function(S){var P=S.ownerDocument.defaultView;return(!P||!P.opener)&&(P=e),P.getComputedStyle(S)},oD=function(S,P,Y){var X,$,Q={};for($ in P)Q[$]=S.style[$],S.style[$]=P[$];X=Y.call(S);for($ in P)S.style[$]=Q[$];return X},ok=new RegExp(Li.join("|"),"i");(function(){function S(){if(Ae){be.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",Ae.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",Sn.appendChild(be).appendChild(Ae);var He=e.getComputedStyle(Ae);Y=He.top!=="1%",xe=P(He.marginLeft)===12,Ae.style.right="60%",Q=P(He.right)===36,X=P(He.width)===36,Ae.style.position="absolute",$=P(Ae.offsetWidth/3)===12,Sn.removeChild(be),Ae=null}}function P(He){return Math.round(parseFloat(He))}var Y,X,$,Q,ie,xe,be=g.createElement("div"),Ae=g.createElement("div");Ae.style&&(Ae.style.backgroundClip="content-box",Ae.cloneNode(!0).style.backgroundClip="",p.clearCloneStyle=Ae.style.backgroundClip==="content-box",b.extend(p,{boxSizingReliable:function(){return S(),X},pixelBoxStyles:function(){return S(),Q},pixelPosition:function(){return S(),Y},reliableMarginLeft:function(){return S(),xe},scrollboxSize:function(){return S(),$},reliableTrDimensions:function(){var He,qe,Be,nt;return ie==null&&(He=g.createElement("table"),qe=g.createElement("tr"),Be=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",Be.style.height="9px",Be.style.display="block",Sn.appendChild(He).appendChild(qe).appendChild(Be),nt=e.getComputedStyle(qe),ie=parseInt(nt.height,10)+parseInt(nt.borderTopWidth,10)+parseInt(nt.borderBottomWidth,10)===qe.offsetHeight,Sn.removeChild(He)),ie}}))})();function Rg(S,P,Y){var X,$,Q,ie,xe=aw.test(P),be=S.style;return Y=Y||H1(S),Y&&(ie=Y.getPropertyValue(P)||Y[P],xe&&ie&&(ie=ie.replace(G,"$1")||void 0),ie===""&&!Ar(S)&&(ie=b.style(S,P)),!p.pixelBoxStyles()&&sw.test(ie)&&ok.test(P)&&(X=be.width,$=be.minWidth,Q=be.maxWidth,be.minWidth=be.maxWidth=be.width=ie,ie=Y.width,be.width=X,be.minWidth=$,be.maxWidth=Q)),ie!==void 0?ie+"":ie}function lD(S,P){return{get:function(){if(S()){delete this.get;return}return(this.get=P).apply(this,arguments)}}}var cD=["Webkit","Moz","ms"],uD=g.createElement("div").style,hD={};function lk(S){for(var P=S[0].toUpperCase()+S.slice(1),Y=cD.length;Y--;)if(S=cD[Y]+P,S in uD)return S}function ow(S){var P=b.cssProps[S]||hD[S];return P||(S in uD?S:hD[S]=lk(S)||S)}var ck=/^(none|table(?!-c[ea]).+)/,uk={position:"absolute",visibility:"hidden",display:"block"},dD={letterSpacing:"0",fontWeight:"400"};function pD(S,P,Y){var X=tr.exec(P);return X?Math.max(0,X[2]-(Y||0))+(X[3]||"px"):P}function lw(S,P,Y,X,$,Q){var ie=P==="width"?1:0,xe=0,be=0,Ae=0;if(Y===(X?"border":"content"))return 0;for(;ie<4;ie+=2)Y==="margin"&&(Ae+=b.css(S,Y+Li[ie],!0,$)),X?(Y==="content"&&(be-=b.css(S,"padding"+Li[ie],!0,$)),Y!=="margin"&&(be-=b.css(S,"border"+Li[ie]+"Width",!0,$))):(be+=b.css(S,"padding"+Li[ie],!0,$),Y!=="padding"?be+=b.css(S,"border"+Li[ie]+"Width",!0,$):xe+=b.css(S,"border"+Li[ie]+"Width",!0,$));return!X&&Q>=0&&(be+=Math.max(0,Math.ceil(S["offset"+P[0].toUpperCase()+P.slice(1)]-Q-be-xe-.5))||0),be+Ae}function fD(S,P,Y){var X=H1(S),$=!p.boxSizingReliable()||Y,Q=$&&b.css(S,"boxSizing",!1,X)==="border-box",ie=Q,xe=Rg(S,P,X),be="offset"+P[0].toUpperCase()+P.slice(1);if(sw.test(xe)){if(!Y)return xe;xe="auto"}return(!p.boxSizingReliable()&&Q||!p.reliableTrDimensions()&&A(S,"tr")||xe==="auto"||!parseFloat(xe)&&b.css(S,"display",!1,X)==="inline")&&S.getClientRects().length&&(Q=b.css(S,"boxSizing",!1,X)==="border-box",ie=be in S,ie&&(xe=S[be])),xe=parseFloat(xe)||0,xe+lw(S,P,Y||(Q?"border":"content"),ie,X,xe)+"px"}b.extend({cssHooks:{opacity:{get:function(S,P){if(P){var Y=Rg(S,"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(S,P,Y,X){if(!(!S||S.nodeType===3||S.nodeType===8||!S.style)){var $,Q,ie,xe=K(P),be=aw.test(P),Ae=S.style;if(be||(P=ow(xe)),ie=b.cssHooks[P]||b.cssHooks[xe],Y!==void 0){if(Q=typeof Y,Q==="string"&&($=tr.exec(Y))&&$[1]&&(Y=na(S,P,$),Q="number"),Y==null||Y!==Y)return;Q==="number"&&!be&&(Y+=$&&$[3]||(b.cssNumber[xe]?"":"px")),!p.clearCloneStyle&&Y===""&&P.indexOf("background")===0&&(Ae[P]="inherit"),(!ie||!("set"in ie)||(Y=ie.set(S,Y,X))!==void 0)&&(be?Ae.setProperty(P,Y):Ae[P]=Y)}else return ie&&"get"in ie&&($=ie.get(S,!1,X))!==void 0?$:Ae[P]}},css:function(S,P,Y,X){var $,Q,ie,xe=K(P),be=aw.test(P);return be||(P=ow(xe)),ie=b.cssHooks[P]||b.cssHooks[xe],ie&&"get"in ie&&($=ie.get(S,!0,Y)),$===void 0&&($=Rg(S,P,X)),$==="normal"&&P in dD&&($=dD[P]),Y===""||Y?(Q=parseFloat($),Y===!0||isFinite(Q)?Q||0:$):$}}),b.each(["height","width"],function(S,P){b.cssHooks[P]={get:function(Y,X,$){if(X)return ck.test(b.css(Y,"display"))&&(!Y.getClientRects().length||!Y.getBoundingClientRect().width)?oD(Y,uk,function(){return fD(Y,P,$)}):fD(Y,P,$)},set:function(Y,X,$){var Q,ie=H1(Y),xe=!p.scrollboxSize()&&ie.position==="absolute",be=xe||$,Ae=be&&b.css(Y,"boxSizing",!1,ie)==="border-box",He=$?lw(Y,P,$,Ae,ie):0;return Ae&&xe&&(He-=Math.ceil(Y["offset"+P[0].toUpperCase()+P.slice(1)]-parseFloat(ie[P])-lw(Y,P,"border",!1,ie)-.5)),He&&(Q=tr.exec(X))&&(Q[3]||"px")!=="px"&&(Y.style[P]=X,X=b.css(Y,P)),pD(Y,X,He)}}}),b.cssHooks.marginLeft=lD(p.reliableMarginLeft,function(S,P){if(P)return(parseFloat(Rg(S,"marginLeft"))||S.getBoundingClientRect().left-oD(S,{marginLeft:0},function(){return S.getBoundingClientRect().left}))+"px"}),b.each({margin:"",padding:"",border:"Width"},function(S,P){b.cssHooks[S+P]={expand:function(Y){for(var X=0,$={},Q=typeof Y=="string"?Y.split(" "):[Y];X<4;X++)$[S+Li[X]+P]=Q[X]||Q[X-2]||Q[0];return $}},S!=="margin"&&(b.cssHooks[S+P].set=pD)}),b.fn.extend({css:function(S,P){return ze(this,function(Y,X,$){var Q,ie,xe={},be=0;if(Array.isArray(X)){for(Q=H1(Y),ie=X.length;be<ie;be++)xe[X[be]]=b.css(Y,X[be],!1,Q);return xe}return $!==void 0?b.style(Y,X,$):b.css(Y,X)},S,P,arguments.length>1)}});function so(S,P,Y,X,$){return new so.prototype.init(S,P,Y,X,$)}b.Tween=so,so.prototype={constructor:so,init:function(S,P,Y,X,$,Q){this.elem=S,this.prop=Y,this.easing=$||b.easing._default,this.options=P,this.start=this.now=this.cur(),this.end=X,this.unit=Q||(b.cssNumber[Y]?"":"px")},cur:function(){var S=so.propHooks[this.prop];return S&&S.get?S.get(this):so.propHooks._default.get(this)},run:function(S){var P,Y=so.propHooks[this.prop];return this.options.duration?this.pos=P=b.easing[this.easing](S,this.options.duration*S,0,1,this.options.duration):this.pos=P=S,this.now=(this.end-this.start)*P+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),Y&&Y.set?Y.set(this):so.propHooks._default.set(this),this}},so.prototype.init.prototype=so.prototype,so.propHooks={_default:{get:function(S){var P;return S.elem.nodeType!==1||S.elem[S.prop]!=null&&S.elem.style[S.prop]==null?S.elem[S.prop]:(P=b.css(S.elem,S.prop,""),!P||P==="auto"?0:P)},set:function(S){b.fx.step[S.prop]?b.fx.step[S.prop](S):S.elem.nodeType===1&&(b.cssHooks[S.prop]||S.elem.style[ow(S.prop)]!=null)?b.style(S.elem,S.prop,S.now+S.unit):S.elem[S.prop]=S.now}}},so.propHooks.scrollTop=so.propHooks.scrollLeft={set:function(S){S.elem.nodeType&&S.elem.parentNode&&(S.elem[S.prop]=S.now)}},b.easing={linear:function(S){return S},swing:function(S){return .5-Math.cos(S*Math.PI)/2},_default:"swing"},b.fx=so.prototype.init,b.fx.step={};var of,j1,hk=/^(?:toggle|show|hide)$/,dk=/queueHooks$/;function cw(){j1&&(g.hidden===!1&&e.requestAnimationFrame?e.requestAnimationFrame(cw):e.setTimeout(cw,b.fx.interval),b.fx.tick())}function mD(){return e.setTimeout(function(){of=void 0}),of=Date.now()}function V1(S,P){var Y,X=0,$={height:S};for(P=P?1:0;X<4;X+=2-P)Y=Li[X],$["margin"+Y]=$["padding"+Y]=S;return P&&($.opacity=$.width=S),$}function gD(S,P,Y){for(var X,$=(Kl.tweeners[P]||[]).concat(Kl.tweeners["*"]),Q=0,ie=$.length;Q<ie;Q++)if(X=$[Q].call(Y,P,S))return X}function pk(S,P,Y){var X,$,Q,ie,xe,be,Ae,He,qe="width"in P||"height"in P,Be=this,nt={},bi=S.style,hr=S.nodeType&&vn(S),Oi=le.get(S,"fxshow");Y.queue||(ie=b._queueHooks(S,"fx"),ie.unqueued==null&&(ie.unqueued=0,xe=ie.empty.fire,ie.empty.fire=function(){ie.unqueued||xe()}),ie.unqueued++,Be.always(function(){Be.always(function(){ie.unqueued--,b.queue(S,"fx").length||ie.empty.fire()})}));for(X in P)if($=P[X],hk.test($)){if(delete P[X],Q=Q||$==="toggle",$===(hr?"hide":"show"))if($==="show"&&Oi&&Oi[X]!==void 0)hr=!0;else continue;nt[X]=Oi&&Oi[X]||b.style(S,X)}if(be=!b.isEmptyObject(P),!(!be&&b.isEmptyObject(nt))){qe&&S.nodeType===1&&(Y.overflow=[bi.overflow,bi.overflowX,bi.overflowY],Ae=Oi&&Oi.display,Ae==null&&(Ae=le.get(S,"display")),He=b.css(S,"display"),He==="none"&&(Ae?He=Ae:(ht([S],!0),Ae=S.style.display||Ae,He=b.css(S,"display"),ht([S]))),(He==="inline"||He==="inline-block"&&Ae!=null)&&b.css(S,"float")==="none"&&(be||(Be.done(function(){bi.display=Ae}),Ae==null&&(He=bi.display,Ae=He==="none"?"":He)),bi.display="inline-block")),Y.overflow&&(bi.overflow="hidden",Be.always(function(){bi.overflow=Y.overflow[0],bi.overflowX=Y.overflow[1],bi.overflowY=Y.overflow[2]})),be=!1;for(X in nt)be||(Oi?"hidden"in Oi&&(hr=Oi.hidden):Oi=le.access(S,"fxshow",{display:Ae}),Q&&(Oi.hidden=!hr),hr&&ht([S],!0),Be.done(function(){hr||ht([S]),le.remove(S,"fxshow");for(X in nt)b.style(S,X,nt[X])})),be=gD(hr?Oi[X]:0,X,Be),X in Oi||(Oi[X]=be.start,hr&&(be.end=be.start,be.start=0))}}function fk(S,P){var Y,X,$,Q,ie;for(Y in S)if(X=K(Y),$=P[X],Q=S[Y],Array.isArray(Q)&&($=Q[1],Q=S[Y]=Q[0]),Y!==X&&(S[X]=Q,delete S[Y]),ie=b.cssHooks[X],ie&&"expand"in ie){Q=ie.expand(Q),delete S[X];for(Y in Q)Y in S||(S[Y]=Q[Y],P[Y]=$)}else P[X]=$}function Kl(S,P,Y){var X,$,Q=0,ie=Kl.prefilters.length,xe=b.Deferred().always(function(){delete be.elem}),be=function(){if($)return!1;for(var qe=of||mD(),Be=Math.max(0,Ae.startTime+Ae.duration-qe),nt=Be/Ae.duration||0,bi=1-nt,hr=0,Oi=Ae.tweens.length;hr<Oi;hr++)Ae.tweens[hr].run(bi);return xe.notifyWith(S,[Ae,bi,Be]),bi<1&&Oi?Be:(Oi||xe.notifyWith(S,[Ae,1,0]),xe.resolveWith(S,[Ae]),!1)},Ae=xe.promise({elem:S,props:b.extend({},P),opts:b.extend(!0,{specialEasing:{},easing:b.easing._default},Y),originalProperties:P,originalOptions:Y,startTime:of||mD(),duration:Y.duration,tweens:[],createTween:function(qe,Be){var nt=b.Tween(S,Ae.opts,qe,Be,Ae.opts.specialEasing[qe]||Ae.opts.easing);return Ae.tweens.push(nt),nt},stop:function(qe){var Be=0,nt=qe?Ae.tweens.length:0;if($)return this;for($=!0;Be<nt;Be++)Ae.tweens[Be].run(1);return qe?(xe.notifyWith(S,[Ae,1,0]),xe.resolveWith(S,[Ae,qe])):xe.rejectWith(S,[Ae,qe]),this}}),He=Ae.props;for(fk(He,Ae.opts.specialEasing);Q<ie;Q++)if(X=Kl.prefilters[Q].call(Ae,S,He,Ae.opts),X)return f(X.stop)&&(b._queueHooks(Ae.elem,Ae.opts.queue).stop=X.stop.bind(X)),X;return b.map(He,gD,Ae),f(Ae.opts.start)&&Ae.opts.start.call(S,Ae),Ae.progress(Ae.opts.progress).done(Ae.opts.done,Ae.opts.complete).fail(Ae.opts.fail).always(Ae.opts.always),b.fx.timer(b.extend(be,{elem:S,anim:Ae,queue:Ae.opts.queue})),Ae}b.Animation=b.extend(Kl,{tweeners:{"*":[function(S,P){var Y=this.createTween(S,P);return na(Y.elem,S,tr.exec(P),Y),Y}]},tweener:function(S,P){f(S)?(P=S,S=["*"]):S=S.match(Fe);for(var Y,X=0,$=S.length;X<$;X++)Y=S[X],Kl.tweeners[Y]=Kl.tweeners[Y]||[],Kl.tweeners[Y].unshift(P)},prefilters:[pk],prefilter:function(S,P){P?Kl.prefilters.unshift(S):Kl.prefilters.push(S)}}),b.speed=function(S,P,Y){var X=S&&typeof S=="object"?b.extend({},S):{complete:Y||!Y&&P||f(S)&&S,duration:S,easing:Y&&P||P&&!f(P)&&P};return b.fx.off?X.duration=0:typeof X.duration!="number"&&(X.duration in b.fx.speeds?X.duration=b.fx.speeds[X.duration]:X.duration=b.fx.speeds._default),(X.queue==null||X.queue===!0)&&(X.queue="fx"),X.old=X.complete,X.complete=function(){f(X.old)&&X.old.call(this),X.queue&&b.dequeue(this,X.queue)},X},b.fn.extend({fadeTo:function(S,P,Y,X){return this.filter(vn).css("opacity",0).show().end().animate({opacity:P},S,Y,X)},animate:function(S,P,Y,X){var $=b.isEmptyObject(S),Q=b.speed(P,Y,X),ie=function(){var xe=Kl(this,b.extend({},S),Q);($||le.get(this,"finish"))&&xe.stop(!0)};return ie.finish=ie,$||Q.queue===!1?this.each(ie):this.queue(Q.queue,ie)},stop:function(S,P,Y){var X=function($){var Q=$.stop;delete $.stop,Q(Y)};return typeof S!="string"&&(Y=P,P=S,S=void 0),P&&this.queue(S||"fx",[]),this.each(function(){var $=!0,Q=S!=null&&S+"queueHooks",ie=b.timers,xe=le.get(this);if(Q)xe[Q]&&xe[Q].stop&&X(xe[Q]);else for(Q in xe)xe[Q]&&xe[Q].stop&&dk.test(Q)&&X(xe[Q]);for(Q=ie.length;Q--;)ie[Q].elem===this&&(S==null||ie[Q].queue===S)&&(ie[Q].anim.stop(Y),$=!1,ie.splice(Q,1));($||!Y)&&b.dequeue(this,S)})},finish:function(S){return S!==!1&&(S=S||"fx"),this.each(function(){var P,Y=le.get(this),X=Y[S+"queue"],$=Y[S+"queueHooks"],Q=b.timers,ie=X?X.length:0;for(Y.finish=!0,b.queue(this,S,[]),$&&$.stop&&$.stop.call(this,!0),P=Q.length;P--;)Q[P].elem===this&&Q[P].queue===S&&(Q[P].anim.stop(!0),Q.splice(P,1));for(P=0;P<ie;P++)X[P]&&X[P].finish&&X[P].finish.call(this);delete Y.finish})}}),b.each(["toggle","show","hide"],function(S,P){var Y=b.fn[P];b.fn[P]=function(X,$,Q){return X==null||typeof X=="boolean"?Y.apply(this,arguments):this.animate(V1(P,!0),X,$,Q)}}),b.each({slideDown:V1("show"),slideUp:V1("hide"),slideToggle:V1("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(S,P){b.fn[S]=function(Y,X,$){return this.animate(P,Y,X,$)}}),b.timers=[],b.fx.tick=function(){var S,P=0,Y=b.timers;for(of=Date.now();P<Y.length;P++)S=Y[P],!S()&&Y[P]===S&&Y.splice(P--,1);Y.length||b.fx.stop(),of=void 0},b.fx.timer=function(S){b.timers.push(S),b.fx.start()},b.fx.interval=13,b.fx.start=function(){j1||(j1=!0,cw())},b.fx.stop=function(){j1=null},b.fx.speeds={slow:600,fast:200,_default:400},b.fn.delay=function(S,P){return S=b.fx&&b.fx.speeds[S]||S,P=P||"fx",this.queue(P,function(Y,X){var $=e.setTimeout(Y,S);X.stop=function(){e.clearTimeout($)}})},(function(){var S=g.createElement("input"),P=g.createElement("select"),Y=P.appendChild(g.createElement("option"));S.type="checkbox",p.checkOn=S.value!=="",p.optSelected=Y.selected,S=g.createElement("input"),S.value="t",S.type="radio",p.radioValue=S.value==="t"})();var yD,Ng=b.expr.attrHandle;b.fn.extend({attr:function(S,P){return ze(this,b.attr,S,P,arguments.length>1)},removeAttr:function(S){return this.each(function(){b.removeAttr(this,S)})}}),b.extend({attr:function(S,P,Y){var X,$,Q=S.nodeType;if(!(Q===3||Q===8||Q===2)){if(typeof S.getAttribute>"u")return b.prop(S,P,Y);if((Q!==1||!b.isXMLDoc(S))&&($=b.attrHooks[P.toLowerCase()]||(b.expr.match.bool.test(P)?yD:void 0)),Y!==void 0){if(Y===null){b.removeAttr(S,P);return}return $&&"set"in $&&(X=$.set(S,Y,P))!==void 0?X:(S.setAttribute(P,Y+""),Y)}return $&&"get"in $&&(X=$.get(S,P))!==null?X:(X=b.find.attr(S,P),X==null?void 0:X)}},attrHooks:{type:{set:function(S,P){if(!p.radioValue&&P==="radio"&&A(S,"input")){var Y=S.value;return S.setAttribute("type",P),Y&&(S.value=Y),P}}}},removeAttr:function(S,P){var Y,X=0,$=P&&P.match(Fe);if($&&S.nodeType===1)for(;Y=$[X++];)S.removeAttribute(Y)}}),yD={set:function(S,P,Y){return P===!1?b.removeAttr(S,Y):S.setAttribute(Y,Y),Y}},b.each(b.expr.match.bool.source.match(/\w+/g),function(S,P){var Y=Ng[P]||b.find.attr;Ng[P]=function(X,$,Q){var ie,xe,be=$.toLowerCase();return Q||(xe=Ng[be],Ng[be]=ie,ie=Y(X,$,Q)!=null?be:null,Ng[be]=xe),ie}});var mk=/^(?:input|select|textarea|button)$/i,gk=/^(?:a|area)$/i;b.fn.extend({prop:function(S,P){return ze(this,b.prop,S,P,arguments.length>1)},removeProp:function(S){return this.each(function(){delete this[b.propFix[S]||S]})}}),b.extend({prop:function(S,P,Y){var X,$,Q=S.nodeType;if(!(Q===3||Q===8||Q===2))return(Q!==1||!b.isXMLDoc(S))&&(P=b.propFix[P]||P,$=b.propHooks[P]),Y!==void 0?$&&"set"in $&&(X=$.set(S,Y,P))!==void 0?X:S[P]=Y:$&&"get"in $&&(X=$.get(S,P))!==null?X:S[P]},propHooks:{tabIndex:{get:function(S){var P=b.find.attr(S,"tabindex");return P?parseInt(P,10):mk.test(S.nodeName)||gk.test(S.nodeName)&&S.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),p.optSelected||(b.propHooks.selected={get:function(S){var P=S.parentNode;return P&&P.parentNode&&P.parentNode.selectedIndex,null},set:function(S){var P=S.parentNode;P&&(P.selectedIndex,P.parentNode&&P.parentNode.selectedIndex)}}),b.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){b.propFix[this.toLowerCase()]=this});function kd(S){var P=S.match(Fe)||[];return P.join(" ")}function Fd(S){return S.getAttribute&&S.getAttribute("class")||""}function uw(S){return Array.isArray(S)?S:typeof S=="string"?S.match(Fe)||[]:[]}b.fn.extend({addClass:function(S){var P,Y,X,$,Q,ie;return f(S)?this.each(function(xe){b(this).addClass(S.call(this,xe,Fd(this)))}):(P=uw(S),P.length?this.each(function(){if(X=Fd(this),Y=this.nodeType===1&&" "+kd(X)+" ",Y){for(Q=0;Q<P.length;Q++)$=P[Q],Y.indexOf(" "+$+" ")<0&&(Y+=$+" ");ie=kd(Y),X!==ie&&this.setAttribute("class",ie)}}):this)},removeClass:function(S){var P,Y,X,$,Q,ie;return f(S)?this.each(function(xe){b(this).removeClass(S.call(this,xe,Fd(this)))}):arguments.length?(P=uw(S),P.length?this.each(function(){if(X=Fd(this),Y=this.nodeType===1&&" "+kd(X)+" ",Y){for(Q=0;Q<P.length;Q++)for($=P[Q];Y.indexOf(" "+$+" ")>-1;)Y=Y.replace(" "+$+" "," ");ie=kd(Y),X!==ie&&this.setAttribute("class",ie)}}):this):this.attr("class","")},toggleClass:function(S,P){var Y,X,$,Q,ie=typeof S,xe=ie==="string"||Array.isArray(S);return f(S)?this.each(function(be){b(this).toggleClass(S.call(this,be,Fd(this),P),P)}):typeof P=="boolean"&&xe?P?this.addClass(S):this.removeClass(S):(Y=uw(S),this.each(function(){if(xe)for(Q=b(this),$=0;$<Y.length;$++)X=Y[$],Q.hasClass(X)?Q.removeClass(X):Q.addClass(X);else(S===void 0||ie==="boolean")&&(X=Fd(this),X&&le.set(this,"__className__",X),this.setAttribute&&this.setAttribute("class",X||S===!1?"":le.get(this,"__className__")||""))}))},hasClass:function(S){var P,Y,X=0;for(P=" "+S+" ";Y=this[X++];)if(Y.nodeType===1&&(" "+kd(Fd(Y))+" ").indexOf(P)>-1)return!0;return!1}});var yk=/\r/g;b.fn.extend({val:function(S){var P,Y,X,$=this[0];return arguments.length?(X=f(S),this.each(function(Q){var ie;this.nodeType===1&&(X?ie=S.call(this,Q,b(this).val()):ie=S,ie==null?ie="":typeof ie=="number"?ie+="":Array.isArray(ie)&&(ie=b.map(ie,function(xe){return xe==null?"":xe+""})),P=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],(!P||!("set"in P)||P.set(this,ie,"value")===void 0)&&(this.value=ie))})):$?(P=b.valHooks[$.type]||b.valHooks[$.nodeName.toLowerCase()],P&&"get"in P&&(Y=P.get($,"value"))!==void 0?Y:(Y=$.value,typeof Y=="string"?Y.replace(yk,""):Y==null?"":Y)):void 0}}),b.extend({valHooks:{option:{get:function(S){var P=b.find.attr(S,"value");return P!=null?P:kd(b.text(S))}},select:{get:function(S){var P,Y,X,$=S.options,Q=S.selectedIndex,ie=S.type==="select-one",xe=ie?null:[],be=ie?Q+1:$.length;for(Q<0?X=be:X=ie?Q:0;X<be;X++)if(Y=$[X],(Y.selected||X===Q)&&!Y.disabled&&(!Y.parentNode.disabled||!A(Y.parentNode,"optgroup"))){if(P=b(Y).val(),ie)return P;xe.push(P)}return xe},set:function(S,P){for(var Y,X,$=S.options,Q=b.makeArray(P),ie=$.length;ie--;)X=$[ie],(X.selected=b.inArray(b.valHooks.option.get(X),Q)>-1)&&(Y=!0);return Y||(S.selectedIndex=-1),Q}}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]={set:function(S,P){if(Array.isArray(P))return S.checked=b.inArray(b(S).val(),P)>-1}},p.checkOn||(b.valHooks[this].get=function(S){return S.getAttribute("value")===null?"on":S.value})});var Mg=e.location,bD={guid:Date.now()},hw=/\?/;b.parseXML=function(S){var P,Y;if(!S||typeof S!="string")return null;try{P=new e.DOMParser().parseFromString(S,"text/xml")}catch{}return Y=P&&P.getElementsByTagName("parsererror")[0],(!P||Y)&&b.error("Invalid XML: "+(Y?b.map(Y.childNodes,function(X){return X.textContent}).join(`
`):S)),P};var xD=/^(?:focusinfocus|focusoutblur)$/,ED=function(S){S.stopPropagation()};b.extend(b.event,{trigger:function(S,P,Y,X){var $,Q,ie,xe,be,Ae,He,qe,Be=[Y||g],nt=u.call(S,"type")?S.type:S,bi=u.call(S,"namespace")?S.namespace.split("."):[];if(Q=qe=ie=Y=Y||g,!(Y.nodeType===3||Y.nodeType===8)&&!xD.test(nt+b.event.triggered)&&(nt.indexOf(".")>-1&&(bi=nt.split("."),nt=bi.shift(),bi.sort()),be=nt.indexOf(":")<0&&"on"+nt,S=S[b.expando]?S:new b.Event(nt,typeof S=="object"&&S),S.isTrigger=X?2:3,S.namespace=bi.join("."),S.rnamespace=S.namespace?new RegExp("(^|\\.)"+bi.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,S.result=void 0,S.target||(S.target=Y),P=P==null?[S]:b.makeArray(P,[S]),He=b.event.special[nt]||{},!(!X&&He.trigger&&He.trigger.apply(Y,P)===!1))){if(!X&&!He.noBubble&&!m(Y)){for(xe=He.delegateType||nt,xD.test(xe+nt)||(Q=Q.parentNode);Q;Q=Q.parentNode)Be.push(Q),ie=Q;ie===(Y.ownerDocument||g)&&Be.push(ie.defaultView||ie.parentWindow||e)}for($=0;(Q=Be[$++])&&!S.isPropagationStopped();)qe=Q,S.type=$>1?xe:He.bindType||nt,Ae=(le.get(Q,"events")||Object.create(null))[S.type]&&le.get(Q,"handle"),Ae&&Ae.apply(Q,P),Ae=be&&Q[be],Ae&&Ae.apply&&ee(Q)&&(S.result=Ae.apply(Q,P),S.result===!1&&S.preventDefault());return S.type=nt,!X&&!S.isDefaultPrevented()&&(!He._default||He._default.apply(Be.pop(),P)===!1)&&ee(Y)&&be&&f(Y[nt])&&!m(Y)&&(ie=Y[be],ie&&(Y[be]=null),b.event.triggered=nt,S.isPropagationStopped()&&qe.addEventListener(nt,ED),Y[nt](),S.isPropagationStopped()&&qe.removeEventListener(nt,ED),b.event.triggered=void 0,ie&&(Y[be]=ie)),S.result}},simulate:function(S,P,Y){var X=b.extend(new b.Event,Y,{type:S,isSimulated:!0});b.event.trigger(X,null,P)}}),b.fn.extend({trigger:function(S,P){return this.each(function(){b.event.trigger(S,P,this)})},triggerHandler:function(S,P){var Y=this[0];if(Y)return b.event.trigger(S,P,Y,!0)}});var bk=/\[\]$/,TD=/\r?\n/g,xk=/^(?:submit|button|image|reset|file)$/i,Ek=/^(?:input|select|textarea|keygen)/i;function dw(S,P,Y,X){var $;if(Array.isArray(P))b.each(P,function(Q,ie){Y||bk.test(S)?X(S,ie):dw(S+"["+(typeof ie=="object"&&ie!=null?Q:"")+"]",ie,Y,X)});else if(!Y&&E(P)==="object")for($ in P)dw(S+"["+$+"]",P[$],Y,X);else X(S,P)}b.param=function(S,P){var Y,X=[],$=function(Q,ie){var xe=f(ie)?ie():ie;X[X.length]=encodeURIComponent(Q)+"="+encodeURIComponent(xe==null?"":xe)};if(S==null)return"";if(Array.isArray(S)||S.jquery&&!b.isPlainObject(S))b.each(S,function(){$(this.name,this.value)});else for(Y in S)dw(Y,S[Y],P,$);return X.join("&")},b.fn.extend({serialize:function(){return b.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var S=b.prop(this,"elements");return S?b.makeArray(S):this}).filter(function(){var S=this.type;return this.name&&!b(this).is(":disabled")&&Ek.test(this.nodeName)&&!xk.test(S)&&(this.checked||!an.test(S))}).map(function(S,P){var Y=b(this).val();return Y==null?null:Array.isArray(Y)?b.map(Y,function(X){return{name:P.name,value:X.replace(TD,`\r
`)}}):{name:P.name,value:Y.replace(TD,`\r
`)}}).get()}});var Tk=/%20/g,wk=/#.*$/,Sk=/([?&])_=[^&]*/,vk=/^(.*?):[ \t]*([^\r\n]*)$/mg,Ik=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ak=/^(?:GET|HEAD)$/,Ck=/^\/\//,wD={},pw={},SD="*/".concat("*"),fw=g.createElement("a");fw.href=Mg.href;function vD(S){return function(P,Y){typeof P!="string"&&(Y=P,P="*");var X,$=0,Q=P.toLowerCase().match(Fe)||[];if(f(Y))for(;X=Q[$++];)X[0]==="+"?(X=X.slice(1)||"*",(S[X]=S[X]||[]).unshift(Y)):(S[X]=S[X]||[]).push(Y)}}function ID(S,P,Y,X){var $={},Q=S===pw;function ie(xe){var be;return $[xe]=!0,b.each(S[xe]||[],function(Ae,He){var qe=He(P,Y,X);if(typeof qe=="string"&&!Q&&!$[qe])return P.dataTypes.unshift(qe),ie(qe),!1;if(Q)return!(be=qe)}),be}return ie(P.dataTypes[0])||!$["*"]&&ie("*")}function mw(S,P){var Y,X,$=b.ajaxSettings.flatOptions||{};for(Y in P)P[Y]!==void 0&&(($[Y]?S:X||(X={}))[Y]=P[Y]);return X&&b.extend(!0,S,X),S}function Dk(S,P,Y){for(var X,$,Q,ie,xe=S.contents,be=S.dataTypes;be[0]==="*";)be.shift(),X===void 0&&(X=S.mimeType||P.getResponseHeader("Content-Type"));if(X){for($ in xe)if(xe[$]&&xe[$].test(X)){be.unshift($);break}}if(be[0]in Y)Q=be[0];else{for($ in Y){if(!be[0]||S.converters[$+" "+be[0]]){Q=$;break}ie||(ie=$)}Q=Q||ie}if(Q)return Q!==be[0]&&be.unshift(Q),Y[Q]}function Pk(S,P,Y,X){var $,Q,ie,xe,be,Ae={},He=S.dataTypes.slice();if(He[1])for(ie in S.converters)Ae[ie.toLowerCase()]=S.converters[ie];for(Q=He.shift();Q;)if(S.responseFields[Q]&&(Y[S.responseFields[Q]]=P),!be&&X&&S.dataFilter&&(P=S.dataFilter(P,S.dataType)),be=Q,Q=He.shift(),Q){if(Q==="*")Q=be;else if(be!=="*"&&be!==Q){if(ie=Ae[be+" "+Q]||Ae["* "+Q],!ie){for($ in Ae)if(xe=$.split(" "),xe[1]===Q&&(ie=Ae[be+" "+xe[0]]||Ae["* "+xe[0]],ie)){ie===!0?ie=Ae[$]:Ae[$]!==!0&&(Q=xe[0],He.unshift(xe[1]));break}}if(ie!==!0)if(ie&&S.throws)P=ie(P);else try{P=ie(P)}catch(qe){return{state:"parsererror",error:ie?qe:"No conversion from "+be+" to "+Q}}}}return{state:"success",data:P}}b.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Mg.href,type:"GET",isLocal:Ik.test(Mg.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":SD,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":b.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(S,P){return P?mw(mw(S,b.ajaxSettings),P):mw(b.ajaxSettings,S)},ajaxPrefilter:vD(wD),ajaxTransport:vD(pw),ajax:function(S,P){typeof S=="object"&&(P=S,S=void 0),P=P||{};var Y,X,$,Q,ie,xe,be,Ae,He,qe,Be=b.ajaxSetup({},P),nt=Be.context||Be,bi=Be.context&&(nt.nodeType||nt.jquery)?b(nt):b.event,hr=b.Deferred(),Oi=b.Callbacks("once memory"),aa=Be.statusCode||{},Os={},Gc={},Uc="canceled",ir={readyState:0,getResponseHeader:function(gr){var Qn;if(be){if(!Q)for(Q={};Qn=vk.exec($);)Q[Qn[1].toLowerCase()+" "]=(Q[Qn[1].toLowerCase()+" "]||[]).concat(Qn[2]);Qn=Q[gr.toLowerCase()+" "]}return Qn==null?null:Qn.join(", ")},getAllResponseHeaders:function(){return be?$:null},setRequestHeader:function(gr,Qn){return be==null&&(gr=Gc[gr.toLowerCase()]=Gc[gr.toLowerCase()]||gr,Os[gr]=Qn),this},overrideMimeType:function(gr){return be==null&&(Be.mimeType=gr),this},statusCode:function(gr){var Qn;if(gr)if(be)ir.always(gr[ir.status]);else for(Qn in gr)aa[Qn]=[aa[Qn],gr[Qn]];return this},abort:function(gr){var Qn=gr||Uc;return Y&&Y.abort(Qn),Gd(0,Qn),this}};if(hr.promise(ir),Be.url=((S||Be.url||Mg.href)+"").replace(Ck,Mg.protocol+"//"),Be.type=P.method||P.type||Be.method||Be.type,Be.dataTypes=(Be.dataType||"*").toLowerCase().match(Fe)||[""],Be.crossDomain==null){xe=g.createElement("a");try{xe.href=Be.url,xe.href=xe.href,Be.crossDomain=fw.protocol+"//"+fw.host!=xe.protocol+"//"+xe.host}catch{Be.crossDomain=!0}}if(Be.data&&Be.processData&&typeof Be.data!="string"&&(Be.data=b.param(Be.data,Be.traditional)),ID(wD,Be,P,ir),be)return ir;Ae=b.event&&Be.global,Ae&&b.active++===0&&b.event.trigger("ajaxStart"),Be.type=Be.type.toUpperCase(),Be.hasContent=!Ak.test(Be.type),X=Be.url.replace(wk,""),Be.hasContent?Be.data&&Be.processData&&(Be.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(Be.data=Be.data.replace(Tk,"+")):(qe=Be.url.slice(X.length),Be.data&&(Be.processData||typeof Be.data=="string")&&(X+=(hw.test(X)?"&":"?")+Be.data,delete Be.data),Be.cache===!1&&(X=X.replace(Sk,"$1"),qe=(hw.test(X)?"&":"?")+"_="+bD.guid+++qe),Be.url=X+qe),Be.ifModified&&(b.lastModified[X]&&ir.setRequestHeader("If-Modified-Since",b.lastModified[X]),b.etag[X]&&ir.setRequestHeader("If-None-Match",b.etag[X])),(Be.data&&Be.hasContent&&Be.contentType!==!1||P.contentType)&&ir.setRequestHeader("Content-Type",Be.contentType),ir.setRequestHeader("Accept",Be.dataTypes[0]&&Be.accepts[Be.dataTypes[0]]?Be.accepts[Be.dataTypes[0]]+(Be.dataTypes[0]!=="*"?", "+SD+"; q=0.01":""):Be.accepts["*"]);for(He in Be.headers)ir.setRequestHeader(He,Be.headers[He]);if(Be.beforeSend&&(Be.beforeSend.call(nt,ir,Be)===!1||be))return ir.abort();if(Uc="abort",Oi.add(Be.complete),ir.done(Be.success),ir.fail(Be.error),Y=ID(pw,Be,P,ir),!Y)Gd(-1,"No Transport");else{if(ir.readyState=1,Ae&&bi.trigger("ajaxSend",[ir,Be]),be)return ir;Be.async&&Be.timeout>0&&(ie=e.setTimeout(function(){ir.abort("timeout")},Be.timeout));try{be=!1,Y.send(Os,Gd)}catch(gr){if(be)throw gr;Gd(-1,gr)}}function Gd(gr,Qn,kg,yw){var Yc,Fg,Hc,Ih,Ah,pl=Qn;be||(be=!0,ie&&e.clearTimeout(ie),Y=void 0,$=yw||"",ir.readyState=gr>0?4:0,Yc=gr>=200&&gr<300||gr===304,kg&&(Ih=Dk(Be,ir,kg)),!Yc&&b.inArray("script",Be.dataTypes)>-1&&b.inArray("json",Be.dataTypes)<0&&(Be.converters["text script"]=function(){}),Ih=Pk(Be,Ih,ir,Yc),Yc?(Be.ifModified&&(Ah=ir.getResponseHeader("Last-Modified"),Ah&&(b.lastModified[X]=Ah),Ah=ir.getResponseHeader("etag"),Ah&&(b.etag[X]=Ah)),gr===204||Be.type==="HEAD"?pl="nocontent":gr===304?pl="notmodified":(pl=Ih.state,Fg=Ih.data,Hc=Ih.error,Yc=!Hc)):(Hc=pl,(gr||!pl)&&(pl="error",gr<0&&(gr=0))),ir.status=gr,ir.statusText=(Qn||pl)+"",Yc?hr.resolveWith(nt,[Fg,pl,ir]):hr.rejectWith(nt,[ir,pl,Hc]),ir.statusCode(aa),aa=void 0,Ae&&bi.trigger(Yc?"ajaxSuccess":"ajaxError",[ir,Be,Yc?Fg:Hc]),Oi.fireWith(nt,[ir,pl]),Ae&&(bi.trigger("ajaxComplete",[ir,Be]),--b.active||b.event.trigger("ajaxStop")))}return ir},getJSON:function(S,P,Y){return b.get(S,P,Y,"json")},getScript:function(S,P){return b.get(S,void 0,P,"script")}}),b.each(["get","post"],function(S,P){b[P]=function(Y,X,$,Q){return f(X)&&(Q=Q||$,$=X,X=void 0),b.ajax(b.extend({url:Y,type:P,dataType:Q,data:X,success:$},b.isPlainObject(Y)&&Y))}}),b.ajaxPrefilter(function(S){var P;for(P in S.headers)P.toLowerCase()==="content-type"&&(S.contentType=S.headers[P]||"")}),b._evalUrl=function(S,P,Y){return b.ajax({url:S,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(X){b.globalEval(X,P,Y)}})},b.fn.extend({wrapAll:function(S){var P;return this[0]&&(f(S)&&(S=S.call(this[0])),P=b(S,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&P.insertBefore(this[0]),P.map(function(){for(var Y=this;Y.firstElementChild;)Y=Y.firstElementChild;return Y}).append(this)),this},wrapInner:function(S){return f(S)?this.each(function(P){b(this).wrapInner(S.call(this,P))}):this.each(function(){var P=b(this),Y=P.contents();Y.length?Y.wrapAll(S):P.append(S)})},wrap:function(S){var P=f(S);return this.each(function(Y){b(this).wrapAll(P?S.call(this,Y):S)})},unwrap:function(S){return this.parent(S).not("body").each(function(){b(this).replaceWith(this.childNodes)}),this}}),b.expr.pseudos.hidden=function(S){return!b.expr.pseudos.visible(S)},b.expr.pseudos.visible=function(S){return!!(S.offsetWidth||S.offsetHeight||S.getClientRects().length)},b.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch{}};var _k={0:200,1223:204},Bg=b.ajaxSettings.xhr();p.cors=!!Bg&&"withCredentials"in Bg,p.ajax=Bg=!!Bg,b.ajaxTransport(function(S){var P,Y;if(p.cors||Bg&&!S.crossDomain)return{send:function(X,$){var Q,ie=S.xhr();if(ie.open(S.type,S.url,S.async,S.username,S.password),S.xhrFields)for(Q in S.xhrFields)ie[Q]=S.xhrFields[Q];S.mimeType&&ie.overrideMimeType&&ie.overrideMimeType(S.mimeType),!S.crossDomain&&!X["X-Requested-With"]&&(X["X-Requested-With"]="XMLHttpRequest");for(Q in X)ie.setRequestHeader(Q,X[Q]);P=function(xe){return function(){P&&(P=Y=ie.onload=ie.onerror=ie.onabort=ie.ontimeout=ie.onreadystatechange=null,xe==="abort"?ie.abort():xe==="error"?typeof ie.status!="number"?$(0,"error"):$(ie.status,ie.statusText):$(_k[ie.status]||ie.status,ie.statusText,(ie.responseType||"text")!=="text"||typeof ie.responseText!="string"?{binary:ie.response}:{text:ie.responseText},ie.getAllResponseHeaders()))}},ie.onload=P(),Y=ie.onerror=ie.ontimeout=P("error"),ie.onabort!==void 0?ie.onabort=Y:ie.onreadystatechange=function(){ie.readyState===4&&e.setTimeout(function(){P&&Y()})},P=P("abort");try{ie.send(S.hasContent&&S.data||null)}catch(xe){if(P)throw xe}},abort:function(){P&&P()}}}),b.ajaxPrefilter(function(S){S.crossDomain&&(S.contents.script=!1)}),b.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(S){return b.globalEval(S),S}}}),b.ajaxPrefilter("script",function(S){S.cache===void 0&&(S.cache=!1),S.crossDomain&&(S.type="GET")}),b.ajaxTransport("script",function(S){if(S.crossDomain||S.scriptAttrs){var P,Y;return{send:function(X,$){P=b("<script>").attr(S.scriptAttrs||{}).prop({charset:S.scriptCharset,src:S.url}).on("load error",Y=function(Q){P.remove(),Y=null,Q&&$(Q.type==="error"?404:200,Q.type)}),g.head.appendChild(P[0])},abort:function(){Y&&Y()}}}});var AD=[],gw=/(=)\?(?=&|$)|\?\?/;b.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var S=AD.pop()||b.expando+"_"+bD.guid++;return this[S]=!0,S}}),b.ajaxPrefilter("json jsonp",function(S,P,Y){var X,$,Q,ie=S.jsonp!==!1&&(gw.test(S.url)?"url":typeof S.data=="string"&&(S.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&gw.test(S.data)&&"data");if(ie||S.dataTypes[0]==="jsonp")return X=S.jsonpCallback=f(S.jsonpCallback)?S.jsonpCallback():S.jsonpCallback,ie?S[ie]=S[ie].replace(gw,"$1"+X):S.jsonp!==!1&&(S.url+=(hw.test(S.url)?"&":"?")+S.jsonp+"="+X),S.converters["script json"]=function(){return Q||b.error(X+" was not called"),Q[0]},S.dataTypes[0]="json",$=e[X],e[X]=function(){Q=arguments},Y.always(function(){$===void 0?b(e).removeProp(X):e[X]=$,S[X]&&(S.jsonpCallback=P.jsonpCallback,AD.push(X)),Q&&f($)&&$(Q[0]),Q=$=void 0}),"script"}),p.createHTMLDocument=(function(){var S=g.implementation.createHTMLDocument("").body;return S.innerHTML="<form></form><form></form>",S.childNodes.length===2})(),b.parseHTML=function(S,P,Y){if(typeof S!="string")return[];typeof P=="boolean"&&(Y=P,P=!1);var X,$,Q;return P||(p.createHTMLDocument?(P=g.implementation.createHTMLDocument(""),X=P.createElement("base"),X.href=g.location.href,P.head.appendChild(X)):P=g),$=B.exec(S),Q=!Y&&[],$?[P.createElement($[1])]:($=sf([S],P,Q),Q&&Q.length&&b(Q).remove(),b.merge([],$.childNodes))},b.fn.load=function(S,P,Y){var X,$,Q,ie=this,xe=S.indexOf(" ");return xe>-1&&(X=kd(S.slice(xe)),S=S.slice(0,xe)),f(P)?(Y=P,P=void 0):P&&typeof P=="object"&&($="POST"),ie.length>0&&b.ajax({url:S,type:$||"GET",dataType:"html",data:P}).done(function(be){Q=arguments,ie.html(X?b("<div>").append(b.parseHTML(be)).find(X):be)}).always(Y&&function(be,Ae){ie.each(function(){Y.apply(this,Q||[be.responseText,Ae,be])})}),this},b.expr.pseudos.animated=function(S){return b.grep(b.timers,function(P){return S===P.elem}).length},b.offset={setOffset:function(S,P,Y){var X,$,Q,ie,xe,be,Ae,He=b.css(S,"position"),qe=b(S),Be={};He==="static"&&(S.style.position="relative"),xe=qe.offset(),Q=b.css(S,"top"),be=b.css(S,"left"),Ae=(He==="absolute"||He==="fixed")&&(Q+be).indexOf("auto")>-1,Ae?(X=qe.position(),ie=X.top,$=X.left):(ie=parseFloat(Q)||0,$=parseFloat(be)||0),f(P)&&(P=P.call(S,Y,b.extend({},xe))),P.top!=null&&(Be.top=P.top-xe.top+ie),P.left!=null&&(Be.left=P.left-xe.left+$),"using"in P?P.using.call(S,Be):qe.css(Be)}},b.fn.extend({offset:function(S){if(arguments.length)return S===void 0?this:this.each(function($){b.offset.setOffset(this,S,$)});var P,Y,X=this[0];if(X)return X.getClientRects().length?(P=X.getBoundingClientRect(),Y=X.ownerDocument.defaultView,{top:P.top+Y.pageYOffset,left:P.left+Y.pageXOffset}):{top:0,left:0}},position:function(){if(this[0]){var S,P,Y,X=this[0],$={top:0,left:0};if(b.css(X,"position")==="fixed")P=X.getBoundingClientRect();else{for(P=this.offset(),Y=X.ownerDocument,S=X.offsetParent||Y.documentElement;S&&(S===Y.body||S===Y.documentElement)&&b.css(S,"position")==="static";)S=S.parentNode;S&&S!==X&&S.nodeType===1&&($=b(S).offset(),$.top+=b.css(S,"borderTopWidth",!0),$.left+=b.css(S,"borderLeftWidth",!0))}return{top:P.top-$.top-b.css(X,"marginTop",!0),left:P.left-$.left-b.css(X,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var S=this.offsetParent;S&&b.css(S,"position")==="static";)S=S.offsetParent;return S||Sn})}}),b.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(S,P){var Y=P==="pageYOffset";b.fn[S]=function(X){return ze(this,function($,Q,ie){var xe;if(m($)?xe=$:$.nodeType===9&&(xe=$.defaultView),ie===void 0)return xe?xe[P]:$[Q];xe?xe.scrollTo(Y?xe.pageXOffset:ie,Y?ie:xe.pageYOffset):$[Q]=ie},S,X,arguments.length)}}),b.each(["top","left"],function(S,P){b.cssHooks[P]=lD(p.pixelPosition,function(Y,X){if(X)return X=Rg(Y,P),sw.test(X)?b(Y).position()[P]+"px":X})}),b.each({Height:"height",Width:"width"},function(S,P){b.each({padding:"inner"+S,content:P,"":"outer"+S},function(Y,X){b.fn[X]=function($,Q){var ie=arguments.length&&(Y||typeof $!="boolean"),xe=Y||($===!0||Q===!0?"margin":"border");return ze(this,function(be,Ae,He){var qe;return m(be)?X.indexOf("outer")===0?be["inner"+S]:be.document.documentElement["client"+S]:be.nodeType===9?(qe=be.documentElement,Math.max(be.body["scroll"+S],qe["scroll"+S],be.body["offset"+S],qe["offset"+S],qe["client"+S])):He===void 0?b.css(be,Ae,xe):b.style(be,Ae,He,xe)},P,ie?$:void 0,ie)}})}),b.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(S,P){b.fn[P]=function(Y){return this.on(P,Y)}}),b.fn.extend({bind:function(S,P,Y){return this.on(S,null,P,Y)},unbind:function(S,P){return this.off(S,null,P)},delegate:function(S,P,Y,X){return this.on(P,S,Y,X)},undelegate:function(S,P,Y){return arguments.length===1?this.off(S,"**"):this.off(P,S||"**",Y)},hover:function(S,P){return this.on("mouseenter",S).on("mouseleave",P||S)}}),b.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(S,P){b.fn[P]=function(Y,X){return arguments.length>0?this.on(P,null,Y,X):this.trigger(P)}});var Lk=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;b.proxy=function(S,P){var Y,X,$;if(typeof P=="string"&&(Y=S[P],P=S,S=Y),!!f(S))return X=n.call(arguments,2),$=function(){return S.apply(P||this,X.concat(n.call(arguments)))},$.guid=S.guid=S.guid||b.guid++,$},b.holdReady=function(S){S?b.readyWait++:b.ready(!0)},b.isArray=Array.isArray,b.parseJSON=JSON.parse,b.nodeName=A,b.isFunction=f,b.isWindow=m,b.camelCase=K,b.type=E,b.now=Date.now,b.isNumeric=function(S){var P=b.type(S);return(P==="number"||P==="string")&&!isNaN(S-parseFloat(S))},b.trim=function(S){return S==null?"":(S+"").replace(Lk,"$1")},typeof define=="function"&&define.amd&&define("jquery",[],function(){return b});var Ok=e.jQuery,Rk=e.$;return b.noConflict=function(S){return e.$===b&&(e.$=Rk),S&&e.jQuery===b&&(e.jQuery=Ok),b},typeof t>"u"&&(e.jQuery=e.$=b),b})});var ND=Ug(RD());document.write(ND.default);var Yd={0:0,90:1,180:0,270:-1},Aw={0:1,90:0,180:-1,270:0},J1=[1,10,100,1e3],MD="http://www.w3.org/2000/svg",BD="http://www.w3.org/1999/xlink",Ou=(function(){var e={svg:MD,xlink:BD};return e[MD]="svg",e[BD]="xlink",e})(),K1=0,kD=1,Cw=2,Oa=10,ml=11,ti=1,lo=6,gl=7,co=16,yl=17,uo=8,bl=9,ho=18,xl=19,on=4,po=12,El=13,Tl=5,fo=14,wl=15,yr=2,Dr=3,FD=0,gs={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},$1=200;var Z1=1e4,GD=0,Ru=4,gn={drag:"DragTool",draw:"DrawTool",paste:"PasteTool",arrayCopy:"ArrayCopyTool",highlight:"HighlightTool",delete:"Delete",rotate:"Rotate",duplicateTo:"DuplicateTo",lock:"LockControl",eleVisable:"EleVisibleMgr",pasteInPlace:"PasteInPlace"},UD="<...>";var Dh="stop-iterate",Q1="can-not-select-flag",Dw={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"]}};var uf=Xk("3.2.130"),YD="05/06/2026";function Xk(e){return e.split(".").slice(0,3).join(".")}var In={tabId:"",doctype:void 0,loading:void 0,version:"V"+uf,buildDate:YD,head:void 0,layerConfig:void 0,srcTabid:""};var px=Ug(ib());var x6=Object.create,zS=Object.defineProperty,E6=Object.getOwnPropertyDescriptor,T6=Object.getOwnPropertyNames,w6=Object.getPrototypeOf,S6=Object.prototype.hasOwnProperty,pf=(e=>typeof oo<"u"?oo:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof oo<"u"?oo:t)[i]}):e)(function(e){if(typeof oo<"u")return oo.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),v6=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),I6=(e,t)=>{for(var i in t)zS(e,i,{get:t[i],enumerable:!0})},A6=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T6(t))!S6.call(e,n)&&n!==i&&zS(e,n,{get:()=>t[n],enumerable:!(r=E6(t,n))||r.enumerable});return e},y0=(e,t,i)=>(i=e!=null?x6(w6(e)):{},A6(t||!e||!e.__esModule?zS(i,"default",{value:e,enumerable:!0}):i,e)),b0=v6((e,t)=>{"use strict";var i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a=(D,j)=>{for(var Z in j)i(D,Z,{get:j[Z],enumerable:!0})},o=(D,j,Z,K)=>{if(j&&typeof j=="object"||typeof j=="function")for(let ee of n(j))!s.call(D,ee)&&ee!==Z&&i(D,ee,{get:()=>j[ee],enumerable:!(K=r(j,ee))||K.enumerable});return D},l=D=>o(i({},"__esModule",{value:!0}),D),c={};a(c,{BroadcastChannelMessageBus:()=>Ee,MessageBus:()=>v,MessageBus2:()=>ne,MessageBusTask:()=>N,MessageBusTask2:()=>z,WindowMessageBridge:()=>I,WorkerMessageBridge:()=>q,createBroadcastP2PStream:()=>It,createBufferedByteBufferStream:()=>je,createBufferedStream:()=>Ne,createBufferedStringStream:()=>it,dropP2PStream:()=>Ht,flowRead:()=>ze,flowWrite:()=>Ci}),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 j=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,j);let Z=new Array(j);for(let K=0;K<this.count;K++)Z[K]=this.buffer[(this.head+K)%this.capacity];this.buffer=Z,this.head=0,this.tail=this.count,this.capacity=j}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 x(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(x);{let j={};for(let Z in D)Object.hasOwnProperty.call(D,Z)&&(j[Z]=x(D[Z]));return j}}function y(D,j){return E(D,j,()=>[])}function E(D,j,Z){let K=D[j];return K!==void 0||(K=Z(j),D[j]=K),K}var T=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 b(D,j){let Z=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===j&&(D.splice(ee,1),ee--,K--,Z++);return Z}var C=w(),A=C.WeakRef||(D=>D);function R(D){if(D!=null){if(typeof D=="object")return new A(D);console.error(D,D instanceof Object,typeof D);return}}function O(D){return D==null?void 0:D.deref()}var M="_MSG_BUS_RPC_",k=300*1e3,G=(D=>(D.PUBLISH="publish",D.SUBSCRIBE="subscribe",D.PUSH="push",D.PULL="pull",D))(G||{}),H=class{constructor(D){this.bus=D}processRemoteMessage(D,j){let Z=R(j),K=D.topic,ee=D.type,ge=D.message;switch(ee){case"pull":this.bus.pull(K,le=>{this.push(K,le,O(Z))});break;case"subscribe":this.bus.subscribe(K,le=>{this.publish(K,le,O(Z))});break;case"publish":this.bus.publish(K,ge,this,O(Z));break;case"push":this.bus.push(K,ge,this,O(Z));break;default:console.debug("unknown message type "+ee)}}rpcCall(D,j,Z,K=k){let ee=R(Z),ge=new Promise(le=>{let ke=this.bus.uniqueRpcTopic(D);this.publish(D,{message:j,reply:ke},O(ee)),this.bus.pull(ke,(rt,gt,et)=>{le({message:rt,bridge:gt,source:R(et)})})});return K>0?Promise.race([ge,new Promise((le,ke)=>{setTimeout(ke,K)})]):ge}},q=class extends H{constructor(D,j){super(D),this.worker=j,j.onmessage=Z=>{this.processRemoteMessage(Z.data,void 0)}}publish(D,j){this.postMessage(D,"publish",j)}subscribe(D){this.postMessage(D,"subscribe",null)}push(D,j){this.postMessage(D,"push",j)}pull(D){this.postMessage(D,"pull",null)}rpcCall(D,j,Z=k){return super.rpcCall(D,j,void 0,Z)}postMessage(D,j,Z){let K={topic:D,type:j,message:Z};this.worker.postMessage(K)}discard(){this.worker.terminate()}},I=class extends H{constructor(D){super(D),window.addEventListener("message",j=>{this.processRemoteMessage(j.data,j.source)},!1)}publish(D,j,Z){this.postMessage(D,"publish",j,Z)}subscribe(D,j){if(j===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(D,"subscribe",null,j)}push(D,j,Z){this.postMessage(D,"push",j,Z)}pull(D,j){if(j===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(D,"pull",null,j)}postMessage(D,j,Z,K){let ee={topic:D,type:j,message:Z};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,j,Z,K){try{D=K?D:x(D),this.callback(D,j,Z)}catch(ee){console.error(ee)}}},v=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,j,Z,K){let ee=this.subscribed[D];if(ee){let ge;for(let le of ee)le.running()?le.execute(j,Z,K,this.unsafe):(ge=ge||new Array,ge.push(le));if(ge)for(let le of ge)b(ee,le)}else console.debug("no sub on topic: "+D)}subscribe(D,j){let Z=new N(j);return y(this.subscribed,D).push(Z),Z}push(D,j,Z,K){let ee=!1,ge=this.pulled[D];if(ge){for(;ge.length>0;){let le=ge.shift();if(le.running()){le.execute(j,Z,K,this.unsafe),ee=!0;break}}ge.length===0&&delete this.pulled[D]}ee||y(this.pushed,D).push({message:j,bridge:Z,source:R(K)})}pull(D,j){let Z=new N(j),K=this.pushed[D];if(K){let ee=K.shift();Z.execute(ee.message,ee.bridge,O(ee.source),this.unsafe),K.length===0&&delete this.pushed[D]}else y(this.pulled,D).push(Z);return Z}pullA(D){return new Promise(j=>{this.pull(D,(Z,K,ee)=>{j({message:Z,bridge:K,source:R(ee)})})})}rpcService(D,j){this.subscribe(D,(Z,K,ee)=>{let{message:ge,reply:le}=Z;try{let ke=j(ge);if(ke instanceof Promise){let rt=R(ee);ke.then(gt=>{this.rpcReply(gt,le,K,O(rt))},gt=>{console.error(gt),this.rpcReply(void 0,le,K,O(rt))})}else this.rpcReply(ke,le,K,ee)}catch(ke){console.error(ke),this.rpcReply(void 0,le,K,ee)}})}rpcCall(D,j,Z=k){let K=new Promise(ee=>{let ge=this.uniqueRpcTopic(D);this.publish(D,{message:j,reply:ge}),this.pull(ge,(le,ke,rt)=>{ee({message:le,bridge:ke,source:R(rt)})})});return Z>0?Promise.race([K,new Promise((ee,ge)=>{setTimeout(ge,Z)})]):K}rpcReply(D,j,Z,K){Z?Z.push(j,D,K):this.push(j,D)}},L="_MSG_BUS_RPC_";function _(D,j){let Z=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===j&&(D.splice(ee,1),ee--,K--,Z++);return Z}function B(D,j){return U(D,j,()=>[])}function U(D,j,Z){let K=D[j];return K!==void 0||(K=Z(j),D[j]=K),K}var z=class{constructor(D,j){this.callback=D,this.unsafe=j,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(D){try{D=this.unsafe?D:x(D),this.callback(D)}catch(j){console.error(j)}}},W=class{constructor(D=crypto.randomUUID()){this.uuid=D,this.rpcTicket=0}subscribeOnce(D,j){let Z=this.subscribe(D,K=>{Z.cancel(),j(K)});return Z}pullA(D){return new Promise(j=>{this.pull(D,j)})}rpcService(D,j){let Z=K=>{try{let{message:ee,replyTopic:ge}=K;try{let le=j(ee);le instanceof Promise?le.then(ke=>{this.publish(ge,{success:!0,result:ke})}).catch(ke=>{console.error(ke),this.publish(ge,{success:!1,err:String(ke)})}):this.publish(ge,{success:!0,result:le})}catch(le){this.publish(ge,{success:!1,err:String(le)})}}finally{this.pull(D,Z)}};this.pull(D,Z)}rpcCall(D,j,Z=0){let K=new Promise((ee,ge)=>{let le=`${L}-${D}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(le,ke=>{ke.success?ee(ke.result):ge(new Error(ke.err))}),this.push(D,{message:j,replyTopic:le})});return Z>0?Promise.race([K,new Promise((ee,ge)=>{setTimeout(ge,Z)})]):K}},ne=class extends W{constructor(D=!1){super(),this.unsafe=D,this.subscribed={},this.pulled={},this.pushed={}}publish(D,j){let Z=this.subscribed[D];if(Z){let K;for(let ee of Z)ee.running()?ee.execute(j):(K=K||new Array,K.push(ee));if(K)for(let ee of K)_(Z,ee)}}subscribe(D,j){let Z=new z(j,this.unsafe);return B(this.subscribed,D).push(Z),Z}push(D,j){let Z=!1,K=this.pulled[D];if(K){for(;K.length>0;){let ee=K.shift();if(ee&&ee.running()){ee.execute(j),Z=!0;break}}K.length===0&&delete this.pulled[D]}Z||B(this.pushed,D).push(j)}pull(D,j){let Z=new z(j,this.unsafe);return this.repull(D,Z),Z}repull(D,j){let Z=this.pushed[D];if(Z){let K=Z.shift();K&&(j.execute(K),Z.length===0&&delete this.pushed[D])}else B(this.pulled,D).push(j)}},me=class extends W{constructor(D=crypto.randomUUID()){super(D),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(D,j){console.debug("BC",this.uuid,"PUBLISH",D,j),this.broadcastPublish(D,j)}subscribe(D,j){console.debug("BC",this.uuid,"SUBSCRIBE",D);let Z=new z(j,!0);return B(this.subscribed,D).push(Z),Z}push(D,j){let Z=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",D,`(${Z})`,j),B(this.pushed,D).push({id:Z,message:j}),this.broadcastPushedHeadMessage(D)}pull(D,j){console.debug("BC",this.uuid,"PULL",D);let Z=new z(j,!0);return B(this.pulled,D).push(Z),this.broadcastWhoHas(D),Z}broadcastPushedHeadMessage(D){let j=this.pushed[D];j&&j[0]&&this.broadcastIHave(D,j[0].id)}onReceivedPublish(D,j,Z){console.debug("BCMSG(",this.uuid,")","from",D,"PUBLISH",j,"message",Z);let K=this.subscribed[j];if(K){let ee;for(let ge of K)ge.running()?ge.execute(Z):(ee=ee||new Array,ee.push(ge));if(ee)for(let ge of ee)_(K,ge);K.length===0&&delete this.subscribed[j]}}onReceivedWhoHas(D,j){console.debug("BCMSG(",this.uuid,")","from",D,"WHOHAS",j),this.broadcastPushedHeadMessage(j)}onReceivedIHave(D,j,Z){console.debug("BCMSG(",this.uuid,")","from",D,"IHAVE",j,"id",Z);let K=this.pulled[j];if(K){let ee;for(let ge of K)if(ge.running()){this.broadcastINeed(j,D,Z);break}else ee=ee||new Array,ee.push(ge);if(ee)for(let ge of ee)_(K,ge);K.length===0&&delete this.pulled[j]}}onReceivedINeed(D,j,Z,K){if(console.debug("BCMSG(",this.uuid,")","from",D,"INEED",j,"source",Z,"id",K),this.uuid===Z){let ee=this.pushed[j];if(ee&&ee[0]&&ee[0].id===K){let{message:ge}=ee.shift();this.broadcastIGive(j,K,D,ge),this.broadcastPushedHeadMessage(j),ee.length===0&&delete this.pushed[j]}}}onReceivedIGive(D,j,Z,K,ee){console.debug("BCMSG(",this.uuid,")","from",D,"IGIVE",j,"id",Z,"target",K,"message",ee);let ge=this.pulled[j];if(ge&&this.uuid===K){let le=!1;for(;ge.length>0;){let ke=ge.shift();if(ke.running()){ke.execute(ee),le=!0;break}}le||this.push(j,ee),ge.length===0&&delete this.pulled[j]}}},Ee=class extends me{constructor(D,j=crypto.randomUUID()){super(j),this.bc=new BroadcastChannel(D),this.bc.onmessage=Z=>{this.onMessage(Z.data)}}onMessage(D){let{type:j,uuid:Z,topic:K}=D;switch(j){case"PUBLISH":{let{message:ee}=D;this.onReceivedPublish(Z,K,ee);break}case"WHOHAS":{this.onReceivedWhoHas(Z,K);break}case"IHAVE":{let{id:ee}=D;this.onReceivedIHave(Z,K,ee);break}case"INEED":{let{source:ee,id:ge}=D;this.onReceivedINeed(Z,K,ee,ge);break}case"IGIVE":{let{target:ee,id:ge,message:le}=D;this.onReceivedIGive(Z,K,ge,ee,le);break}default:console.warn("unsupported",D)}}broadcastPublish(D,j){this.post({type:"PUBLISH",uuid:this.uuid,topic:D,message:j})}broadcastWhoHas(D){this.post({type:"WHOHAS",uuid:this.uuid,topic:D})}broadcastIHave(D,j){this.post({type:"IHAVE",uuid:this.uuid,topic:D,id:j})}broadcastINeed(D,j,Z){this.post({type:"INEED",uuid:this.uuid,topic:D,source:j,id:Z})}broadcastIGive(D,j,Z,K){this.post({type:"IGIVE",uuid:this.uuid,topic:D,id:j,target:Z,message:K})}post(D){this.bc.postMessage(D),Promise.resolve().then(()=>{this.onMessage(D)})}},Se=Symbol("BLOCKING_QUEUE_RESET"),Fe=class{constructor(D,j=()=>1){if(this.maxSize=D,this.itemSizeOf=j,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 j=await new Promise(Z=>{this.waitingProducers.enqueue(Z)});return console.debug("queue is not full",this.size(),j),j?(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 j=this.waitingConsumers.dequeue();Promise.resolve(D).then(j),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(Se).then(D)}return setTimeout(()=>this.closeResolve(),0),Se}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 j=this.waitingProducers.dequeue();Promise.resolve(!0).then(j)}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 j=this.waitingProducers.dequeue();Promise.resolve(!1).then(j)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let j=this.waitingConsumers.dequeue();Promise.resolve(Se).then(j)}D()}})),this.closePromise}};function Ne(D,j,Z=Number.MAX_SAFE_INTEGER){let K=new Fe(Z,j),ee=new ReadableStream({pull(le){let ke=!0,rt=(async()=>{let gt=new Array;do{let et=K.dequeue();if(et instanceof Promise){ke=!1;let si=await et;si===Se?le.close():gt.push(si)}else{let si=et;si===Se?le.close():gt.push(si)}}while(K.size()>0);if(gt.length>0){let et=D(gt);le.enqueue(et)}})();if(!ke)return console.debug("read stream stucked --------------------------------------"),rt},async cancel(){console.debug("buffered readable cancel"),await K.close()}}),ge=new WritableStream({write(le,ke){let rt=!0,gt=(async()=>{let et=K.enqueue(le);typeof et=="boolean"?et||ke.error(new Error("Write stream closed")):(rt=!1,await et||ke.error(new Error("Write stream closed")))})();if(!rt)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),gt},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:ge}}function it(D=Number.MAX_SAFE_INTEGER){return Ne(j=>j.join(""),j=>j.length,D)}function je(D=Number.MAX_SAFE_INTEGER){return Ne(j=>{let Z=new Uint8Array(j.reduce((ee,ge)=>ee+ge.byteLength,0)),K=0;return j.forEach(ee=>{Z.set(ee,K),K+=ee.byteLength}),Z},j=>j.byteLength,D)}function It(D){return new Promise((j,Z)=>{let K=new BroadcastChannel(D),ee=new Fe(1),ge=new T(1),le=null,ke=!1,rt=!1,gt=!1;K.onmessage=et=>{let si=et.data,{type:ji}=si;if(console.debug("p2p",D,"type",ji,"data",ji==="DATA"&&si.data),ji==="DATA")ee.enqueue(si.data);else if(ji==="HI"){if(!le){K.postMessage({type:"HI"});let Ar=0;le={rs:new ReadableStream({async pull(Sr){let vn=await ee.dequeue();vn===Se?(await Li(),Sr.close()):(Sr.enqueue(vn),K.postMessage({type:"ACK"}))},cancel(){return Li()}}),ws:new WritableStream({async write(Sr,vn){await ge.acquireSync()?K.postMessage({type:"DATA",id:Ar++,data:Sr}):(tr(),vn.error(new Error("Write stream closed")))},close(){tr()},abort(){tr()}})},j(le)}}else ji==="REND"?le?ge.close():Sn("REND1"):ji==="WEND"?le?ee.close():Sn("WEND1"):ji==="ACK"&&ge.release();function tr(){ke||(ke=!0,console.debug(D,"p2p write stream closed"),ge.close(),K.postMessage({type:"WEND"}),rt&&(console.debug(D,"p2p channel closed on ws"),K.close()))}async function Li(){rt||(rt=!0,console.debug(D,"p2p read stream closed"),K.postMessage({type:"REND"}),await ee.close(),ke&&(console.debug(D,"p2p channel closed on rs"),K.close()))}async function Sn(Ar){gt||(gt=!0,console.debug(D,"p2p channel connection released on",Ar),ge.close(),ee.close(),le?(le.rs.locked||(console.debug(D,"p2p unlocked read stream direct cancel"),le.rs.cancel()),le.ws.locked||(console.debug(D,"p2p unlocked write stream direct close"),le.ws.close())):(K.postMessage({type:"HI"}),K.close()),Z(new Error("p2p channel connection released")))}},K.postMessage({type:"HI"})})}function Ht(D){return new Promise(j=>{let Z=new BroadcastChannel(D);Z.onmessage=K=>{let ee=K.data,{type:ge}=ee;ge==="HI"&&(Z.postMessage({type:"REND"}),Z.close(),j())},Z.postMessage({type:"REND"})})}async function Ri(D){try{return await It(D)}catch(j){j.message!=="p2p channel connection released"&&console.error(j)}}async function Ci(D,j,Z=10*1024*1024,K=!0){let ee=await Ri(D);if(!ee)return!1;let ge=!1;try{let le,ke=rt=>{if(!le)if(!K)le=ee.ws.getWriter();else if(typeof rt=="string"){let gt=it(Z);gt.readable.pipeTo(ee.ws),le=gt.writable.getWriter()}else{let gt=je(Z);gt.readable.pipeTo(ee.ws),le=gt.writable.getWriter()}return le.write(rt)};if(Array.isArray(j))for(let rt of j)await ke(rt);else await j({write:ke,get desiredSize(){return((le==null?void 0:le.desiredSize)||0)+10}});le&&await le.close(),ge=!0}catch(le){console.error(le)}finally{return ee.rs.cancel(),ge}}async function ze(D,j){var Z,K;let ee=await Ri(D);if(ee)try{let ge=ee.rs.getReader();for((Z=j.start)==null?void 0:Z.call(j);;){let{value:le,done:ke}=await ge.read();if(le!==void 0){let rt;if(j.update instanceof Promise?rt=await j.update(le):rt=j.update(le),rt){await ge.cancel();break}}if(ke){(K=j.end)==null||K.call(j);break}}}catch(ge){console.error(ge)}finally{ee.ws.close()}}}),C6={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"},D6={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"},$D={codeEN:C6,codeCN:D6},i_=class r_{static load(){typeof $D=="object"&&(r_.cache=$D)}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}};i_.cache={};var gS=i_;function P6(){console.log("common init----------------"),gS.load()}function Yo(e,t){throw new Error(`invalid format state on (${t}) of ${e}`)}function _6(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):Yo(e,l);break;case"f":s=t[n++],typeof s=="number"?(i.push(s.toString()),r=0):Yo(e,l);break;case"x":s=t[n++],typeof s=="number"?(i.push((s|0).toString(16)),r=0):Yo(e,l);break;case"X":s=t[n++],typeof s=="number"?(i.push((s|0).toString(16).toUpperCase()),r=0):Yo(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:Yo(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):Yo(e,l)}else Yo(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):Yo(e,l)}else Yo(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):Yo(e,l)}else Yo(e,l);break;default:Yo(e,l)}break;default:Yo(e,l)}}return i.join("")}function n_(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 s_(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 yS(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 L6(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 x=Math.max(p.length,f.length);for(let y=0;y<x;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 O6(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 tx(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 R6(e,t=""){return e.sort((r,n)=>s_(yS(i(r)),yS(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 N6(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 M6(e){return new Promise(t=>{setTimeout(t,e)})}var ote=Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map(e=>e.charCodeAt(0));function B6(){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 dr=(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 k6(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 F6(e){try{return JSON.parse(e)}catch{return console.error(`ParseJSON failed:
`+e),null}}var G6=(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))(G6||{}),U6=(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)}},Y6=(e,t)=>t,H6=class Jg{constructor(t,i=U6,r=Y6){this.level=t,this.writer=i,this.formatter=r}wrap(t){return new Jg(this.level,this.writer,(i,r)=>(r=this.formatter(i,r),t(i,r)))}inject(t){return new Jg(this.level,this.writer,(i,r)=>(r=t(i,r),this.formatter(i,r)))}shadow(...t){return new Jg(this.level,(i,r)=>{this.writer(i,r);for(let n of t)n(i,r)},this.formatter)}mix(...t){return new Jg(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,[_6(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)}},lte=new H6(5),cte=Date.now()-performance.now(),a_=new ArrayBuffer(10),ute=new Float64Array(a_,0,1),hte=new Uint8Array(a_);var XS={};I6(XS,{HAS_PANEL:()=>c8,HAS_PCB:()=>l8,HAS_SCH:()=>o8,HAS_SIM:()=>u8,IS_CLIENT:()=>ic,IS_CLIENT_HALF_OFFLINE:()=>l0,IS_CLIENT_NOT_ONLINE:()=>t8,IS_CLIENT_OFFLINE:()=>c_,IS_CLIENT_ONLINE:()=>kb,IS_DEV:()=>z6,IS_EASYEDA:()=>l_,IS_EASYEDA_CLIENT:()=>e8,IS_ECAD:()=>X6,IS_ENTERPRISE_CLIENT:()=>W6,IS_HALF_OFFLINE:()=>rx,IS_LCEDA:()=>o_,IS_LCEDA_CLIENT:()=>Q6,IS_OFFLINE:()=>nx,IS_ONLINE:()=>ix,IS_PCBLUXSHARE:()=>q6,IS_PRIVATE:()=>E0,PRO_EDITOR_MODE:()=>i8,PRO_EDITOR_MODES:()=>Ts,SSO_EXTERNAL_IDENTITY_DOMAIN:()=>K6,SSO_EXTERNAL_PERMISSION_DOMAIN:()=>$6,SSO_EXTERNAL_PERMISSION_MANAGED_DOMAIN:()=>Z6,SSO_IDENTITY_CONNECT:()=>J6});var j6=(e=>(e.ruler="ruler",e.un_ruler="un_ruler",e))(j6||{}),x0=(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))(x0||{}),V6=(e=>(e.SCH="SCH",e.PCB="PCB",e.PANEL="PANEL",e.SIM="SIM",e))(V6||{}),ZD=B6(),Ts=String((ZD==null?void 0:ZD.PRO_EDITOR_MODE)||"LCEDA").split("-"),z6=Ts.indexOf("DEVPRO")>=0,ic=Ts.indexOf("CLIENT")>=0,o_=Ts.indexOf("LCEDA")>=0,l_=Ts.indexOf("EASYEDA")>=0,E0=Ts.indexOf("PRIVATE")>=0,ix=Ts.indexOf("ONLINE")>=0,rx=Ts.indexOf("HALF_OFFLINE")>=0,nx=Ts.indexOf("OFFLINE")>=0,X6=Ts.indexOf("ECAD")>=0,W6=Ts.indexOf("ENTERPRISE")>=0,q6=Ts.indexOf("PCB_LUXSHARE")>=0,J6=Ts.indexOf("SSO_IDENTITY_CONNECT")>=0,K6=Ts.indexOf("SSO_EXTERNAL_IDENTITY_DOMAIN")>=0,$6=Ts.indexOf("SSO_EXTERNAL_PERMISSION_DOMAIN")>=0,Z6=Ts.indexOf("SSO_EXTERNAL_PERMISSION_MANAGED_DOMAIN")>=0,Q6=ic&&o_,e8=ic&&l_,l0=ic&&rx,t8=ic&&!ix,c_=ic&&nx,kb=ic&&ix,i8=ic?ix?"ONLINE":rx?"HALF_OFFLINE":nx?"OFFLINE":"":"",r8=Ts.indexOf("SCH")>=0,n8=Ts.indexOf("PCB")>=0,s8=Ts.indexOf("PANEL")>=0,a8=Ts.indexOf("SIM")>=0,o8=r8,l8=n8,c8=s8,u8=a8,WS=(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))(WS||{}),ff=class Rh{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`${Rh.CREATE_URL}?${this._params}`}get writeURL(){return`${Rh.WRITE_URL}?${this._params}`}get closeURL(){return`${Rh.CLOSE_URL}?${this._params}`}get cancelURL(){return`${Rh.CANCEL_URL}?${this._params}`}async create(){this._aTarget.href=this.createURL,this._aTarget.click(),this._aTarget.remove(),Rh._openedInstances.set(this.uuid,this),await M6(100)}async write(t){await(await fetch(this.writeURL,{method:"post",body:t})).json()}async close(){await fetch(this.closeURL,{method:"post"}),Rh._openedInstances.delete(this.uuid)}async cancel(){await fetch(this.cancelURL,{method:"post"}),Rh._openedInstances.delete(this.uuid)}};ff.CREATE_URL=`${ff.URL_VERSION}/sw/download/stream/create`,ff.WRITE_URL="/sw/download/stream/write",ff.CLOSE_URL="/sw/download/stream/close",ff.CANCEL_URL="/sw/download/stream/cancel",ff._openedInstances=new Map;var h8=Object.create,u_=Object.defineProperty,d8=Object.getOwnPropertyDescriptor,p8=Object.getOwnPropertyNames,f8=Object.getPrototypeOf,m8=Object.prototype.hasOwnProperty,QD=(e=>typeof pf<"u"?pf:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof pf<"u"?pf:t)[i]}):e)(function(e){if(typeof pf<"u")return pf.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),qi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),g8=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p8(t))!m8.call(e,n)&&n!==i&&u_(e,n,{get:()=>t[n],enumerable:!(r=d8(t,n))||r.enumerable});return e},jf=(e,t,i)=>(i=e!=null?h8(f8(e)):{},g8(t||!e||!e.__esModule?u_(i,"default",{value:e,enumerable:!0}):i,e)),T0=qi((e,t)=>{"use strict";var i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a=(D,j)=>{for(var Z in j)i(D,Z,{get:j[Z],enumerable:!0})},o=(D,j,Z,K)=>{if(j&&typeof j=="object"||typeof j=="function")for(let ee of n(j))!s.call(D,ee)&&ee!==Z&&i(D,ee,{get:()=>j[ee],enumerable:!(K=r(j,ee))||K.enumerable});return D},l=D=>o(i({},"__esModule",{value:!0}),D),c={};a(c,{BroadcastChannelMessageBus:()=>Ee,MessageBus:()=>v,MessageBus2:()=>ne,MessageBusTask:()=>N,MessageBusTask2:()=>z,WindowMessageBridge:()=>I,WorkerMessageBridge:()=>q,createBroadcastP2PStream:()=>It,createBufferedByteBufferStream:()=>je,createBufferedStream:()=>Ne,createBufferedStringStream:()=>it,dropP2PStream:()=>Ht,flowRead:()=>ze,flowWrite:()=>Ci}),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 j=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,j);let Z=new Array(j);for(let K=0;K<this.count;K++)Z[K]=this.buffer[(this.head+K)%this.capacity];this.buffer=Z,this.head=0,this.tail=this.count,this.capacity=j}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 x(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(x);{let j={};for(let Z in D)Object.hasOwnProperty.call(D,Z)&&(j[Z]=x(D[Z]));return j}}function y(D,j){return E(D,j,()=>[])}function E(D,j,Z){let K=D[j];return K!==void 0||(K=Z(j),D[j]=K),K}var T=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 b(D,j){let Z=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===j&&(D.splice(ee,1),ee--,K--,Z++);return Z}var C=w(),A=C.WeakRef||(D=>D);function R(D){if(D!=null){if(typeof D=="object")return new A(D);console.error(D,D instanceof Object,typeof D);return}}function O(D){return D==null?void 0:D.deref()}var M="_MSG_BUS_RPC_",k=300*1e3,G=(D=>(D.PUBLISH="publish",D.SUBSCRIBE="subscribe",D.PUSH="push",D.PULL="pull",D))(G||{}),H=class{constructor(D){this.bus=D}processRemoteMessage(D,j){let Z=R(j),K=D.topic,ee=D.type,ge=D.message;switch(ee){case"pull":this.bus.pull(K,le=>{this.push(K,le,O(Z))});break;case"subscribe":this.bus.subscribe(K,le=>{this.publish(K,le,O(Z))});break;case"publish":this.bus.publish(K,ge,this,O(Z));break;case"push":this.bus.push(K,ge,this,O(Z));break;default:console.debug("unknown message type "+ee)}}rpcCall(D,j,Z,K=k){let ee=R(Z),ge=new Promise(le=>{let ke=this.bus.uniqueRpcTopic(D);this.publish(D,{message:j,reply:ke},O(ee)),this.bus.pull(ke,(rt,gt,et)=>{le({message:rt,bridge:gt,source:R(et)})})});return K>0?Promise.race([ge,new Promise((le,ke)=>{setTimeout(ke,K)})]):ge}},q=class extends H{constructor(D,j){super(D),this.worker=j,j.onmessage=Z=>{this.processRemoteMessage(Z.data,void 0)}}publish(D,j){this.postMessage(D,"publish",j)}subscribe(D){this.postMessage(D,"subscribe",null)}push(D,j){this.postMessage(D,"push",j)}pull(D){this.postMessage(D,"pull",null)}rpcCall(D,j,Z=k){return super.rpcCall(D,j,void 0,Z)}postMessage(D,j,Z){let K={topic:D,type:j,message:Z};this.worker.postMessage(K)}discard(){this.worker.terminate()}},I=class extends H{constructor(D){super(D),window.addEventListener("message",j=>{this.processRemoteMessage(j.data,j.source)},!1)}publish(D,j,Z){this.postMessage(D,"publish",j,Z)}subscribe(D,j){if(j===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(D,"subscribe",null,j)}push(D,j,Z){this.postMessage(D,"push",j,Z)}pull(D,j){if(j===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(D,"pull",null,j)}postMessage(D,j,Z,K){let ee={topic:D,type:j,message:Z};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,j,Z,K){try{D=K?D:x(D),this.callback(D,j,Z)}catch(ee){console.error(ee)}}},v=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,j,Z,K){let ee=this.subscribed[D];if(ee){let ge;for(let le of ee)le.running()?le.execute(j,Z,K,this.unsafe):(ge=ge||new Array,ge.push(le));if(ge)for(let le of ge)b(ee,le)}else console.debug("no sub on topic: "+D)}subscribe(D,j){let Z=new N(j);return y(this.subscribed,D).push(Z),Z}push(D,j,Z,K){let ee=!1,ge=this.pulled[D];if(ge){for(;ge.length>0;){let le=ge.shift();if(le.running()){le.execute(j,Z,K,this.unsafe),ee=!0;break}}ge.length===0&&delete this.pulled[D]}ee||y(this.pushed,D).push({message:j,bridge:Z,source:R(K)})}pull(D,j){let Z=new N(j),K=this.pushed[D];if(K){let ee=K.shift();Z.execute(ee.message,ee.bridge,O(ee.source),this.unsafe),K.length===0&&delete this.pushed[D]}else y(this.pulled,D).push(Z);return Z}pullA(D){return new Promise(j=>{this.pull(D,(Z,K,ee)=>{j({message:Z,bridge:K,source:R(ee)})})})}rpcService(D,j){this.subscribe(D,(Z,K,ee)=>{let{message:ge,reply:le}=Z;try{let ke=j(ge);if(ke instanceof Promise){let rt=R(ee);ke.then(gt=>{this.rpcReply(gt,le,K,O(rt))},gt=>{console.error(gt),this.rpcReply(void 0,le,K,O(rt))})}else this.rpcReply(ke,le,K,ee)}catch(ke){console.error(ke),this.rpcReply(void 0,le,K,ee)}})}rpcCall(D,j,Z=k){let K=new Promise(ee=>{let ge=this.uniqueRpcTopic(D);this.publish(D,{message:j,reply:ge}),this.pull(ge,(le,ke,rt)=>{ee({message:le,bridge:ke,source:R(rt)})})});return Z>0?Promise.race([K,new Promise((ee,ge)=>{setTimeout(ge,Z)})]):K}rpcReply(D,j,Z,K){Z?Z.push(j,D,K):this.push(j,D)}},L="_MSG_BUS_RPC_";function _(D,j){let Z=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===j&&(D.splice(ee,1),ee--,K--,Z++);return Z}function B(D,j){return U(D,j,()=>[])}function U(D,j,Z){let K=D[j];return K!==void 0||(K=Z(j),D[j]=K),K}var z=class{constructor(D,j){this.callback=D,this.unsafe=j,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(D){try{D=this.unsafe?D:x(D),this.callback(D)}catch(j){console.error(j)}}},W=class{constructor(D=crypto.randomUUID()){this.uuid=D,this.rpcTicket=0}subscribeOnce(D,j){let Z=this.subscribe(D,K=>{Z.cancel(),j(K)});return Z}pullA(D){return new Promise(j=>{this.pull(D,j)})}rpcService(D,j){let Z=K=>{try{let{message:ee,replyTopic:ge}=K;try{let le=j(ee);le instanceof Promise?le.then(ke=>{this.publish(ge,{success:!0,result:ke})}).catch(ke=>{console.error(ke),this.publish(ge,{success:!1,err:String(ke)})}):this.publish(ge,{success:!0,result:le})}catch(le){this.publish(ge,{success:!1,err:String(le)})}}finally{this.pull(D,Z)}};this.pull(D,Z)}rpcCall(D,j,Z=0){let K=new Promise((ee,ge)=>{let le=`${L}-${D}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(le,ke=>{ke.success?ee(ke.result):ge(new Error(ke.err))}),this.push(D,{message:j,replyTopic:le})});return Z>0?Promise.race([K,new Promise((ee,ge)=>{setTimeout(ge,Z)})]):K}},ne=class extends W{constructor(D=!1){super(),this.unsafe=D,this.subscribed={},this.pulled={},this.pushed={}}publish(D,j){let Z=this.subscribed[D];if(Z){let K;for(let ee of Z)ee.running()?ee.execute(j):(K=K||new Array,K.push(ee));if(K)for(let ee of K)_(Z,ee)}}subscribe(D,j){let Z=new z(j,this.unsafe);return B(this.subscribed,D).push(Z),Z}push(D,j){let Z=!1,K=this.pulled[D];if(K){for(;K.length>0;){let ee=K.shift();if(ee&&ee.running()){ee.execute(j),Z=!0;break}}K.length===0&&delete this.pulled[D]}Z||B(this.pushed,D).push(j)}pull(D,j){let Z=new z(j,this.unsafe);return this.repull(D,Z),Z}repull(D,j){let Z=this.pushed[D];if(Z){let K=Z.shift();K&&(j.execute(K),Z.length===0&&delete this.pushed[D])}else B(this.pulled,D).push(j)}},me=class extends W{constructor(D=crypto.randomUUID()){super(D),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(D,j){console.debug("BC",this.uuid,"PUBLISH",D,j),this.broadcastPublish(D,j)}subscribe(D,j){console.debug("BC",this.uuid,"SUBSCRIBE",D);let Z=new z(j,!0);return B(this.subscribed,D).push(Z),Z}push(D,j){let Z=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",D,`(${Z})`,j),B(this.pushed,D).push({id:Z,message:j}),this.broadcastPushedHeadMessage(D)}pull(D,j){console.debug("BC",this.uuid,"PULL",D);let Z=new z(j,!0);return B(this.pulled,D).push(Z),this.broadcastWhoHas(D),Z}broadcastPushedHeadMessage(D){let j=this.pushed[D];j&&j[0]&&this.broadcastIHave(D,j[0].id)}onReceivedPublish(D,j,Z){console.debug("BCMSG(",this.uuid,")","from",D,"PUBLISH",j,"message",Z);let K=this.subscribed[j];if(K){let ee;for(let ge of K)ge.running()?ge.execute(Z):(ee=ee||new Array,ee.push(ge));if(ee)for(let ge of ee)_(K,ge);K.length===0&&delete this.subscribed[j]}}onReceivedWhoHas(D,j){console.debug("BCMSG(",this.uuid,")","from",D,"WHOHAS",j),this.broadcastPushedHeadMessage(j)}onReceivedIHave(D,j,Z){console.debug("BCMSG(",this.uuid,")","from",D,"IHAVE",j,"id",Z);let K=this.pulled[j];if(K){let ee;for(let ge of K)if(ge.running()){this.broadcastINeed(j,D,Z);break}else ee=ee||new Array,ee.push(ge);if(ee)for(let ge of ee)_(K,ge);K.length===0&&delete this.pulled[j]}}onReceivedINeed(D,j,Z,K){if(console.debug("BCMSG(",this.uuid,")","from",D,"INEED",j,"source",Z,"id",K),this.uuid===Z){let ee=this.pushed[j];if(ee&&ee[0]&&ee[0].id===K){let{message:ge}=ee.shift();this.broadcastIGive(j,K,D,ge),this.broadcastPushedHeadMessage(j),ee.length===0&&delete this.pushed[j]}}}onReceivedIGive(D,j,Z,K,ee){console.debug("BCMSG(",this.uuid,")","from",D,"IGIVE",j,"id",Z,"target",K,"message",ee);let ge=this.pulled[j];if(ge&&this.uuid===K){let le=!1;for(;ge.length>0;){let ke=ge.shift();if(ke.running()){ke.execute(ee),le=!0;break}}le||this.push(j,ee),ge.length===0&&delete this.pulled[j]}}},Ee=class extends me{constructor(D,j=crypto.randomUUID()){super(j),this.bc=new BroadcastChannel(D),this.bc.onmessage=Z=>{this.onMessage(Z.data)}}onMessage(D){let{type:j,uuid:Z,topic:K}=D;switch(j){case"PUBLISH":{let{message:ee}=D;this.onReceivedPublish(Z,K,ee);break}case"WHOHAS":{this.onReceivedWhoHas(Z,K);break}case"IHAVE":{let{id:ee}=D;this.onReceivedIHave(Z,K,ee);break}case"INEED":{let{source:ee,id:ge}=D;this.onReceivedINeed(Z,K,ee,ge);break}case"IGIVE":{let{target:ee,id:ge,message:le}=D;this.onReceivedIGive(Z,K,ge,ee,le);break}default:console.warn("unsupported",D)}}broadcastPublish(D,j){this.post({type:"PUBLISH",uuid:this.uuid,topic:D,message:j})}broadcastWhoHas(D){this.post({type:"WHOHAS",uuid:this.uuid,topic:D})}broadcastIHave(D,j){this.post({type:"IHAVE",uuid:this.uuid,topic:D,id:j})}broadcastINeed(D,j,Z){this.post({type:"INEED",uuid:this.uuid,topic:D,source:j,id:Z})}broadcastIGive(D,j,Z,K){this.post({type:"IGIVE",uuid:this.uuid,topic:D,id:j,target:Z,message:K})}post(D){this.bc.postMessage(D),Promise.resolve().then(()=>{this.onMessage(D)})}},Se=Symbol("BLOCKING_QUEUE_RESET"),Fe=class{constructor(D,j=()=>1){if(this.maxSize=D,this.itemSizeOf=j,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 j=await new Promise(Z=>{this.waitingProducers.enqueue(Z)});return console.debug("queue is not full",this.size(),j),j?(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 j=this.waitingConsumers.dequeue();Promise.resolve(D).then(j),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(Se).then(D)}return setTimeout(()=>this.closeResolve(),0),Se}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 j=this.waitingProducers.dequeue();Promise.resolve(!0).then(j)}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 j=this.waitingProducers.dequeue();Promise.resolve(!1).then(j)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let j=this.waitingConsumers.dequeue();Promise.resolve(Se).then(j)}D()}})),this.closePromise}};function Ne(D,j,Z=Number.MAX_SAFE_INTEGER){let K=new Fe(Z,j),ee=new ReadableStream({pull(le){let ke=!0,rt=(async()=>{let gt=new Array;do{let et=K.dequeue();if(et instanceof Promise){ke=!1;let si=await et;si===Se?le.close():gt.push(si)}else{let si=et;si===Se?le.close():gt.push(si)}}while(K.size()>0);if(gt.length>0){let et=D(gt);le.enqueue(et)}})();if(!ke)return console.debug("read stream stucked --------------------------------------"),rt},async cancel(){console.debug("buffered readable cancel"),await K.close()}}),ge=new WritableStream({write(le,ke){let rt=!0,gt=(async()=>{let et=K.enqueue(le);typeof et=="boolean"?et||ke.error(new Error("Write stream closed")):(rt=!1,await et||ke.error(new Error("Write stream closed")))})();if(!rt)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),gt},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:ge}}function it(D=Number.MAX_SAFE_INTEGER){return Ne(j=>j.join(""),j=>j.length,D)}function je(D=Number.MAX_SAFE_INTEGER){return Ne(j=>{let Z=new Uint8Array(j.reduce((ee,ge)=>ee+ge.byteLength,0)),K=0;return j.forEach(ee=>{Z.set(ee,K),K+=ee.byteLength}),Z},j=>j.byteLength,D)}function It(D){return new Promise((j,Z)=>{let K=new BroadcastChannel(D),ee=new Fe(1),ge=new T(1),le=null,ke=!1,rt=!1,gt=!1;K.onmessage=et=>{let si=et.data,{type:ji}=si;if(console.debug("p2p",D,"type",ji,"data",ji==="DATA"&&si.data),ji==="DATA")ee.enqueue(si.data);else if(ji==="HI"){if(!le){K.postMessage({type:"HI"});let Ar=0;le={rs:new ReadableStream({async pull(Sr){let vn=await ee.dequeue();vn===Se?(await Li(),Sr.close()):(Sr.enqueue(vn),K.postMessage({type:"ACK"}))},cancel(){return Li()}}),ws:new WritableStream({async write(Sr,vn){await ge.acquireSync()?K.postMessage({type:"DATA",id:Ar++,data:Sr}):(tr(),vn.error(new Error("Write stream closed")))},close(){tr()},abort(){tr()}})},j(le)}}else ji==="REND"?le?ge.close():Sn("REND1"):ji==="WEND"?le?ee.close():Sn("WEND1"):ji==="ACK"&&ge.release();function tr(){ke||(ke=!0,console.debug(D,"p2p write stream closed"),ge.close(),K.postMessage({type:"WEND"}),rt&&(console.debug(D,"p2p channel closed on ws"),K.close()))}async function Li(){rt||(rt=!0,console.debug(D,"p2p read stream closed"),K.postMessage({type:"REND"}),await ee.close(),ke&&(console.debug(D,"p2p channel closed on rs"),K.close()))}async function Sn(Ar){gt||(gt=!0,console.debug(D,"p2p channel connection released on",Ar),ge.close(),ee.close(),le?(le.rs.locked||(console.debug(D,"p2p unlocked read stream direct cancel"),le.rs.cancel()),le.ws.locked||(console.debug(D,"p2p unlocked write stream direct close"),le.ws.close())):(K.postMessage({type:"HI"}),K.close()),Z(new Error("p2p channel connection released")))}},K.postMessage({type:"HI"})})}function Ht(D){return new Promise(j=>{let Z=new BroadcastChannel(D);Z.onmessage=K=>{let ee=K.data,{type:ge}=ee;ge==="HI"&&(Z.postMessage({type:"REND"}),Z.close(),j())},Z.postMessage({type:"REND"})})}async function Ri(D){try{return await It(D)}catch(j){j.message!=="p2p channel connection released"&&console.error(j)}}async function Ci(D,j,Z=10*1024*1024,K=!0){let ee=await Ri(D);if(!ee)return!1;let ge=!1;try{let le,ke=rt=>{if(!le)if(!K)le=ee.ws.getWriter();else if(typeof rt=="string"){let gt=it(Z);gt.readable.pipeTo(ee.ws),le=gt.writable.getWriter()}else{let gt=je(Z);gt.readable.pipeTo(ee.ws),le=gt.writable.getWriter()}return le.write(rt)};if(Array.isArray(j))for(let rt of j)await ke(rt);else await j({write:ke,get desiredSize(){return((le==null?void 0:le.desiredSize)||0)+10}});le&&await le.close(),ge=!0}catch(le){console.error(le)}finally{return ee.rs.cancel(),ge}}async function ze(D,j){var Z,K;let ee=await Ri(D);if(ee)try{let ge=ee.rs.getReader();for((Z=j.start)==null?void 0:Z.call(j);;){let{value:le,done:ke}=await ge.read();if(le!==void 0){let rt;if(j.update instanceof Promise?rt=await j.update(le):rt=j.update(le),rt){await ge.cancel();break}}if(ke){(K=j.end)==null||K.call(j);break}}}catch(ge){console.error(ge)}finally{ee.ws.close()}}}),ar=qi((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 QD=="function")try{s=QD("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(T){var w;return E.prototype=T,w=new E,E.prototype=null,w}})(),l={},c=l.lib={},u=c.Base=(function(){return{extend:function(E){var T=o(this);return E&&T.mixIn(E),(!T.hasOwnProperty("init")||this.init===T.init)&&(T.init=function(){T.$super.init.apply(this,arguments)}),T.init.prototype=T,T.$super=this,T},create:function(){var E=this.extend();return E.init.apply(E,arguments),E},init:function(){},mixIn:function(E){for(var T in E)E.hasOwnProperty(T)&&(this[T]=E[T]);E.hasOwnProperty("toString")&&(this.toString=E.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),h=c.WordArray=u.extend({init:function(E,T){E=this.words=E||[],T!=n?this.sigBytes=T:this.sigBytes=E.length*4},toString:function(E){return(E||p).stringify(this)},concat:function(E){var T=this.words,w=E.words,b=this.sigBytes,C=E.sigBytes;if(this.clamp(),b%4)for(var A=0;A<C;A++){var R=w[A>>>2]>>>24-A%4*8&255;T[b+A>>>2]|=R<<24-(b+A)%4*8}else for(var O=0;O<C;O+=4)T[b+O>>>2]=w[O>>>2];return this.sigBytes+=C,this},clamp:function(){var E=this.words,T=this.sigBytes;E[T>>>2]&=4294967295<<32-T%4*8,E.length=r.ceil(T/4)},clone:function(){var E=u.clone.call(this);return E.words=this.words.slice(0),E},random:function(E){for(var T=[],w=0;w<E;w+=4)T.push(a());return new h.init(T,E)}}),d=l.enc={},p=d.Hex={stringify:function(E){for(var T=E.words,w=E.sigBytes,b=[],C=0;C<w;C++){var A=T[C>>>2]>>>24-C%4*8&255;b.push((A>>>4).toString(16)),b.push((A&15).toString(16))}return b.join("")},parse:function(E){for(var T=E.length,w=[],b=0;b<T;b+=2)w[b>>>3]|=parseInt(E.substr(b,2),16)<<24-b%8*4;return new h.init(w,T/2)}},f=d.Latin1={stringify:function(E){for(var T=E.words,w=E.sigBytes,b=[],C=0;C<w;C++){var A=T[C>>>2]>>>24-C%4*8&255;b.push(String.fromCharCode(A))}return b.join("")},parse:function(E){for(var T=E.length,w=[],b=0;b<T;b++)w[b>>>2]|=(E.charCodeAt(b)&255)<<24-b%4*8;return new h.init(w,T)}},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 T,w=this._data,b=w.words,C=w.sigBytes,A=this.blockSize,R=A*4,O=C/R;E?O=r.ceil(O):O=r.max((O|0)-this._minBufferSize,0);var M=O*A,k=r.min(M*4,C);if(M){for(var G=0;G<M;G+=A)this._doProcessBlock(b,G);T=b.splice(0,M),w.sigBytes-=k}return new h.init(T,k)},clone:function(){var E=u.clone.call(this);return E._data=this._data.clone(),E},_minBufferSize:0}),x=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 T=this._doFinalize();return T},blockSize:512/32,_createHelper:function(E){return function(T,w){return new E.init(w).finalize(T)}},_createHmacHelper:function(E){return function(T,w){return new y.HMAC.init(E,w).finalize(T)}}}),y=l.algo={};return l})(Math);return i})}),sx=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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})}),y8=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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})}),b8=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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})}),rp=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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,x=u[f+2>>>2]>>>24-(f+2)%4*8&255,y=m<<16|g<<8|x,E=0;E<4&&f+E*.75<h;E++)p.push(d.charAt(y>>>6*(3-E)&63));var T=d.charAt(64);if(T)for(;p.length%4;)p.push(T);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,x=m|g;d[p>>>2]|=x<<24-p%4*8,p++}return s.create(d,p)}})(),i.enc.Base64})}),x8=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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,x=h[m+1>>>2]>>>24-(m+1)%4*8&255,y=h[m+2>>>2]>>>24-(m+2)%4*8&255,E=g<<16|x<<8|y,T=0;T<4&&m+T*.75<d;T++)f.push(p.charAt(E>>>6*(3-T)&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,x=m|g;d[p>>>2]|=x<<24-p%4*8,p++}return s.create(d,p)}})(),i.enc.Base64url})}),np=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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 x=0;x<16;x++){var y=g+x,E=m[y];m[y]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360}var T=this._hash.words,w=m[g+0],b=m[g+1],C=m[g+2],A=m[g+3],R=m[g+4],O=m[g+5],M=m[g+6],k=m[g+7],G=m[g+8],H=m[g+9],q=m[g+10],I=m[g+11],N=m[g+12],v=m[g+13],L=m[g+14],_=m[g+15],B=T[0],U=T[1],z=T[2],W=T[3];B=h(B,U,z,W,w,7,c[0]),W=h(W,B,U,z,b,12,c[1]),z=h(z,W,B,U,C,17,c[2]),U=h(U,z,W,B,A,22,c[3]),B=h(B,U,z,W,R,7,c[4]),W=h(W,B,U,z,O,12,c[5]),z=h(z,W,B,U,M,17,c[6]),U=h(U,z,W,B,k,22,c[7]),B=h(B,U,z,W,G,7,c[8]),W=h(W,B,U,z,H,12,c[9]),z=h(z,W,B,U,q,17,c[10]),U=h(U,z,W,B,I,22,c[11]),B=h(B,U,z,W,N,7,c[12]),W=h(W,B,U,z,v,12,c[13]),z=h(z,W,B,U,L,17,c[14]),U=h(U,z,W,B,_,22,c[15]),B=d(B,U,z,W,b,5,c[16]),W=d(W,B,U,z,M,9,c[17]),z=d(z,W,B,U,I,14,c[18]),U=d(U,z,W,B,w,20,c[19]),B=d(B,U,z,W,O,5,c[20]),W=d(W,B,U,z,q,9,c[21]),z=d(z,W,B,U,_,14,c[22]),U=d(U,z,W,B,R,20,c[23]),B=d(B,U,z,W,H,5,c[24]),W=d(W,B,U,z,L,9,c[25]),z=d(z,W,B,U,A,14,c[26]),U=d(U,z,W,B,G,20,c[27]),B=d(B,U,z,W,v,5,c[28]),W=d(W,B,U,z,C,9,c[29]),z=d(z,W,B,U,k,14,c[30]),U=d(U,z,W,B,N,20,c[31]),B=p(B,U,z,W,O,4,c[32]),W=p(W,B,U,z,G,11,c[33]),z=p(z,W,B,U,I,16,c[34]),U=p(U,z,W,B,L,23,c[35]),B=p(B,U,z,W,b,4,c[36]),W=p(W,B,U,z,R,11,c[37]),z=p(z,W,B,U,k,16,c[38]),U=p(U,z,W,B,q,23,c[39]),B=p(B,U,z,W,v,4,c[40]),W=p(W,B,U,z,w,11,c[41]),z=p(z,W,B,U,A,16,c[42]),U=p(U,z,W,B,M,23,c[43]),B=p(B,U,z,W,H,4,c[44]),W=p(W,B,U,z,N,11,c[45]),z=p(z,W,B,U,_,16,c[46]),U=p(U,z,W,B,C,23,c[47]),B=f(B,U,z,W,w,6,c[48]),W=f(W,B,U,z,k,10,c[49]),z=f(z,W,B,U,L,15,c[50]),U=f(U,z,W,B,O,21,c[51]),B=f(B,U,z,W,N,6,c[52]),W=f(W,B,U,z,A,10,c[53]),z=f(z,W,B,U,q,15,c[54]),U=f(U,z,W,B,b,21,c[55]),B=f(B,U,z,W,G,6,c[56]),W=f(W,B,U,z,_,10,c[57]),z=f(z,W,B,U,M,15,c[58]),U=f(U,z,W,B,v,21,c[59]),B=f(B,U,z,W,R,6,c[60]),W=f(W,B,U,z,I,10,c[61]),z=f(z,W,B,U,C,15,c[62]),U=f(U,z,W,B,H,21,c[63]),T[0]=T[0]+B|0,T[1]=T[1]+U|0,T[2]=T[2]+z|0,T[3]=T[3]+W|0},_doFinalize:function(){var m=this._data,g=m.words,x=this._nDataBytes*8,y=m.sigBytes*8;g[y>>>5]|=128<<24-y%32;var E=r.floor(x/4294967296),T=x;g[(y+64>>>9<<4)+15]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,g[(y+64>>>9<<4)+14]=(T<<8|T>>>24)&16711935|(T<<24|T>>>8)&4278255360,m.sigBytes=(g.length+1)*4,this._process();for(var w=this._hash,b=w.words,C=0;C<4;C++){var A=b[C];b[C]=(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,x,y,E,T,w){var b=m+(g&x|~g&y)+E+w;return(b<<T|b>>>32-T)+g}function d(m,g,x,y,E,T,w){var b=m+(g&y|x&~y)+E+w;return(b<<T|b>>>32-T)+g}function p(m,g,x,y,E,T,w){var b=m+(g^x^y)+E+w;return(b<<T|b>>>32-T)+g}function f(m,g,x,y,E,T,w){var b=m+(x^(g|~y))+E+w;return(b<<T|b>>>32-T)+g}n.MD5=o._createHelper(u),n.HmacMD5=o._createHmacHelper(u)})(Math),i.MD5})}),h_=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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],x=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 T=(p<<5|p>>>27)+x+l[y];y<20?T+=(f&m|~f&g)+1518500249:y<40?T+=(f^m^g)+1859775393:y<60?T+=(f&m|f&g|m&g)-1894007588:T+=(f^m^g)-899497514,x=g,g=m,m=f<<30|f>>>2,f=p,p=T}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]+x|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})}),qS=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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(x){for(var y=r.sqrt(x),E=2;E<=y;E++)if(!(x%E))return!1;return!0}function f(x){return(x-(x|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],x=m[1],y=m[2],E=m[3],T=m[4],w=m[5],b=m[6],C=m[7],A=0;A<64;A++){if(A<16)h[A]=p[f+A]|0;else{var R=h[A-15],O=(R<<25|R>>>7)^(R<<14|R>>>18)^R>>>3,M=h[A-2],k=(M<<15|M>>>17)^(M<<13|M>>>19)^M>>>10;h[A]=O+h[A-7]+k+h[A-16]}var G=T&w^~T&b,H=g&x^g&y^x&y,q=(g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22),I=(T<<26|T>>>6)^(T<<21|T>>>11)^(T<<7|T>>>25),N=C+I+G+u[A]+h[A],v=q+H;C=b,b=w,w=T,T=E+N|0,E=y,y=x,x=g,g=N+v|0}m[0]=m[0]+g|0,m[1]=m[1]+x|0,m[2]=m[2]+y|0,m[3]=m[3]+E|0,m[4]=m[4]+T|0,m[5]=m[5]+w|0,m[6]=m[6]+b|0,m[7]=m[7]+C|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})}),E8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),qS()):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})}),d_=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),sx()):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,x=g[0],y=g[1],E=g[2],T=g[3],w=g[4],b=g[5],C=g[6],A=g[7],R=x.high,O=x.low,M=y.high,k=y.low,G=E.high,H=E.low,q=T.high,I=T.low,N=w.high,v=w.low,L=b.high,_=b.low,B=C.high,U=C.low,z=A.high,W=A.low,ne=R,me=O,Ee=M,Se=k,Fe=G,Ne=H,it=q,je=I,It=N,Ht=v,Ri=L,Ci=_,ze=B,D=U,j=z,Z=W,K=0;K<80;K++){var ee,ge,le=d[K];if(K<16)ge=le.high=f[m+K*2]|0,ee=le.low=f[m+K*2+1]|0;else{var ke=d[K-15],rt=ke.high,gt=ke.low,et=(rt>>>1|gt<<31)^(rt>>>8|gt<<24)^rt>>>7,si=(gt>>>1|rt<<31)^(gt>>>8|rt<<24)^(gt>>>7|rt<<25),ji=d[K-2],tr=ji.high,Li=ji.low,Sn=(tr>>>19|Li<<13)^(tr<<3|Li>>>29)^tr>>>6,Ar=(Li>>>19|tr<<13)^(Li<<3|tr>>>29)^(Li>>>6|tr<<26),Sr=d[K-7],vn=Sr.high,na=Sr.low,Wt=d[K-16],ur=Wt.high,ht=Wt.low;ee=si+na,ge=et+vn+(ee>>>0<si>>>0?1:0),ee=ee+Ar,ge=ge+Sn+(ee>>>0<Ar>>>0?1:0),ee=ee+ht,ge=ge+ur+(ee>>>0<ht>>>0?1:0),le.high=ge,le.low=ee}var an=It&Ri^~It&ze,$n=Ht&Ci^~Ht&D,ai=ne&Ee^ne&Fe^Ee&Fe,wi=me&Se^me&Ne^Se&Ne,xn=(ne>>>28|me<<4)^(ne<<30|me>>>2)^(ne<<25|me>>>7),sa=(me>>>28|ne<<4)^(me<<30|ne>>>2)^(me<<25|ne>>>7),Pu=(It>>>14|Ht<<18)^(It>>>18|Ht<<14)^(It<<23|Ht>>>9),sf=(Ht>>>14|It<<18)^(Ht>>>18|It<<14)^(Ht<<23|It>>>9),vh=h[K],Fc=vh.high,dl=vh.low,Cr=Z+sf,Zn=j+Pu+(Cr>>>0<Z>>>0?1:0),Cr=Cr+$n,Zn=Zn+an+(Cr>>>0<$n>>>0?1:0),Cr=Cr+dl,Zn=Zn+Fc+(Cr>>>0<dl>>>0?1:0),Cr=Cr+ee,Zn=Zn+ge+(Cr>>>0<ee>>>0?1:0),Bd=sa+wi,Og=xn+ai+(Bd>>>0<sa>>>0?1:0);j=ze,Z=D,ze=Ri,D=Ci,Ri=It,Ci=Ht,Ht=je+Cr|0,It=it+Zn+(Ht>>>0<je>>>0?1:0)|0,it=Fe,je=Ne,Fe=Ee,Ne=Se,Ee=ne,Se=me,me=Cr+Bd|0,ne=Zn+Og+(me>>>0<Cr>>>0?1:0)|0}O=x.low=O+me,x.high=R+ne+(O>>>0<me>>>0?1:0),k=y.low=k+Se,y.high=M+Ee+(k>>>0<Se>>>0?1:0),H=E.low=H+Ne,E.high=G+Fe+(H>>>0<Ne>>>0?1:0),I=T.low=I+je,T.high=q+it+(I>>>0<je>>>0?1:0),v=w.low=v+Ht,w.high=N+It+(v>>>0<Ht>>>0?1:0),_=b.low=_+Ci,b.high=L+Ri+(_>>>0<Ci>>>0?1:0),U=C.low=U+D,C.high=B+ze+(U>>>0<D>>>0?1:0),W=A.low=W+Z,A.high=z+j+(W>>>0<Z>>>0?1:0)},_doFinalize:function(){var f=this._data,m=f.words,g=this._nDataBytes*8,x=f.sigBytes*8;m[x>>>5]|=128<<24-x%32,m[(x+128>>>10<<5)+30]=Math.floor(g/4294967296),m[(x+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})}),T8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),sx(),d_()):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})}),w8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),sx()):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,x=0,y=0;y<24;y++){h[g+5*x]=(y+1)*(y+2)/2%64;var E=x%5,T=(2*g+3*x)%5;g=E,x=T}for(var g=0;g<5;g++)for(var x=0;x<5;x++)d[g+5*x]=x+(2*g+3*x)%5*5;for(var w=1,b=0;b<24;b++){for(var C=0,A=0,R=0;R<7;R++){if(w&1){var O=(1<<R)-1;O<32?A^=1<<O:C^=1<<O-32}w&128?w=w<<1^113:w<<=1}p[b]=c.create(C,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=[],x=0;x<25;x++)g[x]=new c.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(g,x){for(var y=this._state,E=this.blockSize/2,T=0;T<E;T++){var w=g[x+2*T],b=g[x+2*T+1];w=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360,b=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;var C=y[T];C.high^=b,C.low^=w}for(var A=0;A<24;A++){for(var R=0;R<5;R++){for(var O=0,M=0,k=0;k<5;k++){var C=y[R+5*k];O^=C.high,M^=C.low}var G=f[R];G.high=O,G.low=M}for(var R=0;R<5;R++)for(var H=f[(R+4)%5],q=f[(R+1)%5],I=q.high,N=q.low,O=H.high^(I<<1|N>>>31),M=H.low^(N<<1|I>>>31),k=0;k<5;k++){var C=y[R+5*k];C.high^=O,C.low^=M}for(var v=1;v<25;v++){var O,M,C=y[v],L=C.high,_=C.low,B=h[v];B<32?(O=L<<B|_>>>32-B,M=_<<B|L>>>32-B):(O=_<<B-32|L>>>64-B,M=L<<B-32|_>>>64-B);var U=f[d[v]];U.high=O,U.low=M}var z=f[0],W=y[0];z.high=W.high,z.low=W.low;for(var R=0;R<5;R++)for(var k=0;k<5;k++){var v=R+5*k,C=y[v],ne=f[v],me=f[(R+1)%5+5*k],Ee=f[(R+2)%5+5*k];C.high=ne.high^~me.high&Ee.high,C.low=ne.low^~me.low&Ee.low}var C=y[0],Se=p[A];C.high^=Se.high,C.low^=Se.low}},_doFinalize:function(){var g=this._data,x=g.words,y=this._nDataBytes*8,E=g.sigBytes*8,T=this.blockSize*32;x[E>>>5]|=1<<24-E%32,x[(r.ceil((E+1)/T)*T>>>5)-1]|=128,g.sigBytes=x.length*4,this._process();for(var w=this._state,b=this.cfg.outputLength/8,C=b/8,A=[],R=0;R<C;R++){var O=w[R],M=O.high,k=O.low;M=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360,k=(k<<8|k>>>24)&16711935|(k<<24|k>>>8)&4278255360,A.push(k),A.push(M)}return new a.init(A,b)},clone:function(){for(var g=o.clone.call(this),x=g._state=this._state.slice(0),y=0;y<25;y++)x[y]=x[y].clone();return g}});n.SHA3=o._createHelper(m),n.HmacSHA3=o._createHmacHelper(m)})(Math),i.SHA3})}),S8=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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(b,C){for(var A=0;A<16;A++){var R=C+A,O=b[R];b[R]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360}var M=this._hash.words,k=p.words,G=f.words,H=c.words,q=u.words,I=h.words,N=d.words,v,L,_,B,U,z,W,ne,me,Ee;z=v=M[0],W=L=M[1],ne=_=M[2],me=B=M[3],Ee=U=M[4];for(var Se,A=0;A<80;A+=1)Se=v+b[C+H[A]]|0,A<16?Se+=g(L,_,B)+k[0]:A<32?Se+=x(L,_,B)+k[1]:A<48?Se+=y(L,_,B)+k[2]:A<64?Se+=E(L,_,B)+k[3]:Se+=T(L,_,B)+k[4],Se=Se|0,Se=w(Se,I[A]),Se=Se+U|0,v=U,U=B,B=w(_,10),_=L,L=Se,Se=z+b[C+q[A]]|0,A<16?Se+=T(W,ne,me)+G[0]:A<32?Se+=E(W,ne,me)+G[1]:A<48?Se+=y(W,ne,me)+G[2]:A<64?Se+=x(W,ne,me)+G[3]:Se+=g(W,ne,me)+G[4],Se=Se|0,Se=w(Se,N[A]),Se=Se+Ee|0,z=Ee,Ee=me,me=w(ne,10),ne=W,W=Se;Se=M[1]+_+me|0,M[1]=M[2]+B+Ee|0,M[2]=M[3]+U+z|0,M[3]=M[4]+v+W|0,M[4]=M[0]+L+ne|0,M[0]=Se},_doFinalize:function(){var b=this._data,C=b.words,A=this._nDataBytes*8,R=b.sigBytes*8;C[R>>>5]|=128<<24-R%32,C[(R+64>>>9<<4)+14]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,b.sigBytes=(C.length+1)*4,this._process();for(var O=this._hash,M=O.words,k=0;k<5;k++){var G=M[k];M[k]=(G<<8|G>>>24)&16711935|(G<<24|G>>>8)&4278255360}return O},clone:function(){var b=o.clone.call(this);return b._hash=this._hash.clone(),b}});function g(b,C,A){return b^C^A}function x(b,C,A){return b&C|~b&A}function y(b,C,A){return(b|~C)^A}function E(b,C,A){return b&A|C&~A}function T(b,C,A){return b^(C|~A)}function w(b,C){return b<<C|b>>>32-C}n.RIPEMD160=o._createHelper(m),n.HmacRIPEMD160=o._createHmacHelper(m)})(Math),i.RIPEMD160})}),JS=qi((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ar()):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,x=m.words,y=0;y<d;y++)g[y]^=1549556828,x[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}})})()})}),v8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),qS(),JS()):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]),x=m.words,y=g.words,E=p.keySize,T=p.iterations;x.length<E;){var w=f.update(d).finalize(g);f.reset();for(var b=w.words,C=b.length,A=w,R=1;R<T;R++){A=f.finalize(A),f.reset();for(var O=A.words,M=0;M<C;M++)b[M]^=O[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})}),jh=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),h_(),JS()):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,x=p.keySize,y=p.iterations;g.length<x;){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=x*4,m}});r.EvpKDF=function(u,h,d){return c.create(d).compute(u,h)}})(),i.EvpKDF})}),Ws=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),jh()):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,H){return this.create(this._ENC_XFORM_MODE,G,H)},createDecryptor:function(G,H){return this.create(this._DEC_XFORM_MODE,G,H)},init:function(G,H,q){this.cfg=this.cfg.extend(q),this._xformMode=G,this._key=H,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 H=this._doFinalize();return H},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:(function(){function G(H){return typeof H=="string"?k:R}return function(H){return{encrypt:function(q,I,N){return G(I).encrypt(H,q,I,N)},decrypt:function(q,I,N){return G(I).decrypt(H,q,I,N)}}}})()}),m=s.StreamCipher=f.extend({_doFinalize:function(){var G=this._process(!0);return G},blockSize:1}),g=n.mode={},x=s.BlockCipherMode=a.extend({createEncryptor:function(G,H){return this.Encryptor.create(G,H)},createDecryptor:function(G,H){return this.Decryptor.create(G,H)},init:function(G,H){this._cipher=G,this._iv=H}}),y=g.CBC=(function(){var G=x.extend();G.Encryptor=G.extend({processBlock:function(q,I){var N=this._cipher,v=N.blockSize;H.call(this,q,I,v),N.encryptBlock(q,I),this._prevBlock=q.slice(I,I+v)}}),G.Decryptor=G.extend({processBlock:function(q,I){var N=this._cipher,v=N.blockSize,L=q.slice(I,I+v);N.decryptBlock(q,I),H.call(this,q,I,v),this._prevBlock=L}});function H(q,I,N){var v,L=this._iv;L?(v=L,this._iv=r):v=this._prevBlock;for(var _=0;_<N;_++)q[I+_]^=v[_]}return G})(),E=n.pad={},T=E.Pkcs7={pad:function(G,H){for(var q=H*4,I=q-G.sigBytes%q,N=I<<24|I<<16|I<<8|I,v=[],L=0;L<I;L+=4)v.push(N);var _=o.create(v,I);G.concat(_)},unpad:function(G){var H=G.words[G.sigBytes-1>>>2]&255;G.sigBytes-=H}},w=s.BlockCipher=f.extend({cfg:f.cfg.extend({mode:y,padding:T}),reset:function(){var G;f.reset.call(this);var H=this.cfg,q=H.iv,I=H.mode;this._xformMode==this._ENC_XFORM_MODE?G=I.createEncryptor:(G=I.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==G?this._mode.init(this,q&&q.words):(this._mode=G.call(I,this,q&&q.words),this._mode.__creator=G)},_doProcessBlock:function(G,H){this._mode.processBlock(G,H)},_doFinalize:function(){var G,H=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(H.pad(this._data,this.blockSize),G=this._process(!0)):(G=this._process(!0),H.unpad(G)),G},blockSize:128/32}),b=s.CipherParams=a.extend({init:function(G){this.mixIn(G)},toString:function(G){return(G||this.formatter).stringify(this)}}),C=n.format={},A=C.OpenSSL={stringify:function(G){var H,q=G.ciphertext,I=G.salt;return I?H=o.create([1398893684,1701076831]).concat(I).concat(q):H=q,H.toString(h)},parse:function(G){var H,q=h.parse(G),I=q.words;return I[0]==1398893684&&I[1]==1701076831&&(H=o.create(I.slice(2,4)),I.splice(0,4),q.sigBytes-=16),b.create({ciphertext:q,salt:H})}},R=s.SerializableCipher=a.extend({cfg:a.extend({format:A}),encrypt:function(G,H,q,I){I=this.cfg.extend(I);var N=G.createEncryptor(q,I),v=N.finalize(H),L=N.cfg;return b.create({ciphertext:v,key:q,iv:L.iv,algorithm:G,mode:L.mode,padding:L.padding,blockSize:G.blockSize,formatter:I.format})},decrypt:function(G,H,q,I){I=this.cfg.extend(I),H=this._parse(H,I.format);var N=G.createDecryptor(q,I).finalize(H.ciphertext);return N},_parse:function(G,H){return typeof G=="string"?H.parse(G,this):G}}),O=n.kdf={},M=O.OpenSSL={execute:function(G,H,q,I,N){if(I||(I=o.random(64/8)),N)var v=p.create({keySize:H+q,hasher:N}).compute(G,I);else var v=p.create({keySize:H+q}).compute(G,I);var L=o.create(v.words.slice(H),q*4);return v.sigBytes=H*4,b.create({key:v,iv:L,salt:I})}},k=s.PasswordBasedCipher=R.extend({cfg:R.cfg.extend({kdf:M}),encrypt:function(G,H,q,I){I=this.cfg.extend(I);var N=I.kdf.execute(q,G.keySize,G.ivSize,I.salt,I.hasher);I.iv=N.iv;var v=R.encrypt.call(this,G,H,N.key,I);return v.mixIn(N),v},decrypt:function(G,H,q,I){I=this.cfg.extend(I),H=this._parse(H,I.format);var N=I.kdf.execute(q,G.keySize,G.ivSize,H.salt,I.hasher);I.iv=N.iv;var v=R.decrypt.call(this,G,H,N.key,I);return v}})})()})}),I8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),A8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),C8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),D8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),P8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),_8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),L8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),O8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),R8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),N8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),M8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),Ws()):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})}),B8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),rp(),np(),jh(),Ws()):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=[],T=0;T<256;T++)T<128?E[T]=T<<1:E[T]=T<<1^283;for(var w=0,b=0,T=0;T<256;T++){var C=b^b<<1^b<<2^b<<3^b<<4;C=C>>>8^C&255^99,o[w]=C,l[C]=w;var A=E[w],R=E[A],O=E[R],M=E[C]*257^C*16843008;c[w]=M<<24|M>>>8,u[w]=M<<16|M>>>16,h[w]=M<<8|M>>>24,d[w]=M;var M=O*16843009^R*65537^A*257^w*16843008;p[C]=M<<24|M>>>8,f[C]=M<<16|M>>>16,m[C]=M<<8|M>>>24,g[C]=M,w?(w=A^E[E[E[O^A]]],b^=E[E[b]]):w=b=1}})();var x=[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 T=this._keyPriorReset=this._key,w=T.words,b=T.sigBytes/4,C=this._nRounds=b+6,A=(C+1)*4,R=this._keySchedule=[],O=0;O<A;O++)O<b?R[O]=w[O]:(E=R[O-1],O%b?b>6&&O%b==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^=x[O/b|0]<<24),R[O]=R[O-b]^E);for(var M=this._invKeySchedule=[],k=0;k<A;k++){var O=A-k;if(k%4)var E=R[O];else var E=R[O-4];k<4||O<=4?M[k]=E:M[k]=p[o[E>>>24]]^f[o[E>>>16&255]]^m[o[E>>>8&255]]^g[o[E&255]]}}},encryptBlock:function(E,T){this._doCryptBlock(E,T,this._keySchedule,c,u,h,d,o)},decryptBlock:function(E,T){var w=E[T+1];E[T+1]=E[T+3],E[T+3]=w,this._doCryptBlock(E,T,this._invKeySchedule,p,f,m,g,l);var w=E[T+1];E[T+1]=E[T+3],E[T+3]=w},_doCryptBlock:function(E,T,w,b,C,A,R,O){for(var M=this._nRounds,k=E[T]^w[0],G=E[T+1]^w[1],H=E[T+2]^w[2],q=E[T+3]^w[3],I=4,N=1;N<M;N++){var v=b[k>>>24]^C[G>>>16&255]^A[H>>>8&255]^R[q&255]^w[I++],L=b[G>>>24]^C[H>>>16&255]^A[q>>>8&255]^R[k&255]^w[I++],_=b[H>>>24]^C[q>>>16&255]^A[k>>>8&255]^R[G&255]^w[I++],B=b[q>>>24]^C[k>>>16&255]^A[G>>>8&255]^R[H&255]^w[I++];k=v,G=L,H=_,q=B}var v=(O[k>>>24]<<24|O[G>>>16&255]<<16|O[H>>>8&255]<<8|O[q&255])^w[I++],L=(O[G>>>24]<<24|O[H>>>16&255]<<16|O[q>>>8&255]<<8|O[k&255])^w[I++],_=(O[H>>>24]<<24|O[q>>>16&255]<<16|O[k>>>8&255]<<8|O[G&255])^w[I++],B=(O[q>>>24]<<24|O[k>>>16&255]<<16|O[G>>>8&255]<<8|O[H&255])^w[I++];E[T]=v,E[T+1]=L,E[T+2]=_,E[T+3]=B},keySize:256/32});r.AES=s._createHelper(y)})(),i.AES})}),k8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),rp(),np(),jh(),Ws()):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 x=this._key,y=x.words,E=[],T=0;T<56;T++){var w=l[T]-1;E[T]=y[w>>>5]>>>31-w%32&1}for(var b=this._subKeys=[],C=0;C<16;C++){for(var A=b[C]=[],R=u[C],T=0;T<24;T++)A[T/6|0]|=E[(c[T]-1+R)%28]<<31-T%6,A[4+(T/6|0)]|=E[28+(c[T+24]-1+R)%28]<<31-T%6;A[0]=A[0]<<1|A[0]>>>31;for(var T=1;T<7;T++)A[T]=A[T]>>>(T-1)*4+3;A[7]=A[7]<<5|A[7]>>>27}for(var O=this._invSubKeys=[],T=0;T<16;T++)O[T]=b[15-T]},encryptBlock:function(x,y){this._doCryptBlock(x,y,this._subKeys)},decryptBlock:function(x,y){this._doCryptBlock(x,y,this._invSubKeys)},_doCryptBlock:function(x,y,E){this._lBlock=x[y],this._rBlock=x[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 T=0;T<16;T++){for(var w=E[T],b=this._lBlock,C=this._rBlock,A=0,R=0;R<8;R++)A|=h[R][((C^w[R])&d[R])>>>0];this._lBlock=C,this._rBlock=b^A}var O=this._lBlock;this._lBlock=this._rBlock,this._rBlock=O,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),x[y]=this._lBlock,x[y+1]=this._rBlock},keySize:64/32,ivSize:64/32,blockSize:64/32});function f(x,y){var E=(this._lBlock>>>x^this._rBlock)&y;this._rBlock^=E,this._lBlock^=E<<x}function m(x,y){var E=(this._rBlock>>>x^this._lBlock)&y;this._lBlock^=E,this._rBlock^=E<<x}r.DES=a._createHelper(p);var g=o.TripleDES=a.extend({_doReset:function(){var x=this._key,y=x.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),T=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(T)),this._des3=p.createEncryptor(s.create(w))},encryptBlock:function(x,y){this._des1.encryptBlock(x,y),this._des2.decryptBlock(x,y),this._des3.encryptBlock(x,y)},decryptBlock:function(x,y){this._des3.decryptBlock(x,y),this._des2.encryptBlock(x,y),this._des1.decryptBlock(x,y)},keySize:192/32,ivSize:64/32,blockSize:64/32});r.TripleDES=a._createHelper(g)})(),i.TripleDES})}),F8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),rp(),np(),jh(),Ws()):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,x=h[g>>>2]>>>24-g%4*8&255;m=(m+p[f]+x)%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})}),G8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),rp(),np(),jh(),Ws()):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 x=p.words,y=x[0],E=x[1],T=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360,w=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,b=T>>>16|w&4294901760,C=w<<16|T&65535;g[0]^=T,g[1]^=b,g[2]^=w,g[3]^=C,g[4]^=T,g[5]^=b,g[6]^=w,g[7]^=C;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,x=m>>>16,y=((g*g>>>17)+g*x>>>15)+x*x,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})}),U8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),rp(),np(),jh(),Ws()):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 x=p.words,y=x[0],E=x[1],T=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360,w=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,b=T>>>16|w&4294901760,C=w<<16|T&65535;m[0]^=T,m[1]^=b,m[2]^=w,m[3]^=C,m[4]^=T,m[5]^=b,m[6]^=w,m[7]^=C;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,x=m>>>16,y=((g*g>>>17)+g*x>>>15)+x*x,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})}),Y8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),rp(),np(),jh(),Ws()):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,x){let y=x>>24&255,E=x>>16&255,T=x>>8&255,w=x&255,b=g.sbox[0][y]+g.sbox[1][E];return b=b^g.sbox[2][T],b=b+g.sbox[3][w],b}function d(g,x,y){let E=x,T=y,w;for(let b=0;b<o;++b)E=E^g.pbox[b],T=h(g,E)^T,w=E,E=T,T=w;return w=E,E=T,T=w,T=T^g.pbox[o],E=E^g.pbox[o+1],{left:E,right:T}}function p(g,x,y){let E=x,T=y,w;for(let b=o+1;b>1;--b)E=E^g.pbox[b],T=h(g,E)^T,w=E,E=T,T=w;return w=E,E=T,T=w,T=T^g.pbox[1],E=E^g.pbox[0],{left:E,right:T}}function f(g,x,y){for(let C=0;C<4;C++){g.sbox[C]=[];for(let A=0;A<256;A++)g.sbox[C][A]=c[C][A]}let E=0;for(let C=0;C<o+2;C++)g.pbox[C]=l[C]^x[E],E++,E>=y&&(E=0);let T=0,w=0,b=0;for(let C=0;C<o+2;C+=2)b=d(g,T,w),T=b.left,w=b.right,g.pbox[C]=T,g.pbox[C+1]=w;for(let C=0;C<4;C++)for(let A=0;A<256;A+=2)b=d(g,T,w),T=b.left,w=b.right,g.sbox[C][A]=T,g.sbox[C][A+1]=w;return!0}var m=a.Blowfish=s.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var g=this._keyPriorReset=this._key,x=g.words,y=g.sigBytes/4;f(u,x,y)}},encryptBlock:function(g,x){var y=d(u,g[x],g[x+1]);g[x]=y.left,g[x+1]=y.right},decryptBlock:function(g,x){var y=p(u,g[x],g[x+1]);g[x]=y.left,g[x+1]=y.right},blockSize:64/32,keySize:128/32,ivSize:64/32});r.Blowfish=s._createHelper(m)})(),i.Blowfish})}),H8=qi((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(ar(),sx(),y8(),b8(),rp(),x8(),np(),h_(),qS(),E8(),d_(),T8(),w8(),S8(),JS(),v8(),jh(),Ws(),I8(),A8(),C8(),D8(),P8(),_8(),L8(),O8(),R8(),N8(),M8(),B8(),k8(),F8(),G8(),U8(),Y8()):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})}),j8=(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))(j8||{}),n0=(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))(n0||{}),V8=(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))(V8||{});function s0(e,t,i){return e.slice(t,i)}function Fb(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=s0(e,n,s);try{if(a){let o=a.indexOf("||"),l=o>-1,c=l?s0(a,0,o):a,u=l?s0(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 z8=["SYMBOL","FOOTPRINT","BLOB","FONT","PANEL_LIB","DEVICE","BOARD","INSTANCE","CONFIG","VARIANT","COMPONENT_GROUP","COMPONENT_GROUP_DATA"];function kw(e,t){return z8.includes(t)?t:e}var X8=class{parseFull(e,t,i){let r=t,n=i,s,a=null;Fb(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},x=E=>{if(m.add(s),!t)return;let T=kw(s,a);p[T].data.push(E),p[T].size+=(p[T].size?2:0)+E.length,p[T].size+E.length>i&&g(T)},y=(E,T)=>Fb(E,(w,b,C,A)=>{var R,O,M,k,G,H,q,I;let N=JSON.parse(w);if(N.type==="EDIT_HEAD")l=JSON.parse(b),(R=this.onEditHead)==null||R.call(this,l),(O=e.onEditHead)==null||O.call(e,l),d=!0;else if(N.type==="DOCHEAD"){let v=JSON.parse(b);a=v.docType,s=v.uuid,o=v.client,v.ticket=N.ticket,d||(l={uuid:v.uuid,username:(M=v==null?void 0:v.user)==null?void 0:M.username,nickname:(k=v==null?void 0:v.user)==null?void 0:k.nickname,updateTime:v==null?void 0:v.updateTime},(G=e.onEditHead)==null||G.call(e,l),d=!0),this.onDocHead(v,l,C);let L=kw(s,a);t&&!p[L]&&(p[L]={size:0,data:[],head:""}),t&&(p[L].head=C),x(C)}else{let v=N.num,L=N.client||o;if(r){let _=(I=(q=(H=r.ids)==null?void 0:H[s])==null?void 0:q[L])==null?void 0:I[N.id];if(!_||_[0]!==N.ticket)return;v=_[1],r.size-=1,delete r.ids[s][L][N.id]}if(n){let _=kw(s,a);t&&(n.dNum=(f==null?void 0:f[_])===void 0?0:(f==null?void 0:f[_])+1),n.start=t?p[_].size+2+w.length+2:h+A}this.onLine(N.id,N.ticket,b,N.type,L,a,s,N.firstTicket,N.pend,l||(n==null?void 0:n.editHead),v,C,n),x(C)}},T);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 T=y(u+E,!0);h=h+u.length+E.length-((T==null?void 0:T.length)||0),u="",T&&(u=T)},docMap:f,getDocIds:()=>Array.from(m)}}parseLine(e,t,i){let r=e.indexOf("||"),n=r!==-1,s=n?s0(e,0,r):e,a=n?s0(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){}},Fw=new Uint8Array(8);function Il(){crypto.getRandomValues(Fw);let e="";for(let t=0;t<Fw.length;t++)e+=Fw[t].toString(16).padStart(2,"0");return e}function Kd(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 yo(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 p_=class extends X8{constructor(e){super(),this.unique=Il(),this.maxTicket=0,this.isPendChange=!0,this.isLocalChange=!0,this.cbArr=[],this.tempLocalIds={},this.docMaxTicket={},this.client=e||Il()}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 Il()}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,x=(!g||g&&this.isLocalChange)&&(!d||d&&this.isPendChange),y=(f=this.tempLocalIds[i])==null?void 0:f[r];!o&&m?y?(x=!1,y[0]===t&&y[1]===e&&delete this.tempLocalIds[i][r]):x=!0:!o&&y&&(y[1]>e||y[1]===e&&y[0]>t?x=!1:delete this.tempLocalIds[i][r]),this.setDocMaxTicket(i,e,c),x&&this.cbArr.forEach(E=>E(i,r,n,s,t,e,l,c,void 0,d,h,p))}},W8=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}},q8=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 W8(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 KS=/^[a-zA-Z]+(\d+)$/;function c0(e){let t=e.match(KS);return t?Number(t[1]):null}function ki(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 js(e){return e&&typeof e=="number"&&!isNaN(e)?-e:e}function J8(e,t){let i=[];for(let r=0;r<e.length;r+=2){let n={x:e[r],y:t?js(e[r+1]):e[r+1]};i.push(n)}return i}function go(e,t){return JSON.stringify([t,e])}function _h(e){try{let t=JSON.parse(e);return typeof t=="string"?e:t[1]}catch{return e}}function Gw(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var K8=(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))(K8||{}),$8=(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))($8||{}),Z8=(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))(Z8||{}),Q8=["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"],dte=jf(T0()),e7=(e=>(e.SOLID="SOLID",e.SHORT_DASH="SHORT_DASH",e.DOT="DOT",e.DOT_DASH="DOT_DASH",e))(e7||{}),t7=(e=>(e.PRINT="PRINT",e.COVER="COVER",e.PRINT_AND_COVER="PRINT&COVER",e))(t7||{}),i7=(e=>(e.LEFT="LEFT",e.CENTER="CENTER",e.RIGHT="RIGHT",e))(i7||{}),r7=(e=>(e.TOP="TOP",e.MIDDLE="MIDDLE",e.BOTTOM="BOTTOM",e))(r7||{}),n7=(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))(n7||{}),s7=(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))(s7||{}),a7=(e=>(e.NONE="NONE",e.CLOCK="CLOCK",e.INVERTED="INVERTED",e.INVERTED_CLOCK="INVERTED_CLOCK",e))(a7||{}),o7=(e=>(e.NONE="NONE",e.GRID="GRID",e.OUTLETS="OUTLETS",e))(o7||{}),l7=(e=>(e.NONE="NONE",e.PUSH="PUSH",e.SURROUND="SURROUND",e.OBSTRUCT="OBSTRUCT",e.SURROUND_AND_PUSH="SURROUND&PUSH",e))(l7||{}),c7=(e=>(e.ELLIPSE="ELLIPSE",e.RECT="RECT",e.OVAL="OVAL",e.POLYGON="POLYGON",e))(c7||{}),u7=(e=>(e.ROUND="ROUND",e.RECT="RECT",e.SLOT="SLOT",e))(u7||{}),h7=(e=>(e.SOLID="SOLID",e.GRID_LINE="GRID_LINE",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e))(h7||{}),d7=(e=>(e.ALL="ALL",e.PAD="PAD",e.VIA="VIA",e))(d7||{}),p7=(e=>(e.NONE="NONE",e.SINGLE="SINGLE",e.ALL="ALL",e))(p7||{}),f7=(e=>(e.OPTIMIZA_OPEN="OPTIMIZA_OPEN",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(f7||{}),m7=(e=>(e.OPTIMIZA_STRONG="OPTIMIZA_STRONG",e.OPTIMIZA_WEAK="OPTIMIZA_WEAK",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(m7||{}),g7=(e=>(e.L45="L45",e.L90="L90",e.L="L",e.R45="R45",e.R90="R90",e.R="R",e))(g7||{}),y7=(e=>(e.NORMAL="NORMAL",e.BLIND="BLIND",e.SUTURE="SUTURE",e))(y7||{}),b7=(e=>(e.NORMAL="NORMAL",e.TEST="TEST",e.MARKER="MARKER",e))(b7||{}),x7=(e=>(e.DIVERGENCE="DIVERGENCE",e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(x7||{}),E7=(e=>(e.DOT="DOT",e.CENTER="CENT",e))(E7||{}),T7=(e=>(e.NORMAL="NORMAL",e.BOARD_OUTLINE="BOARD_OUTLINE",e))(T7||{}),w7=(e=>(e.SOLID="SOLID",e.GRID="GRID",e.PLANE="PLANE",e))(w7||{}),S7=(e=>(e.PROHIBIT="PROHIBIT",e.CONSTRAINT="CONSTRAINT",e))(S7||{}),v7=(e=>(e.COMPONENT="COMPONENT",e.VIA="VIA",e.TRACK="TRACK",e.FILL="FILL",e.COPPER="COPPER",e.PLANE="PLANE",e))(v7||{}),I7=(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))(I7||{}),A7=(e=>(e.PUSH_COVER="DRAWER",e.UPPER_LOWER_SHELLS="T&B",e))(A7||{}),C7=(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))(C7||{}),D7=(e=>(e.SLOT="SLOT",e.ENTITY="ENTITY",e))(D7||{}),P7=(e=>(e.AUTO="AUTO",e.UPPER_SHELLS="UPPER_SHELLS",e.LOWER_SHELLS="LOWER_SHELLS",e))(P7||{}),_7=(e=>(e.OUTLINE="OUTLINE",e.SCREW_PILLAR="SCREW_PILLAR",e.ENTITY="ENTITY",e))(_7||{}),L7=(e=>(e.M2="M2",e.M3="M3",e.M4="M4",e.M5="M5",e.M6="M6",e))(L7||{}),O7=(e=>(e.LENGTH="LENGTH",e.RADIUS="RADIUS",e.ANGLE="ANGLE",e))(O7||{}),R7=(e=>(e.MIL="mil",e.INCH="inch",e.CM="cm",e.MM="mm",e))(R7||{}),N7=(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))(N7||{}),M7=(e=>(e.NORMAL="NORMAL",e.DEFAULT="DEFAULT",e))(M7||{}),B7=(e=>(e.ALL="ALL",e.LAYERED="LAYERED",e))(B7||{}),k7=(e=>(e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(k7||{}),F7=(e=>(e.FORTY_FIVE="L45",e.NINETY="L90",e.NINETY_ARC="A90",e))(F7||{}),G7=(e=>(e.LESS="LESS",e.MID="MID",e.MORE="MORE",e))(G7||{}),U7=(e=>(e.SPEED_FIRST="SPEED_FIRST",e.COMPLETION_FIRST="COMPLETION_FIRST",e))(U7||{}),Y7=(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))(Y7||{}),H7=jf(H8());function bS(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 j7(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 ax(e){return H7.default.SHA256(e).toString()}function V7(e,t){let i=[],r=[],n={};Fb(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={};Fb(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 Uw(e,t,i){let{docType:r,uuid:n,client:s,updateTime:a,version:o,user:l,ticket:c}=i,u=[Kd(r,s,n,a,o,l,c)],{delete:h,cover:d,add:p,blobs:f,fonts:m}=V7(e,t);for(let g in h){let{ticket:x,type:y,client:E}=h[g];u.push(yo(y,x+1,g,"",E))}for(let g in d){let{type:x,ticket:y,data:E,client:T}=d[g];u.push(yo(x,y+1,g,E,T))}for(let g in p){let{type:x,ticket:y,data:E,client:T}=p[g];u.push(yo(x,y,g,E,T))}return f.length&&(u.push(Kd("BLOB",s,"BLOB",a,o,l,c)),u=u.concat(f)),m.length&&(u.push(Kd("FONT",s,"FONT",a,o,l,c)),u=u.concat(m)),u.join(`|
`)}function z7(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 X7=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=Gw(this.orderLists,t,()=>new q8(z7)),a=Gw(this.maxNum,t,()=>this.startNum-1),o=Gw(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]}},W7=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 X7(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 f_(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 vf(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[f_(i)]=r}return e}var eP=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 tP(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 q7(e,t){let i=e[0],r=e[1],n=[],s="ALL";if(r instanceof Array){let a=tP(r,t);n.push({layerId:1,isOpen:!0,content:a})}else{for(let a in r){let o=r[a],l=tP(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 J7(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 K7(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 $7(e){return{unit:e[0],netLenMin:e[1],netLenMax:e[2]}}function Z7(e){return{unit:e[0],netLengthTolerance:e[1]}}function Q7(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 e9(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 t9(e){return{unit:e[0],minRadius:e[1],defRadius:e[2],maxRadius:e[3],minInner:e[4],defInner:e[5],maxInner:e[6]}}function i9(e){let t=[{layerId:1,connType:Bf(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 r9(e){let t=[{layerId:1,connType:Bf(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:Bf(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 n9(e){return{unit:e[0],padTopExpan:e[1],padBotExpan:e[2],testPointTopExpan:e[3]?e[3]:-1e3,testPointBotExpan:e[4]?e[4]:-1e3}}function s9(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 a9(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 Bf(e){switch(e=e&&Number(e),e){case 0:return"DIVERGENCE";case 1:return"DIRECT";case 2:return"NON_CONNECT";default:return null}}function o9(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=Bf(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=Bf(n.connType);if(r.mulPad&&r.mulPad.content)for(let n of r.mulPad.content)n.connType=Bf(n.connType);i=r;break}case"PASTE":break;case"SOLDER":break;case"AUTO_ROUTER":break}return i}function l9(e,t,i,r,n,s){if(!(r instanceof Array))return o9(e,r);let a,o=!1;switch(i&&(i==="NORMAL"?o=!1:i==="DEFAULT"&&(o=!0)),e){case"SAFE":{a=q7(r,s),o&&n.addDefaultSafeSpaceData(a);break}case"OTHER":{a=J7(r);break}case"TRACK":{a=K7(r);break}case"NET_LENGTH":{a=$7(r);break}case"NET_LENGTH_TOLERANCE":{a=Z7(r);break}case"DIFFER_ENTAIL":{a=Q7(r);break}case"BLIND":{a=e9(r);break}case"RADIUS":{a=t9(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=i9(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=r9(r);break}case"PASTE":{a=n9(r);break}case"SOLDER":{a=s9(r);break}case"AUTO_ROUTER":{a=a9(r);break}}return a}function c9(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 u9(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 m_(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 h9(e){let t={};return m_(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 $S=class{parseFull(e){m_(e,t=>this.onParseLine(JSON.parse(t))),this.onParseEnd()}},d9=class extends $S{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 eP,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 f_(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=c0(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=c0(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]=l9(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=c9(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=u9(t[1],t[2],vf(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||vf(t[4])),(i.innerPlaneRuleValue||t[5])&&(e[r].innerPlaneValue=i.innerPlaneRuleValue||vf(t[5]))):e[r]={ruleSelect:t[1],ruleOrder:t[2],ruleKeyValue:i.ruleKeyValue,copperValue:i.copperRuleValue||vf(t[4])||{},innerPlaneValue:i.innerPlaneRuleValue||vf(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 eP),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(KS);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]=h9(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,x,y]=e,E=(t=this.stringId[i])!=null?t:i;c&&this.version<1.2&&(l=="default"||l=="")&&(c*=1.5);let T=this.fontCache.find(w=>w.id&&w.id===this.getOldId(E));this.version<1.6&&T&&(T.text=o,T.fontFamily=l,T.fontSize=c/10,T.thickness=u/10,T.bold=h,T.italic=d,T.reverse=m,T.expansion=g/10),this.onString(i,this.curPartition||"",r,n,s,a,o,l,c,u,!!h,!!d,this.transAlignType(p),f,!!m,g,!!x,!!y,this.specialColors[this.getOldId(E)])}},p9=Object.create,g_=Object.defineProperty,f9=Object.getOwnPropertyDescriptor,m9=Object.getOwnPropertyNames,g9=Object.getPrototypeOf,y9=Object.prototype.hasOwnProperty,b9=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),x9=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of m9(t))!y9.call(e,n)&&n!==i&&g_(e,n,{get:()=>t[n],enumerable:!(r=f9(t,n))||r.enumerable});return e},E9=(e,t,i)=>(i=e!=null?p9(g9(e)):{},x9(t||!e||!e.__esModule?g_(i,"default",{value:e,enumerable:!0}):i,e)),T9=b9((e,t)=>{"use strict";t.exports=i,t.exports.default=i;function i(v,L,_){_=_||2;var B=L&&L.length,U=B?L[0]*_:v.length,z=r(v,0,U,_,!0),W=[];if(!z||z.next===z.prev)return W;var ne,me,Ee,Se,Fe,Ne,it;if(B&&(z=u(v,L,z,_)),v.length>80*_){ne=Ee=v[0],me=Se=v[1];for(var je=_;je<U;je+=_)Fe=v[je],Ne=v[je+1],Fe<ne&&(ne=Fe),Ne<me&&(me=Ne),Fe>Ee&&(Ee=Fe),Ne>Se&&(Se=Ne);it=Math.max(Ee-ne,Se-me),it=it!==0?32767/it:0}return s(z,W,_,ne,me,it,0),W}function r(v,L,_,B,U){var z,W;if(U===N(v,L,_,B)>0)for(z=L;z<_;z+=B)W=H(z,v[z],v[z+1],W);else for(z=_-B;z>=L;z-=B)W=H(z,v[z],v[z+1],W);return W&&b(W,W.next)&&(q(W),W=W.next),W}function n(v,L){if(!v)return v;L||(L=v);var _=v,B;do if(B=!1,!_.steiner&&(b(_,_.next)||w(_.prev,_,_.next)===0)){if(q(_),_=L=_.prev,_===_.next)break;B=!0}else _=_.next;while(B||_!==L);return L}function s(v,L,_,B,U,z,W){if(v){!W&&z&&m(v,B,U,z);for(var ne=v,me,Ee;v.prev!==v.next;){if(me=v.prev,Ee=v.next,z?o(v,B,U,z):a(v)){L.push(me.i/_|0),L.push(v.i/_|0),L.push(Ee.i/_|0),q(v),v=Ee.next,ne=Ee.next;continue}if(v=Ee,v===ne){W?W===1?(v=l(n(v),L,_),s(v,L,_,B,U,z,2)):W===2&&c(v,L,_,B,U,z):s(n(v),L,_,B,U,z,1);break}}}}function a(v){var L=v.prev,_=v,B=v.next;if(w(L,_,B)>=0)return!1;for(var U=L.x,z=_.x,W=B.x,ne=L.y,me=_.y,Ee=B.y,Se=U<z?U<W?U:W:z<W?z:W,Fe=ne<me?ne<Ee?ne:Ee:me<Ee?me:Ee,Ne=U>z?U>W?U:W:z>W?z:W,it=ne>me?ne>Ee?ne:Ee:me>Ee?me:Ee,je=B.next;je!==L;){if(je.x>=Se&&je.x<=Ne&&je.y>=Fe&&je.y<=it&&E(U,ne,z,me,W,Ee,je.x,je.y)&&w(je.prev,je,je.next)>=0)return!1;je=je.next}return!0}function o(v,L,_,B){var U=v.prev,z=v,W=v.next;if(w(U,z,W)>=0)return!1;for(var ne=U.x,me=z.x,Ee=W.x,Se=U.y,Fe=z.y,Ne=W.y,it=ne<me?ne<Ee?ne:Ee:me<Ee?me:Ee,je=Se<Fe?Se<Ne?Se:Ne:Fe<Ne?Fe:Ne,It=ne>me?ne>Ee?ne:Ee:me>Ee?me:Ee,Ht=Se>Fe?Se>Ne?Se:Ne:Fe>Ne?Fe:Ne,Ri=x(it,je,L,_,B),Ci=x(It,Ht,L,_,B),ze=v.prevZ,D=v.nextZ;ze&&ze.z>=Ri&&D&&D.z<=Ci;){if(ze.x>=it&&ze.x<=It&&ze.y>=je&&ze.y<=Ht&&ze!==U&&ze!==W&&E(ne,Se,me,Fe,Ee,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0||(ze=ze.prevZ,D.x>=it&&D.x<=It&&D.y>=je&&D.y<=Ht&&D!==U&&D!==W&&E(ne,Se,me,Fe,Ee,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0))return!1;D=D.nextZ}for(;ze&&ze.z>=Ri;){if(ze.x>=it&&ze.x<=It&&ze.y>=je&&ze.y<=Ht&&ze!==U&&ze!==W&&E(ne,Se,me,Fe,Ee,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0)return!1;ze=ze.prevZ}for(;D&&D.z<=Ci;){if(D.x>=it&&D.x<=It&&D.y>=je&&D.y<=Ht&&D!==U&&D!==W&&E(ne,Se,me,Fe,Ee,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0)return!1;D=D.nextZ}return!0}function l(v,L,_){var B=v;do{var U=B.prev,z=B.next.next;!b(U,z)&&C(U,B,B.next,z)&&M(U,z)&&M(z,U)&&(L.push(U.i/_|0),L.push(B.i/_|0),L.push(z.i/_|0),q(B),q(B.next),B=v=z),B=B.next}while(B!==v);return n(B)}function c(v,L,_,B,U,z){var W=v;do{for(var ne=W.next.next;ne!==W.prev;){if(W.i!==ne.i&&T(W,ne)){var me=G(W,ne);W=n(W,W.next),me=n(me,me.next),s(W,L,_,B,U,z,0),s(me,L,_,B,U,z,0);return}ne=ne.next}W=W.next}while(W!==v)}function u(v,L,_,B){var U=[],z,W,ne,me,Ee;for(z=0,W=L.length;z<W;z++)ne=L[z]*B,me=z<W-1?L[z+1]*B:v.length,Ee=r(v,ne,me,B,!1),Ee===Ee.next&&(Ee.steiner=!0),U.push(y(Ee));for(U.sort(h),z=0;z<U.length;z++)_=d(U[z],_);return _}function h(v,L){return v.x-L.x}function d(v,L){var _=p(v,L);if(!_)return L;var B=G(_,v);return n(B,B.next),n(_,_.next)}function p(v,L){var _=L,B=v.x,U=v.y,z=-1/0,W;do{if(U<=_.y&&U>=_.next.y&&_.next.y!==_.y){var ne=_.x+(U-_.y)*(_.next.x-_.x)/(_.next.y-_.y);if(ne<=B&&ne>z&&(z=ne,W=_.x<_.next.x?_:_.next,ne===B))return W}_=_.next}while(_!==L);if(!W)return null;var me=W,Ee=W.x,Se=W.y,Fe=1/0,Ne;_=W;do B>=_.x&&_.x>=Ee&&B!==_.x&&E(U<Se?B:z,U,Ee,Se,U<Se?z:B,U,_.x,_.y)&&(Ne=Math.abs(U-_.y)/(B-_.x),M(_,v)&&(Ne<Fe||Ne===Fe&&(_.x>W.x||_.x===W.x&&f(W,_)))&&(W=_,Fe=Ne)),_=_.next;while(_!==me);return W}function f(v,L){return w(v.prev,v,L.prev)<0&&w(L.next,v,v.next)<0}function m(v,L,_,B){var U=v;do U.z===0&&(U.z=x(U.x,U.y,L,_,B)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==v);U.prevZ.nextZ=null,U.prevZ=null,g(U)}function g(v){var L,_,B,U,z,W,ne,me,Ee=1;do{for(_=v,v=null,z=null,W=0;_;){for(W++,B=_,ne=0,L=0;L<Ee&&(ne++,B=B.nextZ,!!B);L++);for(me=Ee;ne>0||me>0&&B;)ne!==0&&(me===0||!B||_.z<=B.z)?(U=_,_=_.nextZ,ne--):(U=B,B=B.nextZ,me--),z?z.nextZ=U:v=U,U.prevZ=z,z=U;_=B}z.nextZ=null,Ee*=2}while(W>1);return v}function x(v,L,_,B,U){return v=(v-_)*U|0,L=(L-B)*U|0,v=(v|v<<8)&16711935,v=(v|v<<4)&252645135,v=(v|v<<2)&858993459,v=(v|v<<1)&1431655765,L=(L|L<<8)&16711935,L=(L|L<<4)&252645135,L=(L|L<<2)&858993459,L=(L|L<<1)&1431655765,v|L<<1}function y(v){var L=v,_=v;do(L.x<_.x||L.x===_.x&&L.y<_.y)&&(_=L),L=L.next;while(L!==v);return _}function E(v,L,_,B,U,z,W,ne){return(U-W)*(L-ne)>=(v-W)*(z-ne)&&(v-W)*(B-ne)>=(_-W)*(L-ne)&&(_-W)*(z-ne)>=(U-W)*(B-ne)}function T(v,L){return v.next.i!==L.i&&v.prev.i!==L.i&&!O(v,L)&&(M(v,L)&&M(L,v)&&k(v,L)&&(w(v.prev,v,L.prev)||w(v,L.prev,L))||b(v,L)&&w(v.prev,v,v.next)>0&&w(L.prev,L,L.next)>0)}function w(v,L,_){return(L.y-v.y)*(_.x-L.x)-(L.x-v.x)*(_.y-L.y)}function b(v,L){return v.x===L.x&&v.y===L.y}function C(v,L,_,B){var U=R(w(v,L,_)),z=R(w(v,L,B)),W=R(w(_,B,v)),ne=R(w(_,B,L));return!!(U!==z&&W!==ne||U===0&&A(v,_,L)||z===0&&A(v,B,L)||W===0&&A(_,v,B)||ne===0&&A(_,L,B))}function A(v,L,_){return L.x<=Math.max(v.x,_.x)&&L.x>=Math.min(v.x,_.x)&&L.y<=Math.max(v.y,_.y)&&L.y>=Math.min(v.y,_.y)}function R(v){return v>0?1:v<0?-1:0}function O(v,L){var _=v;do{if(_.i!==v.i&&_.next.i!==v.i&&_.i!==L.i&&_.next.i!==L.i&&C(_,_.next,v,L))return!0;_=_.next}while(_!==v);return!1}function M(v,L){return w(v.prev,v,v.next)<0?w(v,L,v.next)>=0&&w(v,v.prev,L)>=0:w(v,L,v.prev)<0||w(v,v.next,L)<0}function k(v,L){var _=v,B=!1,U=(v.x+L.x)/2,z=(v.y+L.y)/2;do _.y>z!=_.next.y>z&&_.next.y!==_.y&&U<(_.next.x-_.x)*(z-_.y)/(_.next.y-_.y)+_.x&&(B=!B),_=_.next;while(_!==v);return B}function G(v,L){var _=new I(v.i,v.x,v.y),B=new I(L.i,L.x,L.y),U=v.next,z=L.prev;return v.next=L,L.prev=v,_.next=U,U.prev=_,B.next=_,_.prev=B,z.next=B,B.prev=z,B}function H(v,L,_,B){var U=new I(v,L,_);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(v){v.next.prev=v.prev,v.prev.next=v.next,v.prevZ&&(v.prevZ.nextZ=v.nextZ),v.nextZ&&(v.nextZ.prevZ=v.prevZ)}function I(v,L,_){this.i=v,this.x=L,this.y=_,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(v,L,_,B){var U=L&&L.length,z=U?L[0]*_:v.length,W=Math.abs(N(v,0,z,_));if(U)for(var ne=0,me=L.length;ne<me;ne++){var Ee=L[ne]*_,Se=ne<me-1?L[ne+1]*_:v.length;W-=Math.abs(N(v,Ee,Se,_))}var Fe=0;for(ne=0;ne<B.length;ne+=3){var Ne=B[ne]*_,it=B[ne+1]*_,je=B[ne+2]*_;Fe+=Math.abs((v[Ne]-v[je])*(v[it+1]-v[Ne+1])-(v[Ne]-v[it])*(v[je+1]-v[Ne+1]))}return W===0&&Fe===0?0:Math.abs((Fe-W)/W)};function N(v,L,_,B){for(var U=0,z=L,W=_-B;z<_;z+=B)U+=(v[W]-v[z])*(v[z+1]+v[W+1]),W=z;return U}i.flatten=function(v){for(var L=v[0][0].length,_={vertices:[],holes:[],dimensions:L},B=0,U=0;U<v.length;U++){for(var z=0;z<v[U].length;z++)for(var W=0;W<L;W++)_.vertices.push(v[U][z][W]);U>0&&(B+=v[U-1].length,_.holes.push(B))}return _}}),w9=(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))(w9||{}),S9=(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))(S9||{}),iP={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},pte=(()=>{let e={};for(let t in iP)e[iP[t]]=t;return e})(),rb,fte=(rb=class{constructor(e,t){this.ratio=e/t}wrap(e){return e*this.ratio}static convert(e,t,i){return e*t/i}},rb.ASIS=new rb(1,1),rb),nb=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}};nb.prototype["px(100)2mil"]=e=>e*10,nb.prototype["px(100)2mm"]=e=>e*.254,nb.prototype["mil2px(100)"]=e=>e/10,nb.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var sb=null,ZS=new ArrayBuffer(8),Yw=new Float64Array(ZS),Hw=new Uint32Array(ZS),rP=new Uint16Array(ZS),nP=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(!sb){let e=this.getUrlVars().version;e?sb="/analyzer/v"+e:sb="/analyzer"}return sb}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;Yw[0]=new Date().getTime(),e.push(Hw[1].toString(16)),Yw[0]=Math.random(),e.push(rP[3].toString(16));let t=rP[2].toString(16);e.push("4"+t.substr(0,3)),Yw[0]=performance.now();let i=Hw[0].toString(16)+Hw[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}},y_=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(Lf.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(Lf.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(Lf.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(Lf.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")}},v9=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(v9||{}),I9=/(\.?0+)$/,Lf=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(nP.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(nP.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);y_.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(I9,"")}},A9=(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))(A9||{});function C9(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var D9=(e,t)=>{e===3?console.error(t):console.log(t)},P9=(e,t)=>Lf.format("%s %s: %s",new Date,C9(e),t),mf,ox=(mf=class{constructor(e,t=D9,i=P9){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 mf(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 mf(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,Lf.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)}},mf.DUMMY=new mf(4),mf),QS=new ArrayBuffer(8),jw=new Float64Array(QS),Vw=new Uint32Array(QS),sP=new Uint16Array(QS),aP=ArrayBuffer;try{aP=self.HTMLImageElement||aP}catch{}var ab=null;function ep(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 x=l(m,g);isNaN(x)?(o[f++]=g,g=a[++p]):(x<=0&&(o[f++]=m,m=a[++d]),x>=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 ca=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(!ab){let e=this.getUrlVars().version;e?ab="/analyzer/v"+e:ab="/analyzer"}return ab}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;jw[0]=new Date().getTime(),e.push(Vw[1].toString(16)),jw[0]=Math.random(),e.push(sP[3].toString(16));let t=sP[2].toString(16);e.push("4"+t.substr(0,3)),jw[0]=performance.now();let i=Vw[0].toString(16)+Vw[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}},_9=[1,10,100,1e3],ob=0,jd=0;function oP(e,t,i){return ob=Math.abs(e-t),i>=5&&ob>1e-5||isNaN(i)&&ob>1e-8?!1:ob<1e-13?!0:(jd=Math.min(lP(e),lP(t)),jd<10&&(jd=10),isNaN(i)||(jd=Math.min(jd,i)),cP(e,jd)===cP(t,jd))}var lb=0,cb=0;function lP(e){return lb=0,cb=0,e>0?lb=e-Math.floor(e):lb=e-Math.ceil(e),cb=(lb.toString()||"").length,cb>2?cb-2:0}function cP(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=_9[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 L9=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(L9||{}),O9=/(\.?0+)$/,Of=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(ca.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(ca.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);qr.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(O9,"")}},qr=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(Of.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(Of.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(Of.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(Of.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")}},ub,Oe=(ub=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}},ub.eps=1e-8,ub.precision=1e8,ub);function kf(e,t){Gb(e.iterator(),t)}function Gb(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var R9=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 xS(e){return new R9(e)}var oa,qt=(oa=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%oa.PIx2,e=e<0?oa.PIx2+e:e,e===oa.PIx2?0:e}static toQuarterBase(e){return oa.regular((e+oa.PI_4)/oa.PI_2*oa.PI_2)}static toQuarterBaseD(e){return oa.regularD(((e+45)/90|0)*90)}static transformD(e,t){return oa.toDegrees(oa.transform(oa.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 oa.regular(s.angle(n))}},oa.PIx2=Math.PI*2,oa.PI_2=Math.PI/2,oa.PI_4=Math.PI/4,oa),An=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)}},b_=new ArrayBuffer(16),uP=new Float64Array(b_),hb=new Int32Array(b_),Xi,we=(Xi=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 Xi(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 Xi(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 Xi((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=qr.normal(e),this.y=qr.normal(t)}get hashed(){return this._hashed==null&&(uP[0]=this.x,uP[1]=this.y,this._hashed=hb[0]^hb[1]^hb[2]^hb[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 Xi(t,i)}add(e){var t=this.x+e.x,i=this.y+e.y;return new Xi(t,i)}div(e){return new Xi(this.x/e,this.y/e)}add1(e,t){return new Xi(this.x+e,this.y+t)}mul(e){return new Xi(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 qt.toDegrees(this.angle2(e))}angle(e){return Math.atan2(this.y-e.y,this.x-e.x)}angleX(e=Xi.ORIGIN){let t=this.angle(e);return t<0&&(t=Math.PI*2+t),t}angleD(e){return qt.toDegrees(this.angle(e))}distance1(e){let t=e.x-this.x,i=e.y-this.y;return An.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,qt.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 Xi(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 Xi(t,i)}hashCode(){return this.hashed}equals(e,t){return e instanceof Xi?oP(e.x,this.x,t)&&oP(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 Xi?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 la(e,e,t,t)}normalize(){if(this.x===0&&this.y===0)return new Xi(0,0);let e=this.x/this.length(),t=this.y/this.length();return new Xi(e,t)}regular(e=1e-4){let t=Math.round(1/e);return new Xi(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}round(e=4){let t=10**(e|0);return new Xi(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}mirrorX(e=Xi.ORIGIN){return new Xi(this.x,2*e.y-this.y)}mirrorY(e=Xi.ORIGIN){return new Xi(2*e.x-this.x,this.y)}mirrorCenter(e=Xi.ORIGIN){return new Xi(2*e.x-this.x,2*e.y-this.y)}clone(){return new Xi(this.x,this.y)}mirror(e=Xi.ORIGIN){return new Xi(2*e.x-this.x,2*e.y-this.y)}pointOnRays(e,t){let i=qt.toRadians(e);return new Xi(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}pointOnRays2(e,t){let i=e.angle(this);return new Xi(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}scale(e){return new Xi(this.x*e,this.y*e)}},Xi.ORIGIN=new Xi(0,0),Xi.X_UNIT_VECTOR=new Xi(1,0),Xi.Y_UNIT_VECTOR=new Xi(0,1),Xi),N9=(e=>(e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT",e))(N9||{}),M9=(e=>(e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM",e))(M9||{}),ys,Nu=(ys=class{constructor(e,t){this.horizontal=e,this.vertical=t}},ys.LT=new ys(0,0),ys.LC=new ys(0,1),ys.LB=new ys(0,2),ys.CT=new ys(1,0),ys.CC=new ys(1,1),ys.CB=new ys(1,2),ys.RT=new ys(2,0),ys.RC=new ys(2,1),ys.RB=new ys(2,2),ys),B9=(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))(B9||{}),Ka=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 kf(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 la(this.minX,this.maxX,this.minY,this.maxY)}build1(){return this.valid()?new la(this.minX,this.maxX,this.minY,this.maxY):new la(0,0,0,0)}},Hg=new Float64Array(4),la=class Sl{static extendRect({x:t,y:i,width:r,height:n}){return new Sl(t,t+r,i,i+n)}static extend1(t,i){if(t===null)return new Sl(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 Sl(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 Sl(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 Sl(r,n,s,a)}static extend4(t,i,r){return new Sl(t.x-i/2,t.x+i/2,t.y-r/2,t.y+r/2)}constructor(t,i,r,n){if(this.minX=qr.normal(t),this.maxX=qr.normal(i),this.minY=qr.normal(r),this.maxY=qr.normal(n),t>i||r>n)throw new Error(`min > max is not permitted: [${t}, ${i}, ${r}, ${n}]`)}get data(){return Hg[0]=this.minX,Hg[1]=this.maxX,Hg[2]=this.minY,Hg[3]=this.maxY,Hg}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 qr.positiveOr0(this.maxX-this.minX+t*2),qr.positiveOr0(this.maxY-this.minY+t*2),new Sl(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 Sl(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 Sl(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 Ka;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 Ka;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 Sl(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),Sl.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?Nu.RT:o<-s?Nu.RB:Nu.RC:a<-n?o>s?Nu.LT:o<-s?Nu.LB:Nu.LC:o>s?Nu.CT:o<-s?Nu.CB:Nu.CC}bbox(){return this}},Ub=class Ni{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=qr.normal(t),this.n=qr.normal(i);let n=t*i;if(r.length===n){for(let s=0;s<r.length;s++)qr.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 Ni.mul(this.m,this.n,t.n,this.data,t.data,i),new Ni(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[Ni.on(n,a,o)]=t[Ni.on(r,a,o)]:o===i+a?s[Ni.on(n,a,o)]=1:s[Ni.on(n,a,o)]=0;return s}inverseMatrix(t,i,r){for(let n=0;n<i;n++){let s=t[Ni.on(r,n,n)];for(let a=0;a<r;a++)t[Ni.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[Ni.on(r,s,s)]===0){let a=new Array(r),o;for(o=s;o<i;o++)if(t[Ni.on(r,o,s)]!==0){ca.arraycopy(t,Ni.on(r,o,0),a,0,r),ca.arraycopy(t,Ni.on(r,s,0),t,Ni.on(r,o,0),r),ca.arraycopy(a,0,t,Ni.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[Ni.on(r,a,s)]/t[Ni.on(r,s,s)];for(let l=0;l<r;l++)t[Ni.on(r,a,l)]-=t[Ni.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[Ni.on(r,a,l)];i[Ni.on(r,a,l)]=i[Ni.on(r,o,l)],i[Ni.on(r,o,l)]=c}}for(let a=0;a<this.m;a++){let o=Math.abs(i[Ni.on(r,a,a)]),l=a;if(t(i[Ni.on(r,a,a)]))for(let u=a+1;u<this.m;u++){if(t(i[Ni.on(r,u,a)])){Math.abs(i[Ni.on(r,u,a)])>o&&(o=Math.abs(i[Ni.on(r,u,a)]),l=u);continue}n(a,u);break}if(t(i[Ni.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[Ni.on(r,a,a)];for(let u=0;u<r;u++)i[Ni.on(r,a,u)]*=c;for(let u=0;u<this.m;u++){if(a===u)continue;let h=i[Ni.on(r,u,a)];for(let d=a;d<r;d++)i[Ni.on(r,u,d)]-=i[Ni.on(r,a,d)]*h}}let s=[];for(let a=0;a<this.m;a++)for(let o=this.n;o<r;o++)s[Ni.on(this.n,a,o-this.n)]=i[Ni.on(r,a,o)];return new Ni(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 Ni(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 Ni?!(this.m!=t.m||this.n!=t.n||!ca.equals(this.data,t.data)):!1}},k9=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],ln,x_=(ln=class extends Ub{static translate(e,t,i){return new ln([1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1])}static translate1(e){return new ln([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 ln([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 ln([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 ln([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 ln([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 ln([e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1])}static flipX(){return new ln([1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1])}static flipY(){return new ln([-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)?ln.rotateZ(t):ln.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 ln(l)}constructor(e=k9){super(4,4,e)}translate(e){return this.multiply4(ln.translate1(e))}translate1(e,t,i){return this.multiply4(ln.translate(e,t,i))}rotateX(e){return this.multiply4(ln.rotateX(e))}rotateY(e){return this.multiply4(ln.rotateY(e))}rotateZ(e){return this.multiply4(ln.rotateZ(e))}scale(e,t=e,i=e){return this.multiply4(ln.scale(e,t,i))}scale1(e){return this.multiply4(ln.scale(e.x,e.y,e.z))}setOrigin(e,t,i){return ln.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 Ub.mul(4,4,4,this.data,e.data,t),new ln(t)}getInverseMatrix(){let e=super.getInverseMatrix();return new ln(e.data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new ln(e.data)}inverse(){let e=this.getInverseMatrix();return new ln(e.data)}toMatrix3(){let e=this.data;return new rr([e[0],e[1],0,e[4],e[5],0,e[12],e[13],1])}},ln.ORIGIN=new ln,ln);function jg(e){return y_.normal(parseFloat(e))}var F9=[1,0,0,0,1,0,0,0,1],Ur,rr=(Ur=class extends Ub{static translate(e,t){return new Ur([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 Ur([t,i,0,-i,t,0,0,0,1])}static rotateD(e){return this.rotate(qt.toRadians(e))}static scale(e,t=e){return new Ur([e,0,0,0,t,0,0,0,1])}static scale1(e,t){return new Ur([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=jg(a[0]),l=jg(a[1]);i=i?i.translate(o,l):Ur.translate(o,l);break;case"rotate":let c=jg(a[0]),u=jg(a[1]),h=jg(a[2]);i=i?i.setOrigin(u,h):Ur.translate(u,h),i=i.rotateD(c);break;default:return}}),i}constructor(e=F9){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 Ub.mul(3,3,3,this.data,e.data,t),new Ur(t)}translate(e,t){return this.multiply3(Ur.translate(e,t))}translate1(e){return this.multiply3(Ur.translate1(e))}scale(e,t=e){return this.multiply3(Ur.scale(e,t))}scale1(e,t){return this.multiply3(Ur.scale1(e,t))}det(){return this.data[0]*this.data[4]-this.data[3]*this.data[1]}invert(){let e=this.getInverseMatrix();return new Ur(e.data)}rotateD(e){return this.multiply3(Ur.rotateD(e))}rotate(e){return this.multiply3(Ur.rotate(e))}resetOffset(){let e=this.data;return new Ur([e[0],e[1],0,e[3],e[4],0,0,0,1])}setOrigin(e,t){return Ur.translate(-e,-t).multiply3(this).translate(e,t)}setOrigin1(e){return this.setOrigin(e.x,e.y)}getInverseMatrix(){return new Ur(super.getInverseMatrix().data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new Ur(e.data)}toMatrix4(){let e=this.data;return new x_([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}},Ur.ORIGIN=new Ur,Ur.MIRROR_Y=new Ur([1,0,0,0,-1,0,0,0,1]),Ur.MIRROR_X=new Ur([-1,0,0,0,1,0,0,0,1]),Ur.ROT_90=new Ur([0,1,0,-1,0,0,0,0,1]),Ur.ROT_N90=new Ur([0,-1,0,1,0,0,0,0,1]),Ur),G9=(e=>(e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE",e))(G9||{}),Mh=(e=>(e[e.CW=0]="CW",e[e.CCW=1]="CCW",e))(Mh||{}),w0=class{},ES=class Kg{constructor(t,i,r){this.p1=t,this.p2=i,this.p3=r}barycentre(){return Kg.barycentre(this.p1,this.p2,this.p3)}incentre(){return Kg.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 Kg.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(An.crossProd2(t,i,r,n,s,a))}scale(t,i){let r=rr.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 Kg(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 db(){return{minDistance:Number.POSITIVE_INFINITY,start:null,end:null}}var rc=class Nh{static getMinDistanceWithoutCross(t,i){let r=db();return Nh.minLine(t,i,r),r.minDistance}static getMinDistance(t,i){return Al(t,i)?0:this.getMinDistanceWithoutCross(t,i)}static getMinLineWithCross(t,i){let r=db();return Nh.minLine(t,i,r),new pe(r.start,r.end)}static getMinLine(t,i){return Nh.intersection(t,i)||this.getMinLineWithCross(t,i)}static getMinDistanceFromPoint(t,i){let r=db();if(i instanceof pe)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=Nh.intersection(t,i),this.minline)this.minDistance=0;else{let r=db();Nh.minLine(t,i,r),this.minline=new pe(r.start,r.end),this.minDistance=r.minDistance}}getDistance(){return this.minDistance}getLine(){return this.minline}static intersection(t,i){let r=Al(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 pe(n[0],n[1]):new pe(n[0],n[0])}static minLine(t,i,r){if(t instanceof pe&&i instanceof pe)return this.minDistanceForLines(t,i,r);if(t instanceof Pe&&i instanceof pe)return this.minDistanceForLineAndArc(t,i,r);if(t instanceof pe&&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=Nh.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),(Zl(t,i.center)||Zl(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);Zl(t,a)&&(this.arcShortestLine(i,r,a,l),this.arcShortestLine(i,r,a,c)),Zl(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));Zl(t,l)&&Oe.greater(i.start().distance2(t.center),0)&&this.arcShortestLine(t,r,i.start(),l),Zl(t,c)&&Oe.greater(i.end().distance2(t.center),0)&&this.arcShortestLine(t,r,i.end(),c),Zl(i,u)&&Oe.greater(t.start().distance2(i.center),0)&&this.arcShortestLine(i,r,t.start(),u),Zl(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(Zl(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(Zl(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=Nh.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(!Zl(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 Zl(e,t){if(Oe.eq(e.sweepAngle,360))return!0;let i=qt.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 U9=[1,10,100,1e3],hP="http://www.w3.org/2000/svg",dP="http://www.w3.org/1999/xlink",pP="http://www.w3.org/XML/1998/namespace",fP="https://easyeda.com/",mte=(function(){var e={svg:hP,xlink:dP,xml:pP,c:fP};return e[hP]="svg",e[dP]="xlink",e[pP]="xml",e[fP]="c",e})(),Xn=(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})(),gte=(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})(),Rs=(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})(),yte=(function(){var e=[],t=[];for(var i in Xn)if(Xn.hasOwnProperty(i)){if(i.match(/^BOARD\d+/))continue;e.push(Xn[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 Xn.TOPLAYER:n={name:Rs[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case Xn.BOTTOMLAYER:n={name:Rs[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case Xn.TOPSILKLAYER:n={name:Rs[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case Xn.BOTTOMSILKLAYER:n={name:Rs[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case Xn.TOPPASTERLAYER:n={name:Rs[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case Xn.BOTTOMPASTERLAYER:n={name:Rs[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case Xn.TOPSOLDERLAYER:n={name:Rs[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case Xn.BOTTOMSOLDERLAYER:n={name:Rs[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case Xn.RATLINES:n={name:Rs[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case Xn.BOARDOUTLINE:n={name:Rs[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case Xn.ALL:n={name:Rs[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case Xn.DOCUMENT:n={name:Rs[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case Xn.TOPASSEMBLY:n={name:Rs[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case Xn.BOTTOMASSEMBLY:n={name:Rs[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case Xn.MECHANICAL:n={name:Rs[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case Xn.MODEL3D:n={name:Rs[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case Xn.LIBBODY:n={name:Rs[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case Xn.PADSURFACE:n={name:Rs[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=Xn.INNER1&&o<=Xn.INNER32?n={name:Rs[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})(),mP={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},bte=(function(){var e={};for(let t in mP)e[mP[t]]=t;return e})(),lx=Math.PI*2,Yb=Math.PI/2,xte=Math.sin(Math.PI/180);function Y9(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=U9[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 E_(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function H9(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 j9(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 V9(e,t,i){return H9(e,t,i)?E_((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}var $g=1e-4,ae=new Float64Array(100);function Al(e,t){if(e instanceof pe&&t instanceof pe)return Kc(e,t);if(e instanceof Pe&&t instanceof pe)return TS(e,t);if(e instanceof pe&&t instanceof Pe)return TS(t,e);if(e instanceof Pe&&t instanceof Pe)return w_(e,t);if(e instanceof lt&&t instanceof lt)return Cb(e,t);if(e instanceof lt&&t instanceof pe)return Cb(e,new lt([t.start(),t.end()]));if(e instanceof pe&&t instanceof lt)return Cb(new lt([e.start(),e.end()]),t);if(e instanceof lt&&t instanceof Pe)return wP(t,e);if(e instanceof Pe&&t instanceof lt)return wP(e,t);throw new Error("not supported operation")}function z9(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new pe(new we(i.minX-1,t),new we(i.maxX+1,t));return Kc(r,e)>0?1:0}else return 0}function X9(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new pe(new we(i.minX-1,t),new we(i.maxX+1,t));return Hb(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function gP(e,t){let i=e.bbox();return i.isContainsY1(t)&&Cb(new lt([new we(i.minX-1,t),new we(i.maxX+1,t)]),e)>0?1:0}function yP(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function W9(e,t){let i=t.length(),r=An.crossProd3(t.start(),t.end(),e.start())/i,n=An.crossProd3(t.start(),t.end(),e.end())/i;return Math.abs(r)<1e-8||Math.abs(n)<1e-8||r*n<0}function Kc(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 bP(t,e,i);else{if(t.isPoint())return bP(e,t,i);{let r=function(E,T){i.isContains2(E,T)&&(ae[y++]=E,ae[y++]=T)};if(!W9(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=An.crossProd2(n,s,l,c,u,h)/d,f=An.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=An.crossProd2(l,c,n,s,a,o)/m,x=An.crossProd2(u,h,n,s,a,o)/m;if(g*x>0&&!Oe.eq(g,0)&&!Oe.eq(x,0))return 0;let y=0;if(Oe.eq(p,0)&&Oe.eq(f,0)){let E=i.UL(),T=i.UR(),w=i.LL(),b=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++]=T.x,ae[y++]=T.y;else{let C=ES.area2(E.x,E.y,l,c,u,h),A=ES.area2(T.x,T.y,l,c,u,h);C<A?(ae[y++]=E.x,ae[y++]=E.y,ae[y++]=b.x,ae[y++]=b.y):(ae[y++]=T.x,ae[y++]=T.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 bP(e,t,i){let r=t.start(),n=t.end(),s=An.crossProd3(e.start(),e.end(),t.start()),a=An.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 Hb(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize($g);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=rc.foot(t,e.center),x=g.distance1(e.center);if(Oe.greater(x,s))return 0;if(Oe.eq(x,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=T_(r,n,o,l,c,u,m,g);let y=ae[m-2],E=ae[m-1];m-=2;let T=An.distance1(r,n,y,E);if(Oe.eq(T,s))ae[m++]=y,ae[m++]=E,ae[m++]=y,ae[m++]=E;else if(T<s)m=Vs(a,r,n,o,l,y,E,m),m=Vs(a,r,n,y,E,c,u,m);else return 0}}else if(p===-1||f===-1)m=Vs(a,r,n,o,l,c,u,m);else{let g=rc.foot(t,e.center),x=g.distance1(e.center);if(Oe.eq(x,s)){let y=function(w){return yP(i,w.x,w.y)&&Nn(e,w)},E=e.start(),T=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(T),0)&&y(T))return ae[m++]=T.x,ae[m++]=T.y,ae[m++]=T.x,ae[m++]=T.y,m;if(h<=s)m=Vs(a,r,n,g.x,g.y,c,u,m),m===2&&(ae[m++]=ae[0],ae[m++]=ae[1]);else if(x<s){if(m=Vs(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=Vs(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(T),0)&&y(T))return ae[m++]=T.x,ae[m++]=T.y,ae[m++]=T.x,ae[m++]=T.y,m;if(d<=s)m=Vs(a,r,n,g.x,g.y,o,l,m),m===2&&(ae[m++]=ae[0],ae[m++]=ae[1]);else if(x<s){if(m=Vs(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=Vs(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=Vs(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=Vs(a,r,n,g.x,g.y,o,l,m))}}if(m>0){let g=0;for(let x=0;x<m;x+=2){let y=ae[x],E=ae[x+1];isFinite(y)&&isFinite(E)&&yP(i,y,E)&&Nn(e,new we(y,E))&&(ae[g++]=y,ae[g++]=E)}return g}else return 0}else return 0}function q9(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=rc.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()),x=f.distance2(e.end());Oe.eq(g,0)?(ae[p++]=e.start().x,ae[p++]=e.start().y):Oe.eq(x,0)?(ae[p++]=e.end().x,ae[p++]=e.end().y):(ae[p++]=f.x,ae[p++]=f.y)}else{p=T_(i,r,s,a,o,l,p,f);let g=ae[p-2],x=ae[p-1],y=An.distance2(i,r,g,x);if(p-=2,Oe.eq(y,n))ae[p++]=g,ae[p++]=x;else if(y<n)p=Vs(n,i,r,s,a,g,x,p),p=Vs(n,i,r,g,x,o,l,p);else return 0}}else if(h===-1||d===-1)p=Vs(n,i,r,s,a,o,l,p);else{let f=rc.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=Vs(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=Vs(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],x=ae[m+1];isFinite(g)&&isFinite(x)&&(ae[f++]=g,ae[f++]=x)}return f}else return 0}else return 0}function Vs(e,t,i,r,n,s,a,o){if(n==a){let E=e-(n-i)*(n-i);if(Oe.greater(E,0)){let T=Math.sqrt(E),w=t-T,b=t+T,C=Math.min(r,s),A=Math.max(r,s);return w>=C&&w<=A&&(ae[o++]=w,ae[o++]=n),b>=C&&b<=A&&(ae[o++]=b,ae[o++]=n),o}}let l=An.distance2(r,n,t,i)-e;if(l===0)return ae[o++]=r,ae[o++]=n,o;let c=An.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,x=0;for(;g!==0;){x++;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=An.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)-An.distance1(f,m,t,i);return(Oe.eq(0,g)||Oe.eq(0,y))&&(ae[o++]=f,ae[o++]=m),o}function T_(e,t,i,r,n,s,a,o){let l=An.dotProd2(i,r,n,s,e,t),c=An.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(An.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=An.distance2(i,r,e,t),x=An.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==x||d==u&&p==h||f==u&&m==h));){y=An.distance2(u,h,e,t);let T=An.dotProd2(d,p,u,h,e,t);if(T==0)break;T<0?(f=u,m=h,x=y):(d=u,p=h,g=y)}return An.distance2(u,h,e,t)<An.distance2(o.x,o.y,e,t)?(ae[a++]=u,ae[a++]=h):(ae[a++]=o.x,ae[a++]=o.y),a}}function TS(e,t){if(e.rx===e.ry)return Hb(e,t);throw new Error("not supported")}function J9(e,t){if(e.rx===e.ry)return q9(e,t);throw new Error("not supported")}function w_(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return K9(e,t);throw new Error("not supported operation")}return 0}function K9(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 Nn(e,t.start())&&(ae[p]=t.start().x,ae[p+1]=t.start().y,p+=2,f=t.start()),Nn(e,t.end())&&(ae[p]=t.end().x,ae[p+1]=t.end().y,p+=2,f=t.end()),p===0?(Nn(t,e.start())&&(ae[p]=e.start().x,ae[p+1]=e.start().y,p+=2),Nn(t,e.end())&&(ae[p]=e.end().x,ae[p+1]=e.end().y,p+=2)):p===2&&(!f.equals1(e.start())&&Nn(t,e.start())&&(ae[p]=e.start().x,ae[p+1]=e.start().y,p+=2),!f.equals1(e.end())&&Nn(t,e.end())&&(ae[p]=e.end().x,ae[p+1]=e.end().y,p+=2)),p}else if(Oe.eq(u,d)){if(xP(e,t))return 4;let p=new pe(e.center,t.center),f=Hb(t,p);return f=EP(e,f),f!==0?f:(f=Hb(e,p),EP(t,f))}else if(Oe.eq(u,h)){if(xP(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,TP(e,t,2)}else{let p=(o-a)/o;return ae[0]=n+(i-n)/p,ae[1]=s+(r-s)/p,TP(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,x=s-r,y=Math.max(a,o),E,T,w,b;if(Math.abs(g)<Math.abs(x)){let O=g/-x,M=m-O*f;E=f-y,T=O*E+M,w=f+y,b=O*w+M}else{let O=x/-g,M=f-O*m;T=m-y,E=O*T+M,b=m+y,w=O*b+M}let C=Vs(l,i,r,E,T,f,m,0);if(C=Vs(l,i,r,f,m,w,b,C),C!==4)throw new Error("cnt !== 4");let A=new we(ae[0],ae[1]),R=new we(ae[2],ae[3]);if(Nn(e,A)&&Nn(t,A))return Nn(e,R)&&Nn(t,R)?4:Lh(e.start(),t,R,A)?(ae[2]=e.start().x,ae[3]=e.start().y,4):Lh(e.end(),t,R,A)?(ae[2]=e.end().x,ae[3]=e.end().y,4):Lh(t.start(),e,R,A)?(ae[2]=t.start().x,ae[3]=t.start().y,4):Lh(t.end(),e,R,A)?(ae[2]=t.end().x,ae[3]=t.end().y,4):2;if(Nn(e,R)&&Nn(t,R))return Lh(e.start(),t,A,R)?(ae[0]=e.start().x,ae[1]=e.start().y,4):Lh(e.end(),t,A,R)?(ae[0]=e.end().x,ae[1]=e.end().y,4):Lh(t.start(),e,A,R)?(ae[0]=t.start().x,ae[1]=t.start().y,4):Lh(t.end(),e,A,R)?(ae[0]=t.end().x,ae[1]=t.end().y,4):(ae[0]=ae[2],ae[1]=ae[3],2);{let O=function(H,q){if(Oe.eq(H.distance1(q.center),q.rx)&&Nn(q,H)){if(H.distance2(A)<H.distance2(R)){if(M)return;M=!0}else{if(k)return;k=!0}ae[G++]=H.x,ae[G++]=H.y}},M=!1,k=!1,G=0;return O(e.start(),t),O(e.end(),t),O(t.start(),e),O(t.end(),e),G}}}function Lh(e,t,i,r){return Oe.eq(e.distance1(t.center),t.rx)&&Nn(t,e)&&e.distance2(i)<e.distance2(r)}function xP(e,t){return Oe.eq(t.start().distance1(e.center),e.rx)&&Nn(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)&&Nn(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)&&Nn(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)&&Nn(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 EP(e,t){if(t===0)return 0;let i=ae[0],r=ae[1];return Nn(e,new we(i,r))?(ae[0]=i,ae[1]=r,ae[2]=i,ae[3]=r,4):0}function TP(e,t,i){if(i===0)return 0;let r=ae[0],n=ae[1],s=new we(r,n);return Nn(e,s)&&Nn(t,s)?(ae[0]=r,ae[1]=n,ae[2]=r,ae[3]=n,4):0}function gf(e,t){return Math.abs(e-t)<=1e-6}function Nn(e,t){let i=e.bbox();if(t.x-i.minX>-$g&&t.x-i.maxX<$g&&t.y-i.minY>-$g&&t.y-i.maxY<$g){let r=qt.regularD(t.angleD(e.center));return gf(r,e.startAngle)||gf(r,e.startAngle+360)||gf(r,e.startAngle-360)||gf(r,e.endAngle())||gf(r,e.endAngle()+360)||gf(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 $9(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 E_(a,o,Math.sin(Math.PI/180))}function Z9(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,x,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,x=c-E,{d:Math.sqrt(g*g+x*x),point:new we(y,E)}))}function tc(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"&&eF(r,s)?a=!r[i].call(r,s):a=!(r===s||r.toString()===s.toString()):typeof r=="number"&&typeof s=="number"?a=!(Q9(r,s)||Number.isNaN(r)&&Number.isNaN(s)):a=r!==s,a})}function Q9(e,t,i=5){return Math.abs(e-t)*Math.pow(10,i)<1}function eF(e,t){return!e||!t||typeof e!="object"||typeof t!="object"?e===t:e.constructor===t.constructor}var li=new Float64Array(100);function Cb(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(I){M=Math.min(M,I),k=Math.max(k,I)},o=function(I,N){let v=Kc(I,N);if(v===0)throw new Error("cnt === 0");for(let L=0;L<v;L+=2)a(ae[L])};if(n>r){for(let I=n-2;I>=2;I-=2)for(let N=I-2;N>=0;N-=2)if(Oe.eq(li[I],li[N])&&Oe.eq(li[I+1],li[N+1])){li[N]=(li[I]+li[N])/2,li[N+1]=(li[I+1]+li[N+1])/2;for(let v=n-3;v>=I;v--)li[v]=li[v+2];n-=2;break}if(n>r){n=0;let I=t.start(),N=new Float64Array(8);e.getPercent(I)!==null&&(N[n++]=I.x,N[n++]=I.y);let v=t.end();e.getPercent(v)!==null&&(N[n++]=v.x,N[n++]=v.y);let L=e.start();t.getPercent(L)!==null&&(N[n++]=L.x,N[n++]=L.y);let _=e.end();return t.getPercent(_)!==null&&(N[n++]=_.x,N[n++]=_.y),ae.set(N),n}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let I=Kc(new pe(u[0],u[1]),new pe(h[0],h[1]));for(let N=0;N<I;N++)li[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,x=Math.sqrt(1/(f**2+m**2));f*=x,m*=x,g*=x;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(I=>{let N=f*I.x+m*I.y+g;N<y&&(y=N),N>E&&(E=N)}),Oe.eq(y,E)){if(c.controls.length===2){let I=Kc(new pe(l.start(),l.end()),new pe(c.start(),c.end()));for(let N=0;N<I;N++)li[n++]=ae[N];if(I!==0)continue}l=new lt([u[0],u[u.length-1]]),u=l.controls}let T=h.map(I=>{let N=f*I.x+m*I.y+g,v=Math.abs(N);return v<s&&(s=v),N}),w=0;for(let I of T){if(Oe.less(I,y))w=w|1;else if(Oe.greater(I,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let b=0,C=0,A=p.x-d.x,R=p.y-d.y,O=Math.sqrt(1/(A**2+R**2));A*=O,R*=O;for(let I=1;I<u.length;I++){let N=u[I],v=(N.x-d.x)*A+(N.y-d.y)*R;v<b?b=v:v>C&&(C=v)}w=0;for(let I of h){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(Oe.less(N,b))w=w|1;else if(Oe.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY;s/=2,s<=Oe.eps&&(s=Oe.eps),y-=s,E+=s,T.forEach((I,N)=>{I>=y&&I<=E&&a(N/(T.length-1))});let G=new pe(new we(0,y),new we(1,y)),H=new pe(new we(0,E),new we(1,E));for(let I=0;I<T.length-1;I++){let N=new we(I/(T.length-1),T[I]),v=N.y<y?1:N.y>E?2:3;for(let L=0;L<T.length;L++){let _=new we(L/(T.length-1),T[L]),B=_.y<y?1:_.y>E?2:3;v!==B&&(v===1?B===2?(o(new pe(N,_),G),o(new pe(N,_),H)):o(new pe(N,_),G):v===2?B===1?(o(new pe(N,_),G),o(new pe(N,_),H)):o(new pe(N,_),H):B===1?o(new pe(N,_),G):o(new pe(N,_),H))}}M!==0&&(c=c.clip(M)[1]),k!==1&&(c=c.clip((k-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 I of c.controls){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(Oe.less(N,b))w=w|1;else if(Oe.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let I=new we((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(I)&&(li[n++]=I.x,li[n++]=I.y)}continue}if(k-M>.8){let[I,N]=c.clip(.5);i.push([I,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)ae[a]=li[a];return n}function tF(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(I){M=Math.min(M,I),k=Math.max(k,I)},o=function(I,N){let v=Kc(I,N);if(v===0)throw new Error("cnt === 0");for(let L=0;L<v;L+=2)a(ae[L])};if(n>r){for(let I=n-2;I>=2;I-=2)for(let N=I-2;N>=0;N-=2)if(Oe.eq(li[I],li[N])&&Oe.eq(li[I+1],li[N+1])){li[N]=(li[I]+li[N])/2,li[N+1]=(li[I+1]+li[N+1])/2;for(let v=n-3;v>=I;v--)li[v]=li[v+2];n-=2;break}if(n>r){n=0;let I=new Float64Array(8),N=t.end(),v=0;e.getPercent(N)!==null&&(I[n++]=N.x,I[n++]=N.y,v=2);let L=e.end();return t.getPercent(L)!==null&&(I[n++]=L.x,I[n++]=L.y,v=v===0?1:3),ae.set(I),{havOverlap:v,cnt:n}}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let I=Kc(new pe(u[0],u[1]),new pe(h[0],h[1]));for(let N=0;N<I;N++)li[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,x=Math.sqrt(1/(f**2+m**2));f*=x,m*=x,g*=x;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(I=>{let N=f*I.x+m*I.y+g;N<y&&(y=N),N>E&&(E=N)}),Oe.eq(y,E)){if(c.controls.length===2){let I=Kc(new pe(l.start(),l.end()),new pe(c.start(),c.end()));for(let N=0;N<I;N++)li[n++]=ae[N];if(I!==0)continue}l=new lt([u[0],u[u.length-1]]),u=l.controls}let T=h.map(I=>{let N=f*I.x+m*I.y+g,v=Math.abs(N);return v<s&&(s=v),N}),w=0;for(let I of T){if(Oe.less(I,y))w=w|1;else if(Oe.greater(I,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let b=0,C=0,A=p.x-d.x,R=p.y-d.y,O=Math.sqrt(1/(A**2+R**2));A*=O,R*=O;for(let I=1;I<u.length;I++){let N=u[I],v=(N.x-d.x)*A+(N.y-d.y)*R;v<b?b=v:v>C&&(C=v)}w=0;for(let I of h){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(Oe.less(N,b))w=w|1;else if(Oe.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY;s/=2,s<=Oe.eps&&(s=Oe.eps),y-=s,E+=s,T.forEach((I,N)=>{I>=y&&I<=E&&a(N/(T.length-1))});let G=new pe(new we(0,y),new we(1,y)),H=new pe(new we(0,E),new we(1,E));for(let I=0;I<T.length-1;I++){let N=new we(I/(T.length-1),T[I]),v=N.y<y?1:N.y>E?2:3;for(let L=0;L<T.length;L++){let _=new we(L/(T.length-1),T[L]),B=_.y<y?1:_.y>E?2:3;v!==B&&(v===1?B===2?(o(new pe(N,_),G),o(new pe(N,_),H)):o(new pe(N,_),G):v===2?B===1?(o(new pe(N,_),G),o(new pe(N,_),H)):o(new pe(N,_),H):B===1?o(new pe(N,_),G):o(new pe(N,_),H))}}M!==0&&(c=c.clip(M)[1]),k!==1&&(c=c.clip((k-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 I of c.controls){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(Oe.less(N,b))w=w|1;else if(Oe.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let I=new we((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(I)&&(li[n++]=I.x,li[n++]=I.y)}continue}if(k-M>.8){let[I,N]=c.clip(.5);i.push([I,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)ae[a]=li[a];return{cnt:n}}var iF=class{constructor(e=Oe.eps){this.eps=e}eq(e,t){return Math.abs(e-t)<=this.eps}setEps(e){this.eps=e}},Vg=new iF;function wP(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(!(Vg.eq(li[c],li[u])&&Vg.eq(li[c+1],li[u+1]))){l(li[u],li[u+1],o);break}function l(c,u,h){let d=!1;for(let p=0;p<h.length;p+=2)if(Vg.eq(c,h[p])&&Vg.eq(u,h[p+1])){d=!0;break}d||h.push(c,u)}},o=[li[0],li[1]];if(a(),o.length>=100&&(Vg.setEps(.001),o=[li[0],li[1]],a(),o.length>=100))throw new Error("clearSamePoint()");n=o.length,o.forEach((l,c)=>li[c]=l)}let s=i.pop();if(s[0]instanceof Pe){let a=function(H){R=Math.min(R,H),O=Math.max(O,H)},o=function(H,q){let I=Kc(H,q);if(I===0)throw new Error("cnt === 0");for(let N=0;N<I;N+=2)a(ae[N])},[l,c]=s,u=c.controls;if(u.length===2){let H=TS(l,new pe(u[0],u[1]));for(let q=0;q<H;q++)li[n++]=ae[q];continue}let h=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,p,f,m,g,x;if(Math.abs(l.sweepAngle)>359){let H=l.rx;p=l.center.add1(H,0),f=l.center.add1(-H,0),h=-H,d=H,m=0,g=1,x=-l.center.y}else{p=l.start(),f=l.end(),m=f.y-p.y,g=p.x-f.x,x=-m*p.x-g*p.y;let H=Math.sqrt(1/(m**2+g**2));m*=H,g*=H,x*=H;let q=m*l.center.x+g*l.center.y+x;l.isCCW?(d=l.rx+q,h=0):(h=q-l.rx,d=0)}let y=u.map(H=>m*H.x+g*H.y+x),E=0;for(let H of y){if(Oe.less(H,h))E=E|1;else if(Oe.greater(H,d))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let T=0,w=0,b=f.x-p.x,C=f.y-p.y,A=Math.sqrt(1/(b**2+C**2));if(b*=A,C*=A,Math.abs(l.sweepAngle)<=180)T=0,w=(f.x-p.x)*b+(f.y-p.y)*C;else throw new Error("not support");E=0;for(let H of u){let q=(H.x-p.x)*b+(H.y-p.y)*C;if(Oe.less(q,T))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 R=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;h-=Oe.eps,d+=Oe.eps,y.forEach((H,q)=>{H>=h&&H<=d&&a(q/(y.length-1))});let M=new pe(new we(0,h),new we(1,h)),k=new pe(new we(0,d),new we(1,d));for(let H=0;H<y.length-1;H++){let q=new we(H/(y.length-1),y[H]),I=q.y<h?1:q.y>d?2:3;for(let N=0;N<y.length;N++){let v=new we(N/(y.length-1),y[N]),L=v.y<h?1:v.y>d?2:3;I!==L&&(I===1?L===2?(o(new pe(q,v),M),o(new pe(q,v),k)):o(new pe(q,v),M):I===2?L===1?(o(new pe(q,v),M),o(new pe(q,v),k)):o(new pe(q,v),k):L===1?o(new pe(q,v),M):o(new pe(q,v),k))}}R!==0&&(c=c.clip(R)[1]),O!==1&&(c=c.clip((O-R)/(1-R))[0]);let G=c.bbox();if(Oe.eq(G.minX,G.maxX)&&Oe.eq(G.minY,G.maxY)){E=0;for(let H of c.controls){let q=(H.x-p.x)*b+(H.y-p.y)*C;if(Oe.less(q,T))E=E|1;else if(Oe.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}E===3&&(li[n++]=(G.minX+G.maxX)/2,li[n++]=(G.minY+G.maxY)/2);continue}O-R>.8?c.clip(.5).forEach(H=>i.push([H,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]=li[s];return n}var rF=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 nF(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)}),rF.getSweep(n)}var sF=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?xi.build2(r):null}static zoomPolygon(e,t){let i=new Array,r=new Array,n=new Array;return nF(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?xi.build2(r):null}static zoomLines(e,t){return this.zoomPolygon(xi.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(Al(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=Al(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=Al(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=Al(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 pe)return new pe(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 pe(i,e),n=new pe(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 pe){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")}},Bt=.001,ha=Bt**2;function wt(e,t){return e.distance2(t)<ha}function Zc(e,t){return Math.abs(e-t)<=1e-4}function aF(e,t){if(e instanceof pe)return new pe(e.start(),t);if(e instanceof Pe){let i=t.angleD(e.center);return Zc(qt.regularD(e.startAngle),qt.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 lt)return e.clip(e.getPercent(t,Bt))[0];throw new Error("not supported operation")}}function nc(e,t=qt.toRadians(e.startAngle)){return e.isCCW?t+=Yb:t-=Yb,new we(Math.cos(t),Math.sin(t))}function u0(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 Rf(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,Bt)!==null||new pe(i.start(),i.end()).distance(n)<=Bt)&&(n=e[r+2]),!n)throw Error("getSecondPoint(controls: readonly Vector2[])");return n}function Mt(e,t){if(e instanceof pe)return e.end().sub(e.start()).normalize();if(e instanceof Pe)return(t?nc(e,t.angle(e.center)):nc(e)).normalize();if(e instanceof lt)if(e.controls.length===2){let[i,r]=e.controls;if(wt(i,r))throw Error("equalsPP(p0, p1)");return r.sub(i).normalize()}else return(t?u0(e,e.getPercent(t,Bt)):u0(e)).normalize();else throw new Error("not support")}function oF(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 lF(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)>Bt;)if(c=(n+s)/2,u=e*Math.pow(c,3)+t*Math.pow(c,2)+i*c+r,Math.abs(u)<Bt){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 zw(e,t,i){if(e instanceof pe||t.distance2(i)<=ha)return new pe(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 lt){let r=e.getPercent(t,Bt),n=e.getPercent(i,Bt);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function wS(e){return Oe.greater(e,0)&&Oe.less(e,1)}function jb(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 wS(a)&&o.push(a),o}function Vb(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 wS(a)&&h.push(a),wS(s)&&h.push(s),h}function S_(e,t){if(e.controls.length===2){let[o,l]=e.controls;wt(o,l)||t.push(new pe(o,l));return}let i,r;if(e.controls.length===3){let[o,l,c]=e.controls;i=jb(o,l,c,"x"),r=jb(o,l,c,"y")}else{let[o,l,c,u]=e.controls;i=Vb(o,l,c,u,"x"),r=Vb(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 cF=1e-5,ev=1,lt=class Na extends w0{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 pe(this.start(),this.end())),this._startToEndL}build1(t){let i=[];return kf(t,(r,n)=>(i.push(n),!0)),new Na(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 Na.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 Na(i),new Na(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,x){let y=Kc(g,x);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,x)=>{let y=Math.abs(x);return y<g?y:g},r),r/=2,r<=i&&(r=i),d.forEach((g,x)=>{this.eq(g,0,i)&&s(x/(d.length-1))});let p=new pe(new we(0,-r),new we(1,-r)),f=new pe(new we(0,r),new we(1,r));for(let g=0;g<d.length-1;g++){let x=new we(g/(d.length-1),d[g]),y=this.less(x.y,0,i)?1:this.greater(x.y,0,i)?2:3;for(let E=0;E<d.length;E++){let T=new we(E/(d.length-1),d[E]),w=this.less(T.y,0,i)?1:this.greater(T.y,0,i)?2:3;y!==w&&(y===1?w===2?(a(new pe(x,T),p),a(new pe(x,T),f)):a(new pe(x,T),p):y===2?w===1?(a(new pe(x,T),p),a(new pe(x,T),f)):a(new pe(x,T),f):w===1?a(new pe(x,T),p):a(new pe(x,T),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,x)=>g.ext2(x),new Ka).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,x]=o.clip(.5);g.isInRange(t,i)?(n.push([g,l,(l+c)/2]),x.isInRange(t,i)&&n.push([x,(l+c)/2,c])):n.push([x,(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 Ka().ext3(this.points(.1)).build1()),this._bbox}bboxWithControls(){return this._bbox_controls||(this._bbox_controls=new Ka().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 Na(i)}stroke(t,i,r,n=ev){let s=sF.zoomLines(xi.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 pe(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>cF&&!(n.distance2(Na.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(Na.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),x=Math.sqrt(f**2-4*p*m)/(2*p),y=g+x;y>=0&&y<=1&&c.push(Na.pointOn(y,this.controls));let E=g-x;E>=0&&E<=1&&c.push(Na.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(Na.pointOn(d,this.controls));let p=u-h;p>=0&&p<=1&&c.push(Na.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 pe(n,a)),n=a,s++}while(n!==i[0]);if(r.length===0)throw Error("buildConverxHull(diff = DoubleKit.eps)");return xi.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[Na.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=jb(p,f,m,"x"),c=jb(p,f,m,"y")}else if(o.length===4){let[p,f,m,g]=o;l=Vb(p,f,m,g,"x"),c=Vb(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(Na.pointOn(u,o)),u=l.pop()||1):(d.push(Na.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=oF(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),x=d.sub(h).mul(3),y=h,E=o*m.x+l*m.y,T=o*g.x+l*g.y,w=o*x.x+l*x.y,b=o*y.x+l*y.y+c,C=Math.sqrt(1/(E**2+T**2));E*=C,T*=C,w*=C,b*=C,r=lF(E,T,w,b)}else throw Error("not support getBeizerPointInLine");return r.forEach(h=>{h>=0&&h<=1&&i.push(h)}),i}reverse(){return new Na(this.controls.slice().reverse())}},Vd,v_=(Vd=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 Vd.instance==null&&(Vd.instance=new Vd),Vd.instance}},Vd.instance=null,Vd),pe=class Xd extends w0{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 Xd(this._start,t);return i._a=this._a,i._b=this._b,i._c=this._c,i}return new Xd(this._start,t)}get midPoint(){return this._start.add(this._end).mul(.5)}toBezier(){return new lt([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 Xd(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=v_.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 la(t[0],t[1],t[2],t[3])}return this.__bbox}multiply3(t){return new Xd(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 tc(i,r)||tc(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=xi.build5([u,-l,u,l,h,l,h,-l]):c=xi.build5([u,l,u,-l,h,-l,h,l]):r===0?c=xi.build2([Pe.build3(new we(u,0),-90,-180,l,l),Pe.build3(new we(h,0),90,-180,l,l)]):c=xi.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=rr.rotate(d).translate1(n);return c.asClose().multiply3(p)}points(t){return[this._start,this._end]}mirrorY(t){return new Xd(this.start().mirrorY(t),this.end().mirrorY(t))}reverse(){return new Xd(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,x=f+m.y*i/2,y=g*g+x*x,E=c*c+u*u,T=h*h+d*d,w=Math.abs(c*f-u*p)/2,b=Math.sqrt(p*p+f*f)*i/4;if(w<=b&&E<=y&&T<=y){if(l)return!0;{let C=new we(n,s).sub(o).normalize(),A=new we(n,s).sub(a).normalize(),R=new we(m.x,m.y).cross(C),O=new we(m.x,m.y).cross(A);return R>=0&&O<=0}}else if(l){let C=i/2;return E<=C*C?!0:T<=C*C}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 uF(e,t=.05){if(e.length<3)return e.slice();let i=e.slice(0,1),r=(s,a,o)=>j9(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 hF=E9(T9()),dF=class{constructor(){this.fac=new Ka,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()}},pF=new dF,xi=class Rn{constructor(t,i){this.__bbox=null,this.primitives=t,this.__bbox=i}static calcBBox(t){return pF.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 pe(r,a)),i.push(s),r=s.end(),!0}),i.length===0&&r!=null&&i.push(new pe(r,r)),new Rn(i)}static build2(t){return Rn.build1(xS(t))}static build3(t){let i=[],r=null;return Gb(t,(n,s)=>(r!==null&&i.push(new pe(r,s)),r=s,!0)),new Rn(i)}static build4(t){return this.build3(xS(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 Rn.build4([t.LL(),t.LR(),t.UR(),t.UL(),t.LL()])}static build7(t){return new Rn(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 pe(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 lt([i,c,u,r])),i=r,o+=7;break}default:throw new Error("invalid rawData")}return Rn.build2(n)}static buildBBox(t,i=0){return i===1?Rn.build5([t.minX,t.minY,t.maxX,t.minY,t.maxX,t.maxY,t.minX,t.maxY,t.minX,t.minY]):Rn.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=hF.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){Rn.triangulate([this],(...r)=>{r.forEach(n=>i(n))},t)}mirror(){let t=[];return this.primitives.forEach(i=>{if(i instanceof pe)i=new pe(i.start().mirror(),i.end().mirror());else if(i instanceof Pe)i=i.mirror();else if(i instanceof lt){let r=i.controls.map(n=>n.mirror());i=new lt(r)}else throw new Error("bug");t.push(i)}),new Rn(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 pe){let s=n.start().round(t),a=n.end().round(t);i[r]=new pe(s,a)}else if(n instanceof lt){let s=n.controls.map(a=>a.round(t));i[r]=new lt(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 Rn(i,this.__bbox)}simplify(t=.05){let i=[],r=!1,n=[],s=this.closed();if(this.primitives.length<=1)return Rn.build2(this.primitives);let a=()=>{if(n.length>2){let l=uF(n,t);for(let c=1;c<l.length;c++)i.push(new pe(l[c-1],l[c]))}else i.push(new pe(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 pe?(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 Rn(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 pe){if(n.end().equals1(n.start()))continue;if(i&&(n.end().equals1(i.start())||V9(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 pe)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 lt){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 ca.addAll(s,this.primitives),s.push(new pe(n,r)),Rn.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 ca.addAll(s,this.primitives),s.push(new pe(n,r)),new Rn(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 pe)n=new pe(n.end(),n.start());else if(n instanceof Pe)n=n.exchangeSweep();else if(n instanceof lt)n=new lt(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new Rn(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 pe)n=new pe(n.end(),n.start());else if(n instanceof Pe)n=n.exchangeSweep1();else if(n instanceof lt)n=new lt(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new Rn(t,this.__bbox)}mirrorY(t){let i=[];return this.primitives.forEach(r=>{if(r instanceof pe)r=r.mirrorY(t);else if(r instanceof Pe)r=r.mirrorY(t);else if(r instanceof lt){let n=r.controls.map(s=>s.mirrorY(t));r=new lt(n)}else throw new Error("bug");i.push(r)}),new Rn(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 Rn.build7(i)}bbox(){return this.__bbox==null&&(this.__bbox=Rn.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 Rn&&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(tc(s,r)||tc(s.reverse(),r))return!0;n++}return!1}else return tc(this.primitives,t.primitives)}clone(){return Rn.build2(this.primitives)}putItem(t,i){if(!t)return!1;if(t instanceof Rn)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=la.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=la.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 pe&&t.primitives[0]instanceof pe&&$9([i,r],[n,s])){this.primitives.pop(),t.primitives.shift();let a=[];a.push(new pe(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 lt){let l=[];S_(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 pe)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 lt){if(gP(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 pe)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 lt){if(gP(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}}},pb=Math.PI*2,Ete=Math.PI/2,Tte=Math.sin(Math.PI/180),fF=4,Pe=class _r extends w0{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){qr.positive(r),qr.positive(n);let o=t.equals(i);if(o)return new _r(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),x=m*p+g*f,y=-g*p+m*f;r=Math.abs(r),n=Math.abs(n);let E=r*r,T=n*n,w=x*x,b=y*y,C=s===d?-1:1,A=(E*T-E*b-T*w)/(E*b+T*w);A=A<0?0:A;let R=C*Math.sqrt(A),O=R*(r*y/n),M=R*-(n*x/r),k=(l+u)/2,G=(c+h)/2,H=k+(m*O-g*M),q=G+(g*O+m*M),I=(x-O)/r,N=(y-M)/n,v=(-x-O)/r,L=(-y-M)/n,_,B;B=Math.sqrt(I*I+N*N),_=I,C=N<0?-1:1;let U=qt.toDegrees(C*Math.acos(_/B));B=Math.sqrt((I*I+N*N)*(v*v+L*L)),_=I*v+N*L,C=I*L-N*v<0?-1:1;let z=_/B,W;z<-1?W=Math.acos(-1):z>1?W=Math.acos(1):W=Math.acos(z);let ne=qt.toDegrees(C*W);!d&&ne>0?ne-=360:d&&ne<0&&(ne+=360),qr.normal(U),qr.normal(ne);let me=p*p/E+f*f/T,Ee=t.distance1(i)/2;r<Ee&&n<Ee&&(r*=Math.sqrt(me),n*=Math.sqrt(me));let Se=o?0:qt.regularD(-U),Fe=o?s?360:0:-ne;return new _r(r,n,new we(H,-q),Se,Fe)}}static build2(t,i,r,n,s,a){qr.positive(n),qr.positive(s),qr.normal(i),qr.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 _r(n,s,t,qt.regularD(i),o)}static build3(t,i,r,n,s){return qr.positive(n),qr.positive(s),qr.normal(r),new _r(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 _r.build2(r,o,l,n,s,a)}static build5(t,i,r){r=qt.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=qt.toDegrees(t.angle(u)),d=qt.toDegrees(i.angle(u));return _r.build2(u,h,d,o,o,c)}static buildCircle(t,i,r=0){return _r.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 _r.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,this.rx,this.ry)}exchangeSweepAndStart(){return _r.build1(this.end(),this.start(),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}exchangeSweep1(){return _r.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)?_r.build3(this.center.mirrorY(),0,360,this.rx,this.ry):_r.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)?_r.build3(this.center.mirror(t),0,360,this.rx,this.ry):_r.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=ES.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(rr.ROT_90)?r=qt.regularD(this.startAngle+90):t.equals(rr.ROT_N90)?r=qt.regularD(this.startAngle-90):r=qt.transformD(this.startAngle,t),_r.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 lt([t,t.add(new we(n,0).multiply3(rr.rotateD(this.startAngle+90))),i.add(new we(n,0).multiply3(rr.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(_r.build3(n.center,n.startAngle,a,n.rx,n.ry),s),r(_r.build3(n.center,n.startAngle+a,a,n.rx,n.ry),s)}else t.push(n)}}buildBBox(){let t=v_.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 la(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 Of.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 rr;o<0&&(o=-o,c=c.multiply3(rr.MIRROR_Y)),l<0&&(l=-l,c=c.multiply3(rr.MIRROR_X)),o===0&&(o=.001),l===0&&(l=.001),c=c.setOrigin1(this.center);let u,h;switch(r===this.sweep()?(u=_r.build3(this.center,this.startAngle,this.sweepAngle,s,a),h=_r.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,o,l)):(u=_r.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,s,a),h=_r.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 xi.build2([u,_r.build3(p,m,d,n,n),h,_r.build3(f,g,d,n,n)])}default:return xi.build2([u,h])}}points2(){let t=Math.ceil(Math.abs(this.sweepAngle)/fF),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 _r(this.rx-t,this.ry-t,this.center,this.startAngle,this.sweepAngle):new _r(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),_r.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new _r(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;return i<0?(i=Math.abs(i),_r.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new _r(i,i,this.center,this.startAngle,this.sweepAngle)}}get bulge(){let t=Math.abs(Y9(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 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+pb-t)/2+t;return n.add(new we(Math.cos(a),Math.sin(a)).mul(s))}}else if(i>t){let a=(t+pb-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=qt.regularD(this.startAngle),r=qt.regularD(this.sweepAngle),n=qt.regularD(t.startAngle),s=qt.regularD(t.sweepAngle);return tc([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(tc([r,i],[s,n])||tc([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 tc([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(tc([r,i],[s,n])||tc([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+=pb),o<=l&&p>=o&&p<=l||o>l&&(p>=o&&p<=pb||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),x=r-m.x,y=n-m.y,E=r-g.x,T=n-g.y;return x*x+y*y<=i*i/4?!0:E*E+T*T<=i*i/4}}isCircle(){return(Oe.eq(Math.abs(this.sweepAngle),360)||this._start.equals1(this._end))&&this.rx==this.ry}reverse(){return _r.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}},I_=new ArrayBuffer(24),Xw=new Float64Array(I_),yf=new Int32Array(I_),Ns,wte=(Ns=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=qr.normal(e),this.y=qr.normal(t),this.z=qr.normal(i),Xw[0]=e,Xw[1]=t,Xw[2]=i,this.hashed=yf[0]^yf[1]^yf[2]^yf[3]^yf[4]^yf[5]}isZeroVector(){return this.x===0&&this.y===0&&this.z===0}hashCode(){return this.hashed}equals(e){return e instanceof Ns?e.x===this.x&&e.y===this.y&&e.z===this.z:!1}cross(e){return new Ns(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 Ns(this.x/e,this.y/e,this.z/e)}sub(e){return new Ns(this.x-e.x,this.y-e.y,this.z-e.z)}add(e){return new Ns(this.x+e.x,this.y+e.y,this.z+e.z)}scale(e){return new Ns(this.x*e,this.y*e,this.z*e)}neg(){return new Ns(-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 Ns(t/n,i/n,r/n):new Ns(t,i,r)}rotate(e,t){return this.multiply4(x_.rotateAxis(e,t))}toVector2(){return new we(this.x,this.y)}},Ns.ORIGIN=new Ns(0,0,0),Ns.X_UNIT_VECTOR=new Ns(1,0,0),Ns.Y_UNIT_VECTOR=new Ns(0,1,0),Ns.Z_UNIT_VECTOR=new Ns(0,0,1),Ns),Cn=class If{static build(t){return t instanceof xi?new If([new es([t])]):t instanceof es?new If([t]):t}static buildByPolygon(t){return t?new If([t]):new If([])}static buildByStroke(t,i,r=1,n){return this.buildByPolygon(es.buildByStroke(t,i,r,ev,n))}static buildCircle(t,i){return this.buildByPolygon(es.buildCircle(t,i))}static buildRect(t){return this.buildByPolygon(es.buildRect(t))}static buildBBox(t){return this.buildByPolygon(es.buildBBox(t))}constructor(t){this.items=t.slice()}multiply3(t){return new If(this.items.map(i=>i.multiply3(t)))}bbox(){return this._bbox||(this._bbox=this.items.reduce((t,i)=>t.ext1(i.bbox()),new Ka).build1()),this._bbox}toPolylineGroups(){return this.items.map(t=>t.toPolylineGroup())}},Pr,Fi=(Pr=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 Pr(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 Pr(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15);if(t==6)return new Pr(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 Pr(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 Pr(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15,t);if(e.length==6)return new Pr(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 Pr(e.r,e.g,e.b,t)}static of7(e){return e==null?null:Pr.of3(e)}constructor(e,t,i,r=1){this.r=qr.positiveOr0(e),this.g=qr.positiveOr0(t),this.b=qr.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 Pr(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 Pr(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 Pr(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}},Pr.WHITE=new Pr(1,1,1,1),Pr.BLACK=new Pr(0,0,0,1),Pr.RED=new Pr(1,0,0,1),Pr.GREEN=new Pr(0,1,0,1),Pr.BLUE=new Pr(0,0,1,1),Pr.Gray=Pr.of3("#9966ff"),Pr.Silver=Pr.of3("#D2D2D2"),Pr.Golden=Pr.of3("#DCAA14"),Pr.Pink=Pr.of3("#ffaec9"),Pr),SP=!1,A_=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(SP){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(SP){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)}},a0=class extends A_{constructor(e){super(),this.plGrps=new Array,this.debug=e}onPolylineGroup(e,t){this.plGrps.push(e)}},S0=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}},mF=e=>e!==0,gF=new class extends S0{decide1(e){return e[0]||e[1]}}(2),Db=new class extends S0{decide1(e){return e[0]&&!e[1]}}(2),Pb=new class extends S0{decide1(e){return e[0]&&e[1]}}(2),Ww=new class extends S0{decide1(e){return e[0]&&!e[1]||!e[0]&&e[1]}}(2),yF=(e=>(e[e.UNMARKED=0]="UNMARKED",e[e.INSIDE=1]="INSIDE",e[e.OUTSIDE=2]="OUTSIDE",e[e.INVALID=3]="INVALID",e))(yF||{}),Yf=class Af{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 Ka().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 pe||i.distance2(r)<1e-6)return new pe(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 Ka().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))&&(IF(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=Af.rebuild(this.shape,this.end,this.start),r=new Af(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return ca.addAll(r.connect,this.connect),r}else return this;else if(t===1)if(this.start.y<this.end.y){let i=Af.rebuild(this.shape,this.end,this.start),r=new Af(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return ca.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 Af?!(this.polyGrp!==t.polyGrp||this.polyIndex!==t.polyIndex):!1}bbox(){return this._bbox}toString(){return Of.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 bF(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 xF(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 bf=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=la.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")}},h0=class{constructor(e){this.changed=!1,this.root=new bf,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){ca.remove(this.itemList,e),this.changed=!0}clear(){this.changed=!1,this.root=new bf,this.itemList.length=0}flushWhenNeed(){if(this.changed){let e=new Array;for(let t of this.itemList)e.push(new bf(t));for(;;){let t=this.organize(e);if(t.length>1)e=t;else break}this.root=new bf(e),this.changed=!1}}organize(e){ep(e,xF,0,e.length);let t=e.length,i=[];for(let r=0;r<t;)if(r+this.capacity2<=t){let n=r+this.capacity2;ep(e,bF,r,n);for(let s=r;s<n;s+=this.capacity){let a=new bf(e.slice(s,s+this.capacity));i.push(a)}r=r+this.capacity*this.capacity}else{let n=new bf(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 qw(e,t){EF(e.iterator(),t)}function EF(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var fb=new Error("list is empty"),mb=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}},TF=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")}},wF=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")}},Jd=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 fb;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw fb;return this.remove(e),e.item}addLast(e){return this.first===null||this.last===null?(this.first=new mb(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 mb(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 fb;return this.first.item}getLast(){if(this.last===null)throw fb;return this.last.item}insertAfter(e,t){let i=new mb(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new mb(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 TF(this.first)}listIterator(){return new wF(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 Jw(e){throw new Error("")}var gb=class{constructor(e,t){this.node1=null,this.node2=null,this.key=e,this.value=t}},SF=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},vF=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},zb=class{constructor(){this.innerList=new Jd,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 gb(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 gb){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 Jd;return n.node2=s.add(n),r.node2=s.add(r),this.innerMap[i]=s,null}}if(n instanceof Jd){let s=null;return qw(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 Jw(n)}get(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof gb)return i.key.equals(e)?i.value:null;if(i instanceof Jd){let r=null;return qw(i,(n,s)=>s.key.equals(e)?(r=s.value,!1):!0),r}return Jw(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 gb)return i.key.equals(e)?(this.delete(i),i.value):null;if(i instanceof Jd){let r=null;return qw(i,(n,s)=>s.key.equals(e)?(r=s.value,this.delete(s),!1):!0),r}return Jw(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 SF(this.innerList.iterator())}values(){return new vF(this.innerList.iterator())}entries(){return this.innerList.iterator()}},Ff=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)}}},vP=ca.funcCopy(ep);function IF(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 pe)i=z9(e.shape,t);else if(e.shape instanceof Pe)i=X9(e.shape,t);else throw new Error("not supported operation");return i}var _b=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 h0(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));vP(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);vP(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=Yf.rebuild(e.shape,a,o);l instanceof Pe&&Math.abs(l.sweepAngle)>190&&(l=new pe(a,o));let c=new Yf(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 Ff;for(let i of this.sides){t.add(i);let r=i.bbox().extendOfSize(1e-5),n=i.shape instanceof pe;for(let s of e.search(r))if(!t.contains(s)){let a=s.shape instanceof pe;if(!(n&&a&&i.next!==null&&i.previous!==null&&(i.next.equals(s)||i.previous.equals(s)))){let o=Al(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)}}}}}}},AF=class C_{constructor(t){this.sides=new Ff,this.others=new Ff,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 kf(this.sides,(i,r)=>(t.push(r.shape),!0)),xi.build2(t).asClose()}hashCode(){return this.id}equals(t){return t!=null&&t instanceof C_?this.id===t.id:!1}},D_=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 pe(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 pe)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 pe(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(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 pe(this.prevSide.end,i),t),r=new Yf(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++)):(r=new Yf(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++),this.firstSide=r),this.prevSide=r,this.sides.push(r)}},P_=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}},Xb=new Error,IP=new class extends S0{decide1(e){return e[0]&&e[1]}}(2),CF=new class extends A_{onPolylineGroup(e,t){throw Xb}onSegment(e,t,i,r,n,s){throw Xb}},DF=class{constructor(e,t){this.rtree=e,this.level=t}},PF=class __ extends _b{static isIntersect(t,i,r=ox.DUMMY){let n=new __(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 D_(!1),IP.rule,t,CF)}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 DF(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,Al(r.shape,s.shape)>0)throw Xb}}sweep(t,i,r){let n=la.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),ep(s,(o,l)=>o.getX(r)-l.getX(r),0,s.length);let a=new P_(this.rule,this,r);for(let o of s)a.onEp(o)}},tv=class ku{constructor(t){this.items=new Array(t.length),ca.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 ku(i)}static build2(t){let i=t.map(r=>xi.build8(r));return new ku(i)}static combinePolylineGroupArr(t){let i=[];for(let r of t)i=i.concat(r.items);return new ku(i)}calcBBox(){let t=new Ka;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 ku(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 ku?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;PF.isIntersect(new ku([a]),new ku([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 ku(i)}},_F=ca.funcCopy(ep),LF=ca.funcCopy(ep),OF=ca.funcCopy(ep);function RF(e){return new Array}function NF(e,t){let i=new a0(!1),r=new o0(e,ox.DUMMY,i);for(let n of t)r.addPolyline(n);return r.simplify(),i.plGrps}var o0=class extends _b{constructor(e,t,i){super(new D_(!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,_F(t,_b.sortByBBoxMinY,0,t.length);let r=new Jd;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 P_(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),x=Math.min(s,m);l=this.compareBySweep(t,u,(g+x)/2)}let p=u.shape;if(p instanceof pe&&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 pe)return t.shape instanceof pe?this.getLineAngle(t.shape)-this.getLineAngle(e.shape):-this.compareArcLine(t.shape,e.shape,i);if(t.shape instanceof pe)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(rr.ROT_N90),a=n.start.multiply3(rr.ROT_N90),o=n.end.multiply3(rr.ROT_N90);n=new Yf(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(rr.ROT_90),n=e.start.multiply3(rr.ROT_90),s=e.end.multiply3(rr.ROT_90),a=new Yf(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 pe&&t&&i.length()<=t)return!1}return!0}connectSides(){let e=new zb,t=new h0(10);for(let s of this.finalSides)e.computeIfAbsent(s.start,RF).push(s),t.add(s.start);let i=0,r=new Ff,n=new Array;for(let s of this.finalSides)if(!r.contains(s)){let a=new Ff,o=s.start,l=new Jd;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 AF(t);kf(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];kf(n.sides,(s,a)=>(a.polyGrp!=-2&&t.put(a,a),!0))}let i=new Ff;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;kf(l.others,(h,d)=>{let p=t.get(d);return p!=null&&c.push(p.finalGrp),!0}),LF(c,ca.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());OF(o,_b.sortByBBoxAreaDesc,0,o.length),this.event.onPolylineGroup(new tv(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}},MF=class{constructor(){this.points=[],this.lines=[],this.arcs=[],this.beziers=[],this.listText=[],this.fonts=[]}addPt(e,t=!0){if(e instanceof pe)this.lines.push(e);else if(e instanceof Pe)this.arcs.push(e);else if(e instanceof lt)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}}},zg,v0=(zg=class{constructor(e){this.map=new zb,this.bus=e}initColor(e){return this.map.computeIfAbsent(e,()=>new MF)}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 zg(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 la)this.bbox(e,t);else if(e instanceof w0)this.primitive(e,t);else if(e instanceof xi)this.polyline(e,t);else if(e instanceof es)this.polygon(e,t);else if(e instanceof Cn)this.group(e,t);else if(e instanceof tv)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 pe(new we(e.maxX,e.maxY),new we(e.maxX,e.minY)),t),this.primitive(new pe(new we(e.maxX,e.maxY),new we(e.minX,e.maxY)),t),this.primitive(new pe(new we(e.minX,e.minY),new we(e.maxX,e.minY)),t),this.primitive(new pe(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||"==================")}},zg.colorBuffersMap=[[!0,Fi.BLUE],[!0,Fi.GREEN],[!0,Fi.WHITE],[!0,Fi.RED],[!0,Fi.Golden],[!0,Fi.Gray]],zg.t1=0,zg),BF=0,I0=class SS{constructor(t,i){this.inters=[],this.shape=t,this.start=t.start(),this.end=t.end(),this.judgeOverlapMap=new Map,i&&(this.id=BF++)}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 pe)return new we((i+n)/2,(r+s)/2);if(this.shape instanceof lt){let a=this.shape.getPercent(t,Bt);return lt.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=lx-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 SS.finalAngle(i,a,r)-SS.finalAngle(i,o,r)<=0?-1:1})}else if(this.shape instanceof pe){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 lt){let t=this.shape;this.inters.sort((i,r)=>t.getPercent(i.coord,Bt)-t.getPercent(r.coord,Bt)<=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(xi.build7(o))}),i.push(new es(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(xi.build7(o))}),i.push(new es(n))}),new Cn(i)}static rebuild(t,i,r){let n;if(t instanceof pe||i.distance2(r)<1e-6)n=new pe(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 lt){let s=t.getPercent(i,Bt),a=t.clip(s)[1];n=a.clip(a.getPercent(r,Bt))[0]}else throw new Error("not supported operation");return Mt(t,i).dot(Mt(n,i))<0?null:n}static returnPolyline(t){return xi.build7(t.map(i=>i.shape))}bbox(){return this.shape.bbox()}},kF=(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))(kF||{});function ua(e,t,i){if(e instanceof Pe&&t instanceof Pe)return UF(e,t);if(e instanceof Pe&&t instanceof pe)return DP(e,t);if(e instanceof pe&&t instanceof Pe)return CP(e,t);if(e instanceof pe&&t instanceof pe)return $d(e,t);if(e instanceof lt&&t instanceof pe)return e.controls.length===2||Yu(e)?$d(new pe(e.start(),e.end()),t):L_(e,t);if(e instanceof pe&&t instanceof lt)return t.controls.length===2||Yu(t)?$d(e,new pe(t.start(),t.end())):vS(e,t);if(e instanceof Pe&&t instanceof lt)return t.controls.length===2||Yu(t)?DP(e,new pe(t.start(),t.end())):FF(e,t);if(e instanceof lt&&t instanceof Pe)return e.controls.length===2||Yu(e)?CP(new pe(e.start(),e.end()),t):GF(e,t);if(e instanceof lt&&t instanceof lt)return iv(e,t);throw new Error("not support")}function xf(e,t){return Mt(e,t.start()).dot(Mt(t,t.start()))<=0?!1:ua(e,t).state<=2}function Kw(e,t){let i=t.getPercent(e.end(),Bt);if(i===null)return!1;if(i===0)return!0;let r=t.clip(i)[0],n=e.buildConverxHull(Bt),s=r.buildConverxHull(Bt),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(),x=f.getShape();if(g instanceof pe&&x instanceof pe){let y=m?$d(g,x).state:d.get($d(x,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 I0(p)),d=h[h.length-1];return h.forEach(p=>{d.connect(p),d=p}),h}}function AP(e,t){let i=e.end().distance2(t.center);if(i>(t.rx+Bt)**2||i<(t.rx-Bt)**2||!(wt(e.end(),t.end())||rv(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>Bt&&Wc(e,s))&&!(r-n>Bt&&e.rx+t.rx-r>Bt&&Wc(e,s+180)):!(r-n>Bt&&Wc(e,s))&&!(e.rx+t.rx-r>Bt&&Wc(e,s+180))}else{if(r+n<=Bt)return!0;let s=e.rx>t.rx?e.center.angleD(t.center):t.center.angleD(e.center);return Wc(e,s)?!1:r-n<=Bt?!0:!Wc(e,s+180)}}function FF(e,t){let i=nv(e,t.start()).toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=iv(a,t).state,r!==0)break}return r===2&&n!==i.length-1?{state:1}:{state:r}}function GF(e,t){let i=t.toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=iv(e,a).state,r!==1)break}return r===2&&n!==i.length-1?{state:0}:{state:r}}function iv(e,t){if(e.controls.length===2||Yu(e))return t.controls.length===2||Yu(t)?$d(new pe(e.start(),t.end()),new pe(t.start(),t.end())):vS(new pe(t.start(),e.end()),t);if(t.controls.length===2||Yu(t))return L_(IS(e,t.start()),new pe(t.start(),t.end()));let i=IS(e,t.start());if(Yu(i))return vS(new pe(t.start(),e.end()),t);let r=Kw(i,t),n=Kw(t,i);if(!r&&!n){let s=tF(i,t);if(s.havOverlap){let a=s.havOverlap!==2,o=s.havOverlap!==1;return ju(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,Bt),f=t.getPercent(d,Bt);if(p===0||f===0)continue;let m=p===1?i:i.clip(p)[0],g=f===1?t:t.clip(f)[0];if(Kw(m,g)){let x=Mt(e,d).cross(Mt(t,d));if(x===0){o=i.end(),l=t.end();break}return{state:x<0?3:4}}a()}return(!o||!l)&&(o=Rf(i.controls,i.controls[0],t),l=Rf(t.controls,i.controls[0],i)),{state:o.sub(i.controls[0]).cross(l.sub(i.controls[0]))>0?4:3}}}return ju(e,t,r,n)}function L_(e,t){let i=IS(e,t.start());if(Yu(i))return $d(new pe(i.start(),i.end()),t);let r=R_(i,t),{isIn:n,bezierIsInLeft:s}=O_(t,i);if(!r&&!n){if(s!==void 0)return{state:s?3:4};let a=null,o=e.getPercent(t.start(),Bt)+.01;for(let l=o>1?1:o;l<=1;){let c=lt.pointOn(l,e.controls);if(d0(t,c)>ha){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 ju(i,t,r,n)}function vS(e,t){let{isIn:i,bezierIsInLeft:r}=O_(e,t),n=R_(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=lt.pointOn(a,t.controls);if(d0(e,o)>ha){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 ju(t,e,i,n)}function UF(e,t){let i=AP(nv(e,t.start()),t),r=AP(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>Bt?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)>Bt&&n.dot(e.center.sub(t.center))>0?{state:t.isCCW?3:4,exitIsInvalid:!1}:{state:e.isCCW?3:4,exitIsInvalid:!0}}return ju(e,t,i,r)}function CP(e,t){let i=rc.foot(e,t.center),r=e.end().distance2(t.center),n=e.end().sub(e.start()),s=(t.rx-Bt)**2,a=r<=(t.rx+Bt)**2&&r>=s&&(n.dot(i.sub(t.start()))<=0||e.start().distance2(e.end())<=e.start().distance2(i)||i.distance2(t.center)>=s)&&(wt(e.end(),t.end())||rv(t,e.end())),o=N_(t,e);if(!a&&!o){let l=e.distance2(t.center);return l<=ha?{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 ju(t,e,a,o)}function Wc(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 rv(e,t){return wt(e.end(),t)||wt(e.start(),t)||Wc(e,t.angleD(e.center))}function O_(e,t){let i=e.panDistance(Bt),r=e.panDistance(-Bt),n=PP(t,i),s=PP(t,r);if(!n.length&&!s.length)return{isIn:t.getPercent(e.end(),Bt)!==null};let a=[...n,...s].sort((u,h)=>u.t-h.t),o=new pe(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()+Bt)break;if(l.length===2){let p=(l[1].t*10+l.shift().t*10)/20,f=lt.pointOn(p,t.controls);if(e.distance2(f)>ha)return{isIn:!1,bezierIsInLeft:e.direct.cross(f.sub(e.start()))>0}}}let c=l.length?o.distance(l[0].interP)>=e.length()+Bt:!0;return{isIn:c,bezierIsInLeft:c?void 0:e.direct.cross(l[0].interP.sub(e.start()))>0}}function R_(e,t){if(d0(t,e.end())>ha||e.getToLineMaxDis2(t)>ha)return!1;let i=HF(t,ha);return e.getToLineMaxDis2(i)<=(t.length()+Bt)**2}function N_(e,t){let i=t.end().angleD(t.start()),r=YF(t,e.end());if(r>ha)return!1;if(Wc(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(Wc(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<=ha&&(wt(e.end(),t.end())||AS(t,e.end()))}var M_=(Bt*2)**2;function nv(e,t){if(wt(e.end(),t))return Pe.build3(e.center,e.endAngle(),0,e.rx,e.ry);if(e.start().distance2(t)<M_)return e;let i=qt.regularD(t.angleD(e.center));if(!Wc(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 IS(e,t){if(wt(e.end(),t))return new lt([t,t]);if(e.start().distance2(t)<M_)return e;let i=e.getPercent(t,Bt);if(i===null)throw new Error("!cutBezier(bezier: Bezier, p: Vector2)");return e.clip(i)[1]}function DP(e,t){let i=N_(nv(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-Bt)**2,o=r<=(e.rx+Bt)**2&&r>=a&&(n.dot(s.sub(t.start()))<=0||t.start().distance2(t.end())<=t.start().distance2(s)||s.distance2(e.center)>=a)&&(wt(e.end(),t.end())||rv(e,t.end()));if(!i&&!o){let l=t.distance2(e.center);return l<=ha?{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 ju(t,e,i,o)}function $d(e,t){if(wt(e.end(),t.end()))return ju(e,t,!0,!0);let i=d0(t,e.end())<=ha&&AS(t,e.end()),r=d0(e,t.end())<=ha&&AS(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 ju(e,t,i,r)}function AS(e,t){return rc.foot(e,t).distance2(e.start())<e.end().distance2(e.start())}function ju(e,t,i,r){if(i)return r?wt(e.end(),t.end())?{state:2}:{state:0}:{state:0};if(r)return{state:1};throw new Error("!end1 && !end2")}function d0(e,t){return(e.a*t.x+e.b*t.y+e.c)**2/(e.a**2+e.b**2)}function YF(e,t){return Math.min(e.distance2(t),rc.foot(e,t).distance2(t))}function HF(e,t){let i=e.panDistance(t),r=e.panDistance(-t);return new pe(r.start(),i.start())}function Yu(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)}),Zc(o,l)}function PP(e,t){let i=Al(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 zc=.01,jF=270;function Uh(e){let t=zc**2,i=e.end(),r=[],n=[];for(let p=0,f=e.primitives.length;p<f;p++){let m=function(O,M){return O instanceof pe&&M instanceof pe&&Math.abs(O.direct.cross(M.direct))<Oe.eps&&O.direct.dot(M.direct)>0||O instanceof Pe&&M instanceof Pe&&Math.abs(O.rx-M.rx)<=Oe.eps&&O.center.distance2(M.center)<Oe.eps&&O.isCCW===M.isCCW},g=function(O){if(jo(O,zc))n.push(null);else{if(O instanceof pe)n.push(O);else if(O instanceof Pe&&O.rx===O.ry)h(O,n);else if(O instanceof lt){let M=[];S_(O,M),M.forEach(k=>{let G=k.start(),H=k.end();u(G,H)||n.push(k)})}else throw new Error("not support!");i=T}},x=function(O){if(O instanceof pe)return O.direct.x===0&&O.direct.y===0;if(O instanceof Pe)return O.sweepAngle===0;if(O instanceof lt){let M=new Set(O.controls.map(G=>G.x)),k=new Set(O.controls.map(G=>G.y));return M.size===1&&k.size===1}else throw new Error("not support")},y=e.primitives[p],E=y.start(),T=y.end();if(x(y))continue;u(i,E)||(n.push(new pe(i,E)),i=E);let w=(p+1)%f,b=e.primitives[w];for(;m(y,b)&&(w=(w+1)%f,b=e.primitives[w],b!==y););if(w===(p+1)%f){g(y);continue}if(b===y){if(!(y instanceof Pe)){if(Math.abs(e.area(.1))<t)return null;throw new Error("simplifyPolyline not support")}let O=y instanceof Pe?y.isCCW:e.area(.1)>0;n.length=0;let M=O?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 C=(()=>{if(y instanceof pe)return(O,M)=>{let k=new pe(O,M);return jo(k,zc)?null:[k]};if(y instanceof Pe)return(O,M)=>{let k;if(O.equals1(M)?k=Pe.build3(y.center,y.startAngle,y.sweep()===1?360:-360,y.rx,y.ry):k=Pe.build4(O,M,y.center,y.rx,y.ry,y.sweep()),jo(k,zc))return null;let G=k.pointOn(k.startAngle+k.sweepAngle/2),H=Pe.build4(k.start(),G,y.center,y.rx,y.ry,y.sweep()),q=Pe.build4(G,k.end(),y.center,y.rx,y.ry,y.sweep());return jo(H,zc)||jo(q,zc)?[k]:[H,q]};throw new Error("not support")})(),A=w===0;if(w<p&&!A&&(A=!C(e.primitives[0].start(),e.primitives[w-1].end()),!A)){let O=C(y.start(),e.primitives[f-1].end());if(O)n.push(...O);else{let M=C(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,b=e.primitives[p];let R=C(y.start(),b.end());if(R?(R.forEach(O=>n.push(O)),i=b.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 x=(f+1)%s;if(m=m!=null?m:n[x],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(Mt(g,g.end()).dot(Mt(m,m.start()))<0){if(!u(g.end(),m.start())){let C=new pe(g.end(),m.start());r.push(C);return}let{rebuildPrevPt:T,rebuildNextPt:w,rebuildLinkLine:b}=_P(n[(y-1+s)%s],g,new pe(g.end(),m.start()),m,n[(f+2)%s]);T&&w&&(T!==g?(n[(y+s)%s]=T,r[r.length-1]&&(r[r.length-1]=T)):w!==m&&(n[(f+1)%s]=w,r[0]===m&&(r[0]=w)),b&&r.push(b))}}}}}),r.length===0)return null;u(i,r[0].start())||r.push(new pe(i,r[0].start()));let a=r[r.length-1];if(r.length===1)return a instanceof Pe?xi.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 lt?xi.build7(a.clip(.5)):null;let o=r.map(p=>new VF(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,x=m.pt,y=x.end();if(!l.isConnected&&!y.equals(g.start())){let E=function(w){l.isConnected=!0,l.pt=g=w,l.next.isVisited=!1},T=function(w){l.isConnected=!0,m.pt=w,m.isVisited=!1,l=m};if(g instanceof pe)if(u(y,g.end())){p();continue}else E(new pe(y,g.end()));else if(x instanceof pe){u(x.start(),g.start())?f():T(new pe(x.start(),g.start()));continue}else if(g instanceof lt)if(u(y,g.end())&&!(g.controls.length!==2&&g.getToLineMaxDis2(g.startToEndL)>=t)){p();continue}else E(new lt([y,...g.controls.slice(1)]));else if(x instanceof lt)u(x.start(),g.start())&&!(x.controls.length!==2&&x.getToLineMaxDis2(x.startToEndL)>=t)?f():T(new lt([...x.controls.slice(0,-1),g.start()]));else if(g instanceof Pe&&x instanceof Pe)if(Math.abs(Math.abs(g.sweepAngle)-180)<Math.abs(Math.abs(x.sweepAngle)-180)){let w=Pe.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=Pe.build5(x.start(),g.start(),x.sweepAngle);u(w.start(),w.end())&&!(w.rx>=zc&&Math.abs(w.sweepAngle)>180)?f():T(w);continue}else throw new Error("not support")}if(Mt(g,g.start()).dot(Mt(x,x.end()))<0){let E=function(b,C,A,R,O,M){if(l.next===m){l=null;return}let{rebuildLinkLine:k,rebuildPrevPt:G,rebuildNextPt:H}=_P(b,C,A,R,O);G&&H&&(G!==C&&(m.prev.pt=G),H!==R&&(l.next.pt=H),k?M.pt=k:p())},T=function(){l.next===m?l=null:(l.next.connect(m.prev),l=l.next,l.isConnected=!1,l.isVisited=!1)},w=ua(x.reverse(),g).state;if(w===0){let b=LP(g,x.start(),g.end());if(d(b)){let C=m.prev.pt,A=l.next.pt;if(Mt(A,A.start()).dot(Mt(C,C.end()))>=0){if(T(),!l)break;continue}if(E(m.prev.prev.pt,C,b instanceof pe?b:new pe(b.start(),b.end()),A,l.next.next.pt,l),!l)break}else l.pt=b;f();continue}else if(w===1){let b=LP(x,x.start(),g.end());if(d(b)){let C=m.prev.pt,A=l.next.pt;if(Mt(A,A.start()).dot(Mt(C,C.end()))>=0){if(T(),!l)break;continue}if(E(m.prev.prev.pt,C,b instanceof pe?b:new pe(b.start(),b.end()),A,l.next.next.pt,m),!l)break}else m.pt=b;p();continue}else if(w===2){if(T(),!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 pe(p.end(),p.start())),xi.build7(r)):p instanceof lt?(u(p.start(),p.end())||r.push(new pe(p.end(),p.start())),xi.build7(r)):null}if(e=xi.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)>jF){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>=zc&&Math.abs(p.sweepAngle)>180||p instanceof lt&&p.controls.length!==2&&p.getToLineMaxDis2(new pe(p.start().add1(1,0),p.end()))>=t)}}function jo(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 lt){if(!(e.controls.length!==2&&e.getToLineMaxDis2(new pe(e.start().add1(1,0),e.end()))>=t))return!0}else return!0;return!1}function Ef(e){if(e.direct.x===0&&e.direct.y===0)throw Error("getEndOfExtendLine(line: Line, distance: number)");let t=Math.abs(zc-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 _P(e,t,i,r,n){if(!e)a();else if(!n)o();else{let l=Mt(e,e.end()),c=Mt(t,e.end()),u=l.dot(c);if(u>=0)a();else{let h=Mt(r,r.end()),d=Mt(n,r.end()),p=h.dot(d);if(p>=0)o();else if(Zc(u,-1)&&Zc(p,-1)){let f=i.center();s(f),i=null}else u>p?a():o()}}function s(l){let c;if(t instanceof pe)c=new pe(t.start(),l);else if(t instanceof lt)c=new lt([...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=jo(c,Bt)?null:c;let u;if(r instanceof pe)u=new pe(l,r.end());else if(r instanceof lt)u=new lt([l,...r.controls.slice(1)]);else if(r instanceof Pe)u=Pe.build5(l,r.end(),r.sweepAngle);else throw new Error("supported");r=jo(u,Bt)?null:u}function a(){if(t instanceof pe){let l=Ef(i.reverse());i=new pe(l,i.end());let c=new pe(t.start(),l);t=jo(c,Bt)?null:c}else if(t instanceof lt){let l=Ef(i.reverse());i=new pe(l,i.end());let c=new lt([...t.controls.slice(0,-1),l]);t=jo(c,Bt)?null:c}else if(t instanceof Pe){let l=Ef(i.reverse());i=new pe(l,i.end());let c=Pe.build5(t.start(),l,t.sweepAngle);t=jo(c,Bt)?null:c}else throw new Error("not supported")}function o(){if(r instanceof pe){let l=Ef(i);i=new pe(i.start(),l);let c=new pe(l,r.end());r=jo(c,Bt)?null:c}else if(r instanceof lt){let l=Ef(i);i=new pe(i.start(),l);let c=new lt([l,...r.controls.slice(1)]);r=jo(c,Bt)?null:c}else if(r instanceof Pe){let l=Ef(i);i=new pe(i.start(),l);let c=Pe.build5(l,r.end(),r.sweepAngle);r=jo(c,Bt)?null:c}else throw new Error("not supported")}return{rebuildPrevPt:t,rebuildNextPt:r,rebuildLinkLine:i}}function LP(e,t,i){if(e instanceof pe||t.distance2(i)<=ha)return new pe(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 lt){let r=e.getPercent(t,Bt),n=e.getPercent(i,Bt);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}var VF=class{constructor(e){this.pt=e}connect(e){this.prev=e,e.next=this}};function Wb(e){let t=A0(),i;if(e instanceof xi){let r=Uh(e);if(r===null)return null;i=r}else if(e instanceof es){let r=e.items.map(n=>Wb(n)).filter(n=>n!==null);if(r.length===0)return null;i=new es(r)}else{let r=e.items.map(n=>Wb(n)).filter(n=>n!==null);if(r.length===0)return null;i=new Cn(r)}return Jc.preprocessPolyline+=Bh(t),i}var Jc={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 A0(){return{timeIndex:Object.assign({},Jc),start:performance.now()}}function OP(e){return Object.values(e).reduce((t,i)=>t+i,0)}function Bh(e){return performance.now()-e.start-(OP(Jc)-OP(e.timeIndex))}function Es(e,t,i,r){let n=Fi.RED,s=Fi.Golden;function a(){if(!r)return;let d=r.initColor(Fi.Golden);d.addPt(o),d.addPoint(o.end()),r.initColor(Fi.RED).addPt(l),r.draw();debugger}let o=e.getShape(),l=i?t.getShape():t.getShape().reverse(),c=Mt(o,l.start()),u=Mt(l),h=c.cross(u);if(Zc(h,0))if(o instanceof pe)if(l instanceof pe){if(Oe.eq(h,0)&&(c.dot(u)>0?!wt(o.end(),l.start()):!wt(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 lt){let d=l.getExtremePoints(o),p=d.length?d[0]:Rf(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 pe)return o.isCCW;if(l instanceof Pe){if(l.center.equals1(o.center)&&(c.dot(u)>0?!wt(o.end(),l.start())&&o.end().sub(l.start()).dot(u)>0:!wt(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 lt)if(l instanceof pe){let d=o.getPercent(l.start(),Bt),p=o.clip(d)[1],f=p.getExtremePoints(l);return(f.length?f[0]:Rf(p.controls,l.start())).sub(l.start()).cross(u)<0}else if(l instanceof lt){let d=o.getPercent(l.start(),Bt),p=o.clip(d)[1],f=p.getExtremePoints(new pe(l.start(),l.end())),m=l.getExtremePoints(new pe(p.start(),p.end())),g=f.length?f[0]:Rf(p.controls,l.start()),x=m.length?m[0]:Rf(l.controls,l.start()),y=g.sub(l.start()),E=x.sub(l.start());return y.cross(E)<0}else throw Error("not support");else throw new Error("not support");else return h<0}function tp(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Pe?nc(s,qt.toRadians(s.endAngle())):s instanceof lt?u0(s,1):s.end().sub(s.start()).normalize(),l=Mt(a),c=o.dot(l);if(Zc(c,-1))return Es(e,t,!0,n)?Es(e,i,r,n)&&Es(t,i,r,n):Es(e,i,r,n)||Es(t,i,r,n);{let u=o.scale(-1).angle(we.ORIGIN),h=l.angle(we.ORIGIN);u>h&&(u-=lx);let d=(u+h)/2,p=new we(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=Mt(f);return p.cross(m)<0?Es(e,i,r,n):Es(t,i,r,n)}}function $w(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Pe?nc(s,qt.toRadians(s.endAngle())):s instanceof lt?u0(s,1):s.end().sub(s.start()).normalize(),l=Mt(a),c=o.dot(l);if(Zc(c,-1))return Es(e,t,!0,n)?Es(e,i,r,n)&&Es(t,i,r,n):Es(e,i,r,n)||Es(t,i,r,n);{let u=o.scale(-1).angle(we.ORIGIN),h=l.angle(we.ORIGIN);u>h&&(u-=lx);let d=(u+h)/2,p=new we(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=Mt(f);if(p.cross(m)<0){let g=o.dot(m)<0,x=ua(g?e.getShape().reverse():e.getShape(),f).state;return x!==3&&x!==4?Es(e,i,r,n):x===(g?4:3)}else{let g=l.dot(m)<0,x=ua(g?t.getShape().reverse():t.getShape(),f).state;return x!==3&&x!==4?Es(t,i,r,n):x===(g?4:3)}}}var zF=(e=>(e[e.NOT_IN=0]="NOT_IN",e[e.IS_IN=1]="IS_IN",e[e.IS_OVERLAP=2]="IS_OVERLAP",e))(zF||{}),XF=(e=>(e[e.AllClear=0]="AllClear",e[e.MapClear=1]="MapClear",e))(XF||{}),qc,Fh=!1;function Vo(e,t,i,r,n,s,a,o=i.side===t,l=!0,c){return qc=n,Fh=s,B_(k_(e,t,l,c,a,i,o,r),i,o,r,0)}function Fu(e,t,i,r,n,s,a,o=r.side===i){qc=n,Fh=s;let l=F_(e,t,i,new Map,r,o,a),c=l instanceof Array?-1:1;return B_(l,r,o,a,c)}function B_(e,t,i,r,n){for(;e instanceof Array;)n++,e.length===4?e=F_(...e,t,i,r):e=k_(...e,t,i,r);return{...e,existOverlap:n>0}}function k_(e,t,i,r,n,s,a,o){if(qb===-1){o.initColor(Fi.RED).addPt(e.getShape()),o.initColor(Fi.Golden).addPt(t.getShape()),o.draw();debugger}let l=e.getShape(),c=a?t.getShape().reverse():t.getShape(),u=(l instanceof Pe?nc(l,i?c.start().angle(l.center):r?qt.toRadians(l.endAngle()):void 0):l instanceof lt?Mt(l,i?c.start():r?l.end():l.start()):l.end().sub(l.start())).normalize(),h=(c instanceof Pe?nc(c,i?void 0:(r?l.end():l.start()).angle(c.center)):c instanceof lt?Mt(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,Zc(f,0))return{state:Es(e,t,!a,o)?1:0,inter:Gu(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 pe&&wt(rc.foot(l,c.start()),r?l.end():l.start()))m=!1;else if(l instanceof Pe||l instanceof lt){let g=r?l.reverse():l,x=ua(c,aF(g,c.start()).reverse()).state;(x===1||x===2)&&(m=!1)}if(m){let g=!r;f=ua(g?l.reverse():l,c,o).state===(g?4:3)?1:0}else r?f=tp(e,e.nextSide,t,!a,o)?1:0:f=tp(e.prevSide,e,t,!a,o)?1:0;return{state:f,inter:Gu(e,t,s,a,i,r,n)}}else return r?{state:Es(e,e.nextSide,!0,o)?0:1,inter:Gu(e,t,s,a,i,r,n),isReversed:!0}:{state:Es(e.prevSide,e,!0,o)?0:1,inter:Gu(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)&&!Fh){let f=e.judgeOverlapMap.get(t);d=r?p.get(f.state):f.state}else d=ua(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)&&!Fh){let f=t.judgeOverlapMap.get(e);d=a?p.get(f.state):f.state}else d=ua(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 x=m.length-1;x>=0;x--){let y=m[x];if(!(f.getShape()instanceof lt)&&!wt(g,y.coord))break;if(y===s)return{state:2,inter:Gu(e,t,s,a,i,r,n)}}}if(d===3||d===4)return{state:d===(r?4:3)?1:0,inter:Gu(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 Gu(e,t,i,r,n,s,a){if(Fh)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)&&wt(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&&wt(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,x=u(m.coord);if(g===x&&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 x=g.getBindedInter().side;if(a.get(t).mapSideList.includes(x)||wt(g.coord,x.getEnd())&&a.get(t).mapSideList.includes(x.nextSide))return d(g);if(a.has(x)){let y=t.getShape().reverse(),E=Mt(y,g.coord).dot(Mt(x.getShape(),g.coord))<0,T=E?x.getShape().reverse():x.getShape(),w=ua(y,E?zw(T,g.coord,T.end()):zw(T,T.start(),g.coord)).state;if(w===1||w===2)return d(g)}else a.has(x.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&&wt(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,x=u(m.coord);if(g===x&&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 x=g.getBindedInter().side;if(a.get(t).mapSideList.includes(x)||wt(g.coord,g.getBindedInter().side.getEnd())&&a.get(t).mapSideList.includes(x.nextSide))return d(g);if(!a.has(x)&&a.has(x.prevSide)){let y=t.getShape().reverse(),E=Mt(y,g.coord).dot(Mt(x.getShape(),g.coord))<0;if(a.has(x.prevSide)){let T=E?x.getShape().reverse():x.getShape(),w=ua(t.getShape(),zw(T,g.coord,T.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!==(wt(p.coord,e.prevSide.getEnd())?e.prevSide:e))return!1;let f;if(n){if(wt(p.coord,l.start()))return!0;f=ua(s?o.reverse():o,m(l)).state}else{if(wt(p.coord,s?o.end():o.start()))return!0;f=ua(l,m(s?o.reverse():o)).state}return f===2||f===1;function m(g){if(g instanceof pe)return wt(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 lt)return g.clip(g.getPercent(p.coord,Bt))[0];throw new Error("not supported operation")}}function d(p){let f=i.getBindedInter(),m=i.side,g=f.side,x=i===p,y=i;if(r){let E=i.getIndex()-1;for(;m;){let T=m.inters;for(;E>=0;E--)if(i=T[E],i===p){x||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(qc===0)!i.isInvalid&&(!wt(i.coord,p.coord)||i.side===p.side&&i.getBindedInter().side===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(qc===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 T=m.inters;for(;E<T.length;E++){i=T[E];let w=i.getBindedInter();if(i===p){x||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(qc===0)!i.isInvalid&&(!wt(i.coord,p.coord)||m===p.side&&(wt(w.side.getEnd(),i.coord)?w.side.nextSide:w.side)===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(qc===1){let b=w.side;a.has(m)&&a.get(m).mapSideList.includes(b)&&(i.setIsInvalid(),i.isDealed(),y=i)}}m=m==null?void 0:m.nextSide,E=0}}if(qc===0&&!wt(f.coord,p.coord))if(n?a.has(g)?a.get(g).sideIsReversed:s:c){let E=f.getIndex()-1;for(;g;){let T=a.has(g),w=g.inters;for(;E>=0;E--){if(f=w[E],f===p.getBindedInter()){g=null;break}f.isInvalid||!T||(!wt(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 T=g.inters,w=a.has(g);for(;E<T.length;E++){if(f=T[E],f===p.getBindedInter()){g=null;break}let b=wt(g.getEnd(),f.coord)?a.has(g.nextSide):!1;f.isInvalid||!(w||b)||(!wt(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 F_(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?nc(o,c.start().angle(o.center)):o instanceof lt?Mt(o,c.start()):o.end().sub(o.start())).normalize(),h=(l instanceof Pe?nc(l,c.start().angle(l.center)):l instanceof lt?Mt(l,c.start()):l.end().sub(l.start())).normalize(),d=u.dot(h);if(Zc(d,-1)){let p=s?i.getShape().reverse():i.getShape(),f=Mt(p).normalize(),m=u.add(h.scale(-1)).normalize().dot(f),g=ua(o.reverse(),l,a).state;if(m>-.9&&(g===3||g===4))return{state:g===4?0:1,inter:Gu(t,i,n,s,!0,!1,r)};let x=Vo(e,i,n,a,qc,Fh,r.size===0?new Map:r,s);return x.state===2?x:g===4?x.state===0||x.inter!==n?x:Vo(t,i,n,a,qc,Fh,r.size===0?new Map:r,s):x.state===1||x.inter!==n?x:Vo(t,i,n,a,qc,Fh,r.size===0?new Map:r,s)}else{let p=u.scale(-1).angle(we.ORIGIN),f=h.angle(we.ORIGIN);p>f&&(p-=lx);let m=(p+f)/2,g=new we(Math.cos(m),Math.sin(m)),x=Mt(c).normalize(),y=x.angle(we.ORIGIN),E=p<y&&y<f&&o instanceof pe&&l instanceof pe&&c instanceof pe;if(g.cross(x)<=0){if(u.scale(-1).dot(x)<0){let T;return n.coord.equals1(c.start())?T=Mt(o,n.coord).dot(Mt(c,n.coord))<0:c instanceof pe&&(T=Mt(o,o.end()).dot(c.direct)<0),{state:tp(e,t,i,!s,a)?1:0,inter:Gu(e,i,n,s,!0,T,r)}}return E&&o.distance2(c.start())>ha?[t,i,!0,void 0,r]:[e,i,!0,void 0,r]}else return h.dot(x)<=0?{state:tp(e,t,i,!s,a)?1:0,inter:Gu(t,i,n,s,!0,void 0,r)}:E&&l.distance2(c.start())>ha?[e,i,!0,void 0,r]:[t,i,!0,void 0,r]}}var qb=0;function WF(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(Fi.RED).addPt(o),r.initColor(Fi.Golden).addPt(l),r.draw();debugger}let c=0,u=!1;if(e===-1){let C=Fu(s,s.nextSide,a,n,c,u,r),A=C.state!==0;if(C.state===2){let O=Mt(o,t.coord).add(Mt(s.nextSide.getShape(),t.coord)).normalize(),M=Mt(l,t.coord).add(Mt(a.nextSide.getShape(),t.coord)).normalize();return b(A,O.dot(M)>0)}let R=Fu(s,s.nextSide,a.nextSide,n,c,u,r);return C.state!==R.state?(w(C,R),1):b(A,C.state!==Fu(a,a.nextSide,s,t,c,!0,r).state,C.inter,R.inter)}if(e===1){let C=Vo(s,a,n,r,c,u,new Map),A=C.state!==0;if(C.state===2)return b(A,Mt(o,t.coord).dot(Mt(l,t.coord))>0);let R;if(C.isReversed&&C.existOverlap&&wt(C.inter.coord,a.getEnd())&&C.inter.getBindedInter().side!==s){let k=C.inter.getBindedInter().side;if(k===s.nextSide)R={state:tp(s,k,a.nextSide,!0,r)?1:0,inter:n};else if(k===s.prevSide){if(R={state:tp(k,s,a.nextSide,!0,r)?1:0,inter:C.inter},C.state===R.state&&t!==C.inter){let G=Mt(l,t.coord),H=Mt(a.nextSide.getShape(),t.coord),q=Mt(k.getShape(),t.coord);return b(A,G.add(H).dot(q)>0,C.inter,R.inter)}}else R=Vo(s,a.nextSide,n,r,c,u,new Map)}else R=Vo(s,a.nextSide,n,r,c,u,new Map);if(C.state!==R.state)return w(C,R),1;let O=Mt(l,t.coord),M=Mt(a.nextSide.getShape(),t.coord);if(Zc(O.dot(M),-1)){let k=Es(a,a.nextSide,!0,r);return b(A,C.state!==Vo(a.nextSide,s,t,r,c,!0,new Map,k?!A:A,!1).state,C.inter,R.inter)}else{let k=Mt(o,t.coord);return b(A,O.add(M).dot(k)>0,C.inter,R.inter)}}if(!(o instanceof lt||l instanceof lt))return 1;let h=Mt(o,t.coord),d=Mt(l,t.coord),p,f;if(l instanceof pe)p=new pe(t.coord,l.start()),f=new pe(t.coord,l.end());else if(l instanceof Pe){let C=t.coord.angleD(l.center);p=Pe.build2(l.center,C,l.startAngle,l.rx,l.ry,l.isCCW?0:1),f=Pe.build2(l.center,C,l.endAngle(),l.rx,l.ry,l.isCCW?1:0)}else if(l instanceof lt){let C=l.getPercent(t.coord,Bt);[p,f]=l.clip(C),p=p.reverse()}else throw new Error("not support");let m=h.dot(d)>0,g,x;m?(g=ua(o.reverse(),p).state,x=ua(o,f).state):(g=ua(o,p).state,x=ua(o.reverse(),f).state);let y;g===0?y=Vo(m?s.prevSide:s.nextSide,a,n,r,c,u,new Map,!0,!1,m):g===1?y=Vo(s,a.prevSide,n,r,c,u,new Map,!0,!0,m):g===2?m?y=Fu(s.prevSide,s,a.prevSide,n,c,u,r,!0):y=Fu(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 b(E,m);let T;if(x===0?T=Vo(m?s.nextSide:s.prevSide,a,n,r,c,u,new Map,!1,!1,!m):x===1?T=Vo(s,a.nextSide,n,r,c,u,new Map,!1,!0,!m):x===2?m?T=Fu(s,s.nextSide,a.nextSide,n,c,u,r,!1):T=Fu(s.prevSide,s,a.nextSide,n,c,u,r,!1):m?x===3?T={inter:n,state:1}:T={inter:n,state:0}:x===3?T={inter:n,state:0}:T={inter:n,state:1},y.state===T.state)return y.inter===T.inter?(t.setIsInvalid(),0):b(E,m,y.inter,T.inter);return w(y,T),1;function w(C,A){let R=C.state!==0;if(C.inter===A.inter){t.setOutToIn(R);return}else Tf(C.inter,A.inter,!0),Tf(A.inter,C.inter,!1);let O=[];if(e===-1){let k=Mt(o,t.coord),G=Mt(s.nextSide.getShape(),t.coord),H=Mt(l,t.coord),q=Mt(a.nextSide.getShape(),t.coord);O.push(k.dot(H)),O.push(k.dot(q)),O.push(G.dot(H)),O.push(G.dot(q))}else{let k=Mt(o,t.coord);O.push(Mt(l,t.coord).dot(k)),O.push(Mt(a.nextSide.getShape(),t.coord).dot(k))}if(O.reduce((k,G)=>Math.abs(k)>Math.abs(G)?k:G,0)>0)if(i===1||i===0||i===2||i===3)t.setOutToIn(R);else throw new Error("not support");else if(i===1)M(!R);else if(i===0||i===2||i===3)M(R);else throw new Error("not support");function M(k){t.setIsInvalid();let G=(k?C:A).inter;delete G.isInvalid,delete G.getBindedInter().isInvalid,G.setOutToIn(!R)}}function b(C,A,R,O){if(R===O){if(t.side.outline.inters.find(G=>!G.isInvalid&&G!==t&&wt(G.coord,t.coord)))return t.setIsInvalid(),0;let M=new Uu(t.coord,s,r),k=new Uu(t.coord,a,r);return M.bind(k),A?s.inters.splice(t.getIndex(),0,M):s.inters.splice(t.getIndex()+1,0,M),a.inters.splice(t.getBindedInter().getIndex(),0,k),M.setOutToIn(C),t.setOutToIn(!C),M.isDealed(),s.inters.forEach((G,H)=>G.setIndex(H)),a.inters.forEach((G,H)=>G.setIndex(H)),2}else{let M=function(){let k=R.getBindedInter(),G=O.getBindedInter();delete R.isInvalid,delete k.isInvalid,delete O.isInvalid,delete G.isInvalid,R.setOutToIn(!C),O.setOutToIn(C),Tf(R,O,!0),Tf(O,R,!1),Tf(k,G,A),Tf(G,k,!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 C?0:(M(),2);if(i===0||i===2||i===3)return C?(M(),2):0;throw new Error("not support")}}}}function Tf(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(!wt(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 RP=0,Uu=class{constructor(e,t,i){this.id=RP++,this.coord=e,this.side=t,i&&(this.id=RP++,this.drawDebug=i);let r=new Ka;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 pe)return e.end().sub(e.start());if(e instanceof Pe){let t=this.coord.angle(e.center);return e.isCCW?t+=Yb:t-=Yb,new we(Math.cos(t),Math.sin(t))}else{if(e instanceof lt)return u0(e,e.getPercent(this.coord,Bt));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){Zw++;let r=Zw===-1,n=this.drawDebug.initColor(Fi.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=I0.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:Zw,handleId:qb,boolId:Qg})),new Error("inter !== this");return Uh(xi.build7(e))}},Zw=0,Qw=class CS{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 I0(l,n)),o=a[a.length-1];return a.forEach(l=>{o.connect(l),o=l}),s?new CS(a,t,i,r,s):new CS(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(Bt).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 xi.build7(t)}};function NP(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(Bt)).filter(l=>l.bbox().extendOfSize(Bt).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 qF(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 h0(10),s=new h0(10);e.forEach(o=>o.forEach(l=>n.add(l))),t.forEach(o=>o.forEach(l=>s.add(l)));let a=NP(e,s,r);return NP(t,n,(o,l)=>r(l,o)).forEach(o=>a.push(o)),a}var JF=class{constructor(e){this.roots=[],this.nodes=e.sort((t,i)=>t.bbox().minX-i.bbox().minX).map(t=>new KF(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}},KF=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 es(r):i}else return new es(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 MP(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 pe)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 lt)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 BP(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 x=r(d);p.push(x),d.length=0}d.push(g);continue}d.push(Number(g))}d.length&&(p.push(r(d)),d.length=0);let f=xi.build7(p);o.push(f)});let l=new es(o);i.push(l)}),new Cn(i);function r(n){let s=n[0];if(s==="Line")return new pe(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 lt(a)}else throw new Error("not support")}}var $F=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 BP(this.group1Str)}getGroup2(){return BP(this.group2Str)}},eS=new ox(2),Zg=class{getUnion(e,t=!0){return t&&(e=e.map(i=>this.asSameSweep([i])[0])),NF(mF,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 a0(!1),r=new o0(Db.rule,eS,i);for(let n of e){let s=Db.weight(0);r.addPolyline(n,s)}for(let n of t){let s=Db.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getIntersection(e,t){let i=new a0(!1),r=new o0(Pb.rule,eS,i);for(let n of e){let s=Pb.weight(0);r.addPolyline(n,s)}for(let n of t){let s=Pb.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getMutuallyExclusive(e,t){let i=new a0(!1),r=new o0(Ww.rule,eS,i);for(let n of e){let s=Ww.weight(0);r.addPolyline(n,s)}for(let n of t){let s=Ww.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}},Qg=0,tS=!1;function e0(e,t,i,r,n){let s=A0(),a=[],o=[],l=[],c=new Set,u;if(n){if(u=new v0(n),Qg++,tS){debugger;tS=!1;let T=new $F;e0(T.rule,T.getGroup1(),T.getGroup2(),r,n)}if(Qg===-1||tS){console.table({rule:e,group1:MP(t),group2:MP(i)}),u.clear();let T=u.initColor(Fi.GREEN),w=u.initColor(Fi.WHITE),b=u.initColor(Fi.BLUE),C=u.initColor(Fi.Gray);t.items.forEach(A=>A.items.forEach((R,O)=>{O>0?w.addPly(R):T.addPly(R)})),i.items.forEach(A=>A.items.forEach((R,O)=>{O>0?C.addPly(R):b.addPly(R)})),u.draw();debugger}}let h=t.items.length!==0&&i.items.length!==0?t.bbox().extendOfSize(Bt).intersection1(i.bbox().extendOfSize(Bt)):null;if(h){let T=[],w=[];switch(e){case 0:{for(let b of t.items)b.bbox().isIntersect(h)&&T.push(b);for(let b of i.items)b.bbox().isIntersect(h)&&w.push(b);break}case 1:case 3:{for(let b of t.items)b.bbox().isIntersect(h)?T.push(b):a.push(b);for(let b of i.items)b.bbox().isIntersect(h)?w.push(b):a.push(b);break}case 2:{for(let b of t.items)b.bbox().isIntersect(h)?T.push(b):a.push(b);for(let b of i.items)b.bbox().isIntersect(h)&&w.push(b);break}default:throw new Error("not support")}T.length!==t.items.length&&(t=new Cn(T)),w.length!==i.items.length&&(i=new Cn(w))}else{switch(e){case 0:break;case 1:case 3:{t.items.forEach(T=>a.push(T)),i.items.forEach(T=>a.push(T));break}case 2:{t.items.forEach(T=>a.push(T));break}default:throw new Error("not support")}t=new Cn([]),i=new Cn([])}y(t,o,!0),y(i,l,!1);let d=e===2||e===3?(T,w)=>wt(T.getEnd(),w)?T.nextSide:T:(T,w)=>wt(T.prevSide.getEnd(),w)?T.prevSide:T,p=(T,w,b)=>{if(wt(T.getEnd(),b)){if(T.inters.findIndex(C=>C.getBindedInter().side===w&&wt(C.coord,T.getEnd()))===-1)return new Uu(b,T,u)}else return new Uu(b,T,u)},f=e===2||e===3?(T,w,b)=>{if(wt(T.getStart(),b)){if(T.inters.findIndex(C=>C.getBindedInter().side===w&&wt(C.coord,T.getStart()))===-1)return new Uu(b,T,u)}else return new Uu(b,T,u)}:p;r.seek(t,i,(T,w,b,C,A,R)=>{let O=o[T][w],M=l[C][A],k=O.sides[b],G=M.sides[R],H=Al(k.getShape(),G.getShape());if((k.getShape()instanceof lt||G.getShape()instanceof lt)&&H>=4){if(k.getShape()instanceof Pe||G.getShape()instanceof Pe){let I=function(v,L){let _=!1;for(let B=0;B<L.length;B+=2)wt(new we(L[B],L[B+1]),v)&&(_=!0);_||L.push(v.x,v.y)},N=[ae[0],ae[1]];for(let v=0;v<H;v+=2){let L=new we(ae[v],ae[v+1]);for(let _=v+2;_<H;_+=2){let B=new we(ae[_],ae[_+1]);if(!wt(L,B)){I(B,N);break}}}H=N.length,N.forEach((v,L)=>ae[L]=v)}else for(let I=H-2;I>=2;I-=2)for(let N=I-2;N>=0;N-=2)if(wt(new we(ae[I],ae[I+1]),new we(ae[N],ae[N+1]))){ae[N]=(ae[I]+ae[N])/2,ae[N+1]=(ae[I+1]+ae[N+1])/2;for(let v=H-3;v>=I;v--)ae[v]=ae[v+2];H-=2;break}}let q=0;if(H===4){let I=function(L){return wt(k.getEnd(),L)||wt(k.prevSide.getEnd(),L)||wt(G.prevSide.getEnd(),L)||wt(G.getEnd(),L)},N=new we(ae[0],ae[1]),v=()=>{let L=new Uu(N,k,u),_=new Uu(N,G,u);L.bind(_),L.setIsInvalid(),L.isDealed(),O.inters.push(L),M.inters.push(_)};if(ae[0]===ae[2]&&ae[1]===ae[3])if(I(N))q=2;else{v();return}}for(;q<H;q+=2){let I=new we(ae[q],ae[q+1]),N=k,v=G;if(wt(N.prevSide.getEnd(),I)&&(N=N.prevSide),v=d(v,I),k!==N&&G!==v){let _=e===2||e===3?G.getEnd():v.getEnd();N.getEnd().distance1(I)<_.distance1(I)?(I=N.getEnd(),wt(_,I)||(v=G)):(I=_,wt(N.getEnd(),I)||(N=k))}let L=p(N,v,I);if(L){let _=f(v,N,I);_&&(N.addInter(L),O.inters.push(L),v.addInter(_),M.inters.push(_),L.bind(_),O.intersect(M,c))}}return H},n);let m=E(),g=qF(o,l,e);g.forEach(T=>!T.startAndEndIsSameOutsideFlag()&&T.reverse()),new JF(m.concat(g)).getPolygons().forEach(T=>a.push(T));let x=new Cn(a);if(u){if(Qg===-1){let T=u.initColor(Fi.RED),w=u.initColor(Fi.Golden);a.forEach(b=>{T.addPly(b.items[0]),b.items.slice(1).forEach(C=>w.addPly(C))}),u.draw();debugger;throw new Error}x.id=Qg}return Jc.BooleanTools+=Bh(s),x;function y(T,w,b){T.items.forEach(C=>{let A=[];A.push(Qw.build(C.items[0],b,!0,u,C)),C.items.slice(1).forEach(R=>{A.push(Qw.build(R,b,!1,u))}),w.push(A)})}function E(){let T=[];return c.forEach(b=>{e===2||e===3?b.forEach(A=>{A.isGroup1||A.reverse(),A.sides.forEach(R=>R.sortInters())}):b.forEach(A=>A.sides.forEach(R=>R.sortInters())),b.map(A=>A.sides.filter(R=>R.inters.length)).flat(2).sort((A,R)=>{let O=A.inters,M=R.inters,k=wt(O[O.length-1].coord,A.getEnd()),G=wt(M[M.length-1].coord,R.getEnd());if(k&&G){let H=0,q=0;for(let I=O.length-2;I>=0&&wt(O[I].coord,A.getEnd());I--)H++;for(let I=M.length-2;I>=0&&wt(M[I].coord,R.getEnd());I--)q++;return q-H}else return k?-1:1}).forEach(A=>{A.inters.forEach(R=>{if(R.dealed)return;let O=R.side,M=R.getBindedInter().side,k;wt(O.getEnd(),R.coord)&&wt(M.getEnd(),R.coord)?k=-1:wt(O.getEnd(),R.coord)?(k=1,R=R.getBindedInter()):wt(M.getEnd(),R.coord)&&(k=1);let G=WF(k,R,e,u);R.isDealed(),G&&(O.outline.setAllInterIsInvalidToFalse(),M.outline.setAllInterIsInvalidToFalse())})}),C(b),e===3&&(b.forEach(A=>{A.reverse(),A.sides.forEach(R=>{R.sortInters(),R.inters.forEach(O=>{O.resetVisitStatus()})})}),C(b));function C(A){A.forEach(R=>{R.inters.forEach(O=>{if(O.isInvalid||O.getVisited())return;let M=O.findStartInter(),k=w(e)?M.run():M.getBindedInter().run(),G=R.polyline.primitives;if(k){if(G.length===k.primitives.length){let H=new Set(G);if(!k.primitives.some(q=>!H.has(q))){T.push(R);return}}T.push(Qw.build(k,!0,!0,u))}})})}}),T;function w(b){switch(b){case 0:case 2:case 3:return!0;case 1:return!1;default:throw Error("not support the rule")}}}}var yb=/\bstablilizetion\b/.test(self.location.href)||!0,bb={intersect(e,t,i,r){try{return e0(0,e,t,i,r)}catch(n){if(yb){let s=new Zg().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 Cn(s.map(a=>new es(a.items)))}throw n}},union(e,t,i,r){try{return e0(1,e,t,i,r)}catch(n){if(yb){let s=new Zg,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 Cn(o.map(l=>new es(l.items)))}throw n}},diff(e,t,i,r){try{return e0(2,e,t,i,r)}catch(n){if(yb){let s=new Zg().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 Cn(s.map(a=>new es(a.items)))}throw n}},xor(e,t,i,r){try{return e0(3,e,t,i,r)}catch(n){if(yb){let s=new Zg().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 Cn(s.map(a=>new es(a.items)))}throw n}}},ZF=class extends o0{constructor(e,t,i,r,n,s){super(e.rule,ox.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=Al(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)}},QF=class extends a0{constructor(e){super(!!e),e&&(this.drawDebug=new v0(e),this.blueDrawing=this.drawDebug.initColor(Fi.BLUE),this.greenDrawing=this.drawDebug.initColor(Fi.GREEN),this.redDrawing=this.drawDebug.initColor(Fi.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 iS(e,t,i,r,n){let s=A0(),a=new QF(n);new ZF(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 es(u.filter(h=>h)))});let l=new Cn(o);return Jc.BooleanTools+=Bh(s),l}var rS=!0,Xg={intersect(e,t,i,r){try{return bb.intersect(e,t,i,r)}catch(n){if(rS)throw n;return console.error(n),iS(Pb,e,t,i,r)}},union(e,t,i,r){try{return bb.union(e,t,i,r)}catch(n){if(rS)throw n;return console.error(n),iS(gF,e,t,i,r)}},diff(e,t,i,r){try{return bb.diff(e,t,i,r)}catch(n){if(rS)throw n;return console.error(n),iS(Db,e,t,i,r)}},xor(e,t,i,r){return bb.xor(e,t,i,r)}},eG=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=A0(),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 x=f.items[m];if(n.isIntersect(x.bbox()))for(let y=0,E=x.primitives.length;y<E;y++){let T=x.primitives[y].bbox();n.isIntersect(T)&&a.push({bbox:T,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let o=a.length;if(o===0){Jc.IntersectionSeeker+=Bh(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 x=f.items[m];if(n.isIntersect(x.bbox()))for(let y=0,E=x.primitives.length;y<E;y++){let T=x.primitives[y].bbox();n.isIntersect(T)&&l.push({bbox:T,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let c=l.length;if(c===0){Jc.IntersectionSeeker+=Bh(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],x=l[f];i(g.polygonIndex,g.polylineIndex,g.ptIndex,x.polygonIndex,x.polylineIndex,x.ptIndex)}Jc.IntersectionSeeker+=Bh(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++}Jc.IntersectionSeeker+=Bh(s)}},Ra,zs=(Ra=class{static getDebug(){return Ra.drawDebug||(Ra.drawDebug=new v0(Ra.curBus)),Ra.drawDebug}static getDrawing(e=Fi.GREEN){return this.getDebug().initColor(e)}static clearDrawing(){Ra.getDebug().clear()}static drawText(e,t,i=Fi.GREEN){Ra.getDrawing(i).addText(e,t,1.5,.1,!0)}static drawBBox(e,t=Fi.GREEN){if(!e)return;let i=Ra.getDrawing(t),r=new pe(e.UL(),e.UR()),n=new pe(e.UR(),e.LR()),s=new pe(e.LR(),e.LL()),a=new pe(e.LL(),e.UL());i.addPt(r),i.addPt(n),i.addPt(s),i.addPt(a)}static drawPolyType(e,t){let i=Ra.getDrawing(t);if(e instanceof xi)i.addPly(e);else if(e instanceof es)for(let r of e.items)r instanceof xi?i.addPly(r):this.drawPolyType(r,t);else if(e instanceof Cn)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}}},Ra.UseRunArrange=!0,Ra.UseOptimizeSplit=!0,Ra.LocalBestThread=4,Ra.HandleDiff=!0,Ra.OcTreeSplitStep=4,Ra.PrintStart=new we(150,-200),Ra),Wg=class DS{static getPolyTypeLine(t){let i=[];if(t instanceof xi)for(let r of t.primitives)i.push(r);else if(t instanceof es)for(let r of t.items)if(r instanceof xi)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 Cn)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 xi)i.push(t);else if(t instanceof es)for(let r of t.items)if(r instanceof xi)i.push(r);else{let n=this.getPolyTypePolyLine(r);for(let s of n)i.push(s)}else if(t instanceof Cn)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 Ka;for(let r of t){let n=DS.getSingleBBox(r);i.ext1(n)}return i.build1()}static getSingleBBox(t){if(t instanceof Array){let i=new Ka,r=DS.getListBBox(t.slice(1));return i.ext1(r),i.build1()}else return t.bbox()}static doDrawRule(t,i=zs.PrintStart){if(t.length<2)return[i,i,i];let r=5,n=10,s=t[0],a=zs.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),zs.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);zs.drawText(d,"N:"+a);for(let p of o){let f=new pe(p,d),m=new Array;m.push(f);let g=xi.build1(xS(m));zs.drawPolyType(g,Fi.GREEN)}return[d,new we(c,l),new we(u,l)]}static drawRule(t,i=zs.PrintStart,r=!1,n){zs.clearDrawing(),this.doDrawRule(t,i),r&&this.doDrawRulePolygon(t,n),zs.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=Fi.RED),s.name&&zs.drawText(s.bbox().UL(),s.name,a),zs.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)}},tG=class Cf{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 la(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=Cf.createNode(i,s,p),x=Cf.ocTreeSplitNode(m,g,r,n,s);if(x.length===t.length)return t;a.push(x)}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,x=o.y+u*m,y=[[],[],[],[]],E=new Array(4),T=new Array(4);T[0]=new la(o.x,g,x,l.y),T[1]=new la(g,l.x,x,l.y),T[2]=new la(o.x,g,o.y,x),T[3]=new la(g,l.x,o.y,x);for(let A of t){let R=n(A).center(),O=-1,M=-1;R.x===g?O=Math.random()>=.5?1:-1:R.x>g?O=1:R.x<g&&(O=-1),R.y===x?M=Math.random()>=.5?1:-1:R.y>x?M=1:R.y<x&&(M=-1),O===1&&M===1?y[1].push(A):O===1&&M===-1?y[3].push(A):O===-1&&M===-1?y[2].push(A):O===-1&&M===1&&y[0].push(A)}for(let A=0;A<4;A++){let R=y[A];if(R.length<=0)continue;let O=new Ka;for(let M of R)O.ext1(n(M));E[A]=O.build1()}let w=0,b=0;for(let A of E)A&&(w+=A.area());b=w;let C=(A,R)=>{if(!E[A]||!E[R])return 0;let O=E[A].intersection1(E[R]);return O?O.area():0};b-=C(0,1),b-=C(0,2),b-=C(0,3),b-=C(1,2),b-=C(1,3),b-=C(2,3),b/w>=h&&(d=y,p=T)}for(let f=0;f<d.length;f++){let m=d[f];if(m.length<=0)continue;let g=p[f],x;if(m.length===t.length?x=Cf.ocTreeSplitNode(m,g,r,n):x=Cf.ocTreeSplitNodeMinIntersect(m,g,r,n),x.length===t.length)return t;s.push(x)}return s}static ocTreeSplit(t,i,r,n){return Cf.ocTreeSplitNode(t,i,r,n,zs.OcTreeSplitStep)}},iG=class G_{static simplifyRules(t,i){return zs.UseOptimizeSplit&&(t=this.optimizeSplit(t,i)),t}static OcTreeOptimizeSplit(t){let i=t[0];if(i!==1||t.length<=zs.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=Wg.getListBBox(r),a=tG.ocTreeSplit(n,s,zs.LocalBestThread,c=>{let u=t[c];return Wg.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(zs.HandleDiff){let s=t[1],a;if(Array.isArray(s)){let o=this.optimizeSplit(s,i);if(o.length<=1)return[2];a=PS(o,i)}else a=PS([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=Wg.getListBBox([...c.slice(1)]);Wg.KeepBBoxPolygonGroup(u,a)&&o.push(c)}else Wg.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>zs.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=G_.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}},rG=(e=>(e[e.INTERSECT=0]="INTERSECT",e[e.UNION=1]="UNION",e[e.DIFF=2]="DIFF",e[e.XOR=3]="XOR",e))(rG||{});function t0(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=t0(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=t0(s),!s)||i.push(s)}break;case 2:let r=e[1];if(Array.isArray(r)&&(r=t0(r)),!r)return null;i.push(r);for(let n=2;n<e.length;n++){let s=e[n];Array.isArray(s)&&(s=t0(s),!s)||i.push(s)}break;default:throw new Error("not support boolean rule!")}return i.length===1?null:i}function nS(e,t,i){return Array.isArray(e)?U_(e,t,i):e}function sS(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 U_(e,t,i,r=!0){let n=new Array(e.length-1);for(let s=1;s<e.length;s++)n[s-1]=nS(e[s],t,i);switch(e[0]){case 0:return sS(n,Xg.intersect,t,i);case 1:return sS(n,Xg.union,t,i);case 2:let s=sS(n.slice(1),Xg.union,t,i);return s?Xg.diff(n[0],s,t,i):n[0];case 3:let a=nS(e[1],t,i);for(let o=2;o<e.length;o++)a=Xg.xor(a,nS(e[o],t,i),t,i);return a;default:throw new Error("not support boolean rule! "+e[0])}}function Y_(e){let t=[e[0]];for(let i=1;i<e.length;i++){let r=e[i];if(Array.isArray(r)){let n=Y_(r);Array.isArray(n)?n.length>1&&t.push(n):t.push(n)}else{let n=Wb(r);n!==null&&t.push(Cn.build(n))}}return t}function nG(e,t){zs.curBus=t,e=Y_(e);let i;return zs.UseRunArrange?i=iG.simplifyRules(e,t):i=t0(e),i.length<=1?new Cn([]):PS(i,t)}function PS(e,t,i=!0){if(!e||e.length===1)return new Cn([]);let r=e,n=new eG,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),U_(r,n,t,i)}var xb=new Error("list is empty"),Eb=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}},sG=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")}},aG=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")}},oG=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 xb;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw xb;return this.remove(e),e.item}addLast(e){if(this.first===null||this.last===null){let t=new Eb(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 Eb(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 xb;return this.first.item}getLast(){if(this.last===null)throw xb;return this.last.item}insertAfter(e,t){let i=new Eb(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new Eb(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 sG(this.first)}listIterator(){return new aG(this.first)}toArray(){let e=new Array,t=this.first;for(;t!=null;)e.push(t.item),t=t.next;return e}},Lb=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=>wt(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=Mt(e,n),a=Mt(i.side.getShape(),n),o=Mt(r.side.getShape(),n);return s.dot(a)>s.dot(o)?i:r},void 0)}getEntryInter(){}},aS=0;function H_(e,t){let i=e.primitives[0];if(e.primitives.length===1&&i instanceof Pe&&Math.abs(i.sweepAngle)===360)return[e];let r=A0();aS++;let n,s=gG(e);if(s.length===0)return[];let a=uG(s);if(aS===-1){n=new v0(t);let u=n.initColor(Fi.BLUE);s.forEach(d=>u.addPt(d.getShape()));let h=n.initColor(Fi.GREEN);a.forEach(d=>h.addPoint(d.coord)),n.draw();debugger;throw new Error}if(a.length===0)return[xi.build7(s.map(u=>u.getShape()))];hG(a);let o=[],l=!1;try{fG(a,n)}catch(u){u.customType==="IS_OVERLAP"?(l=!0,o=new Zg().getUnion([e]).map(h=>h.items).flat(2)):console.error(u)}if(l)return o;let c=pG(a);if(!c.length)return[xi.build7(s.map(u=>u.getShape()))];if(o=lG(c,n),o.length===0)return console.warn("=====deSelfIntersection=====",aS),[];if(n)throw o.forEach(u=>{n.initColor(Fi.WHITE).addPly(u),n.draw();debugger}),new Error;return Jc.deSelfIntersection+=Bh(r),o}function lG(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(Fi.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(j_(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 Lb));if(g.length){let y=Uh(xi.build7(g));y&&i.push(y)}let x=a.filter(y=>!(y instanceof Lb));if(s=o[h].getOutInter(x[x.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=Uh(xi.build7(a.filter(u=>!(u instanceof Lb))));c&&i.push(c)})}),i}function cG(e){return{next(){return e.hasNext()?{value:e.next()}:{done:!0,value:void 0}},[Symbol.iterator](){return this}}}function uG(e){let t=[],i=new oG;for(let r of e.slice().sort((n,s)=>n.bbox().minY-s.bbox().minY)){for(let n of cG(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 Uu(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]),x=f.distance2(m)>f.distance2(g)?m:g,y=d.prevSide;a(wt(y.getEnd(),x)?y:d,x).bind(a(p,x))},l=s.getShape(),c=r.getShape(),u=Al(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(wt(g.getEnd(),m)?g:f,m)},p=new we(ae[0],ae[1]);if(h&&!wt(p,s.prevSide.getEnd())&&!wt(p,r.prevSide.getEnd())&&Mt(l,p).dot(Mt(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 hG(e){e.forEach(t=>{let i=t.side.getEnd();if(t.isInvalid||!wt(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(!wt(a.coord,i))break;a!==t&&a.getBindedInter().side===n&&a.setIsInvalid()}})}function dG(e){let t=new h0(10);return e.forEach(i=>{i.isInvalid||t.add(i)}),t}function pG(e){let t=[],i=dG(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 Lb(n);n.forEach(o=>{o.group=a,s.has(o.side)&&o.visitSelf(),s.add(o.side)}),t.push(a)}}),t}function fG(e,t){e.forEach(i=>{if(i.isInvalid||i.dealed)return;let r=i.side,n=i.getBindedInter().side,s;wt(r.getEnd(),i.coord)&&wt(n.getEnd(),i.coord)?s=-1:wt(r.getEnd(),i.coord)?r.nextSide!==n&&(s=1,i=i.getBindedInter()):wt(n.getEnd(),i.coord)&&n.nextSide!==r&&(s=1),mG(s,i,t),i.isDealed()})}function mG(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(xf(a.reverse(),o.reverse())||xf(n.nextSide.getShape(),s.nextSide.getShape())){let h=Fu(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=Fu(n,n.nextSide,s.nextSide,r,l,c,i);h.state===d.state&&u(h,d)}else if(!(xf(a.reverse(),s.nextSide.getShape())||xf(n.nextSide.getShape(),o.reverse()))){let h=$w(n,n.nextSide,s,!1,i);h===$w(n,n.nextSide,s.nextSide,!0,i)&&h!==$w(s,s.nextSide,n.nextSide,!0,i)&&t.setIsInvalid()}}else if(e===1){let h=function(d,p){return Mt(d,p.start()).dot(Mt(p,p.start()))>0};if(xf(a.reverse(),o.reverse())||xf(a,s.nextSide.getShape())){let d=Vo(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=Vo(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=Es(n,s,!1,i);d===Es(n,s.nextSide,!0,i)&&d!==tp(s,s.nextSide,new I0(j_(a,t.coord,a.end()),i),!0,i)&&t.setIsInvalid()}}function u(h,d){h.inter.setIsInvalid(),d.inter.setIsInvalid(),t.setIsInvalid()}}function j_(e,t,i){if(e instanceof pe||t.distance2(i)<1e-6)return new pe(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 lt){let r=e.getPercent(t,Bt),n=e.getPercent(i,Bt);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function gG(e){let t=Uh(e);if(!t)return[];let i=t.primitives.map(n=>new I0(n,null)),r=i[i.length-1];return i.forEach(n=>{r.connect(n),r=n}),i}var wf,yG=(wf=class{static clearData(e){this.originalPrimitive=[],this.offsetPrimitive=[],this.rawOffsetPrimitive=[],this.offsetDistance=0,this.testI++,this.testI===0?this.drawDebug=new v0(e):delete this.drawDebug}static createRawOffsetEdge(){if(this.drawDebug){let e=this.drawDebug.initColor(Fi.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(Fi.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 pe(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=Uh(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=nG(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(Fi.BLUE);this.rawOffsetPrimitive.forEach(c=>l.addPt(c)),this.drawDebug.draw();debugger}let o=i?this.createClippingEdge(r):[xi.build2(this.rawOffsetPrimitive)];if(this.drawDebug){let l=this.drawDebug.initColor(Fi.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(Fi.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 pe)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=Z9(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=H_(xi.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 pe)return e.panDistance(this.offsetDistance);throw new Error("not support!")}static connectPrimitive(e,t){e.offsetEdge instanceof pe&&t.offsetEdge instanceof pe?this.lineToLineConnect(e,t):e.offsetEdge instanceof Pe&&t.offsetEdge instanceof Pe?this.arcToArcConnect(e,t):e.offsetEdge instanceof pe&&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 pe(i.start(),u);this.rawOffsetPrimitive.push(h);let d=new pe(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 pe(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 pe(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 pe(c.start(),c.end()))):c=new pe(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 pe(e.center,r):Math.abs(e.sweepAngle)<1e-4?l=new pe(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 pe(l.start(),l.end()))),this.rawOffsetPrimitive.push(l);let c=new pe(r,t.end());this.updateNextOffsetPrimitive(a,c)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(n,e,t,s)}static isTrueArcIntersection(e,t){return Nn(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=J9(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=w_(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 pe(i.center,a):Math.abs(i.sweepAngle)<1e-4?o=new pe(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 pe(o.start(),o.end()))),this.rawOffsetPrimitive.push(o),a.equals1(r.center)?l=new pe(a,r.center):Math.abs(r.sweepAngle)<1e-4?l=new pe(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 pe(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)}}},wf.originalPrimitive=[],wf.offsetPrimitive=[],wf.rawOffsetPrimitive=[],wf.testI=0,wf),bG=class i0 extends w0{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(rr.rotateD(this.angle)))}end(){return this.start()}getLeftPoint(){return this.leftUpPoint.add(new we(0,-this.height/2).multiply3(rr.rotateD(this.angle)))}getRightPoint(){return this.leftUpPoint.add(new we(this.width,-this.height/2).multiply3(rr.rotateD(this.angle)))}extend(t){return new i0(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=rr.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 la(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 pe(o,l),new pe(l,c),new pe(c,u),new pe(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 pe(l,c),Pe.build1(c,u,s,s,!1,0),new pe(u,h),Pe.build1(h,d,s,s,!1,0),new pe(d,p),Pe.build1(p,f,s,s,!1,0),new pe(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=rr.rotateD(this.angle).translate1(i);return xi.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(rr.rotateD(this.angle)).multiply3(t),n=new we(0,-this.height).multiply3(rr.rotateD(this.angle)).multiply3(t);return t.isMirrored()?new i0(i,n.length(),r.length(),n.angleD(we.ORIGIN),this.isCCW===1?0:1,this.radius*r.length()/this.width):new i0(i,r.length(),n.length(),r.angleD(we.ORIGIN),this.isCCW,this.radius*r.length()/this.width)}reverse(){return new i0(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 xi.build2(s.primitives.concat(new pe(s.primitives[0].start(),a.primitives[0].start()),a.primitives,new pe(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.")}},xG=.01,es=class Ql{static simplify(t){return t=Uh(t),t?new Ql([t]):null}static buildByStroke(t,i,r=1,n=ev,s){if(t instanceof Pe&&(t.rx<i/2+xG||Math.abs(t.sweepAngle)>180&&Oe.lesseq(t.start().distance1(t.end()),i))){let o=H_(t.stroke(i,r,0),s);if(o.length===0)return null;if(o.length===1)return new Ql(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 Ql(l)}else if(t instanceof bG){let o=t.stroke1(i,r,0).map(l=>Uh(l));return o[0]?o[1]?new Ql(o):new Ql([o[0]]):null}let a=t.stroke(i,r,0,n);return a?this.simplify(a):null}static buildCircle(t,i){return this.simplify(xi.build7([Pe.buildCircle(t,i,0)]))}static buildRect(t){return this.simplify(t.toPolyline())}static buildBBox(t){return this.simplify(xi.buildBBox(t,0))}constructor(t){this.items=t.slice()}multiply3(t){return new Ql(this.items.map(i=>i.multiply3(t)))}bbox(){return this.items[0].bbox()}isEqual(t){return t instanceof Ql?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 Cn([this]);let r=this.items[0],n=[];for(let u of r.primitives)if(u instanceof pe)n.push(u);else if(u instanceof Pe&&u.rx===u.ry)a(u);else if(u instanceof lt)s(u);else throw new Error("not support!");r=xi.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 pe(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=[];yG.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 Cn([new Ql(o)]);else if(o.length===0)console.warn("outlines.length === 0"),c=new Cn([]);else if(l.length===0)c=new Cn(o.map(u=>new Ql([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 Cn(u.map(h=>new Ql(h)))}return c}toPolylineGroup(){return new tv(this.items)}},EG=(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))(EG||{}),TG=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 wG(e){return new TG(e)}function SG(e){return e===32||e===9||e===13||e===10}var vG=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}},oS=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}},IG=/(\.?0+)$/,_S=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(oS.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(oS.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(oS.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(IG,"")}};function AG(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var CG=(e,t)=>{e===3?console.error(...t):e===2?console.warn(...t):console.log(...t)},DG=(e,t)=>[AG(e)].concat(t),LS=class OS{static mix(...t){return new OS(0,(i,r)=>{for(let n of t)n.write(i,r)},(i,r)=>r)}constructor(t,i=CG,r=DG){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 OS(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,[_S.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,[_S.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)}};LS.DUMMY=new LS(4);var PG=LS,lS=500,kP=String.fromCharCode,_G=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<=lS)return kP.apply(null,e);{let i=new Array;for(let r=0;r<e.length;r+=lS){let n=Math.min(t-r,lS),s=kP.apply(null,e.slice(r,r+n));i.push(s)}return i.join("")}}},V_=(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))(V_||{}),z_=(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))(z_||{});function LG(e){return 97<=e&&e<=122||65<=e&&e<=90}function bs(e){let t=parseFloat(e);if(isFinite(t))return t;throw new Error("expect number")}var FP=class extends vG{constructor(e,t=!0,i=PG.DUMMY){super(),this.buffer=new _G,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=Mh.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),V_[this.lexState]),this.lexState){case 0:return SG(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):LG(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,z_[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 pe(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=bs(e),this.parseState=2,t;case 2:{this.y=this.yAxis*bs(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*bs(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 pe(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 pe(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 pe(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*bs(e),this.parseState=9,!0;case 9:return this.x2=bs(e),this.parseState=10,!0;case 10:return this.y2=this.yAxis*bs(e),this.parseState=11,!0;case 11:return this.x=bs(e),this.parseState=12,!0;case 12:{this.y=this.yAxis*bs(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 lt([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=bs(e),this.parseState=15,!0;case 15:return this.rotation=bs(e),this.parseState=16,!0;case 16:return this.isLargeArc=bs(e)===1,this.parseState=17,!0;case 17:return this.sweep=bs(e)===1?Mh.CW:Mh.CCW,this.parseState=18,!0;case 18:return this.x=bs(e),this.parseState=19,!0;case 19:{this.y=this.yAxis*bs(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*bs(e),this.parseState=22,!0;case 22:return this.x=bs(e),this.parseState=23,!0;case 23:{this.y=this.yAxis*bs(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 lt([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*bs(e),this.parseState=26,!0;case 26:return this.x=bs(e),this.parseState=27,!0;case 27:{this.y=this.yAxis*bs(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 lt([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=xi.build1(wG(this.group));return this.group.length=0,this.on(e)}}onException(e){throw e}},Ste=_S.fmtNumber,GP=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 pe)this.encLine1(e);else if(e instanceof Pe)this.encArc(e);else if(e instanceof lt)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()===Mh.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()===Mh.CCW?0:1,t.x,this.yAxis*t.y):this.buffer.push(e.rx,e.ry,0,e.isLarge()?1:0,e.sweep()===Mh.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()===Mh.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}},OG=class extends $S{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=c0(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 FP(i=>(t.push(new GP(!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,x]=e,y=g[0],E=y[1],T=-y[2],w=y[1]+y[3],b=-y[2]+y[4],C=y[5],A=y[6],R=+y[7],O=+y[8],M=rr.scale(w-E,b-T).rotateD(-R);O&&(M=M.multiply3(rr.MIRROR_X)),M=M.translate(E,T),M=this.matrix2svg(M),M=this.encMatrix(M),this.onPoly(c,0,u,-R,h,d,p,f,m,!0,[["R",0,0,1,1,C,A,0,0]],!0,!0,this.lockConfig.some(k=>k===e[1]),this.hideConfig.some(k=>k===e[1]),this.invisibleConfig.some(k=>k===e[1]),u===1?1:(t=this.coverConfig[e[1]])!=null?t:null,x||((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,x]=e,[y,E,T,w,b,C,A,R,O]=g[0],M=rr.rotateD(R);O&&(M=M.multiply3(rr.MIRROR_X));let k;O?k=new pe(new we(0,0),new we(0,-b)).multiply3(M):k=new pe(new we(0,0),new we(w,0)).multiply3(M);let G=k.end().angleD(k.start()),H=O===1;w=O===1?b:w,b=O===1?w:b;let q=rr.scale(w,b).rotateD(-G);H&&(q=q.multiply3(rr.MIRROR_X)),q=q.translate(E,-T),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(I=>I===e[1]),this.hideConfig.some(I=>I===e[1]),this.invisibleConfig.some(I=>I===e[1]),u===1?1:(t=this.coverConfig[e[1]])!=null?t:null,x||((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,x]=e,y=g[0],E=y[1],T=-y[2],w=y[3],b=y[4],C=+y[5],A=+y[6],R=rr.scale(w,b).rotateD(-C);A&&(R=R.multiply3(rr.MIRROR_X)),R=R.translate(E,T),R=this.matrix2svg(R),R=this.encMatrix(R),this.onPoly(c,0,u,-C,h,d,p,f,m,!0,[["ELLIPSE",0,0,1,1,0,0]],!0,!0,this.lockConfig.some(O=>O===e[1]),this.hideConfig.some(O=>O===e[1]),this.invisibleConfig.some(O=>O===e[1]),u===1?1:(t=this.coverConfig[e[1]])!=null?t:null,x||((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,R!=null?R:null)}parsePolyGroup(e){var t,i,r,n,s,a,o,l;let[,c,,u,h,d,p,f,m,,,g,x]=e,y=!0,E=!0,T=this.decMultiPoly(g).d;this.onPoly(c,0,u,0,h,d,p,f,m,!0,this.encPath(T),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,x||((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 Ka,i=e.map(r=>{let n="";return new FP(s=>(t.ext1(s.bbox()),n=new GP().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 rr([t,i,0,r,n,0,s,a,1]);o=rr.MIRROR_Y.multiply3(o).multiply3(rr.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,x,y,E;if(this.version<2){let[,T,w,b,C,A,R,O,M,k,G,H,q,I,N,v,L,_,B,U]=e;A=js(A);let z=M;O=O===1,q=q===1,I=I===1,N=N===1;let W=-(v[15]/3|0)+2,ne=v%3;B=B||1,U=U||1;let me=this.fontCache[e[1]],{bbox:Ee,d:Se}=this.decMultiPoly(me),Fe=Ee.width(),Ne=Ee.height();Ne=Ne||0,Fe=Fe||0;let it=0;switch(ne){case 1:it=-Fe/2;break;case 2:it=-Fe;break}let je=0;switch(W){case 1:je=Ne/2;break;case 0:je=Ne;break}let It=rr.translate(it,je).scale(B,U).rotateD(-R);O&&(It=It.multiply3(rr.MIRROR_X)),It=It.translate(C,A);let Ht=this.matrix2svg(It),Ri=this.encMatrix(Ht);this.onString(T,w,b,R,z,k,G,H,q,I,N,((-W||0)+2)*3+(ne||0),L,_,this.lockConfig.some(Ci=>Ci===e[1]),this.hideConfig.some(Ci=>Ci===e[1]),this.invisibleConfig.some(Ci=>Ci===e[1]),b===1?1:(t=this.coverConfig[e[1]])!=null?t:null,(i=this.commentConfig[e[1]])!=null?i:null,b===2?3:(n=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?n:null,b===2?_:(a=(s=this.trnCtrlConfig[e[1]])==null?void 0:s.trans_print)!=null?a:null,b===2?1-_:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,Ri,!!Ri,this.encPath(Se))}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(T=>T===e[1]),this.hideConfig.some(T=>T===e[1]),this.invisibleConfig.some(T=>T===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=(x=this.transformConfig[e[1]])==null?void 0:x.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))}},RG=class extends $S{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=c0(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=c0(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]=js(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:js(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)}},NG=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)}}},X_=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 Kd(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 yo("META_CREATE",e,"META_CREATE",i)}modifier(e,t){let i=typeof t=="string"?t:JSON.stringify(t);return yo("META_MODIFY",e,"META_MODIFY",i)}delete(e,t){let i=t||JSON.stringify({isDelete:!0});return yo("DELETE_DOC",e,"DELETE_DOC",i)}},sv=class extends X_{constructor(){super(...arguments),this.doctype="BLOB"}buildStr(e,t,i){let r=typeof i=="string"?i:JSON.stringify(this.buildData(i));return yo("BLOB",e,t,r)}buildData(e){return{filename:e.filename,content:e.content}}};var W_=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:go(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:go(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:go(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:go(e,"PRIMITIVE"),dataType:"PRIMITIVE",data:JSON.stringify(t)}}encodeNet(e,t){return{id:go(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:go(e,"LAYER_PHYS"),dataType:"LAYER_PHYS",data:JSON.stringify(t)}}encodeLayer(e,t){return{id:go(e,"LAYER"),dataType:"LAYER",data:JSON.stringify(t)}}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}},MG=class extends d9{constructor(e=!1){super(void 0,void 0,void 0,void 0,e),this.encode=new W_,this.maxTicket=0,this.blobEncode=new sv,this.blobData=[],this.encodeData="",this.placeholder=0}handleData(e){this.encodeData?this.encodeData=this.encodeData+`|
`+yo(e.dataType,++this.maxTicket,e.id,e.data):this.encodeData=yo(e.dataType,++this.maxTicket,e.id,e.data)}getZIndex(e){let t=e.match(KS);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,x,y){let E=this.getZIndex(e);this.handleData(this.encode.encodeString(ki(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:x,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,x,y,E,T,w,b,C){let A=this.getZIndex(e);A&&b&&(A=A+"."+String(b)),this.handleData(this.encode.encodeAttr(ki(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:x,reverse:y,expansion:E,mirror:T,locked:w,zIndex:A===null?null:Number(A),specialColor:C}))}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(ki(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(ki(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(ki(e),p))}onShellCut(e,t,i,r,n,s,a,o,l){let c=this.getZIndex(e);this.handleData(this.encode.encodeShellCut(ki(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(ki(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(ki(e),h))}onFpcFill(e,t,i,r,n,s,a,o){let l=this.getZIndex(e);this.handleData(this.encode.encodeFpcFill(ki(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(ki(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(ki(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(ki(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(ki(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(ki(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(ki(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(ki(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(ki(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=ax(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(ki(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(ki(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(ki(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(ki(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,x,y,E,T,w,b,C,A,R,O){let M=this.getZIndex(e);this.handleData(this.encode.encodePad(ki(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:x,bottomSolderExpansion:y,topPasteExpansion:E,bottomPasteExpansion:T,locked:w,zIndex:M===null?null:Number(M),connectMode:b,spokeSpace:C,spokeWidth:A,spokeAngle:R,unusedInnerLayers:O,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(ki(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,x,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:x,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 BG(e,t,i,r=new Date().getTime(),n=String(r),s){let a=new MG(i),o="",l=Il();if(o=Kd("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 UG,u=c.head({doc:"FONT",client:l,updateTime:r,version:n,user:s});for(let h of a.fontCache){let d=bS(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 kG=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)}}},FG=class extends RG{constructor(){super(),this.encode=new kG,this.maxTicket=0,this.blobEncode=new sv,this.blobData=[],this.encodeData="",this.placeholder=0}handleData(e){this.encodeData?this.encodeData=this.encodeData+`|
`+yo(e.dataType,++this.maxTicket,e.id,e.data):this.encodeData=yo(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,x,y,E,T){this.handleData(this.encode.encodeAttr(ki(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),parentId:n,key:s,value:a,keyVisible:o,valueVisible:l,x:c,y:js(u),rotation:h,color:d,fillColor:p,fontFamily:f,fontSize:m,strikeout:g,underline:x,italic:y,fontWeight:E,align:T,version:"2.0"}))}onTable(e,t,i,r,n,s,a,o,l,c,u){this.handleData(this.encode.encodeTable(ki(e),{partId:t,groupId:i,startX:r,startY:js(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(ki(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),centerX:n,centerY:js(s),radiusX:a,radiusY:js(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=ax(h);this.blobData.push(this.blobEncode.buildStr(1,d,{filename:"",content:h})),h=`blob:${d}`}this.handleData(this.encode.encodeObj(ki(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),fileName:n,startX:s,startY:js(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(ki(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),display:n,x:a,y:js(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(ki(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),dotX1:n,dotY1:js(s),dotX2:a,dotY2:js(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(ki(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),startX:n,startY:js(s),referX:a,referY:js(o),endX:l,endY:js(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(ki(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),centerX:n,centerY:js(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(ki(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),points:J8(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(ki(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),x:n,y:js(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:js(e.originY)}))}onBezier(e,t,i,r,n,s,a,o,l,c){this.handleData(this.encode.encodeBezier(ki(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 GG(e,t,i=new Date().getTime(),r=String(i),n){let s=new FG,a="";s.parseFull(t);let o=Il();s.encodeData&&(a=Kd("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 UG=class extends X_{constructor(){super(...arguments),this.doctype="FONT"}buildStr(e,t,i){let r=typeof i=="string"?i:JSON.stringify(this.buildData(i));return yo("FONT",e,t,r)}buildData(e){return{width:e.width,height:e.height,path:e.path}}};var YG=class extends OG{constructor(){super(),this.encode=new NG,this.maxTicket=0,this.blobEncode=new sv,this.blobData=[],this.encodeData="",this.placeholder=0}handleData(e){this.encodeData?this.encodeData=this.encodeData+`|
`+yo(e.dataType,++this.maxTicket,e.id,e.data):this.encodeData=yo(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,x,y,E){this.handleData(this.encode.encodeAuxLine(ki(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,x){this.handleData(this.encode.encodeDimension(ki(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,x,y,E,T,w,b,C,A){this.handleData(this.encode.encodeString(ki(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:x,transScope:this.transScopeType(E),transPrint:T,transWhite:w,matrix:b,strokes:C,path:A,name:y}))}onPoly(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f,m,g,x,y,E,T,w){if(typeof o=="string"&&o.startsWith("data:")){let b=ax(o);this.blobData.push(this.blobEncode.buildStr(1,b,{filename:"",content:o})),o=`blob:${b}`}this.handleData(this.encode.encodePoly(ki(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:T,matrix:w,name:x}))}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 HG(e,t,i,r=new Date().getTime(),n=String(r),s){let a=new YG,o="";a.parseFull(t);let l=Il();return a.encodeData&&(o=Kd(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 q_=class extends W7{constructor(e){let t=e||new p_;super(t,0,Q8),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=_h(e);i?this.parseLayer(l,i,r,n,s):this.onDelLayer(l,r,n,s);break}case"LAYER_PHYS":{let l=_h(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=_h(e);i?this.parseNet(l,i,r,n,s):this.onDelNet(l,r,n,s);break}case"PRIMITIVE":{let l=_h(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=_h(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=_h(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=_h(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=_h(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=j7(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=vf(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)}},jG=(e=>(e.UNIVERSAL="UNIVERSAL",e))(jG||{}),VG=(e=>(e.SINGLE="SINGLE",e.MULTIPLE="MULTIPLE",e))(VG||{}),zG=(e=>(e.NONE="NONE",e.NAME="NAME",e.NUMBER="NUMBER",e))(zG||{}),XG=(e=>(e.NONE="NONE",e.ZONE="ZONE",e))(XG||{}),WG=jf(T0());function p0(){return self.EDITOR_TOP||self}function Gf(e){return self[e]=self[e]||new WG.BroadcastChannelMessageBus(e)}var Wd=(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},qG=jf(T0()),Lr={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"},JG={projectUpdate:Lr.projectUpdate,personUpdate:Lr.personUpdate,projectCanSave:Lr.canSavePend,getProject:"/mgr/projectWorker/footprint/getCanvas",getPerson:"/mgr/libWorker/getFootprint",unwatch:"/mgr/projectWorker/footprint/unwatchCanvas"},KG={projectUpdate:Lr.projectUpdate,projectCanSave:Lr.canSavePend,getProject:"/mgr/projectWorker/pcb/getCanvas",unwatch:"/mgr/projectWorker/pcb/unwatchCanvas"},vte={projectUpdate:Lr.projectUpdate,projectCanSave:Lr.canSavePend,getProject:"/mgr/projectWorker/sheet/getCanvas",unwatch:"/mgr/projectWorker/sheet/unwatchCanvas"},Ite={projectUpdate:Lr.projectUpdate,getProject:"/mgr/projectWorker/schematic/getCanvas",unwatch:"/mgr/projectWorker/schematic/unwatchCanvas"},Ate={projectUpdate:Lr.projectUpdate,projectCanSave:Lr.canSavePend,getProject:"/mgr/projectWorker/simulation/getCanvas",unwatch:"/mgr/projectWorker/simulation/unwatchCanvas"},Cte={projectUpdate:Lr.projectUpdate,personUpdate:Lr.personUpdate,projectCanSave:Lr.canSavePend,getProject:"/mgr/projectWorker/symbol/getCanvasOnCompiler",getPerson:"/mgr/libWorker/getSymbol",unwatch:"/mgr/projectWorker/symbol/unwatchCanvas"},Dte={projectUpdate:Lr.projectUpdate,personUpdate:Lr.personUpdate,projectCanSave:Lr.canSavePend,getProject:"/mgr/projectWorker/panel/getCanvas",getPerson:"/mgr/libWorker/getPanelLib",unwatch:"/mgr/projectWorker/panel/unwatchCanvas"},mo={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"},av=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}},Oh={publish:"publish",destroy:"destroy",init:"init",selected:"selected"},$G=class{constructor(e,t,i,r=(a=>(a=p0())==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||Gf(`/${this.windowId}/notify`),this.dataBus=n||this.wsBus,this._client=(a=p0())==null?void 0:a._WS_ID_}get client(){return this._client}watch(){this.dataBus.publish(mo.send,{topic:mo.watch,uuid:this.uuid,path:this.path})}initPublish(){var e;this.dataBus.publish(mo.send,{topic:mo.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Oh.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(mo.established,e=>{this._client=e,this.watch(),this.initPublish()})),!this.client){let e=await this.wsBus.rpcCall(mo.getWsId);if(!e||this.client)return;this._client=e}this.watch(),this.sub.push(this.wsBus.subscribe(mo.disconnect,e=>{this.initIds[e]&&this.onDestroy(this.initIds[e],e)})),this.sub.push(this.dataBus.subscribe(Wd(mo.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 Oh.destroy:this.onDestroy(t.userId,t.client),delete this.initIds[t.client];break;case Oh.init:this.initIds[t.client]||(this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||""));break;case Oh.selected:this.onSelected(t.user,t.client,t.data||"");break;case Oh.publish:this.dataBus.publish(mo.send,{topic:mo.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Oh.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(mo.send,{topic:mo.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Oh.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(mo.send,{topic:mo.unwatch,uuid:this.uuid,path:this.path,msg:{type:Oh.destroy,userId:this.user.uuid,client:this.client}});for(let e of this.sub)e.cancel();this.sub=[],this.initIds={}}}},UP=class extends $G{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)}},ZG=class{constructor(e,t,i,r=(x=>(x=p0())==null?void 0:x._TAB_ID_)(),n=new av,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=Gf(`/${r}/notify`),s||(this._unique=Il()),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,qG.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=Gf(`/${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(Wd(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(Lr.subMaxTick,l=>{this.consistencyManager.setMaxTicket(l.ticket,l.force)})),i&&t&&this.sub.push(this.dataBus.subscribe(Lr.subBlob,l=>{this.pushOnLine(l,"BLOB")})),i&&e&&this.sub.push(this.dataBus.subscribe(Lr.subFont,l=>{this.pushOnLine(l,"FONT")})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(Wd(Lr.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||Il(),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(Lr.getUserL);this.selectManager=new UP(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=Gf(`/${this.windowId}/libWorker`),!this.busTopic.getPerson)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");let s=i?Il():"";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||Il(),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(Wd(this.busTopic.personUpdate,{uuid:this.uuid}),l=>{this.pushOnLine(l,this.uuid)})),e&&this.sub.push(this.dataBus.subscribe(Wd(Wd(Lr.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(Lr.getUserL);this.selectManager=new UP(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(Lr.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=Il();this.dataBus.publish(Lr.pushSync,e),await this.dataBus.pullA(Wd(Lr.pullASync,{id:e}))}async destroy(){return this.isDestroy?{success:!1}:(this.consistencyManager&&this.dataBus&&this.dataBus.publish(Lr.pushRevoke,[this.uuid,this.uniqueId,this.consistencyManager.getClient()]),this.clear(),this.isDestroy=!0,this.isWatch&&this.dataBus&&!this.isProject&&this.dataBus.publish(Lr.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?Lr.projectSave:Lr.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(Lr.hasSaveData,{uuid:this.uuid,uniqueId:this.uniqueId})}},QG=(e=>(e.DIFFERENTIAL_PAIR="DIFFERENTIAL_PAIR",e.NET_CLASS="NET_CLASS",e.EQL_NET_GRP="EQL_NET_GRP",e))(QG||{}),eU=class extends q_{constructor(e){super(e)}onComponent(){}onComponentNum(){}onDelComponent(){}onPadNet(){}onDelPadNet(){}};var Pte=jf(T0()),_te=jf(T0());var tU=class extends q_{constructor(e,t,i,r,n,s,a,o=(l=>(l=p0())==null?void 0:l._TAB_ID_)()){let l=new p_(o);super(l),this.isProject=i,this.encode=s,this.base=new ZG(e,t,i,o,r,l,n,n==="PCB"?KG:JG,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=ax(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=bS(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=bS(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:go(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:go(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:go(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:go(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:go(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:go(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:go(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"})}}},J_=class extends tU{constructor(e,t,i,r,n=(s=>(s=p0())==null?void 0:s._TAB_ID_)()){super(e,t,i,r,"FOOTPRINT",new W_,{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(){}},iU=class extends eU{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){}},rU=class extends J_{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 av,r)}canvasSelected(){return""}onSelectChange(e,t,i){}onSelectQuit(e,t){}async getByDataType(e){let t="";if(this.isProject?(this.dataBus=this.dataBus||Gf(`/${this.windowId}/project/${this.path}`),t=await this.dataBus.rpcCall("/mgr/projectWorker/getDataByType",{doc:this.uuid,dataType:e})):(this.dataBus=this.dataBus||Gf(`/${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 iU;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){}},K_=(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))(K_||{}),$_=(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))($_||{}),Z_=(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))(Z_||{}),Q_=(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))(Q_||{}),eL=(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))(eL||{}),tL=(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))(tL||{}),iL=(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))(iL||{}),rL=(e=>(e.SEARCH_LIST="/pro-mgr/api/copper/searchList",e.SET="/pro-mgr/api/copper/set",e.DELETE="/pro-mgr/api/copper/delete",e))(rL||{}),nL=(e=>(e.SEARCH_LIST="/pro-mgr/api/font/searchList",e.SET="/pro-mgr/api/font/set",e.DELETE="/pro-mgr/api/font/delete",e))(nL||{}),sL=(e=>(e.SEARCH_LIST="/pro-mgr/api/blob/searchList",e.SET="/pro-mgr/api/blob/set",e))(sL||{}),aL=(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))(aL||{}),oL=(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))(oL||{}),lL=(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))(lL||{}),Vu={PROJECT:K_,BRANCH:$_,SCHEMATIC:Z_,DOCUMENT:Q_,DEVICE:eL,COMPONENT:tL,TAG:iL,COPPER:rL,FONT:nL,BLOB:sL,ATTR:aL,CLIENT:oL,OTHER:lL},Tb=y0(b0()),r0={bus:void 0,get messageBus(){if(r0.bus===void 0)if(typeof window<"u"){let e=ut();e._MSG_BUS_=e._MSG_BUS_||new Tb.MessageBus,r0.bus=e._MSG_BUS_}else self._WORKER_BUS_=self._WORKER_BUS_||new Tb.WorkerMessageBridge(new Tb.MessageBus,self),r0.bus=self._WORKER_BUS_;return r0.bus},get messageBus2(){return self._MSG_BUS2_=self._MSG_BUS2_||new Tb.MessageBus2},loginedUserUuid:void 0},bt=r0,nU=(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))(nU||{}),sU=(e=>(e.SYMBOL="S",e.FOOTPRINT="F",e.PRODUCT="P",e.MODEL_3D="3D",e))(sU||{}),aU=(e=>(e.BOTTOM_COMPONENT_LIB="BOTTOM_COMPONENT_LIB",e.DIALOG="DIALOG",e))(aU||{}),oU=["S","F","P","3D"],lU=["F","3D"],cU=(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))(cU||{}),Gh="|",uU=/^[^|]+(\|[^|]+)?$/,hU=(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))(hU||{}),dU=(e=>(e.Device="Device",e.Symbol="Symbol",e.Footprint="Footprint",e))(dU||{}),YP=[{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"}],HP=[{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"}],pU=["S"],fU=["S"],mU=["S"],gU=["3D"],yU={footprint:lU,device:oU,symbol:pU,model3D:gU,panelLib:fU,cbb:mU,modelSimLib:[]},bU=(e=>(e.eprj=".eprj",e.eprj_backup=".eprj_backup",e.eprj2=".eprj2",e))(bU||{});async function xU(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 cL=[2,20,18,19,21,22,17,25,31];function Jb(e){return e&&cL.indexOf(e)>=0}function uL(e){return cL.indexOf(e)>=0&&e!==17}function EU(e){return e===""?!1:!!(e&&uU.test(e))}var TU=async e=>{let{keys:t,values:i}=hL(e);return await xU([...t,...i].sort().join(""))},hL=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}=hL(n);t=new Set([...t,...s]),i=new Set([...i,...a])}else i.add(JSON.stringify(n))}return{keys:t,values:i}};function jP(e){let{uuid:t,path:i}=e;return t?t+(i?`${Gh}${i}`:""):void 0}function wU(e){let{source:t,path:i}=e;return t+(i?`${Gh}${i}`:"")}async function cS(e,t){if(t)return t;let{updateTime:i}=e;return i?String(i):await TU(e)}async function SU(e){let{data:t,force:i=!0,defalut:r}=e,{source:n,version:s}=t;n?(EU(n)||(t.source=jP(t)),n.includes(Gh)||(t.source=wU(t)),s?s==="1"&&(t.version=await cS(t)):t.version=await cS(t,r)):i&&(t.source=jP(t),t.version=await cS(t,r))}function dL(){let e=navigator.userLanguage||navigator.language;return e&&e.includes("zh")?"zh-cn":"en"}function uS(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=dL()==="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 da(e){return String(e).length===13?Number(e):String(e).length===10?Number(e)*1e3:Number(e)}function Vf(e){var t;return e.path||e.project_uuid||((t=e.owner)==null?void 0:t.uuid)}var vU=y0(b0()),pL=(e=>e)(pL||{}),fL=(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))(fL||{}),mL=(e=>(e.GET="/PrjDB/config/getData",e.UPDATE="/PrjDB/config/updateData",e))(mL||{}),gL=(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))(gL||{}),yL=(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))(yL||{}),bL=(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))(bL||{}),xL=(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))(xL||{}),EL=(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))(EL||{}),TL=(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))(TL||{}),wL=(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))(wL||{}),SL=(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))(SL||{}),vL=(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))(vL||{}),IL=(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))(IL||{}),AL=(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))(AL||{}),CL=(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))(CL||{}),DL=(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))(DL||{}),PL=(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))(PL||{}),_L=(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))(_L||{}),ii={VARIANT:PL,COMPONENT_GROUP:_L,COMMON:pL,PROJECT:fL,CONFIG:mL,BOARD:gL,SCHEMATIC:yL,SHEET:bL,SIMULATION:xL,PCB:EL,PANEL:TL,SYMBOL:wL,FOOTPRINT:SL,DEVICE:vL,ATTR:IL,BLOB:AL,COPPER:CL,FONT:DL};function sp(e){return!e.data}function IU(e){return!!(e.path&&e.uuid&&e.docType&&e.isProject!==void 0&&Object.keys(e).length===4)}async function Vh(e){let{origin:t,target:i}=e;if(i.isProject){let r={uuid:i.uuid,data:t,overwriteCanvas:sp(t)};if(i.docType===4)return{success:(await bt.messageBus.rpcCall(ii.FOOTPRINT.COVER,[r,i.path])).message.success};if(Jb(i.docType))return{success:(await bt.messageBus.rpcCall(ii.SYMBOL.COVER,[r,i.path])).message.success};throw new Error("Api call error!")}else{let r=await t_.getProLibSource(t);if(r.success===!1)return{success:!1,code:r.code,message:r.message};let n=r.result,s=await t_.getProLibSource(i);if(s.success===!1)return{success:!1,code:s.code,message:s.message};let a=s.result,o=Il(),l;if(i.docType===4)l=Uw(a,n,{docType:n0.FOOTPRINT,uuid:i.uuid,client:o});else if(i.docType===29)l=Uw(a,n,{docType:n0.PANEL_LIB,uuid:i.uuid,client:o});else if(Jb(i.docType))l=Uw(a,n,{docType:n0.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 bt.messageBus.rpcCall(Vu.COMPONENT.SET_HISTORY,c);return u.success===!1?{success:!1,code:u.code,message:u.message}:{success:!0}}}function LL(e){return self[e]=self[e]||new vU.BroadcastChannelMessageBus(e)}var AU=(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))(AU||{}),CU=(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))(CU||{}),DU=(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))(DU||{}),ov={D3Model:{client3DModelList:"api/client/steps"}},Ze=class{};Ze.CANVAS_UNIT_MM="mm",Ze.CANVAS_UNIT_MIL="mil",Ze.HEX_BLACK_COLOR="#000000",Ze.HEX_WHITE_COLOR="#FFFFFF",Ze.HEX_RED_COLOR="#FF0000",Ze.HEX_GREEN_COLOR="#00FF00",Ze.HEX_BLUE_COLOR="#0000FF",Ze.HEX_GRAY_COLOR1="#F1F1F1",Ze.HEX_GRAY_COLOR2="#EFEFEF",Ze.HEX_GRAY_COLOR3="#999999",Ze.HEX_GRAY_COLOR4="#666666",Ze.HEX_GRAY_COLOR5="#333333",Ze.HEX_GRAY_COLOR6="#CCCCCC",Ze.DEFAULT_PAGESIZE=50,Ze.SYMBOLTYPE_ITEM_ALL_VALUE="@all",Ze.SYMBOLTYPE_ITEM_ALL_TITLE="All",Ze.D3MVIEW_DEFAULT_TRANSFORM="0, 0, 0, 0, 0, 0, 0, 0, 0",Ze.DEVICE_INDEX_TAG="$_",Ze.DEVICE_SPLIT_TAG="@_",Ze.LIB_SPLIT_TAG="#_",Ze.CATEGORY_ITEM_ALL_VALUE="@all",Ze.CATEGORY_ITEM_ALL_TITLE="All",Ze.FAVORITELIB_UUID="star",Ze.SYSTEMLIB_UUID="0819f05c4eef4c71ace90d822a990e87",Ze.SYSTEMLIB_UUID_ALIAS="lcsc",Ze.USERLIB_ALIAS="mine",Ze.PUBLICLIB_ALIAS="user",Ze.STD_PUBLIC_LIB_UUID="stdPublic",Ze.RECENT_LIB_UUID="recent",Ze.INTERNAL_LIB_ALIAS="Internal",Ze.PERSIONAL_WORKSPACE="Personal",Ze.EDU_WORKSPACE="6d84b27f18f540b6a31c4d657314ab13",Ze.EDA_TEST_WORKSPACE="407ec92f2a2f4275bf08cbebf64f5e08",Ze.LIB_SYSTEM_KEY="system",Ze.LIB_PROJECT_KEY="project",Ze.LIB_PERSONAL_KEY="personal",Ze.LIB_PUBLIC_KEY="public",Ze.LIB_INTERNAL_KEY="Internal",Ze.LIB_FAVORITE_KEY="favorite",Ze.LIB_TEMAS_KEY="teams",Ze.API=ov,Ze.ERR_CODE={NORMAL:-1,DUP_NAME:-9001};var VP={},PU=(function(e,t,i,r,n){var s=new Worker(VP[t]||(VP[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}),nr=Uint8Array,Ja=Uint16Array,C0=Int32Array,zf=new nr([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]),Xf=new nr([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]),f0=new nr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),OL=function(e,t){for(var i=new Ja(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];for(var n=new C0(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}},RL=OL(zf,2),lv=RL.b,Kb=RL.r;lv[28]=258,Kb[258]=28;var NL=OL(Xf,0),ML=NL.b,RS=NL.r,m0=new Ja(32768);for(Or=0;Or<32768;++Or)Mu=(Or&43690)>>1|(Or&21845)<<1,Mu=(Mu&52428)>>2|(Mu&13107)<<2,Mu=(Mu&61680)>>4|(Mu&3855)<<4,m0[Or]=((Mu&65280)>>8|(Mu&255)<<8)>>1;var Mu,Or,Cl=(function(e,t,i){for(var r=e.length,n=0,s=new Ja(t);n<r;++n)e[n]&&++s[e[n]-1];var a=new Ja(t);for(n=1;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;var o;if(i){o=new Ja(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[m0[h]>>l]=c}else for(o=new Ja(r),n=0;n<r;++n)e[n]&&(o[n]=m0[a[e[n]-1]++]>>15-e[n]);return o}),zu=new nr(288);for(Or=0;Or<144;++Or)zu[Or]=8;var Or;for(Or=144;Or<256;++Or)zu[Or]=9;var Or;for(Or=256;Or<280;++Or)zu[Or]=7;var Or;for(Or=280;Or<288;++Or)zu[Or]=8;var Or,Hf=new nr(32);for(Or=0;Or<32;++Or)Hf[Or]=5;var Or,BL=Cl(zu,9,0),kL=Cl(zu,9,1),FL=Cl(Hf,5,0),GL=Cl(Hf,5,1),Ob=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},vl=function(e,t,i){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&i},Rb=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(t&7)},Wf=function(e){return(e+7)/8|0},$c=function(e,t,i){return(t==null||t<0)&&(t=0),(i==null||i>e.length)&&(i=e.length),new nr(e.subarray(t,i))},UL=["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"],Ii=function(e,t,i){var r=new Error(t||UL[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Ii),!i)throw r;return r},cx=function(e,t,i,r){var n=e.length,s=r?r.length:0;if(!n||t.f&&!t.l)return i||new nr(0);var a=!i,o=a||t.i!=2,l=t.i;a&&(i=new nr(n*3));var c=function(it){var je=i.length;if(it>je){var It=new nr(Math.max(je*2,it));It.set(i),i=It}},u=t.f||0,h=t.p||0,d=t.b||0,p=t.l,f=t.d,m=t.m,g=t.n,x=n*8;do{if(!p){u=vl(e,h,1);var y=vl(e,h+1,3);if(h+=3,y)if(y==1)p=kL,f=GL,m=9,g=5;else if(y==2){var E=vl(e,h,31)+257,T=vl(e,h+10,15)+4,w=E+vl(e,h+5,31)+1;h+=14;for(var b=new nr(w),C=new nr(19),A=0;A<T;++A)C[f0[A]]=vl(e,h+A*3,7);h+=T*3;for(var R=Ob(C),O=(1<<R)-1,M=Cl(C,R,1),A=0;A<w;){var k=M[vl(e,h,O)];h+=k&15;var G=k>>4;if(G<16)b[A++]=G;else{var H=0,q=0;for(G==16?(q=3+vl(e,h,3),h+=2,H=b[A-1]):G==17?(q=3+vl(e,h,7),h+=3):G==18&&(q=11+vl(e,h,127),h+=7);q--;)b[A++]=H}}var I=b.subarray(0,E),N=b.subarray(E);m=Ob(I),g=Ob(N),p=Cl(I,m,1),f=Cl(N,g,1)}else Ii(1);else{var G=Wf(h)+4,v=e[G-4]|e[G-3]<<8,L=G+v;if(L>n){l&&Ii(0);break}o&&c(d+v),i.set(e.subarray(G,L),d),t.b=d+=v,t.p=h=L*8,t.f=u;continue}if(h>x){l&&Ii(0);break}}o&&c(d+131072);for(var _=(1<<m)-1,B=(1<<g)-1,U=h;;U=h){var H=p[Rb(e,h)&_],z=H>>4;if(h+=H&15,h>x){l&&Ii(0);break}if(H||Ii(2),z<256)i[d++]=z;else if(z==256){U=h,p=null;break}else{var W=z-254;if(z>264){var A=z-257,ne=zf[A];W=vl(e,h,(1<<ne)-1)+lv[A],h+=ne}var me=f[Rb(e,h)&B],Ee=me>>4;me||Ii(3),h+=me&15;var N=ML[Ee];if(Ee>3){var ne=Xf[Ee];N+=Rb(e,h)&(1<<ne)-1,h+=ne}if(h>x){l&&Ii(0);break}o&&c(d+131072);var Se=d+W;if(d<N){var Fe=s-N,Ne=Math.min(N,Se);for(Fe+d<0&&Ii(3);d<Ne;++d)i[d]=r[Fe+d]}for(;d<Se;++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?$c(i,0,d):i.subarray(0,d)},Xc=function(e,t,i){i<<=t&7;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},Df=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},Nb=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:kh,l:0};if(n==1){var a=new nr(i[0].s+1);return a[i[0].s]=1,{t:a,l:1}}i.sort(function(w,b){return w.f-b.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 Ja(d+1),f=$b(i[u-1],p,0);if(f>t){var r=0,m=0,g=f-t,x=1<<g;for(s.sort(function(b,C){return p[C.s]-p[b.s]||b.f-C.f});r<n;++r){var y=s[r].s;if(p[y]>t)m+=x-(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 T=s[r].s;p[T]==t&&(--p[T],++m)}f=t}return{t:new nr(p),l:f}},$b=function(e,t,i){return e.s==-1?Math.max($b(e.l,t,i+1),$b(e.r,t,i+1)):t[e.s]=i},NS=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Ja(++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}},Pf=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},cv=function(e,t,i){var r=i.length,n=Wf(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},MS=function(e,t,i,r,n,s,a,o,l,c,u){Xc(t,u++,i),++n[256];for(var h=Nb(n,15),d=h.t,p=h.l,f=Nb(s,15),m=f.t,g=f.l,x=NS(d),y=x.c,E=x.n,T=NS(m),w=T.c,b=T.n,C=new Ja(19),A=0;A<y.length;++A)++C[y[A]&31];for(var A=0;A<w.length;++A)++C[w[A]&31];for(var R=Nb(C,7),O=R.t,M=R.l,k=19;k>4&&!O[f0[k-1]];--k);var G=c+5<<3,H=Pf(n,zu)+Pf(s,Hf)+a,q=Pf(n,d)+Pf(s,m)+a+14+3*k+Pf(C,O)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&G<=H&&G<=q)return cv(t,u,e.subarray(l,l+c));var I,N,v,L;if(Xc(t,u,1+(q<H)),u+=2,q<H){I=Cl(d,p,0),N=d,v=Cl(m,g,0),L=m;var _=Cl(O,M,0);Xc(t,u,E-257),Xc(t,u+5,b-1),Xc(t,u+10,k-4),u+=14;for(var A=0;A<k;++A)Xc(t,u+3*A,O[f0[A]]);u+=3*k;for(var B=[y,w],U=0;U<2;++U)for(var z=B[U],A=0;A<z.length;++A){var W=z[A]&31;Xc(t,u,_[W]),u+=O[W],W>15&&(Xc(t,u,z[A]>>5&127),u+=z[A]>>12)}}else I=BL,N=zu,v=FL,L=Hf;for(var A=0;A<o;++A){var ne=r[A];if(ne>255){var W=ne>>18&31;Df(t,u,I[W+257]),u+=N[W+257],W>7&&(Xc(t,u,ne>>23&31),u+=zf[W]);var me=ne&31;Df(t,u,v[me]),u+=L[me],me>3&&(Df(t,u,ne>>5&8191),u+=Xf[me])}else Df(t,u,I[ne]),u+=N[ne]}return Df(t,u,I[256]),u+N[256]},YL=new C0([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kh=new nr(0),HL=function(e,t,i,r,n,s){var a=s.z||e.length,o=new nr(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=YL[t-1],d=h>>13,p=h&8191,f=(1<<i)-1,m=s.p||new Ja(32768),g=s.h||new Ja(f+1),x=Math.ceil(i/3),y=2*x,E=function(Ht){return(e[Ht]^e[Ht+1]<<x^e[Ht+2]<<y)&f},T=new C0(25e3),w=new Ja(288),b=new Ja(32),C=0,A=0,R=s.i||0,O=0,M=s.w||0,k=0;R+2<a;++R){var G=E(R),H=R&32767,q=g[G];if(m[H]=q,g[G]=H,M<=R){var I=a-R;if((C>7e3||O>24576)&&(I>423||!c)){u=MS(e,l,0,T,w,b,A,O,k,R-k,u),O=C=A=0,k=R;for(var N=0;N<286;++N)w[N]=0;for(var N=0;N<30;++N)b[N]=0}var v=2,L=0,_=p,B=H-q&32767;if(I>2&&G==E(R-B))for(var U=Math.min(d,I)-1,z=Math.min(32767,R),W=Math.min(258,I);B<=z&&--_&&H!=q;){if(e[R+v]==e[R+v-B]){for(var ne=0;ne<W&&e[R+ne]==e[R+ne-B];++ne);if(ne>v){if(v=ne,L=B,ne>U)break;for(var me=Math.min(B,ne-2),Ee=0,N=0;N<me;++N){var Se=R-B+N&32767,Fe=m[Se],Ne=Se-Fe&32767;Ne>Ee&&(Ee=Ne,q=Se)}}}H=q,q=m[H],B+=H-q&32767}if(L){T[O++]=268435456|Kb[v]<<18|RS[L];var it=Kb[v]&31,je=RS[L]&31;A+=zf[it]+Xf[je],++w[257+it],++b[je],M=R+v,++C}else T[O++]=e[R],++w[e[R]]}}for(R=Math.max(R,M);R<a;++R)T[O++]=e[R],++w[e[R]];u=MS(e,l,c,T,w,b,A,O,k,R-k,u),c||(s.r=u&7|l[u/8|0]<<3,u-=7,s.h=g,s.p=m,s.i=R,s.w=M)}else{for(var R=s.w||0;R<a+c;R+=65535){var It=R+65535;It>=a&&(l[u/8|0]=c,It=a),u=cv(l,u+1,e.subarray(R,It))}s.i=a}return $c(o,0,r+Wf(u)+n)},_U=(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})(),uv=function(){var e=-1;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=_U[i&255^t[r]]^i>>>8;e=i},d:function(){return~e}}},jL=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}}},qf=function(e,t,i,r,n){if(!n&&(n={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),a=new nr(s.length+e.length);a.set(s),a.set(e,s.length),e=a,n.w=s.length}return HL(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)},VL=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},zP=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},wb=[],LU=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},OU=function(e,t,i,r){if(!wb[i]){for(var n="",s={},a=e.length-1,o=0;o<a;++o)n=zP(e[o],n,s);wb[i]={c:zP(e[a],n,s),e:s}}var l=VL({},wb[i].e);return PU(wb[i].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",i,l,LU(l),r)},hv=function(){return[nr,Ja,C0,zf,Xf,f0,lv,ML,kL,GL,m0,UL,Cl,Ob,vl,Rb,Wf,$c,Ii,cx,UU,zL,BU]},RU=function(){return[nr,Ja,C0,zf,Xf,f0,Kb,RS,BL,zu,FL,Hf,m0,YL,kh,Cl,Xc,Df,Nb,$b,NS,Pf,cv,MS,Wf,$c,HL,qf,GU,zL]},NU=function(){return[dv,WL]},MU=function(){return[JL]},zL=function(e){return postMessage(e,[e.buffer])},BU=function(e){return e&&{out:e.size&&new nr(e.size),dictionary:e.dictionary}},Yh=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()}},ux=function(e,t,i,r,n,s,a){var o,l=OU(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||Ii(5),o&&t.ondata(Ii(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([])})},Nf=function(e,t){return e[t]|e[t+1]<<8},Mf=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},hS=function(e,t){return Mf(e,t)+Mf(e,t+4)*4294967296},cn=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},XL=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&&cn(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)}},dv=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&Ii(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)},WL=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},qL=function(e){return 10+(e.filename?e.filename.length+1:0)},kU=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=jL();n.p(t.dictionary),cn(e,2,n.d())}},JL=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Ii(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&Ii(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function D0(e,t){return typeof e=="function"&&(t=e,e={}),this.ondata=t,e}var Hu=(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 nr(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(qf(t,this.o,0,0,this.s),i)},e.prototype.push=function(t,i){this.ondata||Ii(5),this.s.l&&Ii(4);var r=t.length+this.s.z;if(r>this.b.length){if(r>2*this.b.length-32768){var n=new nr(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||Ii(5),this.s.l&&Ii(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},e})(),FU=(function(){function e(t,i){ux([RU,function(){return[Yh,Hu]}],this,D0.call(this,t,i),function(r){var n=new Hu(r.data);onmessage=Yh(n)},6,1)}return e})();function GU(e,t){return qf(e,t||{},0,0)}var zo=(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 nr(32768),this.p=new nr(0),r&&this.o.set(r)}return e.prototype.e=function(t){if(this.ondata||Ii(5),this.d&&Ii(4),!this.p.length)this.p=t;else if(t.length){var i=new nr(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=cx(this.p,this.s,this.o);this.ondata($c(r,i,this.s.b),this.d),this.o=$c(r,this.s.b-32768),this.s.b=this.o.length,this.p=$c(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(t,i){this.e(t),this.c(i)},e})(),KL=(function(){function e(t,i){ux([hv,function(){return[Yh,zo]}],this,D0.call(this,t,i),function(r){var n=new zo(r.data);onmessage=Yh(n)},7,0)}return e})();function UU(e,t){return cx(e,{i:2},t&&t.out,t&&t.dictionary)}var Lte=(function(){function e(t,i){this.c=uv(),this.l=0,this.v=1,Hu.call(this,t,i)}return e.prototype.push=function(t,i){this.c.p(t),this.l+=t.length,Hu.prototype.push.call(this,t,i)},e.prototype.p=function(t,i){var r=qf(t,this.o,this.v&&qL(this.o),i&&8,this.s);this.v&&(XL(r,this.o),this.v=0),i&&(cn(r,r.length-8,this.c.d()),cn(r,r.length-4,this.l)),this.ondata(r,i)},e.prototype.flush=function(){Hu.prototype.flush.call(this)},e})();function dS(e,t){t||(t={});var i=uv(),r=e.length;i.p(e);var n=qf(e,t,qL(t),8),s=n.length;return XL(n,t),cn(n,s-8,i.d()),cn(n,s-4,r),n}var BS=(function(){function e(t,i){this.v=1,this.r=0,zo.call(this,t,i)}return e.prototype.push=function(t,i){if(zo.prototype.e.call(this,t),this.r+=t.length,this.v){var r=this.p.subarray(this.v-1),n=r.length>3?dv(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}zo.prototype.c.call(this,i),this.s.f&&!this.s.l&&!i&&(this.v=Wf(this.s.p)+9,this.s={i:0},this.o=new nr(0),this.push(new nr(0),i))},e})(),YU=(function(){function e(t,i){var r=this;ux([hv,NU,function(){return[Yh,zo,BS]}],this,D0.call(this,t,i),function(n){var s=new BS(n.data);s.onmember=function(a){return postMessage(a)},onmessage=Yh(s)},9,0,function(n){return r.onmember&&r.onmember(n)})}return e})();function HU(e,t){var i=dv(e);return i+8>e.length&&Ii(6,"invalid gzip data"),cx(e.subarray(i,-8),{i:2},t&&t.out||new nr(WL(e)),t&&t.dictionary)}var Ote=(function(){function e(t,i){this.c=jL(),this.v=1,Hu.call(this,t,i)}return e.prototype.push=function(t,i){this.c.p(t),Hu.prototype.push.call(this,t,i)},e.prototype.p=function(t,i){var r=qf(t,this.o,this.v&&(this.o.dictionary?6:2),i&&4,this.s);this.v&&(kU(r,this.o),this.v=0),i&&cn(r,r.length-4,this.c.d()),this.ondata(r,i)},e.prototype.flush=function(){Hu.prototype.flush.call(this)},e})(),kS=(function(){function e(t,i){zo.call(this,t,i),this.v=t&&t.dictionary?2:1}return e.prototype.push=function(t,i){if(zo.prototype.e.call(this,t),this.v){if(this.p.length<6&&!i)return;this.p=this.p.subarray(JL(this.p,this.v-1)),this.v=0}i&&(this.p.length<4&&Ii(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),zo.prototype.c.call(this,i)},e})(),jU=(function(){function e(t,i){ux([hv,MU,function(){return[Yh,zo,kS]}],this,D0.call(this,t,i),function(r){var n=new kS(r.data);onmessage=Yh(n)},11,0)}return e})(),XP=(function(){function e(t,i){this.o=D0.call(this,t,i)||{},this.G=BS,this.I=zo,this.Z=kS}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||Ii(5),this.s)this.s.push(t,i);else{if(this.p&&this.p.length){var r=new nr(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})(),Rte=(function(){function e(t,i){XP.call(this,t,i),this.queuedSize=0,this.G=YU,this.I=KL,this.Z=jU}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,XP.prototype.push.call(this,t,i)},e})();var WP=typeof TextEncoder<"u"&&new TextEncoder,FS=typeof TextDecoder<"u"&&new TextDecoder,$L=0;try{FS.decode(kh,{stream:!0}),$L=1}catch{}var ZL=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:$c(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)}},Nte=(function(){function e(t){this.ondata=t,$L?this.t=new TextDecoder:this.p=kh}return e.prototype.push=function(t,i){if(this.ondata||Ii(5),i=!!i,this.t){this.ondata(this.t.decode(t,{stream:!0}),i),i&&(this.t.decode().length&&Ii(8),this.t=null);return}this.p||Ii(4);var r=new nr(this.p.length+t.length);r.set(this.p),r.set(t,this.p.length);var n=ZL(r),s=n.s,a=n.r;i?(a.length&&Ii(8),this.p=null):this.p=a,this.ondata(s,i)},e})(),Mte=(function(){function e(t){this.ondata=t}return e.prototype.push=function(t,i){this.ondata||Ii(5),this.d&&Ii(4),this.ondata(GS(t),this.d=i||!1)},e})();function GS(e,t){if(t){for(var i=new nr(e.length),r=0;r<e.length;++r)i[r]=e.charCodeAt(r);return i}if(WP)return WP.encode(e);for(var n=e.length,s=new nr(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 nr(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 $c(s,0,a)}function VU(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(FS)return FS.decode(e);var n=ZL(e),s=n.s,i=n.r;return i.length&&Ii(8),s}}var QL=function(e){return e==1?3:e<6?2:e==9?1:0},zU=function(e,t){for(;Nf(e,t)!=1;t+=4+Nf(e,t+2));return[hS(e,t+12),hS(e,t+4),hS(e,t+20)]},Mb=function(e){var t=0;if(e)for(var i in e){var r=e[i].length;r>65535&&Ii(9),t+=r+4}return t},qP=function(e,t,i,r,n,s,a,o){var l=r.length,c=i.extra,u=o&&o.length,h=Mb(c);cn(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)&&Ii(10),cn(e,t,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1&&(cn(e,t,i.crc),cn(e,t+4,s<0?-s-2:s),cn(e,t+8,i.size)),cn(e,t+12,l),cn(e,t+14,h),t+=16,a!=null&&(cn(e,t,u),cn(e,t+6,i.attrs),cn(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;cn(e,t,+f),cn(e,t+2,g),e.set(m,t+4),t+=4+g}return u&&(e.set(o,t),t+=u),t},XU=function(e,t,i,r,n){cn(e,t,101010256),cn(e,t+8,i),cn(e,t+10,i),cn(e,t+12,r),cn(e,t+16,n)},Zb=(function(){function e(t){this.filename=t,this.c=uv(),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||Ii(5),this.c.p(t),this.size+=t.length,i&&(this.crc=this.c.d()),this.process(t,i||!1)},e})(),Bte=(function(){function e(t,i){var r=this;i||(i={}),Zb.call(this,t),this.d=new Hu(i,function(n,s){r.ondata(null,n,s)}),this.compression=8,this.flag=QL(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){Zb.prototype.push.call(this,t,i)},e})(),kte=(function(){function e(t,i){var r=this;i||(i={}),Zb.call(this,t),this.d=new FU(i,function(n,s,a){r.ondata(n,s,a)}),this.compression=8,this.flag=QL(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){Zb.prototype.push.call(this,t,i)},e})(),Fte=(function(){function e(t){this.ondata=t,this.u=[],this.d=1}return e.prototype.add=function(t){var i=this;if(this.ondata||Ii(5),this.d&2)this.ondata(Ii(4+(this.d&1)*8,0,1),null,!1);else{var r=GS(t.filename),n=r.length,s=t.comment,a=s&&GS(s),o=n!=t.filename.length||a&&s.length!=a.length,l=n+Mb(t.extra)+30;n>65535&&this.ondata(Ii(11,0,1),null,!1);var c=new nr(l);qP(c,0,t,r,o,-1);var u=[c],h=function(){for(var g=0,x=u;g<x.length;g++){var y=x[g];i.ondata(null,y,!1)}u=[]},d=this.d;this.d=0;var p=this.u.length,f=VL(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,x,y){if(g)i.ondata(g,x,y),i.terminate();else if(m+=x.length,u.push(x),y){var E=new nr(16);cn(E,0,134695760),cn(E,4,t.crc),cn(E,8,m),cn(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(Ii(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+Mb(a.extra)+(a.o?a.o.length:0)}for(var o=new nr(r+22),l=0,c=this.u;l<c.length;l++){var a=c[l];qP(o,t,a,a.f,a.u,-a.c-2,i,a.o),t+=46+a.f.length+Mb(a.extra)+(a.o?a.o.length:0),i+=a.b}XU(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 WU=(function(){function e(){}return e.prototype.push=function(t,i){this.ondata(null,t,i)},e.compression=0,e})(),Gte=(function(){function e(){var t=this;this.i=new zo(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})(),Ute=(function(){function e(t,i){var r=this;i<32e4?this.i=new zo(function(n,s){r.ondata(null,n,s)}):(this.i=new KL(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=$c(t,0)),this.i.push(t,i)},e.compression=8,e})(),Yte=(function(){function e(t){this.onfile=t,this.k=[],this.o={0:WU},this.p=kh}return e.prototype.push=function(t,i){var r=this;if(this.onfile||Ii(5),this.p||Ii(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 nr(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 x,y=Mf(c,o);if(y==67324752){a=1,l=o,f.d=null,f.c=0;var E=Nf(c,o+6),T=Nf(c,o+8),w=E&2048,b=E&8,C=Nf(c,o+26),A=Nf(c,o+28);if(u>o+30+C+A){var R=[];f.k.unshift(R),a=2;var O=Mf(c,o+18),M=Mf(c,o+22),k=VU(c.subarray(o+30,o+=30+C),!w);O==4294967295?(x=b?[-2]:zU(c,o),O=x[0],M=x[1]):b&&(O=-1),o+=A,f.c=O;var G,H={name:k,compression:T,start:function(){if(H.ondata||Ii(5),!O)H.ondata(null,kh,!0);else{var q=r.o[T];q||H.ondata(Ii(14,"unknown compression type "+T,1),null,!1),G=O<0?new q(k):new q(k,O,M),G.ondata=function(L,_,B){H.ondata(L,_,B)};for(var I=0,N=R;I<N.length;I++){var v=N[I];G.push(v,!1)}r.k[0]==R&&r.c?r.d=G:G.push(kh,!0)}},terminate:function(){G&&G.terminate&&G.terminate()}};O>=0&&(H.size=O,H.originalSize=M),f.onfile(H)}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=kh,h<0){var g=a?c.subarray(0,l-12-(h==-2&&8)-(Mf(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&&Ii(13),this.p=null)},e.prototype.register=function(t){this.o[t.compression]=t},e})(),qU=(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))(qU||{}),JU=(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))(JU||{});function Zd(e,t={}){if(!e)return"";let{proCode:i,code:r,message:n}=e;switch(i||r){case 401:return Ve("UNAUTHORIZED");case 402:return Ve("LOGIN_FAIL");case 422:return Ve("PERMISSION_DENIED");case 1111111:return Ve("PERMISSION_DENIED1");case 2000001:return Ve("PRJ_NOT_EXIST");case 4000002:return Ve("ERROR_PATH");case 6000001:return Ve("PROJECT_NOT_FOUND");case 1111112:return Ve("PERMISSION_DENIED_PARAMS",{type:n});case 1111113:return Ve("DATA_NOT_FOUND");case 1111114:return Ve("PARAMS_DATA_NOT_FOUND",{type:n});case 42222:return Ve("REQUEST_PARAM_ILLEGAL");case 1111115:return Ve("REQUEST_PARAM_ILLEGAL1");case 1111116:return Ve("REQUEST_PARAMS_ILLEGAL2",{type:n});case 1111117:return Ve("REQUEST_PARAMS_NOT_NULL",{type:n});case 1111118:return Ve("REQUEST_PARAMS_NOT_ALL_NULL",{type:n});case 1111119:return Ve("REQUEST_PARAMS_MUST_ARRAY",{type:n});case 1111120:return Ve("REQUEST_PARAMS_MUST_STRING",{type:n});case 1111121:return Ve("REQUEST_PARAMS_MUST_NUMBER",{type:n});case 1111122:return Ve("REQUEST_PARAMS_MUST_NUMBER_ARRAY",{type:n});case 1111123:return Ve("REQUEST_PARAMS_MUST_STRING_ARRAY",{type:n});case 1111124:return Ve("REQUEST_PARAMS_LENGTH_ERROR",{type:n});case 1111125:return Ve("REQUEST_PARAMS_TYPE_ERROR",{type:n});case 2001:return Ve("ILLEGAL_NAME");case 1111126:return Ve("ILLEGAL_NAME1");case 1111128:return Ve("ILLEGAL_NAME_ZH");case 1111127:return Ve("UUID_ERROR");case 1000001:return Ve("DUPLICATE_DATA");case 11e3:return Ve("DUPLICATE_DATA1");case 1000017:return Ve("DUPLICATE_DATA_PARAMS",{type:n});case 10034:return Ve("UPLOAD_LIMIT");case 1000003:return Ve("MORE_THAN_LIMIT");case 1000004:return Ve("FILE_MORE_THAN_LIMIT",{type:n});case 1000005:return Ve("PARAMS_MORE_THAN_LIMIT",{type:n});case 1000006:return Ve("IMAGE_MORE_THAN_LIMIT_PARAMS");case 1000007:return Ve("FILE_MORE_THAN_LIMIT_PARAMS");case 1000019:return Ve("END_MUST_AFTER_START");case 1000002:return Ve("FILE_READ_ONLY");case 1000008:return Ve("FILE_READ_ONLY1");case 1000010:return Ve("DATA_NOT_EXIST",{documentName:t.documentName});case 1000009:return Ve("REQUEST_PARAMS_TIME_ERROR");case 1000018:return Ve("FILES_PATH_NOT_FOUND");case 1000011:return Ve("FILES_DATA_NOT_FOUND");case 1000012:return Ve("FILES_TYPE_ERROR");case 1000013:return Ve("FILES_TYPE_MUST_BE_ONE",{type:n});case 1000014:return Ve("SET_WATERMARK_FAIL");case 1000015:return Ve("MYSQL_CRUD_ERROR",{type:n});case 1000016:return Ve("PARAMS_JSON_FAILED",{type:n});case 3000001:return Ve("MYSQL_ERROR");case 404:return Ve("NOT_FOUND");case 2002:return Ve("PRJ_NAME_EXISTS");case 3002:return Ve("BACKUP_NAME_EXISTS");case 2003:return Ve("TITLE_ILLEGAL_LEN",{documentName:t.documentName});case 2000001:return Ve("LIB_NOT_EXIST");case 3001001:return Ve("CONFIG_API_URLS_ERROR");case 3001002:return Ve("ONE_CLICK_ORDER_NOT_OPEN");case 3001003:return Ve("MATERIAL_NOT_OPEN");case 3001004:return Ve("SNAPSHOT_DEPTH_LIMIT");case 3001005:return Ve("OCR_SYMBOL_URL_ERROR");case 4000001:return Ve("USER_DATA_NOT_FOUND");case 4000012:return Ve("USER_DISABLE_ERROR");case 4000003:return Ve("USER_EXISTS_LOGIN_ERROR");case 4000004:return Ve("USER_UNAUTHORIZED_MODULES_ERROR");case 4000005:return Ve("USER_UNAUTHORIZED_ACCESS_ERROR");case 4000006:return Ve("ADMIN_NOT_CHANGE_PASSWORD");case 4000007:return Ve("SAME_PASSWORD_NEW_PASSWORD");case 4000008:return Ve("USER_ONLINE_REGISTRATION_FAILED");case 4000009:return Ve("USER_PASSWORD_CAN_NOT_DEFAULT");case 4000010:return Ve("USER_BEFORE_PASSWORD_ERROR");case 4000011:return Ve("USER_PASSWORD_LENGTH_ERROR");case 5000001:return Ve("ORG_ROLE_NOT_CREATE");case 5000002:return Ve("ORG_ROLE_NAME_DUPLICATE");case 5000003:return Ve("ORG_ROLE_ORIGIN_ERROR",{message:n});case 5000004:return Ve("ORG_ROLE_NOT_DEFAULT");case 5000005:return Ve("ADMIN_ROLE_NOT_CHANGE");case 5000006:return Ve("ADMIN_NOT_CHANGE_STATUS");case 6000002:return Ve("PROJECT_ARCHIVED");case 6000003:return Ve("PROJECT_UUID_NULL");case 6000004:return Ve("PROJECT_UUID_ERROR");case 6000005:return Ve("PROJECT_OR_TEAM_UUID_ERROR");case 6000006:return Ve("PROJECT_NOT_PERSON_ERROR");case 6000007:return Ve("PROJECT_DUPLICATE_NAME");case 6000008:return Ve("ANNOTATION_HAS_BE_FOUND");case 6000009:return Ve("ANNOTATION_NOT_FOUND");case 6000010:return Ve("ANNOTATION_CREATE_ERROR");case 6000011:return Ve("ANNOTATION_UPDATE_ERROR");case 6000012:return Ve("ANNOTATION_DELETE_ERROR");case 6000013:return Ve("PROJECT_DUPLICATE_PATH");case 7000001:return Ve("TEAM_NOT_FOUND");case 7000002:return Ve("TEAM_UUID_NULL");case 7000003:return Ve("TEAM_FOLDER_ERROR");case 7000004:return Ve("TEAM_FOLDER_DEEP_ERROR");case 7000005:return Ve("TEAM_FOLDER_UUID_ERROR");case 7000006:return Ve("TEAM_URL_DUPLICATE");case 7000007:return Ve("TEAM_CAN_NOT_DELETE");case 8000001:return Ve("COMPONENT_UUID_NULL");case 8000002:return Ve("COMPONENT_DATA_NOT_FOUND");case 8000003:return Ve("COMPONENT_NAME_DUPLICATE");case 8000004:return Ve("COMPONENT_TYPE_ERROR");case 8001001:return Ve("DELETE_SON_CATEGORY");case 9000001:return Ve("LICENSE");case 9000002:return Ve("START_TIME");case 9000003:return Ve("END_TIME");case 9000004:return Ve("PROJECT_LIMIT");case 9000005:return Ve("USER_LIMIT");case 9000006:return Ve("ONLINE_NUMBER_LIMIT");case 9000007:return Ve("COMPANY_CODE");case 9000008:return Ve("LIMIT_PCB");case 9000009:return Ve("LIMIT_SCH");case 9000011:return Ve("LIMIT_PANEL");case 9000010:return Ve("TIME_ERROR");case 9000012:return Ve("LICENSE_ERROR");case 9000013:return Ve("LICENSE_TYPE_ERROR");case 9000014:return Ve("LICENSE_ORIGIN_ERROR",{type:n});case 11000001:return Ve("BRANCH_DATA_NOT_FOUND");case 11000002:return Ve("PARENT_UUID_ERROR");case 11000003:return Ve("BRANCH_MUST_AFTER_NODE");case 11000004:return Ve("BRANCH_NAME_ERROR");case 11000005:return Ve("BRANCH_NAME_DUPLICATE");case 11000006:return Ve("BRANCH_UUID_ERROR");case 11000007:return Ve("BRANCH_NODE_SET_ERROR");case 11000008:return Ve("BRANCH_DELETE_MAIN_ERROR");case 11000009:return Ve("BRANCH_CHECK_OUT_ERROR");case 12000001:return Ve("DOCUMENT_UUID_ERROR");case 12000002:return Ve("UPDATE_FAILED");case 1000020:return Ve("INNER_API_KEY_ERROR");case 11000010:return Ve("BRANCH_MORE_THAN_LIMIT");case 1000021:return Ve("WORKSPACE_API_ERROR")}return n}function Ve(e,t){return dL()==="zh-cn"?gS.match("codeCN",e,t)||"":gS.match("codeEN",e,t)||""}function Xo(e){return e===422||e===1111111||e===6000002}function Dl(e){return e===1000001||e===11e3||e===8000003}var KU=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)}},$U=(e=>(e.IsActive="/pro-ui/liveness/monitor/isActive",e))($U||{});async function ZU(){var e;if(!E0)return!0;let t=!1,i=ut();return typeof window>"u"&&i._TAB_ID_?t=await LL(`/${i._TAB_ID_}/notify`).rpcCall("/pro-ui/liveness/monitor/isActive"):t=(e=await bt.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 QU=(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))(QU||{}),eY=(e=>(e.ContentType="Content-Type",e.Editorversion="Editor-Version",e))(eY||{}),tY=(e=>(e.Json="json",e.Blob="blob",e))(tY||{}),iY=0;async function Ot(e,t,i={},r={},n=!1){if(!await rY())throw new Error("\u975E\u6CD5\u8BF7\u6C42!!!");return await nY(e,t,i,r,n)}async function rY(){return await ZU()}async function nY(e,t,i={},r={},n=!1){return new Promise(async(s,a)=>{try{let l=iY++;var o;e=e||"GET",sY(e,i,r),o=i,r=r;let c=aY(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),oY(u,e,r,n),o=await lY(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=Zd(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 sY(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 JP(e,t=50){return typeof e!="string"?!1:e.length*2>t*1024*1024}function aY(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(JP(i[p])){u=!0;break}}if(u){let p=new FormData;for(let f in i){let m=i[f];JP(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 oY(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 pS=1e4;async function lY(e,t,i,r,n={}){if(t.match(/post/i)&&i.startsWith("/")&&!i.startsWith("/servicecenter/")&&typeof r=="string"&&r.length>=pS&&(r=dS(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>=pS){let l=new Blob([dS(new TextEncoder().encode(o),{level:1})]);r.set(a,l)}else if(o instanceof Blob&&o.size>=pS){let l=new Blob([dS(await KU.blobToUint8Array(o),{level:9})]);r.set(a,l,o.name)}}e.setRequestHeader("Content-Encoding","gzip")}return r}async function eO(e,t,i,r){if(!r||!i){let a=`invalid parameters ${r}|${i}.`;return{code:Ze.ERR_CODE.NORMAL,success:!1,msg:a,message:a,result:null}}let n=await Ot("POST",t?dr(Pt.DEVICE.DELETE,{uuid:r}):dr(Pt.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 cY(e,t,i){if(e){let u="operations not currently supported.";return{code:Ze.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 Sf(e,!0,t,i.devices||[]);r.result.devices={...n.result};let s=await Sf(e,!1,t,i.symbols||[]);r.result.symbols={...s.result};let a=await Sf(e,!1,t,i.footprints||[]);r.result.footprints={...a.result};let o=await Sf(e,!1,t,i.d3models||[]);r.result.d3models={...o.result};let l=await Sf(e,!1,t,i.cbbs||[]);r.result.cbbs={...l.result};let c=await Sf(e,!1,t,i.panels||[]);return r.result.panels={...c.result},r}async function Sf(e,t,i,r){let n=[],s=[];for(let a=0;a<r.length;a++){let o=await eO(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 tO(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 zh(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 P0(e,t=!1){return e?t?KP(e):e.indexOf("@")>=0?uY(e):e.indexOf("_")>=0?hY(e):KP(e):{componentTitleOrId:void 0,path:void 0,isLocaleFilenameMode:!1}}function KP(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 uY(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 hY(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 pv(e,t){let i=P0(e,!0),r=i.path||t,n={code:Ze.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 dY=class{constructor(){if(!crypto||!crypto.subtle)throw new Error("\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301crypto api");this.tool=crypto.subtle}},pY=class extends dY{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 $P(e){let t=e.match(/[\da-f]{2}/gi);return t?new Uint8Array(t.map(function(i){return parseInt(i,16)})).buffer:null}function fY(e,t="utf-8"){var i=new TextDecoder(t);return i.decode(e)}async function _0(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 mY(e,i);return fY(r)}}else if(e.dataStr)return e.dataStr;return null}catch(t){throw new Error("fetch\u5931\u8D25!!!"+t)}}async function mY(e,t){let i=new pY;try{let{key:r,iv:n}=e;if(t&&n&&r){let s=$P(r),a=$P(n);await i.init({key:s,iv:a});let o=await i.decrypt(t);return HU(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 iO=(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))(iO||{}),rO=(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))(rO||{}),nO=(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))(nO||{}),sO=(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))(sO||{}),aO=(e=>(e.SET="/api/v4/components/{uuid}/histories",e.GET="/api/v4/components/{uuid}/histories/{historyUuid}",e))(aO||{}),oO=(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))(oO||{}),lO=(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))(lO||{}),cO=(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))(cO||{}),uO=(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))(uO||{}),hO=(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))(hO||{}),dO=(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))(dO||{}),pO=(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))(pO||{}),fO=(e=>(e.SEARCH_LIST="/api/v2/resources/search",e.SET="/api/v2/resources/upload",e))(fO||{}),mO=(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))(mO||{}),gO=(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))(gO||{}),yO=(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))(yO||{}),Pt={PROJECT:iO,BRANCH:rO,SNAPSHOT:nO,PROJECT_HISTORY:sO,COMPONENT_HISTORY:aO,SCHEMATIC:oO,DOCUMENT:lO,DEVICE:cO,COMPONENT:uO,TAG:hO,COPPER:dO,FONT:pO,BLOB:fO,ATTR:mO,CLIENT:gO,OTHER:yO};function Hh(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 gY(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 fv(e,t,i){let r=new Date().getTime(),n=Hh(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 bO(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 L0(e,t=Ze.SYSTEMLIB_UUID,i){if(!e)return null;let r=null,n=P0(e,!0),s=n.path||t;if(n.isLocaleFilenameMode)return r=(await pv(n.componentTitleOrId,s)).result,r;let a=await Ot("GET",dr(Pt.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 _0(r);r.dataStr=o}catch(o){console.error(o)}if(!r&&e&&i){let o=await bO(e);o.success&&o.result instanceof Blob&&(r=fv(e,i,n.path))}return r}var mv=class{},yY=(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))(yY||{}),ue=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 Xs(e,t){let i=Object.keys(t);for(let r=0;r<i.length;r++)bj.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 O0(e,t){return e[t]}function xO(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 ue("DEVICE_NAMA_ERROR",i)}}function EO(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 ue("SYMBOL_NAMA_ERROR",i)}}function TO(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 ue("FOOTPRINT_NAMA_ERROR",i)}}function wO(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 ue("PANEL_LIB_NAMA_ERROR",i)}}function SO(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 ue("D3MODEL_NAMA_ERROR",i)}}function vO(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 ue("SIM_MODEL_NAMA_ERROR",i)}}async function Uf(e,t){let i=[],r=[],n=async o=>{let{message:l}=await bt.messageBus.rpcCall(Vu.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:Ze.ERR_CODE.NORMAL,success:!1,result:null,message:a}}function Ma(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 bY(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 qg(e=0,t=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(t-e+1))+e}function g0(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(qg(1,9))),t[19]&&(t[19]=i.substr(+t[19]&3|8,1)),t[8]&&(t[8]=String(qg(1,9))),t[13]&&(t[13]=String(qg(1,9))),t[18]&&(t[18]=String(qg(1,9))),t[23]&&(t[23]=String(qg(1,9))),t.join("")}function ZP(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 xY=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:[]}},EY=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:[]}},TY=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:[]}},wY=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:[]}},SY=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:[]}},vY=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:[]}},IY=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:[]}},AY=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 Hh(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,x,y,E,T,w,b,C,A,R,O,M,k,G,H,q,I,N,v,L,_,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 z;return{uuid:U.uuid,display_title:U.name,docType:17,project_uuid:(z=e.uuid)!=null?z:e.name,title:U.name.toLocaleLowerCase()}}))!=null?d:[],schematics:(f=(p=e.schematics)==null?void 0:p.map(U=>{var z,W;let ne=(W=(z=e.sheets)==null?void 0:z.filter(me=>me.belongSchematicUuid===U.uuid).map(me=>({uuid:me.uuid,ticket:0})))!=null?W:[];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 z,W,ne,me,Ee,Se,Fe,Ne,it,je,It;return{description:(z=U.description)!=null?z:"",display_title:U.name,docType:3,project_uuid:(W=e.uuid)!=null?W:"",thumb:U.thumb,title:U.name.toLocaleLowerCase(),updateTime:this.transformTime(U.updateTime),uuid:U.uuid,creator:U.creator?{avatar:"",nickname:(me=(ne=U.creator)==null?void 0:ne.name)!=null?me:"",username:(Se=(Ee=U.creator)==null?void 0:Ee.name)!=null?Se:"",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:(it=U==null?void 0:U.modifier.name)!=null?it:"",username:(je=U==null?void 0:U.modifier.name)!=null?je:"",uuid:(It=U==null?void 0:U.modifier.uuid)!=null?It:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id}}}))!=null?g:[],schs:(y=(x=e.sheets)==null?void 0:x.map(U=>{var z,W,ne,me,Ee,Se,Fe,Ne;return{description:(z=U.description)!=null?z:"",display_title:U.name,docType:1,project_uuid:(W=e.uuid)!=null?W:"",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:(me=U==null?void 0:U.creator.name)!=null?me:"",uuid:(Ee=U==null?void 0:U.creator.uuid)!=null?Ee:""}:{avatar:"",nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:U!=null&&U.modifier?{nickname:(Se=U==null?void 0:U.modifier.name)!=null?Se:"",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:(T=(E=e.classification)==null?void 0:E.primaryClassificationName)!=null?T:"",name_cn:(b=(w=e.classification)==null?void 0:w.primaryClassificationName)!=null?b:"",title:(A=(C=e.classification)==null?void 0:C.primaryClassificationName)!=null?A:"",uuid:(O=(R=e.classification)==null?void 0:R.primaryClassificationUuid)!=null?O:""},child_tag:{name:(k=(M=e.classification)==null?void 0:M.secondaryClassificationName)!=null?k:"",name_cn:(H=(G=e.classification)==null?void 0:G.secondaryClassificationName)!=null?H:"",title:(I=(q=e.classification)==null?void 0:q.secondaryClassificationName)!=null?I:"",uuid:(v=(N=e.classification)==null?void 0:N.secondaryClassificationUuid)!=null?v:""}},updated_at:this.transformTimeStr(e.updateTime),uuid:(L=e.uuid)!=null?L:e.name,boards:(B=(_=e.boards)==null?void 0:_.map(U=>({name:U.name,pcb:U.pcbUuid,sch:U.schUuid})))!=null?B:[]}}},CY=class IO{constructor(t){this.transformer=new AY(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 EY(t.device,this)),t.symbol&&(this.symbol=new IY(t.symbol,this)),t.footprint&&(this.footprint=new TY(t.footprint,this)),t.panelLib&&(this.panelLib=new SY(t.panelLib,this)),t.cbb&&(this.cbb=new xY(t.cbb,this)),t.model3D&&(this.model3D=new wY(t.model3D,this)),t.modelSimLib&&(this.modelSimLib=new vY(t.modelSimLib,this))}static async set(t){var i,r,n,s,a,o,l,c,u,h;let d=new IO(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?YP.filter(n=>r.includes(Number(n.value))||!n.value):YP}else if(t==="symbol"){let r=this._symbolSupportedSymbolTypes;i=r?HP.filter(n=>r.includes(Number(n.value))||!n.value):HP}return i.length>2?i:[]}getPreviewTypesInTab(t){let i=yU[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))}},DY=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)}},gv=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){}},PY=class extends gv{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}},AO=class extends J_{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 av(!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 _Y(e,t){let i=0;return function(...r){let n=new Date().getTime();n-i>t&&(e.apply(this,r),i=n)}}function LY(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(b){let C=r,A=n;return r=n=void 0,c=b,a=e.apply(A,C),a}function f(b){return c=b,o=window.setTimeout(x,t),u?p(b):a}function m(b){let C=b-l,A=b-c,R=t-C;return h?Math.min(R,s-A):R}function g(b){let C=b-l,A=b-c;return l===void 0||C>=t||C<0||h&&A>=s}function x(){let b=Date.now();if(g(b))return y(b);o=window.setTimeout(x,m(b))}function y(b){return o=void 0,d&&r?p(b):(r=n=void 0,a)}function E(){o!==void 0&&clearTimeout(o),c=0,r=l=n=o=void 0}function T(){return o===void 0?a:y(Date.now())}function w(){let b=Date.now(),C=g(b);if(r=arguments,n=this,l=b,C){if(o===void 0)return f(l);if(h)return o=window.setTimeout(x,t),p(l)}return o===void 0&&(o=window.setTimeout(x,t)),a}return w.cancel=E,w.flush=T,w}var ip=new Map;ip.set("<","&lt;");ip.set(">","&gt;");ip.set('"',"&quot;");ip.set("'","&apos;");ip.set("&","&amp;");function CO(e){if(typeof e!="string")return e;if(e==null)return"";function t(i){return ip.get(i)}return e==null?"":tx(e,ip)?(e+"").replace(/[<>'"&]/g,t):e}var ap=new Map;ap.set("&lt;","<");ap.set("&gt;",">");ap.set("&quot;",'"');ap.set("&apos;","'");ap.set("&amp;","&");ap.set("&#039;","'");function OY(e){if(typeof e!="string")return e;if(e==null)return"";let t={"&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&amp;":"&","&#039;":"'"};function i(r){return ap.get(r)}return tx(e,t)?(e+"").replace(/&([^;]+);/g,i):e}var R0=new Map;R0.set("~","&#126;");R0.set("^","&#94;");R0.set("#@$","&#35;&#64;&#36;");R0.set("`","&#96;");function RY(e){if(typeof e!="string")return e;if(e==null)return"";let t={"~":"&#126;","^":"&#94;","#@$":"&#35;&#64;&#36;","`":"&#96;"};function i(r){return R0.get(r)}return tx(e,t)?e.replace(/(\~|\^|#@\$|\`)/g,i):e}function US(e){if(typeof e!="object"||e===null||e===void 0)return e;if(Array.isArray(e))return e.map(US);{let t={};for(let i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=US(e[i]));return t}}function YS(e){if(typeof e!="object"||e===null||e instanceof Date)return typeof e=="string"&&e.includes("<")&&(e=CO(e)),e;if(Array.isArray(e))return e.map(YS);{let t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=YS(e[i]));return t}}function NY(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 MY(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 BY(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 kY=class extends gv{constructor(e){super(),this._action=e}get action(){return this._action}onAttr(e,t,i){i||this.action(t.key,t.value)}};async function FY(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 AO(e,t,i);n.compiler=o,o.setHandler(new kY(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=P0(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 L0(n.d3modelItemId)),n.compiler.destroy(),s.clear(),a(n)})}async function GY(e,t){let i={padList:[]};return new Promise(async r=>{try{let n=new rU(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 UY(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 YY(e,t){typeof e=="string"&&(e=parseFloat(e));let i=Math.pow(10,t);return Math.round(e*i)/i}var HY={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 jY(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function VY(e){return e<0?(360+e%360)%360:e>=360?e%360:e}function DO(e,t,i,r){var n=e-i,s=t-r;return n*n+s*s}function zY(e,t,i,r){return Math.sqrt(DO(e,t,i,r))}function XY(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 WY(e){return PO(e)&&Object.keys(e).length===0}function PO(e){return Object.prototype.toString.call(e).slice(8,-1)==="Object"}function qY(e){return _O(e)||LO(e)}function _O(e){return Object.prototype.toString.call(e).slice(8,-1)==="AsyncFunction"}function LO(e){return Object.prototype.toString.call(e).slice(8,-1)==="Function"}var Wi=class{};Wi.unitConversion=HY,Wi.ConcurrencyTaskQueue=DY,Wi.FootprintCompilerInstance=AO,Wi.FootprintCompilerHandlerProxy=gv,Wi.FootprintCompilerAttr=PY,Wi.createCSVString=NY,Wi.svg2png=MY,Wi.imageData2NewImage=BY,Wi.htmlEncode=CO,Wi.htmlDecode=OY,Wi.strEncode=RY,Wi.isEmptyObj=WY,Wi.isPlainObject=PO,Wi.isFn=qY,Wi.isAsyncFunction=_O,Wi.isNormalFunction=LO,Wi.formatDate=Hh,Wi.formatDate2=gY,Wi.deepClone=US,Wi.deepCloneWithHtmlEncode=YS,Wi.naturalSortComparator=s_,Wi.naturalSortSplitor=yS,Wi.naturalSort=L6,Wi.naturalStrSort=O6,Wi.naturalSort1=R6,Wi.naturalCompare=N6,Wi.isObjKeyInStr=tx,Wi.throttle=_Y,Wi.debounce=LY,Wi.findList=Ma,Wi.findListAll=bY,Wi.randomString=k6,Wi.parseJSON=F6,Wi.splitComponentId2FolderAndFilenameMixin=P0,Wi.getFootprintPadInfo=GY,Wi.getFootprint3DInfo=FY;var zd=class{};zd.toFixed=UY,zd.toFixed1=YY,zd.floatEqual=jY,zd.fixAngle=VY,zd.getDistance=zY,zd.getDistance2=DO,zd.getAngleByDot=XY;var OO=class HS{constructor(){this._changeCbs=new Set,this._map=new Map,this._debounceNotify=Wi.debounce(()=>{this._notify()},50)}static get context(){return ut()}static getInstance(){var t;return(t=this.context.extendLibManager)!=null?t:this.context.extendLibManager=new HS}_notify(){for(let t of this._changeCbs)t()}onChange(t){this._changeCbs.add(t)}offChange(t){this._changeCbs.delete(t)}_getLibId(t){return`${HS.LIB_ID_PREFFIX}${t}`}async addLibWithId(t){this._map.set(t.id,await CY.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())}};OO.LIB_ID_PREFFIX="extend_lib_";var as=OO,JY=0;async function N0(e,t,i,r,n=!0,s,a){let o=null,l="requestid"+ ++JY;s&&s(l);let c={user_uuid:e,path:t,type:i};r!==void 0&&(c.bindTypes=r),a&&a(c);try{if(as.getInstance().hasLib(e))return await KY(e,i,n);let h=await Ot("GET",Pt.TAG.LIST,c,{headers:{path:t},searchParams:!0});if(h.success)return{...h,result:await yv(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:Ze.ERR_CODE.NORMAL,success:!1,result:null,msg:u||"Fetch Category List Error"}}async function KY(e,t,i){var r;let n=[];for(let s of t){let a=await((r=as.getInstance().getLib(e))==null?void 0:r.getCategoryTreeDataItemsByCategoryType(s));a&&n.push(a)}return{code:0,success:!0,result:await yv(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 $Y(e=!0){let t=null;try{let r=await Ot("POST",Pt.TAG.DEVICE_CATE);if(r.success)return{...r,result:await yv(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:Ze.ERR_CODE.NORMAL,success:!1,result:null,msg:i||"Fetch Category List Error"}}async function yv(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(ZP("order_no")),n.forEach(h=>{h.children.length>1&&h.children.sort(ZP("order_no"))}),n.forEach(h=>{i.push({...h})}),t){let h=(await bt.messageBus.rpcCall("I18nTranslateService",{str:Ze.CATEGORY_ITEM_ALL_TITLE})).message;i.unshift({title:Ze.CATEGORY_ITEM_ALL_TITLE,titleAdditional:h||Ze.CATEGORY_ITEM_ALL_TITLE,id:Ze.CATEGORY_ITEM_ALL_VALUE,order_no:Number.MAX_SAFE_INTEGER,disableTranslate:!1,children:[],parentId:void 0}),r.push(Ze.CATEGORY_ITEM_ALL_VALUE)}return{languageHashtable:a,treeData:i,selectedIds:r,categoryIds:c,childCategory2ParentCategoryMap:u,sourceCategoryList:e}}async function Qd(e){let{categories:t,type:i,uuid:r}=e,n=await N0(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:x,child_order_no:y}=t[f];if(m){let E=Ma(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 b=Ma(E.data.children,"title",g);if(b.index>=0){o.push({name:b.data.title,type:i,user_uuid:r,order_no:b.data.order_no,parent_uuid:E.data.id,uuid:b.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 T=g0(),w=g0();l.push({name:m,type:i,user_uuid:r,order_no:typeof x<"u"?x:f+1,parent_uuid:void 0,uuid:T}),g&&c.push({name:g,type:i,user_uuid:r,order_no:typeof y<"u"?y:f+1,parent_uuid:T,uuid:w})}}let u=[];if(l.length){let f=await Uf(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=Ma(l,"uuid",c[m].parent_uuid);g.index>=0&&g.data.__remoteId&&(c[m].parent_uuid=g.data.__remoteId)}let f=await Uf(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 bv(e){let{uuid:t,path:i,types:r,names:n}=e;return new Promise(async(s,a)=>{let o=await N0(t,i,r,void 0,!1);if(o.code!==0){s({...o,code:Ze.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=Ma(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=Ma(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 ZY(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 RO(e){try{let{uuid:t,path:i,types:r,names:n}=e,s={primary:n[0],secondary:n[1]},a=await bv({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:Ze.ERR_CODE.NORMAL,message:t.message,result:null}}}async function QY(e,t,i,r=!1){let n=await bv(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 Uf(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 Uf(a);d.success&&d.result.successList.length&&(l=d.result.successList.map(p=>p.result))}}else if(!r&&a.length){let h=await Uf(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 eH(e,t){let i=[],r=[],n=async o=>{let{message:l}=await bt.messageBus.rpcCall(Vu.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:Ze.ERR_CODE.NORMAL,success:!1,result:null,message:a}}async function tH(e){let{uuid:t,path:i,types:r,ids:n}=e;return new Promise(async(s,a)=>{let o=await N0(t,i,r,void 0,!1);if(o.code!==0){s({...o,code:Ze.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=Ma(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=Ma(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 iH=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 Qd({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 Qd({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 Qd({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 rH(e,t){let i=[],r=[],n=async o=>{let{message:l}=await bt.messageBus.rpcCall(Vu.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:Ze.ERR_CODE.NORMAL,success:!1,result:null,message:a}}var xs=class{};xs.categoryAddtition=new iH,xs.fetchCategoryList=N0,xs.fetchInternalCategoryList=$Y,xs.addCategoriesBatch=Uf,xs.deleteCategoriesBatch=eH,xs.updateCategoriesBatch=rH,xs.addCategoriesBatchByNameArray=Qd,xs.queryCategoryBatchByNames=bv,xs.queryCategoryBatchByIds=tH,xs.formatRepeatCategoryArr=ZY,xs.bindAndCreateCategory=QY,xs.getCategoryNamesByTags=Wu;async function Wu(e,t,i){if(!e)return[];if(e instanceof Array)return e;let r=zh(e);if(r=r.filter(c=>!!c),!r.length)return[];let n=(await bt.messageBus.rpcCall("LocaleCurrFetch",{})).message||"en",s=await N0(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 NO(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=zh(r.tags));else{if(!e.uuid||!e.path)throw new ue("PARAMETER_VERIFICATION","missing 3d-model uuid or path data.");l=e.uuid,c=e.path,n=await Jr.getD3Model({isProject:e.isProject,uuid:e.uuid,path:e.path}),n&&(n.title=n.display_title,a=await Wu(n.tags,e.path,[5]))}if(!i){let u=await xs.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 Jf(e){return e?{uuid:e.uuid,nickname:e.nickname,username:e.username}:{}}function nH(e){return Array.isArray(e)?e:e?[e]:[]}function Kf(e){return e?{uuid:e.uuid,nickname:e.nickname,username:e.username}:{}}function $f(e){return e?{uuid:e.uuid,nickname:e.nickname,username:e.username}:{}}function MO(e,t){return{title:t.title,description:t.description,images:nH(t.images),attributes:t.attributes,uuid:t.uuid,path:Vf(t)||e,ticket:t.ticket,updateTime:da(t.updateTime),createTime:da(t.createTime),display_title:t.display_title,creator:Jf(t.creator),modifier:Kf(t.modifier),owner:$f(t.owner),symbol_type:t.symbol_type}}function Xh(e,t){return{...MO(e,t),isFavorite:t.isFavorite,tags:t.tags,produce_code:t.produce_code}}function Sb(e,t){return{...MO(e,t),custom_tags:t.custom_tags,source:t.source,version:t.version}}function BO(e,t){return{title:t.title,description:t.description,docType:t.docType,path:Vf(t)||e,uuid:t.uuid,ticket:t.ticket,updateTime:da(t.updateTime),createTime:da(t.createTime),display_title:t.display_title,creator:Jf(t.creator),modifier:Kf(t.modifier),owner:$f(t.owner)}}function Qc(e,t){return{...BO(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 fS(e,t){return{...BO(e,t),custom_tags:t.custom_tags,source:t.source,version:t.version}}function kO(e,t){return{title:t.title,description:t.description,docType:t.docType,uuid:t.uuid,path:Vf(t)||e,ticket:t.ticket,updateTime:da(t.updateTime),createTime:da(t.createTime),display_title:t.display_title,creator:Jf(t.creator),modifier:Kf(t.modifier),owner:$f(t.owner)}}function eu(e,t){return{...kO(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 mS(e,t){return{...kO(e,t),custom_tags:t.custom_tags,source:t.source,version:t.version}}async function Zf(e,t){return{title:t.title,description:t.description,path:Vf(t)||e,docType:t.docType,uuid:t.uuid,ticket:t.ticket,updateTime:da(t.updateTime),createTime:da(t.createTime),display_title:t.display_title,creator:Jf(t.creator),modifier:Kf(t.modifier),owner:$f(t.owner),tags:t.tags,dataStrId:t.dataStrId,dataStr:await _0(t)}}function op(e,t){return{title:t.title,description:t.description,path:Vf(t)||e,docType:t.docType,uuid:t.uuid,ticket:t.ticket,updateTime:da(t.updateTime),createTime:da(t.createTime),display_title:t.display_title,creator:Jf(t.creator),modifier:Kf(t.modifier),owner:$f(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 lp(e,t){return{title:t.title,path:Vf(t)||e,docType:t.docType,uuid:t.uuid,ticket:t.ticket,updateTime:da(t.updateTime),createTime:da(t.createTime),display_title:t.display_title,creator:Jf(t.creator),modifier:Kf(t.modifier),owner:$f(t.owner),tags:t.tags,history_uuid:t.history_uuid,key:t.key,iv:t.iv,dataStrId:t.dataStrId,dataStr:await _0(t)}}async function sH(e){let{d3modelItemIn:t,d3modelItemOut:i,d3modelTagIds:r,d3modelTagTitles:n}=await NO(e.d3model,e.path,e.isProject),s=t||i;if(!s)throw new ue("PARAMETER_VERIFICATION","missing 3d-model data.");SO(s.title),"path"in e.d3model&&e.d3model.override&&Xs(s,e.d3model.override);let a=await Ot("POST",Pt.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 Zf(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("D3MODEL_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("CREATE_D3MODEL_PERMISSIONS",o):new ue("CREATE_D3MODEL",o)}async function Qb(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 Jr.getSymbolSearchList(c))[a]||[]}if(r===28){let c={isProject:e,path:i,titles:[a]};l=(await Jr.getDeviceSearchList(c))[a]||[]}if(r===4){let c={isProject:e,path:i,titles:[a]};l=(await Jr.getFootprintSearchList(c))[a]||[]}return r===16&&(l=(await Jr.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 ue?`${String(c.action)}|${String(c.message)}`:c.message||"QueryComponentsByTitle call error."}}}function QP(e,t){return e.path==t}function e_(e){try{let t=JSON.parse(e);return{parentName:t[0],childName:t[1]}}catch{return{parentName:"",childName:""}}}function aH(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 FO(e,t){typeof e.footprintItemId<"u"&&(t.Footprint=e.footprintItemId),typeof e.symbolItemId<"u"&&(t.Symbol=e.symbolItemId)}async function GO(e,t){let i=aH(e),r=e.footprintItem,n=e.symbolItem,s={},a=async(E,T)=>{let w="",b="",C=!1,A=t==="zh-hans",R=E.parent_tag,O=E.child_tag;if(R&&R.uuid&&(C=!0,w=A&&R.name_cn||R.name),C&&O&&O.uuid){let M=A&&O.name_cn||O.name;w+=`:${M}`}if(w){let M=w.split(":")[0],k=w.split(":")[1],G=await Qd({categories:k?[{parentName:M,childName:k}]:[{parentName:M}],type:[+T],uuid:i["device-owner"]}),H=G.allParentCreated[0]?G.allParentCreated[0].uuid:void 0,q=G.allChildCreated[0]?G.allChildCreated[0].uuid:void 0;H&&(b=q?[H,q]:[H])}return b},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:T}=e_(r.custom_tags);if(E){let w=await Qd({categories:T?[{parentName:E,childName:T}]:[{parentName:E}],type:[4],uuid:i["device-owner"]}),b=w.allParentCreated[0]?w.allParentCreated[0].uuid:void 0,C=w.allChildCreated[0]?w.allChildCreated[0].uuid:void 0;b&&(o["file-customTags"]=C?[b,C]:[b])}}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:T}=e_(n.custom_tags);if(E){let w=await Qd({categories:T?[{parentName:E,childName:T}]:[{parentName:E}],type:[4],uuid:i["device-owner"]}),b=w.allParentCreated[0]?w.allParentCreated[0].uuid:void 0,C=w.allChildCreated[0]?w.allChildCreated[0].uuid:void 0;b&&(l["file-customTags"]=C?[b,C]:[b])}}let c,u,h,d,p=!1,f=!1,m=!1;async function g(){if(i["footprint-name"])if(QP(r,i["device-owner"]||i["device-lib"]))h=r,c=null;else{let E=await Qb(!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 x(){if(!i["new-symbol"]&&i["symbol-name"]&&n)if(QP(n,i["device-owner"]||i["device-lib"]))d=n,u=null;else{let E=await Qb(!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 x();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 xv(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=zh(n.tags)));else{if(!e.uuid||!e.path)throw new ue("PARAMETER_VERIFICATION","missing footprint uuid or path data.");c=e.uuid,u=e.path,s=await Jr.getFootprint({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await Wu(s.tags,e.path,[4]))}if(!i){let h=await xs.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 Ev(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=zh(n.tags)));else{if(!e.uuid||!e.path)throw new ue("PARAMETER_VERIFICATION","missing symbol uuid or path data.");c=e.uuid,u=e.path,s=await Jr.getSymbol({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await Wu(s.tags,e.path,[2])),l=e.isProject}if(!i){let h=await xs.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 UO(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=zh(n.tags)));else{if(!e.uuid||!e.path)throw new ue("PARAMETER_VERIFICATION","missing device uuid or path data.");s=await Jr.getDevice({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await Wu(s.tags,e.path,[3])),l=e.isProject}if(!i){let c=await xs.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 YO(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:x}=await Ev(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=x}else if(n)if(s){let d=await Jr.getSymbol({isProject:t,uuid:n,path:s});if(u=n,h=s,d){d.title=d.display_title,o=d,c=await Wu(d.tags,s,[2]);let p=await xs.categoryAddtition.addActuator(c,[0],i,2);l=p.uuids,c=p.titles}}else{let d=null;try{d=await Jr.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 HO(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:x}=await xv(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=x}else if(n)if(s){let d=await Jr.getFootprint({isProject:t,uuid:n,path:s});if(u=n,h=s,d){d.title=d.display_title,o=d,c=await Wu(d.tags,s,[4]);let p=await xs.categoryAddtition.addActuator(c,[0],i,4);l=p.uuids,c=p.titles}}else{let d=null;try{d=await Jr.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 jO(e,t,i,r,n,s){if(!r)return;let a=null;if("data"in r)n.title&&(a=await Jr.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&&Xs(n,r.override);try{a=await Jr.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 Jr.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 Vh({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 ue("CREATE_SYMBOL_MIGRATE_CANVAS_ERROR",o.message||"migrate canvas error.")}}}async function VO(e,t,i,r,n,s){if(!r)return;let a=null;if("data"in r)n.title&&(a=await Jr.createFootprint({isProject:e,path:t,footprint:{data:{...n,tags:s}}})),i.attributes&&a&&typeof a=="object"&&(i.attributes.Footprint=a.uuid);else{r.override&&Xs(n,r.override);try{a=await Jr.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 Jr.createFootprint({isProject:e,path:t,footprint:{data:{...n,tags:s}}})),i.attributes&&a&&typeof a=="object"){i.attributes.Footprint=a.uuid;let o=await Vh({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 ue("CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",o.message||"migrate canvas error.")}}}async function oH(e){let{deviceItemIn:t,deviceItemOut:i,deviceTagIds:r,deviceTagTitles:n,isDeviceFromProject:s}=await UO(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 ue("PARAMETER_VERIFICATION","missing device data.");a.title=e.device&&"path"in e.device&&e.device.override&&O0(e.device.override,"title")||a.title,xO(a.title);let{symbolItemIn:o,symbolItemOut:l,symbolTagIds:c,symbolTagTitles:u,symbolItemOriginUuid:h,symbolItemOriginPath:d}=await YO(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&&Xs(p,e.symbol.override);let{footprintItemIn:m,footprintItemOut:g,footprintTagIds:x,footprintTagTitles:y,footprintItemOriginUuid:E,footprintItemOriginPath:T}=await HO(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&&Xs(w,e.footprint.override),a.attributes&&g&&typeof g=="object"&&(a.attributes.Footprint=g.uuid);let b=!1,C=!1,A=await GO({symbolItem:p,footprintItem:w,userIdSelected:e.path,isNeedCreateSymbolAndAssocia:f},void 0);if(A.isNeedConfirm){let M=(await bt.messageBus.rpcCall("OpenSameNameSaveAsDlgService",{...A},31536e8)).message;if(!M){let k="an exception occurred while executing the cross-bind program.";throw new ue("CROSS_BIND",k)}if(M.action==="cancel"||M.action==="close"){let k="quit operate while executing the cross-bind program.";throw new ue("CROSS_BIND_EXIT",k)}A.updateCache=M.data,a.attributes&&Object.keys(A.updateCache).length&&(A.updateCache.symbolItemId&&(b=!0),A.updateCache.footprintItemId&&(C=!0),FO(A.updateCache,a.attributes))}!b&&p&&await jO(e.isProject,e.path,a,e.symbol,p,u),!C&&w&&await VO(e.isProject,e.path,a,e.footprint,w,y),"path"in e.device&&e.device.override&&(delete e.device.override.tags,Xs(a,e.device.override));let R=await Ot("POST",Pt.DEVICE.CREATE,{...a,tags:r,owner:e.path,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(R.code===0&&R.success){let M=R.result;return Xh(e.path,M)}let O=R.message||R.msg||"Request Error.";throw Dl(R.code)?new ue("DEVICE_SAME_NAMA_EXISTS",O):Xo(R.code)?new ue("CREATE_DEVICE_PERMISSIONS",O):new ue("CREATE_DEVICE",O)}async function lH(e){let{footprintItemIn:t,footprintItemOut:i,footprintTagIds:r,footprintTagTitles:n}=await xv(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 ue("PARAMETER_VERIFICATION","missing footprint data.");s.title="path"in e.footprint&&e.footprint.override&&O0(e.footprint.override,"title")||s.title,TO(s.title),"path"in e.footprint&&e.footprint.override&&(delete e.footprint.override.tags,Xs(s,e.footprint.override));let a=await Ot("POST",Pt.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 Vh({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 ue("CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return eu(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("FOOTPRINT_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("CREATE_FOOTPRINT_PERMISSIONS",o):new ue("CREATE_FOOTPRINT",o)}async function zO(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=zh(n.tags));else{if(!e.uuid||!e.path)throw new ue("PARAMETER_VERIFICATION","missing simModel uuid or path data.");c=e.uuid,u=e.path,s=await Jr.getSimModel({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await Wu(s.tags,e.path,[6]))}if(!i){let h=await xs.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 cH(e){let{simModelItemIn:t,simModelItemOut:i,simModelTagIds:r,simModelTagTitles:n}=await zO(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 ue("PARAMETER_VERIFICATION","missing sim-model data.");s.title="path"in e.simModel&&e.simModel.override&&O0(e.simModel.override,"title")||s.title,vO(s.title),"path"in e.simModel&&e.simModel.override&&(delete e.simModel.override.tags,Xs(s,e.simModel.override));let a=await Ot("POST",Pt.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 lp(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("SIM_MODEL_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("CREATE_SIM_MODEL_PERMISSIONS",o):new ue("CREATE_SIM_MODEL",o)}async function uH(e){let{symbolItemIn:t,symbolItemOut:i,symbolTagIds:r,symbolTagTitles:n}=await Ev(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 ue("PARAMETER_VERIFICATION","missing symbol data.");s.title="path"in e.symbol&&e.symbol.override&&O0(e.symbol.override,"title")||s.title,EO(s.title),"path"in e.symbol&&e.symbol.override&&(delete e.symbol.override.tags,Xs(s,e.symbol.override));let a=await Ot("POST",Pt.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 Vh({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 ue("CREATE_SYMBOL_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return Qc(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("SYMBOL_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("CREATE_SYMBOL_PERMISSIONS",o):new ue("CREATE_SYMBOL",o)}async function hH(e){let t=await Ot("GET",dr(Pt.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 ue("GET_DEVICE_NOT_FOUND","data not found");return Xh(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new ue("GET_DEVICE",i)}async function dH(e){let t=await Ot("GET",dr(Pt.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 ue("GET_FOOTPRINT_NOT_FOUND","data not found");return eu(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new ue("GET_FOOTPRINT",i)}async function pH(e){let t=await Ot("GET",dr(Pt.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 lp(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new ue("GET_SIM_MODEL",i)}function sc(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 fH(e){let t=await Ot("GET",Pt.COMPONENT.LIST,{...sc(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 lp(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 ue("GET_SIM_MODEL_LIST",i)}async function mH(e){let t=await Ot("GET",dr(Pt.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 ue("GET_SYMBOL_NOT_FOUND","data not found");return Qc(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new ue("GET_SYMBOL",i)}async function gH(e){let{deviceItemIn:t,deviceItemOut:i,deviceTagIds:r,deviceTagTitles:n,isDeviceFromProject:s}=await UO(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 ue("PARAMETER_VERIFICATION","missing device data.");a.title!==void 0&&xO(a.title);let{symbolItemIn:o,symbolItemOut:l,symbolTagIds:c,symbolTagTitles:u,symbolItemOriginUuid:h,symbolItemOriginPath:d}=await YO(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&&Xs(p,e.symbol.override),a.attributes&&l&&typeof l=="object"&&(a.attributes.Symbol=l.uuid);let{footprintItemIn:m,footprintItemOut:g,footprintTagIds:x,footprintTagTitles:y,footprintItemOriginUuid:E,footprintItemOriginPath:T}=await HO(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&&Xs(w,e.footprint.override),a.attributes&&g&&typeof g=="object"&&(a.attributes.Footprint=g.uuid);let b=!1,C=!1,A=await GO({symbolItem:p,footprintItem:w,userIdSelected:e.path,isNeedCreateSymbolAndAssocia:f},void 0);if(A.isNeedConfirm){let M=(await bt.messageBus.rpcCall("OpenSameNameSaveAsDlgService",{...A},31536e8)).message;if(!M){let k="an exception occurred while executing the cross-bind program.";throw new ue("CROSS_BIND",k)}if(M.action==="cancel"||M.action==="close"){let k="quit operate while executing the cross-bind program.";throw new ue("CROSS_BIND_EXIT",k)}A.updateCache=M.data,a.attributes&&Object.keys(A.updateCache).length&&(A.updateCache.symbolItemId&&(b=!0),A.updateCache.footprintItemId&&(C=!0),FO(A.updateCache,a.attributes))}!b&&p&&await jO(e.isProject,e.path,a,e.symbol,p,u),!C&&w&&await VO(e.isProject,e.path,a,e.footprint,w,y),"path"in e.device&&e.device.override&&(delete e.device.override.tags,Xs(a,e.device.override));let R=await Ot("POST",dr(Pt.DEVICE.UPDATE,{uuid:e.uuid}),{...a,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(R.code===0&&R.success&&R.result){let M=R.result;return Xh(e.path,M)}let O=R.message||R.msg||"Request Error.";throw Dl(R.code)?new ue("DEVICE_SAME_NAMA_EXISTS",O):Xo(R.code)?new ue("CREATE_DEVICE_PERMISSIONS",O):new ue("UPDATE_DEVICE",O)}async function yH(e){let{footprintItemIn:t,footprintItemOut:i,footprintTagIds:r,footprintTagTitles:n}=await xv(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 ue("PARAMETER_VERIFICATION","missing footprint data.");s.title!==void 0&&TO(s.title),"path"in e.footprint&&e.footprint.override&&(delete e.footprint.override.tags,Xs(s,e.footprint.override));let a=await Ot("POST",dr(Pt.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 Vh({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 ue("UPDATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return eu(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("FOOTPRINT_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("UPDATE_FOOTPRINT_PERMISSIONS",o):new ue("UPDATE_FOOTPRINT",o)}async function bH(e){let{simModelItemIn:t,simModelItemOut:i,simModelTagIds:r,simModelTagTitles:n}=await zO(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 ue("PARAMETER_VERIFICATION","missing simModel data.");s.title!==void 0&&vO(s.title),"path"in e.simModel&&e.simModel.override&&(delete e.simModel.override.tags,Xs(s,e.simModel.override));let a=await Ot("POST",dr(Pt.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 ue("UPDATE_SIM_MODEL",l)}if(s.dataStr){let l=await Ot("POST",dr(Pt.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 ue("UPDATE_SIM_MODEL",c)}}if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;return await lp(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("SIM_MODEL_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("UPDATE_SIM_MODEL_PERMISSIONS",o):new ue("UPDATE_SYMBOL",o)}async function xH(e){let{symbolItemIn:t,symbolItemOut:i,symbolTagIds:r,symbolTagTitles:n}=await Ev(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 ue("PARAMETER_VERIFICATION","missing symbol data.");s.title!==void 0&&EO(s.title),"path"in e.symbol&&e.symbol.override&&(delete e.symbol.override.tags,Xs(s,e.symbol.override));let a=await Ot("POST",dr(Pt.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 Vh({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 ue("UPDATE_SYMBOL_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return Qc(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("SYMBOL_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("UPDATE_SYMBOL_PERMISSIONS",o):new ue("UPDATE_SYMBOL",o)}async function EH(e){let t=await Ot("GET",Pt.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 Zf(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 ue("GET_D3MODEL_LIST",i)}async function TH(e){let t=await Ot("GET",Pt.COMPONENT.LIST,{...sc(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(eu(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 ue("GET_FOOTPRINT_LIST",i)}async function wH(e){let t=await Ot("GET",Pt.COMPONENT.LIST,{...sc(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(Qc(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 ue("GET_SYMBOL_LIST",i)}async function SH(e){var t,i;let r=await Ot("GET",Pt.DEVICE.LIST,{...sc(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=Xh(e.path,o);e.withPackage&&(t=o.symbol_info)!=null&&t.uuid&&(l.symbol=Qc(e.path,o.symbol_info)),e.withPackage&&(i=o.footprint_info)!=null&&i.uuid&&(l.footprint=eu(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 ue("GET_DEVICE_LIST",n)}async function vH(e){return e.titles?await IH(e):e.uuids?await AH(e):await CH(e)}async function IH(e){var t,i;let{path:r,titles:n,user_uuids:s}=e,a=await Ot("POST",Pt.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=Xh(r,h);e.withPackage&&(t=h.symbol_info)!=null&&t.uuid&&(d.symbol=Qc(r,h.symbol_info)),e.withPackage&&(i=h.footprint_info)!=null&&i.uuid&&(d.footprint=eu(r,h.footprint_info)),l[c].push(d)}}return l}let o=a.message||a.msg||"Request Error.";throw new ue("GET_DEVICE_SEARCH_LIST",o)}async function AH(e){let{path:t,uuids:i}=e,r=await Ot("POST",Pt.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=Xh(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new ue("GET_DEVICE_SEARCH_UUIDS",n)}async function CH(e){var t,i;let{path:r,query:n={},uid:s,page:a,pageSize:o,tags:l=[],wd:c}=e,u=await Ot("POST",Pt.DEVICE.SEARCH_LIST,{...sc(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 x=0;x<g.length;x++){let y=g[x],E=Xh(r,y);e.withPackage&&(t=y.symbol_info)!=null&&t.uuid&&(E.symbol=Qc(r,y.symbol_info)),e.withPackage&&(i=y.footprint_info)!=null&&i.uuid&&(E.footprint=eu(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 ue("GET_DEVICE_SEARCH_LIST",h)}async function DH(e){return e.titles?await PH(e):e.uuids?await _H(e):await LH(e)}async function PH(e){let{path:t,titles:i,docType:r,user_uuids:n}=e,s=await Ot("POST",Pt.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=Qc(t,u);o[l].push(h)}}return o}let a=s.message||s.msg||"Request Error.";throw new ue("GET_SYMBOL_SEARCH_LIST",a)}async function _H(e){let{path:t,uuids:i}=e,r=await Ot("POST",Pt.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=Qc(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new ue("GET_SYMBOL_SEARCH_UUIDS",n)}async function LH(e){let{path:t,query:i,uid:r,page:n,pageSize:s,tags:a=[],wd:o,docType:l}=e,c=await Ot("POST",Pt.COMPONENT.SEARCH_LIST,{...sc(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 x=m[g],y=Qc(t,x);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 ue("GET_SYMBOL_SEARCH_LIST",u)}async function OH(e){return e.titles?await RH(e):e.uuids?await NH(e):await MH(e)}async function RH(e){let{path:t,titles:i,user_uuids:r}=e,n=await Ot("POST",Pt.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=eu(t,c);a[o].push(u)}}return a}let s=n.message||n.msg||"Request Error.";throw new ue("GET_FOOTPRINT_SEARCH_LIST",s)}async function NH(e){let{path:t,uuids:i}=e,r=await Ot("POST",Pt.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=eu(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new ue("GET_FOOTPRINT_SEARCH_UUIDS",n)}async function MH(e){let{path:t,query:i={},uid:r,page:n,pageSize:s,tags:a=[],wd:o}=e,l=await Ot("POST",Pt.COMPONENT.SEARCH_LIST,{...sc(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],x=eu(t,g);h.push(x)}}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 ue("GET_FOOTPRINT_SEARCH_LIST",c)}async function BH(e){return e.titles?await kH(e):e.uuids?await FH(e):await GH(e)}async function kH(e){let{path:t,docType:i,titles:r}=e,n=await Ot("POST",Pt.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 lp(e.path,c);a[o].push(u)}}return a}let s=n.message||n.msg||"Request Error.";throw new ue("GET_SIM_MODEL_SEARCH_LIST",s)}async function FH(e){let{path:t,uuids:i}=e,r=await Ot("POST",Pt.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 lp(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new ue("GET_SIM_MODEL_SEARCH_UUIDS",n)}async function GH(e){let{path:t,query:i={},uid:r,page:n,pageSize:s,docType:a,tags:o=[],wd:l}=e,c=await Ot("POST",Pt.COMPONENT.SEARCH_LIST,{...sc(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 x=m[g];d.push(await lp(e.path,x))}}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 ue("GET_SIM_MODEL_SEARCH_LIST",u)}async function UH(e){if(e.attributes.Symbol){let s=await Jr.getSymbol({isProject:e.isProject,uuid:e.attributes.Symbol,path:e.path})}if(e.attributes.Footprint){let s=await Jr.getFootprint({isProject:e.isProject,uuid:e.attributes.Footprint,path:e.path})}let t=await Jr.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 Ot("POST",dr(Pt.DEVICE.UPDATE,{uuid:e.uuid}),{...t,title:t.display_title||t.title,tags:t.tags?tO(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 Xh(e.path,s)}let n=r.message||r.msg||"Request Error.";throw Xo(r.code)?new ue("CREATE_DEVICE_PERMISSIONS",n):new ue("UPDATE_DEVICE_ATTRIBUTES",n)}async function YH(e){return e.titles?await HH(e):e.uuids?await jH(e):await VH(e)}async function HH(e){let{path:t,titles:i,user_uuids:r}=e;if(c_||l0&&t!==Ze.SYSTEMLIB_UUID){let n=await Ot("POST",Pt.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 ue("GET_D3MODEL_SEARCH_LIST",s)}else{let n=await Ot("POST",Pt.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 Zf(e.path,c);a[o].push(u)}}return a}let s=n.message||n.msg||"Request Error.";throw new ue("GET_D3MODEL_SEARCH_LIST",s)}}async function jH(e){let{path:t,uuids:i}=e,r=await Ot("POST",Pt.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 Zf(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new ue("GET_D3MODEL_SEARCH_UUIDS",n)}async function VH(e){let{path:t,query:i={},uid:r,page:n,pageSize:s,tags:a=[],wd:o}=e,l=await Ot("POST",Pt.COMPONENT.SEARCH_LIST,{...sc(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 Zf(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 ue("GET_D3MODEL_SEARCH_LIST",c)}async function zH(e){return e.titles?await XH(e):e.uuids?await WH(e):await qH(e)}async function XH(e){let{path:t,titles:i}=e,r=await Ot("POST",Pt.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=op(e.path,l);s[a].push(c)}}return s}let n=r.message||r.msg||"Request Error.";throw new ue("GET_PANEL_LIB_SEARCH_LIST",n)}async function WH(e){let{path:t,uuids:i}=e,r=await Ot("POST",Pt.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=op(t,a);s.push(o)}return s}let n=r.message||r.msg||"Request Error.";throw new ue("GET_PANEL_LIB_SEARCH_UUIDS",n)}async function qH(e){let{path:t,query:i={},uid:r,page:n,pageSize:s,tags:a=[],wd:o}=e,l=await Ot("POST",Pt.COMPONENT.SEARCH_LIST,{...sc(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(op(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 ue("GET_PANEL_LIB_SEARCH_LIST",c)}async function JH(e){let t=await Ot("GET",dr(Pt.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 ue("GET_PANEL_LIB_NOT_FOUND","data not found");return op(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new ue("GET_PANEL_LIB",i)}async function XO(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=zh(n.tags));else{if(!e.uuid||!e.path)throw new ue("PARAMETER_VERIFICATION","missing panelLib uuid or path data.");c=e.uuid,u=e.path,s=await Jr.getPanelLib({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,r&&Array.isArray(r)?o=r:o=await Wu(s.tags,e.path,[29]))}if(!i){let h=await xs.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 KH(e){let{panelLibItemIn:t,panelLibItemOut:i,panelLibTagIds:r,panelLibTagTitles:n}=await XO(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 ue("PARAMETER_VERIFICATION","missing panelLib data.");s.title="path"in e.panelLib&&e.panelLib.override&&O0(e.panelLib.override,"title")||s.title,wO(s.title),"path"in e.panelLib&&e.panelLib.override&&(delete e.panelLib.override.tags,Xs(s,e.panelLib.override));let a=await Ot("POST",Pt.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 Vh({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 ue("CREATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return op(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("PANELLIB_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("CREATE_PANEL_LIB_PERMISSIONS",o):new ue("CREATE_PANEL_LIB",o)}async function $H(e){let{panelLibItemIn:t,panelLibItemOut:i,panelLibTagIds:r,panelLibTagTitles:n}=await XO(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 ue("PARAMETER_VERIFICATION","missing panelLib data.");s.title!==void 0&&wO(s.title),"path"in e.panelLib&&e.panelLib.override&&(delete e.panelLib.override.tags,Xs(s,e.panelLib.override));let a=await Ot("POST",dr(Pt.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 Vh({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 ue("UPDATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",c.message||"migrate canvas error.")}return op(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("PANELLIB_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("UPDATE_PANEL_LIB_PERMISSIONS",o):new ue("UPDATE_PANEL_LIB",o)}async function ZH(e){let t=await Ot("GET",Pt.COMPONENT.LIST,{...sc(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(op(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 ue("GET_PANEL_LIB_LIST",i)}async function QH(e){let{d3modelItemIn:t,d3modelItemOut:i,d3modelTagIds:r,d3modelTagTitles:n}=await NO(e.d3model,e.path,e.isProject),s=t||i;if(!s)throw new ue("PARAMETER_VERIFICATION","missing d3Model data.");s.title!==void 0&&SO(s.title),"path"in e.d3model&&e.d3model.override&&Xs(s,e.d3model.override);let a=await Ot("POST",dr(Pt.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 ue("UPDATE_D3MODEL",l)}if(s.dataStr){let l=await Ot("POST",dr(Pt.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 ue("UPDATE_D3MODEL",c)}}if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;return await Zf(e.path,l)}let o=a.message||a.msg||"Request Error.";throw Dl(a.code)?new ue("D3MODEL_SAME_NAMA_EXISTS",o):Xo(a.code)?new ue("UPDATE_D3MODEL_PERMISSIONS",o):new ue("UPDATE_SYMBOL",o)}async function ej(e){let t={uid:e.uid,path:e.path};if(e.tags){let{result:n}=await RO({uuid:e.uid,path:e.path,types:[3],names:e.tags});t.tag=n}let i=await Ot("POST",Pt.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 ue("GET_DEVICE_ATTRIBUTES_KEYS",r)}async function tj(e){let t={uid:e.uid,path:e.path,key:e.key};if(e.tags){let{result:n}=await RO({uuid:e.uid,path:e.path,types:[3],names:e.tags});t.tag=n}let i=await Ot("POST",Pt.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 ue("GET_DEVICE_ATTRIBUTES_VALUES",r)}var ij=class extends mv{async getDevice(e){return await hH(e)}async getDeviceAttributesKeys(e){return await ej(e)}async getDeviceAttributesValues(e){return tj(e)}async getSymbol(e){return await mH(e)}async getFootprint(e){return await dH(e)}async getPanelLib(e){return await JH(e)}async getD3Model(e){return await L0(e.uuid,e.path)}async getSimModel(e){return await pH(e)}async getDeviceList(e){return await SH(e)}async getSymbolList(e){return await wH(e)}async getFootprintList(e){return await TH(e)}async getPanelLibList(e){return await ZH(e)}async getD3ModelList(e){return await EH(e)}async getSimModelList(e){return fH(e)}async getDeviceSearchList(e){return await vH(e)}async getSymbolSearchList(e){return await DH(e)}async getFootprintSearchList(e){return await OH(e)}async getPanelLibSearchList(e){return await zH(e)}async getD3ModelSearchList(e){return await YH(e)}async getSimModelSearchList(e){return BH(e)}async createDevice(e){return await oH(e)}async createSymbol(e){return await uH(e)}async createFootprint(e){return await lH(e)}async createD3Model(e){return await sH(e)}async createPanelLib(e){return await KH(e)}async createSimModel(e){return await cH(e)}async updateDevice(e){return await gH(e)}async updateDeviceAttributes(e){return await UH(e)}async updateSymbol(e){return await xH(e)}async updateFootprint(e){return await yH(e)}async updatePanelLib(e){return await $H(e)}async updateD3Model(e){return await QH(e)}async updateSimModel(e){return await bH(e)}async deleteDevice(e){let t=await Ot("POST",dr(Pt.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 ue("DELETE_DEVICE",i)}}async deleteSymbol(e){let t=await Ot("POST",dr(Pt.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 ue("DELETE_SYMBOL",i)}}async deleteFootprint(e){let t=await Ot("POST",dr(Pt.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 ue("DELETE_FOOTPRINT",i)}}async deletePanelLib(e){let t=await Ot("POST",dr(Pt.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 ue("DELETE_PANEL_LIB",i)}}async deleteSimModel(e){let t=await Ot("POST",dr(Pt.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 ue("DELETE_SIM_MODEL",i)}}async delete3DModel(e){let t=await Ot("POST",dr(Pt.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 ue("DELETE_3DMODEL",i)}}async starDevice(e){let t=await Ot("POST",dr(Pt.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 ue("STAR_DEVICE",i)}}async starSymbol(e){let t=await Ot("POST",dr(Pt.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 ue("STAR_SYMBOL",i)}}async starFootprint(e){let t=await Ot("POST",dr(Pt.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 ue("STAR_FOOTPRINT",i)}}async starPanelLib(e){let t=await Ot("POST",dr(Pt.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 ue("STAR_PANEL_LIB",i)}}async unstarDevice(e){let t=await Ot("POST",dr(Pt.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 ue("UNSTAR_DEVICE",i)}}async unstarSymbol(e){let t=await Ot("POST",dr(Pt.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 ue("UNSTAR_SYMBOL",i)}}async unstarFootprint(e){let t=await Ot("POST",dr(Pt.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 ue("UNSTAR_FOOTPRINT",i)}}async unstarPanelLib(e){let t=await Ot("POST",dr(Pt.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 ue("UNSTAR_PANEL_LIB",i)}}},Xu=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})));bt.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})));bt.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})));bt.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){bt.messageBus.publish("logI18nLogView",{type:"warn",msg:["Devices are automatically renamed when they are added to the project library :",e.join("\u3001")]})}static renamedSymbol(e){bt.messageBus.publish("logI18nLogView",{type:"warn",msg:["Symbols are automatically renamed when they are added to the project library :",e.join("\u3001")]})}static renamedFootprint(e){bt.messageBus.publish("logI18nLogView",{type:"warn",msg:["Footprints are automatically renamed when they are added to the project library :",e.join("\u3001")]})}},rj=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 bt.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}},nj=class extends rj{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)}},Tv=class extends nj{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 SU({data:t}),uS(t),t.project_uuid=t.path=this.path,t}async onUpdate(e){let t=JSON.parse(JSON.stringify(e));return uS(t),t}async getTemplate(e,t={}){let{uuid:i,path:r,updateTime:n}=e,s=`${i}${Gh}${r}`,a=n==null?void 0:n.toString(),o=Object.assign(e,{path:r,source:s,version:a},t);return uS(o),o}},WO=class extends Tv{async getOrigin(){var e;let{path:t,uuid:i,isProject:r}=this.data;if(sp(this.data)){let{override:n}=this.data;if(n&&n.attributes)throw new ue("CREATE_DEVICE_GET_ORIGIN","Api call error!");if(r){let{message:s}=await bt.messageBus.rpcCall("/pro-mgr/hasProject",[t]);if(s){let a=[i,t],o=(await bt.messageBus.rpcCall(ii.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 ue("CREATE_DEVICE_GET_ORIGIN","Device details data does not exist")}else throw new ue("CREATE_DEVICE_GET_ORIGIN","Get project library data source Project is not open!")}else if(as.getInstance().hasLib(t)){let s=as.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 ue("CREATE_DEVICE_GET_ORIGIN","Device details data does not exist")}else{let s={path:t,uuid:i},{message:a}=await bt.messageBus.rpcCall(Vu.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 ue("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 bt.messageBus.rpcCall(ii.DEVICE.TRY_RENAME,i)).message;return r&&(e.display_title=e.title=r),t!==r&&Xu.renamedDevice([t]),{success:!0}}},sj=class extends WO{onHandle(e){return this.onAdd(e)}async matching(e){if(this.byUUID){let t=[e.uuid,this.path],i=await(await bt.messageBus.rpcCall(ii.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 bt.messageBus.rpcCall(ii.DEVICE.GET_BY_SOURCE_VERSION,t)).message;if(i)return Xu.sameVersionDevice([e.display_title||e.title]),i}if(this.bySource){let t=[e.source,this.path],i=(await bt.messageBus.rpcCall(ii.DEVICE.GET_LAST,t)).message;if(i)return Xu.diffVersionDevice({[i.display_title||i.title]:[i.uuid]}),i}}}async isRename(e){let t=[e.display_title||e.title,this.path];if((await bt.messageBus.rpcCall(ii.DEVICE.IS_RENAME,t)).message)throw new ue("DEVICE_SAME_NAMA_EXISTS","Device duplicate name");return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new ue("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 ue("CREATE_DEVICE",n.message||"Creation of the device failed!");i=this.origin}}return{success:!0,result:{respond:t,addData:i}}}},qO=class extends Tv{async getOrigin(){var e;let{path:t,uuid:i,isProject:r}=this.data;if(sp(this.data)){let{override:n}=this.data;if(r){let{message:s}=await bt.messageBus.rpcCall("/pro-mgr/hasProject",[t]);if(s){let a=[i,t],o=(await bt.messageBus.rpcCall(ii.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 ue("CREATE_FOOTPRINT_GET_ORIGIN","Footprint details data does not exist")}else throw new ue("CREATE_FOOTPRINT_GET_ORIGIN","Get project library data source Project is not open!")}else if(as.getInstance().hasLib(t)){let s=as.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 ue("CREATE_FOOTPRINT_GET_ORIGIN","Footprint details data does not exist")}else{let s={path:t,uuid:i},{message:a}=await bt.messageBus.rpcCall(Vu.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 ue("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 bt.messageBus.rpcCall(ii.FOOTPRINT.TRY_RENAME,i)).message;return r&&(e.display_title=e.title=r),t!==r&&Xu.renamedFootprint([t]),{success:!0}}},wv=class extends qO{onHandle(e){return this.onAdd(e)}async matching(e){if(this.byUUID){let t=[e.uuid,this.path],i=(await bt.messageBus.rpcCall(ii.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 bt.messageBus.rpcCall(ii.FOOTPRINT.GET_BY_SOURCE_VERSION,t)).message;if(i)return Xu.sameVersionFootprint([e.display_title||e.title]),i}if(this.bySource){let t=[e.source,this.path],i=(await bt.messageBus.rpcCall(ii.FOOTPRINT.GET_LAST,t)).message;if(i)return Xu.diffVersionFootprint({[i.display_title||i.title]:[i.uuid]}),i}}}async isRename(e){let t=[e.display_title||e.title,this.path];if((await bt.messageBus.rpcCall(ii.FOOTPRINT.IS_RENAME,t)).message)throw new ue("CREATE_FOOTPRINT","Library duplicate name");return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new ue("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 ue("CREATE_FOOTPRINT",n.message||"Creation of the footprint failed!");i=this.origin}}return{success:!0,result:{respond:t,addData:i}}}},JO=class extends Tv{async getOrigin(){var e;let{path:t,uuid:i,isProject:r}=this.data;if(sp(this.data)){let{override:n}=this.data;if(r){let{message:s}=await bt.messageBus.rpcCall("/pro-mgr/hasProject",[t]);if(s){let a=[i,t],o=(await bt.messageBus.rpcCall(ii.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 ue("CREATE_SYMBOL_GET_ORIGIN","Symbol details data does not exist")}else throw new ue("CREATE_SYMBOL_GET_ORIGIN","Get project library data source Project is not open!")}else if(as.getInstance().hasLib(t)){let s=as.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 ue("CREATE_SYMBOL_GET_ORIGIN","Symbol details data does not exist")}else{let s={path:t,uuid:i},{message:a}=await bt.messageBus.rpcCall(Vu.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 ue("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 bt.messageBus.rpcCall(ii.SYMBOL.TRY_RENAME,i)).message;return r&&(e.display_title=e.title=r),t!==r&&Xu.renamedSymbol([t]),{success:!0}}},Sv=class extends JO{onHandle(e){return this.onAdd(e)}async matching(e){if(this.byUUID){let t=[e.uuid,this.path],i=(await bt.messageBus.rpcCall(ii.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 bt.messageBus.rpcCall(ii.SYMBOL.GET_BY_SOURCE_VERSION,t)).message;if(i)return Xu.sameVersionSymbol([e.display_title||e.title]),i}if(this.bySource){let t=[e.source,this.path],i=(await bt.messageBus.rpcCall(ii.SYMBOL.GET_LAST,t)).message;if(i)return Xu.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 bt.messageBus.rpcCall(ii.SYMBOL.IS_RENAME,t)).message)throw new ue("CREATE_SYMBOL","Library duplicate name");return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new ue("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 ue("CREATE_SYMBOL",n.message||"Creation of the symbol failed!");i=this.origin}}return{success:!0,result:{respond:t,addData:i}}}},Qf=class{constructor(e){this.path=e}async check(){let{message:{hasPermission:e,errMsg:t}}=await bt.messageBus.rpcCall("canAddLib",[this.path]);if(!e)throw new ue("CREATE_DEVICE_PERMISSIONS",t||"You don't have permission!");return{success:!0}}},aj=class extends Qf{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 sj(m).start();if(g.success===!1)throw new ue("CREATE_DEVICE",g.message||"Creation of the device failed!");let{respond:x,addData:y}=g.result;if(this.result.device=x,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:T,Footprint:w}=E,b=T&&(await bt.messageBus.rpcCall(ii.SYMBOL.GET,[T,this.path])).message,C=w&&(await bt.messageBus.rpcCall(ii.FOOTPRINT.GET,[w,this.path])).message;this.result.symbol={success:!0,result:b},this.result.footprint={success:!0,result:C}}}if(this.data.symbol){let m={...d,data:this.data.symbol},g=await new Sv(m).start();if(g.success===!1&&g.code===404){if(this.addData.device){this.addData.device.attributes.Symbol="";let{display_title:x,title:y}=this.addData.device,E=x||y;bt.messageBus.publish("logI18nLogView",{type:"warn",msg:["The following devices lose bound symbol data!",E]})}}else{if(g.success===!1)throw new ue("CREATE_DEVICE",g.message||"Creation of the device failed!");{let{respond:x,addData:y}=g.result;if(this.result.symbol=x,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 ue("CREATE_DEVICE",E)}}}}if(this.data.footprint){let m={...d,data:this.data.footprint},g=await new wv(m).start();if(g.success===!1&&g.code===404){if(this.addData.device){this.addData.device.attributes.Footprint="";let{display_title:x,title:y}=this.addData.device,E=x||y;bt.messageBus.publish("logI18nLogView",{type:"warn",msg:["The following devices lose bound footprint data!",E]})}}else{if(g.success===!1)throw new ue("CREATE_DEVICE",g.message||"Creation of the device failed!");{let{respond:x,addData:y}=g.result;if(this.result.footprint=x,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 ue("CREATE_DEVICE",E)}}}}let p=await this.create();if(!p.success)throw new ue("CREATE_DEVICE",p.message||"Creation of the device failed!");let f=await this.updateBind();if(!f.success)throw new ue("CREATE_DEVICE",f.message||"Creation of the device failed!");if(!this.result)throw new ue("CREATE_DEVICE","Project library device added failed!");return await this.onsuccess(this.result),{success:!0,result:this.result}}catch(d){throw new ue("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(Gh);!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&&!uL((t=this.addData.symbol)==null?void 0:t.docType))throw new ue("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 ue("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(Gh)||(this.addData.device.attributes["3D Model"]=`${n}${Gh}${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 bt.messageBus.rpcCall(ii.DEVICE.CREATE,e);if(!t.success)throw new ue("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 bt.messageBus.rpcCall(ii.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=Zd(e.symbol)||e.symbol.message),e.footprint&&!e.footprint.success&&(e.footprint.message=Zd(e.footprint)||e.footprint.message),e.device&&!e.device.success&&(e.device.message=Zd(e.device)||e.device.message)}},oj=class extends WO{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 ue("UPDATE_DEVICE",e.message||"Update of the device failed!");if(!this.origin)throw new ue("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 bt.messageBus.rpcCall(ii.DEVICE.IS_CHANGE,i)).message){let r=await this.rename(this.origin,{path:this.path});if(!r.success)throw new ue("UPDATE_DEVICE",r.message||"Update of the device failed!")}return{success:!0,result:this.origin}}},lj=class extends Qf{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 oj(this.uuid,p).start();if(f.success){let m=f.result;m&&(this.updateData=m),this.getBind()}else throw new ue("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 Sv(p).start();if(!f.success)throw new ue("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 x="The symbol associated with the device does not exist!";throw new ue("UPDATE_DEVICE",x)}}if(this.data.footprint){let p={...u,data:this.data.footprint,renameKey:this.renameKey},f=await new wv(p).start();if(!f.success)throw new ue("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 x="The footprint associated with the device does not exist!";throw new ue("UPDATE_DEVICE",x)}}let h=await this.create();if(!h.success)throw new ue("UPDATE_DEVICE",h.message||"Update of the device failed!");let d=await this.update();if(!d.success)throw new ue("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 ue("UPDATE_DEVICE",p)}return await this.onsuccess(this.result),{success:!0,result:Object.assign(this.result,{map:this.map})}}catch(u){throw new ue("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(Gh);!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&&!uL((t=this.addData.symbol)==null?void 0:t.docType))throw new ue("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 ue("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 bt.messageBus.rpcCall(ii.SYMBOL.CREATE,[e,this.path])).message;if(!i.success)throw new ue("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 bt.messageBus.rpcCall(ii.FOOTPRINT.CREATE,[t,this.path])).message;if(!i.success)throw new ue("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 bt.messageBus.rpcCall(ii.DEVICE.UPDATE,n)).message;if(!s){let a=r.display_title||r.title||"";throw new ue("UPDATE_DEVICE",`Update of the device failed! title: ${a}`)}this.result.device={success:!0,result:s}}return{success:!0}}async onbefore(){sp(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=Zd(e.symbol)||e.symbol.message),e.footprint&&!e.footprint.success&&(e.footprint.message=Zd(e.footprint)||e.footprint.message),e.device&&!e.device.success&&(e.device.message=Zd(e.device)||e.device.message)}},cj=class extends Qf{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 Sv({...e,data:this.data}).start();if(!t.success)throw new ue("CREATE_SYMBOL",t.message||"Project library symbol added failed!");let{addData:i,respond:r}=t.result;if(r&&!r.success)throw new ue("CREATE_SYMBOL",r.message||"Project library symbol added failed!");if(r&&r.success)this.result=r.result;else if(i){let n=(await bt.messageBus.rpcCall(ii.SYMBOL.CREATE,[i,this.path])).message;if(!n.success)throw new ue("CREATE_SYMBOL","Project library symbol added failed!");this.result=n.result}if(!this.result)throw new ue("CREATE_SYMBOL","Project library symbol added failed!");return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){}async onsuccess(e){}},uj=class extends Qf{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 wv({...e,data:this.data}).start();if(!t.success)throw new ue("CREATE_FOOTPRINT",t.message||"Creation of the footprint failed!");let{addData:i,respond:r}=t.result;if(r&&!r.success)throw new ue("CREATE_FOOTPRINT",r.message||"Creation of the footprint failed!");if(r&&r.success)this.result=r.result;else if(i){let n=(await bt.messageBus.rpcCall(ii.FOOTPRINT.CREATE,[i,this.path])).message;if(!n.success)throw new ue("CREATE_FOOTPRINT","Project library footprint added failed!");this.result=n.result}if(!this.result)throw new ue("CREATE_FOOTPRINT","Project library footprint added failed!");return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){}async onsuccess(e){}},hj=class extends JO{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 ue("UPDATE_SYMBOL",e.message||"Update of the symbol failed!");if(!this.origin)throw new ue("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 bt.messageBus.rpcCall(ii.SYMBOL.IS_CHANGE,i)).message){let r=await this.rename(this.origin,{path:this.path});if(!r.success)throw new ue("UPDATE_SYMBOL",r.message||"Update of the symbol failed!")}return{success:!0,result:this.origin}}},dj=class extends Qf{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 hj(this.uuid,i).start();if(!r.success)throw new ue("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 bt.messageBus.rpcCall(ii.SYMBOL.COVER,[n,this.path])).message;if(!s.success)throw new ue("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 ue("UPDATE_SYMBOL",{text:o,args:{title:a}})}return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){sp(this.data)?(this.onlyIdentity=!0,this.keepVersion=!0):(this.onlyIdentity=!1,this.keepVersion=!1)}async onsuccess(e){}},pj=class extends qO{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 ue("UPDATE_FOOTPRINT",e.message||"Update of the footprint failed!");if(!this.origin)throw new ue("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 bt.messageBus.rpcCall(ii.FOOTPRINT.IS_CHANGE,i)).message){let r=await this.rename(this.origin,{path:this.path});if(!r.success)throw new ue("UPDATE_FOOTPRINT",r.message||"Update of the footprint failed!")}return{success:!0,result:this.origin}}},fj=class extends Qf{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 pj(this.uuid,i).start();if(!r.success)throw new ue("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 bt.messageBus.rpcCall(ii.FOOTPRINT.COVER,[n,this.path])).message;if(!s.success)throw new ue("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 ue("UPDATE_FOOTPRINT",a)}return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){sp(this.data)?(this.onlyIdentity=!0,this.keepVersion=!0):(this.onlyIdentity=!1,this.keepVersion=!1)}async onsuccess(e){}},mj=class extends mv{async getDevice(e){let t=[e.uuid,e.path],{message:i}=await bt.messageBus.rpcCall(ii.DEVICE.GET,t);if(!i)throw new ue("GET_DEVICE","Device details data does not exist");return Sb(e.path,i)}async getDeviceAttributesKeys(e){let{message:t}=await bt.messageBus.rpcCall(ii.DEVICE.GET_ATTRIBUTES_KEYS,e);if(!t.success)throw new ue("GET_DEVICE_ATTRIBUTES_KEYS",t.message);return t.result}async getDeviceAttributesValues(e){let{message:t}=await bt.messageBus.rpcCall(ii.DEVICE.GET_ATTRIBUTES_VALUES,e);if(!t.success)throw new ue("GET_DEVICE_ATTRIBUTES_VALUES",t.message);return t.result}async getSymbol(e){let t=[e.uuid,e.path],{message:i}=await bt.messageBus.rpcCall(ii.SYMBOL.GET,t);if(!i)throw new ue("GET_SYMBOL","Symbol details data does not exist");return fS(e.path,i)}async getFootprint(e){let t=[e.uuid,e.path],{message:i}=await bt.messageBus.rpcCall(ii.FOOTPRINT.GET,t);if(!i)throw new ue("GET_FOOTPRINT","Footprint details data does not exist");return mS(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 aj(s).start();if(!a.success)throw new ue("CREATE_DEVICE",a.message);let o=a.result.device;if(!(o!=null&&o.success))throw new ue("CREATE_DEVICE",o==null?void 0:o.message);let l=o.result;return Sb(e.path,l)}async createSymbol(e){let{path:t,symbol:i}=e,r={path:t,data:i},n=await new cj(r).start();if(!n.success)throw new ue("CREATE_SYMBOL",n.message);let s=n.result;return fS(e.path,s)}async createFootprint(e){let{path:t,footprint:i}=e,r={path:t,data:i},n=await new uj(r).start();if(!n.success)throw new ue("CREATE_FOOTPRINT",n.message);let s=n.result;return mS(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 lj(a).start();if(!o.success)throw new ue("UPDATE_DEVICE",o.message);let l=o.result.device;if(!(l!=null&&l.success))throw new ue("CREATE_DEVICE",l==null?void 0:l.message);let c=l.result;return Sb(e.path,c)}async updateDeviceAttributes(e){let t=(await bt.messageBus.rpcCall(ii.DEVICE.UPDATE,[e,e.path])).message;if(!t)throw new ue("UPDATE_DEVICE_ATTRIBUTES",t.message);return Sb(e.path,t)}async updateSymbol(e){let{uuid:t,path:i,symbol:r}=e,n={path:i,uuid:t,data:r},s=await new dj(n).start();if(!s.success)throw new ue("UPDATE_SYMBOL",s.message);let a=s.result;return fS(e.path,a)}async updateFootprint(e){let{uuid:t,path:i,footprint:r}=e,n={path:i,uuid:t,data:r},s=await new fj(n).start();if(!s.success)throw new ue("UPDATE_FOOTPRINT",s.message);let a=s.result;return mS(e.path,a)}async deleteDevice(e){if(!(await bt.messageBus.rpcCall(ii.DEVICE.DEL,[e.uuid,e.path])).message)throw new ue("DELETE_DEVICE","delete failed!")}async deleteSymbol(e){if(!(await bt.messageBus.rpcCall(ii.SYMBOL.DEL,[e.uuid,e.path])).message)throw new ue("DELETE_SYMBOL","delete failed!")}async deleteFootprint(e){if(!(await bt.messageBus.rpcCall(ii.FOOTPRINT.DEL,[e.uuid,e.path])).message)throw new ue("DELETE_FOOTPRINT","delete failed!")}async getDeviceList(e){let t=(await bt.messageBus.rpcCall(ii.DEVICE.GET_LIST,e)).message;if(!t.success)throw new ue("GET_DEVICE_LIST",t.message);return t.result}async getDeviceSearchList(e){let t=(await bt.messageBus.rpcCall(ii.DEVICE.GET_LIST,e)).message;if(!t.success)throw new ue("GET_DEVICE_LIST",t.message);return t.result}async getSymbolList(e){let t=(await bt.messageBus.rpcCall(ii.SYMBOL.GET_LIST,e)).message;if(!t.success)throw new ue("GET_SYMBOL_LIST",t.message);return t.result}async getSymbolSearchList(e){let t=(await bt.messageBus.rpcCall(ii.SYMBOL.GET_LIST,e)).message;if(!t.success)throw new ue("GET_SYMBOL_LIST",t.message);return t.result}async getFootprintList(e){let t=(await bt.messageBus.rpcCall(ii.FOOTPRINT.GET_LIST,e)).message;if(!t.success)throw new ue("GET_FOOTPRINT_LIST",t.message);return t.result}async getFootprintSearchList(e){let t=(await bt.messageBus.rpcCall(ii.FOOTPRINT.GET_LIST,e)).message;if(!t.success)throw new ue("GET_FOOTPRINT_LIST",t.message);return t.result}},gj=class extends mv{constructor(){super(...arguments),this._normalErrorMsg="Request Error.",this._extendLibManager=as.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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("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 ue("CREATE_DEVICE","Not Supported.")}createSymbol(e){throw new ue("GET_SYMBOL","Not Supported.")}createFootprint(e){throw new ue("CREATE_FOOTPRINT","Not Supported.")}updateDevice(e){throw new ue("UPDATE_DEVICE","Not Supported.")}updateSymbol(e){throw new ue("GET_SYMBOL","Not Supported.")}updateFootprint(e){throw new ue("GET_SYMBOL","Not Supported.")}deleteDevice(e){throw new ue("GET_SYMBOL","Not Supported.")}deleteSymbol(e){throw new ue("GET_SYMBOL","Not Supported.")}deleteFootprint(e){throw new ue("GET_SYMBOL","Not Supported.")}},yj=(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))(yj||{}),bj=["title","description","tags","images"],fi=new ij,ss=new mj,Vc=new gj,Jr=class{static getDevice(e){return as.getInstance().hasLib(e.path)?Vc.getDevice(e):e.isProject?ss.getDevice(e):fi.getDevice(e)}static getDeviceAttributesKeys(e){return e.isProject?ss.getDeviceAttributesKeys(e):fi.getDeviceAttributesKeys(e)}static getDeviceAttributesValues(e){return e.isProject?ss.getDeviceAttributesValues(e):fi.getDeviceAttributesValues(e)}static getSymbol(e){return as.getInstance().hasLib(e.path)?Vc.getSymbol(e):e.isProject?ss.getSymbol(e):fi.getSymbol(e)}static getFootprint(e){return as.getInstance().hasLib(e.path)?Vc.getFootprint(e):e.isProject?ss.getFootprint(e):fi.getFootprint(e)}static getPanelLib(e){if(e.isProject)throw new ue("GET_PANEL_LIB","Api call error!");return fi.getPanelLib(e)}static getD3Model(e){return as.getInstance().hasLib(e.path)?Vc.getModel3D(e):e.isProject?null:fi.getD3Model(e)}static getSimModel(e){if(e.isProject)throw new ue("GET_SIM_MODEL","Api call error!");return fi.getSimModel(e)}static getDeviceList(e){return as.getInstance().hasLib(e.path)?Vc.getDeviceList(e):e.isProject?ss.getDeviceList(e):fi.getDeviceList(e)}static getSymbolList(e){return as.getInstance().hasLib(e.path)?Vc.getSymbolList(e):e.isProject?ss.getSymbolList(e):fi.getSymbolList(e)}static getFootprintList(e){return as.getInstance().hasLib(e.path)?Vc.getFootprintList(e):e.isProject?ss.getFootprintList(e):fi.getFootprintList(e)}static getPanelLibList(e){if(e.isProject)throw new ue("GET_D3MODEL_LIST","Api call error!");return fi.getPanelLibList(e)}static getD3ModelList(e){if(e.isProject)throw new ue("GET_D3MODEL_LIST","Api call error!");return fi.getD3ModelList(e)}static getSimModelList(e){if(e.isProject)throw new ue("GET_SIM_MODEL_LIST","Api call error!");return fi.getSimModelList(e)}static getDeviceSearchList(e){return as.getInstance().hasLib(e.path)?Vc.getDeviceSearchList(e):e.isProject?ss.getDeviceSearchList(e):fi.getDeviceSearchList(e)}static getSymbolSearchList(e){return as.getInstance().hasLib(e.path)?Vc.getSymbolSearchList(e):e.isProject?ss.getSymbolSearchList(e):fi.getSymbolSearchList(e)}static getFootprintSearchList(e){return as.getInstance().hasLib(e.path)?Vc.getFootprintSearchList(e):e.isProject?ss.getFootprintSearchList(e):fi.getFootprintSearchList(e)}static getPanelLibSearchList(e){if(e.isProject)throw new ue("GET_PANEL_LIB_SEARCH_LIST","Api call error!");return fi.getPanelLibSearchList(e)}static getD3ModelSearchList(e){if(e.isProject)throw new ue("GET_D3MODEL_SEARCH_LIST","Api call error!");return fi.getD3ModelSearchList(e)}static getSimModelSearchList(e){if(e.isProject)throw new ue("GET_SIM_MODEL_SEARCH_LIST","Api call error!");return fi.getSimModelSearchList(e)}static createDevice(e){return e.isProject?ss.createDevice(e):fi.createDevice(e)}static createSymbol(e){return e.isProject?ss.createSymbol(e):fi.createSymbol(e)}static createFootprint(e){return e.isProject?ss.createFootprint(e):fi.createFootprint(e)}static createD3Model(e){return e.isProject?null:fi.createD3Model(e)}static createPanelLib(e){if(e.isProject)throw new ue("CREATE_PANEL_LIB","Api call error!");return fi.createPanelLib(e)}static createSimModel(e){if(e.isProject)throw new ue("CREATE_SIM_MODEL","Api call error!");return fi.createSimModel(e)}static updateDevice(e){return e.isProject?ss.updateDevice(e):fi.updateDevice(e)}static updateDeviceAttributes(e){return e.isProject?ss.updateDeviceAttributes(e):fi.updateDeviceAttributes(e)}static updateSymbol(e){return e.isProject?ss.updateSymbol(e):fi.updateSymbol(e)}static updateFootprint(e){return e.isProject?ss.updateFootprint(e):fi.updateFootprint(e)}static updatePanelLib(e){if(e.isProject)throw new ue("UPDATE_PANEL_LIB","Api call error!");return fi.updatePanelLib(e)}static updateD3Model(e){if(e.isProject)throw new ue("UPDATE_D3MODEL","Api call error!");return fi.updateD3Model(e)}static updateSimModel(e){if(e.isProject)throw new ue("UPDATE_SIM_MODEL","Api call error!");return fi.updateSimModel(e)}static deleteDevice(e){return e.isProject?ss.deleteDevice(e):fi.deleteDevice(e)}static deleteSymbol(e){return e.isProject?ss.deleteSymbol(e):fi.deleteSymbol(e)}static deleteFootprint(e){return e.isProject?ss.deleteFootprint(e):fi.deleteFootprint(e)}static deletePanelLib(e){if(e.isProject)throw new ue("DELETE_PANEL_LIB","Api call error!");return fi.deletePanelLib(e)}static deleteSimModel(e){if(e.isProject)throw new ue("DELETE_SIM_MODEL","Api call error!");return fi.deleteSimModel(e)}static deleteD3Model(e){if(e.isProject)throw new ue("DELETE_3DMODEL","Api call error!");return fi.delete3DModel(e)}static starDevice(e){if(e.isProject)throw new ue("STAR_DEVICE","Api call error!");return fi.starDevice(e)}static starSymbol(e){if(e.isProject)throw new ue("STAR_SYMBOL","Api call error!");return fi.starSymbol(e)}static starFootprint(e){if(e.isProject)throw new ue("STAR_FOOTPRINT","Api call error!");return fi.starFootprint(e)}static starPanelLib(e){if(e.isProject)throw new ue("STAR_PANEL_LIB","Api call error!");return fi.starPanelLib(e)}static unstarDevice(e){if(e.isProject)throw new ue("UNSTAR_DEVICE","Api call error!");return fi.unstarDevice(e)}static unstarSymbol(e){if(e.isProject)throw new ue("UNSTAR_SYMBOL","Api call error!");return fi.unstarSymbol(e)}static unstarFootprint(e){if(e.isProject)throw new ue("UNSTAR_FOOTPRINT","Api call error!");return fi.unstarFootprint(e)}static unstarPanelLib(e){if(e.isProject)throw new ue("UNSTAR_PANEL_LIB","Api call error!");return fi.unstarPanelLib(e)}};async function KO(e,t,i,r={}){r.eachProcessHook&&r.eachProcessHook(.01);let n=i||Ze.SYSTEMLIB_UUID,s=null;if(t)try{s=await Jr.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 Jr.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 Jr.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=P0(h,!0),f=p.path||Ze.SYSTEMLIB_UUID||n;if(p.componentTitleOrId&&(p.isLocaleFilenameMode?c=(await pv(p.componentTitleOrId,f)).result:c=await L0(p.componentTitleOrId,f)),!c&&h&&d){if(r.isCheckD3ModelFileExist){let m=await bO(h);m.success&&m.result instanceof Blob?o.d3DModel=!1:o.d3DModel=!0}else o.d3DModel=!0;c=fv(h,d,p.path)}}return r.eachProcessHook&&r.eachProcessHook(1),{setPath:n,deviceItem:s,symbolItem:a,footprintItem:l,d3modelItem:c,hasIdButNotFound:o}}async function xj(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 KO(e,t,i,{eachProcessHook:d,isCheckD3ModelFileExist:l}):p=await Jr.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 Jr.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 Jr.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 L0(t,i),message:""}}catch(h){return{code:-1,success:!1,result:null,message:h.message.toString()}}}let c=await Ot("GET",o?dr(Pt.DEVICE.GET,{uuid:t}):dr(Pt.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 jS(e,t){let i=e.owner||{},r=typeof e.updated_at=="string"?e.updated_at:typeof e.updated_at=="number"?Hh(new Date(e.updated_at)):"",n=typeof e.updateTime=="string"?e.updateTime:typeof e.updateTime=="number"?Hh(new Date(da(e.updateTime))):"";return{...e,$id:String(t),numberIndex:t+1,ownerBelong:i.username,updateTimeString:r||n}}function Ej(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 Tj(e,t,i,r){let n=await new Promise(a=>{fetch(ov.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=Hh(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:da(a.mtime),updated_at:l,createTime:da(a.mtime),created_at:l,creator:null,dataStr:"",public:void 0,type:16};return{...jS(c,o)}}),s.result.count=n.result.length):(s.code=Ze.ERR_CODE.NORMAL,s.success=!1,s.msg=n.message||"Fetch local 3D model list error."),s}async function wj(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(ov.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)=>jS(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=Ej(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=Hh(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:da(d.mtime),updated_at:f,createTime:da(d.mtime),created_at:f,creator:null,dataStr:"",public:void 0,source:void 0,std_uuid:void 0,ticket:0,type:16};return{...jS(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 $O(e){let t=null;return t=vv(e.title),!t.success||(t=ZO(e.description),!t.success)?t:{code:0,success:!0,message:"",key:"",result:null}}function Sj(e){let t=null;return t=vv(e.name),!t.success||(t=vj(e.type),!t.success)||(t=Ij(e.model),!t.success)?t:{code:0,success:!0,message:"",key:"",result:null}}function vv(e){let t={code:0,success:!0,message:"",key:"",result:null};return(!e||e.length<=0||e.length>128)&&(t.code=Ze.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}function ZO(e){let t={code:0,success:!0,message:"",key:"",result:null};return e&&e.length>255&&(t.code=Ze.ERR_CODE.NORMAL,t.success=!1,t.message="Description should be no more than 255 letters"),t}function vj(e){let t={code:0,success:!0,message:"",key:"",result:null};return e||(t.code=Ze.ERR_CODE.NORMAL,t.success=!1,t.message="The 3D model type is incorrect!"),t}function Ij(e){let t={code:0,success:!0,message:"",key:"",result:null};return e||(t.code=Ze.ERR_CODE.NORMAL,t.success=!1,t.message="The 3D model is incorrect!"),t}async function Aj(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=$O({title:r.title,description:r.description});if(!n.success)return{code:n.code,success:!1,result:null,message:n.message};let s=await Ot("POST",dr(Pt.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 Cj(e){let t=Sj(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 Ot("POST",Pt.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 ec=class{};ec.createDefaultD3modelItem=fv,ec.fetchD3ModelItemHandle=L0,ec.updateD3ModelItem=Aj,ec.uploadD3ModelItem=Cj,ec.d3modelInfoVerify=$O,ec.d3modelInfoTitleVerify=vv,ec.d3modelInfoDescriptionVerify=ZO,ec.fetchD3ModelListOnLocaleFolder=Tj,ec.fetchD3ModelListBySearchOnLocaleFolder=wj,ec.fetchD3ModelItemOnLocaleFolder=pv;function Dj(e,t=void 0){let i=null;if(i=QO(e.title),!i.success||(i=eR(e.description),!i.success)||(i=tR(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=Ze.ERR_CODE.NORMAL,r.success=!1,r.message="The title length must be between 1~128 characters!"),r}function QO(e){let t={code:0,success:!0,message:"",key:"",result:null};return(!e||e.length<=0||e.length>128)&&(t.code=Ze.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}function eR(e){let t={code:0,success:!0,message:"",key:"",result:null};return e&&e.length>255&&(t.code=Ze.ERR_CODE.NORMAL,t.success=!1,t.message="Description should be no more than 255 letters"),t}function tR(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=Ze.ERR_CODE.NORMAL,t.message="{0} should be no more than 255 letters",t.key=n,t}return t}var _f=class{};_f.deviceInfoVerify=Dj,_f.deviceInfoTitleVerify=QO,_f.deviceInfoDescriptionVerify=eR,_f.deviceInfoAttributesVerify=tR,_f.fetchDeviceItem=KO;function Pj(){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 _j(e="",t="",i=""){let r=t||"[Empty Footprint Component Item]",n=new Date().getTime(),s=Hh(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:Ze.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 Lj(e){let t=null;return t=Oj(e.title),t.success?{code:0,success:!0,message:"",key:void 0,result:null}:t}function Oj(e){let t={code:0,success:!0,message:"",key:void 0,result:null};return(!e||e.length<=0||e.length>128)&&(t.code=Ze.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}var Bb=class{};Bb.footprintInfoVerify=Lj,Bb.createEmptyFootprintItem=_j,Bb.createEmptyFootprintDataStr=Pj;function Rj(e){let t=null;return t=Nj(e.title),!t.success||(t=Mj(e.docType),!t.success)?t:{code:0,success:!0,message:"",key:void 0,result:null}}function Nj(e){let t={code:0,success:!0,message:"",key:void 0,result:null};return(!e||e.length<=0||e.length>128)&&(t.code=Ze.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}function Mj(e){let t={code:0,success:!0,message:"",key:void 0,result:null};return(typeof e>"u"||!e)&&(t.code=Ze.ERR_CODE.NORMAL,t.success=!1,t.message="Document data abnormality"),t}var iR=class{};iR.symbolInfoVerify=Rj;async function Bj(e=!1,t,i,r,n=[]){let s={isDuplicate:!1,path:r,uuids:[]},a=i.toLocaleLowerCase(),o=await Qb(e,a,r,t,bt.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 kj=(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))(kj||{});async function rR(){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 hx(e,t){let i=[],r=[];E0?r=e:t&&t.length?r=t:r=e;let n=null;return r.forEach(s=>{s.uuid===Ze.SYSTEMLIB_UUID?n={title:s.nickname,id:s.uuid,key:Ze.LIB_SYSTEM_KEY}:i.push({title:s.nickname,id:s.uuid,key:Ze.LIB_PERSONAL_KEY})}),n&&i.unshift(n),i}async function dx(e,t){let i=hx(e,t)||[],r=[],n=null;return i.forEach((s,a)=>{s.id===Ze.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:Ze.LIB_PROJECT_KEY}),[...r]}async function Fj(e,t){let i=await rR();if(!i)return await dx(e,t);let r=hx(e,t),n=Ma(r,"id",Ze.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:n_(h),id:h,key:h})}),s.splice(1,0,{title:"Project",id:"",key:Ze.LIB_PROJECT_KEY}),[...s]}function Gj(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="@"+g0(new Date().getTime())),typeof a[l.id]<"u"?(a[l.id]+=1,l.id=l.id+Ze.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 nR(e,t){let i=hx(e,t)||[],r=[],n=null;return i.forEach((s,a)=>{s.id===Ze.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:Ze.LIB_PROJECT_KEY}),[...r]}async function Uj(e,t){let i=await rR();if(!i)return await dx(e,t);let r=[],{projectPath:n,cbbPath:s,libPath:a=[],onlinePrjBackupPath:o,autoCheckVersionUpdate:l}=i;return a.forEach(c=>{r.push({title:n_(c),id:c,key:c})}),r.splice(1,0,{title:"Project",id:"",key:Ze.LIB_PROJECT_KEY}),[...r]}function Yj(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="@"+g0(new Date().getTime())),typeof a[l.id]<"u"?(a[l.id]+=1,l.id=l.id+Ze.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 sR(e,t){let i=[],r=[];return E0?r=e:t&&t.length?r=t:r=e,r.forEach(n=>{i.push({title:n.nickname,id:n.uuid,key:Ze.LIB_TEMAS_KEY})}),i}async function ex(e,t){let i=sR(e,t);return[{title:"System",id:Ze.SYSTEMLIB_UUID,key:Ze.LIB_SYSTEM_KEY},{title:"Project",id:"",key:Ze.LIB_PROJECT_KEY},{title:"Personal",id:"",key:Ze.LIB_PERSONAL_KEY},{title:"Favorite",id:Ze.FAVORITELIB_UUID,key:Ze.LIB_FAVORITE_KEY},...i]}function aR(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=Ze.PUBLICLIB_ALIAS;break}default:}c.id||(c.id="@"+g0(new Date().getTime())),typeof o[c.id]<"u"?(o[c.id]+=1,c.id=c.id+Ze.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 VS(e,t){return await ex(e,t)}function Hj(e,t,i,r,n){return aR(e,t,i,r,n)}function oR(e,t,i,r,n,s,a){if(!ic){let l=aR(e,i,r,n,typeof s<"u"?!!s:a);return vb(l,t),Ib(l)}if(kb){let l=Hj(e,i,r,n,typeof s<"u"?!!s:a);return vb(l,t),Ib(l)}if(l0){let l=Gj(e,i,n,typeof s<"u"?!!s:a);return vb(l,t),Ib(l)}let o=Yj(e,i,n,typeof s<"u"?!!s:a);return vb(o,t),Ib(o)}function vb(e,t){let i=Ma(e.treeData,"key",Ze.LIB_SYSTEM_KEY);i.index>=0&&e.treeData.splice(i.index,1);let r=Ma(e.treeData,"key",Ze.LIB_PERSONAL_KEY);r.index>=0&&e.treeData.splice(r.index,1);let n=Ma(e.treeData,"key","project");n.index>=0&&e.treeData.splice(n.index,1);let s=Ma(e.treeData,"key",Ze.LIB_FAVORITE_KEY);s.index>=0&&e.treeData.splice(s.index,1);let a=Ma(e.treeData,"key","selected");a.index>=0&&e.treeData.splice(a.index,1);let o=Ma(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"?E0||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 Ib(e){return e.selectedIds.length?e.selectedIds:e.selectedIds.push(e.treeData[0].id),e}async function jj(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 lR(t,a,o,e,i,l),x=oR(g,r,[],h,m,!l),y=[];for(let E=0;E<x.treeData.length;E++){let T=x.treeData[E];T.id===Ze.SYSTEMLIB_UUID&&c||T.id===Ze.FAVORITELIB_UUID&&u||(rx||nx||T.key===Ze.LIB_PERSONAL_KEY&&(T.title=T.titleAdditional=h.username),T.title&&y.push(T))}return y}var Vj=(e=>(e.Normal="Normal",e.D3Model="D3Model",e.AssociateDeviceDialog="associateDeviceDialog",e.Cbb="Cbb",e))(Vj||{}),Bu=class{};Bu.createInitLibList=lR,Bu.createFixLibList=jj,Bu.filterInitLibList=oR,Bu.fetchTeamsLibsFromGVars=sR,Bu.fetchClientTeamsLibsFromGVars=hx,Bu.createSourceLibListByWebMode=ex,Bu.createSourceLibListByOnlineClientMode=VS,Bu.createSourceLibListByOfflineClientMode=nR,Bu.createSourceLibListByHalfofflineClientMode=dx;async function lR(e,t,i,r,n,s){let a=[];return e==="Normal"?ic?kb?(a=await VS(t,i),s&&Ab(a),a):l0?(a=await dx(t,i),s&&Ab(a),a):(a=await nR(t,i),s&&Ab(a),a):(a=await ex(t,i),s&&Ab(a),a):e==="D3Model"?ic?kb?(a=await VS(t,i),a):l0?(a=await Fj(t,i),a):(a=await Uj(t,i),a):(a=await ex(t,i),a):[]}function Ab(e){let t=Ma(e,"key",Ze.LIB_PROJECT_KEY);t.index>=0&&e.splice(t.index,1)}var Hte=y0(b0());var jte=y0(b0());var Vte=y0(b0());var Ho=class{};Ho.D3Model=ec,Ho.Device=_f,Ho.Footprint=Bb,Ho.Symbol=iR,Ho.deleteComponentItem=eO,Ho.deleteComponents=cY,Ho.fetchComponentItem=xj,Ho.queryComponentsByTitle=Qb,Ho.pickUpComponentTags2Ids=tO,Ho.pickUpComponentTags2Names=zh,Ho.getDataStrById=_0,Ho.duplicateNameDetection=Bj;var t_=class qd{static async getOldLibByNet(t){try{let{dataStrId:i,dataStr:r}=t;return i||r?{success:!0,result:await _0(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=BG(r,t,a)}else n===29?s=HG(r,t,n0.PANEL_LIB):Jb(n)&&(s=GG(r,t).dataStr);return s}static async getOtherLibByNet(t){try{let{isProject:i,uuid:r,path:n,docType:s}=t;if(IU(t)){let c={ignoreDoctypeCheck:!0},u=(await Ho.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 bt.messageBus.rpcCall(Vu.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 bt.messageBus.rpcCall(Vu.COMPONENT.GET_HISTORY_DATA,[u.result])).message}}else if(o||l){let c=await qd.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=qd.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 LL(`/${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 bt.messageBus.rpcCall("/pro-mgr/hasProject",[i]);return s?n===4?{success:!0,result:(await bt.messageBus.rpcCall(ii.FOOTPRINT.GET_STR,[r,i])).message||""}:Jb(n)?{success:!0,result:(await bt.messageBus.rpcCall(ii.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=as.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=qd.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 as.getInstance().hasLib(r)?qd.getExtendLib(t):i?qd.getProjectLibByWorker(t):qd.getOtherLibByWorker(t)}catch(i){return{success:!1,message:i.message}}}},cR=(e=>(e.INIT_DB="/CommonDB/initDB",e))(cR||{}),uR=(e=>(e.GET="/CommonDB/project/getData",e.GET_ALL="/CommonDB/project/getAllArrData",e))(uR||{}),hR=(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))(hR||{}),dR=(e=>(e.GET="/CommonDB/copyAndPasteTableCell/getData",e.SET="/CommonDB/copyAndPasteTableCell/setData",e.IS_EXIST="/CommonDB/copyAndPasteTableCell/isExist",e))(dR||{}),pR=(e=>(e.SET="/CommonDB/log/setData",e.DEL="/CommonDB/log/delData",e.DEL_LOTS="/CommonDB/log/delLotsData",e.GET_ALL="/CommonDB/log/getAllArrData",e))(pR||{}),fR=(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))(fR||{}),mR=(e=>(e.SET="/CommonDB/basicLibraryList/addData",e.GET="/CommonDB/basicLibraryList/getData",e.IS_EXIST="/CommonDB/basicLibraryList/isExist",e))(mR||{}),gR=(e=>(e.SET="/CommonDB/clipBoard/addData",e.GET="/CommonDB/clipBoard/getData",e.IS_EXIST="/CommonDB/clipBoard/isExist",e))(gR||{}),yR=(e=>(e.GET="/CommonDB/lockPrj/getData",e.READ_WRITE="/CommonDB/lockPrj/readwriteData",e))(yR||{}),bR=(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))(bR||{}),M0={COMMON:cR,PROJECT:uR,COPYANDPASTE:hR,COPYANDPASTE_TABLE_CELL:dR,LOG:pR,COMPONENT_LOG:fR,LIB:mR,CLIP_BOARD:gR,LOCK_PROJECT:yR,PROJECT_CACHE:bR},zj=(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))(zj||{}),Xj=(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))(Xj||{}),Wj=(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))(Wj||{}),qj=(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))(qj||{});var Jj=(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))(Jj||{}),Kj=(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))(Kj||{}),$j=(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))($j||{}),Zj=(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))(Zj||{}),Qj=(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))(Qj||{}),eV=(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))(eV||{}),tV=(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))(tV||{}),iV=(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))(iV||{});var rV=(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))(rV||{}),nV=(e=>(e.ON_UPDATE="/pro-mgr/project/project/onUpdate",e.UPLOAD_FAILED="/pro-mgr/project/upload/onfailed",e))(nV||{}),sV=(e=>(e.ON_UPDATE="/pro-mgr/project/config/onUpdate",e))(sV||{}),aV=(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))(aV||{}),oV=(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))(oV||{}),lV=(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))(lV||{}),cV=(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))(cV||{}),uV=(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))(uV||{}),hV=(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))(hV||{}),dV=(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))(dV||{}),pV=(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))(pV||{}),fV=(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))(fV||{}),mV=(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))(mV||{}),gV=(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))(gV||{}),yV=(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))(yV||{});var zte=new Error("list is empty");var bV=(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))(bV||{});var xV=class{};xV.syncLoginedUserInfo=e=>{bt.loginedUserUuid=e.uuid};var EV=(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))(EV||{});P6();var cp=window._MSG_BUS_=window._MSG_BUS_||new px.MessageBus,fx=new px.WindowMessageBridge(cp);function Rr(e,t){return cp.rpcCall(e,t)}function em(e,t="",i=ut()){if(typeof e!="string"){console.warn("bubbleRPCCall topic not string");return}return fx.rpcCall(e,t,i)}function TR(e,t){fx.publish(e,t,ut())}function wR(e,t,i){var r=parent;if(r!=window){if(typeof e!="string"){console.warn("bubbleCall func not string");return}var n=t||[],s=[{args:n,uuid:i,func:e}];return r.panelCallByEditor.apply(window,s)}}function SR(e,t){if(typeof e=="string"&&t)ER(e,t);else if(e&&typeof e=="object")for(let i of Object.keys(e))ER(i,e[i])}function xR(e){return t=>e.apply(e,Array.isArray(t)?t:[t])}function ER(e,t){e.startsWith("-")?cp.rpcService(e.substring(1),xR(t)):cp.subscribe(e,xR(t))}var Wo=class Wo{static invoke(t,i){if(Wo.hooks[t])return i?Wo.hooks[t].apply(null,i):Wo.hooks[t].apply();{let r=Wo.wildcardHooks;for(let n in r)if(new RegExp(n).test(t))return r[n](t,i)}return!1}};Wo.hooks={},Wo.wildcardHooks={},Wo.registerHook=function(t,i){if(typeof t=="string")if(t.indexOf("*")>=0){let r="^"+t.replace(/\*/g,".*?")+"$";Wo.wildcardHooks[r]=i}else Wo.hooks[t]=i;else if(t instanceof RegExp)Wo.wildcardHooks[t]=i;else for(let r of Object.keys(t))Wo.registerHook(r,t[r])};var B0=Wo;var Ke=(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))(Ke||{}),tm=["combination","group","arc","ellipse","rect","text","obj","dimension","auxiliaryLine","auxiliaryPoint","dimensionLength","dimensionAngle","dimensionRadius"];var Gi=class{};Gi.text="Text",Gi.arc="Elliptical Arc",Gi.rect="Rect",Gi.ellipse="Ellipse",Gi.obj="Image",Gi.group="Shape",Gi.auxiliaryLine="Auxiliary Line",Gi.auxiliaryPoint="Auxiliary Point",Gi.dimension="Smart Dimension",Gi.dimensionLength="Dimension Length",Gi.dimensionAngle="Dimension Angle",Gi.dimensionRadius="Dimension Radius",Gi.combination="Group";var vR=["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 IR={1:"Print Layer",2:"Opacity Control Layer",3:"Board Outline Layer",4:"Slot Hole Layer",5:"Glue Cutout Layer",6:"Lighting Simulation Layer"};var Iv={3:"#ff0000",4:"#ff0000",5:"#009900",2:"#000000",7:"#000000"};var AR={"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 Wh(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 CR(){let e=["0","6,6","3,10","4,2,1,2"],t=[];for(let i of e)t.push(Wh(i));return t}function Av(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 Dv=(i=>(i.Portrait="Portrait",i.Landscape="Landscape",i))(Dv||{}),TV=["393mmx579mm"],Cv=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}};Cv.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 wV={"attr-x-y":{componentType:"point",title:"X/Y",calcu:!0}},SV={"reference-point":{componentType:"nine-grid",title:"Reference Point"}},tu={"attr-rotation":{componentType:"text-input",title:"Rotate",calcu:!0}},Jh={"attr-conceal":{componentType:"select",title:"Hide",options:[{text:"Yes",value:"yes"},{text:"No",value:"no"}]}},up={"attr-locked":{componentType:"select",title:"Locked",options:[{text:"Yes",value:"yes"},{text:"No",value:"no"}]}},Kh=(e={})=>({"attr-name":{componentType:"text-input",type:"text-input",title:"Name",...e}}),$h={"attr-id":{componentType:"text-input",type:"text-input",title:"ID"}},DR={"attr-hide":{componentType:"select",title:"Valid",options:[{text:"Yes",value:"no"},{text:"No (The production file is not output)",value:"yes"}]}},mx={"attr-start":{componentType:"point",type:"number-input-xy-row",title:"StartPosition X/Y",calcu:!0}},gx={"attr-end":{componentType:"point",title:"EndPosition X/Y",calcu:!0}},vV={"attr-dimension-object":{componentType:"text-area",type:"text-area-dimension",title:"Object"}},IV={"attr-length":{componentType:"text-input",type:"text-input",title:"Length"}},AV={"attr-radius":{componentType:"text-input",calcu:!0,type:"number-input",title:"Round Angle"}},CV={"attr-width-height-pair":{componentType:"width-height-pair",widthTitle:"Width",heightTitle:"Height"}},im={"attr-obb-width-height-pair":{componentType:"width-height-pair",widthTitle:"Width",heightTitle:"Height"}},hp={...SV,...wV,...CV},Zh=(e={})=>({"attr-layer":{componentType:"select",type:"layer",title:"Layer",...e}}),PR={"attr-scope":{type:"scope",title:"Scope",options:["Print and White Background","Print Layer","White Background"]}},k0={...Kh(),...$h,...Zh(),"attr-cover":{componentType:"select",type:"yes-no",title:"Cover",options:[{text:"Yes",value:"yes"},{text:"No",value:"no"}]},...PR,"attr-transparency":{componentType:"text-input",type:"text-input",title:"Transparency(Print,White)"},...DR,...Jh,...up},_R={...Kh(),...$h,...Zh(),...Jh,...up},DV={...Kh(),...$h,...Zh(),...Jh,...up},PV={"attr-fill-stroke-pair":{componentType:"fill-stroke-pair",fillTitle:"Fill Color",strokeTitle:"Stroke Color"}},_V={"attr-stroke-width":{componentType:"text-input",type:"number-input",title:"Line Width",calcu:!0}},yx={...PV,..._V},LV=[{title:"Basic Info",attr:k0},{title:"Transformation",attr:hp},{title:"Style",attr:{...im,...tu,...yx}}],OV=[{title:"Basic Info",attr:k0},{title:"Transformation",attr:hp},{title:"Style",attr:{...im,"attr-short-long-radius":{componentType:"width-height-pair",widthTitle:"ShortRadius",heightTitle:"LongRadius"},...tu,...yx}}],RV=[{title:"Basic Info",attr:k0},{title:"Transformation",attr:hp},{title:"Style",attr:{...im,...AV,...tu,...yx}}],NV=[{title:"Basic Info",attr:{...Kh(),...$h,...Zh({disabled:!1}),...Jh,"attr-dimension-category":{componentType:"select",title:"Types",options:["Annotation","Constraint"]}}},{title:"Style",attr:{...vV,"attr-dimension":{componentType:"text-input",calcu:!0,title:"Length"}}}],MV=[{title:"Basic Info",attr:DV},{title:"Style",attr:{...mx,...gx,...tu,...IV}}],BV={"attr-angle":{componentType:"text-input",title:"Angle"}},kV={"attr-dimension-angle":{componentType:"point",title:"AnglePoint X/Y",calcu:!0}},FV=[{title:"Basic Info",attr:_R},{title:"Style",attr:{...kV,...mx,...gx,...tu,...BV}}],GV=[{title:"Basic Info",attr:_R},{title:"Style",attr:{...mx,...gx,"attr-short-radius":{type:"text-input",title:"ShortRadius",disabled:!0},"attr-long-radius":{type:"text-input",title:"LongRadius",disabled:!0},...tu}}],UV={"attr-arc-type":{type:"select",title:"Arc Type",options:["Center Arc","Two Points Arc"]}},YV={"attr-circle-center":{componentType:"point",title:"CircleCenter X/Y",calcu:!0},...mx,...gx,...im,"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"},...tu},HV=[{title:"Basic Info",attr:{...k0,...UV}},{title:"Transformation",attr:hp},{title:"Style",attr:{...YV,...yx}}],LR={"attr-x":{componentType:"text-input",type:"number-input",title:"X Location"}},OR={"attr-y":{componentType:"text-input",type:"number-input",title:"Y Location"}},RR={"attr-stroke-style":{componentType:"select",title:"Line Style",options:CR()}},NR={"attr-color":{componentType:"color",resetColor:!0,title:"Color"}},jV=[{title:"Basic Info",attr:{...Kh(),...$h,...Zh(),...Jh,...up}},{title:"Style",attr:{...LR,...OR,...NR,...RR}}],VV=[{title:"Basic Info",attr:{...Kh(),...$h,...Zh(),...Jh,...up}},{title:"Style",attr:{...LR,...OR,...NR,...RR}}],zV=[{title:"Basic Info",attr:{"attr-textarea":{type:"text-area",title:"Text"},...$h,...Zh(),...PR,"attr-transparency":{type:"text-input",title:"Transparency(Print,White)"},...DR,...Jh,...up}},{title:"Transformation",attr:hp},{title:"Style",attr:{...im,...tu,"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"}}}],XV=[{title:"Basic Info",attr:k0},{title:"Transformation",attr:hp},{title:"Style",attr:{...im,...tu}}],WV=[{title:"Basic Info",attr:{...Kh(),...$h,...Jh,...up}},{title:"Transformation",attr:hp},{title:"Style",attr:{...tu}}],MR={canvas:[{title:"Page",attr:{...Kh({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"]},...Zh({disabled:!0}),"attr-direction":{type:"select",title:"Direction",options:Object.values(Dv)},"attr-widthxheight":{type:"select",title:"Width X Height",options:TV},"attr-remark":{type:"text-input",title:"Remark"}}}],obj:XV,group:LV,text:zV,arc:HV,rect:RV,ellipse:OV,auxiliaryLine:jV,auxiliaryPoint:VV,combination:WV,dimension:NV,dimensionLength:MV,dimensionAngle:FV,dimensionRadius:GV};var BR={line:{modifyProp:"stroke"},dot:{modifyProp:"fill"}};var qV=Object.create,x3=Object.defineProperty,JV=Object.getOwnPropertyDescriptor,KV=Object.getOwnPropertyNames,$V=Object.getPrototypeOf,ZV=Object.prototype.hasOwnProperty,QV=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ez=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of KV(t))!ZV.call(e,n)&&n!==i&&x3(e,n,{get:()=>t[n],enumerable:!(r=JV(t,n))||r.enumerable});return e},tz=(e,t,i)=>(i=e!=null?qV($V(e)):{},ez(t||!e||!e.__esModule?x3(i,"default",{value:e,enumerable:!0}):i,e)),iz=QV((e,t)=>{"use strict";t.exports=i,t.exports.default=i;function i(v,L,_){_=_||2;var B=L&&L.length,U=B?L[0]*_:v.length,z=r(v,0,U,_,!0),W=[];if(!z||z.next===z.prev)return W;var ne,me,Ee,Se,Fe,Ne,it;if(B&&(z=u(v,L,z,_)),v.length>80*_){ne=Ee=v[0],me=Se=v[1];for(var je=_;je<U;je+=_)Fe=v[je],Ne=v[je+1],Fe<ne&&(ne=Fe),Ne<me&&(me=Ne),Fe>Ee&&(Ee=Fe),Ne>Se&&(Se=Ne);it=Math.max(Ee-ne,Se-me),it=it!==0?32767/it:0}return s(z,W,_,ne,me,it,0),W}function r(v,L,_,B,U){var z,W;if(U===N(v,L,_,B)>0)for(z=L;z<_;z+=B)W=H(z,v[z],v[z+1],W);else for(z=_-B;z>=L;z-=B)W=H(z,v[z],v[z+1],W);return W&&b(W,W.next)&&(q(W),W=W.next),W}function n(v,L){if(!v)return v;L||(L=v);var _=v,B;do if(B=!1,!_.steiner&&(b(_,_.next)||w(_.prev,_,_.next)===0)){if(q(_),_=L=_.prev,_===_.next)break;B=!0}else _=_.next;while(B||_!==L);return L}function s(v,L,_,B,U,z,W){if(v){!W&&z&&m(v,B,U,z);for(var ne=v,me,Ee;v.prev!==v.next;){if(me=v.prev,Ee=v.next,z?o(v,B,U,z):a(v)){L.push(me.i/_|0),L.push(v.i/_|0),L.push(Ee.i/_|0),q(v),v=Ee.next,ne=Ee.next;continue}if(v=Ee,v===ne){W?W===1?(v=l(n(v),L,_),s(v,L,_,B,U,z,2)):W===2&&c(v,L,_,B,U,z):s(n(v),L,_,B,U,z,1);break}}}}function a(v){var L=v.prev,_=v,B=v.next;if(w(L,_,B)>=0)return!1;for(var U=L.x,z=_.x,W=B.x,ne=L.y,me=_.y,Ee=B.y,Se=U<z?U<W?U:W:z<W?z:W,Fe=ne<me?ne<Ee?ne:Ee:me<Ee?me:Ee,Ne=U>z?U>W?U:W:z>W?z:W,it=ne>me?ne>Ee?ne:Ee:me>Ee?me:Ee,je=B.next;je!==L;){if(je.x>=Se&&je.x<=Ne&&je.y>=Fe&&je.y<=it&&E(U,ne,z,me,W,Ee,je.x,je.y)&&w(je.prev,je,je.next)>=0)return!1;je=je.next}return!0}function o(v,L,_,B){var U=v.prev,z=v,W=v.next;if(w(U,z,W)>=0)return!1;for(var ne=U.x,me=z.x,Ee=W.x,Se=U.y,Fe=z.y,Ne=W.y,it=ne<me?ne<Ee?ne:Ee:me<Ee?me:Ee,je=Se<Fe?Se<Ne?Se:Ne:Fe<Ne?Fe:Ne,It=ne>me?ne>Ee?ne:Ee:me>Ee?me:Ee,Ht=Se>Fe?Se>Ne?Se:Ne:Fe>Ne?Fe:Ne,Ri=x(it,je,L,_,B),Ci=x(It,Ht,L,_,B),ze=v.prevZ,D=v.nextZ;ze&&ze.z>=Ri&&D&&D.z<=Ci;){if(ze.x>=it&&ze.x<=It&&ze.y>=je&&ze.y<=Ht&&ze!==U&&ze!==W&&E(ne,Se,me,Fe,Ee,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0||(ze=ze.prevZ,D.x>=it&&D.x<=It&&D.y>=je&&D.y<=Ht&&D!==U&&D!==W&&E(ne,Se,me,Fe,Ee,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0))return!1;D=D.nextZ}for(;ze&&ze.z>=Ri;){if(ze.x>=it&&ze.x<=It&&ze.y>=je&&ze.y<=Ht&&ze!==U&&ze!==W&&E(ne,Se,me,Fe,Ee,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0)return!1;ze=ze.prevZ}for(;D&&D.z<=Ci;){if(D.x>=it&&D.x<=It&&D.y>=je&&D.y<=Ht&&D!==U&&D!==W&&E(ne,Se,me,Fe,Ee,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0)return!1;D=D.nextZ}return!0}function l(v,L,_){var B=v;do{var U=B.prev,z=B.next.next;!b(U,z)&&C(U,B,B.next,z)&&M(U,z)&&M(z,U)&&(L.push(U.i/_|0),L.push(B.i/_|0),L.push(z.i/_|0),q(B),q(B.next),B=v=z),B=B.next}while(B!==v);return n(B)}function c(v,L,_,B,U,z){var W=v;do{for(var ne=W.next.next;ne!==W.prev;){if(W.i!==ne.i&&T(W,ne)){var me=G(W,ne);W=n(W,W.next),me=n(me,me.next),s(W,L,_,B,U,z,0),s(me,L,_,B,U,z,0);return}ne=ne.next}W=W.next}while(W!==v)}function u(v,L,_,B){var U=[],z,W,ne,me,Ee;for(z=0,W=L.length;z<W;z++)ne=L[z]*B,me=z<W-1?L[z+1]*B:v.length,Ee=r(v,ne,me,B,!1),Ee===Ee.next&&(Ee.steiner=!0),U.push(y(Ee));for(U.sort(h),z=0;z<U.length;z++)_=d(U[z],_);return _}function h(v,L){return v.x-L.x}function d(v,L){var _=p(v,L);if(!_)return L;var B=G(_,v);return n(B,B.next),n(_,_.next)}function p(v,L){var _=L,B=v.x,U=v.y,z=-1/0,W;do{if(U<=_.y&&U>=_.next.y&&_.next.y!==_.y){var ne=_.x+(U-_.y)*(_.next.x-_.x)/(_.next.y-_.y);if(ne<=B&&ne>z&&(z=ne,W=_.x<_.next.x?_:_.next,ne===B))return W}_=_.next}while(_!==L);if(!W)return null;var me=W,Ee=W.x,Se=W.y,Fe=1/0,Ne;_=W;do B>=_.x&&_.x>=Ee&&B!==_.x&&E(U<Se?B:z,U,Ee,Se,U<Se?z:B,U,_.x,_.y)&&(Ne=Math.abs(U-_.y)/(B-_.x),M(_,v)&&(Ne<Fe||Ne===Fe&&(_.x>W.x||_.x===W.x&&f(W,_)))&&(W=_,Fe=Ne)),_=_.next;while(_!==me);return W}function f(v,L){return w(v.prev,v,L.prev)<0&&w(L.next,v,v.next)<0}function m(v,L,_,B){var U=v;do U.z===0&&(U.z=x(U.x,U.y,L,_,B)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==v);U.prevZ.nextZ=null,U.prevZ=null,g(U)}function g(v){var L,_,B,U,z,W,ne,me,Ee=1;do{for(_=v,v=null,z=null,W=0;_;){for(W++,B=_,ne=0,L=0;L<Ee&&(ne++,B=B.nextZ,!!B);L++);for(me=Ee;ne>0||me>0&&B;)ne!==0&&(me===0||!B||_.z<=B.z)?(U=_,_=_.nextZ,ne--):(U=B,B=B.nextZ,me--),z?z.nextZ=U:v=U,U.prevZ=z,z=U;_=B}z.nextZ=null,Ee*=2}while(W>1);return v}function x(v,L,_,B,U){return v=(v-_)*U|0,L=(L-B)*U|0,v=(v|v<<8)&16711935,v=(v|v<<4)&252645135,v=(v|v<<2)&858993459,v=(v|v<<1)&1431655765,L=(L|L<<8)&16711935,L=(L|L<<4)&252645135,L=(L|L<<2)&858993459,L=(L|L<<1)&1431655765,v|L<<1}function y(v){var L=v,_=v;do(L.x<_.x||L.x===_.x&&L.y<_.y)&&(_=L),L=L.next;while(L!==v);return _}function E(v,L,_,B,U,z,W,ne){return(U-W)*(L-ne)>=(v-W)*(z-ne)&&(v-W)*(B-ne)>=(_-W)*(L-ne)&&(_-W)*(z-ne)>=(U-W)*(B-ne)}function T(v,L){return v.next.i!==L.i&&v.prev.i!==L.i&&!O(v,L)&&(M(v,L)&&M(L,v)&&k(v,L)&&(w(v.prev,v,L.prev)||w(v,L.prev,L))||b(v,L)&&w(v.prev,v,v.next)>0&&w(L.prev,L,L.next)>0)}function w(v,L,_){return(L.y-v.y)*(_.x-L.x)-(L.x-v.x)*(_.y-L.y)}function b(v,L){return v.x===L.x&&v.y===L.y}function C(v,L,_,B){var U=R(w(v,L,_)),z=R(w(v,L,B)),W=R(w(_,B,v)),ne=R(w(_,B,L));return!!(U!==z&&W!==ne||U===0&&A(v,_,L)||z===0&&A(v,B,L)||W===0&&A(_,v,B)||ne===0&&A(_,L,B))}function A(v,L,_){return L.x<=Math.max(v.x,_.x)&&L.x>=Math.min(v.x,_.x)&&L.y<=Math.max(v.y,_.y)&&L.y>=Math.min(v.y,_.y)}function R(v){return v>0?1:v<0?-1:0}function O(v,L){var _=v;do{if(_.i!==v.i&&_.next.i!==v.i&&_.i!==L.i&&_.next.i!==L.i&&C(_,_.next,v,L))return!0;_=_.next}while(_!==v);return!1}function M(v,L){return w(v.prev,v,v.next)<0?w(v,L,v.next)>=0&&w(v,v.prev,L)>=0:w(v,L,v.prev)<0||w(v,v.next,L)<0}function k(v,L){var _=v,B=!1,U=(v.x+L.x)/2,z=(v.y+L.y)/2;do _.y>z!=_.next.y>z&&_.next.y!==_.y&&U<(_.next.x-_.x)*(z-_.y)/(_.next.y-_.y)+_.x&&(B=!B),_=_.next;while(_!==v);return B}function G(v,L){var _=new I(v.i,v.x,v.y),B=new I(L.i,L.x,L.y),U=v.next,z=L.prev;return v.next=L,L.prev=v,_.next=U,U.prev=_,B.next=_,_.prev=B,z.next=B,B.prev=z,B}function H(v,L,_,B){var U=new I(v,L,_);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(v){v.next.prev=v.prev,v.prev.next=v.next,v.prevZ&&(v.prevZ.nextZ=v.nextZ),v.nextZ&&(v.nextZ.prevZ=v.prevZ)}function I(v,L,_){this.i=v,this.x=L,this.y=_,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(v,L,_,B){var U=L&&L.length,z=U?L[0]*_:v.length,W=Math.abs(N(v,0,z,_));if(U)for(var ne=0,me=L.length;ne<me;ne++){var Ee=L[ne]*_,Se=ne<me-1?L[ne+1]*_:v.length;W-=Math.abs(N(v,Ee,Se,_))}var Fe=0;for(ne=0;ne<B.length;ne+=3){var Ne=B[ne]*_,it=B[ne+1]*_,je=B[ne+2]*_;Fe+=Math.abs((v[Ne]-v[je])*(v[it+1]-v[Ne+1])-(v[Ne]-v[it])*(v[je+1]-v[Ne+1]))}return W===0&&Fe===0?0:Math.abs((Fe-W)/W)};function N(v,L,_,B){for(var U=0,z=L,W=_-B;z<_;z+=B)U+=(v[W]-v[z])*(v[z+1]+v[W+1]),W=z;return U}i.flatten=function(v){for(var L=v[0][0].length,_={vertices:[],holes:[],dimensions:L},B=0,U=0;U<v.length;U++){for(var z=0;z<v[U].length;z++)for(var W=0;W<L;W++)_.vertices.push(v[U][z][W]);U>0&&(B+=v[U-1].length,_.holes.push(B))}return _}}),kR={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},Dse=(()=>{let e={};for(let t in kR)e[kR[t]]=t;return e})(),FR=class{constructor(t,i){this.ratio=t/i}wrap(t){return t*this.ratio}static convert(t,i,r){return t*i/r}};FR.ASIS=new FR(1,1);var $x=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}};$x.prototype["px(100)2mil"]=e=>e*10;$x.prototype["px(100)2mm"]=e=>e*.254;$x.prototype["mil2px(100)"]=e=>e/10;$x.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var bx=null,lI=new ArrayBuffer(8),Pv=new Float64Array(lI),_v=new Uint32Array(lI),GR=new Uint16Array(lI),UR=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(!bx){let e=this.getUrlVars().version;e?bx="/analyzer/v"+e:bx="/analyzer"}return bx}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;Pv[0]=new Date().getTime(),e.push(_v[1].toString(16)),Pv[0]=Math.random(),e.push(GR[3].toString(16));let t=GR[2].toString(16);e.push("4"+t.substr(0,3)),Pv[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}},E3=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(pm.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(pm.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(pm.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(pm.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")}},rz=/(\.?0+)$/,pm=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(UR.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(UR.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);E3.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(rz,"")}};function nz(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var sz=(e,t)=>{e===3?console.error(t):console.log(t)},az=(e,t)=>pm.format("%s %s: %s",new Date,nz(e),t),Jv=class Kv{constructor(t,i=sz,r=az){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 Kv(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 Kv(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,pm.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)}};Jv.DUMMY=new Jv(4);var Zx=Jv,cI=new ArrayBuffer(8),Lv=new Float64Array(cI),Ov=new Uint32Array(cI),YR=new Uint16Array(cI),HR=ArrayBuffer;try{HR=self.HTMLImageElement||HR}catch{}var xx=null;function yp(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 x=l(m,g);isNaN(x)?(o[f++]=g,g=a[++p]):(x<=0&&(o[f++]=m,m=a[++d]),x>=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(!xx){let e=this.getUrlVars().version;e?xx="/analyzer/v"+e:xx="/analyzer"}return xx}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(Ov[1].toString(16)),Lv[0]=Math.random(),e.push(YR[3].toString(16));let t=YR[2].toString(16);e.push("4"+t.substr(0,3)),Lv[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}},oz=[1,10,100,1e3],Ex=0,dp=0;function jR(e,t,i){return Ex=Math.abs(e-t),i>=5&&Ex>1e-5||isNaN(i)&&Ex>1e-8?!1:Ex<1e-13?!0:(dp=Math.min(VR(e),VR(t)),dp<10&&(dp=10),isNaN(i)||(dp=Math.min(dp,i)),zR(e,dp)===zR(t,dp))}var Tx=0,wx=0;function VR(e){return Tx=0,wx=0,e>0?Tx=e-Math.floor(e):Tx=e-Math.ceil(e),wx=(Tx.toString()||"").length,wx>2?wx-2:0}function zR(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=oz[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 lz=/(\.?0+)$/,fm=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);Kr.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(lz,"")}},Kr=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(fm.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(fm.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(fm.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(fm.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")}},De=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}};De.eps=1e-8,De.precision=1e8;function gm(e,t){Ux(e.iterator(),t)}function Ux(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var cz=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 $v(e){return new cz(e)}var Rx=class qo{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%qo.PIx2,t=t<0?qo.PIx2+t:t,t===qo.PIx2?0:t}static toQuarterBase(t){return qo.regular((t+qo.PI_4)/qo.PI_2*qo.PI_2)}static toQuarterBaseD(t){return qo.regularD(((t+45)/90|0)*90)}static transformD(t,i){return qo.toDegrees(qo.transform(qo.toRadians(t),i))}static transform(t,i){let r=Math.cos(t),n=Math.sin(t),s=new V(i.data[6],i.data[7]),a=new V(r,n).multiply3(i);return qo.regular(a.angle(s))}};Rx.PIx2=Math.PI*2,Rx.PI_2=Math.PI/2,Rx.PI_4=Math.PI/4;var Jt=Rx,kn=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)}},T3=new ArrayBuffer(16),XR=new Float64Array(T3),Sx=new Int32Array(T3),pp=class Yr{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 Yr(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 Yr(Math.cos(t),Math.sin(t))}static getCrossPoint1(t,i,r,n){if(t.equals1(i)||r.equals1(n)||De.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 Yr((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=Kr.normal(t),this.y=Kr.normal(i)}get hashed(){return this._hashed==null&&(XR[0]=this.x,XR[1]=this.y,this._hashed=Sx[0]^Sx[1]^Sx[2]^Sx[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 Yr(i,r)}add(t){var i=this.x+t.x,r=this.y+t.y;return new Yr(i,r)}div(t){return new Yr(this.x/t,this.y/t)}add1(t,i){return new Yr(this.x+t,this.y+i)}mul(t){return new Yr(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 Jt.toDegrees(this.angle2(t))}angle(t){return Math.atan2(this.y-t.y,this.x-t.x)}angleX(t=Yr.ORIGIN){let i=this.angle(t);return i<0&&(i=Math.PI*2+i),i}angleD(t){return Jt.toDegrees(this.angle(t))}distance1(t){let i=t.x-this.x,r=t.y-this.y;return kn.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,Jt.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 Yr(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 Yr(i,r)}hashCode(){return this.hashed}equals(t,i){return t instanceof Yr?jR(t.x,this.x,i)&&jR(t.y,this.y,i):!1}equals1(t){return t?De.eq(this.x,t.x)&&De.eq(this.y,t.y):!1}equals2(t,i){return t instanceof Yr?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 xt(t,t,i,i)}normalize(){if(this.x===0&&this.y===0)return new Yr(0,0);let t=this.x/this.length(),i=this.y/this.length();return new Yr(t,i)}regular(t=1e-4){let i=Math.round(1/t);return new Yr(Math.round(this.x*i)/i,Math.round(this.y*i)/i)}round(t=4){let i=10**(t|0);return new Yr(Math.round(this.x*i)/i,Math.round(this.y*i)/i)}mirrorX(t=Yr.ORIGIN){return new Yr(this.x,2*t.y-this.y)}mirrorY(t=Yr.ORIGIN){return new Yr(2*t.x-this.x,this.y)}mirrorCenter(t=Yr.ORIGIN){return new Yr(2*t.x-this.x,2*t.y-this.y)}clone(){return new Yr(this.x,this.y)}mirror(t=Yr.ORIGIN){return new Yr(2*t.x-this.x,2*t.y-this.y)}pointOnRays(t,i){let r=Jt.toRadians(t);return new Yr(this.x+Math.cos(r)*i,this.y+Math.sin(r)*i)}pointOnRays2(t,i){let r=t.angle(this);return new Yr(this.x+Math.cos(r)*i,this.y+Math.sin(r)*i)}scale(t){return new Yr(this.x*t,this.y*t)}};pp.ORIGIN=new pp(0,0),pp.X_UNIT_VECTOR=new pp(1,0),pp.Y_UNIT_VECTOR=new pp(0,1);var V=pp,uz=(e=>(e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT",e))(uz||{}),hz=(e=>(e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM",e))(hz||{}),Bs=class{constructor(t,i){this.horizontal=t,this.vertical=i}};Bs.LT=new Bs(0,0),Bs.LC=new Bs(0,1),Bs.LB=new Bs(0,2),Bs.CT=new Bs(1,0),Bs.CC=new Bs(1,1),Bs.CB=new Bs(1,2),Bs.RT=new Bs(2,0),Bs.RC=new Bs(2,1),Bs.RB=new Bs(2,2);var qu=Bs,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 gm(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 V(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 xt(this.minX,this.maxX,this.minY,this.maxY)}build1(){return this.valid()?new xt(this.minX,this.maxX,this.minY,this.maxY):new xt(0,0,0,0)}},F0=new Float64Array(4),xt=class Pl{static extendRect({x:t,y:i,width:r,height:n}){return new Pl(t,t+r,i,i+n)}static extend1(t,i){if(t===null)return new Pl(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 Pl(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 Pl(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 Pl(r,n,s,a)}static extend4(t,i,r){return new Pl(t.x-i/2,t.x+i/2,t.y-r/2,t.y+r/2)}constructor(t,i,r,n){if(this.minX=Kr.normal(t),this.maxX=Kr.normal(i),this.minY=Kr.normal(r),this.maxY=Kr.normal(n),t>i||r>n)throw new Error(`min > max is not permitted: [${t}, ${i}, ${r}, ${n}]`)}get data(){return F0[0]=this.minX,F0[1]=this.maxX,F0[2]=this.minY,F0[3]=this.maxY,F0}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 De.greatereq(t,this.minX)&&De.lesseq(t,this.maxX)}isContainsY(t){return t>=this.minY&&t<=this.maxY}isContainsY1(t){return De.greatereq(t,this.minY)&&De.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 Kr.positiveOr0(this.maxX-this.minX+t*2),Kr.positiveOr0(this.maxY-this.minY+t*2),new Pl(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 De.greatereq(this.maxX,t.maxX)&&De.lesseq(this.minX,t.minX)&&De.greatereq(this.maxY,t.maxY)&&De.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 Pl(i,r,n,s)}intersection1(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(De.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 De.greater(n,s)?null:(n>s&&(s=n),new Pl(i,r,n,s))}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}UL(){return new V(this.minX,this.maxY)}UR(){return new V(this.maxX,this.maxY)}LL(){return new V(this.minX,this.minY)}LR(){return new V(this.maxX,this.minY)}center(){return new V(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 Pl(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),Pl.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?qu.RT:o<-s?qu.RB:qu.RC:a<-n?o>s?qu.LT:o<-s?qu.LB:qu.LC:o>s?qu.CT:o<-s?qu.CB:qu.CC}bbox(){return this}},Yx=class Mi{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=Kr.normal(t),this.n=Kr.normal(i);let n=t*i;if(r.length===n){for(let s=0;s<r.length;s++)Kr.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 Mi.mul(this.m,this.n,t.n,this.data,t.data,i),new Mi(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[Mi.on(n,a,o)]=t[Mi.on(r,a,o)]:o===i+a?s[Mi.on(n,a,o)]=1:s[Mi.on(n,a,o)]=0;return s}inverseMatrix(t,i,r){for(let n=0;n<i;n++){let s=t[Mi.on(r,n,n)];for(let a=0;a<r;a++)t[Mi.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[Mi.on(r,s,s)]===0){let a=new Array(r),o;for(o=s;o<i;o++)if(t[Mi.on(r,o,s)]!==0){fa.arraycopy(t,Mi.on(r,o,0),a,0,r),fa.arraycopy(t,Mi.on(r,s,0),t,Mi.on(r,o,0),r),fa.arraycopy(a,0,t,Mi.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[Mi.on(r,a,s)]/t[Mi.on(r,s,s)];for(let l=0;l<r;l++)t[Mi.on(r,a,l)]-=t[Mi.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 De.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[Mi.on(r,a,l)];i[Mi.on(r,a,l)]=i[Mi.on(r,o,l)],i[Mi.on(r,o,l)]=c}}for(let a=0;a<this.m;a++){let o=Math.abs(i[Mi.on(r,a,a)]),l=a;if(t(i[Mi.on(r,a,a)]))for(let u=a+1;u<this.m;u++){if(t(i[Mi.on(r,u,a)])){Math.abs(i[Mi.on(r,u,a)])>o&&(o=Math.abs(i[Mi.on(r,u,a)]),l=u);continue}n(a,u);break}if(t(i[Mi.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[Mi.on(r,a,a)];for(let u=0;u<r;u++)i[Mi.on(r,a,u)]*=c;for(let u=0;u<this.m;u++){if(a===u)continue;let h=i[Mi.on(r,u,a)];for(let d=a;d<r;d++)i[Mi.on(r,u,d)]-=i[Mi.on(r,a,d)]*h}}let s=[];for(let a=0;a<this.m;a++)for(let o=this.n;o<r;o++)s[Mi.on(this.n,a,o-this.n)]=i[Mi.on(r,a,o)];return new Mi(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 Mi(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 Mi?!(this.m!=t.m||this.n!=t.n||!fa.equals(this.data,t.data)):!1}},dz=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Zv=class Dn extends Yx{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(V.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=dz){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 Yx.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 he([t[0],t[1],0,t[4],t[5],0,t[12],t[13],1])}};Zv.ORIGIN=new Zv;var w3=Zv;function G0(e){return E3.normal(parseFloat(e))}var pz=[1,0,0,0,1,0,0,0,1],lc=class ks extends Yx{static translate(t,i){return new ks([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 ks([i,r,0,-r,i,0,0,0,1])}static rotateD(t){return this.rotate(Jt.toRadians(t))}static scale(t,i=t){return new ks([t,0,0,0,i,0,0,0,1])}static scale1(t,i){return new ks([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=G0(o[0]),c=G0(o[1]);r=r?r.translate(l,c):ks.translate(l,c);break;case"rotate":let u=G0(o[0]),h=G0(o[1]),d=G0(o[2]);r=r?r.setOrigin(h,d):ks.translate(h,d),r=r.rotateD(u);break;default:return}}),r}constructor(t=pz){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 Yx.mul(3,3,3,this.data,t.data,i),new ks(i)}translate(t,i){return this.multiply3(ks.translate(t,i))}translate1(t){return this.multiply3(ks.translate1(t))}scale(t,i=t){return this.multiply3(ks.scale(t,i))}scale1(t,i){return this.multiply3(ks.scale1(t,i))}det(){return this.data[0]*this.data[4]-this.data[3]*this.data[1]}invert(){let t=this.getInverseMatrix();return new ks(t.data)}rotateD(t){return this.multiply3(ks.rotateD(t))}rotate(t){return this.multiply3(ks.rotate(t))}resetOffset(){let t=this.data;return new ks([t[0],t[1],0,t[3],t[4],0,0,0,1])}setOrigin(t,i){return ks.translate(-t,-i).multiply3(this).translate(t,i)}setOrigin1(t){return this.setOrigin(t.x,t.y)}getInverseMatrix(){return new ks(super.getInverseMatrix().data)}getTransposeMatrix(){let t=super.getTransposeMatrix();return new ks(t.data)}toMatrix4(){let t=this.data;return new w3([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}};lc.ORIGIN=new lc,lc.MIRROR_Y=new lc([1,0,0,0,-1,0,0,0,1]),lc.MIRROR_X=new lc([-1,0,0,0,1,0,0,0,1]),lc.ROT_90=new lc([0,1,0,-1,0,0,0,0,1]),lc.ROT_N90=new lc([0,-1,0,1,0,0,0,0,1]);var he=lc,xp=(e=>(e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE",e))(xp||{}),vs=(e=>(e[e.CW=0]="CW",e[e.CCW=1]="CCW",e))(vs||{}),ry=class{},bm=class j0{constructor(t,i,r){this.p1=t,this.p2=i,this.p3=r}barycentre(){return j0.barycentre(this.p1,this.p2,this.p3)}incentre(){return j0.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 V(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 V(l/o,c/o)}area(){return j0.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(kn.crossProd2(t,i,r,n,s,a))}scale(t,i){let r=he.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 j0(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=V.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 vx(){return{minDistance:Number.POSITIVE_INFINITY,start:null,end:null}}var dc=class td{static getMinDistanceWithoutCross(t,i){let r=vx();return td.minLine(t,i,r),r.minDistance}static getMinDistance(t,i){return bo(t,i)?0:this.getMinDistanceWithoutCross(t,i)}static getMinLineWithCross(t,i){let r=vx();return td.minLine(t,i,r),new te(r.start,r.end)}static getMinLine(t,i){return td.intersection(t,i)||this.getMinLineWithCross(t,i)}static getMinDistanceFromPoint(t,i){let r=vx();if(i instanceof te)this.point2LineMinLine(r,i,t);else if(i instanceof Te)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=td.intersection(t,i),this.minline)this.minDistance=0;else{let r=vx();td.minLine(t,i,r),this.minline=new te(r.start,r.end),this.minDistance=r.minDistance}}getDistance(){return this.minDistance}getLine(){return this.minline}static intersection(t,i){let r=bo(t,i);if(r===0)return;let n=new Array;for(let s=0;s<r;s+=2){let a=new V(se[s],se[s+1]);n.push(a)}return n.length>1?new te(n[0],n[1]):new te(n[0],n[0])}static minLine(t,i,r){if(t instanceof te&&i instanceof te)return this.minDistanceForLines(t,i,r);if(t instanceof Te&&i instanceof te)return this.minDistanceForLineAndArc(t,i,r);if(t instanceof te&&i instanceof Te)return this.minDistanceForLineAndArc(i,t,r);if(t instanceof Te&&i instanceof Te)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=td.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),(oc(t,i.center)||oc(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 V(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);oc(t,a)&&(this.arcShortestLine(i,r,a,l),this.arcShortestLine(i,r,a,c)),oc(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));oc(t,l)&&De.greater(i.start().distance2(t.center),0)&&this.arcShortestLine(t,r,i.start(),l),oc(t,c)&&De.greater(i.end().distance2(t.center),0)&&this.arcShortestLine(t,r,i.end(),c),oc(i,u)&&De.greater(t.start().distance2(i.center),0)&&this.arcShortestLine(i,r,t.start(),u),oc(i,h)&&De.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(oc(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(oc(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=td.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(!oc(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(!De.eq(t.b,0)&&!De.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 V(r.x+n.x*s,r.y+n.y*s)}else return De.eq(t.b,0)&&!De.eq(t.a,0)?new V(t.start().x,i.y):!De.eq(t.b,0)&&De.eq(t.a,0)?new V(i.x,t.start().y):i}};function oc(e,t){if(De.eq(e.sweepAngle,360))return!0;let i=Jt.regularD(t.angleD(e.center));return e.sweepAngle>0?(De.less(i,e.startAngle)&&(i+=360),De.greatereq(e.endAngle(),i)):(De.greater(i,e.startAngle)&&(i-=360),De.lesseq(e.endAngle(),i))}var fz=[1,10,100,1e3],WR="http://www.w3.org/2000/svg",qR="http://www.w3.org/1999/xlink",JR="http://www.w3.org/XML/1998/namespace",KR="https://easyeda.com/",Lse=(function(){var e={svg:WR,xlink:qR,xml:JR,c:KR};return e[WR]="svg",e[qR]="xlink",e[JR]="xml",e[KR]="c",e})(),Wn=(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})(),Ose=(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})(),Ms=(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})(),Rse=(function(){var e=[],t=[];for(var i in Wn)if(Wn.hasOwnProperty(i)){if(i.match(/^BOARD\d+/))continue;e.push(Wn[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 Wn.TOPLAYER:n={name:Ms[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case Wn.BOTTOMLAYER:n={name:Ms[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case Wn.TOPSILKLAYER:n={name:Ms[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case Wn.BOTTOMSILKLAYER:n={name:Ms[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case Wn.TOPPASTERLAYER:n={name:Ms[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case Wn.BOTTOMPASTERLAYER:n={name:Ms[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case Wn.TOPSOLDERLAYER:n={name:Ms[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case Wn.BOTTOMSOLDERLAYER:n={name:Ms[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case Wn.RATLINES:n={name:Ms[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case Wn.BOARDOUTLINE:n={name:Ms[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case Wn.ALL:n={name:Ms[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case Wn.DOCUMENT:n={name:Ms[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case Wn.TOPASSEMBLY:n={name:Ms[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case Wn.BOTTOMASSEMBLY:n={name:Ms[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case Wn.MECHANICAL:n={name:Ms[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case Wn.MODEL3D:n={name:Ms[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case Wn.LIBBODY:n={name:Ms[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case Wn.PADSURFACE:n={name:Ms[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=Wn.INNER1&&o<=Wn.INNER32?n={name:Ms[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})(),$R={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},Nse=(function(){var e={};for(let t in $R)e[$R[t]]=t;return e})(),Qx=Math.PI*2,Hx=Math.PI/2,Mse=Math.sin(Math.PI/180);function mz(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=fz[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 S3(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function gz(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 yz(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 bz(e,t,i){return gz(e,t,i)?S3((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}var V0=1e-4,se=new Float64Array(100);function bo(e,t){if(e instanceof te&&t instanceof te)return au(e,t);if(e instanceof Te&&t instanceof te)return Qv(e,t);if(e instanceof te&&t instanceof Te)return Qv(t,e);if(e instanceof Te&&t instanceof Te)return I3(e,t);if(e instanceof Ue&&t instanceof Ue)return Nx(e,t);if(e instanceof Ue&&t instanceof te)return Nx(e,new Ue([t.start(),t.end()]));if(e instanceof te&&t instanceof Ue)return Nx(new Ue([e.start(),e.end()]),t);if(e instanceof Ue&&t instanceof Te)return n3(t,e);if(e instanceof Te&&t instanceof Ue)return n3(e,t);throw new Error("not supported operation")}function xz(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new te(new V(i.minX-1,t),new V(i.maxX+1,t));return au(r,e)>0?1:0}else return 0}function Ez(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new te(new V(i.minX-1,t),new V(i.maxX+1,t));return jx(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function ZR(e,t){let i=e.bbox();return i.isContainsY1(t)&&Nx(new Ue([new V(i.minX-1,t),new V(i.maxX+1,t)]),e)>0?1:0}function QR(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function Tz(e,t){let i=t.length(),r=kn.crossProd3(t.start(),t.end(),e.start())/i,n=kn.crossProd3(t.start(),t.end(),e.end())/i;return Math.abs(r)<1e-8||Math.abs(n)<1e-8||r*n<0}function au(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 e3(t,e,i);else{if(t.isPoint())return e3(e,t,i);{let r=function(E,T){i.isContains2(E,T)&&(se[y++]=E,se[y++]=T)};if(!Tz(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=kn.crossProd2(n,s,l,c,u,h)/d,f=kn.crossProd2(a,o,l,c,u,h)/d;if(p*f>0&&!De.eq(p,0)&&!De.eq(f,0))return 0;let m=e.length(),g=kn.crossProd2(l,c,n,s,a,o)/m,x=kn.crossProd2(u,h,n,s,a,o)/m;if(g*x>0&&!De.eq(g,0)&&!De.eq(x,0))return 0;let y=0;if(De.eq(p,0)&&De.eq(f,0)){let E=i.UL(),T=i.UR(),w=i.LL(),b=i.LR();if(De.eq(i.width(),0))De.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(De.eq(i.height(),0))se[y++]=E.x,se[y++]=E.y,se[y++]=T.x,se[y++]=T.y;else{let C=bm.area2(E.x,E.y,l,c,u,h),A=bm.area2(T.x,T.y,l,c,u,h);C<A?(se[y++]=E.x,se[y++]=E.y,se[y++]=b.x,se[y++]=b.y):(se[y++]=T.x,se[y++]=T.y,se[y++]=w.x,se[y++]=w.y)}}else if(De.eq(p,0))r(n,s);else if(De.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 e3(e,t,i){let r=t.start(),n=t.end(),s=kn.crossProd3(e.start(),e.end(),t.start()),a=kn.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(De.eq(s/e.length(),0))return se[0]=r.x,se[1]=r.y,2}else if(De.eq(a/e.length(),0))return se[0]=n.x,se[1]=n.y,2;return 0}function jx(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(V0);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=De.eq(h,s)?0:h>s?1:-1,f=De.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=dc.foot(t,e.center),x=g.distance1(e.center);if(De.greater(x,s))return 0;if(De.eq(x,s))De.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):De.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=v3(r,n,o,l,c,u,m,g);let y=se[m-2],E=se[m-1];m-=2;let T=kn.distance1(r,n,y,E);if(De.eq(T,s))se[m++]=y,se[m++]=E,se[m++]=y,se[m++]=E;else if(T<s)m=ws(a,r,n,o,l,y,E,m),m=ws(a,r,n,y,E,c,u,m);else return 0}}else if(p===-1||f===-1)m=ws(a,r,n,o,l,c,u,m);else{let g=dc.foot(t,e.center),x=g.distance1(e.center);if(De.eq(x,s)){let y=function(w){return QR(i,w.x,w.y)&&Bn(e,w)},E=e.start(),T=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(De.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(De.eq(t.distance2(T),0)&&y(T))return se[m++]=T.x,se[m++]=T.y,se[m++]=T.x,se[m++]=T.y,m;if(h<=s)m=ws(a,r,n,g.x,g.y,c,u,m),m===2&&(se[m++]=se[0],se[m++]=se[1]);else if(x<s){if(m=ws(a,r,n,g.x,g.y,c,u,m),m===2&&y(new V(se[0],se[1])))return se[m++]=se[0],se[m++]=se[1],m;m=ws(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(De.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(De.eq(t.distance2(T),0)&&y(T))return se[m++]=T.x,se[m++]=T.y,se[m++]=T.x,se[m++]=T.y,m;if(d<=s)m=ws(a,r,n,g.x,g.y,o,l,m),m===2&&(se[m++]=se[0],se[m++]=se[1]);else if(x<s){if(m=ws(a,r,n,g.x,g.y,o,l,m),m===2&&y(new V(se[0],se[1])))return se[m++]=se[0],se[m++]=se[1],m;m=ws(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=ws(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=ws(a,r,n,g.x,g.y,o,l,m))}}if(m>0){let g=0;for(let x=0;x<m;x+=2){let y=se[x],E=se[x+1];isFinite(y)&&isFinite(E)&&QR(i,y,E)&&Bn(e,new V(y,E))&&(se[g++]=y,se[g++]=E)}return g}else return 0}else return 0}function wz(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=De.eq(c,n)?0:c>n?1:-1,d=De.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=dc.foot(t,e.center),m=f.distance2(e.center);if(De.greater(m,n))return 0;if(De.eq(m,n)){let g=f.distance2(e.start()),x=f.distance2(e.end());De.eq(g,0)?(se[p++]=e.start().x,se[p++]=e.start().y):De.eq(x,0)?(se[p++]=e.end().x,se[p++]=e.end().y):(se[p++]=f.x,se[p++]=f.y)}else{p=v3(i,r,s,a,o,l,p,f);let g=se[p-2],x=se[p-1],y=kn.distance2(i,r,g,x);if(p-=2,De.eq(y,n))se[p++]=g,se[p++]=x;else if(y<n)p=ws(n,i,r,s,a,g,x,p),p=ws(n,i,r,g,x,o,l,p);else return 0}}else if(h===-1||d===-1)p=ws(n,i,r,s,a,o,l,p);else{let f=dc.foot(t,e.center);h===0?(se[p++]=t.start().x,se[p++]=t.start().y,De.neq(f.distance2(t.start()),0)&&(s-f.x)*(o-f.x)+(a-f.y)*(l-f.y)<0&&(p=ws(n,i,r,f.x,f.y,o,l,p))):(se[p++]=t.end().x,se[p++]=t.end().y,De.neq(f.distance2(t.end()),0)&&(s-f.x)*(o-f.x)+(a-f.y)*(l-f.y)<0&&(p=ws(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],x=se[m+1];isFinite(g)&&isFinite(x)&&(se[f++]=g,se[f++]=x)}return f}else return 0}else return 0}function ws(e,t,i,r,n,s,a,o){if(n==a){let y=e-(n-i)*(n-i);if(De.greater(y,0)){let E=Math.sqrt(y),T=t-E,w=t+E,b=Math.min(r,s),C=Math.max(r,s);return T>=b&&T<=C&&(se[o++]=T,se[o++]=n),w>=b&&w<=C&&(se[o++]=w,se[o++]=n),o}}let l=kn.distance2(r,n,t,i)-e;if(l===0)return se[o++]=r,se[o++]=n,o;let c=kn.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?De.eq(l,0)&&(se[o++]=r,se[o++]=n):De.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?De.eq(l,0)&&(se[o++]=r,se[o++]=n):De.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,x=0;for(;g!==0;){x++;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=kn.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 v3(e,t,i,r,n,s,a,o){let l=kn.dotProd2(i,r,n,s,e,t),c=kn.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(kn.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=kn.distance2(i,r,e,t),x=kn.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==x||d==u&&p==h||f==u&&m==h));){y=kn.distance2(u,h,e,t);let T=kn.dotProd2(d,p,u,h,e,t);if(T==0)break;T<0?(f=u,m=h,x=y):(d=u,p=h,g=y)}return kn.distance2(u,h,e,t)<kn.distance2(o.x,o.y,e,t)?(se[a++]=u,se[a++]=h):(se[a++]=o.x,se[a++]=o.y),a}}function Qv(e,t){if(e.rx===e.ry)return jx(e,t);throw new Error("not supported")}function Sz(e,t){if(e.rx===e.ry)return wz(e,t);throw new Error("not supported")}function I3(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return vz(e,t);throw new Error("not supported operation")}return 0}function vz(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(De.greater(u,d)||De.less(u,h))return 0;if(De.eq(h+u,0)){let p=0,f;return Bn(e,t.start())&&(se[p]=t.start().x,se[p+1]=t.start().y,p+=2,f=t.start()),Bn(e,t.end())&&(se[p]=t.end().x,se[p+1]=t.end().y,p+=2,f=t.end()),p===0?(Bn(t,e.start())&&(se[p]=e.start().x,se[p+1]=e.start().y,p+=2),Bn(t,e.end())&&(se[p]=e.end().x,se[p+1]=e.end().y,p+=2)):p===2&&(!f.equals1(e.start())&&Bn(t,e.start())&&(se[p]=e.start().x,se[p+1]=e.start().y,p+=2),!f.equals1(e.end())&&Bn(t,e.end())&&(se[p]=e.end().x,se[p+1]=e.end().y,p+=2)),p}else if(De.eq(u,d)){if(t3(e,t))return 4;let p=new te(e.center,t.center),f=jx(t,p);return f=i3(e,f),f!==0?f:(f=jx(e,p),i3(t,f))}else if(De.eq(u,h)){if(t3(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,r3(e,t,2)}else{let p=(o-a)/o;return se[0]=n+(i-n)/p,se[1]=s+(r-s)/p,r3(e,t,2)}}else{let p,f;if(e.rx>t.rx){let R=(e.center.distance2(t.center)-l+c)/(u*2)/u;p=(i-n)*R+n,f=(r-s)*R+s}else{let R=(e.center.distance2(t.center)-c+l)/(u*2)/u;p=(n-i)*R+i,f=(s-r)*R+r}let m=n-i,g=s-r,x=Math.max(a,o)*2,y,E,T,w;if(Math.abs(m)<Math.abs(g)){let R=m/-g,O=f-R*p;y=p-x,E=R*y+O,T=p+x,w=R*T+O}else{let R=g/-m,O=p-R*f;E=f-x,y=R*E+O,w=f+x,T=R*w+O}let b;if(e.rx>t.rx?(b=ws(c,n,s,y,E,p,f,0),b=ws(c,n,s,p,f,T,w,b)):(b=ws(l,i,r,y,E,p,f,0),b=ws(l,i,r,p,f,T,w,b)),b!==4)throw new Error("cnt !== 4");let C=new V(se[0],se[1]),A=new V(se[2],se[3]);if(Bn(e,C)&&Bn(t,C))return Bn(e,A)&&Bn(t,A)?4:Qh(e.start(),t,A,C)?(se[2]=e.start().x,se[3]=e.start().y,4):Qh(e.end(),t,A,C)?(se[2]=e.end().x,se[3]=e.end().y,4):Qh(t.start(),e,A,C)?(se[2]=t.start().x,se[3]=t.start().y,4):Qh(t.end(),e,A,C)?(se[2]=t.end().x,se[3]=t.end().y,4):2;if(Bn(e,A)&&Bn(t,A))return Qh(e.start(),t,C,A)?(se[0]=e.start().x,se[1]=e.start().y,4):Qh(e.end(),t,C,A)?(se[0]=e.end().x,se[1]=e.end().y,4):Qh(t.start(),e,C,A)?(se[0]=t.start().x,se[1]=t.start().y,4):Qh(t.end(),e,C,A)?(se[0]=t.end().x,se[1]=t.end().y,4):(se[0]=se[2],se[1]=se[3],2);{let R=function(G,H){if(De.eq(G.distance1(H.center),H.rx)&&Bn(H,G)){if(G.distance2(C)<G.distance2(A)){if(O)return;O=!0}else{if(M)return;M=!0}se[k++]=G.x,se[k++]=G.y}},O=!1,M=!1,k=0;return R(e.start(),t),R(e.end(),t),R(t.start(),e),R(t.end(),e),k}}}function Qh(e,t,i,r){return De.eq(e.distance1(t.center),t.rx)&&Bn(t,e)&&e.distance2(i)<e.distance2(r)}function t3(e,t){return De.eq(t.start().distance1(e.center),e.rx)&&Bn(e,t.start())?(se[0]=t.start().x,se[1]=t.start().y,se[2]=t.start().x,se[3]=t.start().y,!0):De.eq(t.end().distance1(e.center),e.rx)&&Bn(e,t.end())?(se[0]=t.end().x,se[1]=t.end().y,se[2]=t.end().x,se[3]=t.end().y,!0):De.eq(e.start().distance1(t.center),t.rx)&&Bn(t,e.start())?(se[0]=e.start().x,se[1]=e.start().y,se[2]=e.start().x,se[3]=e.start().y,!0):De.eq(e.end().distance1(t.center),t.rx)&&Bn(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 i3(e,t){if(t===0)return 0;let i=se[0],r=se[1];return Bn(e,new V(i,r))?(se[0]=i,se[1]=r,se[2]=i,se[3]=r,4):0}function r3(e,t,i){if(i===0)return 0;let r=se[0],n=se[1],s=new V(r,n);return Bn(e,s)&&Bn(t,s)?(se[0]=r,se[1]=n,se[2]=r,se[3]=n,4):0}function rm(e,t){return Math.abs(e-t)<=1e-6}function Bn(e,t){let i=e.bbox();if(t.x-i.minX>-V0&&t.x-i.maxX<V0&&t.y-i.minY>-V0&&t.y-i.maxY<V0){let r=Jt.regularD(t.angleD(e.center));return rm(r,e.startAngle)||rm(r,e.startAngle+360)||rm(r,e.startAngle-360)||rm(r,e.endAngle())||rm(r,e.endAngle()+360)||rm(r,e.endAngle()-360)?!0:e.sweepAngle>0?(De.less(r,e.startAngle)&&(r+=360),De.greatereq(e.endAngle(),r)):(De.greater(r,e.startAngle)&&(r-=360),De.lesseq(e.endAngle(),r))}else return!1}function Iz(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 S3(a,o,Math.sin(Math.PI/180))}function Az(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,x,y,E;return u===0&&h===0?{d:Math.sqrt(d*d+p*p),point:new V(n,s)}:(r=(d*u+p*h)/(u*u+h*h),r<0?{d:Math.sqrt(d*d+p*p),point:new V(n,s)}:r>1?(f=l-a,m=c-o,{d:Math.sqrt(f*f+m*m),point:new V(a,o)}):(y=n+r*u,E=s+r*h,g=l-y,x=c-E,{d:Math.sqrt(g*g+x*x),point:new V(y,E)}))}function hc(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"&&Dz(r,s)?a=!r[i].call(r,s):a=!(r===s||r.toString()===s.toString()):typeof r=="number"&&typeof s=="number"?a=!(Cz(r,s)||Number.isNaN(r)&&Number.isNaN(s)):a=r!==s,a})}function Cz(e,t,i=5){return Math.abs(e-t)*Math.pow(10,i)<1}function Dz(e,t){return!e||!t||typeof e!="object"||typeof t!="object"?e===t:e.constructor===t.constructor}var ci=new Float64Array(100);function Nx(e,t){if(e.bbox().extendOfSize(De.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(I){M=Math.min(M,I),k=Math.max(k,I)},o=function(I,N){let v=au(I,N);if(v===0)throw new Error("cnt === 0");for(let L=0;L<v;L+=2)a(se[L])};if(n>r){for(let I=n-2;I>=2;I-=2)for(let N=I-2;N>=0;N-=2)if(De.eq(ci[I],ci[N])&&De.eq(ci[I+1],ci[N+1])){ci[N]=(ci[I]+ci[N])/2,ci[N+1]=(ci[I+1]+ci[N+1])/2;for(let v=n-3;v>=I;v--)ci[v]=ci[v+2];n-=2;break}if(n>r){n=0;let I=t.start(),N=new Float64Array(8);e.getPercent(I)!==null&&(N[n++]=I.x,N[n++]=I.y);let v=t.end();e.getPercent(v)!==null&&(N[n++]=v.x,N[n++]=v.y);let L=e.start();t.getPercent(L)!==null&&(N[n++]=L.x,N[n++]=L.y);let _=e.end();return t.getPercent(_)!==null&&(N[n++]=_.x,N[n++]=_.y),se.set(N),n}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let I=au(new te(u[0],u[1]),new te(h[0],h[1]));for(let N=0;N<I;N++)ci[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,x=Math.sqrt(1/(f**2+m**2));f*=x,m*=x,g*=x;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(I=>{let N=f*I.x+m*I.y+g;N<y&&(y=N),N>E&&(E=N)}),De.eq(y,E)){if(c.controls.length===2){let I=au(new te(l.start(),l.end()),new te(c.start(),c.end()));for(let N=0;N<I;N++)ci[n++]=se[N];if(I!==0)continue}l=new Ue([u[0],u[u.length-1]]),u=l.controls}let T=h.map(I=>{let N=f*I.x+m*I.y+g,v=Math.abs(N);return v<s&&(s=v),N}),w=0;for(let I of T){if(De.less(I,y))w=w|1;else if(De.greater(I,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let b=0,C=0,A=p.x-d.x,R=p.y-d.y,O=Math.sqrt(1/(A**2+R**2));A*=O,R*=O;for(let I=1;I<u.length;I++){let N=u[I],v=(N.x-d.x)*A+(N.y-d.y)*R;v<b?b=v:v>C&&(C=v)}w=0;for(let I of h){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(De.less(N,b))w=w|1;else if(De.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY;s/=2,s<=De.eps&&(s=De.eps),y-=s,E+=s,T.forEach((I,N)=>{I>=y&&I<=E&&a(N/(T.length-1))});let G=new te(new V(0,y),new V(1,y)),H=new te(new V(0,E),new V(1,E));for(let I=0;I<T.length-1;I++){let N=new V(I/(T.length-1),T[I]),v=N.y<y?1:N.y>E?2:3;for(let L=0;L<T.length;L++){let _=new V(L/(T.length-1),T[L]),B=_.y<y?1:_.y>E?2:3;v!==B&&(v===1?B===2?(o(new te(N,_),G),o(new te(N,_),H)):o(new te(N,_),G):v===2?B===1?(o(new te(N,_),G),o(new te(N,_),H)):o(new te(N,_),H):B===1?o(new te(N,_),G):o(new te(N,_),H))}}M!==0&&(c=c.clip(M)[1]),k!==1&&(c=c.clip((k-M)/(1-M))[0]);let q=c.bbox();if(De.eq(q.minX,q.maxX)&&De.eq(q.minY,q.maxY)){w=0;for(let I of c.controls){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(De.less(N,b))w=w|1;else if(De.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let I=new V((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(I)&&(ci[n++]=I.x,ci[n++]=I.y)}continue}if(k-M>.8){let[I,N]=c.clip(.5);i.push([I,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)se[a]=ci[a];return n}function Pz(e,t){if(e.bbox().extendOfSize(De.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(I){M=Math.min(M,I),k=Math.max(k,I)},o=function(I,N){let v=au(I,N);if(v===0)throw new Error("cnt === 0");for(let L=0;L<v;L+=2)a(se[L])};if(n>r){for(let I=n-2;I>=2;I-=2)for(let N=I-2;N>=0;N-=2)if(De.eq(ci[I],ci[N])&&De.eq(ci[I+1],ci[N+1])){ci[N]=(ci[I]+ci[N])/2,ci[N+1]=(ci[I+1]+ci[N+1])/2;for(let v=n-3;v>=I;v--)ci[v]=ci[v+2];n-=2;break}if(n>r){n=0;let I=new Float64Array(8),N=t.end(),v=0;e.getPercent(N)!==null&&(I[n++]=N.x,I[n++]=N.y,v=2);let L=e.end();return t.getPercent(L)!==null&&(I[n++]=L.x,I[n++]=L.y,v=v===0?1:3),se.set(I),{havOverlap:v,cnt:n}}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let I=au(new te(u[0],u[1]),new te(h[0],h[1]));for(let N=0;N<I;N++)ci[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,x=Math.sqrt(1/(f**2+m**2));f*=x,m*=x,g*=x;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(I=>{let N=f*I.x+m*I.y+g;N<y&&(y=N),N>E&&(E=N)}),De.eq(y,E)){if(c.controls.length===2){let I=au(new te(l.start(),l.end()),new te(c.start(),c.end()));for(let N=0;N<I;N++)ci[n++]=se[N];if(I!==0)continue}l=new Ue([u[0],u[u.length-1]]),u=l.controls}let T=h.map(I=>{let N=f*I.x+m*I.y+g,v=Math.abs(N);return v<s&&(s=v),N}),w=0;for(let I of T){if(De.less(I,y))w=w|1;else if(De.greater(I,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let b=0,C=0,A=p.x-d.x,R=p.y-d.y,O=Math.sqrt(1/(A**2+R**2));A*=O,R*=O;for(let I=1;I<u.length;I++){let N=u[I],v=(N.x-d.x)*A+(N.y-d.y)*R;v<b?b=v:v>C&&(C=v)}w=0;for(let I of h){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(De.less(N,b))w=w|1;else if(De.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY;s/=2,s<=De.eps&&(s=De.eps),y-=s,E+=s,T.forEach((I,N)=>{I>=y&&I<=E&&a(N/(T.length-1))});let G=new te(new V(0,y),new V(1,y)),H=new te(new V(0,E),new V(1,E));for(let I=0;I<T.length-1;I++){let N=new V(I/(T.length-1),T[I]),v=N.y<y?1:N.y>E?2:3;for(let L=0;L<T.length;L++){let _=new V(L/(T.length-1),T[L]),B=_.y<y?1:_.y>E?2:3;v!==B&&(v===1?B===2?(o(new te(N,_),G),o(new te(N,_),H)):o(new te(N,_),G):v===2?B===1?(o(new te(N,_),G),o(new te(N,_),H)):o(new te(N,_),H):B===1?o(new te(N,_),G):o(new te(N,_),H))}}M!==0&&(c=c.clip(M)[1]),k!==1&&(c=c.clip((k-M)/(1-M))[0]);let q=c.bbox();if(De.eq(q.minX,q.maxX)&&De.eq(q.minY,q.maxY)){w=0;for(let I of c.controls){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(De.less(N,b))w=w|1;else if(De.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let I=new V((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(I)&&(ci[n++]=I.x,ci[n++]=I.y)}continue}if(k-M>.8){let[I,N]=c.clip(.5);i.push([I,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)se[a]=ci[a];return{cnt:n}}var _z=class{constructor(e=De.eps){this.eps=e}eq(e,t){return Math.abs(e-t)<=this.eps}setEps(e){this.eps=e}},U0=new _z;function n3(e,t){if(e.bbox().extendOfSize(De.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(!(U0.eq(ci[c],ci[u])&&U0.eq(ci[c+1],ci[u+1]))){l(ci[u],ci[u+1],o);break}function l(c,u,h){let d=!1;for(let p=0;p<h.length;p+=2)if(U0.eq(c,h[p])&&U0.eq(u,h[p+1])){d=!0;break}d||h.push(c,u)}},o=[ci[0],ci[1]];if(a(),o.length>=100&&(U0.setEps(.001),o=[ci[0],ci[1]],a(),o.length>=100))throw new Error("clearSamePoint()");n=o.length,o.forEach((l,c)=>ci[c]=l)}let s=i.pop();if(s[0]instanceof Te){let a=function(H){R=Math.min(R,H),O=Math.max(O,H)},o=function(H,q){let I=au(H,q);if(I===0)throw new Error("cnt === 0");for(let N=0;N<I;N+=2)a(se[N])},[l,c]=s,u=c.controls;if(u.length===2){let H=Qv(l,new te(u[0],u[1]));for(let q=0;q<H;q++)ci[n++]=se[q];continue}let h=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,p,f,m,g,x;if(Math.abs(l.sweepAngle)>359){let H=l.rx;p=l.center.add1(H,0),f=l.center.add1(-H,0),h=-H,d=H,m=0,g=1,x=-l.center.y}else{p=l.start(),f=l.end(),m=f.y-p.y,g=p.x-f.x,x=-m*p.x-g*p.y;let H=Math.sqrt(1/(m**2+g**2));m*=H,g*=H,x*=H;let q=m*l.center.x+g*l.center.y+x;l.isCCW?(d=l.rx+q,h=0):(h=q-l.rx,d=0)}let y=u.map(H=>m*H.x+g*H.y+x),E=0;for(let H of y){if(De.less(H,h))E=E|1;else if(De.greater(H,d))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let T=0,w=0,b=f.x-p.x,C=f.y-p.y,A=Math.sqrt(1/(b**2+C**2));if(b*=A,C*=A,Math.abs(l.sweepAngle)<=180)T=0,w=(f.x-p.x)*b+(f.y-p.y)*C;else throw new Error("not support");E=0;for(let H of u){let q=(H.x-p.x)*b+(H.y-p.y)*C;if(De.less(q,T))E=E|1;else if(De.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let R=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;h-=De.eps,d+=De.eps,y.forEach((H,q)=>{H>=h&&H<=d&&a(q/(y.length-1))});let M=new te(new V(0,h),new V(1,h)),k=new te(new V(0,d),new V(1,d));for(let H=0;H<y.length-1;H++){let q=new V(H/(y.length-1),y[H]),I=q.y<h?1:q.y>d?2:3;for(let N=0;N<y.length;N++){let v=new V(N/(y.length-1),y[N]),L=v.y<h?1:v.y>d?2:3;I!==L&&(I===1?L===2?(o(new te(q,v),M),o(new te(q,v),k)):o(new te(q,v),M):I===2?L===1?(o(new te(q,v),M),o(new te(q,v),k)):o(new te(q,v),k):L===1?o(new te(q,v),M):o(new te(q,v),k))}}R!==0&&(c=c.clip(R)[1]),O!==1&&(c=c.clip((O-R)/(1-R))[0]);let G=c.bbox();if(De.eq(G.minX,G.maxX)&&De.eq(G.minY,G.maxY)){E=0;for(let H of c.controls){let q=(H.x-p.x)*b+(H.y-p.y)*C;if(De.less(q,T))E=E|1;else if(De.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}E===3&&(ci[n++]=(G.minX+G.maxX)/2,ci[n++]=(G.minY+G.maxY)/2);continue}O-R>.8?c.clip(.5).forEach(H=>i.push([H,l])):i.push([c,l])}else{let[a,o]=s;i.push([Te.build3(o.center,o.startAngle,o.sweepAngle/2,o.rx,o.ry),a]),i.push([Te.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]=ci[s];return n}var Lz=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 Oz(e){let t=e.primitives,i=t[0],r=i instanceof Te?i.sweepAngle%360:null;if(t.length===1&&i instanceof Te&&(De.eq(r,0)||De.eq(Math.abs(r),360)))return!!i.isCCW;let n=new Array;return e.points(.1,s=>{n.push(s)}),Lz.getSweep(n)}var Rz=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?Et.build2(r):null}static zoomPolygon(e,t){let i=new Array,r=new Array,n=new Array;return Oz(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?Et.build2(r):null}static zoomLines(e,t){return this.zoomPolygon(Et.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 Te&&c instanceof Te)&&!this.isCW(l.end(),c.start(),o.end())){if(bo(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 Te&&n instanceof Te)&&!this.isCW(r.end(),n.start(),s.end())){let a=bo(r,n);for(let o=0;o<a;o+=2){let l=new V(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 Te&&h instanceof Te)&&!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 Te.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=Te.build2(s,c,u,n,n,0),f=Te.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=bo(r,n);for(let o=0;o<a;o+=2){let l=new V(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=bo(a,r);for(let l=0;l<o;l+=2){let c=new V(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 te)return new te(t,i);if(e instanceof Te){let r=e,n=t.angleD(r.center),s=i.angleD(r.center);return Te.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 te(i,e),n=new te(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 te){if(e.isPoint())return;{let i=e.panDistance(t);return i.length()>1e-5?i:void 0}}else if(e instanceof Te){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||De.eq(Math.abs(i.sweepAngle),360)?i:void 0}else throw new Error("not supported operation")}},Ft=.001,ga=Ft**2;function St(e,t){return e.distance2(t)<ga}function ou(e,t){return Math.abs(e-t)<=1e-4}function Nz(e,t){if(e instanceof te)return new te(e.start(),t);if(e instanceof Te){let i=t.angleD(e.center);return ou(Jt.regularD(e.startAngle),Jt.regularD(i))?Te.build3(e.center,e.startAngle,0,e.rx,e.ry):Te.build2(e.center,e.startAngle,i,e.rx,e.ry,e.isCCW?1:0)}else{if(e instanceof Ue)return e.clip(e.getPercent(t,Ft))[0];throw new Error("not supported operation")}}function pc(e,t=Jt.toRadians(e.startAngle)){return e.isCCW?t+=Hx:t-=Hx,new V(Math.cos(t),Math.sin(t))}function ey(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 mm(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 te(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 te)return e.end().sub(e.start()).normalize();if(e instanceof Te)return(t?pc(e,t.angle(e.center)):pc(e)).normalize();if(e instanceof Ue)if(e.controls.length===2){let[i,r]=e.controls;if(St(i,r))throw Error("equalsPP(p0, p1)");return r.sub(i).normalize()}else return(t?ey(e,e.getPercent(t,Ft)):ey(e)).normalize();else throw new Error("not support")}function Mz(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 Bz(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 Rv(e,t,i){if(e instanceof te||t.distance2(i)<=ga)return new te(t,i);if(e instanceof Te)return Te.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof Ue){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 Mx(e){return De.greater(e,0)&&De.less(e,1)}function Vx(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 Mx(a)&&o.push(a),o}function zx(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(De.lesseq(u,0))s=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;else if(De.lesseq(o,0)){let d=-c/l;return Mx(d)?[d]:[]}else{let d=Math.sqrt(u);s=(-l-d)/(2*o),a=(-l+d)/(2*o);let p=o*2;if(De.lesseq(s,1)&&De.greatereq(s,0)){let f=Number.NEGATIVE_INFINITY;for(;De.neq(s,f);){f=s;let m=p*s+l;s=-(o*s**2+l*s+c-m*s)/m}}if(De.lesseq(a,1)&&De.greatereq(a,0)){let f=Number.NEGATIVE_INFINITY;for(;De.neq(a,f);){f=a;let m=p*a+l;a=-(o*a**2+l*a+c-m*a)/m}}}let h=[];return Mx(a)&&h.push(a),Mx(s)&&h.push(s),h}function eE(e,t){if(e.controls.length===2){let[o,l]=e.controls;St(o,l)||t.push(new te(o,l));return}let i,r;if(e.controls.length===3){let[o,l,c]=e.controls;i=Vx(o,l,c,"x"),r=Vx(o,l,c,"y")}else{let[o,l,c,u]=e.controls;i=zx(o,l,c,u,"x"),r=zx(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(De.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 kz=1e-5,uI=1,Ue=class Ba extends ry{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 te(this.start(),this.end())),this._startToEndL}build1(t){let i=[];return gm(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=De.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=De.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,x){let y=au(g,x);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,x)=>{let y=Math.abs(x);return y<g?y:g},r),r/=2,r<=i&&(r=i),d.forEach((g,x)=>{this.eq(g,0,i)&&s(x/(d.length-1))});let p=new te(new V(0,-r),new V(1,-r)),f=new te(new V(0,r),new V(1,r));for(let g=0;g<d.length-1;g++){let x=new V(g/(d.length-1),d[g]),y=this.less(x.y,0,i)?1:this.greater(x.y,0,i)?2:3;for(let E=0;E<d.length;E++){let T=new V(E/(d.length-1),d[E]),w=this.less(T.y,0,i)?1:this.greater(T.y,0,i)?2:3;y!==w&&(y===1?w===2?(a(new te(x,T),p),a(new te(x,T),f)):a(new te(x,T),p):y===2?w===1?(a(new te(x,T),p),a(new te(x,T),f)):a(new te(x,T),f):w===1?a(new te(x,T),p):a(new te(x,T),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,x)=>g.ext2(x),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,x]=o.clip(.5);g.isInRange(t,i)?(n.push([g,l,(l+c)/2]),x.isInRange(t,i)&&n.push([x,(l+c)/2,c])):n.push([x,(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=uI){let s=Rz.zoomLines(Et.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 te(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>kz&&!(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),x=Math.sqrt(f**2-4*p*m)/(2*p),y=g+x;y>=0&&y<=1&&c.push(Ba.pointOn(y,this.controls));let E=g-x;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=De.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 te(n,a)),n=a,s++}while(n!==i[0]);if(r.length===0)throw Error("buildConverxHull(diff = DoubleKit.eps)");return Et.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)<=De.eps||Math.abs(s)<=De.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(De.greater(m,0)&&De.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=Vx(p,f,m,"x"),c=Vx(p,f,m,"y")}else if(o.length===4){let[p,f,m,g]=o;l=zx(p,f,m,g,"x"),c=zx(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;)De.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=Mz(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),x=d.sub(h).mul(3),y=h,E=o*m.x+l*m.y,T=o*g.x+l*g.y,w=o*x.x+l*x.y,b=o*y.x+l*y.y+c,C=Math.sqrt(1/(E**2+T**2));E*=C,T*=C,w*=C,b*=C,r=Bz(E,T,w,b)}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())}},A3=class z0{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]=V.ORIGIN,this.textOffsetCache[1]=new V(0,-.5),this.textOffsetCache[2]=new V(0,-1),this.textOffsetCache[3]=new V(-.5,0),this.textOffsetCache[4]=new V(-.5,-.5),this.textOffsetCache[5]=new V(-.5,-1),this.textOffsetCache[6]=new V(-1,0),this.textOffsetCache[7]=new V(-1,-.5),this.textOffsetCache[8]=new V(-1,-1)}static getCache(){return z0.instance==null&&(z0.instance=new z0),z0.instance}};A3.instance=null;var C3=A3,te=class fp extends ry{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(De.eq(this.distance(t),0)){let i=new fp(this._start,t);return i._a=this._a,i._b=this._b,i._c=this._c,i}return new fp(this._start,t)}get midPoint(){return this._start.add(this._end).mul(.5)}toBezier(){return new Ue([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 V(this._start.x+r,this._start.y+i),a=new V(this._end.x+r,this._end.y+i);return new fp(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=C3.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 xt(t[0],t[1],t[2],t[3])}return this.__bbox}multiply3(t){return new fp(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 hc(i,r)||hc(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=Et.build5([u,-l,u,l,h,l,h,-l]):c=Et.build5([u,l,u,-l,h,-l,h,l]):r===0?c=Et.build2([Te.build3(new V(u,0),-90,-180,l,l),Te.build3(new V(h,0),90,-180,l,l)]):c=Et.build2([Te.build3(new V(u,0),90,180,l,l),Te.build3(new V(h,0),-90,180,l,l)]);let d=Math.atan2(a,s),p=he.rotate(d).translate1(n);return c.asClose().multiply3(p)}points(t){return[this._start,this._end]}mirrorY(t){return new fp(this.start().mirrorY(t),this.end().mirrorY(t))}reverse(){return new fp(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 V(-f,p).normalize(),g=p+m.x*i/2,x=f+m.y*i/2,y=g*g+x*x,E=c*c+u*u,T=h*h+d*d,w=Math.abs(c*f-u*p)/2,b=Math.sqrt(p*p+f*f)*i/4;if(w<=b&&E<=y&&T<=y){if(l)return!0;{let C=new V(n,s).sub(o).normalize(),A=new V(n,s).sub(a).normalize(),R=new V(m.x,m.y).cross(C),O=new V(m.x,m.y).cross(A);return R>=0&&O<=0}}else if(l){let C=i/2;return E<=C*C?!0:T<=C*C}else return!1}isParallel(t,i=!1){let r=De.eq(Math.abs(this.direct.cross(t.direct)),0),n=!i||De.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 Fz(e,t=.05){if(e.length<3)return e.slice();let i=e.slice(0,1),r=(s,a,o)=>yz(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 Gz=tz(iz());function D3(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 Uz=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()}},Yz=new Uz,Et=class Mn{constructor(t,i){this.primitives=t,this.__bbox=i}static calcBBox(t){return Yz.calcBBox(t)}static build1(t){let i=[],r=null;return Ux(t,(n,s)=>{let a=s.start();return r!==null&&!a.equals(r)&&i.push(new te(r,a)),i.push(s),r=s.end(),!0}),i.length===0&&r!=null&&i.push(new te(r,r)),new Mn(i)}static build2(t){return Mn.build1($v(t))}static build3(t){let i=[],r=null;return Ux(t,(n,s)=>(r!==null&&i.push(new te(r,s)),r=s,!0)),new Mn(i)}static build4(t){return this.build3($v(t))}static build5(t){let i=[];for(let r=0;r<t.length;r+=2)i.push(new V(t[r],t[r+1]));return this.build4(i)}static build6(t){return Mn.build4([t.LL(),t.LR(),t.UR(),t.UL(),t.LL()])}static build7(t){return new Mn(t)}static build8(t){let i=new V(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 V(l[1],l[2]),n.push(Te.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 V(l[0],l[1]),n.push(new te(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 V(l[0],l[1]),u=new V(l[2],l[3]);r=new V(l[4],l[5]),n.push(new Ue([i,c,u,r])),i=r,o+=7;break}default:throw new Error("invalid rawData")}return Mn.build2(n)}static buildBBox(t,i=0){return i===1?Mn.build5([t.minX,t.minY,t.maxX,t.minY,t.maxX,t.maxY,t.minX,t.maxY,t.minX,t.minY]):Mn.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],x=m.sub(d).normalize().cross(g.sub(d).normalize());if(De.neq(x,0)){if(h===!0){if(x<0){p.length=0;break}}else if(h===!1){if(x>0){p.length=0;break}}else h=x>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=Gz.default(a,o),c=[];for(let u=1;u<a.length;u+=2)c.push(new V(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){Mn.triangulate([this],(...n)=>{n.forEach(s=>i(s))},t,r)}mirror(){let t=[];return this.primitives.forEach(i=>{if(i instanceof te)i=new te(i.start().mirror(),i.end().mirror());else if(i instanceof Te)i=i.mirror();else if(i instanceof Ue){let r=i.controls.map(n=>n.mirror());i=new Ue(r)}else throw new Error("bug");t.push(i)}),new Mn(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 te){let s=n.start().round(t),a=n.end().round(t);i[r]=new te(s,a)}else if(n instanceof Ue){let s=n.controls.map(a=>a.round(t));i[r]=new Ue(s)}else if(n instanceof Te){let s=n.start().round(t),a=n.end().round(t),o=n.sweepAngle;i[r]=Te.build5(s,a,o)}}return new Mn(i,this.__bbox)}simplify(t=.05){let i=[],r=!1,n=[],s=this.closed();if(this.primitives.length<=1)return Mn.build2(this.primitives);let a=()=>{if(n.length>2){let l=Fz(n,t);for(let c=1;c<l.length;c++)i.push(new te(l[c-1],l[c]))}else i.push(new te(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 te?(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 Mn(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 te){if(n.end().equals1(n.start()))continue;if(i&&(n.end().equals1(i.start())||bz(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 te)i+=(a.x+s.x)*(a.y-s.y);else if(n instanceof Te)i+=(a.x+s.x)*(a.y-s.y),i+=Math.PI*n.rx2*n.sweepAngle/180-V.normal(n.center,n.start(),n.end());else if(n instanceof Ue){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 te(n,r)),Mn.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 te(n,r)),new Mn(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 te)n=new te(n.end(),n.start());else if(n instanceof Te)n=n.exchangeSweep();else if(n instanceof Ue)n=new Ue(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new Mn(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 te)n=new te(n.end(),n.start());else if(n instanceof Te)n=n.exchangeSweep1();else if(n instanceof Ue)n=new Ue(n.controls.slice().reverse());else throw new Error("bug");t[i]=n}return new Mn(t,this.__bbox)}mirrorY(t){let i=[];return this.primitives.forEach(r=>{if(r instanceof te)r=r.mirrorY(t);else if(r instanceof Te)r=r.mirrorY(t);else if(r instanceof Ue){let n=r.controls.map(s=>s.mirrorY(t));r=new Ue(n)}else throw new Error("bug");i.push(r)}),new Mn(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 Te?s.points1(t):s.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Te?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 Te?s.points2():s.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Te?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 Mn.build7(i)}bbox(){return this.__bbox==null&&(this.__bbox=Mn.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 Te))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 Mn&&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(hc(s,r)||hc(s.reverse(),r))return!0;n++}return!1}else return hc(this.primitives,t.primitives)}clone(){return Mn.build2(this.primitives)}putItem(t,i){if(!t)return!1;if(t instanceof Mn)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=xt.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=xt.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 te&&t.primitives[0]instanceof te&&Iz([i,r],[n,s])){this.primitives.pop(),t.primitives.shift();let a=[];a.push(new te(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 Te){let c=t.angleD(V.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 Te&&(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(Te.build3(o.center,l,u-l,o.rx,o.ry)),l=u),u+=90;l<c&&a(Te.build3(o.center,l,c-l,o.rx,o.ry))}else{let u=270;for(;u>=c;)u<l&&(a(Te.build3(o.center,l,u-l,o.rx,o.ry)),l=u),u-=90;l>c&&a(Te.build3(o.center,l,c-l,o.rx,o.ry))}}else if(o instanceof Ue){let l=[];eE(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 te)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 Te){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 Ue){if(ZR(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 te)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 Te){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 Ue){if(ZR(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}}},Ix=Math.PI*2,Bse=Math.PI/2,kse=Math.sin(Math.PI/180),Hz=4,Te=class or extends ry{constructor(t,i,r,n,s){super(),this.rx=t,this.ry=i,this.center=r,this.startAngle=n,this.sweepAngle=s,this._start=V.ORIGIN,this._end=V.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 V(this.rx,this.rx).hashCode(),i=t*i+this.center.hashCode(),i=t*i+new V(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){Kr.positive(r),Kr.positive(n);let o=t.equals(i);if(o)return new or(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),x=m*p+g*f,y=-g*p+m*f;r=Math.abs(r),n=Math.abs(n);let E=r*r,T=n*n,w=x*x,b=y*y,C=s===d?-1:1,A=(E*T-E*b-T*w)/(E*b+T*w);A=A<0?0:A;let R=C*Math.sqrt(A),O=R*(r*y/n),M=R*-(n*x/r),k=(l+u)/2,G=(c+h)/2,H=k+(m*O-g*M),q=G+(g*O+m*M),I=(x-O)/r,N=(y-M)/n,v=(-x-O)/r,L=(-y-M)/n,_,B;B=Math.sqrt(I*I+N*N),_=I,C=N<0?-1:1;let U=Jt.toDegrees(C*Math.acos(_/B));B=Math.sqrt((I*I+N*N)*(v*v+L*L)),_=I*v+N*L,C=I*L-N*v<0?-1:1;let z=_/B,W;z<-1?W=Math.acos(-1):z>1?W=Math.acos(1):W=Math.acos(z);let ne=Jt.toDegrees(C*W);!d&&ne>0?ne-=360:d&&ne<0&&(ne+=360),Kr.normal(U),Kr.normal(ne);let me=p*p/E+f*f/T,Ee=t.distance1(i)/2;r<Ee&&n<Ee&&(r*=Math.sqrt(me),n*=Math.sqrt(me));let Se=o?0:Jt.regularD(-U),Fe=o?s?360:0:-ne;return new or(r,n,new V(H,-q),Se,Fe)}}static build2(t,i,r,n,s,a){Kr.positive(n),Kr.positive(s),Kr.normal(i),Kr.normal(r);let o;return i===r?(i=Jt.regularD(i),r=Jt.regularD(r),o=0):(i=Jt.regularD(i),r=Jt.regularD(r),a===1?r<=i&&(r+=360):r>=i&&(i+=360),o=r-i),new or(n,s,t,Jt.regularD(i),o)}static build3(t,i,r,n,s){return Kr.positive(n),Kr.positive(s),Kr.normal(r),new or(n,s,t,Jt.regularD(i),r)}static build4(t,i,r,n,s,a){let o=t.angleD(r),l=i.angleD(r);return or.build2(r,o,l,n,s,a)}static build5(t,i,r){r=Jt.toRadians(r);let n=i.sub(t),s=new V(-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(V.ORIGIN,a),c,u;r>0?(c=1,u=i.add(l.scale(o))):(c=0,u=t.sub(l.scale(o)));let h=Jt.toDegrees(t.angle(u)),d=Jt.toDegrees(i.angle(u));return or.build2(u,h,d,o,o,c)}static buildCircle(t,i,r=0){return or.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=Jt.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(Jt.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 or.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,this.rx,this.ry)}exchangeSweepAndStart(){return or.build1(this.end(),this.start(),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}exchangeSweep1(){return or.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)?or.build3(this.center.mirrorY(),0,360,this.rx,this.ry):or.build1(i.mirrorY(t),r.mirrorY(t),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}mirror(t=V.ORIGIN){let i=this.start(),r=this.end();return i.equals(r)?or.build3(this.center.mirror(t),0,360,this.rx,this.ry):or.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=bm.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(he.ROT_90)?r=Jt.regularD(this.startAngle+90):t.equals(he.ROT_N90)?r=Jt.regularD(this.startAngle-90):r=Jt.transformD(this.startAngle,t),or.build3(this.center.multiply3(t),r,i,t.iScale*this.rx,t.iScale*this.ry)}angleIsInArc(t){return t=Jt.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=Jt.toRadians(this.sweepAngle)/2,n=4/3*(1-Math.cos(r))/Math.sin(r)*this.rx;return new Ue([t,t.add(new V(n,0).multiply3(he.rotateD(this.startAngle+90))),i.add(new V(n,0).multiply3(he.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(or.build3(n.center,n.startAngle,a,n.rx,n.ry),s),r(or.build3(n.center,n.startAngle+a,a,n.rx,n.ry),s)}else t.push(n)}}buildBBox(){let t=C3.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 xt(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 fm.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 he;o<0&&(o=-o,c=c.multiply3(he.MIRROR_Y)),l<0&&(l=-l,c=c.multiply3(he.MIRROR_X)),o===0&&(o=.001),l===0&&(l=.001),c=c.setOrigin1(this.center);let u,h;switch(r===this.sweep()?(u=or.build3(this.center,this.startAngle,this.sweepAngle,s,a),h=or.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,o,l)):(u=or.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,s,a),h=or.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 Et.build2([u,or.build3(p,m,d,n,n),h,or.build3(f,g,d,n,n)])}default:return Et.build2([u,h])}}points2(){let t=Math.ceil(Math.abs(this.sweepAngle)/Hz),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/Jt.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/Jt.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 or(this.rx-t,this.ry-t,this.center,this.startAngle,this.sweepAngle):new or(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),or.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new or(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;return i<0?(i=Math.abs(i),or.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new or(i,i,this.center,this.startAngle,this.sweepAngle)}}get bulge(){let t=Math.abs(mz(this.sweepAngle,3))/180*Math.PI;return Math.tan(t/4)}get midPoint(){let t=Jt.toRadians(this.startAngle),i=Jt.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 V(Math.cos(a),Math.sin(a)).mul(s))}else{if(i==t)return n.add(new V(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(s));{let a=(i+Ix-t)/2+t;return n.add(new V(Math.cos(a),Math.sin(a)).mul(s))}}else if(i>t){let a=(t+Ix-i)/2+i;return n.add(new V(Math.cos(a),Math.sin(a)).mul(s))}else{if(i==t)return n.add(new V(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(s));{let a=(t-i)/2+i;return n.add(new V(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=Jt.regularD(this.startAngle),r=Jt.regularD(this.sweepAngle),n=Jt.regularD(t.startAngle),s=Jt.regularD(t.sweepAngle);return hc([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(hc([r,i],[s,n])||hc([Jt.regularD(i+r)],[n]))}equals1(t){let i=Jt.regularD(this.startAngle),r=Jt.regularD(this.sweepAngle),n=Jt.regularD(t.startAngle),s=Jt.regularD(t.sweepAngle);return hc([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(hc([r,i],[s,n])||hc([Jt.regularD(i+r)],[n]))}inArea(t,i){let r=t.x,n=t.y,s=this.center,a=this.rx,o=Jt.toRadians(this.startAngle);this.sweep()==0&&(o=Jt.toRadians(this.endAngle()));let l=Jt.toRadians(this.endAngle());this.sweep()==0&&(l=Jt.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+=Ix),o<=l&&p>=o&&p<=l||o>l&&(p>=o&&p<=Ix||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 V(s.x+Math.cos(o)*f,s.y+Math.sin(o)*f),g=new V(s.x+Math.cos(l)*f,s.y+Math.sin(l)*f),x=r-m.x,y=n-m.y,E=r-g.x,T=n-g.y;return x*x+y*y<=i*i/4?!0:E*E+T*T<=i*i/4}}isCircle(){return(De.eq(Math.abs(this.sweepAngle),360)||this._start.equals1(this._end))&&this.rx==this.ry}reverse(){return or.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 te(this.center,this.center);if(i<De.eps){i=Math.abs(i);let r=or.build3(this.center,this.startAngle-180,this.sweepAngle,i,i);return r.area()<1e-5?new te(r.start(),r.end()):r}return new or(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;if(i===0)return new te(this.center,this.center);if(i<De.eps){i=Math.abs(i);let r=or.build3(this.center,this.startAngle-180,this.sweepAngle,i,i);return r.area()<1e-5?new te(r.start(),r.end()):r}return new or(i,i,this.center,this.startAngle,this.sweepAngle)}}},P3=new ArrayBuffer(24),Nv=new Float64Array(P3),nm=new Int32Array(P3),ed=class cc{static normal(t,i,r){let n=i.sub(t),s=r.sub(i);return n.cross(s)}static random(){return new cc(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=Kr.normal(t),this.y=Kr.normal(i),this.z=Kr.normal(r),Nv[0]=t,Nv[1]=i,Nv[2]=r,this.hashed=nm[0]^nm[1]^nm[2]^nm[3]^nm[4]^nm[5]}isNormalized(){return De.eq(this.length(),1)}isZeroVector(){return this.x===0&&this.y===0&&this.z===0}hashCode(){return this.hashed}equals(t){return t instanceof cc?t.x===this.x&&t.y===this.y&&t.z===this.z:!1}cross(t){return new cc(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 cc(this.x/t,this.y/t,this.z/t)}sub(t){return new cc(this.x-t.x,this.y-t.y,this.z-t.z)}add(t){return new cc(this.x+t.x,this.y+t.y,this.z+t.z)}scale(t){return new cc(this.x*t,this.y*t,this.z*t)}neg(){return new cc(-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 cc(i/s,r/s,n/s):new cc(i,r,n)}rotate(t,i){return this.multiply4(w3.rotateAxis(t,i))}toVector2(){return new V(this.x,this.y)}};ed.ORIGIN=new ed(0,0,0),ed.X_UNIT_VECTOR=new ed(1,0,0),ed.Y_UNIT_VECTOR=new ed(0,1,0),ed.Z_UNIT_VECTOR=new ed(0,0,1);var pr=class cm{static build(t){return t instanceof Et?new cm([new $r([t])]):t instanceof $r?new cm([t]):t}static buildByPolygon(t){return t?new cm([t]):new cm([])}static buildByStroke(t,i,r=1,n){return this.buildByPolygon($r.buildByStroke(t,i,r,uI,n))}static buildCircle(t,i){return this.buildByPolygon($r.buildCircle(t,i))}static buildRect(t){return this.buildByPolygon($r.buildRect(t))}static buildBBox(t){return this.buildByPolygon($r.buildBBox(t))}constructor(t){this.items=t.slice()}multiply3(t){return new cm(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())}},Fs=class _l{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 _l(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 _l(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15);if(i==6)return new _l(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 _l(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 _l(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15,i);if(t.length==6)return new _l(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 _l(t.r,t.g,t.b,i)}static of7(t){return t==null?null:_l.of3(t)}constructor(t,i,r,n=1){this.r=Kr.positiveOr0(t),this.g=Kr.positiveOr0(i),this.b=Kr.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 _l(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 _l(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 _l(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}};Fs.WHITE=new Fs(1,1,1,1),Fs.BLACK=new Fs(0,0,0,1),Fs.RED=new Fs(1,0,0,1),Fs.GREEN=new Fs(0,1,0,1),Fs.BLUE=new Fs(0,0,1,1),Fs.Gray=Fs.of3("#9966ff"),Fs.Silver=Fs.of3("#D2D2D2"),Fs.Golden=Fs.of3("#DCAA14"),Fs.Pink=Fs.of3("#ffaec9");var Ui=Fs,s3=!1,_3=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(s3){let r=new V(e.getX(i),i),n=new V(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(s3){let r=new V(e.getX(i),i),n=new V(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)}},Z0=class extends _3{constructor(e){super(),this.plGrps=new Array,this.debug=e}onPolylineGroup(e,t){this.plGrps.push(e)}},ny=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}},jz=e=>e!==0;var Vz=new class extends ny{decide1(e){return e[0]||e[1]}}(2),Bx=new class extends ny{decide1(e){return e[0]&&!e[1]}}(2),kx=new class extends ny{decide1(e){return e[0]&&e[1]}}(2),Mv=new class extends ny{decide1(e){return e[0]&&!e[1]||!e[0]&&e[1]}}(2),xm=class um{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 te||i.distance2(r)<1e-6)return new te(i,r);if(t instanceof Te){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 Te.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))&&(Zz(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=um.rebuild(this.shape,this.end,this.start),r=new um(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=um.rebuild(this.shape,this.end,this.start),r=new um(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 um?!(this.polyGrp!==t.polyGrp||this.polyIndex!==t.polyIndex):!1}bbox(){return this._bbox}toString(){return fm.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 zz(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 Xz(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 sm=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=xt.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")}},ty=class{constructor(e){this.changed=!1,this.root=new sm,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 sm,this.itemList.length=0}flushWhenNeed(){if(this.changed){let e=new Array;for(let t of this.itemList)e.push(new sm(t));for(;;){let t=this.organize(e);if(t.length>1)e=t;else break}this.root=new sm(e),this.changed=!1}}organize(e){yp(e,Xz,0,e.length);let t=e.length,i=[];for(let r=0;r<t;)if(r+this.capacity2<=t){let n=r+this.capacity2;yp(e,zz,r,n);for(let s=r;s<n;s+=this.capacity){let a=new sm(e.slice(s,s+this.capacity));i.push(a)}r=r+this.capacity*this.capacity}else{let n=new sm(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 Bv(e,t){Wz(e.iterator(),t)}function Wz(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var Ax=new Error("list is empty"),Cx=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}},qz=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")}},Jz=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")}},mp=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 Ax;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw Ax;return this.remove(e),e.item}addLast(e){return this.first===null||this.last===null?(this.first=new Cx(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 Cx(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 Ax;return this.first.item}getLast(){if(this.last===null)throw Ax;return this.last.item}insertAfter(e,t){let i=new Cx(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new Cx(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 qz(this.first)}listIterator(){return new Jz(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 kv(e){throw new Error("")}var Dx=class{constructor(e,t){this.node1=null,this.node2=null,this.key=e,this.value=t}},Kz=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},$z=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},Xx=class{constructor(){this.innerList=new mp,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 Dx(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 Dx){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 mp;return n.node2=s.add(n),r.node2=s.add(r),this.innerMap[i]=s,null}}if(n instanceof mp){let s=null;return Bv(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 kv(n)}get(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof Dx)return i.key.equals(e)?i.value:null;if(i instanceof mp){let r=null;return Bv(i,(n,s)=>s.key.equals(e)?(r=s.value,!1):!0),r}return kv(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 Dx)return i.key.equals(e)?(this.delete(i),i.value):null;if(i instanceof mp){let r=null;return Bv(i,(n,s)=>s.key.equals(e)?(r=s.value,this.delete(s),!1):!0),r}return kv(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 Kz(this.innerList.iterator())}values(){return new $z(this.innerList.iterator())}entries(){return this.innerList.iterator()}},ym=class{constructor(){this.innerMap=new Xx}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)}}},a3=fa.funcCopy(yp);function Zz(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 te)i=xz(e.shape,t);else if(e.shape instanceof Te)i=Ez(e.shape,t);else throw new Error("not supported operation");return i}var Fx=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 ty(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));a3(t,V.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 V(n.x+(r.x-n.x)*2,n.y+(r.y-n.y)*2);a3(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=xm.rebuild(e.shape,a,o);l instanceof Te&&Math.abs(l.sweepAngle)>190&&(l=new te(a,o));let c=new xm(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 ym;for(let i of this.sides){t.add(i);let r=i.bbox().extendOfSize(1e-5),n=i.shape instanceof te;for(let s of e.search(r))if(!t.contains(s)){let a=s.shape instanceof te;if(!(n&&a&&i.next!==null&&i.previous!==null&&(i.next.equals(s)||i.previous.equals(s)))){let o=bo(i.shape,s.shape);for(let l=0;l<o;l+=2){let c=new V(se[l],se[l+1]);i.inters.push(c),s.inters.push(c),this.event.onIntersect(c,i,s)}}}}}}},Qz=class L3{constructor(t){this.sides=new ym,this.others=new ym,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 gm(this.sides,(i,r)=>(t.push(r.shape),!0)),Et.build2(t).asClose()}hashCode(){return this.id}equals(t){return t!=null&&t instanceof L3?this.id===t.id:!1}},O3=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 te(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 te)this.addSide(n,t);else if(r&&n instanceof Te&&n.rx===n.ry)this.addArc(n,t);else{let s=null;for(let a of n.points(i))s!=null&&this.addSide(new te(s,a),t),s=a}return this.completeGroup(t)}addArc(e,t){let i=e.sweepAngle,r=Jt.regularD(e.startAngle),n=r+i;if(i>0){let s=90;for(;s<=n;)s>r&&(this.addSide(Te.build3(e.center,r,s-r,e.rx,e.ry),t),r=s),s+=90;r<n&&this.addSide(Te.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(Te.build3(e.center,r,s-r,e.rx,e.ry),t),r=s),s-=90;r>n&&this.addSide(Te.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 te(this.prevSide.end,i),t),r=new xm(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++)):(r=new xm(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++),this.firstSide=r),this.prevSide=r,this.sides.push(r)}},R3=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())&&De.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}},Wx=new Error,o3=new class extends ny{decide1(e){return e[0]&&e[1]}}(2),eX=new class extends _3{onPolylineGroup(e,t){throw Wx}onSegment(e,t,i,r,n,s){throw Wx}},tX=class{constructor(e,t){this.rtree=e,this.level=t}},iX=class N3 extends Fx{static isIntersect(t,i,r=Zx.DUMMY){let n=new N3(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 O3(!1),o3.rule,t,eX)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=o3.weight(i);for(let s of t)this.addPolyline(s,r);let n=this.buildRTree();return this.sides.length=0,new tX(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===Wx)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,bo(r.shape,s.shape)>0)throw Wx}}sweep(t,i,r){let n=xt.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),yp(s,(o,l)=>o.getX(r)-l.getX(r),0,s.length);let a=new R3(this.rule,this,r);for(let o of s)a.onEp(o)}},Nr=class Ju{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 Ux(t,(r,n)=>(i.push(n),!0)),new Ju(i)}static build2(t){let i=t.map(r=>Et.build8(r));return new Ju(i)}static combinePolylineGroupArr(t){let i=[];for(let r of t)i=i.concat(r.items);return new Ju(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 Ju(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 Ju?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;iX.isIntersect(new Ju([a]),new Ju([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 Ju(i)}},rX=fa.funcCopy(yp),nX=fa.funcCopy(yp),sX=fa.funcCopy(yp);function aX(e){return new Array}function oX(e,t){let i=new Z0(!1),r=new Q0(e,Zx.DUMMY,i);for(let n of t)r.addPolyline(n);return r.simplify(),i.plGrps}var Q0=class extends Fx{constructor(e,t,i){super(new O3(!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,rX(t,Fx.sortByBBoxMinY,0,t.length);let r=new mp;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;De.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(De.less(s.bbox().minY,t))De.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 R3(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),x=Math.min(s,m);l=this.compareBySweep(t,u,(g+x)/2)}let p=u.shape;if(p instanceof te&&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 De.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(!De.eq(r,n))return r-n;if(e.shape instanceof te)return t.shape instanceof te?this.getLineAngle(t.shape)-this.getLineAngle(e.shape):-this.compareArcLine(t.shape,e.shape,i);if(t.shape instanceof te)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 De.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(he.ROT_N90),a=n.start.multiply3(he.ROT_N90),o=n.end.multiply3(he.ROT_N90);n=new xm(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(he.ROT_90),n=e.start.multiply3(he.ROT_90),s=e.end.multiply3(he.ROT_90),a=new xm(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 Te){if(t&&i.rx<=t)return!1}else if(i instanceof te&&t&&i.length()<=t)return!1}return!0}connectSides(){let e=new Xx,t=new ty(10);for(let s of this.finalSides)e.computeIfAbsent(s.start,aX).push(s),t.add(s.start);let i=0,r=new ym,n=new Array;for(let s of this.finalSides)if(!r.contains(s)){let a=new ym,o=s.start,l=new mp;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 Qz(t);gm(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 Xx;for(let r in this.sideGroups){let n=this.sideGroups[r];gm(n.sides,(s,a)=>(a.polyGrp!=-2&&t.put(a,a),!0))}let i=new ym;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;gm(l.others,(h,d)=>{let p=t.get(d);return p!=null&&c.push(p.finalGrp),!0}),nX(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());sX(o,Fx.sortByBBoxAreaDesc,0,o.length),this.event.onPolylineGroup(new Nr(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}},lX=class{constructor(){this.points=[],this.lines=[],this.arcs=[],this.beziers=[],this.listText=[],this.fonts=[]}addPt(e,t=!0){if(e instanceof te)this.lines.push(e);else if(e instanceof Te)this.arcs.push(e);else if(e instanceof Ue)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,Jt.toRadians(a.startAngle),Jt.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}}},eI=class M3{constructor(t){this.map=new Xx,this.bus=t}initColor(t){return this.map.computeIfAbsent(t,()=>new lX)}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 M3(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 V)this.point(t,i);else if(t instanceof xt)this.bbox(t,i);else if(t instanceof ry)this.primitive(t,i);else if(t instanceof Et)this.polyline(t,i);else if(t instanceof $r)this.polygon(t,i);else if(t instanceof pr)this.group(t,i);else if(t instanceof Nr)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 te(new V(t.maxX,t.maxY),new V(t.maxX,t.minY)),i),this.primitive(new te(new V(t.maxX,t.maxY),new V(t.minX,t.maxY)),i),this.primitive(new te(new V(t.minX,t.minY),new V(t.maxX,t.minY)),i),this.primitive(new te(new V(t.minX,t.minY),new V(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||"==================")}};eI.colorBuffersMap=[[!0,Ui.BLUE],[!0,Ui.GREEN],[!0,Ui.WHITE],[!0,Ui.RED],[!0,Ui.Golden],[!0,Ui.Gray]],eI.t1=0;var sy=eI,cX=0,ay=class tI{constructor(t,i){this.inters=[],this.shape=t,this.start=t.start(),this.end=t.end(),this.judgeOverlapMap=new Map,i&&(this.id=cX++)}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 Te){let a=this.shape.rx,o=new V((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 V(l.x+Math.cos(c)*a,l.y+Math.sin(c)*a)}else{if(this.shape instanceof te)return new V((i+n)/2,(r+s)/2);if(this.shape instanceof Ue){let a=this.shape.getPercent(t,Ft);return Ue.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=Qx-s),s}sortInters(){if(this.shape instanceof Te){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 tI.finalAngle(i,a,r)-tI.finalAngle(i,o,r)<=0?-1:1})}else if(this.shape instanceof te){let t=this.start,i=this.end,r=new V(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 Ue){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(Et.build7(o))}),i.push(new $r(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(Et.build7(o))}),i.push(new $r(n))}),new pr(i)}static rebuild(t,i,r){let n;if(t instanceof te||i.distance2(r)<1e-6)n=new te(i,r);else if(t instanceof Te)n=Te.build2(t.center,i.angleD(t.center),r.angleD(t.center),t.rx,t.ry,t.isCCW?1:0);else if(t instanceof Ue){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 Et.build7(t.map(i=>i.shape))}bbox(){return this.shape.bbox()}};function ma(e,t,i){if(e instanceof Te&&t instanceof Te)return dX(e,t);if(e instanceof Te&&t instanceof te)return u3(e,t);if(e instanceof te&&t instanceof Te)return c3(e,t);if(e instanceof te&&t instanceof te)return gp(e,t);if(e instanceof Ue&&t instanceof te)return e.controls.length===2||eh(e)?gp(new te(e.start(),e.end()),t):B3(e,t);if(e instanceof te&&t instanceof Ue)return t.controls.length===2||eh(t)?gp(e,new te(t.start(),t.end())):iI(e,t);if(e instanceof Te&&t instanceof Ue)return t.controls.length===2||eh(t)?u3(e,new te(t.start(),t.end())):uX(e,t);if(e instanceof Ue&&t instanceof Te)return e.controls.length===2||eh(e)?c3(new te(e.start(),e.end()),t):hX(e,t);if(e instanceof Ue&&t instanceof Ue)return hI(e,t);throw new Error("not support")}function am(e,t){return kt(e,t.start()).dot(kt(t,t.start()))<=0?!1:ma(e,t).state<=2}function Fv(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(),x=f.getShape();if(g instanceof te&&x instanceof te){let y=m?gp(g,x).state:d.get(gp(x,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 ay(p)),d=h[h.length-1];return h.forEach(p=>{d.connect(p),d=p}),h}}function l3(e,t){let i=e.end().distance2(t.center);if(i>(t.rx+Ft)**2||i<(t.rx-Ft)**2||!(St(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>Ft&&ru(e,s))&&!(r-n>Ft&&e.rx+t.rx-r>Ft&&ru(e,s+180)):!(r-n>Ft&&ru(e,s))&&!(e.rx+t.rx-r>Ft&&ru(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 ru(e,s)?!1:r-n<=Ft?!0:!ru(e,s+180)}}function uX(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 hX(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||eh(e))return t.controls.length===2||eh(t)?gp(new te(e.start(),t.end()),new te(t.start(),t.end())):iI(new te(t.start(),e.end()),t);if(t.controls.length===2||eh(t))return B3(rI(e,t.start()),new te(t.start(),t.end()));let i=rI(e,t.start());if(eh(i))return iI(new te(t.start(),e.end()),t);let r=Fv(i,t),n=Fv(t,i);if(!r&&!n){let s=Pz(i,t);if(s.havOverlap){let a=s.havOverlap!==2,o=s.havOverlap!==1;return th(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 V(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(Fv(m,g)){let x=kt(e,d).cross(kt(t,d));if(x===0){o=i.end(),l=t.end();break}return{state:x<0?3:4}}a()}return(!o||!l)&&(o=mm(i.controls,i.controls[0],t),l=mm(t.controls,i.controls[0],i)),{state:o.sub(i.controls[0]).cross(l.sub(i.controls[0]))>0?4:3}}}return th(e,t,r,n)}function B3(e,t){let i=rI(e,t.start());if(eh(i))return gp(new te(i.start(),i.end()),t);let r=F3(i,t),{isIn:n,bezierIsInLeft:s}=k3(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=Ue.pointOn(l,e.controls);if(iy(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 th(i,t,r,n)}function iI(e,t){let{isIn:i,bezierIsInLeft:r}=k3(e,t),n=F3(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=Ue.pointOn(a,t.controls);if(iy(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 th(t,e,i,n)}function dX(e,t){let i=l3(pI(e,t.start()),t),r=l3(t,e);if(!i&&!r){let n=pc(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 th(e,t,i,r)}function c3(e,t){let i=dc.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)&&(St(e.end(),t.end())||dI(t,e.end())),o=G3(t,e);if(!a&&!o){let l=e.distance2(t.center);return l<=ga?{state:n.cross(pc(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 th(t,e,a,o)}function ru(e,t){return t=Jt.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 St(e.end(),t)||St(e.start(),t)||ru(e,t.angleD(e.center))}function k3(e,t){let i=e.panDistance(Ft),r=e.panDistance(-Ft),n=h3(t,i),s=h3(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 te(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=Ue.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 F3(e,t){if(iy(t,e.end())>ga||e.getToLineMaxDis2(t)>ga)return!1;let i=fX(t,ga);return e.getToLineMaxDis2(i)<=(t.length()+Ft)**2}function G3(e,t){let i=t.end().angleD(t.start()),r=pX(t,e.end());if(r>ga)return!1;if(ru(e,i+90)){if(dc.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(ru(e,i-90)){if(dc.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&&(St(e.end(),t.end())||nI(t,e.end()))}var U3=(Ft*2)**2;function pI(e,t){if(St(e.end(),t))return Te.build3(e.center,e.endAngle(),0,e.rx,e.ry);if(e.start().distance2(t)<U3)return e;let i=Jt.regularD(t.angleD(e.center));if(!ru(e,i))throw new Error("!angleIsInArc(arc, angle)");return Te.build2(e.center,i,e.endAngle(),e.rx,e.ry,e.isCCW?1:0)}function rI(e,t){if(St(e.end(),t))return new Ue([t,t]);if(e.start().distance2(t)<U3)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 u3(e,t){let i=G3(pI(e,t.start()),t),r=t.end().distance2(e.center),n=t.end().sub(t.start()),s=dc.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)&&(St(e.end(),t.end())||dI(e,t.end()));if(!i&&!o){let l=t.distance2(e.center);return l<=ga?{state:n.cross(pc(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 th(t,e,i,o)}function gp(e,t){if(St(e.end(),t.end()))return th(e,t,!0,!0);let i=iy(t,e.end())<=ga&&nI(t,e.end()),r=iy(e,t.end())<=ga&&nI(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 th(e,t,i,r)}function nI(e,t){return dc.foot(e,t).distance2(e.start())<e.end().distance2(e.start())}function th(e,t,i,r){if(i)return r?St(e.end(),t.end())?{state:2}:{state:0}:{state:0};if(r)return{state:1};throw new Error("!end1 && !end2")}function iy(e,t){return(e.a*t.x+e.b*t.y+e.c)**2/(e.a**2+e.b**2)}function pX(e,t){return Math.min(e.distance2(t),dc.foot(e,t).distance2(t))}function fX(e,t){let i=e.panDistance(t),r=e.panDistance(-t);return new te(r.start(),i.start())}function eh(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)}),ou(o,l)}function h3(e,t){let i=bo(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 V(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 iu=.01,mX=270;function Ol(e){let t=iu**2,i=e.end(),r=[],n=[];for(let p=0,f=e.primitives.length;p<f;p++){let m=function(O,M){return O instanceof te&&M instanceof te&&Math.abs(O.direct.cross(M.direct))<De.eps&&O.direct.dot(M.direct)>0||O instanceof Te&&M instanceof Te&&Math.abs(O.rx-M.rx)<=De.eps&&O.center.distance2(M.center)<De.eps&&O.isCCW===M.isCCW},g=function(O){if(Jo(O,iu))n.push(null);else{if(O instanceof te)n.push(O);else if(O instanceof Te&&O.rx===O.ry)h(O,n);else if(O instanceof Ue){let M=[];eE(O,M),M.forEach(k=>{let G=k.start(),H=k.end();u(G,H)||n.push(k)})}else throw new Error("not support!");i=T}},x=function(O){if(O instanceof te)return O.direct.x===0&&O.direct.y===0;if(O instanceof Te)return O.sweepAngle===0;if(O instanceof Ue){let M=new Set(O.controls.map(G=>G.x)),k=new Set(O.controls.map(G=>G.y));return M.size===1&&k.size===1}else throw new Error("not support")},y=e.primitives[p],E=y.start(),T=y.end();if(x(y))continue;u(i,E)||(n.push(new te(i,E)),i=E);let w=(p+1)%f,b=e.primitives[w];for(;m(y,b)&&(w=(w+1)%f,b=e.primitives[w],b!==y););if(w===(p+1)%f){g(y);continue}if(b===y){if(!(y instanceof Te)){if(Math.abs(e.area(.1))<t)return null;throw new Error("simplifyPolyline not support")}let O=y instanceof Te?y.isCCW:e.area(.1)>0;n.length=0;let M=O?180:-180;n.push(Te.build3(y.center,y.startAngle,M,y.rx,y.ry),Te.build3(y.center,y.startAngle+M,M,y.rx,y.ry));break}let C=(()=>{if(y instanceof te)return(O,M)=>{let k=new te(O,M);return Jo(k,iu)?null:[k]};if(y instanceof Te)return(O,M)=>{let k;if(O.equals1(M)?k=Te.build3(y.center,y.startAngle,y.sweep()===1?360:-360,y.rx,y.ry):k=Te.build4(O,M,y.center,y.rx,y.ry,y.sweep()),Jo(k,iu))return null;let G=k.pointOn(k.startAngle+k.sweepAngle/2),H=Te.build4(k.start(),G,y.center,y.rx,y.ry,y.sweep()),q=Te.build4(G,k.end(),y.center,y.rx,y.ry,y.sweep());return Jo(H,iu)||Jo(q,iu)?[k]:[H,q]};throw new Error("not support")})(),A=w===0;if(w<p&&!A&&(A=!C(e.primitives[0].start(),e.primitives[w-1].end()),!A)){let O=C(y.start(),n[0].end());if(O.length===1)n[0]=O[0];else if(O.length===2)n[0]=O[1],n.push(O[0]);else throw new Error("!!!generatorPt");break}p=w===0?f-1:w-1,b=e.primitives[p];let R=C(y.start(),b.end());if(R?(R.forEach(O=>n.push(O)),i=b.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 x=(f+1)%s;if(m=m!=null?m:n[x],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 C=new te(g.end(),m.start());r.push(C);return}let{rebuildPrevPt:T,rebuildNextPt:w,rebuildLinkLine:b}=d3(n[(y-1+s)%s],g,new te(g.end(),m.start()),m,n[(f+2)%s]);T&&w&&(T!==g?(n[(y+s)%s]=T,r[r.length-1]&&(r[r.length-1]=T)):w!==m&&(n[(f+1)%s]=w,r[0]===m&&(r[0]=w)),b&&r.push(b))}}}}}),r.length===0)return null;u(i,r[0].start())||r.push(new te(i,r[0].start()));let a=r[r.length-1];if(r.length===1)return a instanceof Te?Et.build7([Te.build2(a.center,0,180,a.rx,a.ry,a.sweep()),Te.build2(a.center,180,360,a.rx,a.ry,a.sweep())]):a instanceof Ue?Et.build7(a.clip(.5)):null;let o=r.map(p=>new gX(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,x=m.pt,y=x.end();if(!l.isConnected&&!y.equals(g.start())){let E=function(w){l.isConnected=!0,l.pt=g=w,l.next.isVisited=!1},T=function(w){l.isConnected=!0,m.pt=w,m.isVisited=!1,l=m};if(g instanceof te)if(u(y,g.end())){p();continue}else E(new te(y,g.end()));else if(x instanceof te){u(x.start(),g.start())?f():T(new te(x.start(),g.start()));continue}else if(g instanceof Ue)if(u(y,g.end())&&!(g.controls.length!==2&&g.getToLineMaxDis2(g.startToEndL)>=t)){p();continue}else E(new Ue([y,...g.controls.slice(1)]));else if(x instanceof Ue)u(x.start(),g.start())&&!(x.controls.length!==2&&x.getToLineMaxDis2(x.startToEndL)>=t)?f():T(new Ue([...x.controls.slice(0,-1),g.start()]));else if(g instanceof Te&&x instanceof Te)if(Math.abs(Math.abs(g.sweepAngle)-180)<Math.abs(Math.abs(x.sweepAngle)-180)){let w=Te.build5(y,g.end(),g.sweepAngle);if(u(w.start(),w.end())&&!(w.rx>=iu&&Math.abs(w.sweepAngle)>180)){p();continue}else E(w)}else{let w=Te.build5(x.start(),g.start(),x.sweepAngle);u(w.start(),w.end())&&!(w.rx>=iu&&Math.abs(w.sweepAngle)>180)?f():T(w);continue}else throw new Error("not support")}if(kt(g,g.start()).dot(kt(x,x.end()))<0){let E=function(b,C,A,R,O,M){if(l.next===m){l=null;return}let{rebuildLinkLine:k,rebuildPrevPt:G,rebuildNextPt:H}=d3(b,C,A,R,O);G&&H&&(G!==C&&(m.prev.pt=G),H!==R&&(l.next.pt=H),k?M.pt=k:p())},T=function(){l.next===m?l=null:(l.next.connect(m.prev),l=l.next,l.isConnected=!1,l.isVisited=!1)},w=ma(x.reverse(),g).state;if(w===0){let b=p3(g,x.start(),g.end());if(d(b)){let C=m.prev.pt,A=l.next.pt;if(kt(A,A.start()).dot(kt(C,C.end()))>=0){if(T(),!l)break;continue}if(E(m.prev.prev.pt,C,b instanceof te?b:new te(b.start(),b.end()),A,l.next.next.pt,l),!l)break}else l.pt=b;f();continue}else if(w===1){let b=p3(x,x.start(),g.end());if(d(b)){let C=m.prev.pt,A=l.next.pt;if(kt(A,A.start()).dot(kt(C,C.end()))>=0){if(T(),!l)break;continue}if(E(m.prev.prev.pt,C,b instanceof te?b:new te(b.start(),b.end()),A,l.next.next.pt,m),!l)break}else m.pt=b;p();continue}else if(w===2){if(T(),!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 Te?(u(p.start(),p.end())?r[0]=Te.buildCircle(p.center,p.rx,p.sweep()):r.push(new te(p.end(),p.start())),Et.build7(r)):p instanceof Ue?(u(p.start(),p.end())||r.push(new te(p.end(),p.start())),Et.build7(r)):null}if(e=Et.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)>mX){let m=p.sweepAngle/2;h(Te.build3(p.center,p.startAngle,m,p.rx,p.ry),f),h(Te.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 Te&&p.rx>=iu&&Math.abs(p.sweepAngle)>180||p instanceof Ue&&p.controls.length!==2&&p.getToLineMaxDis2(new te(p.start().add1(1,0),p.end()))>=t)}}function Jo(e,t){if(!e)return!0;let i=e.start(),r=e.end();if(i.distance2(r)<t**2)if(e instanceof Te){if(!(e.rx>=t&&Math.abs(e.sweepAngle)>180))return!0}else if(e instanceof Ue){if(!(e.controls.length!==2&&e.getToLineMaxDis2(new te(e.start().add1(1,0),e.end()))>=t))return!0}else return!0;return!1}function om(e){if(e.direct.x===0&&e.direct.y===0)throw Error("getEndOfExtendLine(line: Line, distance: number)");let t=Math.abs(iu-e.length())+De.eps,i={x:e.direct.normalize().x*t,y:e.direct.normalize().y*t},r=e.end();return new V(r.x+i.x,r.y+i.y)}function d3(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(ou(u,-1)&&ou(p,-1)){let f=i.center();s(f),i=null}else u>p?a():o()}}function s(l){let c;if(t instanceof te)c=new te(t.start(),l);else if(t instanceof Ue)c=new Ue([...t.controls.slice(0,-1),l]);else if(t instanceof Te)c=Te.build5(t.start(),l,t.sweepAngle);else throw new Error("not supported");t=Jo(c,Ft)?null:c;let u;if(r instanceof te)u=new te(l,r.end());else if(r instanceof Ue)u=new Ue([l,...r.controls.slice(1)]);else if(r instanceof Te)u=Te.build5(l,r.end(),r.sweepAngle);else throw new Error("supported");r=Jo(u,Ft)?null:u}function a(){if(t instanceof te){let l=om(i.reverse());i=new te(l,i.end());let c=new te(t.start(),l);t=Jo(c,Ft)?null:c}else if(t instanceof Ue){let l=om(i.reverse());i=new te(l,i.end());let c=new Ue([...t.controls.slice(0,-1),l]);t=Jo(c,Ft)?null:c}else if(t instanceof Te){let l=om(i.reverse());i=new te(l,i.end());let c=Te.build5(t.start(),l,t.sweepAngle);t=Jo(c,Ft)?null:c}else throw new Error("not supported")}function o(){if(r instanceof te){let l=om(i);i=new te(i.start(),l);let c=new te(l,r.end());r=Jo(c,Ft)?null:c}else if(r instanceof Ue){let l=om(i);i=new te(i.start(),l);let c=new Ue([l,...r.controls.slice(1)]);r=Jo(c,Ft)?null:c}else if(r instanceof Te){let l=om(i);i=new te(i.start(),l);let c=Te.build5(l,r.end(),r.sweepAngle);r=Jo(c,Ft)?null:c}else throw new Error("not supported")}return{rebuildPrevPt:t,rebuildNextPt:r,rebuildLinkLine:i}}function p3(e,t,i){if(e instanceof te||t.distance2(i)<=ga)return new te(t,i);if(e instanceof Te)return Te.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof Ue){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 gX=class{constructor(e){this.pt=e}connect(e){this.prev=e,e.next=this}};function qx(e){let t=Ep(),i;if(e instanceof Et){let r=Ol(e);if(r===null)return null;i=r}else if(e instanceof $r){let r=e.items.map(n=>qx(n)).filter(n=>n!==null);if(r.length===0)return null;i=new $r(r)}else{let r=e.items.map(n=>qx(n)).filter(n=>n!==null);if(r.length===0)return null;i=new pr(r)}return Ll.preprocessPolyline+=su(t),i}var Ll={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 Ep(){return{timeIndex:Object.assign({},Ll),start:performance.now()}}function f3(e){return Object.values(e).reduce((t,i)=>t+i,0)}function su(e){return performance.now()-e.start-(f3(Ll)-f3(e.timeIndex))}function Ss(e,t,i,r){let n=Ui.RED,s=Ui.Golden;function a(){if(!r)return;let d=r.initColor(Ui.Golden);d.addPt(o),d.addPoint(o.end()),r.initColor(Ui.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(ou(h,0))if(o instanceof te)if(l instanceof te){if(De.eq(h,0)&&(c.dot(u)>0?!St(o.end(),l.start()):!St(o.start(),l.start())))throw a(),new Error("line and line");return h<0}else{if(l instanceof Te)return c.cross(l.center.sub(o.start()))<0;if(l instanceof Ue){let d=l.getExtremePoints(o),p=d.length?d[0]:mm(l.controls,o.start());return c.cross(p.sub(o.start()))<0}else throw new Error("not support")}else if(o instanceof Te){if(l instanceof te)return o.isCCW;if(l instanceof Te){if(l.center.equals1(o.center)&&(c.dot(u)>0?!St(o.end(),l.start())&&o.end().sub(l.start()).dot(u)>0:!St(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 Ue)if(l instanceof te){let d=o.getPercent(l.start(),Ft),p=o.clip(d)[1],f=p.getExtremePoints(l);return(f.length?f[0]:mm(p.controls,l.start())).sub(l.start()).cross(u)<0}else if(l instanceof Ue){let d=o.getPercent(l.start(),Ft),p=o.clip(d)[1],f=p.getExtremePoints(new te(l.start(),l.end())),m=l.getExtremePoints(new te(p.start(),p.end())),g=f.length?f[0]:mm(p.controls,l.start()),x=m.length?m[0]:mm(l.controls,l.start()),y=g.sub(l.start()),E=x.sub(l.start());return y.cross(E)<0}else throw Error("not support");else throw new Error("not support");else return h<0}function bp(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Te?pc(s,Jt.toRadians(s.endAngle())):s instanceof Ue?ey(s,1):s.end().sub(s.start()).normalize(),l=kt(a),c=o.dot(l);if(ou(c,-1))return Ss(e,t,!0,n)?Ss(e,i,r,n)&&Ss(t,i,r,n):Ss(e,i,r,n)||Ss(t,i,r,n);{let u=o.scale(-1).angle(V.ORIGIN),h=l.angle(V.ORIGIN);u>h&&(u-=Qx);let d=(u+h)/2,p=new V(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=kt(f);return p.cross(m)<0?Ss(e,i,r,n):Ss(t,i,r,n)}}function Gv(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Te?pc(s,Jt.toRadians(s.endAngle())):s instanceof Ue?ey(s,1):s.end().sub(s.start()).normalize(),l=kt(a),c=o.dot(l);if(ou(c,-1))return Ss(e,t,!0,n)?Ss(e,i,r,n)&&Ss(t,i,r,n):Ss(e,i,r,n)||Ss(t,i,r,n);{let u=o.scale(-1).angle(V.ORIGIN),h=l.angle(V.ORIGIN);u>h&&(u-=Qx);let d=(u+h)/2,p=new V(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,x=ma(g?e.getShape().reverse():e.getShape(),f).state;return x!==3&&x!==4?Ss(e,i,r,n):x===(g?4:3)}else{let g=l.dot(m)<0,x=ma(g?t.getShape().reverse():t.getShape(),f).state;return x!==3&&x!==4?Ss(t,i,r,n):x===(g?4:3)}}}var nu,rd=!1;function Ko(e,t,i,r,n,s,a,o=i.side===t,l=!0,c){return nu=n,rd=s,Y3(H3(e,t,l,c,a,i,o,r),i,o,r,0)}function $u(e,t,i,r,n,s,a,o=r.side===i){nu=n,rd=s;let l=j3(e,t,i,new Map,r,o,a),c=l instanceof Array?-1:1;return Y3(l,r,o,a,c)}function Y3(e,t,i,r,n){for(;e instanceof Array;)n++,e.length===4?e=j3(...e,t,i,r):e=H3(...e,t,i,r);return{...e,existOverlap:n>0}}function H3(e,t,i,r,n,s,a,o){if(Jx===-1){o.initColor(Ui.RED).addPt(e.getShape()),o.initColor(Ui.Golden).addPt(t.getShape()),o.draw();debugger}let l=e.getShape(),c=a?t.getShape().reverse():t.getShape(),u=(l instanceof Te?pc(l,i?c.start().angle(l.center):r?Jt.toRadians(l.endAngle()):void 0):l instanceof Ue?kt(l,i?c.start():r?l.end():l.start()):l.end().sub(l.start())).normalize(),h=(c instanceof Te?pc(c,i?void 0:(r?l.end():l.start()).angle(c.center)):c instanceof Ue?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,ou(f,0))return{state:Ss(e,t,!a,o)?1:0,inter:Zu(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 te&&St(dc.foot(l,c.start()),r?l.end():l.start()))m=!1;else if(l instanceof Te||l instanceof Ue){let g=r?l.reverse():l,x=ma(c,Nz(g,c.start()).reverse()).state;(x===1||x===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=bp(e,e.nextSide,t,!a,o)?1:0:f=bp(e.prevSide,e,t,!a,o)?1:0;return{state:f,inter:Zu(e,t,s,a,i,r,n)}}else return r?{state:Ss(e,e.nextSide,!0,o)?0:1,inter:Zu(e,t,s,a,i,r,n),isReversed:!0}:{state:Ss(e.prevSide,e,!0,o)?0:1,inter:Zu(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)&&!rd){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)&&!rd){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 x=m.length-1;x>=0;x--){let y=m[x];if(!(f.getShape()instanceof Ue)&&!St(g,y.coord))break;if(y===s)return{state:2,inter:Zu(e,t,s,a,i,r,n)}}}if(d===3||d===4)return{state:d===(r?4:3)?1:0,inter:Zu(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 Zu(e,t,i,r,n,s,a){if(rd)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)&&St(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&&St(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,x=u(m.coord);if(g===x&&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 x=g.getBindedInter().side;if(a.get(t).mapSideList.includes(x)||St(g.coord,x.getEnd())&&a.get(t).mapSideList.includes(x.nextSide))return d(g);if(a.has(x)){let y=t.getShape().reverse(),E=kt(y,g.coord).dot(kt(x.getShape(),g.coord))<0,T=E?x.getShape().reverse():x.getShape(),w=ma(y,E?Rv(T,g.coord,T.end()):Rv(T,T.start(),g.coord)).state;if(w===1||w===2)return d(g)}else a.has(x.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&&St(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,x=u(m.coord);if(g===x&&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 x=g.getBindedInter().side;if(a.get(t).mapSideList.includes(x)||St(g.coord,g.getBindedInter().side.getEnd())&&a.get(t).mapSideList.includes(x.nextSide))return d(g);if(!a.has(x)&&a.has(x.prevSide)){let y=t.getShape().reverse(),E=kt(y,g.coord).dot(kt(x.getShape(),g.coord))<0;if(a.has(x.prevSide)){let T=E?x.getShape().reverse():x.getShape(),w=ma(t.getShape(),Rv(T,g.coord,T.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!==(St(p.coord,e.prevSide.getEnd())?e.prevSide:e))return!1;let f;if(n){if(St(p.coord,l.start()))return!0;f=ma(s?o.reverse():o,m(l)).state}else{if(St(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 te)return St(p.coord,g.end())?g:g.cutLine(p.coord);if(g instanceof Te)return Te.build2(g.center,g.startAngle,p.coord.angleD(g.center),g.rx,g.ry,g.isCCW?1:0);if(g instanceof Ue)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,x=i===p,y=i;if(r){let E=i.getIndex()-1;for(;m;){let T=m.inters;for(;E>=0;E--)if(i=T[E],i===p){x||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(nu===0)!i.isInvalid&&(!St(i.coord,p.coord)||i.side===p.side&&i.getBindedInter().side===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(nu===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 T=m.inters;for(;E<T.length;E++){i=T[E];let w=i.getBindedInter();if(i===p){x||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(nu===0)!i.isInvalid&&(!St(i.coord,p.coord)||m===p.side&&(St(w.side.getEnd(),i.coord)?w.side.nextSide:w.side)===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(nu===1){let b=w.side;a.has(m)&&a.get(m).mapSideList.includes(b)&&(i.setIsInvalid(),i.isDealed(),y=i)}}m=m==null?void 0:m.nextSide,E=0}}if(nu===0&&!St(f.coord,p.coord))if(n?a.has(g)?a.get(g).sideIsReversed:s:c){let E=f.getIndex()-1;for(;g;){let T=a.has(g),w=g.inters;for(;E>=0;E--){if(f=w[E],f===p.getBindedInter()){g=null;break}f.isInvalid||!T||(!St(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 T=g.inters,w=a.has(g);for(;E<T.length;E++){if(f=T[E],f===p.getBindedInter()){g=null;break}let b=St(g.getEnd(),f.coord)?a.has(g.nextSide):!1;f.isInvalid||!(w||b)||(!St(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 j3(e,t,i,r,n,s,a){let o=e.getShape(),l=t.getShape(),c=s?i.getShape().reverse():i.getShape(),u=(o instanceof Te?pc(o,c.start().angle(o.center)):o instanceof Ue?kt(o,c.start()):o.end().sub(o.start())).normalize(),h=(l instanceof Te?pc(l,c.start().angle(l.center)):l instanceof Ue?kt(l,c.start()):l.end().sub(l.start())).normalize(),d=u.dot(h);if(ou(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:Zu(t,i,n,s,!0,!1,r)};let x=Ko(e,i,n,a,nu,rd,r.size===0?new Map:r,s);return x.state===2?x:g===4?x.state===0||x.inter!==n?x:Ko(t,i,n,a,nu,rd,r.size===0?new Map:r,s):x.state===1||x.inter!==n?x:Ko(t,i,n,a,nu,rd,r.size===0?new Map:r,s)}else{let p=u.scale(-1).angle(V.ORIGIN),f=h.angle(V.ORIGIN);p>f&&(p-=Qx);let m=(p+f)/2,g=new V(Math.cos(m),Math.sin(m)),x=kt(c).normalize(),y=x.angle(V.ORIGIN),E=p<y&&y<f&&o instanceof te&&l instanceof te&&c instanceof te;if(g.cross(x)<=0){if(u.scale(-1).dot(x)<0){let T;return n.coord.equals1(c.start())?T=kt(o,n.coord).dot(kt(c,n.coord))<0:c instanceof te&&(T=kt(o,o.end()).dot(c.direct)<0),{state:bp(e,t,i,!s,a)?1:0,inter:Zu(e,i,n,s,!0,T,r)}}return E&&o.distance2(c.start())>ga?[t,i,!0,void 0,r]:[e,i,!0,void 0,r]}else return h.dot(x)<=0?{state:bp(e,t,i,!s,a)?1:0,inter:Zu(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 Jx=0;function yX(e,t,i,r){let n=t.getBindedInter(),s=t.side,a=n.side,o=s.getShape(),l=a.getShape();if(r&&(Jx++,Jx===-1)){r.initColor(Ui.RED).addPt(o),r.initColor(Ui.Golden).addPt(l),r.draw();debugger}let c=0,u=!1;if(e===-1){let C=$u(s,s.nextSide,a,n,c,u,r),A=C.state!==0;if(C.state===2){let O=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 b(A,O.dot(M)>0)}let R=$u(s,s.nextSide,a.nextSide,n,c,u,r);return C.state!==R.state?(w(C,R),1):b(A,C.state!==$u(a,a.nextSide,s,t,c,!0,r).state,C.inter,R.inter)}if(e===1){let C=Ko(s,a,n,r,c,u,new Map),A=C.state!==0;if(C.state===2)return b(A,kt(o,t.coord).dot(kt(l,t.coord))>0);let R;if(C.isReversed&&C.existOverlap&&St(C.inter.coord,a.getEnd())&&C.inter.getBindedInter().side!==s){let k=C.inter.getBindedInter().side;if(k===s.nextSide)R={state:bp(s,k,a.nextSide,!0,r)?1:0,inter:n};else if(k===s.prevSide){if(R={state:bp(k,s,a.nextSide,!0,r)?1:0,inter:C.inter},C.state===R.state&&t!==C.inter){let G=kt(l,t.coord),H=kt(a.nextSide.getShape(),t.coord),q=kt(k.getShape(),t.coord);return b(A,G.add(H).dot(q)>0,C.inter,R.inter)}}else R=Ko(s,a.nextSide,n,r,c,u,new Map)}else R=Ko(s,a.nextSide,n,r,c,u,new Map);if(C.state!==R.state)return w(C,R),1;let O=kt(l,t.coord),M=kt(a.nextSide.getShape(),t.coord);if(ou(O.dot(M),-1)){let k=Ss(a,a.nextSide,!0,r);return b(A,C.state!==Ko(a.nextSide,s,t,r,c,!0,new Map,k?!A:A,!1).state,C.inter,R.inter)}else{let k=kt(o,t.coord);return b(A,O.add(M).dot(k)>0,C.inter,R.inter)}}if(!(o instanceof Ue||l instanceof Ue))return 1;let h=kt(o,t.coord),d=kt(l,t.coord),p,f;if(l instanceof te)p=new te(t.coord,l.start()),f=new te(t.coord,l.end());else if(l instanceof Te){let C=t.coord.angleD(l.center);p=Te.build2(l.center,C,l.startAngle,l.rx,l.ry,l.isCCW?0:1),f=Te.build2(l.center,C,l.endAngle(),l.rx,l.ry,l.isCCW?1:0)}else if(l instanceof Ue){let C=l.getPercent(t.coord,Ft);[p,f]=l.clip(C),p=p.reverse()}else throw new Error("not support");let m=h.dot(d)>0,g,x;m?(g=ma(o.reverse(),p).state,x=ma(o,f).state):(g=ma(o,p).state,x=ma(o.reverse(),f).state);let y;g===0?y=Ko(m?s.prevSide:s.nextSide,a,n,r,c,u,new Map,!0,!1,m):g===1?y=Ko(s,a.prevSide,n,r,c,u,new Map,!0,!0,m):g===2?m?y=$u(s.prevSide,s,a.prevSide,n,c,u,r,!0):y=$u(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 b(E,m);let T;if(x===0?T=Ko(m?s.nextSide:s.prevSide,a,n,r,c,u,new Map,!1,!1,!m):x===1?T=Ko(s,a.nextSide,n,r,c,u,new Map,!1,!0,!m):x===2?m?T=$u(s,s.nextSide,a.nextSide,n,c,u,r,!1):T=$u(s.prevSide,s,a.nextSide,n,c,u,r,!1):m?x===3?T={inter:n,state:1}:T={inter:n,state:0}:x===3?T={inter:n,state:0}:T={inter:n,state:1},y.state===T.state)return y.inter===T.inter?(t.setIsInvalid(),0):b(E,m,y.inter,T.inter);return w(y,T),1;function w(C,A){let R=C.state!==0;if(C.inter===A.inter){t.setOutToIn(R);return}else lm(C.inter,A.inter,!0),lm(A.inter,C.inter,!1);let O=[];if(e===-1){let k=kt(o,t.coord),G=kt(s.nextSide.getShape(),t.coord),H=kt(l,t.coord),q=kt(a.nextSide.getShape(),t.coord);O.push(k.dot(H)),O.push(k.dot(q)),O.push(G.dot(H)),O.push(G.dot(q))}else{let k=kt(o,t.coord);O.push(kt(l,t.coord).dot(k)),O.push(kt(a.nextSide.getShape(),t.coord).dot(k))}if(O.reduce((k,G)=>Math.abs(k)>Math.abs(G)?k:G,0)>0)if(i===1||i===0||i===2||i===3)t.setOutToIn(R);else throw new Error("not support");else if(i===1)M(!R);else if(i===0||i===2||i===3)M(R);else throw new Error("not support");function M(k){t.setIsInvalid();let G=(k?C:A).inter;delete G.isInvalid,delete G.getBindedInter().isInvalid,G.setOutToIn(!R)}}function b(C,A,R,O){if(R===O){if(t.side.outline.inters.find(G=>!G.isInvalid&&G!==t&&St(G.coord,t.coord)))return t.setIsInvalid(),0;let M=new Qu(t.coord,s,r),k=new Qu(t.coord,a,r);return M.bind(k),A?s.inters.splice(t.getIndex(),0,M):s.inters.splice(t.getIndex()+1,0,M),a.inters.splice(t.getBindedInter().getIndex(),0,k),M.setOutToIn(C),t.setOutToIn(!C),M.isDealed(),s.inters.forEach((G,H)=>G.setIndex(H)),a.inters.forEach((G,H)=>G.setIndex(H)),2}else{let M=function(){let k=R.getBindedInter(),G=O.getBindedInter();delete R.isInvalid,delete k.isInvalid,delete O.isInvalid,delete G.isInvalid,R.setOutToIn(!C),O.setOutToIn(C),lm(R,O,!0),lm(O,R,!1),lm(k,G,A),lm(G,k,!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 C?0:(M(),2);if(i===0||i===2||i===3)return C?(M(),2):0;throw new Error("not support")}}}}function lm(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(!St(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 m3=0,Qu=class{constructor(e,t,i){this.id=m3++,this.coord=e,this.side=t,i&&(this.id=m3++,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 te)return e.end().sub(e.start());if(e instanceof Te){let t=this.coord.angle(e.center);return e.isCCW?t+=Hx:t-=Hx,new V(Math.cos(t),Math.sin(t))}else{if(e instanceof Ue)return ey(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){Uv++;let r=Uv===-1,n=this.drawDebug.initColor(Ui.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(De.eq(o.distance2(l),0))return;let c=ay.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?(De.eq(l.distance2(t.coord),0)?r(l,s.getEnd()):r(l,t.coord),o=!1):De.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:Uv,handleId:Jx,boolId:W0})),new Error("inter !== this");return Ol(Et.build7(e))}},Uv=0,Yv=class sI{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 ay(l,n)),o=a[a.length-1];return a.forEach(l=>{o.connect(l),o=l}),s?new sI(a,t,i,r,s):new sI(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 Et.build7(t)}};function g3(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 bX(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 ty(10),s=new ty(10);e.forEach(o=>o.forEach(l=>n.add(l))),t.forEach(o=>o.forEach(l=>s.add(l)));let a=g3(e,s,r);return g3(t,n,(o,l)=>r(l,o)).forEach(o=>a.push(o)),a}var xX=class{constructor(e){this.roots=[],this.nodes=e.sort((t,i)=>t.bbox().minX-i.bbox().minX).map(t=>new EX(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}},EX=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 $r(r):i}else return new $r(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 y3(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 te)u=`Line,${l.start().x},${l.start().y},${l.end().x},${l.end().y}`;else if(l instanceof Te)u=`Arc,${l.center.x},${l.center.y},${l.startAngle},${l.sweepAngle},${l.rx}`;else if(l instanceof Ue)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 b3(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 x=r(d);p.push(x),d.length=0}d.push(g);continue}d.push(Number(g))}d.length&&(p.push(r(d)),d.length=0);let f=Et.build7(p);o.push(f)});let l=new $r(o);i.push(l)}),new pr(i);function r(n){let s=n[0];if(s==="Line")return new te(new V(n[1],n[2]),new V(n[3],n[4]));if(s==="Arc")return Te.build3(new V(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 V(n[o],n[o+1]));return new Ue(a)}else throw new Error("not support")}}var TX=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 b3(this.group1Str)}getGroup2(){return b3(this.group2Str)}},Hv=new Zx(2),X0=class{getUnion(e,t=!0){return t&&(e=e.map(i=>this.asSameSweep([i])[0])),oX(jz,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 Z0(!1),r=new Q0(Bx.rule,Hv,i);for(let n of e){let s=Bx.weight(0);r.addPolyline(n,s)}for(let n of t){let s=Bx.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getIntersection(e,t){let i=new Z0(!1),r=new Q0(kx.rule,Hv,i);for(let n of e){let s=kx.weight(0);r.addPolyline(n,s)}for(let n of t){let s=kx.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getMutuallyExclusive(e,t){let i=new Z0(!1),r=new Q0(Mv.rule,Hv,i);for(let n of e){let s=Mv.weight(0);r.addPolyline(n,s)}for(let n of t){let s=Mv.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}},W0=0,jv=!1;function q0(e,t,i,r,n){let s=Ep(),a=[],o=[],l=[],c=new Set,u;if(n){if(u=new sy(n),W0++,jv){debugger;jv=!1;let T=new TX;q0(T.rule,T.getGroup1(),T.getGroup2(),r,n)}if(W0===-1||jv){console.table({rule:e,group1:y3(t),group2:y3(i)}),u.clear();let T=u.initColor(Ui.GREEN),w=u.initColor(Ui.WHITE),b=u.initColor(Ui.BLUE),C=u.initColor(Ui.Gray);t.items.forEach(A=>A.items.forEach((R,O)=>{O>0?w.addPly(R):T.addPly(R)})),i.items.forEach(A=>A.items.forEach((R,O)=>{O>0?C.addPly(R):b.addPly(R)})),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 T=[],w=[];switch(e){case 0:{for(let b of t.items)b.bbox().isIntersect(h)&&T.push(b);for(let b of i.items)b.bbox().isIntersect(h)&&w.push(b);break}case 1:case 3:{for(let b of t.items)b.bbox().isIntersect(h)?T.push(b):a.push(b);for(let b of i.items)b.bbox().isIntersect(h)?w.push(b):a.push(b);break}case 2:{for(let b of t.items)b.bbox().isIntersect(h)?T.push(b):a.push(b);for(let b of i.items)b.bbox().isIntersect(h)&&w.push(b);break}default:throw new Error("not support")}T.length!==t.items.length&&(t=new pr(T)),w.length!==i.items.length&&(i=new pr(w))}else{switch(e){case 0:break;case 1:case 3:{t.items.forEach(T=>a.push(T)),i.items.forEach(T=>a.push(T));break}case 2:{t.items.forEach(T=>a.push(T));break}default:throw new Error("not support")}t=new pr([]),i=new pr([])}y(t,o,!0),y(i,l,!1);let d=e===2||e===3?(T,w)=>St(T.getEnd(),w)?T.nextSide:T:(T,w)=>St(T.prevSide.getEnd(),w)?T.prevSide:T,p=(T,w,b)=>{if(St(T.getEnd(),b)){if(T.inters.findIndex(C=>C.getBindedInter().side===w&&St(C.coord,T.getEnd()))===-1)return new Qu(b,T,u)}else return new Qu(b,T,u)},f=e===2||e===3?(T,w,b)=>{if(St(T.getStart(),b)){if(T.inters.findIndex(C=>C.getBindedInter().side===w&&St(C.coord,T.getStart()))===-1)return new Qu(b,T,u)}else return new Qu(b,T,u)}:p;r.seek(t,i,(T,w,b,C,A,R)=>{let O=o[T][w],M=l[C][A],k=O.sides[b],G=M.sides[R],H=bo(k.getShape(),G.getShape());if((k.getShape()instanceof Ue||G.getShape()instanceof Ue)&&H>=4){if(k.getShape()instanceof Te||G.getShape()instanceof Te){let I=function(v,L){let _=!1;for(let B=0;B<L.length;B+=2)St(new V(L[B],L[B+1]),v)&&(_=!0);_||L.push(v.x,v.y)},N=[se[0],se[1]];for(let v=0;v<H;v+=2){let L=new V(se[v],se[v+1]);for(let _=v+2;_<H;_+=2){let B=new V(se[_],se[_+1]);if(!St(L,B)){I(B,N);break}}}H=N.length,N.forEach((v,L)=>se[L]=v)}else for(let I=H-2;I>=2;I-=2)for(let N=I-2;N>=0;N-=2)if(St(new V(se[I],se[I+1]),new V(se[N],se[N+1]))){se[N]=(se[I]+se[N])/2,se[N+1]=(se[I+1]+se[N+1])/2;for(let v=H-3;v>=I;v--)se[v]=se[v+2];H-=2;break}}let q=0;if(H===4){let I=function(L){return St(k.getEnd(),L)||St(k.prevSide.getEnd(),L)||St(G.prevSide.getEnd(),L)||St(G.getEnd(),L)},N=new V(se[0],se[1]),v=()=>{let L=new Qu(N,k,u),_=new Qu(N,G,u);L.bind(_),L.setIsInvalid(),L.isDealed(),O.inters.push(L),M.inters.push(_)};if(se[0]===se[2]&&se[1]===se[3])if(I(N))q=2;else{v();return}}for(;q<H;q+=2){let I=new V(se[q],se[q+1]),N=k,v=G;if(St(N.prevSide.getEnd(),I)&&(N=N.prevSide),v=d(v,I),k!==N&&G!==v){let _=e===2||e===3?G.getEnd():v.getEnd();N.getEnd().distance1(I)<_.distance1(I)?(I=N.getEnd(),St(_,I)||(v=G)):(I=_,St(N.getEnd(),I)||(N=k))}let L=p(N,v,I);if(L){let _=f(v,N,I);_&&(N.addInter(L),O.inters.push(L),v.addInter(_),M.inters.push(_),L.bind(_),O.intersect(M,c))}}return H},n);let m=E(),g=bX(o,l,e);g.forEach(T=>!T.startAndEndIsSameOutsideFlag()&&T.reverse()),new xX(m.concat(g)).getPolygons().forEach(T=>a.push(T));let x=new pr(a);if(u){if(W0===-1){let T=u.initColor(Ui.RED),w=u.initColor(Ui.Golden);a.forEach(b=>{T.addPly(b.items[0]),b.items.slice(1).forEach(C=>w.addPly(C))}),u.draw();debugger;throw new Error}x.id=W0}return Ll.BooleanTools+=su(s),x;function y(T,w,b){T.items.forEach(C=>{let A=[];A.push(Yv.build(C.items[0],b,!0,u,C)),C.items.slice(1).forEach(R=>{A.push(Yv.build(R,b,!1,u))}),w.push(A)})}function E(){let T=[];return c.forEach(b=>{e===2||e===3?b.forEach(A=>{A.isGroup1||A.reverse(),A.sides.forEach(R=>R.sortInters())}):b.forEach(A=>A.sides.forEach(R=>R.sortInters())),b.map(A=>A.sides.filter(R=>R.inters.length)).flat(2).sort((A,R)=>{let O=A.inters,M=R.inters,k=St(O[O.length-1].coord,A.getEnd()),G=St(M[M.length-1].coord,R.getEnd());if(k&&G){let H=0,q=0;for(let I=O.length-2;I>=0&&St(O[I].coord,A.getEnd());I--)H++;for(let I=M.length-2;I>=0&&St(M[I].coord,R.getEnd());I--)q++;return q-H}else return k?-1:1}).forEach(A=>{A.inters.forEach(R=>{if(R.dealed)return;let O=R.side,M=R.getBindedInter().side,k;St(O.getEnd(),R.coord)&&St(M.getEnd(),R.coord)?k=-1:St(O.getEnd(),R.coord)?(k=1,R=R.getBindedInter()):St(M.getEnd(),R.coord)&&(k=1);let G=yX(k,R,e,u);R.isDealed(),G&&(O.outline.setAllInterIsInvalidToFalse(),M.outline.setAllInterIsInvalidToFalse())})}),C(b),e===3&&(b.forEach(A=>{A.reverse(),A.sides.forEach(R=>{R.sortInters(),R.inters.forEach(O=>{O.resetVisitStatus()})})}),C(b));function C(A){A.forEach(R=>{R.inters.forEach(O=>{if(O.isInvalid||O.getVisited())return;let M=O.findStartInter(),k=w(e)?M.run():M.getBindedInter().run(),G=R.polyline.primitives;if(k){if(G.length===k.primitives.length){let H=new Set(G);if(!k.primitives.some(q=>!H.has(q))){T.push(R);return}}T.push(Yv.build(k,!0,!0,u))}})})}}),T;function w(b){switch(b){case 0:case 2:case 3:return!0;case 1:return!1;default:throw Error("not support the rule")}}}}var Px=/\bstablilizetion\b/.test(self.location.href)||!0,_x={intersect(e,t,i,r){try{return q0(0,e,t,i,r)}catch(n){if(Px){let s=new X0().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 pr(s.map(a=>new $r(a.items)))}throw n}},union(e,t,i,r){try{return q0(1,e,t,i,r)}catch(n){if(Px){let s=new X0,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 pr(o.map(l=>new $r(l.items)))}throw n}},diff(e,t,i,r){try{return q0(2,e,t,i,r)}catch(n){if(Px){let s=new X0().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 pr(s.map(a=>new $r(a.items)))}throw n}},xor(e,t,i,r){try{return q0(3,e,t,i,r)}catch(n){if(Px){let s=new X0().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 pr(s.map(a=>new $r(a.items)))}throw n}}},wX=class extends Q0{constructor(e,t,i,r,n,s){super(e.rule,Zx.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=bo(a.shape,o.shape);for(let c=0;c<l;c+=2){let u=new V(se[c],se[c+1]);a.inters.push(u),o.inters.push(u),this.event.onIntersect(u,a,o)}return l},this.bus)}},SX=class extends Z0{constructor(e){super(!!e),e&&(this.drawDebug=new sy(e),this.blueDrawing=this.drawDebug.initColor(Ui.BLUE),this.greenDrawing=this.drawDebug.initColor(Ui.GREEN),this.redDrawing=this.drawDebug.initColor(Ui.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 Vv(e,t,i,r,n){let s=Ep(),a=new SX(n);new wX(e,a,t,i,r,n).simplify();let o=[];a.plGrps.forEach(c=>{let u=c.items.map(h=>qx(h));u[0]&&o.push(new $r(u.filter(h=>h)))});let l=new pr(o);return Ll.BooleanTools+=su(s),l}var zv=!0,Y0={intersect(e,t,i,r){try{return _x.intersect(e,t,i,r)}catch(n){if(zv)throw n;return console.error(n),Vv(kx,e,t,i,r)}},union(e,t,i,r){try{return _x.union(e,t,i,r)}catch(n){if(zv)throw n;return console.error(n),Vv(Vz,e,t,i,r)}},diff(e,t,i,r){try{return _x.diff(e,t,i,r)}catch(n){if(zv)throw n;return console.error(n),Vv(Bx,e,t,i,r)}},xor(e,t,i,r){return _x.xor(e,t,i,r)}},vX=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=Ep(),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 x=f.items[m];if(n.isIntersect(x.bbox()))for(let y=0,E=x.primitives.length;y<E;y++){let T=x.primitives[y].bbox();n.isIntersect(T)&&a.push({bbox:T,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let o=a.length;if(o===0){Ll.IntersectionSeeker+=su(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 x=f.items[m];if(n.isIntersect(x.bbox()))for(let y=0,E=x.primitives.length;y<E;y++){let T=x.primitives[y].bbox();n.isIntersect(T)&&l.push({bbox:T,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let c=l.length;if(c===0){Ll.IntersectionSeeker+=su(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],x=l[f];i(g.polygonIndex,g.polylineIndex,g.ptIndex,x.polygonIndex,x.polylineIndex,x.ptIndex)}Ll.IntersectionSeeker+=su(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++}Ll.IntersectionSeeker+=su(s)}},hm=class Ku{static getDebug(){return Ku.drawDebug||(Ku.drawDebug=new sy(Ku.curBus)),Ku.drawDebug}static getDrawing(t=Ui.GREEN){return this.getDebug().initColor(t)}static clearDrawing(){Ku.getDebug().clear()}static drawText(t,i,r=Ui.GREEN){Ku.getDrawing(r).addText(t,i,1.5,.1,!0)}static drawBBox(t,i=Ui.GREEN){if(!t)return;let r=Ku.getDrawing(i),n=new te(t.UL(),t.UR()),s=new te(t.UR(),t.LR()),a=new te(t.LR(),t.LL()),o=new te(t.LL(),t.UL());r.addPt(n),r.addPt(s),r.addPt(a),r.addPt(o)}static drawPolyType(t,i){let r=Ku.getDrawing(i);if(t instanceof Et)r.addPly(t);else if(t instanceof $r)for(let n of t.items)n instanceof Et?r.addPly(n):this.drawPolyType(n,i);else if(t instanceof pr)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}}};hm.UseOptimizeSplit=!0,hm.LocalBestThread=4,hm.HandleDiff=!0,hm.OcTreeSplitStep=4,hm.PrintStart=new V(150,-200);var pa=hm,H0=class aI{static getPolyTypeLine(t){let i=[];if(t instanceof Et)for(let r of t.primitives)i.push(r);else if(t instanceof $r)for(let r of t.items)if(r instanceof Et)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 pr)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 Et)i.push(t);else if(t instanceof $r)for(let r of t.items)if(r instanceof Et)i.push(r);else{let n=this.getPolyTypePolyLine(r);for(let s of n)i.push(s)}else if(t instanceof pr)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=aI.getSingleBBox(r);i.ext1(n)}return i.build1()}static getSingleBBox(t){if(t instanceof Array){let i=new ot,r=aI.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 V(0,-n));for(let p=1;p<t.length;p++){let f=t[p];if(f instanceof Array){i=i.add(new V(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 V(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 V(r,0))}let h=0;for(let p of o)h+=p.x;let d=new V(h/o.length,i.y+n);pa.drawText(d,"N:"+a);for(let p of o){let f=new te(p,d),m=new Array;m.push(f);let g=Et.build1($v(m));pa.drawPolyType(g,Ui.GREEN)}return[d,new V(c,l),new V(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=Ui.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)}},IX=class dm{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 xt(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=dm.createNode(i,s,p),x=dm.ocTreeSplitNode(m,g,r,n,s);if(x.length===t.length)return t;a.push(x)}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,x=o.y+u*m,y=[[],[],[],[]],E=new Array(4),T=new Array(4);T[0]=new xt(o.x,g,x,l.y),T[1]=new xt(g,l.x,x,l.y),T[2]=new xt(o.x,g,o.y,x),T[3]=new xt(g,l.x,o.y,x);for(let A of t){let R=n(A).center(),O=-1,M=-1;R.x===g?O=Math.random()>=.5?1:-1:R.x>g?O=1:R.x<g&&(O=-1),R.y===x?M=Math.random()>=.5?1:-1:R.y>x?M=1:R.y<x&&(M=-1),O===1&&M===1?y[1].push(A):O===1&&M===-1?y[3].push(A):O===-1&&M===-1?y[2].push(A):O===-1&&M===1&&y[0].push(A)}for(let A=0;A<4;A++){let R=y[A];if(R.length<=0)continue;let O=new ot;for(let M of R)O.ext1(n(M));E[A]=O.build1()}let w=0,b=0;for(let A of E)A&&(w+=A.area());b=w;let C=(A,R)=>{if(!E[A]||!E[R])return 0;let O=E[A].intersection1(E[R]);return O?O.area():0};b-=C(0,1),b-=C(0,2),b-=C(0,3),b-=C(1,2),b-=C(1,3),b-=C(2,3),b/w>=h&&(d=y,p=T)}for(let f=0;f<d.length;f++){let m=d[f];if(m.length<=0)continue;let g=p[f],x;if(m.length===t.length?x=dm.ocTreeSplitNode(m,g,r,n):x=dm.ocTreeSplitNodeMinIntersect(m,g,r,n),x.length===t.length)return t;s.push(x)}return s}static ocTreeSplit(t,i,r,n){return dm.ocTreeSplitNode(t,i,r,n,pa.OcTreeSplitStep)}},AX=class V3{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=H0.getListBBox(r),a=IX.ocTreeSplit(n,s,pa.LocalBestThread,c=>{let u=t[c];return H0.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=Kx(o,i)}else a=Kx([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=H0.getListBBox([...c.slice(1)]);H0.KeepBBoxPolygonGroup(u,a)&&o.push(c)}else H0.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=V3.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}},fc=(e=>(e[e.INTERSECT=0]="INTERSECT",e[e.UNION=1]="UNION",e[e.DIFF=2]="DIFF",e[e.XOR=3]="XOR",e))(fc||{});function J0(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=J0(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=J0(s),!s)||i.push(s)}break;case 2:let r=e[1];if(Array.isArray(r)&&(r=J0(r)),!r)return null;i.push(r);for(let n=2;n<e.length;n++){let s=e[n];Array.isArray(s)&&(s=J0(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 Xv(e,t,i){return Array.isArray(e)?z3(e,t,i):e}function Wv(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 z3(e,t,i,r=!0){let n=new Array(e.length-1);for(let s=1;s<e.length;s++)n[s-1]=Xv(e[s],t,i);switch(e[0]){case 0:return Wv(n,Y0.intersect,t,i);case 1:return Wv(n,Y0.union,t,i);case 2:let s=Wv(n.slice(1),Y0.union,t,i);return s?Y0.diff(n[0],s,t,i):n[0];case 3:let a=Xv(e[1],t,i);for(let o=2;o<e.length;o++)a=Y0.xor(a,Xv(e[o],t,i),t,i);return a;default:throw new Error("not support boolean rule! "+e[0])}}function X3(e){let t=[e[0]];for(let i=1;i<e.length;i++){let r=e[i];if(Array.isArray(r))t.push(X3(r));else{let n=qx(r);n?t.push(pr.build(n)):t.push(new pr([]))}}return t}function CX(e){let t=[];for(let i=0;i<e.length;i+=2){let r=e[i],n=e[i+1];n?t.push({xor:id([3,r,n]),union:id([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=id([2,r.xor,n.union]),o=id([2,n.xor,r.union]),l=[];a.items.forEach(c=>l.push(c)),o.items.forEach(c=>l.push(c)),t[s]={xor:new pr(l),union:id([1,r.union,n.union])}}t.length=Math.ceil(t.length/2)}return t[0].xor}function oI(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 pr)r.push(s);else{let a=oI(s);a instanceof pr?r.push(a):r.push(id(a))}}return CX(r)}let i=[t];for(let r=1;r<e.length;r++){let n=e[r];n instanceof pr?i.push(n):i.push(oI(n))}return id(i)}function id(e,t){if(!pa.UseOptimizeSplit)return Kx(e,t);let i=AX.optimizeSplit(e,t);return i.length<=1?new pr([]):Kx(i,t)}function fI(e,t){pa.curBus=t;let i=X3(e),r=J0(i);if(!(r instanceof Array))return r||new pr([]);let n=oI(r);return n instanceof pr?n:id(n)}function Kx(e,t,i=!0){if(!e||e.length===1)return new pr([]);let r=e,n=new vX,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),z3(r,n,t,i)}var Lx=new Error("list is empty"),Ox=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}},DX=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")}},PX=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")}},_X=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 Lx;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw Lx;return this.remove(e),e.item}addLast(e){if(this.first===null||this.last===null){let t=new Ox(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 Ox(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 Lx;return this.first.item}getLast(){if(this.last===null)throw Lx;return this.last.item}insertAfter(e,t){let i=new Ox(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new Ox(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 DX(this.first)}listIterator(){return new PX(this.first)}toArray(){let e=new Array,t=this.first;for(;t!=null;)e.push(t.item),t=t.next;return e}},Gx=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=>St(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(){}},qv=0;function W3(e,t){let i=e.primitives[0];if(e.primitives.length===1&&i instanceof Te&&Math.abs(i.sweepAngle)===360)return[e];let r=Ep();qv++;let n,s=GX(e);if(s.length===0)return[];let a=RX(s);if(qv===-1){n=new sy(t);let u=n.initColor(Ui.BLUE);s.forEach(d=>u.addPt(d.getShape()));let h=n.initColor(Ui.GREEN);a.forEach(d=>h.addPoint(d.coord)),n.draw();debugger;throw new Error}if(a.length===0)return[Et.build7(s.map(u=>u.getShape()))];NX(a);let o=[],l=!1;try{kX(a,n)}catch(u){u.customType==="IS_OVERLAP"?(l=!0,o=new X0().getUnion([e]).map(h=>h.items).flat(2)):console.error(u)}if(l)return o;let c=BX(a);if(!c.length)return[Et.build7(s.map(u=>u.getShape()))];if(o=LX(c,n),o.length===0)return console.warn("=====deSelfIntersection=====",qv),[];if(n)throw o.forEach(u=>{n.initColor(Ui.WHITE).addPly(u),n.draw();debugger}),new Error;return Ll.deSelfIntersection+=su(r),o}function LX(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(Ui.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){De.eq(m.distance2(g),0)||l(q3(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 Gx));if(g.length){let y=Ol(Et.build7(g));y&&i.push(y)}let x=a.filter(y=>!(y instanceof Gx));if(s=o[h].getOutInter(x[x.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}De.eq(p.getEnd().distance2(s.coord),0)?l(p.getShape()):u(p.getStart(),s.coord)}}while(s.group!==n);let c=Ol(Et.build7(a.filter(u=>!(u instanceof Gx))));c&&i.push(c)})}),i}function OX(e){return{next(){return e.hasNext()?{value:e.next()}:{done:!0,value:void 0}},[Symbol.iterator](){return this}}}function RX(e){let t=[],i=new _X;for(let r of e.slice().sort((n,s)=>n.bbox().minY-s.bbox().minY)){for(let n of OX(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 Qu(p,d,null);return d.inters.push(f),t.push(f),f},o=function(d,p){let f=d.getEnd(),m=new V(se[0],se[1]),g=new V(se[2],se[3]),x=f.distance2(m)>f.distance2(g)?m:g,y=d.prevSide;a(St(y.getEnd(),x)?y:d,x).bind(a(p,x))},l=s.getShape(),c=r.getShape(),u=bo(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(St(g.getEnd(),m)?g:f,m)},p=new V(se[0],se[1]);if(h&&!St(p,s.prevSide.getEnd())&&!St(p,r.prevSide.getEnd())&&kt(l,p).dot(kt(c,p))>0)continue;for(let f=0;f<u;f+=2){let m=new V(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 NX(e){e.forEach(t=>{let i=t.side.getEnd();if(t.isInvalid||!St(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(!St(a.coord,i))break;a!==t&&a.getBindedInter().side===n&&a.setIsInvalid()}})}function MX(e){let t=new ty(10);return e.forEach(i=>{i.isInvalid||t.add(i)}),t}function BX(e){let t=[],i=MX(e);return e.forEach(r=>{if(r.isInvalid||r.group)return;let n=i.search(r.bbox().extendOfSize(De.eps)).filter(s=>!s.group);if(n.length){let s=new Set,a=new Gx(n);n.forEach(o=>{o.group=a,s.has(o.side)&&o.visitSelf(),s.add(o.side)}),t.push(a)}}),t}function kX(e,t){e.forEach(i=>{if(i.isInvalid||i.dealed)return;let r=i.side,n=i.getBindedInter().side,s;St(r.getEnd(),i.coord)&&St(n.getEnd(),i.coord)?s=-1:St(r.getEnd(),i.coord)?r.nextSide!==n&&(s=1,i=i.getBindedInter()):St(n.getEnd(),i.coord)&&n.nextSide!==r&&(s=1),FX(s,i,t),i.isDealed()})}function FX(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(am(a.reverse(),o.reverse())||am(n.nextSide.getShape(),s.nextSide.getShape())){let h=$u(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=$u(n,n.nextSide,s.nextSide,r,l,c,i);h.state===d.state&&u(h,d)}else if(!(am(a.reverse(),s.nextSide.getShape())||am(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(am(a.reverse(),o.reverse())||am(a,s.nextSide.getShape())){let d=Ko(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=Ko(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=Ss(n,s,!1,i);d===Ss(n,s.nextSide,!0,i)&&d!==bp(s,s.nextSide,new ay(q3(a,t.coord,a.end()),i),!0,i)&&t.setIsInvalid()}}function u(h,d){h.inter.setIsInvalid(),d.inter.setIsInvalid(),t.setIsInvalid()}}function q3(e,t,i){if(e instanceof te||t.distance2(i)<1e-6)return new te(t,i);if(e instanceof Te)return Te.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.sweep());if(e instanceof Ue){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 GX(e){let t=Ol(e);if(!t)return[];let i=t.primitives.map(n=>new ay(n,null)),r=i[i.length-1];return i.forEach(n=>{r.connect(n),r=n}),i}var K0=class{static clearData(e){this.originalPrimitive=[],this.offsetPrimitive=[],this.rawOffsetPrimitive=[],this.offsetDistance=0,this.testI++,this.testI===0?this.drawDebug=new sy(e):delete this.drawDebug}static createRawOffsetEdge(){if(this.drawDebug){let e=this.drawDebug.initColor(Ui.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(Ui.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 Te?i=Te.build4(this.offsetPrimitive[0].offsetEdge.start(),t.end(),t.center,t.rx,t.ry,t.sweep()):i=new te(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[Te.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=Ol(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=fI(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(Ui.BLUE);this.rawOffsetPrimitive.forEach(c=>l.addPt(c)),this.drawDebug.draw();debugger}let o=i?this.createClippingEdge(r):[Et.build2(this.rawOffsetPrimitive)];if(this.drawDebug){let l=this.drawDebug.initColor(Ui.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(Ui.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 Te)l=o.midPoint;else if(o instanceof te)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 Te?h=this.pointArcClosest(l,u):h=Az(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 V(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 De.less(r,n)?Math.sqrt(r):Math.sqrt(n)}static createClippingEdge(e){let t=[],i=[],r=W3(Et.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];De.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 Te)return e.panDistance2(this.offsetDistance);if(e instanceof te)return e.panDistance(this.offsetDistance);throw new Error("not support!")}static connectPrimitive(e,t){e.offsetEdge instanceof te&&t.offsetEdge instanceof te?this.lineToLineConnect(e,t):e.offsetEdge instanceof Te&&t.offsetEdge instanceof Te?this.arcToArcConnect(e,t):e.offsetEdge instanceof te&&t.offsetEdge instanceof Te?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 te(i.start(),h);this.rawOffsetPrimitive.push(d);let p=new te(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 te(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=Te.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 Te){let s=n.center.sub(n.end()).normalize();n.isCCW?r=new V(s.y,-s.x):r=new V(-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 te(e.start(),r);this.rawOffsetPrimitive.push(l);let c;!t.center.equals1(r)||t.sweepAngle>1e-4?(c=Te.build4(r,t.end(),t.center,t.rx,t.ry,t.sweep()),c instanceof Te&&c.sweepAngle===0&&(c=new te(c.start(),c.end()))):c=new te(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=Te.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 te(e.center,r):Math.abs(e.sweepAngle)<1e-4?l=new te(e.start(),r):(l=Te.build4(e.start(),r,e.center,e.rx,e.ry,e.sweep()),l instanceof Te&&l.sweepAngle===0&&(l=new te(l.start(),l.end()))),this.rawOffsetPrimitive.push(l);let c=new te(r,t.end());this.updateNextOffsetPrimitive(a,c)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(n,e,t,s)}static isTrueArcIntersection(e,t){return Bn(e,t)}static getSweepAngel(e,t,i,r){let n=e.angleD(i),s=t.angleD(i),a;return n===s?a=0:(n=Jt.regularD(n),s=Jt.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=Sz(t,e);if(r){i.intersectionNum=r/2;for(let n=0;n<r-1;n+=2){let s=new V(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=I3(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 te(i.center,a):Math.abs(i.sweepAngle)<1e-4?o=new te(i.start(),a):(o=Te.build4(i.start(),a,i.center,i.rx,i.ry,i.sweep()),o instanceof Te&&o.sweepAngle===0&&(o=new te(o.start(),o.end()))),this.rawOffsetPrimitive.push(o),a.equals1(r.center)?l=new te(a,r.center):Math.abs(r.sweepAngle)<1e-4?l=new te(a,r.end()):(l=Te.build4(a,r.end(),r.center,r.rx,r.ry,r.sweep()),l instanceof Te&&l.sweepAngle===0&&(l=new te(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=Te.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)}}};K0.originalPrimitive=[],K0.offsetPrimitive=[],K0.rawOffsetPrimitive=[],K0.testI=0;var UX=class $0 extends ry{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 V(this.radius,0).multiply3(he.rotateD(this.angle)))}end(){return this.start()}getLeftPoint(){return this.leftUpPoint.add(new V(0,-this.height/2).multiply3(he.rotateD(this.angle)))}getRightPoint(){return this.leftUpPoint.add(new V(this.width,-this.height/2).multiply3(he.rotateD(this.angle)))}extend(t){return new $0(this.leftUpPoint.add(new V(-t,t).rotateD(V.ORIGIN,this.angle)),this.width+t*2,this.height+t*2,this.angle,this.isCCW,this.radius+t)}bbox(){let t=he.rotateD(this.angle),{leftUpPoint:i,width:r,height:n,radius:s}=this,a=i.add(new V(s,-s).multiply3(t)),o=i.add(new V(s,s-n).multiply3(t)),l=i.add(new V(r-s,-s).multiply3(t)),c=i.add(new V(r-s,s-n).multiply3(t));return new xt(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=V.ORIGIN,l=new V(r,0),c=new V(r,-n),u=new V(0,-n);t.push(new te(o,l),new te(l,c),new te(c,u),new te(u,o))}else{let o=new V(0,-s),l=new V(s,0),c=new V(r-s,0),u=new V(r,-s),h=new V(r,s-n),d=new V(r-s,-n),p=new V(s,-n),f=new V(0,s-n);t.push(Te.build1(o,l,s,s,!1,0),new te(l,c),Te.build1(c,u,s,s,!1,0),new te(u,h),Te.build1(h,d,s,s,!1,0),new te(d,p),Te.build1(p,f,s,s,!1,0),new te(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=he.rotateD(this.angle).translate1(i);return Et.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 V(this.width,0).multiply3(he.rotateD(this.angle)).multiply3(t),n=new V(0,-this.height).multiply3(he.rotateD(this.angle)).multiply3(t);return t.isMirrored()?new $0(i,n.length(),r.length(),n.angleD(V.ORIGIN),this.isCCW===1?0:1,this.radius*r.length()/this.width):new $0(i,r.length(),n.length(),r.angleD(V.ORIGIN),this.isCCW,this.radius*r.length()/this.width)}reverse(){return new $0(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 Et.build2(s.primitives.concat(new te(s.primitives[0].start(),a.primitives[0].start()),a.primitives,new te(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.")}},YX=.01,$r=class uc{static simplify(t){return t=Ol(t),t?new uc([t]):null}static buildByStroke(t,i,r=1,n=uI,s){if(t instanceof Te&&(t.rx<i/2+YX||Math.abs(t.sweepAngle)>180&&De.lesseq(t.start().distance1(t.end()),i))){let o=W3(t.stroke(i,r,0),s);if(o.length===0)return null;if(o.length===1)return new uc(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 uc(l)}else if(t instanceof UX){let o=t.stroke1(i,r,0).map(l=>Ol(l));return o[0]?o[1]?new uc(o):new uc([o[0]]):null}let a=t.stroke(i,r,0,n);return a?this.simplify(a):null}static buildCircle(t,i){return this.simplify(Et.build7([Te.buildCircle(t,i,0)]))}static buildRect(t){return this.simplify(t.toPolyline())}static buildBBox(t){return this.simplify(Et.buildBBox(t,0))}constructor(t){this.items=t.slice()}multiply3(t){return new uc(this.items.map(i=>i.multiply3(t)))}bbox(){return this.items[0].bbox()}isEqual(t){return t instanceof uc?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 pr([this]);let r=this.items[0],n=[];for(let u of r.primitives)if(u instanceof te)n.push(u);else if(u instanceof Te&&u.rx===u.ry)a(u);else if(u instanceof Ue)s(u);else throw new Error("not support!");r=Et.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 te(p,f))}}function a(u){if(Math.abs(u.sweepAngle)>270){let h=u.sweepAngle/2;a(Te.build3(u.center,u.startAngle,h,u.rx,u.ry)),a(Te.build3(u.center,u.startAngle+h,h,u.rx,u.ry))}else n.push(u)}let o=[],l=[];K0.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 pr([new uc(o)]);else if(o.length===0)console.warn("outlines.length === 0"),c=new pr([]);else if(l.length===0)c=new pr(o.map(u=>new uc([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 pr(u.map(h=>new uc(h)))}return c}toPolylineGroup(){return new Nr(this.items)}};var mc=typeof window>"u"?!1:/\bpanelBoolDebug\b/.test(ut().location.search),Em=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(mc){let n=new V(this.getX(t,r),r),s=new V(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(mc){let n=new V(this.getX(t,r),r),s=new V(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){}};function J3(e){return/^(pixel|mil|mm|inch)$/i.test(e)}function qs(e){return Gt(e,"pixel","mm")}function ya(e){return Gt(e,"mm","pixel")}function Gt(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 Xe={adsorbGrid:{visible:!0,gridSize:ya(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 nd(e,t,i){Xe[e][t]=i}function Rl(e){return navigator.userAgent.indexOf(e)}var tE=Rl("Mac OS")>0,HX=Rl("chromeframe")>0||Rl("x-clock")>0,K3=(Rl("MSIE")>0||Rl("Trident")>=0)&&!HX,$3=Rl("Edge/")>0,xo=Rl("Opera/")===0,sd=Rl("Firefox/")>0,qae=sd&&navigator.userAgent.match(/Firefox\/(\d+(\.\d+)?)/)[1],Jae=Rl("AppleWebKit")>0,oy=Rl("Chrome/")>0&&!K3&&!$3&&!xo&&!sd,Kae=oy&&navigator.userAgent.match(/Chrome\/(\d+(\.\d+)?)/)[1],$ae=Rl("Safari/")>-1&&!K3&&!$3&&!xo&&!sd&&!oy,Zae=Rl("Electron/")>0;function Qe(e={},t){return Object.hasOwnProperty.call(e,t)}function Z3(e){return new Promise(t=>setTimeout(t,e))}function lu(...e){}function Q3(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 $o(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(b){let C=r,A=n;return r=n=void 0,c=b,a=e.apply(A,C),a}function f(b){return c=b,o=setTimeout(x,t),u?p(b):a}function m(b){let C=b-l,A=b-c,R=t-C;return h?Math.min(R,s-A):R}function g(b){let C=b-l,A=b-c;return l===void 0||C>=t||C<0||h&&A>=s}function x(){let b=Date.now();if(g(b))return y(b);o=setTimeout(x,m(b))}function y(b){return o=void 0,d&&r?p(b):(r=n=void 0,a)}function E(){o!==void 0&&clearTimeout(o),c=0,r=l=n=o=void 0}function T(){return o===void 0?a:y(Date.now())}function w(){let b=Date.now(),C=g(b);if(r=arguments,n=this,l=b,C){if(o===void 0)return f(l);if(h)return o=setTimeout(x,t),p(l)}return o===void 0&&(o=setTimeout(x,t)),a}return w.cancel=E,w.flush=T,w}function eN(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),$o(e,t,{leading:r,maxWait:t,trailing:n})}function Zt(e){if(typeof e!="object"||e===null||e instanceof Date||e instanceof ArrayBuffer)return e;if(Array.isArray(e))return e.map(Zt);let t={};for(let i in e)Qe(e,i)&&(t[i]=Zt(e[i]));return t}var tN={camelize(e){let t=/-(\w)/g;return e.replace(t,(i,r)=>r.toUpperCase())},hyphenate(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}},iN=Object.prototype.toString;function os(e){return iN.call(e).slice(8,-1)==="Number"&&!Number.isNaN(e)}function Nt(e){return Eo(e)&&Object.keys(e).length===0}function cy(e){return Eo(e)&&Object.keys(e).length}function Eo(e){return iN.call(e)==="[object Object]"}function ly(e,t){if(Eo(e)){for(let i in e){let r=e[i];if(!ly(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(!ly(e[i],t[i]))return!1;return!0}function Fn(e){return e.nextElementSibling?e.nextElementSibling.id:e.parentNode?"<"+e.parentNode.id:""}function rN(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function Hr(...e){if(console.error(...e),jX())throw new Error("Plz Check code")}function jX(){return!1}function ft(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=J1[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 mI(e=""){return e.replace(/[ ,]{2,}| /g,",").split(",").map(Number)}function iE(e,t){for(let i in t)if(Qe(t,i)&&e.indexOf(i)!==-1)return!0;return!1}function ih(e){let t={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;","&":"&amp;"};function i(r){return t[r]}return e==null?"":iE(e+"",t)?(e+"").replace(/[<>'"&]/g,i):e}function uy(e){if(!gc(e))return e;let t={"&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&amp;":"&","&#039;":"'"};function i(r){return t[r]}return iE(e,t)?(e+"").replace(/&([^;]+);/g,i):e}function nN(e){if(typeof e!="string")return e;var t={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"};function i(r){return t[r]}return iE(e,t)?(e+"").replace(/[<>'"]/g,i):e}function gc(e){return typeof e=="string"}function gI(e){return gc(e)&&e.length!==0}function yc(e){return e?e.trim?e.trim():e.replace(/^\s+|\s+$/g,""):""}function re(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 Ou&&(a=t.substr(s.length+1),oy?e.setAttributeNS(Ou[s],t,i):e.setAttributeNS(Ou[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)Qe(t,n)&&(n.indexOf(":")>0?(s=n.substr(0,n.indexOf(":")),s in Ou&&(a=n.substr(s.length+1),t[n]===""?e.hasAttributeNS(Ou[s],a)&&e.removeAttributeNS(Ou[s],a):oy?e.setAttributeNS(Ou[s],n,t[n]):e.setAttributeNS(Ou[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||xo&&typeof e.length=="number"){if(typeof t=="string"&&r==2)return e[0]?re(e[0],t):null;if(r==2)for(o=0;o<e.length;o++)re(e[o],t);else if(r>=3)for(o=0;o<e.length;o++)re(e[o],t,i);return e}}function ba(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 Js(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 cu(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 To(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 de(e){return!e||self.IN_WORKER?(console.error("no id",e,"Plz check code"),null):document.getElementById(e)}function Zr(e,t){if(!e||e=="#")return[];try{return(t||document).querySelectorAll(e)}catch{return[]}}function jr(e,t){if(!e||e=="#")return null;try{return(t||document).querySelector(e)}catch{return null}}function sN(e,t){var i=e&&e.cloneNode(t!==!1);return i}function Tt(e,t){let i=document.createElementNS("http://www.w3.org/2000/svg",e);return t&&re(i,t),i}var Nl="ignore-me";function aN(){let e=[],t=J.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(ba(n,Nl))continue;e.push(n.id)}}return e}function Qt(e){if(!e||!e.tagName||e==J.gCanvas||ba(e,Ml)||e.contains(J.gCanvas))return"";let t=re(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||""}var Ioe=Math.PI*2,Aoe=Math.PI/2,Coe=Math.sin(Math.PI/180),rE=class{constructor(t,i){this.x=+t||0,this.y=+i||0}toString(){return ft(this.x,4)+"_"+ft(this.y,4)}};function nE(e,t){if(!e||typeof e!="string")return"";var i=/\d+\.\d{12,}/g,r=J1[t]||Math.pow(10,t)||10;return e.replace(i,function(n){return(Math.round(parseFloat(n)*r+1e-10)/r).toString()})}function bc(e,t,i){return e>=i.x&&e<=i.x+i.width&&t>=i.y&&t<=i.y+i.height}function hy(e,t){return bc(e.x,e.y,t)&&bc(e.x+e.width,e.y,t)&&bc(e.x,e.y+e.height,t)&&bc(e.x+e.width,e.y+e.height,t)}function oN(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 lN(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 cN(e,t){for(var i=e.points,r=i.length||i.numberOfItems,n=0;n<r;n++)if(bc(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 Tm(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 sE(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 x=(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,y}}function $a(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 Ks(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,x,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,x=c-E,{d:Math.sqrt(g*g+x*x),point:{x:y,y:E}}))}function wo(e,t,i,r){let n=e-i,s=t-r;return n*n+s*s}function Bl(e,t,i,r){return Math.sqrt(wo(e,t,i,r))}function dy(e,t){return Bl(e.x,e.y,t.x,t.y)}function $s(e,t,i,r){if(t=+t,i=+i,r=+r,t=fr(t),t===0)return e.slice(0);let n=e.map(d=>+d),s=n.length;Qe(Yd,t)||(Yd[t]=Math.sin(t*Math.PI/180),Aw[t]=Math.cos(t*Math.PI/180));var a=Yd[t],o=Aw[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 ad(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 fr(e){return e<0?(360+e%360)%360:e>=360?e%360:e}function ei(e,t,i=10**-3){let r=e-t;return(r>0?r:-r)<i}function uN(e){return ei(e,0)?0:e}function Zs(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 aE(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 Zo(e,t,i,r,n){return Math.pow(e-i,2)+Math.pow(t-r,2)<=Math.pow(n,2)}function rh(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 WX(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 yI(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 qX(e,t){return{a:e.y-t.y,b:t.x-e.x,c:e.x*t.y-t.x*e.y}}function hN(e,t,i,r,n,s){let{a,b:o,c:l}=qX({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 uu(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],JX(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 JX(e,t,i){return WX(e,t,i)?ei((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}function dN(e,t){return Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))}function pN(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,x=h*p-u*d,y=g*g/(i*i)+x*x/(r*r);y>1&&(i=i*Math.sqrt(y),r=r*Math.sqrt(y));var E=i*r,T=i*x,w=r*g,b=T*T+w*w;b||Hr("start point can not be same as end point");var C=Math.sqrt(Math.abs((E*E-b)/b));s==a&&(C=-C);var A=C*T/r,R=-C*w/i;let O=h*A-u*R+f,M=u*A+h*R+m;var k=(g-A)/i,G=(g+A)/i,H=(x-R)/r,q=(x+R)/r;let I=L(1,0,k,H),N=L(k,H,-G,-q);for(;N>c;)N-=c;for(;N<0;)N+=c;(a==!1||a==0)&&(N-=c);let v=I+N;for(;v>c;)v-=c;for(;v<0;)v+=c;function L(_,B,U,z){var W=_*U+B*z,ne=Math.sqrt((_*_+B*B)*(U*U+z*z)),me=Math.acos(W/ne);return _*z-B*U<0&&(me=-me),me}return{cx:O,cy:M,startAngle:I,deltaAngle:N,endAngle:v}}function fN(e){return e/180*Math.PI}function py(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 oE(e){typeof e=="string"&&(e=py(e));var t=e.M,i=e.A,r=e.A.rx,n=Math.atan2(i.y-t.y,i.x-t.x),s=yI(t,n),a=yI(i,n),o=Bl(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 yI(u,-n)}function mN(e){for(var t=[],i=e.numberOfItems,r,n=0;n<i;n++)r=e.getItem(n),t[n]=new rE(r.x,r.y);return t}function fy(e){let t=[];if(!e)return t;let i=mI(e),r=i.length-1;for(let n=0;n<r;n+=2)t[n/2]=new rE(i[n],i[n+1]);return t}function gN(e,t){return e^=t,t^=e,e^=t,[e,t]}function yN(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 bN(e,t){return t=t||J,t.decimalPlacesShow=t.decimalPlacesShow!==void 0?t.decimalPlacesShow:2,ft(e,t.decimalPlacesShow,t.fixedDecimal)}function un(e,t){return t=t&&typeof t.decimalPlaces=="number"?t:J,ft(e,t.decimalPlaces)}var kl={altKeyEnabled:!1,getSanpSize:function(e){return kl.altKeyEnabled?+Xe.adsorbGrid.altSnapSize||1:+Xe.adsorbGrid["distance"+e]||1}};var Ye=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}};Ye.eps=1e-8,Ye.precision=1e8;function od(e,t,i,r,n,s,a,o,l){var c=Math.PI*2;function u(U,z,W,ne){var me=U*W+z*ne,Ee=Math.sqrt((U*U+z*z)*(W*W+ne*ne)),Se=Math.acos(me/Ee);return U*ne-z*W<0&&(Se=-Se),Se}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,x=1e-5;a<0&&(a=-a),o<0&&(o=-o),a==o&&(l=0);var y=Math.sin(l),E=Math.cos(l),T=(e-i)/2,w=(t-r)/2,b=(e+i)/2,C=(t+r)/2;if(a<x||o<x)return m=u(1,0,i-e,r-t),d({cx:b,cy:C,theta1:m,delta_theta:Math.PI});var A=E*T+y*w,R=E*w-y*T,O=A*A/(a*a)+R*R/(o*o);O>1&&(a=a*Math.sqrt(O),o=o*Math.sqrt(O));var M=a*o,k=a*R,G=o*A,H=k*k+G*G;if(!H)return d({cx:b,cy:C,theta1:0,delta_theta:0});var q=(M*M-H)/H;q=Math.sqrt(Math.abs(q)),n===s&&(q=-q);var I=q*k/o,N=-q*G/a;p=E*I-y*N+b,f=y*I+E*N+C;var v=(A-I)/a,L=(A+I)/a,_=(R-N)/o,B=(R+N)/o;for(m=u(1,0,v,_),g=u(v,_,-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 lE(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),x=(a*(d-u+m-p)-o*(h-u+f-p))/(2*c*a-2*l*o);if(!isFinite(g)||!isFinite(x))return;var y=Math.sqrt((e-g)*(e-g)+(t-x)*(t-x)),E=[e-n,t-s],T=[i-n,r-s],w=E[0]*T[0]+E[1]*T[1],b=w<0?0:1;function C(k,G,H){var q=Math.acos(ft(k/H,3));return G>=0?q:Math.PI*2-q}var A=C(e-g,t-x,y),R=C(i-g,r-x,y),O=C(n-g,s-x,y),M=0;return O>A?(R>O||R<A)&&(M=1):R>O&&R<A&&(M=1),{angle:0,largeArcFlag:b,sweepFlag:M,x1:e,y1:t,x2:i,y2:r,cx:g,cy:x,r:y}}var $e=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 V(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=he.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=he.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 V(0,0).multiply3(i),n=r.x,s=r.y,a=new V(1,0).multiply3(i),o=new V(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 V(c[0],c[1]).multiply3(i);l.push(u)}return l}static calcuEllipse(t){let i=this.createMatrixFrom6(t),r=new he(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 he([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 bI(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 KX=.99,$X=50;function TN(e,t){let i=[],r=[],n=t**2;for(let s of e.primitives){if(s instanceof te&&s.length()<$X){r.length===0?r.push(s.start(),s.end()):r.push(s.end());continue}r.length!==0&&(i.push(...EN(r,n).primitives),r.length=0),i.push(s)}return r.length!==0&&i.push(...EN(r,n).primitives),Et.build2(i)}function xI(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(V.ORIGIN);return r.cross(n)<0?V.getVector2(u+c):V.getVector2(u-c)}function xN(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(!(Ye.greater(p*h.cross(d),0)&&Ye.greater(p*u.cross(d),0)))return null;let f=c.sub(n),m=Number.NEGATIVE_INFINITY;for(let T of i){let w=Math.abs(f.cross(T[0].sub(n)));w>m&&(m=w)}let g=V.getCrossPoint1(n,s,l,c)||n.add(c).scale(.5),x=Math.abs(g.sub(n).cross(f)),y=Math.min(1,m/x*4/3),E=new Ue([n,n.add(g.sub(n).scale(y)),c.add(g.sub(c).scale(y)),c]);for(let T of i){let[w,b]=T,C=E.getPointsBySlope(Ye.eq(b.x,0)?Number.POSITIVE_INFINITY:b.y/b.x);if(C.length!==1||w.distance2(C[0])>r)return null}return E}function EN(e,t){if(e.length<2)throw new Error("The length of outline can't be less than 2!");let i=bI(e,-1);if(i.length===2)return Et.build2([new te(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(xI(s,a,o)),s=a,a=o):(n.push(o.sub(a).scale(-1).normalize()),s=a,a=o);let l=bI(i),c=1;for(let m=1;m<i.length-1;m++)o=i[m+1],i[m]===l[c]&&(n.push(xI(s,a,o)),c++),s=a,a=o;r?(o=i[1],n.push(xI(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],x=n[m],y=d.sub(g);if(y.cross(p)*y.cross(x)>0)f=new te(d,g),h.length=0,p=x;else if(Math.abs(x.dot(p))<KX){if(f instanceof Ue){let E=xN(f,new Ue([d,d,g]),h,t);E?(u.pop(),f=E):f=new te(d,g)}else f=new te(d,g);m!==l.length-1&&(p=g.sub(l[m+1]).normalize()),h.length=0}else{let E=new Ue([d,V.getCrossPoint2(d,p,g,x)||d.add(g).scale(.5),g]);if(f instanceof Ue){let T=xN(f,E,h,t);T?(u.pop(),E=T):h.length=0}f=E,h.push([g,x]),p=x}u.push(f),d=g}for(let m=0;m<u.length;m++){let g=u[m];if(g instanceof Ue)try{let x=g.controls,y=x[0],E=x[x.length-1].sub(y).normalize(),T=!0;for(let w=1;w<x.length-1;w++)if(!Ye.eq(1,x[w].sub(y).normalize().dot(E))){T=!1;break}T&&(u[m]=new te(x[0],x[x.length-1]))}catch{}}return Et.build2(u)}function wm(e,t){ZX(e.iterator(),t)}function ZX(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var EI=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 wN(e){return new EI(e)}function vN(e){return e===32||e===9||e===13||e===10}var cE=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 IN=eval;var uE=null,SI=new ArrayBuffer(8),TI=new Float64Array(SI),wI=new Uint32Array(SI),AN=new Uint16Array(SI),QX=IN;function Fl(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 x=l(m,g);isNaN(x)?(o[f++]=g,g=a[++p]):(x<=0&&(o[f++]=m,m=a[++d]),x>=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 Is=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(!uE){let t=this.getUrlVars().version;t?uE="/analyzer/v"+t:uE="/analyzer"}return uE}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;TI[0]=new Date().getTime(),t.push(wI[1].toString(16)),TI[0]=Math.random(),t.push(AN[3].toString(16));let i=AN[2].toString(16);t.push("4"+i.substr(0,3)),TI[0]=performance.now();let r=wI[0].toString(16)+wI[1].toString(16);return t.push("0"+r.substr(0,3)),t.push(r.substr(3)),t.join("-")}static funcCopy(t){return QX("("+t.toString()+")")}static NVL(...t){for(let i of t)if(i!==null)return i;return null}};var hu=class{static rgb(t){if(0<=t&&t<=255)return t;throw new Error(So.format("RGB should not nagative and not over 255(0xFF): %X",t))}static normal(t){if(isFinite(t))return t;throw new Error(So.format("%f is not permitted",t))}static positiveOr0(t){if(t>=0)return t;throw new Error(So.format("%f must >= 0",t))}static positive(t){if(t>0)return t;throw new Error(So.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){os(t)||Hr(t)}};var eW=/(\.?0+)$/,So=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(Is.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(Is.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(Is.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);hu.nullOrEmpty(a)||r.push(a);break}}return r}static fmtNumber(t){return t.toFixed(5).replace(eW,"")}};function tW(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var iW=(e,t)=>{e===3?console.error(...t):e===2?console.warn(...t):console.log(...t)},rW=(e,t)=>[tW(e)].concat(t),Sm=class Sm{static mix(...t){return new Sm(0,(i,r)=>{for(let n of t)n.write(i,r)},(i,r)=>r)}constructor(t,i=iW,r=rW){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 Sm(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,[So.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,[So.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)}};Sm.DUMMY=new Sm(4);var xc=Sm;var vI=500,CN=String.fromCharCode,hE=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<=vI)return CN.apply(null,t);{let r=new Array;for(let n=0;n<t.length;n+=vI){let s=Math.min(i-n,vI),a=CN.apply(null,t.slice(n,n+s));r.push(a)}return r.join("")}}};var PN=(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))(PN||{}),_N=(k=>(k[k.UNKNOW=0]="UNKNOW",k[k.MOVE_X=1]="MOVE_X",k[k.MOVE_Y=2]="MOVE_Y",k[k.LINE_X=3]="LINE_X",k[k.LINE_Y=4]="LINE_Y",k[k.HORIZONTAL_X=5]="HORIZONTAL_X",k[k.VERTICAL_Y=6]="VERTICAL_Y",k[k.CUBIC_BEZIER_X1=7]="CUBIC_BEZIER_X1",k[k.CUBIC_BEZIER_Y1=8]="CUBIC_BEZIER_Y1",k[k.CUBIC_BEZIER_X2=9]="CUBIC_BEZIER_X2",k[k.CUBIC_BEZIER_Y2=10]="CUBIC_BEZIER_Y2",k[k.CUBIC_BEZIER_X=11]="CUBIC_BEZIER_X",k[k.CUBIC_BEZIER_Y=12]="CUBIC_BEZIER_Y",k[k.ARC_RX=13]="ARC_RX",k[k.ARC_RY=14]="ARC_RY",k[k.ARC_ROTATION=15]="ARC_ROTATION",k[k.ARC_LARGE=16]="ARC_LARGE",k[k.ARC_SWEEP=17]="ARC_SWEEP",k[k.ARC_X=18]="ARC_X",k[k.ARC_Y=19]="ARC_Y",k[k.SMOOTH_CUBIC_BEZIER_X2=20]="SMOOTH_CUBIC_BEZIER_X2",k[k.SMOOTH_CUBIC_BEZIER_Y2=21]="SMOOTH_CUBIC_BEZIER_Y2",k[k.SMOOTH_CUBIC_BEZIER_X=22]="SMOOTH_CUBIC_BEZIER_X",k[k.SMOOTH_CUBIC_BEZIER_Y=23]="SMOOTH_CUBIC_BEZIER_Y",k[k.QUADRATIC_BEZIER_X1=24]="QUADRATIC_BEZIER_X1",k[k.QUADRATIC_BEZIER_Y1=25]="QUADRATIC_BEZIER_Y1",k[k.QUADRATIC_BEZIER_X=26]="QUADRATIC_BEZIER_X",k[k.QUADRATIC_BEZIER_Y=27]="QUADRATIC_BEZIER_Y",k))(_N||{});function nW(e){return 97<=e&&e<=122||65<=e&&e<=90}function As(e){let t=parseFloat(e);if(isFinite(t))return t;throw new Error("expect number")}var Za=class extends cE{constructor(i,r=!0,n=xc.DUMMY){super();this.buffer=new hE;this.group=new Array;this.subPartStart=V.ORIGIN;this.curPoint=V.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),PN[this.lexState]),this.lexState){case 0:return vN(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):nW(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,_N[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 te(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=As(i),this.parseState=2,r;case 2:{this.y=this.yAxis*As(i);let s;return this.isAbsolute?s=new V(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*As(i);let s;return this.isAbsolute?s=new V(this.x,this.y):s=this.curPoint.add1(this.x,this.y),this.group.push(new te(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 V(this.x,this.curPoint.y):s=this.curPoint.add1(this.x,0),this.group.push(new te(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 V(this.curPoint.x,this.y):s=this.curPoint.add1(0,this.y),this.group.push(new te(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*As(i),this.parseState=9,!0;case 9:return this.x2=As(i),this.parseState=10,!0;case 10:return this.y2=this.yAxis*As(i),this.parseState=11,!0;case 11:return this.x=As(i),this.parseState=12,!0;case 12:{this.y=this.yAxis*As(i);let s,a,o;return this.isAbsolute?(s=new V(this.x1,this.y1),a=new V(this.x2,this.y2),o=new V(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 Ue([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=As(i),this.parseState=15,!0;case 15:return this.rotation=As(i),this.parseState=16,!0;case 16:return this.isLargeArc=As(i)===1,this.parseState=17,!0;case 17:return this.sweep=As(i)===1?vs.CW:vs.CCW,this.parseState=18,!0;case 18:return this.x=As(i),this.parseState=19,!0;case 19:{this.y=this.yAxis*As(i);let s;return this.isAbsolute?s=new V(this.x,this.y):s=this.curPoint.add1(this.x,this.y),this.rx&&this.ry&&this.group.push(Te.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*As(i),this.parseState=22,!0;case 22:return this.x=As(i),this.parseState=23,!0;case 23:{this.y=this.yAxis*As(i);let s,a;this.isAbsolute?(s=new V(this.x2,this.y2),a=new V(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 Ue([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*As(i),this.parseState=26,!0;case 26:return this.x=As(i),this.parseState=27,!0;case 27:{this.y=this.yAxis*As(i);let s,a;return this.isAbsolute?(s=new V(this.x1,this.y1),a=new V(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 Ue([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=Et.build1(wN(this.group));return this.group.length=0,this.on(i)}}onException(i){throw i}};var Ole=So.fmtNumber,vo=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 te)this.encLine1(t);else if(t instanceof Te)this.encArc(t);else if(t instanceof Ue)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 LN(e,t){let i=[],r=new Za(s=>(i.push(s),!0),!1);r.parse(e),r.finish();let n=new vo(!1);for(let s of i){let a=TN(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 Yi(e,t=!0){let i=new Array;return new Za(r=>(i.push(r),!0),t).parse(e),i}function ls(e,t=!1,i=.01,r){let n=!0;r&&(n=r.reverseY);let s=Array();for(let a of e){let o=new vo(n);o.encPl(a);let l=o.fixNumber(4).toString();s.push(t?ON(l,i):l)}return s.join(" ")}function my(e,t=!0,i=.01){let r=new vo;e.forEach((s,a)=>{r.encPl(s),r.close(a===e.length-1)});let n=r.toString();return[t?ON(n,i):n]}function ON(e,t=.01){let i=sW(e);try{let r=LN(e,t);return r=aW(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 sW(e){return e.split(/m/i).slice(1).map(i=>({isClose:/z\s*$/i.test(i)}))}function aW(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 vm(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 ka=class ka{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%ka.PIx2,t<0?ka.PIx2+t:t}static toQuarterBase(t){return ka.regular((t+ka.PI_4)/ka.PI_2*ka.PI_2)}static toQuarterBaseD(t){return ka.regularD(((t+45)/90|0)*90)}static transformD(t,i){return ka.toDegrees(ka.transform(ka.toRadians(t),i))}static transform(t,i){let r=Math.cos(t),n=Math.sin(t),s=new V(i.data[6],i.data[7]),a=new V(r,n).multiply3(i);return ka.regular(a.angle(s))}};ka.PIx2=Math.PI*2,ka.PI_2=Math.PI/2,ka.PI_4=Math.PI/4;var xa=ka;var ld=class{constructor(t){this.data=t;let i=pN(this.data.x1,this.data.y1,this.data.rx,this.data.ry,xa.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 he.scale(this.data.rx,this.data.ry).rotateD(this.data.angle).translate(this.cx,this.cy)}getInverseMatrix(){let t=this.getMatrix();return new he(t.getInverseMatrix().data)}vectorStart(){return new V(this.data.x1,this.data.y1)}vectorEnd(){return new V(this.data.x2,this.data.y2)}vectorCenter(){return new V(this.cx,this.cy)}startAngle(){return fr(-this.vectorStart().angleD2(this.vectorCenter()))}endAngle(){return fr(-this.vectorEnd().angleD2(this.vectorCenter()))}setAngle(t,i){let r=this.getMatrix(),n=xa.toRadians(t),s=this.vectorCenter(),a=Math.cos(n)*10,o=Math.sin(n)*10,l=this.getInverseMatrix(),u=new V(s.x+a,s.y+o).multiply3(l).angle2(V.ORIGIN),h=new V(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 V(this.data.x1,this.data.y1).sub(s),p=new V(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 he(i.getInverseMatrix().data),n=this.vectorStart().multiply3(r),s=n.angleD2(V.ORIGIN),a=this.vectorEnd().multiply3(r),o=this.data.sweep,l=[],c=0,u=aE(n,{x:0,y:0},a),h=xa.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:x,cos:y,sin:E}=Math,T=p(f(c/t));T=g(2,x(m(c*10),T)),t=f(c/T)*(o===1?1:-1);let w=xa.toRadians(s),b=xa.toRadians(t);l.push(this.vectorStart());for(let C=1;C<T;C++)w+=b,l.push(new V(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=$e.getMatrix6FromMatrix(t);return Ei({...this.data,matrix:i},"ellipse")}};function oW(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 lW(e){let t=new ld(e),i=t.getMatrix(),r=t.vectorStart(),n=t.vectorEnd(),[s,a,o,l,c,u]=$e.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),x=Math.sin(m),y=s*g+o*x+c,E=a*g+l*x+u;p.push(new V(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 Ec(f.build())}function RN(e){let{matrix:t,tempMatrix:i}=e,r=$e.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 V(h[0],h[1]).multiply3(r);c.ext6(d.x,d.y)}let u=c.build();return Ec(u)}function cW(e){let t=Yi(e.tempD||e.d,!1),i=new ot;for(let n of t)for(let s of n.primitives)s instanceof Ue?i.ext1(s.bboxWithControls()):i.ext1(s.bbox());let r=i.build();return Ec(r)}function pE(e){let t=Yi(e.tempD||e.d,!1),i=new ot;for(let n of t)for(let s of n.primitives)if(s instanceof Ue){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 uW(e){let t=$e.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 hW(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 dW(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 pW(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 fW(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 mW(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 gW(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 MN={text:e=>uW(e),obj:e=>RN(e),ellipse:e=>oW(e),arc:e=>lW(e),rect:e=>RN(e),group:e=>cW(e),dimensionLength:e=>hW(e),dimensionAngle:e=>dW(e),dimensionRadius:e=>pW(e),dimension:e=>gW(e),auxiliaryLine:e=>fW(e),auxiliaryPoint:e=>mW(e),_runtime:e=>{switch(e.subCmdKey){case"select-box":return Ec(xt.extendRect(e));default:break}}},II=["text","obj","ellipse","rect","group","arc"];function fE(e,t){return xt.extendRect(Ei(e,t))}function Ei(e,t){return t=t||e.cmdKey,MN[t](e)}function BN(){let e=new Map;return t=>{if(e.has(t.gId))return e.get(t.gId);{let i=Ei(t);return e.set(t.gId,i),i}}}function mE(e){let t=new ot;for(let i of e)t.ext10(MN[i.cmdKey](i));return Ec(t.build())}function Ec(e){return{x:e.minX,y:e.minY,width:e.width(),height:e.height()}}async function kN(e,t={},i=F.gJsonCache){Tc(e)||(e=[e]),i||(i=F.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 mi.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}yW(n.cmdKey,a,s)}return i}function yW(e,t,i){for(let r in i){if(!Qe(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=tN.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 Tp=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){}};var Qs=class extends Tp{},br={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 gy=!1,yy,ea=class ea extends Qs{constructor(){super()}getSymbol(){return br.adapt_view_tool}static setAdaptAreaSelectionView(t){gy!==t&&(gy=t,t||this.hideSelectBox())}static isAdaptAreaSelectionView(){return gy}install(){console.log(this.getSymbol(),"installed"),yy=sN(J.selectBox1),J.svgRoot.appendChild(yy)}uninstall(){console.log(this.getSymbol(),"uninstalled"),dt(yy)}onMouseLeftUp(t){if(!gy)return;ea.leftClickTimes++;let{originalEvent:i}=t,{x:r,y:n}=Ti(i,!1);if(ea.leftClickTimes%2===1&&(ea.firstClickDot={x:r,y:n}),ea.leftClickTimes%2===0){let s={x:Math.min(ea.firstClickDot.x,r),y:Math.min(ea.firstClickDot.y,n),width:Math.abs(ea.firstClickDot.x-r),height:Math.abs(ea.firstClickDot.y-n)};pu(s,1),ea.hideSelectBox(),document.dispatchEvent(new MouseEvent("mousemove",{clientX:t.mouseX,clientY:t.mouseY}))}}onMouseRightUp(t){ea.isAdaptAreaSelectionView()&&bW(),t.toolFinished=!0}onMouseMove(t){if(!gy||ea.leftClickTimes%2===0)return;let{x:i,y:r}=ea.firstClickDot,{originalEvent:n}=t,{x:s,y:a}=Ti(n,!1),o=s-i,l=a-r;by(ea.firstClickDot.x,ea.firstClickDot.y,o,l,{target:yy})}static hideSelectBox(){du({target:yy}),ea.leftClickTimes=0}};ea.leftClickTimes=0;var wc=ea;function bW(){J.windowBridge.publish("toggleLinkbuttonActive",[["adaptAreaSelectionView"],!1],ut()),xr(),document.querySelector("#g1").classList.remove("none-events"),wc.setAdaptAreaSelectionView(!1)}var ni={renderer:null,history:null};var gE=class{constructor(t){this.id="selectBox1";this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}render(){return ni.renderer.attrs(this.id,{display:"",width:this.width,height:this.height,x:this.x,y:this.y,stroke:J.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=F.getRuntime(this.id)||{};return Object.assign(i,t)}setData(){F.setRuntime(this.id,this.toData())}multiply3(t){throw new Error("Method not implemented.")}rotateSelf(t,i){throw new Error("Method not implemented.")}};var Tn=(e,t={create8Dots:!1})=>{if(Array.isArray(e)&&e.length){if(e.length===1){let i=t.create8Dots&&Gs(e[0])||[],r=i.slice(0,8).concat(i[0],i[1]).join(" ");re(J.selectBox1,{display:"none"}),nh(r,"block"),["group"].includes(Qt(e[0]))&&jt.isAnchorMode(e[0].id)&&nh("","none")}else{let i=Mr(e,!0);by(i.x,i.y,i.width,i.height),new gE(i).render().setData(),Gs(J.selectBox1),nh("","none")}return}else console.error(e)};function nh(e,t=""){ni.renderer.attrs("ctrl-polyline",{points:e,display:t})}var CI=class{constructor(){this.controlDotArr=[];this.controlLineArr=[];this.bezierHandleArr=[];this.circleArr=[];this.handleInfo=[];this.anchorInfo=[];this.dotsInfo=[];this.addListener=FN(()=>{document.addEventListener("click",t=>{if(!J.doctype)return;let{target:i,ctrlKey:r}=t,{x:n,y:s}=Ti(t);!r&&this.isClickedAnchor(i,n,s)&&this.clickHandler(t)})});window.frameElement&&(this.gControlDotsContainer=de("gControlDots"),this.gControlLinesContainer=de("gControlLines"),this.addListener())}isClickedAnchor(t,i,r){if(Qt(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=wo(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 V(t,i);if(rh(n,this.anchorInfo.slice(0,4)))return null;let a,o=(16/J.gZoom)**2;for(let d of this.anchorInfo){let p=wo(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=de(r);s&&s.classList.remove("selected"),i.selected=!1}r===t&&(de(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?jt.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"?ni.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)&&To(r,"hide")}}showHandleOfIndexes(t){this.hideAll();for(let i of this.bezierHandleArr){let r=+i.dataset.belong||0;t.includes(r)&&To(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=de("gControlDots"),i=de("gControlRects"),r=de("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/J.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(),Eo(t))return this.mainV2(t);let i=t.length/2,r=t.isModifyAnchor,n=t.handleIndexes||new Map,s=4/J.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(ei(0,s.area()))return-1;let a=Qa();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(Ks(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];mt(o)&&console.error("check code"),u?re(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 Tt("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=he.scale(s,s).translate(r,n),o=$e.getMatrix6FromMatrix(a);return Tt("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/J.gZoom*2;return this.createRect(r,t,i,n,45)}createRect(t,i,r,n,s=0){let a=he.scale(n,n).rotateD(s).translate(i,r),o=$e.getMatrix6FromMatrix(a);return Tt("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:+re(r,"data-x"),y:+re(r,"data-y"),size:t,degree:+re(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=he.scale(s,s).rotateD(a).translate(r,n),l=$e.getMatrix6FromMatrix(o);ct.updateTransform(l,t)}hideAll(){return this.hideAllLines().hideAllHandle(),this.selectedCdotId=null,this}emptyData(){return this.anchorInfo=[],this}},ts=new CI;var xy=Object.freeze({});function Ey(e){return Object.prototype.toString.call(e).slice(8,-1)==="Set"}function mt(e){return e==null}function Fa(e){return e===void 0}function wp(e){return typeof e=="function"}var DI=class{sync(t,i,r){let n=new Pi(t),a=n.getMatrix().multiply3(i),o=$e.getMatrix6FromMatrix(a),l=n.getInverseMatrix(),c=new V(t.x1,t.y1).multiply3(l).multiply3(a),u=new V(t.x2,t.y2).multiply3(l).multiply3(a),h=a.isMirrored()?t.sweep===1?0:1:t.sweep,d=$e.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=pi.checkOne("arc",t,i);n!==!1&&pi.addCallBack(()=>{var s;n(),this.sync(t,i,r),(s=r==null?void 0:r.fn)==null||s.call(r),Pi.createHalfArc(t.gId)})}syncArcSize(t,i,r,n){let{x:s,y:a,width:o,height:l}=Ei(t),c=1,u=1;if(mt(r)||(c=r/o),mt(n)||(u=n/l),c===0||u===0||c===1&&u===1)return;let h=he.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 Pi(h).vectorCenter(),m=he.scale(h.rx,h.ry).rotateD(p||d).translate(f.x,f.y),g=[];for(let x of u){let y=new V(x[0],x[1]).multiply3(m);g.push(y.x,y.y)}return g}get8Dots2(t){let i=he.rotateD(-t.rotation).setOrigin(t.x1,t.y1),r=new Pi(t),s=r.getMatrix().multiply3(i),a=$e.getMatrix6FromMatrix(s),o=r.getInverseMatrix(),l=new V(t.x1,t.y1).multiply3(o).multiply3(s),c=new V(t.x2,t.y2).multiply3(o).multiply3(s),u=s.isMirrored()?t.sweep===1?0:1:t.sweep,h=$e.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}=Ei(d,"arc"),x=[[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=he.rotateD(t.rotation).setOrigin(t.x1,t.y1);for(let[T,w]of x){let b=new V(T,w).multiply3(E);y.push(b.x,b.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}=Ei(t);r=new V(n+a/2,s+o/2)}return he.rotateD(i-t.rotation).setOrigin1(r)}},sr=new DI;var fu=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(mc){let x=(await J.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=x[0],E=x[1],T=x[2];s=Math.max(s,E),o=a;let w=new Za(b=>(l.push(b),!0),!1);y.forEach(b=>b.forEach(C=>w.parse(C))),a+=T}else{let x=(await J.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=x[0],E=x[1],T=x[2];c=T,s=Math.max(s,E),o=a,y.forEach(w=>{for(let b of w)for(let C=0,A=b.ys.length;C<A;C++)b.ys[C]-=o,i.x&&(b.xs[C]+=+i.x),i.y&&(b.ys[C]-=+i.y);n.push(w)}),a+=T}}let u=n.length;for(let f=0;f<u;f++)n[f].forEach(g=>{let x=g.xs.length,y=[];for(let T=0;T<x;T++){let w=new V(this.toFix(g.xs[T],5),this.toFix(g.ys[T],5));y.push(w)}let E=Et.build4(y);l.push(E)});let h=he.translate(0,o);l=l.map(f=>f.multiply3(h));let d=ls(l,!1),p=new xt(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 GN(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)Qe(e,i.key)&&Object.assign(i,e[i.key]);return t}function UN(){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 EW={Common:[GN({lock:{checked:!1}}),UN()],"Hide inactive elements":[GN({hide:{visible:!1}}),UN()]},Gl={checked:!0,visible:!0},kue={"all-state":{visible:{...Gl},hide:{...Gl},lock:{visible:!0,checked:!1},unlock:{...Gl}},"all-element-type":{obj:{...Gl},group:{...Gl},rect:{...Gl},ellipse:{...Gl},text:{...Gl},arc:{...Gl},auxiliaryLine:{...Gl},dimension:{...Gl},dimensionLength:{...Gl}}},yE={};for(let e of EW.Common){let t=yE[e.allKey]={};for(let i of e.lists)t[i.key]={...i}}function Ga(){return yE}function Ty(e){return{auxiliaryPoint:"auxiliaryLine",dimensionAngle:"dimensionLength",dimensionRadius:"dimensionLength"}[e]||e}var Qo=class Qo{static invoke(t,i){if(Qo.hooks[t])return i?Qo.hooks[t].apply(null,i):Qo.hooks[t].apply();if(t.indexOf("draw(")===0||t.indexOf("place_")===0)return ud(t),!0;{let r=Qo.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}};Qo.hooks={},Qo.wildcardHooks={},Qo.registerHook=function(t,i){if(typeof t=="string")if(t.indexOf("*")>=0){let r="^"+t.replace(/\*/g,".*")+"$";Qo.wildcardHooks[r]=i}else Qo.hooks[t]=i;else if(t instanceof RegExp)Qo.wildcardHooks[t]=i;else for(let r of Object.keys(t))Qo.registerHook(r,t[r])};var wy=Qo;var bE=class bE{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!!wy.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;Ji(r,c)[l]=Zt(u)});let s=t.getCombHistory().map(o=>o[1]),a=new st().getAllCombinationData(s);for(let o of a)Ji(r,"combination")[o.gId]=Zt(o);return r}static record(t,i){switch(t){case 0:{i(),bE.add({type:0,data:Zt(F.getJsonCacheByIds(at.getLastRecordPrimitiveIds()))});break}}}};bE.stack=[];var Vr=bE,PI={[gn.draw]:TW,[gn.drag]:wW,[gn.delete]:SW,[gn.rotate]:vW,[gn.paste]:AW,[gn.duplicateTo]:DW,[gn.lock]:CW,[gn.eleVisable]:IW,[gn.pasteInPlace]:PW};function Ea(e){return function(t){var i;return(i=PI[e])==null||i.call(PI,t),t}}function TW(e){let{next:t}=e;e.next=function(...i){if(!["draw(origin)"].includes(J.cmdToken)){if(["draw(polygon)","draw(polyline)"].includes(J.cmdToken))return t.call(this,...i);Vr.record(0,t.bind(this,...i))}}}function wW(e){let{onMouseLeftUp:t}=e.prototype;return e.prototype.onMouseLeftUp=function(...i){t.call(this,...i),(this.accumulateX||this.accumulateY)&&Vr.add({type:2,movement:new V(this.accumulateX,this.accumulateY)})},e}function SW(e){let{do:t}=e.prototype;e.prototype.do=function(...i){let r=t.call(this,...i);return Vr.add({type:4}),r}}function vW(e){let{do:t}=e.prototype;e.prototype.do=function(...i){t.call(this,...i),this.success&&Vr.add({type:3,degree:this.degree})}}function IW(e){let{toggleElementsDisplay:t,toggleVisible:i}=e;e.toggleElementsDisplay=function(...r){t.call(this,...r);let n=r[1];Vr.add({type:10,isVisable:n})},e.toggleVisible=function(...r){i.call(this,...r);let n=r[1];Vr.add({type:10,isVisable:n})}}function AW(e){let{onMouseLeftDown:t}=e.prototype;e.prototype.onMouseLeftDown=function(...i){t.call(this,...i),["ctrl_drag_copy","ctrl_drag_copy2"].includes(this.type)?Vr.add({type:8,data:Vr.getJsonCacheByJsonSnapshot(this.jsonSnapshot),movement:this.accmulate}):Vr.add({type:6,data:Vr.getJsonCacheByJsonSnapshot(this.jsonSnapshot)})}}function CW(e){let{unlockAll:t,setCombinationLockStatus:i,setLockStatus:r,setElementsLockStatus:n}=e.prototype;e.prototype.unlockAll=function(...s){t.call(this,...s),Vr.add({type:5,locked:!1})},e.prototype.setCombinationLockStatus=function(...s){let a=s[1];i.call(this,...s),Vr.add({type:5,locked:a})},e.prototype.setLockStatus=function(...s){let a=s[1];r.call(this,...s),Vr.add({type:5,locked:a})},e.prototype.setElementsLockStatus=function(...s){let a=s[1];n.call(this,...s),Vr.add({type:5,locked:a})}}function DW(e){let{do:t}=e;e.do=async function(...i){let r=await t.call(this,...i);return Vr.add({type:7,data:Zt(Vr.getJsonCacheByJsonSnapshot(e.snap)),movement:r.movement}),r}}function PW(){Vr.add({type:11})}function el(e){if(typeof e=="number")switch(ft(fr(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 Sp(e,t,i,r=Z1){let n=new V(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 te(s,a)}function TE(e,t){if(e.length!==0)for(let i of e){let{data:r,view:n}=i;LW(r,t),OW(n,{x:r.x1,y:r.y1},{x:r.x2,y:r.y2})}}function LW(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=sE(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 OW(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 wE(e){switch(el(e)){case"horizontal":return"Horizontal Auxiliary Line";case"vertical":return"Vertical Auxiliary Line";default:return"Auxiliary Line"}}function Am(e,t){e.setAttribute("r",String(t))}var mu=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):Tt("line");if(!s)throw new Error("err");return re(s,n),s}getTextBBox(t){let i=Tt("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/J.gZoom,fill:"black",...r}),s=this.container?this.container.querySelector("#"+i):Tt("circle");if(!s)throw new Error("err");return re(s,n),s}extendPoint(t,i,r){let n=new V(t.x,t.y),s=new V(i.x,i.y),a=s.angleD(n),o=s.rotateD(n,-a),l=new V(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 V(o[0],o[1])).map(o=>o.rotateD(new V(0,0),i)).map(o=>o.add(r)).map(o=>[o.x,o.y]).flat().join(" "),a=this.container?this.container.querySelector("#"+n):Tt("polyline");return re(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 _I=class{sync(t,i,r){let s=Yi(t.d,!1).map(o=>o.multiply3(i)),a=ls(s,!1,.01,{reverseY:!1});ni.renderer.attr(t.gId,"d",a),t.tempD=a,r.updateD&&(t.d=a)}syncGroup(t,i,r){let n=pi.checkOne("group",t,i);n!==!1&&pi.addCallBack(()=>{var s;wp(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}=Ei(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 he.rotateD(i-c).setOrigin(l.x,l.y)}syncGroupSize(t,i,r,n){let{x:s,y:a,width:o,height:l}=cs(de(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=he.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}=YN(t),l={x:n+a/2,y:s+o/2},c=he.rotateD(-(0-i)).setOrigin(l.x,-l.y),h=Yi(r).map(y=>y.multiply3(c)),d=new ot;for(let y of h)for(let E of y.primitives)if(E instanceof Ue){let T=new ot;E.getBezierPoints(.5,b=>{T.ext2(b)});let w=T.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=he.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]],x=[];for(let y of g){let E=new V(y[0],y[1]).multiply3(m);x.push(E.x,-E.y)}return x}},Gn=new _I;var Ul=class{constructor(t){this.data=t}getAuxiliaryLinePrimitive(t,i,r,n=Z1){let s=new V(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 te(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=sE(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(xt.extendRect((l=J.svgRoot)==null?void 0:l.viewBox.animVal));let{gId:t,x1:i,y1:r,x2:n,y2:s,strokeColor:a,strokeStyle:o}=this.data;ni.renderer.attrs(t,{x1:i,x2:n,y1:r,y2:s,stroke:a,"stroke-dasharray":Pn.lineStyle[o]})}toData(){}setData(){}unmount(){dt(de(this.data.gId))}multiply3(t){let i=new V(this.data.x1,this.data.y1),r=new V(this.data.x2,this.data.y2),{x:n,y:s}=i.multiply3(t),{x:a,y:o}=r.multiply3(t),l=ft(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=he.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 he;return Fa(t)||(r=r.multiply3(he.MIRROR_X)),Fa(i)||(r=r.multiply3(he.MIRROR_Y)),r.setOrigin(t||0,i||0)}};var hn=class e extends mu{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,Fa(i.visible)&&(i.visible=!0),this.visible=i.visible,Fa(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 V(this.angleX,this.angleY)}setStart(i,r){return this.x1=i,this.y1=r,this}vectorStart(){return new V(this.x1,this.y1)}getStartAngle(){let i=this.vectorStart().angleD2(this.vectorAngle());return fr(i)}getEndAngle(){let i=this.vectorEnd().angleD2(this.vectorAngle());return fr(i)}setEnd(i,r){return this.x2=i,this.y2=r,this}vectorEnd(){return new V(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=F.getDimensionAngle(this.gId);return Nt(r)?i:(Object.assign(r,i),r)}setData(){let i=this.toData();return F.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 V(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(mt(i)){let o=this.getBBox();i=new V(o.x+o.width/2,o.y+o.height/2)}let r=he.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(mt(i)){let o=this.getBBox();i=new V(o.x+o.width/2,o.y+o.height/2)}let r=he.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=Tt("g",{id:this.gId,c_partid:"dimensionAngle",class:"dimensionAngle",layer:8,display:this.visible?"":"none"});this.container=h,i===!1&&tt.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=aE(this.vectorStart(),this.vectorAngle(),this.vectorEnd())||0,r=xa.toDegrees(i);return ft(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 V(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"):Tt("text",{x:0,y:0}),n=r.getBBox();return!n.width&&!n.height&&(n=this.getTextBBox(r.textContent)),r.textContent=i+"\xB0",{matrix:he.scale(.5,.5).translate(this.textX,this.textY),text:r,bbox:n}}getTextBBoxOutline(){let{matrix:i,bbox:r}=this.getTextMatrix(),n=xt.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=$e.getMatrix6FromMatrix(n);return i?{m3:n,textContent:r.textContent}:(ct.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 V(this.textX,this.textY)}renderArc(i=!1){let r=this.arcOffsetX,n=["M"],s=new V(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=fr(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"):Tt("path");return re(d,h),d}findContainsControlPoint(i,r){let n=5/J.gZoom;return Zo(i,r,this.x1,this.y1,n)?this.getCircleId("start"):Zo(i,r,this.x2,this.y2,n)?this.getCircleId("end"):Zo(i,r,this.textX,this.textY,n)?this.getCircleId("text"):Zo(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(){F.iteratorDimensionAngle(i=>{let r=new e(i).render();r=null})}};var dn=class e extends mu{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,mt(i.measureX1)||this.initTextPosition(),this.direction=i.direction,this.container=i.gId&&document.getElementById(i.gId),Fa(i.visible)&&(i.visible=!0),this.visible=i.visible,Fa(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}=is.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=F.getDimensionLength(this.gId);return Nt(r)?i:(Object.assign(r,i),r)}setData(){return F.setDimension(this.gId,this.toData(),"dimensionLength"),this}setStart(i,r){return this.x1=i,this.y1=r,this}vectorStart(){return new V(this.x1,this.y1)}setEnd(i,r){return this.x2=i,this.y2=r,this}vectorEnd(){return new V(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=$s([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 V(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}=is.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=Tt("g",{id:this.gId,class:"dimensionLength",c_partid:"dimensionLength",layer:8,display:this.visible?"":"none"});this.container=d,!i&&tt.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 V(this.measureStart.x,this.measureStart.y),n=new V(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"+re(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/J.gZoom,s=this.getMidTextPoint();return Zo(i,r,s.x,s.y,n)?this.getKeyDotId("text"):Zo(i,r,this.x1,this.y1,n)?this.getKeyDotId("start"):Zo(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 V(this.measureStart.x,this.measureStart.y),s=new V(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"+re(a,"points"):a}renderStartLine(i=!1){let r=this.vectorStart(),n=this.measureStart;return Zs(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 Zs(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 dy(this.measureStart,this.measureEnd)}getTextMatrix(){let i=this.container?this.container.querySelector("text"):Tt("text",{x:0,y:0}),r=this.calcLengthPixel(),n=this.measureStart,s=this.measureEnd,a=ft(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 V(n.x,n.y),u=new V(s.x,s.y).angleD(c);s.x<n.x&&(c=new V(s.x,s.y),u=new V(n.x,n.y).angleD(c));let h=he.translate(l.x-o.width/2,l.y-o.height/2).rotateD(u).setOrigin(l.x,l.y);return h=h.multiply3(he.scale(.5,.5).setOrigin(l.x,l.y)),{text:i,matrix:h,bbox:o}}getTextBBoxOutline(){let{matrix:i,bbox:r}=this.getTextMatrix(),n=xt.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=$e.getMatrix6FromMatrix(n);return ct.updateTransform(s,r),r}updateDistance(i){let r=new V(this.measureStart.x,this.measureStart.y),n=new V(this.measureEnd.x,this.measureEnd.y),s=n.angleD2(r);this.direction==="xy"&&s===0&&(s=new V(this.x1,this.y1).angleD2(r)+90);let a=new V(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(){F.iteratorDimensionLength(i=>{let r=new e(i).render();r=null})}};var us=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 Iy=1e-4,fe=new Float64Array(100);function Sc(e,t){if(e instanceof te&&t instanceof te)return Pm(e,t);if(e instanceof Te&&t instanceof te)return LI(e,t);if(e instanceof te&&t instanceof Te)return LI(t,e);if(e instanceof Te&&t instanceof Te)return MW(e,t);if(e instanceof Ue&&t instanceof Ue)return SE(e,t);if(e instanceof Ue&&t instanceof te)return SE(e,new Ue([t.start(),t.end()]));if(e instanceof te&&t instanceof Ue)return SE(new Ue([e.start(),e.end()]),t);if(e instanceof Ue&&t instanceof Te)return WN(t,e);if(e instanceof Te&&t instanceof Ue)return WN(e,t);throw new Error("not supported operation")}function qN(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=Sc(o,l)>0,a)),a)),a}function JN(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new te(new V(i.minX-1,t),new V(i.maxX+1,t));return Pm(r,e)>0?1:0}else return 0}function KN(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new te(new V(i.minX-1,t),new V(i.maxX+1,t));return Ay(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function $N(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new te(new V(i.minX-1,t),new V(i.maxX+1,t)),n=Ay(e,r);return n>0?n:0}else return 0}else throw new Error("not supported operation")}function Cy(e,t){let i=e.bbox();return i.isContainsY1(t)&&SE(new Ue([new V(i.minX-1,t),new V(i.maxX+1,t)]),e)>0?1:0}function HN(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function RW(e,t){let i=us.crossProd3(t.start(),t.end(),e.start()),r=us.crossProd3(t.start(),t.end(),e.end());return Math.abs(i)<1e-8||Math.abs(r)<1e-8||i*r<0}function Pm(e,t){let i=e.bbox().intersection1(t.bbox());if(!i)return 0;if(e.isPoint())if(t.isPoint()){let r=i.center();return fe[0]=r.x,fe[1]=r.y,2}else return jN(t,e,i);else{if(t.isPoint())return jN(e,t,i);{let y=function(E,T){i.isContains2(E,T)&&(fe[x++]=E,fe[x++]=T)};if(!RW(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=us.crossProd2(r,n,o,l,c,u)/h,p=us.crossProd2(s,a,o,l,c,u)/h;if(d*p>0&&!Ye.eq(d,0)&&!Ye.eq(p,0))return 0;let f=e.length(),m=us.crossProd2(o,l,r,n,s,a)/f,g=us.crossProd2(c,u,r,n,s,a)/f;if(m*g>0&&!Ye.eq(m,0)&&!Ye.eq(g,0))return 0;let x=0;if(Ye.eq(d,0)&&Ye.eq(p,0)){let E=i.UL(),T=i.UR(),w=i.LL(),b=i.LR();if(Ye.eq(i.width(),0))Ye.eq(i.height(),0)?(fe[x++]=E.x,fe[x++]=E.y):(fe[x++]=E.x,fe[x++]=E.y,fe[x++]=w.x,fe[x++]=w.y);else if(Ye.eq(i.height(),0))fe[x++]=E.x,fe[x++]=E.y,fe[x++]=T.x,fe[x++]=T.y;else{let C=bm.area2(E.x,E.y,o,l,c,u),A=bm.area2(T.x,T.y,o,l,c,u);C<A?(fe[x++]=E.x,fe[x++]=E.y,fe[x++]=b.x,fe[x++]=b.y):(fe[x++]=T.x,fe[x++]=T.y,fe[x++]=w.x,fe[x++]=w.y)}}else if(Ye.eq(d,0))y(r,n);else if(Ye.eq(p,0))y(s,a);else{let E=Math.abs(d/(d-p));y(r+(s-r)*E,n+(a-n)*E)}return x}}}function jN(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 fe[0]=o.x,fe[1]=o.y,2}else if(Math.abs(s)<Math.abs(a)){if(Ye.eq(s/Math.sqrt(e.a**2+e.b**2),0))return fe[0]=r.x,fe[1]=r.y,2}else if(Ye.eq(a/Math.sqrt(e.a**2+e.b**2),0))return fe[0]=n.x,fe[1]=n.y,2;return 0}function Ay(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(Iy);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=Ye.eq(h,s)?0:h>s?1:-1,f=Ye.eq(d,s)?0:d>s?1:-1,m=0;if(p===-1&&f===-1)return 0;if(p===0&&f===0)fe[m++]=o,fe[m++]=l,fe[m++]=c,fe[m++]=u;else if(p===1&&f===1){let g=yu.foot(t,e.center),x=g.distance1(e.center);if(Ye.greater(x,s))return 0;if(Ye.eq(x,s))Ye.eq(t.distance2(e.start()),0)?(fe[m++]=e.start().x,fe[m++]=e.start().y,fe[m++]=e.start().x,fe[m++]=e.start().y):Ye.eq(t.distance2(e.end()),0)?(fe[m++]=e.end().x,fe[m++]=e.end().y,fe[m++]=e.end().x,fe[m++]=e.end().y):(fe[m++]=g.x,fe[m++]=g.y,fe[m++]=g.x,fe[m++]=g.y);else{m=NW(r,n,o,l,c,u,m);let y=fe[m-2],E=fe[m-1],T=us.distance1(r,n,y,E);if(m-=2,Ye.eq(T,s))fe[m++]=y,fe[m++]=E;else if(T<s)m=tl(a,r,n,o,l,y,E,m),m=tl(a,r,n,y,E,c,u,m);else return 0}}else if(p===-1||f===-1)m=tl(a,r,n,o,l,c,u,m);else{let g=yu.foot(t,e.center),x=g.distance1(e.center);if(Ye.eq(x,s)){let T=function(w){return HN(i,w.x,w.y)&&Er(e,w)},y=e.start(),E=e.end();if(p===0){let w=t.start();if(T(w))return fe[m++]=w.x,fe[m++]=w.y,fe[m++]=w.x,fe[m++]=w.y,m;if(T(g))return fe[m++]=g.x,fe[m++]=g.y,fe[m++]=g.x,fe[m++]=g.y,m;if(Ye.eq(t.distance2(y),0)&&T(y))return fe[m++]=y.x,fe[m++]=y.y,fe[m++]=y.x,fe[m++]=y.y,m;if(Ye.eq(t.distance2(E),0)&&T(E))return fe[m++]=E.x,fe[m++]=E.y,fe[m++]=E.x,fe[m++]=E.y,m;if(h<=s)m=tl(a,r,n,g.x,g.y,c,u,m),m===2&&(fe[m++]=fe[0],fe[m++]=fe[1]);else if(x<s){if(m=tl(a,r,n,g.x,g.y,c,u,m),m===2&&T(new V(fe[0],fe[1])))return fe[m++]=fe[0],fe[m++]=fe[1],m;m=tl(a,r,n,g.x,g.y,o,l,0),m===2&&(fe[m++]=fe[0],fe[m++]=fe[1])}}else{let w=t.end();if(T(w))return fe[m++]=w.x,fe[m++]=w.y,fe[m++]=w.x,fe[m++]=w.y,m;if(T(g))return fe[m++]=g.x,fe[m++]=g.y,fe[m++]=g.x,fe[m++]=g.y,m;if(Ye.eq(t.distance2(y),0)&&T(y))return fe[m++]=y.x,fe[m++]=y.y,fe[m++]=y.x,fe[m++]=y.y,m;if(Ye.eq(t.distance2(E),0)&&T(E))return fe[m++]=E.x,fe[m++]=E.y,fe[m++]=E.x,fe[m++]=E.y,m;if(d<=s)m=tl(a,r,n,g.x,g.y,o,l,m),m===2&&(fe[m++]=fe[0],fe[m++]=fe[1]);else if(x<s){if(m=tl(a,r,n,g.x,g.y,o,l,m),m===2&&T(new V(fe[0],fe[1])))return fe[m++]=fe[0],fe[m++]=fe[1],m;m=tl(a,r,n,g.x,g.y,c,u,0),m===2&&(fe[m++]=fe[0],fe[m++]=fe[1])}}}else if(p===0){let y=t.start();fe[m++]=y.x,fe[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=tl(a,r,n,g.x,g.y,c,u,m))}else{let y=t.end();fe[m++]=y.x,fe[m++]=y.y,(o-g.x)*(c-g.x)+(l-g.y)*(u-g.y)<0&&(m=tl(a,r,n,g.x,g.y,o,l,m))}}if(m>0){let g=0;for(let x=0;x<m;x+=2){let y=fe[x],E=fe[x+1];isFinite(y)&&isFinite(E)&&HN(i,y,E)&&Er(e,new V(y,E))&&(fe[g++]=y,fe[g++]=E)}return g}else return 0}else return 0}function tl(e,t,i,r,n,s,a,o){if(n==a){let E=e-(n-i)*(n-i);if(Ye.greater(E,0)){let T=Math.sqrt(E),w=t-T,b=t+T,C=Math.min(r,s),A=Math.max(r,s);return w>=C&&w<=A&&(fe[o++]=w,fe[o++]=n),b>=C&&b<=A&&(fe[o++]=b,fe[o++]=n),o}}let l=us.distance2(r,n,t,i)-e,c=us.distance2(s,a,t,i)-e,u=r,h=n,d=s,p=a,f=NaN,m=NaN,g=Number.POSITIVE_INFINITY,x=0;for(;g!==0;){x++;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=us.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)-us.distance1(f,m,t,i);return(Ye.eq(0,g)||Ye.eq(0,y))&&(fe[o++]=f,fe[o++]=m),o}function NW(e,t,i,r,n,s,a){if(us.crossProd2(i,r,n,s,e,t)==0){let l=us.dotProd2(i,r,n,s,e,t),c=us.dotProd2(n,s,i,r,e,t);return l<0&&c<0?(fe[a++]=e,fe[a++]=t,a):l>=0?(fe[a++]=n,fe[a++]=s,a):(fe[a++]=i,fe[a++]=r,a)}else{let l=NaN,c=NaN,u=i,h=r,d=n,p=s,f=us.distance2(i,r,e,t),m=us.distance2(n,s,e,t),g=Number.POSITIVE_INFINITY,x=0;for(;g>0&&(x++,l=u+(d-u)*.5,c=h+(p-h)*.5,!(f==m||u==l&&h==c||d==l&&p==c));){g=us.distance2(l,c,e,t);let y=us.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 fe[a++]=l,fe[a++]=c,a}}function LI(e,t){if(e.rx===e.ry)return Ay(e,t);throw new Error("not supported")}function MW(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return BW(e,t);throw new Error("not supported operation")}return 0}function BW(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(Ye.greater(u,d)||Ye.less(u,h))return 0;if(Ye.eq(u,d)){if(VN(e,t))return 4;let p=new te(e.center,t.center),f=Ay(t,p);return f=zN(e,f),f!==0?f:(f=Ay(e,p),zN(t,f))}else if(Ye.greater(h,0)&&Ye.greater(u,0)&&Ye.eq(u,h)){if(VN(e,t))return 4;if(a>o){let p=(a-o)/a;return fe[0]=i+(n-i)/p,fe[1]=r+(s-r)/p,XN(e,t,2)}else{let p=(o-a)/o;return fe[0]=n+(i-n)/p,fe[1]=s+(r-s)/p,XN(e,t,2)}}else if(Ye.eq(h,0)&&Ye.eq(u,0)){let p=0,f;return Er(e,t.start())&&(fe[p]=t.start().x,fe[p+1]=t.start().y,p+=2,f=t.start()),Er(e,t.end())&&(fe[p]=t.end().x,fe[p+1]=t.end().y,p+=2,f=t.end()),p===0?(Er(t,e.start())&&(fe[p]=e.start().x,fe[p+1]=e.start().y,p+=2),Er(t,e.end())&&(fe[p]=e.end().x,fe[p+1]=e.end().y,p+=2)):p===2&&(!f.equals1(e.start())&&Er(t,e.start())&&(fe[p]=e.start().x,fe[p+1]=e.start().y,p+=2),!f.equals1(e.end())&&Er(t,e.end())&&(fe[p]=e.end().x,fe[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,x=n-i,y=s-r,E=Math.max(a,o),T,w,b,C;if(Math.abs(x)<Math.abs(y)){let M=x/-y,k=g-M*m;T=m-E,w=M*T+k,b=m+E,C=M*b+k}else{let M=y/-x,k=m-M*g;w=g-E,T=M*w+k,C=g+E,b=M*C+k}let A=tl(l,i,r,T,w,m,g,0);if(A=tl(l,i,r,m,g,b,C,A),A!==4)throw new Error("cnt !== 4");let R=new V(fe[0],fe[1]),O=new V(fe[2],fe[3]);if(Er(e,R)&&Er(t,R))return Er(e,O)&&Er(t,O)?4:hd(e.start(),t,O,R)?(fe[2]=e.start().x,fe[3]=e.start().y,4):hd(e.end(),t,O,R)?(fe[2]=e.end().x,fe[3]=e.end().y,4):hd(t.start(),e,O,R)?(fe[2]=t.start().x,fe[3]=t.start().y,4):hd(t.end(),e,O,R)?(fe[2]=t.end().x,fe[3]=t.end().y,4):2;if(Er(e,O)&&Er(t,O))return hd(e.start(),t,R,O)?(fe[0]=e.start().x,fe[1]=e.start().y,4):hd(e.end(),t,R,O)?(fe[0]=e.end().x,fe[1]=e.end().y,4):hd(t.start(),e,R,O)?(fe[0]=t.start().x,fe[1]=t.start().y,4):hd(t.end(),e,R,O)?(fe[0]=t.end().x,fe[1]=t.end().y,4):(fe[0]=fe[2],fe[1]=fe[3],2);{let H=function(q,I){if(Ye.eq(q.distance1(I.center),I.rx)&&Er(I,q)){if(q.distance2(R)<q.distance2(O)){if(M)return;M=!0}else{if(k)return;k=!0}fe[G++]=q.x,fe[G++]=q.y}},M=!1,k=!1,G=0;return H(e.start(),t),H(e.end(),t),H(t.start(),e),H(t.end(),e),G}}}function hd(e,t,i,r){return Ye.eq(e.distance1(t.center),t.rx)&&Er(t,e)&&e.distance2(i)<e.distance2(r)}function VN(e,t){return Ye.eq(t.start().distance1(e.center),e.rx)&&Er(e,t.start())?(fe[0]=t.start().x,fe[1]=t.start().y,fe[2]=t.start().x,fe[3]=t.start().y,!0):Ye.eq(t.end().distance1(e.center),e.rx)&&Er(e,t.end())?(fe[0]=t.end().x,fe[1]=t.end().y,fe[2]=t.end().x,fe[3]=t.end().y,!0):Ye.eq(e.start().distance1(t.center),t.rx)&&Er(t,e.start())?(fe[0]=e.start().x,fe[1]=e.start().y,fe[2]=e.start().x,fe[3]=e.start().y,!0):Ye.eq(e.end().distance1(t.center),t.rx)&&Er(t,e.end())?(fe[0]=e.end().x,fe[1]=e.end().y,fe[2]=e.end().x,fe[3]=e.end().y,!0):!1}function zN(e,t){if(t===0)return 0;let i=fe[0],r=fe[1];return Er(e,new V(i,r))?(fe[0]=i,fe[1]=r,fe[2]=i,fe[3]=r,4):0}function XN(e,t,i){if(i===0)return 0;let r=fe[0],n=fe[1],s=new V(r,n);return Er(e,s)&&Er(t,s)?(fe[0]=r,fe[1]=n,fe[2]=r,fe[3]=n,4):0}function Dm(e,t){return Math.abs(e-t)<=1e-6}function Er(e,t){let i=e.bbox();if(t.x-i.minX>-Iy&&t.x-i.maxX<Iy&&t.y-i.minY>-Iy&&t.y-i.maxY<Iy){let r=xa.regularD(t.angleD(e.center));return Dm(r,e.startAngle)||Dm(r,e.startAngle+360)||Dm(r,e.startAngle-360)||Dm(r,e.endAngle())||Dm(r,e.endAngle()+360)||Dm(r,e.endAngle()-360)?!0:e.sweepAngle>0?(Ye.less(r,e.startAngle)&&(r+=360),Ye.greatereq(e.endAngle(),r)):(Ye.greater(r,e.startAngle)&&(r-=360),Ye.lesseq(e.endAngle(),r))}else return!1}var hs=new Float64Array(100);function SE(e,t){if(e.bbox().extendOfSize(Ye.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 O=function(q){A=Math.min(A,q),R=Math.max(R,q)},G=function(q,I){let N=Pm(q,I);if(N===0)throw new Error("cnt === 0");for(let v=0;v<N;v+=2)O(fe[v])};if(n>r){for(let q=n-2;q>=2;q-=2)for(let I=q-2;I>=0;I-=2)if(Ye.eq(hs[q],hs[I])&&Ye.eq(hs[q+1],hs[I+1])){hs[I]=(hs[q]+hs[I])/2,hs[I+1]=(hs[q+1]+hs[I+1])/2;for(let N=n-3;N>=q;N--)hs[N]=hs[N+2];n-=2;break}if(n>r){n=0;let q=t.start(),I=new Float64Array(8);e.getPercent(q)!==null&&(I[n++]=q.x,I[n++]=q.y);let N=t.end();e.getPercent(N)!==null&&(I[n++]=N.x,I[n++]=N.y);let v=e.start();t.getPercent(v)!==null&&(I[n++]=v.x,I[n++]=v.y);let L=e.end();return t.getPercent(N)!==null&&(I[n++]=L.x,I[n++]=L.y),fe.set(I),n}}let[s,a]=i.pop(),o=s.controls,l=a.controls;if(o.length===2&&l.length===2){let q=Pm(new te(o[0],o[1]),new te(l[0],l[1]));for(let I=0;I<q;I++)hs[n++]=fe[I];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 I=h*q.x+d*q.y+p;I<m&&(m=I),I>g&&(g=I)}),Ye.eq(m,g)){if(a.controls.length===2){let q=Pm(new te(s.start(),s.end()),new te(a.start(),a.end()));for(let I=0;I<q;I++)hs[n++]=fe[I];if(q!==0)continue}s=new Ue([o[0],o[o.length-1]]),o=s.controls}let x=l.map(q=>h*q.x+d*q.y+p),y=0;for(let q of x){if(Ye.less(q,m))y=y|1;else if(Ye.greater(q,g))y=y|2;else{y=3;break}if(y===3)break}if(y!==3)continue;let E=0,T=0,w=u.x-c.x,b=u.y-c.y,C=Math.sqrt(1/(w**2+b**2));w*=C,b*=C;for(let q=1;q<o.length;q++){let I=o[q],N=(I.x-c.x)*w+(I.y-c.y)*b;N<E?E=N:N>T&&(T=N)}y=0;for(let q of l){let I=(q.x-c.x)*w+(q.y-c.y)*b;if(Ye.less(I,E))y=y|1;else if(Ye.greater(I,T))y=y|2;else{y=3;break}if(y===3)break}if(y!==3)continue;let A=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY;m-=Ye.eps,g+=Ye.eps,x.forEach((q,I)=>{q>=m&&q<=g&&O(I/(x.length-1))});let M=new te(new V(0,m),new V(1,m)),k=new te(new V(0,g),new V(1,g));for(let q=0;q<x.length-1;q++){let I=new V(q/(x.length-1),x[q]),N=I.y<m?1:I.y>g?2:3;for(let v=0;v<x.length;v++){let L=new V(v/(x.length-1),x[v]),_=L.y<m?1:L.y>g?2:3;N!==_&&(N===1?_===2?(G(new te(I,L),M),G(new te(I,L),k)):G(new te(I,L),M):N===2?_===1?(G(new te(I,L),M),G(new te(I,L),k)):G(new te(I,L),k):_===1?G(new te(I,L),M):G(new te(I,L),k))}}A!==0&&(a=a.clip(A)[1]),R!==1&&(a=a.clip((R-A)/(1-A))[0]);let H=a.bbox();if(Ye.eq(H.minX,H.maxX)&&Ye.eq(H.minY,H.maxY)){y=0;for(let q of a.controls){let I=(q.x-c.x)*w+(q.y-c.y)*b;if(Ye.less(I,E))y=y|1;else if(Ye.greater(I,T))y=y|2;else{y=3;break}if(y===3)break}y===3&&(hs[n++]=(H.minX+H.maxX)/2,hs[n++]=(H.minY+H.maxY)/2);continue}if(R-A>.8){let[q,I]=a.clip(.5);i.push([q,s]),i.push([I,s])}else i.push([a,s])}for(let s=0;s<n;s++)fe[s]=hs[s];return n}function WN(e,t){if(e.bbox().extendOfSize(Ye.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=0;for(;i.length!==0;){let n=i.pop();if(n[0]instanceof Te){let A=function(G){b=Math.min(b,G),C=Math.max(C,G)},M=function(G,H){let q=Pm(G,H);if(q===0)throw new Error("cnt === 0");for(let I=0;I<q;I+=2)A(fe[I])},[s,a]=n,o=a.controls;if(o.length===2){let G=LI(s,new te(o[0],o[1]));for(let H=0;H<G;H++)hs[r++]=fe[H];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 H=d*s.center.x+p*s.center.y+f;s.isCCW?(c=s.rx+H,l=0):(l=H-s.rx,c=0)}let m=o.map(G=>d*G.x+p*G.y+f),g=0;for(let G of m){if(Ye.less(G,l))g=g|1;else if(Ye.greater(G,c))g=g|2;else{g=3;break}if(g===3)break}if(g!==3)continue;let x=0,y=0,E=h.x-u.x,T=h.y-u.y,w=Math.sqrt(1/(E**2+T**2));if(E*=w,T*=w,Math.abs(s.sweepAngle)<=180)x=0,y=(h.x-u.x)*E+(h.y-u.y)*T;else throw new Error("not support");g=0;for(let G of o){let H=(G.x-u.x)*E+(G.y-u.y)*T;if(Ye.less(H,x))g=g|1;else if(Ye.greater(H,y))g=g|2;else{g=3;break}if(g===3)break}if(g!==3)continue;let b=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY;l-=Ye.eps,c+=Ye.eps,m.forEach((G,H)=>{G>=l&&G<=c&&A(H/(m.length-1))});let R=new te(new V(0,l),new V(1,l)),O=new te(new V(0,c),new V(1,c));for(let G=0;G<m.length-1;G++){let H=new V(G/(m.length-1),m[G]),q=H.y<l?1:H.y>c?2:3;for(let I=0;I<m.length;I++){let N=new V(I/(m.length-1),m[I]),v=N.y<l?1:N.y>c?2:3;q!==v&&(q===1?v===2?(M(new te(H,N),R),M(new te(H,N),O)):M(new te(H,N),R):q===2?v===1?(M(new te(H,N),R),M(new te(H,N),O)):M(new te(H,N),O):v===1?M(new te(H,N),R):M(new te(H,N),O))}}b!==0&&(a=a.clip(b)[1]),C!==1&&(a=a.clip((C-b)/(1-b))[0]);let k=a.bbox();if(Ye.eq(k.minX,k.maxX)&&Ye.eq(k.minY,k.maxY)){g=0;for(let G of a.controls){let H=(G.x-u.x)*E+(G.y-u.y)*T;if(Ye.less(H,x))g=g|1;else if(Ye.greater(H,y))g=g|2;else{g=3;break}if(g===3)break}g===3&&(hs[r++]=(k.minX+k.maxX)/2,hs[r++]=(k.minY+k.maxY)/2);continue}C-b>.8?a.clip(.5).forEach(G=>i.push([G,s])):i.push([a,s])}else{let[s,a]=n;i.push([Te.build3(a.center,a.startAngle,a.sweepAngle/2,a.rx,a.ry),s]),i.push([Te.build3(a.center,a.startAngle+a.sweepAngle/2,a.sweepAngle/2,a.rx,a.ry),s])}}for(let n=0;n<r;n++)fe[n]=hs[n];return r}var yu=class e{constructor(t,i){this.minDistance=Number.MAX_VALUE;this.p=t,this.p1=i,this.intersection()?(this.minDistance=0,this.minline=new te(V.ORIGIN,V.ORIGIN)):this.minline=this.minLine()}getDistance(){return this.minDistance}getLine(){return this.minline}intersection(){return Sc(this.p,this.p1)>0}minLine(){if(this.p instanceof te&&this.p1 instanceof te){let t=this.p,i=this.p1;return this.minDistanceForLines(t,i,this.minline)}else if(this.p instanceof Te&&this.p1 instanceof te){let t=this.p,i=this.p1;return this.minDistanceForLineAndArc(t,i,this.minline)}else if(this.p instanceof te&&this.p1 instanceof Te){let t=this.p1,i=this.p;return this.minDistanceForLineAndArc(t,i,this.minline)}else if(this.p instanceof Te&&this.p1 instanceof Te){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),Er(t,i.center)&&Er(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 te(new V(a,s),r);n=t.rx-n,n<this.minDistance&&(this.minDistance=n,i=o)}else{let s=new te(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 Er(t,a)&&(r=this.arcShortestLine(i,r,a,l),r=this.arcShortestLine(i,r,a,c)),Er(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 te(t.start(),i.svgEnd);n.length()<this.minDistance&&(this.minDistance=n.length(),r=n),n=new te(i.start(),t.svgEnd),n.length()<this.minDistance&&(this.minDistance=n.length(),r=n)}return r}point2ArcMinDistance(t,i,r){if(Er(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(Er(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 te(i,r)),t}arcShortestLine(t,i,r,n){if(Er(t,n)){let s=new te(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(!Ye.eq(t.b,0)&&!Ye.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 V(r,n)}else return Ye.eq(t.b,0)&&!Ye.eq(t.a,0)?new V(t.start().x,i.y):!Ye.eq(t.b,0)&&Ye.eq(t.a,0)?new V(i.x,t.start().y):i}};var OI=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 te)return this.shape.direct;if(this.shape instanceof Te){let t=this.start.sub(this.shape.center).normalize();return this.shape.sweep()==vs.CCW?new V(-t.y,t.x):new V(t.y,-t.x)}else return null}getEndDirect(){if(this.shape instanceof te)return this.shape.direct;if(this.shape instanceof Te){let t=this.end.sub(this.shape.center).normalize();return this.shape.sweep()==vs.CCW?new V(-t.y,t.x):new V(t.y,-t.x)}else return null}},RI=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 te){let n=yu.foot(i,t).distance1(t);return Ye.eq(n,0)?i.bbox().isContains(t):!1}else if(i instanceof Te){let r=t.distance1(i.center);return Ye.eq(r,i.rx)?Er(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 OI(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 V(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)&&Ye.greater(h.maxX,o)){let d=u.shape;if(d instanceof te){let p=s.cross(d.direct);if(Ye.eq(p,0)){let f=!1;Ye.greatereq(u.start.x,o)&&(u.interInStart=!1,f=!f),Ye.greatereq(u.end.x,o)&&(u.intersInEnd=!1,f=!f),f&&(u.othersIntersCount=1);continue}else if(Ye.eq(u.start.y,l)&&Ye.greatereq(u.start.x,o))u.interInStart=!0;else if(Ye.eq(u.end.y,l)&&Ye.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;Ye.greatereq(f,o)&&(u.othersIntersCount=1)}}else if(d instanceof Te){let{center:p}=d,f=t.distance1(p);if(Ye.greatereq(Math.abs(d.sweepAngle),360)){Ye.lesseq(f,d.rx)&&(u.othersIntersCount=1);continue}let m=Math.abs(l-p.y);if(Ye.eq(m,d.rx)){Ye.greatereq(u.start.x,o)&&Ye.eq(u.start.y,l)&&(u.interInStart=!0),Ye.greatereq(u.end.x,o)&&Ye.eq(u.end.y,l)&&(u.intersInEnd=!0);continue}else{let g=$N(d,l);if(g>0){for(let x=0;x<g;x+=2)if(Ye.greatereq(fe[x],o)){let y=new V(fe[x],fe[x+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&&Ye.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}},ZN=new RI;function vE(e,t=1){return t>0?e.reduce((i,r)=>i.concat(Array.isArray(r)?vE(r,t-1):r),[]):e.slice()}var NI=Object.freeze([]);function MI(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 Tc(e){return Array.isArray(e)}function kW(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 FW(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 dd=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=xt.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 dd,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){Is.remove(this.itemList,t),this.changed=!0}clear(){this.changed=!1,this.root=new dd,this.itemList.length=0}flushWhenNeed(){if(this.changed){let t=new Array;for(let i of this.itemList)t.push(new dd(i));for(;;){let i=this.organize(t);if(i.length>1)t=i;else break}this.root=new dd(t),this.changed=!1}}organize(t){Fl(t,FW,0,t.length);let i=t.length,r=[];for(let n=0;n<i;)if(n+this.capacity2<=i){let s=n+this.capacity2;Fl(t,kW,n,s);for(let a=n;a<s;a+=this.capacity){let o=new dd(t.slice(a,a+this.capacity));r.push(o)}n=n+this.capacity*this.capacity}else{let s=new dd(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 _m=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 sh=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 te)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 Te){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 Ue){if(Cy(c,s)===0)throw new Error("no inters");fe[0]>n&&(r+=l.y>o.y?1:-1)}else throw new Error("not support!");else if(l.x>n)if(c instanceof te)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 Te){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 Ue){if(Cy(c,s)===0)throw new Error("no inters");fe[0]>n&&(r+=l.y>o.y?1:-1)}else throw new Error("not support!")}i=l}return r}};function IE(e,t){let i=0;if(Math.abs(e.start.y-t)<=1e-4)fe[i++]=e.start.x;else if(Math.abs(e.end.y-t)<=1e-4)fe[i++]=e.end.x;else if(e.shape instanceof te)i=JN(e.shape,t);else if(e.shape instanceof Te)i=KN(e.shape,t);else if(e.shape instanceof Ue)i=Cy(e.shape,t);else throw new Error("not supported operation");return i}var fd=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))&&(IE(this,t)>0?this._x=fe[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 te)t=new te(this.shape.end(),this.shape.start());else if(this.shape instanceof Te)t=Te.build3(this.shape.center,this.shape.endAngle(),-this.shape.sweepAngle,this.shape.rx,this.shape.ry);else if(this.shape instanceof Ue)t=new Ue(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 So.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 Ua=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 BI=new class extends Ua{decide1(t){return t[0]||t[1]}}(2),mpe=[BI,new class extends Ua{decide1(t){return t[0]||t[1]||t[2]}}(3),new class extends Ua{decide1(t){return t[0]||t[1]||t[2]||t[3]}}(4),new class extends Ua{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]}}(5),new class extends Ua{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]||t[5]}}(6),new class extends Ua{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]}}(7),new class extends Ua{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7]}}(8),new class extends Ua{decide1(t){return t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7]||t[8]}}(9)],Spe=new class extends Ua{decide1(t){return t[0]&&!t[1]}}(2),Ipe=new class extends Ua{decide1(t){return t[0]&&t[1]}}(2),Cpe=new class extends Ua{decide1(t){return t[0]&&!t[1]||!t[0]&&t[1]}}(2);var Lm=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 te(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 sh(i);for(let r of t.primitives)if(r instanceof te)this.addSide(r);else if(r instanceof Te&&r.rx===r.ry)this.addArc(r);else if(r instanceof Ue&&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 te(n,s)),n=s}return this.completeGroup()}addArc(t){let i=t.sweepAngle,r=xa.regularD(t.startAngle),n=r+i;if(i>0){let s=90;for(;s<=n;)s>r&&(this.addSide(Te.build3(t.center,r,s-r,t.rx,t.ry)),r=s),s+=90;r<n&&this.addSide(Te.build3(t.center,r,n-r,t.rx,t.ry))}else if(i<0){let s=270;for(;s>=n;)s<r&&(this.addSide(Te.build3(t.center,r,s-r,t.rx,t.ry)),r=s),s-=90;r>n&&this.addSide(Te.build3(t.center,r,n-r,t.rx,t.ry))}}isInRange(t){return Ye.greater(t,0)&&Ye.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(Ye.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(Ye.lesseq(a,1)&&Ye.greatereq(a,0)){let m=Number.NEGATIVE_INFINITY;for(;Ye.neq(a,m);){m=a;let g=f*a+c;a=-(l*a**2+c*a+u-g*a)/g}}if(Ye.lesseq(o,1)&&Ye.greatereq(o,0)){let m=Number.NEGATIVE_INFINITY;for(;Ye.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(Ye.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 te(this.prevPoint,r),!1)}else if(this.equals(r,n)){this.prevPoint=r;return}}let s=new fd(t,r,n,this.polyGrp,this.polyIndex++,this.curSideChain);this.curSideChain.sides.push(s),this.prevPoint=n}};var AE=new Error("list is empty"),Om=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}},kI=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")}},FI=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")}},Ao=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 AE;return this.remove(t),t.item}removeLast(){let t=this.last;if(t===null)throw AE;return this.remove(t),t.item}addLast(t){if(this.first===null||this.last===null){let i=new Om(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 Om(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 AE;return this.first.item}getLast(){if(this.last===null)throw AE;return this.last.item}insertAfter(t,i){let r=new Om(this,i);return t.insertAfter(r),t===this.last&&(this.last=r),this.cnt++,r}insertBefore(t,i){let r=new Om(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 kI(this.first)}listIterator(){return new FI(this.first)}toArray(){let t=new Array,i=this.first;for(;i!=null;)t.push(i.item),i=i.next;return t}};var Rm=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())&&Ye.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 GW=!0,UW=!1,YW=!1,HW=!0,jW=!0,VW=!0,zW=!0,CE=class extends Em{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 DE(e){throw new Error("")}var Nm=class{constructor(t,i){this.node1=null;this.node2=null;this.key=t,this.value=i}},GI=class{constructor(t){this.itors=t}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},UI=class{constructor(t){this.itors=t}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},PE=class{constructor(){this.innerList=new Ao;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 Nm(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 Nm){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 Ao;return s.node2=a.add(s),n.node2=a.add(n),this.innerMap[r]=a,null}}if(s instanceof Ao){let a=null;return wm(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 DE(s)}get(t){let i=t.hashCode(),r=this.innerMap[i];if(r===void 0)return null;if(r instanceof Nm)return r.key.equals(t)?r.value:null;if(r instanceof Ao){let n=null;return wm(r,(s,a)=>a.key.equals(t)?(n=a.value,!1):!0),n}return DE(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 Nm)return r.key.equals(t)?(this.delete(r),r.value):null;if(r instanceof Ao){let n=null;return wm(r,(s,a)=>a.key.equals(t)?(n=a.value,this.delete(a),!1):!0),n}return DE(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 GI(this.innerList.iterator())}values(){return new UI(this.innerList.iterator())}entries(){return this.innerList.iterator()}};var YI=class{constructor(){this.points=[];this.lines=[];this.arcs=[];this.beziers=[];this.listText=[];this.fonts=[]}addPt(t,i=!0){if(t instanceof te)this.lines.push(t);else if(t instanceof Te)this.arcs.push(t);else if(t instanceof Ue)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,xa.toRadians(o.startAngle),xa.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}}},_E=class{constructor(t){this.map=new PE;this.bus=t}initColor(t){return this.map.computeIfAbsent(t,()=>new YI)}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()}},en=class en{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 en(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 en(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15);if(i==6)return new en(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 en(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 en(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15,i);if(t.length==6)return new en(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 en(t.r,t.g,t.b,i)}static of7(t){return t==null?null:en.of3(t)}constructor(t,i,r,n=1){this.r=hu.positiveOr0(t),this.g=hu.positiveOr0(i),this.b=hu.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 en(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 en(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 en(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}};en.WHITE=new en(1,1,1,1),en.BLACK=new en(0,0,0,1),en.RED=new en(1,0,0,1),en.GREEN=new en(0,1,0,1),en.BLUE=new en(0,0,1,1),en.Gray=en.of3("#9966ff"),en.Silver=en.of3("#D2D2D2"),en.Golden=en.of3("#DCAA14");var md=en;var XW=!0,WW=!1,qW=!1,JW=!0,KW=!0,eM=md.RED,$W=md.GREEN,tM=md.BLUE,HI=new md(1,1,0),ZW=new md(1,0,1),vp=class extends CE{constructor(i,r=null){super(i);this.plGrps=new Array;r&&(this.drawDebug=new _E(r))}onPolylineGroup(i,r){super.onPolylineGroup(i,r),this.plGrps.push(i),!(!this.drawDebug||!KW)&&i.items.forEach((n,s)=>n.primitives.forEach(a=>{this.drawDebug.initColor(s===0?$W:ZW).addPt(a)}))}onOriginSide(i){super.onOriginSide(i),!(!this.drawDebug||!XW)&&this.drawDebug.initColor(tM).addPt(i.shape)}onIntersect(i,r,n){super.onIntersect(i,r,n),!(!this.drawDebug||!WW)&&this.drawDebug.initColor(eM).addPoint(i)}onScan(i,r,n,s,a,o){if(super.onScan(i,r,n,s,a,o),!this.drawDebug||!qW)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 V(l,n).rotate(V.ORIGIN,-Math.PI/2):new V(l,n);this.drawDebug.initColor(tM).addText(c,`${a}=${o}${i?"=V":""}`)}onResultSide(i){if(super.onResultSide(i),!(!this.drawDebug||!JW)&&this.lastResultChain!==i.chain&&(this.lastResultChain=i.chain,i.chain.status===0)){for(let r of i.chain.sides)this.drawDebug.initColor(HI).addPt(r.shape,!1);i.chain.startNode&&(this.drawDebug.initColor(HI).addPoint(i.chain.start),this.drawDebug.initColor(HI).addPoint(i.chain.end))}}onDebugSide(i){var r;super.onDebugSide(i),(r=this.drawDebug)==null||r.initColor(eM).addPt(i.shape)}onEnd(){var i;(i=this.drawDebug)==null||i.draw()}};var LE=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 OE=class{constructor(){this.chain=new sh(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=Et.build2(t).asClose()}return this._polyline}bbox(){return this.polyline.bbox()}};var RE=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 NE=class e{constructor(t){this.childs=new Array;this._bbox=null;this.parent=null;this.capacity=t}bbox(){return hu.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=xt.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=xt.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=xt.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=xt.extend2(a._bbox,h).area(),p=xt.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}}},ME=class{constructor(t){this.items=new Set;this.root=new NE(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 NE?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 QW=Is.funcCopy(Fl),BE=class{constructor(t){this.parents=new Set;this.childrenRTree=new ME(10);this.marked=!1;this.markedChildNum=0;this.item=t}bbox(){return this.item.bbox()}};function iM(e){let t=e.map(r=>new BE(r));QW(t,(r,n)=>n.bbox().area()-r.bbox().area(),0,t.length);let i=new BE(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 kE=.01,eq=Is.funcCopy(Fl),tq=Is.funcCopy(Fl),iq=Is.funcCopy(Fl),rq=Is.funcCopy(Fl);function nq(e,t){return e.bbox().minY-t.bbox().minY}function sq(e,t){return e.bbox().area()-t.bbox().area()}function aq(e,t,i){if(e instanceof te||t.distance2(i)<1e-6)return new te(t,i);if(e instanceof Te){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 Te.build2(e.center,s,a,e.rx,e.ry,n)}else if(e instanceof Ue){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 jI,rM={};function nM(){return typeof performance<"u"?performance.now():Date.now()}function Dy(e){rM[e]=(rM[e]||0)-jI+(jI=nM())}var oq=0,lq=0,cq=0,uq=0,hq=0,dq=0,pq=0,FE=class e extends _m{constructor(i,r,n,s=!0){super(new Lm(!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,tq(r,nq,0,r.length);let o=new Ao;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();pq+=this.scanLines}simplify0(){dq++,oq+=this.blockOriginChainsIndex.length,cq+=this.sides.length,jI=nM(),this.seekIntersection(),Dy("seekIntersection"),this.splitSidesByInters(),this.blockChainsIndex.forEach(i=>{lq+=i.length,i.forEach(r=>uq+=r.sides.length)}),Dy("splitSidesByInters"),this.sweepBlocks(),hq+=this.blocks.length,Dy("sweepBlocks"),this.connectSides(),Dy("connectSides"),this.fillResult(),Dy("fillResult"),this.event instanceof vp&&this.event.onEnd()}simplify(){try{this.simplify0()}catch{this.event instanceof vp&&(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 RE(n,this.blockOriginChainsIndex[s]),o=a.bbox();o.width()<=kE||o.height()<=kE||this.blocks.push(a)});let i=iM(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 Ao;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;Ye.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(Ye.less(d.bbox().minY,r))Ye.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 Rm(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,x=d.bbox().maxY,y=Math.max(a,g),E=Math.min(o,x);u=this.compareBySweep(r,d,(y+E)/2)}let m=d.shape;if(m instanceof te&&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 Ye.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,IE(i,a)===0)throw new Error("intersY(s1, y) === 0");if(n=fe[0],IE(r,a)===0)throw new Error("intersY(s2, y) === 0");return s=fe[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(!Ye.eq(s,a))return s-a;if(i.shape instanceof te){if(r.shape instanceof te)return this.getLineAngle(r.shape)-this.getLineAngle(i.shape);if(r.shape instanceof Te)return-this.compareArcLine(r.shape,i.shape,n);if(r.shape instanceof Ue)return this.compareSide(i,r,s,a,n);throw new Error("not support")}else if(i.shape instanceof Te){if(r.shape instanceof te)return this.compareArcLine(i.shape,r.shape,n);if(r.shape instanceof Te){let o=i.shape,l=r.shape,c=this.getArcAngle(o,n),u=this.getArcAngle(l,n);return Ye.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 Ue)return this.compareSide(i,r,s,a,n);throw new Error("not support")}}else if(i.shape instanceof Ue){if(r.shape instanceof te)return this.compareSide(i,r,s,a,n);if(r.shape instanceof Te)return this.compareSide(i,r,s,a,n);if(r.shape instanceof Ue)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(he.ROT_90),l=n.start.multiply3(he.ROT_90),c=n.end.multiply3(he.ROT_90),u=new fd(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()>kE||l.height()>kE){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 Ao;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 OE;wm(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());rq(a,sq,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 Nr(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 iq(a,Is.sortAsc,0,a.length),a}splitSides(i,r,n,s){if(i.inters.length===2){let u=new fd(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 V(o.x+(a.x-o.x)*2,o.y+(a.y-o.y)*2);eq(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=aq(i.shape,c,u);d instanceof Te&&Math.abs(d.sweepAngle)>190&&(d=new te(c,u));let p=new fd(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 sh(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 sh(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=Sc(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(Ye.eq(fe[a],fe[o])&&Ye.eq(fe[a+1],fe[o+1])){fe[o]=(fe[a]+fe[o])/2,fe[o+1]=(fe[a+1]+fe[o+1])/2;for(let l=s-3;l>=a;l--)fe[l]=fe[l+2];s-=2;break}if(n===r.next){if(s<=2)continue;(fe[0]-n.start.x)**2+(fe[1]-n.start.y)**2<(fe[2]-n.start.x)**2+(fe[3]-n.start.y)**2&&(fe[0]=fe[2],fe[1]=fe[3]),s=2}else if(n===r.previous){if(s<=2)continue;(fe[0]-n.end.x)**2+(fe[1]-n.end.y)**2<(fe[2]-n.end.x)**2+(fe[3]-n.end.y)**2&&(fe[0]=fe[2],fe[1]=fe[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 V(fe[a],fe[a+1]),l=new LE;r.inters.push([o,l]),n.inters.push([o,l]),this.event.onIntersect(o,r,n)}}}}}};var Py=Ug(ib());var GE;mc&&(typeof window<"u"?GE=window._MSG_BUS_=window._MSG_BUS_||new Py.MessageBus:GE=new Py.WorkerMessageBridge(new Py.MessageBus,self));var Ip=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=D3(l);c.length<l.length&&(a=Et.build4(c));for(let u of a.primitives){let h=u.stroke(r,xp.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 Nr(r));return i.length<=1?i:this.runBoolean(fc.UNION,t)}getUnion2(t){return this.run([fc.UNION,...t])}_union_polyline(t){return this.run([fc.UNION,...t])}_union_polygon(t){return this.run([fc.UNION,...t])}getSubtraction(t,i){return this.run([fc.DIFF,this.union(t),this.union(i)])}getSubtraction1(t){return this.runBoolean(fc.DIFF,t)}getSubtraction2(t,i){return this.run([fc.DIFF,t,i])}getIntersection(t){return this.runBoolean(fc.INTERSECT,t)}getMutuallyExclusive(t){return this.runBoolean(fc.XOR,t)}run(t){let i=Ep(),r=fI(t,GE);return Ll.runBoolean+=su(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 vp(!1,GE&&null),r=new FE(BI.rule,new xc(1),i);for(let s of t)r.addPolyline(Ol(s.asClose()));r.simplify();let n=[];return i.plGrps.forEach(s=>{let a=[Ol(s.items[0])];if(a[0]){for(let o=1;o<s.items.length;o++){let l=Ol(s.items[o]);l&&a.push(l)}n.push(new $r(a))}}),new pr(n)}};var _y=Math.PI*2,VI=({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}},fq=(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}]},sM=(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)},mq=(e,t,i,r,n,s,a,o,l,c,u,h)=>{os(o)||Hr(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 x=g*n/s*h,y=g*-s/n*u,E=c*x-l*y+(e+i)/2,T=l*x+c*y+(t+r)/2,w=(u-x)/n,b=(h-y)/s,C=(-u-x)/n,A=(-h-y)/s,R=sM(1,0,w,b),O=sM(w,b,C,A);return o===0&&O>0&&(O-=_y),o===1&&O<0&&(O+=_y),[E,T,R,O]},gq=({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*_y/360),h=Math.cos(a*_y/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,x,y]=mq(e,t,i,r,n,s,o,l,u,h,d,p),E=Math.abs(y)/(_y/4);Math.abs(1-E)<1e-7&&(E=1);let T=Math.max(Math.ceil(E),1);y/=T;for(let w=0;w<T;w++)c.push(fq(x,y)),x+=y;return c.map(w=>{let{x:b,y:C}=VI(w[0],n,s,h,u,m,g),{x:A,y:R}=VI(w[1],n,s,h,u,m,g),{x:O,y:M}=VI(w[2],n,s,h,u,m,g);return{x1:b,y1:C,x2:A,y2:R,x:O,y:M}})};function gd(e){let t=gq({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=>os(r)?uN(r):r).join(" ")}var Ly=Ug(ib());var UE;mc&&(typeof window<"u"?UE=window._MSG_BUS_=window._MSG_BUS_||new Ly.MessageBus:UE=new Ly.WorkerMessageBridge(new Ly.MessageBus,self));function yq(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=>Et.build2([c]))):[o]);s&&(e=new Nr(a.flat()))}let r=new Ip;if(t===0)return e;let n=[];if(i!=null&&i.fill)r.union(e.items).items.forEach(a=>{let o=new $r([a.items[0]]).extend(t),l=[];a.items.slice(1).forEach(h=>{let d=new $r([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 te)return c.direct.x===0&&c.direct.y===0;if(c instanceof Te)return c.sweepAngle===0;if(c instanceof Ue){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 Ue){let d=[];eE(u,d),d.forEach(p=>{let f=$r.buildByStroke(p,s,xp.ROUND,.1,UE);f&&a.push(f)});return}let h=$r.buildByStroke(u,s,xp.ROUND,.1,UE);h&&a.push(h)})}),r._union_polygon(a).items.forEach(c=>{c.items.forEach(u=>{n.push(u)})})}return new Nr(n)}function ah(e,t,i){return yq(e,t,i)}function bq(e,t){if(!(e!=null&&e.length))return[];let i=[],r=[],n=new Ip;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 aM(e,t){return bq(e,t)}function Co(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=H=>`${H.x} ${H.y}`;if(h){if(!o&&!l){let Ne=$e.rectShapeNoRadius(h);return i&&Ne.reverse(),`M ${Ne.map(je=>je.x+" "+je.y).join(" L ")} Z`}let{width:H,height:q}=$e.getRectShapeForAttr(h);if(o>=H/2&&l>=q/2){let Ne=$e.createMatrixFrom6(h),it=new V(1,1).multiply3(Ne),je=Ne.multiply3(he.scale(.5,.5).setOrigin1(it));return h=$e.getMatrix6FromMatrix(je),Yl({matrix:h},t)}let I=.551915024494,N=0,v=0,L=1,_=1;o=Math.min(o/H,.5),l=Math.min(l/q,.5);let B=[N,N+o*(1-I),N+o,L-o,L-o+o*I,L],U=[v,v+l*(1-I),v+l,_-l,_-l+l*I,_],z=[0,0,1,2,3,4,5,5,5,5,4,3,2,1,0,0],W=[2,1,0,0,0,0,1,2,3,4,5,5,5,5,4,3],ne=z.map((Ne,it)=>new V(B[Ne],U[W[it]])),me=$e.createMatrixFrom6(h),Ee=ne.map(Ne=>Ne.multiply3(me));i&&Ee.reverse();let Se=Ne=>`${d(Ee[Ne])} C ${d(Ee[Ne+1])} ${d(Ee[Ne+2])} ${d(Ee[Ne+3])}`;return`M ${Se(0)} L ${Se(4)} L ${Se(8)} L ${Se(12)} Z`}let p=u?-c:+c,f=new V(r,a),m=H=>H.rotateD(f,p),g=H=>new V(H[0],H[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 x=(r+s)/2,y=(n+a)/2,E=Math.abs(s-r),T=Math.abs(a-n);if(o=Math.min(o,E/2),l=Math.min(l,T/2),o>=E/2&&l>=T/2)return Yl({cx:x,cy:y,rx:o,ry:l,rotation:c,isCCW:u},t);let w=.551915024494,b=[r,r+o*(1-w),r+o,s-o,s-o+o*w,s],C=[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],R=[2,1,0,0,0,0,1,2,3,4,5,5,5,5,4,3],O=A.map((H,q)=>g([b[H],C[R[q]]]));i&&O.reverse();let M=p?O.map(m):O,k=H=>`${d(M[H])} C ${d(M[H+1])} ${d(M[H+2])} ${d(M[H+3])}`;return`M ${k(0)} L ${k(4)} L ${k(8)} L ${k(12)} Z`}function Yl(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=$e.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 V(0,0),m=E=>{let T=new V(h[E]*r,d[E]*n);return p&&(T=T.rotateD(f,p)),`${T.x+s} ${T.y+a}`},g=E=>`M ${m(E)}`,x=E=>`C ${m(E)} ${m(E+1)} ${m(E+2)}`;return i&&d.reverse(),`${g(0)} ${x(1)} ${x(4)} ${x(7)} ${x(10)}`}function Ap(e){switch(e.cmdKey){case"rect":return Co(e);case"ellipse":return Yl(e);case"group":return e.d;case"obj":return zI(e);case"text":return xq(e);case"arc":return gd(e);default:Hr(e);break}}function zI(e){let t=$e.rectShapeNoRadius(e.matrix);return`M ${t[0].x+" "+t[0].y} 
	L ${t.slice(1).map(r=>r.x+" "+r.y).join(" ")} Z`}function oM(e,t={ccw:!1}){let{cx:i,cy:r,r:n}=e;return Yl({cx:i,cy:r,rx:n,ry:n},t)}function xq(e){let t=_i.convertJsonCache2PolyLines({d:e.d},"group"),i=he.MIRROR_Y.multiply3($e.createMatrixFrom6(e.matrix).multiply3(he.MIRROR_Y)),r=t.multiply3(i).round(4);return ls(r.items,!1)}function lM(e,t){if(!t||t<0||!e.items.length)return[];let i=ah(e,t/2,{fill:!1});return i?[i]:[]}var YE=class{constructor(){}parser(t,i){let r=t.tagName,n,s=t.id;switch(r){case"ellipse":n=Yl(i.ellipse[s]);break;case"rect":n=Co(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=gd(t);break;case"text":{r=this.transferTextObj(t);break}case"obj":{r=this.transferImageObj(t);break}}return r}transferText(t,i){let r=he.MIRROR_Y.multiply3($e.createMatrixFrom6(i.text[t.id].matrix).multiply3(he.MIRROR_Y)),n=t.querySelector("path").getAttribute("d"),a=Yi(n).map(l=>l.multiply3(r)),[o]=my(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 Yl(t)}transferRectObj(t){return Co(t)}transferImageObj(t){return zI(t)}transferTextObj(t){let{cacheWidth:i,cacheHeight:r,hAlign:n,vAlign:s,rotation:a}=t,o=Eq(i,r,void 0,void 0,n,s,a,void 0,void 0,void 0),c=Yi(t.d).map(h=>h.multiply3(o)),[u]=my(c,!1);return u}},XI=class{constructor(){this.bool=new Ip}convertSvg2Polylines(t,i){let r=new YE,n=[];for(let s of t){let a=r.parser(s,i),o=Yi(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=Ap(r),s=Yi(n);i.push(s)}return i}convertJsonCache2PolyLines(t,i){let n=new YE().jsonCacheParser(t,i),s=Yi(n);return new Nr(s)}convertPolylines2Svg(t,i=!1,r=!1,n=.01){let s=[];if(i)t.length&&s.push(...my(vE(t.map(a=>a.items)),r,n));else for(let a of t)s.push(...my(a.items,r,n));return s}boolExclusive(t){return this.bool.getMutuallyExclusive(t)}boolSubtraction(t,i){return t.length?aM([new Nr(t)],i.length?[new Nr(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=>bo(a,o)))))}extend(t,i){return i===0?[new Nr(t)]:this.bool.extend(t,i)}},_i=new XI;function Eq(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 he;return d=d.scale(1,-1),d=d.rotateD(a),o&&(d=d.multiply3(he.MIRROR_X)),l<0&&(d=he.MIRROR_X.multiply3(d),l=-l),c<0&&(d=he.MIRROR_Y.multiply3(d),c=-c),d=d.translate(i,-r),d=he.scale(l,-c).translate(u,-h).multiply3(d),d}var WI=class{showShapeControl(t,i){il();let r=de(t);if(!r)throw new Error("");Tn([r],{create8Dots:!0}),i==="click"&&(Ce.select(r),_e("panel_updateAttrPanel"))}getData(t){let i=[];for(let r of t){let n=Qt(r),s,a,o,l=r.id,c;switch(n){case"rect":{c=F.getRect(l);let f=$e.getRectShapeForAttr(c.matrix),[m,g]=F.translateByOrigin(f.x,f.y+f.height);s=m,a=g;break}case"ellipse":{c=F.getEllipse(l);let{cx:f,cy:m}=gi.getEllipseFromMatrix(c.matrix),[g,x]=F.translateByOrigin(f,m);s=g,a=x;break}case"obj":c=F.getObj(l);let u=Tr.getImageShapeForAttr(c.matrix),[h,d]=F.translateByOrigin(u.x,u.y+u.height);s=h,a=d;break;case"text":{c=F.getText(l);let{x:f,y:m}=lr.getTextForAttrs(c),[g,x]=F.translateByOrigin(f,m);s=g,a=x;break}case"arc":case"group":c=F.getById(l).json;let p=cs(de(l));s=p.x,a=p.y+p.height;break;default:throw new Error(n)}o=IR[c.layer],s=Gt(s,"pixel","mm"),a=Gt(-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}},qI=new WI;function JI(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 cM(){let e=[],t=Un.data.event,{x:i,y:r}=Ti(t,!1),n=Oy(i,r);e.push(...n);let s=oh(i,r);e.push(...s.map(h=>de(h)));let a=Mm(i,r);e.push(...a);let o=Ry(i,r);e.push(...o);let l=Cp(i,r);e.push(...l);let c=vc(i,r);e.push(...c.map(h=>de(h))),e=Array.from(new Set(e));let u=qI.getData(e);console.log(u),_e("panel/show-select-element",[{x:t.clientX,y:t.clientY},u])}function qn(e){return["dimension","dimensionAngle","dimensionLength","dimensionRadius","auxiliaryLine","auxiliaryPoint"].includes(e)}var yn=document.getElementById.bind(document);function HE(e){let t=e.target;if(t==document||t==document.documentElement||t==document.body)return;let i=Hl(t),r;Bm.isShowContextMenu(e)?r=t:i&&F.getById(i.id).json.layer!=7&&(r=i);let{x:n,y:s}=Ti(e,!1);return r=r||$I(n,s)[0],r=r||KI(n,s)[0],r=r||Oy(n,s).values().next().value,r=r||yn(oh(n,s)[0]),r=r||yn(vc(n,s)[0]),r=r||Cp(n,s)[0],r=r||ZI(n,s)[0],r=r||QI(n,s)[0],r=r||eA(n,s)[0],r=r||tA(n,s)[0],r=r||Ry(n,s)[0],r}function oh(e,t){let i=[];return F.iteratorEllipse(r=>{if(yi.eleIsHide(r))return;let n=$e.createMatrixFrom6(r.matrix),s=new he(n.getInverseMatrix().data),a=new V(e,t).multiply3(s),o=Bl(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&&$a(0,0,a.x,a.y,1,1)<=1&&i.push(r.gId)}),i}function vc(e,t,i){let r=[];return F.iteratorArc(n=>{if(yi.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 Pi(n).points(1);for(let l of o)if(a.isContains(l)){r.push(n.gId);return}}),r}function Oy(e,t){let i=new Set,r=Ga();if(!r["all-element-type"].rect.checked||!r["all-element-type"].rect.visible)return i;let n=F.getRect(),s=Qa();for(let a in n){let o=F.getRect(a);if(yi.eleIsHide(o))continue;let l=Co(o),c=Yi(l),u=[];for(let p of c)p.points(.5,f=>{u.push(new V(f.x,-f.y))});let h=Et.build4(u);if(o.displayFill&&o.fillColor!=="none"&&![3,7].includes(o.layer)){let p=jE(e,t),{minX:f,maxX:m,minY:g,maxY:x}=p,y=[{x:f,y:g},{x:m,y:g},{x:m,y:x},{x:f,y:x}];for(let E of y)if(ZN.inPolyline(new V(E.x,E.y),h)){i.add(yn(a));break}}else for(let p=1;p<u.length;p++){let f=u[p-1],m=u[p];if(Ks({x:e,y:t},f,m).d<s){i.add(yn(a));break}}}return i}function Ry(e,t){let i=jE(e,t),r=new Set,n=Ga();if(!n["all-element-type"].text.checked||!n["all-element-type"].text.visible)return Array.from(r);let s=F.getText();for(let a in s){if(yi.eleIsHide(F.getText(a)))continue;let o=yn(a),l=mr.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}],x=JI(l);for(let y of g)if(uu(y,x)){r.add(yn(a));continue}}return Array.from(r)}function KI(e,t){let i=F.getAuxiliaryLine(),r=[];for(let n in i){let s=i[n];switch(el(s.rotation)){case"horizontal":{Math.abs(t-s.y)<Qa()&&r.push(yn(s.gId));break}case"vertical":{Math.abs(e-s.x)<Qa()&&r.push(yn(s.gId));break}}}return r}function $I(e,t){let i=F.getAuxiliaryPoint(),r=[],n=new V(e,t);for(let s in i){let a=i[s];new V(a.x,a.y).distance1(n)<Qa()&&r.push(yn(a.gId))}return r}function ZI(e,t){let i=[],r=Qa(),n={x:e,y:t};return F.iteratorDimension(s=>{let a=Ks(n,s.start.primitivePoint,s.start.otherPoint).d;if(a<r){i.push(yn(s.gId));return}if(a=Ks(n,s.end.primitivePoint,s.end.otherPoint).d,a<r){i.push(yn(s.gId));return}if(a=Ks(n,s.start.otherPoint,s.end.otherPoint).d,a<r){i.push(yn(s.gId));return}let o=new wn(s).getTextBBoxOutline();if(rh(n,o)){i.push(yn(s.gId));return}}),i}function QI(e,t){let i=[],r={x:e,y:t},n=Qa();return F.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=Ks(r,a,l).d;if(u<n){i.push(yn(s.gId));return}if(u=Ks(r,o,c).d,u<n){i.push(yn(s.gId));return}if(u=Ks(r,a,o).d,u<n){i.push(yn(s.gId));return}let h=new dn(s).getTextBBoxOutline();if(rh(r,h)){i.push(yn(s.gId));return}}),i}function eA(e,t){let i=[],r={x:e,y:t},n=Qa();return F.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=Ks(r,a,o).d;if(c<n){i.push(yn(s.gId));return}if(c=Ks(r,a,l).d,c<n){i.push(yn(s.gId));return}let u=new hn(s).getTextBBoxOutline();if(rh(r,u)){i.push(yn(s.gId));return}}),i}function tA(e,t){let i=[],r={x:e,y:t},n=Qa();return F.iteratorDimensionRadius(s=>{if(Ks(r,{x:s.x1,y:s.y1},{x:s.x2,y:s.y2}).d<n){i.push(yn(s.gId));return}let o=new tn(s).getTextBBoxOutline();if(rh(r,o)){i.push(yn(s.gId));return}}),i}function Cp(e,t){let i=jE(e,t),r=new Set,n=Qa();return F.iteratorGroup(s=>{let a=s.gId;if(yi.eleIsHide(s))return;let o=cs(yn(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=Yi(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(b=>b.x+" "+b.y).join(" L ")+" z",T=Yi(E);_i.boolIntersection([T,h]).length&&r.add(yn(a))}else for(let p=1;p<d.length;p++){let f=d[p-1],m=d[p];if(Ks({x:e,y:t},f,m).d<n){r.add(yn(a));break}}}),Array.from(r)}function Mm(e,t){let i=new Set;if(!Ga()["all-element-type"].obj.checked)return[];let n=F.getObj(),s=jE(e,t);for(let a in n){if(yi.eleIsHide(F.getObj(a)))continue;let o=new ot,l=mr.image.get(yn(a),"multi").slice(0,8);for(let x=0,y=l.length;x<y;x+=2)o.ext6(l[x],l[x+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=JI(l);for(let x of m)if(uu(x,g)){i.add(yn(a));continue}}return Array.from(i)}function uM(e,t){let i=[];return F.iteratorDimensionAngle(r=>{let n=new hn(r).findContainsControlPoint(e,t);n&&i.push({parentId:r.gId,id:n})}),F.iteratorDimensionLength(r=>{let n=new dn(r).findContainsControlPoint(e,t);n&&i.push({parentId:r.gId,id:n})}),F.iteratorDimensionRadius(r=>{let n=new tn(r).findContainsControlPoint(e,t);n&&i.push({parentId:r.gId,id:n})}),i}function Dp(e,t,i){if(i=i||VE().filter(r=>!qn(r.cmdKey)),i.length){let r=mE(i);if(xt.extendRect(r).isContains2(e,t))return!0}return!1}function hM(e,t){let i,r=Et.build6(xt.extendRect(e));switch(t.cmdKey){case"dimension":let{start:n,end:s}=t;i=Et.build7([new te(new V(n.primitivePoint.x,n.primitivePoint.y),new V(n.otherPoint.x,n.otherPoint.y)),new te(new V(s.primitivePoint.x,s.primitivePoint.y),new V(s.otherPoint.x,s.otherPoint.y)),new te(new V(n.otherPoint.x,n.otherPoint.y),new V(s.otherPoint.x,s.otherPoint.y))]);break;case"dimensionLength":let{measureX1:a,measureY1:o,measureX2:l,measureY2:c}=t;i=Et.build7([new te(new V(a,o),new V(t.x1,t.y1)),new te(new V(l,c),new V(t.x2,t.y2)),new te(new V(a,o),new V(l,c))]);break;case"dimensionAngle":let{angleX:u,angleY:h}=t;i=Et.build7([new te(new V(u,h),new V(t.x1,t.y1)),new te(new V(u,h),new V(t.x2,t.y2))]);break;case"dimensionRadius":i=Et.build7([new te(new V(t.x1,t.y1),new V(t.x2,t.y2))]);break;case"auxiliaryLine":case"auxiliaryPoint":let d=Ei(t,t.cmdKey);return lN(e,d);default:break}for(let n of r.primitives)for(let s of i.primitives)if(Sc(n,s))return!0;return!1}function jE(e,t){let i=Qa();return new ot().ext6(e,t).ext7(i).build()}var Ny=class Ny extends mu{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&&de(i.gId)}getRxRyPixel(){let i=oh(this.x1,this.y1),r=i[0];if(i.length===0){let n=vc(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}=F.getById(i);if(Nt(r))return this;if(n==="ellipse"){let{cx:s,cy:a,rx:o,ry:l}=gi.getEllipseFromMatrix(r.matrix);this.cx=s,this.cy=a,this.rx=o,this.ry=l}else if(n==="arc"){let a=new Pi(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 V(this.cx,this.cy)}getContainer(){return this.measureId&&this.setMeasureId(this.measureId),this.render(),this.container}setHead(i,r){let{json:n,cmdKey:s}=F.getById(this.measureId),a;s==="arc"?a=new Pi(n).getMatrix():a=$e.createMatrixFrom6(n.matrix);let o=new he(a.getInverseMatrix().data),l=new V(i,r).multiply3(o).angle(V.ORIGIN),c=Math.sin(l),u=Math.cos(l),h=new V(u,c).multiply3(a);if(s==="arc"){let d=new Pi(n),p=new V(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 V(this.x1,this.y1)}calcTail(i,r){let n=new V(i,r).angleD2(this.vectorEllipseCenter()),s=new V(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 V(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=F.getDimensionRadius(this.gId);return Nt(r)?i:(Object.assign(r,i),r)}setData(){let i=this.toData();return F.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"+re(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=Tt("g",{id:this.gId,class:"dimensionRadius",c_partid:"dimensionRadius",layer:this.layer,display:this.visible?"":"none"});!i&&tt.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):Tt("rect"),o=this.extendLineAttr({id:i,class:r,x:-.5,y:-.5,width:1,height:1,fill:"#00FFFF",stroke:"none"});re(a,o);let l=4/J.gZoom*2,c=he.scale(l,l).translate(n,s),u=$e.getMatrix6FromMatrix(c);return ct.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=$s([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 V(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 fr(i)}getLineRotation(){return this.vectorTail().angleD2(this.vectorHead())}calcTextPoint(){let i=this.getLineRotation(),r=new V(this.textOffsetX,-10).rotateD(new V(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"):Tt("text",{x:0,y:0});i=ft(qs(i),2),r=ft(qs(r),2),n.textContent="Rx"+i+"mm,Ry"+r+"mm";let s=this.vectorTail().angleD2(this.vectorHead()),a=he.translate(this.textX,this.textY),o=n.getBBox();!o.width&&!o.height&&(o=this.getTextBBox(n.textContent));let l=.5;return a=he.scale(l,l).rotateD(s).multiply3(a),{text:n,m3:a,bbox:o}}getTextBBoxOutline(){let{m3:i,bbox:r}=this.getTextMatrix(),n=xt.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=$e.getMatrix6FromMatrix(n);return ct.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(Zo(i,r,this.x1,this.y1,n))return this.getId("head");if(Zo(i,r,this.x2,this.y2,n))return this.getId("tail");if(Zo(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=hN(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(){F.iteratorDimensionRadius(i=>{let r=new Ny(i).render();r=null})}};Ny.updateMeasureValue=$o(Ny.zoom);var tn=Ny;var Yn={move(e,t,i){if(!t&&!i)return;let r=e.cmdKey;this[r]?this[r](e,t,i):Hr(r,e)},auxiliaryLine:(e,t,i)=>{e.x+=t,e.y+=i,new Ul(e).render()},auxiliaryPoint:(e,t,i)=>{e.x+=t,e.y+=i;let r=de(e.gId);jl.circle1(r,t,i)},dimension(e,t,i){let r=new wn(e).translate(t,i).render();r=null},dimensionLength(e,t,i){let r=new dn(e);r.translate(t,i).render(),r.setData()},dimensionAngle(e,t,i){let r=new hn(e);r.translate(t,i).render(),r.setData()},dimensionRadius(e,t,i){let r=new tn(e);r.translate(t,i).render(),r.setData()},obj(e,t,i){let r=he.translate(t,i);Tr.syncImage(e,r)},text(e,t,i){let r=he.translate(t,i);lr.syncText(e,r,{updateMatrix:!0})},group(e,t,i){let r=he.translate(t,i);Gn.syncGroup(e,r,{updateD:!0})},ellipse(e,t,i){let r=he.translate(t,i);gi.syncEllipse(e,r,{updateMatrix:!0})},arc(e,t,i){let r=he.translate(t,i);sr.syncArc(e,r,{updateD:!0})},rect(e,t,i){let r=he.translate(t,i);Ai.syncRect(e,r,{updateMatrix:!0})}};var Do=class{constructor(){this.allDimensions=[];this.ignoreDimension=new Set;this.xNode=new Set;this.yNode=new Set;this.reset()}reset(){return this.allDimensions.length=0,F.iteratorDimension(t=>{this.allDimensions.push(new wn(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 st().findAllEleByOneEle(s.id);for(let o of a)at.jsonSnap.addOne(F.getById(o).json);at.jsonSnap.addOne(F.getById(s.id).json)}for(let s of i){r.add(s.id);let a=new st().findAllEleByOneEle(s.id);for(let o of a)at.jsonSnap.addOne(F.getById(o).json);at.jsonSnap.addOne(F.getById(s.id).json)}let n=this.findDimensionByPrimitiveId(r);for(let s of n)at.jsonSnap.addOne(F.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)Yn.move(F.getById(s).json,t,0);for(let s of n)Yn.move(F.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)),F.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 st;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 st().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 is.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 st().findAllEleByOneEle(t);for(let n of r)i.add(n)}checkAbandonedBySelfDimensionInX(t){return t.start.id===t.end.id&&!mt(t.startNextXMove)&&!mt(t.endNextXMove)&&!ei(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&&!mt(t.startNextYMove)&&!mt(t.endNextYMove)&&!ei(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(!mt(u.startNextXMove)&&u.startNextXMove!==i&&u.categoryIsConstraint())return console.warn(i,u.startNextXMove),!1;if(!mt(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(!mt(u.endNextXMove)&&!ei(u.endNextXMove,i)&&u.getCategory()!=="Annotation")return console.warn(i,u.endNextXMove),!1;if(!mt(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(!mt(u.startNextYMove)&&u.startNextYMove!==i&&u.categoryIsConstraint())return console.warn(i,u.startNextYMove),!1;if(!mt(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(!mt(u.endNextYMove)&&u.endNextYMove!==i&&u.categoryIsConstraint())return console.warn(i,u.endNextYMove),!1;if(!mt(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=F.getDimension(n),a=new wn(s);if(a.categoryIsConstraint()&&a.isSelfDimension()&&s.direction===i||a.categoryIsConstraint()&&a.isSelfDimension()&&s.direction==="xy")return!0}return!1}};var zE={scale(e,t,i,r){let{json:n,cmdKey:s}=F.getById(e),a=he.scale(t,i).setOrigin1(r);this[s]?this[s](n,a):Hr(s)},obj(e,t){Tr.syncImage(e,t,{updateMatrix:!0})},text(e,t){lr.syncText(e,t,{updateMatrix:!0})},group(e,t){Gn.syncGroup(e,t,{updateD:!0})},ellipse(e,t){gi.syncEllipse(e,t,{updateMatrix:!0})},arc(e,t){sr.syncArc(e,t,{updateD:!0})},rect(e,t){Ai.syncRect(e,t,{updateMatrix:!0})}};var iA=class{constructor(){}storeFollow(t,i){this.lastFollowHandleX=t,this.lastFollowHandleY=i}storeDriving(t,i){this.lastDrivingHandleX=t,this.lastDrivingHandleY=i}exchangeFollow(){mt(this.lastFollowHandleX)||(this.followHandleX=this.lastFollowHandleX,this.followHandleY=this.lastFollowHandleY,this.lastFollowHandleX=null,this.lastFollowHandleY=null)}exchangeDriving(){mt(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 V(t.x1,t.y1),l=new V(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();mt(c)||(n.x2=c,n.y2=u)}else{let c=new V(n.x2,n.y2),{x:u,y:h}=this.getFollowHandle(),{x:d,y:p}=Ta.getDrivingHandle();mt(u)||(c=new V(u,h)),mt(d)||(o=new V(d,p));let f=jt.handleFollowHandle(new V(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 V(t.x2,t.y2),l=new V(t.x2+i,t.y2+r);if(a==="C"){if(s.ctrl){this.exchangeFollow(),this.exchangeDriving();let{x:c,y:u}=Ta.getFollowHandle();mt(c)||(n.x1=c,n.y1=u)}else{let c=new V(n.x1,n.y1),{x:u,y:h}=this.getFollowHandle();mt(u)||(c=new V(u,h));let{x:d,y:p}=this.getDrivingHandle();mt(d)||(o=new V(d,p));let f=jt.handleFollowHandle(new V(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)}}},Ta=new iA;var _n={createPath8Dots:function(e){let t=Mr([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 _n.path_arc.get(e.gId);case"rect":return _n.rect.get(e,t);case"obj":return _n.image.get(e,t);case"ellipse":return _n.ellipse.get(e);case"group":return _n.path_group.get(e);case"text":return _n.text.get(e,t);case"_runtime":{let i=e;switch(i.subCmdKey){case"select-box":return _n.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=re(e,"id")=="selectBox1"?"selectbox":h,!_n[h])throw new Error(h);_n[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=V.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=ct.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 ct.getMaxOuterBoundingBox(o,e)},set:function(e,t,i,r,n,s,a,o,l=!1,c,u={}){let h=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=F.getText(e.id);lr.syncText(d,h,{updateMatrix:!1})}},g:{get:function(e){if(Qt(e)==="text")return _n.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(Qt(e)==="text")return _n.text.set.apply(e,arguments);jl.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=ct.createMatrixFrom6(e.tempMatrix||e.matrix),o=[];for(let[l,c]of n){let u=new V(l,c).multiply3(a);o.push(u.x,u.y)}return o}return ct.getMaxOuterBoundingBox(n.slice(0,4),e)},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=F.gJsonCache.obj[e.id];if(!h)return;let d=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u);Tr.syncImage(h,d,{updateMatrix:!1})}},rect:{get:function(e,t="multi"){let i=Eo(e)?e:F.getRect(e.id),{matrix:r,tempMatrix:n}=i,s=ct.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 V(d[0],d[1]).multiply3(s);h.push(p.x,p.y)}return h}return ct.getMaxOuterBoundingBox(u.slice(0,4),i)},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=F.getRect(e.id);Ai.syncRect(d,h,{updateMatrix:!1})}},circle:{get:function(e){let t=+re(e,"cx"),i=+re(e,"cy"),r=+re(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=_n.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,re(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=$e.createMatrixFrom6(u||h),f=[];for(let m of c){let g=new V(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=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=F.getEllipse(e.id);gi.syncEllipse(d,h,{updateMatrix:!1})}},line:{get:function(e){return[+re(e,"x1"),+re(e,"y1"),+re(e,"x2"),+re(e,"y2")]},set:function(e,t,i,r,n){t||(t=_n.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),re(e,s)}},polygon:{get:function(e){let t=yc(re(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?(!ei(s[o]*2,s[0]+s[o-2])||!ei(s[o+1]*2,s[1]+s[o-1]))&&s.splice(o,0,0,0):i%2&&(!ei(s[o]*2,s[o-2]+s[o+2])||!ei(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,x;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]],x=a[c[i]+1],!ei((d-f)*(x-m),(g-f)*(p-m))){h=!1;break}if(h)return;let y={points:nE(a.join(" "))};re(e,y)}},path:{get:function(e){let t=_p(e);if(t){let w=e.tagName+"_"+t;if(_n[w]&&_n[w].get)return _n[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,x,y,E,T;for(u=0;u<r;u++)switch(d=i.getItem(u),p=d.pathSegType,u===0&&p!=yr&&p!=Dr&&p!=ti&&a.push(n,s),h=a.length/2-1,p){case ti:n=o,s=l;break;case yr:if(n=d.x,s=d.y,o=n,l=s,u+1==r||(g=i.getItem(u+1),m=g.pathSegType,m==yr||m==Dr||m==ti))break;a.push(n,s),m==on&&a.push((n+g.x)/2,(s+g.y)/2);break;case on:if(a.push(n=d.x,s=d.y),u+1==r)break;g=i.getItem(u+1),m=g.pathSegType,m==ti&&(g=i.getItem(0)),(m==on||m==ti)&&a.push((n+g.x)/2,(s+g.y)/2);break;case po:a.push(n=d.x,s);break;case fo:a.push(n,s=d.y);break;case lo: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 uo: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 ho:case Oa:if(f=i.getItem(u-1),x=od(f.x,f.y,d.x,d.y,d.largeArcFlag?1:0,d.sweepFlag?1:0,d.r1,d.r2,d.angle),y=x.cx,T=x.cy,E=ad([f.x,f.y],[y,T],x.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==ti&&(g=i.getItem(0)),(m==on||m==ti)&&a.push((n+g.x)/2,(s+g.y)/2);break;case Dr:if(n+=d.x,s+=d.y,o=n,l=s,u+1==r||(m=i.getItem(u+1).pathSegType,m==yr||m==Dr||m==ti))break;a.push(n,s);break;case Tl:a.push(n+=d.x,s+=d.y);break;case El:a.push(n+=d.x,s);break;case wl:a.push(n,s+=d.y);break;case gl: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 yl:c.push({from:h+1,to:h+2}),a.push(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.x1,s+d.y1,n+=d.x,s+=d.y);break;case xl:case ml:a.push(n+=d.x,s+=d.y);break;default:break}if(re(e,"drag")!="self"){let w=_n.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(Qt(e)==="arc"&&re(e,"third-point")){let M=fy(t.join(" "));re(e,{d:s,"third-point":M[2].x+","+M[2].y})}else re(e,{d:s});return}let a=_p(e);if(a){let M=e.tagName+"_"+a;if(_n[M]&&_n[M].set){_n[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,x,y,E,T,w,b,C,A,R,O;if(s&&re(e,{d:s}),t.c_helper_lines||(i=i>>1),!t.c_helper_lines&&p%2){m=u.getItem(i+1),m.pathSegType==Oa?(g=u.getItem(i),y=t[p*2],E=t[p*2+1],T=Tm({x:g.x,y:g.y},{x:m.x,y:m.y},{x:y+r,y:E+n}),T<4&&(T=4),T=Math.sqrt(T),w=m.sweepFlag,b=m.r1,C=wo(g.x,g.y,m.x,m.y),A=(m.x-g.x)*(E-g.y)-(y-g.x)*(m.y-g.y),R=(m.x-g.x)*(E+n-g.y)-(y+r-g.x)*(m.y-g.y),A*R<0&&(w^=1),b=C/(8*T)+T/2,O=b>T?0:1,b=Pp(b),m.r1=b,m.r2=b,m.largeArcFlag=O,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 ti:break;case yr:case Dr:if(f+1==h||(x=u.getItem(f+1).pathSegType,x==yr||x==Dr||x==ti))break;if(d++,d==i){m.x=ft(m.x+r,3),m.y=ft(m.y+n,3);break e}break;case on:case Tl:if(d++,d==i){m.x=ft(m.x+r,3),m.y=ft(m.y+n,3);break e}break;case po:case El:if(d++,d==i){m.x+=r;break e}break;case fo:case wl:if(d++,d==i){m.y+=n;break e}break;case lo:case gl: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 yl: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 uo:case bl: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 ho:case xl:case ml:if(d++,d==i){m.x+=r,m.y+=n;break e}break;case Oa:if(d++,d==i){m.x+=r,m.y+=n;break e}break;default:break}}},path_group:{get:function(e){if(jt.is8DotsMode(e.gId))return Gn.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,x,y=new Map;for(let E=0;E<r;E++){u=i.getItem(E),h=u.pathSegType;let T=E-1>-1&&i.getItem(E-1);E===0&&h!=yr&&h!=Dr&&h!=ti&&a.push(n,s);let w=a.length/2-1;switch(h){case ti:n=o,s=l;break;case yr:if(n=u.x,s=u.y,o=n,l=s,E+1==r||(p=i.getItem(E+1),d=p.pathSegType,d==yr||d==Dr||d==ti))break;a.push(n,s),d==on;break;case on:if(a.push(n=u.x,s=u.y),E+1==r)break;p=i.getItem(E+1),d=p.pathSegType,d==ti&&(p=i.getItem(0)),d==on||d==ti;break;case po:a.push(n=u.x,s);break;case fo:a.push(n,s=u.y);break;case lo:c.push({from:w,to:w+1,belong:w},{from:w+2,to:w+3,belong:w+3});let b=T.x===u.x1&&T.y===u.y1,C=u.x2===u.x&&u.y2===u.y;y.set(w+1,{belong:w,display:!b}),y.set(w+2,{belong:w+3,display:!C}),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 uo: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 ho:case Oa:if(T=i.getItem(E-1),f=od(T.x,T.y,u.x,u.y,u.largeArcFlag?1:0,u.sweepFlag?1:0,u.r1,u.r2,u.angle),m=f.cx,x=f.cy,g=ad([T.x,T.y],[m,x],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==ti&&(p=i.getItem(0)),d==on||d==ti;break;case Dr:if(n+=u.x,s+=u.y,o=n,l=s,E+1==r||(d=i.getItem(E+1).pathSegType,d==yr||d==Dr||d==ti))break;a.push(n,s);break;case Tl:a.push(n+=u.x,s+=u.y);break;case El:a.push(n+=u.x,s);break;case wl:a.push(n,s+=u.y);break;case gl: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 yl:c.push({from:w+1,to:w+2}),a.push(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.x1,s+u.y1,n+=u.x,s+=u.y);break;case xl:case ml: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(jt.isAnchorMode(e.id)&&!l){if(/[^ahvqtsc]/i.test(s)){let x=!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]){x=!1;break}if(x)return}let d=e.pathSegList,p=d.numberOfItems,f=-1,m,g;s&&re(e,{d:s});e:for(let x=0;x<p;x++){let y=x-1>-1&&d.getItem(x-1),E=y.pathSegTypeAsLetter,T=d.getItem(x),w=x+1<p&&d.getItem(x+1),b=w.pathSegTypeAsLetter;switch(T.pathSegType){case ti:break;case yr:case Dr:if(m=T,x+1==p||(g=w.pathSegType,g==yr||g==Dr||g==ti))break;if(f++,f==i){let C=ft(T.x+r,3),A=ft(T.y+n,3);b==="C"&&w.x1===T.x&&w.y1===T.y&&(w.x1=C,w.y1=A),T.x=C,T.y=A;break e}break;case on:case Tl:if(f++,f==i){T.x=ft(T.x+r,3),T.y=ft(T.y+n,3);break e}break;case po:case El:if(f++,f==i){T.x+=r;break e}break;case fo:case wl:if(f++,f==i){T.y+=n;break e}break;case lo:case gl:if(f++,f==i){Ta.setPrevHandlePosition(T,r,n,y,u),T.x1+=r,T.y1+=n;break e}if(f++,f==i){Ta.setNextHandlePosition(T,r,n,w,u),T.x2+=r,T.y2+=n;break e}if(f++,f==i){T.x=ft(T.x+r,3),T.y=ft(T.y+n,3),T.x2=ft(T.x2+r),T.y2=ft(T.y2+n),b==="C"&&(w.x1+=r,w.x1=ft(w.x1),w.y1+=n,w.y1=ft(w.y1)),x!==p-1&&d.getItem(x+1).pathSegType===ti&&(m.x=T.x,m.y=T.y);break e}break;case co:case yl:if(f++,f==i){T.x2+=r,T.y2+=n;break e}if(f++,f==i){T.x+=r,T.y+=n;break e}break;case uo:case bl:if(f++,f==i){T.x1+=r,T.y1+=n;break e}if(f++,f==i){T.x+=r,T.y+=n;break e}break;case ho:case xl:case ml:if(f++,f==i){T.x+=r,T.y+=n;break e}break;case Oa:if(f++,f==i){T.x+=r,T.y+=n;break e}break;default:break}}return}let h=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u);Gn.syncGroup(F.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=od(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=ad([n[0],n[1]],[o,l],a.delta_theta/2),u=py(re(e,"d")),h=oE(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&&re(e,{d:s});return}let a,o,l,c=t?t.slice(0):_n.path_arc2.get(e);if(i===3&&(c[0]+=r,c[1]+=n,c[2]+=r,c[3]+=n),i===0&&ei(c[0]+r,c[2])&&ei(c[1]+n,c[3])||i===1&&ei(c[2]+r,c[0])&&ei(c[3]+n,c[1])||i===2&&ei((c[2]-c[0])*(c[5]+n-c[1]),(c[3]-c[1])*(c[4]+r-c[0])))return;if(i===2){if(a=Tm({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&&re(e,"d",s);let u=e.pathSegList.getItem(1),h=u.r1,d=+u.largeArcFlag,p=+u.sweepFlag,f=wo(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=wo(c[0],c[1],c[2],c[3])),h=f/(8*a)+a/2,d=h>a?0:1,c[0]=Pp(c[0]),c[1]=Pp(c[1]),h=Pp(h),c[2]=Pp(c[2]),c[3]=Pp(c[3]),re(e,"d","M"+c[0]+","+c[1]+" A"+h+","+h+" 0 "+d+" "+p+" "+c[2]+","+c[3])}},path_arc:{get(e){let{json:t}=F.getById(e),i=t.temp||t,r=sr.get8Dots2(i),n=new Pi(i),s=n.vectorCenter();if(jt.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=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=F.getById(e.id).json;sr.syncArc(d,h,{updateD:!1})}}};var wa=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&&ni.renderer.attr(this.dom.id,"fill","var(--selectColor)"),this}getDistance(t){return new V(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=Tt("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 J.svgRoot.appendChild(t),this.dom=t,this.zoom(),t}zoom(){let t=4/J.gZoom*2,i=he.scale(t,t).translate(this.position[0],this.position[1]),r=$e.getMatrix6FromMatrix(i);ct.updateTransform(r,this.dom)}unmount(){this.clicked||this.dom&&(this.dom.remove(),this.dom=null)}};var By=class{constructor(){this.data=[];this.primitiveBBox=[]}loadPointsOfRect(t){let i=Ai.getDotsForAdsorp(t),r=[],n=i.pop();r.push(new wa(t.gId,[n.x,n.y],"rect",-1));for(let s=0;s<4;s++)r.push(new wa(t.gId,[i[s].x,i[s].y],"rect",s));return r}loadPointsOfEllipse(t){let i=gi.getDotsForAdsorp(t.gId),r=[],n=i.pop();r.push(new wa(t.gId,[n.x,n.y],"ellipse",-1));let s=i.length;for(let a=4;a<s;a++)r.push(new wa(t.gId,[i[a].x,i[a].y],"ellipse",a));return r}loadPointsOfArc(t){let i=[],r=sr.get8Dots2(t),{x:n,y:s,width:a,height:o}=Ei(t);i.push(new wa(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 wa(t.gId,[r[c],r[c+1]],"arc",c/2));return i}loadPointsOfText(t){let i=[],{x:r,y:n,width:s,height:a}=Lp(t);i.push(new wa(t.gId,[r+s/2,n+a/2],"text",-1));let o=mr.text.get(t),l=o.length/2;for(let c=0;c<l;c+=2)i.push(new wa(t.gId,[o[c],o[c+1]],"text",c/2));return i}loadPointsOfImage(t){let i=[],r=mr.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 wa(t.gId,[l,c],"obj",o/2)),n.ext6(l,c)}let a=n.build();return i.push(new wa(t.gId,[a.minX+a.width()/2,a.minY+a.height()/2],"obj",-1)),i}loadPointsOfGroup(t){let i=[],r=Gn.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 wa(t.gId,[l,c],"group",o/2)),s.ext6(l,c)}let a=s.build();return i.push(new wa(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:Hr(t);break}return i}load(){this.data.length=0,this.primitiveBBox.length=0,F.iterator(t=>{if(qn(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=F.getItemOrderSortMap(),n=-1/0,s="";for(let a of t){let o=a.getPrimitiveId(),l=r.get(o);F.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}=F.getById(c),d=_n.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(uu(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/J.gZoom*2}},Vl=new By;var km=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 V(r.getX(),r.getY()).multiply3(t);i.push(new wa(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(mt(s)&&mt(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();ei(s,0)&&(s=0),ei(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 ky=class{calcuPerpendicular(t,i,r){let n=new V(t.x,t.y),s=new V(i.x,i.y).angle(n),a=new V(i.x,i.y).rotate(n,-s),o=new V(r.x,r.y).rotate(n,-s),l=new V(t.x,o.y).rotate(n,s),c=new V(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 F.iteratorDimension(r=>{(t.has(r.start.id)||t.has(r.end.id))&&i.add(r)}),Array.from(i)}excludeDimension(t){return F.iteratorDimension(i=>{t.has(i.gId)&&t.delete(i.gId)}),t}changeSelfDimensionSize(t,i){let r=F.getDimension(t),n=new wn(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=Vl.loadPointsByData(F.getById(c).json),x=new km(g),y=he.scale(d,p).setOrigin1(new V(f.x,f.y));x.transform(y);let{moveNode:E,stillNode:T}=x.getTransformedNode(),w=new Do;w.setNodeVisited(new Set),w.setIgnoreDimension(new Set([t]));let b=w.findDimensionNode(E);if(b===!1)return!1;let C=pi.setSkipCheck(!0);for(let A of b){let{dx:R,dy:O,xNode:M,yNode:k}=A,{canMoveX:G,canMoveY:H}=w.getAllAffectedPrimitivesId(M,k);w.prepareHistory(M,k),M=w.removeXNode(T,M),k=w.removeYNode(T,k),G=w.removeXPrimitive(new Set([c]),G),H=w.removeYPrimitive(new Set([c]),H),w.movePrimitive(R,O,G,H).moveDimension(R,O,M,k)}zE.scale(c,d,p,new V(f.x,f.y)),C()}changeDimensionSize(t,i){let r=F.getDimension(t);if(r.category!=="Constraint")throw new Error("err");let n=new wn(r),{offset:{dx:s,dy:a},moveElementId:o,staticElementId:l}=n.updateDistance(i),c=new st,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 Do;g.setIgnoreDimension(new Set([t])),g.findDimensionNodeByPrimitiveId(new Set([o]));let{all:x,canMoveX:y,canMoveY:E}=g.getAllAffectedPrimitivesId();x.add(t);let T=r.direction,w=new st,b=w.searchCombination(m),C=w.searchCombination(o);if(b&&C&&b==C&&(y=g.getMoveIdsInCom(m,o,b).canMoveX,E=g.getMoveIdsInCom(m,o,b).canMoveY),T==="y"&&E.has(m)){this.toastMsg();return}if(T==="x"&&y.has(m)){this.toastMsg();return}if(T==="xy"&&x.has(m)){this.toastMsg();return}let A=pi.setSkipCheck(!0);g.prepareHistory().movePrimitive(s,a).moveDimension(s,a),A()}toastMsg(){J.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){re(de(t),"category",i)}getSideLockedElements(t,i,r=!0){let n=new Set([t]),s=new Do;s.setIgnoreDimension(n).findDimensionNodeByPrimitiveId(new Set([i]));let{all:a}=s.getAllAffectedPrimitivesId(void 0,void 0,r),o=Ya(),l=new Map;for(let{elements:u,combinationId:h}of o)for(let d of u)if(h&&r){let p=F.getCombination(h).locked;l.set(d,{combinationId:h,id:d,cmdkey:"combination",locked:p})}else{let{cmdKey:p,json:f}=F.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=F.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}=F.getById(t.id);if(t.cmdkey==="combination"&&i.cmdkey==="combination"&&t.id===i.id){rs({value:"{0} {a} are currently locked.Please unlock first.",options:{a:r.name,0:Gi[t.cmdkey]},translateOptionKeys:[0]},"warn");return}if(t.id===i.id&&t.cmdkey!=="combination"){let s=r.name;s&&(s=":"+s),rs({value:"{0} {a} are currently locked.Please unlock first.",options:{a:r.id.slice(1)+s,0:Gi[t.cmdkey]},translateOptionKeys:[0]},"warn");return}let n=F.getById(i.id).json;rs({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:Gi[t.cmdkey],1:Gi[i.cmdkey]},translateOptionKeys:[0,1]},"warn")}isInSameCombination(t){let r=new XE().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 st,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}=F.getById(t.start.id),{cmdKey:h,json:d}=F.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=Ga();if(a["all-element-type"].dimension.checked===!1||a["all-element-type"].dimension.visible===!1)return;let o=new wn(t),l={name:"",object:{startId:t.start.id,endId:t.end.id},type:o.getCategory(),size:ft(o.getDistance(),2),overed:!1,hide:["name","obj","category"],id:t.gId,created:!1};F.compilerManager.pauseDateMerge(),_e("panel/open-smart-dimension-dialog",[l])}updateDimensionData(t,i){Qe(i,"attr-dimension")&&this.changeDimensionSize(t,i["attr-dimension"]);let r=F.getDimension(t);if(Qe(i,"attr-dimension-category")){let n=i["attr-dimension-category"];r.category=n,this.updateCategory(t,n)}Qe(i,"attr-name")&&(r.name=i["attr-name"])}},is=new ky;var wn=class extends mu{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=de(i.gId);let r=this.start.otherPoint,n=this.end.otherPoint;this.visible=i.visible;let s=new V(r.x,r.y).distance1(new V(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:Gi[i],primitiveTypeStart:Gi[r]}}toJSON(){let i=F.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 Nt(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",re(s,"points")].join(" ")+["M",re(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=Tt("g",{id:this.gId,c_partid:"dimension",layer:8,category:this.category,display:this.visible?"":"none"}),this.container=r,!i&&tt.appendTargetLayer(r,8),r.appendChild(n),r.appendChild(s),r.appendChild(a),r.appendChild(o),r.appendChild(l),r.appendChild(c)),this.nextTick(),i||ni.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 ni.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=is.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 V(this.start.otherPoint.x,this.start.otherPoint.y),r=new V(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 V(this.start.otherPoint.x,this.start.otherPoint.y),n=new V(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"):Tt("text",{x:0,y:0}),r=this.start.otherPoint,n=this.end.otherPoint,s=new V(r.x,r.y).distance1(new V(n.x,n.y)),a=ft(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 V(r.x,r.y),u=new V(n.x,n.y).angleD(c);n.x<r.x&&(c=new V(n.x,n.y),u=new V(r.x,r.y).angleD(c));let h=he.translate(l.x-o.width/2,l.y-o.height/2).rotateD(u).setOrigin(l.x,l.y);return h=h.multiply3(he.scale(.5,.5).setOrigin(l.x,l.y)),{bbox:o,matrix:h,text:i}}getTextBBoxOutline(){let{matrix:i,bbox:r}=this.getTextMatrix(),n=xt.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=$e.getMatrix6FromMatrix(r);return ct.updateTransform(s,n),n}updateDistance(i){let r=new V(this.start.otherPoint.x,this.start.otherPoint.y),n=new V(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 V(this.start.primitivePoint.x,this.start.primitivePoint.y).angleD2(r)+90);let l=new V(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 Us(e,t,i){switch(i=t.gId||i,e){case"rect":return Fy(t,i);case"group":return rl(t,i);case"ellipse":return Gy(t,i);case"text":return Fm(t,i);case"obj":return Uy(t,i);case"dimension":return rA(t,i);case"auxiliaryLine":return Yy(t,i);case"auxiliaryPoint":return Op(t,i);case"dimensionLength":return Tq(t,i);case"dimensionAngle":return wq(t,i);case"dimensionRadius":return Sq(t,i);case"arc":return lh(t,i);default:console.error(e);break}}function Fy(e,t){if(!e||Nt(e)){dt(de(t)),F.setRect(t);return}let i=Pn.rect(e),r=Cs(i),n=de(t);return n?n.replaceWith(r):tt.appendTargetLayer(r,e.layer),F.setRect(t,e),de(t)}function rl(e,t){if(t=t||e.gId,!e||Nt(e)){dt(de(t)),F.setGroup(t);return}let i=Pn.group(e),r=Cs(i),n=de(t);return n?n.replaceWith(r):tt.appendTargetLayer(r,e.layer),F.setGroup(t,e),de(t)}function Gy(e,t){if(!e||Nt(e)){dt(de(t)),F.setEllipse(t);return}let i=Pn.ellipse(e),r=Cs(i),n=de(t);return n?n.replaceWith(r):tt.appendTargetLayer(r,e.layer),F.setEllipse(t,e),de(t)}function lh(e,t){if(t=e.gId||t,!e||Nt(e)){ni.renderer.removeNode(t),F.setArc(t);return}let i=Pn.arc(e),r=document.getElementById(t),n=Cs(i);return r?r.replaceWith(n):tt.appendTargetLayer(n,e.layer),F.setArc(t,e),de(t)}function Fm(e,t){if(!e||Nt(e)){dt(de(t)),F.setText(t);return}let i=Pn.text(e),r=Cs(i),n=de(t);return n?n.replaceWith(r):tt.appendTargetLayer(r,e.layer),F.setText(t,e),de(t)}function Uy(e,t){if(t=t||e.gId,!e||Nt(e)){dt(de(t)),F.setObj(t);return}let i=Pn.obj(e),r=Cs(i),n=de(t);return n?n.replaceWith(r):tt.appendTargetLayer(r,e.layer),F.setObj(t,e),de(t)}function rA(e,t){if(t=t!=null?t:e.gId,!e||Nt(e)){dt(de(t)),F.setDimension(t);return}let i=Pn.dimension(e),r=Cs(i),n=de(t);n?n.replaceWith(r):tt.appendTargetLayer(r,e.layer),F.setDimension(t,e);let s=new wn(e).render();return s=null,de(t)}function Tq(e,t){if(t=t||e.gId,!e||Nt(e)){dt(de(t)),F.setDimension(t,{},"dimensionLength");return}let i=de(t),r=new dn(e).getContainer();return i?i.replaceWith(r):tt.appendTargetLayer(r,e.layer,!0,{cmdKey:"dimensionLength"}),new dn(e).render(),F.setDimension(t,e,"dimensionLength"),r}function wq(e,t){if(t=t||e.gId,!e||Nt(e)){dt(de(t)),F.setDimension(t,{},"dimensionAngle");return}let i=de(t),r=new hn(e).getContainer();return i?i.replaceWith(r):tt.appendTargetLayer(r,e.layer,!0,{cmdKey:"dimensionAngle"}),F.setDimension(t,e,"dimensionAngle"),r}function Sq(e,t){if(t=t||e.gId,!e||Nt(e)){dt(de(t)),F.setDimension(t,{},"dimensionRadius");return}let i=de(t),r=new tn(e).getContainer();return i?i.replaceWith(r):tt.appendTargetLayer(r,e.layer,!0,{cmdKey:"dimensionRadius"}),F.setDimension(t,e,"dimensionRadius"),r}function Yy(e,t){if(t=t!=null?t:e.gId,!e||Nt(e)){dt(de(t)),F.setAuxiliaryLine(t);return}let i=Pn.auxiliaryLine(e),r=Cs(i),n=de(t);if(!n)tt.appendTargetLayer(r,e.layer);else{let s=Ce.isSelected(n);n.replaceWith(r),s&&(Ce.unselect(n),Ce.select([r]))}return F.setAuxiliaryLine(t,e),TE([{data:e,view:de(t)}],xt.extendRect(J.svgRoot.viewBox.animVal)),de(t)}function Op(e,t){if(t=t!=null?t:e.gId,!e||Nt(e)){dt(de(t)),F.setAuxiliaryPoint(t);return}let i=Pn.auxiliaryPoint(e),r=Cs(i),n=de(t);if(!n)tt.appendTargetLayer(r,e.layer);else{let s=Ce.isSelected(n);n.replaceWith(r),s&&(Ce.unselect(n),Ce.select([r]))}return F.setAuxiliaryPoint(t,e),Am(de(t),Ru/J.gZoom),de(t)}var yi=class{static hasVisible(t){for(let i of t){let r=F.getById(i).json;if(!this.eleIsHide(r))return!0}return!1}static hasHidden(t){for(let i of t){let r=F.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 st,n=r.searchCombination(t.gId);if(n&&r.findFamily(n).getAllParents().some(d=>F.getCombination(d).visible===!1)||((c=tt.getCurrentScheme())==null?void 0:c.options.some(u=>+u.id==+t.layer&&!u.visible)))return!0;let a=Ga();if(a["all-element-type"][Ty(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=F.getById(t).json,r=this.eleIsHide(i);ni.renderer.attr(t,"display",r?"none":"")}static toggleElementsDisplay(t,i){let{elements:r,combinations:n}=new st().getSelectedCombinations(t),s=new oi;for(let o of r)s.addOne(F.getById(o).json),F.getById(o).json.visible=i,this.applyElementsVisible(o);let a=new st;for(let o of n){s.addOneCombineByComId(o);let l=F.getCombination(o);l.visible=i;let c=a.getAllElesfromTop(o).elements;for(let u of c)s.addOne(F.getById(u).json),this.applyElementsVisible(u)}s.updateAndSave()}static showAll(){let t=new oi;F.iteratorCombination(n=>{n.visible===!1&&(t.addOneCombineByComId(n.gId),n.visible=!0)});let i=Zt(tt.currentScheme);i.options.forEach(n=>{n.visible=!0}),tt.apply(i),_e("setFilterConfig"),_e("syncActivePanelLayerContent"),F.getItemOrder().forEach(n=>{let{json:s,cmdKey:a}=F.getById(n),{visible:o}=s;o===!1&&(t.addOne(s),s.visible=!0,Us(a,s))}),t.updateAndSave()}static isEyeGray(t,i){var f;let{layer:r,gId:n,locked:s,hide:a}=t||{},o=new st,l=o.searchCombination(n),c=!1,u=!1,h=!1,d=Ga();l&&(c=o.findFamily(l).getAllParents().some(g=>F.getCombination(g).visible===!1)),(f=tt.getCurrentScheme())==null||f.options.forEach(m=>{m.id===r&&!m.visible&&(u=!0)}),h=!d["all-element-type"][Ty(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 st().findFamily(t).getAllParents();return r.shift(),{combination:r.some(s=>F.getCombination(s).visible===!1)}}static toggleVisible(t,i){var n;let r=F.getById(t).json;r.visible=i!=null?i:!r.visible,((n=Ki.currentHoverEle)==null?void 0:n.id)===t&&(r.visible?Ki.createHighlightStyle(Ki.currentHoverEle):Ki.removeHighlightStroke()),this.applyElementsVisible(t)}};yi=La([Ea(gn.eleVisable)],yi);function dM(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:x,rotation:y,cacheWidth:E,cacheHeight:T,isWhiteBackground:w}=e,b={layer:t,opacity:r,locked:m,rotation:y,id:h,transform:ct.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":x,"font-style":l,"font-size":n,"font-family":a,"font-weight":+c==1?"bold":"normal","text-decoration":o,display:yi.eleIsHide(e)?"none":""};return t==2&&(r=Rp(+e.transparencyPrint*100,+e.transparencyWhite*100),b.opacity=r),`<g ${Object.entries(b).map(([A,R])=>`${A}="${ih(String(R))}"`).join(" ")}>
        <rect class="hitbox" stroke="none" fill="transparent" x="0" y="${-T}" width="${E}" height="${T}"></rect>
        <path class="primitive-text" d="${u}" stroke-width="0" stroke="none" fill="${s}"/>
    </g>`}var nA=class{constructor(t){this.elm=t;this.rectElm=jr("rect.hitbox",t),this.pathElm=jr("path",t),this.data=F.getText(t.id)}async name(t){if(t=uy(t),t.length>4096)return J.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,Tn([this.elm],{create8Dots:!0})}strokeColor(t){re(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 fu().getPath(l,h)}async syncTextFont(t){let{d:i,bbox:r}=await this.getTextPathInfo(t),n=r.height(),s=r.width();re(this.rectElm,{y:-n,width:s,height:n}),re(this.pathElm,"d",i),this.data.cacheWidth=s,this.data.cacheHeight=n,this.data.d=i}},WE=nA,sA=class{getTextPostion(t){let{matrix:i}=t,r=t.cacheWidth,n=t.cacheHeight,s=ct.createMatrixFrom6(i),{x:a,y:o}=this.getTextOrigin(t.gId),l=new V(-a,-o).multiply3(s),c=new V(0,-n).multiply3(s),h=new V(r,0).multiply3(s).distance1(l),d=c.distance1(l),p=Lp(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||F.getText(t),mt(i)&&(i=n.hAlign),mt(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=he.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=ct.createMatrixFrom6(t.matrix),{x:s,y:a}=this.getTextOrigin(t.gId),o=r||new V(-s,-a).multiply3(n),l=t.rotation||0,c=Math.round((i-l)*100)/100;if(c)return he.rotateD(c).setOrigin1(o)}sync(t,i,r){let n=ct.createMatrixFrom6(t.matrix),s=n.multiply3(i);r.reverse&&(s=i.multiply3(n));let a=$e.getMatrix6FromMatrix(s);r.updateMatrix&&(t.matrix=a),t.tempMatrix=a,ct.updateTransform(a,de(t.gId))}syncText(t,i,r){let n=pi.checkOne("text",t,i);n!==!1&&pi.addCallBack(()=>{var s;wp(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=F.getText(n),a=ct.createMatrixFrom6(s.matrix),o=this.getTextPostion(t),l=i*o.initWidth,c=r*o.initHeight,u=l/o.currentWidth,h=c/o.currentHeight;mt(i)&&(u=1),mt(r)&&(h=1);let d=this.getTextOrigin(n),p=new V(-d.x,-d.y).multiply3(a),f=he.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(os(i)&&(o=i/s),os(r)&&(l=r/a),o===1&&l===1)return;if(!n){let{x:u,y:h}=this.getTextOrigin(t.gId),d=ct.createMatrixFrom6(t.matrix);n=new V(-u,-h).multiply3(d)}let c=he.scale(o,l).setOrigin1(n);this.syncText(t,c,{updateMatrix:!0})}resetText(t){let i=t.id,r=F.getText(i),{matrix:n,rotation:s}=r,a=$e.createMatrixFrom6(n),{x:o,y:l}=this.getTextOrigin(i),c=new V(-o,-l).multiply3(a),u=he.translate(o,l).scale(1,1).rotateD(s).translate1(c),h=$e.getMatrix6FromMatrix(u);r.matrix=h,delete r.tempMatrix,ct.updateTransform(h,t)}syncTextPosition(t,i,r){let{x:n,y:s}=Ei(t,"text");i=os(i)?i:n,r=os(r)?r:s;let a=i-n,o=r-s;if(!a&&!o)return;let l=he.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}}},lr=new sA;function vq(e){let t=n=>re(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 oM({cx:n,cy:s,r:a})}case"ellipse":{let[n,s,a,o]=i(["cx","cy","rx","ry"]);return Yl({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=+re(e,"x")||0,s=+re(e,"y")||0,a=parseInt(window.getComputedStyle(e).height,10),o=parseInt(window.getComputedStyle(e).width,10),l=he.scale(o,a).translate(n,s),c=$e.getMatrix6FromMatrix(l);return Co({matrix:c})}default:break}return""}function pM(e){return/^#[\da-f]+$|^\w+$/i.test(e)}function Iq(e,t,i){for(;t.parentNode!==i;){if(e.includes(t.parentNode.tagName))return!0;t=t.parentNode}return!1}function fM(e,t,i,r,n,s){let a=Ha(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=T=>Array.from(l.querySelectorAll(T)),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,x=he.scale(p,f).setOrigin(t,i).translate(m*p,g*f),y=he.rotateD(d).setOrigin(t,i);J.gCanvas.appendChild(l);let E=u("path,circle,ellipse,line,polygon,polyline,rect");return o=Array.from(E).map(T=>{if(Iq([...c],T,l))return null;let b=vq(T);if(!b)return null;let C=Aq(T,x,J.gCanvas),R=Yi(b,!1).map(L=>L.multiply3(C).multiply3(y)),O=ls(R,!1,.01,{reverseY:!1});if(!O)return null;let M=window.getComputedStyle(T).fill,k="";M.startsWith("rgb")&&(k=Q3(M));let G=k||re(T,"fill")||M,H=re(T,"stroke")||"none",q=re(T,"stroke-width")||"1";G=pM(G)||G=="none"?G:"#000000",H=pM(H)?H:"none",q=Math.max(0,parseFloat(q)||0);let I=G!="none";!(H!="none"&&q>0)&&!I&&(H="#000000",q=1);let v=F.getInitialGroupData({gId:_t(),layer:tt.getTargetPlaceLayer("group")});return v.d=O,v.fillColor=G,v.strokeColor=H,v.strokeWidth=q,v}),J.gCanvas.removeChild(l),o.filter(Boolean)}function Aq(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 ct.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||J.svgRoot).multiply3(t)}function eo(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++}}}var qE=class{constructor(t,i){this.position=t,this.angles=i}};var Ds=class{constructor(t,i,r,n){this.beLongId=n,this.position=t,this.type=r,this.angles=i}};var Ac=class{constructor(t){this.bbox=t}};var Um=10,JE=7,Hy=9,mM=3,jy=8,KE=1,gM="2 3 2",Ym="#FF0000",bu="drawing",aA=["AuxiliaryPoint","AuxiliaryLineIntersect","BaseCross","Shape","AuxiliaryLine","ExtendLineIntersect","ExtendLine"];var oA=class{getLines(t,i,r){let n=new V(1,0),s=new V(0,1),a=new te(t.sub(n.mul(r/2)),t.add(n.mul(r/2))),o=new te(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 te(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 te(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 V(1,0);return new te(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=Sc(t[n],t[s]);for(let o=0;o<a;o+=2){let l=new V(fe[o],fe[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=aA.indexOf(t),n=aA.indexOf(i);return r-n}},Np=new oA;var $E=class{constructor(t,i,r,n){this.baseCrossFlagMgr=n,this.baseDotMgr=i,this.baseShapeMgr=r,this.excludeShapeIdMap=t}deal(t,i,r=Um/J.gZoom,n){let s,a,o,l=[],c,u=new V(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=yu.foot(d,u),f=p.distance1(u);f<r&&(r=f,s=p,a=null,o=[d],c="ExtendLine")}let h=Np.getLinesIntersectPointInfo(l);for(let d of h){let p=d.point.distance1(u);p<JE/J.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=F.getAuxiliaryPoint();for(let o in s){if((a=this.excludeShapeIdMap)!=null&&a.get(o))continue;let l=de(o);if(o!==bu&&(!l||re(l,"display")==="none"))continue;let c=s[o],u=new V(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=F.getAuxiliaryLine(),o=[];for(let c in a){if((l=this.excludeShapeIdMap)!=null&&l.get(c))continue;let u=de(c);if(c!==bu&&(!u||re(u,"display")==="none"))continue;let h=a[c],d=new V(h.x,h.y),p=d.add1(1,0).rotateD(d,h.rotation),f=new te(d,p),m=yu.foot(f,t),g=m.distance1(t);g<i&&(i=g,r=m,s=null,n={id:c,type:"AuxiliaryLine"}),g<JE/J.gZoom&&o.push(Np.getOneLine(new V(m.x,m.y),h.rotation,(J.svgRoot.width.baseVal.value+J.svgRoot.height.baseVal.value)/J.gZoom))}if(o.length>1){let c=Np.getLinesIntersectPointInfo(o);for(let u of c){let h=u.point.distance1(t);h<JE/J.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(Um/J.gZoom).build(),l=this.baseDotMgr.map;for(let u in l){if((c=this.excludeShapeIdMap)!=null&&c.get(u))continue;let h=de(u);if(u!==bu&&(!h||re(h,"display")==="none")||!o.intersection1(this.baseShapeMgr.getShapeBBox(u).extendOfSize(Um/J.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(...Np.getLines(o.position,o.angles,(J.svgRoot.width.baseVal.value+J.svgRoot.height.baseVal.value)/J.gZoom))}return[i,r,n,s,a]}};var ZE=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>Hy&&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 QE=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 e2=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 yd=class{};var t2=class extends yd{constructor(i,r){super();this.template=`<circle name="adsorption-point" class="adsorption"  cx="{x}" cy="{y}" r="${mM}" fill="${Ym}" stroke-width="0" transform="scale(${1/J.gZoom})" transform-origin="{x} {y}"></circle>`;this.x=0;this.y=0;this.x=i,this.y=r}getTemplate(){return Cs(this.template.replace(/\{\w+\}/g,i=>this[i.slice(1,i.length-1)]))}};var r2=class extends yd{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="${KE}" stroke="${Ym}" transform="scale(${1/J.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-jy,this.maxX=i+jy,this.minY=r-jy,this.maxY=r+jy}getTemplate(){return Cs(this.template.replace(/\{\w+\}/g,i=>this[i.slice(1,i.length-1)]))}};var n2=class extends yd{constructor(i,r){super();this.template=`<path name="adsorption-extend-line" class="adsorption" d="M {startX} {startY} L {endX} {endY}" stroke-width="${KE}" stroke-dasharray="${gM}" stroke="${Ym}" transform="scale(${1/J.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(J.svgRoot.width.baseVal.value+J.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=(J.svgRoot.width.baseVal.value+J.svgRoot.height.baseVal.value)/J.gZoom,a=i.add(new V(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 Cs(this.template.replace(/\{\w+\}/g,i=>this[i.slice(1,i.length-1)]))}};var lA=class{json2BaseCache(t,i,r){switch(t){case"ellipse":{let n=gi.getDotsForAdsorp(i),s=n.pop(),a=new ot;for(let u of n)a.ext2(u);let o=a.build(),l=new Ac(o);return{baseDots:n.map(u=>new Ds(u,new Set,0,i)).concat(new Ds(s,new Set,2,i)),baseShape:l}}case"arc":{let n=new Pi(r),s=new ot;for(let c of n.points(1))s.ext2(c);let a=s.build(),o=new Ac(a);return{baseDots:this.getBoxPoints(a).map(c=>new Ds(c,new Set,0,i)).concat(new Ds(n.vectorCenter(),new Set,2,i)).concat(new Ds(n.vectorStart(),new Set,1,i)).concat(new Ds(n.vectorEnd(),new Set,1,i)),baseShape:o}}case"group":{let{d:n}=r,s=new Nr(Yi(n)),{minX:a,maxX:o,minY:l,maxY:c}=s.bbox(),u=new xt(a,o,Math.min(-l,-c),Math.max(-l,-c)),h=new Ac(u),d=this.getBoxPoints(u),p=this.getGroupSelfPoints(i),f=u.center();return{baseDots:d.map(g=>new Ds(g,new Set,0,i)).concat(p.map(g=>new Ds(g.position,g.angles,1,i)),new Ds(f,new Set,2,i)),baseShape:h}}case"rect":{let n=ch(de(i)),s=new Ac(new xt(n.x,n.x+n.width,n.y,n.y+n.height)),a=Ai.getDotsForAdsorp(r),o=a.pop();return{baseDots:a.map(c=>new Ds(c,new Set,0,i)).concat(new Ds(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 Ac(a),l=a.center();return{baseDots:s.map(u=>new Ds(u.position,new Set([-((n||0)/180*Math.PI)]),0,i)).concat(new Ds(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 xt(0,0,0,0),o=new Ac(a),l=a.center();return{baseDots:s.map(u=>new Ds(u.position,new Set([-((n||0)/180*Math.PI)]),0,i)).concat(new Ds(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=de(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 V(a[a.length-2],a[a.length-1])}}getSelfPoints(t){let i=de(t);if(!i)return console.error(`Adsorption: does not exist ${t} shape, can not get self dots`),[];let r=[],n=mr.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 V(n[a],n[a+1]),l=a<n.length-3&&new V(n[a+2],n[a+3]),c=a>1&&new V(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}},cA=new lA;var yM={0:"ADSORPTION",1:"UPDATE SHAPE",2:"REMOVE SHAPE",3:"BUILD ALL SHAPE",4:"DRAG ADSORPTION"},s2=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(yM[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 ${yM[t]} operate time is too long and it takes ${i}ms`),this._warnTimes++}};var uA=class{constructor(){this.FILTER_SHAPE_KEYS=["ellipse","group","rect","text","obj","arc"];this.baseDotMgr=new QE;this.baseCrossFlagMgr=new ZE;this.baseShapeMgr=new e2;this.performanceMonitor=new s2;this._enabled=!0;this.excludeShapeIdMap=new Map;this._coreTool=new $E(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 de(t)}addCrossFlag(t,i=new Set){let r=new qE(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}=cA.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 V(t[n],t[n+1]),a=n<t.length-3&&new V(t[n+2],t[n+3]),o=n>1&&new V(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 Ds(s,u,i,bu))}this.baseDotMgr.updateDots(bu,r),this.baseShapeMgr.updateShape(bu,new Ac(new ot().ext3(r.map(n=>n.position)).build()))}else this.baseDotMgr.removeDots(bu),this.baseShapeMgr.removeShape(bu)}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),eo(F.gJsonCache,(t,i)=>{this.FILTER_SHAPE_KEYS.includes(t)&&eo(i,(r,n)=>{let{baseShape:s,baseDots:a}=cA.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 x,y;return Np.targetIdSortHandler(m[1].target.type,g[1].target.type)||(((x=g[1].adsorptionExtendLine)==null?void 0:x.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 V(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=Um/J.gZoom,n){return this._coreTool.deal(t,i,r,n)}setAdsorptionPointHTML(t,i){let r=new t2(t,i).getTemplate();J.svgRoot.appendChild(r),this.adsorptionPoints.add(r)}setExtendLineHTML(t){J.svgRoot.appendChild(new n2(t.start(),t.end()).getTemplate())}setCrossFlagHTML(t,i){J.svgRoot.appendChild(new r2(t,i).getTemplate())}clearAdsorptionPointHTML(){for(let t of this.adsorptionPoints)dt(t)}clearExtendLineHTML(){for(let t of Zr('[name="adsorption-extend-line"]',J.svgRoot))t.parentNode.removeChild(t)}clearCrossFlagHTML(){for(let t of Zr('[name="adsorption-cross-flag"]',J.svgRoot))t.parentNode.removeChild(t)}clearAdsorptionHTML(){this.clearCrossFlagCache(),this.clearAdsorptionPointHTML(),this.clearExtendLineHTML()}removeExtraCrossFlagHTML(){let t=Zr('[name="adsorption-cross-flag"]',J.svgRoot);if(t.length>Hy){let i=t.length-Hy;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(){Zr(".adsorption",J.svgRoot).forEach(t=>{re(t,"transform",`scale(${1/J.gZoom})`)})}setExcludeShapeIds(t=[]){return eo(t,(i,r)=>{this.excludeShapeIdMap.set(r,!0)}),this}clearExcludeShapeIds(){return this.excludeShapeIdMap.clear(),this}},bM,Lt=bM=bM||new uA;var Hm=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=J.defaultImage.userW,a=J.defaultImage.userH,o=he.scale(s,a).rotateD(this.rotation).translate(t,i),l=$e.getMatrix6FromMatrix(o);if(r)this.data.matrix=l,n.next(t,i),Lt.clearExcludeShapeIds();else if(!r)if(n.target)ct.updateTransform(l,n.target);else{let c=_t();Lt.setExcludeShapeIds([c]);let u=F.getInitialImageData({gId:c,layer:tt.getTargetPlaceLayer("obj")});u.content=J.defaultImage.src,this.data=u,this.data.gId=c,this.data.height=a,this.data.width=s,n.target=Tt("image",{id:c,class:Nl,preserveAspectRatio:"none",c_partid:"obj","xlink:href":u.content,x:0,y:0,width:1,height:1}),tt.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,")&&J.defaultImage.insertSvgAsPath){let l=a.content.slice(26),c;try{c=decodeURIComponent(escape(atob(l)))}catch(h){console.error(h);return}let u=fM(c,t,i,J.defaultImage.userW,J.defaultImage.userH,{rotation:this.rotation});if(u.length){Xt(),F.removeOne(r),s.target=null;let h=[];for(let p of u){let f=rl(p);tt.appendTargetLayer(f),h.push(f.id)}let d=[];for(let p of h){let f=de(p),m=Fn(f),g=zr(p,{cmdKey:"group",refId:m},Object.create(null),F.getById(f.id).json);d.push(g),Ce.select([f])}at.save(d)}else _e("ui/toastMsg",{type:"success",msg:"No svg shapes",timer:3}),dt(s.target),s.target=null;return}r=Uy(this.data),ja([r]),tt.appendTargetLayer(r),Xt(),Ce.select([r]),Lt.updateShapeCache(r.id,"obj",this.data),_e("panel_updateAttrPanel"),dt(s.target)}Je.started=!0}static end(t){var i=Je;i.target&&F.removeOne(i.target)}};Hm.rotation=0;function xM(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=Ha(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)EM(n,l+":");return i=new XMLSerializer().serializeToString(n),t+btoa(unescape(encodeURIComponent(i)))}function EM(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))EM(n,t)}var Po=class Po{static getJsonkeysArr(){return["rect","obj","ellipse","text","group","arc","auxiliaryLine","auxiliaryPoint","dimension","dimensionAngle","dimensionLength","dimensionRadius"]}static getLayerOrderContainer(){let t=jm(),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=Po.getJsonkeysArr();i!=null&&i.before&&i.before(n);let o=Po.convertAll(a,t,s);n.push('<g xmlns="http://www.w3.org/2000/svg" id="g1">'),n.push(Po.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(Qe(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(Qe(i[s],a))try{let o=i[s][a];r[a]=Po[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="${Po.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=Rp(+t.transparencyPrint*100,+t.transparencyWhite*100));let d=t.hide?1:0,p=t.locked?1:0,f=yi.eleIsHide(t)?"none":"",m=ih(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}=Ai.getRectFromMatrix(t.matrix),a=`transform="${ct.getTransformStr(n)}"`,o=Po.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 Pq(t)}static dimension(t){return new wn(t).getSvg()}static dimensionLength(t){return new dn(t).getSvg()}static dimensionAngle(t){return new hn(t).getSvg()}static dimensionRadius(t){return new tn(t).getSvg()}static auxiliaryLine(t){let i=Po.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=Po.generateCustomizeStr(t);return`<circle c_partid="auxiliaryPoint" id="${t.gId}" cx="${t.x}" cy="${t.y}" r="${Ru}" ${i}/>`}static ellipse(t){let{rx:i,ry:r,matrixArr:n}=gi.getEllipseFromMatrix(t.matrix),a=`transform="${ct.getTransformStr(n)}"`,o=Po.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=Pi.getD(t);return`<path ${Po.generateCustomizeStr(t,["stroke-linecap: round"])} d="${i}" c_partid="arc" id="${t.gId}" />`}static group(t){let i=Po.generateCustomizeStr(t,["stroke-linecap: round"]);return`<path id="${t.gId}" ${i} c_partid="group" d="${t.d}"/>`}static text(t){return dM(t)}};Po.lineStyle={0:"0",1:"6,6",2:"3,10",3:"4,2,1,2"};var Pn=Po;function Pq(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=ct.getTransformStr(e.matrix);e.content=xM(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:yi.eleIsHide(e)?"none":"",transform:l};return`<image ${Object.entries(c).map(([h,d])=>`${h}="${ih(String(d))}"`).join(" ")}></image>`}var Pi=class e extends ld{constructor(i){super(i);this.startAnchorSelected=!1;this.endAnchorSelected=!1;this.middleAnchorSelected=!1;this.centerSelected=!1}getMatrix(){return he.scale(this.data.rx,this.data.ry).rotateD(this.data.angle).translate(this.cx,this.cy)}getInverseMatrix(){let i=this.getMatrix();return new he(i.getInverseMatrix().data)}setControlDotSelected(i,r){return Zs({x:i,y:r},this.vectorStart())?(this.startAnchorSelected=!0,!0):Zs({x:i,y:r},this.vectorEnd())?(this.endAnchorSelected=!0,!0):Zs({x:i,y:r},this.vectorCenter())?(this.centerSelected=!0,!0):Zs({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=he.rotateD(-n).setOrigin1(i),a=this.getMatrix().multiply3(s),{a:o,b:l,c,d:u,e:h,f:d}=$e.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,x=l*f+u*m+d,y=new V(g,x).rotateD(i,n);return this.middleVector=y,y}else{let f=Math.cos(p),m=Math.sin(p),g=o*f+c*m+h,x=l*f+u*m+d,y=new V(g,x).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=he.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);sr.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=lE.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=he.translate(-s.x,-s.y).rotateD(-o),h=l.distance1(s),d=a.distance1(s);Ye.eq(h,0)&&(h=1),Ye.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);sr.syncArc(this.data,m,{updateD:n.updateD||!1})}forCenterArc(i,r,n){let s=new V(i,r),a=this.getMatrix(),o=new he(a.getInverseMatrix().data),l,c,u,h;if(this.startAnchorSelected){let f=this.vectorStart().add(s).multiply3(o).angle2(V.ORIGIN);u=new V(Math.cos(f),Math.sin(f)).multiply3(a),h={x1:u.x,y1:u.y},c=this.vectorEnd().sub(this.vectorCenter()),l=new V(u.x,u.y).sub(this.vectorCenter())}else if(this.endAnchorSelected){let f=this.vectorEnd().add(s).multiply3(o).angle2(V.ORIGIN);u=new V(Math.cos(f),Math.sin(f)).multiply3(a),h={x2:u.x,y2:u.y},c=new V(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=he.translate(i,r);sr.syncArc(F.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 V(this.cx,this.cy)}startAngle(){return fr(-this.vectorStart().angleD2(this.vectorCenter()))}endAngle(){return fr(-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=he.rotateD(-this.data.angle).scale(i/this.data.rx,r/this.data.ry).rotateD(this.data.angle).setOrigin1(n||this.vectorCenter());return sr.syncArc(this.data,s,{updateD:!0}),this}setData(){return F.setArc(this.data.gId,this.data),this}render(i){i=i||this.data,ni.renderer.attr(i.gId,"d",e.getD(i))}static getLoverArcId(i){return i+"-lover"}static removeHalfArc(i){i=this.getLoverArcId(i),TM([i])}static createHalfArc(i){if(jt.isEditingPath()!==i)return;let{json:r,cmdKey:n}=F.getById(i);if(n!=="arc")return;let s=Zt(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=Pn.arc(s);ni.renderer.removeNode(s.gId);let o=Cs(a);J.gCanvas.appendChild(o),ni.renderer.attr(s.gId,"pointer-events","none"),o.classList.add(Nl)}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 hA=class{constructor(){this.id="highlight-ele";this.containerId="container-for-create-stroke";this.currentHoverEle=null;this.debouncedAppendSelectStroke=$o(()=>{var i;let t=(i=F.selectedRepeater)==null?void 0:i.getSelfSelectMap();this.appendSelectStroke(t).emptyLastHoverEle().removeHighlightStroke()},0)}appendSelectStroke(t=F.selectedRepeater.getChangeMap(),i=!0){let r=de(this.containerId),n=document.createDocumentFragment(),s=this;return t.forEach((u,h)=>{let{cmdKey:d,color:p}=u,f=de(h);if(f)switch(p!=null&&p.startsWith("--")&&(p=`var(${p})`),d){case"text":let m=f.querySelector(".primitive-text");p||(p=F.getById(h).json.strokeColor),l(m,"fill",p);break;case"auxiliaryPoint":p||(p=F.getAuxiliaryPoint(h).fillColor),l(f,"fill",p);break;case"auxiliaryLine":p||(p=F.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=de(d);if(i&&(c("#"+d),p=null),h&&p)p.setAttribute("stroke",h);else if(h){let f=de(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){Zr(u).forEach(h=>h.remove())}}removeHighlightStroke(){return dt(jr(`[id^="${this.id}"]`)),this}removeCombinationElmsHighlightStroke(){return dt(Zr(`[id^="${this.id}"]`)),this}refreshHighlightStroke(){let t=Zr(`[id^="${this.id}"]`);this.emptyLastHoverEle(),this.removeCombinationElmsHighlightStroke(),t.forEach(i=>{let r=i.id.replace(`${this.id}-`,""),n=de(r);n&&this.createHighlightStyle(n)})}emptyLastHoverEle(){return this.currentHoverEle=null,this}removeHighlightById(t){Zr(`[id$="${t}"]`).forEach(r=>r.remove())}emptySelectContainer(){return vr().forEach(t=>{var r;let{cmdKey:i}=F.getById(t.id);if(!["text","auxiliaryLine","auxiliaryPoint","dimension","dimensionLength","dimensionAngle","dimensionRadius"].includes(i)){let n="select-for-"+t.id;(r=de(n))==null||r.remove()}}),this}createOneStroke(t,i="--selectColor"){let{json:r,cmdKey:n}=F.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=Tt("ellipse",{cx:0,cy:0,rx:1,ry:1,...a});break}case"obj":{o=Tt("rect",{x:0,y:0,width:1,height:1,...a});break}case"rect":{let{width:l,height:c,matrixArr:u}=Ai.getRectFromMatrix(s);o=Tt("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=Tt("path",{d:l,...a});break}case"arc":{let l=Pi.getD(r);delete a.transform,o=Tt("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;de(this.containerId).appendChild(r),jr}shouldRemoveHighlight(t){this.currentHoverEle&&this.currentHoverEle.id===t&&this.removeHighlightStroke().emptyLastHoverEle()}removeCombinationHighLight(){this.removeCombinationElmsHighlightStroke().emptyLastHoverEle()}},Ki=new hA;var a2=class{constructor(t){this.objs=t;this.deleted=!1}do(t=!1){let i=ts.anchorOrHandleHasSelected();if(i&&i.type!=="bbox"){let u=de(i.id);Bm.deletePathNode(u,i),il();return}let r=this.objs,n=is.findDimensionByPrimitiveIds(new Set(r.map(u=>u.id))).map(u=>de(u.gId));if(r.push(...n),!r.length)return;let s=r.map(u=>u.id),{combinations:a,elements:o}=new st().getSelectedCombinations(s);if(wr.hasCombinationLocked(a)||wr.hasEleLocked(o)){zl();return}let l=new oi(r),c=[];for(let u=0;u<r.length;u++){let h=r[u];c.push(F.getById(h.id).json),h&&F.removeOne(h)}for(let u of a)c.push(F.getById(u).json),F.deleteCombInParent(u),this.deleteCombinationAndChild(u);return t?(l.update(),F.freshItemOrder()):l.updateAndSave(),this.deleted=!0,c}isDeletedSuccess(){return this.deleted}deleteCombinationAndChild(t){let{combinations:i}=F.getCombination(t);F.setCombination(t);for(let r of i)this.deleteCombinationAndChild(r)}},Vy=class extends a2{};Vy=La([Ea(gn.delete)],Vy);function _o(e,t=!1){e=e||vr();let i=e.map(u=>u.id),r=new st,{combinations:n}=r.getSelectedCombinations(i),s=[],a=new Set(i);for(let u of n){let{elements:h,name:d,id:p}=F.getCombination(u);s.push(p+(d?":"+d:""));for(let f of h)a.add(f)}let o=Array.from(a).map(u=>de(u)),l=t?new a2(o):new Vy(o),c=l.do(t);return l.isDeletedSuccess()&&r.deleteCombinationToast(s),c.forEach(u=>Ki.removeHighlightById(u.gId)),c}var _q=$o(()=>{new $i().updateHole()}),o2=null,$i=class{constructor(){this.container=de("combination-container")}setMask(t){o2=t}getMask(){return o2}removeMask(){dt(o2),o2=null,this.removeUseEle()}removeUseEle(){for(;this.container.firstChild;)dt(this.container.firstChild)}zoom(){this.getMask()&&this.updateHole()}hoistPrimitives(t){for(let i of F.getItemOrder())if(t.includes(i)){let r="use-"+i;if(!jr("#"+r,this.container)){let s=Tt("use",{href:"#"+i,id:r});this.container.appendChild(s)}}}updateHole(t=!1){let i=jt.isEditingPath();if(i)return this.updateHoleForPath(i);if(!Kt.isEditing())return;let r=this.getMask()||this.createMask();this.setMask(r),t&&this.removeUseEle();let n=Kt.getCurrentEditingComId(),s=new st,a=Array.from(s.getAllElesfromTop(n).elements),o=F.getAllAssistPrimitive();this.hoistPrimitives([...a,...o]);let l=a.map(u=>de(u)),c={x:0,y:0,width:0,height:0};l.length&&(c=Mr(l)),this.innerUpdateHole(c,r)}updateHoleForPath(t){let{json:i,cmdKey:r}=F.getById(t);if(Nt(i))return jt.endEditingPath();let{x:n,y:s,width:a,height:o}=Ei(i,r);r==="arc"&&({x:n,y:s,width:a,height:o}=new ld(i).bboxEllipse());let l=new ot().ext5(n,n+a,s,s+o).ext7(Qa()).build(),c=this.getMask()||this.createMask();this.setMask(c);let u=Ec(l);this.innerUpdateHole(u,c),Pi.createHalfArc(t);let h=F.getAllAssistPrimitive();this.hoistPrimitives(h)}innerUpdateHole(t,i){let{x:r,y:n,width:s,height:a}=cs(J.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(" ");re(i,"d",p)}createMask(){let t=Tt("path",{id:"panel-mask",d:"",fill:"black",opacity:.2});return J.svgRoot.insertBefore(t,this.container),t}};$i.updateHole=_q;var l2=null,dA=class{constructor(){}getSelectDependMaskMode(t){if(!jt.isEleCanSelect(t))return qn(F.getById(t).cmdKey)?[{id:t}]:[];let i=new st,r=i.searchCombination(t);if(this.isEditing()){if(!r)return qn(F.getById(t).cmdKey)?[{id:t}]:[];let s=this.getCurrentEditingComId();if(s===r)return[de(t)];if(!i.findFamily(r).getAllParents().includes(s))return[];let a=i.findFamily(r,s).peekParent();return[...i.getAllElesfromTop(a).elements].map(l=>de(l))}if(r){let s=i.findFamily(r).peekParent();if(!this.isCombCanSelect(s))return[]}return[...i.findAllEleByOneEle(t)].map(s=>de(s))}findCombinationElementsById(t){let i=new st,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:Q1}isCombCanSelect(t){let i=F.getCombination(t);return!(!Ga()["all-state"].lock.checked&&i.locked)}isEditing(){return!!l2}setEditing(t){return t?(l2=t,new $i().updateHole()):(l2=null,new $i().removeMask()),this}deleteCombinations(t){let i=this.selectCombinations(t);if(i.length===0){let r=new oi;for(let n of t)F.deleteCombInParent(n),r.addOneCombineByComId(n),F.setCombination(n);r.updateAndSave();return}_o(i)}selectCombinations(t){let i=new Set,r=new st;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=>de(s));return Ce.select(n),Tn(n,{create8Dots:!0}),n}getCurrentEditingComId(){return l2}isEleCanSelect(t){if(!this.isEditing())return!0;let i=this.getCurrentEditingComId();return new st().getAllElesfromTop(i).elements.has(t)}},Kt=new dA;var pA=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"&&ts.hideAll()}startEditPath(t){this.toggleMode(t),this.currentRecords.get(t)==="box"?this.endEditingPath():(this.setCurrentEditingPath(t),Pi.createHalfArc(t))}setCurrentEditingPath(t){this.currentEditingPath=t,new $i().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"),Pi.removeHalfArc(this.currentEditingPath),this.currentEditingPath=null,new $i().removeMask(),Kt.isEditing()){let t=Kt.getCurrentEditingComId();Kt.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=vr()[0],r=this.getAnchorInfo(i),n=r.length,{json:s}=F.getById(i.id),a=Zt(s),o=Fn(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);re(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);re(i,"d",d),s.d=d,l=!0;break;default:console.error(u);break}else console.error(u.type);if(l){let d=zr(i.id,{cmdKey:"group",refId:o},a,s);Gs(i),at.save(d);break}}}Ki.removeHighlightStroke().emptyLastHoverEle().emptySelectContainer()}getPathSegment(t){function i(n){for(let s of n)if(Number.isNaN(s)||mt(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 re(t,"d",this.hoveredD),Gs(t),this.insertAnchorIndex}createHoverAnchor(t,i,r){if(!t){this.insertAnchorIndex>-1&&this.removeMiddleAnchor();return}if(this.is8DotsMode(t.id)||F.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=ts.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=Yi(u)[0].primitives[0].clip(.5),f=p[0].controls,m=p[1].controls,g=ts.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 x=this.getPathD(a);this.hoveredD=x;break}case"Q":{if(o.index+2===this.insertAnchorIndex)return;this.removeMiddleAnchor();let h=new Ue([new V(o.x,o.y),new V(l.x1,l.y1),new V(l.x,l.y)]).clip(.5),d=h[0].controls,p=h[1].controls,f=ts.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=Ks({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=Yi(d)[0].primitives[0],m=[];f.getBezierPoints(1,function(g){m.push(g)}),h=a;for(let g of m){let x=wo(i,r,g.x,-g.y);h=Math.min(h,x)}}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)||F.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];ts.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=he.translate(-t.x,-t.y).rotateD(-a);return r.multiply3(o).multiply3(he.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),x=g.pathSegType;m===0&&x!=yr&&x!=Dr&&x!=ti&&(console.warn(g,x),d.push({x:n,y:s,index:f,type:""}));let y=d.length-1;switch(x){case ti:n=a,s=o;break;case yr:{if(n=g.x,s=g.y,a=n,o=s,m+1==r||(u=i.getItem(m+1),c=u.pathSegType,c==yr||c==Dr||c==ti))break;let T=`M ${n} ${s} `;d.push({x:n,y:s,index:f++,type:"M",d:T});break}case Dr:if(n+=g.x,s+=g.y,a=n,o=s,m+1==r||(c=i.getItem(m+1).pathSegType,c==yr||c==Dr||c==ti))break;p.push(n,s);break;case on:{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==ti&&(u=i.getItem(0)),c==on||c==ti;break}case po:d.push({x:g.x,y:s,index:++f,type:""});break;case fo:d.push({x:n,y:g.y,index:++f,type:""});break;case lo: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 uo:{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 T=" 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:T});break}case ho:case Oa:if(p.push(n=g.x,s=g.y),m+1==r)break;u=i.getItem(m+1),c=u.pathSegType,c==ti&&(u=i.getItem(0)),c==on||c==ti;break;case Tl:p.push(n+=g.x,s+=g.y);break;case El:p.push(n+=g.x,s);break;case wl:p.push(n,s+=g.y);break;case gl: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 yl:l.push({from:y+1,to:y+2}),p.push(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.x1,s+g.y1,n+=g.x,s+=g.y);break;case xl:case ml:p.push(n+=g.x,s+=g.y);break;default:break}}return d}},jt=new pA;var st=class{constructor(){}modifyCombination(t){let i=new oi;for(let r of t){let n=r.combId;i.addOneCombineByComId(n);let s=F.getCombination(n);Fa(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),F.getCombination(l).parent=n}i.updateAndSave()}removeFromGroup(t){let i="",r="";Array.isArray(t)||(t=Ce.getIds());let n=new oi;for(let s of t){let a=this.searchCombination(s);if(!a)continue;n.addOneCombineByComId(a);let o=F.getCombination(a);r=o.id||o.gId,i=o.name;let l=o.elements.indexOf(s);o.elements.splice(l,1),Ce.unselect(de(s))}n.updateAndSave(),Xt(),new $i().updateHole(),fn("updateAttrPanel"),rs({value:"{0} element removed from the group:group{idWithName}",options:{0:t.length,idWithName:r.replace("e","")+(i?`:${i}`:"")}},"success")}getSelectedCombinations(t){let i=Ya(),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=Ya(),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=_t(),s=Kt.getCurrentEditingComId(),a=F.getInitialCombinationData({gId:n,elements:Array.from(r),combinations:Array.from(i),parent:s}),o=new oi;o.addOneCombineByComId(n,{}),o.addOneCombineByComId(s),F.setCombination(n,a);let l=F.getCombination(s);for(let c of r)l.elements.splice(l.elements.indexOf(c),1);for(let c of i){let u=F.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=Sa(vr()).map(o=>o.id);if(!t.length)return;if(Kt.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=_t(),s=F.getInitialCombinationData({gId:n,elements:Array.from(i),combinations:Array.from(r)});F.setCombination(n,s);let a=new oi;a.addOneCombineByComId(n,{});for(let o of r){a.addOneCombineByComId(o);let l=F.getCombination(o);l.parent=n}a.updateAndSave(),this.afterCombine(i.size+r.size)}afterCombine(t){t!==0&&(rs({value:"{0} objects grouped successfully",options:{0:t}},"success"),_e("panel_updateAttrPanel"))}deleteCombinationToast(t){t.length!==0&&rs({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),F.setCombination(r);i.updateAndSave()}unCombine(){let t=new Set,i=Ce.getIds(),r=new oi,n=new Set,s=[];for(let o of i){let l=this.searchCombination(o);if(l){let c=Kt.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=F.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)F.getCombination(h).parent=c?c.id:null;let u=F.getCombination();delete u[o],s.push("Combination"+l.id.replace("e","")+(l.name?`:${l.name}`:""))}r.updateAndSave();let a=Array.from(t);rs({value:"{num} Ungrouped successfully:{groupIdWithNames}",options:{num:a.length,groupIdWithNames:s},translateOptionKeys:["groupIdWithNames"],translateIndexOfArray:"all"},"success"),_e("panel_updateAttrPanel"),$i.updateHole()}unCombineAllEmpty(){let t=this.getAllEmptyCombinations();this.deleteEmptyCombination(t),rs({value:"Successfully cancel all empty group"},"success")}unCombineAll(){let t=!1,i=new oi;F.iteratorCombination(r=>{t=!0,i.addOneCombineByComId(r.gId),F.setCombination(r.gId)}),t&&(i.updateAndSave(),rs({value:"Successfully cancel all group"},"success"),Kt.setEditing(null),jt.endEditingPath())}joinGroup(t){let i=F.getCombination(t).name,r=Ce.getIds();r=Sa(r.map(l=>de(l))).map(l=>l.id);let{elements:n,combinations:s}=this.getSelectedCombinations(r),a=[],o=F.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=F.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),Ce.unselectAll(),Ce.select(r.map(l=>({id:l}))),rs({value:"{0} objects join group successfully:group{idWithName}",options:{0:n.size+s.size,idWithName:o.replace("e","")+(i?`:${i}`:"")}},"success"),Kt.isEditing()&&(new $i().updateHole(),Xt()))}peekParent(){return this.parent.at(-1)}findFamily(t,i=null){let r=F.getCombination(t),n=[t];for(;r.parent&&r.parent!==i;)r=F.getCombination(r.parent),n.push(r.gId);return this.parent=n.filter(s=>s),this}getAllParents(){return this.parent}findParent(t){let i=F.getCombination(t);return i.parent?F.getCombination(i.parent):null}searchCombination(t){let i;return F.iteratorCombination(r=>{if(r.elements.includes(t))return i=r.gId,Dh}),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=F.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}=F.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),F.setCombination(a.gId,a)}let s=[];for(let a of n){t.addOne(F.getById(a.id).json,{});let o=Kt.getCurrentEditingComId();if(o){let l=F.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)F.getCombination(a).parent=o}getAllCombinationData(t){let i=new Set,r=[];for(let n of t){let s=Kt.getCurrentEditingComId(),a=this.findFamily(n,s).getAllParents();for(let o of a){if(i.has(o))continue;i.add(o);let l=F.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=Kt.getCurrentEditingComId(),c=this.findFamily(o,l).getAllParents();for(let u of c)n.has(u)||(n.add(u),r.push(F.getCombination(u)))}}let s=[];for(let a of r){let o=structuredClone(a);o.gId=_t(),s.push(o),i.set(a.gId,o.gId)}return{oldIdMapNewId:i,copiedCombination:s}}getAllEmptyCombinations(){let t=[];return F.iteratorCombination(({gId:i})=>{!this.getAllChildEles(i).size&&t.push(i)}),[...t]}};var fA=class{constructor(){}getTree(t=null){let i=[];return F.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 c2(e=null){return new fA().getTree(e)}function Ya(){let e=new st,t=Kt.getCurrentEditingComId(),i=c2(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=F.getCombination(a.id);n.push({elements:Array.from(o),combinationId:a.id,selectable:!l.locked})}let s=F.getItemOrder();for(let a of s)r.has(a)||n.push({elements:[a]});return n}var XE=class{constructor(){this.allCombLevelElements=Ya()}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}=F.getById(n);t.set(n,{id:n,cmdKey:s,combinationId:r})}return t}};var Lq=Object.create,h4=Object.defineProperty,Oq=Object.getOwnPropertyDescriptor,Rq=Object.getOwnPropertyNames,Nq=Object.getPrototypeOf,Mq=Object.prototype.hasOwnProperty,wM=(e=>typeof oo<"u"?oo:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof oo<"u"?oo:t)[i]}):e)(function(e){if(typeof oo<"u")return oo.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),er=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Bq=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Rq(t))!Mq.call(e,n)&&n!==i&&h4(e,n,{get:()=>t[n],enumerable:!(r=Oq(t,n))||r.enumerable});return e},lg=(e,t,i)=>(i=e!=null?Lq(Nq(e)):{},Bq(t||!e||!e.__esModule?h4(i,"default",{value:e,enumerable:!0}):i,e)),d1=er((e,t)=>{"use strict";var i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a=(D,j)=>{for(var Z in j)i(D,Z,{get:j[Z],enumerable:!0})},o=(D,j,Z,K)=>{if(j&&typeof j=="object"||typeof j=="function")for(let ee of n(j))!s.call(D,ee)&&ee!==Z&&i(D,ee,{get:()=>j[ee],enumerable:!(K=r(j,ee))||K.enumerable});return D},l=D=>o(i({},"__esModule",{value:!0}),D),c={};a(c,{BroadcastChannelMessageBus:()=>Ee,MessageBus:()=>v,MessageBus2:()=>ne,MessageBusTask:()=>N,MessageBusTask2:()=>z,WindowMessageBridge:()=>I,WorkerMessageBridge:()=>q,createBroadcastP2PStream:()=>It,createBufferedByteBufferStream:()=>je,createBufferedStream:()=>Ne,createBufferedStringStream:()=>it,dropP2PStream:()=>Ht,flowRead:()=>ze,flowWrite:()=>Ci}),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 j=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,j);let Z=new Array(j);for(let K=0;K<this.count;K++)Z[K]=this.buffer[(this.head+K)%this.capacity];this.buffer=Z,this.head=0,this.tail=this.count,this.capacity=j}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 x(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(x);{let j={};for(let Z in D)Object.hasOwnProperty.call(D,Z)&&(j[Z]=x(D[Z]));return j}}function y(D,j){return E(D,j,()=>[])}function E(D,j,Z){let K=D[j];return K!==void 0||(K=Z(j),D[j]=K),K}var T=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 b(D,j){let Z=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===j&&(D.splice(ee,1),ee--,K--,Z++);return Z}var C=w(),A=C.WeakRef||(D=>D);function R(D){if(D!=null){if(typeof D=="object")return new A(D);console.error(D,D instanceof Object,typeof D);return}}function O(D){return D==null?void 0:D.deref()}var M="_MSG_BUS_RPC_",k=300*1e3,G=(D=>(D.PUBLISH="publish",D.SUBSCRIBE="subscribe",D.PUSH="push",D.PULL="pull",D))(G||{}),H=class{constructor(D){this.bus=D}processRemoteMessage(D,j){let Z=R(j),K=D.topic,ee=D.type,ge=D.message;switch(ee){case"pull":this.bus.pull(K,le=>{this.push(K,le,O(Z))});break;case"subscribe":this.bus.subscribe(K,le=>{this.publish(K,le,O(Z))});break;case"publish":this.bus.publish(K,ge,this,O(Z));break;case"push":this.bus.push(K,ge,this,O(Z));break;default:console.debug("unknown message type "+ee)}}rpcCall(D,j,Z,K=k){let ee=R(Z),ge=new Promise(le=>{let ke=this.bus.uniqueRpcTopic(D);this.publish(D,{message:j,reply:ke},O(ee)),this.bus.pull(ke,(rt,gt,et)=>{le({message:rt,bridge:gt,source:R(et)})})});return K>0?Promise.race([ge,new Promise((le,ke)=>{setTimeout(ke,K)})]):ge}},q=class extends H{constructor(D,j){super(D),this.worker=j,j.onmessage=Z=>{this.processRemoteMessage(Z.data,void 0)}}publish(D,j){this.postMessage(D,"publish",j)}subscribe(D){this.postMessage(D,"subscribe",null)}push(D,j){this.postMessage(D,"push",j)}pull(D){this.postMessage(D,"pull",null)}rpcCall(D,j,Z=k){return super.rpcCall(D,j,void 0,Z)}postMessage(D,j,Z){let K={topic:D,type:j,message:Z};this.worker.postMessage(K)}discard(){this.worker.terminate()}},I=class extends H{constructor(D){super(D),window.addEventListener("message",j=>{this.processRemoteMessage(j.data,j.source)},!1)}publish(D,j,Z){this.postMessage(D,"publish",j,Z)}subscribe(D,j){if(j===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(D,"subscribe",null,j)}push(D,j,Z){this.postMessage(D,"push",j,Z)}pull(D,j){if(j===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(D,"pull",null,j)}postMessage(D,j,Z,K){let ee={topic:D,type:j,message:Z};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,j,Z,K){try{D=K?D:x(D),this.callback(D,j,Z)}catch(ee){console.error(ee)}}},v=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,j,Z,K){let ee=this.subscribed[D];if(ee){let ge;for(let le of ee)le.running()?le.execute(j,Z,K,this.unsafe):(ge=ge||new Array,ge.push(le));if(ge)for(let le of ge)b(ee,le)}else console.debug("no sub on topic: "+D)}subscribe(D,j){let Z=new N(j);return y(this.subscribed,D).push(Z),Z}push(D,j,Z,K){let ee=!1,ge=this.pulled[D];if(ge){for(;ge.length>0;){let le=ge.shift();if(le.running()){le.execute(j,Z,K,this.unsafe),ee=!0;break}}ge.length===0&&delete this.pulled[D]}ee||y(this.pushed,D).push({message:j,bridge:Z,source:R(K)})}pull(D,j){let Z=new N(j),K=this.pushed[D];if(K){let ee=K.shift();Z.execute(ee.message,ee.bridge,O(ee.source),this.unsafe),K.length===0&&delete this.pushed[D]}else y(this.pulled,D).push(Z);return Z}pullA(D){return new Promise(j=>{this.pull(D,(Z,K,ee)=>{j({message:Z,bridge:K,source:R(ee)})})})}rpcService(D,j){this.subscribe(D,(Z,K,ee)=>{let{message:ge,reply:le}=Z;try{let ke=j(ge);if(ke instanceof Promise){let rt=R(ee);ke.then(gt=>{this.rpcReply(gt,le,K,O(rt))},gt=>{console.error(gt),this.rpcReply(void 0,le,K,O(rt))})}else this.rpcReply(ke,le,K,ee)}catch(ke){console.error(ke),this.rpcReply(void 0,le,K,ee)}})}rpcCall(D,j,Z=k){let K=new Promise(ee=>{let ge=this.uniqueRpcTopic(D);this.publish(D,{message:j,reply:ge}),this.pull(ge,(le,ke,rt)=>{ee({message:le,bridge:ke,source:R(rt)})})});return Z>0?Promise.race([K,new Promise((ee,ge)=>{setTimeout(ge,Z)})]):K}rpcReply(D,j,Z,K){Z?Z.push(j,D,K):this.push(j,D)}},L="_MSG_BUS_RPC_";function _(D,j){let Z=0,K=D.length;for(let ee=0;ee<K;ee++)D[ee]===j&&(D.splice(ee,1),ee--,K--,Z++);return Z}function B(D,j){return U(D,j,()=>[])}function U(D,j,Z){let K=D[j];return K!==void 0||(K=Z(j),D[j]=K),K}var z=class{constructor(D,j){this.callback=D,this.unsafe=j,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(D){try{D=this.unsafe?D:x(D),this.callback(D)}catch(j){console.error(j)}}},W=class{constructor(D=crypto.randomUUID()){this.uuid=D,this.rpcTicket=0}subscribeOnce(D,j){let Z=this.subscribe(D,K=>{Z.cancel(),j(K)});return Z}pullA(D){return new Promise(j=>{this.pull(D,j)})}rpcService(D,j){let Z=K=>{try{let{message:ee,replyTopic:ge}=K;try{let le=j(ee);le instanceof Promise?le.then(ke=>{this.publish(ge,{success:!0,result:ke})}).catch(ke=>{console.error(ke),this.publish(ge,{success:!1,err:String(ke)})}):this.publish(ge,{success:!0,result:le})}catch(le){this.publish(ge,{success:!1,err:String(le)})}}finally{this.pull(D,Z)}};this.pull(D,Z)}rpcCall(D,j,Z=0){let K=new Promise((ee,ge)=>{let le=`${L}-${D}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(le,ke=>{ke.success?ee(ke.result):ge(new Error(ke.err))}),this.push(D,{message:j,replyTopic:le})});return Z>0?Promise.race([K,new Promise((ee,ge)=>{setTimeout(ge,Z)})]):K}},ne=class extends W{constructor(D=!1){super(),this.unsafe=D,this.subscribed={},this.pulled={},this.pushed={}}publish(D,j){let Z=this.subscribed[D];if(Z){let K;for(let ee of Z)ee.running()?ee.execute(j):(K=K||new Array,K.push(ee));if(K)for(let ee of K)_(Z,ee)}}subscribe(D,j){let Z=new z(j,this.unsafe);return B(this.subscribed,D).push(Z),Z}push(D,j){let Z=!1,K=this.pulled[D];if(K){for(;K.length>0;){let ee=K.shift();if(ee&&ee.running()){ee.execute(j),Z=!0;break}}K.length===0&&delete this.pulled[D]}Z||B(this.pushed,D).push(j)}pull(D,j){let Z=new z(j,this.unsafe);return this.repull(D,Z),Z}repull(D,j){let Z=this.pushed[D];if(Z){let K=Z.shift();K&&(j.execute(K),Z.length===0&&delete this.pushed[D])}else B(this.pulled,D).push(j)}},me=class extends W{constructor(D=crypto.randomUUID()){super(D),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(D,j){console.debug("BC",this.uuid,"PUBLISH",D,j),this.broadcastPublish(D,j)}subscribe(D,j){console.debug("BC",this.uuid,"SUBSCRIBE",D);let Z=new z(j,!0);return B(this.subscribed,D).push(Z),Z}push(D,j){let Z=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",D,`(${Z})`,j),B(this.pushed,D).push({id:Z,message:j}),this.broadcastPushedHeadMessage(D)}pull(D,j){console.debug("BC",this.uuid,"PULL",D);let Z=new z(j,!0);return B(this.pulled,D).push(Z),this.broadcastWhoHas(D),Z}broadcastPushedHeadMessage(D){let j=this.pushed[D];j&&j[0]&&this.broadcastIHave(D,j[0].id)}onReceivedPublish(D,j,Z){console.debug("BCMSG(",this.uuid,")","from",D,"PUBLISH",j,"message",Z);let K=this.subscribed[j];if(K){let ee;for(let ge of K)ge.running()?ge.execute(Z):(ee=ee||new Array,ee.push(ge));if(ee)for(let ge of ee)_(K,ge);K.length===0&&delete this.subscribed[j]}}onReceivedWhoHas(D,j){console.debug("BCMSG(",this.uuid,")","from",D,"WHOHAS",j),this.broadcastPushedHeadMessage(j)}onReceivedIHave(D,j,Z){console.debug("BCMSG(",this.uuid,")","from",D,"IHAVE",j,"id",Z);let K=this.pulled[j];if(K){let ee;for(let ge of K)if(ge.running()){this.broadcastINeed(j,D,Z);break}else ee=ee||new Array,ee.push(ge);if(ee)for(let ge of ee)_(K,ge);K.length===0&&delete this.pulled[j]}}onReceivedINeed(D,j,Z,K){if(console.debug("BCMSG(",this.uuid,")","from",D,"INEED",j,"source",Z,"id",K),this.uuid===Z){let ee=this.pushed[j];if(ee&&ee[0]&&ee[0].id===K){let{message:ge}=ee.shift();this.broadcastIGive(j,K,D,ge),this.broadcastPushedHeadMessage(j),ee.length===0&&delete this.pushed[j]}}}onReceivedIGive(D,j,Z,K,ee){console.debug("BCMSG(",this.uuid,")","from",D,"IGIVE",j,"id",Z,"target",K,"message",ee);let ge=this.pulled[j];if(ge&&this.uuid===K){let le=!1;for(;ge.length>0;){let ke=ge.shift();if(ke.running()){ke.execute(ee),le=!0;break}}le||this.push(j,ee),ge.length===0&&delete this.pulled[j]}}},Ee=class extends me{constructor(D,j=crypto.randomUUID()){super(j),this.bc=new BroadcastChannel(D),this.bc.onmessage=Z=>{this.onMessage(Z.data)}}onMessage(D){let{type:j,uuid:Z,topic:K}=D;switch(j){case"PUBLISH":{let{message:ee}=D;this.onReceivedPublish(Z,K,ee);break}case"WHOHAS":{this.onReceivedWhoHas(Z,K);break}case"IHAVE":{let{id:ee}=D;this.onReceivedIHave(Z,K,ee);break}case"INEED":{let{source:ee,id:ge}=D;this.onReceivedINeed(Z,K,ee,ge);break}case"IGIVE":{let{target:ee,id:ge,message:le}=D;this.onReceivedIGive(Z,K,ge,ee,le);break}default:console.warn("unsupported",D)}}broadcastPublish(D,j){this.post({type:"PUBLISH",uuid:this.uuid,topic:D,message:j})}broadcastWhoHas(D){this.post({type:"WHOHAS",uuid:this.uuid,topic:D})}broadcastIHave(D,j){this.post({type:"IHAVE",uuid:this.uuid,topic:D,id:j})}broadcastINeed(D,j,Z){this.post({type:"INEED",uuid:this.uuid,topic:D,source:j,id:Z})}broadcastIGive(D,j,Z,K){this.post({type:"IGIVE",uuid:this.uuid,topic:D,id:j,target:Z,message:K})}post(D){this.bc.postMessage(D),Promise.resolve().then(()=>{this.onMessage(D)})}},Se=Symbol("BLOCKING_QUEUE_RESET"),Fe=class{constructor(D,j=()=>1){if(this.maxSize=D,this.itemSizeOf=j,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 j=await new Promise(Z=>{this.waitingProducers.enqueue(Z)});return console.debug("queue is not full",this.size(),j),j?(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 j=this.waitingConsumers.dequeue();Promise.resolve(D).then(j),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(Se).then(D)}return setTimeout(()=>this.closeResolve(),0),Se}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 j=this.waitingProducers.dequeue();Promise.resolve(!0).then(j)}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 j=this.waitingProducers.dequeue();Promise.resolve(!1).then(j)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let j=this.waitingConsumers.dequeue();Promise.resolve(Se).then(j)}D()}})),this.closePromise}};function Ne(D,j,Z=Number.MAX_SAFE_INTEGER){let K=new Fe(Z,j),ee=new ReadableStream({pull(le){let ke=!0,rt=(async()=>{let gt=new Array;do{let et=K.dequeue();if(et instanceof Promise){ke=!1;let si=await et;si===Se?le.close():gt.push(si)}else{let si=et;si===Se?le.close():gt.push(si)}}while(K.size()>0);if(gt.length>0){let et=D(gt);le.enqueue(et)}})();if(!ke)return console.debug("read stream stucked --------------------------------------"),rt},async cancel(){console.debug("buffered readable cancel"),await K.close()}}),ge=new WritableStream({write(le,ke){let rt=!0,gt=(async()=>{let et=K.enqueue(le);typeof et=="boolean"?et||ke.error(new Error("Write stream closed")):(rt=!1,await et||ke.error(new Error("Write stream closed")))})();if(!rt)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),gt},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:ge}}function it(D=Number.MAX_SAFE_INTEGER){return Ne(j=>j.join(""),j=>j.length,D)}function je(D=Number.MAX_SAFE_INTEGER){return Ne(j=>{let Z=new Uint8Array(j.reduce((ee,ge)=>ee+ge.byteLength,0)),K=0;return j.forEach(ee=>{Z.set(ee,K),K+=ee.byteLength}),Z},j=>j.byteLength,D)}function It(D){return new Promise((j,Z)=>{let K=new BroadcastChannel(D),ee=new Fe(1),ge=new T(1),le=null,ke=!1,rt=!1,gt=!1;K.onmessage=et=>{let si=et.data,{type:ji}=si;if(console.debug("p2p",D,"type",ji,"data",ji==="DATA"&&si.data),ji==="DATA")ee.enqueue(si.data);else if(ji==="HI"){if(!le){K.postMessage({type:"HI"});let Ar=0;le={rs:new ReadableStream({async pull(Sr){let vn=await ee.dequeue();vn===Se?(await Li(),Sr.close()):(Sr.enqueue(vn),K.postMessage({type:"ACK"}))},cancel(){return Li()}}),ws:new WritableStream({async write(Sr,vn){await ge.acquireSync()?K.postMessage({type:"DATA",id:Ar++,data:Sr}):(tr(),vn.error(new Error("Write stream closed")))},close(){tr()},abort(){tr()}})},j(le)}}else ji==="REND"?le?ge.close():Sn("REND1"):ji==="WEND"?le?ee.close():Sn("WEND1"):ji==="ACK"&&ge.release();function tr(){ke||(ke=!0,console.debug(D,"p2p write stream closed"),ge.close(),K.postMessage({type:"WEND"}),rt&&(console.debug(D,"p2p channel closed on ws"),K.close()))}async function Li(){rt||(rt=!0,console.debug(D,"p2p read stream closed"),K.postMessage({type:"REND"}),await ee.close(),ke&&(console.debug(D,"p2p channel closed on rs"),K.close()))}async function Sn(Ar){gt||(gt=!0,console.debug(D,"p2p channel connection released on",Ar),ge.close(),ee.close(),le?(le.rs.locked||(console.debug(D,"p2p unlocked read stream direct cancel"),le.rs.cancel()),le.ws.locked||(console.debug(D,"p2p unlocked write stream direct close"),le.ws.close())):(K.postMessage({type:"HI"}),K.close()),Z(new Error("p2p channel connection released")))}},K.postMessage({type:"HI"})})}function Ht(D){return new Promise(j=>{let Z=new BroadcastChannel(D);Z.onmessage=K=>{let ee=K.data,{type:ge}=ee;ge==="HI"&&(Z.postMessage({type:"REND"}),Z.close(),j())},Z.postMessage({type:"REND"})})}async function Ri(D){try{return await It(D)}catch(j){j.message!=="p2p channel connection released"&&console.error(j)}}async function Ci(D,j,Z=10*1024*1024,K=!0){let ee=await Ri(D);if(!ee)return!1;let ge=!1;try{let le,ke=rt=>{if(!le)if(!K)le=ee.ws.getWriter();else if(typeof rt=="string"){let gt=it(Z);gt.readable.pipeTo(ee.ws),le=gt.writable.getWriter()}else{let gt=je(Z);gt.readable.pipeTo(ee.ws),le=gt.writable.getWriter()}return le.write(rt)};if(Array.isArray(j))for(let rt of j)await ke(rt);else await j({write:ke,get desiredSize(){return((le==null?void 0:le.desiredSize)||0)+10}});le&&await le.close(),ge=!0}catch(le){console.error(le)}finally{return ee.rs.cancel(),ge}}async function ze(D,j){var Z,K;let ee=await Ri(D);if(ee)try{let ge=ee.rs.getReader();for((Z=j.start)==null?void 0:Z.call(j);;){let{value:le,done:ke}=await ge.read();if(le!==void 0){let rt;if(j.update instanceof Promise?rt=await j.update(le):rt=j.update(le),rt){await ge.cancel();break}}if(ke){(K=j.end)==null||K.call(j);break}}}catch(ge){console.error(ge)}finally{ee.ws.close()}}}),cr=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 wM=="function")try{s=wM("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(T){var w;return E.prototype=T,w=new E,E.prototype=null,w}})(),l={},c=l.lib={},u=c.Base=(function(){return{extend:function(E){var T=o(this);return E&&T.mixIn(E),(!T.hasOwnProperty("init")||this.init===T.init)&&(T.init=function(){T.$super.init.apply(this,arguments)}),T.init.prototype=T,T.$super=this,T},create:function(){var E=this.extend();return E.init.apply(E,arguments),E},init:function(){},mixIn:function(E){for(var T in E)E.hasOwnProperty(T)&&(this[T]=E[T]);E.hasOwnProperty("toString")&&(this.toString=E.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),h=c.WordArray=u.extend({init:function(E,T){E=this.words=E||[],T!=n?this.sigBytes=T:this.sigBytes=E.length*4},toString:function(E){return(E||p).stringify(this)},concat:function(E){var T=this.words,w=E.words,b=this.sigBytes,C=E.sigBytes;if(this.clamp(),b%4)for(var A=0;A<C;A++){var R=w[A>>>2]>>>24-A%4*8&255;T[b+A>>>2]|=R<<24-(b+A)%4*8}else for(var O=0;O<C;O+=4)T[b+O>>>2]=w[O>>>2];return this.sigBytes+=C,this},clamp:function(){var E=this.words,T=this.sigBytes;E[T>>>2]&=4294967295<<32-T%4*8,E.length=r.ceil(T/4)},clone:function(){var E=u.clone.call(this);return E.words=this.words.slice(0),E},random:function(E){for(var T=[],w=0;w<E;w+=4)T.push(a());return new h.init(T,E)}}),d=l.enc={},p=d.Hex={stringify:function(E){for(var T=E.words,w=E.sigBytes,b=[],C=0;C<w;C++){var A=T[C>>>2]>>>24-C%4*8&255;b.push((A>>>4).toString(16)),b.push((A&15).toString(16))}return b.join("")},parse:function(E){for(var T=E.length,w=[],b=0;b<T;b+=2)w[b>>>3]|=parseInt(E.substr(b,2),16)<<24-b%8*4;return new h.init(w,T/2)}},f=d.Latin1={stringify:function(E){for(var T=E.words,w=E.sigBytes,b=[],C=0;C<w;C++){var A=T[C>>>2]>>>24-C%4*8&255;b.push(String.fromCharCode(A))}return b.join("")},parse:function(E){for(var T=E.length,w=[],b=0;b<T;b++)w[b>>>2]|=(E.charCodeAt(b)&255)<<24-b%4*8;return new h.init(w,T)}},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 T,w=this._data,b=w.words,C=w.sigBytes,A=this.blockSize,R=A*4,O=C/R;E?O=r.ceil(O):O=r.max((O|0)-this._minBufferSize,0);var M=O*A,k=r.min(M*4,C);if(M){for(var G=0;G<M;G+=A)this._doProcessBlock(b,G);T=b.splice(0,M),w.sigBytes-=k}return new h.init(T,k)},clone:function(){var E=u.clone.call(this);return E._data=this._data.clone(),E},_minBufferSize:0}),x=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 T=this._doFinalize();return T},blockSize:512/32,_createHelper:function(E){return function(T,w){return new E.init(w).finalize(T)}},_createHmacHelper:function(E){return function(T,w){return new y.HMAC.init(E,w).finalize(T)}}}),y=l.algo={};return l})(Math);return i})}),V2=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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})}),kq=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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})}),Fq=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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})}),zp=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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,x=u[f+2>>>2]>>>24-(f+2)%4*8&255,y=m<<16|g<<8|x,E=0;E<4&&f+E*.75<h;E++)p.push(d.charAt(y>>>6*(3-E)&63));var T=d.charAt(64);if(T)for(;p.length%4;)p.push(T);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,x=m|g;d[p>>>2]|=x<<24-p%4*8,p++}return s.create(d,p)}})(),i.enc.Base64})}),Gq=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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,x=h[m+1>>>2]>>>24-(m+1)%4*8&255,y=h[m+2>>>2]>>>24-(m+2)%4*8&255,E=g<<16|x<<8|y,T=0;T<4&&m+T*.75<d;T++)f.push(p.charAt(E>>>6*(3-T)&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,x=m|g;d[p>>>2]|=x<<24-p%4*8,p++}return s.create(d,p)}})(),i.enc.Base64url})}),Xp=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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 x=0;x<16;x++){var y=g+x,E=m[y];m[y]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360}var T=this._hash.words,w=m[g+0],b=m[g+1],C=m[g+2],A=m[g+3],R=m[g+4],O=m[g+5],M=m[g+6],k=m[g+7],G=m[g+8],H=m[g+9],q=m[g+10],I=m[g+11],N=m[g+12],v=m[g+13],L=m[g+14],_=m[g+15],B=T[0],U=T[1],z=T[2],W=T[3];B=h(B,U,z,W,w,7,c[0]),W=h(W,B,U,z,b,12,c[1]),z=h(z,W,B,U,C,17,c[2]),U=h(U,z,W,B,A,22,c[3]),B=h(B,U,z,W,R,7,c[4]),W=h(W,B,U,z,O,12,c[5]),z=h(z,W,B,U,M,17,c[6]),U=h(U,z,W,B,k,22,c[7]),B=h(B,U,z,W,G,7,c[8]),W=h(W,B,U,z,H,12,c[9]),z=h(z,W,B,U,q,17,c[10]),U=h(U,z,W,B,I,22,c[11]),B=h(B,U,z,W,N,7,c[12]),W=h(W,B,U,z,v,12,c[13]),z=h(z,W,B,U,L,17,c[14]),U=h(U,z,W,B,_,22,c[15]),B=d(B,U,z,W,b,5,c[16]),W=d(W,B,U,z,M,9,c[17]),z=d(z,W,B,U,I,14,c[18]),U=d(U,z,W,B,w,20,c[19]),B=d(B,U,z,W,O,5,c[20]),W=d(W,B,U,z,q,9,c[21]),z=d(z,W,B,U,_,14,c[22]),U=d(U,z,W,B,R,20,c[23]),B=d(B,U,z,W,H,5,c[24]),W=d(W,B,U,z,L,9,c[25]),z=d(z,W,B,U,A,14,c[26]),U=d(U,z,W,B,G,20,c[27]),B=d(B,U,z,W,v,5,c[28]),W=d(W,B,U,z,C,9,c[29]),z=d(z,W,B,U,k,14,c[30]),U=d(U,z,W,B,N,20,c[31]),B=p(B,U,z,W,O,4,c[32]),W=p(W,B,U,z,G,11,c[33]),z=p(z,W,B,U,I,16,c[34]),U=p(U,z,W,B,L,23,c[35]),B=p(B,U,z,W,b,4,c[36]),W=p(W,B,U,z,R,11,c[37]),z=p(z,W,B,U,k,16,c[38]),U=p(U,z,W,B,q,23,c[39]),B=p(B,U,z,W,v,4,c[40]),W=p(W,B,U,z,w,11,c[41]),z=p(z,W,B,U,A,16,c[42]),U=p(U,z,W,B,M,23,c[43]),B=p(B,U,z,W,H,4,c[44]),W=p(W,B,U,z,N,11,c[45]),z=p(z,W,B,U,_,16,c[46]),U=p(U,z,W,B,C,23,c[47]),B=f(B,U,z,W,w,6,c[48]),W=f(W,B,U,z,k,10,c[49]),z=f(z,W,B,U,L,15,c[50]),U=f(U,z,W,B,O,21,c[51]),B=f(B,U,z,W,N,6,c[52]),W=f(W,B,U,z,A,10,c[53]),z=f(z,W,B,U,q,15,c[54]),U=f(U,z,W,B,b,21,c[55]),B=f(B,U,z,W,G,6,c[56]),W=f(W,B,U,z,_,10,c[57]),z=f(z,W,B,U,M,15,c[58]),U=f(U,z,W,B,v,21,c[59]),B=f(B,U,z,W,R,6,c[60]),W=f(W,B,U,z,I,10,c[61]),z=f(z,W,B,U,C,15,c[62]),U=f(U,z,W,B,H,21,c[63]),T[0]=T[0]+B|0,T[1]=T[1]+U|0,T[2]=T[2]+z|0,T[3]=T[3]+W|0},_doFinalize:function(){var m=this._data,g=m.words,x=this._nDataBytes*8,y=m.sigBytes*8;g[y>>>5]|=128<<24-y%32;var E=r.floor(x/4294967296),T=x;g[(y+64>>>9<<4)+15]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,g[(y+64>>>9<<4)+14]=(T<<8|T>>>24)&16711935|(T<<24|T>>>8)&4278255360,m.sigBytes=(g.length+1)*4,this._process();for(var w=this._hash,b=w.words,C=0;C<4;C++){var A=b[C];b[C]=(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,x,y,E,T,w){var b=m+(g&x|~g&y)+E+w;return(b<<T|b>>>32-T)+g}function d(m,g,x,y,E,T,w){var b=m+(g&y|x&~y)+E+w;return(b<<T|b>>>32-T)+g}function p(m,g,x,y,E,T,w){var b=m+(g^x^y)+E+w;return(b<<T|b>>>32-T)+g}function f(m,g,x,y,E,T,w){var b=m+(x^(g|~y))+E+w;return(b<<T|b>>>32-T)+g}n.MD5=o._createHelper(u),n.HmacMD5=o._createHmacHelper(u)})(Math),i.MD5})}),d4=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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],x=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 T=(p<<5|p>>>27)+x+l[y];y<20?T+=(f&m|~f&g)+1518500249:y<40?T+=(f^m^g)+1859775393:y<60?T+=(f&m|f&g|m&g)-1894007588:T+=(f^m^g)-899497514,x=g,g=m,m=f<<30|f>>>2,f=p,p=T}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]+x|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})}),ZA=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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(x){for(var y=r.sqrt(x),E=2;E<=y;E++)if(!(x%E))return!1;return!0}function f(x){return(x-(x|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],x=m[1],y=m[2],E=m[3],T=m[4],w=m[5],b=m[6],C=m[7],A=0;A<64;A++){if(A<16)h[A]=p[f+A]|0;else{var R=h[A-15],O=(R<<25|R>>>7)^(R<<14|R>>>18)^R>>>3,M=h[A-2],k=(M<<15|M>>>17)^(M<<13|M>>>19)^M>>>10;h[A]=O+h[A-7]+k+h[A-16]}var G=T&w^~T&b,H=g&x^g&y^x&y,q=(g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22),I=(T<<26|T>>>6)^(T<<21|T>>>11)^(T<<7|T>>>25),N=C+I+G+u[A]+h[A],v=q+H;C=b,b=w,w=T,T=E+N|0,E=y,y=x,x=g,g=N+v|0}m[0]=m[0]+g|0,m[1]=m[1]+x|0,m[2]=m[2]+y|0,m[3]=m[3]+E|0,m[4]=m[4]+T|0,m[5]=m[5]+w|0,m[6]=m[6]+b|0,m[7]=m[7]+C|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})}),Uq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ZA()):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})}),p4=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),V2()):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,x=g[0],y=g[1],E=g[2],T=g[3],w=g[4],b=g[5],C=g[6],A=g[7],R=x.high,O=x.low,M=y.high,k=y.low,G=E.high,H=E.low,q=T.high,I=T.low,N=w.high,v=w.low,L=b.high,_=b.low,B=C.high,U=C.low,z=A.high,W=A.low,ne=R,me=O,Ee=M,Se=k,Fe=G,Ne=H,it=q,je=I,It=N,Ht=v,Ri=L,Ci=_,ze=B,D=U,j=z,Z=W,K=0;K<80;K++){var ee,ge,le=d[K];if(K<16)ge=le.high=f[m+K*2]|0,ee=le.low=f[m+K*2+1]|0;else{var ke=d[K-15],rt=ke.high,gt=ke.low,et=(rt>>>1|gt<<31)^(rt>>>8|gt<<24)^rt>>>7,si=(gt>>>1|rt<<31)^(gt>>>8|rt<<24)^(gt>>>7|rt<<25),ji=d[K-2],tr=ji.high,Li=ji.low,Sn=(tr>>>19|Li<<13)^(tr<<3|Li>>>29)^tr>>>6,Ar=(Li>>>19|tr<<13)^(Li<<3|tr>>>29)^(Li>>>6|tr<<26),Sr=d[K-7],vn=Sr.high,na=Sr.low,Wt=d[K-16],ur=Wt.high,ht=Wt.low;ee=si+na,ge=et+vn+(ee>>>0<si>>>0?1:0),ee=ee+Ar,ge=ge+Sn+(ee>>>0<Ar>>>0?1:0),ee=ee+ht,ge=ge+ur+(ee>>>0<ht>>>0?1:0),le.high=ge,le.low=ee}var an=It&Ri^~It&ze,$n=Ht&Ci^~Ht&D,ai=ne&Ee^ne&Fe^Ee&Fe,wi=me&Se^me&Ne^Se&Ne,xn=(ne>>>28|me<<4)^(ne<<30|me>>>2)^(ne<<25|me>>>7),sa=(me>>>28|ne<<4)^(me<<30|ne>>>2)^(me<<25|ne>>>7),Pu=(It>>>14|Ht<<18)^(It>>>18|Ht<<14)^(It<<23|Ht>>>9),sf=(Ht>>>14|It<<18)^(Ht>>>18|It<<14)^(Ht<<23|It>>>9),vh=h[K],Fc=vh.high,dl=vh.low,Cr=Z+sf,Zn=j+Pu+(Cr>>>0<Z>>>0?1:0),Cr=Cr+$n,Zn=Zn+an+(Cr>>>0<$n>>>0?1:0),Cr=Cr+dl,Zn=Zn+Fc+(Cr>>>0<dl>>>0?1:0),Cr=Cr+ee,Zn=Zn+ge+(Cr>>>0<ee>>>0?1:0),Bd=sa+wi,Og=xn+ai+(Bd>>>0<sa>>>0?1:0);j=ze,Z=D,ze=Ri,D=Ci,Ri=It,Ci=Ht,Ht=je+Cr|0,It=it+Zn+(Ht>>>0<je>>>0?1:0)|0,it=Fe,je=Ne,Fe=Ee,Ne=Se,Ee=ne,Se=me,me=Cr+Bd|0,ne=Zn+Og+(me>>>0<Cr>>>0?1:0)|0}O=x.low=O+me,x.high=R+ne+(O>>>0<me>>>0?1:0),k=y.low=k+Se,y.high=M+Ee+(k>>>0<Se>>>0?1:0),H=E.low=H+Ne,E.high=G+Fe+(H>>>0<Ne>>>0?1:0),I=T.low=I+je,T.high=q+it+(I>>>0<je>>>0?1:0),v=w.low=v+Ht,w.high=N+It+(v>>>0<Ht>>>0?1:0),_=b.low=_+Ci,b.high=L+Ri+(_>>>0<Ci>>>0?1:0),U=C.low=U+D,C.high=B+ze+(U>>>0<D>>>0?1:0),W=A.low=W+Z,A.high=z+j+(W>>>0<Z>>>0?1:0)},_doFinalize:function(){var f=this._data,m=f.words,g=this._nDataBytes*8,x=f.sigBytes*8;m[x>>>5]|=128<<24-x%32,m[(x+128>>>10<<5)+30]=Math.floor(g/4294967296),m[(x+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})}),Yq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),V2(),p4()):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})}),Hq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),V2()):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,x=0,y=0;y<24;y++){h[g+5*x]=(y+1)*(y+2)/2%64;var E=x%5,T=(2*g+3*x)%5;g=E,x=T}for(var g=0;g<5;g++)for(var x=0;x<5;x++)d[g+5*x]=x+(2*g+3*x)%5*5;for(var w=1,b=0;b<24;b++){for(var C=0,A=0,R=0;R<7;R++){if(w&1){var O=(1<<R)-1;O<32?A^=1<<O:C^=1<<O-32}w&128?w=w<<1^113:w<<=1}p[b]=c.create(C,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=[],x=0;x<25;x++)g[x]=new c.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(g,x){for(var y=this._state,E=this.blockSize/2,T=0;T<E;T++){var w=g[x+2*T],b=g[x+2*T+1];w=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360,b=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;var C=y[T];C.high^=b,C.low^=w}for(var A=0;A<24;A++){for(var R=0;R<5;R++){for(var O=0,M=0,k=0;k<5;k++){var C=y[R+5*k];O^=C.high,M^=C.low}var G=f[R];G.high=O,G.low=M}for(var R=0;R<5;R++)for(var H=f[(R+4)%5],q=f[(R+1)%5],I=q.high,N=q.low,O=H.high^(I<<1|N>>>31),M=H.low^(N<<1|I>>>31),k=0;k<5;k++){var C=y[R+5*k];C.high^=O,C.low^=M}for(var v=1;v<25;v++){var O,M,C=y[v],L=C.high,_=C.low,B=h[v];B<32?(O=L<<B|_>>>32-B,M=_<<B|L>>>32-B):(O=_<<B-32|L>>>64-B,M=L<<B-32|_>>>64-B);var U=f[d[v]];U.high=O,U.low=M}var z=f[0],W=y[0];z.high=W.high,z.low=W.low;for(var R=0;R<5;R++)for(var k=0;k<5;k++){var v=R+5*k,C=y[v],ne=f[v],me=f[(R+1)%5+5*k],Ee=f[(R+2)%5+5*k];C.high=ne.high^~me.high&Ee.high,C.low=ne.low^~me.low&Ee.low}var C=y[0],Se=p[A];C.high^=Se.high,C.low^=Se.low}},_doFinalize:function(){var g=this._data,x=g.words,y=this._nDataBytes*8,E=g.sigBytes*8,T=this.blockSize*32;x[E>>>5]|=1<<24-E%32,x[(r.ceil((E+1)/T)*T>>>5)-1]|=128,g.sigBytes=x.length*4,this._process();for(var w=this._state,b=this.cfg.outputLength/8,C=b/8,A=[],R=0;R<C;R++){var O=w[R],M=O.high,k=O.low;M=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360,k=(k<<8|k>>>24)&16711935|(k<<24|k>>>8)&4278255360,A.push(k),A.push(M)}return new a.init(A,b)},clone:function(){for(var g=o.clone.call(this),x=g._state=this._state.slice(0),y=0;y<25;y++)x[y]=x[y].clone();return g}});n.SHA3=o._createHelper(m),n.HmacSHA3=o._createHmacHelper(m)})(Math),i.SHA3})}),jq=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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(b,C){for(var A=0;A<16;A++){var R=C+A,O=b[R];b[R]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360}var M=this._hash.words,k=p.words,G=f.words,H=c.words,q=u.words,I=h.words,N=d.words,v,L,_,B,U,z,W,ne,me,Ee;z=v=M[0],W=L=M[1],ne=_=M[2],me=B=M[3],Ee=U=M[4];for(var Se,A=0;A<80;A+=1)Se=v+b[C+H[A]]|0,A<16?Se+=g(L,_,B)+k[0]:A<32?Se+=x(L,_,B)+k[1]:A<48?Se+=y(L,_,B)+k[2]:A<64?Se+=E(L,_,B)+k[3]:Se+=T(L,_,B)+k[4],Se=Se|0,Se=w(Se,I[A]),Se=Se+U|0,v=U,U=B,B=w(_,10),_=L,L=Se,Se=z+b[C+q[A]]|0,A<16?Se+=T(W,ne,me)+G[0]:A<32?Se+=E(W,ne,me)+G[1]:A<48?Se+=y(W,ne,me)+G[2]:A<64?Se+=x(W,ne,me)+G[3]:Se+=g(W,ne,me)+G[4],Se=Se|0,Se=w(Se,N[A]),Se=Se+Ee|0,z=Ee,Ee=me,me=w(ne,10),ne=W,W=Se;Se=M[1]+_+me|0,M[1]=M[2]+B+Ee|0,M[2]=M[3]+U+z|0,M[3]=M[4]+v+W|0,M[4]=M[0]+L+ne|0,M[0]=Se},_doFinalize:function(){var b=this._data,C=b.words,A=this._nDataBytes*8,R=b.sigBytes*8;C[R>>>5]|=128<<24-R%32,C[(R+64>>>9<<4)+14]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,b.sigBytes=(C.length+1)*4,this._process();for(var O=this._hash,M=O.words,k=0;k<5;k++){var G=M[k];M[k]=(G<<8|G>>>24)&16711935|(G<<24|G>>>8)&4278255360}return O},clone:function(){var b=o.clone.call(this);return b._hash=this._hash.clone(),b}});function g(b,C,A){return b^C^A}function x(b,C,A){return b&C|~b&A}function y(b,C,A){return(b|~C)^A}function E(b,C,A){return b&A|C&~A}function T(b,C,A){return b^(C|~A)}function w(b,C){return b<<C|b>>>32-C}n.RIPEMD160=o._createHelper(m),n.HmacRIPEMD160=o._createHmacHelper(m)})(Math),i.RIPEMD160})}),QA=er((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(cr()):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,x=m.words,y=0;y<d;y++)g[y]^=1549556828,x[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}})})()})}),Vq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ZA(),QA()):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]),x=m.words,y=g.words,E=p.keySize,T=p.iterations;x.length<E;){var w=f.update(d).finalize(g);f.reset();for(var b=w.words,C=b.length,A=w,R=1;R<T;R++){A=f.finalize(A),f.reset();for(var O=A.words,M=0;M<C;M++)b[M]^=O[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})}),Ad=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),d4(),QA()):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,x=p.keySize,y=p.iterations;g.length<x;){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=x*4,m}});r.EvpKDF=function(u,h,d){return c.create(d).compute(u,h)}})(),i.EvpKDF})}),ra=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),Ad()):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,H){return this.create(this._ENC_XFORM_MODE,G,H)},createDecryptor:function(G,H){return this.create(this._DEC_XFORM_MODE,G,H)},init:function(G,H,q){this.cfg=this.cfg.extend(q),this._xformMode=G,this._key=H,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 H=this._doFinalize();return H},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:(function(){function G(H){return typeof H=="string"?k:R}return function(H){return{encrypt:function(q,I,N){return G(I).encrypt(H,q,I,N)},decrypt:function(q,I,N){return G(I).decrypt(H,q,I,N)}}}})()}),m=s.StreamCipher=f.extend({_doFinalize:function(){var G=this._process(!0);return G},blockSize:1}),g=n.mode={},x=s.BlockCipherMode=a.extend({createEncryptor:function(G,H){return this.Encryptor.create(G,H)},createDecryptor:function(G,H){return this.Decryptor.create(G,H)},init:function(G,H){this._cipher=G,this._iv=H}}),y=g.CBC=(function(){var G=x.extend();G.Encryptor=G.extend({processBlock:function(q,I){var N=this._cipher,v=N.blockSize;H.call(this,q,I,v),N.encryptBlock(q,I),this._prevBlock=q.slice(I,I+v)}}),G.Decryptor=G.extend({processBlock:function(q,I){var N=this._cipher,v=N.blockSize,L=q.slice(I,I+v);N.decryptBlock(q,I),H.call(this,q,I,v),this._prevBlock=L}});function H(q,I,N){var v,L=this._iv;L?(v=L,this._iv=r):v=this._prevBlock;for(var _=0;_<N;_++)q[I+_]^=v[_]}return G})(),E=n.pad={},T=E.Pkcs7={pad:function(G,H){for(var q=H*4,I=q-G.sigBytes%q,N=I<<24|I<<16|I<<8|I,v=[],L=0;L<I;L+=4)v.push(N);var _=o.create(v,I);G.concat(_)},unpad:function(G){var H=G.words[G.sigBytes-1>>>2]&255;G.sigBytes-=H}},w=s.BlockCipher=f.extend({cfg:f.cfg.extend({mode:y,padding:T}),reset:function(){var G;f.reset.call(this);var H=this.cfg,q=H.iv,I=H.mode;this._xformMode==this._ENC_XFORM_MODE?G=I.createEncryptor:(G=I.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==G?this._mode.init(this,q&&q.words):(this._mode=G.call(I,this,q&&q.words),this._mode.__creator=G)},_doProcessBlock:function(G,H){this._mode.processBlock(G,H)},_doFinalize:function(){var G,H=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(H.pad(this._data,this.blockSize),G=this._process(!0)):(G=this._process(!0),H.unpad(G)),G},blockSize:128/32}),b=s.CipherParams=a.extend({init:function(G){this.mixIn(G)},toString:function(G){return(G||this.formatter).stringify(this)}}),C=n.format={},A=C.OpenSSL={stringify:function(G){var H,q=G.ciphertext,I=G.salt;return I?H=o.create([1398893684,1701076831]).concat(I).concat(q):H=q,H.toString(h)},parse:function(G){var H,q=h.parse(G),I=q.words;return I[0]==1398893684&&I[1]==1701076831&&(H=o.create(I.slice(2,4)),I.splice(0,4),q.sigBytes-=16),b.create({ciphertext:q,salt:H})}},R=s.SerializableCipher=a.extend({cfg:a.extend({format:A}),encrypt:function(G,H,q,I){I=this.cfg.extend(I);var N=G.createEncryptor(q,I),v=N.finalize(H),L=N.cfg;return b.create({ciphertext:v,key:q,iv:L.iv,algorithm:G,mode:L.mode,padding:L.padding,blockSize:G.blockSize,formatter:I.format})},decrypt:function(G,H,q,I){I=this.cfg.extend(I),H=this._parse(H,I.format);var N=G.createDecryptor(q,I).finalize(H.ciphertext);return N},_parse:function(G,H){return typeof G=="string"?H.parse(G,this):G}}),O=n.kdf={},M=O.OpenSSL={execute:function(G,H,q,I,N){if(I||(I=o.random(64/8)),N)var v=p.create({keySize:H+q,hasher:N}).compute(G,I);else var v=p.create({keySize:H+q}).compute(G,I);var L=o.create(v.words.slice(H),q*4);return v.sigBytes=H*4,b.create({key:v,iv:L,salt:I})}},k=s.PasswordBasedCipher=R.extend({cfg:R.cfg.extend({kdf:M}),encrypt:function(G,H,q,I){I=this.cfg.extend(I);var N=I.kdf.execute(q,G.keySize,G.ivSize,I.salt,I.hasher);I.iv=N.iv;var v=R.encrypt.call(this,G,H,N.key,I);return v.mixIn(N),v},decrypt:function(G,H,q,I){I=this.cfg.extend(I),H=this._parse(H,I.format);var N=I.kdf.execute(q,G.keySize,G.ivSize,H.salt,I.hasher);I.iv=N.iv;var v=R.decrypt.call(this,G,H,N.key,I);return v}})})()})}),zq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),Xq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),Wq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),qq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),Jq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),Kq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),$q=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),Zq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),Qq=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),eJ=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),tJ=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),ra()):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})}),iJ=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),zp(),Xp(),Ad(),ra()):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=[],T=0;T<256;T++)T<128?E[T]=T<<1:E[T]=T<<1^283;for(var w=0,b=0,T=0;T<256;T++){var C=b^b<<1^b<<2^b<<3^b<<4;C=C>>>8^C&255^99,o[w]=C,l[C]=w;var A=E[w],R=E[A],O=E[R],M=E[C]*257^C*16843008;c[w]=M<<24|M>>>8,u[w]=M<<16|M>>>16,h[w]=M<<8|M>>>24,d[w]=M;var M=O*16843009^R*65537^A*257^w*16843008;p[C]=M<<24|M>>>8,f[C]=M<<16|M>>>16,m[C]=M<<8|M>>>24,g[C]=M,w?(w=A^E[E[E[O^A]]],b^=E[E[b]]):w=b=1}})();var x=[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 T=this._keyPriorReset=this._key,w=T.words,b=T.sigBytes/4,C=this._nRounds=b+6,A=(C+1)*4,R=this._keySchedule=[],O=0;O<A;O++)O<b?R[O]=w[O]:(E=R[O-1],O%b?b>6&&O%b==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^=x[O/b|0]<<24),R[O]=R[O-b]^E);for(var M=this._invKeySchedule=[],k=0;k<A;k++){var O=A-k;if(k%4)var E=R[O];else var E=R[O-4];k<4||O<=4?M[k]=E:M[k]=p[o[E>>>24]]^f[o[E>>>16&255]]^m[o[E>>>8&255]]^g[o[E&255]]}}},encryptBlock:function(E,T){this._doCryptBlock(E,T,this._keySchedule,c,u,h,d,o)},decryptBlock:function(E,T){var w=E[T+1];E[T+1]=E[T+3],E[T+3]=w,this._doCryptBlock(E,T,this._invKeySchedule,p,f,m,g,l);var w=E[T+1];E[T+1]=E[T+3],E[T+3]=w},_doCryptBlock:function(E,T,w,b,C,A,R,O){for(var M=this._nRounds,k=E[T]^w[0],G=E[T+1]^w[1],H=E[T+2]^w[2],q=E[T+3]^w[3],I=4,N=1;N<M;N++){var v=b[k>>>24]^C[G>>>16&255]^A[H>>>8&255]^R[q&255]^w[I++],L=b[G>>>24]^C[H>>>16&255]^A[q>>>8&255]^R[k&255]^w[I++],_=b[H>>>24]^C[q>>>16&255]^A[k>>>8&255]^R[G&255]^w[I++],B=b[q>>>24]^C[k>>>16&255]^A[G>>>8&255]^R[H&255]^w[I++];k=v,G=L,H=_,q=B}var v=(O[k>>>24]<<24|O[G>>>16&255]<<16|O[H>>>8&255]<<8|O[q&255])^w[I++],L=(O[G>>>24]<<24|O[H>>>16&255]<<16|O[q>>>8&255]<<8|O[k&255])^w[I++],_=(O[H>>>24]<<24|O[q>>>16&255]<<16|O[k>>>8&255]<<8|O[G&255])^w[I++],B=(O[q>>>24]<<24|O[k>>>16&255]<<16|O[G>>>8&255]<<8|O[H&255])^w[I++];E[T]=v,E[T+1]=L,E[T+2]=_,E[T+3]=B},keySize:256/32});r.AES=s._createHelper(y)})(),i.AES})}),rJ=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),zp(),Xp(),Ad(),ra()):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 x=this._key,y=x.words,E=[],T=0;T<56;T++){var w=l[T]-1;E[T]=y[w>>>5]>>>31-w%32&1}for(var b=this._subKeys=[],C=0;C<16;C++){for(var A=b[C]=[],R=u[C],T=0;T<24;T++)A[T/6|0]|=E[(c[T]-1+R)%28]<<31-T%6,A[4+(T/6|0)]|=E[28+(c[T+24]-1+R)%28]<<31-T%6;A[0]=A[0]<<1|A[0]>>>31;for(var T=1;T<7;T++)A[T]=A[T]>>>(T-1)*4+3;A[7]=A[7]<<5|A[7]>>>27}for(var O=this._invSubKeys=[],T=0;T<16;T++)O[T]=b[15-T]},encryptBlock:function(x,y){this._doCryptBlock(x,y,this._subKeys)},decryptBlock:function(x,y){this._doCryptBlock(x,y,this._invSubKeys)},_doCryptBlock:function(x,y,E){this._lBlock=x[y],this._rBlock=x[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 T=0;T<16;T++){for(var w=E[T],b=this._lBlock,C=this._rBlock,A=0,R=0;R<8;R++)A|=h[R][((C^w[R])&d[R])>>>0];this._lBlock=C,this._rBlock=b^A}var O=this._lBlock;this._lBlock=this._rBlock,this._rBlock=O,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),x[y]=this._lBlock,x[y+1]=this._rBlock},keySize:64/32,ivSize:64/32,blockSize:64/32});function f(x,y){var E=(this._lBlock>>>x^this._rBlock)&y;this._rBlock^=E,this._lBlock^=E<<x}function m(x,y){var E=(this._rBlock>>>x^this._lBlock)&y;this._lBlock^=E,this._rBlock^=E<<x}r.DES=a._createHelper(p);var g=o.TripleDES=a.extend({_doReset:function(){var x=this._key,y=x.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),T=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(T)),this._des3=p.createEncryptor(s.create(w))},encryptBlock:function(x,y){this._des1.encryptBlock(x,y),this._des2.decryptBlock(x,y),this._des3.encryptBlock(x,y)},decryptBlock:function(x,y){this._des3.decryptBlock(x,y),this._des2.encryptBlock(x,y),this._des1.decryptBlock(x,y)},keySize:192/32,ivSize:64/32,blockSize:64/32});r.TripleDES=a._createHelper(g)})(),i.TripleDES})}),nJ=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),zp(),Xp(),Ad(),ra()):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,x=h[g>>>2]>>>24-g%4*8&255;m=(m+p[f]+x)%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})}),sJ=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),zp(),Xp(),Ad(),ra()):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 x=p.words,y=x[0],E=x[1],T=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360,w=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,b=T>>>16|w&4294901760,C=w<<16|T&65535;g[0]^=T,g[1]^=b,g[2]^=w,g[3]^=C,g[4]^=T,g[5]^=b,g[6]^=w,g[7]^=C;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,x=m>>>16,y=((g*g>>>17)+g*x>>>15)+x*x,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})}),aJ=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),zp(),Xp(),Ad(),ra()):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 x=p.words,y=x[0],E=x[1],T=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360,w=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,b=T>>>16|w&4294901760,C=w<<16|T&65535;m[0]^=T,m[1]^=b,m[2]^=w,m[3]^=C,m[4]^=T,m[5]^=b,m[6]^=w,m[7]^=C;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,x=m>>>16,y=((g*g>>>17)+g*x>>>15)+x*x,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})}),oJ=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),zp(),Xp(),Ad(),ra()):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,x){let y=x>>24&255,E=x>>16&255,T=x>>8&255,w=x&255,b=g.sbox[0][y]+g.sbox[1][E];return b=b^g.sbox[2][T],b=b+g.sbox[3][w],b}function d(g,x,y){let E=x,T=y,w;for(let b=0;b<o;++b)E=E^g.pbox[b],T=h(g,E)^T,w=E,E=T,T=w;return w=E,E=T,T=w,T=T^g.pbox[o],E=E^g.pbox[o+1],{left:E,right:T}}function p(g,x,y){let E=x,T=y,w;for(let b=o+1;b>1;--b)E=E^g.pbox[b],T=h(g,E)^T,w=E,E=T,T=w;return w=E,E=T,T=w,T=T^g.pbox[1],E=E^g.pbox[0],{left:E,right:T}}function f(g,x,y){for(let C=0;C<4;C++){g.sbox[C]=[];for(let A=0;A<256;A++)g.sbox[C][A]=c[C][A]}let E=0;for(let C=0;C<o+2;C++)g.pbox[C]=l[C]^x[E],E++,E>=y&&(E=0);let T=0,w=0,b=0;for(let C=0;C<o+2;C+=2)b=d(g,T,w),T=b.left,w=b.right,g.pbox[C]=T,g.pbox[C+1]=w;for(let C=0;C<4;C++)for(let A=0;A<256;A+=2)b=d(g,T,w),T=b.left,w=b.right,g.sbox[C][A]=T,g.sbox[C][A+1]=w;return!0}var m=a.Blowfish=s.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var g=this._keyPriorReset=this._key,x=g.words,y=g.sigBytes/4;f(u,x,y)}},encryptBlock:function(g,x){var y=d(u,g[x],g[x+1]);g[x]=y.left,g[x+1]=y.right},decryptBlock:function(g,x){var y=p(u,g[x],g[x+1]);g[x]=y.left,g[x+1]=y.right},blockSize:64/32,keySize:128/32,ivSize:64/32});r.Blowfish=s._createHelper(m)})(),i.Blowfish})}),lJ=er((e,t)=>{(function(i,r,n){typeof e=="object"?t.exports=e=r(cr(),V2(),kq(),Fq(),zp(),Gq(),Xp(),d4(),ZA(),Uq(),p4(),Yq(),Hq(),jq(),QA(),Vq(),Ad(),ra(),zq(),Xq(),Wq(),qq(),Jq(),Kq(),$q(),Zq(),Qq(),eJ(),tJ(),iJ(),rJ(),nJ(),sJ(),aJ(),oJ()):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})}),cJ=(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))(cJ||{}),uJ=(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))(uJ||{}),hJ=(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))(hJ||{});function s1(e,t,i){return e.slice(t,i)}function SM(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=s1(e,n,s);try{if(a){let o=a.indexOf("||"),l=o>-1,c=l?s1(a,0,o):a,u=l?s1(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 dJ=["SYMBOL","FOOTPRINT","BLOB","FONT","PANEL_LIB","DEVICE","BOARD","INSTANCE","CONFIG","VARIANT","COMPONENT_GROUP","COMPONENT_GROUP_DATA"];function a1(e,t){return dJ.includes(t)?t:e}var eC=class{parseFull(e,t,i){let r=t,n=i,s,a=null;SM(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},x=E=>{if(m.add(s),!t)return;let T=a1(s,a);p[T].data.push(E),p[T].size+=(p[T].size?2:0)+E.length,p[T].size+E.length>i&&g(T)},y=(E,T)=>SM(E,(w,b,C,A)=>{var R,O,M,k,G,H,q,I;let N=JSON.parse(w);if(N.type==="EDIT_HEAD")l=JSON.parse(b),(R=this.onEditHead)==null||R.call(this,l),(O=e.onEditHead)==null||O.call(e,l),d=!0;else if(N.type==="DOCHEAD"){let v=JSON.parse(b);a=v.docType,s=v.uuid,o=v.client,v.ticket=N.ticket,d||(l={uuid:v.uuid,username:(M=v==null?void 0:v.user)==null?void 0:M.username,nickname:(k=v==null?void 0:v.user)==null?void 0:k.nickname,updateTime:v==null?void 0:v.updateTime},(G=e.onEditHead)==null||G.call(e,l),d=!0),this.onDocHead(v,l,C);let L=a1(s,a);t&&!p[L]&&(p[L]={size:0,data:[],head:""}),t&&(p[L].head=C),x(C)}else{let v=N.num,L=N.client||o;if(r){let _=(I=(q=(H=r.ids)==null?void 0:H[s])==null?void 0:q[L])==null?void 0:I[N.id];if(!_||_[0]!==N.ticket)return;v=_[1],r.size-=1,delete r.ids[s][L][N.id]}if(n){let _=a1(s,a);t&&(n.dNum=(f==null?void 0:f[_])===void 0?0:(f==null?void 0:f[_])+1),n.start=t?p[_].size+2+w.length+2:h+A}this.onLine(N.id,N.ticket,b,N.type,L,a,s,N.firstTicket,N.pend,l||(n==null?void 0:n.editHead),v,C,n),x(C)}},T);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 T=y(u+E,!0);h=h+u.length+E.length-((T==null?void 0:T.length)||0),u="",T&&(u=T)},docMap:f,getDocIds:()=>Array.from(m)}}parseLine(e,t,i){let r=e.indexOf("||"),n=r!==-1,s=n?s1(e,0,r):e,a=n?s1(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){}},mA=new Uint8Array(8);function Wl(){crypto.getRandomValues(mA);let e="";for(let t=0;t<mA.length;t++)e+=mA[t].toString(16).padStart(2,"0");return e}function gA(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 kp(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 tC=class extends eC{constructor(e){super(),this.unique=Wl(),this.maxTicket=0,this.isPendChange=!0,this.isLocalChange=!0,this.cbArr=[],this.tempLocalIds={},this.docMaxTicket={},this.client=e||Wl()}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 Wl()}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,x=(!g||g&&this.isLocalChange)&&(!d||d&&this.isPendChange),y=(f=this.tempLocalIds[i])==null?void 0:f[r];!o&&m?y?(x=!1,y[0]===t&&y[1]===e&&delete this.tempLocalIds[i][r]):x=!0:!o&&y&&(y[1]>e||y[1]===e&&y[0]>t?x=!1:delete this.tempLocalIds[i][r]),this.setDocMaxTicket(i,e,c),x&&this.cbArr.forEach(E=>E(i,r,n,s,t,e,l,c,void 0,d,h,p))}},pJ=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}},FA=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 pJ(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 Yp(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var fJ=(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))(fJ||{}),mJ=(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))(mJ||{}),gJ=(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))(gJ||{});function vM(e,t){return e.ticket===t.ticket?e.client<t.client:e.ticket<t.ticket}var Qi=class f4{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=f4.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(vM(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);vM(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);}},m4=["GROUP","POLY","STRING","AUXLINE","DIMENSION"],yJ=["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"],bJ=["ATTR","WIRE","BUS","TEXT","POLY","CIRCLE","ARC","BUSENTRY","RECT","PIN","OBJ","COMPONENT","PART","ELLIPSE","BEZIER","TABLE","MASK_REGION"],xJ=["SCH_PAGE","SIMULATION"],IM=e=>e==="PCB"||e==="FOOTPRINT"?0:1,g4=e=>e==="PCB"||e==="FOOTPRINT"?yJ:e==="PANEL"||e==="PANEL_LIB"?m4:e==="SCH_PAGE"||e==="SYMBOL"||e==="SIMULATION"?bJ:[];function AM(e,t,i){var r,n;let s=e.get(t),a=e.get(i),o=Qi.getHead(s),l=Qi.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 EJ=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=g4(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=Yp(this.numSets[e].orderLists,l,()=>new FA((f,m)=>AM(this.wDocData.get(e),f,m))),h=Yp(this.numSets[e].maxNum,l,()=>IM(t)-1),d=this.wDocData.get(e).get(i);if(s&&(u.remove(i),h-=d.step||1),!Qi.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=Yp(this.numSets[e].orderLists,n,()=>new FA((l,c)=>AM(this.wDocData.get(e),l,c))),a=Yp(this.numSets[e].maxNum,n,()=>IM(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]}},TJ=lg(d1()),Rc=(e=>(e.SOLID="SOLID",e.SHORT_DASH="SHORT_DASH",e.DOT="DOT",e.DOT_DASH="DOT_DASH",e))(Rc||{}),al=(e=>(e.PRINT="PRINT",e.COVER="COVER",e.PRINT_AND_COVER="PRINT&COVER",e))(al||{}),wJ=(e=>(e.LEFT="LEFT",e.CENTER="CENTER",e.RIGHT="RIGHT",e))(wJ||{}),SJ=(e=>(e.TOP="TOP",e.MIDDLE="MIDDLE",e.BOTTOM="BOTTOM",e))(SJ||{}),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||{}),vJ=(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))(vJ||{}),IJ=(e=>(e.NONE="NONE",e.CLOCK="CLOCK",e.INVERTED="INVERTED",e.INVERTED_CLOCK="INVERTED_CLOCK",e))(IJ||{}),AJ=(e=>(e.NONE="NONE",e.GRID="GRID",e.OUTLETS="OUTLETS",e))(AJ||{}),CJ=(e=>(e.NONE="NONE",e.PUSH="PUSH",e.SURROUND="SURROUND",e.OBSTRUCT="OBSTRUCT",e.SURROUND_AND_PUSH="SURROUND&PUSH",e))(CJ||{}),DJ=(e=>(e.ELLIPSE="ELLIPSE",e.RECT="RECT",e.OVAL="OVAL",e.POLYGON="POLYGON",e))(DJ||{}),PJ=(e=>(e.ROUND="ROUND",e.RECT="RECT",e.SLOT="SLOT",e))(PJ||{}),_J=(e=>(e.SOLID="SOLID",e.GRID_LINE="GRID_LINE",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e))(_J||{}),LJ=(e=>(e.ALL="ALL",e.PAD="PAD",e.VIA="VIA",e))(LJ||{}),OJ=(e=>(e.NONE="NONE",e.SINGLE="SINGLE",e.ALL="ALL",e))(OJ||{}),RJ=(e=>(e.OPTIMIZA_OPEN="OPTIMIZA_OPEN",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(RJ||{}),NJ=(e=>(e.OPTIMIZA_STRONG="OPTIMIZA_STRONG",e.OPTIMIZA_WEAK="OPTIMIZA_WEAK",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(NJ||{}),MJ=(e=>(e.L45="L45",e.L90="L90",e.L="L",e.R45="R45",e.R90="R90",e.R="R",e))(MJ||{}),BJ=(e=>(e.NORMAL="NORMAL",e.BLIND="BLIND",e.SUTURE="SUTURE",e))(BJ||{}),kJ=(e=>(e.NORMAL="NORMAL",e.TEST="TEST",e.MARKER="MARKER",e))(kJ||{}),FJ=(e=>(e.DIVERGENCE="DIVERGENCE",e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(FJ||{}),GJ=(e=>(e.DOT="DOT",e.CENTER="CENT",e))(GJ||{}),UJ=(e=>(e.NORMAL="NORMAL",e.BOARD_OUTLINE="BOARD_OUTLINE",e))(UJ||{}),YJ=(e=>(e.SOLID="SOLID",e.GRID="GRID",e.PLANE="PLANE",e))(YJ||{}),HJ=(e=>(e.PROHIBIT="PROHIBIT",e.CONSTRAINT="CONSTRAINT",e))(HJ||{}),jJ=(e=>(e.COMPONENT="COMPONENT",e.VIA="VIA",e.TRACK="TRACK",e.FILL="FILL",e.COPPER="COPPER",e.PLANE="PLANE",e))(jJ||{}),VJ=(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))(VJ||{}),zJ=(e=>(e.PUSH_COVER="DRAWER",e.UPPER_LOWER_SHELLS="T&B",e))(zJ||{}),XJ=(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))(XJ||{}),WJ=(e=>(e.SLOT="SLOT",e.ENTITY="ENTITY",e))(WJ||{}),qJ=(e=>(e.AUTO="AUTO",e.UPPER_SHELLS="UPPER_SHELLS",e.LOWER_SHELLS="LOWER_SHELLS",e))(qJ||{}),JJ=(e=>(e.OUTLINE="OUTLINE",e.SCREW_PILLAR="SCREW_PILLAR",e.ENTITY="ENTITY",e))(JJ||{}),KJ=(e=>(e.M2="M2",e.M3="M3",e.M4="M4",e.M5="M5",e.M6="M6",e))(KJ||{}),$J=(e=>(e.LENGTH="LENGTH",e.RADIUS="RADIUS",e.ANGLE="ANGLE",e))($J||{}),ZJ=(e=>(e.MIL="mil",e.INCH="inch",e.CM="cm",e.MM="mm",e))(ZJ||{}),QJ=(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))(QJ||{}),eK=(e=>(e.NORMAL="NORMAL",e.DEFAULT="DEFAULT",e))(eK||{}),tK=(e=>(e.ALL="ALL",e.LAYERED="LAYERED",e))(tK||{}),iK=(e=>(e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(iK||{}),rK=(e=>(e.FORTY_FIVE="L45",e.NINETY="L90",e.NINETY_ARC="A90",e))(rK||{}),nK=(e=>(e.LESS="LESS",e.MID="MID",e.MORE="MORE",e))(nK||{}),sK=(e=>(e.SPEED_FIRST="SPEED_FIRST",e.COMPLETION_FIRST="COMPLETION_FIRST",e))(sK||{}),aK=(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))(aK||{}),oK=lg(lJ());function lK(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 Vm(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 CM(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 y4(e){return oK.default.SHA256(e).toString()}function zy(e,t,i,r){let n="";return i?r?n=e+":"+t:n=e:r?n=t:n="",n}function cK(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 Cc=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(Vm(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(Vm(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=zy(f.key,g,f.keyVisible,f.valueVisible)}else if(f.key==="Footprint"){let g=t[m]||m;m=zy(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 x=(s=(n=r.cData)==null?void 0:n[h])==null?void 0:s[f.parentId];if(x){let y=JSON.parse(x);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],T=i[E];T&&Object.entries(T).forEach(w=>g.set(w[0],w[1]))}}}m=zy(f.key,cK(m,g),f.keyVisible,f.valueVisible)}else m=zy(f.key,m,f.keyVisible,f.valueVisible);m&&l.fonts.add(Vm(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(Vm(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(Vm(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=zy(s.key,s.value,s.keyVisible,s.valueVisible);t.fonts.add(Vm(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}},uK=Object.create(null),hK=class extends tC{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 EJ(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 Qi.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 Qi.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 Qi.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&&Qi.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,Qi.getFirstTicket(c),m),h.forEach(g=>Qi.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=a1(o,this.getDoctype(o));await u.init(s,a,h,l);for(let d of c){let[p,f,m,g,x]=d;if(f.last===m){let y=u.get(g.start);i(o,p,g,m,f,y,x)}else x.forEach(y=>Qi.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=[];Qi.preForEach(i,o=>{if(o.pend&&(!n||o.client===n)){if(a.push(o),o===i.last){let l=Qi.getPreNode(i,o);if(s)for(;l&&l.pend;)a.push(l),l=Qi.getPreNode(i,l);r.update(e,t,i,o,l,a)}else a.forEach(l=>Qi.remove(i,l));return!0}return!1}),Qi.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 Qi.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 x=[d,p,g.ticket,g.client,g.dataType,g.data,g.pend];e.needNum&&x.push(f.num),a.push(x);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,x)=>{let y=Qi.getHead(p.get(g)),E=Qi.getHead(p.get(x)),T=y.firstTicket||y.ticket,w=E.firstTicket||E.ticket;return T===w?y.client>E.client?1:-1:T-w});for(let g of m){let x=p.get(g);x&&(x.num&&(x.num=void 0),this.orderTree.setOrderNum(d,f,g,x,!1),!u(x)&&c(d,g,x))}}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=Wl(),(0,TJ.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,x,y,E,T,w,b,C,A,R,O,M,k,G,H,q,I,N,v,L,_,B,U,z,W,ne,me,Ee;let{updateTime:Se,versions:Fe,keepClient:Ne,keepFirst:it,notDocHead:je,isPend:It,user:Ht}=e,{headTicket:Ri,clearDelete:Ci,needNum:ze,uniqueId:D,client:j,extractData:Z}=e,{removeBoard:K,eIds:ee,notChangePend:ge}=e,le=e.docIds||(ee?[]:void 0),ke=Ci&&!!Z;if(D&&this.uniqueIds[D]&&(le=Object.keys(this.uniqueIds[D]),e.docIds&&(le=le.filter(et=>e.docIds.includes(et)))),le||(le=this.getForeachKeys(ke)),ee)for(let et in ee)le.some(si=>si===et)||le.push(et);let rt,gt;ke&&(rt=new Set,gt=new Set);for(let et of le){let si=(r=this.wDocData)==null?void 0:r.get(et);if(!si){ze&&!["FONT","BLOB"].includes(et)&&!this.orderTree.has(et)&&this.orderTree.add(et);continue}let ji=Se||((s=(n=this.docHead)==null?void 0:n[et])==null?void 0:s.updateTime)||new Date().getTime(),tr=(Fe==null?void 0:Fe[et])||((o=(a=this.docHead)==null?void 0:a[et])==null?void 0:o.version)||String(ji),Li=this.getDoctype(et);if(Ci){let Wt=si.get("DELETE_DOC");if(Wt&&Wt.last.data&&(l=JSON.parse(Wt.last.data))!=null&&l.isDelete){if(xJ.includes(Li)){let ur=si.get("META"),ht=ur?JSON.parse(ur.last.data):null,an=!!ht;if(Li==="SCH_PAGE"&&an){let $n=(c=this.wDocData)==null?void 0:c.get(ht.schematic),ai=(h=(u=$n.get("DELETE_DOC"))==null?void 0:u.last)==null?void 0:h.data;an=$n&&(!ai||ai&&!((d=JSON.parse(ai))!=null&&d.isDelete))}if(an){let $n=gA(((f=(p=this.docHead)==null?void 0:p[et])==null?void 0:f.docType)||this.mainDocType,j||this.getClient(),et,ji,tr,Ht||((g=(m=this.docHead)==null?void 0:m[et])==null?void 0:g.user),Ri||((y=(x=this.docHead)==null?void 0:x[et])==null?void 0:y.ticket));i($n)?await t($n,!0):t($n,!0);let ai=kp("DELETE_DOC",Qi.getFirstTicket(Wt),"DELETE_DOC",Wt.last.data);if(i(ai)?await t(ai):t(ai),ur){if(Li==="SCH_PAGE"){for(let[xn,sa]of si)if(sa.last.dataType==="META_PLACEHOLDER"&&sa.last.data){let Pu=kp("META_PLACEHOLDER",Qi.getFirstTicket(sa),ht.schematic,sa.last.data);i(Pu)?await t(Pu):t(Pu)}}let wi=kp("META",Qi.getFirstTicket(ur),"META",ur.last.data);i(wi)?await t(wi):t(wi)}}}continue}}let Sn;if(et==="FONT"&&rt){Sn=[];for(let Wt of rt)Sn.push(CM(Wt))}if(!je){let Wt=gA(((T=(E=this.docHead)==null?void 0:E[et])==null?void 0:T.docType)||this.mainDocType,j||this.getClient(),et,ji,tr,Ht||((b=(w=this.docHead)==null?void 0:w[et])==null?void 0:b.user),Ri||((A=(C=this.docHead)==null?void 0:C[et])==null?void 0:A.ticket));D&&this.onDocHead({docType:((O=(R=this.docHead)==null?void 0:R[et])==null?void 0:O.docType)||this.mainDocType,uuid:et,client:j||this.getClient(),updateTime:ji,version:tr,user:Ht||((k=(M=this.docHead)==null?void 0:M[et])==null?void 0:k.user),ticket:Ri||((H=(G=this.docHead)==null?void 0:G[et])==null?void 0:H.ticket)}),i(Wt)?await t(Wt,!0):t(Wt,!0)}if(!je&&e.needCreator){let Wt=gA(((I=(q=this.docHead)==null?void 0:q[et])==null?void 0:I.docType)||this.mainDocType,j||this.getClient(),et,(v=(N=this.creators)==null?void 0:N[et])==null?void 0:v.createTime,tr,(_=(L=this.creators)==null?void 0:L[et])==null?void 0:_.creator,Ri||((U=(B=this.docHead)==null?void 0:B[et])==null?void 0:U.ticket));i(Wt)?await t(Wt):t(Wt)}let Ar;if(D&&(Ar=Array.from(this.uniqueIds[D][et]),this.uniqueIds[D][et].clear(),delete this.uniqueIds[D][et]),ee&&ee[et]&&(Ar=ee[et]),Ar||(Ar=ze||Ci?Array.from(si.keys()).sort((Wt,ur)=>{let ht=Qi.getHead(si.get(Wt)),an=Qi.getHead(si.get(ur)),$n=ht.firstTicket||ht.ticket,ai=an.firstTicket||an.ticket;return $n===ai?ht.client>an.client?1:-1:$n-ai}):Array.from(si.keys())),ze&&!["FONT","BLOB"].includes(Li)&&!this.orderTree.has(et)){this.orderTree.add(et);for(let Wt of Ar){let ur=si.get(Wt);ur&&(this.isFilterData(ur.last,e,!1)||(ur.num&&(ur.num=void 0),this.orderTree.setOrderNum(et,Li,Wt,ur,!1)))}}let Sr={},vn=0,na=Cc.getInitProps();for(let Wt of Ar){let ur=si.get(Wt);if(!ur)continue;let ht;if(D?Qi.preForEach(ur,ai=>ai.unique===D?(ht=ai,delete ai.unique,ge||(delete ai.pend,this.setDocMaxTicket(et,ai.ticket,ai.pend),ai===ur.last&&this.cbArr.forEach(wi=>wi(et,Wt,ai.data,ai.dataType,ai.client,ai.ticket,Qi.getFirstTicket(ur),void 0,void 0,!0,void 0))),!0):!1):ht=ur.last,this.isFilterData(ht,e,!0))continue;if(ke&&et==="FONT"&&Sn){let ai=CM(Wt);if(!Sn.some(wi=>lK(ai,wi)))continue}if(ke&&et==="BLOB"&&!gt.has(Wt))continue;if(It&&ht.pend&&!ge&&(delete ht.pend,this.setDocMaxTicket(et,ht.ticket,!1),this.cbArr.forEach(ai=>ai(et,Wt,ht.data,ht.dataType,ht.client,ht.ticket,Qi.getFirstTicket(ur),void 0,void 0,!0,void 0))),Ci){if(ht.dataType==="ELE_PLACEHOLDER"){let wi=JSON.parse(ht.data);Sr[wi.dataType]===void 0?Sr[wi.dataType]=wi.max:Sr[wi.dataType]+=wi.max;continue}let ai=g4(Li);if(ai&&ai.includes(ht.dataType))if(ht.data!==""){if(Sr[ht.dataType]){let wi={dataType:ht.dataType,max:Sr[ht.dataType]},xn=kp("ELE_PLACEHOLDER",Qi.getFirstTicket(ur)-1,`placeholder${++vn}`,JSON.stringify(wi));i(xn)?await t(xn):t(xn),delete Sr[ht.dataType]}}else{Sr[ht.dataType]===void 0?Sr[ht.dataType]=1:++Sr[ht.dataType];continue}}let an=ht.data;if(this.getCache&&ht.hId&&ht.data===void 0){let ai=ht.dNum||0,wi=a1(et,Li);if(!((Ee=(me=(ne=(W=(z=this.historyMap)==null?void 0:z[ht.hId])==null?void 0:W[ht.hNum])==null?void 0:ne[wi])==null?void 0:me[ai])!=null&&Ee.cache)){this.historyMap[ht.hId]||(this.historyMap[ht.hId]={}),this.historyMap[ht.hId][ht.hNum]||(this.historyMap[ht.hId][ht.hNum]={}),this.historyMap[ht.hId][ht.hNum][wi]||(this.historyMap[ht.hId][ht.hNum][wi]={}),this.historyMap[ht.hId][ht.hNum][wi][ai]||(this.historyMap[ht.hId][ht.hNum][wi][ai]={cache:null,promise:null});let xn=this.getCache();this.historyMap[ht.hId][ht.hNum][wi][ai].cache=xn;let sa=xn.init(ht.hId,ht.hNum,wi,ai);this.historyMap[ht.hId][ht.hNum][wi][ai].promise=sa,await sa,delete this.historyMap[ht.hId][ht.hNum][wi][ai].promise}this.historyMap[ht.hId][ht.hNum][wi][ai].promise&&await this.historyMap[ht.hId][ht.hNum][wi][ai].promise,an=this.historyMap[ht.hId][ht.hNum][wi][ai].cache.get(ht.start)}if(ht.dataType==="META"&&K&&K.includes(et)&&an){let ai=JSON.parse(an);ai.board&&(ai.board="",an=JSON.stringify(ai))}let $n=kp(ht.dataType,ht.ticket,Wt,an,Ne?ht.client:void 0,it&&ht.ticket!==Qi.getFirstTicket(ur)?Qi.getFirstTicket(ur):void 0,void 0,ze?ur.num:void 0);if(ke)switch(Li){case"PCB":{Cc.collectPcb(et,Wt,ht.dataType,an,na);break}case"FOOTPRINT":{Cc.collectFt(et,Wt,ht.dataType,an,na);break}case"PANEL":{Cc.collectPanel(et,Wt,ht.dataType,an,na);break}case"SYMBOL":{Cc.collectSymbol(et,Wt,ht.dataType,an,na);break}case"SCH_PAGE":case"SIMULATION":{Cc.collectSymbol(et,Wt,ht.dataType,an,na);break}default:break}i($n)?await t($n):t($n)}if(ze){let Wt=kp("MAX_NUM",1,"MAX_NUM",JSON.stringify(this.orderTree.getMaxNum(et)));i(Wt)?await t(Wt):t(Wt)}if(ke){let Wt;switch(Li){case"PCB":{Wt=Cc.pcb(Z.deviceNames,Z.footprintNames,Z.deviceAttrs,na);break}case"FOOTPRINT":{Wt=Cc.footprint(na);break}case"PANEL":{Wt=Cc.panel(na);break}case"SYMBOL":{Wt=Cc.symbol(na);break}case"SCH_PAGE":case"SIMULATION":{Wt=Cc.sheet(na).dataSet;break}default:break}if(Wt!=null&&Wt.fonts)for(let ur of Wt.fonts)rt.add(ur);if(Wt!=null&&Wt.blobs)for(let ur of Wt.blobs)gt.add(ur)}}}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 uK,e)}remoteChange(e,t,i,r,n,s,a,o,l,c,u,h,d,p,f){var m,g,x,y,E;this.setMaxTicket(e),a&&this.setDoctype(i,a),o=o||h===this.getUnique();let T=(y=(x=(g=(m=this.wDocData)==null?void 0:m.get)==null?void 0:g.call(m,i))==null?void 0:x.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),b=T?Qi.getFirstTicket(w):null,C=T&&T.ticket===e&&T.client===t&&!!T.pend!=!!c,A=s!=="ELE_PLACEHOLDER"&&(!o||o&&this.getIsLocalChange())&&(!C||C&&this.getIsPendChange()),R=Qi.find(w,G=>G.client===t&&G.ticket===e);if(R){this.setDocMaxTicket(i,e,c),f&&(R.hId=f.uuid,R.hNum=f.num,R.start=f.start,f.dNum&&(R.dNum=f.dNum)),this.getCache&&!this.cacheType.includes(s)&&(E=R.data)!=null&&E.length&&R!=null&&R.hId&&delete R.data,R.pend&&!c&&(delete R.pend,A&&R===w.last&&this.cbArr.forEach(G=>G(i,r,n,s,t,e,Qi.getFirstTicket(w),c,void 0,C,h)));return}let O=e;if(c){let G=[];Qi.preForEach(w,H=>H.client===t&&H.pend&&H.ticket<e?(G.push(H),!0):!1),G.length&&G.length===Qi.getLength(w)&&(O=b||e),G.forEach(H=>{Qi.remove(w,H)})}let M={client:t,ticket:O,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 k=!T||T.ticket<e||T.ticket===e&&T.client<t;if(Qi.insert(w,M),this.orderTree.has(i)&&(!T||b>e))try{this.orderTree.setOrderNum(i,this.getDoctype(i),r,w,!0,b&&b>e)}catch(G){console.error(G)}if(this.setDocMaxTicket(i,O,c),k){let G=Qi.getFirstTicket(w);A&&this.cbArr.forEach(H=>H(i,r,n,s,t,e,G,c,void 0,C,h))}}};function dK(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 pK=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=Yp(this.orderLists,t,()=>new FA(dK)),a=Yp(this.maxNum,t,()=>this.startNum-1),o=Yp(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]}},fK=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 pK(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 mK=Object.create,b4=Object.defineProperty,gK=Object.getOwnPropertyDescriptor,yK=Object.getOwnPropertyNames,bK=Object.getPrototypeOf,xK=Object.prototype.hasOwnProperty,EK=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),TK=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of yK(t))!xK.call(e,n)&&n!==i&&b4(e,n,{get:()=>t[n],enumerable:!(r=gK(t,n))||r.enumerable});return e},wK=(e,t,i)=>(i=e!=null?mK(bK(e)):{},TK(t||!e||!e.__esModule?b4(i,"default",{value:e,enumerable:!0}):i,e)),SK=EK((e,t)=>{"use strict";t.exports=i,t.exports.default=i;function i(v,L,_){_=_||2;var B=L&&L.length,U=B?L[0]*_:v.length,z=r(v,0,U,_,!0),W=[];if(!z||z.next===z.prev)return W;var ne,me,Ee,Se,Fe,Ne,it;if(B&&(z=u(v,L,z,_)),v.length>80*_){ne=Ee=v[0],me=Se=v[1];for(var je=_;je<U;je+=_)Fe=v[je],Ne=v[je+1],Fe<ne&&(ne=Fe),Ne<me&&(me=Ne),Fe>Ee&&(Ee=Fe),Ne>Se&&(Se=Ne);it=Math.max(Ee-ne,Se-me),it=it!==0?32767/it:0}return s(z,W,_,ne,me,it,0),W}function r(v,L,_,B,U){var z,W;if(U===N(v,L,_,B)>0)for(z=L;z<_;z+=B)W=H(z,v[z],v[z+1],W);else for(z=_-B;z>=L;z-=B)W=H(z,v[z],v[z+1],W);return W&&b(W,W.next)&&(q(W),W=W.next),W}function n(v,L){if(!v)return v;L||(L=v);var _=v,B;do if(B=!1,!_.steiner&&(b(_,_.next)||w(_.prev,_,_.next)===0)){if(q(_),_=L=_.prev,_===_.next)break;B=!0}else _=_.next;while(B||_!==L);return L}function s(v,L,_,B,U,z,W){if(v){!W&&z&&m(v,B,U,z);for(var ne=v,me,Ee;v.prev!==v.next;){if(me=v.prev,Ee=v.next,z?o(v,B,U,z):a(v)){L.push(me.i/_|0),L.push(v.i/_|0),L.push(Ee.i/_|0),q(v),v=Ee.next,ne=Ee.next;continue}if(v=Ee,v===ne){W?W===1?(v=l(n(v),L,_),s(v,L,_,B,U,z,2)):W===2&&c(v,L,_,B,U,z):s(n(v),L,_,B,U,z,1);break}}}}function a(v){var L=v.prev,_=v,B=v.next;if(w(L,_,B)>=0)return!1;for(var U=L.x,z=_.x,W=B.x,ne=L.y,me=_.y,Ee=B.y,Se=U<z?U<W?U:W:z<W?z:W,Fe=ne<me?ne<Ee?ne:Ee:me<Ee?me:Ee,Ne=U>z?U>W?U:W:z>W?z:W,it=ne>me?ne>Ee?ne:Ee:me>Ee?me:Ee,je=B.next;je!==L;){if(je.x>=Se&&je.x<=Ne&&je.y>=Fe&&je.y<=it&&E(U,ne,z,me,W,Ee,je.x,je.y)&&w(je.prev,je,je.next)>=0)return!1;je=je.next}return!0}function o(v,L,_,B){var U=v.prev,z=v,W=v.next;if(w(U,z,W)>=0)return!1;for(var ne=U.x,me=z.x,Ee=W.x,Se=U.y,Fe=z.y,Ne=W.y,it=ne<me?ne<Ee?ne:Ee:me<Ee?me:Ee,je=Se<Fe?Se<Ne?Se:Ne:Fe<Ne?Fe:Ne,It=ne>me?ne>Ee?ne:Ee:me>Ee?me:Ee,Ht=Se>Fe?Se>Ne?Se:Ne:Fe>Ne?Fe:Ne,Ri=x(it,je,L,_,B),Ci=x(It,Ht,L,_,B),ze=v.prevZ,D=v.nextZ;ze&&ze.z>=Ri&&D&&D.z<=Ci;){if(ze.x>=it&&ze.x<=It&&ze.y>=je&&ze.y<=Ht&&ze!==U&&ze!==W&&E(ne,Se,me,Fe,Ee,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0||(ze=ze.prevZ,D.x>=it&&D.x<=It&&D.y>=je&&D.y<=Ht&&D!==U&&D!==W&&E(ne,Se,me,Fe,Ee,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0))return!1;D=D.nextZ}for(;ze&&ze.z>=Ri;){if(ze.x>=it&&ze.x<=It&&ze.y>=je&&ze.y<=Ht&&ze!==U&&ze!==W&&E(ne,Se,me,Fe,Ee,Ne,ze.x,ze.y)&&w(ze.prev,ze,ze.next)>=0)return!1;ze=ze.prevZ}for(;D&&D.z<=Ci;){if(D.x>=it&&D.x<=It&&D.y>=je&&D.y<=Ht&&D!==U&&D!==W&&E(ne,Se,me,Fe,Ee,Ne,D.x,D.y)&&w(D.prev,D,D.next)>=0)return!1;D=D.nextZ}return!0}function l(v,L,_){var B=v;do{var U=B.prev,z=B.next.next;!b(U,z)&&C(U,B,B.next,z)&&M(U,z)&&M(z,U)&&(L.push(U.i/_|0),L.push(B.i/_|0),L.push(z.i/_|0),q(B),q(B.next),B=v=z),B=B.next}while(B!==v);return n(B)}function c(v,L,_,B,U,z){var W=v;do{for(var ne=W.next.next;ne!==W.prev;){if(W.i!==ne.i&&T(W,ne)){var me=G(W,ne);W=n(W,W.next),me=n(me,me.next),s(W,L,_,B,U,z,0),s(me,L,_,B,U,z,0);return}ne=ne.next}W=W.next}while(W!==v)}function u(v,L,_,B){var U=[],z,W,ne,me,Ee;for(z=0,W=L.length;z<W;z++)ne=L[z]*B,me=z<W-1?L[z+1]*B:v.length,Ee=r(v,ne,me,B,!1),Ee===Ee.next&&(Ee.steiner=!0),U.push(y(Ee));for(U.sort(h),z=0;z<U.length;z++)_=d(U[z],_);return _}function h(v,L){return v.x-L.x}function d(v,L){var _=p(v,L);if(!_)return L;var B=G(_,v);return n(B,B.next),n(_,_.next)}function p(v,L){var _=L,B=v.x,U=v.y,z=-1/0,W;do{if(U<=_.y&&U>=_.next.y&&_.next.y!==_.y){var ne=_.x+(U-_.y)*(_.next.x-_.x)/(_.next.y-_.y);if(ne<=B&&ne>z&&(z=ne,W=_.x<_.next.x?_:_.next,ne===B))return W}_=_.next}while(_!==L);if(!W)return null;var me=W,Ee=W.x,Se=W.y,Fe=1/0,Ne;_=W;do B>=_.x&&_.x>=Ee&&B!==_.x&&E(U<Se?B:z,U,Ee,Se,U<Se?z:B,U,_.x,_.y)&&(Ne=Math.abs(U-_.y)/(B-_.x),M(_,v)&&(Ne<Fe||Ne===Fe&&(_.x>W.x||_.x===W.x&&f(W,_)))&&(W=_,Fe=Ne)),_=_.next;while(_!==me);return W}function f(v,L){return w(v.prev,v,L.prev)<0&&w(L.next,v,v.next)<0}function m(v,L,_,B){var U=v;do U.z===0&&(U.z=x(U.x,U.y,L,_,B)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==v);U.prevZ.nextZ=null,U.prevZ=null,g(U)}function g(v){var L,_,B,U,z,W,ne,me,Ee=1;do{for(_=v,v=null,z=null,W=0;_;){for(W++,B=_,ne=0,L=0;L<Ee&&(ne++,B=B.nextZ,!!B);L++);for(me=Ee;ne>0||me>0&&B;)ne!==0&&(me===0||!B||_.z<=B.z)?(U=_,_=_.nextZ,ne--):(U=B,B=B.nextZ,me--),z?z.nextZ=U:v=U,U.prevZ=z,z=U;_=B}z.nextZ=null,Ee*=2}while(W>1);return v}function x(v,L,_,B,U){return v=(v-_)*U|0,L=(L-B)*U|0,v=(v|v<<8)&16711935,v=(v|v<<4)&252645135,v=(v|v<<2)&858993459,v=(v|v<<1)&1431655765,L=(L|L<<8)&16711935,L=(L|L<<4)&252645135,L=(L|L<<2)&858993459,L=(L|L<<1)&1431655765,v|L<<1}function y(v){var L=v,_=v;do(L.x<_.x||L.x===_.x&&L.y<_.y)&&(_=L),L=L.next;while(L!==v);return _}function E(v,L,_,B,U,z,W,ne){return(U-W)*(L-ne)>=(v-W)*(z-ne)&&(v-W)*(B-ne)>=(_-W)*(L-ne)&&(_-W)*(z-ne)>=(U-W)*(B-ne)}function T(v,L){return v.next.i!==L.i&&v.prev.i!==L.i&&!O(v,L)&&(M(v,L)&&M(L,v)&&k(v,L)&&(w(v.prev,v,L.prev)||w(v,L.prev,L))||b(v,L)&&w(v.prev,v,v.next)>0&&w(L.prev,L,L.next)>0)}function w(v,L,_){return(L.y-v.y)*(_.x-L.x)-(L.x-v.x)*(_.y-L.y)}function b(v,L){return v.x===L.x&&v.y===L.y}function C(v,L,_,B){var U=R(w(v,L,_)),z=R(w(v,L,B)),W=R(w(_,B,v)),ne=R(w(_,B,L));return!!(U!==z&&W!==ne||U===0&&A(v,_,L)||z===0&&A(v,B,L)||W===0&&A(_,v,B)||ne===0&&A(_,L,B))}function A(v,L,_){return L.x<=Math.max(v.x,_.x)&&L.x>=Math.min(v.x,_.x)&&L.y<=Math.max(v.y,_.y)&&L.y>=Math.min(v.y,_.y)}function R(v){return v>0?1:v<0?-1:0}function O(v,L){var _=v;do{if(_.i!==v.i&&_.next.i!==v.i&&_.i!==L.i&&_.next.i!==L.i&&C(_,_.next,v,L))return!0;_=_.next}while(_!==v);return!1}function M(v,L){return w(v.prev,v,v.next)<0?w(v,L,v.next)>=0&&w(v,v.prev,L)>=0:w(v,L,v.prev)<0||w(v,v.next,L)<0}function k(v,L){var _=v,B=!1,U=(v.x+L.x)/2,z=(v.y+L.y)/2;do _.y>z!=_.next.y>z&&_.next.y!==_.y&&U<(_.next.x-_.x)*(z-_.y)/(_.next.y-_.y)+_.x&&(B=!B),_=_.next;while(_!==v);return B}function G(v,L){var _=new I(v.i,v.x,v.y),B=new I(L.i,L.x,L.y),U=v.next,z=L.prev;return v.next=L,L.prev=v,_.next=U,U.prev=_,B.next=_,_.prev=B,z.next=B,B.prev=z,B}function H(v,L,_,B){var U=new I(v,L,_);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(v){v.next.prev=v.prev,v.prev.next=v.next,v.prevZ&&(v.prevZ.nextZ=v.nextZ),v.nextZ&&(v.nextZ.prevZ=v.prevZ)}function I(v,L,_){this.i=v,this.x=L,this.y=_,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(v,L,_,B){var U=L&&L.length,z=U?L[0]*_:v.length,W=Math.abs(N(v,0,z,_));if(U)for(var ne=0,me=L.length;ne<me;ne++){var Ee=L[ne]*_,Se=ne<me-1?L[ne+1]*_:v.length;W-=Math.abs(N(v,Ee,Se,_))}var Fe=0;for(ne=0;ne<B.length;ne+=3){var Ne=B[ne]*_,it=B[ne+1]*_,je=B[ne+2]*_;Fe+=Math.abs((v[Ne]-v[je])*(v[it+1]-v[Ne+1])-(v[Ne]-v[it])*(v[je+1]-v[Ne+1]))}return W===0&&Fe===0?0:Math.abs((Fe-W)/W)};function N(v,L,_,B){for(var U=0,z=L,W=_-B;z<_;z+=B)U+=(v[W]-v[z])*(v[z+1]+v[W+1]),W=z;return U}i.flatten=function(v){for(var L=v[0][0].length,_={vertices:[],holes:[],dimensions:L},B=0,U=0;U<v.length;U++){for(var z=0;z<v[U].length;z++)for(var W=0;W<L;W++)_.vertices.push(v[U][z][W]);U>0&&(B+=v[U-1].length,_.holes.push(B))}return _}}),vK=(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))(vK||{}),IK=(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))(IK||{}),DM={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},Rwe=(()=>{let e={};for(let t in DM)e[DM[t]]=t;return e})(),u2,Nwe=(u2=class{constructor(e,t){this.ratio=e/t}wrap(e){return e*this.ratio}static convert(e,t,i){return e*t/i}},u2.ASIS=new u2(1,1),u2),h2=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}};h2.prototype["px(100)2mil"]=e=>e*10,h2.prototype["px(100)2mm"]=e=>e*.254,h2.prototype["mil2px(100)"]=e=>e/10,h2.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var d2=null,iC=new ArrayBuffer(8),yA=new Float64Array(iC),bA=new Uint32Array(iC),PM=new Uint16Array(iC),_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(!d2){let e=this.getUrlVars().version;e?d2="/analyzer/v"+e:d2="/analyzer"}return d2}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;yA[0]=new Date().getTime(),e.push(bA[1].toString(16)),yA[0]=Math.random(),e.push(PM[3].toString(16));let t=PM[2].toString(16);e.push("4"+t.substr(0,3)),yA[0]=performance.now();let i=bA[0].toString(16)+bA[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}},x4=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(ig.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(ig.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(ig.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(ig.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")}},AK=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(AK||{}),CK=/(\.?0+)$/,ig=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);x4.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(CK,"")}},DK=(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))(DK||{});function PK(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var _K=(e,t)=>{e===3?console.error(t):console.log(t)},LK=(e,t)=>ig.format("%s %s: %s",new Date,PK(e),t),zm,z2=(zm=class{constructor(e,t=_K,i=LK){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 zm(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 zm(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,ig.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)}},zm.DUMMY=new zm(4),zm),rC=new ArrayBuffer(8),xA=new Float64Array(rC),EA=new Uint32Array(rC),LM=new Uint16Array(rC),OM=ArrayBuffer;try{OM=self.HTMLImageElement||OM}catch{}var p2=null;function jp(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 x=l(m,g);isNaN(x)?(o[f++]=g,g=a[++p]):(x<=0&&(o[f++]=m,m=a[++d]),x>=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 Aa=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(!p2){let e=this.getUrlVars().version;e?p2="/analyzer/v"+e:p2="/analyzer"}return p2}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;xA[0]=new Date().getTime(),e.push(EA[1].toString(16)),xA[0]=Math.random(),e.push(LM[3].toString(16));let t=LM[2].toString(16);e.push("4"+t.substr(0,3)),xA[0]=performance.now();let i=EA[0].toString(16)+EA[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}},OK=[1,10,100,1e3],f2=0,Mp=0;function RM(e,t,i){return f2=Math.abs(e-t),i>=5&&f2>1e-5||isNaN(i)&&f2>1e-8?!1:f2<1e-13?!0:(Mp=Math.min(NM(e),NM(t)),Mp<10&&(Mp=10),isNaN(i)||(Mp=Math.min(Mp,i)),MM(e,Mp)===MM(t,Mp))}var m2=0,g2=0;function NM(e){return m2=0,g2=0,e>0?m2=e-Math.floor(e):m2=e-Math.ceil(e),g2=(m2.toString()||"").length,g2>2?g2-2:0}function MM(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=OK[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 RK=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(RK||{}),NK=/(\.?0+)$/,rg=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(Aa.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(Aa.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);rn.nullOrEmpty(s)||i.push(s);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(NK,"")}},rn=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(rg.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(rg.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(rg.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(rg.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")}},y2,Re=(y2=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}},y2.eps=1e-8,y2.precision=1e8,y2);function sg(e,t){N2(e.iterator(),t)}function N2(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var MK=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 GA(e){return new MK(e)}var va,$t=(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)}},E4=new ArrayBuffer(16),BM=new Float64Array(E4),b2=new Int32Array(E4),Zi,Ie=(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)||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 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=rn.normal(e),this.y=rn.normal(t)}get hashed(){return this._hashed==null&&(BM[0]=this.x,BM[1]=this.y,this._hashed=b2[0]^b2[1]^b2[2]^b2[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 $t.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 $t.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,$t.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?RM(e.x,this.x,t)&&RM(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 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 Ia(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=$t.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),BK=(e=>(e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT",e))(BK||{}),kK=(e=>(e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM",e))(kK||{}),Ps,uh=(Ps=class{constructor(e,t){this.horizontal=e,this.vertical=t}},Ps.LT=new Ps(0,0),Ps.LC=new Ps(0,1),Ps.LB=new Ps(0,2),Ps.CT=new Ps(1,0),Ps.CC=new Ps(1,1),Ps.CB=new Ps(1,2),Ps.RT=new Ps(2,0),Ps.RC=new Ps(2,1),Ps.RB=new Ps(2,2),Ps),FK=(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))(FK||{}),Oo=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 sg(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 Ia(this.minX,this.maxX,this.minY,this.maxY)}build1(){return this.valid()?new Ia(this.minX,this.maxX,this.minY,this.maxY):new Ia(0,0,0,0)}},Xy=new Float64Array(4),Ia=class Xl{static extendRect({x:t,y:i,width:r,height:n}){return new Xl(t,t+r,i,i+n)}static extend1(t,i){if(t===null)return new Xl(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 Xl(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 Xl(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 Xl(r,n,s,a)}static extend4(t,i,r){return new Xl(t.x-i/2,t.x+i/2,t.y-r/2,t.y+r/2)}constructor(t,i,r,n){if(this.minX=rn.normal(t),this.maxX=rn.normal(i),this.minY=rn.normal(r),this.maxY=rn.normal(n),t>i||r>n)throw new Error(`min > max is not permitted: [${t}, ${i}, ${r}, ${n}]`)}get data(){return Xy[0]=this.minX,Xy[1]=this.maxX,Xy[2]=this.minY,Xy[3]=this.maxY,Xy}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 rn.positiveOr0(this.maxX-this.minX+t*2),rn.positiveOr0(this.maxY-this.minY+t*2),new Xl(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 Xl(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 Xl(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 Oo;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 Oo;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 Xl(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),Xl.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?uh.RT:o<-s?uh.RB:uh.RC:a<-n?o>s?uh.LT:o<-s?uh.LB:uh.LC:o>s?uh.CT:o<-s?uh.CB:uh.CC}bbox(){return this}},M2=class Bi{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=rn.normal(t),this.n=rn.normal(i);let n=t*i;if(r.length===n){for(let s=0;s<r.length;s++)rn.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 Bi.mul(this.m,this.n,t.n,this.data,t.data,i),new Bi(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[Bi.on(n,a,o)]=t[Bi.on(r,a,o)]:o===i+a?s[Bi.on(n,a,o)]=1:s[Bi.on(n,a,o)]=0;return s}inverseMatrix(t,i,r){for(let n=0;n<i;n++){let s=t[Bi.on(r,n,n)];for(let a=0;a<r;a++)t[Bi.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[Bi.on(r,s,s)]===0){let a=new Array(r),o;for(o=s;o<i;o++)if(t[Bi.on(r,o,s)]!==0){Aa.arraycopy(t,Bi.on(r,o,0),a,0,r),Aa.arraycopy(t,Bi.on(r,s,0),t,Bi.on(r,o,0),r),Aa.arraycopy(a,0,t,Bi.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[Bi.on(r,a,s)]/t[Bi.on(r,s,s)];for(let l=0;l<r;l++)t[Bi.on(r,a,l)]-=t[Bi.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[Bi.on(r,a,l)];i[Bi.on(r,a,l)]=i[Bi.on(r,o,l)],i[Bi.on(r,o,l)]=c}}for(let a=0;a<this.m;a++){let o=Math.abs(i[Bi.on(r,a,a)]),l=a;if(t(i[Bi.on(r,a,a)]))for(let u=a+1;u<this.m;u++){if(t(i[Bi.on(r,u,a)])){Math.abs(i[Bi.on(r,u,a)])>o&&(o=Math.abs(i[Bi.on(r,u,a)]),l=u);continue}n(a,u);break}if(t(i[Bi.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[Bi.on(r,a,a)];for(let u=0;u<r;u++)i[Bi.on(r,a,u)]*=c;for(let u=0;u<this.m;u++){if(a===u)continue;let h=i[Bi.on(r,u,a)];for(let d=a;d<r;d++)i[Bi.on(r,u,d)]-=i[Bi.on(r,a,d)]*h}}let s=[];for(let a=0;a<this.m;a++)for(let o=this.n;o<r;o++)s[Bi.on(this.n,a,o-this.n)]=i[Bi.on(r,a,o)];return new Bi(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 Bi(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 Bi?!(this.m!=t.m||this.n!=t.n||!Aa.equals(this.data,t.data)):!1}},GK=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],mn,T4=(mn=class extends M2{static translate(e,t,i){return new mn([1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1])}static translate1(e){return new mn([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 mn([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 mn([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 mn([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 mn([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 mn([e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1])}static flipX(){return new mn([1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1])}static flipY(){return new mn([-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)?mn.rotateZ(t):mn.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 mn(l)}constructor(e=GK){super(4,4,e)}translate(e){return this.multiply4(mn.translate1(e))}translate1(e,t,i){return this.multiply4(mn.translate(e,t,i))}rotateX(e){return this.multiply4(mn.rotateX(e))}rotateY(e){return this.multiply4(mn.rotateY(e))}rotateZ(e){return this.multiply4(mn.rotateZ(e))}scale(e,t=e,i=e){return this.multiply4(mn.scale(e,t,i))}scale1(e){return this.multiply4(mn.scale(e.x,e.y,e.z))}setOrigin(e,t,i){return mn.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 M2.mul(4,4,4,this.data,e.data,t),new mn(t)}getInverseMatrix(){let e=super.getInverseMatrix();return new mn(e.data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new mn(e.data)}inverse(){let e=this.getInverseMatrix();return new mn(e.data)}toMatrix3(){let e=this.data;return new Kn([e[0],e[1],0,e[4],e[5],0,e[12],e[13],1])}},mn.ORIGIN=new mn,mn);function Wy(e){return x4.normal(parseFloat(e))}var UK=[1,0,0,0,1,0,0,0,1],Xr,Kn=(Xr=class extends M2{static translate(e,t){return new Xr([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 Xr([t,i,0,-i,t,0,0,0,1])}static rotateD(e){return this.rotate($t.toRadians(e))}static scale(e,t=e){return new Xr([e,0,0,0,t,0,0,0,1])}static scale1(e,t){return new Xr([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=Wy(a[0]),l=Wy(a[1]);i=i?i.translate(o,l):Xr.translate(o,l);break;case"rotate":let c=Wy(a[0]),u=Wy(a[1]),h=Wy(a[2]);i=i?i.setOrigin(u,h):Xr.translate(u,h),i=i.rotateD(c);break;default:return}}),i}constructor(e=UK){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 M2.mul(3,3,3,this.data,e.data,t),new Xr(t)}translate(e,t){return this.multiply3(Xr.translate(e,t))}translate1(e){return this.multiply3(Xr.translate1(e))}scale(e,t=e){return this.multiply3(Xr.scale(e,t))}scale1(e,t){return this.multiply3(Xr.scale1(e,t))}det(){return this.data[0]*this.data[4]-this.data[3]*this.data[1]}invert(){let e=this.getInverseMatrix();return new Xr(e.data)}rotateD(e){return this.multiply3(Xr.rotateD(e))}rotate(e){return this.multiply3(Xr.rotate(e))}resetOffset(){let e=this.data;return new Xr([e[0],e[1],0,e[3],e[4],0,0,0,1])}setOrigin(e,t){return Xr.translate(-e,-t).multiply3(this).translate(e,t)}setOrigin1(e){return this.setOrigin(e.x,e.y)}getInverseMatrix(){return new Xr(super.getInverseMatrix().data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new Xr(e.data)}toMatrix4(){let e=this.data;return new T4([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}},Xr.ORIGIN=new Xr,Xr.MIRROR_Y=new Xr([1,0,0,0,-1,0,0,0,1]),Xr.MIRROR_X=new Xr([-1,0,0,0,1,0,0,0,1]),Xr.ROT_90=new Xr([0,1,0,-1,0,0,0,0,1]),Xr.ROT_N90=new Xr([0,-1,0,1,0,0,0,0,1]),Xr),YK=(e=>(e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE",e))(YK||{}),HK=(e=>(e[e.CW=0]="CW",e[e.CCW=1]="CCW",e))(HK||{}),p1=class{},UA=class Zy{constructor(t,i,r){this.p1=t,this.p2=i,this.p3=r}barycentre(){return Zy.barycentre(this.p1,this.p2,this.p3)}incentre(){return Zy.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 Zy.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=Kn.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 Zy(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 x2(){return{minDistance:Number.POSITIVE_INFINITY,start:null,end:null}}var Lc=class Td{static getMinDistanceWithoutCross(t,i){let r=x2();return Td.minLine(t,i,r),r.minDistance}static getMinDistance(t,i){return ql(t,i)?0:this.getMinDistanceWithoutCross(t,i)}static getMinLineWithCross(t,i){let r=x2();return Td.minLine(t,i,r),new ye(r.start,r.end)}static getMinLine(t,i){return Td.intersection(t,i)||this.getMinLineWithCross(t,i)}static getMinDistanceFromPoint(t,i){let r=x2();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=Td.intersection(t,i),this.minline)this.minDistance=0;else{let r=x2();Td.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=ql(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=Td.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),(Dc(t,i.center)||Dc(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);Dc(t,a)&&(this.arcShortestLine(i,r,a,l),this.arcShortestLine(i,r,a,c)),Dc(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));Dc(t,l)&&Re.greater(i.start().distance2(t.center),0)&&this.arcShortestLine(t,r,i.start(),l),Dc(t,c)&&Re.greater(i.end().distance2(t.center),0)&&this.arcShortestLine(t,r,i.end(),c),Dc(i,u)&&Re.greater(t.start().distance2(i.center),0)&&this.arcShortestLine(i,r,t.start(),u),Dc(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(Dc(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(Dc(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=Td.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(!Dc(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 Dc(e,t){if(Re.eq(e.sweepAngle,360))return!0;let i=$t.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 jK=[1,10,100,1e3],kM="http://www.w3.org/2000/svg",FM="http://www.w3.org/1999/xlink",GM="http://www.w3.org/XML/1998/namespace",UM="https://easyeda.com/",Mwe=(function(){var e={svg:kM,xlink:FM,xml:GM,c:UM};return e[kM]="svg",e[FM]="xlink",e[GM]="xml",e[UM]="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})(),Bwe=(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})(),Ys=(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})(),kwe=(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:Ys[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case Jn.BOTTOMLAYER:n={name:Ys[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case Jn.TOPSILKLAYER:n={name:Ys[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case Jn.BOTTOMSILKLAYER:n={name:Ys[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case Jn.TOPPASTERLAYER:n={name:Ys[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case Jn.BOTTOMPASTERLAYER:n={name:Ys[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case Jn.TOPSOLDERLAYER:n={name:Ys[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case Jn.BOTTOMSOLDERLAYER:n={name:Ys[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case Jn.RATLINES:n={name:Ys[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case Jn.BOARDOUTLINE:n={name:Ys[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case Jn.ALL:n={name:Ys[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case Jn.DOCUMENT:n={name:Ys[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case Jn.TOPASSEMBLY:n={name:Ys[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case Jn.BOTTOMASSEMBLY:n={name:Ys[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case Jn.MECHANICAL:n={name:Ys[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case Jn.MODEL3D:n={name:Ys[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case Jn.LIBBODY:n={name:Ys[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case Jn.PADSURFACE:n={name:Ys[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=Jn.INNER1&&o<=Jn.INNER32?n={name:Ys[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})(),YM={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},Fwe=(function(){var e={};for(let t in YM)e[YM[t]]=t;return e})(),X2=Math.PI*2,B2=Math.PI/2,Gwe=Math.sin(Math.PI/180);function VK(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=jK[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 w4(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function zK(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 XK(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 WK(e,t,i){return zK(e,t,i)?w4((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}var Qy=1e-4,oe=new Float64Array(100);function ql(e,t){if(e instanceof ye&&t instanceof ye)return Su(e,t);if(e instanceof Le&&t instanceof ye)return YA(e,t);if(e instanceof ye&&t instanceof Le)return YA(t,e);if(e instanceof Le&&t instanceof Le)return v4(e,t);if(e instanceof pt&&t instanceof pt)return D2(e,t);if(e instanceof pt&&t instanceof ye)return D2(e,new pt([t.start(),t.end()]));if(e instanceof ye&&t instanceof pt)return D2(new pt([e.start(),e.end()]),t);if(e instanceof pt&&t instanceof Le)return qM(t,e);if(e instanceof Le&&t instanceof pt)return qM(e,t);throw new Error("not supported operation")}function qK(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 Su(r,e)>0?1:0}else return 0}function JK(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 k2(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)&&D2(new pt([new Ie(i.minX-1,t),new Ie(i.maxX+1,t)]),e)>0?1:0}function jM(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function KK(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 Su(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 VM(t,e,i);else{if(t.isPoint())return VM(e,t,i);{let r=function(E,T){i.isContains2(E,T)&&(oe[y++]=E,oe[y++]=T)};if(!KK(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,x=Ln.crossProd2(u,h,n,s,a,o)/m;if(g*x>0&&!Re.eq(g,0)&&!Re.eq(x,0))return 0;let y=0;if(Re.eq(p,0)&&Re.eq(f,0)){let E=i.UL(),T=i.UR(),w=i.LL(),b=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++]=T.x,oe[y++]=T.y;else{let C=UA.area2(E.x,E.y,l,c,u,h),A=UA.area2(T.x,T.y,l,c,u,h);C<A?(oe[y++]=E.x,oe[y++]=E.y,oe[y++]=b.x,oe[y++]=b.y):(oe[y++]=T.x,oe[y++]=T.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 VM(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 k2(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(Qy);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=Lc.foot(t,e.center),x=g.distance1(e.center);if(Re.greater(x,s))return 0;if(Re.eq(x,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=S4(r,n,o,l,c,u,m,g);let y=oe[m-2],E=oe[m-1];m-=2;let T=Ln.distance1(r,n,y,E);if(Re.eq(T,s))oe[m++]=y,oe[m++]=E,oe[m++]=y,oe[m++]=E;else if(T<s)m=ta(a,r,n,o,l,y,E,m),m=ta(a,r,n,y,E,c,u,m);else return 0}}else if(p===-1||f===-1)m=ta(a,r,n,o,l,c,u,m);else{let g=Lc.foot(t,e.center),x=g.distance1(e.center);if(Re.eq(x,s)){let y=function(w){return jM(i,w.x,w.y)&&jn(e,w)},E=e.start(),T=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(T),0)&&y(T))return oe[m++]=T.x,oe[m++]=T.y,oe[m++]=T.x,oe[m++]=T.y,m;if(h<=s)m=ta(a,r,n,g.x,g.y,c,u,m),m===2&&(oe[m++]=oe[0],oe[m++]=oe[1]);else if(x<s){if(m=ta(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=ta(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(T),0)&&y(T))return oe[m++]=T.x,oe[m++]=T.y,oe[m++]=T.x,oe[m++]=T.y,m;if(d<=s)m=ta(a,r,n,g.x,g.y,o,l,m),m===2&&(oe[m++]=oe[0],oe[m++]=oe[1]);else if(x<s){if(m=ta(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=ta(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=ta(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=ta(a,r,n,g.x,g.y,o,l,m))}}if(m>0){let g=0;for(let x=0;x<m;x+=2){let y=oe[x],E=oe[x+1];isFinite(y)&&isFinite(E)&&jM(i,y,E)&&jn(e,new Ie(y,E))&&(oe[g++]=y,oe[g++]=E)}return g}else return 0}else return 0}function $K(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=Lc.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()),x=f.distance2(e.end());Re.eq(g,0)?(oe[p++]=e.start().x,oe[p++]=e.start().y):Re.eq(x,0)?(oe[p++]=e.end().x,oe[p++]=e.end().y):(oe[p++]=f.x,oe[p++]=f.y)}else{p=S4(i,r,s,a,o,l,p,f);let g=oe[p-2],x=oe[p-1],y=Ln.distance2(i,r,g,x);if(p-=2,Re.eq(y,n))oe[p++]=g,oe[p++]=x;else if(y<n)p=ta(n,i,r,s,a,g,x,p),p=ta(n,i,r,g,x,o,l,p);else return 0}}else if(h===-1||d===-1)p=ta(n,i,r,s,a,o,l,p);else{let f=Lc.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=ta(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=ta(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],x=oe[m+1];isFinite(g)&&isFinite(x)&&(oe[f++]=g,oe[f++]=x)}return f}else return 0}else return 0}function ta(e,t,i,r,n,s,a,o){if(n==a){let E=e-(n-i)*(n-i);if(Re.greater(E,0)){let T=Math.sqrt(E),w=t-T,b=t+T,C=Math.min(r,s),A=Math.max(r,s);return w>=C&&w<=A&&(oe[o++]=w,oe[o++]=n),b>=C&&b<=A&&(oe[o++]=b,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,x=0;for(;g!==0;){x++;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 S4(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),x=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==x||d==u&&p==h||f==u&&m==h));){y=Ln.distance2(u,h,e,t);let T=Ln.dotProd2(d,p,u,h,e,t);if(T==0)break;T<0?(f=u,m=h,x=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 YA(e,t){if(e.rx===e.ry)return k2(e,t);throw new Error("not supported")}function ZK(e,t){if(e.rx===e.ry)return $K(e,t);throw new Error("not supported")}function v4(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return QK(e,t);throw new Error("not supported operation")}return 0}function QK(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(zM(e,t))return 4;let p=new ye(e.center,t.center),f=k2(t,p);return f=XM(e,f),f!==0?f:(f=k2(e,p),XM(t,f))}else if(Re.eq(u,h)){if(zM(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,WM(e,t,2)}else{let p=(o-a)/o;return oe[0]=n+(i-n)/p,oe[1]=s+(r-s)/p,WM(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,x=s-r,y=Math.max(a,o),E,T,w,b;if(Math.abs(g)<Math.abs(x)){let O=g/-x,M=m-O*f;E=f-y,T=O*E+M,w=f+y,b=O*w+M}else{let O=x/-g,M=f-O*m;T=m-y,E=O*T+M,b=m+y,w=O*b+M}let C=ta(l,i,r,E,T,f,m,0);if(C=ta(l,i,r,f,m,w,b,C),C!==4)throw new Error("cnt !== 4");let A=new Ie(oe[0],oe[1]),R=new Ie(oe[2],oe[3]);if(jn(e,A)&&jn(t,A))return jn(e,R)&&jn(t,R)?4:xd(e.start(),t,R,A)?(oe[2]=e.start().x,oe[3]=e.start().y,4):xd(e.end(),t,R,A)?(oe[2]=e.end().x,oe[3]=e.end().y,4):xd(t.start(),e,R,A)?(oe[2]=t.start().x,oe[3]=t.start().y,4):xd(t.end(),e,R,A)?(oe[2]=t.end().x,oe[3]=t.end().y,4):2;if(jn(e,R)&&jn(t,R))return xd(e.start(),t,A,R)?(oe[0]=e.start().x,oe[1]=e.start().y,4):xd(e.end(),t,A,R)?(oe[0]=e.end().x,oe[1]=e.end().y,4):xd(t.start(),e,A,R)?(oe[0]=t.start().x,oe[1]=t.start().y,4):xd(t.end(),e,A,R)?(oe[0]=t.end().x,oe[1]=t.end().y,4):(oe[0]=oe[2],oe[1]=oe[3],2);{let O=function(H,q){if(Re.eq(H.distance1(q.center),q.rx)&&jn(q,H)){if(H.distance2(A)<H.distance2(R)){if(M)return;M=!0}else{if(k)return;k=!0}oe[G++]=H.x,oe[G++]=H.y}},M=!1,k=!1,G=0;return O(e.start(),t),O(e.end(),t),O(t.start(),e),O(t.end(),e),G}}}function xd(e,t,i,r){return Re.eq(e.distance1(t.center),t.rx)&&jn(t,e)&&e.distance2(i)<e.distance2(r)}function zM(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 XM(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 WM(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 Xm(e,t){return Math.abs(e-t)<=1e-6}function jn(e,t){let i=e.bbox();if(t.x-i.minX>-Qy&&t.x-i.maxX<Qy&&t.y-i.minY>-Qy&&t.y-i.maxY<Qy){let r=$t.regularD(t.angleD(e.center));return Xm(r,e.startAngle)||Xm(r,e.startAngle+360)||Xm(r,e.startAngle-360)||Xm(r,e.endAngle())||Xm(r,e.endAngle()+360)||Xm(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 e$(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 w4(a,o,Math.sin(Math.PI/180))}function t$(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,x,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,x=c-E,{d:Math.sqrt(g*g+x*x),point:new Ie(y,E)}))}function _c(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"&&r$(r,s)?a=!r[i].call(r,s):a=!(r===s||r.toString()===s.toString()):typeof r=="number"&&typeof s=="number"?a=!(i$(r,s)||Number.isNaN(r)&&Number.isNaN(s)):a=r!==s,a})}function i$(e,t,i=5){return Math.abs(e-t)*Math.pow(10,i)<1}function r$(e,t){return!e||!t||typeof e!="object"||typeof t!="object"?e===t:e.constructor===t.constructor}var ui=new Float64Array(100);function D2(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(I){M=Math.min(M,I),k=Math.max(k,I)},o=function(I,N){let v=Su(I,N);if(v===0)throw new Error("cnt === 0");for(let L=0;L<v;L+=2)a(oe[L])};if(n>r){for(let I=n-2;I>=2;I-=2)for(let N=I-2;N>=0;N-=2)if(Re.eq(ui[I],ui[N])&&Re.eq(ui[I+1],ui[N+1])){ui[N]=(ui[I]+ui[N])/2,ui[N+1]=(ui[I+1]+ui[N+1])/2;for(let v=n-3;v>=I;v--)ui[v]=ui[v+2];n-=2;break}if(n>r){n=0;let I=t.start(),N=new Float64Array(8);e.getPercent(I)!==null&&(N[n++]=I.x,N[n++]=I.y);let v=t.end();e.getPercent(v)!==null&&(N[n++]=v.x,N[n++]=v.y);let L=e.start();t.getPercent(L)!==null&&(N[n++]=L.x,N[n++]=L.y);let _=e.end();return t.getPercent(_)!==null&&(N[n++]=_.x,N[n++]=_.y),oe.set(N),n}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let I=Su(new ye(u[0],u[1]),new ye(h[0],h[1]));for(let N=0;N<I;N++)ui[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,x=Math.sqrt(1/(f**2+m**2));f*=x,m*=x,g*=x;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(I=>{let N=f*I.x+m*I.y+g;N<y&&(y=N),N>E&&(E=N)}),Re.eq(y,E)){if(c.controls.length===2){let I=Su(new ye(l.start(),l.end()),new ye(c.start(),c.end()));for(let N=0;N<I;N++)ui[n++]=oe[N];if(I!==0)continue}l=new pt([u[0],u[u.length-1]]),u=l.controls}let T=h.map(I=>{let N=f*I.x+m*I.y+g,v=Math.abs(N);return v<s&&(s=v),N}),w=0;for(let I of T){if(Re.less(I,y))w=w|1;else if(Re.greater(I,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let b=0,C=0,A=p.x-d.x,R=p.y-d.y,O=Math.sqrt(1/(A**2+R**2));A*=O,R*=O;for(let I=1;I<u.length;I++){let N=u[I],v=(N.x-d.x)*A+(N.y-d.y)*R;v<b?b=v:v>C&&(C=v)}w=0;for(let I of h){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(Re.less(N,b))w=w|1;else if(Re.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY;s/=2,s<=Re.eps&&(s=Re.eps),y-=s,E+=s,T.forEach((I,N)=>{I>=y&&I<=E&&a(N/(T.length-1))});let G=new ye(new Ie(0,y),new Ie(1,y)),H=new ye(new Ie(0,E),new Ie(1,E));for(let I=0;I<T.length-1;I++){let N=new Ie(I/(T.length-1),T[I]),v=N.y<y?1:N.y>E?2:3;for(let L=0;L<T.length;L++){let _=new Ie(L/(T.length-1),T[L]),B=_.y<y?1:_.y>E?2:3;v!==B&&(v===1?B===2?(o(new ye(N,_),G),o(new ye(N,_),H)):o(new ye(N,_),G):v===2?B===1?(o(new ye(N,_),G),o(new ye(N,_),H)):o(new ye(N,_),H):B===1?o(new ye(N,_),G):o(new ye(N,_),H))}}M!==0&&(c=c.clip(M)[1]),k!==1&&(c=c.clip((k-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 I of c.controls){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(Re.less(N,b))w=w|1;else if(Re.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let I=new Ie((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(I)&&(ui[n++]=I.x,ui[n++]=I.y)}continue}if(k-M>.8){let[I,N]=c.clip(.5);i.push([I,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)oe[a]=ui[a];return n}function n$(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(I){M=Math.min(M,I),k=Math.max(k,I)},o=function(I,N){let v=Su(I,N);if(v===0)throw new Error("cnt === 0");for(let L=0;L<v;L+=2)a(oe[L])};if(n>r){for(let I=n-2;I>=2;I-=2)for(let N=I-2;N>=0;N-=2)if(Re.eq(ui[I],ui[N])&&Re.eq(ui[I+1],ui[N+1])){ui[N]=(ui[I]+ui[N])/2,ui[N+1]=(ui[I+1]+ui[N+1])/2;for(let v=n-3;v>=I;v--)ui[v]=ui[v+2];n-=2;break}if(n>r){n=0;let I=new Float64Array(8),N=t.end(),v=0;e.getPercent(N)!==null&&(I[n++]=N.x,I[n++]=N.y,v=2);let L=e.end();return t.getPercent(L)!==null&&(I[n++]=L.x,I[n++]=L.y,v=v===0?1:3),oe.set(I),{havOverlap:v,cnt:n}}}let[l,c]=i.pop(),u=l.controls,h=c.controls;if(u.length===2&&h.length===2){let I=Su(new ye(u[0],u[1]),new ye(h[0],h[1]));for(let N=0;N<I;N++)ui[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,x=Math.sqrt(1/(f**2+m**2));f*=x,m*=x,g*=x;let y=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY;if(u.forEach(I=>{let N=f*I.x+m*I.y+g;N<y&&(y=N),N>E&&(E=N)}),Re.eq(y,E)){if(c.controls.length===2){let I=Su(new ye(l.start(),l.end()),new ye(c.start(),c.end()));for(let N=0;N<I;N++)ui[n++]=oe[N];if(I!==0)continue}l=new pt([u[0],u[u.length-1]]),u=l.controls}let T=h.map(I=>{let N=f*I.x+m*I.y+g,v=Math.abs(N);return v<s&&(s=v),N}),w=0;for(let I of T){if(Re.less(I,y))w=w|1;else if(Re.greater(I,E))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let b=0,C=0,A=p.x-d.x,R=p.y-d.y,O=Math.sqrt(1/(A**2+R**2));A*=O,R*=O;for(let I=1;I<u.length;I++){let N=u[I],v=(N.x-d.x)*A+(N.y-d.y)*R;v<b?b=v:v>C&&(C=v)}w=0;for(let I of h){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(Re.less(N,b))w=w|1;else if(Re.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w!==3)continue;let M=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY;s/=2,s<=Re.eps&&(s=Re.eps),y-=s,E+=s,T.forEach((I,N)=>{I>=y&&I<=E&&a(N/(T.length-1))});let G=new ye(new Ie(0,y),new Ie(1,y)),H=new ye(new Ie(0,E),new Ie(1,E));for(let I=0;I<T.length-1;I++){let N=new Ie(I/(T.length-1),T[I]),v=N.y<y?1:N.y>E?2:3;for(let L=0;L<T.length;L++){let _=new Ie(L/(T.length-1),T[L]),B=_.y<y?1:_.y>E?2:3;v!==B&&(v===1?B===2?(o(new ye(N,_),G),o(new ye(N,_),H)):o(new ye(N,_),G):v===2?B===1?(o(new ye(N,_),G),o(new ye(N,_),H)):o(new ye(N,_),H):B===1?o(new ye(N,_),G):o(new ye(N,_),H))}}M!==0&&(c=c.clip(M)[1]),k!==1&&(c=c.clip((k-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 I of c.controls){let N=(I.x-d.x)*A+(I.y-d.y)*R;if(Re.less(N,b))w=w|1;else if(Re.greater(N,C))w=w|2;else{w=3;break}if(w===3)break}if(w===3){let I=new Ie((q.minX+q.maxX)/2,(q.minY+q.maxY)/2);l.getPercent(I)&&(ui[n++]=I.x,ui[n++]=I.y)}continue}if(k-M>.8){let[I,N]=c.clip(.5);i.push([I,l]),i.push([N,l])}else i.push([c,l])}for(let a=0;a<n;a++)oe[a]=ui[a];return{cnt:n}}var s$=class{constructor(e=Re.eps){this.eps=e}eq(e,t){return Math.abs(e-t)<=this.eps}setEps(e){this.eps=e}},qy=new s$;function qM(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(!(qy.eq(ui[c],ui[u])&&qy.eq(ui[c+1],ui[u+1]))){l(ui[u],ui[u+1],o);break}function l(c,u,h){let d=!1;for(let p=0;p<h.length;p+=2)if(qy.eq(c,h[p])&&qy.eq(u,h[p+1])){d=!0;break}d||h.push(c,u)}},o=[ui[0],ui[1]];if(a(),o.length>=100&&(qy.setEps(.001),o=[ui[0],ui[1]],a(),o.length>=100))throw new Error("clearSamePoint()");n=o.length,o.forEach((l,c)=>ui[c]=l)}let s=i.pop();if(s[0]instanceof Le){let a=function(H){R=Math.min(R,H),O=Math.max(O,H)},o=function(H,q){let I=Su(H,q);if(I===0)throw new Error("cnt === 0");for(let N=0;N<I;N+=2)a(oe[N])},[l,c]=s,u=c.controls;if(u.length===2){let H=YA(l,new ye(u[0],u[1]));for(let q=0;q<H;q++)ui[n++]=oe[q];continue}let h=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,p,f,m,g,x;if(Math.abs(l.sweepAngle)>359){let H=l.rx;p=l.center.add1(H,0),f=l.center.add1(-H,0),h=-H,d=H,m=0,g=1,x=-l.center.y}else{p=l.start(),f=l.end(),m=f.y-p.y,g=p.x-f.x,x=-m*p.x-g*p.y;let H=Math.sqrt(1/(m**2+g**2));m*=H,g*=H,x*=H;let q=m*l.center.x+g*l.center.y+x;l.isCCW?(d=l.rx+q,h=0):(h=q-l.rx,d=0)}let y=u.map(H=>m*H.x+g*H.y+x),E=0;for(let H of y){if(Re.less(H,h))E=E|1;else if(Re.greater(H,d))E=E|2;else{E=3;break}if(E===3)break}if(E!==3)continue;let T=0,w=0,b=f.x-p.x,C=f.y-p.y,A=Math.sqrt(1/(b**2+C**2));if(b*=A,C*=A,Math.abs(l.sweepAngle)<=180)T=0,w=(f.x-p.x)*b+(f.y-p.y)*C;else throw new Error("not support");E=0;for(let H of u){let q=(H.x-p.x)*b+(H.y-p.y)*C;if(Re.less(q,T))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 R=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;h-=Re.eps,d+=Re.eps,y.forEach((H,q)=>{H>=h&&H<=d&&a(q/(y.length-1))});let M=new ye(new Ie(0,h),new Ie(1,h)),k=new ye(new Ie(0,d),new Ie(1,d));for(let H=0;H<y.length-1;H++){let q=new Ie(H/(y.length-1),y[H]),I=q.y<h?1:q.y>d?2:3;for(let N=0;N<y.length;N++){let v=new Ie(N/(y.length-1),y[N]),L=v.y<h?1:v.y>d?2:3;I!==L&&(I===1?L===2?(o(new ye(q,v),M),o(new ye(q,v),k)):o(new ye(q,v),M):I===2?L===1?(o(new ye(q,v),M),o(new ye(q,v),k)):o(new ye(q,v),k):L===1?o(new ye(q,v),M):o(new ye(q,v),k))}}R!==0&&(c=c.clip(R)[1]),O!==1&&(c=c.clip((O-R)/(1-R))[0]);let G=c.bbox();if(Re.eq(G.minX,G.maxX)&&Re.eq(G.minY,G.maxY)){E=0;for(let H of c.controls){let q=(H.x-p.x)*b+(H.y-p.y)*C;if(Re.less(q,T))E=E|1;else if(Re.greater(q,w))E=E|2;else{E=3;break}if(E===3)break}E===3&&(ui[n++]=(G.minX+G.maxX)/2,ui[n++]=(G.minY+G.maxY)/2);continue}O-R>.8?c.clip(.5).forEach(H=>i.push([H,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]=ui[s];return n}var a$=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 o$(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)}),a$.getSweep(n)}var l$=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?vi.build2(r):null}static zoomPolygon(e,t){let i=new Array,r=new Array,n=new Array;return o$(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?vi.build2(r):null}static zoomLines(e,t){return this.zoomPolygon(vi.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(ql(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=ql(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=ql(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=ql(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")}},Yt=.001,Da=Yt**2;function vt(e,t){return e.distance2(t)<Da}function vu(e,t){return Math.abs(e-t)<=1e-4}function c$(e,t){if(e instanceof ye)return new ye(e.start(),t);if(e instanceof Le){let i=t.angleD(e.center);return vu($t.regularD(e.startAngle),$t.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 pt)return e.clip(e.getPercent(t,Yt))[0];throw new Error("not supported operation")}}function Oc(e,t=$t.toRadians(e.startAngle)){return e.isCCW?t+=B2:t-=B2,new Ie(Math.cos(t),Math.sin(t))}function c1(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 ng(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,Yt)!==null||new ye(i.start(),i.end()).distance(n)<=Yt)&&(n=e[r+2]),!n)throw Error("getSecondPoint(controls: readonly Vector2[])");return n}function Ut(e,t){if(e instanceof ye)return e.end().sub(e.start()).normalize();if(e instanceof Le)return(t?Oc(e,t.angle(e.center)):Oc(e)).normalize();if(e instanceof pt)if(e.controls.length===2){let[i,r]=e.controls;if(vt(i,r))throw Error("equalsPP(p0, p1)");return r.sub(i).normalize()}else return(t?c1(e,e.getPercent(t,Yt)):c1(e)).normalize();else throw new Error("not support")}function u$(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 h$(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)>Yt;)if(c=(n+s)/2,u=e*Math.pow(c,3)+t*Math.pow(c,2)+i*c+r,Math.abs(u)<Yt){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 TA(e,t,i){if(e instanceof ye||t.distance2(i)<=Da)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 pt){let r=e.getPercent(t,Yt),n=e.getPercent(i,Yt);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function HA(e){return Re.greater(e,0)&&Re.less(e,1)}function F2(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 HA(a)&&o.push(a),o}function G2(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 HA(a)&&h.push(a),HA(s)&&h.push(s),h}function I4(e,t){if(e.controls.length===2){let[o,l]=e.controls;vt(o,l)||t.push(new ye(o,l));return}let i,r;if(e.controls.length===3){let[o,l,c]=e.controls;i=F2(o,l,c,"x"),r=F2(o,l,c,"y")}else{let[o,l,c,u]=e.controls;i=G2(o,l,c,u,"x"),r=G2(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 d$=1e-5,nC=1,pt=class za extends p1{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 sg(t,(r,n)=>(i.push(n),!0)),new za(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 za.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 za(i),new za(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,x){let y=Su(g,x);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,x)=>{let y=Math.abs(x);return y<g?y:g},r),r/=2,r<=i&&(r=i),d.forEach((g,x)=>{this.eq(g,0,i)&&s(x/(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 x=new Ie(g/(d.length-1),d[g]),y=this.less(x.y,0,i)?1:this.greater(x.y,0,i)?2:3;for(let E=0;E<d.length;E++){let T=new Ie(E/(d.length-1),d[E]),w=this.less(T.y,0,i)?1:this.greater(T.y,0,i)?2:3;y!==w&&(y===1?w===2?(a(new ye(x,T),p),a(new ye(x,T),f)):a(new ye(x,T),p):y===2?w===1?(a(new ye(x,T),p),a(new ye(x,T),f)):a(new ye(x,T),f):w===1?a(new ye(x,T),p):a(new ye(x,T),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,x)=>g.ext2(x),new Oo).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,x]=o.clip(.5);g.isInRange(t,i)?(n.push([g,l,(l+c)/2]),x.isInRange(t,i)&&n.push([x,(l+c)/2,c])):n.push([x,(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 Oo().ext3(this.points(.1)).build1()),this._bbox}bboxWithControls(){return this._bbox_controls||(this._bbox_controls=new Oo().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 za(i)}stroke(t,i,r,n=nC){let s=l$.zoomLines(vi.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>d$&&!(n.distance2(za.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(za.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),x=Math.sqrt(f**2-4*p*m)/(2*p),y=g+x;y>=0&&y<=1&&c.push(za.pointOn(y,this.controls));let E=g-x;E>=0&&E<=1&&c.push(za.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(za.pointOn(d,this.controls));let p=u-h;p>=0&&p<=1&&c.push(za.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 vi.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[za.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=F2(p,f,m,"x"),c=F2(p,f,m,"y")}else if(o.length===4){let[p,f,m,g]=o;l=G2(p,f,m,g,"x"),c=G2(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(za.pointOn(u,o)),u=l.pop()||1):(d.push(za.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=u$(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),x=d.sub(h).mul(3),y=h,E=o*m.x+l*m.y,T=o*g.x+l*g.y,w=o*x.x+l*x.y,b=o*y.x+l*y.y+c,C=Math.sqrt(1/(E**2+T**2));E*=C,T*=C,w*=C,b*=C,r=h$(E,T,w,b)}else throw Error("not support getBeizerPointInLine");return r.forEach(h=>{h>=0&&h<=1&&i.push(h)}),i}reverse(){return new za(this.controls.slice().reverse())}},Bp,A4=(Bp=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 Bp.instance==null&&(Bp.instance=new Bp),Bp.instance}},Bp.instance=null,Bp),ye=class Fp extends p1{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 Fp(this._start,t);return i._a=this._a,i._b=this._b,i._c=this._c,i}return new Fp(this._start,t)}get midPoint(){return this._start.add(this._end).mul(.5)}toBezier(){return new pt([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 Fp(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=A4.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 Ia(t[0],t[1],t[2],t[3])}return this.__bbox}multiply3(t){return new Fp(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 _c(i,r)||_c(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=vi.build5([u,-l,u,l,h,l,h,-l]):c=vi.build5([u,l,u,-l,h,-l,h,l]):r===0?c=vi.build2([Le.build3(new Ie(u,0),-90,-180,l,l),Le.build3(new Ie(h,0),90,-180,l,l)]):c=vi.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=Kn.rotate(d).translate1(n);return c.asClose().multiply3(p)}points(t){return[this._start,this._end]}mirrorY(t){return new Fp(this.start().mirrorY(t),this.end().mirrorY(t))}reverse(){return new Fp(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,x=f+m.y*i/2,y=g*g+x*x,E=c*c+u*u,T=h*h+d*d,w=Math.abs(c*f-u*p)/2,b=Math.sqrt(p*p+f*f)*i/4;if(w<=b&&E<=y&&T<=y){if(l)return!0;{let C=new Ie(n,s).sub(o).normalize(),A=new Ie(n,s).sub(a).normalize(),R=new Ie(m.x,m.y).cross(C),O=new Ie(m.x,m.y).cross(A);return R>=0&&O<=0}}else if(l){let C=i/2;return E<=C*C?!0:T<=C*C}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 p$(e,t=.05){if(e.length<3)return e.slice();let i=e.slice(0,1),r=(s,a,o)=>XK(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 f$=wK(SK()),m$=class{constructor(){this.fac=new Oo,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()}},g$=new m$,vi=class Hn{constructor(t,i){this.__bbox=null,this.primitives=t,this.__bbox=i}static calcBBox(t){return g$.calcBBox(t)}static build1(t){let i=[],r=null;return N2(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(GA(t))}static build3(t){let i=[],r=null;return N2(t,(n,s)=>(r!==null&&i.push(new ye(r,s)),r=s,!0)),new Hn(i)}static build4(t){return this.build3(GA(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 pt([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=f$.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 pt){let r=i.controls.map(n=>n.mirror());i=new pt(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 pt){let s=n.controls.map(a=>a.round(t));i[r]=new pt(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=p$(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())||WK(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 pt){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 Aa.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 Aa.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 pt)n=new pt(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 pt)n=new pt(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 pt){let n=r.controls.map(s=>s.mirrorY(t));r=new pt(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(_c(s,r)||_c(s.reverse(),r))return!0;n++}return!1}else return _c(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=Ia.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=Ia.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&&e$([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 pt){let l=[];I4(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 pt){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 pt){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}}},E2=Math.PI*2,Uwe=Math.PI/2,Ywe=Math.sin(Math.PI/180),y$=4,Le=class kr extends p1{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){rn.positive(r),rn.positive(n);let o=t.equals(i);if(o)return new kr(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),x=m*p+g*f,y=-g*p+m*f;r=Math.abs(r),n=Math.abs(n);let E=r*r,T=n*n,w=x*x,b=y*y,C=s===d?-1:1,A=(E*T-E*b-T*w)/(E*b+T*w);A=A<0?0:A;let R=C*Math.sqrt(A),O=R*(r*y/n),M=R*-(n*x/r),k=(l+u)/2,G=(c+h)/2,H=k+(m*O-g*M),q=G+(g*O+m*M),I=(x-O)/r,N=(y-M)/n,v=(-x-O)/r,L=(-y-M)/n,_,B;B=Math.sqrt(I*I+N*N),_=I,C=N<0?-1:1;let U=$t.toDegrees(C*Math.acos(_/B));B=Math.sqrt((I*I+N*N)*(v*v+L*L)),_=I*v+N*L,C=I*L-N*v<0?-1:1;let z=_/B,W;z<-1?W=Math.acos(-1):z>1?W=Math.acos(1):W=Math.acos(z);let ne=$t.toDegrees(C*W);!d&&ne>0?ne-=360:d&&ne<0&&(ne+=360),rn.normal(U),rn.normal(ne);let me=p*p/E+f*f/T,Ee=t.distance1(i)/2;r<Ee&&n<Ee&&(r*=Math.sqrt(me),n*=Math.sqrt(me));let Se=o?0:$t.regularD(-U),Fe=o?s?360:0:-ne;return new kr(r,n,new Ie(H,-q),Se,Fe)}}static build2(t,i,r,n,s,a){rn.positive(n),rn.positive(s),rn.normal(i),rn.normal(r);let o;return i===r?(i=$t.regularD(i),r=$t.regularD(r),o=0):(i=$t.regularD(i),r=$t.regularD(r),a===1?r<=i&&(r+=360):r>=i&&(i+=360),o=r-i),new kr(n,s,t,$t.regularD(i),o)}static build3(t,i,r,n,s){return rn.positive(n),rn.positive(s),rn.normal(r),new kr(n,s,t,$t.regularD(i),r)}static build4(t,i,r,n,s,a){let o=t.angleD(r),l=i.angleD(r);return kr.build2(r,o,l,n,s,a)}static build5(t,i,r){r=$t.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=$t.toDegrees(t.angle(u)),d=$t.toDegrees(i.angle(u));return kr.build2(u,h,d,o,o,c)}static buildCircle(t,i,r=0){return kr.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=$t.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($t.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 kr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,this.rx,this.ry)}exchangeSweepAndStart(){return kr.build1(this.end(),this.start(),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}exchangeSweep1(){return kr.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)?kr.build3(this.center.mirrorY(),0,360,this.rx,this.ry):kr.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)?kr.build3(this.center.mirror(t),0,360,this.rx,this.ry):kr.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=UA.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(Kn.ROT_90)?r=$t.regularD(this.startAngle+90):t.equals(Kn.ROT_N90)?r=$t.regularD(this.startAngle-90):r=$t.transformD(this.startAngle,t),kr.build3(this.center.multiply3(t),r,i,t.iScale*this.rx,t.iScale*this.ry)}angleIsInArc(t){return t=$t.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=$t.toRadians(this.sweepAngle)/2,n=4/3*(1-Math.cos(r))/Math.sin(r)*this.rx;return new pt([t,t.add(new Ie(n,0).multiply3(Kn.rotateD(this.startAngle+90))),i.add(new Ie(n,0).multiply3(Kn.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(kr.build3(n.center,n.startAngle,a,n.rx,n.ry),s),r(kr.build3(n.center,n.startAngle+a,a,n.rx,n.ry),s)}else t.push(n)}}buildBBox(){let t=A4.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 Ia(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 rg.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 Kn;o<0&&(o=-o,c=c.multiply3(Kn.MIRROR_Y)),l<0&&(l=-l,c=c.multiply3(Kn.MIRROR_X)),o===0&&(o=.001),l===0&&(l=.001),c=c.setOrigin1(this.center);let u,h;switch(r===this.sweep()?(u=kr.build3(this.center,this.startAngle,this.sweepAngle,s,a),h=kr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,o,l)):(u=kr.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,s,a),h=kr.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 vi.build2([u,kr.build3(p,m,d,n,n),h,kr.build3(f,g,d,n,n)])}default:return vi.build2([u,h])}}points2(){let t=Math.ceil(Math.abs(this.sweepAngle)/y$),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/$t.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/$t.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 kr(this.rx-t,this.ry-t,this.center,this.startAngle,this.sweepAngle):new kr(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),kr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new kr(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;return i<0?(i=Math.abs(i),kr.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new kr(i,i,this.center,this.startAngle,this.sweepAngle)}}get bulge(){let t=Math.abs(VK(this.sweepAngle,3))/180*Math.PI;return Math.tan(t/4)}get midPoint(){let t=$t.toRadians(this.startAngle),i=$t.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+E2-t)/2+t;return n.add(new Ie(Math.cos(a),Math.sin(a)).mul(s))}}else if(i>t){let a=(t+E2-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=$t.regularD(this.startAngle),r=$t.regularD(this.sweepAngle),n=$t.regularD(t.startAngle),s=$t.regularD(t.sweepAngle);return _c([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(_c([r,i],[s,n])||_c([$t.regularD(i+r)],[n]))}equals1(t){let i=$t.regularD(this.startAngle),r=$t.regularD(this.sweepAngle),n=$t.regularD(t.startAngle),s=$t.regularD(t.sweepAngle);return _c([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(s)])&&(_c([r,i],[s,n])||_c([$t.regularD(i+r)],[n]))}inArea(t,i){let r=t.x,n=t.y,s=this.center,a=this.rx,o=$t.toRadians(this.startAngle);this.sweep()==0&&(o=$t.toRadians(this.endAngle()));let l=$t.toRadians(this.endAngle());this.sweep()==0&&(l=$t.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+=E2),o<=l&&p>=o&&p<=l||o>l&&(p>=o&&p<=E2||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),x=r-m.x,y=n-m.y,E=r-g.x,T=n-g.y;return x*x+y*y<=i*i/4?!0:E*E+T*T<=i*i/4}}isCircle(){return(Re.eq(Math.abs(this.sweepAngle),360)||this._start.equals1(this._end))&&this.rx==this.ry}reverse(){return kr.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}},C4=new ArrayBuffer(24),wA=new Float64Array(C4),Wm=new Int32Array(C4),Hs,Hwe=(Hs=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=rn.normal(e),this.y=rn.normal(t),this.z=rn.normal(i),wA[0]=e,wA[1]=t,wA[2]=i,this.hashed=Wm[0]^Wm[1]^Wm[2]^Wm[3]^Wm[4]^Wm[5]}isZeroVector(){return this.x===0&&this.y===0&&this.z===0}hashCode(){return this.hashed}equals(e){return e instanceof Hs?e.x===this.x&&e.y===this.y&&e.z===this.z:!1}cross(e){return new Hs(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 Hs(this.x/e,this.y/e,this.z/e)}sub(e){return new Hs(this.x-e.x,this.y-e.y,this.z-e.z)}add(e){return new Hs(this.x+e.x,this.y+e.y,this.z+e.z)}scale(e){return new Hs(this.x*e,this.y*e,this.z*e)}neg(){return new Hs(-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 Hs(t/n,i/n,r/n):new Hs(t,i,r)}rotate(e,t){return this.multiply4(T4.rotateAxis(e,t))}toVector2(){return new Ie(this.x,this.y)}},Hs.ORIGIN=new Hs(0,0,0),Hs.X_UNIT_VECTOR=new Hs(1,0,0),Hs.Y_UNIT_VECTOR=new Hs(0,1,0),Hs.Z_UNIT_VECTOR=new Hs(0,0,1),Hs),On=class Qm{static build(t){return t instanceof vi?new Qm([new ns([t])]):t instanceof ns?new Qm([t]):t}static buildByPolygon(t){return t?new Qm([t]):new Qm([])}static buildByStroke(t,i,r=1,n){return this.buildByPolygon(ns.buildByStroke(t,i,r,nC,n))}static buildCircle(t,i){return this.buildByPolygon(ns.buildCircle(t,i))}static buildRect(t){return this.buildByPolygon(ns.buildRect(t))}static buildBBox(t){return this.buildByPolygon(ns.buildBBox(t))}constructor(t){this.items=t.slice()}multiply3(t){return new Qm(this.items.map(i=>i.multiply3(t)))}bbox(){return this._bbox||(this._bbox=this.items.reduce((t,i)=>t.ext1(i.bbox()),new Oo).build1()),this._bbox}toPolylineGroups(){return this.items.map(t=>t.toPolylineGroup())}},Br,Hi=(Br=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 Br(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 Br(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15);if(t==6)return new Br(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 Br(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 Br(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15,t);if(e.length==6)return new Br(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 Br(e.r,e.g,e.b,t)}static of7(e){return e==null?null:Br.of3(e)}constructor(e,t,i,r=1){this.r=rn.positiveOr0(e),this.g=rn.positiveOr0(t),this.b=rn.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 Br(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 Br(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 Br(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}},Br.WHITE=new Br(1,1,1,1),Br.BLACK=new Br(0,0,0,1),Br.RED=new Br(1,0,0,1),Br.GREEN=new Br(0,1,0,1),Br.BLUE=new Br(0,0,1,1),Br.Gray=Br.of3("#9966ff"),Br.Silver=Br.of3("#D2D2D2"),Br.Golden=Br.of3("#DCAA14"),Br.Pink=Br.of3("#ffaec9"),Br),JM=!1,D4=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(JM){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(JM){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)}},o1=class extends D4{constructor(e){super(),this.plGrps=new Array,this.debug=e}onPolylineGroup(e,t){this.plGrps.push(e)}},f1=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}},b$=e=>e!==0,x$=new class extends f1{decide1(e){return e[0]||e[1]}}(2),P2=new class extends f1{decide1(e){return e[0]&&!e[1]}}(2),_2=new class extends f1{decide1(e){return e[0]&&e[1]}}(2),SA=new class extends f1{decide1(e){return e[0]&&!e[1]||!e[0]&&e[1]}}(2),E$=(e=>(e[e.UNMARKED=0]="UNMARKED",e[e.INSIDE=1]="INSIDE",e[e.OUTSIDE=2]="OUTSIDE",e[e.INVALID=3]="INVALID",e))(E$||{}),og=class eg{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 Oo().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 Oo().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))&&(D$(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=eg.rebuild(this.shape,this.end,this.start),r=new eg(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return Aa.addAll(r.connect,this.connect),r}else return this;else if(t===1)if(this.start.y<this.end.y){let i=eg.rebuild(this.shape,this.end,this.start),r=new eg(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return Aa.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 eg?!(this.polyGrp!==t.polyGrp||this.polyIndex!==t.polyIndex):!1}bbox(){return this._bbox}toString(){return rg.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 T$(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 w$(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 qm=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=Ia.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")}},u1=class{constructor(e){this.changed=!1,this.root=new qm,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){Aa.remove(this.itemList,e),this.changed=!0}clear(){this.changed=!1,this.root=new qm,this.itemList.length=0}flushWhenNeed(){if(this.changed){let e=new Array;for(let t of this.itemList)e.push(new qm(t));for(;;){let t=this.organize(e);if(t.length>1)e=t;else break}this.root=new qm(e),this.changed=!1}}organize(e){jp(e,w$,0,e.length);let t=e.length,i=[];for(let r=0;r<t;)if(r+this.capacity2<=t){let n=r+this.capacity2;jp(e,T$,r,n);for(let s=r;s<n;s+=this.capacity){let a=new qm(e.slice(s,s+this.capacity));i.push(a)}r=r+this.capacity*this.capacity}else{let n=new qm(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 vA(e,t){S$(e.iterator(),t)}function S$(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var T2=new Error("list is empty"),w2=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}},v$=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")}},I$=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")}},Up=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 T2;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw T2;return this.remove(e),e.item}addLast(e){return this.first===null||this.last===null?(this.first=new w2(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 w2(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 T2;return this.first.item}getLast(){if(this.last===null)throw T2;return this.last.item}insertAfter(e,t){let i=new w2(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new w2(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 v$(this.first)}listIterator(){return new I$(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 IA(e){throw new Error("")}var S2=class{constructor(e,t){this.node1=null,this.node2=null,this.key=e,this.value=t}},A$=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},C$=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},U2=class{constructor(){this.innerList=new Up,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 S2(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 S2){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 Up;return n.node2=s.add(n),r.node2=s.add(r),this.innerMap[i]=s,null}}if(n instanceof Up){let s=null;return vA(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 IA(n)}get(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof S2)return i.key.equals(e)?i.value:null;if(i instanceof Up){let r=null;return vA(i,(n,s)=>s.key.equals(e)?(r=s.value,!1):!0),r}return IA(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 S2)return i.key.equals(e)?(this.delete(i),i.value):null;if(i instanceof Up){let r=null;return vA(i,(n,s)=>s.key.equals(e)?(r=s.value,this.delete(s),!1):!0),r}return IA(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 A$(this.innerList.iterator())}values(){return new C$(this.innerList.iterator())}entries(){return this.innerList.iterator()}},ag=class{constructor(){this.innerMap=new U2}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)}}},KM=Aa.funcCopy(jp);function D$(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=qK(e.shape,t);else if(e.shape instanceof Le)i=JK(e.shape,t);else throw new Error("not supported operation");return i}var L2=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 u1(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));KM(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);KM(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=og.rebuild(e.shape,a,o);l instanceof Le&&Math.abs(l.sweepAngle)>190&&(l=new ye(a,o));let c=new og(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 ag;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=ql(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)}}}}}}},P$=class P4{constructor(t){this.sides=new ag,this.others=new ag,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 sg(this.sides,(i,r)=>(t.push(r.shape),!0)),vi.build2(t).asClose()}hashCode(){return this.id}equals(t){return t!=null&&t instanceof P4?this.id===t.id:!1}},_4=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=$t.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 og(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++)):(r=new og(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++),this.firstSide=r),this.prevSide=r,this.sides.push(r)}},L4=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}},Y2=new Error,$M=new class extends f1{decide1(e){return e[0]&&e[1]}}(2),_$=new class extends D4{onPolylineGroup(e,t){throw Y2}onSegment(e,t,i,r,n,s){throw Y2}},L$=class{constructor(e,t){this.rtree=e,this.level=t}},O$=class O4 extends L2{static isIntersect(t,i,r=z2.DUMMY){let n=new O4(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 _4(!1),$M.rule,t,_$)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=$M.weight(i);for(let s of t)this.addPolyline(s,r);let n=this.buildRTree();return this.sides.length=0,new L$(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===Y2)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,ql(r.shape,s.shape)>0)throw Y2}}sweep(t,i,r){let n=Ia.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),jp(s,(o,l)=>o.getX(r)-l.getX(r),0,s.length);let a=new L4(this.rule,this,r);for(let o of s)a.onEp(o)}},sC=class hh{constructor(t){this.items=new Array(t.length),Aa.arraycopy(t,0,this.items,0,t.length),this.__bbox=this.calcBBox()}static build1(t){let i=[];return N2(t,(r,n)=>(i.push(n),!0)),new hh(i)}static build2(t){let i=t.map(r=>vi.build8(r));return new hh(i)}static combinePolylineGroupArr(t){let i=[];for(let r of t)i=i.concat(r.items);return new hh(i)}calcBBox(){let t=new Oo;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 hh(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 hh?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;O$.isIntersect(new hh([a]),new hh([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 hh(i)}},R$=Aa.funcCopy(jp),N$=Aa.funcCopy(jp),M$=Aa.funcCopy(jp);function B$(e){return new Array}function k$(e,t){let i=new o1(!1),r=new l1(e,z2.DUMMY,i);for(let n of t)r.addPolyline(n);return r.simplify(),i.plGrps}var l1=class extends L2{constructor(e,t,i){super(new _4(!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,R$(t,L2.sortByBBoxMinY,0,t.length);let r=new Up;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 L4(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),x=Math.min(s,m);l=this.compareBySweep(t,u,(g+x)/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(Kn.ROT_N90),a=n.start.multiply3(Kn.ROT_N90),o=n.end.multiply3(Kn.ROT_N90);n=new og(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(Kn.ROT_90),n=e.start.multiply3(Kn.ROT_90),s=e.end.multiply3(Kn.ROT_90),a=new og(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 U2,t=new u1(10);for(let s of this.finalSides)e.computeIfAbsent(s.start,B$).push(s),t.add(s.start);let i=0,r=new ag,n=new Array;for(let s of this.finalSides)if(!r.contains(s)){let a=new ag,o=s.start,l=new Up;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 P$(t);sg(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 U2;for(let r in this.sideGroups){let n=this.sideGroups[r];sg(n.sides,(s,a)=>(a.polyGrp!=-2&&t.put(a,a),!0))}let i=new ag;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;sg(l.others,(h,d)=>{let p=t.get(d);return p!=null&&c.push(p.finalGrp),!0}),N$(c,Aa.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());M$(o,L2.sortByBBoxAreaDesc,0,o.length),this.event.onPolylineGroup(new sC(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}},F$=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 pt)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,$t.toRadians(a.startAngle),$t.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}}},Jy,m1=(Jy=class{constructor(e){this.map=new U2,this.bus=e}initColor(e){return this.map.computeIfAbsent(e,()=>new F$)}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 Jy(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 Ia)this.bbox(e,t);else if(e instanceof p1)this.primitive(e,t);else if(e instanceof vi)this.polyline(e,t);else if(e instanceof ns)this.polygon(e,t);else if(e instanceof On)this.group(e,t);else if(e instanceof sC)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||"==================")}},Jy.colorBuffersMap=[[!0,Hi.BLUE],[!0,Hi.GREEN],[!0,Hi.WHITE],[!0,Hi.RED],[!0,Hi.Golden],[!0,Hi.Gray]],Jy.t1=0,Jy),G$=0,g1=class jA{constructor(t,i){this.inters=[],this.shape=t,this.start=t.start(),this.end=t.end(),this.judgeOverlapMap=new Map,i&&(this.id=G$++)}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 pt){let a=this.shape.getPercent(t,Yt);return pt.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=X2-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 jA.finalAngle(i,a,r)-jA.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 pt){let t=this.shape;this.inters.sort((i,r)=>t.getPercent(i.coord,Yt)-t.getPercent(r.coord,Yt)<=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(vi.build7(o))}),i.push(new ns(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(vi.build7(o))}),i.push(new ns(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 pt){let s=t.getPercent(i,Yt),a=t.clip(s)[1];n=a.clip(a.getPercent(r,Yt))[0]}else throw new Error("not supported operation");return Ut(t,i).dot(Ut(n,i))<0?null:n}static returnPolyline(t){return vi.build7(t.map(i=>i.shape))}bbox(){return this.shape.bbox()}},U$=(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))(U$||{});function Ca(e,t,i){if(e instanceof Le&&t instanceof Le)return j$(e,t);if(e instanceof Le&&t instanceof ye)return e4(e,t);if(e instanceof ye&&t instanceof Le)return QM(e,t);if(e instanceof ye&&t instanceof ye)return Hp(e,t);if(e instanceof pt&&t instanceof ye)return e.controls.length===2||mh(e)?Hp(new ye(e.start(),e.end()),t):R4(e,t);if(e instanceof ye&&t instanceof pt)return t.controls.length===2||mh(t)?Hp(e,new ye(t.start(),t.end())):VA(e,t);if(e instanceof Le&&t instanceof pt)return t.controls.length===2||mh(t)?e4(e,new ye(t.start(),t.end())):Y$(e,t);if(e instanceof pt&&t instanceof Le)return e.controls.length===2||mh(e)?QM(new ye(e.start(),e.end()),t):H$(e,t);if(e instanceof pt&&t instanceof pt)return aC(e,t);throw new Error("not support")}function Jm(e,t){return Ut(e,t.start()).dot(Ut(t,t.start()))<=0?!1:Ca(e,t).state<=2}function AA(e,t){let i=t.getPercent(e.end(),Yt);if(i===null)return!1;if(i===0)return!0;let r=t.clip(i)[0],n=e.buildConverxHull(Yt),s=r.buildConverxHull(Yt),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(),x=f.getShape();if(g instanceof ye&&x instanceof ye){let y=m?Hp(g,x).state:d.get(Hp(x,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 g1(p)),d=h[h.length-1];return h.forEach(p=>{d.connect(p),d=p}),h}}function ZM(e,t){let i=e.end().distance2(t.center);if(i>(t.rx+Yt)**2||i<(t.rx-Yt)**2||!(vt(e.end(),t.end())||oC(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>Yt&&Eu(e,s))&&!(r-n>Yt&&e.rx+t.rx-r>Yt&&Eu(e,s+180)):!(r-n>Yt&&Eu(e,s))&&!(e.rx+t.rx-r>Yt&&Eu(e,s+180))}else{if(r+n<=Yt)return!0;let s=e.rx>t.rx?e.center.angleD(t.center):t.center.angleD(e.center);return Eu(e,s)?!1:r-n<=Yt?!0:!Eu(e,s+180)}}function Y$(e,t){let i=lC(e,t.start()).toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=aC(a,t).state,r!==0)break}return r===2&&n!==i.length-1?{state:1}:{state:r}}function H$(e,t){let i=t.toBezier2(),r,n=0;for(let s=i.length;n<s;n++){let a=i[n];if(r=aC(e,a).state,r!==1)break}return r===2&&n!==i.length-1?{state:0}:{state:r}}function aC(e,t){if(e.controls.length===2||mh(e))return t.controls.length===2||mh(t)?Hp(new ye(e.start(),t.end()),new ye(t.start(),t.end())):VA(new ye(t.start(),e.end()),t);if(t.controls.length===2||mh(t))return R4(zA(e,t.start()),new ye(t.start(),t.end()));let i=zA(e,t.start());if(mh(i))return VA(new ye(t.start(),e.end()),t);let r=AA(i,t),n=AA(t,i);if(!r&&!n){let s=n$(i,t);if(s.havOverlap){let a=s.havOverlap!==2,o=s.havOverlap!==1;return gh(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,Yt),f=t.getPercent(d,Yt);if(p===0||f===0)continue;let m=p===1?i:i.clip(p)[0],g=f===1?t:t.clip(f)[0];if(AA(m,g)){let x=Ut(e,d).cross(Ut(t,d));if(x===0){o=i.end(),l=t.end();break}return{state:x<0?3:4}}a()}return(!o||!l)&&(o=ng(i.controls,i.controls[0],t),l=ng(t.controls,i.controls[0],i)),{state:o.sub(i.controls[0]).cross(l.sub(i.controls[0]))>0?4:3}}}return gh(e,t,r,n)}function R4(e,t){let i=zA(e,t.start());if(mh(i))return Hp(new ye(i.start(),i.end()),t);let r=M4(i,t),{isIn:n,bezierIsInLeft:s}=N4(t,i);if(!r&&!n){if(s!==void 0)return{state:s?3:4};let a=null,o=e.getPercent(t.start(),Yt)+.01;for(let l=o>1?1:o;l<=1;){let c=pt.pointOn(l,e.controls);if(h1(t,c)>Da){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 gh(i,t,r,n)}function VA(e,t){let{isIn:i,bezierIsInLeft:r}=N4(e,t),n=M4(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=pt.pointOn(a,t.controls);if(h1(e,o)>Da){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 gh(t,e,i,n)}function j$(e,t){let i=ZM(lC(e,t.start()),t),r=ZM(t,e);if(!i&&!r){let n=Oc(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>Yt?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)>Yt&&n.dot(e.center.sub(t.center))>0?{state:t.isCCW?3:4,exitIsInvalid:!1}:{state:e.isCCW?3:4,exitIsInvalid:!0}}return gh(e,t,i,r)}function QM(e,t){let i=Lc.foot(e,t.center),r=e.end().distance2(t.center),n=e.end().sub(e.start()),s=(t.rx-Yt)**2,a=r<=(t.rx+Yt)**2&&r>=s&&(n.dot(i.sub(t.start()))<=0||e.start().distance2(e.end())<=e.start().distance2(i)||i.distance2(t.center)>=s)&&(vt(e.end(),t.end())||oC(t,e.end())),o=B4(t,e);if(!a&&!o){let l=e.distance2(t.center);return l<=Da?{state:n.cross(Oc(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 gh(t,e,a,o)}function Eu(e,t){return t=$t.regularD(t),e.sweepAngle>0?(t<e.startAngle&&(t+=360),e.endAngle()>t):(t>e.startAngle&&(t-=360),e.endAngle()<t)}function oC(e,t){return vt(e.end(),t)||vt(e.start(),t)||Eu(e,t.angleD(e.center))}function N4(e,t){let i=e.panDistance(Yt),r=e.panDistance(-Yt),n=t4(t,i),s=t4(t,r);if(!n.length&&!s.length)return{isIn:t.getPercent(e.end(),Yt)!==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()+Yt)break;if(l.length===2){let p=(l[1].t*10+l.shift().t*10)/20,f=pt.pointOn(p,t.controls);if(e.distance2(f)>Da)return{isIn:!1,bezierIsInLeft:e.direct.cross(f.sub(e.start()))>0}}}let c=l.length?o.distance(l[0].interP)>=e.length()+Yt:!0;return{isIn:c,bezierIsInLeft:c?void 0:e.direct.cross(l[0].interP.sub(e.start()))>0}}function M4(e,t){if(h1(t,e.end())>Da||e.getToLineMaxDis2(t)>Da)return!1;let i=z$(t,Da);return e.getToLineMaxDis2(i)<=(t.length()+Yt)**2}function B4(e,t){let i=t.end().angleD(t.start()),r=V$(t,e.end());if(r>Da)return!1;if(Eu(e,i+90)){if(Lc.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(Eu(e,i-90)){if(Lc.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<=Da&&(vt(e.end(),t.end())||XA(t,e.end()))}var k4=(Yt*2)**2;function lC(e,t){if(vt(e.end(),t))return Le.build3(e.center,e.endAngle(),0,e.rx,e.ry);if(e.start().distance2(t)<k4)return e;let i=$t.regularD(t.angleD(e.center));if(!Eu(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 zA(e,t){if(vt(e.end(),t))return new pt([t,t]);if(e.start().distance2(t)<k4)return e;let i=e.getPercent(t,Yt);if(i===null)throw new Error("!cutBezier(bezier: Bezier, p: Vector2)");return e.clip(i)[1]}function e4(e,t){let i=B4(lC(e,t.start()),t),r=t.end().distance2(e.center),n=t.end().sub(t.start()),s=Lc.foot(t,e.center),a=(e.rx-Yt)**2,o=r<=(e.rx+Yt)**2&&r>=a&&(n.dot(s.sub(t.start()))<=0||t.start().distance2(t.end())<=t.start().distance2(s)||s.distance2(e.center)>=a)&&(vt(e.end(),t.end())||oC(e,t.end()));if(!i&&!o){let l=t.distance2(e.center);return l<=Da?{state:n.cross(Oc(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 gh(t,e,i,o)}function Hp(e,t){if(vt(e.end(),t.end()))return gh(e,t,!0,!0);let i=h1(t,e.end())<=Da&&XA(t,e.end()),r=h1(e,t.end())<=Da&&XA(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 gh(e,t,i,r)}function XA(e,t){return Lc.foot(e,t).distance2(e.start())<e.end().distance2(e.start())}function gh(e,t,i,r){if(i)return r?vt(e.end(),t.end())?{state:2}:{state:0}:{state:0};if(r)return{state:1};throw new Error("!end1 && !end2")}function h1(e,t){return(e.a*t.x+e.b*t.y+e.c)**2/(e.a**2+e.b**2)}function V$(e,t){return Math.min(e.distance2(t),Lc.foot(e,t).distance2(t))}function z$(e,t){let i=e.panDistance(t),r=e.panDistance(-t);return new ye(r.start(),i.start())}function mh(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)}),vu(o,l)}function t4(e,t){let i=ql(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 xu=.01,X$=270;function vd(e){let t=xu**2,i=e.end(),r=[],n=[];for(let p=0,f=e.primitives.length;p<f;p++){let m=function(O,M){return O instanceof ye&&M instanceof ye&&Math.abs(O.direct.cross(M.direct))<Re.eps&&O.direct.dot(M.direct)>0||O instanceof Le&&M instanceof Le&&Math.abs(O.rx-M.rx)<=Re.eps&&O.center.distance2(M.center)<Re.eps&&O.isCCW===M.isCCW},g=function(O){if(nl(O,xu))n.push(null);else{if(O instanceof ye)n.push(O);else if(O instanceof Le&&O.rx===O.ry)h(O,n);else if(O instanceof pt){let M=[];I4(O,M),M.forEach(k=>{let G=k.start(),H=k.end();u(G,H)||n.push(k)})}else throw new Error("not support!");i=T}},x=function(O){if(O instanceof ye)return O.direct.x===0&&O.direct.y===0;if(O instanceof Le)return O.sweepAngle===0;if(O instanceof pt){let M=new Set(O.controls.map(G=>G.x)),k=new Set(O.controls.map(G=>G.y));return M.size===1&&k.size===1}else throw new Error("not support")},y=e.primitives[p],E=y.start(),T=y.end();if(x(y))continue;u(i,E)||(n.push(new ye(i,E)),i=E);let w=(p+1)%f,b=e.primitives[w];for(;m(y,b)&&(w=(w+1)%f,b=e.primitives[w],b!==y););if(w===(p+1)%f){g(y);continue}if(b===y){if(!(y instanceof Le)){if(Math.abs(e.area(.1))<t)return null;throw new Error("simplifyPolyline not support")}let O=y instanceof Le?y.isCCW:e.area(.1)>0;n.length=0;let M=O?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 C=(()=>{if(y instanceof ye)return(O,M)=>{let k=new ye(O,M);return nl(k,xu)?null:[k]};if(y instanceof Le)return(O,M)=>{let k;if(O.equals1(M)?k=Le.build3(y.center,y.startAngle,y.sweep()===1?360:-360,y.rx,y.ry):k=Le.build4(O,M,y.center,y.rx,y.ry,y.sweep()),nl(k,xu))return null;let G=k.pointOn(k.startAngle+k.sweepAngle/2),H=Le.build4(k.start(),G,y.center,y.rx,y.ry,y.sweep()),q=Le.build4(G,k.end(),y.center,y.rx,y.ry,y.sweep());return nl(H,xu)||nl(q,xu)?[k]:[H,q]};throw new Error("not support")})(),A=w===0;if(w<p&&!A&&(A=!C(e.primitives[0].start(),e.primitives[w-1].end()),!A)){let O=C(y.start(),e.primitives[f-1].end());if(O)n.push(...O);else{let M=C(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,b=e.primitives[p];let R=C(y.start(),b.end());if(R?(R.forEach(O=>n.push(O)),i=b.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 x=(f+1)%s;if(m=m!=null?m:n[x],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(Ut(g,g.end()).dot(Ut(m,m.start()))<0){if(!u(g.end(),m.start())){let C=new ye(g.end(),m.start());r.push(C);return}let{rebuildPrevPt:T,rebuildNextPt:w,rebuildLinkLine:b}=i4(n[(y-1+s)%s],g,new ye(g.end(),m.start()),m,n[(f+2)%s]);T&&w&&(T!==g?(n[(y+s)%s]=T,r[r.length-1]&&(r[r.length-1]=T)):w!==m&&(n[(f+1)%s]=w,r[0]===m&&(r[0]=w)),b&&r.push(b))}}}}}),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?vi.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 pt?vi.build7(a.clip(.5)):null;let o=r.map(p=>new W$(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,x=m.pt,y=x.end();if(!l.isConnected&&!y.equals(g.start())){let E=function(w){l.isConnected=!0,l.pt=g=w,l.next.isVisited=!1},T=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(x instanceof ye){u(x.start(),g.start())?f():T(new ye(x.start(),g.start()));continue}else if(g instanceof pt)if(u(y,g.end())&&!(g.controls.length!==2&&g.getToLineMaxDis2(g.startToEndL)>=t)){p();continue}else E(new pt([y,...g.controls.slice(1)]));else if(x instanceof pt)u(x.start(),g.start())&&!(x.controls.length!==2&&x.getToLineMaxDis2(x.startToEndL)>=t)?f():T(new pt([...x.controls.slice(0,-1),g.start()]));else if(g instanceof Le&&x instanceof Le)if(Math.abs(Math.abs(g.sweepAngle)-180)<Math.abs(Math.abs(x.sweepAngle)-180)){let w=Le.build5(y,g.end(),g.sweepAngle);if(u(w.start(),w.end())&&!(w.rx>=xu&&Math.abs(w.sweepAngle)>180)){p();continue}else E(w)}else{let w=Le.build5(x.start(),g.start(),x.sweepAngle);u(w.start(),w.end())&&!(w.rx>=xu&&Math.abs(w.sweepAngle)>180)?f():T(w);continue}else throw new Error("not support")}if(Ut(g,g.start()).dot(Ut(x,x.end()))<0){let E=function(b,C,A,R,O,M){if(l.next===m){l=null;return}let{rebuildLinkLine:k,rebuildPrevPt:G,rebuildNextPt:H}=i4(b,C,A,R,O);G&&H&&(G!==C&&(m.prev.pt=G),H!==R&&(l.next.pt=H),k?M.pt=k:p())},T=function(){l.next===m?l=null:(l.next.connect(m.prev),l=l.next,l.isConnected=!1,l.isVisited=!1)},w=Ca(x.reverse(),g).state;if(w===0){let b=r4(g,x.start(),g.end());if(d(b)){let C=m.prev.pt,A=l.next.pt;if(Ut(A,A.start()).dot(Ut(C,C.end()))>=0){if(T(),!l)break;continue}if(E(m.prev.prev.pt,C,b instanceof ye?b:new ye(b.start(),b.end()),A,l.next.next.pt,l),!l)break}else l.pt=b;f();continue}else if(w===1){let b=r4(x,x.start(),g.end());if(d(b)){let C=m.prev.pt,A=l.next.pt;if(Ut(A,A.start()).dot(Ut(C,C.end()))>=0){if(T(),!l)break;continue}if(E(m.prev.prev.pt,C,b instanceof ye?b:new ye(b.start(),b.end()),A,l.next.next.pt,m),!l)break}else m.pt=b;p();continue}else if(w===2){if(T(),!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())),vi.build7(r)):p instanceof pt?(u(p.start(),p.end())||r.push(new ye(p.end(),p.start())),vi.build7(r)):null}if(e=vi.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)>X$){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>=xu&&Math.abs(p.sweepAngle)>180||p instanceof pt&&p.controls.length!==2&&p.getToLineMaxDis2(new ye(p.start().add1(1,0),p.end()))>=t)}}function nl(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 pt){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 Km(e){if(e.direct.x===0&&e.direct.y===0)throw Error("getEndOfExtendLine(line: Line, distance: number)");let t=Math.abs(xu-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 i4(e,t,i,r,n){if(!e)a();else if(!n)o();else{let l=Ut(e,e.end()),c=Ut(t,e.end()),u=l.dot(c);if(u>=0)a();else{let h=Ut(r,r.end()),d=Ut(n,r.end()),p=h.dot(d);if(p>=0)o();else if(vu(u,-1)&&vu(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 pt)c=new pt([...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=nl(c,Yt)?null:c;let u;if(r instanceof ye)u=new ye(l,r.end());else if(r instanceof pt)u=new pt([l,...r.controls.slice(1)]);else if(r instanceof Le)u=Le.build5(l,r.end(),r.sweepAngle);else throw new Error("supported");r=nl(u,Yt)?null:u}function a(){if(t instanceof ye){let l=Km(i.reverse());i=new ye(l,i.end());let c=new ye(t.start(),l);t=nl(c,Yt)?null:c}else if(t instanceof pt){let l=Km(i.reverse());i=new ye(l,i.end());let c=new pt([...t.controls.slice(0,-1),l]);t=nl(c,Yt)?null:c}else if(t instanceof Le){let l=Km(i.reverse());i=new ye(l,i.end());let c=Le.build5(t.start(),l,t.sweepAngle);t=nl(c,Yt)?null:c}else throw new Error("not supported")}function o(){if(r instanceof ye){let l=Km(i);i=new ye(i.start(),l);let c=new ye(l,r.end());r=nl(c,Yt)?null:c}else if(r instanceof pt){let l=Km(i);i=new ye(i.start(),l);let c=new pt([l,...r.controls.slice(1)]);r=nl(c,Yt)?null:c}else if(r instanceof Le){let l=Km(i);i=new ye(i.start(),l);let c=Le.build5(l,r.end(),r.sweepAngle);r=nl(c,Yt)?null:c}else throw new Error("not supported")}return{rebuildPrevPt:t,rebuildNextPt:r,rebuildLinkLine:i}}function r4(e,t,i){if(e instanceof ye||t.distance2(i)<=Da)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 pt){let r=e.getPercent(t,Yt),n=e.getPercent(i,Yt);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}var W$=class{constructor(e){this.pt=e}connect(e){this.prev=e,e.next=this}};function H2(e){let t=y1(),i;if(e instanceof vi){let r=vd(e);if(r===null)return null;i=r}else if(e instanceof ns){let r=e.items.map(n=>H2(n)).filter(n=>n!==null);if(r.length===0)return null;i=new ns(r)}else{let r=e.items.map(n=>H2(n)).filter(n=>n!==null);if(r.length===0)return null;i=new On(r)}return wu.preprocessPolyline+=wd(t),i}var wu={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 y1(){return{timeIndex:Object.assign({},wu),start:performance.now()}}function n4(e){return Object.values(e).reduce((t,i)=>t+i,0)}function wd(e){return performance.now()-e.start-(n4(wu)-n4(e.timeIndex))}function _s(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=Ut(o,l.start()),u=Ut(l),h=c.cross(u);if(vu(h,0))if(o instanceof ye)if(l instanceof ye){if(Re.eq(h,0)&&(c.dot(u)>0?!vt(o.end(),l.start()):!vt(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 pt){let d=l.getExtremePoints(o),p=d.length?d[0]:ng(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?!vt(o.end(),l.start())&&o.end().sub(l.start()).dot(u)>0:!vt(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 pt)if(l instanceof ye){let d=o.getPercent(l.start(),Yt),p=o.clip(d)[1],f=p.getExtremePoints(l);return(f.length?f[0]:ng(p.controls,l.start())).sub(l.start()).cross(u)<0}else if(l instanceof pt){let d=o.getPercent(l.start(),Yt),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]:ng(p.controls,l.start()),x=m.length?m[0]:ng(l.controls,l.start()),y=g.sub(l.start()),E=x.sub(l.start());return y.cross(E)<0}else throw Error("not support");else throw new Error("not support");else return h<0}function Vp(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Le?Oc(s,$t.toRadians(s.endAngle())):s instanceof pt?c1(s,1):s.end().sub(s.start()).normalize(),l=Ut(a),c=o.dot(l);if(vu(c,-1))return _s(e,t,!0,n)?_s(e,i,r,n)&&_s(t,i,r,n):_s(e,i,r,n)||_s(t,i,r,n);{let u=o.scale(-1).angle(Ie.ORIGIN),h=l.angle(Ie.ORIGIN);u>h&&(u-=X2);let d=(u+h)/2,p=new Ie(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=Ut(f);return p.cross(m)<0?_s(e,i,r,n):_s(t,i,r,n)}}function CA(e,t,i,r,n){let s=e.getShape(),a=t.getShape(),o=s instanceof Le?Oc(s,$t.toRadians(s.endAngle())):s instanceof pt?c1(s,1):s.end().sub(s.start()).normalize(),l=Ut(a),c=o.dot(l);if(vu(c,-1))return _s(e,t,!0,n)?_s(e,i,r,n)&&_s(t,i,r,n):_s(e,i,r,n)||_s(t,i,r,n);{let u=o.scale(-1).angle(Ie.ORIGIN),h=l.angle(Ie.ORIGIN);u>h&&(u-=X2);let d=(u+h)/2,p=new Ie(Math.cos(d),Math.sin(d)),f=r?i.getShape():i.getShape().reverse(),m=Ut(f);if(p.cross(m)<0){let g=o.dot(m)<0,x=Ca(g?e.getShape().reverse():e.getShape(),f).state;return x!==3&&x!==4?_s(e,i,r,n):x===(g?4:3)}else{let g=l.dot(m)<0,x=Ca(g?t.getShape().reverse():t.getShape(),f).state;return x!==3&&x!==4?_s(t,i,r,n):x===(g?4:3)}}}var q$=(e=>(e[e.NOT_IN=0]="NOT_IN",e[e.IS_IN=1]="IS_IN",e[e.IS_OVERLAP=2]="IS_OVERLAP",e))(q$||{}),J$=(e=>(e[e.AllClear=0]="AllClear",e[e.MapClear=1]="MapClear",e))(J$||{}),Tu,Sd=!1;function sl(e,t,i,r,n,s,a,o=i.side===t,l=!0,c){return Tu=n,Sd=s,F4(G4(e,t,l,c,a,i,o,r),i,o,r,0)}function dh(e,t,i,r,n,s,a,o=r.side===i){Tu=n,Sd=s;let l=U4(e,t,i,new Map,r,o,a),c=l instanceof Array?-1:1;return F4(l,r,o,a,c)}function F4(e,t,i,r,n){for(;e instanceof Array;)n++,e.length===4?e=U4(...e,t,i,r):e=G4(...e,t,i,r);return{...e,existOverlap:n>0}}function G4(e,t,i,r,n,s,a,o){if(j2===-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 Le?Oc(l,i?c.start().angle(l.center):r?$t.toRadians(l.endAngle()):void 0):l instanceof pt?Ut(l,i?c.start():r?l.end():l.start()):l.end().sub(l.start())).normalize(),h=(c instanceof Le?Oc(c,i?void 0:(r?l.end():l.start()).angle(c.center)):c instanceof pt?Ut(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,vu(f,0))return{state:_s(e,t,!a,o)?1:0,inter:ph(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&&vt(Lc.foot(l,c.start()),r?l.end():l.start()))m=!1;else if(l instanceof Le||l instanceof pt){let g=r?l.reverse():l,x=Ca(c,c$(g,c.start()).reverse()).state;(x===1||x===2)&&(m=!1)}if(m){let g=!r;f=Ca(g?l.reverse():l,c,o).state===(g?4:3)?1:0}else r?f=Vp(e,e.nextSide,t,!a,o)?1:0:f=Vp(e.prevSide,e,t,!a,o)?1:0;return{state:f,inter:ph(e,t,s,a,i,r,n)}}else return r?{state:_s(e,e.nextSide,!0,o)?0:1,inter:ph(e,t,s,a,i,r,n),isReversed:!0}:{state:_s(e.prevSide,e,!0,o)?0:1,inter:ph(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)&&!Sd){let f=e.judgeOverlapMap.get(t);d=r?p.get(f.state):f.state}else d=Ca(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)&&!Sd){let f=t.judgeOverlapMap.get(e);d=a?p.get(f.state):f.state}else d=Ca(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 x=m.length-1;x>=0;x--){let y=m[x];if(!(f.getShape()instanceof pt)&&!vt(g,y.coord))break;if(y===s)return{state:2,inter:ph(e,t,s,a,i,r,n)}}}if(d===3||d===4)return{state:d===(r?4:3)?1:0,inter:ph(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 ph(e,t,i,r,n,s,a){if(Sd)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)&&vt(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&&vt(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,x=u(m.coord);if(g===x&&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 x=g.getBindedInter().side;if(a.get(t).mapSideList.includes(x)||vt(g.coord,x.getEnd())&&a.get(t).mapSideList.includes(x.nextSide))return d(g);if(a.has(x)){let y=t.getShape().reverse(),E=Ut(y,g.coord).dot(Ut(x.getShape(),g.coord))<0,T=E?x.getShape().reverse():x.getShape(),w=Ca(y,E?TA(T,g.coord,T.end()):TA(T,T.start(),g.coord)).state;if(w===1||w===2)return d(g)}else a.has(x.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&&vt(l.start(),i.coord))return n?m:m.getBindedInter();let g=m.getBindedInter().side,x=u(m.coord);if(g===x&&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 x=g.getBindedInter().side;if(a.get(t).mapSideList.includes(x)||vt(g.coord,g.getBindedInter().side.getEnd())&&a.get(t).mapSideList.includes(x.nextSide))return d(g);if(!a.has(x)&&a.has(x.prevSide)){let y=t.getShape().reverse(),E=Ut(y,g.coord).dot(Ut(x.getShape(),g.coord))<0;if(a.has(x.prevSide)){let T=E?x.getShape().reverse():x.getShape(),w=Ca(t.getShape(),TA(T,g.coord,T.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!==(vt(p.coord,e.prevSide.getEnd())?e.prevSide:e))return!1;let f;if(n){if(vt(p.coord,l.start()))return!0;f=Ca(s?o.reverse():o,m(l)).state}else{if(vt(p.coord,s?o.end():o.start()))return!0;f=Ca(l,m(s?o.reverse():o)).state}return f===2||f===1;function m(g){if(g instanceof ye)return vt(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 pt)return g.clip(g.getPercent(p.coord,Yt))[0];throw new Error("not supported operation")}}function d(p){let f=i.getBindedInter(),m=i.side,g=f.side,x=i===p,y=i;if(r){let E=i.getIndex()-1;for(;m;){let T=m.inters;for(;E>=0;E--)if(i=T[E],i===p){x||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(Tu===0)!i.isInvalid&&(!vt(i.coord,p.coord)||i.side===p.side&&i.getBindedInter().side===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(Tu===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 T=m.inters;for(;E<T.length;E++){i=T[E];let w=i.getBindedInter();if(i===p){x||(i.setIsInvalid(),i.isDealed(),y=i),m=null;break}else if(Tu===0)!i.isInvalid&&(!vt(i.coord,p.coord)||m===p.side&&(vt(w.side.getEnd(),i.coord)?w.side.nextSide:w.side)===p.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),y=i);else if(Tu===1){let b=w.side;a.has(m)&&a.get(m).mapSideList.includes(b)&&(i.setIsInvalid(),i.isDealed(),y=i)}}m=m==null?void 0:m.nextSide,E=0}}if(Tu===0&&!vt(f.coord,p.coord))if(n?a.has(g)?a.get(g).sideIsReversed:s:c){let E=f.getIndex()-1;for(;g;){let T=a.has(g),w=g.inters;for(;E>=0;E--){if(f=w[E],f===p.getBindedInter()){g=null;break}f.isInvalid||!T||(!vt(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 T=g.inters,w=a.has(g);for(;E<T.length;E++){if(f=T[E],f===p.getBindedInter()){g=null;break}let b=vt(g.getEnd(),f.coord)?a.has(g.nextSide):!1;f.isInvalid||!(w||b)||(!vt(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 U4(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?Oc(o,c.start().angle(o.center)):o instanceof pt?Ut(o,c.start()):o.end().sub(o.start())).normalize(),h=(l instanceof Le?Oc(l,c.start().angle(l.center)):l instanceof pt?Ut(l,c.start()):l.end().sub(l.start())).normalize(),d=u.dot(h);if(vu(d,-1)){let p=s?i.getShape().reverse():i.getShape(),f=Ut(p).normalize(),m=u.add(h.scale(-1)).normalize().dot(f),g=Ca(o.reverse(),l,a).state;if(m>-.9&&(g===3||g===4))return{state:g===4?0:1,inter:ph(t,i,n,s,!0,!1,r)};let x=sl(e,i,n,a,Tu,Sd,r.size===0?new Map:r,s);return x.state===2?x:g===4?x.state===0||x.inter!==n?x:sl(t,i,n,a,Tu,Sd,r.size===0?new Map:r,s):x.state===1||x.inter!==n?x:sl(t,i,n,a,Tu,Sd,r.size===0?new Map:r,s)}else{let p=u.scale(-1).angle(Ie.ORIGIN),f=h.angle(Ie.ORIGIN);p>f&&(p-=X2);let m=(p+f)/2,g=new Ie(Math.cos(m),Math.sin(m)),x=Ut(c).normalize(),y=x.angle(Ie.ORIGIN),E=p<y&&y<f&&o instanceof ye&&l instanceof ye&&c instanceof ye;if(g.cross(x)<=0){if(u.scale(-1).dot(x)<0){let T;return n.coord.equals1(c.start())?T=Ut(o,n.coord).dot(Ut(c,n.coord))<0:c instanceof ye&&(T=Ut(o,o.end()).dot(c.direct)<0),{state:Vp(e,t,i,!s,a)?1:0,inter:ph(e,i,n,s,!0,T,r)}}return E&&o.distance2(c.start())>Da?[t,i,!0,void 0,r]:[e,i,!0,void 0,r]}else return h.dot(x)<=0?{state:Vp(e,t,i,!s,a)?1:0,inter:ph(t,i,n,s,!0,void 0,r)}:E&&l.distance2(c.start())>Da?[e,i,!0,void 0,r]:[t,i,!0,void 0,r]}}var j2=0;function K$(e,t,i,r){let n=t.getBindedInter(),s=t.side,a=n.side,o=s.getShape(),l=a.getShape();if(r&&(j2++,j2===-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 C=dh(s,s.nextSide,a,n,c,u,r),A=C.state!==0;if(C.state===2){let O=Ut(o,t.coord).add(Ut(s.nextSide.getShape(),t.coord)).normalize(),M=Ut(l,t.coord).add(Ut(a.nextSide.getShape(),t.coord)).normalize();return b(A,O.dot(M)>0)}let R=dh(s,s.nextSide,a.nextSide,n,c,u,r);return C.state!==R.state?(w(C,R),1):b(A,C.state!==dh(a,a.nextSide,s,t,c,!0,r).state,C.inter,R.inter)}if(e===1){let C=sl(s,a,n,r,c,u,new Map),A=C.state!==0;if(C.state===2)return b(A,Ut(o,t.coord).dot(Ut(l,t.coord))>0);let R;if(C.isReversed&&C.existOverlap&&vt(C.inter.coord,a.getEnd())&&C.inter.getBindedInter().side!==s){let k=C.inter.getBindedInter().side;if(k===s.nextSide)R={state:Vp(s,k,a.nextSide,!0,r)?1:0,inter:n};else if(k===s.prevSide){if(R={state:Vp(k,s,a.nextSide,!0,r)?1:0,inter:C.inter},C.state===R.state&&t!==C.inter){let G=Ut(l,t.coord),H=Ut(a.nextSide.getShape(),t.coord),q=Ut(k.getShape(),t.coord);return b(A,G.add(H).dot(q)>0,C.inter,R.inter)}}else R=sl(s,a.nextSide,n,r,c,u,new Map)}else R=sl(s,a.nextSide,n,r,c,u,new Map);if(C.state!==R.state)return w(C,R),1;let O=Ut(l,t.coord),M=Ut(a.nextSide.getShape(),t.coord);if(vu(O.dot(M),-1)){let k=_s(a,a.nextSide,!0,r);return b(A,C.state!==sl(a.nextSide,s,t,r,c,!0,new Map,k?!A:A,!1).state,C.inter,R.inter)}else{let k=Ut(o,t.coord);return b(A,O.add(M).dot(k)>0,C.inter,R.inter)}}if(!(o instanceof pt||l instanceof pt))return 1;let h=Ut(o,t.coord),d=Ut(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 C=t.coord.angleD(l.center);p=Le.build2(l.center,C,l.startAngle,l.rx,l.ry,l.isCCW?0:1),f=Le.build2(l.center,C,l.endAngle(),l.rx,l.ry,l.isCCW?1:0)}else if(l instanceof pt){let C=l.getPercent(t.coord,Yt);[p,f]=l.clip(C),p=p.reverse()}else throw new Error("not support");let m=h.dot(d)>0,g,x;m?(g=Ca(o.reverse(),p).state,x=Ca(o,f).state):(g=Ca(o,p).state,x=Ca(o.reverse(),f).state);let y;g===0?y=sl(m?s.prevSide:s.nextSide,a,n,r,c,u,new Map,!0,!1,m):g===1?y=sl(s,a.prevSide,n,r,c,u,new Map,!0,!0,m):g===2?m?y=dh(s.prevSide,s,a.prevSide,n,c,u,r,!0):y=dh(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 b(E,m);let T;if(x===0?T=sl(m?s.nextSide:s.prevSide,a,n,r,c,u,new Map,!1,!1,!m):x===1?T=sl(s,a.nextSide,n,r,c,u,new Map,!1,!0,!m):x===2?m?T=dh(s,s.nextSide,a.nextSide,n,c,u,r,!1):T=dh(s.prevSide,s,a.nextSide,n,c,u,r,!1):m?x===3?T={inter:n,state:1}:T={inter:n,state:0}:x===3?T={inter:n,state:0}:T={inter:n,state:1},y.state===T.state)return y.inter===T.inter?(t.setIsInvalid(),0):b(E,m,y.inter,T.inter);return w(y,T),1;function w(C,A){let R=C.state!==0;if(C.inter===A.inter){t.setOutToIn(R);return}else $m(C.inter,A.inter,!0),$m(A.inter,C.inter,!1);let O=[];if(e===-1){let k=Ut(o,t.coord),G=Ut(s.nextSide.getShape(),t.coord),H=Ut(l,t.coord),q=Ut(a.nextSide.getShape(),t.coord);O.push(k.dot(H)),O.push(k.dot(q)),O.push(G.dot(H)),O.push(G.dot(q))}else{let k=Ut(o,t.coord);O.push(Ut(l,t.coord).dot(k)),O.push(Ut(a.nextSide.getShape(),t.coord).dot(k))}if(O.reduce((k,G)=>Math.abs(k)>Math.abs(G)?k:G,0)>0)if(i===1||i===0||i===2||i===3)t.setOutToIn(R);else throw new Error("not support");else if(i===1)M(!R);else if(i===0||i===2||i===3)M(R);else throw new Error("not support");function M(k){t.setIsInvalid();let G=(k?C:A).inter;delete G.isInvalid,delete G.getBindedInter().isInvalid,G.setOutToIn(!R)}}function b(C,A,R,O){if(R===O){if(t.side.outline.inters.find(G=>!G.isInvalid&&G!==t&&vt(G.coord,t.coord)))return t.setIsInvalid(),0;let M=new fh(t.coord,s,r),k=new fh(t.coord,a,r);return M.bind(k),A?s.inters.splice(t.getIndex(),0,M):s.inters.splice(t.getIndex()+1,0,M),a.inters.splice(t.getBindedInter().getIndex(),0,k),M.setOutToIn(C),t.setOutToIn(!C),M.isDealed(),s.inters.forEach((G,H)=>G.setIndex(H)),a.inters.forEach((G,H)=>G.setIndex(H)),2}else{let M=function(){let k=R.getBindedInter(),G=O.getBindedInter();delete R.isInvalid,delete k.isInvalid,delete O.isInvalid,delete G.isInvalid,R.setOutToIn(!C),O.setOutToIn(C),$m(R,O,!0),$m(O,R,!1),$m(k,G,A),$m(G,k,!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 C?0:(M(),2);if(i===0||i===2||i===3)return C?(M(),2):0;throw new Error("not support")}}}}function $m(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(!vt(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 s4=0,fh=class{constructor(e,t,i){this.id=s4++,this.coord=e,this.side=t,i&&(this.id=s4++,this.drawDebug=i);let r=new Oo;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+=B2:t-=B2,new Ie(Math.cos(t),Math.sin(t))}else{if(e instanceof pt)return c1(e,e.getPercent(this.coord,Yt));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){DA++;let r=DA===-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(Re.eq(o.distance2(l),0))return;let c=g1.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:DA,handleId:j2,boolId:t1})),new Error("inter !== this");return vd(vi.build7(e))}},DA=0,PA=class WA{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 g1(l,n)),o=a[a.length-1];return a.forEach(l=>{o.connect(l),o=l}),s?new WA(a,t,i,r,s):new WA(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(Yt).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 vi.build7(t)}};function a4(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(Yt)).filter(l=>l.bbox().extendOfSize(Yt).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 $$(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 u1(10),s=new u1(10);e.forEach(o=>o.forEach(l=>n.add(l))),t.forEach(o=>o.forEach(l=>s.add(l)));let a=a4(e,s,r);return a4(t,n,(o,l)=>r(l,o)).forEach(o=>a.push(o)),a}var Z$=class{constructor(e){this.roots=[],this.nodes=e.sort((t,i)=>t.bbox().minX-i.bbox().minX).map(t=>new Q$(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}},Q$=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 ns(r):i}else return new ns(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 o4(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 pt)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 l4(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 x=r(d);p.push(x),d.length=0}d.push(g);continue}d.push(Number(g))}d.length&&(p.push(r(d)),d.length=0);let f=vi.build7(p);o.push(f)});let l=new ns(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 pt(a)}else throw new Error("not support")}}var eZ=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 l4(this.group1Str)}getGroup2(){return l4(this.group2Str)}},_A=new z2(2),e1=class{getUnion(e,t=!0){return t&&(e=e.map(i=>this.asSameSweep([i])[0])),k$(b$,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 o1(!1),r=new l1(P2.rule,_A,i);for(let n of e){let s=P2.weight(0);r.addPolyline(n,s)}for(let n of t){let s=P2.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getIntersection(e,t){let i=new o1(!1),r=new l1(_2.rule,_A,i);for(let n of e){let s=_2.weight(0);r.addPolyline(n,s)}for(let n of t){let s=_2.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}getMutuallyExclusive(e,t){let i=new o1(!1),r=new l1(SA.rule,_A,i);for(let n of e){let s=SA.weight(0);r.addPolyline(n,s)}for(let n of t){let s=SA.weight(1);r.addPolyline(n,s)}return r.simplify(),i.plGrps}},t1=0,LA=!1;function i1(e,t,i,r,n){let s=y1(),a=[],o=[],l=[],c=new Set,u;if(n){if(u=new m1(n),t1++,LA){debugger;LA=!1;let T=new eZ;i1(T.rule,T.getGroup1(),T.getGroup2(),r,n)}if(t1===-1||LA){console.table({rule:e,group1:o4(t),group2:o4(i)}),u.clear();let T=u.initColor(Hi.GREEN),w=u.initColor(Hi.WHITE),b=u.initColor(Hi.BLUE),C=u.initColor(Hi.Gray);t.items.forEach(A=>A.items.forEach((R,O)=>{O>0?w.addPly(R):T.addPly(R)})),i.items.forEach(A=>A.items.forEach((R,O)=>{O>0?C.addPly(R):b.addPly(R)})),u.draw();debugger}}let h=t.items.length!==0&&i.items.length!==0?t.bbox().extendOfSize(Yt).intersection1(i.bbox().extendOfSize(Yt)):null;if(h){let T=[],w=[];switch(e){case 0:{for(let b of t.items)b.bbox().isIntersect(h)&&T.push(b);for(let b of i.items)b.bbox().isIntersect(h)&&w.push(b);break}case 1:case 3:{for(let b of t.items)b.bbox().isIntersect(h)?T.push(b):a.push(b);for(let b of i.items)b.bbox().isIntersect(h)?w.push(b):a.push(b);break}case 2:{for(let b of t.items)b.bbox().isIntersect(h)?T.push(b):a.push(b);for(let b of i.items)b.bbox().isIntersect(h)&&w.push(b);break}default:throw new Error("not support")}T.length!==t.items.length&&(t=new On(T)),w.length!==i.items.length&&(i=new On(w))}else{switch(e){case 0:break;case 1:case 3:{t.items.forEach(T=>a.push(T)),i.items.forEach(T=>a.push(T));break}case 2:{t.items.forEach(T=>a.push(T));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?(T,w)=>vt(T.getEnd(),w)?T.nextSide:T:(T,w)=>vt(T.prevSide.getEnd(),w)?T.prevSide:T,p=(T,w,b)=>{if(vt(T.getEnd(),b)){if(T.inters.findIndex(C=>C.getBindedInter().side===w&&vt(C.coord,T.getEnd()))===-1)return new fh(b,T,u)}else return new fh(b,T,u)},f=e===2||e===3?(T,w,b)=>{if(vt(T.getStart(),b)){if(T.inters.findIndex(C=>C.getBindedInter().side===w&&vt(C.coord,T.getStart()))===-1)return new fh(b,T,u)}else return new fh(b,T,u)}:p;r.seek(t,i,(T,w,b,C,A,R)=>{let O=o[T][w],M=l[C][A],k=O.sides[b],G=M.sides[R],H=ql(k.getShape(),G.getShape());if((k.getShape()instanceof pt||G.getShape()instanceof pt)&&H>=4){if(k.getShape()instanceof Le||G.getShape()instanceof Le){let I=function(v,L){let _=!1;for(let B=0;B<L.length;B+=2)vt(new Ie(L[B],L[B+1]),v)&&(_=!0);_||L.push(v.x,v.y)},N=[oe[0],oe[1]];for(let v=0;v<H;v+=2){let L=new Ie(oe[v],oe[v+1]);for(let _=v+2;_<H;_+=2){let B=new Ie(oe[_],oe[_+1]);if(!vt(L,B)){I(B,N);break}}}H=N.length,N.forEach((v,L)=>oe[L]=v)}else for(let I=H-2;I>=2;I-=2)for(let N=I-2;N>=0;N-=2)if(vt(new Ie(oe[I],oe[I+1]),new Ie(oe[N],oe[N+1]))){oe[N]=(oe[I]+oe[N])/2,oe[N+1]=(oe[I+1]+oe[N+1])/2;for(let v=H-3;v>=I;v--)oe[v]=oe[v+2];H-=2;break}}let q=0;if(H===4){let I=function(L){return vt(k.getEnd(),L)||vt(k.prevSide.getEnd(),L)||vt(G.prevSide.getEnd(),L)||vt(G.getEnd(),L)},N=new Ie(oe[0],oe[1]),v=()=>{let L=new fh(N,k,u),_=new fh(N,G,u);L.bind(_),L.setIsInvalid(),L.isDealed(),O.inters.push(L),M.inters.push(_)};if(oe[0]===oe[2]&&oe[1]===oe[3])if(I(N))q=2;else{v();return}}for(;q<H;q+=2){let I=new Ie(oe[q],oe[q+1]),N=k,v=G;if(vt(N.prevSide.getEnd(),I)&&(N=N.prevSide),v=d(v,I),k!==N&&G!==v){let _=e===2||e===3?G.getEnd():v.getEnd();N.getEnd().distance1(I)<_.distance1(I)?(I=N.getEnd(),vt(_,I)||(v=G)):(I=_,vt(N.getEnd(),I)||(N=k))}let L=p(N,v,I);if(L){let _=f(v,N,I);_&&(N.addInter(L),O.inters.push(L),v.addInter(_),M.inters.push(_),L.bind(_),O.intersect(M,c))}}return H},n);let m=E(),g=$$(o,l,e);g.forEach(T=>!T.startAndEndIsSameOutsideFlag()&&T.reverse()),new Z$(m.concat(g)).getPolygons().forEach(T=>a.push(T));let x=new On(a);if(u){if(t1===-1){let T=u.initColor(Hi.RED),w=u.initColor(Hi.Golden);a.forEach(b=>{T.addPly(b.items[0]),b.items.slice(1).forEach(C=>w.addPly(C))}),u.draw();debugger;throw new Error}x.id=t1}return wu.BooleanTools+=wd(s),x;function y(T,w,b){T.items.forEach(C=>{let A=[];A.push(PA.build(C.items[0],b,!0,u,C)),C.items.slice(1).forEach(R=>{A.push(PA.build(R,b,!1,u))}),w.push(A)})}function E(){let T=[];return c.forEach(b=>{e===2||e===3?b.forEach(A=>{A.isGroup1||A.reverse(),A.sides.forEach(R=>R.sortInters())}):b.forEach(A=>A.sides.forEach(R=>R.sortInters())),b.map(A=>A.sides.filter(R=>R.inters.length)).flat(2).sort((A,R)=>{let O=A.inters,M=R.inters,k=vt(O[O.length-1].coord,A.getEnd()),G=vt(M[M.length-1].coord,R.getEnd());if(k&&G){let H=0,q=0;for(let I=O.length-2;I>=0&&vt(O[I].coord,A.getEnd());I--)H++;for(let I=M.length-2;I>=0&&vt(M[I].coord,R.getEnd());I--)q++;return q-H}else return k?-1:1}).forEach(A=>{A.inters.forEach(R=>{if(R.dealed)return;let O=R.side,M=R.getBindedInter().side,k;vt(O.getEnd(),R.coord)&&vt(M.getEnd(),R.coord)?k=-1:vt(O.getEnd(),R.coord)?(k=1,R=R.getBindedInter()):vt(M.getEnd(),R.coord)&&(k=1);let G=K$(k,R,e,u);R.isDealed(),G&&(O.outline.setAllInterIsInvalidToFalse(),M.outline.setAllInterIsInvalidToFalse())})}),C(b),e===3&&(b.forEach(A=>{A.reverse(),A.sides.forEach(R=>{R.sortInters(),R.inters.forEach(O=>{O.resetVisitStatus()})})}),C(b));function C(A){A.forEach(R=>{R.inters.forEach(O=>{if(O.isInvalid||O.getVisited())return;let M=O.findStartInter(),k=w(e)?M.run():M.getBindedInter().run(),G=R.polyline.primitives;if(k){if(G.length===k.primitives.length){let H=new Set(G);if(!k.primitives.some(q=>!H.has(q))){T.push(R);return}}T.push(PA.build(k,!0,!0,u))}})})}}),T;function w(b){switch(b){case 0:case 2:case 3:return!0;case 1:return!1;default:throw Error("not support the rule")}}}}var v2=/\bstablilizetion\b/.test(self.location.href)||!0,I2={intersect(e,t,i,r){try{return i1(0,e,t,i,r)}catch(n){if(v2){let s=new e1().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 ns(a.items)))}throw n}},union(e,t,i,r){try{return i1(1,e,t,i,r)}catch(n){if(v2){let s=new e1,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 ns(l.items)))}throw n}},diff(e,t,i,r){try{return i1(2,e,t,i,r)}catch(n){if(v2){let s=new e1().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 ns(a.items)))}throw n}},xor(e,t,i,r){try{return i1(3,e,t,i,r)}catch(n){if(v2){let s=new e1().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 ns(a.items)))}throw n}}},tZ=class extends l1{constructor(e,t,i,r,n,s){super(e.rule,z2.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=ql(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)}},iZ=class extends o1{constructor(e){super(!!e),e&&(this.drawDebug=new m1(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 OA(e,t,i,r,n){let s=y1(),a=new iZ(n);new tZ(e,a,t,i,r,n).simplify();let o=[];a.plGrps.forEach(c=>{let u=c.items.map(h=>H2(h));u[0]&&o.push(new ns(u.filter(h=>h)))});let l=new On(o);return wu.BooleanTools+=wd(s),l}var RA=!0,Ky={intersect(e,t,i,r){try{return I2.intersect(e,t,i,r)}catch(n){if(RA)throw n;return console.error(n),OA(_2,e,t,i,r)}},union(e,t,i,r){try{return I2.union(e,t,i,r)}catch(n){if(RA)throw n;return console.error(n),OA(x$,e,t,i,r)}},diff(e,t,i,r){try{return I2.diff(e,t,i,r)}catch(n){if(RA)throw n;return console.error(n),OA(P2,e,t,i,r)}},xor(e,t,i,r){return I2.xor(e,t,i,r)}},rZ=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=y1(),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 x=f.items[m];if(n.isIntersect(x.bbox()))for(let y=0,E=x.primitives.length;y<E;y++){let T=x.primitives[y].bbox();n.isIntersect(T)&&a.push({bbox:T,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let o=a.length;if(o===0){wu.IntersectionSeeker+=wd(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 x=f.items[m];if(n.isIntersect(x.bbox()))for(let y=0,E=x.primitives.length;y<E;y++){let T=x.primitives[y].bbox();n.isIntersect(T)&&l.push({bbox:T,polygonIndex:d,polylineIndex:m,ptIndex:y})}}}let c=l.length;if(c===0){wu.IntersectionSeeker+=wd(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],x=l[f];i(g.polygonIndex,g.polylineIndex,g.ptIndex,x.polygonIndex,x.polylineIndex,x.ptIndex)}wu.IntersectionSeeker+=wd(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++}wu.IntersectionSeeker+=wd(s)}},Va,ia=(Va=class{static getDebug(){return Va.drawDebug||(Va.drawDebug=new m1(Va.curBus)),Va.drawDebug}static getDrawing(e=Hi.GREEN){return this.getDebug().initColor(e)}static clearDrawing(){Va.getDebug().clear()}static drawText(e,t,i=Hi.GREEN){Va.getDrawing(i).addText(e,t,1.5,.1,!0)}static drawBBox(e,t=Hi.GREEN){if(!e)return;let i=Va.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=Va.getDrawing(t);if(e instanceof vi)i.addPly(e);else if(e instanceof ns)for(let r of e.items)r instanceof vi?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}}},Va.UseRunArrange=!0,Va.UseOptimizeSplit=!0,Va.LocalBestThread=4,Va.HandleDiff=!0,Va.OcTreeSplitStep=4,Va.PrintStart=new Ie(150,-200),Va),$y=class qA{static getPolyTypeLine(t){let i=[];if(t instanceof vi)for(let r of t.primitives)i.push(r);else if(t instanceof ns)for(let r of t.items)if(r instanceof vi)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 vi)i.push(t);else if(t instanceof ns)for(let r of t.items)if(r instanceof vi)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 Oo;for(let r of t){let n=qA.getSingleBBox(r);i.ext1(n)}return i.build1()}static getSingleBBox(t){if(t instanceof Array){let i=new Oo,r=qA.getListBBox(t.slice(1));return i.ext1(r),i.build1()}else return t.bbox()}static doDrawRule(t,i=ia.PrintStart){if(t.length<2)return[i,i,i];let r=5,n=10,s=t[0],a=ia.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),ia.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);ia.drawText(d,"N:"+a);for(let p of o){let f=new ye(p,d),m=new Array;m.push(f);let g=vi.build1(GA(m));ia.drawPolyType(g,Hi.GREEN)}return[d,new Ie(c,l),new Ie(u,l)]}static drawRule(t,i=ia.PrintStart,r=!1,n){ia.clearDrawing(),this.doDrawRule(t,i),r&&this.doDrawRulePolygon(t,n),ia.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&&ia.drawText(s.bbox().UL(),s.name,a),ia.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)}},nZ=class tg{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 Ia(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=tg.createNode(i,s,p),x=tg.ocTreeSplitNode(m,g,r,n,s);if(x.length===t.length)return t;a.push(x)}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,x=o.y+u*m,y=[[],[],[],[]],E=new Array(4),T=new Array(4);T[0]=new Ia(o.x,g,x,l.y),T[1]=new Ia(g,l.x,x,l.y),T[2]=new Ia(o.x,g,o.y,x),T[3]=new Ia(g,l.x,o.y,x);for(let A of t){let R=n(A).center(),O=-1,M=-1;R.x===g?O=Math.random()>=.5?1:-1:R.x>g?O=1:R.x<g&&(O=-1),R.y===x?M=Math.random()>=.5?1:-1:R.y>x?M=1:R.y<x&&(M=-1),O===1&&M===1?y[1].push(A):O===1&&M===-1?y[3].push(A):O===-1&&M===-1?y[2].push(A):O===-1&&M===1&&y[0].push(A)}for(let A=0;A<4;A++){let R=y[A];if(R.length<=0)continue;let O=new Oo;for(let M of R)O.ext1(n(M));E[A]=O.build1()}let w=0,b=0;for(let A of E)A&&(w+=A.area());b=w;let C=(A,R)=>{if(!E[A]||!E[R])return 0;let O=E[A].intersection1(E[R]);return O?O.area():0};b-=C(0,1),b-=C(0,2),b-=C(0,3),b-=C(1,2),b-=C(1,3),b-=C(2,3),b/w>=h&&(d=y,p=T)}for(let f=0;f<d.length;f++){let m=d[f];if(m.length<=0)continue;let g=p[f],x;if(m.length===t.length?x=tg.ocTreeSplitNode(m,g,r,n):x=tg.ocTreeSplitNodeMinIntersect(m,g,r,n),x.length===t.length)return t;s.push(x)}return s}static ocTreeSplit(t,i,r,n){return tg.ocTreeSplitNode(t,i,r,n,ia.OcTreeSplitStep)}},sZ=class Y4{static simplifyRules(t,i){return ia.UseOptimizeSplit&&(t=this.optimizeSplit(t,i)),t}static OcTreeOptimizeSplit(t){let i=t[0];if(i!==1||t.length<=ia.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=$y.getListBBox(r),a=nZ.ocTreeSplit(n,s,ia.LocalBestThread,c=>{let u=t[c];return $y.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(ia.HandleDiff){let s=t[1],a;if(Array.isArray(s)){let o=this.optimizeSplit(s,i);if(o.length<=1)return[2];a=JA(o,i)}else a=JA([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=$y.getListBBox([...c.slice(1)]);$y.KeepBBoxPolygonGroup(u,a)&&o.push(c)}else $y.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>ia.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=Y4.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}},aZ=(e=>(e[e.INTERSECT=0]="INTERSECT",e[e.UNION=1]="UNION",e[e.DIFF=2]="DIFF",e[e.XOR=3]="XOR",e))(aZ||{});function r1(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=r1(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=r1(s),!s)||i.push(s)}break;case 2:let r=e[1];if(Array.isArray(r)&&(r=r1(r)),!r)return null;i.push(r);for(let n=2;n<e.length;n++){let s=e[n];Array.isArray(s)&&(s=r1(s),!s)||i.push(s)}break;default:throw new Error("not support boolean rule!")}return i.length===1?null:i}function NA(e,t,i){return Array.isArray(e)?H4(e,t,i):e}function MA(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]=NA(e[s],t,i);switch(e[0]){case 0:return MA(n,Ky.intersect,t,i);case 1:return MA(n,Ky.union,t,i);case 2:let s=MA(n.slice(1),Ky.union,t,i);return s?Ky.diff(n[0],s,t,i):n[0];case 3:let a=NA(e[1],t,i);for(let o=2;o<e.length;o++)a=Ky.xor(a,NA(e[o],t,i),t,i);return a;default:throw new Error("not support boolean rule! "+e[0])}}function j4(e){let t=[e[0]];for(let i=1;i<e.length;i++){let r=e[i];if(Array.isArray(r)){let n=j4(r);Array.isArray(n)?n.length>1&&t.push(n):t.push(n)}else{let n=H2(r);n!==null&&t.push(On.build(n))}}return t}function oZ(e,t){ia.curBus=t,e=j4(e);let i;return ia.UseRunArrange?i=sZ.simplifyRules(e,t):i=r1(e),i.length<=1?new On([]):JA(i,t)}function JA(e,t,i=!0){if(!e||e.length===1)return new On([]);let r=e,n=new rZ,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 A2=new Error("list is empty"),C2=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}},lZ=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")}},cZ=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")}},uZ=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 A2;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw A2;return this.remove(e),e.item}addLast(e){if(this.first===null||this.last===null){let t=new C2(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 C2(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 A2;return this.first.item}getLast(){if(this.last===null)throw A2;return this.last.item}insertAfter(e,t){let i=new C2(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new C2(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 lZ(this.first)}listIterator(){return new cZ(this.first)}toArray(){let e=new Array,t=this.first;for(;t!=null;)e.push(t.item),t=t.next;return e}},O2=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=>vt(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=Ut(e,n),a=Ut(i.side.getShape(),n),o=Ut(r.side.getShape(),n);return s.dot(a)>s.dot(o)?i:r},void 0)}getEntryInter(){}},BA=0;function V4(e,t){let i=e.primitives[0];if(e.primitives.length===1&&i instanceof Le&&Math.abs(i.sweepAngle)===360)return[e];let r=y1();BA++;let n,s=xZ(e);if(s.length===0)return[];let a=pZ(s);if(BA===-1){n=new m1(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[vi.build7(s.map(u=>u.getShape()))];fZ(a);let o=[],l=!1;try{yZ(a,n)}catch(u){u.customType==="IS_OVERLAP"?(l=!0,o=new e1().getUnion([e]).map(h=>h.items).flat(2)):console.error(u)}if(l)return o;let c=gZ(a);if(!c.length)return[vi.build7(s.map(u=>u.getShape()))];if(o=hZ(c,n),o.length===0)return console.warn("=====deSelfIntersection=====",BA),[];if(n)throw o.forEach(u=>{n.initColor(Hi.WHITE).addPly(u),n.draw();debugger}),new Error;return wu.deSelfIntersection+=wd(r),o}function hZ(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){Re.eq(m.distance2(g),0)||l(z4(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 O2));if(g.length){let y=vd(vi.build7(g));y&&i.push(y)}let x=a.filter(y=>!(y instanceof O2));if(s=o[h].getOutInter(x[x.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=vd(vi.build7(a.filter(u=>!(u instanceof O2))));c&&i.push(c)})}),i}function dZ(e){return{next(){return e.hasNext()?{value:e.next()}:{done:!0,value:void 0}},[Symbol.iterator](){return this}}}function pZ(e){let t=[],i=new uZ;for(let r of e.slice().sort((n,s)=>n.bbox().minY-s.bbox().minY)){for(let n of dZ(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 fh(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]),x=f.distance2(m)>f.distance2(g)?m:g,y=d.prevSide;a(vt(y.getEnd(),x)?y:d,x).bind(a(p,x))},l=s.getShape(),c=r.getShape(),u=ql(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(vt(g.getEnd(),m)?g:f,m)},p=new Ie(oe[0],oe[1]);if(h&&!vt(p,s.prevSide.getEnd())&&!vt(p,r.prevSide.getEnd())&&Ut(l,p).dot(Ut(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 fZ(e){e.forEach(t=>{let i=t.side.getEnd();if(t.isInvalid||!vt(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(!vt(a.coord,i))break;a!==t&&a.getBindedInter().side===n&&a.setIsInvalid()}})}function mZ(e){let t=new u1(10);return e.forEach(i=>{i.isInvalid||t.add(i)}),t}function gZ(e){let t=[],i=mZ(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 O2(n);n.forEach(o=>{o.group=a,s.has(o.side)&&o.visitSelf(),s.add(o.side)}),t.push(a)}}),t}function yZ(e,t){e.forEach(i=>{if(i.isInvalid||i.dealed)return;let r=i.side,n=i.getBindedInter().side,s;vt(r.getEnd(),i.coord)&&vt(n.getEnd(),i.coord)?s=-1:vt(r.getEnd(),i.coord)?r.nextSide!==n&&(s=1,i=i.getBindedInter()):vt(n.getEnd(),i.coord)&&n.nextSide!==r&&(s=1),bZ(s,i,t),i.isDealed()})}function bZ(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(Jm(a.reverse(),o.reverse())||Jm(n.nextSide.getShape(),s.nextSide.getShape())){let h=dh(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=dh(n,n.nextSide,s.nextSide,r,l,c,i);h.state===d.state&&u(h,d)}else if(!(Jm(a.reverse(),s.nextSide.getShape())||Jm(n.nextSide.getShape(),o.reverse()))){let h=CA(n,n.nextSide,s,!1,i);h===CA(n,n.nextSide,s.nextSide,!0,i)&&h!==CA(s,s.nextSide,n.nextSide,!0,i)&&t.setIsInvalid()}}else if(e===1){let h=function(d,p){return Ut(d,p.start()).dot(Ut(p,p.start()))>0};if(Jm(a.reverse(),o.reverse())||Jm(a,s.nextSide.getShape())){let d=sl(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=sl(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=_s(n,s,!1,i);d===_s(n,s.nextSide,!0,i)&&d!==Vp(s,s.nextSide,new g1(z4(a,t.coord,a.end()),i),!0,i)&&t.setIsInvalid()}}function u(h,d){h.inter.setIsInvalid(),d.inter.setIsInvalid(),t.setIsInvalid()}}function z4(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 pt){let r=e.getPercent(t,Yt),n=e.getPercent(i,Yt);return e.clip(r)[1].clip((n-r)/(1-r))[0]}else throw new Error("not supported operation")}function xZ(e){let t=vd(e);if(!t)return[];let i=t.primitives.map(n=>new g1(n,null)),r=i[i.length-1];return i.forEach(n=>{r.connect(n),r=n}),i}var Zm,EZ=(Zm=class{static clearData(e){this.originalPrimitive=[],this.offsetPrimitive=[],this.rawOffsetPrimitive=[],this.offsetDistance=0,this.testI++,this.testI===0?this.drawDebug=new m1(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 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=vd(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=oZ(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(Hi.BLUE);this.rawOffsetPrimitive.forEach(c=>l.addPt(c)),this.drawDebug.draw();debugger}let o=i?this.createClippingEdge(r):[vi.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 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=t$(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=V4(vi.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=$t.regularD(n),s=$t.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=ZK(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=v4(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)}}},Zm.originalPrimitive=[],Zm.offsetPrimitive=[],Zm.rawOffsetPrimitive=[],Zm.testI=0,Zm),TZ=class n1 extends p1{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(Kn.rotateD(this.angle)))}end(){return this.start()}getLeftPoint(){return this.leftUpPoint.add(new Ie(0,-this.height/2).multiply3(Kn.rotateD(this.angle)))}getRightPoint(){return this.leftUpPoint.add(new Ie(this.width,-this.height/2).multiply3(Kn.rotateD(this.angle)))}extend(t){return new n1(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=Kn.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 Ia(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=Kn.rotateD(this.angle).translate1(i);return vi.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(Kn.rotateD(this.angle)).multiply3(t),n=new Ie(0,-this.height).multiply3(Kn.rotateD(this.angle)).multiply3(t);return t.isMirrored()?new n1(i,n.length(),r.length(),n.angleD(Ie.ORIGIN),this.isCCW===1?0:1,this.radius*r.length()/this.width):new n1(i,r.length(),n.length(),r.angleD(Ie.ORIGIN),this.isCCW,this.radius*r.length()/this.width)}reverse(){return new n1(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 vi.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.")}},wZ=.01,ns=class Pc{static simplify(t){return t=vd(t),t?new Pc([t]):null}static buildByStroke(t,i,r=1,n=nC,s){if(t instanceof Le&&(t.rx<i/2+wZ||Math.abs(t.sweepAngle)>180&&Re.lesseq(t.start().distance1(t.end()),i))){let o=V4(t.stroke(i,r,0),s);if(o.length===0)return null;if(o.length===1)return new Pc(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 Pc(l)}else if(t instanceof TZ){let o=t.stroke1(i,r,0).map(l=>vd(l));return o[0]?o[1]?new Pc(o):new Pc([o[0]]):null}let a=t.stroke(i,r,0,n);return a?this.simplify(a):null}static buildCircle(t,i){return this.simplify(vi.build7([Le.buildCircle(t,i,0)]))}static buildRect(t){return this.simplify(t.toPolyline())}static buildBBox(t){return this.simplify(vi.buildBBox(t,0))}constructor(t){this.items=t.slice()}multiply3(t){return new Pc(this.items.map(i=>i.multiply3(t)))}bbox(){return this.items[0].bbox()}isEqual(t){return t instanceof Pc?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 pt)s(u);else throw new Error("not support!");r=vi.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=[];EZ.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 Pc(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 Pc([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 Pc(h)))}return c}toPolylineGroup(){return new sC(this.items)}},SZ=(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))(SZ||{});var kA=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}},vZ=/(\.?0+)$/,KA=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(kA.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(kA.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(kA.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(vZ,"")}};function IZ(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var AZ=(e,t)=>{e===3?console.error(...t):e===2?console.warn(...t):console.log(...t)},CZ=(e,t)=>[IZ(e)].concat(t),c4=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=AZ,r=CZ){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,[KA.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,[KA.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)}};c4.DUMMY=new c4(4);var jwe=String.fromCharCode;var DZ=(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))(DZ||{}),PZ=(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))(PZ||{});var Vwe=KA.fmtNumber;var _Z=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 LZ=(e=>(e.UNIVERSAL="UNIVERSAL",e))(LZ||{}),OZ=(e=>(e.SINGLE="SINGLE",e.MULTIPLE="MULTIPLE",e))(OZ||{}),RZ=(e=>(e.NONE="NONE",e.NAME="NAME",e.NUMBER="NUMBER",e))(RZ||{}),NZ=(e=>(e.NONE="NONE",e.ZONE="ZONE",e))(NZ||{});var MZ=lg(d1());function Id(){return self.EDITOR_TOP||self}function R2(e){return self[e]=self[e]||new MZ.BroadcastChannelMessageBus(e)}var Gp=(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 BZ=lg(d1()),Fr={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"},zwe={projectUpdate:Fr.projectUpdate,personUpdate:Fr.personUpdate,projectCanSave:Fr.canSavePend,getProject:"/mgr/projectWorker/footprint/getCanvas",getPerson:"/mgr/libWorker/getFootprint",unwatch:"/mgr/projectWorker/footprint/unwatchCanvas"},Xwe={projectUpdate:Fr.projectUpdate,projectCanSave:Fr.canSavePend,getProject:"/mgr/projectWorker/pcb/getCanvas",unwatch:"/mgr/projectWorker/pcb/unwatchCanvas"},Wwe={projectUpdate:Fr.projectUpdate,projectCanSave:Fr.canSavePend,getProject:"/mgr/projectWorker/sheet/getCanvas",unwatch:"/mgr/projectWorker/sheet/unwatchCanvas"},qwe={projectUpdate:Fr.projectUpdate,getProject:"/mgr/projectWorker/schematic/getCanvas",unwatch:"/mgr/projectWorker/schematic/unwatchCanvas"},Jwe={projectUpdate:Fr.projectUpdate,projectCanSave:Fr.canSavePend,getProject:"/mgr/projectWorker/simulation/getCanvas",unwatch:"/mgr/projectWorker/simulation/unwatchCanvas"},Kwe={projectUpdate:Fr.projectUpdate,personUpdate:Fr.personUpdate,projectCanSave:Fr.canSavePend,getProject:"/mgr/projectWorker/symbol/getCanvasOnCompiler",getPerson:"/mgr/libWorker/getSymbol",unwatch:"/mgr/projectWorker/symbol/unwatchCanvas"},kZ={projectUpdate:Fr.projectUpdate,personUpdate:Fr.personUpdate,projectCanSave:Fr.canSavePend,getProject:"/mgr/projectWorker/panel/getCanvas",getPerson:"/mgr/libWorker/getPanelLib",unwatch:"/mgr/projectWorker/panel/unwatchCanvas"};var Lo={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"},cg=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}},Ed={publish:"publish",destroy:"destroy",init:"init",selected:"selected"},FZ=class{constructor(e,t,i,r=(a=>(a=Id())==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||R2(`/${this.windowId}/notify`),this.dataBus=n||this.wsBus,this._client=(a=Id())==null?void 0:a._WS_ID_}get client(){return this._client}watch(){this.dataBus.publish(Lo.send,{topic:Lo.watch,uuid:this.uuid,path:this.path})}initPublish(){var e;this.dataBus.publish(Lo.send,{topic:Lo.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Ed.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(Lo.established,e=>{this._client=e,this.watch(),this.initPublish()})),!this.client){let e=await this.wsBus.rpcCall(Lo.getWsId);if(!e||this.client)return;this._client=e}this.watch(),this.sub.push(this.wsBus.subscribe(Lo.disconnect,e=>{this.initIds[e]&&this.onDestroy(this.initIds[e],e)})),this.sub.push(this.dataBus.subscribe(Gp(Lo.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 Ed.destroy:this.onDestroy(t.userId,t.client),delete this.initIds[t.client];break;case Ed.init:this.initIds[t.client]||(this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||""));break;case Ed.selected:this.onSelected(t.user,t.client,t.data||"");break;case Ed.publish:this.dataBus.publish(Lo.send,{topic:Lo.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Ed.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(Lo.send,{topic:Lo.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Ed.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(Lo.send,{topic:Lo.unwatch,uuid:this.uuid,path:this.path,msg:{type:Ed.destroy,userId:this.user.uuid,client:this.client}});for(let e of this.sub)e.cancel();this.sub=[],this.initIds={}}}},u4=class extends FZ{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)}},GZ=class{constructor(e,t,i,r=(x=>(x=Id())==null?void 0:x._TAB_ID_)(),n=new cg,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=R2(`/${r}/notify`),s||(this._unique=Wl()),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,BZ.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=R2(`/${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(Gp(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(Fr.subMaxTick,l=>{this.consistencyManager.setMaxTicket(l.ticket,l.force)})),i&&t&&this.sub.push(this.dataBus.subscribe(Fr.subBlob,l=>{this.pushOnLine(l,"BLOB")})),i&&e&&this.sub.push(this.dataBus.subscribe(Fr.subFont,l=>{this.pushOnLine(l,"FONT")})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(Gp(Fr.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||Wl(),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(Fr.getUserL);this.selectManager=new u4(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=R2(`/${this.windowId}/libWorker`),!this.busTopic.getPerson)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");let s=i?Wl():"";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||Wl(),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(Gp(this.busTopic.personUpdate,{uuid:this.uuid}),l=>{this.pushOnLine(l,this.uuid)})),e&&this.sub.push(this.dataBus.subscribe(Gp(Gp(Fr.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(Fr.getUserL);this.selectManager=new u4(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(Fr.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=Wl();this.dataBus.publish(Fr.pushSync,e),await this.dataBus.pullA(Gp(Fr.pullASync,{id:e}))}async destroy(){return this.isDestroy?{success:!1}:(this.consistencyManager&&this.dataBus&&(this.pendPromise&&await this.pendPromise,this.dataBus.publish(Fr.pushRevoke,[this.uuid,this.uniqueId,this.consistencyManager.getClient()])),this.clear(),this.isDestroy=!0,this.isWatch&&this.dataBus&&!this.isProject&&this.dataBus.publish(Fr.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?Fr.projectSave:Fr.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(Fr.hasSaveData,{uuid:this.uuid,uniqueId:this.uniqueId})}};var UZ=(e=>(e.DIFFERENTIAL_PAIR="DIFFERENTIAL_PAIR",e.NET_CLASS="NET_CLASS",e.EQL_NET_GRP="EQL_NET_GRP",e))(UZ||{});var YZ=class extends fK{constructor(e){let t=e||new tC;super(t,1,m4),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 HZ=class{constructor(e,t,i){this.uuid=e,this.maxTicket=0,this.encodeConsistency=new hK(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),kp(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=y4(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")}}},X4=class extends HZ{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 $we=lg(d1()),Zwe=lg(d1());var W2=class extends YZ{constructor(e,t,i,r,n=(s=>(s=Id())==null?void 0:s._TAB_ID_)()){let s=new tC(Wl());super(s),this.uuid=e,this.path=t,this.isProject=i,this.windowId=n,this.encode=new _Z,this.base=new GZ(e,t,i,n,r,s,i?"PANEL":"PANEL_LIB",kZ,{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=y4(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 cC(){var t,i,r,n;return((n=(r=(i=(t=J)==null?void 0:t.profileSetting)==null?void 0:i.commSystemSetting)==null?void 0:r.SYSTEM)==null?void 0:n.dragMiddleMouseButton)==="moveCanvas"}var Wp=class Wp extends Tp{constructor(){super(...arguments);this.start=!1;this.lastX=0;this.lastY=0;this.lastMove=0;this.startX=0;this.startY=0;this.afterMidUp=lu}static setViewBox(i,r){let n=J.gZoom,s=mi.getViewBox();s[0]-=i/n,s[1]-=r/n,mi.setViewBox(s)}startGrabCanvas(i){return this.lastX=i.mouseX,this.lastY=i.mouseY,this.helperCursorBefore=J.helperCursor,xr("grabbing"),()=>{xr(),this.start=!1}}onMouseMidDown(i){i.originalEvent.preventDefault(),cC()?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(J.helperCursor=="grabbing"){let r=this.helperCursorBefore;r?this.rootcursor?xr(r,!0):xr(r):xr()}if(this.start)return this.start=!1,Wp.dragpanning=!0,setTimeout(function(){Wp.dragpanning=!1},5),Dh}onMouseMove(i){if(this.moveCanvasCore(i),this.start)return Dh}moveCanvasCore(i){(i.mouseRightMoving||i.mouseMidMoving&&cC())&&this.moveCanvas(i),i.mouseMidMoving&&!cC()&&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;Gr.canStart=!1,Wp.setViewBox(n,s),this.lastX=i.mouseX,this.lastY=i.mouseY,this.lastMove=r,new $i().updateHole()}}zoomCanvas(i){let r=performance.now();if(r-this.lastMove>8){let n=i.mouseY-this.lastY,a=J.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};Cd(+a,l),this.lastMove=r,this.lastY=i.mouseY}}};Wp.dragpanning=!1,Wp.ready=!1;var Nc=Wp;var Sg=Ug(q4());var J2=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 $i;for(let a of t.selectItems){if(a.parentId){console.warn(a);let{json:c,cmdKey:u}=F.getById(a.parentId);switch(u){case"dimensionAngle":{let h=new hn(c);h.setControlDotSelected(a.id),this.dragDimensionDots.push(h)}break;case"dimensionLength":{let h=new dn(c);h.setControlDotSelected(a.id),this.dragDimensionDots.push(h)}break;case"dimensionRadius":{let h=new tn(c);h.setControlDotSelected(a.id),this.dragDimensionDots.push(h)}break}continue}let{json:o,cmdKey:l}=F.getById(a.id);if(l==="dimension"?(this.drivingDimensions.add(o),this.selectedDimensionObjs.push(de(a.id))):this.selectedObjs.push(de(a.id)),l==="auxiliaryPoint")this.auxiliaryPoints.add(o);else if(l==="auxiliaryLine")switch(el(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 Do,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),Lt.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=Ya(),d=new Map;for(let{elements:p,combinationId:f,selectable:m}of h)for(let g of p)d.set(g,f?!m:wr.isLockedById(g));if(o!==0){for(let p of new Set([...c]))if(d.get(p)){this.abandonMove=!0;let{cmdKey:f,json:m}=F.getById(p),g=Gi[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}=F.getById(p),g=Gi[f];i.add(g+m.id.slice(1))}}this.abandonMove&&rs({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 st;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==Kt.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==Kt.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=>de(c))),this.yMoveEles=new Set(Array.from(n).map(c=>de(c)))}};var b1=class{constructor(t){this.dragContext=t}onDrag(t,i){if(!this.dragContext.abandonMove){for(let r of this.dragContext.drivingDimensions){let n=new wn(r).updateOtherP(t,i);n=null}for(let r of this.dragContext.selectedObjs)Yn.move(F.getById(r.id).json,t,i);this.dragContext.dimensionMgr.moveDimension(t,i);for(let r of this.dragContext.xMoveEles)Yn.move(F.getById(r.id).json,t,0);for(let r of this.dragContext.yMoveEles)Yn.move(F.getById(r.id).json,0,i);for(let r of this.dragContext.dragDimensionDots)r.moveControlPoint(t,i).render()}}};var x1=jZ();function jZ(){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,"-":sd?173:189,"+":sd?61:187,"[":219,"]":221,"\\":220,";":sd?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]];Qe(e,i)||(e[i]=t[n])}tE&&(sd?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)}var VZ={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"},uC=class{getCursor(){return this._cursor}switch(t){if(t!=this._cursor){if(this._cursor=t,t===4){delete J.svgRoot.dataset.cursor;return}J.svgRoot.dataset.cursor=VZ[t]}}isBoxRotateCursor(){return[9,6,8,7].includes(this._cursor)}mouseMoveCursor(t,i,r,n=!0){if(J.cmdToken||Mc())return;let s=t.target;if(Qt(s)==="cdot")return this.cDotCursor(s);let a=ts.isNearBBoxEdge(r);if(a>-1)return this.cDotCursor(de("cdot"+a));let o=Hl(i||s);if(o&&Ce.isSelected(o)&&n)return this.switch(5);let l=ts.findCanRotateControlDotInfo(r.x,r.y);return l!=null?this.boxRotateCursor(l.index,this.getBoxCDotRotation()):Dp(r.x,r.y)&&!jt.isEditingPath()?this.switch(5):this.switch(4)}cDotCursor(t){var a,o;let i=vr(),r=i[0];if(!r)return;let n=(()=>{let l=0,c=t;for(;c=c.previousElementSibling;)l++;return l})(),s=360-((o=(a=F.gJsonCache[Qt(r)])==null?void 0:a[r.id])==null?void 0:o.rotation)||0;if(i.length>1)return this.boxCDotResizeCursor(n,0);switch(Qt(r)){case"rect":case"obj":return this.boxCDotResizeCursor(n,s);case"ellipse":{let l=ei(r.rx.animVal.value,r.ry.animVal.value),c=s;return l?c=0:c=this.getBoxCDotRotation(),this.boxCDotResizeCursor(n,c)}default:jt.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=de("cdot0"),i=new V(Number(t.dataset.x),Number(t.dataset.y)),r=de("cdot1"),n=new V(Number(r.dataset.x),Number(r.dataset.y));return fr(-n.angleD(i))}},J4,yh=J4=J4||new uC;var qp=[],hC=0,K4=lu;async function $4(){let e=Date.now();for(;qp.length&&Date.now()-e<100;)await qp.shift()();let t=qp.length&&hC?1-qp.length/hC:1;K4(t),qp.length&&setTimeout($4,0)}var bh={addTask(e){return qp.push(e),bh},run(){hC=qp.length,$4()},onProgress(e){return K4=e,bh}};var dC=new WeakMap,Vn={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",Vn.onMouseMove,!1),this.on||(document.addEventListener("mousedown",Vn.onMouseDown,!1),document.addEventListener("mouseup",Vn.onMouseUp,!1),Vn.selectedObjs=vr(),this.bbox=this.outerBBox(this.selectedObjs),Vn.on=!0)},onMouseDown(e){let t=Vn,i=Ti(e,!0),r=i.x,n=i.y;if(e.button==Cw)t.lastMouseRightDownPosition={x:e.clientX,y:e.clientY},J.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;_e("editArray",[{rowSpacing:s,columnSpacing:a,row:Vn.row,column:Vn.column}]),document.removeEventListener("mousemove",Vn.onMouseMove,!1)}t.hasMoved=!1},onMouseUp(e){e.preventDefault(),e.stopPropagation();let t=Vn,i={x:e.clientX,y:e.clientY};e.button==Cw&&t.lastMouseRightDownPosition&&Zs(i,t.lastMouseRightDownPosition)&&_e("editArray",[])},onMouseMove(e){if(!Vn.followCursor)return;J.helperCursor=!0,Vn.hasMoved=!0;let t=Ti(e,!1),i=t.x,r=t.y;Vn.moveByCursor(i,r)},end(){document.removeEventListener("mousedown",Vn.onMouseDown,!1),document.removeEventListener("mouseup",Vn.onMouseUp,!1),document.removeEventListener("mousemove",Vn.onMouseMove,!1),ps(!1),this.clearPreviewItem(),Vn.on=!1,this.bbox=null,this.firstMove=!0,this.selectedObjs=[],this.hasMoved=!1,this.lastMouseRightDownPosition=null,this.followCursor=!1,J.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&&re(this.previewItems[e][t],"transform","translate("+n.columnOffset*t+","+n.rowOffset*e+")")),fn("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)dC.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)/Xe.adsorbGrid.gridSize)*Xe.adsorbGrid.gridSize,s=Math.round((r+this.bbox.width)/Xe.adsorbGrid.gridSize)*Xe.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),ps(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}=F.getById(dC.get(n).id),o;switch(a){case"rect":o=Ai.getRectFromMatrix(s).matrixArr;break;case"ellipse":o=gi.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?ct.getTransformStr(o||s):"";re(n,"transform"," translate("+t*r+","+e*i+") "+l)}},simpleClone(e){let t=[];return e.forEach(i=>{let r=i.cloneNode(!0);dC.set(r,i),t.push(r),J.gCanvas.appendChild(r)}),t},outerBBox(e){return Z4(e)},adaptAll(e,t,i,r,n){let s=Mr(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};pu(a,1)},execute(e){if(Vn.end(),!e)return;let t=vr(),i=Vn.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 st,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,x=new Map,y=[];t.forEach(E=>{bh.addTask(()=>{let{json:T,cmdKey:w}=F.getById(E.id),b=c*m,C=l*f,A,R=Zt(T),O=_t();R.gId=O,A=Us(w,R),Yn.move(R,b,C),u.push(A),x.set(E.id,O);let M=h.searchCombination(E.id);if(M&&!g.has(M)){g.add(M);let k=_t(),G=Zt(F.getCombination(M));G.gId=k,y.push(G),x.set(M,k)}})}),p.push({copiedCombination:y,oldIdMapNewId:x})}bh.addTask(()=>{this.adaptAll(t,r,n,l,c),u.forEach(f=>To(f,"selected")),p.forEach(f=>h.pasteCombination(d,f.copiedCombination,f.oldIdMapNewId)),this.clonedElements=u,Ce.select(u),_e("panel_updateAttrPanel")}),o&&bh.addTask(function(){let f=u.map(g=>{let x=F.getRefId(g.id);return zr(g.id,{cmdKey:Qt(g),refId:x},{},F.getById(g.id).json)});d.update();let m=d.getCombHistory();at.save([...f,...m])}),bh.onProgress(function(f){f=Math.min(1,Math.max(f,.01)),fn("progressUpdate",[f,"Array"])}),bh.run()}};var K2=class{constructor(t){this.elms=t;this.polymer=new Map;this.updatePolymer()}updatePolymer(){let{polymer:t}=this;this.elms.forEach(i=>{let r=Qt(i);t.has(r)?t.get(r).add(i):t.set(r,new Set([i]))})}};var $2=class{constructor(t){this.elms=t;this.elmsClassified=new K2(new Set(t)).polymer}};function zZ(e){let{json:t,cmdKey:i}=F.getById(e.id),r=F.getShapeAttr(t,i);if(Qe(r,"attr-x"))return new V(+r["attr-x"],+r["attr-y"]);if(Qe(r,"attr-start-x"))return new V(+r["attr-start-x"],+r["attr-start-y"]);console.error(r,"Plz check code")}function pC(e){let t=zZ(e),i=ol(t);return{moveX:ft(i.x,2)-t.x,moveY:ft(i.y,2)-t.y}}var Z2=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;Ey(r)||Array.isArray(r)?n=Mr([...r],!0):n=ch(r),i.set(r,n)}return i}get canEquidistantAlign(){return this.elms.size>2}get bboxs(){return Q4([...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)}}},Q2=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 eT(...e){new mC(...e).do().afterDo()}var mC=class{constructor(t,i,r){this.elms=t;this.alignCmd=i;this.refObject=r;this.context=new $2(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=pC(n[0]);if(s.moveX||s.moveY)for(let a of n)at.jsonSnap.addOne(F.getById(a.id).json),Yn.move(F.getById(a.id).json,s.moveX,s.moveY)}else{let s=pC(n);(s.moveX||s.moveY)&&(at.jsonSnap.addOne(F.getById(n.id).json),Yn.move(F.getById(n.id).json,s.moveX,s.moveY))}}rebuildAlignEdgeByCmdRefObject(t){if(!this.refObject)return;let i=ch(this.refObject),r=xt.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}=Z2.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}=Xe.adsorbGrid,c=[];for(let u of o){let h=r.get(u),{moveX:d,moveY:p}=Q2.run(t,{bbox:h,edge:n,spacing:s,gridSize:l});Ey(u)||(u=new Set([u]));for(let f of u)d===0&&p===0&&pi.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)at.jsonSnap.addOne(F.getById(f.id).json),Yn.move(F.getById(f.id).json,h,d)}}align(){this.alignCmd==="align_grid"?this.alignGrid():this.alignCommon()}do(){let t=pi.createContext(!0);return this.align(),t(),this}afterDo(){let t=Sa(this.elms.flat(1/0));Ce.select(t),t.length&&Tn(t,{create8Dots:!0}),Ki.emptyLastHoverEle().emptySelectContainer().appendSelectStroke()}};var XZ={align_top:!0,align_left:!0,align_right:!0,align_bottom:!0,align_vertical_center:!1,align_horizontal_center:!1},WZ={align_top:!1,align_left:!1,align_right:!1,align_bottom:!1,align_vertical_center:!0,align_horizontal_center:!0},xh=class xh{constructor(t,i){this.cmd=t;this.elms=i;this.pointerUp=async t=>{if(t.button!==0||!t.target)return;let i=t.target;re(i,"name")==="adsorption-point"&&(i=Lt.currentAdsorptionShapeElement);let r=Hl(i);r&&(Ce.select(r),eT(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=de(`${new.target.textElmId}`)}static isSelectRefObjectCmd(t){return XZ[t]}static async needSelectRefobject(t){return(await Ro("isCheckedSelectAlignrefObject")).message&&this.isSelectRefObjectCmd(t)}static isSelectRefObjectCmdForCenters(t){return WZ[t]}static async needSelectRefobjectForCenters(t){return(await Ro("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(){Jp(),xh.running=!0,J.cmdToken=this.cmd,this.textElm.classList.remove("hide"),this.textElm.textContent=(await Ro("i18n",xh.textContent)).message;let t=(await J.windowBridge.rpcCall("getThemeCssVariable",["--common-bg-color","--common-font-color"],Id())).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/J.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=J.gZoom,d=(t-r[0])*h+c,p=(i-r[1])*h-l-u;return{left:d,top:p}}updateTipPosition(t){let i=mi.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}=Un.data;xr("cross-red",t,n);let s=Ti(new MouseEvent("mousemove",{clientX:i,clientY:r}));fs("",s),this.updateTipPosition(s)}clearContent(){xr(),fs(),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),Lt.clearAdsorptionHTML(),tT(),this.clearContent(),xh.running=!1}};xh.instance=null,xh.running=!1,xh.textElmId="cross-text",xh.textContent="Please Select The Reference Object";var No=xh;var iT=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 qZ(this.middleware)(this.context)}handle(t){for(let i=0;i<t.length;i++)this.use(t[i]);return this.do()}};function qZ(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 Dd=JZ();function JZ(){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 eB(e,t){let{cmdKey:i,json:r}=e&&F.getById(e.id)||{};t.target.dataset.type=="handle"&&(e=t.target);let n=new iT({target:e,cmdKey:i,json:r,event:t});n.use($Z),n.use(ZZ),n.use(KZ),n.use(QZ),n.use(eQ),n.use(tQ),n.do()}function KZ({target:e,cmdKey:t,json:i},r){if(t==="dimension"){new ky().dblclickHandler(i);return}r()}function $Z({target:e,cmdKey:t},i){if(!e){if(jt.isEditingPath())return jt.endEditingPath();if(Kt.isEditing()){let r=Kt.getCurrentEditingComId();Kt.setEditing(null).selectCombinations([r])}return}i()}function ZZ({target:e,cmdKey:t},i){let r=new st,n=r.searchCombination(e.id);if(!n){i();return}if(Kt.isEditing()){let s=Kt.getCurrentEditingComId(),a=r.getAllElesfromTop(s).combinations;if(a.size===0)return i();Xt();for(let o of r.findFamily(n,s).getAllParents().reverse())if(a.has(o))return Kt.setEditing(o);i()}else{let s=r.findFamily(n).peekParent();Xt(),Kt.setEditing(s)}}function QZ({target:e,cmdKey:t},i){if(Kt.isEditing()){let r=new st().findFamily(Kt.getCurrentEditingComId()).peekParent();if(!new st().getAllElesfromTop(r).elements.has(e.id))return i()}if(["arc","group"].includes(t)&&!Ce.isUnselectAble(e.id)){jt.startEditPath(e.id),Ce.unselectAll().select([e]);return}e.dataset.type!="handle"&&i()}async function eQ({target:e,cmdKey:t,event:i},r){let n,s;if(t==="text"){if(Dd.forbiddenDataChange())return;s=(await J.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}=F.getById(e.id).json,{checked:h}=yE["all-element-type"].text;if(c||!h)return;let d="text-input-box",p="textInputBox-container",f=de(d),m=de(p);if(F.compilerManager.pauseDateMerge(),!f){let O=function(){if(l)return;l=!0;let M=n,k=new oi([M]),G=f.value.trim();if(G==="")return _o([M]);G=nN(G),new WE(M).name(G).then(function(){k.updateAndSave(),_e("panel_updateAttrPanel")})},C=["--bg-color-input","--border-color-input","--border-color-focus-input","--common-font-color","--bg-color-pop-up-content","--font-color-input"],A=(await J.windowBridge.rpcCall("getThemeCssVariable",C,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 R=document.createElement("div");R.setAttribute("class","i18n"),R.innerText=s,R.style.fontSize="12px",R.style.color=A["--common-font-color"],m.appendChild(R),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",O,!1),f.addEventListener("blur",function(){O(),setTimeout(()=>{dt(m),F.compilerManager.resumeDataMerge()},0)},!1),f.addEventListener("keydown",function(k){k.keyCode==13&&(k.preventDefault(),k.stopPropagation())}),f.addEventListener("keyup",function(M){let k=13,G=27,{keyCode:H}=M;if(M.keyCode==32&&M.stopPropagation(),H==G&&(M.stopPropagation(),setTimeout(()=>{dt(m)},0)),!M.ctrlKey&&!M.shiftKey&&!M.altKey&&H==k){if(f.value.trim().length>4096)return J.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(H===k&&M.preventDefault(),(M.ctrlKey||M.shiftKey||M.altKey)&&H==k){let v=de(re(f,"data-targetid"));if(!(Qt(v)=="text"&&v.parentNode==J.gCanvas))M.preventDefault(),M.stopPropagation();else{var q=M.currentTarget,I=q.selectionStart,N=q.selectionEnd;f.value=f.value.substring(0,I)+`
`+f.value.substring(N),q.selectionStart=I+1,q.selectionEnd=I+1}}},!1);var g=f.style.resize!==void 0;g||(function(M){var k=0,G=0,H=0,q=0,I=!1;function N(_){_.button===K1&&(I&&L(),_.offsetX>M.offsetWidth-16&&_.offsetY>M.offsetHeight-16&&(_.preventDefault(),M.style.cursor="nwse-resize",document.addEventListener("mousemove",v,!1),document.addEventListener("mouseup",L,!1),I=!0,k=_.pageX,G=_.pageY,H=parseInt(M.style.width,10),q=parseInt(M.style.height,10)))}function v(_){var B=H+_.pageX-k,U=q+_.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(){I&&(M.style.cursor="",document.removeEventListener("mousemove",v,!1),document.removeEventListener("mouseup",L,!1),I=!1)}M.addEventListener("mousedown",N,!1),M.addEventListener("blur",L,!1)})(f)}let x=o.pageX,y=o.pageY;f.style.display="",m.style.display="inline-block",f.value=u,f.select(),f.focus(),n=e,re(f,"data-targetid",e.id),(function(C){let A=C.value.replace(/[^\x00-\xff]/g,"**").split(/\r\n|\r|\n/),R=A.length,O=0;for(let M=0;M<A.length;M++)O=Math.max(A[M].length,O);re(f,"rows",R),re(f,"cols",O),f.style.height="100px"})(f);let E=m.offsetWidth,T=m.offsetHeight,w=Math.max(y-5,5),b=Math.max(x-5,5);b+E>document.documentElement.offsetWidth&&(b-=E),w+T>document.documentElement.offsetHeight&&(w-=T),m.style.left=b+"px",m.style.top=w+"px"}}function tQ({target:e,cmdKey:t},i){let r=Sa([e]);if(r.length&&Tn(r,{create8Dots:!0}),jt.isEditingPath())return jt.endEditingPath();if(Kt.isEditing()){let n=Kt.getCurrentEditingComId();Kt.setEditing(null).selectCombinations([n])}i()}var rT=new xc(0);async function iQ(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 nT(e,t){e.startsWith("data:")&&rT.info("initial bytes \u2248 "+((e.length-30)*.75|0));let r=await iQ(e);return await rQ(r,t)}function gC(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 rQ(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),x=Math.max(f,a),y=(M,k)=>{if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(M,k);{let G=document.createElement("canvas");return G.width=M,G.height=k,G}},E=y(g,x),T=g<p?p-g>>1:0,w=x<f?f-x>>1:0;E.getContext("2d").drawImage(e,T,w,p,f),p=g,f=x;let C=await gC(E),A=C.size;rT.info("scaled to bytes: "+A);let R=.8;for(;A>i&&p>64&&f>64;){m*=R,p=p*R|0,f=f*R|0;let M=y(p,f);M.getContext("2d").drawImage(E,0,0,p,f);let G=await gC(M,"image/png"),H=C.size;if(o){let q=await gC(M,"image/jpeg",.8),I=q.size;C=H<=I?G:q,A=H<=I?H:I}else C=G,A=H;rT.info("scaled to bytes: "+A)}return rT.info("final bytes: ",{size:A,width:p,height:f}),{dataURL:await nQ(C,"DataURL"),width:p,height:f,bytes:A}}async function nQ(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 tB(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 iB(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 sQ(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 aQ(s)}function sQ(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 aQ(e){if(typeof FileReader!="object"){let t=oQ(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 oQ(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 rB(e){let t=e&&e.text;if(!t)return e;let i=new fu;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(mt(d))continue;let{x:p,y:f}=lr.getTextOrigin(void 0,void 0,void 0,n),m=he.translate(p,f).scale(h,d).rotateD(-c);u&&(m=m.multiply3(he.MIRROR_X)),m=m.translate(o,l),n.matrix=$e.getMatrix6FromMatrix(m),delete n.x,delete n.y,delete n.widthPercent,delete n.heightPercent,delete n.mirror}return e}var ll=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)};ll.prototype.classname="SVGPathSegList";Object.defineProperty(ll.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0});ll.prototype._checkPathSynchronizedToList=function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())};ll.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")))}};ll.prototype.segmentChanged=function(e){this._writeListToPath()};ll.prototype.clear=function(){this._checkPathSynchronizedToList(),this._list.forEach(function(e){e._owningPathSegList=null}),this._list=[],this._writeListToPath()};ll.prototype.initialize=function(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e};ll.prototype._checkValidIndex=function(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw"INDEX_SIZE_ERR"};ll.prototype.getItem=function(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]};ll.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};ll.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};ll.prototype.removeItem=function(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);var t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t};ll.prototype.appendItem=function(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e};var Dt={};Dt.PATHSEG_UNKNOWN=0;Dt.PATHSEG_CLOSEPATH=1;Dt.PATHSEG_MOVETO_ABS=2;Dt.PATHSEG_MOVETO_REL=3;Dt.PATHSEG_LINETO_ABS=4;Dt.PATHSEG_LINETO_REL=5;Dt.PATHSEG_CURVETO_CUBIC_ABS=6;Dt.PATHSEG_CURVETO_CUBIC_REL=7;Dt.PATHSEG_CURVETO_QUADRATIC_ABS=8;Dt.PATHSEG_CURVETO_QUADRATIC_REL=9;Dt.PATHSEG_ARC_ABS=10;Dt.PATHSEG_ARC_REL=11;Dt.PATHSEG_LINETO_HORIZONTAL_ABS=12;Dt.PATHSEG_LINETO_HORIZONTAL_REL=13;Dt.PATHSEG_LINETO_VERTICAL_ABS=14;Dt.PATHSEG_LINETO_VERTICAL_REL=15;Dt.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16;Dt.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17;Dt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18;Dt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19;var sT="not implement",Jl=function(e){this._string=e,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=Dt.PATHSEG_UNKNOWN,this._skipOptionalSpaces()};Jl.prototype._isCurrentSpace=function(){var e=this._string[this._currentIndex];return e<=" "&&(e==" "||e==`
`||e=="	"||e=="\r"||e=="\f")};Jl.prototype._skipOptionalSpaces=function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex};Jl.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)};Jl.prototype.hasMoreData=function(){return this._currentIndex<this._endIndex};Jl.prototype.peekSegmentType=function(){var e=this._string[this._currentIndex];return this._pathSegTypeFromChar(e)};Jl.prototype._pathSegTypeFromChar=function(e){switch(e){case"Z":case"z":return Dt.PATHSEG_CLOSEPATH;case"M":return Dt.PATHSEG_MOVETO_ABS;case"m":return Dt.PATHSEG_MOVETO_REL;case"L":return Dt.PATHSEG_LINETO_ABS;case"l":return Dt.PATHSEG_LINETO_REL;case"C":return Dt.PATHSEG_CURVETO_CUBIC_ABS;case"c":return Dt.PATHSEG_CURVETO_CUBIC_REL;case"Q":return Dt.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return Dt.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return Dt.PATHSEG_ARC_ABS;case"a":return Dt.PATHSEG_ARC_REL;case"H":return Dt.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return Dt.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return Dt.PATHSEG_LINETO_VERTICAL_ABS;case"v":return Dt.PATHSEG_LINETO_VERTICAL_REL;case"S":return Dt.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return Dt.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return Dt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return Dt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return Dt.PATHSEG_UNKNOWN}};Jl.prototype._nextCommandHelper=function(e,t){return(e=="+"||e=="-"||e=="."||e>="0"&&e<="9")&&t!=Dt.PATHSEG_CLOSEPATH?t==Dt.PATHSEG_MOVETO_ABS?Dt.PATHSEG_LINETO_ABS:t==Dt.PATHSEG_MOVETO_REL?Dt.PATHSEG_LINETO_REL:t:Dt.PATHSEG_UNKNOWN};Jl.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return!0;var e=this.peekSegmentType();return e==Dt.PATHSEG_MOVETO_ABS||e==Dt.PATHSEG_MOVETO_REL};Jl.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}};Jl.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}};Jl.prototype.parseSegment=function(){var e=this._string[this._currentIndex],t=this._pathSegTypeFromChar(e);if(t==Dt.PATHSEG_UNKNOWN){if(this._previousCommand==Dt.PATHSEG_UNKNOWN||(t=this._nextCommandHelper(e,this._previousCommand),t==Dt.PATHSEG_UNKNOWN))return null}else this._currentIndex++;switch(this._previousCommand=t,t){case Dt.PATHSEG_MOVETO_REL:return["m",this._parseNumber(),this._parseNumber()];case Dt.PATHSEG_MOVETO_ABS:return["M",this._parseNumber(),this._parseNumber()];case Dt.PATHSEG_LINETO_REL:return["l",this._parseNumber(),this._parseNumber()];case Dt.PATHSEG_LINETO_ABS:return["L",this._parseNumber(),this._parseNumber()];case Dt.PATHSEG_LINETO_HORIZONTAL_REL:return["h",this._parseNumber()];case Dt.PATHSEG_LINETO_HORIZONTAL_ABS:return["H",this._parseNumber()];case Dt.PATHSEG_LINETO_VERTICAL_REL:return["v",this._parseNumber()];case Dt.PATHSEG_LINETO_VERTICAL_ABS:return["V",this._parseNumber()];case Dt.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),["Z"];case Dt.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 Dt.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 Dt.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 Dt.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 Dt.PATHSEG_CURVETO_QUADRATIC_REL:{let i={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return[sT,i.x,i.y,i.x1,i.y1]}case Dt.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 Dt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return[sT,this._parseNumber(),this._parseNumber()];case Dt.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return[sT,this._parseNumber(),this._parseNumber()];case Dt.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[sT,i.x,i.y,i.x1,i.y1,i.arcAngle,i.arcLarge,i.arcSweep]}case Dt.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 nB=function(e){if(!e||e.length==0)return[];let t=[],i=new Jl(e);if(!i.initialCommandIsMoveTo())return[];for(;i.hasMoreData();){let r=i.parseSegment();if(!r)return[];t.push(r)}return t};function sB(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":Hr(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=gd({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=nB(o);l.shift(),t.push(...sB(l)),i=s[1].x,r=s[1].y;break}case"Z":t.push({op:"h",c:[]});break;default:Hr(a,s,"Plz check code");break}n=s}return t}function aT(e){if(!e.includes("A"))return e;let t=nB(e),i=sB(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:Hr(n);break}return r.join(" ")}var zn=class{static decHead(t){return{...t}}static decDetail(t){let{title:i,docType:r=x0.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:x,transScope:y}=i,E=this.decTransform(i.matrix),{transparencyPrint:T,transparencyWhite:w}=this.getTransparencyPrintAndTransparencyWhite(i),b={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:!!x,hide:!g,scope:this.getScope(y),isWhiteBackground:!1,transparencyPrint:T,transparencyWhite:w,cmdKey:"ellipse",name:m,locked:p,visible:f};return this.fixedShape(b,d),b}static getScope(t){let i=1;switch(t){case al.PRINT_AND_COVER:i=1;break;case al.PRINT:i=2;break;case al.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 al.PRINT_AND_COVER:i=1-(s!==void 0?s:o),r=1-(a!==void 0?a:1);break;case al.PRINT:i=1-(s!==void 0?s:1),r=1-(a!==void 0?a:o);break;case al.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:x,cover:y,transScope:E}=i,[,T,w,b,C,A,R,O,M,k,G]=p[0],H=this.decTransform(i.matrix),{transparencyPrint:q,transparencyWhite:I}=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:T,y1:-w,rx:C,ry:A,angle:R,large:O,sweep:M,x2:k,y2:-G,cover:!!y,type:b==="CA"?1:2,matrix:H,hide:!f,gId:t,locked:m,visible:g,zIndex:this.getZIndexOrDefault(i),scope:this.getScope(E),isWhiteBackground:!1,transparencyPrint:q,transparencyWhite:I,cmdKey:"arc",name:x};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:x,transScope:y,name:E}=i;if(o.startsWith("data:")||o.startsWith("blob:")||o.length>20)return this.decObj(t,i);{let{transparencyPrint:T,transparencyWhite:w}=this.getTransparencyPrintAndTransparencyWhite(i),b=this.decTransform(i.matrix),C=p[0],A={gId:t,name:E,layer:r,rotation:-n,strokeWidth:a,strokeStyle:this.getStrokeStyleNumber(h),strokeColor:s,fillColor:o,opacity:l,rx:C[5],ry:C[6],displayFill:c,displayStroke:u,matrix:b,cover:!!f,hide:!m,locked:x,visible:g,transparencyPrint:T,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 J.windowBridge.rpcCall(ii.BLOB.GET,[s,J.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:x,name:y,transScope:E}=i,T=this.decTransform(i.matrix),w=this.decMultiPoly(p).d,{transparencyPrint:b,transparencyWhite:C}=this.getTransparencyPrintAndTransparencyWhite(i),A={layer:r,rotation:-n,strokeWidth:a,strokeStyle:this.getStrokeStyleNumber(h),strokeColor:s,fillColor:o,opacity:l,d:aT(w),displayFill:c,displayStroke:u,matrix:T,hide:!m,gId:t,locked:x,visible:g,zIndex:this.getZIndexOrDefault(i),cover:!!f,scope:this.getScope(E),isWhiteBackground:!1,transparencyPrint:b,transparencyWhite:C,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:x,transScope:y}=i,{valid:E,locked:T,visible:w,path:b}=i,C=this.decTransform(i.matrix),A=b?this.decFontCache(b):{},{vAlign:R,hAlign:O}=this.getAlign(p),{transparencyPrint:M,transparencyWhite:k}=this.getTransparencyPrintAndTransparencyWhite(i),G={layer:n,rotation:-s,key:m,name:m,fontFamily:a,fontSize:o,fontWeight:!!l,italic:c,underline:u,vAlign:R,hAlign:O,strokeColor:d,opacity:f,d:"",cacheHeight:0,cacheWidth:0,matrix:C,cover:!!x,hide:!E,gId:t,locked:T,visible:w,...A,zIndex:this.getZIndexOrDefault(i),scope:this.getScope(y),isWhiteBackground:!1,transparencyPrint:M,transparencyWhite:k,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 V(d[m],d[m+1]));let p=s,f;switch(n){case"LENGTH-CONSTRAINT":case"LENGTH-MEASUREMENT":{let[m,g,x,y]=h,E=m.x===g.x?"x":m.y===g.y?"y":"xy",T=this.getDimCategory(n);f={name:c,gId:t,cmdKey:"dimension",layer:r,category:T,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:x.x,y:-x.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,x]=h;f={name:c,gId:t,cmdKey:"dimensionRadius",layer:r,x1:m.x,y1:-m.y,x2:g.x,y2:-g.y,textX:x.x,textY:-x.y,locked:o,visible:l,ellipseId:p[0],rotation:u,zIndex:this.getZIndexOrDefault(i)};break}case"ANGLE":{let[m,g,x,y]=h;f={name:c,gId:t,cmdKey:"dimensionAngle",layer:r,x1:m.x,y1:-m.y,angleX:g.x,angleY:-g.y,x2:x.x,y2:-x.y,textX:y.x,textY:-y.y,locked:o,visible:l,rotation:u,zIndex:this.getZIndexOrDefault(i)};break}case"LENGTH":{let[m,g,x,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:x.x,measureY2:-x.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 Za(a=>(i.ext1(a.bbox()),s=new vo().encPl(a).toString(),!1),!0).parse("M"+n.join(" ")),s}).join(" ");return{bbox:i.build(),d:r}}static prepareX1Y1ForAuxiliaryLine(t){let i=Sp(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(mt(c))return;let{x:u,y:h}=lr.getTextOrigin(void 0,void 0,void 0,t),d=he.translate(u,h).scale(l,c).rotateD(-a);o&&(d=d.multiply3(he.MIRROR_X)),d=d.translate(n,s),t.matrix=$e.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 he([i,s,0,r,a,0,n,o,1]);return l=he.MIRROR_Y.multiply3(l).multiply3(he.MIRROR_Y),this.matrix2svg(l)}static resize(t){let i=J.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 J.messageBus.rpcCall("/panel/resizeImageFromURL",[t,s])).message.dataURL:(await nT(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 Rc.SOLID:return 0;case Rc.SHORT_DASH:return 1;case Rc.DOT:return 2;case Rc.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}};zn.lf=new fu,zn.imageHashMap=new Map,zn.imageDataMap=new Map;var Mo=class{static uploadDeleteById(t,i){switch(i||(i=F.getById(t).cmdKey),i){case"auxiliaryLine":case"auxiliaryPoint":{F.compilerManager.deleteAuxLine(t);break}case"text":F.compilerManager.deleteString(t);break;case"combination":F.compilerManager.deleteGroup(t);break;case"dimension":case"dimensionAngle":case"dimensionLength":case"dimensionRadius":F.compilerManager.deleteDimension(t);break;case"arc":case"obj":case"rect":case"group":case"ellipse":{F.compilerManager.deletePoly(t);break}}}static applyRemoteDelete(t){t.forEach(n=>this.beUploadDeleteMap.set(n,F.getById(n).json));let i=t.map(n=>de(n)).filter(n=>n);if(!i.length)return;_o(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=F.getById(t[1]).json,a=this.beUploadDeleteMap.get(t[1]);return(Nt(s)||!s)&&!Nt(r)&&!Nt(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}};Mo.beUploadDeleteMap=new Map;var Iu=class{static uploadData(t,i,r=F.compilerManager){var s;switch(t==="canvas"?"canvas":(i==null?void 0:i.cmdKey)||F.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=F.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=F.exchangeJsonCache(i);if(this.uploadData("canvas",i.head,t),F.iterator(n=>{let s=n.gId;this.uploadData(s,n,t)}),r(),t instanceof W2)return t.save()}static uploadJsonCache2(t){let i=F.gJsonCache,r=new Map;oT(i.head,t.head)||r.set("canvas",t.head),tm.forEach(s=>{let a=[];Object.keys(i[s]).forEach(o=>{var l,c;oT((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=F.exchangeJsonCache(t);r.forEach((s,a)=>{typeof s=="object"?this.uploadData(a,s):Mo.uploadDeleteById(a,s)}),n()}static uploadObjContent(t,i,r){r||(r=Zt(F.getById(t).json));let{content:n,gId:s}=r,a=zn.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}=F.getById(t);if(i&&(r=i),Nt(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:lQ(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||F.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}=F.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=F.getById(t).json;if(i&&(r=i),Nt(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:x,transparencyWhite:y,matrix:E,displayFill:T,displayStroke:w,scope:b}=r,{fillColor:C}=r,A;switch(d){case"rect":A=[["R",0,0,1,1,r.rx,r.ry,0,0]];break;case"arc":let{x1:O,y1:M,type:k,rx:G,ry:H,angle:q,large:I,sweep:N,x2:v,y2:L}=r,_="A";k===1&&(_="CA"),A=[["M",O,-M,_,G,H,q,I,N,v,-L]];break;case"ellipse":A=[["ELLIPSE",0,0,1,1,0,0]];break;case"group":A=aB(r.d);break;case"obj":let{content:B}=r;A=[["R",0,0,1,1,0,0,0,0]];let U=zn.imageHashMap.get(t);C=U?"blob:"+U:B}return{groupId:this.getCombinationId(t),layer:n,rotation:-s,strokeWidth:a,strokeStyle:this.getStrokeStyle(l),strokeColor:o,fillColor:C,opacity:c,autoClose:!1,ploys:A,displayFill:T,displayStroke:w,locked:u,zIndex:p,valid:!h,visible:f,cover:Number(m),name:g,transScope:this.getScope(b),transPrint:1-x,transWhite:1-y,matrix:oB(E)}}static getStringData(t,i){let r=F.getText(t);if(i&&(r=i),Nt(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:x,visible:y,cover:E,transparencyPrint:T,transparencyWhite:w,matrix:b,name:C,d:A,scope:R}=r;return{groupId:this.getCombinationId(t),layer:n,rotation:-s,value:C,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:!x,visible:y,cover:Number(E),name:C,transScope:this.getScope(R),transPrint:1-T,transWhite:1-w,matrix:oB(b),strokes:!1,path:aB(A)}}static getGroup(t,i){let r=F.getCombination(t);if(i&&(r=i),Nt(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}=F.getById(t);i&&(r=i);let n,s,a;switch(r.cmdKey){case"dimension":{let{start:m,end:g}=r,x=m.primitivePoint,y=m.otherPoint,E=g.otherPoint,T=g.primitivePoint;s=[m.id,g.id],a=cQ(r),n=[x.x,-x.y,y.x,-y.y,E.x,-E.y,T.x,-T.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 Nt(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(F.gJsonCache.combination).find(r=>r.elements.includes(t));return i?i.gId:"0"}static getStrokeStyle(t){switch(t){case 0:return Rc.SOLID;case 1:return Rc.SHORT_DASH;case 2:return Rc.DOT;case 3:return Rc.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=al.PRINT_AND_COVER;switch(t){case 1:i=al.PRINT_AND_COVER;break;case 2:i=al.PRINT;break;case 3:i=al.COVER;break;default:}return i}};function aB(e){let t=new Array;return new Za(i=>(t.push(new vo(!0).encPl(i).toArray().slice(1)),!0),!0).parse(e),t}function oB(e){if(!e)return[1,0,0,0,1,0];let[t,i,r,n,s,a]=e,o=new he([t,i,0,r,n,0,s,a,1]);o=he.MIRROR_Y.multiply3(o).multiply3(he.MIRROR_Y);let[l,c,u,h,d,p,f,m,g]=o.data;return[l,h,f,c,d,m]}function lQ(e){return typeof e=="string"?String(e):e}function cQ(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 oT(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(!oT(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)||!oT(e[n],t[n]))return!1;return!0}var Au=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}}};Au.maxZIndex=0;var Pd=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-Xe.canvas.originX,s=i-Xe.canvas.originY;bn().setOriginXY({x:t,y:i}),r&&at.save(["originXY","set.origin",{offsetX:n,offsetY:s}])}static end(){fs()}};var E1={maxId:0,name:"name",material:"acrylic",thickness:"0.8mm",craft:"Transparent",desc:"",width:"393mm",height:"579mm",title:"",display_title:"",coverColor:"white",print:"Bottom Side"},lT=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=F.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=zn.decDetail(n);this.addMergeData("detail",l)}else if(i==="canvas"){let l=zn.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===F.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),Mo.applyRemoteDelete(i),this.refreshSelected(r),_e("panel_updateAttrPanel"),_e("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=zn.decDimension(r,n);break;case"string":l=await zn.decString(r,n);break;case"poly":l=await zn.decPoly(r,n);break;case"auxLine":l=zn.decAuxLine(r,n);break;case"blob":this.handleBlob(o,n);return}l.id=this.numberToId(a),Au.maxZIndex=Math.max(l.zIndex,Au.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=zn.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}=F.getById(a).json;for(let c of t){let{zIndex:u,layer:h}=F.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(Ke[t]){let{gId:r}=i;if(this.isIllegal(i))return;if(Ji(this.jsonCache,t)[r]=i,t!=="combination"&&tm.includes(t)&&!this.jsonCache.itemOrder.includes(r)&&this.jsonCache.itemOrder.push(r),t==="dimension"){let n=F.getById(i.start.id).json;n?Eh(n.cmdKey,i.start,n):this.fixDimensionMap.set(i.start.id,i.start),n=F.getById(i.end.id).json,n?Eh(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),Eh(t,n,i))}}}renderData(t,i){if(t==="detail")J.windowBridge.publish("setTitle",[J.tabId,i.display_title],ut());else if(t==="canvas"){let r=mi.getCanvasAttrs();Pd.setOrigin(i.originX,i.originY,!1),mi.setCanvasWidthHeight(i.width,i.height,r["attr-direction"],!1)}else if(t==="combination")i.elements.forEach(r=>yi.applyElementsVisible(r));else if(Ke[t]){let r=Us(t,i),n=tt.getNextEleById(i.gId);n?J.gCanvas.insertBefore(r,n):tt.switchLayer(r,i.layer)}}setItemOrderArr(){let t=cT();this.jsonCache.itemOrder.sort((i,r)=>{let{zIndex:n,layer:s}=F.getById(i).json,{zIndex:a,layer:o}=F.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;Ce.getIds().filter(a=>t.some(({data:o})=>o.gId===a)).forEach(a=>de(a).classList.add(ug));let r=new Map,n=((s=F.selectedRepeater)==null?void 0:s.getSelectMap())||new Map;t.forEach(({data:a})=>{let o=n.get(a.gId);o&&r.set(a.gId,o)}),Ki.appendSelectStroke(r,!0),Bc(void 0,Kp())}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=F.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(Ke[n]){let{gId:s}=i;if(this.isIllegal(i))return;if(Ji(t,n)[s]=i,n==="dimension"){let a=F.getById(i.start.id).json;a?Eh(a.cmdKey,i.start,a):this.fixDimensionMap.set(i.start.id,i.start),a=F.getById(i.end.id).json,a?Eh(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),Eh(n,a,i))}}}}),this.mergeDataMap.clear(),t}handleBlob(t,i){zn.decBlob(t,i),zn.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)||F.getById(t).json}onChangeNum(t,i){let r=this.mergeDataMap.get(t)||F.getById(t).json;r&&(r.id=this.numberToId(i))}numberToId(t){return"e"+t}onDelete(t){if(zn.imageDataMap.get(t)){zn.imageDataMap.delete(t);for(let[r,n]of zn.imageHashMap.entries())if(n===t)return zn.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=Zr(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=F.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}=Ei(t);if(ei(o,0)&&ei(l,0))return!0}break;case"rect":let i=t,{width:r,height:n}=Ai.getRectFromMatrix(i.matrix);if(ei(r,0)||ei(n,0))return!0;break;case"arc":{let s=t;if(Zs({x:s.x1,y:s.y1},{x:s.x2,y:s.y2}))return!0}break;default:break}return!1}};var $p=class e extends W2{constructor(i,r,n,s=new cg(!1)){super(i,r,n,s);this.decoders=new lT;this.channel=s}static async getJsonCache(i,r){let n=(await J.windowBridge.rpcCall("getActiveProject",null,ut())).message,s=r===n,a=new e(i,r,s,new cg(!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=F.exchangeJsonCache(i),n=i.itemOrder.map(s=>{var a;return(a=F.getById(s).json)==null?void 0:a.zIndex});n.length!==new Set(n).size&&(i.itemOrder.forEach((s,a)=>{let o=F.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 Iu.uploadData("canvas",i.head,this),super.save()}async getMergeDataJsonCache(){return await this.decoders.getJsonCacheByMergeDataMap()}uploadData(i,r){Iu.uploadData(i,r,this)}uploadHistoryData(i){Tc(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=F.getById(s).cmdKey;(a==="combination"?Nt(r[3]||{}):Nt(r[4]||{}))?Mo.uploadDeleteById(s,a):n==="combine-json"?Iu.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"&&!Nt(n[4])&&((s=F.getById(n[1]).json)==null?void 0:s.zIndex)===void 0}).forEach(n=>r.set(n[1],n[4])),r.size&&F.getItemOrder().forEach(n=>{let s=r.get(n);if(s){let a=F.getById(n).json;a.zIndex=s.zIndex=++F.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 F.selectedRepeater.getSelect()}onSelectChange(i,r,n){F.selectedRepeater.changeSelect(i,r,n)}onSelectQuit(i,r){F.selectedRepeater.onDestroy(i,r)}};function uT(e){let t=F.exchangeJsonCache(e),i=new Map;F.iterator((r,n,s)=>{i.set(s,{...r,cmd:n,gId:s})}),F.iteratorDimension(r=>{let n=i.get(r.start.id);n&&Eh(n.cmd,r.start,n),n=i.get(r.end.id),n&&Eh(n.cmd,r.end,n)}),t()}function Eh(e,t,i){let r=new By;switch(e){case"rect":{let n=r.loadPointsOfRect(i);hg(n,t);break}case"ellipse":{let n=r.loadPointsOfEllipse(i);hg(n,t);break}case"obj":{let n=r.loadPointsOfImage(i);hg(n,t);break}case"text":{let n=r.loadPointsOfText(i);hg(n,t);break}case"group":{let n=r.loadPointsOfGroup(i);hg(n,t);break}case"arc":{let n=r.loadPointsOfArc(i);hg(n,t);break}default:console.error(e,"Plz check code");break}}function hg(e,t){for(let i of e)if(Zs(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 lB(e){await rB(e),dQ(e),pQ(e),uT(e),hQ(e)}function hQ(e){let t=F.exchangeJsonCache(e),i=new Set([]);F.iterator((r,n,s)=>{switch(n){case"group":{let{x:c,y:u,width:h,height:d}=Ei(r);ei(h,0)&&ei(d,0)&&i.add(s)}break;case"rect":let a=r,{width:o,height:l}=Ai.getRectFromMatrix(a.matrix);(ei(o,0)||ei(l,0))&&i.add(s);break;case"arc":{let c=r;Zs({x:c.x1,y:c.y1},{x:c.x2,y:c.y2})&&i.add(s)}break;default:break}});for(let r of i)F.removeOne({id:r});F.removeItemOrder(i),t()}function dQ(e){let t=e.auxiliaryLine||{};for(let i in t){let r=t[i],n=Sp(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 pQ(e){let t=F.exchangeJsonCache(e);F.iterator((i,r,n)=>{i.cmdKey=r,i.gId=n,["dimensionAngle","dimensionLength","dimensionRadius"].includes(r)&&(i.rotation=0),i.cmdKey==="group"&&(i.d=aT(i.d))}),t()}function fQ(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 T1(e){let[t,i,r,n,s,a,o,l,c]=e.data;return[t,i,n,s,o,l]}function hT(e){let t=J.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 J.messageBus.rpcCall("/panel/resizeImageFromURL",[e,n])).message.dataURL:(await nT(e,n)).dataURL)()}async function cB(e,t=!1){console.debug("decompressing...",e);let{dataStr:i,json:r,docType:n,title:s,display_title:a}=e;if(n!==gs.PANEL&&n!==gs.PANEL_LIB)throw new Error(`invalid doctype(${JSON.stringify(n)}), need panel(${gs.PANEL})`);n===gs.PANEL_LIB&&(t=!0);let o={DOCTYPE:d},l={head:{title:s,display_title:a,docType:n,maxId:0,version:uf,name:"name",material:"PVC",thickness:"0.2mm",craft:"Transparent",desc:"xxxxx",width:787,height:1181}},c=0,u=fQ(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 lB(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?gQ(m):yQ(m)}function p(){let f={decoders:o,jsonCache:l,docVersion:c,sync:t};c<=1&&mQ(f)}}function mQ(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:x,hAlign:y,vAlign:E}=c;g=g||0,x=x||0;let T=0;switch(y){case 1:T=-x/2;break;case 2:T=-x;break}let w=0;switch(E){case 1:w=g/2;break;case 0:w=g;break}let b=he.translate(T,w).scale(f,m).rotateD(-d);p&&(b=b.multiply3(he.MIRROR_X)),b=b.translate(u,h),c.matrix=T1(b),c.visible=!0}function s(l,c){let{x:u,y:h,width:d,height:p,rotation:f,mirror:m}=c,g=he.scale(d,p).rotateD(-f);m&&(g=g.multiply3(he.MIRROR_X)),g=g.translate(u,-h),c.matrix=T1(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=he.scale(d-u,p-h).rotateD(-f);m&&(g=g.multiply3(he.MIRROR_X)),g=g.translate(u,h),c.matrix=T1(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=he.scale(d,p).rotateD(-f);m&&(g=g.multiply3(he.MIRROR_X)),g=g.translate(u,h),c.matrix=T1(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 gQ(e){let{decoders:t,jsonCache:i,sync:r}=e;Object.assign(t,{HEAD:a,LOCK:o,HIDE:u,INVISIBLE:c,COVER:l,TRN_CTRL:x,COMMENT:y,POLY:E,STRING:O,FONT_CACHE:k,TRANSFORM:h,AUXLINE:g,DIMENSION:p,GROUP:d,__POST_PROCESS__:H});let n={},s=new Array;i.itemOrder=s;function a(I){Object.assign(i.head,I[1]),i.head.originY=-(i.head.originY||0)}function o(I){let N=I[1];for(let v of N)v in n?n[v].locked=!0:console.warn(`LOCK ${v} not found`)}function l(I){let N=I[1],v=I[2];N in n?n[N].cover=!!v:console.warn(`COVER ${N} not found`)}function c(I){let N=I[1];for(let v of N)v in n?n[v].visible=!1:console.warn(`INVISIBLE ${v} not found`)}function u(I){let N=I[1];for(let v of N)v in n?n[v].hide=!0:console.warn(`HIDE ${v} not found`)}function h(I){let N=I[1];if(N in n){let[v,L,_,B,U,z]=I[2],W=new he([v,B,0,L,U,0,_,z,1]);W=he.MIRROR_Y.multiply3(W).multiply3(he.MIRROR_Y),n[N].matrix=T1(W)}else console.warn(`TRANSFORM ${N} not found`)}function d(I){let N=`e${I[1]}`,v=`e${I[2]}`,L=I[3],_=!!I[4],B=!!I[5],U={gId:N,name:L,locked:B,visible:_,cmdKey:"combination",parent:I[2]===0?null:v,combinations:[],elements:[]};n[N]=U,Ji(i,"combination")[N]=U}function p(I){let N=new Array,v=I[7];for(let _=0;_<v.length-1;_+=2)N.push(new V(v[_],v[_+1]));let L=I[8];switch(I[3]){case"LENGTH-CONSTRAINT":case"LENGTH-MEASUREMENT":{let[_,B,U,z]=N,W=_.x===B.x?"x":_.y===B.y?"y":"xy",ne=f(I[3]),me={name:"",gId:I[1],cmdKey:"dimension",layer:I[2],category:ne,direction:W,start:{id:L[0],index:0,cmdKey:"",primitivePoint:{x:_.x,y:-_.y},otherPoint:{x:B.x,y:-B.y}},end:{id:L[1],index:0,cmdKey:"",otherPoint:{x:U.x,y:-U.y},primitivePoint:{x:z.x,y:-z.y}},visible:!0,locked:!1};M("dimension",I[1],0,me);break}case"RADIUS-MEASUREMENT":{let[_,B,U]=N,z={name:"",gId:I[1],cmdKey:"dimensionRadius",layer:I[2],x1:_.x,y1:-_.y,x2:B.x,y2:-B.y,textX:U.x,textY:-U.y,locked:!1,visible:!0,ellipseId:L[0]};M("dimensionRadius",I[1],0,z);break}case"ANGLE":{let[_,B,U,z]=N,W={name:"",gId:I[1],cmdKey:"dimensionAngle",layer:I[2],x1:_.x,y1:-_.y,angleX:B.x,angleY:-B.y,x2:U.x,y2:-U.y,textX:z.x,textY:-z.y,locked:!1,visible:!0};M("dimensionAngle",I[1],0,W);break}case"LENGTH":{let[_,B,U,z]=N,W=_.x===B.x?"x":_.y===B.y?"y":"xy",ne={name:"",gId:I[1],cmdKey:"dimensionLength",layer:I[2],x1:_.x,y1:-_.y,measureX1:B.x,measureY1:-B.y,measureX2:U.x,measureY2:-U.y,x2:z.x,y2:-z.y,direction:W,locked:!1,visible:!0,rotation:0};M("dimensionLength",I[1],0,ne);break}}}function f(I){switch(I){case"LENGTH-MEASUREMENT":return"Annotation";case"LENGTH-CONSTRAINT":return"Constraint";default:throw new Error(`unknown dimension type ${JSON.stringify(I)}`)}}function m(I){if(I!==null)return I===""?null:I}function g(I){if(I[10]===0){let N={gId:I[1],cmdKey:"auxiliaryPoint",visible:!0,name:"",layer:I[3],x:I[4],y:-I[5],fillColor:m(I[9]),locked:!1};M("auxiliaryPoint",I[1],I[2],N)}else{let N={gId:I[1],name:"",layer:I[3],x:I[4],y:-I[5],rotation:I[6],strokeStyle:I[8],strokeColor:m(I[9]),locked:!1};M("auxiliaryLine",I[1],I[2],N)}}function x(I){let N=I[1],v=I[2],L=I[3],_=I[4];if(N in n){let B=n[N];switch(v){case 1:B.transparencyPrint=1-(L!==void 0?L:B.opacity),B.transparencyWhite=1-(_!==void 0?_:1);break;case 2:B.transparencyPrint=1-(L!==void 0?L:1),B.transparencyWhite=1-(_!==void 0?_:B.opacity);break;case 3:B.transparencyPrint=1-(L!==void 0?L:B.opacity),B.transparencyWhite=1-(_!==void 0?_:B.opacity);break;default:}}else console.warn(`TRN_CTRL ${N} not found`)}function y(I){let N=I[1],v=I[2];N in n?n[N].name=v:console.warn(`COMMENT ${N} not found`)}function E(I){let N=!!(I[12]||I[12]===void 0),v=!!(I[13]||I[13]===void 0);if(I[11].length===1){let L=I[11][0];switch(L[0]){case"R":return b(I,N,v);case"ELLIPSE":return T(I,N,v);case"M":return L[3]==="A"||L[3]==="CA"?w(I,N,v):R(I,N,v);default:return R(I,N,v)}}else return R(I,N,v)}function T(I,N,v){let L={layer:I[3],rotation:-I[4],strokeWidth:I[5],strokeStyle:I[6],strokeColor:I[7],fillColor:I[8],opacity:I[9],displayFill:N,displayStroke:v};M("ellipse",I[1],I[2],L)}function w(I,N,v){let[,L,_,B,U,z,W,ne,me,Ee,Se]=I[11][0],Fe={layer:I[3],rotation:-I[4],strokeWidth:I[5],strokeStyle:I[6],strokeColor:I[7],fillColor:I[8],opacity:I[9],displayFill:N,displayStroke:v,x1:L,y1:-_,rx:U,ry:z,angle:W,large:ne,sweep:me,x2:Ee,y2:-Se,type:B==="CA"?1:2};M("arc",I[1],I[2],Fe)}function b(I,N,v){let L=I[8];if(L.startsWith("data:")||L.startsWith("blob:"))return C(I,L);{let _=I[11][0],B={layer:I[3],rotation:-I[4],strokeWidth:I[5],strokeStyle:I[6],strokeColor:I[7],fillColor:L,opacity:I[9],rx:_[5],ry:_[6],displayFill:N,displayStroke:v};M("rect",I[1],I[2],B)}}function C(I,N){if(N){let v=/^blob:(.+)$/.exec(N);return v?(async()=>{let L=v[1],{dataUrl:_}=(await J.messageBus.rpcCall("/pro-mgr/getBlob",{hash:L})).message;_&&(_=await hT(_),A(I,_))})():(async()=>{let L=await hT(N);A(I,L)})()}}function A(I,N){let v={gId:I[1],layer:I[3],rotation:-I[4],content:N,opacity:I[9],locked:!1};M("obj",I[1],I[2],v)}function R(I,N,v){let L=G(I[11]).d,_={layer:I[3],rotation:-I[4],strokeWidth:I[5],strokeStyle:I[6],strokeColor:I[7],fillColor:I[8],opacity:I[9],d:L,displayFill:N,displayStroke:v};M("group",I[1],I[2],_)}function O(I){let N={layer:I[3],rotation:-I[4],key:I[5],name:I[5],fontFamily:I[6],fontSize:I[7],fontWeight:I[8],italic:I[9]===1,underline:I[10]===1,strikeout:I[11]===1,vAlign:-(I[12]/3|0)+2,hAlign:I[12]%3,strokeColor:I[13],opacity:I[14]};M("text",I[1],I[2],N)}function M(I,N,v,L){var _;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(I)&&(L.matrix=[1,0,0,1,0,0]),Ji(i,I)[N]=L,v>0){let B=`e${v}`,U=(_=i.combination)==null?void 0:_[B];U?U.elements.push(N):console.warn("GROUP",v,"not found")}}function k(I){let{bbox:N,d:v}=G(I[2]),L=n[I[1]];L.d=v,L.cacheWidth=N.width(),L.cacheHeight=N.height()}function G(I){let N=new ot,v=I.map(L=>{let _="";return new Za(B=>(N.ext1(B.bbox()),_=new vo().encPl(B).toString(),!1),!0).parse("M"+L.join(" ")),_}).join(" ");return{bbox:N.build(),d:v}}function H(){q()}function q(){eo(i.combination,(I,N)=>{if(N.parent){let v=n[N.parent];v?v.combinations.push(I):(console.warn("parent combination",N.parent,"not found"),N.parent=null)}})}}function yQ(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:T});let n={},s=new Array;i.itemOrder=s;function a(b){Object.assign(i.head,b[1]),i.head.originY=-(i.head.originY||0),i.head.print==="AHead Side"&&(i.head.print="Ahead Side")}function o(b){let C=b[1];for(let A of C)A in n?n[A].locked=!0:console.warn(`LOCK ${A} not found`)}function l(b){let C=b[1];for(let A of C)A in n?n[A].hide=!0:console.warn(`HIDE ${A} not found`)}function c(b){let C=b[1],A=b[2];C in n?n[C].cover=!!A:console.warn(`COVER ${C} not found`)}function u(b){let C=b[1],A=b[2],R=b[3],O=b[4];if(C in n){let M=n[C];switch(A){case 1:M.transparencyPrint=1-(R!==void 0?R:M.opacity),M.transparencyWhite=1-(O!==void 0?O:1);break;case 2:M.transparencyPrint=1-(R!==void 0?R:1),M.transparencyWhite=1-(O!==void 0?O:M.opacity);break;case 3:M.transparencyPrint=1-(R!==void 0?R:M.opacity),M.transparencyWhite=1-(O!==void 0?O:M.opacity);break;default:}}else console.warn(`TRN_CTRL ${C} not found`)}function h(b){let C=b[1],A=b[2];C in n?n[C].name=A:console.warn(`COMMENT ${C} not found`)}async function d(b){if(b[11].length===1)switch(b[11][0][0]){case"R":return await f(b);case"ELLIPSE":return p(b);default:return x(b)}else return x(b)}function p(b){let C=b[11][0],A={layer:b[3],strokeWidth:b[4],strokeStyle:b[5],strokeColor:b[6],fillColor:b[7],opacity:b[8],cx:C[1],cy:-C[2],rx:C[3],ry:C[4],rotation:+C[5],isCCW:+C[6],name:b[12]};E("ellipse",b[1],A)}async function f(b){let C=b[7];if(C.startsWith("data:")||C.startsWith("blob:"))await m(b,C);else{let A=b[11][0],R={layer:b[3],strokeWidth:b[4],strokeStyle:b[5],strokeColor:b[6],fillColor:C,opacity:b[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:b[12]};E("rect",b[1],R)}}async function m(b,C){if(C){let A=/^blob:(.+)$/.exec(C);return A?(async()=>{let R=A[1],{dataUrl:O}=(await J.messageBus.rpcCall("/pro-mgr/getBlob",{hash:R})).message;O&&(O=await hT(O),g(b,O))})():(async()=>{let R=await hT(C);g(b,R)})()}}function g(b,C){let[A,R,O,M,k,G,H,q,I]=b[11][0],N=he.rotateD(q);I&&(N=N.multiply3(he.MIRROR_X));let v;I?v=new te(new V(0,0),new V(0,-k)).multiply3(N):v=new te(new V(0,0),new V(M,0)).multiply3(N);let L={gId:b[1],layer:b[3],content:C,opacity:b[8],mirror:I===1,width:I===1?k:M,height:I===1?M:k,rotation:v.end().angleD(v.start()),x:R,y:O,locked:!1,name:b[12]};E("obj",b[1],L)}function x(b){let C=w(b[11]).d,A={layer:b[3],strokeWidth:b[4],strokeStyle:b[5],strokeColor:b[6],fillColor:b[7],opacity:b[8],d:C,name:b[12]};E("group",b[1],A)}function y(b){let C={layer:b[3],x:b[4],y:-b[5],rotation:b[6],mirror:b[7]===1,key:b[8],name:b[8],fontFamily:b[9],fontSize:b[10],fontWeight:b[11],italic:b[12]===1,underline:b[13]===1,strikeout:b[14]===1,vAlign:-(b[15]/3|0)+2,hAlign:b[15]%3,strokeColor:b[16],opacity:b[17],widthPercent:b[18]||1,heightPercent:b[19]||1};E("text",b[1],C)}function E(b,C,A){n[C]=A,s.push(C),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=""),Ji(i,b)[C]=A}function T(b){let{bbox:C,d:A}=w(b[2]),R=n[b[1]];R.d=A,R.cacheWidth=C.width(),R.cacheHeight=C.height()}function w(b){let C=new ot,A=b.map(R=>{let O="";return new Za(M=>(C.ext1(M.bbox()),O=new vo().encPl(M).toString(),!1),!1).parse("M"+R.join(" ")),O}).join(" ");return{bbox:C.build(),d:A}}}var{IS_CLIENT:uB,IS_EASYEDA:uLe,IS_PRIVATE:hLe,IS_ONLINE:dLe,IS_HALF_OFFLINE:pLe,IS_OFFLINE:fLe}=XS;var dg=class{constructor(t,i=xy){this.options=i;this.hasLocked=!1;this.success=!1;this.degree=0;this.objs=t.filter(r=>{let n=wr.isLockedById(r.id);return this.hasLocked=n,!n}).filter(r=>Qt(r)!=="dimension")}do(t){let{hasLocked:i}=this;if(i){zl();return}if(!this.objs.length)return;if(this.degree=fr(this.degree+t),this.options.notSaveHistory){kc(this.objs,t),Tn(this.objs,{create8Dots:!1});return}let r=pi.createContext(!0);this.objs=to(this.objs).filter(s=>F.getById(s.id).cmdKey!=="auxiliaryLine");for(let s of this.objs){let{cmdKey:a,json:o}=F.getById(s.id);qn(a)&&at.jsonSnap.addOne(o)}kc(this.objs,t),r();let n=Sa(this.objs);n.length&&Tn(n,{create8Dots:!0}),new $i().updateHole(),this.success=!0}};dg=La([Ea(gn.rotate)],dg);function pg(e,t=.01){return e.closed()?!1:e.primitives.length===1&&e.primitives[0]instanceof te?!0:!(e.end().distance2(e.start())<=t*t)}function fg(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;pg(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]),x=f[1].distance1(f[2]),y=f[1].distance1(f[3]),E=Math.min(m,g,x,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(x!=E)continue;if(u=Et.build2(c.primitives.concat(p.primitives)),c=u,l.polylineNew=u,l.op=1,d.op=2,a.splice(h,1),h=o,!pg(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 dT=new Error,hB=new class extends Ua{decide1(t){return t[0]&&t[1]}}(2),bQ=new class extends Em{onPolylineGroup(){throw dT}onSegment(){throw dT}},yC=class{constructor(t,i){this.rtree=t,this.level=i}},pT=class e extends _m{static isIntersect(t,i,r=xc.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 Is.addAll(o,e.getInterY(t.items)),Is.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 Lm(!1),hB.rule,t,bQ)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=hB.weight(i);for(let s of t)this.addPolyline(s,r);let n=this.buildRTree();return this.sides.length=0,new yC(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===dT)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,Sc(r.shape,s.shape)>0)throw dT}}fillValidSides(t,i,r){for(let n of i)isFinite(n.getX(r))&&t.push(n)}sweep(t,i,r){let n=xt.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),Fl(s,(o,l)=>o.getX(r)-l.getX(r),0,s.length);let a=new Rm(this.rule,this,r);for(let o of s)a.onEp(o)}};function fT(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(Qe(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 dB(e){var i;return(i=/url\(#(.*)\)/.exec(e))==null?void 0:i[1]}var bC=47,xQ=47,mT="three-m",xC=` 
<pattern id="${mT}" patternUnits="userSpaceOnUse" x="0" y="0" width="${bC}" height="${xQ}">
    <rect x="0" y="0" width="${bC}" height="${bC}" 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 EQ(e){let i={[mT]:xC}[e];return i||Hr("Not exists exact pattern: ",e),i}function pB(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>
            ${EQ(s)}
        </defs>

        ${n}
        </svg>
    `}var SQ=4,gB=0,yB=0;async function bB(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;gB=0,yB=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 x=fT({material:s,craft:a}),y=(parseFloat(l)||1)*f;A(["LAYER_PHYS",4,x,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 b(7),await b(1),await b(2),await b(3),await b(4),await b(8),await b(6),c[E]=fB(["ITEM_ORDER",h]);let T=c.join(`
`);return{blobStr:u.join(`
`),dataStr:T};async function b(O){let M=e[O];for(let k=M.length-1;k>=0;k--){let G=M[k];await C(G,O)}}async function C(O,M){let{polylineGroup:k,fillColor:G,strokeColor:H,strokeWidth:q,strokeStyle:I,opacity:N,content:v,data:L}=O,_=IQ(k);if(!(N<=0)){if(G.startsWith("url(#")){let B=dB(G),U=k.bbox(),z=[U.LL(),U.UL(),U.UR(),U.LR()].map(Ne=>[Ne.x,Ne.y]).flat(1),W=ls(k.multiply3(he.MIRROR_Y.setOrigin1(U.center())).items,!1,.01,{reverseY:!1}),ne=`<path d="M ${z} Z"
			 fill="url(#${B})" stroke-width="1" stroke="none" opacity="1"></path>`,me=pB(U.minX,U.minY,U.width(),U.height(),ne,B),Ee="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(me))),Se=R(Ee),Fe=gT();A(["TEXTURE",Fe,0,Se,5,z,0,_,N]),h.push(Fe);return}if(v&&L){let B=R(v),U=$e.createMatrixFrom6(L.matrix),z=0,W=1,ne=0,me=1,Ee=[[z,me],[z,ne],[W,ne],[W,me]],Se=[];for(let it of Ee){let je=new V(it[0],it[1]).multiply3(U);Se.push(je.x,-je.y)}let Fe=_,Ne=gT();A(["TEXTURE",Ne,0,B,M,Se,0,Fe,N]),h.push(Ne)}else{let B=M==4;if(B&&(G="#ffffff",H="none"),G&&G!="none"){let U=gT();A(["FILL",U,0,"",M,0,0,_,0]),B||A(["PROP",U,G,N]),h.push(U)}if(H&&H!="none"&&q>0)for(let U of _){let z=gT();A(["POLY",z,0,"",M,q,U,0]),A(["PROP",z,H,N]),h.push(z)}}}}function A(O){c.push(fB(O))}function R(O){if(d[O])return"blob:"+d[O];let M=vQ();return u.push(JSON.stringify(["BLOB",M,"",O])),d[O]=M,"blob:"+M}}function gT(){return"e"+ ++gB}function vQ(){return"b"+ ++yB}function fB(e){return e=e.map(t=>typeof t=="boolean"?t?1:0:t),JSON.stringify(e)}function IQ(e){return e.items.map(AQ)}function AQ(e){return DQ(e).map(CQ)}function CQ(e){return typeof e=="number"&&e&&(e|0)!==e?+e.toFixed(SQ):e}function DQ(e){let t=0;return e.primitives.reduce((i,r)=>(r instanceof te||r instanceof Te&&r.rx===r.ry?i.push(r):r.points(.1).reduce((n,s)=>(s.equals1(n)||i.push(new te(n,s)),s)),i),[]).reduce((i,r)=>{if(r instanceof te){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 Te){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 PQ(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 _Q(e,t,i){let r=t[0]%e,n=t[0]/e|0,s=r,a=n,o=[new V(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 x=Math.sqrt(f**2+m**2),y=f/x,E=m/x;g=Math.abs(y*c-E*l)>i}if(g){if(u.clear(),o.length>1){let x=o[o.length-1],y=o[o.length-2];(x.x-s)*(y.y-a)+(x.y-a)*(y.x-s)===0&&o.pop()}o.push(new V(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 V(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 EB(e,t,i=2,r=2){PQ(e,t);let n=OQ(t,e),s=new Array;n.forEach(o=>{let l=new Array;o.forEach(c=>{let u=_Q(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(LQ(c,r))}return a}function LQ(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 te){let u=n.pop();n.push(new te(u.start(),o))}else n.push(new te(r,o));n.push(new te(o,a))}else n.push(new Ue([r,o,a]));r=a}return Et.build2(n)}function xB(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 OQ(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([xB(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(xB(d,d-1,e,i,1,n,s)),i[d-1]===u[u.length-1]&&i[d]!==1&&u.pop())}}return a}function RQ(e){let t=e.toString(2),i=32-t.length;return i>0?"0".repeat(i)+t:t}var yT=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(RQ(i[r]));console.log(t.join(" "))}};function NQ(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 MQ(e);default:return null}}function MQ(e){var t=e.split(","),i=t[0].match(/:(.*?);/)[1],r=kQ(t[1]);return new Blob([r],{type:i})}function BQ(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 kQ(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|=BQ(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 TB(e){let{source:t,type:i,width:r=100,height:n=100,alphaLimit:s=15}=e,a=NQ(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 yT(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=EB(r,m);return g=g.map(y=>y.map(E=>E.multiply3(he.translate(-1,-1)))),h!==1&&(g=g.map(y=>y.map(E=>E.multiply3(he.scale(1/h))))),new Nr(g.flat())}var w1=class w1 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=w1.proxyMap[t],!r)){let n=`importScripts('${t}');`;r=URL.createObjectURL(new Blob([n],{type:"application/javascript"})),w1.proxyMap[t]=r}super(r,i)}};w1.proxyMap={};var bT=w1;var xT=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 bT(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 ET(){return"_r"+(Math.random()*1e6|0)}function FQ(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 GQ(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=ET(),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=FQ(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 UQ(e){let t={},i=[];return e=e.replace(/(\s(?:id="))([^"]+)/g,(r,n,s)=>(i.includes(s)||(i.push(s),t[s]=ET()),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 EC(e){e=UQ(e),e=GQ(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[T,w]=E.trim().split('="');s[T]=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),x=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+x,f=EC(f),`<g transform="${u||""}" opacity="${h||1}">
${f}
</g>`})),e}var S1=4,v1=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}=$e.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 TB(c);if(d){let p=$e.createMatrixFrom6(a),f=he.translate(0,l).scale(1/o,1/l).multiply3(p);return d=d.multiply3(he.MIRROR_Y).multiply3(f).multiply3(he.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=Gt(i,"mm","pixel"),s=Gt(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=Gt(i,"mm","pixel"),s=Gt(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=Gt((o-l)/2,"mm","pixel"),h=Gt(-a-(c-a)/2,"mm","pixel"),d="";for(let p of t){let{polylineGroup:f,fillColor:m,strokeColor:g,strokeWidth:x,opacity:y,content:E,data:T}=p,w=ls(f.items,!1);if(w=vm(w,S1),E&&T){let b=`matrix(${T.matrix})`,C=E.startsWith("data:image/svg+xml;base64,"),A;if(C){let G=E.slice(E.indexOf(",")+1),H=decodeURIComponent(escape(atob(G)));if(H.includes("<script")||H.includes("<foreignObject"))continue;H=H.slice(H.indexOf("<svg"));let q=H.indexOf(">"),I=H.slice(0,q+1),N=H.slice(q+1),v=(B,U)=>{var ne;let z=new RegExp(`\\s+${U}="([^"]*)"`);return((ne=B.match(z))==null?void 0:ne[1])||""},L=B=>{var W;B=B.toLowerCase(),B=B.replace(/px/,"").trim();let U=(W=B.match(/[a-z]+$/i))==null?void 0:W[0],z=parseFloat(B);return z&&J3(U)&&(z=Gt(z,U,"pixel")),z||0},_=v(I,"viewBox");if(!_){let B=v(I,"width"),U=v(I,"height");if(B&&U){let z=L(B),W=L(U);_=`0 0 ${z} ${W}`}else _=`0 0 ${T.width} ${T.height}`}I=I.replace(/\s(x|y|width|height|transform|xmlns|xmlns:xlink|xml:space|version|style|id|preserveAspectRatio|opacity|viewBox)=".*?"/g,""),I=I.replace(/<svg(\s|>)/,`<svg x="0" y="0" width="1" height="1" preserveAspectRatio="none" opacity="${y}" viewBox="${_}"$1`),H=I+N,H=EC(H),A=`<g data-origin-id="${T.gId}" transform="${b}">
${H}
</g>`}else tB(E)&&(E=await iB(E)),A=`<image x="0" y="0" width="1" height="1" opacity="${y}" transform="${b}" preserveAspectRatio="none" xlink:href="${E}"/>`;let R=`<path d="${w}" fill="#ffffff" stroke="none"/>`,O=ET(),M=`<defs><mask id="${O}" maskUnits="userSpaceOnUse" x="${u}" y="${h}">${R}</mask></defs>`,k=`mask="url(#${O})"`;d+=`
${M}
<g ${k}>
${A}
</g>
`}else{m===void 0&&(m="none"),x===void 0&&(x=0),g===void 0&&(g="none"),y===void 0&&(y=1);let b=`<path d="${w}" fill="${m}" stroke-width="${x}" stroke="${g}" opacity="${y}" ${s}/>`;d+=n?`
<g>${b}</g>`:`
${b}`}}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=Gt(i,"mm","pixel"),a=Gt(r,"mm","pixel"),o=Gt(-n,"mm","pixel"),l=Gt(-r+n,"mm","pixel"),c=vm(`M${o} ${l} ${s} ${a}`,S1).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:x}=this._docBBox,y=50,E=Math.max(g+y*2,d),T=Math.max(x+y*2,p),w=f+g/2-E/2,b=m+x/2-T/2;i=Gt(E,"pixel","mm"),r=Gt(T,"pixel","mm"),c=vm(`M${w} ${b} ${E} ${T}`,S1).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=jQ(t,this._head);return i=vm(i,S1),`<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=vm(r,S1),[{polylineGroup:new Nr(Yi(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&&Nr.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,x=m.opacity;if(!pT.isIntersect(g,u))continue;let y=g.items,E=_i.boolIntersection([y,d]);if(!E.length)continue;f=!0;let T=this.getOpacityMergeValue(h,x,i);if(T==h&&T==x){let w=_i.boolAggregate([y,d]),b=o(w);g.items.length=0,b?d=b.items:d.length=0;continue}else if(T==h){let w=_i.boolSubtraction(y,d),b=o(w);b?m.polylineGroup=b:g.items.length=0;continue}else if(T==x){let w=_i.boolSubtraction(d,y),b=o(w);b?d=b.items:d.length=0;continue}else{let w=_i.boolSubtraction(y,d),b=_i.boolSubtraction(d,y),C=o(w),A=o(b),R=o(E),O={...m,polylineGroup:R,opacity:T};C?(m.polylineGroup=C,a.push(O)):(m.polylineGroup=R,m.opacity=T),A?d=A.items:d.length=0;continue}}p.length&&a.push(...p),d.length&&(f&&(c.polylineGroup=new Nr(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?[Nr.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 _i.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=_i.boolSubtraction1([o.polylineGroup.items].concat(s));if(l.length){let u=(r?[Nr.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 te)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,x=m.bbox(),y=a(f);if(h.isSeparated(x))continue;let E=r?this.getOpacityMergeValue(l.opacity,f.opacity,r):l.opacity;if(h.isInside(x)&&!y){let w=wB(h);if(!_i.boolSubtraction([w],g).length){n.push({...l,opacity:E});continue}}if(x.isInside(h)&&!d){let w=wB(x);if(!_i.boolSubtraction([w],u).length){n.push({...l,polylineGroup:m,opacity:E});continue}}let T=_i.boolIntersection([u,g]);if(T.length){let w=Nr.combinePolylineGroupArr(T);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=_i.convertJsonCache2PolyLines({d:t.d},"group"),a=he.MIRROR_Y.multiply3($e.createMatrixFrom6(t.matrix).multiply3(he.MIRROR_Y));return s.multiply3(a).round(4)}return _i.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)pg(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=fg(c,i);u.updatedItems.concat(u.noChangeItems).map(d=>d.polylineNew||d.polyline).forEach(d=>{n.push({...t[0],polylineGroup:new Nr([d])})})}}),r.length<1)return n;if(r.length===1)return r[0]=r[0].asClose(),n.push({...t[0],polylineGroup:new Nr(r)}),n;let s=fg(r,i);s.noChangeItems.forEach(o=>o.polyline=o.polyline.asClose());let a=s.updatedItems.concat(s.noChangeItems).map(o=>({...t[0],polylineGroup:new Nr([o.polylineNew||o.polyline])}));return n=n.concat(a),n}init(t,i=!0){let r=t.head.docType==gs.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=Zt(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&&eo(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]),Fa(m)&&Hr(u,"\u6CE8\u610F\uFF1A\u5B58\u5728\u65E0\u6392\u5E8F\u4FE1\u606F\u5F97\u56FE\u5143")})}eo(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)&&eo(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,x=1,y=r==1,E=r==6,T=r==5,w=r==2,b=r==7,C=r==3||r==4,A=m=="obj"&&!!f&&f.startsWith("data:image/"),R=m=="text";if((y||E)&&n<.001)return[];if(m==="obj"&&!A)return[];c=c||0,d===!1&&(h="none"),p===!1&&(l="none"),R&&(h=h||l||"#000000",l="none"),h=h||"none",l=l||"none",T&&(h="none",l=Iv[r],c=1,n=1),C&&(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,x=1-t.transparencyWhite||0,n=i?x:g),r==7&&(h="none",l="#ff00ff",c=1,n=1),Object.assign(t,{fillColor:h,strokeColor:l,strokeWidth:c,opacity:n});let O={jsonKey:m,gId:t.gId,polylineGroup:this.jsonObjToPolylineGroup(t,m),layer:r,opacity:n,opacityCover:x,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((T||w||b)&&m==="group"){let{polylineGroup:M}=O;return HQ(M),_i.boolSubtraction(M.items,[]).map(H=>({...O,polylineGroup:H}))}return y&&!A||E?this.buildSvgJsonFillStroke(O):[O]}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=(T,w)=>T.filter(b=>w.includes(b.scope)),m=async T=>{let w=[];for(let b of T){let{content:C,data:A}=b;if(!!(C&&A)){let{polylineGroup:O}=b,M=await this.getImageOutline({polylineGroup:O,content:C,data:A}),k={...b,polylineGroup:M,content:"",data:null};w.push(k)}else w.push(b)}return w},g=this.makeProgressForward(r,0,1,n.length+1),x={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 T=0,w=E?1:n.length;T<w;T++){console.time("build 1.2 "+(T+1)+"/"+w);let b=E?null:n[T].polylineGroup.bbox(),C={};for(let O of y){if(E){C[O]=x[O];continue}C[O]=[];let M=x[O];for(let k of M)k.polylineGroup.bbox().isIntersect(b)&&C[O].push(k)}let A=E?n:[n[T]],R=C[4]||[];{let O=C[1]||[];O=this.intersectSvgJson(O,A);let M=O.slice(),k=C[2]||[],G=k;G=f(G,[2,1]),G=G.filter(q=>q.opacity<1),G=this.getOpacitySvgJson(A,G),console.time("build 2.3"),O=this.intersectSvgJson(O,G,1),console.timeEnd("build 2.3"),t&&(O=this.subSvgJson(O,R,!1)),O=O.filter(q=>q.opacity>=.001),o=o.concat(O);let H=k.map(q=>({...q,opacity:q.opacityCover}));H=f(H,[3,1]),H=H.filter(q=>q.opacity<1),H=this.getOpacitySvgJson(A,H),M=M.map(q=>{let{fillColor:I,strokeColor:N,content:v,data:L,jsonKey:_}=q;return I!="none"&&(I="#ffffff"),N!="none"&&(N="#ffffff"),(!!(v&&L)||_=="obj")&&(I="#ffffff",N="none"),{...q,fillColor:I,strokeColor:N}}),M=await m(M),M=this.purifyCoverData(M),M=this.intersectSvgJson(M,H,1),t&&(M=this.subSvgJson(M,R,!1)),M=M.filter(q=>q.opacity>=.001),h=h.concat(M)}{let O=C[2]||[];O=this.applyGlueStroke(O,2),O=this.mergeSvgJson(O,!1),O=this.extendSvgJson(O,Gt(0,"mm","pixel")),O=this.intersectSvgJson(O,A);let M=C[7]||[];M=this.applyGlueStroke(M,7),M=this.mergeSvgJson(M,!1),M=this.extendSvgJson(M,Gt(0,"mm","pixel")),M=this.intersectSvgJson(M,A);let k=C[5]||[];k=this.mergeSvgJson(k,!1),k=this.applyGlueStroke(k,5),k=this.extendSvgJson(k,Gt(0,"mm","pixel")),k=this.intersectSvgJson(k,A);let G=this.subSvgJson(A,R,!1);G=this.applyGlueStroke(G,3);for(let N of G)N.polylineGroup.items.shift();let H=Gt(0,"mm","pixel");G=this.extendSvgJson(G,H);let q=this.mergeSvgJson([...G,...k,...O,...M]),I=this.createEntireGlue(A,q);this._boardGroup[8]=I,l=l.concat(G,k,O,M)}{let O=this.subSvgJson(A,R,!1);s=s.concat(O)}{let O=C[7]||[];O=this.intersectSvgJson(O,A),O=this.subSvgJson(O,R,!1),u=u.concat(O)}{let O=C[6]||[];c=c.concat(O)}g(),console.timeEnd("build 1.2 "+(T+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(#"+mT+")",n.strokeColor="none";return r}applyGlueStroke(t,i){return t.map(r=>({...r,opacity:1,fillColor:"none",strokeColor:Iv[i],strokeWidth:1}))}createJsonCache(t){let i={...t};for(let r of II)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:ls(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];eo(E,(T,w)=>{let{layer:b,hide:C}=w;C||c.includes(+b)&&(b==3?r.push(w):b==4&&n.push(w),II.includes(y)&&(o[T]=fE(w,y),l[T]=w),s.includes(T)||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(he.MIRROR_Y));d.sort((y,E)=>{let T=p[y].minY-p[E].minY,w=p[y].minX-p[E].minX;return Math.abs(T)<5&&Math.abs(w)>5?w:Math.abs(T)>5&&Math.abs(w)<5?T:T||w});let f=u.length,m=Array(f),g=.3,x=.7/f;for(let y of d){let E=p[y],T=this.createJsonCache(t),{minX:w,minY:b,maxX:C,maxY:A}=E;T.BBox={x:w,y:b,width:C-w,height:A-b},m[y]=T;let R={};eo(o,(k,G)=>{let H=l[k],{layer:q,cmdKey:I}=H;q!=3&&G.isIntersect(E)&&(T[I][k]=H,R[k]=!0)}),T.itemOrder=s.filter(k=>R[k]===!0);let O=this.createBoardId(R,y);T.itemOrder.unshift(O);let M=this.createBoardJsonItem(u[y],O);T.group[O]=M,i(g+=x)}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=>Et.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)&&!_i.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=lu}={}){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=>xt.extendRect(p.BBox)).reduce((p,f)=>xt.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 xT;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=x=>{let y=x.result;c.set(y),p(),console.log(`task complete: ${++m} / ${u}`)};for(let x of s)f.addTask({op:"generateSvgData",args:[{jsonCache:x,forPreview:i}]}).then(g);f.start(),await f.all().finally(()=>f.destroy()),await Z3(100)}else for(let p of s){let m=await new e().generateSvgData(p,{forPreview:i,progressCallback:r,boardGroupCallback:g=>{for(let x of[7,4,3,1,2,8,6])this._boardGroup[x]=g[x].concat(this._boardGroup[x]||[])}});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=lu,boardGroupCallback:n=lu}={}){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 bB(o,this._head);return i(1),{blobStr:l,dataStr:c,productionSvg:this.getProductionSVG(s)}}};function wB(e){return Et.build4([e.UL(),e.UR(),e.LR(),e.LL(),e.UL()])}function HQ(e){e.items.map((t,i)=>(t.closed()||(e.items[i]=t.asClose()),t))}var SB=new v1;function jQ(e,{width:t,height:i}){let r=Gt(10,"mm","pixel"),n=Gt(2.5,"mm","pixel"),s=Gt(t,"mm","pixel"),a=Gt(i,"mm","pixel"),o=Gt(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 Zp(e,t){return e.map(i=>{let r=i.id,{json:n,cmdKey:s}=F.getById(i.id);return t.includes(s)?{gId:r,jsonObj:n,element:i}:null}).filter(i=>i&&!!i.jsonObj)}function TT(e){let t=[];for(let i in e.ellipse||{}){let r=_t(),n=e.ellipse[i];n.gId=r;let s=Gy(n,r);t.push(s)}for(let i in e.rect||{}){let r=e.rect[i],n=_t();r.gId=n;let s=Fy(r,n);t.push(s)}for(let i in e.group||{}){let r=e.group[i],n=_t();r.gId=n;let s=rl(r,n);t.push(s)}for(let i in e.text||{}){let r=e.text[i],n=_t();r.gId=n;let s=Fm(r,n);t.push(s)}for(let i in e.obj||{}){let r=e.obj[i],n=_t();r.gId=n;let s=Uy(r,n);t.push(s)}for(let i in e.arc||{}){let r=e.arc[i],n=_t();r.gId=n;let s=lh(r,n);t.push(s)}for(let i in e.auxiliaryLine||{}){let r=e.auxiliaryLine[i],n=_t();r.gId=n;let s=Yy(r,n);t.push(s)}for(let i in e.auxiliaryPoint||{}){let r=e.auxiliaryPoint[i],n=_t();r.gId=n;let s=Op(r,n);t.push(s)}return t}function VQ(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 zQ(e){let i=Yi(e).map(n=>n.reverse()).reverse();return ls(i,!1)}function XQ(e){let t=Yi(e),i=.05,r=t.map(s=>s.simplify(i));return ls(r,!1)}function WQ(e){let[t,i,r,n,s,a]=e,o=new he([t,i,0,r,n,0,s,a,1]),l=new V(0,0).multiply3(o),{x:c,y:u}=l,h=new V(1,0).multiply3(o),d=new V(0,1).multiply3(o),p=h.distance1(l),f=d.distance1(l);return{cx:c,cy:u,rx:p,ry:f}}function vB(){let e=Ce.get(),t=["rect","ellipse","text","arc"],i=Zp(e,t);if(!i.length)return;let r=[],n=[];i.forEach(s=>{let{gId:a,jsonObj:o,element:l}=s,c=Ap(o),u=_t(),h=F.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=rl(h,u);J.gCanvas.insertBefore(d,l),r.push(zr(a,{cmdKey:o.cmdKey,refId:Fn(l)},o,{})),F.removeOne(l),r.push(zr(u,{cmdKey:"group",refId:Fn(d)},"",h)),n.push(d)}),r.length&&at.save(r),Xt(),Ce.unselectAll(),Ce.select(n),n.length===1&&Gs(n[0]),_e("panel_updateAttrPanel")}function IB(){let e=Ce.get(),t=["ellipse","group","rect","arc"],i=Zp(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:x,strokeWidth:y,displayStroke:E,rx:T,ry:w}=o;if(!E)return;let b=$e.expandRectMatrixByStrokeWidth(x,y,!0);u=Co({...o,rx:T+y/2,ry:w+y/2,matrix:b});try{let A=$e.expandRectMatrixByStrokeWidth(x,y,!1),R=Co({...o,rx:Math.max(0,T-y/2),ry:Math.max(0,w-y/2),matrix:A},{ccw:!0});u+=R}catch(A){console.error(A)}}else if(o.cmdKey==="ellipse"){let{strokeWidth:x,matrix:y}=o,E=x/2,T=WQ(y),{cx:w,cy:b}=T,C=$e.calcuEllipse(y);if(u=Yl({rotation:C.degree,cx:w,cy:b,rx:C.a+E,ry:C.b+E},{ccw:!1}),E<C.a&&E<C.b){let R=Yl({rotation:C.degree,cx:w,cy:b,rx:C.a-E,ry:C.b-E},{ccw:!0});u+=R}}else{let x=_i.convertJsonCache2PolyLines(o,o.cmdKey),y=lM(x,o.strokeWidth);if(!y.length)return;u=y.map(E=>ls(E.items,!1)).join(" ")}let h=[o.strokeColor,o.fillColor,"#000000"].find(x=>x&&x!="none"),{json:d,cmdKey:p}=F.getById(l.id),f=F.getInitialGroupData({gId:_t(),layer:d.layer});f.d=u,f.fillColor=h,f.strokeColor="none",f.strokeWidth=0;let m=rl(f);if(J.gCanvas.insertBefore(m,l.nextSibling),r.push(zr(m.id,{cmdKey:"group",refId:Fn(m)},"",f)),o.fillColor&&o.fillColor!=="none"){re(l,"stroke-width",0),re(l,"stroke","none");let x=Zt(d);x.strokeWidth=0,x.strokeColor="none",r.push(zr(l.id,{cmdKey:p,refId:Fn(l)},d,x)),o.strokeWidth=0,o.strokeColor="none"}else r.push(zr(l.id,{cmdKey:p,refId:Fn(l)},d,"")),F.removeOne(l);n.push(m)}),r.length&&(r.length&&at.save(r),Xt(),Ce.unselectAll(),Ce.select(n),n.length===1&&Gs(n[0]),_e("panel_updateAttrPanel"))}function AB(){let e=Ce.get().sort(VQ),t=["rect","ellipse","group","arc"],i=Zp(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=Ap(u);s.push(d.trim()),n.push(h)}),!s.length)return;Xt();let a=i.slice(-1)[0].element,{json:o}=F.getById(a.id),l=F.getInitialGroupData({gId:_t(),layer:o.layer,d:s.join(" "),strokeWidth:o.strokeWidth,strokeColor:o.strokeColor,strokeStyle:o.strokeStyle,fillColor:o.fillColor});ni.renderer.insertBefore(l,a.id),r.push(zr(l.gId,{cmdKey:"group",refId:a.id},"",l));for(let c of n){let{cmdKey:u,json:h}=F.getById(c.id);r.push(zr(c.id,{cmdKey:u,refId:Fn(c)},h,"")),F.removeOne(c)}at.save(r),Ce.select([{id:l.gId}])}function CB(){let e=Ce.get(),t=["group"],i=Zp(e,t);if(!i.length)return;Xt();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:_t()}),p=rl(d);J.gCanvas.insertBefore(p,l),r.push(zr(p.id,{cmdKey:"group",refId:l.id},"",d)),n.push(p)}r.push(zr(a,{cmdKey:"group",refId:Fn(l)},o,"")),F.removeOne(l)}),r.length&&at.save(r),Ce.select(n)}async function DB(e={warnSvg:!1}){var c;let t=Ce.get(),i=["obj"],r=Zp(t,i);if(!r.length)return;let n=[],s=[],a=new v1,o=Au.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=ls(d.items,!1),f=Object.assign({},o,{d:p,gId:_t()}),m=rl(f);n.push(zr(m.id,{cmdKey:"group",refId:(c=m.nextElementSibling)==null?void 0:c.id},"",f)),s.push(m)}l&&(e!=null&&e.warnSvg)&&!n.length&&wT({type:"warn",message:"This file type is not currently supported"}),n.length&&(rs({value:"Outline has been generated."},"success"),n.length&&at.save(n),Xt(),Ce.select(s))}function PB(e){e=e||Ce.get();let i=["group","arc"],r=Zp(e,i);if(!r.length)return;let n=r.map(u=>{if(u.jsonObj.cmdKey=="arc"){let d=u.jsonObj.matrix&&$e.createMatrixFrom6(u.jsonObj.matrix),p=gd(u.jsonObj),f=Yi(p);return d&&(f=f.map(m=>m.multiply3(d))),{...u,polylines:f}}let h=Yi(u.jsonObj.d);return{...u,polylines:h}});n=n.filter(u=>u.polylines.some(h=>pg(h)));let s=[],a=[],o=[];n.forEach(u=>{let{gId:h,jsonObj:d,element:p,polylines:f}=u;if(f.length>1){let m=fg(f,.01);if(m.updatedItems.length){let g=m.updatedItems.map(y=>y.polylineNew),x=ls(g,!1);s.push(zr(h,{refId:Fn(p),cmdKey:"group"},d,{...d,d:x})),re(p,"d",x),d.d=x,a.push(p)}return}o.push(u)});let l=o.map(u=>u.polylines[0]),c=fg(l,.01);c.removedItems.forEach(u=>{let h=o[u.index],{gId:d,element:p}=h,{cmdKey:f,json:m}=F.getById(p.id);s.push(zr(d,{cmdKey:f,refId:Fn(p)},m,"")),F.removeOne(p)}),c.updatedItems.forEach(u=>{let h=o[u.index],{gId:d,jsonObj:p,element:f}=h,m=ls([u.polylineNew],!1);s.push(zr(d,{refId:Fn(f),cmdKey:"group"},p,{...p,d:m})),re(f,"d",m),p.d=m,a.push(f)}),s.length&&(at.save(s),Xt(),Ce.select(a))}function _B(e,t){t=t||Ce.get();let i=["group"],r=Zp(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&&(re(c,"d",h),n.push(zr(o,{cmdKey:"group",refId:Fn(c)},Zt(l),Zt(l).d=h)),l.d=h,s.push(c))}),n.length&&(at.save(n),Xt(),Ce.select(s))}function LB(e){_B(zQ,e)}function OB(e){_B(XQ,e)}function RB(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,""),re(e,r,n)}}function TC(){let t=Ha(new XMLSerializer().serializeToString(J.gCanvas)).getElementById("g1"),i=t.children;for(let y of Array.from(i))re(y,"hide")==1?t.removeChild(y):RB(y);let r;for(;r=jr(".hitbox",t);)dt(r);let n=de("panelFrameSheet").cloneNode(!0);t.insertBefore(n,t.firstElementChild);let s=J.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}=cs(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),x=Array.from(document.styleSheets).reduce((y,E)=>{if(E instanceof CSSStyleSheet&&!E.href&&!E.disabled)try{y+=Array.from(E.cssRules).map(T=>ih(T.cssText)).join("")}catch(T){console.warn("ERROR",T)}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>${x}</style>${a}${g}</svg>`}var wC={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 qQ(e){return e.map(JQ).filter($Q)}function JQ(e){let{cmdKey:t,json:i}=F.getById(e);if(!t)return;let r=wC[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:yi.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=wE(i.rotation)),s}function KQ(e){return!!e}function $Q(e){return KQ(e)}var mg=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)}};mg.layer={4:!0,2:!0,1:!0,3:!0,5:!0,6:!0,7:!0,8:!0},mg._all=!0;function NB(){let e=qQ([...F.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:AR[n],list:s,iconColor:"orange",type:"PanelLayer",visible:mg.layer[n]}});return[{name:fn("getActiveFileTitle"),type:"Panel",iconColor:J.doctype===gs.PANEL_LIB?"":"primaryBlue",visible:mg.all,list:i}]}var ZQ=["ellipse","group","polyline","rect","text","obj","canvas","arc","dimension","auxiliary"];function QQ(e){let t={};return ZQ.forEach(i=>{Object.assign(t,e[i]?e[i]:{})}),t}var MB={"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},I1={visible:!1,hide:!0,lock:!0,unlock:!1},SC={"fully-transparent":0,translucence:.5,opacification:1},vC={"have-white-background":!0,"no-white-background":!1};function eee(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=F.gJsonCache,o=Ga(),l=[],c=o[t]?Object.keys(o[t]):[t],u=QQ(a);for(let h=0;h<c.length;h+=1){let d=c[h],p=[];if(Qe(o["all-element-type"],d)&&(n&&(o["all-element-type"][d].checked=i),s&&(o["all-element-type"][d].visible=r)),Qe(a,d)&&(p=Object.keys(a[d])),d==="dimension"&&(p=Object.keys(F.getDimension())),d==="dimensionLength"){let f=F.getDimensionAngle(),m=F.getDimensionLength(),g=F.getDimensionRadius();p=[...Object.keys(f),...Object.keys(m),...Object.keys(g)]}if(d==="auxiliaryLine"){let f=F.getAuxiliaryLine(),m=F.getAuxiliaryPoint();p=[...Object.keys(f),...Object.keys(m)]}if(MB[d]){Qe(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==MB[d]&&p.push(f)}if(I1[d]!=null){Qe(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==I1[d]&&p.push(f);break;case"hide":u[f].hide==I1[d]&&p.push(f);break;case"lock":u[f].locked==I1[d]&&p.push(f);break;case"unlock":u[f].locked==I1[d]&&p.push(f);break}}if(SC[d]!==void 0){Qe(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==SC[d]&&p.push(f);break;case"translucence":u[f].opacity>0&&u[f].opacity<1&&p.push(f);break;case"opacification":u[f].opacity==SC[d]&&p.push(f);break}}if(vC[d]!==void 0){Qe(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===vC[d]&&p.push(f);break;case"no-white-background":u[f].cover==vC[d]&&p.push(f);break}}if(d=="boundary"){let f=o["all-layer"][d];Qe(o["all-layer"],d)&&(n&&(f.checked=i),s&&(f.visible=r)),Js(de("panelFrameSheet"),"hide",f.visible)}l.push(...p)}for(let h of l)yi.applyElementsVisible(h)}function BB(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])}eee(e)}function Bo(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},BB(s)}}return}let t=Ga();for(let i in t)for(let r in t[i]){let n=Zt(t[i][r]),s={[r]:n};n.checked===!0&&delete n.checked,n.visible===!0&&delete n.visible,Object.keys(n).length!==0&&BB(s)}}var Xa=class{constructor(){this.id="panelFrameSheet"}init(t){let i=t.docType===gs.PANEL_LIB?"none":"";this.isHidden()&&(i="none"),ni.renderer.removeNode(this.id);let r=Tt("path",{id:this.id,fill:"none",stroke:"red","stroke-width":"1","pointer-events":"none","vector-effect":"non-scaling-stroke",display:i});return J.gCanvas.parentNode.insertBefore(r,J.gCanvas.nextElementSibling),this.update(),r}update(){ni.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){ni.renderer.attr(this.id,"display",t?"":"none")}isHidden(){var i;let t=(i=tt.getCurrentScheme())==null?void 0:i.options.find(r=>r.id===-1);return(t==null?void 0:t.visible)===!1}getMarkSize(){let t=Gt(10,"mm","pixel"),i=Gt(2.5,"mm","pixel"),r=Gt(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}=F.getHead(),r=Gt(parseFloat(t),"mm","pixel"),n=Gt(parseFloat(i),"mm","pixel");return{w:r,h:n}}};var gg=class gg{static refreshCanvas(t){let i={},r=!1,n=mi.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&&mi.modify_canvas(i)}static updateGlobalTheme(t){let r=document.getElementById("themeStyle").sheet,n=gg.getRootRuleIndex(r);n!=-1&&r.deleteRule(n);let s=Av(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=J.profileSetting.commSystemSetting.PANEL_THEME){let i=t||J.panelThemeCache;this.rebuildPanelThemeCache(t);let{color:r}=i;this.refreshCanvas(r),this.updateGlobalTheme(i)}static rebuildPanelThemeCache(t){J.panelThemeCache=t}};gg.customizeKey="customize",gg.blackKey="black",gg.whiteKey="white";var A1=gg;function kB(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 IC={text:"text",arc:"arc",rect:"rect",polyline:"line",group:"line",circle:"circle",line:"line",ellipse:"ellipse",auxiliaryPoint:"auxiliaryPoint",auxiliaryLine:"auxiliaryLine"};async function FB(){let e=(await J.windowBridge.rpcCall("getProfileSetting","",ut())).message,t=(await Ro("getPanelFilterConfigDetail",[J.tabId])).message;Bo(t);let i=+e.commSystemSetting.PANEL_CANVAS.panel_gridSize;i=ya(i);let r=+e.commSystemSetting.PANEL_CANVAS.panelAltSnapGridSize;r=ya(r),nd("adsorbGrid","distanceX",i),nd("adsorbGrid","distanceY",i),nd("adsorbGrid","gridSize",i),nd("adsorbGrid","altSnapSize",r),await Gr.updateConfig(),Qe(e,"commSystemSetting")?J.profileSetting=e||{}:(J.profileSetting||(J.profileSetting={}),J.profileSetting.commSystemSetting=e);let n=J.profileSetting,s=n.commSystemSetting.OBJECT;if(s){let a=s.theme.activeTheme||"color";s.theme[a]&&(Xe.canvas.bgColor=s.theme[a].color.background,Xe.canvas.gridColor=s.theme[a].color.grid)}n.commSystemSetting.PANEL_CANVAS.gridStyle&&(n.commSystemSetting.PANEL_CANVAS.gridStyle==="not"?Xe.adsorbGrid.visible=!1:(Xe.adsorbGrid.visible=!0,Xe.adsorbGrid.gridType=n.commSystemSetting.PANEL_CANVAS.gridStyle)),n.commSystemSetting.PANEL_CANVAS.gridSize&&(Xe.adsorbGrid.gridSize=n.commSystemSetting.PANEL_CANVAS.gridSize),J.windowBridge.publish("tabChange",{tabId:J.tabId,docType:J.doctype},ut())}function yg(){return"rightClickEnd"}var GB="--selectColor",ST=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 Ro("getUserInfoFromCache")).message;let t=(await J.windowBridge.rpcCall("getActiveProject",null,ut())).message;this.canPublishSelect=(await J.windowBridge.rpcCall("ui/hasDocCreatePermission",{projectId:t,showMsg:!1},ut())).message}getSelect(){let t=Ce.getIds().slice(0,1e3).map(i=>({cmdKey:F.getById(i).cmdKey,uuid:i}));return JSON.stringify({data:t,updateTime:+new Date})}onDestroy(t,i){this.userSelectMap.delete(t),Ki.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 J.windowBridge.rpcCall("getUserColor",t.uuid,ut())).message;this.userSelectMap.set(t.uuid,{user:t,selected:s.data,updateTime:a,selectColor:o}),Ki.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}))}),Ce.getIds().forEach(r=>{let n=F.getById(r).cmdKey;t.set(r,{cmdKey:n,color:GB,uuid:r})}),t}getSelfSelectMap(){let t=new Map;return Ce.getIds().forEach(i=>{let r=F.getById(i).cmdKey;t.set(i,{cmdKey:r,color:GB,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 AC(e,t,i){vT(0);let r=(await J.windowBridge.rpcCall("getActiveProject",null,ut())).message,n=t===r,s=F.compilerManager;if(!F.compilerManager){let d=x0.PANEL_LIB===i.docType,p=new cg(d);if(s=new $p(e,t,n,p),F.selectedRepeater=new ST(s),await F.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",E1),await s.save()),vT(.5),s.pauseDateMerge(),F.compilerManager=s,mi.clear(),UB(a),bn().setOriginXY(),mi.initCanvasSize(i),await FB();let c=await Pn.toSVG(a);i.docType&&(J.doctype=i.docType,F.gJsonCache.head.docType=i.docType);let u=Ha(c);if(!u){console.error("Invalid Xml",c);return}let h=document.importNode(u.documentElement,!0);if(!h){wT({type:"error",message:"import node failure"});return}if(vT(.8),A1.setTheme(),CC(),new Xa().init(i),h=jr("g",h),h){let d=document.createDocumentFragment();for(;h.firstChild;)d.appendChild(h.firstChild);J.gCanvas.appendChild(d),d=null}vT(1),Lt.setShapeCache(),at.clear({saved:i.saved}),bn().fitview(),s.resumeDataMerge(),_e("switchGridSizeBtn",{value:qs(Xe.adsorbGrid.gridSize)}),_e("setTopMenuItemsChecked",{"unit(mm)":!0}),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel_updateAttrPanel")}function vT(e){fn("progressUpdate",[e,"Open Panel","OpenPanel"])}var IT=class{constructor(t){this.encoder=new X4(t)}uploadJsonCache(t){Iu.uploadJsonCache(this.encoder,t)}getDataStr(){return this.encoder.getDataStr()}};var tee={CANVAS:"onCanvas",POLY:"onPoly",GROUP:"onGroup",STRING:"onString",DIMENSION:"onDimension",AUXLINE:"onAuxLine",BLOB:"onBlob"},bg=class extends eC{constructor(i=F.compilerManager){super();this.compiler=i;this.success=!1}async decodeDataStr(i){let r=F.exchangeJsonCache(F.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=tee[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 YB(){let e=J.profileSetting&&J.profileSetting.commSystemSetting&&J.profileSetting.commSystemSetting.PANEL_CANVAS.cursor;return(J.profileSetting&&J.profileSetting.commSystemSetting&&J.profileSetting.commSystemSetting.PANEL_CANVAS.schAlwaysDisplayCursor)===!0&&e!=="None"}function HB(){YB()&&(J.helperCursor="cross-red")}function jB(){let e=YB();J.helperCursor=e?"cross-red":J.cmdToken?J.helperCursor:""}function VB(){return J.profileSetting.commSystemSetting.PANEL_CANVAS.cursor==="Small"}function bn(){return{openDocComplete:()=>{J.openDocComplete=!0},getOpenDocComplete(){return J.openDocComplete},fitview:_C,"color-exchange"(){$B()},duplicateToCursor(){if(Ce.getIds().length==0){J.windowBridge.publish("panelMessage",{type:"show",timeout:3e3,title:"Information",msg:"Nothing selected",showType:"slide"},ut());return}Ir.exit(),J.frameHelper.getToolProcessor().switchToPasteTool("duplicate")},projectPermission(){return Dd.forbiddenDataChange()},decodeNewJsonStr:async e=>{let t=new bg,{jsonCache:i,success:r}=await t.decodeDataStr(e);return r?i:!1},uploadJsonCache2:async(e,t)=>(Iu.uploadJsonCache2(e),at.clear({saved:t.saved}),await F.compilerManager.getJsonCache()),importDocEdit:AC,"-syncImportDocEdit":async e=>{let{uuid:t,path:i,options:r}=e;await AC(t,i,r)},closeDoc(){var e;(e=F.compilerManager)==null||e.destroy()},duplicatePaste:async()=>{if(!Ce.getIds().length){J.windowBridge.publish("panelMessage",{type:"show",timeout:3e3,title:"Information",msg:"Nothing selected",showType:"slide"},ut());return}XB(),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),J.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 F.compilerManager.save()},"panel/resumeDataMerge"(){F.compilerManager.resumeDataMerge()},unlockAll(){wr.unlockAll(),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},showAll(){yi.showAll(),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},hide(){let e=Ce.getIds();yi.toggleElementsDisplay(e,!1),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},unhide(){let e=Ce.getIds();yi.toggleElementsDisplay(e,!0),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},showRuler(){_e("changeRulerVisible",[window.frameElement.classList.contains("un_ruler"),J.tabId])},modifyCanvas:mi.modify_canvas,setTabId:function(e){console.warn("you may not have to setTabId, because tabId already exist",J.tabId),e&&(J.tabId=e)},updateSystemConfig:function(e){J.profileSetting=e,J.topMenuStatus.sync(),Gr.updateConfig(),jB(),J.helperCursor||ps(!1)},rotate(e){let i=Mc(),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 de(c)}),r=r.filter(function(c){return c&&ba(c.parentNode,Ml)}),r.length){let c=new oi(r);kc(r,e),Tn(r),!i&&c.updateAndSave(),_e("panel_updateAttrPanel")}return}let a=J.frameHelper.getToolProcessorCurrentTool(),o=a==null?void 0:a.getSymbol();if([br.drag_tool,br.paste_tool,br.place_lib_tool,br.draw].includes(o)){a.rotate(e),_e("panel_updateAttrPanel");return}if([br.rotate_by_anchor_tool,br.drag_control_dot_tool].includes(o))return;let l=new dg(vr(),{notSaveHistory:i});return l.do(e),_e("panel_updateAttrPanel"),Ki.debouncedAppendSelectStroke(),l.success},delete(){_o(),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},"delete-all":function(){OC(),_o(),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},duplicateTo:function(...e){xg.do(...e)},storeImageData:function(e){J.defaultImage=e},forceReleaseToken:function(){Jp()},getJsonCache(e={getPath:!1}){return F.getGJsonCache(e.getPath)},getActiveCompressStr(){let e=new IT(J.tabId.split("@")[0]);return e.uploadJsonCache(F.gJsonCache),e.getDataStr()},getProductWidthHeight:()=>F.getProductWidthHeight(),setToolbarCmd:function(){return ud.apply(null,arguments)},zoom:Cd,getViewStatus:function(){return C1()},getFrameInfo(){return new Xa().getAllInfo()},updateSaveIndex:function(){at.savedIndex=at.index.value},getSG(){return{S:{value:J.gZoom},G:{value:Xe.adsorbGrid.gridSize,unit:Xe.canvas.unit}}},undo:function(){Je.started||Je.dots.length||Je.target||Mc()||at.go(-1)},redo:function(){Je.started&&Je.dots.length||Mc()||at.go(1)},cut:async function(){J.frameHelper.getToolProcessor().switchToReferencePointTool();let e=vr();e.length&&(Ir.referenceIsSelectedReferencePoint?Ir.enterCutStart(J.tabId,e):(J.windowBridge.publish("setReferencePosition",void 0,ut()),_d()))},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{}J.frameHelper.getToolProcessor().switchToReferencePointTool();let i=vr();return Array.isArray(e)&&(i=e),i.filter(n=>{let{cmdKey:s}=F.getById(n.id);return s!=="dimension"}).length?(t&&Ir.referenceIsSelectedReferencePoint?(xr("cross-red",void 0,void 0,"\u8BF7\u9009\u62E9\u53C2\u8003\u70B9"),Ir.enterCopyStart(i||vr())):(J.windowBridge.publish("setReferencePosition",void 0,ut()),await Ld(i)),t?Promise.resolve(Ir.referenceIsSelectedReferencePoint):!1):Promise.resolve(Ir.referenceIsSelectedReferencePoint)},async paste(e){try{let t=await window.top.navigator.clipboard.read();if(t.length>0&&!t[0].types[0])return}catch{}J.frameHelper.getToolProcessor().switchToPasteTool(gc(e)?e:"")},async pasteInPlace(){await zB(),_e("panel_updateAttrPanel"),_e("updateMenuByDocStatus"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},abortReferencePointMode:function(){Ir.abortReferencePointMode()},abortReferencePointModeAndCancelPaste(){Ir.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 de(r)});i=i.filter(function(r){return r&&ba(r.parentNode,Ml)})}},distribute_vertical_equidistant(e){AT("align_vertical_equidistant",e)},distribute_horizontal_equidistant(e){AT("align_horizontal_equidistant",e)},endEditingPath(){jt.endEditingPath()},select_none(){Xt(),Kt.setEditing(null)},selectById(e,t){let{notReleaseActive:i}=t;i||Ce.unselectAll();let r=e.map(n=>de(n)).filter(n=>n);Ce.select(r)},highlightById:function(e){let t=de(e);t&&(yi.eleIsHide(F.getById(e).json)||Ki.createHighlightStyle(de(e)),Ce.highlight(t))},unhighlightById:function(e){de(e)&&Ce.unhighlight(de(e)),Ki.shouldRemoveHighlight(e)},highlightCombination:function(e){let t=new st,{elements:i}=t.getAllElesfromTop(e);[...i].forEach(r=>{let n=de(r);n&&(yi.eleIsHide(F.getById(r).json)||Ki.createHighlightStyle(n,!0),Ce.highlight(n))})},unhighlightCombination:function(e){let t=new st,{elements:i}=t.getAllElesfromTop(e);[...i].forEach(r=>{yi.eleIsHide(F.getById(r).json)||bn().unhighlightById(r)}),Ki.removeCombinationElmsHighlightStroke()},unSelectById:function(e){Array.isArray(e)||(e=[e]),e.forEach(t=>{de(t)&&Ce.unselect(de(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 de(r)});if(i=i.filter(function(r){return r&&ba(r.parentNode,Ml)}),i.length)return Ce.select(i)}else typeof e=="string"?Ce.select(de(e)):Ce.select(e)},bring_to_front:function(e){WB(e),new $i().updateHole(!0),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},send_to_back:function(e){qB(e),new $i().updateHole(!0),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},raise_one_level:function(e){JB(e),new $i().updateHole(!0),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},lower_one_level:function(e){KB(e),new $i().updateHole(!0),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},rotate_left:function(){var e=arguments[0];typeof e=="object"&&e.ids||bn().rotate(270)},endCutState:function(e){Ir.endCutState(e)},rotate_right:function(){var e=arguments[0];typeof e=="object"&&e.ids||bn().rotate(90)},fliph(){let e=J.frameHelper.getToolProcessorCurrentTool(),t=e==null?void 0:e.getSymbol();[br.drag_tool,br.paste_tool,br.place_lib_tool].includes(t)?e.flipH():DC(1),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel_updateAttrPanel")},flipv(){let e=J.frameHelper.getToolProcessorCurrentTool(),t=e==null?void 0:e.getSymbol();[br.drag_tool,br.paste_tool,br.place_lib_tool].includes(t)?e.flipV():DC(0),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel_updateAttrPanel")},lock(e){e=e||Ce.getIds(),wr.setLockStatus(e,!0),Bo(),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel_updateAttrPanel")},lockElements(e){e=e||Ce.getIds(),wr.setElementsLockStatus(e,!0),Bo()},unlockElements(e){e=e||Ce.getIds(),wr.setElementsLockStatus(e,!1),Bo()},unlock(e){e=e||Ce.getIds(),wr.setLockStatus(e,!1),Bo(),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel_updateAttrPanel")},isLocked(e){let t=de(e);return t&&wr.isLockedById(t.id)},lockCombination:e=>{wr.setCombinationLockStatus(e,!0),_e("panel_updateAttrPanel")},unlockCombination:e=>{wr.setCombinationLockStatus(e,!1),_e("panel_updateAttrPanel")},isEleInCombination:function(e){return{eleInCombination:new st().searchCombination(e)}},canvas_config:function(){return Zt(Xe.canvas)},getEleAttrParams(){let e=Ce.get();return e.length?PC(e):[{cmdKey:"canvas"}]},attrGetData(e){return DT(e,J.tabId)},currZoom:function(){return J.currZoom},getSelected:function(){return vr()},pasteFromDataStr:async function(e){let t=await cB(e);J.frameHelper.getToolProcessor().switchToPasteTool("paste_dxf",await TT(t),e.origin?void 0:"center")},releaseActive:function(e){return Xt(e)},setOrigin:function({originX:e,originY:t}){Pd.setOrigin(e,t)},setOriginXY:function(e){e||(e={x:F.gJsonCache.head.originX||0,y:F.gJsonCache.head.originY||0}),e.x=isFinite(e.x)&&e.x!==null?+e.x:Xe.canvas.originX,e.y=isFinite(e.y)&&e.y!==null?+e.y:Xe.canvas.originY,e.x=un(e.x),e.y=un(e.y),Xe.canvas.originX=e.x,Xe.canvas.originY=e.y;var t=.5/J.gZoom;re(de("gridOH"),{y1:e.y+t,y2:e.y+t}),re(de("gridOV"),{x1:e.x+t,x2:e.x+t}),re(de("gridPattern"),{x:e.x,y:e.y}),F.gJsonCache.head.originX=e.x,F.gJsonCache.head.originY=e.y,Bc()},snap_grid:function(){Xe.adsorbGrid.enabled=!Xe.adsorbGrid.enabled},visible_grid:function(){var e=re(de("gridBg"),"display")||"";e=e=="none"?"":"none",re(de("gridBg"),{display:e}),Xe.adsorbGrid.visible=!e},deleteObjs:function(e){if(typeof e=="string")e=de(e);else if(typeof e=="object"&&e.ids){let t=e.ids;if(!Array.isArray(t))return;e=t.map(function(i){return de(i)})}_o(e)},adaptAreaSelectionView(){Jp(),xr("cross-red"),J.contextmenuDisableOnce=!0,document.querySelector("#g1").classList.add("none-events"),wc.setAdaptAreaSelectionView(!0)},adaptSelectionView:LC,highlightItems:function(e,t={scrollElementsIntoView:!0}){let i;function r(l,c=!0){c&&(Eg(l.x,l.y),ps(l.x,l.y,{strokeWidth:"2",strokeLinecap:"square"})),clearTimeout(i),i=setTimeout(()=>{re(de("gMarkError"),"visibility","hidden"),ps(!1),J.helperCursor=void 0},1e3)}let{scrollElementsIntoView:n}=t,s=[];for(let l of e)de(l)&&s.push(de(l));let a=Mr(s,!0),o=new V(a.x+a.width/2,a.y+a.height/2);n?pu(a,1,!0):pu(a,0),r(o,!0),new $i().updateHole()},convertStrokeToShape(){return IB()},convertBaseShapeToPath:function(){return vB()},combineShapes:function(){AB(),_e("updateMenuByDocStatus"),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel/updateTreeActiveElements")},generateImageOutline:async function(){await DB({warnSvg:!0}),_e("updateMenuByDocStatus"),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel/updateTreeActiveElements")},breakShapeApart(){CB(),_e("updateMenuByDocStatus"),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel/updateTreeActiveElements")},joinPath(){PB(),_e("updateMenuByDocStatus"),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel/updateTreeActiveElements")},reversePath:function(){return LB()},simplifyPath:function(){return OB()},deleteEmptyCombination(e){new st().deleteEmptyCombination(e)},groupSelected(){new st().combine(),_e("updateMenuByDocStatus"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},ungroupSelected(){new st().unCombine(),_e("updateMenuByDocStatus"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},ungroupAllEmpty(){new st().unCombineAllEmpty(),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},ungroupAll(){new st().unCombineAll(),_e("panel_updateAttrPanel"),_e("updateMenuByDocStatus"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},enterGroup(){let e=new st,t=Ce.getIds(),i=e.searchCombination(t[0]);if(!i)return;let r=e.findFamily(i).peekParent();Kt.setEditing(r),_e("panel/updateTreeActiveElements"),_e("panel_updateAttrPanel")},removeFromGroup(e){new st().removeFromGroup(e),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},joinGroup(e){if(!e)return;new st().joinGroup(e),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)},exportPanelSVG:function(e){let t=TC();if(uB)return J.windowBridge.publish("exportFileClientWay",{data:{fileData:t,fileTitle:`${e}.svg`,extension:"svg"}},ut());ZB(new Blob([t]),`${e}.svg`)},PanelLayerMaster:()=>tt,getSelectedObjsInfoInTreeNode(){let e=Ce.getIds(),t=[];if(e.length>0){let{combinations:i,elements:r}=new st().getSelectedCombinations(e);i.forEach(n=>{t.push({type:"CombinationGroup",id:n})}),r.forEach(n=>{let s=de(n);switch(Qt(s)){case"auxiliaryLine":t.push({type:wE(F.getAuxiliaryLine(s.id).rotation),id:s.id});default:t.push({type:wC[Qt(s)],id:s.id})}})}return t},selectCount:()=>Ce.count(),repeat:()=>{var r;let{useable:e}=Vr,t=Vr.get();if(!e||!t)return;let i={4:n=>{bn().delete()},3:n=>{bn().rotate(n.degree)},2:n=>{CT(vr(),n.movement)},0:async n=>{bn().duplicateTo(n.data)},7:async n=>{bn().duplicateTo(n.data,n.movement)},6:async n=>{bn().duplicateTo(n.data)},8:n=>{bn().duplicateTo(n.data,n.movement)},5:n=>{let s=Ce.getIds();n.locked?bn().lock(s):bn().unlock(s)},10:n=>{n.isVisable?bn().unhide():bn().hide()},11:()=>{bn().pasteInPlace()}};_e("panel_updateAttrPanel"),(r=i[t.type])==null||r.call(i,t)}}}var iee="clickedCanvas",Od=class Od extends Qs{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=D1()==="continuousSelection";if(this.ctrl=s||o,this.eventTarget=n,[document,document.documentElement,document.body].includes(n))return;let l=J.svgRoot===n?void 0:HE(r);this.target=l}onMouseLeftDown(i){var a;Od.elementsForDrag=[];let{canvasX:r,canvasY:n}=i;if(this.oldCanvansDot.x=r,this.oldCanvansDot.y=n,this.hasMouseLeftDownBeforeUp=!0,J.windowBridge.publish(iee,[{mouseButton:"left",mouseMotion:"down"}],ut()),this.handleTarget(i),!this.eventTarget)return;if(Dp(r,n)&&!jt.isEditingPath()&&!this.ctrl){Od.elementsForDrag=Ce.getIds().map(o=>({id:o}));return}if(!this.target&&!this.ctrl&&this.eventTarget&&this.eventTarget.tagName!="TEXTAREA"&&!Vn.on&&yh.getCursor()==4&&Xt(),this.ctrl)this.target&&((a=J.profileSetting)!=null&&a.commSystemSetting.PANEL_CANVAS.is_ctrl_drag_to_drag)&&(this.isDragCopy=!0,this.leftDownForDragCopyEle=this.target);else if(this.target){let o=uM(r,n);if(o.length){Od.elementsForDrag=o;return}if(Ce.getIds().includes(this.target.id)){Od.elementsForDrag=Ce.getIds().map(c=>({id:c}));return}let l=Kt.getSelectDependMaskMode(this.target.id);Od.elementsForDrag=l}}onMouseLeftUp(i){if(Vn.on||No.running)return;this.isDragCopy=!1;let{canvasX:r,canvasY:n}=i,{x:s,y:a}=this.oldCanvansDot,o=Dp(r,n)&&!jt.isEditingPath();!this.target&&o&&r==s&&n==a&&(yh.switch(4),Xt()),this.ctrl?this.target&&Ce.toggle([this.target]):this.loopSelect(i.originalEvent),this.hasMouseLeftDownBeforeUp&&_e("panel_updateAttrPanel"),this.hasMouseLeftDownBeforeUp=!1;let{x:l,y:c}=Ti(i.originalEvent,!1);jt.clickShowSegmentHandle(this.target,l,c),_e("panel/updateTreeActiveElements"),_e("updateMenuByDocStatus")}loopSelect(i){let r=ree(i),n=F.getItemOrderSortMap();if(r.size<1){Xt(),this.target&&Ce.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=+re(c.ele,"layer"),d=+re(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(Ce.isSelected(u.ele)){a=c+1,!this.ctrl&&Ce.unselect(u.ele);break}}a=a===s.length?0:a,!this.ctrl&&a===0&&Xt();let o=0,l;for(let c of s){if(o===a){l=c.ele;break}o++}Ce.select([l])}onMouseRightDown(i){this.handleTarget(i)}isCtrlDargMove(i){return i.mouseLeftMoving&&i.originalEvent.ctrlKey&&this.isDragCopy}onMouseMove(i){var a;if(Ce.unhighlight(this.hoverNearByTarget),this.handleTarget(i),Ce.highlight(this.target),this.hoverNearByTarget=this.target,!i.originalEvent.altKey&&J.cmdToken){let o=Hl(i.originalEvent.target);o&&o!==J.svgRoot&&Lt.boxCenterAddCrossFlag(o.id)}if(this.isCtrlDargMove(i)){let o="ctrl_drag_copy2";Ce.getIds().includes(this.leftDownForDragCopyEle.id)||Ce.unselectAll(),Ce.select([this.leftDownForDragCopyEle]);let l=bn();l.copy(void 0,!1).then(c=>{!c&&l.paste(o)}),this.isDragCopy=!1,this.leftDownForDragCopyEle=null;return}Ki.createHighlightStyle(this.hoverNearByTarget);let r=!0;!((a=J.profileSetting)!=null&&a.commSystemSetting.PANEL_CANVAS.is_ctrl_drag_to_drag)&&i.ctrlKeyDown&&(r=!1),yh.mouseMoveCursor(i.originalEvent,this.target,new V(i.canvasX,i.canvasY),r);let{x:n,y:s}=Ti(i.originalEvent,!1);jt.createHoverAnchor(this.target,n,s)}onDoubleClick(i){var n;this.handleTarget(i);let r=F.getById((n=this.target)==null?void 0:n.id).json;r&&r.locked||(eB(this.target,i.originalEvent),_e("panel_updateAttrPanel"),_e("panel/updateTreeActiveElements"))}onMouseRightUp(i){if(!Nc.dragpanning&&No.running){No.instance.cancel();return}if(Vn.on||(this.handleTarget(i),this.ctrl))return;let r=this.eventTarget.classList.contains("hitbox");if(r&&!J.gCanvas.contains(this.eventTarget))return;let n=this.eventTarget==J.svgRoot,s=this.target==J.svgRoot;if(Qt(this.target)!=="cdot"){this.target&&!Ce.isSelected(this.target)&&!s&&(Xt(),Ce.select([this.target]));let o=Hl(this.eventTarget);!r&&o&&!Ce.isSelected(o)&&!n&&Xt()}e5(this.event,this.target),_e("panel_updateAttrPanel"),_e("panel/updateTreeActiveElements"),_e("updateMenuByDocStatus")}install(){console.log(this.getSymbol(),"installed")}uninstall(){console.log(this.getSymbol(),"uninstalled")}getSymbol(){return br.highlight}};Od.elementsForDrag=[];var Tg=Od;function ree(e){let t=Ti(e,!1),{x:i,y:r}=t,n=new Set,s=KI(i,r);if(s.length)for(let x of s)n.add(x);let a=$I(i,r);if(a.length)for(let x of a)n.add(x);let o=ZI(i,r);for(let x of o)n.add(x);let l=QI(i,r);for(let x of l)n.add(x);let c=eA(i,r);for(let x of c)n.add(x);let u=tA(i,r);for(let x of u)n.add(x);let h=Oy(i,r);if(h.size)for(let x of h)n.add(x);let d=oh(i,r);if(d.length)for(let x of d)n.add(de(x));let p=vc(i,r);if(p.length)for(let x of p)n.add(de(x));let f=Cp(i,r);if(f.length)for(let x of f)n.add(x);let m=Mm(i,r);if(m.length)for(let x of m)n.add(x);let g=Ry(i,r);for(let x of g)n.add(x);return n}var Pa=class Pa{static rotate(t,i,r,n){if(MI(t))if(ko){let s=+re(ko,"c_rotate")||0;return re(ko,{c_rotate:fr(s+i)}),Pa.rotateOne(ko,i,r,n)}else{let s;return t.forEach(function(a){s=Pa.rotateOne(a,i,r,n)}),s}else return Pa.rotateOne(t,i,r,n)}static rotateOne(t,i,r,n){if(r===void 0||n===void 0){let s=re(t,"c_origin"),a=re(t,"c_partid");if(a==="part_text")[r,n]=s.split(",").map(parseFloat);else if(a==="part"){let o=Ic(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=Ic(t);r=o.x+o.width/2,n=o.y+o.height/2}}return Pa[t.tagName]&&Pa[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){Pa.rotate(t[0],i,r,n);return}if(r!==void 0&&n!==void 0){for(s=0;s<a;s++)Pa.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"&&!re(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(re(t[s],"c_origin")),!c&&t[s].tagName=="text"&&(c={x:+re(t[s],"x"),y:+re(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=ft((l.x+l.x2)/2,3),n=ft((l.y+l.y2)/2,3),s=0;s<a;s++)Pa.rotate(t[s],i,r,n)}static g(t,i,r,n){if(i===void 0&&(i=270),i%360===0)return;let s=re(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=$s(o,i,r,n),re(t,"c_origin",o.join(","))),s&&(l=fr(+(re(t,"rotation")||0)),l=fr(l-i),re(t,"rotation",l)),Qt(t)==="text"){let d=he.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++)Pa.rotate(d[f],i,r,n)}}static svg(t,i,r,n){let s=re(t,"x"),a=re(t,"y");if(r===void 0||n===void 0)Pa.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++)Pa.hasOwnProperty(o[c].tagName)&&Pa.rotate(o[c],i,r,n)}else s!==null&&a!==null&&Pa.image(t,i,r,n)}static rect(t,i,r,n){let s=F.getById(t.id).json;Ai.syncRectByRotation(i,s,new V(r,n))}static image(t,i,r,n){if(i===0||!re(t,"xlink:href"))return;if(r===void 0||n===void 0){let o=Ic(t);r=ft(o.x+o.width/2,3),n=ft(o.y+o.height/2,3)}let a=he.rotateD(-i).setOrigin(r,-n);Tr.syncImage(F.gJsonCache.obj[t.id],a)}static circle(t,i,r,n){let s=[+re(t,"cx"),+re(t,"cy")];s=$s(s,i,r,n),re(t,{cx:s[0],cy:s[1]})}static ellipse(t,i,r,n){let s=[+re(t,"cx"),+re(t,"cy")];if(s=$s(s,i,r,n),re(t,{cx:s[0],cy:s[1]}),i%90){J.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=re(t,"rx"),o=re(t,"ry");re(t,{rx:o,ry:a})}}static line(t,i,r,n){let s=[+re(t,"x1"),+re(t,"y1"),+re(t,"x2"),+re(t,"y2")];s=$s(s,i,r,n),re(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=yc(re(t,"points")).split(/[\s\,]+/);s=$s(s,i,r,n),re(t,{points:s.join(" ")})}static polygon(t,i,r,n){Pa.polyline(t,i,r,n)}static path(t,i,r,n){if(i%360===0)return;if(re(t,"c_partid")==="arc"){let x=_T(t);x=$s(x,i,r,n),re(t,{"third-point":x[4]+","+x[5]})}i=fr(i);let s=xo,a=t.pathSegList,o=a.numberOfItems,l,c,u,h,d,p,f,m,g;for(let x=0;x<o;x++)if(l=null,c=a.getItem(x),u=c.pathSegType,g=u%2===0,!(u==FD||u==ti)){switch(g?(h=u,d=r,p=n):(h=u-1,d=0,p=0),c._owningPathSegList=null,h){case yr:l=$s([c.x,c.y],i,d,p),c.x=l[0],c.y=l[1];break;case on:l=$s([c.x,c.y],i,d,p),c.x=l[0],c.y=l[1];break;case lo:l=$s([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 uo:l=$s([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 Oa:l=$s([c.x,c.y],i,d,p),c.x=l[0],c.y=l[1],c.r1!=c.r2?c.angle=fr(c.angle+i):c.angle=0;break;case po:i==180?c.x=g?r+r-c.x:-c.x:(f=Yd[i],g?m=t.createSVGPathSegLinetoVerticalAbs((c.x-r)*f+n):m=t.createSVGPathSegLinetoVerticalRel(c.x*f),a.replaceItem(m,x));break;case fo:i==180?c.y=g?n+n-c.y:-c.y:(f=Yd[i],g?m=t.createSVGPathSegLinetoHorizontalAbs(r-(c.y-n)*f):m=t.createSVGPathSegLinetoHorizontalRel(-c.y*f),a.replaceItem(m,x));break;case co:l=$s([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 ho:l=$s([c.x,c.y],i,d,p),c.x=l[0],c.y=l[1];break;default:break}c._owningPathSegList=a}a.segmentChanged()}};Pa.pinTextNeedInvert=!1;var PT=Pa;var io={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&&io[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=re(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++)io[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=re(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;io[n](e[i],null,t)}return t},flipH:function(e,t){return e instanceof NodeList||Array.isArray(e)?io.elementsFlipH(e,t):io.elementsFlipH([e],t)},flipV:function(e,t){return e instanceof NodeList||Array.isArray(e)?io.elementsFlipV(e,t):io.elementsFlipV([e],t)},g:function(e,t,i){if(Qt(e)==="text"){let n;t!==null?n=he.MIRROR_X.setOrigin(t,0):n=he.MIRROR_Y.setOrigin(0,i),lr.syncText(F.getById(e.id).json,n,{updateMatrix:!0})}else{let n=re(e,"c_origin"),s,a,o,l;n&&(s=n.split(","),l={x:+s[0],y:+s[1]},io.point(l,t,i),re(e,"c_origin",l.x+","+l.y));let c=fr(+(re(e,"rotation")||0));t!==null&&c%180===0&&(c=fr(c+180)),i!==null&&c%180!==0&&(c=fr(c+180)),re(e,"rotation",c);let u=e.children||e.childNodes;for(o=u.length,a=0;a<o;a++){let h=u[a].tagName;h&&Qe(PT,h)&&io[h](u[a],t,i)}}},rect:function(e,t,i){let r=F.getRect(e.id);if(t!==null){let n=he.MIRROR_X.setOrigin(t,0);Ai.syncRect(r,n,{updateMatrix:!0})}if(i!==null){let n=he.MIRROR_Y.setOrigin(0,i);Ai.syncRect(r,n,{updateMatrix:!0})}},image(e,t,i){let r=F.gJsonCache.obj[e.id];if(!mt(t)){let n=he.MIRROR_X.setOrigin(t,0);Tr.syncImage(r,n)}if(!mt(i)){let n=he.MIRROR_Y.setOrigin(0,i);Tr.syncImage(r,n)}},obj:function(e,t,i){let r=F.gJsonCache.obj[e.id];if(t!==null){let n=he.MIRROR_X.setOrigin(t,0);Tr.syncImage(r,n)}if(i!==null){let n=he.MIRROR_Y.setOrigin(0,i);Tr.syncImage(r,n)}},circle:function(e,t,i){let r=F.getEllipse(e.id);if(t!==null){let n=he.MIRROR_X.setOrigin(t,0);gi.syncEllipse(r,n,{updateMatrix:!0})}if(i!==null){let n=he.MIRROR_Y.setOrigin(0,i);gi.syncEllipse(r,n,{updateMatrix:!0})}},ellipse:function(e,t,i){io.circle(e,t,i)},line:function(e,t,i){t!==null&&(re(e,"x1",2*t-re(e,"x1")),re(e,"x2",2*t-re(e,"x2"))),i!==null&&(re(e,"y1",2*i-re(e,"y1")),re(e,"y2",2*i-re(e,"y2")))},polyline:function(e,t,i){let r=yc(re(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]}re(e,{points:r.join(" ")})},polygon:function(e,t,i){io.polyline(e,t,i)},arc(e,t,i){let r=he.MIRROR_X.setOrigin(t,0);mt(i)||(r=he.MIRROR_Y.setOrigin(0,i)),sr.syncArc(e,r,{updateD:!0})},path(e,t,i){let{cmdKey:r,json:n}=F.getById(e.id);if(r==="arc")return io.arc(n,t,i);let s;xo&&(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=re(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]),re(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=re(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]),re(e,"c_helper_dots",d.join(","))}}if(re(e,"c_partid")==="arc"&&re(e,"third-point")){let m=re(e,"third-point").split(",");t!==null?re(e,{"third-point":c-m[0]+","+m[1]}):i!==null&&re(e,{"third-point":m[0]+","+(u-m[1])})}n.d=re(e,"d"),F.changedJsoncache(n.gId,r)}};var wg=class{constructor(t){this.data=t}toData(){}setData(){}render(){let{gId:t,x:i,y:r}=this.data,n=de(t);n==null||n.setAttribute("cx",String(i)),n==null||n.setAttribute("cy",String(r))}unmount(){dt(de(this.data.gId))}multiply3(t){let i=new V(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=he.rotateD(t).setOrigin1(i);this.multiply3(r)}flipH(t){let i=(t.x-this.data.x)*2,r=he.translate(i,0);this.multiply3(r)}flipV(t){let i=(t.y-this.data.y)*2,r=he.translate(0,i);this.multiply3(r)}};var cl=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}=F.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?io.flipH([r],i.x):io.flipV([r],i.y);break}}}mirrorGroup(t,i=this.center,r=this.isH){let n=he.MIRROR_Y.setOrigin(0,i.y);r&&(n=he.MIRROR_X.setOrigin(i.x,0)),Gn.syncGroup(t,n,{updateD:!0,fn(){r?t.rotation=-fr(360+t.rotation):t.rotation=-fr(t.rotation+360)}})}mirrorDimensionRadius(t,i=this.center,r=this.isH){let n=new tn(t),s=he.MIRROR_Y.setOrigin(0,i.y);r&&(s=he.MIRROR_X.setOrigin(i.x,0)),n.multiply3(s)}mirrorDimensionLength(t,i=this.center,r=this.isH){let n=new dn(t),s=he.MIRROR_Y.setOrigin(0,i.y);r&&(s=he.MIRROR_X.setOrigin(i.x,0)),n.multiply3(s)}mirrorDimensionAngle(t,i,r){let n=new hn(t);r?n.flipH(i):n.flipV(i)}mirrorAuxiliaryLine(t,i=this.center,r=this.isH){let n=new Ul(t);r?n.flipH(i):n.flipV(i)}mirrorAuxiliaryPoint(t,i=this.center,r=this.isH){let n=new wg(t);r?n.flipH(i):n.flipV(i)}};var ul=class extends Qs{constructor(){super();this.lastX=void 0;this.lastY=void 0;this.accumulateX=0;this.accumulateY=0;this.dashedBoxForPerf=null;this.updateRightPanel=eN(()=>{this.dragContext.selectedObjs.length!==0&&_e("panel_updateAttrPanel")},100);this.auxiliaryLineId="drag-auxiliary-line";this.shiftKeyDown=!1}static canSwitchMe(i){if(!i.mouseLeftMoving)return!1;let r=Tg.elementsForDrag.filter(o=>!Ce.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 st().getSelectedCombinations(n);for(let o of s)if(F.getCombination(o).locked)return zl(n),!1;for(let o of a)if(wr.isLockedById(o))return zl(n),!1;return i.selectItems=r,!0}getSymbol(){return br.drag_tool}install(i){this.startX=i.startX,this.startY=i.startY,this.lastX=i.startX,this.lastY=i.startY,this.dragContext=new J2(i),this.dragElements=new b1(this.dragContext),this.onDragStart(),this.checkShouldCreateSelectionBox(),Ce.unselectAll();for(let r of i.selectItems)Ce.select([{id:r.parentId||r.id}]);console.log(this.getSymbol(),"installed")}uninstall(i){ul.isDragging=!1,console.log(this.getSymbol(),"uninstalled")}checkShouldCreateSelectionBox(){let{selectedObjs:i}=this.dragContext;if(i.length>$1){let n=Mr(i);this.dashedBoxForPerf=NC(n,{"stroke-dasharray":"6, 6",class:Nl,stroke:J.panelThemeCache.color.select});for(let s of i)cu(s,"hidden")}}onDragStart(){at.startBatch(),ul.isDragging=!0;let i=this.dragContext.selectedObjs.filter(o=>!["auxiliaryLine","auxiliaryPoint"].includes(Qt(o))),r=Mr(i);this.startBBox=xt.extendRect(r),this._radian=0,il(),du(),Lt.setExcludeShapeIds(this.dragContext.selectedObjs.map(o=>o.id));let n=Array.from(this.dragContext.affectedDimensions).map(o=>de(o)).concat(Array.from(this.dragContext.drivingDimensions).map(o=>de(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])at.jsonSnap.addOne(F.getById(o.id).json);let a=()=>{Ki.emptyLastHoverEle().emptySelectContainer().removeHighlightStroke(),jt.removeMiddleAnchor()};a(),setTimeout(a,0)}onDrag(i,r){if(this.dashedBoxForPerf)return jl.svg(this.dashedBoxForPerf,i,r);!this.dashedBoxForPerf&&this.dragElements.onDrag(i,r),yh.switch(5);let n=Sa(this.dragContext.selectedObjs);n.length&&Tn(n,{create8Dots:!1}),this.dragContext.combinationMask.updateHole(),this.updateRightPanel(),Rd()}handleSelectionBox(){if(!this.dashedBoxForPerf)return;dt(this.dashedBoxForPerf),this.dashedBoxForPerf=null;let{selectedObjs:i}=this.dragContext;for(let r of i)To(r,"hidden");this.onDrag(this.accumulateX,this.accumulateY)}onComplete(){this.onEnd(),_e("panel_updateAttrPanel"),_e("updateMenuByDocStatus"),_e("panel/updateTreeActiveElements"),this.freshBoundingBox(),Ki.debouncedAppendSelectStroke()}freshBoundingBox(){let i=Sa(this.dragContext.selectedObjs);i.length&&Tn(i,{create8Dots:!0})}onEnd(){Gr.cancel(),this._radian=0,this.handleSelectionBox(),this.removeAuxiliaryLine(),at.saveBatch(),Lt.clearAdsorptionHTML(),Lt.clearExcludeShapeIds(),yh.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;Gr.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=t5(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})),J.helperCursor==="cross-red"){let{x:p,y:f}=Ti(n,!0);ps(p,f)}this.freshBoundingBox(),Ki.emptySelectContainer()}createAuxiliaryLine(i,r){let n=this.auxiliaryLineId,s=document.getElementById(n),a=[i.x,i.y,r.x,r.y].join(" ");s?re(s,{points:a}):(s=Tt("polyline",{id:n,points:a,"vector-effect":"non-scaling-stroke",stroke:J.panelThemeCache.color.select}),J.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+=Xe.adsorbGrid.gridSize*r[0],n.clientY+=Xe.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(ul.isDragging){if(Gr.cancel(),at.jsonSnap.recovery(i),at.cancelSaveBatch(),i){let r=Tg.elementsForDrag.map(s=>de(s.parentId||s.id)),n=Sa(r);n.length&&Tn(n,{create8Dots:!0})}Tg.elementsForDrag.length=0,Lt.clearAdsorptionHTML()}}onKeyUp(i){let{originalEvent:r}=i;r=r;let{keyCode:n}=r;switch(n){case x1.Space:break;case x1.Shift:let s=new MouseEvent("mousemove",this.lastClient);document.dispatchEvent(s),this.removeAuxiliaryLine();break;case x1.Esc:{i.toolFinished=!0,this.cancel();break}default:break}}onMouseLeftUp(i){i.toolFinished=!0,this.onComplete()}onMouseRightUp(i){Nc.dragpanning||(i.toolFinished=!0,this.cancel())}rotate(i){pi.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=>F.getById(s.id).cmdKey!=="auxiliaryLine");kc(to(n),i),pi.runTask()}flipH(){pi.createContext();let i=to(this.dragContext.selectedObjs.concat(this.dragContext.selectedDimensionObjs)),r=ro(i,!0,{ignoreSnap:!0});new cl(i).mirror(!0,r),pi.runTask(),this.freshBoundingBox()}flipV(){pi.createContext();let i=to(this.dragContext.selectedObjs.concat(this.dragContext.selectedDimensionObjs)),r=ro(i,!0,{ignoreSnap:!0});new cl(i).mirror(!1,r),pi.runTask(),this.freshBoundingBox()}getCurrentBBox(i){let r=this.startBBox.width(),n=this.startBBox.height(),s=this.startBBox.minX,a=this.startBBox.minY,o=he.translate(-s-r/2,-a-n/2).multiply3(he.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 V(l.x+s,l.y+a));for(let l of this.dragContext.horizontalAuxiliaryLines)o(new V(i.x,l.y+a));for(let l of this.dragContext.verticalAuxiliaryLines)o(new V(l.x+s,i.y));return Object.values(r);function o(...l){for(let c of l)r[`${c.x}_${c.y}`]=c}}};ul.isDragging=!1,ul=La([Ea(gn.drag)],ul);var ms=class ms extends Qs{static exit(){this.ready=!1}static enterCutStart(t,i){this.tabId=t,this.ready=!0,this.cutStart=!0,this.clipboard=vr(),this.objs=i,this.referencePosition=void 0,this.pasteFrom="cut",fn("setIsCutPasteFinish",[!1]),J.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",J.windowBridge.rpcCall("i18n",this.content,ut()).then(r=>{this.i18nText=r.message,this.showHelpCursor()})}static showReferencePointAndText(t,i,r="",n=!1){if(!this.referenceIsSelectedReferencePoint){fs();return}this.setContent(r);let{top:s,left:a}=this.getCursorTextPosition(t,i);(n||this.ready||this.pasteFrom==="cut"&&!this.referencePosition)&&(0,Sg.default)(`#${this.id}`).css({left:a+ms.offsetPosition.x,top:s+ms.offsetPosition.y}),this.updateReferencePointText(n)}static async showReferText(t){if(this.ready){this.setContent(this.content);let{currAbsX:i,currAbsY:r}=t||Un.data,{top:n,left:s}=this.getCursorTextPosition(i,r);(0,Sg.default)(`#${this.id}`).css({left:s+ms.offsetPosition.x,top:n+ms.offsetPosition.y}),this.updateReferencePointText(!0)}else this.showOrHideText(!1)}static abortReferencePointMode(t=!0){this.ready&&fs(),this.ready=!1,this.cutStart=!1,Lt.clearAdsorptionHTML(),t?xr(!1):this.showOrHideText(!1)}static setContent(t){if(!t)return!1;this.content=t}static showOrHideText(t=!0){let i=(0,Sg.default)(`#${this.id}`);t?i.removeClass("hide"):i.addClass("hide")}static updateReferencePointText(t){let i=(0,Sg.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=mi.getViewBox()){let s=(0,Sg.default)(`#${this.id}`).height(),a=6,o=16,l=J.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=i5({x:t,y:i}),n=r.x,s=r.y;this.referencePosition={offX:n,offY:s},J.windowBridge.publish("setReferencePosition",{offX:n,offY:s},ut()),this.ready=!1,Lt.clearAdsorptionHTML(),xr(!1),fs(),this.cutStart?(this.cutStart=!1,!ul.isDragging&&_d()):Ld(this.objs,this.cutStart)}_e("updateMenuByDocStatus")}}static pasteAfterCut(){return this.pasteFrom==="cut"&&!this.ready&&!this.referencePosition}static getTabId(){return ms.tabId}static async showHelpCursor(){let{currAbsX:t,clientX:i,clientY:r,currAbsY:n}=Un.data;xr(this.cursor,t,n),fs("",{x:t,y:n}),this.showReferText({currAbsX:t,currAbsY:n})}static endCutState(t){ms.getTabId()===t&&fn("getIsCutPasteFinish")&&(_d(!0),ms.abortReferencePointMode())}static async saveSelectObjs(){await Ld(this.objs)}install(){console.log(this.getSymbol(),"installed")}uninstall(){console.log(this.getSymbol(),"uninstalled")}getSymbol(){return br.referencePoint_tool}onMouseLeftDown(t){t.toolFinished=!0;let{canvasX:i,canvasY:r}=t;ms.updateReferencePointPosition(i,r),Xt()}onMouseRightUp(t){t.toolFinished=!0,ms.ready&&ms.abortReferencePointMode()}static canSwitchMe(){var i;let t=((i=J.profileSetting)==null?void 0:i.commSystemSetting.PANEL_CANVAS.referencePointPanelSelectMethod)==="select";return ms.referenceIsSelectedReferencePoint=t,!!ms.referenceIsSelectedReferencePoint}};ms.content="Please select a reference point",ms.id="cross-text",ms.ready=!1,ms.pasteFrom="copy",ms.cursor="cross-red",ms.referenceIsSelectedReferencePoint=!0,ms.offsetPosition={x:18,y:4};var Ir=ms;var r5="panel-copy-json";async function _d(e=!1){let t=vr();Ir.referenceIsSelectedReferencePoint&&Ir.clipboard&&(t=Ir.clipboard);let r=[...is.findDimensionByPrimitiveIds(new Set(t.map(o=>o.id))).map(o=>de(o.gId)),...t],{combinations:n,elements:s}=new st().getSelectedCombinations(r.map(o=>o.id));if(wr.hasEleLocked(s)||wr.hasEleLocked(n)){zl();return}!e&&await Ld(r,!0);let a=new oi(r);for(let o of n)F.deleteCombInParent(o).setCombination(o);F.removeMultiData(r),Ki.removeCombinationElmsHighlightStroke(),a.updateAndSave(),_e("panel_updateAttrPanel"),_e("updateMenuByDocStatus")}async function Ld(e,t){let i=e.map(n=>F.getById(n.id).json);await n5(i)&&_e("ui/toastMsg",{type:"success",msg:t?"Cut Success!":"Copy Success!",timer:3})}async function n5(e){let t=(await J.windowBridge.rpcCall("getActiveProject",null,ut())).message,i=Tt("g",{doctype:J.doctype,projectId:t}),r=F.getItemOrderSortMap();e.sort((l,c)=>r.get(l.id)-r.get(c.id));let n=new Set,s=new st;for(let l of e){let c=s.searchCombination(l.gId);if(c){let h=Kt.getCurrentEditingComId(),d=s.findFamily(c,h).getAllParents();for(let p of d){if(Kt.getCurrentEditingComId()===p||n.has(p))continue;n.add(p);let f=F.getCombination(p),m=Tt("g",{c_partid:"combination",jsonCache:JSON.stringify(f)});i.appendChild(m)}}let u=Tt("g",{c_partid:l.cmdKey,jsonCache:JSON.stringify(l)});Ce.unselect(u),Ce.unhighlight(u),i.appendChild(u)}let a=new XMLSerializer().serializeToString(i),{message:o}=await Ro(M0.CLIP_BOARD.SET,[r5,a]);return _e("updateMenuByDocStatus"),o}async function Qp(){return(await Ro(M0.CLIP_BOARD.GET,[r5])).message}async function s5(e){let t=await a5(e);await n5([t]),J.frameHelper.getToolProcessor().switchToPasteTool("")}async function a5(e,t=V.ORIGIN){let i=(await J.windowBridge.rpcCall("/pro-ui/getImageInfoByFilesForSch",[[e]],ut())).message[0],r=_t();Lt.setExcludeShapeIds([r]);let n=he.scale(i.width,i.height).translate1(t),s=$e.getMatrix6FromMatrix(n);return F.getInitialImageData({gId:r,matrix:s,content:i.src,layer:tt.getTargetPlaceLayer("obj")})}function MC(e,t){if(!e||!e.length)return;let i=e.length;Xt();for(let d=-1;++d<i;){let p=+re(e[d],"layer");tt.appendTargetLayer(e[d],p),Lt.setExcludeShapeIds([e[d].id])}let r=Mr(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&&Qt(e[0])==="text"){let{x:f,y:m}=lr.getTextOrigin(e[0].id);d-=f,p-=m}t={offX:d,offY:p}}var n=C1(),s=Un.data.clientX||n.clientWidth/2,a=Un.data.clientY||n.clientHeight/2;let o=cd({x:s,y:a}),l={x:t.offX,y:t.offY},c=ol({x:o.x,y:o.y}),u=c.x-l.x,h=c.y-l.y;return Th(e,u,h),l&&xr("cross-red",l.x+u,l.y+h,{enforceEnterRefPoint:!0}),{targets:e,...c}}async function zB(){let e=new oi,t=[],i=new Map,r=[],n=await Qp(),s=Ha(n),o=[...document.importNode(s.documentElement,!0).childNodes],l=[];for(let c of o){let u=LT(c),h=u.gId,d=u.cmdKey;if(u.gId=_t(),i.set(h,u.gId),d==="combination")t.push(u);else if(d==="dimension")r.push(u);else{let p=Us(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=Us("dimension",c);l.push(f)}}new st().pasteCombination(e,t,i),e.updateAndSave(),Ce.unselectAll(),Ce.select(l),Ea(gn.pasteInPlace)(null)}function XB(){let e=Ce.get().slice();if(!e.length)return;Xt(),Ce.unselectAll();let t=new oi,{oldIdMapNewId:i,copiedCombination:r}=new st().getAffectedCombinations(e.map(n=>n.id));e.map(n=>{let{json:s,cmdKey:a}=F.getById(n.id),o=Zt(s);o.gId=_t(),ni.renderer.insertBefore(o,F.getRefId(n.id)),i.set(s.gId,o.gId),t.addOne(o,{},a),Ce.select([{id:o.gId}])}),new st().pasteCombination(t,r,i),t.updateAndSave(),Bo()}var xg=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=Zt(t[o][l]),u=_t();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 zn.fixStringPath(c));let h=Us(o,c);a.push(h),this.snap.addOne(c,{},o)}}return i=i||new V(0,Mr(a).height||Xe.adsorbGrid.gridSize),CT(a,i,{saveHistory:!1}),new st().pasteCombination(this.snap,n,r),this.snap.updateAndSave(),BC(),Ce.select(a),{nodes:a,movement:i}}};xg=La([Ea(gn.duplicateTo)],xg);async function nee(e){let t=e.dataTransfer.files[0];if(t.type.indexOf("image")!==-1){event.preventDefault();let{x:i,y:r}=Ti(e,!0),n=await a5(t,new V(i,r)),s=Us(n.cmdKey,n),a=new oi;a.addOne(n,{}),a.updateAndSave(),Ce.unselectAll(),Ce.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")?J.windowBridge.publish("/pro-ui/setImage",[i],ut()):await s5(i)}}),document.addEventListener("drop",nee));var vg=class extends Qs{constructor(i,r,n){super();this.prepareFinish=!1;this.accmulate=new V(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(Mc())return!1;if(!i){let r=await Qp();if(!r)return!1;let n=Ha(r),a=[...document.importNode(n.documentElement,!0).childNodes];return a.length?a.some(l=>{let c=LT(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"),Gr.cancel(),this.removeCopiedNodes()}getSymbol(){return br.paste_tool}async prepare(i){this.prepareFinish=!1,at.startBatch();let r;this.type==="paste_dxf"?r=MC(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){pi.createContext();let r=to(this.nodes).filter(n=>F.getById(n.id).cmdKey!=="auxiliaryLine");kc(r,i),pi.runTask()}flipH(){pi.createContext();let i=to(this.nodes),r=ro(i,!0,{ignoreSnap:!0});new cl(i).mirror(!0,r),pi.runTask()}flipV(){pi.createContext();let i=to(this.nodes),r=ro(i,!0,{ignoreSnap:!0});new cl(i).mirror(!1,r),pi.runTask()}onMouseMove(i){if(!this.prepareFinish)return;if(!this.nodes)return at.cancelSaveBatch(),i.toolFinished=!0;Gr.tryStart(i);let{originalEvent:r}=i;kl.altKeyEnabled=i.altKeyDown;let{x:n,y:s}=Ti(r,!0),a=n-this.lastX,o=s-this.lastY;(a||o)&&(Th(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,Wa(this.nodes),Ce.unselectAll().select(this.nodes);let r=this.jsonSnapshot;new st().pasteCombination(r,this.copiedCombination,this.oldIdMapNewId,this.nodes),at.saveBatch(),new $i().updateHole(),r.updateAndSave(),xr(),this.nodes=[],Lt.clearAdsorptionHTML(),Lt.clearExcludeShapeIds(),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel/updateTreeActiveElements"),_e("panel_updateAttrPanel"),J.doctype===gs.PANEL&&J.windowBridge.rpcCall(M0.LOG.SET,[{type:WS.PRIMITIVE_PASTE_ACROSS_PROJECT,content:[{"Panel Name":F.gJsonCache.head.display_title}],project_uuid:J.currentProject.projectId}],ut())}onMouseLeftUp(i){this.type==="ctrl_drag_copy2"&&this.onMouseLeftDown(i)}onMouseRightUp(i){this.prepareFinish&&(Nc.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=[...Ce.get()];else{((h=J.profileSetting)==null?void 0:h.commSystemSetting.PANEL_CANVAS.referencePointPanelSelectMethod)==="select"&&Ir.ready&&(J.windowBridge.publish("setReferencePosition",void 0,ut()),Ir.pasteAfterCut()?await _d():await Ld(vr())),r={offX:0,offY:0};let p=await Qp(),f=Ha(p);n=document.importNode(f.documentElement,!0),s=[...n.childNodes];let m=re(n,"projectId"),{message:g}=await J.windowBridge.rpcCall("getActiveProject",null,ut());g!==m?P1("referencePosition")&&P1("referencePosition")!=="undefined"?r=JSON.parse(P1("referencePosition")):r=void 0:r=(await J.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=Qt(f),g=LT(f)||Zt(F.gJsonCache[m][f.id]),x=_t();if(c.set(g.gId,x),g.gId=x,g.visible=!0,m==="combination")l.push(g);else if(m==="dimension")o.push(g);else{let y=Us(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 x=Us("dimension",d);a.push(x)}}let u=MC(a,r);return fn("setIsCutPasteFinish",[!0]),Ir.abortReferencePointMode(!1),Ir.pasteAfterCut()&&_d(!0),u}removeCopiedNodes(){var i;(i=this.nodes)!=null&&i.length&&(F.removeMultiData(this.nodes),Ce.unselect(this.nodes))}cancelPaste(){Wa(this.nodes,"cancel"),this.removeCopiedNodes(),xr(),Lt.clearExcludeShapeIds(),Lt.clearAdsorptionHTML(),at.cancelSaveBatch()}};vg=La([Ea(gn.paste)],vg);function LT(e){return JSON.parse(re(e,"jsonCache"))}var ef=class ef extends Qs{constructor(){super(...arguments);this.nodes=[]}getSymbol(){return br.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),xr("cross-red",this.lastX,this.lastY,{enforceEnterRefPoint:!0})}prepareNodes(i){let r=F.gJsonCache,n=Zt(ef.data.jsonCache),s=F.exchangeJsonCache(n),a=new Map,o=new Map,l=new Set;this.copiedCombination=[],this.oldIdMapNewId=new Map,F.iterator((h,d,p)=>{a.set(p,h),o.set(p,d),this.oldIdMapNewId.set(p,""),d==="dimension"&&l.add(p)}),F.iteratorCombination((h,d,p)=>{a.set(p,h),o.set(p,d);let f=_t();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=_t();d.gId=f,this.oldIdMapNewId.set(h,f),p==="dimensionRadius"&&(d.ellipseId=this.oldIdMapNewId.get(d.ellipseId));let m=Us(p,d,f);c.push(m)}this.prepareDimensions(l,a,this.oldIdMapNewId,c),Lt.clearExcludeShapeIds().setExcludeShapeIds(c.map(h=>h.id)),this.nodes=c;for(let h of c)cu(h,Nl);if(c.length){let{x:h,y:d,width:p,height:f}=o5(c);Th(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=_t();o.gId=d,n.set(a,d);let p=Us("dimension",o);s.push(p)}}}uninstall(i){Gr.cancel(),console.log(this.getSymbol()," uninstalled")}rotate(i){let r=to(this.nodes).filter(n=>F.getById(n.id).cmdKey!=="auxiliaryLine");kc(r,i)}flipH(){let i=to(this.nodes),r=ro(i,!0,{ignoreSnap:!0});new cl(i).mirror(!0,r)}flipV(){let i=to(this.nodes),r=ro(i,!0,{ignoreSnap:!0});new cl(i).mirror(!1,r)}onMouseLeftUp(i){Xt(),Ce.select(this.nodes),Wa(this.nodes);let r=new oi;new st().pasteCombination(r,this.copiedCombination,this.oldIdMapNewId,this.nodes);for(let n of this.nodes){To(n,Nl);let{json:s,cmdKey:a}=F.getById(n.id);r.addOne(s,{},a),Lt.updateShapeCache(s.gId,a,s)}r.updateAndSave(),this.prepareNodes(i),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),this.uploadPlacePanelLibLog()}onMouseRightUp(i){Wa(this.nodes,"cancel"),i.toolFinished=!0,ef.data=null,F.removeMultiData(this.nodes),xr(!1),Lt.clearAdsorptionHTML(),_e("openPlaceClosedBottomBar")}onMouseMove(i){let{originalEvent:r}=i,{x:n,y:s}=Ti(r,!r.altKey),a=n-this.lastX,o=s-this.lastY;Gr.tryStart(i),Th(this.nodes,a,o),this.lastX=n,this.lastY=s}static async setPlacingStatus(i){if(i.jsonCache=await $p.getJsonCache(i.uuid,i.path),this.resetPanelLibItemOrder(i.jsonCache),i.jsonCache.itemOrder.length===0){rs("Placement failed, panel library has no content","warn"),_e("openPlaceClosedBottomBar");return}let r=J.frameHelper.getToolProcessor();if(r.currentToolIs(br.place_lib_tool)){let n=r.getCtx();r.currentTool.onMouseRightUp(n),r.switchToHighlightTool()}else if(r.currentToolIs(br.draw)){let n=r.getCtx();r.currentTool.uninstall(n),r.switchToHighlightTool()}i.svgStr=Pn.toSVG(i.jsonCache),this.isPlacing=!0,this.data=i}static resetPanelLibItemOrder(i){let r=F.exchangeJsonCache(i);i.itemOrder.forEach(n=>{let s=F.getById(n).json;s&&(s.zIndex=void 0)}),r()}uploadPlacePanelLibLog(){var i;J.windowBridge.publish("addUploadPlaceLibLog",{uuid:ef.data.uuid,lib_type:6,path:(i=ef.data.owner)==null?void 0:i.uuid},ut())}};ef.isPlacing=!1;var tf=ef;var kC=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=J.frameHelper.getToolProcessorCurrentTool(),{horizontal:i,vertical:r}=this.pointData,n=this.altKeyDown?this.config.altStep:this.config.step,s=n*i,a=n*r;Nc.setViewBox(-s,-a),this.updateCtx(),t.onMouseMove(this.ctx),Un(this.ctx.originalEvent),(t instanceof vg||t instanceof tf)&&l5(this.ctx.originalEvent)}updateCtx(){let t=this.ctx,i=cd({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}=cd({x:t.mouseX,y:t.mouseY}),[n,s,a,o]=mi.getViewBox();this.ctx.canvasX=i,this.ctx.canvasY=r;let l=i-n,c=r-s,u=this.edgeRangeSize/J.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 J.windowBridge.rpcCall("getProfileSetting","",Id())).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}os((r=i.step)==null?void 0:r.value)&&(this.config.step=(n=i.step)==null?void 0:n.value),os((s=i.speed)==null?void 0:s.value)&&(this.config.speed=(a=i.speed)==null?void 0:a.value),os((o=i.altStep)==null?void 0:o.value)&&(this.config.altStep=(l=i.altStep)==null?void 0:l.value)}}},Gr=new kC;window.document.addEventListener("mouseleave",e=>{document.contains(e.relatedTarget)||(Gr.canStart=!1)});window.document.addEventListener("mouseenter",e=>{var t,i;(i=(t=e.relatedTarget)==null?void 0:t.id)!=null&&i.includes("cdot")||(Gr.canStart=!0,Gr.isRunning=!0)});window.top.addEventListener("keydown",e=>{Gr.altKeyDown=e.altKey});window.top.addEventListener("keyup",e=>{Gr.altKeyDown=e.altKey});window.addEventListener("keydown",e=>{Gr.altKeyDown=e.altKey});window.addEventListener("keyup",e=>{Gr.altKeyDown=e.altKey});function du(e){re((e==null?void 0:e.target)||J.selectBox1,{display:"none"})}function by(e,t,i,r,n){re((n==null?void 0:n.target)||J.selectBox1,{display:"",width:Math.abs(i),height:Math.abs(r),x:Math.min(e,e+i),y:Math.min(t,t+r),stroke:J.panelThemeCache.color.select,visible:"visible"})}function FC(e,t=""){let i=de("selection-polygon");re(i,{points:e,class:Ce.unselectableClass,display:t,stroke:J.panelThemeCache.color.select})}function GC(){let e=Ls.selectionMode;if(!["polygonInside","polygonOutside"].includes(e))return;let i=de("selection-polygon"),r=mN(i.points);FC("","none");let n=e==="polygonOutside",s=Ya();for(let a of s){let o=!1;for(let l of a.elements){let c=Ic(de(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=see(f,r),o)break}o=n?!o:o;for(let l of a.elements)Ls.selectElement(de(l),o,!0)}}function see(e,t){let i=0;for(let r of e)rh(r,t)&&i++;return e.length===i}var hl=class hl extends Qs{constructor(){super();this.start=!1}getSymbol(){return br.drag_select_area_tool}static canSwitchMe(i){var u;let{canvasX:r,canvasY:n,originalEvent:s}=i,a=HE(s);!((u=J.profileSetting)!=null&&u.commSystemSetting.PANEL_CANVAS.is_ctrl_drag_to_drag)&&i.ctrlKeyDown&&(a=void 0);let l=!a;return Dp(r,n)&&(l=!1),this.clickedCanvas=l,l}install(i){console.log(this.getSymbol(),"installed");let r=i.originalEvent;if(Qt(r.target)!=="cdot"&&!wc.isAdaptAreaSelectionView()){var n=Ti(r,!1);hl.ready=!0,this.x0=n.x,this.y0=n.y,this.dx=0,this.dy=0,this.x1=this.x0,this.y1=this.y0,il()}}uninstall(){console.log(this.getSymbol(),"uninstalled")}ondrag(i,r){if(r.dx===0||r.dy===0){du();return}by(r.x0,r.y0,r.dx,r.dy)}static handlePolylineSelection(){let i=hl.selectionMode;if(!["lineTouched"].includes(i))return;let n=de("selection-polyline");if(n.points.numberOfItems<2)return;let s=Ya();for(let a of s){let o;for(let l of a.elements){let c=Ic(de(l));if(o=cN(n,c),o)break}for(let l of a.elements)hl.selectElement(de(l),o,!0)}hl.showSelectPolyline("","none")}static showSelectPolyline(i,r=""){let n=de("selection-polyline");return re(n,{points:i,class:Ce.unselectableClass,display:r}),n}static selectElement(i,r,n){Ce.isSelected(i)!==r&&(n?r&&Ce.select([i]):Ce.toggle([i],r))}ondragend(i,r){if(du(),Gr.cancel(),!this.start)return;let n=hl.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=Yi(Co({matrix:[s.width,0,0,s.height,s.x,s.y]})),o=Ya();for(let l of o){if(l.combinationId&&F.getCombination(l.combinationId).visible===!1)continue;let c;for(let u of l.elements){let{cmdKey:h,json:d}=F.getById(u),p=Ei(d);if(r.dx>0)c=hy(p,s);else{if(qn(h))c=hM(s,d);else{let f;h==="text"?f=Yi(Co({matrix:[p.width,0,0,p.height,p.x,p.y]})):f=_i.convertData2Polyline([d])[0],f.some(g=>a.some(x=>qN(g,x)))&&(c=!0)}c=c||hy(p,s)}if(c)break}c=n?!c:c;for(let u of l.elements)hl.selectElement(de(u),c,i.ctrlKey)}}onMouseLeftUp(i){if(i.toolFinished=!0,hl.clickedCanvas=!1,!hl.ready)return;let r=i.originalEvent;this.ondragend(r,this),this.start=!1,setTimeout(()=>{hl.ready=!1}),_e("panel_updateAttrPanel"),_e("updateMenuByDocStatus"),_e("panel/updateTreeActiveElements")}onMouseMove(i){let r=i.originalEvent;var n=this;if(hl.ready){Gr.tryStart(i);var s=Ti(r,!1),a=s.x,o=s.y,l=a-n.x0,c=o-n.y0;if(!n.start){if((l*l+c*c)*J.gZoom*J.gZoom<9)return;n.start=!0}n.x1=a,n.y1=o,n.dx=l,n.dy=c,this.ondrag(r,this)}}};hl.ready=!1;var Ls=hl;function _1(e="",t){if(Ls.selectionMode!==e){switch(Ls.selectionMode=e,e){case"polygonInside":case"polygonOutside":{ud("draw(polygon)");break}case"lineTouched":{ud("draw(polyline)",t);break}case"rectangleInside":case"rectangleOutside":return J.frameHelper.getToolProcessor().switchToRectSelectTool();case"continuousSelection":{xr("cross-red"),fs();return}case"":{xr(),fs();return}default:throw new Error(`DragSelectAreaTool: Unknown SelectionMode ${e}`)}Ls.selectionMode=e}}function D1(){return Ls.selectionMode}var nn=10,L1=1,c5=.8,u5=.4,UC=class{getGridPointRadius(t){return L1/t}getGridPointSVGHTML(t=Xe.adsorbGrid.gridSize||5,i=L1){return`<path type="dot" opacity="${u5}" d="${this.getGridPointPathDFor1(t,i)}"/><path type="dot" opacity="${c5}" d="${this.getGridPointPathDFor10(t,i)}"/>`}getGridLineSVGHTML(t=Xe.adsorbGrid.gridSize||5){return`<path type="line" opacity="${u5}" d="${this.getGridLinePathDFor1(t)}"/><path type="line" opacity="${c5}" d="${this.getGridLinePathDFor10(t)}"/>`}getGridPointPathDFor10(t=Xe.adsorbGrid.gridSize||5,i=L1){return[this.getGridPointDByXY(-i,-i,i),this.getGridPointDByXY(-i+t*nn,-i,i),this.getGridPointDByXY(-i,-i+t*nn,i),this.getGridPointDByXY(-i+t*nn,-i+t*nn,i)].join(" ")}getGridPointPathDFor1(t=Xe.adsorbGrid.gridSize||5,i=L1){let r=[];for(let n=0;n<nn+1;n++)for(let s=0;s<nn+1;s++)(n===0||n===nn)&&(s===0||s===nn)||r.push(this.getGridPointDByXY(t*n-i,t*s-i,i));return r.join(" ")}getGridPointDByXY(t,i,r=L1){let n=2*r;return`M ${t} ${i} L ${t+n} ${i} ${t+n} ${i+n} ${t} ${i+n} ${t} ${i}`}getGridLinePathDFor10(t=Xe.adsorbGrid.gridSize||5){return`M 0 0 L 0 ${t*nn} M 0 0 L ${t*nn} 0 M 0 ${t*nn} L ${t*nn} ${t*nn} M ${t*nn} 0 L ${t*nn} ${t*nn}`}getGridLinePathDFor1(t=Xe.adsorbGrid.gridSize||5){let i=[];for(let r=1;r<nn;r++)i.push(`M 0 ${t*r} L ${nn*t} ${t*r} M ${t*r} 0 L ${t*r} ${t*nn}`);return i.join(" ")}},Fo=new UC;function OT(e,t,i){if(!mt(t)){t=t%360;for(let r of e)switch(r.cmdKey){case"rect":Ai.syncRectByRotation(t,r,i);break;case"ellipse":gi.syncEllipseByRotation(t,r,i);break;case"arc":sr.rotate(r,t,i);break;case"group":Gn.syncGroupWithRotation(r,t,i);break;case"text":lr.syncTextWithRotation(r,t,i);break;case"obj":Tr.syncImageByRotation(t,r,i);break;case"dimensionAngle":new hn(r).rotateSelf(t,i);break;case"dimensionLength":new dn(r).rotateSelf(t,i);break;case"dimensionRadius":new tn(r).rotateSelf(t,i);break;case"auxiliaryPoint":new wg(r).rotateSelf(t,i);break;default:console.error(r);break}}}function Sa(e){return e.filter(t=>{let{cmdKey:i}=F.getById(t.id);return!qn(i)})}function Mc(){return ul.isDragging||Ls.ready}function Cd(e,t,i){let r=i?.1:J.zoomRatio.min;if(e=Math.max(e,r),e=Math.min(e,J.zoomRatio.max),J.currZoom===e)return;let n=J.gZoom;J.currZoom=e,J.gZoom=e/100;var s=mi.getViewBox(),a=+re(J.svgRoot,"width"),o=+re(J.svgRoot,"height");if(t=t||{},!Qe(t,"clientX")){var l=cs(J.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/J.gZoom,u=[s[0]+t.clientX*c,s[1]+t.clientY*c,a/J.gZoom,o/J.gZoom];return Gr.canStart=!1,mi.setViewBox(u),oee(e,u),NT(u)}function NT(e){let[t,i,r,n]=e;return xt.extendRect({x:t,y:i,width:r,height:n})}var oee=$o(function(e,t){Bc(),J.windowBridge.publish("ui/canvasInfo",{tabId:J.tabId,scaleValue:+(J.gZoom*100||0).toFixed(2),unitValue:"unit(mm)"},ut()),new $i().zoom();var i=J.gZoom===1?1:ft(100/e+1e-5,5),r=.5/J.gZoom,n=function(d){return d/J.gZoom};let s=MT(),a=de("gridCell");if(re(a,{transform:he.toDOMMatrix(he.scale(s/Xe.adsorbGrid.gridSize))}),re(de("gridPattern"),{width:s*nn,height:s*nn,x:Xe.canvas.originX,y:Xe.canvas.originY}),Xe.adsorbGrid.gridType==="dot"){let d=s/Xe.adsorbGrid.gridSize*J.gZoom,p=Fo.getGridPointRadius(d),[f,m]=Zr("path",a);re(f,{d:Fo.getGridPointPathDFor1(void 0,p)}),re(m,{d:Fo.getGridPointPathDFor10(void 0,p)})}re(de("gridOH"),{"stroke-width":i,y1:Xe.canvas.originY+r,y2:Xe.canvas.originY+r}),re(de("gridOV"),{"stroke-width":i,x1:Xe.canvas.originX+r,x2:Xe.canvas.originX+r});var o=Math.max(i*4,1);o=Math.min(o,2);var l;for(l=0;l<h5.length;l++)re(h5[l],{r:4*i});ts.zoom(4*i*2),Vl.zoom(),dn.zoom(),hn.zoom(),tn.zoom(),(function(d,p){if(d){var f=d.sheet.cssRules[0];f&&(f.style.strokeWidth=p)}})(de("px1Style"),i);let c=Zr("#gCursors>image");for(l=0;l<c.length;l++){var u=J.helperCursorConfig[c[l].id];if(u&&u.trs){var h=J.gZoom==1?u.trs:u.trs.replace(/-?[\d.]+/g,n);re(c[l],{width:u.width/J.gZoom,height:u.height/J.gZoom,transform:h})}}window.frameElement&&window.frameElement.setAttribute("winzoom",String(e)),Lt.clearCrossFlagCache(),Lt.adsorptionHTMLZoom(),Zr('[c_partid="auxiliaryPoint"]',J.gCanvas).forEach(d=>Am(d,Ru/J.gZoom))}),RT=-1;function MT(e){let t=e||+Xe.adsorbGrid.gridSize;for(;t*J.gZoom<10;)t*J.gZoom*2>=10?t*=2:t*J.gZoom*5>=10?t*=5:t*=10;if(J.gZoom<1){let i=Xe.adsorbGrid.gridSize;RT===15/.254?RT=20/.254:RT=15/.254,t=Math.max(1,Math.floor(RT/J.gZoom/i))*i}return t}function Hl(e){if(e==document)return null;for(;e&&e.parentNode!=J.gCanvas;)e=e.parentNode;return e}function zl(e){J.windowBridge.publish("openPanelDialog",{ids:e,whichDialog:"drag-warn"},ut())}function CT(e,t,{saveHistory:i=!0}=xy){if(Mc())return;let r=wr.hasEleLocked(e.map(a=>a.id));if(r){zl([r]);return}e=e.filter(function(a){let{cmdKey:o}=F.getById(a.id);return!(wr.isLockedById(a.id)||o==="dimension")});let n=()=>{Th(e,t.x,t.y),Wa(e)};i?pi.wrapDo(n):n();let s=Sa(e);return s.length&&Tn(s,{create8Dots:!0}),Ki.appendSelectStroke(),!0}function DC(e){let t=to(vr());if(t.length===0)return;let i=pi.createContext(!0);for(let n of t)at.jsonSnap.addOne(F.getById(n.id).json);let r=ro(t,!0,{ignoreSnap:!0});new cl(t).mirror(!!+e,r),i(),t=Sa(t),t.length&&Tn(t,{create8Dots:!0}),Ki.appendSelectStroke()}function kc(e,t){if(!e.length){console.error(e,t);return}let i=t||-90;i=i>0?i-360:i,Ki.emptyLastHoverEle().emptySelectContainer().removeHighlightStroke();let r=e.filter(s=>{let{cmdKey:a}=F.getById(s.id);return a!=="dimension"}),n=ro(r,!1,{ignoreSnap:!0});for(let s of e){let{json:a}=F.getById(s.id);OT([a],i+(a.rotation||0),new V(n.x,n.y))}}function WB(e){let t;e[0]instanceof Element?t=e:t=Ig({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=F.getRefId(s.id),l=tt.getLastEleByLayerId(re(s,"layer"));if(!l||l===s)continue;let c=l.nextSibling,u=F.getById(s.id).json,h=u.zIndex,d=F.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&&at.save(r)}function qB(e){let t=Ig({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=F.getRefId(s.id),l=tt.getFirstEleByLayerId(re(s,"layer"));if(!l||l===s)continue;let c=F.getById(s.id).json,u=c.zIndex,h=F.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&&at.save(r)}function lee(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 Ig(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(Zr("#"+o.join(",#"),J.gCanvas)))(n):vr();return a=a.filter(o=>!!o),i||(a=a.filter(function(o){return!wr.isLockedById(o.id)})),t||a.sort(lee),r&&a.reverse(),a}function JB(e){let t=Ig({ids:e,reverse:!0}),i=[];for(let r of t){let n=tt.getNextSameLayerNode(r);if(n&&!t.includes(n)){let s=n.id||"",a=tt.getNextSameLayerNode(n),o=(a==null?void 0:a.id)||"",l=F.getById(r.id).json,c=l.zIndex,{zIndex:u}=F.getById(s).json||{},{zIndex:h=u+2}=F.getById(o).json||{};l.zIndex=(u+h)/2,c===l.zIndex?d5(l,r,i,"raise"):i.push(["json",r.id,{cmdKey:l.cmdKey,refId:o},{zIndex:c},{zIndex:l.zIndex}]);let d=F.getItemOrder().find(f=>{let m=F.getById(f).json;return f!==l.gId&&l.zIndex<m.zIndex}),p=jr(`#${d}`);r.parentNode.insertBefore(r,p||a),i.push(["elePosition",r.id,s,o])}}i.length&&at.save(i)}function KB(e){let t=Ig({ids:e}),i=[];for(let r of t){let n=tt.getPrevSameLayerNode(r);if(n&&!t.includes(n)){let s=r.nextElementSibling,a=(s==null?void 0:s.id)||"",o=n.id||"",l=tt.getPrevSameLayerNode(n),c=F.getById(r.id).json,u=c.zIndex,{zIndex:h}=F.getById(o).json||{},{zIndex:d=h-2}=F.getById(l==null?void 0:l.id).json||{};c.zIndex=(h+d)/2,u===c.zIndex?d5(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&&at.save(i)}function d5(e,t,i,r){let n=r==="raise"?1:-1,{zIndex:s}=e,a=tt.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 x;let m=F.getById(p).json;m.zIndex=u+d*(f+1);let g=o[f+1]||((x=tt.getNextSameLayerNode(jr(`#${p}`)))==null?void 0:x.id);i.push(["json",p,{cmdKey:m.cmdKey,refId:g||""},{zIndex:s},{zIndex:m.zIndex}])})}var h5=[];function UB(e){e.head.version=uf,F.gJsonCache=e,re(window.frameElement,"jsonCacheReady",!0)}var Bm=class{static isShowContextMenu({target:t,type:i,button:r}){return this.canDeleteDot(t)&&Qt(t)==="cdot"&&i==="mouseup"&&r===2}static canDeleteDot(t){return re(t,"class")!=="light"}static deletePathNode(t,i){let r=t.id;if(!r)return;let n=Ce.get()[0],s,a;if(wr.isLockedById(n.id)||!n||!ba(n.parentNode,Ml)||!t||t.parentNode!=J.gControlDots||re(t,"class")=="light"||n.tagName!="path"&&n.tagName!="polyline"&&n.tagName!="polygon")return;let o=+r.substr(4);if(s=J.gControlDots.children[1],s&&(re(s,"class")=="light"||re(s,"visibility")=="hidden")&&(o=o>>1),(d=>d.tagName==="path")(n)){if(i&&i.type==="anchor"&&n.pathSegList.numberOfItems<=2)return;let d=Fn(n),p=zr(n.id,{cmdKey:"group",refId:d},F.getById(n.id).json);if(p5(n,o),n.getTotalLength()<.01)_o([n]);else{Gs(n);let f=F.getById(n.id).json;f.d=re(n,"d"),p[4]=Zt(f),at.save(p)}return}var c=n,u=c.points,h=u.numberOfItems;h<=2||o>=0&&o<h&&(a=["attr",c.id,{points:re(c,"points")}],u.removeItem(o),Gs(c),a[3]={points:re(c,"points")},at.save(a))}};function to(e){let t=[];for(let i of e){let r=F.getById(i.id).cmdKey;if(r=="dimension"&&F.getDimension(i.id).category=="Constraint")return is.toastMsg(),[];["dimension","auxiliaryLine","auxiliaryPoint"].includes(r)||t.push(i)}if(!t.length)return[];if(e.length>1){let i=new Do().findDimensionByPrimitiveId(new Set(e.map(r=>r.id)));for(let r of i)if(F.getDimension(r).category=="Constraint")return is.toastMsg(),[]}return e}var wh=class wh{static bringObjsToFront(t){let i;t[0]instanceof Element?i=t:i=Ig({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 Ro("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 Ao;jm().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 NI;let r=this,n=[],s=new DocumentFragment;Zr(`[layer="${t}"]`,J.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=jr(`[layer="${o}"]`,J.gCanvas)))&&c(o)}l||(l=jr(`[layer="${i}"]`,J.gCanvas));let u=l?h=>{l.before(h)}:h=>{J.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);F.getItemOrder().forEach(a=>{var l;if(((l=F.getById(a).json)==null?void 0:l.layer)===this._activeLayer){let c=jr(`#${a}`);J.gCanvas.insertBefore(c,s)}});break}if(Object.keys(i).length===1&&!i[n]){this.setActiveLayer(null);break}}}static removeActived(){let t=F.getItemOrder(),i=null;for(let r=t.length-1;r>=0;r--){let n=jr(`#${t[r]}`);n&&(J.gCanvas.insertBefore(n,i),i=n)}}static applyLocked(){let{locked:t}=this.recorder;for(let i in t){let r=[...Zr(`[layer="${i}"]`,J.gCanvas)],n=t[i];r.forEach(s=>Js(s,Ce.unselectableClass,n))}}static applyVisible(){let{visible:t}=this.recorder;for(let i in t)+i===-1&&new Xa().display(t[i]);F.iterator(i=>{mt(i.layer)||yi.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=wh.activeLayer,r=!0,n={}){var l;let s=n.cmdKey||Qt(t);O1[s].includes(+i)||(r&&J.windowBridge.publish("ui/toastMsg",{type:"warn",msg:cee[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))||{};Js(t,Ce.unselectableClass,o)}static getTargetPlaceLayer(t){return O1[t].includes(wh.activeLayer)?wh.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=jm(),o=wh.getLastEleByLayerId(i);if(o)s=(c=o.nextElementSibling)==null?void 0:c.id,J.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=wh.getFirstEleByLayerId(this.activeLayer),s=o==null?void 0:o.id),J.gCanvas.insertBefore(t,o)}return r.push(at.createElePosition(t.id,n,s)),r}static getZIndexMap(){let t=F.getItemOrder(),i={};t.forEach(n=>{let{zIndex:s}=F.getById(n).json;f5(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=J.gCanvas.firstChild;for(;;){if(!r)return null;if(+re(r,"layer")==+t)return r;r=r.nextSibling}}static getLastEleByLayerId(t){let r=J.gCanvas.lastChild;if(!r)return null;for(;;){if(+re(r,"layer")==+t)return r;if(r=r.previousSibling,!r)return null}}static getNextEleById(t){let i=F.getItemOrder(),r=cT(),{layer:n,zIndex:s}=F.getById(t).json,a=this._activeLayer===n,o=i.find(l=>{let{layer:c,zIndex:u}=F.getById(l).json;if(c===n)return u>s&&jr(`#${l}`);if(!a&&n!==8){let h=r.get(c),d=r.get(n);return h>d&&jr(`#${l}`)}});return o?jr(`#${o}`):null}static getNodeLayer(t){return+re(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}}};wh._activeLayer=null,wh.recorder=Object.create(null);var tt=wh,cee={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 ug="selected",YC="highlight",m5="object-unselectable",g5=$o(()=>{var e;(e=F.selectedRepeater)==null||e.updateChange(),Ki.appendSelectStroke(),Bc(void 0,Kp())},0);function uee(e){let t=e.id;if(!Ce.isUnselectAble(t))return no.select(t),Js(de(t),ug,!0),g5(),!0}function BT(e){no.unselect(e.id),Js(e,ug,!1),g5()}function kT(e){ba(e,m5)||Js(e,YC,!0)}function FT(e){Js(e,YC,!1)}var Ce=class{static isUnselectAble(t){let i=Ga(),{json:r,cmdKey:n}=F.getById(t);if(!r)return!0;let s=jt.isEditingPath();if(s&&t!==s&&!qn(n))return!0;let{layer:a,hide:o,gId:l,locked:c}=r;if(i["all-element-type"][Ty(n)].checked===!1||yi.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}=tt.getCurrentScheme();for(let h of u)if(+h.id==+a&&h.locked)return!0;return!1}static count(){return no.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(!Kt.isEleCanSelect(t)&&!qn(F.getById(t).cmdKey)||!jt.isEleCanSelect(t)&&!qn(F.getById(t).cmdKey))return;let i=Kt.findCombinationElementsById(t);if(i!==Q1){for(let r of i)Js(de(r),ug,!0),no.select(r);uee({id:t})}}static unselect(t){if(t){if(t.nodeType==1)BT(t);else if(t.length)for(var i=0,r=t.length;i<r;i++)BT(t[i])}}static unSelectById(t){no.unselect(t)}static highlight(t){if(t){if(t.nodeType==1)kT(t);else if(t.length)for(var i=0,r=t.length;i<r;i++)kT(t[i])}}static unhighlight(t){if(t){if(t.nodeType==1)FT(t);else if(t.length)for(var i=0,r=t.length;i<r;i++)FT(t[i])}}static toggleHighlight(t,i){if(t){if(t.nodeType==1)i===!0?kT(t):i===!1&&FT(t);else if(t.length)for(var r=0,n=t.length;r<n;r++)i===!0?kT(t[r]):i===!1&&FT(t[r])}}static isSelected(t){return yi.eleIsHide(F.getById(t.id).json)?!1:no.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?BT(t[r]):i===void 0&&(no.isSelect(t[r].id)?BT(t[r]):this.select([t[r]]))}static unselectAll(){return no.get().clear(),this}static get(){let t=no.get(),i=[];for(let r of t){let n=jr("#"+r,J.gCanvas);n?i.push(n):(console.error("no dom, Plz check code",r),no.unselect(r))}return i}static getIds(){return[...no.get()]}};Ce.highlightClass=YC,Ce.selectClass=ug,Ce.unselectableClass=m5;var GT=class{constructor(){this.selectIds=new Set}select(t){if(!gc(t))throw new Error(t);this.selectIds.add(t)}unselect(t){if(!gc(t))throw new Error(t);this.selectIds.delete(t)}isSelect(t){if(!gc(t))throw new Error(t);return this.selectIds.has(t)}get(){return this.selectIds}getIds(){return[...this.selectIds]}clear(){this.selectIds.clear()}},no=new GT,Ag=new GT;function y5(e,t){let i=new Pi(e),r=i.vectorCenter(),n=Ei(e,"arc"),s=hi.transferXYByReference(n),a=new V(s[0],s[1]);for(let[o,l]of Object.entries(t))switch(o){case"attr-width":sr.syncArcSize(e,a,l,null);break;case"attr-height":sr.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=he.translate(l-r.x,0);sr.syncArc(e,c,{updateD:!0})}break;case"attr-circle-center-y":{let c=he.translate(0,l-r.y);sr.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":{sr.rotate(e,-l,a);break}case"attr-x":{let c=he.translate(l-s[0],0);sr.syncArc(e,c,{updateD:!0})}break;case"attr-y":{let c=he.translate(0,l-s[1]);sr.syncArc(e,c,{updateD:!0})}break;default:console.error(o,"Plz check code");break}}function b5(e,t){let i=new tn(e),r=ro([de(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 V(r.x,r.y));break}i.setData().render()}function x5(e,t){let i=new hn(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 E5(e,t){let i=new dn(e),r=ro([de(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 V(r.x,r.y));return}i.calcuMeasurePoint().setData().render()}function T5(e,t){let i=Ei(t,"ellipse"),r=hi.transferXYByReference({...i,x:e["attr-x"]||i.x,y:e["attr-y"]||i.y}),n=new V(r[0],r[1]);if(Qe(e,"attr-x")||Qe(e,"attr-y")){let s=hi.transferXYByReference({...i,x:e["attr-x"],y:e["attr-y"]},!0);gi.syncEllipsePosition(t,s[0],s[1])}if((Qe(e,"attr-width")||Qe(e,"attr-height"))&&gi.syncEllipseSize(t,e["attr-width"],e["attr-height"],n),Qe(e,"attr-rotation")){let s=hi.transferXYByReference(i),a=new V(s[0],s[1]),o=e["attr-rotation"];gi.syncEllipseByRotation(-o,t,a,{beautify:!0})}(Qe(e,"attr-short-radius")||Qe(e,"attr-long-radius"))&&gi.syncEllipseRadius(t,e["attr-short-radius"],e["attr-long-radius"],n)}async function w5(e,t){let i=de(t.gId),r=new WE(i),n=Lp(t),s=hi.transferXYByReference({...n,x:e["attr-x"],y:e["attr-y"]},!0);lr.syncTextPosition(t,s[0],s[1]);let a=hi.transferXYByReference({...n}),o=new V(a[0],a[1]);(Qe(e,"attr-width")||Qe(e,"attr-height"))&&lr.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{_o([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]=UT(c);lr.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":lr.resetText(i);break;case"attr-rotation":lr.syncTextWithRotation(t,-c,o);break;case"attr-width":case"attr-height":case"attr-obb-width":case"attr-obb-height":break;default:break}}}function S5(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=J.panelThemeCache.fillColor.auxiliaryPoint;case"attr-conceal":{e.visible=t[i]!=="yes";break}default:console.error(`AuxiliaryLine: can not update attr(${i}) on auxiliaryLine`)}}function v5(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=J.panelThemeCache.color.auxiliaryLine;break}case"attr-stroke-style":{e.strokeStyle=Wh(r).key;break}default:console.warn(`AuxiliaryLine: can not update attr(${i}) on auxiliaryLine`)}}new Ul(e).render()}function I5(e,t){let{x:i,y:r,width:n,height:s}=Mr(t),a=[],o=1,l=1,c=hi.transferXYByReference({x:i,y:r,width:n,height:s}),u=new V(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=hi.transferXYByReference({x:m,y:r,width:n,height:s},!0)[0]-i;break;case"attr-y":case"attr-bbox-y":p=hi.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}=F.getById(f.id);OT([g],-h+g.rotation,u),Yn.move(g,d,p);let x=Ei(g);hee(m,g,o*x.width,l*x.height,u),a.push(()=>{Array.isArray(g.tempMatrix)&&F.updatePrimitiveJson(g.gId,"matrix",g.tempMatrix)})}return a}function hee(e,t,i,r,n){switch(e){case"group":Gn.syncGroupSize(t,i,r,n);break;case"obj":Tr.syncImageSize(t,n,i,r);break;case"text":lr.syncTextSize(t,i,r,n);break;case"ellipse":gi.syncEllipseSize(t,i,r,n);break;case"arc":sr.syncArcSize(t,n,i,r);break;case"rect":Ai.syncRectSize(t,n,i,r);break;default:console.error(e)}}function dee(e,t){console.warn(e,t);let i=[],r=e.id,s=new st().getAllElesfromTop(r).elements;for(let c of s)i.push(de(c));let a=DT([e],J.tabId);t=hi.widthHeightKeepSameRatio(t,a);for(let c of i)at.jsonSnap.addOne(F.getById(c.id).json);at.jsonSnap.addOneCombineByComId(r);let o=[],l=F.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(...I5(t,i));break e}default:o.push(...I5(t,i));break}return o}async function D5(e,t){var m,g,x;t=Zt(t);let i=[];if(e.cmdKey==="canvas")return mi.modify_canvas(t);let{cmdKey:r,id:n}=e,s=de(n);if("combination"===r)return dee(e,t);let a=PC([s]),o=DT(a,J.tabId,{notCreate8Dots:!0});t=hi.widthHeightKeepSameRatio(t,o);let l=(g=(m=F.gJsonCache[r])==null?void 0:m[s.id])==null?void 0:g.layer,c=+t["attr-layer"],u=F.getById(n).json;if(xee(u,t),Qe(t,"attr-layer")&&(c==l?delete t["attr-layer"]:(t["attr-transparency-print"]=1,t["attr-transparency-white"]=1,re(s,"opacity",1),u.transparencyPrint=1,u.transparencyWhite=1)),t=hi.filterModifyAttrs(t,o),Qe(t,"attr-rotation")&&!pee(t["attr-rotation"],u,r)&&delete t["attr-rotation"],Object.keys(t).length===0)return;if(at.jsonSnap.addOne(u),console.log(e,t),Qe(t,"attr-rotation")){let y=fr(t["attr-rotation"]);t["attr-rotation"]=y}switch((Qe(t,"attr-obb-width")||Qe(t,"attr-obb-height"))&&new Nd().syncSelfObbSize(u,t["attr-obb-width"],t["attr-obb-height"]),r){case"obj":let y=t["attr-href"];if(y!==void 0&&!yN(y)||y!==void 0&&_5(y)!=y||c&&c!==1)return;gee(t,u);break;case"rect":fee(t,u);break;case"ellipse":T5(t,u);break;case"group":mee(t,u);break;case"text":await w5(t,u);break;case"auxiliaryLine":{v5(u,t);break}case"auxiliaryPoint":{S5(u,t),Op(u,s.id);break}case"dimension":{is.updateDimensionData(e.id,t);break}case"dimensionLength":{E5(u,t);break}case"dimensionAngle":{x5(u,t);break}case"dimensionRadius":{b5(u,t);break}case"arc":{y5(u,t);break}default:console.error(r);break}if(Qe(t,"attr-locked")&&(u.locked=t["attr-locked"]==="yes"),Qe(t,"attr-conceal")&&(u.visible=t["attr-conceal"]!=="yes",yi.applyElementsVisible(n)),Qe(t,"attr-layer")){let y=((x=F.gJsonCache[r])==null?void 0:x[s.id])||{},E={layer:y.layer,cover:"cover"in y?y.cover:re(s,"cover")=="1",scope:y.scope},T={layer:c,cover:E.cover,scope:E.scope},w=O1[r];if(!w||w.includes(T.layer)){T.layer==1&&(T.cover=E.cover,y.cover=!0),T.layer==2&&(T.scope=E.scope||1,re(s,"scope",T.scope),y.scope=T.scope);let b=tt.switchLayer(s,c);i.push(...b),re(s,"layer",c),y.layer=c;let C=Zt(tt.getCurrentScheme());for(let A of C.options)A.actived===!0&&(A.actived=!1),+A.id==+c&&(A.actived=!0);tt.apply(C),_e("panel/active-layer",[c,J.tabId,{updateUI:!0}])}}if(Qe(t,"attr-cover")&&re(s,"cover",t["attr-cover"]==="yes"?1:0),Qe(t,"attr-scope")&&re(s,"scope",t["attr-scope"]),Qe(t,"attr-name")&&re(s,"name",t["attr-name"]),Qe(t,"attr-hide")&&re(s,"hide",t["attr-hide"]==="yes"?"1":"0"),Qe(t,"attr-transparency-print")&&[+c,+l].includes(2)){let y=Rp(+t["attr-transparency-print"]*100,+t["attr-transparency-white"]*100);re(s,"opacity",y),re(s,"transparency-print",t["attr-transparency-print"]),re(s,"transparency-white",t["attr-transparency-white"])}let h=r==="text",d=["auxiliaryLine","auxiliaryPoint","dimension","dimensionAngle","dimensionLength","dimensionRadius"].includes(r),p=Qe(t,"attr-stroke-color"),f=Qe(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 T=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":T==="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,R1(s,r,u)}if("attr-fill-color-display"in t){let y=t["attr-fill-color-display"];u.displayFill=y,N1(u)}if(Qe(t,"attr-stroke-width")){let y=t["attr-stroke-width"];u.strokeWidth=y,jC(s,r,y)}if(!mt(u.displayStroke)&&Qe(t,"attr-stroke-color")){let y=t["attr-stroke-color"];u.strokeColor=y,R1(s,r,u)}if(!mt(u.displayFill)&&Qe(t,"attr-fill-color")){let y=t["attr-fill-color"];u.fillColor=y,N1(u)}i.length&&at.save(i),t&&Reflect.ownKeys(t).length&&kN(e,t)}function pee(e,t,i){if(!["obj","rect","ellipse","group","text","arc"].includes(i))return!0;let r=M1(t),n=hi.transferXYByReference(r),s=new V(n[0],n[1]),a;switch(i){case"obj":a=Tr.getRotationMatrix(e,t,s);break;case"rect":a=Ai.getRotationMatrix(-e,t,s);break;case"ellipse":a=gi.getRotationMatrix(-e,t,s,{beautify:!0});break;case"group":a=Gn.getRotationMatrix(t,-e,s);break;case"text":a=lr.getRotationMatrix(t,-e,s);break;case"arc":{a=sr.getRotationMatrix(t,-e,s);break}default:return!0}return pi.checkOne(i,t,a)}function R1(e,t,i){let r=i.strokeColor||"none";t==="text"&&re(jr("path",e),{stroke:r,fill:r}),i.displayStroke===!1&&(r="none"),re(e,{stroke:r})}function N1(e){let t=e.fillColor||"none";e.displayFill===!1&&(t="none"),ni.renderer.attr(e.gId,"fill",t)}function jC(e,t,i){switch(t){case"text":re(jr("path",e),{"stroke-width":i});break;default:re(e,{"stroke-width":i});break}}function PC(e){let t=new Map,i=Ya();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}=F.getById(s.id);r.push({id:s.id,cmdKey:a})}return r}function A5(e){let t=Tt("image",{"xlink:href":e.content});J.gCanvas.appendChild(t);let i=t.getBBox();return dt(t),i}function Rp(e,t){let{point:i}=Ks({x:e,y:t},{x:0,y:0},{x:100,y:100}),r=dy({x:0,y:0},{x:100,y:100});return 1-dy({x:i.x,y:i.y},{x:100,y:100})/r}var P5=(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))(P5||{}),HC=class{constructor(){this.referencePointKey="reference-point";this.getReferencePoint()}getReferencePoint(){let t=localStorage.getItem(this.referencePointKey),i=mt(t)?6:+t;return Object.values(P5).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=Zt(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 Qe(t,r)&&Qe(t,n)?t:Qe(t,r)?(t[n]=+(+t[r]/i[r]*i[n]).toFixed(2),t):Qe(t,n)?(t[r]=+(t[n]/i[n]*i[r]).toFixed(2),t):Qe(t,s)&&Qe(t,a)?t:Qe(t,s)?(t[a]=+(+t[s]/i[s]*i[a]).toFixed(2),t):(Qe(t,a)&&(t[s]=+(t[a]/i[a]*i[s]).toFixed(2)),t)}},hi=new HC;function fee(e,t){let i=M1(t),r=hi.transferXYByReference(i),n=new V(r[0],r[1]);if(Qe(e,"attr-x")||Qe(e,"attr-y")){let s=hi.transferXYByReference({x:e["attr-x"],y:e["attr-y"],width:i.width,height:i.height},!0);Ai.syncRectPosition(t,s[0],s[1])}if((Qe(e,"attr-width")||Qe(e,"attr-height"))&&Ai.syncRectSize(t,n,e["attr-width"],e["attr-height"]),"attr-rotation"in e){let s=+e["attr-rotation"];Ai.syncRectByRotation(-s,t,n)}if(Qe(e,"attr-radius")){let s=e["attr-radius"];re(de(t.gId),{rx:s,ry:s}),t.rx=s,t.ry=s}}function mee(e,t){let i=Gn.getGroupBBox(t),r=hi.transferXYByReference(i),n=new V(r[0],r[1]);if(Qe(e,"attr-rotation")){let s=e["attr-rotation"];Gn.syncGroupWithRotation(t,-s,n)}if("attr-x"in e){let s=hi.transferXYByReference({...i,x:e["attr-x"]},!0);Yn.move(t,s[0]-i.x,0)}if("attr-y"in e){let s=hi.transferXYByReference({...i,y:e["attr-y"]},!0);Yn.move(t,0,s[1]-i.y)}Gn.syncGroupSize(t,e["attr-width"],e["attr-height"],n)}function gee(e,t){let i=de(t.gId),r=M1(t),n=hi.transferXYByReference(r),s=new V(n[0],n[1]);if(("attr-width"in e||"attr-height"in e)&&Tr.syncImageSize(t,s,e["attr-width"],e["attr-height"]),"attr-x"in e||"attr-y"in e){let a=hi.transferXYByReference({x:e["attr-x"],y:e["attr-y"],width:r.width,height:r.height},!0);Tr.syncImagePosition(i,a[0],a[1])}for(let a in e){let o=e[a];switch(a){case"attr-href":t.content=o,re(i,{"xlink:href":o});break;case"attr-transparency":o=Math.min(Math.max(+o,0),100),t.opacity=1-o/100;let l=Qe(e,"attr-layer")?+e["attr-layer"]:t.layer;re(i,"opacity",l==2?1-t.opacity:t.opacity);break;case"attr-rotation":Tr.syncImageByRotation(-o,t,s);break;case"attr-reset-image-width":{let{width:c,height:u}=A5(t),h=Tr.getImageShapeForAttr(t.matrix),d=$e.createMatrixFrom6(t.matrix).getInverseMatrix(),p=he.scale(c/u*h.height,h.height).rotateD(t.rotation).translate(h.x,h.y),f=new he(d.data);Tr.syncImage(t,f.multiply3(p));break}case"attr-reset-image-height":{let{width:c,height:u}=A5(t),h=Tr.getImageShapeForAttr(t.matrix),d=$e.createMatrixFrom6(t.matrix).getInverseMatrix(),p=he.scale(h.width,u/c*h.width).rotateD(t.rotation).translate(h.x,h.y),f=new he(d.data);Tr.syncImage(t,f.multiply3(p));break}default:console.error("image attr",a);break}}}function $B(){let e=Ce.get(),t=new oi(e);for(let i of e){let{json:r,cmdKey:n}=F.getById(i.id);if(!r.fillColor||!r.strokeColor)continue;let s=r.strokeColor;r.strokeColor=r.fillColor,r.fillColor=s,R1(i,n,r),N1(r)}t.updateAndSave(),_e("panel_updateAttrPanel")}function DT(e,t,i={}){let r=F.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 st().getAllElesfromTop(o.id).elements;for(let c of l)a.add(de(c));continue}o.id&&a.add(de(o.id))}!i.notCreate8Dots&&a.size&&Tn([...a],{create8Dots:!0}),a.size===0&&(il(),du(),nh("","none"));for(let o of e){let l=o.cmdKey;if(l==="canvas"){s.target[t].canvas=o,s=C5(s,mi.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=F.getShapeAttr(c[o.id],o.cmdKey);s=C5(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=yee(e.filter(o=>!qn(o.cmdKey)),s),s}function yee(e,t){if(e.length<2)return t;let i=[];for(let r of e)r.cmdKey==="combination"?F.getCombination(r.id).elements.forEach(n=>{i.push(de(n))}):i.push(de(r.id));return bee(i,t)}function bee(e,t){let i=Mr(e),r=hi.transferXYByReference(i),[n,s]=F.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 C5(e,t){let i="attr-selected-count";t.cmdKey!=="canvas"&&e[i]++;for(let n in t){if(!Qe(t,n)||n===i||n==="docType"){t.docType&&!e.docType&&(e.docType=t.docType);continue}if(!Qe(e,n)){e[n]=t[n];continue}if(n==="target"){e.target||(e.target={}),t.target||(t.target={});for(let s in t[n])Qe(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"&&qn(e.type)&&qn(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]=UD),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 xee(e,t){if(e.locked)for(let i in t)vR.includes(i)||delete t[i];return t}var VC=class{constructor(){this.polyline=[]}async run(t){this.type=t;let i=VE().filter(r=>!qn(r.cmdKey));if(!i.length){Hr("\u5F53\u524D\u753B\u5E03\u4E2D\u6CA1\u6709\u9009\u4E2D\u7684\u5143\u7D20");return}if(t=="boolSubtraction"){let r=F.getItemOrderMap();i.sort((n,s)=>r.get(n.gId)-r.get(s.gId))}this.selectedObjs=i,ni.history.startBatch(),i=await Promise.all(i.map(async r=>{let n=Ei(r),{x:s,y:a,height:o,width:l}=n,c=hi.getReferencePoint();hi.setReferencePoint(0);let u=a,h=s,d=s+l,p=a+o,f=qs(u),m=qs(h),g=qs(d),x=qs(p),y=ya(Cu(f)),E=ya(Cu(m)),T=ya(Cu(g)),w=ya(Cu(x)),b=u-y,C=h-E,A=T-E,R=w-y;return Yn.move(r,-C,-b),await D5({id:r.gId,cmdKey:r.cmdKey},{"attr-width":A,"attr-height":R}),hi.setReferencePoint(c),r})),this.polyline=_i.convertData2Polyline(i),this.operate(),ni.history.saveBatch()}operate(){let t;switch(this.type){case"boolAggregate":t=_i.boolAggregate(this.polyline);break;case"boolIntersection":t=_i.boolIntersection(this.polyline);break;case"boolSubtraction":if(t=_i.boolSubtraction1(this.polyline),!t.length&&this.polyline.length==2){let n=[this.polyline[1],this.polyline[0]];t=_i.boolSubtraction1(n)}break;case"boolExclusive":t=_i.boolExclusive(this.polyline);break}t=t.map(n=>n.round(4));let i=["boolAggregate","boolSubtraction"].includes(this.type),r=_i.convertPolylines2Svg(t,i,!1);r.length&&(Xt(),this.removeSelectedObjs(),this.createNewShape(r))}removeSelectedObjs(){let t=[...this.selectedObjs],i=is.findDimensionByPrimitiveIds(new Set(t.map(r=>r.gId)));for(let r of i)ni.history.jsonSnap.addOne(F.getById(r.gId).json),F.removeOne({id:r.gId});for(let r of t)ni.history.jsonSnap.addOne(r),F.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=_t(),s=F.getInitialGroupData({gId:n,layer:i.layer,d:r,fillColor:i.fillColor,strokeColor:i.strokeColor,strokeWidth:i.strokeWidth});rl(s),Ce.select([{id:s.gId}]),ni.history.jsonSnap.addOne(s,{},"group")}}};async function L5(e){let t=new VC;await t.run(e),t=null,_e("panel_updateAttrPanel")}var YT=class{constructor(){this.BBoxCached=BN();this.PolylineCached=_i.convertData2PolylineCached()}hasObjOutBoard(){let t=[],i=[];if(F.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=SB.getMergeCloseBoardSvgJson(F.gJsonCache,3);n.forEach(a=>{let l=a.polylineGroup.multiply3(he.MIRROR_Y).bbox();r.set(a,l)});let s=[];for(let a of i){let{cmd:o,id:l}=a,{json:c}=F.getById(l),u=0,h=this.BBoxCached(c);for(let d of n){let p=r.get(d);if(xt.extendRect(h).isSeparated(p)){u++;continue}if(p.isContainsBBox1(xt.extendRect(h)))break;let f=this.PolylineCached([c]);if(_i.boolIntersection([f[0],d.polylineGroup.items]).length)break;u++}u===n.length&&s.push({id:l,cmd:Gi[o]})}return s}boardGapCheck(t,i){let r=[],n=[],s=new Xa,a=F.getInitialGroupData({d:s.getPanelMarkPathDForDesign(),gId:"frame-sheet",cmdKey:"group",matrix:$e.getMatrix6FromMatrix(he.ORIGIN)});F.iterator((o,l,c)=>{if(!o.hide&&l!=="combination"&&o.layer===t){let u=this.PolylineCached([F.getById(c).json,a]);_i.boolIsIntersection(u[0],u[1])&&r.push({data:o,cmd:l,id:c})}});for(let o=0;o<r.length-1;o++){let l=Zt(F.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=Ec(xt.extendRect(p).extendOfSize(i)),x=g.width/p.width,y=g.height/p.height,E,T,w;for(let b=o+1;b<r.length;b++){let C=r[b],A=C.data,R=C.cmd,O=C.id,M=this.BBoxCached(A);if(xt.extendRect(g).isSeparated(xt.extendRect(M)))continue;switch(h){case"rect":w=$e.createMatrixFrom6(u.matrix).multiply3(he.scale(x,y).setOrigin(f,m)),l[h][d].matrix=$e.getMatrix6FromMatrix(w);break;case"ellipse":w=$e.createMatrixFrom6(u.matrix).multiply3(he.scale(x,y).setOrigin(f,m)),l[h][d].matrix=$e.getMatrix6FromMatrix(w);break;case"arc":u.displayFill=!0,u.fillColor="#000000",E=_i.convertJsonCache2PolyLines(u,"arc"),T=ah(E,i);break;case"group":E=_i.convertJsonCache2PolyLines(u,"group"),T=ah(E,i);break}let k=this.PolylineCached([F.getById(d).json,F.getById(O).json]),G=ah(new Nr(k[0]),i),H=["group","arc"].includes(h)?_i.boolIntersection([T.items,k[1]]):_i.boolIntersection([G.items,k[1]]);if(H.length){let q=[{id:d,cmd:Gi[h]},{id:O,cmd:Gi[R]}],I=new ot().ext1(H[0].__bbox).build();I.width()>.13&&I.height()>.13&&n.push(q)}}}return n}hasObjInMark(){let t=[],i=[],r=O5();return F.iterator((n,s,a)=>{n.hide||n.layer===4&&s!="combination"&&i.push({data:n,cmd:s,id:a})}),F.iterator((n,s,a)=>{if(n.hide||n.layer===8||n.layer===4||s==="combination"||yi.eleIsHide(n))return;let o=this.BBoxCached(n);if(n.strokeWidth&&n.displayStroke){let l=n.strokeWidth;s==="group"?r=O5(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(!xt.extendRect(o).isSeparated(xt.extendRect(u))){for(let h of i){let d=this.PolylineCached([F.getById(a).json,F.getById(h.id).json]),p=d[1];if(_i.boolIntersection(d).length){let f=[];for(let m of p)m.points(.5,g=>{f.push({x:g.x,y:-g.y})});if(uu({x:l.x0,y:l.y0},f)&&uu({x:l.x100,y:l.y100},f)&&uu({x:l.x200,y:l.y200},f)&&uu({x:l.x300,y:l.y300},f))return}}hy(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":(bc(d,p,o)||Eee(d,p,n))&&t.push(a);break;case"ellipse":let{cx:f,cy:m,rx:g,ry:x}=gi.getEllipseFromMatrix(n.matrix);($a(f,m,d,p,g,x)<=1||Tee(d,p,n))&&t.push(a);break;case"arc":let y=vc(d,p);y.length&&y.forEach(w=>{t.push(w)}),wee(d,p,n)&&t.push(a);break;case"text":See(u,n)&&t.push(a);break;case"group":let E=Cp(d,p);E.length&&E.forEach(w=>{t.push(w.id)});break;case"obj":let T=Mm(d,p);T.length&&T.forEach(w=>{t.push(w.id)});break}}}}}),[...new Set(t)]}hasObjOutMaterialFrame(){let t=[],{w:i,h:r}=new Xa().getMaterialFrameSize();return F.iterator((n,s,a)=>{if(n.layer!==3)return;let{x:o,y:l,width:c,height:u}=s==="group"?pE(n):Ei(n);(o<0||-l>r||o+c>i||-l-u<0)&&t.push({displayId:n.id,gId:n.gId})}),t}};function O5(e=0){let t=[];return new Xa().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 Eee(e,t,i){if(i.strokeWidth&&i.displayStroke){let r=i.strokeWidth/2,n=Ei(i,"rect"),s=Zt(n);s.x+=r,s.y+=r,s.width-=r*2,s.height-=r*2;let a=Zt(n),o=Zt(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=$a(l,c,e,t,r,r)<=1||$a(u,h,e,t,r,r)<=1||$a(d,p,e,t,r,r)<=1||$a(f,m,e,t,r,r)<=1;if(!bc(e,t,s)&&(bc(e,t,a)||bc(e,t,o)||g))return!0}return!1}function Tee(e,t,i){if(i.strokeWidth&&i.displayStroke){let{cx:r,cy:n,rx:s,ry:a}=gi.getEllipseFromMatrix(i.matrix),o=s-i.strokeWidth/2,l=a-i.strokeWidth/2,c=s+i.strokeWidth/2,u=a+i.strokeWidth/2,h=$a(r,n,e,t,o,l),d=$a(r,n,e,t,c,u);if(h>=1&&d<=1)return!0}return!1}function wee(e,t,i){let r=(i.x1+i.x2)/2,n=(i.y1+i.y2)/2,s=new V(i.x1-i.x2,i.y1-i.y2),a=new V(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=$a(r,n,e,t,l,c),p=$a(r,n,e,t,u,h),f=$a(i.x1,i.y1,e,t,i.strokeWidth/2,i.strokeWidth),m=$a(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"&&$a(r,n,e,t,i.rx,i.ry)<=1&&o<=0)}function See(e,t){let i=ct.createMatrixFrom6(t.matrix),r=Yi(t.d,!1),n=[];for(let s of r)s.points(.5,a=>{n.push(a.multiply3(i))});for(let s of n)if(bc(s.x,s.y,e))return!0;return!1}var B1={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:"]},zC=class{constructor(){this.busTopic="panel/design-check";this.logTopic="panel/design-check-show-log"}check(){this.drc=new YT;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:[Go(B1.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:[Go(B1.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=[Go("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}})];J.windowBridge.publish("bottomBarLog",{type:"info",tabType:"panelDrcLog",openTab:!0,msg:l},ut())}else{let l=[Go("Generate {0} fabrication file successfully! Error: {1}, Warning: {2}, Info: {3}.",{params:{0:r,1:n,2:a,3:o}})];J.windowBridge.publish("bottomBarLog",{type:"info",tabType:"panelDrcLog",openTab:!0,msg:l},ut())}_e("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:[Go(B1[i][0]),{text:Go(B1[i][1]),call:{topic:"panel/active-layer",args:[i,J.tabId]}}]}}getBottomWarn(t,i,r,n="panelDrcLog"){return{type:t,tabType:n,openTab:!0,msg:[Go(B1[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 F.iterator(i=>{i.layer&&t.add(+i.layer)}),t}checkIfEleNotInAnyBoard(t){let i=this.drc.hasObjOutBoard();if(i.length){let r=[],n=new st;i.forEach((s,a)=>{let o=n.searchCombination(s.id)||"",{id:l}=F.getById(s.id).json;r.push({text:Go(s.cmd)+l.replace(/^e/,"")+(a==i.length-1?"":","),attr:{panelid:J.tabId,id:s.id,comId:o}})}),t.push(this.getBottomWarn("warn","outBoard",r))}}checkGapOfBoards(t){let i=ya(2),r=this.drc.boardGapCheck(3,i);if(r.length){let n=[],s=new st;r.forEach((a,o)=>{let l=s.searchCombination(a[0].id)||"",c=s.searchCombination(a[1].id)||"",{id:u}=F.getById(a[0].id).json,{id:h}=F.getById(a[1].id).json;n.push({text:Go(a[0].cmd)+u.replace(/^e/,""),attr:{panelid:J.tabId,id:a[0].id,comId:l}},Go("And"),{text:Go(a[1].cmd)+h.replace(/^e/,""),attr:{panelid:J.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 st;i.forEach((s,a)=>{let o=F.getById(s).json,l=o.id,c=n.searchCombination(s)||"",u=Gi[o.cmdKey];r.push({text:Go(u)+l.replace(/^e/,""),attr:{panelid:J.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 st;i.forEach(({displayId:s,gId:a},o)=>{let l=n.searchCombination(a)||"",c=Gi[F.getById(a).cmdKey];r.push({text:Go(c)+s.replace(/^e/,""),attr:{panelid:J.tabId,id:a,comId:l}},o===i.length-1?"":",")}),t.push(this.getBottomWarn("error","outMaterial",r))}}showMsg(t){_e("logClear","panelDrcLog"),_e("bottomBarLogGroupStart","panelDrcLog");for(let i of t)_e("bottomBarLog",i)}},rf=new zC;var Md=class Md{static ready(){let t=J.cmdToken.includes("xy")?"xy":J.cmdToken.includes("x")?"x":"y";this.addingRuler=!0,this.currentDirection=t,Vl.load(),Lt.enabled=!1,Xt(),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=F.getDimension(a);this.currentDimension=new wn(d)}let l=this.currentDimension.toJSON();if(s){this.currentDimension.unmount(),this.currentDimension=null;return}let c=this.currentDimension.getDistance(),u=!ei(c,+r);r=ya(+r),l.category=n,l.name=i;let h=rA(l);at.startBatch(),o&&at.jsonSnap.addOne(l,{}),n==="Constraint"&&u&&(is.changeDimensionSize(this.currentDimension.getId(),r),Vl.load()),at.saveBatch(),Ce.select([h]),_e("panel_updateAttrPanel"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),this.currentDimension=null,F.compilerManager.resumeDataMerge()}static getCurrentDirection(){return Md.currentDirection}static lockCurrentDirection(){this.lockedDirection=!this.lockedDirection}static unLockCurrentDirection(){this.lockedDirection=!1}static mousedownLeft(t){let{canvasX:i,canvasY:r}=t;if(F.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 Do,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:F.getById(s).json,end:F.getById(a).json,...this.currentDimension.getPrimitiveType()},type:this.currentDimension.getCategory(),size:this.currentDimension.getDistance(),overed:c,created:!0};_e("panel/open-smart-dimension-dialog",[u]);return}let n=Vl.findNearestLabelPoint(new V(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=Vl.findNearbyPrimitiveLabelPoint(t,i);this.hoveLabelDots=this.lockTargetLabelDots.get()||Vl.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=is.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=_t();this.currentDimension=new wn({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([]),F.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||(Lt.enabled=!0),this.next()}};Md.addingRuler=!1,Md.lockedDirection=!1,Md.clickedLabelDots=[],Md.hoveLabelDots=[],Md.lockTargetLabelDots=(()=>{let t=[];return{lockToggle(i){t.length?t=[]:t=i},get(){return t.length?t:void 0}}})();var Cg=Md;var Iee={["-"+rf.busTopic]:rf.check.bind(rf),"-panel/get-combine-data":c2,"-panel/edit-combination"(e){Kt.setEditing(e)},"-panel/get-edit-combination-id"(){return Kt.getCurrentEditingComId()},"-panel/get-editingPath"(){return jt.isEditingPath()},"-panel/select-combination"(e){Kt.selectCombinations(e)},"-panel/modify-combination"(e){new st().modifyCombination(e)},"-panel/get-allCombinationAndElesFromTop"(e){let{elements:t,combinations:i}=new st().getAllElesfromTop(e);return{elements:[...t],combinations:[...i]}},"-/panel/getObjectTreeData":NB,"-getPanelInfo":async()=>{let e=J.doctype,[t,i]=(window.frameElement.id||"").replace("frame_","").split("@");return{docType:e,path:i,uuid:t}},changeSelectionMode:_1,applyFilter:Bo,"panel/BoolOperation":L5,"panel/select-overlap":cM,"panel/show-element-control":qI.showShapeControl,"main2iframe/trigger-event":R5,[rf.logTopic]:rf.showExportMsg.bind(rf),"/panel/place_lib":tf.setPlacingStatus.bind(tf),"panel/place-dimension":e=>{Cg.placeDimension(e)},"panel/delete-combination"(e){Kt.deleteCombinations(e)},"-panel/update-reference-point"(e){hi.setReferencePoint(e)},"panel/set-project-permission":Dd.set};var HT=class{static async createJsonCache(t){let r=await new bg().decodeDataStr(t);r.success&&r.jsonCache&&(this.jsonCache=r.jsonCache)}static panelChangeUpdateJsonCache(t){let i=F.exchangeJsonCache(this.jsonCache);t.forEach(r=>{let{shapeIds:n,layerId:s,isVisible:a}=r;n.forEach(o=>{var c;let l=(c=F.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=F.exchangeJsonCache(this.jsonCache),i=F.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(),Pn.toSVG(this.jsonCache,{viewBox:a,before:()=>{}})}static updateStrokeWidth(t){if(!this.jsonCache)return;let i=F.exchangeJsonCache(this.jsonCache);F.iterator(r=>{Reflect.has(r,"strokeWidth")&&r.strokeWidth!==t&&(r.strokeWidth=t)}),i()}static updateScale(t){if(!this.jsonCache||!(t>0))return;let i=F.exchangeJsonCache(this.jsonCache),r=he.scale(t);F.iterator(n=>{let{cmdKey:s}=n;zE[s](n,r)}),i()}static async import(t){if(!this.jsonCache)return;let i=F.exchangeJsonCache(this.jsonCache);if(F.iterator(n=>{if(!n.visible){let{gId:s,cmdKey:a}=n,o=F.gJsonCache[a];o&&o[s]&&delete o[s]}}),F.getBBox().area()===0){i(),rs("No Data!","warn");return}i();let r=await TT(this.jsonCache);J.frameHelper.getToolProcessor().switchToPasteTool("paste_dxf",r,t?"center":void 0)}static dispose(){this.jsonCache=null}};HT.jsonCache=null;function _e(e,t=""){J.windowBridge.publish(e,t,ut())}function rs(e,t="warn"){_e("ui/toastMsg",{type:t,msg:e,timer:3})}var pi=class{constructor(){this.tasks=[];this.noSolution=!1;this.isRunningTask=!1;this.ignorePrimitiveIds=new Set;this.labelPointTransformMap=new Map;this.dimensionMgr=new Do}static setSkipCheck(t){return this.skipCheck=t,()=>{this.skipCheck=!t}}static createContext(t=!1){return this.self=new this,t&&at.startBatch(),()=>{this.runTask(),t&&at.saveBatch(),uT(F.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?lu: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=Vl.loadPointsByData(t);return i=new km(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(wr.isLockedById(g)){let x=Gi[F.getById(g).cmdKey];o=!0;let y=F.getById(g).json;l.add(x+(y==null?void 0:y.id.slice(1)))}}if(h!==0){for(let g of new Set([...m]))if(wr.isLockedById(g)){let x=Gi[F.getById(g).cmdKey];o=!0;let y=F.getById(g).json;l.add(x+(y==null?void 0:y.id.slice(1)))}}}return o&&(rs({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),at.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)}})}};pi.skipCheck=!1;var XC=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}=F.getEllipse(t),p=ct.createMatrixFrom6(h||d),f=[];for(let m of u){let g=new V(m[0],m[1]).multiply3(p);f.push(g)}return f}sync(t,i,r){let s=ct.createMatrixFrom6(t.matrix).multiply3(i),a=$e.getMatrix6FromMatrix(s);r.updateMatrix&&(t.matrix=a),t.tempMatrix=a,this.updateEllipseShape(de(t.gId),t)}syncEllipse(t,i,r){let n=pi.checkOne("ellipse",t,i);n!==!1&&pi.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(!os(t))return;let{matrix:s,rotation:a}=i,o=a||0,l=ct.createMatrixFrom6(s),c=r||new V(this.center.x,this.center.y).multiply3(l);return he.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]=hi.getReference(),h=new V(1-u,1-c),d=$e.createMatrixFrom6(t.matrix).getInverseMatrix(),p=he.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}=Ei(t,"ellipse");i=os(i)?i:n,r=os(r)?r:s;let a=i-n,o=r-s;if(!a&&!o)return;let l=he.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 V(h,d)}let s=WC(t),a=s.width,o=s.height,l=1,c=1;if(mt(i)||(l=i/a),mt(r)||(c=r/o),l===0||c===0||l===1&&c===1)return;let u=he.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);re(t,{rx:r,ry:n}),ct.updateTransform(s,t)}getEllipseFromMatrix(t){let i=ct.createMatrixFrom6(t),r=new V(this.center.x,this.center.y).multiply3(i),n=new V(this.unitRx.x,this.unitRx.y).multiply3(i),s=new V(this.unitRy.x,this.unitRy.y).multiply3(i),a=n.distance1(r),o=s.distance1(r),c=he.scale(1/a,1/o).multiply3(i),u=$e.getMatrix6FromMatrix(c);return{cx:r.x,cy:r.y,rx:a,ry:o,matrixArr:u}}},gi=new XC;function Sh(e){let t=e.cmdKey=="arc"?sr.get8Dots2(e):mr.get(de(e.gId),"single"),i=Bl(t[0],t[1],t[2],t[3]),r=Bl(t[0],t[1],t[6],t[7]);return{obbWidth:i,obbHeight:r}}function N5(e){let t=new Pi(e),i=Ei(e,"arc"),r=t.vectorCenter(),[n,s]=F.translateByOrigin(r.x,r.y),[a,o]=F.translateByOrigin(e.x1,e.y1),[l,c]=F.translateByOrigin(e.x2,e.y2),u=hi.transferXYByReference(i),[h,d]=F.translateByOrigin(u[0],u[1]),{obbWidth:p,obbHeight:f}=Sh(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":hi.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":Cu(t.startAngle()),"attr-end-angle":Cu(t.endAngle()),"attr-arc-type":e.type===1?"Center Arc":"Two Points Arc","attr-rotation":Math.abs(e.rotation||0)}}function M5(e){let t=Ei(e),{obbWidth:i,obbHeight:r}=Sh(e),n=hi.transferXYByReference(t),[s,a]=F.translateByOrigin(n[0],n[1]),{rx:o,ry:l}=gi.getEllipseFromMatrix(e.matrix);return{"reference-point":hi.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":ei(s,0)?0:s,"attr-y":ei(a,0)?0:a,"attr-rotation":Math.abs(e.rotation||0)}}function B5(e){let t=new wn(e);return{"attr-dimension-object":[{start:F.getById(e.start.id).json,end:F.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 k5(e){let t=Tr.getRectBBox(e.matrix),{obbWidth:i,obbHeight:r}=Sh(e),n=hi.transferXYByReference(t),[s,a]=F.translateByOrigin(n[0],n[1]);return{"reference-point":hi.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 F5(e){let t=Ei(e,"text"),i=hi.transferXYByReference(t),[r,n]=F.translateByOrigin(i[0],i[1]),{obbWidth:s,obbHeight:a}=Sh(e);return{"reference-point":hi.getReferencePoint(),"attr-textarea":e.name||"","attr-x":ei(r,0)?0:r,"attr-y":ei(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 G5(e){let[t,i]=F.translateByOrigin(e.x1,e.y1),[r,n]=F.translateByOrigin(e.x2,e.y2),[s,a]=F.translateByOrigin(e.angleX,e.angleY);return{"attr-angle":new hn(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 U5(e){let[t,i]=F.translateByOrigin(e.x1,e.y1),[r,n]=F.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 dn(e).calcLengthPixel()}}function Y5(e,t,i){let[r,n]=F.translateByOrigin(e.x,e.y),s=mt(e.strokeStyle)?t.auxiliaryLine.dash:e.strokeStyle,a={"attr-color":e.strokeColor||`${i.auxiliaryLine}`,"attr-stroke-style":Wh(s).value};switch(el(e.rotation)){case"horizontal":a["attr-y"]=+n.toFixed(2);break;case"vertical":a["attr-x"]=+r.toFixed(2);break}return a}var Nd=class{getRectBBox(t){return $e.getRectBBox(t)}syncSelfObbSize(t,i,r){let n=de(t.gId),s=1,a=1,o=Math.round(t.rotation*100)/100*(Math.PI/180),{obbWidth:l,obbHeight:c}=Sh(t),u=ch(n),h=hi.transferXYByReference(u),d=new V(h[0],h[1]);if(mt(i)||(s=i/l),mt(r)||(a=r/c),s===0||a===0||s===1&&a===1)return;let p=$e.createMatrixFrom6(t.tempMatrix||t.matrix),m=p.getInverseMatrix().scale(s,a).multiply3(p);switch(t.cmdKey){case"rect":Ai.syncRect(t,m,{updateMatrix:!0});break;case"ellipse":gi.syncEllipse(t,m,{updateMatrix:!0});break;case"arc":sr.syncArc(t,m,{updateD:!0});break;case"obj":Tr.syncImage(t,m,{updateMatrix:!0});break;case"text":lr.syncText(t,m,{updateMatrix:!0});break;case"group":Gn.syncGroup(t,m,{updateD:!0});break}}};var k1=class extends Nd{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=ct.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 V(d[0],d[1]).multiply3(s);h.push(p)}return h}sync(i,r,n){let a=ct.createMatrixFrom6(i.matrix).multiply3(r),o=$e.getMatrix6FromMatrix(a);n.updateMatrix&&(i.matrix=o),i.tempMatrix=o,this.updateRectShape(de(i.gId),i)}syncRect(i,r,n){let s=pi.checkOne("rect",i,r);s!==!1&&pi.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);ni.renderer.attrs(r.gId,{width:n,height:s}),ct.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 he.rotateD(a).setOrigin1(n)}getRectFromMatrix(i){let r=ct.createMatrixFrom6(i),n=new V(this.start.x,this.start.y).multiply3(r),s=new V(this.unitWidth.x,this.unitWidth.y).multiply3(r),a=new V(this.unitHeight.x,this.unitHeight.y).multiply3(r),o=s.distance1(n),l=a.distance1(n),u=he.scale(o?1/o:1,l?1/l:1).multiply3(r),h=$e.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=mt(r)||Number.isNaN(r)?s:r,n=mt(n)||Number.isNaN(n)?a:n;let c=r-s,u=n-a;if(!c&&!u)return;let h=he.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(mt(n)||(u=n/l),mt(s)||(h=s/c),u===0||h===0||u===1&&h===1)return;let d=he.scale(u,h).setOrigin1(r);this.syncRect(i,d,{updateMatrix:!0})}},Ai=new k1;var mr={createPath8Dots:function(e){let t=Mr([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 mr.selectbox.get(e);switch(Qt(e)){case"arc":return mr.path_arc.get(r);default:break}return mr[i]?mr[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=re(e,"id")=="selectBox1"?"selectbox":h,!mr[h])throw new Error(h);mr[h].set(e,t,i,r,n,s,a,o,l,c,u)},selectbox:{get:function(e){let t=+re(e,"x"),i=+re(e,"y"),r=+re(e,"width"),n=+re(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=Eo(e)?e:F.getText(e.id),r=i.cacheWidth,n=i.cacheHeight,s=new Array,a=V.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=ct.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 ct.getMaxOuterBoundingBox(l,i)},set:function(e,t,i,r,n,s,a,o,l=!1,c,u={}){let h=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=F.getText(e.id);lr.syncText(d,h,{updateMatrix:!1})}},g:{get:function(e){if(Qt(e)==="text")return mr.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(Qt(e)==="text")return mr.text.set.apply(e,arguments);jl.g(e,r,n)}},svg:{get:function(e){return mr.rect.get(e)},set:function(e,t,i,r,n){return mr.rect.set(e,t,i,r,n)}},image:{get:function(e,t="multi"){let i=Eo(e)?e:F.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=ct.createMatrixFrom6(i.tempMatrix||i.matrix),l=[];for(let[c,u]of s){let h=new V(c,u).multiply3(o);l.push(h.x,h.y)}return l}return ct.getMaxOuterBoundingBox(s.slice(0,4),i)},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=F.gJsonCache.obj[e.id];if(!h)return;let d=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u);Tr.syncImage(h,d,{updateMatrix:!1})}},rect:{get:function(e,t="multi"){let i=Eo(e)?e:F.getRect(e.id),{matrix:r,tempMatrix:n}=i,s=ct.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 V(d[0],d[1]).multiply3(s);h.push(p.x,p.y)}return h}return ct.getMaxOuterBoundingBox(u.slice(0,4),i)},set:function(e,t,i,r,n,s,a,o,l=!1,c=!1,u={}){let h=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=F.getRect(e.id);Ai.syncRect(d,h,{updateMatrix:!1})}},circle:{get:function(e){let t=+re(e,"cx"),i=+re(e,"cy"),r=+re(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=mr.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,re(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=Eo(e)?e:F.getEllipse(e.id),{tempMatrix:d,matrix:p,rotation:f}=h,m=$e.createMatrixFrom6(d||p),g=[];for(let x of u){let y=new V(x[0],x[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=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=F.getEllipse(e.id);gi.syncEllipse(d,h,{updateMatrix:!1})}},line:{get:function(e){return[+re(e,"x1"),+re(e,"y1"),+re(e,"x2"),+re(e,"y2")]},set:function(e,t,i,r,n){t||(t=mr.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),re(e,s)}},polygon:{get:function(e){let t=yc(re(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?(!ei(s[o]*2,s[0]+s[o-2])||!ei(s[o+1]*2,s[1]+s[o-1]))&&s.splice(o,0,0,0):i%2&&(!ei(s[o]*2,s[o-2]+s[o+2])||!ei(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,x;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]],x=a[c[i]+1],!ei((d-f)*(x-m),(g-f)*(p-m))){h=!1;break}if(h)return;let y={points:nE(a.join(" "))};re(e,y)}},path:{get:function(e){let t=_p(e);if(t){let w=e.tagName+"_"+t;if(mr[w]&&mr[w].get)return mr[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,x,y,E,T;for(u=0;u<r;u++)switch(d=i.getItem(u),p=d.pathSegType,u===0&&p!=yr&&p!=Dr&&p!=ti&&a.push(n,s),h=a.length/2-1,p){case ti:n=o,s=l;break;case yr:if(n=d.x,s=d.y,o=n,l=s,u+1==r||(g=i.getItem(u+1),m=g.pathSegType,m==yr||m==Dr||m==ti))break;a.push(n,s),m==on&&a.push((n+g.x)/2,(s+g.y)/2);break;case on:if(a.push(n=d.x,s=d.y),u+1==r)break;g=i.getItem(u+1),m=g.pathSegType,m==ti&&(g=i.getItem(0)),(m==on||m==ti)&&a.push((n+g.x)/2,(s+g.y)/2);break;case po:a.push(n=d.x,s);break;case fo:a.push(n,s=d.y);break;case lo: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 uo: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 ho:case Oa:if(f=i.getItem(u-1),x=od(f.x,f.y,d.x,d.y,d.largeArcFlag?1:0,d.sweepFlag?1:0,d.r1,d.r2,d.angle),y=x.cx,T=x.cy,E=ad([f.x,f.y],[y,T],x.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==ti&&(g=i.getItem(0)),(m==on||m==ti)&&a.push((n+g.x)/2,(s+g.y)/2);break;case Dr:if(n+=d.x,s+=d.y,o=n,l=s,u+1==r||(m=i.getItem(u+1).pathSegType,m==yr||m==Dr||m==ti))break;a.push(n,s);break;case Tl:a.push(n+=d.x,s+=d.y);break;case El:a.push(n+=d.x,s);break;case wl:a.push(n,s+=d.y);break;case gl: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 yl:c.push({from:h+1,to:h+2}),a.push(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.x1,s+d.y1,n+=d.x,s+=d.y);break;case xl:case ml:a.push(n+=d.x,s+=d.y);break;default:break}if(re(e,"drag")!="self"){let w=mr.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(Qt(e)==="arc"&&re(e,"third-point")){let M=fy(t.join(" "));re(e,{d:s,"third-point":M[2].x+","+M[2].y})}else re(e,{d:s});return}let a=_p(e);if(a){let M=e.tagName+"_"+a;if(mr[M]&&mr[M].set){mr[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,x,y,E,T,w,b,C,A,R,O;if(s&&re(e,{d:s}),t.c_helper_lines||(i=i>>1),!t.c_helper_lines&&p%2){m=u.getItem(i+1),m.pathSegType==Oa?(g=u.getItem(i),y=t[p*2],E=t[p*2+1],T=Tm({x:g.x,y:g.y},{x:m.x,y:m.y},{x:y+r,y:E+n}),T<4&&(T=4),T=Math.sqrt(T),w=m.sweepFlag,b=m.r1,C=wo(g.x,g.y,m.x,m.y),A=(m.x-g.x)*(E-g.y)-(y-g.x)*(m.y-g.y),R=(m.x-g.x)*(E+n-g.y)-(y+r-g.x)*(m.y-g.y),A*R<0&&(w^=1),b=C/(8*T)+T/2,O=b>T?0:1,b=un(b),m.r1=b,m.r2=b,m.largeArcFlag=O,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 ti:break;case yr:case Dr:if(f+1==h||(x=u.getItem(f+1).pathSegType,x==yr||x==Dr||x==ti))break;if(d++,d==i){m.x=ft(m.x+r,3),m.y=ft(m.y+n,3);break e}break;case on:case Tl:if(d++,d==i){m.x=ft(m.x+r,3),m.y=ft(m.y+n,3);break e}break;case po:case El:if(d++,d==i){m.x+=r;break e}break;case fo:case wl:if(d++,d==i){m.y+=n;break e}break;case lo:case gl: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 yl: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 uo:case bl: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 ho:case xl:case ml:if(d++,d==i){m.x+=r,m.y+=n;break e}break;case Oa:if(d++,d==i){m.x+=r,m.y+=n;break e}break;default:break}}},path_group:{get:function(e,t){if(jt.is8DotsMode(e.id)){let{json:E}=F.getById(e.id);return Gn.getGroup8Dots({...E,d:re(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,x,y=new Map;for(let E=0;E<r;E++){u=i.getItem(E),h=u.pathSegType;let T=E-1>-1&&i.getItem(E-1);E===0&&h!=yr&&h!=Dr&&h!=ti&&a.push(n,s);let w=a.length/2-1;switch(h){case ti:n=o,s=l;break;case yr:if(n=u.x,s=u.y,o=n,l=s,E+1==r||(p=i.getItem(E+1),d=p.pathSegType,d==yr||d==Dr||d==ti))break;a.push(n,s),d==on;break;case on:if(a.push(n=u.x,s=u.y),E+1==r)break;p=i.getItem(E+1),d=p.pathSegType,d==ti&&(p=i.getItem(0)),d==on||d==ti;break;case po:a.push(n=u.x,s);break;case fo:a.push(n,s=u.y);break;case lo:c.push({from:w,to:w+1,belong:w},{from:w+2,to:w+3,belong:w+3});let b=T.x===u.x1&&T.y===u.y1,C=u.x2===u.x&&u.y2===u.y;y.set(w+1,{belong:w,display:!b}),y.set(w+2,{belong:w+3,display:!C}),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 uo: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 ho:case Oa:if(T=i.getItem(E-1),f=od(T.x,T.y,u.x,u.y,u.largeArcFlag?1:0,u.sweepFlag?1:0,u.r1,u.r2,u.angle),m=f.cx,x=f.cy,g=ad([T.x,T.y],[m,x],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==ti&&(p=i.getItem(0)),d==on||d==ti;break;case Dr:if(n+=u.x,s+=u.y,o=n,l=s,E+1==r||(d=i.getItem(E+1).pathSegType,d==yr||d==Dr||d==ti))break;a.push(n,s);break;case Tl:a.push(n+=u.x,s+=u.y);break;case El:a.push(n+=u.x,s);break;case wl:a.push(n,s+=u.y);break;case gl: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 yl:c.push({from:w+1,to:w+2}),a.push(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.x1,s+u.y1,n+=u.x,s+=u.y);break;case xl:case ml: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(jt.isAnchorMode(e.id)&&!l){if(/[^ahvqtsc]/i.test(s)){let x=!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]){x=!1;break}if(x)return}let d=e.pathSegList,p=d.numberOfItems,f=-1,m,g;s&&re(e,{d:s});e:for(let x=0;x<p;x++){let y=x-1>-1&&d.getItem(x-1),E=y.pathSegTypeAsLetter,T=d.getItem(x),w=x+1<p&&d.getItem(x+1),b=w.pathSegTypeAsLetter;switch(T.pathSegType){case ti:break;case yr:case Dr:if(m=T,x+1==p||(g=w.pathSegType,g==yr||g==Dr||g==ti))break;if(f++,f==i){let C=ft(T.x+r,3),A=ft(T.y+n,3);b==="C"&&w.x1===T.x&&w.y1===T.y&&(w.x1=C,w.y1=A),T.x=C,T.y=A;break e}break;case on:case Tl:if(f++,f==i){T.x=ft(T.x+r,3),T.y=ft(T.y+n,3);break e}break;case po:case El:if(f++,f==i){T.x+=r;break e}break;case fo:case wl:if(f++,f==i){T.y+=n;break e}break;case lo:case gl:if(f++,f==i){Ta.setPrevHandlePosition(T,r,n,y,u),T.x1+=r,T.y1+=n;break e}if(f++,f==i){Ta.setNextHandlePosition(T,r,n,w,u),T.x2+=r,T.y2+=n;break e}if(f++,f==i){T.x=ft(T.x+r,3),T.y=ft(T.y+n,3),T.x2=ft(T.x2+r),T.y2=ft(T.y2+n),b==="C"&&(w.x1+=r,w.x1=ft(w.x1),w.y1+=n,w.y1=ft(w.y1)),x!==p-1&&d.getItem(x+1).pathSegType===ti&&(m.x=T.x,m.y=T.y);break e}break;case co:case yl:if(f++,f==i){T.x2+=r,T.y2+=n;break e}if(f++,f==i){T.x+=r,T.y+=n;break e}break;case uo:case bl:if(f++,f==i){T.x1+=r,T.y1+=n;break e}if(f++,f==i){T.x+=r,T.y+=n;break e}break;case ho:case xl:case ml:if(f++,f==i){T.x+=r,T.y+=n;break e}break;case Oa:if(f++,f==i){T.x+=r,T.y+=n;break e}break;default:break}}return}let h=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u);Gn.syncGroup(F.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=od(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=ad([n[0],n[1]],[o,l],a.delta_theta/2),u=py(re(e,"d")),h=oE(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&&re(e,{d:s});return}let a,o,l,c=t?t.slice(0):mr.path_arc2.get(e);if(i===3&&(c[0]+=r,c[1]+=n,c[2]+=r,c[3]+=n),i===0&&ei(c[0]+r,c[2])&&ei(c[1]+n,c[3])||i===1&&ei(c[2]+r,c[0])&&ei(c[3]+n,c[1])||i===2&&ei((c[2]-c[0])*(c[5]+n-c[1]),(c[3]-c[1])*(c[4]+r-c[0])))return;if(i===2){if(a=Tm({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&&re(e,"d",s);let u=e.pathSegList.getItem(1),h=u.r1,d=+u.largeArcFlag,p=+u.sweepFlag,f=wo(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=wo(c[0],c[1],c[2],c[3])),h=f/(8*a)+a/2,d=h>a?0:1,c[0]=un(c[0]),c[1]=un(c[1]),h=un(h),c[2]=un(c[2]),c[3]=un(c[3]),re(e,"d","M"+c[0]+","+c[1]+" A"+h+","+h+" 0 "+d+" "+p+" "+c[2]+","+c[3])}},path_arc:{get(e){let{json:t}=F.getById(e),i=t.temp||t,r=sr.get8Dots2(i),n=new Pi(i),s=n.vectorCenter();if(jt.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=ct.getEightControlMatrix3(t,i,r,n,c,l,s,u),d=F.getById(e.id).json;sr.syncArc(d,h,{updateD:!1})}}};function H5(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 Aee(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,T]=H5(f,m,i);m=T,f=E}let g=0,x=0;switch(i){case 0:g=l,x=c;break;case 1:g=a,x=c;break;case 2:g=a,x=o;break;case 3:g=l,x=o;break;case 4:g=(a+l)/2,x=c;break;case 5:g=a,x=(o+c)/2;break;case 6:g=(a+l)/2,x=o;break;case 7:g=l,x=(o+c)/2;break}let y=he.scale(f,m);return y=s.ctrl?y.setOrigin(u,h):y.setOrigin(g,x),y}var ct=class e{static createMatrixFrom6([t,i,r,n,s,a]){return new he([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 he([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 $e.getMatrix6FromMatrix(new he)}static getTransformStr(t){return`matrix(${t.join(",")})`}static updateTransform(t,i){let r=this.getTransformStr(t);re(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),Aee(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,x=l.ctrl?new V(m,g):new V(p,f),y=Math.atan2(t[1]-t[3],t[0]-t[2]),E=new V(u,h),T=new V(r,n),w=he.translate(-x.x,-x.y).rotate(-y),b=E.multiply3(w),C=E.add(T).multiply3(w),A=1,R=1;if(Ye.neq(b.x,0)&&Ye.neq(C.x,0)&&(A=C.x/b.x),Ye.neq(b.y,0)&&Ye.neq(C.y,0)&&(R=C.y/b.y),s){let M=H5(A,R,i);A=M[0],R=M[1]}return w.scale(A,R).rotate(y).translate(x.x,x.y)}static rotateDots(t,i,r,n){let s=fN(i),a=he.rotate(s).setOrigin(r,n),o=[];for(let l of t){let c=new V(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 x=new V(g[0],g[1]).multiply3(n);r.push(x)}let s=r[0].distance1(r[2]),a=r[1].distance1(r[3]),o=r[1],l=i.rotation;Ye.greatereq(s,a)&&(o=r[0]);let c=he.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=he.rotateD(l).setOrigin1(o);for(let g of p){let x=new V(g[0],g[1]).multiply3(m);f.push(x.x,x.y)}return f}};function JC(e,t,i={updateMatrix:!0}){let r=ct.createMatrixFrom6(e.matrix);t&&(r=r.multiply3(t));let n=$e.getMatrix6FromMatrix(r);i.updateMatrix&&(e.matrix=n),e.tempMatrix=n,ct.updateTransform(n,de(e.gId)),Cee(e)}var qC=class extends Nd{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=pi.checkOne("obj",i,r);s!==!1&&pi.addCallBack(()=>{var a;s(),JC(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;mt(s)&&(s=r.rotation);let o=ct.createMatrixFrom6(a),l=n||new V(this.center.x,this.center.y).multiply3(o),c=Math.round((i-s)*100)/100;if(c)return he.rotateD(c).setOrigin1(l)}getImageShapeForAttr(i){let r=ct.createMatrixFrom6(i),n=new V(this.start.x,this.start.y).multiply3(r),s=n.x,a=n.y,o=new V(this.unitWidth.x,this.unitWidth.y).multiply3(r),l=new V(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=F.getObj(i.id),{x:a,y:o,width:l,height:c}=this.getRectBBox(s.matrix);r=os(r)?r:a,n=os(n)?n:o;let u=r-a,h=n-o;if(!u&&!h)return;let d=he.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(mt(n)||(u=n/l),mt(s)||(h=s/c),u===0||h===0||u===1&&h===1)return;let d=he.scale(u,h).setOrigin1(r);this.syncImage(i,d,{updateMatrix:!0})}},Tr=new qC,Cee=$o(e=>{J.messageBus.publish("panel/adsorption/updateShapeCache",[e.gId,"obj",e])},100);var jl=class e{static g(t,i,r){if(isFinite(i)||(i=0),isFinite(r)||(r=0),!t||i===0&&r===0)return;if(Qt(t)==="text"){let o=he.translate(i,r);lr.syncText(F.getById(t.id).json,o,{updateMatrix:!0});return}let s=t.children,a=s.length;for(let o=0;o<a;o++)Qe(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&&re(t,{x:+(re(t,"x")||0)+i}),r!==0&&re(t,{y:+(re(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=he.translate(i,r),s=new k1,a=F.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=he.translate(i,r);JC(F.gJsonCache.obj[t.id],n)}static circle1(t,i,r){isFinite(i)||(i=0),isFinite(r)||(r=0),!(!t||i===0&&r===0)&&re(t,{cx:+re(t,"cx")+i,cy:+re(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=he.translate(i,r),s=F.getEllipse(t.id);gi.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)&&re(t,{x1:+re(t,"x1")+i,x2:+re(t,"x2")+i,y1:+re(t,"y1")+r,y2:+re(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=yc(re(t,"points")).split(/[\s\,]+/g);for(let s=0;s<n.length-1;s+=2)n[s]=ft(+n[s]+i,4),n[s+1]=ft(+n[s+1]+r,4);re(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]=ft(h[d]+p,4)}if(re(t,"c_partid")==="arc"){let h=_T(t);h=h.map((d,p)=>p%2===0?+d+a:+d+o),re(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=re(t,"d"),s=F.getGroup(t.id);s.d=n}};function Cs(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=Ha(e);if(t){let i=document.importNode(t.documentElement,!0);return i.removeChild(i.childNodes[0])}}console.warn(`parse fail. invalid svg.
`+e)}function NC(e,t){let i=+e.x+e.width/2+","+(+e.y+e.height/2);return J.gCanvas.insertBefore(Tt("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}),J.gCanvas.firstChild)}function ol(e){let t=Xe.canvas.originX,i=Xe.canvas.originY,r=kl.getSanpSize("X"),n=kl.getSanpSize("Y"),s=Math.round((e.x-t)/r)*r+t,a=Math.round((e.y-i)/n)*n+i;return{x:un(s),y:un(a)}}var ko;function Th(e,t,i){if(e.length>=$1){if(!ko){let r=Mr(e);ko=NC(r),Wa.x=0,Wa.y=0;for(let n of e)cu(n,"hidden")}jl.svg(ko,t,i)}else for(let r=0;r<e.length;r++)Yn.move(F.getById(e[r].id).json,t,i);return Wa.x+=t,Wa.y+=i,!0}function Dee(){dt(ko),ko=null}Wa.x=0;Wa.y=0;function Wa(e,t){if(!(!e||!e.length||!ko)){if(Dee(),t!="cancel"){e.forEach(function(n){To(n,"hidden")});let i=Wa.x,r=Wa.y;for(let n=0;n<e.length;n++){let s=F.getById(e[n].id||e[n].gId).json;Yn.move(s,i,r)}}il()}}function _C(){let e=new Xa,t=F.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 Eg(Xe.canvas.originX,Xe.canvas.originY);{let n=Ec(r);return pu(n)}}function LC(e=1){let t=Ce.get()||[],[i,r]=t.reduce((s,a)=>(Qt(a)==="auxiliaryLine"?s[0].push(a):s[1].push(a),s),[[],[]]);if(i.length===t.length)return V5(i);let n=Mr(r,!0);return pu(n,e)}function pu(e,t=1,i=!1,r=20){if(!e||!e.x&&!e.y&&!e.width&&!e.height)return;let n=J.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>J.zoomRatio.max&&(u=J.zoomRatio.max,h=u/100);let d=h!=n,p=mi.getViewBox();if(p[0]=s-p[2]/2,p[1]=a-p[3]/2,mi.setViewBox(p),d){let f={clientX:(s-p[0])*n,clientY:(a-p[1])*n};return i&&(u=u>180?180:u),Cd(u,f,!0)}return NT(p)}function Eg(e,t){let i=mi.getViewBox();return i[0]+=e-(i[0]+i[2]/2),i[1]+=t-(i[1]+i[3]/2),mi.setViewBox(i),NT(i)}function cd(e){let t=mi.getViewBox(),i=J.gZoom;return{x:t[0]+e.x/i,y:t[1]+e.y/i}}function Dg(e){let t=mi.getViewBox(),i=J.gZoom,r=(e.x-t[0])*i,n=(e.y-t[1])*i;return{clientX:r,clientY:n}}function i5(e,t=Xe.adsorbGrid.gridSize,i){i=i||{x:Xe.canvas.originX,y:Xe.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=ft(r.x,2),r.y=ft(r.y,2),r}function Pee(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 _ee(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=Pee({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 Z4(e){let t=[],i=new Map;e.forEach(n=>{t.push(...Zr('[c_partid="auxiliaryLine"]',n)),t.forEach(function(s){s.style.display!=="none"&&(i.set(s,s.style.display),s.style.display="none")})});let r=Mr(e);return i.size&&i.forEach((n,s)=>{s.style.display=n,i.delete(s)}),r}function j5(e){let t=Zr('[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=cs(e);return i.size&&i.forEach((n,s)=>{s.style.display=n,i.delete(s)}),r}function z5(e){let t,i;try{i=e.cloneNode(!0),J.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 cs(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=z5(e)}try{!t.x&&!t.y&&!t.width&&!t.height&&de("root").compareDocumentPosition(e)!=20&&(t=z5(e))}catch(r){console.log(r)}return t}function Mr(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=Ic(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 o5(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=>re(a,"c_partid")!=="auxiliaryLine"),n=e.filter(a=>re(a,"c_partid")==="auxiliaryLine"),s;for(let a=0;a<r.length;a++){if(!r[a])continue;let o=Ic(r[a],t);re(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}=F.getAuxiliaryLine(n[a].id),l=Ic(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 ro(e,t,i){if(!e||!e[0])return{x:0,y:0};if(ko){let s=ko.getBBox();return{x:s.x+s.width/2,y:s.y+s.height/2}}let r=Mr(e,t),n={x:un(r.x+r.width/2),y:un(r.y+r.height/2)};return(!i||!i.ignoreSnap)&&(n=ol(n)),n}function WC(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 M1(e){let{matrix:t,tempMatrix:i}=e,r=ct.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 V(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 YN(e){let t=Yi(e.d),i=new ot;for(let n of t)i.ext1(n.multiply3(he.MIRROR_Y).bbox());let r=i.build();return{x:r.minX,y:r.minY,width:r.width(),height:r.height()}}function Lp(e){let t=ct.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 ch(e){let t,{cmdKey:i,json:r}=F.getById(e.id);switch(i){case"ellipse":return WC(r);case"arc":return new Pi(r.temp||r).bbox();case"obj":case"rect":return M1(r);case"group":return cs(e)||pE(r);case"text":return Lp(r);case"dimensionLength":case"dimensionAngle":case"dimensionRadius":case"auxiliaryPoint":case"auxiliaryLine":return Ei(r,i)}if(e.tagName!="g"){let a=e.style.display;return e.style.display="inline !important",e.tagName=="path"?t=X5(e):t=cs(e),e.style.display=a,t}else t=cs(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],!(re(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=X5(d)),u&&(u.width||u.height)){if(re(d,"transform"))try{let p=d.getTransformToElement(a);u=_ee(u,p)}catch{}l=l?oN(l,u):u}}return l||{x:0,y:0,width:0,height:0}}return t=s(e),!t.width&&!t.height&&(t=j5(e)),t}function X5(e,t){let i=cs(e),r,n;return!i.width&&!i.height&&!i.x&&!i.y?re(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 Ic(e,t){let i=ch(e);return i.x=un(i.x),i.y=un(i.y),i.width=un(i.width),i.height=un(i.height),i}function _p(e){if(!e||e.tagName!="path")return;if(re(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(re(e,"c_partid")==="arc")return"arc";if(re(e,"c_partid")==="earc")return"earc"}else if(/^(?:MALZ|MLAZ|MLLAZ?)$/.test(r))return"pie"}function _T(e){if(re(e,"c_partid")==="arc"&&re(e,"third-point")){let t=e.getPathData(),i=re(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 KC(e){return e.pathSegTypeAsLetter}function W5(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 Lee(e,t,i){let r=e.numberOfItems;for(let n=i;n<r;n++){let s=KC(e.getItem(n));if(s=="M"||s=="m")return n>i?-1:n;if(s==t)return n}return-1}function p5(e,t){if(!e||e.tagName!="path"||isNaN(t)||t<0||!_p(e))return;let r=mr.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=KC(c),h,d=o+1<s?n.getItem(o+1):"",p=o+1<s?KC(d):"",f,m=W5(u),g=p?W5(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 x=Lee(n,"Z",o+1);x>=0&&(h=e.createSVGPathSegLinetoAbs(r[a*2],r[a*2+1]),n.replaceItem(h,x)),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 Rt=class Rt extends Au{static getDefaultGJsonCache(){return{head:{originX:0,originY:0,title:"",display_title:"",name:"",docType:gs.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 Rt.iterator((i,r,n)=>{if(!["combination","auxiliaryLine","_runtime"].includes(r))try{let s=Ei(i,r);t.ext1(xt.extendRect(s))}catch(s){console.log(s,r)}}),t.valid()||t.ext1(new xt(0,0,0,0)),Rt.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=!yi.eleIsHide(r),r.cmdKey){case"text":break;default:r.d=Ap(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(()=>{Hr("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 st,n=Object();for(let a of t){let o=r.searchCombination(a);o&&i.add(o)}let s=new st().getAllCombinationData([...i]);for(let a of s)Ji(n,"combination")[a.gId]=a;return t.forEach(a=>{let{json:o,cmdKey:l}=Rt.getById(a);Ji(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=Ji(Rt.gJsonCache,"dimension");return t?i[t]||{}:i}static getDimensionLength(t){let i=Ji(Rt.gJsonCache,"dimensionLength");return t?i[t]||{}:i}static getDimensionRadius(t){let i=Ji(Rt.gJsonCache,"dimensionRadius");return t?i[t]||{}:i}static getDimensionAngle(t){let i=Ji(Rt.gJsonCache,"dimensionAngle");return t?i[t]||{}:i}static getRect(t){let i=Ji(Rt.gJsonCache,"rect");return t?i[t]||{}:i}static insertOneData(t,i,r){switch(i){case"obj":Rt.setObj(t,r);break;case"group":Rt.setGroup(t,r);break;case"ellipse":Rt.setEllipse(t,r);break;case"rect":Rt.setRect(t,r);break;case"text":Rt.setText(t,r);break;case"auxiliaryLine":Rt.setAuxiliaryLine(t,r);break;case"auxiliaryPoint":Rt.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=Ji(Rt.gJsonCache,"rect");if(!i||Nt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"rect");return}return r[t]=i,this.changedJsoncache(t,"rect"),i}static getArc(t){let i=Ji(Rt.gJsonCache,"arc");return t?i[t]||Object.create(null):i}static setArc(t,i){let r=Ji(Rt.gJsonCache,"arc");return!i||Nt(i)?delete r[t]:r[t]=i,this.changedJsoncache(t,"arc"),this}static getEllipse(t){let i=Ji(Rt.gJsonCache,"ellipse");return t?i[t]||Object.create(null):i}static setEllipse(t,i){let r=Ji(Rt.gJsonCache,"ellipse");if(!i||Nt(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=Ji(Rt.gJsonCache,r);return!i||Nt(i)?Reflect.deleteProperty(n,t):n[t]=i,this.changedJsoncache(t,r),this}static getCombination(t){let i=Ji(Rt.gJsonCache,"combination");return t?i[t]||Object.create(null):i}static deleteCombInParent(t){let r=new st().findParent(t);return r&&r.combinations.splice(r.combinations.indexOf(t),1),this}static setCombination(t,i){let r=Ji(Rt.gJsonCache,"combination");if(!i||Nt(i)){Reflect.deleteProperty(r,t);return}r[t]=i}static getAuxiliaryLine(t){let i=Ji(Rt.gJsonCache,"auxiliaryLine");return t?i[t]||Object.create(null):i}static setAuxiliaryLine(t,i){let r=Ji(Rt.gJsonCache,"auxiliaryLine");if(!i||Nt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"auxiliaryLine");return}return r[t]=i,this.changedJsoncache(t,"auxiliaryLine"),i}static getAuxiliaryPoint(t){let i=Ji(Rt.gJsonCache,"auxiliaryPoint");return t?i[t]||Object.create(null):i}static setAuxiliaryPoint(t,i){let r=Ji(Rt.gJsonCache,"auxiliaryPoint");if(!i||Nt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"auxiliaryPoint");return}return r[t]=i,this.changedJsoncache(t,"auxiliaryPoint"),i}static getRuntime(t){let i=Ji(Rt.gJsonCache,"_runtime");return t?i[t]||{}:i}static setRuntime(t,i){let r=Ji(Rt.gJsonCache,"_runtime");if(!i||Nt(i)){Reflect.deleteProperty(r,t);return}return r[t]=i,i}static getText(t){let i=Ji(Rt.gJsonCache,"text");return t?i[t]||{}:i}static setText(t,i){let r=Ji(Rt.gJsonCache,"text");if(!i||Nt(i)){Reflect.deleteProperty(r,t),this.changedJsoncache(t,"text");return}return r[t]=i,this.changedJsoncache(t,"text"),i}static getObj(t){let i=Ji(Rt.gJsonCache,"obj");return t?i[t]||{}:i}static setObj(t,i){let r=Ji(Rt.gJsonCache,"obj");if(!i||Nt(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={}}=Rt.gJsonCache;return t?i[t]||{}:i}static setGroup(t,i){let r=Ji(Rt.gJsonCache,"group");if(!i||Nt(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 st().searchCombination(i);if(s){let l=Rt.getCombination(s);l.elements.splice(l.elements.indexOf(i),1)}let a=Rt.gJsonCache[r];a&&a[i]&&(delete a[i],this.changedJsoncache(i,r)),(o=ni.renderer)==null||o.removeNode(i),Lt.removeShapeCache(i)}static freshItemOrder(){let t=aN().filter(i=>Rt.getById(i).json);return Rt.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=Rt.gJsonCache.itemOrder;return Zt(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=Rt.gJsonCache[i][t];!r||Nt(r)?Lt.removeShapeCache(t):Lt.updateShapeCache(t,i,r),$i.updateHole(),tn.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)===Dh)break}static getAllAssistPrimitive(){let t={};for(let r of["auxiliaryLine","auxiliaryPoint","dimension","dimensionAngle","dimensionLength","dimensionRadius"])t[r]=!0;let i=[];return Rt.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}=Rt.gJsonCache.head,[s,a]=[+t-(r||0),+i-(n||0)];return[ei(s,0)?0:+s,ei(a,0)?0:+a]}static getShapeAttr(t,i){let r=J.panelThemeCache.color,n=J.panelThemeCache.shape,s=J.panelThemeCache.fontStyle,a=J.panelThemeCache.fillColor,o={type:i,"attr-topic":Gi[i],"attr-id":"$"+t.id,"attr-name":t.name||"","attr-layer":t.layer};if(Qe(t,"locked")&&(o["attr-locked"]=t.locked===!0?"yes":"no"),Qe(t,"hide")&&(o["attr-hide"]=t.hide===!0?"yes":"no"),Qe(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=F5(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}=Ai.getRectBBox(t.matrix),{obbWidth:m,obbHeight:g}=Sh(t),x=hi.transferXYByReference({x:h,y:d,width:p,height:f}),[y,E]=this.translateByOrigin(x[0],x[1]),T=jT(t,n,i);Object.assign(o,{"reference-point":hi.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)},T)}break;case"ellipse":{Object.assign(o,M5(t),jT(t,n,i));break}case"group":{let h=cs(de(t.gId)),{obbWidth:d,obbHeight:p}=Sh(t),f=hi.transferXYByReference(h),[m,g]=Rt.translateByOrigin(f[0],f[1]);Object.assign(o,{"reference-point":hi.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)},jT(t,n,i));break}case"obj":{l=k5(t);break}case"dimension":l=B5(t);break;case"auxiliaryLine":{l=Y5(t,n,r);break}case"auxiliaryPoint":{let[h,d]=Rt.translateByOrigin(t.x,t.y),p=IC[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 st().getAllElesfromTop(h.gId).elements,p=Array.from(d).map(y=>de(y)),f=Mr(p),m=hi.transferXYByReference(f),[g,x]=Rt.translateByOrigin(m[0],m[1]);l={"reference-point":hi.getReferencePoint(),"attr-name":h.name,"attr-x":g,"attr-y":x,"attr-width":f.width,"attr-height":f.height,"attr-rotation":0};break}case"dimensionLength":{l=U5(t);break}case"dimensionAngle":{l=G5(t);break}case"dimensionRadius":{let h=t,[d,p]=Rt.translateByOrigin(h.x1,h.y1),[f,m]=Rt.translateByOrigin(h.x2,h.y2),{rx:g,ry:x}=new tn(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":x,"attr-rotation":Math.abs(h.rotation||0)};break}case"arc":{l=N5(t),Object.assign(l,jT(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?`${Wh(p.fontItalic).text}`:h.italic?"italic":"normal","attr-font-underline":h.underline==null?`${kB(p.fontUnderline).text}`:h.underline?"underline":"inherit","attr-origin":u(h)}}function u(h){let d=!1;Qe(h,"hAlign")||(h.hAlign=0),Qe(h,"vAlign")||(h.vAlign=2),Qe(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=E1.width),i||(t=E1.height);try{let a=[],o=Gt(t,"pixel"),l=Gt(i,"pixel"),c=xt.extendRect({x:0,y:-l,width:o,height:l});Rt.iterator((m,g)=>{m.layer===3&&c.isIntersect(fE(m,g))&&a.push(m)});let u=mE(a),h=xt.extendRect(u),d=c.intersection1(h),p=Gt(d.width(),"pixel","mm"),f=Gt(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"}}};Rt.gJsonCache={head:{originX:0,originY:0,title:"",display_title:"",name:"",docType:gs.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:{}},Rt.id2cmd=new Map,Rt.CmdKeyMethodMap={text:t=>Rt.getText(t),obj:t=>Rt.getObj(t),rect:t=>Rt.getRect(t),group:t=>Rt.getGroup(t),ellipse:t=>Rt.getEllipse(t),arc:t=>Rt.getArc(t),combination:t=>Rt.getCombination(t),dimension:t=>Rt.getDimension(t),dimensionLength:t=>Rt.getDimensionLength(t),dimensionRadius:t=>Rt.getDimensionRadius(t),dimensionAngle:t=>Rt.getDimensionAngle(t),auxiliaryLine:t=>Rt.getAuxiliaryLine(t),auxiliaryPoint:t=>Rt.getAuxiliaryPoint(t),_runtime:t=>Rt.getRuntime(t)};var F=Rt;function jT(e,t,i){let r=IC[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":Wh(n).value,type:r,"attr-fill-color-display":e.displayFill,"attr-stroke-color-display":e.displayStroke};return hi.filterAttrByLayer(a,e.layer),a}window.frameElement&&window.addEventListener("unload",()=>{var e;(e=F.compilerManager)==null||e.destroy()});var $C=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=de(i),s=F.getById(i).json;for(let a in t){let o=t[a];switch(F.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=F.getDimension(i),c=new wn(l).render();c=null}break;case"x":{this.updateX(n,r,o);break}case"y":{this.updateY(n,r,o);break}case"rx":re(n,"rx",o);break;case"ry":re(n,"ry",o);break;case"layer":re(n,"layer",o);break;case"category":this.updateCategory(n,r,o);break;case"cover":break;case"hide":re(n,"hide",o?"1":"0");break;case"locked":break;case"opacity":break;case"scope":break;case"fillColor":case"displayFill":N1(s);break;case"displayStroke":case"strokeColor":R1(n,r,s);break;case"strokeWidth":jC(n,r,o);break;case"transparencyWhite":case"transparencyPrint":{let l=F.getById(n.id).json,c=+t["attr-transparency-print"]||l.transparencyPrint,u=+t["attr-transparency-white"]||l.transparencyWhite,h=Rp(c*100,u*100);re(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":yi.applyElementsVisible(i);break;case"tempD":break;case"strokeStyle":this.updateStrokeStyle(s);break;default:console.error(a);break}}r==="auxiliaryLine"?new Ul(s).render():r==="arc"&&new Pi(s).render(),F.compilerManager.uploadData(i)}}updateStrokeStyle(t){switch(t.cmdKey){case"auxiliaryLine":ni.renderer.attr(t.gId,"stroke-dasharray",Pn.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}=gi.getEllipseFromMatrix(r);re(t,{rx:o,ry:l}),ct.updateTransform(c,t)}break;case"rect":let{width:n,height:s,matrixArr:a}=Ai.getRectFromMatrix(r);re(t,{width:n,height:s}),ct.updateTransform(a,t);break;case"obj":case"text":ct.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"),re(t,"d",r);break;case"group":re(t,"d",r);break;default:console.error("err");break}}updateX1(t){let{json:i,cmdKey:r}=F.getById(t);switch(r){case"dimensionLength":new dn(i).render();break;case"dimensionAngle":new hn(i).render();break;case"dimensionRadius":new tn(i).render();break;case"arc":new Pi(i).render();break;default:console.error(r,"not handle x1");break}}updateTextX(t){let{json:i,cmdKey:r}=F.getById(t);switch(r){case"dimensionAngle":new hn(i).render();break;case"dimensionRadius":new tn(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":re(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];ly(s,t[n])||(r[n]=s)}for(let n in t){let s=i[n];ly(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)}},Pg=new $C;var ZC=0,Vt=class Vt{static checkBatchStateIsCorrect(){this.batchState!==ZC&&Hr(ZC,this.batchState)}static save(t){if(!Array.isArray(t)||t.length===0)throw _e("reportError",[new Error("History.save :: first argument is not an array")]),console.error(t),new Error("err");if(Vt.batchState){Array.isArray(t)&&Array.isArray(t[0])?[].push.apply(Vt.queueBatchRecords,t):Vt.queueBatchRecords.push(t);return}Vt.index.value>=Vt.maxLength-1?(Vt.records.shift(),Vt.savedIndex>-1&&(Vt.savedIndex-=1)):Vt.index.value++,Vt.timestamps[Vt.index.value]=Date.now(),F.freshItemOrder(),this.handleSelected("redo",t),F.compilerManager.resumeDataMerge(),F.compilerManager.uploadHistoryData(t),Vt.records[Vt.index.value]=t,Vt.records.length=Vt.index.value+1,fn("triggerEvent",["history_change",{tabId:J.tabId},Vt.records.length,Vt.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;Vt.timestamps.length=0,Vt.records.length=0,Vt.index.value=-1,Vt.savedIndex=i?-2:Vt.index.value,Vt.batchState=0,fn("triggerEvent",["history_change",{tabId:J.tabId},Vt.records.length,Vt.index.value,i])}static goTo(t){if(t>=-1&&t!==Vt.index.value&&t<Vt.records.length){if(t>Vt.index.value)for(let i=Vt.index.value+1;i<=t;i++)Vt.doCmdBatch("redo",Vt.records[i]);else for(let i=Vt.index.value;i>t;i--)Vt.doCmdBatch("undo",Vt.records[i]);Vt.index.value=t,fn("triggerEvent",["history_change",{tabId:J.tabId},Vt.records.length,Vt.index.value,!0]),F.freshItemOrder(),_e("panel_updateAttrPanel"),_e("updateMenuByDocStatus"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE),_e("panel/updateTreeActiveElements");return}console.log("history.goTo("+t+") not available")}static go(t){Vt.goTo(Vt.index.value+t)}static doCmdBatch(t,i){eD(),t=="redo"?Vt.redoOne(i):Vt.undoOne(i),this.handleSelected(t,i),this.upLoadBatch(i,t)}static handleSelected(t,i){var s;let r=no.getIds(),n=Ag.getIds();i.forEach(a=>{var u;if(!tm.includes((u=a[2])==null?void 0:u.cmdKey))return;let o=a[1],l=!1,c=!1;t==="redo"?(l=Nt(a[4]),c=Nt(a[3])):(l=Nt(a[3]),c=Nt(a[4])),l&&r.includes(o)?(Ag.select(o),no.unselect(o)):c&&n.includes(o)&&(no.select(o),Ag.unselect(o))}),(s=F.selectedRepeater)==null||s.updateChange()}static upLoadBatch(t,i){Tc(t[0])||(t=[t]),t.forEach(r=>{let n=r[0];["json","combine-json"].includes(n)?this.uploadDeleteOrCreate(r,i):n==="originXY"&&F.compilerManager.uploadData("canvas")})}static defineUndoRedo(t,i){Vt.undoRedoHandlers[t]=i}static undoOne(t){if(Array.isArray(t[0])){let r=t.length;for(let n=r-1;n>=0;n--)Vt.undoOne(t[n]);return}let i=Vt.undoRedoHandlers[t[0]];t=Mo.updateRecord(t,"undo"),i.undo&&i.undo(t)}static redoOne(t){if(Tc(t[0])){let r=t.length;for(let n=r-1;n>=0;n--)Vt.redoOne(t[n]);return}let i=Vt.undoRedoHandlers[t[0]];t=Mo.updateRecord(t,"redo"),i&&i.redo&&i.redo(t)}static uploadDeleteOrCreate(t,i){let r=t.at(-1),n=t.at(-2);if(Nt(r)||Nt(n)||!r||!n){let s=t.at(1),a=(r==null?void 0:r.cmdKey)||(n==null?void 0:n.cmdKey);i==="redo"?Nt(r)||!r?Mo.uploadDeleteById(s,a):F.compilerManager.uploadData(s,r):Nt(n)||!n?Mo.uploadDeleteById(s,a):F.compilerManager.uploadData(s,n)}}static canRedo(){return Vt.index.value<Vt.records.length-1}static canUndo(){return Vt.index.value>=0}static createElePosition(t,i,r){return["elePosition",t,i,r]}static getLastRecordPrimitiveIds(){let t=Vt.records[Vt.records.length-1];return t?(Array.isArray(t[0])?t:[t]).reduce((r,[n,s])=>(n==="json"&&r.push(s),r),[]):[]}};Vt.records=[],Vt.timestamps=[],Vt.queueBatchRecords=[],Vt.maxLength=50,Vt.index={value:-1},Vt.savedIndex=-1,Vt.batchState=ZC,Vt.undoRedoHandlers=[];var at=Vt;at.defineUndoRedo("originXY",{undo:function(e){var t=e[2];if(!(!t.offsetX&&t.offsetX!=0||!t.offsetY&&t.offsetY!=0)){var i={};i.x=Xe.canvas.originX-t.offsetX,i.y=Xe.canvas.originY-t.offsetY,bn().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=Xe.canvas.originX+t.offsetX,i.y=Xe.canvas.originY+t.offsetY,bn().setOriginXY({x:i.x,y:i.y})}}});at.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=de(i[n]);s&&QC(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=de(i[s]);a&&QC(a.parentNode,a,n[s])}}});at.defineUndoRedo("combine-json",{undo(e){let[,t,i,r]=e;F.setCombination(t,i),new $i().updateHole()},redo(e){let[,t,i,r]=e;F.setCombination(t,r),new $i().updateHole()}});at.defineUndoRedo("json",{undo(e){let[t,i,r,n,s]=e,{cmdKey:a,refId:o}=r;if(cy(n)&&cy(s))return Pg.run(n,i,a)},redo(e){let[t,i,r,n,s]=e,{cmdKey:a,refId:o}=r;if(cy(n)&&cy(s))return Pg.run(s,i,a)}});function zr(e,{cmdKey:t,refId:i},r,n){return["json",e,{cmdKey:t,refId:i},Zt(r),Zt(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(F.getById(i.gId||i.id).json)}createCombineJsonHistory(t,i,r){return i=i||F.getCombination(t),["combine-json",t,Zt(i),Zt(r)]}addOneCombine(t,i){let n=new st().searchCombination(t);this.addOneCombineByComId(n,i)}addOneCombineByComId(t,i){if(!t||this.uniqueCombineIds.has(t))return;this.uniqueCombineIds.add(t);let n=new st().findParent(t);n&&(this.uniqueCombineIds.add(n.gId),this.histCombine.push(this.createCombineJsonHistory(n.gId,n))),i=i||F.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=F.getRefId(t.gId),a=i||t,o=zr(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),F.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=F.getById(i[n].gId).json,o=t[n][3];delete a.tempMatrix,delete a.tempD;let l=Pg.diff(o,a);if(Nt(l))continue;F.changedJsoncache(o.gId||a.gId,o.cmdKey||a.cmdKey);let c=Nt(o),u=Nt(a);t[n][3]=Pg.diff(a,o),t[n][4]=l,c&&(t[n][3]={}),u&&(t[n][4]={}),r.push(t[n])}this.hist=r,this.updateCombine(),F.compilerManager.resumeDataMerge()}updateCombine(){let t=[];for(let i of this.histCombine){let[,r,n]=i,s=F.getCombination(r),a=Pg.diff(n,s);Nt(a)||(i.pop(),i.push(Zt(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&&at.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?Us(n,s):F.insertOneData(s.gId,n,s)}return this}};var F1=class{constructor(){}isLockedById(t){let{locked:i}=F.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;F.iteratorCombination(r=>{r.locked===!0&&(t.addOneCombineByComId(r.gId),r.locked=!1)}),F.getItemOrder().forEach(r=>{let{json:n,cmdKey:s}=F.getById(r),{locked:a}=n;a===!0&&(t.addOne(n),n.locked=!1)}),t.updateAndSave()}setLockStatus(t,i){let r=new st,{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=F.getCombination(o);l.locked=i}for(let o of n){let{json:l,cmdKey:c}=F.getById(o);c!=="dimension"&&(l.locked=i)}a.updateAndSave()}setCombinationLockStatus(t,i){let r=new oi;r.addOneCombineByComId(t);let n=F.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 F.getCombination(t).locked}setElementsLockStatus(t,i){let r=new oi(t.map(n=>({id:n})));for(let n of t){let{json:s}=F.getById(n);s.locked=i}r.updateAndSave(),_e("panel_updateAttrPanel")}toggleLockStatus(t){at.startBatch(),t.forEach(i=>{let r=F.getCombination(i);if(!Nt(r))this.setCombinationLockStatus(i,!r.locked);else{let{json:s}=F.getById(i);this.setLockStatus([i],!s.locked)}}),at.saveBatch()}};F1=La([Ea(gn.lock)],F1);var wr=new F1;var nf=class{static ready(t=el(J.cmdToken)){Je.started=!0,this.buildLine(t),this._type=t,J.helperCursor=""}static buildLine(t){switch(t){case"cross":{this.lines=[new _g(F.getInitialAuxiliaryLineData({gId:_t()})),new _g(F.getInitialAuxiliaryLineData({gId:_t(),rotation:90}))];break}case"horizontal":{this.lines=[new _g(F.getInitialAuxiliaryLineData({gId:_t()}))];break}case"vertical":{this.lines=[new _g(F.getInitialAuxiliaryLineData({gId:_t(),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,de(n.gId)?new Ul(n.toJSON()).render():tt.appendTargetLayer(n.svg,8);Rd(),r&&Vr.record(0,()=>{Je.next()})}static next(){let t=[];for(let i of this.lines){let r=Yy(i.toJSON());tt.appendTargetLayer(r,8);let n=Fn(r);t.push(zr(i.gId,{cmdKey:"auxiliaryLine",refId:n},{},i.toJSON())),Ce.select([r])}this.buildLine(this._type),t.length&&at.save(t)}static end(){for(let t of this.lines)dt(de(t.gId));this.lines.length=0,this._type=null,Rd()}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)?ft(Gt(i,"pixel",Xe.canvas.unit),2):null,s=["cross","horizontal"].includes(this._type)?ft(Gt(-r,"pixel",Xe.canvas.unit),2):null,a=Dg({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()}};nf.lines=[];var _g=class{constructor(t){this.svg=Tt("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 el(this.rotation)}updateSVG(){if(this.x==null||this.y==null||this.rotation==null)return;let t=J.svgRoot.viewBox.animVal,i=Math.max(t.width,t.height),r=Sp(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=Sp(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}}};function Ro(e,t="",i=ut()){return J.windowBridge.rpcCall(e,t,i)}function fn(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 Un(e){Un.data.event=e;var t=6;if([2,4].includes(e.buttons)||[1,2].includes(e.button))return;var i=Ti(e,!1),r=e.target,n=Xe.canvas,s=Un.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==J.svgRoot||ba(r,Ml)||J.gCanvas.contains(r))&&(s.lastUpX=l,s.lastUpY=c);var u=l-s.lastUpX,h=c-s.lastUpY;e.type=="mouseup"&&(r==J.svgRoot||ba(r,Ml)||J.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={...ol(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)*J.gZoom>t||Math.abs(h)*J.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,fn("updateMouseXY",[f]),de("mouse-x-for-test").value=i.x,de("mouse-y-for-test").value=-i.y;function m(g){return g=d?Gt(+g,"pixel",d):+g,g=bN(g),d?g+d:g}}Un.data={clientX:null,clientY:null,lastUpX:null,lastUpY:null,uplock:!1,currAbsX:0,currAbsY:0,event:null};function Ti(e,t){let i=cd({x:e.clientX,y:e.clientY}),{x:r,y:n}=i;return t===!0&&!e.altKey?Oee(i):t!==!1&&Xe.adsorbGrid.enabled?ol(i):{x:un(r),y:un(n)}}function Oee(e){let t=Lt.adsorption(e.x,e.y);return t!=null?t:Xe.adsorbGrid.enabled?ol(e):e}function t5(e,t){let i=Lt.dragAdsorption(e.x,e.y,t);return i!=null?{x:un(i.x),y:un(i.y)}:Xe.adsorbGrid.enabled?ol(e):{x:un(e.x),y:un(e.y)}}function il(){let e=de("gControlDots"),t=de("gControlRects"),i=de("gControlLines"),r=[e,t,i];for(let n of r)n.classList.add("hide");ts.hideAll().emptyData()}function Gs(e,t="single"){let i=F.getById(e.id||e.gId).json||Object(),r=_n.get(i,t)||mr.get(e);return ts.main(r),Eo(r)?r.bbox:r}async function e5(e,t){let i=t||e.target,r=i==J.svgRoot,n=Qt(i);i.parentNode===J.gControlDots?n="cdot":i=Hl(i);let s=n==="cdot",a=vr();(!s&&!r&&i&&i.tagName!="TEXTAREA"&&(!i||!Ce.isSelected(i))||r)&&!a&&Xt(),!s&&i&&(Ce.select([i]),["auxiliaryLine","auxiliaryPoint","dimension"].includes(n)||Tn([i]));let o=[n],{x:l,y:c}=Ti(e,!1),u=ts.findControlDot(l,c);u&&u.belongCmdKey==="arc"&&(o=[u.belongCmdKey]),(u||s)&&ts.selectAnchorOrHandle((u==null?void 0:u.id)||(i==null?void 0:i.id)),(r||(u==null?void 0:u.type)==="bbox"||Ce.getIds().length===0)&&(o="canvas");let h=i==null?void 0:i.id,d=Ce.getIds(),{combinations:p}=new st().getSelectedCombinations(d);if(!jt.isEditingPath())for(let w of d){let{cmdKey:b,json:C}=F.getById(w),A=Ei(C,b);xt.extendRect(A).isContains1(l,c)&&(o=[b])}let f=(await Ro("getPanelFilterConfig",[J.tabId])).message,{checkInDisableFlag:m,checkInHideFlag:g,checkOutDisableFlag:x,checkOutHideFlag:y}=Dd.get(),E=!await Qp(),T={filterConfig:f,tabId:J.tabId,target:o,targetId:h,docType:J.doctype,cmdKey:n,clientX:e.clientX,clientY:e.clientY,x:l,y:c,hasLocked:wr.hasEleLocked(d),hasUnLocked:wr.hasUnLockedObjs(a),hasVisible:yi.hasVisible(d),hasHidden:yi.hasHidden(d),selectsCount:a.length,combinationCount:Object.keys(F.getCombination()).length,isEditCombine:Kt.isEditing(),isClipboardEmpty:E,aboveCombination:Array.from(p),checkInDisableFlag:m,checkInHideFlag:g,checkOutDisableFlag:x,checkOutHideFlag:y};J.contextmenuDisableOnce||J.windowBridge.publish("showEditorContextMenu",[T],ut())}function vr(){return Ce.get()}function VE(){let e=Ce.getIds(),t=[];for(let i of e)t.push(F.getById(i).json);return t}function Xt(e){eD(),BC(e),du()}function eD(){let e=Zr("#g1 ."+Ce.highlightClass);for(var t=e.length-1;t>=0;t--)Ce.unhighlight(e[t])}function BC(e){var t=e||vr(),i=t.length;if(i>0)for(var r=i;--r>=0;)Ce.unselect(t[r]);Ag.clear(),il(),nh("","none");var n=Zr("."+Ce.selectClass,J.gCanvas);return Ce.unselect(n),i}function OC(){var i;let e=Ya(),t=new st;(i=F.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=>de(a)).filter(a=>a);Ce.select(s)}else Ce.select([de(r.elements[0])]);_e("panel_updateAttrPanel"),_e("updateMenuByDocStatus")}function Bc(e=mi.getViewBox(),t={}){fn("updateRuler",[{zoom:J.gZoom,unit:Xe.canvas.unit,vbX:e[0],vbY:e[1],originX:Xe.canvas.originX,originY:Xe.canvas.originY,...t}],J.tabId)}function Rd(){fn("updateRuler",[Kp()],J.tabId)}function Kp(e=mi.getViewBox(),t=J.gZoom){let i=[],r=[];switch(J.cmdToken){case"place_auxiliary(crossLine)":case"place_auxiliary(verticalLine)":case"place_auxiliary(horizontalLine)":{let n=nf.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 Ce.getIds().forEach(n=>{let s=F.getAuxiliaryLine(n);if(s!=null)switch(el(s.rotation)){case"vertical":{i.push({position:(s.x-e[0])*t,content:String(ft(Gt(s.x,"pixel",Xe.canvas.unit),2))});break}case"horizontal":{r.push({position:(s.y-e[1])*t,content:String(ft(Gt(-s.y,"pixel",Xe.canvas.unit),2))});break}}}),{auxiliaryX:i,auxiliaryY:r}}function C1(){var e=document.body,t=document.documentElement;return{zoom:J.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:+re(J.svgRoot,"width"),canvasHeight:+re(J.svgRoot,"height"),viewBox:re(J.svgRoot,"viewBox"),unit:Xe.canvas.unit}}function xr(e,t,i,r){let n=/^(grab|grabbing|row-resize|col-resize|crosshair)$/;if(J.helperCursor&&e!=="grabbing"&&(J.helperCursor=="cross-red"?ps(!1):n.test(J.helperCursor)?To(J.svgRoot,"cursor-"+J.helperCursor):re(de(J.helperCursor),{display:"none"})),e&&n.test(e)){cu(J.svgRoot,"cursor-"+e),J.helperCursor=e;return}let s=!1;e&&J.helperCursorConfig[e]?e=="cross-red"?fn("panel/getCrossCursor")===!1?(ps(!1),s=!0):arguments.length>=3?(ps(t,i),s=!0):J.helperCursor&&t===!0?ps(!1):(r!==void 0?ps(!1,void 0,{content:r}):ps(!1),s=!0):arguments.length>=3&&t!==void 0&&i!==void 0?re(de(e),{x:t,y:i,display:""}):J.helperCursor&&t===!0?re(de(e),{display:""}):(re(de(e),{x:-1e5,y:-1e5,display:""}),s=!0):s=!0,Js(J.svgRoot,"cursor-none",!s),J.helperCursor=e||"",!e&&ps(!1)}function ps(e,t,i){let r=fn("panel/getCrossCursor");if(r==="None"&&(e=!1),e!==!1&&(!isFinite(e)||!isFinite(t)))return;var n=de("cross-x"),s=de("cross-y"),a=de("cross-text");!Ir.ready&&!No.running&&cu(a,"hide");let o=mi.getViewBox();if(o=[o[0]-o[2],o[1]-o[3],o[2]*3,o[3]*3],e===!1||r===!1){re(n,"d","M0 0"),re(s,"d","M0 0"),J.cmdToken!==""?Ir.exit():(e||!e&&r==="None")&&Ir.showReferText();return}if(VB()){let u=60;u=u/J.gZoom,o=[e-u/2,t-u/2,u,u]}re(n,"d","M"+e+" "+o[1]+" v"+o[3]),re(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;Ir.ready&&Ir.showReferencePointAndText(e,t,l,c),i&&i.stroke?(re(n,"stroke",i.stroke),re(s,"stroke",i.stroke)):(re(n,"stroke","red"),re(s,"stroke","red")),i&&i.strokeWidth?(re(n,"stroke-width",i.strokeWidth),re(s,"stroke-width",i.strokeWidth),re(n,"stroke-dasharray",i.strokeWidth*2+","+i.strokeWidth*2),re(s,"stroke-dasharray",i.strokeWidth*2+","+i.strokeWidth*2),i.strokeLinecap&&(n.style.strokeLinecap=i.strokeLinecap,s.style.strokeLinecap=i.strokeLinecap)):(re(n,"stroke-width","1"),re(s,"stroke-width","1"),re(n,"stroke-dasharray","2, 2"),re(s,"stroke-dasharray","2, 2"),n.style.strokeLinecap="round",s.style.strokeLinecap="round")}function l5(e){if(!J.helperCursor&&HB(),!J.helperCursor||e.shiftKey)return;if(Js(de("cross-x"),"hide",!J.helperCursor),Js(de("cross-y"),"hide",!J.helperCursor),fs(e),(e.target==document.documentElement||e.target==document.body)&&!xo){J.helperCursor=="cross-red"?ps(!1):re(de(J.helperCursor),{display:"none"});return}var t,i;Xe.adsorbGrid.enabled||(t=Object.assign({},Xe.adsorbGrid),Object.assign(Xe.adsorbGrid,{distanceX:1,distanceY:1,enabled:!0}),i=function(){Object.assign(Xe.adsorbGrid,t)});let r,n;if(Xe.adsorbGrid.enabled&&J.helperCursor!="cursor-hand"&&J.helperCursor!="cursor-grab"&&J.helperCursor!="cursor-freedraw"){kl.altKeyEnabled=e.altKey;let a=wc.isAdaptAreaSelectionView()||J.helperCursor==="grabbing",o=Ti(e,!a);r=o.x,n=o.y}else{var s=Ti(e,!1);r=s.x,n=s.y}J.helperCursor=="cross-red"?(fs("",{x:r,y:n}),ps(r,n)):re(de(J.helperCursor),{x:r,y:n,display:""}),i&&i()}async function AT(e,t){if(t=(t==null?void 0:t.ids)||t,Tc(t)||(t=Ce.get()),t.some(s=>wr.isLockedById(s.id)))return zl();let r=t.map(s=>gc(s)?de(s):s.gId?de(s.gId):s);r=r.filter(s=>{let a=Qt(s);return"dimension"!==a});let n=Ree(r);if(await No.needSelectRefobject(e)||await No.needSelectRefobjectForCenters(e)){await new No(e,n).startSelect();return}eT(n,e),_e("panel_updateAttrPanel")}function Ree(e){let t=e.map(a=>a.id),{combinations:i,elements:r}=new st().getSelectedCombinations(t),n=[];for(let a of r)n.push(de(a));let s=new st;for(let a of i){let o=s.getAllElesfromTop(a).elements,l=[];for(let c of o)l.push(de(c));n.push(l)}return n}function V5(e,t=20){let i=[],r=[];for(let d of e){let p=F.getAuxiliaryLine(d.id),f=el(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=mi.getViewBox(),c=i.length?(n+s)/2:l[0]+l[2]/2,u=r.length?(a+o)/2:l[1]+l[3]/2;Eg(c,u);let h=xt.extendRect(J.svgRoot.viewBox.animVal);if(h.minX>n-t||h.maxX<s+t||h.minY>a-t||h.maxY<o+t){let d=mi.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>J.zoomRatio.max&&(g=J.zoomRatio.max,m=g/100);let x={clientX:(c-d[0])*J.gZoom,clientY:(u-d[1])*J.gZoom};fn("zoom",[g,window.frameElement,x,!0])}}var VT=class{static ready(){}static onKeyUp(t){let i=Je,{keyCode:r}=t;switch(r){case"Enter":if(!i.dots.length)return;let n={clientX:Un.data.clientX,clientY:Un.data.clientY,button:K1,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=yg()==="rightClickEnd",{ctrlKey:s}=t;s&&(n=!1);let a=Je;if(mt(i)&&mt(r)){let l=Ti(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),Ls.handlePolylineSelection());break}return a.STATUSEXIT}static mouseupRight(t){let i=yg()==="rightClickEnd",r=Je,{x:n,y:s}=Ti(t,!0);return r.dots.length===0?(Je.restart(),r.STATUSEXIT):(i?(["lineTouched"].includes(Ls.selectionMode)&&r.next(n,s,!0),Ls.handlePolylineSelection(),_e("panel_updateAttrPanel"),_e("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&&!Zs({x:t,y:i},{x:s[s.length-2],y:s[s.length-1]})&&s.push(t,i),Ls.selectionMode==="lineTouched"){Ls.showSelectPolyline(s.join(" "));return}let o=s.slice(2).join(" "),l=`M ${s[0]} ${s[1]} ${o?"L "+o:""}`;n.target?(re(n.target,{d:l}),n.dots.length>=4&&Lt.updateDrawingShapeCache(n.dots)):(n.target=Tt("path",{d:l,fill:"none",c_partid:"group",locked:0,layer:tt.getTargetPlaceLayer("group"),opacity:1,hide:0,scope:1,cover:1,rotation:0,name:""}),tt.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{tt.appendTargetLayer(r.target);let o=Fn(a);at.save(zr(a.id,{cmdKey:"group",refId:o},{},F.getById(a.id).json))}r.started=!1}static end(t){var i=Je;F.removeOne(i.target),dt(i.target)}};var G1=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 x=_t();this.data=F.getInitialRectData({gId:x,layer:tt.getTargetPlaceLayer("rect")});let y=J.panelThemeCache.fillColor.rect,E=J.panelThemeCache.shape.rect.width;E=Gt(E,"mm","pixel");let T=J.panelThemeCache.color.rect;this.data.fillColor=y,this.data.strokeWidth=E,this.data.strokeColor=T,n.target=Tt("rect",{id:x,x:0,y:0,width:1,height:1,"stroke-width":E,"stroke-color":T,c_partid:"rect",fill:y,opacity:.3,rx:0,ry:0}),h=!0}let d=he.scale(c,u).translate(o,l),p=$e.getMatrix6FromMatrix(d);this.data.matrix=p;let{width:f,height:m,matrixArr:g}=Ai.getRectFromMatrix(p);re(n.target,{width:f,height:m}),ct.updateTransform(g,n.target),h&&tt.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=Fy(this.data,a.id),ja([a]),tt.appendTargetLayer(a),Xt(),Ce.select(a),Gs(a),this.ready())),r.started=!1}static end(){var i;let t=(i=this.data)==null?void 0:i.gId;t&&F.removeMultiData([{id:t}]),this.ready()}};G1.data=null;var zT=class{static ready(){}static mouseupLeft(t){let i=yg()==="rightClickEnd",r=Je,{x:n,y:s}=Ti(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),GC());break}return r.STATUSEXIT}static mouseupRight(t){let i=yg()==="rightClickEnd",r=Je,{x:n,y:s}=Ti(t,!0);return r.dots.length===0?(Je.restart(),r.STATUSEXIT):(i?(r.next(n,s,!0),GC(),_e("panel_updateAttrPanel"),_e("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=Ls.selectionMode;if(["polygonInside","polygonOutside"].includes(o)){FC(a);return}n.target?re(n.target,{points:a}):(n.target=Tt("polygon",{points:a,fill:"none",c_partid:"line",class:Ce.unselectableClass,"stroke-dasharray":"3, 3","vector-effect":"non-scaling-stroke","stroke-width":"1px",locked:0,layerid:tt.getTargetPlaceLayer("group")}),tt.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&&(F.removeOne(i.target),dt(i.target))}};var q5="drag-auxiliary-line",Du=class{constructor(t,i){this.auxiliaryLineId=q5;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?re(n,{points:s}):(n=Tt("polyline",{id:r,points:s,"vector-effect":"non-scaling-stroke",stroke:J.panelThemeCache.color.select}),J.gCanvas.appendChild(n))}static removeAuxiliaryLine(){dt(document.getElementById(this.auxiliaryLineId))}static overrideXY(t,i,r,n){if(t&&i){let s=new V(i.x,i.y),a=new V(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(he.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}}};Du.auxiliaryLineId=q5;var U1=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=ft(Bl(t,i,o,l));if(c===0)return;let u=!1;if(!this.data){let g=_t();this.data=F.getInitialEllipseData({gId:g,layer:tt.getTargetPlaceLayer("ellipse")});let x=J.panelThemeCache.fillColor.circle,y=J.panelThemeCache.shape.circle.width;y=Gt(y,"mm","pixel");let E=J.panelThemeCache.color.circle;this.data.fillColor=x,this.data.strokeWidth=y,this.data.strokeColor=E,n.target=Tt("ellipse",{id:g,cx:0,cy:0,rx:1,ry:1,fill:x,"stroke-color":E,"stroke-width":y,c_partid:"ellipse",opacity:.3}),u=!0}let h=he.scale(c,c).translate(o,l),d=$e.getMatrix6FromMatrix(h);this.data.matrix=d;let{rx:p,ry:f,matrixArr:m}=gi.getEllipseFromMatrix(d);re(n.target,{rx:p,ry:f}),ct.updateTransform(m,n.target),u&&tt.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=Gy(this.data,a.id),ja([a]),tt.appendTargetLayer(a),this.ready())),r.started=!1,Xt(),Ce.select(a),Gs(a)}static end(t){var r;let i=(r=this.data)==null?void 0:r.gId;i&&F.removeMultiData([{id:i}]),this.ready()}};var XT=class{};var Lg=class extends XT{static getTextNode(){return Cs(`
	<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=uy(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=_t();t.id=i,this.data=F.getInitialTextData({gId:i});let r=J.panelThemeCache.fontStyle.text,n=this.attrs["attr-font-color"]||J.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=Gt(this.attrs["attr-font-size"]||r.fontSize,"mm","pixel"),c=this.attrs["attr-font-family"]||r.fontFamily,[u,h]=UT(this.attrs["attr-origin"]);this.data.vAlign=+h,this.data.hAlign=u;let d=new fu,{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 x=Tt("path",{d:p,fill:n}),y=Tt("rect",{width:g,height:m,x:0,class:"hitbox",y:-m,stroke:"none",fill:"transparent"});t.appendChild(y),t.appendChild(x),t=Fm(this.data,this.data.gId),t.classList.add(Nl),Yn.text(this.data,Un.data.currAbsX,Un.data.currAbsY),tt.appendTargetLayer(t),Je.target=t,Lt.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;tD(s,"visibility"),s.classList.remove("hide");let{x:a,y:o}=lr.getTextOrigin("",this.data.hAlign,this.data.vAlign,this.data),l=he.translate(t+a,i+o).rotateD(this.rotation).setOrigin(t,i),c=$e.getMatrix6FromMatrix(l);return ct.updateTransform(c,s),r&&(Lt.clearExcludeShapeIds(),tD(s,"pointer-events"),this.data.matrix=c,s=Fm(this.data,this.data.gId),Vr.record(0,()=>{ja([s])}),tt.appendTargetLayer(s),Je.next()),s}static end(t){Je.target&&Je.target.parentNode&&!t&&F.removeOne(Je.target),this.template=null,J.windowBridge.publish("openForceClosedBottomBar",null,ut())}};Lg.rotation=0;var WT=class{constructor(t={}){this.path=Tt("path",{...t}),tt.appendTargetLayer(this.path)}render(t){return re(this.path,"d",t),this}remove(){dt(this.path)}getPath(){return this.path}},qT=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,Ta.flush()}mouseupLeft(t,i,r){this.isPressingMouseLeftDown&&this.hasMoved&&this.handlePoints.push(i,r),this.isPressingMouseLeftDown=!1}getFollowHandle(t,i,r,n,s){if(Ta.storeDriving(t,i),s!=null&&s.ctrl){Ta.exchangeFollow(),Ta.exchangeDriving();let{x:a,y:o}=Ta.getFollowHandle();mt(a)||(n.x=a,n.y=o)}else{let a=new V(n.x,n.y),{x:o,y:l}=Ta.getFollowHandle(),{x:c,y:u}=Ta.getDrivingHandle();mt(o)||(a=new V(o,l));let h=new V(t,i);mt(c)||(h=new V(c,u));let d=jt.handleFollowHandle(new V(r.x,r.y),{oldP:h,newP:new V(t,i)},a);n.x=d.x,n.y=d.y,Ta.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=dN(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=jt.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=jt.getPathD(d);if(this.data){re(s.target,{d:p});let m=this.anchorInfo.length,g=this.anchorInfo[m-1],x={type:"M",x:g.x,y:g.y,d:["M",g.x,g.y].join(" "),index:0},y=jt.getPathD([x,h]);this.virtualLine.render(y);let E="";m>1&&(E=jt.getPathD(this.anchorInfo)),this.realityLine.render(E),d.pop(),Lt.updateDrawingShapeCache(jt.getPoints(d))}else{let m=tt.getTargetPlaceLayer("group"),g=_t();this.data=F.getInitialGroupData({gId:g,layer:m});let x=J.panelThemeCache.shape.line.width,y=J.panelThemeCache.color.line;x=Gt(x,"mm","pixel"),this.data.strokeWidth=x,this.data.strokeColor=y;let E=J.panelThemeCache.fillColor.line||"none";this.data.fillColor=E;let T={opacity:1,"stroke-width":x,stroke:y,fill:E,c_partid:"group"};this.realityLine=new WT(T),T.opacity=.3,this.virtualLine=new WT(T).render(p),s.target=Tt("path",{id:g,d:p,opacity:1,strokeWidth:x,strokeColor:y,fill:"none",c_partid:"group"}),tt.appendTargetLayer(s.target),re(s.target,{display:"none"}),jt.toggleMode(s.target.id)}nh("","none"),Gs(s.target);let f=o?[o.index,l.index]:[l.index];ts.showHandleOfIndexes(f)}next(){var r,n;let i=Je.target;if(this.anchorInfo.length>1&&i){let s=jt.getPathD(this.anchorInfo);this.data.d=s,i=rl(this.data,i.id),ja([i]),tt.appendTargetLayer(i)}this.anchorInfo.length<2?(dt(i),ts.hideAll().removeAllAnchor(),i=null):(jt.toggleMode(i.id),Ce.select(i),Gs(i)),(r=this.realityLine)==null||r.remove(),(n=this.virtualLine)==null||n.remove(),this.ready()}end(){this.data&&F.removeMultiData([{id:this.data.gId}]),this.ready(),ts.hideAll().removeAllAnchor(),this.realityLine&&(this.realityLine.remove(),this.virtualLine.remove())}};var JT=class{constructor(t){this.panelDraw=t}ready(){Je.started=!0,this.point=new KT(F.getInitialAuxiliaryPointData({gId:_t()}))}draw(t,i,r){this.point.x=t,this.point.y=i,de(this.point.gId)||tt.appendTargetLayer(this.point.svg,8),Rd(),r&&Vr.record(0,()=>{this.panelDraw.next()})}next(){at.startBatch();let t=Op(this.point.toJSON());tt.appendTargetLayer(t,8);let i=Fn(t);at.save(zr(this.point.gId,{cmdKey:"auxiliaryPoint",refId:i},{},this.point.toJSON())),this.point.destroy(),Ce.select([t]),at.saveBatch(),this.point=new KT(F.getInitialAuxiliaryPointData({gId:_t()}))}end(){var t,i;dt(de((t=this.point)==null?void 0:t.gId)),(i=this.point)==null||i.destroy(),this.point=null,Rd()}getRulerAuxiliaryXY(){let t={x:[],y:[]},{x:i,y:r}=this.point||{};if(i==null&&r==null)return t;let n=ft(Gt(i,"pixel",Xe.canvas.unit),2),s=ft(Gt(-r,"pixel",Xe.canvas.unit),2),a=Dg({x:i,y:r});return t.x.push({position:a.clientX,content:String(n)}),t.y.push({position:a.clientY,content:String(s)}),t}},KT=class{constructor(t){this.cmdKey="auxiliaryPoint";this.svg=Tt("circle",{c_partid:"auxiliaryPoint",r:Ru});for(let i in t)this[i]=t[i];Am(this.svg,Ru/J.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 $T=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=_t();return new dn({gId:t})}ready(){Xt(),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();F.setDimension(r.gId,r,"dimensionLength"),i.addOne(F.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 ZT=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=_t();this.current=new hn({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(F.getById(i.id).json,{},"dimensionAngle"),t.updateAndSave(),Ce.select([i]),_e("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 QT=class{constructor(t){this.panelDraw=t}ready(){this.current=null,Je.dots.length=0}draw(t,i,r){if(!this.current&&r){let n=oh(t,i),s=n[0];if(n.length===0){let o=vc(t,i);if(o.length===0)return;s=o[0]}let a=_t();this.current=new tn({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){Xt();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"),F.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 ew=class{constructor(t){this.panelDraw=t}createLine(t,i){this.helpLine=Tt("line",{fill:J.panelThemeCache.fillColor.arc,stroke:J.panelThemeCache.color.arc,"stroke-width":Gt(J.panelThemeCache.shape.arc.width||1,"mm","pixel"),opacity:.5,x1:t,y1:i,x2:t,y2:i}),J.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)re(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=lE.apply(null,a);if(!o)return;if(!this.data){let l=_t();this.data=F.getInitialArcData({gId:l,layer:tt.activeLayer||1,type:2,fillColor:J.panelThemeCache.fillColor.arc,strokeColor:J.panelThemeCache.color.arc,strokeWidth:Gt(J.panelThemeCache.shape.arc.width||1,"mm","pixel")}),Lt.enabled=!1,this.panelDraw.target=lh(this.data),Lt.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,re(this.panelDraw.target,"d",Pi.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?F.removeOne(s):(ja([s]),Xt(),Ce.select([s]))),r.started=!1,this.ready()}beforeStepBack(){let t=Je;this.ready(),F.removeOne(t.target),t.target=null}end(){let t=this.panelDraw.target;t&&F.removeOne(t),this.panelDraw.dots.length=0,this.ready()}};var tw=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 V(s,a).distance1(new V(t,i))/2,l=["M"+s+","+a,"A"+o+","+o,0,1,1,t+","+i].join(" ");if(!this.data){let c=_t();this.data=F.getInitialArcData({gId:c,layer:tt.activeLayer||1,type:2,x1:s,y1:a,fillColor:J.panelThemeCache.fillColor.arc,strokeColor:J.panelThemeCache.color.arc,strokeWidth:Gt(J.panelThemeCache.shape.arc.width||1,"mm","pixel")}),Lt.enabled=!1,n.target=lh(this.data),Lt.enabled=!0}this.data.x2=t,this.data.y2=i,this.data.rx=this.data.ry=o,ni.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?(ja([n]),Xt(),Ce.select(n),this.ready()):this.end())}end(){this.data&&F.removeMultiData([{id:this.data.gId}]),this.ready()}};var iw=class{constructor(t){this.opacityCircleId="opacityCircleId";this.panelDraw=t}createCircle(t,i){this.opacityCircle=Tt("circle",{cx:t,cy:i,r:0,id:this.opacityCircleId,fill:J.panelThemeCache.fillColor.arc||"none",stroke:J.panelThemeCache.color.arc||"black",opacity:.5,"stroke-width":Gt(J.panelThemeCache.shape.arc.width||1,"mm","pixel")}),J.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 V(n[0],n[1]);s===2&&r&&this.createCircle(a.x,a.y);let o=Bl(n[0],n[1],t,i);if(s===4){o=Bl(n[0],n[1],n[2],n[3]),r&&(ni.renderer.removeNode(this.opacityCircleId),this.data=F.getInitialArcData({gId:_t(),layer:tt.activeLayer||1,type:1,rx:o,ry:o,x1:n[2],y1:n[3],x2:n[2],y2:n[3],fillColor:J.panelThemeCache.fillColor.arc,strokeColor:J.panelThemeCache.color.arc,strokeWidth:Gt(J.panelThemeCache.shape.arc.width||1,"mm","pixel")}),Lt.enabled=!1,this.panelDraw.target=lh(this.data),Lt.enabled=!0);let l=new V(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 V(this.data.x1,this.data.y1).sub(a),u=new V(this.data.x2,this.data.y2).sub(a),h=c.cross(u);this.data.large=h>0?0:1,re(this.panelDraw.target,{d:Pi.getD(this.data)});return}if(s===6){this.panelDraw.next();return}re(this.opacityCircle,{r:o})}next(t,i,r){let n=this.panelDraw.dots.length,s=this.panelDraw.target;n===6?(ja([s]),Xt(),Ce.select([s])):n>2&&(ni.renderer.removeNode(this.data.gId),F.removeMultiData([{id:this.data.gId}])),ni.renderer.removeNode(this.opacityCircleId)}beforeStepBack(){let t=this.panelDraw.target;F.removeOne(t);let[i,r]=this.panelDraw.dots;this.createCircle(i,r)}end(){let t=this.panelDraw.target;t&&F.removeOne(t),ni.renderer.removeNode(this.opacityCircleId),this.ready()}};var Je=class extends Qs{constructor(t,i){super(),J.cmdToken=t,Je.ready(i),t!=="place_part(text)"&&_e("setTopBarItemChecked",[t])}getSymbol(){return br.draw}uninstall(){console.log(this.getSymbol(),"uninstalled"),Je.end(),Gr.cancel(),_1(),fs()}install(){console.log(this.getSymbol(),"installed"),Xt(),yh.switch(4)}static canSwitchMe(t){return J.cmdToken==="place_part(text)"?!0:J.cmdToken!==t}static ready(t){if(this.readyed)return;this.readyed=!0,Js(J.gCanvas,"events-none",!0);let{currAbsX:i,currAbsY:r}=Un.data;["place_auxiliary(crossLine)","place_auxiliary(horizontalLine)","place_auxiliary(verticalLine)"].includes(J.cmdToken)||xr("cross-red",i,r),fs(void 0,{x:i,y:r}),this.drawers(J.cmdToken).ready(t),jt.endEditingPath()}static drawers(t=J.cmdToken){if(this.activeDrawer)return this.activeDrawer;switch(t){case"draw(measure-length)":return this.activeDrawer=new $T(this);case"draw(measure-angle)":return this.activeDrawer=new ZT(this);case"draw(measure-radius)":return this.activeDrawer=new QT(this);case"draw(arc)":return this.activeDrawer=new ew(this);case"draw(arcCenter)":return this.activeDrawer=new iw(this);case"draw(arc2)":return this.activeDrawer=new tw(this);case"draw(pen)":return this.activeDrawer=new qT(this);case"draw(dimension-xy)":case"draw(dimension-x)":case"draw(dimension-y)":return Cg;case"draw(circle)":return U1;case"place_part(text)":return Lg;case"draw(ellipse)":return U1;case"draw(image)":return Hm;case"draw(polyline)":return VT;case"draw(polygon)":return zT;case"draw(rect)":return G1;case"draw(origin)":return Pd;case"place_auxiliary(point)":return this.activeDrawer=new JT(this),this.activeDrawer;case"place_auxiliary(crossLine)":case"place_auxiliary(verticalLine)":case"place_auxiliary(horizontalLine)":return nf;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=J.cmdToken,s=i.drawers(n);s&&s.onKeyDown&&s.onKeyDown(t)}onKeyUp(t){let{key:i}=t,r=Je;switch(i){case"Shift":Du.removeAuxiliaryLine(),r.lastToolContext.shiftKeyDown=!1,this.onMouseMove(r.lastToolContext,!1);break}if(!r.readyed)return;let n=J.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=J.cmdToken,s=i.drawers(n),{lastClickPoint:a}=i,{x:o,y:l}=Ti(t.originalEvent,!0),c=Du.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(!xo&&(i.target==document.documentElement||i.target==document.body))return;var a=n.dots;let o=Ti(i,!0),l=o.x,c=o.y,u=Du.overrideXY(r,s,l,c);if(l=u.x,c=u.y,n.started||(n.started=!0,a.length=0),n.drawers(J.cmdToken)&&typeof n.drawers(J.cmdToken).mouseupLeft=="function"){var h=n.drawers(J.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(J.contextmenuDisableOnce=!0,setTimeout(function(){J.contextmenuDisableOnce=!1},5),!xo&&(i.target==document.documentElement||i.target==document.body))return;let n=Ti(i,!0),s=n.x,a=n.y,o=r.drawers(J.cmdToken),l=o==null?void 0:o.mouseupRight;wp(l)&&l.call(o,i,t)===r.STATUSEXIT||(!J.cmdToken||!r.started||J.cmdToken.indexOf("place_part")===0||J.cmdToken==="draw(image)"||J.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&&Gr.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),kl.altKeyEnabled=n;var h,d;if(Xe.adsorbGrid.enabled||(h=Object.assign({},Xe.adsorbGrid),Object.assign(Xe.adsorbGrid,{distanceX:1,distanceY:1,enabled:!0}),d=function(){Object.assign(Xe.adsorbGrid,h)}),!xo&&(s.target==document.documentElement||s.target==document.body)){d&&d();return}if(c.drawers(J.cmdToken)&&typeof c.drawers(J.cmdToken).mousemove=="function"){var p=c.drawers(J.cmdToken).mousemove(s);if(p===c.STATUSEXIT){d&&d();return}}var f=l.dots;let{x:m,y:g}=Ti(s,!0),{cmdToken:x}=J;["draw(dimension-xy)"].includes(x)&&(o=!1);let y=Du.overrideXY(o,u,m,g);if(m=y.x,g=y.y,o&&!["draw(polyline)","draw(polygon)"].includes(x)&&Du.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(x)||ps(m,g),fs("",{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(J.cmdToken);typeof(i==null?void 0:i.mouseWheel)=="function"&&i.mouseWheel(t)}rotate(t){let i=Je;switch(J.cmdToken){case"draw(image)":Hm.rotate(t);break;case"place_part(text)":Lg.rotate(t);break;default:console.trace(J.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=J.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&&Xt(),this.drawers(J.cmdToken).next(t,i),this.target&&Ce.select([this.target]),this.target=null,this.dots.length=0,this.mockX=null,this.mockY=null,Mee(J.cmdToken),_e("panel_updateAttrPanel"),_e("panel/updateTreeActiveElements"),_e("forceRenderTree",Di.PANEL_OBJECT_ROOT_NODE)}static end(t){var i;(i=this.drawers(J.cmdToken))==null||i.end(t),this.mockX=null,this.mockY=null,this.target=null,this.started=!1,this.dots.length=0,this.readyed=!1,_e("setTopBarItemChecked"),_e("updateMenuByDocStatus"),xr(),Du.removeAuxiliaryLine(),Lt.clearAdsorptionHTML(),Lt.updateDrawingShapeCache(null),Bo(),this.activeDrawer=null,tT(),fs()}static restart(){var i;!this.started||!this.dots.length?this.end(27):J.cmdToken==="draw(pen)"?this.next():(i=this.drawers(J.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=La([Ea(gn.draw)],Je);function Mee(e){let t=tt.currentScheme.options.some(r=>r.actived===!0),i=!1;e==="place_part(text)"?tt.activeLayer!==1&&tt.activeLayer!==2&&(i=!0):e==="draw(image)"&&(i=!0),(!t||i)&&J.windowBridge.rpcCall("switchActiveLayer",[1,{notSaveHistory:!0}],ut())}function ja(e){let t=new oi;if(Kt.isEditing()){let i=Kt.getCurrentEditingComId();t.addOneCombineByComId(i),F.getCombination(i).elements.push(...e.map(n=>n.id)),new $i().updateHole()}e.forEach(i=>{t.addOne(F.getById(i.id).json,{})}),t.updateAndSave()}function ud(e,t=Object()){e||Hr(e),!Ls.ready&&(Lt.clearAdsorptionHTML(),Lt.updateDrawingShapeCache(null),J.frameHelper.getToolProcessor().switchToDrawTool(e,t))}function tT(){J.cmdToken=""}function Jp(){No.running?No.instance.cancel():J.cmdToken&&Je.end()}var fs=AI((e,t)=>{var l,c,u;let i;e&&(i=Ti(e,!1)),!t&&i&&(t=ol(i));let r=t?Dg(t):{clientX:0,clientY:0},n=window.frameElement.getBoundingClientRect(),s={left:n.left,top:n.top},a=J.cmdToken==="draw(arc)"?"draw(arc3)":J.cmdToken,o={left:r.clientX+s.left,top:r.clientY+s.top,cmdToken:a,selectionMode:D1(),color:(u=(c=(l=J)==null?void 0:l.panelThemeCache)==null?void 0:c.color)==null?void 0:u.select,copyType:Ir.ready?Ir.pasteFrom:void 0};_e("updateCursorIcon",[o])});var J5,K5,$5,mi=class e{static init(){J5=de("gridBg"),K5=de("gridOH"),$5=de("gridOV"),J.selectBox1=de("selectBox1"),J.gControlDots=de("gControlDots"),J.gControlRects=de("gControlRects"),J.gControlLines=de("gControlLines"),J.gCanvas=de("g1")}static clear(){Jp(),Xt(),rN(J.gCanvas)}static initCanvasSize(t){let i=document.documentElement.clientWidth,r=document.documentElement.clientHeight,n=Xe.canvas.originX,s=Xe.canvas.originY;re(J.svgRoot,{width:i,height:r,viewBox:[n-i/2,s-r/2,i,r].join(" ")}),t.tabId&&(J.tabId=t.tabId)}static getCanvasAttrs(){let t=F.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=F.gJsonCache,r=!1,n=e.getCanvasAttrs(),{gridType:s}=Xe.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=Dw[c].thickness[0],a.craft=Dw[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,Xe.canvas.bgColor=c}break;case"attr-canvas-grid-visible":let u=c&&c!=="none";Xe.adsorbGrid.visible=u,re(de("gridBg"),"display",u?"":"none");break;case"attr-canvas-grid-color":{let h=de("gridCell"),d=de("gridOH"),p=de("gridOV"),f=(o=BR[s])==null?void 0:o.modifyProp;f&&re(h,{[f]:c}),re(d,"stroke",c),re(p,"stroke",c),Xe.canvas.gridColor=c;break}case"attr-canvas-grid-size":{let h=de("gridPattern"),d=de("gridCell"),p=MT(+c),f={width:p*nn,height:p*nn};re(h,f),re(d,{transform:he.toDOMMatrix(he.scale(p/+c))});let[m,g]=Zr("path",d);if(s==="line")re(m,{d:Fo.getGridLinePathDFor1(+c)}),re(g,{d:Fo.getGridLinePathDFor10(+c)});else{let x=p/+c*J.gZoom;re(m,{d:Fo.getGridPointPathDFor1(+c,Fo.getGridPointRadius(x))}),re(g,{d:Fo.getGridPointPathDFor10(+c,Fo.getGridPointRadius(x))})}Xe.adsorbGrid.gridSize=+c;break}case"attr-canvas-snap-size":nd("adsorbGrid","distanceX",+c),nd("adsorbGrid","distanceY",+c),Qe(t,"attr-canvas-snap")||(Xe.adsorbGrid.enabled=+c>1e-4);break;case"attr-canvas-snap":Xe.adsorbGrid.enabled=c=="yes";break;case"attr-canvas-alt-snap-size":Xe.adsorbGrid.altSnapSize=+c||1;break;case"attr-canvas-grid-style":{let h={gridColor:"#FFFFFF"};if(Xe.adsorbGrid.gridType=c,c==="not")break;let d=de("gridCell"),p=Xe.canvas.gridColor||h.gridColor,f=MT();if(re(d,{transform:he.toDOMMatrix(he.scale(f/Xe.adsorbGrid.gridSize)),width:f*nn,height:f*nn,fill:p,type:"dot"}),c==="dot"){let m=f/Xe.adsorbGrid.gridSize*J.gZoom;d.innerHTML=Fo.getGridPointSVGHTML(void 0,Fo.getGridPointRadius(m))}else d.innerHTML=Fo.getGridLineSVGHTML();re(de("gridPattern"),{width:f*nn,height:f*nn}),re(de("gridBg"),"fill","url(#gridPattern)");break}case"attr-direction":{e.setCanvasWidthHeight(a.width,a.height,c);break}default:break}}r&&(F.compilerManager.uploadData("canvas"),fn("triggerEvent",["history_change",{tabId:J.tabId},at.records.length,at.index.value,!0])),J.windowBridge.publish("ui/canvasInfo",{tabId:J.tabId,scaleValue:+(J.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=gN(s,a);[s,a]=l,[t,i]=l.map(c=>`${c}mm`)}F.setHead({width:t,height:i}),new Xa().update(),n&&bn().fitview()}static async modify_json(t,i){for(let r in t){if(!Qe(t,r))continue;let n=t[r];switch(r){case"attr-canvas-name":i.head.title=n;break;default:break}}}static getViewBox(){return re(J.svgRoot,"viewBox").split(" ").map(parseFloat)}static setViewBox([t,i,r,n]){re(J.svgRoot,"viewBox",[t,i,r,n].join(" ")),re(J5,{x:t,y:i,width:r,height:n}),re(K5,{x1:t,x2:t+r}),re($5,{y1:i,y2:i+n}),Bc([t,i,r,n],Kp()),TE(Object.values(F.getAuxiliaryLine()).map(s=>({data:s,view:de(s.gId)})),new xt(t,t+r,i,i+n).extendOfSize(GD))}};function CC(){let e={"attr-canvas-width":1e3,"attr-canvas-height":1e3,"attr-canvas-bgcolor":J.panelThemeCache.color.background,"attr-canvas-grid-visible":Xe.adsorbGrid.visible,"attr-canvas-grid-color":J.panelThemeCache.color.grid,"attr-canvas-grid-size":Xe.adsorbGrid.gridSize||ya(10),"attr-canvas-grid-style":Xe.adsorbGrid.gridType,"attr-canvas-snap-size":Xe.adsorbGrid.distanceX,"attr-canvas-alt-snap-size":Xe.adsorbGrid.altSnapSize};mi.modify_canvas(e)}function R5({type:e,button:t}){if(t!==kD)return;let i=new MouseEvent(e,{button:t});document.dispatchEvent(i)}var rw=class{get gridType(){return Xe.adsorbGrid.gridType||J.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"),mi.modify_canvas(t)}};var J={openDocComplete:!1,topMenuStatus:new rw,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:mc?Number.NEGATIVE_INFINITY:5,max:mc?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},Ml="shapeBox",nw=[1,2,3,4,5,6,7],O1={text:[1,2],rect:nw,ellipse:nw,group:nw,arc:nw,obj:[1],dimension:[8],dimensionLength:[8],dimensionAngle:[8],dimensionRadius:[8],auxiliaryLine:[8],auxiliaryPoint:[8]};function jm(){return[6,5,1,2,7,3,4,8,-1]}function cT(){let e=new Map;return jm().forEach((i,r)=>{e.set(i,r)}),e}var Z5;Object.defineProperty(J,"helperCursor",{set(e){return console.warn("helperCursor",e),Z5=e,!0},get(){return Z5}});function _t(){return"e"+Wl()}var iD;function P1(e){if(iD)return Qe(iD,String(e))?iD[e]:null;try{return localStorage.getItem(e)}catch{return null}}function Ha(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 _5(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 TM(e){for(let t of e)dt(de(t))}function tD(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 UT(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 FN(e){let t=!1;return function(){t||(t=!0,e.apply(this,arguments))}}function Cu(e,t){return t=t||J,t.decimalPlacesShow=t.decimalPlacesShow!==void 0?t.decimalPlacesShow:2,ft(e,t.decimalPlacesShow,t.fixedDecimal)}function Pp(e,t){return t=t&&typeof t.decimalPlaces=="number"?t:J,ft(e,t.decimalPlaces)}function QC(e,t,i){if(!t){console.error("\u4EE3\u7801\u51FA\u9519\uFF0C\u8BF7\u68C0\u67E5");return}e=e||J.gCanvas,typeof i=="string"&&(i=de(i)),i?e.insertBefore(t,i):e.appendChild(t)}function Q5(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}function f5(e,t){return Q5(e,t,()=>[])}function Ji(e,t){return Q5(e,t,()=>({}))}function Go(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&&eo(s,(a,o)=>{i.setAttribute(`i18n-params-${a}`,o+"")}),i.outerHTML}function AI(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 Qa(){return 3/J.gZoom}function Q4(e,t,i=!1){let r=[];for(let n=0;n<e.length;n++){let s=e[n],a=t(s);Fa(a)||(r.push(a),i&&(e.splice(n,1),--n))}return r}function wT(e){if(window.frameElement)return J.windowBridge.publish("showMessager",[e],ut());J.messageBus.publish("showMessager",[e])}function ZB(e,t){let i=document.createElement("a");i.download=t,i.href=URL.createObjectURL(e),i.click(),i=null}var ek={top:[0,-90,0],bottom:[0,90,180],left:[-90,0,0],right:[90,0,0],front:[0,0,0],back:[180,0,0]},Bee=39.37,kee="0";function rD(e){return parseFloat(e)*Bee}function Y1(e){In.head&&e&&Object.assign(In.head,e)}var sn=class sn{static async init(){let t="canvas";try{await Rr("/engine/init",t),await Rr("/engine/camera/add",["0",-1,1,-1,1]),await Rr("/engine/camera/set3DType",["0",!1]),await Rr("/engine/pcb/setMode",1),await Rr("/engine/setLayerDistance",rD(sn.layerDistance))}catch(i){console.error("panel 3d init error",i)}}static async loadData(t){let{blobStr:i,dataStr:r,head:n}=t;if(!r||!n)return;In.head=n;let{message:s}=await Rr("/engine/loadData",[r,!0]),a=s.map(l=>l.id);sn.availableLayers=a,i&&await Rr("/engine/layer/loadBlob",i),sn.setLayerVisible(5,!1),await Rr("/engine/camera/adapt","0"),sn.setCoverColor(n.coverColor);let o=n.coverColor=="black";sn.setLayerVisible(3,o)}static isLayerAvailable(t){var r;return!(((r=In.head)==null?void 0:r.coverColor)=="black")&&t==3?!1:sn.availableLayers.includes(t)}static setLayerVisible(t,i){sn.isLayerAvailable(t)&&Rr("/engine/layer/setVisible",[t,i])}static setLayerDistance(t){let i=parseFloat(t);isNaN(i)||(sn.layerDistance=Cu(i)+sn.lengthUnit,Rr("/engine/setLayerDistance",rD(t)))}static setMaterial(t){let i=fT(t);if(!i)return;let{material:r,craft:n}=t;!r||!n||(Y1({material:r,craft:n}),sn.isLayerAvailable(4)&&Rr("/engine/layer/setMaterial",[4,i]))}static setThickness(t){let i=parseFloat(t);if(isNaN(i))return;let r=rD(t);Y1({thickness:t}),sn.isLayerAvailable(4)&&Rr("/engine/layer/setThickness",[4,r])}static setCoverColor(t){var i;t&&(Y1({coverColor:t}),sn.setPrintMethod((i=In.head)==null?void 0:i.print))}static setBackgroundColor(t){t&&Y1({backgroundColor:t})}static setPrintMethod(t){var o;if(!t)return;Y1({print:t});let i=[[7],[1],[2],[3],[4],[5],[6]],r=[[4],[7],[1],[2],[3],[5],[6]],s=t!="Bottom Side"?i:r;((o=In.head)==null?void 0:o.coverColor)=="black"||(s=s.filter(l=>l[0]!=3)),s=s.filter(l=>sn.isLayerAvailable(l[0])),Rr("/engine/layer/setOrder",s)}static async toggle3DView(t){var i;if(t in ek)await Rr("/engine/camera/set3DType",["0",!0]),await Rr("/engine/camera/rotateTo",["0",...ek[t]]),await Rr("/engine/camera/adapt","0"),await Rr("/engine/setAbleRender",!0);else switch(t){case"refresh":await Rr("/engine/camera/set3DType",["0",!1]),await Rr("/engine/camera/rotateTo",["0",0,-45,0]),await Rr("/engine/camera/adapt","0"),await Rr("/engine/setAbleRender",!0);break;case"adaptAll":await Rr("/engine/camera/adapt","0"),await Rr("/engine/setAbleRender",!0);break;case"normal":await Rr("/engine/pcb/setMode",1),await Rr("/engine/model/setRenderMode",0),em("UIswitch3dView","normal"),sn.setPrintMethod((i=In.head)==null?void 0:i.print);break;case"outline":await Rr("/engine/pcb/setMode",2),await Rr("/engine/model/setRenderMode",1),em("UIswitch3dView","outline");break;case"gerber":Rr("/engine/pcb/setMode",0),Rr("/engine/model/setRenderMode",0),em("UIswitch3dView","gerber");break;default:console.error("unsupported command",t)}}static zoom(t){Rr("/engine/camera/mulScale",["0",t])}static getCanvasAttrs(t){if(t=t||In.head,!t)return{};let{name:i,width:r,height:n,coverColor:s,material:a,craft:o,print:l,thickness:c,backgroundColor:u}=t,h={cmdKey:"canvas","attr-topic":"Page","attr-name":i||"","attr-background-color":u||"#CCCCCC","attr-material":a||"","attr-thickness":c||"","attr-craft":o||"","attr-print":l||"","attr-cover-color":s||"white","attr-width":r||"","attr-height":n||"","attr-layer-distance":sn.layerDistance};for(let d of["attr-material","attr-thickness","attr-craft","attr-print"])h[d]||(h[d]=MR.canvas[0].attr[d].options[0]);return h}static attrApply(t,i){if(!In.head)return{};switch(t){case"attr-layer-distance":{i>=0&&sn.setLayerDistance(i);break}case"attr-material":{let{material:r,craft:n,thickness:s}=i;sn.setMaterial({material:r,craft:n}),sn.setThickness(s);break}case"attr-craft":{let{material:r}=In.head,n=i;sn.setMaterial({material:r,craft:n});break}case"attr-thickness":{sn.setThickness(i);break}case"attr-cover-color":{sn.setCoverColor(i);break}case"attr-background-color":{sn.setBackgroundColor(i);break}case"attr-print":{sn.setPrintMethod(i);break}}}};sn.activeLayer=1,sn.availableLayers=[],sn.layerDistance=kee,sn.lengthUnit="mm";var Uo=sn;var tk={setTabId:function(e){In.tabId=e},attrGetData(){if(!In.head)return{};let e=Uo.getCanvasAttrs();return Object.assign({target:{[In.tabId]:{canvas:{cmdKey:"canvas"}}},docType:gs.PANEL3D,cmdKey:"canvas"},e)}},ik={"-panel/getDocStatus":()=>{},"-setTabId"(e){In.tabId=e},"-/panel/3d/setSrcTabId":e=>{In.srcTabid=e},"-/panel/3d/loadData":async e=>{await Uo.loadData(e)},"-panel/3d/layerConfig":()=>In.layerConfig,"-panel/3d/getHead":()=>In.head||{},closeDocsByHashIds:()=>{},openArchiveProject:()=>{},"/panel/3d/setLayerConfig":e=>{In.layerConfig=e},"/panel/3d/attrApply":e=>{let{name:t,value:i}=e;Uo.attrApply(t,i)},"/panel/3d/setLayerVisible":e=>{let{layer:t,visible:i,id:r}=e;Uo.setLayerVisible(t||r,i)},"zoom(in)":function(){Uo.zoom(1.5)},"zoom(out)":function(){Uo.zoom(1/1.5)},"-toggleView(importChanges)":async()=>{let{message:e}=await fx.rpcCall("/panel/3d/source",{tabId:In.srcTabid},ut()),{dataStr:t}=e;if(t){await cp.rpcCall("/panel/3d/loadData",e);for(let i of In.layerConfig){let{layer:r,visible:n,id:s}=i;Uo.setLayerVisible(r||s,n)}cp.publish("/panel/3d/printMethodChanged",e.head.print)}},async"-Preview3D"(e){await Uo.loadData(e)},toggle3DView:function(e){Uo.toggle3DView(e.cmd)}};In.doctype=gs.PANEL3D;window.addEventListener("load",function(){console.log("panel 3d window load"),window.loaded=!0,wR("triggerEvent",["editor_load"])},!1);document.addEventListener("click",function(e){TR("triggerClick",e&&e.type)},!1);Uo.init();B0.registerHook(tk);window.callCommand=B0;SR(ik);em("setTabActive",[In.tabId]);})();
/*! 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
   *)

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/panel3d.js.map
