!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/x6")):"function"==typeof define&&define.amd?define(["exports","@antv/x6"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).X6PluginClipboard={},t.X6)}(this,(function(t,e){"use strict";class i{constructor(){this.cells=[]}copy(t,i,s={}){this.options=Object.assign({},s);const o=(e.Model.isModel(i)?i:i.model).cloneSubGraph(t,s);this.cells=e.ArrayExt.sortBy(Object.keys(o).map((t=>o[t])),(t=>t.isEdge()?2:1)),this.serialize(s)}cut(t,i,s={}){this.copy(t,i,s);(e.Graph.isGraph(i)?i.model:i).batchUpdate("cut",(()=>{t.forEach((t=>t.remove()))}))}paste(t,i={}){const s=Object.assign(Object.assign({},this.options),i),{offset:o,edgeProps:n,nodeProps:l}=s;let r=20,a=20;o&&(r="number"==typeof o?o:o.dx,a="number"==typeof o?o:o.dy),this.deserialize(s);const c=this.cells;c.forEach((t=>{t.model=null,t.removeProp("zIndex"),(r||a)&&t.translate(r,a),l&&t.isNode()&&t.prop(l),n&&t.isEdge()&&t.prop(n)}));const p=e.Graph.isGraph(t)?t.model:t;return p.batchUpdate("paste",(()=>{p.addCells(this.cells)})),this.copy(c,t,i),c}serialize(t){!1!==t.useLocalStorage&&s.save(this.cells)}deserialize(t){if(t.useLocalStorage){const t=s.fetch();t&&(this.cells=t)}}isEmpty(t={}){return t.useLocalStorage&&this.deserialize(t),this.cells.length<=0}clean(){this.options={},this.cells=[],s.clean()}}var s;!function(t){const i=`${e.Config.prefixCls}.clipboard.cells`;t.save=function(t){if(window.localStorage){const e=t.map((t=>t.toJSON()));localStorage.setItem(i,JSON.stringify(e))}},t.fetch=function(){if(window.localStorage){const t=localStorage.getItem(i),s=t?JSON.parse(t):[];if(s)return e.Model.fromJSON(s)}},t.clean=function(){window.localStorage&&localStorage.removeItem(i)}}(s||(s={})),e.Graph.prototype.isClipboardEnabled=function(){const t=this.getPlugin("clipboard");return!!t&&t.isEnabled()},e.Graph.prototype.enableClipboard=function(){const t=this.getPlugin("clipboard");return t&&t.enable(),this},e.Graph.prototype.disableClipboard=function(){const t=this.getPlugin("clipboard");return t&&t.disable(),this},e.Graph.prototype.toggleClipboard=function(t){const e=this.getPlugin("clipboard");return e&&e.toggleEnabled(t),this},e.Graph.prototype.isClipboardEmpty=function(t){const e=this.getPlugin("clipboard");return!e||e.isEmpty(t)},e.Graph.prototype.getCellsInClipboard=function(){const t=this.getPlugin("clipboard");return t?t.getCellsInClipboard():[]},e.Graph.prototype.cleanClipboard=function(){const t=this.getPlugin("clipboard");return t&&t.clean(),this},e.Graph.prototype.copy=function(t,e){const i=this.getPlugin("clipboard");return i&&i.copy(t,e),this},e.Graph.prototype.cut=function(t,e){const i=this.getPlugin("clipboard");return i&&i.cut(t,e),this},e.Graph.prototype.paste=function(t,e){const i=this.getPlugin("clipboard");return i?i.paste(t,e):[]};class o extends e.Basecoat{get disabled(){return!0!==this.options.enabled}get cells(){return this.clipboardImpl.cells}constructor(t={}){super(),this.name="clipboard",this.options=Object.assign({enabled:!0},t)}init(t){this.graph=t,this.clipboardImpl=new i,this.clipboardImpl.deserialize(this.options)}isEnabled(){return!this.disabled}enable(){this.disabled&&(this.options.enabled=!0)}disable(){this.disabled||(this.options.enabled=!1)}toggleEnabled(t){return null!=t?t!==this.isEnabled()&&(t?this.enable():this.disable()):this.isEnabled()?this.disable():this.enable(),this}isEmpty(t={}){return this.clipboardImpl.isEmpty(t)}getCellsInClipboard(){return this.cells}clean(t){return this.disabled&&!t||(this.clipboardImpl.clean(),this.notify("clipboard:changed",{cells:[]})),this}copy(t,e={}){return this.disabled||(this.clipboardImpl.copy(t,this.graph,Object.assign(Object.assign({},this.commonOptions),e)),this.notify("clipboard:changed",{cells:t})),this}cut(t,e={}){return this.disabled||(this.clipboardImpl.cut(t,this.graph,Object.assign(Object.assign({},this.commonOptions),e)),this.notify("clipboard:changed",{cells:t})),this}paste(t={},e=this.graph){return this.disabled?[]:this.clipboardImpl.paste(e,Object.assign(Object.assign({},this.commonOptions),t))}get commonOptions(){return function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(this.options,["enabled"])}notify(t,e){this.trigger(t,e),this.graph.trigger(t,e)}dispose(){this.clean(!0),this.off()}}!function(t,e,i,s){var o,n=arguments.length,l=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,i,s);else for(var r=t.length-1;r>=0;r--)(o=t[r])&&(l=(n<3?o(l):n>3?o(e,i,l):o(e,i))||l);n>3&&l&&Object.defineProperty(e,i,l)}([e.Basecoat.dispose()],o.prototype,"dispose",null),t.Clipboard=o}));
