json-canvas-viewer 3.2.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +114 -51
  2. package/dist/bridges.cjs +2 -0
  3. package/dist/bridges.cjs.map +1 -0
  4. package/dist/bridges.js +2 -0
  5. package/dist/bridges.js.map +1 -0
  6. package/dist/chimp.cjs +1 -0
  7. package/dist/chimp.js +1 -0
  8. package/dist/controller--Q72jFEw.cjs +2 -0
  9. package/dist/controller--Q72jFEw.cjs.map +1 -0
  10. package/dist/controller-siZ5v-SD.js +2 -0
  11. package/dist/controller-siZ5v-SD.js.map +1 -0
  12. package/dist/dev.cjs +2 -0
  13. package/dist/dev.cjs.map +1 -0
  14. package/dist/dev.js +2 -0
  15. package/dist/dev.js.map +1 -0
  16. package/dist/index-BSkMdAcV.cjs +2 -0
  17. package/dist/index-BSkMdAcV.cjs.map +1 -0
  18. package/dist/index-u8PUIMyl.js +2 -0
  19. package/dist/index-u8PUIMyl.js.map +1 -0
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/modules.cjs +2 -0
  25. package/dist/modules.cjs.map +1 -0
  26. package/dist/modules.js +2 -0
  27. package/dist/modules.js.map +1 -0
  28. package/dist/renderer-CZ85ZN6O.js +2 -0
  29. package/dist/renderer-CZ85ZN6O.js.map +1 -0
  30. package/dist/renderer-D9iInH9_.cjs +2 -0
  31. package/dist/renderer-D9iInH9_.cjs.map +1 -0
  32. package/dist/types/bridges/renderToString.d.ts +6 -0
  33. package/dist/types/bridges/vitePlugin.d.ts +8 -0
  34. package/dist/types/bridges/vueComponent.vue.d.ts +23 -0
  35. package/dist/types/bridges.d.ts +3 -0
  36. package/dist/types/chimp.d.ts +7 -0
  37. package/dist/types/core/baseModule.d.ts +15 -0
  38. package/dist/types/{controller.d.ts → core/controller.d.ts} +5 -9
  39. package/dist/types/{dataManager.d.ts → core/dataManager.d.ts} +17 -17
  40. package/dist/types/{declarations.d.ts → core/declarations.d.ts} +29 -15
  41. package/dist/types/core/index.d.ts +14 -0
  42. package/dist/types/{interactionHandler.d.ts → core/interactionHandler.d.ts} +3 -3
  43. package/dist/types/{overlayManager.d.ts → core/overlayManager.d.ts} +4 -4
  44. package/dist/types/{renderer.d.ts → core/renderer.d.ts} +1 -1
  45. package/dist/types/{utilities.d.ts → core/utilities.d.ts} +2 -3
  46. package/dist/types/dev.d.ts +8 -0
  47. package/dist/types/index.d.ts +2 -20
  48. package/dist/types/{controls → modules/controls}/index.d.ts +2 -2
  49. package/dist/types/{debugPanel → modules/debugPanel}/index.d.ts +2 -2
  50. package/dist/types/{minimap → modules/minimap}/index.d.ts +3 -3
  51. package/dist/types/{mistouchPreventer → modules/mistouchPreventer}/index.d.ts +2 -2
  52. package/dist/types/modules.d.ts +4 -0
  53. package/package.json +35 -9
  54. package/dist/types/baseModule.d.ts +0 -11
  55. package/dist/types/canvasViewer.d.ts +0 -22
  56. package/dist/types/renderToString.d.ts +0 -2
  57. package/dist/types/shared.d.ts +0 -1
package/dist/chimp.js ADDED
@@ -0,0 +1 @@
1
+ const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:i,getOwnPropertyDescriptor:s}=Object;let{freeze:r,seal:o,create:a}=Object,{apply:l,construct:c}="undefined"!=typeof Reflect&&Reflect;r||(r=function(e){return e}),o||(o=function(e){return e}),l||(l=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return e.apply(t,i)}),c||(c=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const h=S(Array.prototype.forEach),p=S(Array.prototype.lastIndexOf),u=S(Array.prototype.pop),d=S(Array.prototype.push),m=S(Array.prototype.splice),f=S(String.prototype.toLowerCase),g=S(String.prototype.toString),x=S(String.prototype.match),b=S(String.prototype.replace),k=S(String.prototype.indexOf),w=S(String.prototype.trim),v=S(Object.prototype.hasOwnProperty),y=S(RegExp.prototype.test),T=(C=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c(C,t)});var C;function S(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return l(e,t,i)}}function E(e,i){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:f;t&&t(e,null);let r=i.length;for(;r--;){let t=i[r];if("string"==typeof t){const e=s(t);e!==t&&(n(i)||(i[r]=e),t=e)}e[t]=!0}return e}function _(e){for(let t=0;t<e.length;t++){v(e,t)||(e[t]=null)}return e}function M(t){const n=a(null);for(const[i,s]of e(t)){v(t,i)&&(Array.isArray(s)?n[i]=_(s):s&&"object"==typeof s&&s.constructor===Object?n[i]=M(s):n[i]=s)}return n}function z(e,t){for(;null!==e;){const n=s(e,t);if(n){if(n.get)return S(n.get);if("function"==typeof n.value)return S(n.value)}e=i(e)}return function(){return null}}const R=r(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),A=r(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),D=r(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),L=r(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),I=r(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),N=r(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),O=r(["#text"]),P=r(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),$=r(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),B=r(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),F=r(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),H=o(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y=o(/<%[\w\W]*|[\w\W]*%>/gm),U=o(/\$\{[\w\W]*/gm),X=o(/^data-[\-\w.\u00B7-\uFFFF]+$/),V=o(/^aria-[\-\w]+$/),j=o(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),q=o(/^(?:\w+script|data):/i),W=o(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),G=o(/^html$/i),Z=o(/^[a-z][.\w]*(-[.\w]+)+$/i);var Q=/* @__PURE__ */Object.freeze({__proto__:null,ARIA_ATTR:V,ATTR_WHITESPACE:W,CUSTOM_ELEMENT:Z,DATA_ATTR:X,DOCTYPE_NAME:G,ERB_EXPR:Y,IS_ALLOWED_URI:j,IS_SCRIPT_OR_DATA:q,MUSTACHE_EXPR:H,TMPLIT_EXPR:U});const K=1,J=3,ee=7,te=8,ne=9;var ie=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const i=e=>t(e);if(i.version="3.3.1",i.removed=[],!n||!n.document||n.document.nodeType!==ne||!n.Element)return i.isSupported=!1,i;let{document:s}=n;const o=s,l=o.currentScript,{DocumentFragment:c,HTMLTemplateElement:C,Node:S,Element:_,NodeFilter:H,NamedNodeMap:Y=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:U,DOMParser:X,trustedTypes:V}=n,q=_.prototype,W=z(q,"cloneNode"),Z=z(q,"remove"),ie=z(q,"nextSibling"),se=z(q,"childNodes"),re=z(q,"parentNode");if("function"==typeof C){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let oe,ae="";const{implementation:le,createNodeIterator:ce,createDocumentFragment:he,getElementsByTagName:pe}=s,{importNode:ue}=o;let de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof e&&"function"==typeof re&&le&&void 0!==le.createHTMLDocument;const{MUSTACHE_EXPR:me,ERB_EXPR:fe,TMPLIT_EXPR:ge,DATA_ATTR:xe,ARIA_ATTR:be,IS_SCRIPT_OR_DATA:ke,ATTR_WHITESPACE:we,CUSTOM_ELEMENT:ve}=Q;let{IS_ALLOWED_URI:ye}=Q,Te=null;const Ce=E({},[...R,...A,...D,...I,...O]);let Se=null;const Ee=E({},[...P,...$,...B,...F]);let _e=Object.seal(a(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Me=null,ze=null;const Re=Object.seal(a(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ae=!0,De=!0,Le=!1,Ie=!0,Ne=!1,Oe=!0,Pe=!1,$e=!1,Be=!1,Fe=!1,He=!1,Ye=!1,Ue=!0,Xe=!1,Ve=!0,je=!1,qe={},We=null;const Ge=E({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ze=null;const Qe=E({},["audio","video","img","source","image","track"]);let Ke=null;const Je=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),et="http://www.w3.org/1998/Math/MathML",tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";let it=nt,st=!1,rt=null;const ot=E({},[et,tt,nt],g);let at=E({},["mi","mo","mn","ms","mtext"]),lt=E({},["annotation-xml"]);const ct=E({},["title","style","font","a","script"]);let ht=null;const pt=["application/xhtml+xml","text/html"];let ut=null,dt=null;const mt=s.createElement("form"),ft=function(e){return e instanceof RegExp||e instanceof Function},gt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!dt||dt!==e){if(e&&"object"==typeof e||(e={}),e=M(e),ht=-1===pt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,ut="application/xhtml+xml"===ht?g:f,Te=v(e,"ALLOWED_TAGS")?E({},e.ALLOWED_TAGS,ut):Ce,Se=v(e,"ALLOWED_ATTR")?E({},e.ALLOWED_ATTR,ut):Ee,rt=v(e,"ALLOWED_NAMESPACES")?E({},e.ALLOWED_NAMESPACES,g):ot,Ke=v(e,"ADD_URI_SAFE_ATTR")?E(M(Je),e.ADD_URI_SAFE_ATTR,ut):Je,Ze=v(e,"ADD_DATA_URI_TAGS")?E(M(Qe),e.ADD_DATA_URI_TAGS,ut):Qe,We=v(e,"FORBID_CONTENTS")?E({},e.FORBID_CONTENTS,ut):Ge,Me=v(e,"FORBID_TAGS")?E({},e.FORBID_TAGS,ut):M({}),ze=v(e,"FORBID_ATTR")?E({},e.FORBID_ATTR,ut):M({}),qe=!!v(e,"USE_PROFILES")&&e.USE_PROFILES,Ae=!1!==e.ALLOW_ARIA_ATTR,De=!1!==e.ALLOW_DATA_ATTR,Le=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ie=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Ne=e.SAFE_FOR_TEMPLATES||!1,Oe=!1!==e.SAFE_FOR_XML,Pe=e.WHOLE_DOCUMENT||!1,Fe=e.RETURN_DOM||!1,He=e.RETURN_DOM_FRAGMENT||!1,Ye=e.RETURN_TRUSTED_TYPE||!1,Be=e.FORCE_BODY||!1,Ue=!1!==e.SANITIZE_DOM,Xe=e.SANITIZE_NAMED_PROPS||!1,Ve=!1!==e.KEEP_CONTENT,je=e.IN_PLACE||!1,ye=e.ALLOWED_URI_REGEXP||j,it=e.NAMESPACE||nt,at=e.MATHML_TEXT_INTEGRATION_POINTS||at,lt=e.HTML_INTEGRATION_POINTS||lt,_e=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ft(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(_e.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ft(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(_e.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(_e.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ne&&(De=!1),He&&(Fe=!0),qe&&(Te=E({},O),Se=[],!0===qe.html&&(E(Te,R),E(Se,P)),!0===qe.svg&&(E(Te,A),E(Se,$),E(Se,F)),!0===qe.svgFilters&&(E(Te,D),E(Se,$),E(Se,F)),!0===qe.mathMl&&(E(Te,I),E(Se,B),E(Se,F))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?Re.tagCheck=e.ADD_TAGS:(Te===Ce&&(Te=M(Te)),E(Te,e.ADD_TAGS,ut))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?Re.attributeCheck=e.ADD_ATTR:(Se===Ee&&(Se=M(Se)),E(Se,e.ADD_ATTR,ut))),e.ADD_URI_SAFE_ATTR&&E(Ke,e.ADD_URI_SAFE_ATTR,ut),e.FORBID_CONTENTS&&(We===Ge&&(We=M(We)),E(We,e.FORBID_CONTENTS,ut)),e.ADD_FORBID_CONTENTS&&(We===Ge&&(We=M(We)),E(We,e.ADD_FORBID_CONTENTS,ut)),Ve&&(Te["#text"]=!0),Pe&&E(Te,["html","head","body"]),Te.table&&(E(Te,["tbody"]),delete Me.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw T('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw T('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');oe=e.TRUSTED_TYPES_POLICY,ae=oe.createHTML("")}else void 0===oe&&(oe=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const s="dompurify"+(n?"#"+n:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(r){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(V,l)),null!==oe&&"string"==typeof ae&&(ae=oe.createHTML(""));r&&r(e),dt=e}},xt=E({},[...A,...D,...L]),bt=E({},[...I,...N]),kt=function(e){d(i.removed,{element:e});try{re(e).removeChild(e)}catch(t){Z(e)}},wt=function(e,t){try{d(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(n){d(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Fe||He)try{kt(t)}catch(n){}else try{t.setAttribute(e,"")}catch(n){}},vt=function(e){let t=null,n=null;if(Be)e="<remove></remove>"+e;else{const t=x(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ht&&it===nt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const i=oe?oe.createHTML(e):e;if(it===nt)try{t=(new X).parseFromString(i,ht)}catch(o){}if(!t||!t.documentElement){t=le.createDocument(it,"template",null);try{t.documentElement.innerHTML=st?ae:i}catch(o){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(s.createTextNode(n),r.childNodes[0]||null),it===nt?pe.call(t,Pe?"html":"body")[0]:Pe?t.documentElement:r},yt=function(e){return ce.call(e.ownerDocument||e,e,H.SHOW_ELEMENT|H.SHOW_COMMENT|H.SHOW_TEXT|H.SHOW_PROCESSING_INSTRUCTION|H.SHOW_CDATA_SECTION,null)},Tt=function(e){return e instanceof U&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof Y)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Ct=function(e){return"function"==typeof S&&e instanceof S};function St(e,t,n){h(e,e=>{e.call(i,t,n,dt)})}const Et=function(e){let t=null;if(St(de.beforeSanitizeElements,e,null),Tt(e))return kt(e),!0;const n=ut(e.nodeName);if(St(de.uponSanitizeElement,e,{tagName:n,allowedTags:Te}),Oe&&e.hasChildNodes()&&!Ct(e.firstElementChild)&&y(/<[/\w!]/g,e.innerHTML)&&y(/<[/\w!]/g,e.textContent))return kt(e),!0;if(e.nodeType===ee)return kt(e),!0;if(Oe&&e.nodeType===te&&y(/<[/\w]/g,e.data))return kt(e),!0;if(!(Re.tagCheck instanceof Function&&Re.tagCheck(n))&&(!Te[n]||Me[n])){if(!Me[n]&&Mt(n)){if(_e.tagNameCheck instanceof RegExp&&y(_e.tagNameCheck,n))return!1;if(_e.tagNameCheck instanceof Function&&_e.tagNameCheck(n))return!1}if(Ve&&!We[n]){const t=re(e)||e.parentNode,n=se(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const s=W(n[i],!0);s.__removalCount=(e.__removalCount||0)+1,t.insertBefore(s,ie(e))}}}return kt(e),!0}return e instanceof _&&!function(e){let t=re(e);t&&t.tagName||(t={namespaceURI:it,tagName:"template"});const n=f(e.tagName),i=f(t.tagName);return!!rt[e.namespaceURI]&&(e.namespaceURI===tt?t.namespaceURI===nt?"svg"===n:t.namespaceURI===et?"svg"===n&&("annotation-xml"===i||at[i]):Boolean(xt[n]):e.namespaceURI===et?t.namespaceURI===nt?"math"===n:t.namespaceURI===tt?"math"===n&&lt[i]:Boolean(bt[n]):e.namespaceURI===nt?!(t.namespaceURI===tt&&!lt[i])&&!(t.namespaceURI===et&&!at[i])&&!bt[n]&&(ct[n]||!xt[n]):!("application/xhtml+xml"!==ht||!rt[e.namespaceURI]))}(e)?(kt(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!y(/<\/no(script|embed|frames)/i,e.innerHTML)?(Ne&&e.nodeType===J&&(t=e.textContent,h([me,fe,ge],e=>{t=b(t,e," ")}),e.textContent!==t&&(d(i.removed,{element:e.cloneNode()}),e.textContent=t)),St(de.afterSanitizeElements,e,null),!1):(kt(e),!0)},_t=function(e,t,n){if(Ue&&("id"===t||"name"===t)&&(n in s||n in mt))return!1;if(De&&!ze[t]&&y(xe,t));else if(Ae&&y(be,t));else if(Re.attributeCheck instanceof Function&&Re.attributeCheck(t,e));else if(!Se[t]||ze[t]){if(!(Mt(e)&&(_e.tagNameCheck instanceof RegExp&&y(_e.tagNameCheck,e)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(e))&&(_e.attributeNameCheck instanceof RegExp&&y(_e.attributeNameCheck,t)||_e.attributeNameCheck instanceof Function&&_e.attributeNameCheck(t,e))||"is"===t&&_e.allowCustomizedBuiltInElements&&(_e.tagNameCheck instanceof RegExp&&y(_e.tagNameCheck,n)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(n))))return!1}else if(Ke[t]);else if(y(ye,b(n,we,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==k(n,"data:")||!Ze[e]){if(Le&&!y(ke,b(n,we,"")));else if(n)return!1}else;return!0},Mt=function(e){return"annotation-xml"!==e&&x(e,ve)},zt=function(e){St(de.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Tt(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Se,forceKeepAttr:void 0};let s=t.length;for(;s--;){const o=t[s],{name:a,namespaceURI:l,value:c}=o,p=ut(a),d=c;let m="value"===a?d:w(d);if(n.attrName=p,n.attrValue=m,n.keepAttr=!0,n.forceKeepAttr=void 0,St(de.uponSanitizeAttribute,e,n),m=n.attrValue,!Xe||"id"!==p&&"name"!==p||(wt(a,e),m="user-content-"+m),Oe&&y(/((--!?|])>)|<\/(style|title|textarea)/i,m)){wt(a,e);continue}if("attributename"===p&&x(m,"href")){wt(a,e);continue}if(n.forceKeepAttr)continue;if(!n.keepAttr){wt(a,e);continue}if(!Ie&&y(/\/>/i,m)){wt(a,e);continue}Ne&&h([me,fe,ge],e=>{m=b(m,e," ")});const f=ut(e.nodeName);if(_t(f,p,m)){if(oe&&"object"==typeof V&&"function"==typeof V.getAttributeType)if(l);else switch(V.getAttributeType(f,p)){case"TrustedHTML":m=oe.createHTML(m);break;case"TrustedScriptURL":m=oe.createScriptURL(m)}if(m!==d)try{l?e.setAttributeNS(l,a,m):e.setAttribute(a,m),Tt(e)?kt(e):u(i.removed)}catch(r){wt(a,e)}}else wt(a,e)}St(de.afterSanitizeAttributes,e,null)},Rt=function e(t){let n=null;const i=yt(t);for(St(de.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)St(de.uponSanitizeShadowNode,n,null),Et(n),zt(n),n.content instanceof c&&e(n.content);St(de.afterSanitizeShadowDOM,t,null)};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,s=null,r=null,a=null;if(st=!e,st&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Ct(e)){if("function"!=typeof e.toString)throw T("toString is not a function");if("string"!=typeof(e=e.toString()))throw T("dirty is not a string, aborting")}if(!i.isSupported)return e;if($e||gt(t),i.removed=[],"string"==typeof e&&(je=!1),je){if(e.nodeName){const t=ut(e.nodeName);if(!Te[t]||Me[t])throw T("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof S)n=vt("\x3c!----\x3e"),s=n.ownerDocument.importNode(e,!0),s.nodeType===K&&"BODY"===s.nodeName||"HTML"===s.nodeName?n=s:n.appendChild(s);else{if(!Fe&&!Ne&&!Pe&&-1===e.indexOf("<"))return oe&&Ye?oe.createHTML(e):e;if(n=vt(e),!n)return Fe?null:Ye?ae:""}n&&Be&&kt(n.firstChild);const l=yt(je?e:n);for(;r=l.nextNode();)Et(r),zt(r),r.content instanceof c&&Rt(r.content);if(je)return e;if(Fe){if(He)for(a=he.call(n.ownerDocument);n.firstChild;)a.appendChild(n.firstChild);else a=n;return(Se.shadowroot||Se.shadowrootmode)&&(a=ue.call(o,a,!0)),a}let p=Pe?n.outerHTML:n.innerHTML;return Pe&&Te["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&y(G,n.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+p),Ne&&h([me,fe,ge],e=>{p=b(p,e," ")}),oe&&Ye?oe.createHTML(p):p},i.setConfig=function(){gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),$e=!0},i.clearConfig=function(){dt=null,$e=!1},i.isValidAttribute=function(e,t,n){dt||gt({});const i=ut(e),s=ut(t);return _t(i,s,n)},i.addHook=function(e,t){"function"==typeof t&&d(de[e],t)},i.removeHook=function(e,t){if(void 0!==t){const n=p(de[e],t);return-1===n?void 0:m(de[e],n,1)[0]}return u(de[e])},i.removeHooks=function(e){de[e]=[]},i.removeAllHooks=function(){de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();function se(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var re={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function oe(e){re=e}var ae={exec:()=>null};function le(e,t=""){let n="string"==typeof e?e:e.source,i={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(he.caret,"$1"),n=n.replace(e,s),i},getRegex:()=>new RegExp(n,t)};return i}var ce=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),he={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},pe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ue=/(?:[*+-]|\d{1,9}[.)])/,de=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,me=le(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),fe=le(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ge=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,xe=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,be=le(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",xe).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ke=le(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ue).getRegex(),we="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ve=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ye=le("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",ve).replace("tag",we).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Te=le(ge).replace("hr",pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we).getRegex(),Ce={blockquote:le(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Te).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:be,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:pe,html:ye,lheading:me,list:ke,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Te,table:ae,text:/^[^\n]+/},Se=le("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we).getRegex(),Ee={...Ce,lheading:fe,table:Se,paragraph:le(ge).replace("hr",pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Se).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we).getRegex()},_e={...Ce,html:le("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",ve).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ae,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:le(ge).replace("hr",pe).replace("heading"," *#{1,6} *[^\n]").replace("lheading",me).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Me=/^( {2,}|\\)\n(?!\s*$)/,ze=/[\p{P}\p{S}]/u,Re=/[\s\p{P}\p{S}]/u,Ae=/[^\s\p{P}\p{S}]/u,De=le(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Re).getRegex(),Le=/(?!~)[\p{P}\p{S}]/u,Ie=le(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ce?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ne=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Oe=le(Ne,"u").replace(/punct/g,ze).getRegex(),Pe=le(Ne,"u").replace(/punct/g,Le).getRegex(),$e="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Be=le($e,"gu").replace(/notPunctSpace/g,Ae).replace(/punctSpace/g,Re).replace(/punct/g,ze).getRegex(),Fe=le($e,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Le).getRegex(),He=le("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ae).replace(/punctSpace/g,Re).replace(/punct/g,ze).getRegex(),Ye=le(/\\(punct)/,"gu").replace(/punct/g,ze).getRegex(),Ue=le(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Xe=le(ve).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ve=le("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Xe).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),je=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,qe=le(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",je).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),We=le(/^!?\[(label)\]\[(ref)\]/).replace("label",je).replace("ref",xe).getRegex(),Ge=le(/^!?\[(ref)\](?:\[\])?/).replace("ref",xe).getRegex(),Ze=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Qe={_backpedal:ae,anyPunctuation:Ye,autolink:Ue,blockSkip:Ie,br:Me,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:ae,emStrongLDelim:Oe,emStrongRDelimAst:Be,emStrongRDelimUnd:He,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:qe,nolink:Ge,punctuation:De,reflink:We,reflinkSearch:le("reflink|nolink(?!\\()","g").replace("reflink",We).replace("nolink",Ge).getRegex(),tag:Ve,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:ae},Ke={...Qe,link:le(/^!?\[(label)\]\((.*?)\)/).replace("label",je).getRegex(),reflink:le(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",je).getRegex()},Je={...Qe,emStrongRDelimAst:Fe,emStrongLDelim:Pe,url:le(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ze).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:le(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ze).getRegex()},et={...Je,br:le(Me).replace("{2,}","*").getRegex(),text:le(Je.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},tt={normal:Ce,gfm:Ee,pedantic:_e},nt={normal:Qe,gfm:Je,breaks:et,pedantic:Ke},it={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},st=e=>it[e];function rt(e,t){if(t){if(he.escapeTest.test(e))return e.replace(he.escapeReplace,st)}else if(he.escapeTestNoEncode.test(e))return e.replace(he.escapeReplaceNoEncode,st);return e}function ot(e){try{e=encodeURI(e).replace(he.percentDecode,"%")}catch{return null}return e}function at(e,t){let n=e.replace(he.findPipe,(e,t,n)=>{let i=!1,s=t;for(;--s>=0&&"\\"===n[s];)i=!i;return i?"|":" |"}).split(he.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(he.slashPipe,"|");return n}function lt(e,t,n){let i=e.length;if(0===i)return"";let s=0;for(;s<i;){if(e.charAt(i-s-1)!==t)break;s++}return e.slice(0,i-s)}function ct(e,t,n,i,s){let r=t.href,o=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:r,title:o,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,l}var ht=class{options;rules;lexer;constructor(e){this.options=e||re}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:lt(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let s=i[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=s.length?e.slice(s.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=lt(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:lt(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=lt(t[0],"\n").split("\n"),n="",i="",s=[];for(;e.length>0;){let t,r=!1,o=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))o.push(e[t]),r=!0;else{if(r)break;o.push(e[t])}e=e.slice(t);let a=o.join("\n"),l=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,i=i?`${i}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,s,!0),this.lexer.state.top=c,0===e.length)break;let h=s.at(-1);if("code"===h?.type)break;if("blockquote"===h?.type){let t=h,r=t.raw+"\n"+e.join("\n"),o=this.blockquote(r);s[s.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,i=i.substring(0,i.length-t.text.length)+o.text;break}if("list"===h?.type){let t=h,r=t.raw+"\n"+e.join("\n"),o=this.list(r);s[s.length-1]=o,n=n.substring(0,n.length-h.raw.length)+o.raw,i=i.substring(0,i.length-t.raw.length)+o.raw,e=r.substring(s.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,s={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let r=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,i="",a="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],h=!l.trim(),p=0;if(this.options.pedantic?(p=2,a=l.trimStart()):h?p=t[1].length+1:(p=t[2].search(this.rules.other.nonSpaceChar),p=p>4?1:p,a=l.slice(p),p+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),s=this.rules.other.fencesBeginRegex(p),r=this.rules.other.headingBeginRegex(p),o=this.rules.other.htmlBeginRegex(p);for(;e;){let u,d=e.split("\n",1)[0];if(c=d,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||r.test(c)||o.test(c)||t.test(c)||n.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=p||!c.trim())a+="\n"+u.slice(p);else{if(h||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(l)||r.test(l)||n.test(l))break;a+="\n"+c}!h&&!c.trim()&&(h=!0),i+=d+"\n",e=e.substring(d.length+1),l=u.slice(p)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(o=!0)),s.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=i}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));s.loose=n}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=at(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?r.align.push("right"):this.rules.other.tableAlignCenter.test(e)?r.align.push("center"):this.rules.other.tableAlignLeft.test(e)?r.align.push("left"):r.align.push(null);for(let e=0;e<n.length;e++)r.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:r.align[e]});for(let e of s)r.rows.push(at(e,r.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:r.align[t]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=lt(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),ct(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return ct(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[2]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,o=r,a=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+r);null!=(i=l.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(s=[...n].length,i[3]||i[4]){o+=s;continue}if((i[5]||i[6])&&r%3&&!((r+s)%3)){a+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o+a);let t=[...i[0]][0].length,l=e.slice(0,r+i.index+t+s);if(Math.min(r,s)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},pt=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=/* @__PURE__ */Object.create(null),this.options=e||re,this.options.tokenizer=this.options.tokenizer||new ht,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:he,block:tt.normal,inline:nt.normal};this.options.pedantic?(t.block=tt.pedantic,t.inline=nt.pedantic):this.options.gfm&&(t.block=tt.gfm,this.options.breaks?t.inline=nt.breaks:t.inline=nt.gfm),this.tokenizer.rules=t}static get rules(){return{block:tt,inline:nt}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(he.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(he.tabCharGlobal," ").replace(he.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);1===i.raw.length&&void 0!==n?n.raw+="\n":t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let s=e;if(this.options.extensions?.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){let r=t.at(-1);n&&"paragraph"===r?.type?(r.raw+=(r.raw.endsWith("\n")?"":"\n")+i.raw,r.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=s.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,i=e,s=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(i));)n=s[2]?s[2].length:0,i=i.slice(0,s.index+n)+"["+"a".repeat(s[0].length-n-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,o="";for(;e;){let n;if(r||(o=""),r=!1,this.options.extensions?.inline?.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let i=t.at(-1);"text"===n.type&&"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,i,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(s)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),r=!0;let i=t.at(-1);"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},ut=class{options;parser;constructor(e){this.options=e||re}space(e){return""}code({text:e,lang:t,escaped:n}){let i=(t||"").match(he.notSpaceStart)?.[0],s=e.replace(he.endingNewline,"")+"\n";return i?'<pre><code class="language-'+rt(i)+'">'+(n?s:rt(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:rt(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,i="";for(let r=0;r<e.items.length;r++){let t=e.items[r];i+=this.listitem(t)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let i="";for(let s=0;s<e.rows.length;s++){let t=e.rows[s];n="";for(let e=0;e<t.length;e++)n+=this.tablecell(t[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${rt(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=ot(e);if(null===s)return i;let r='<a href="'+(e=s)+'"';return t&&(r+=' title="'+rt(t)+'"'),r+=">"+i+"</a>",r}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=ot(e);if(null===s)return rt(n);let r=`<img src="${e=s}" alt="${n}"`;return t&&(r+=` title="${rt(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:rt(e.text)}},dt=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},mt=class e{options;renderer;textRenderer;constructor(e){this.options=e||re,this.options.renderer=this.options.renderer||new ut,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new dt}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let e=i,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let s=i;switch(s.type){case"space":t+=this.renderer.space(s);break;case"hr":t+=this.renderer.hr(s);break;case"heading":t+=this.renderer.heading(s);break;case"code":t+=this.renderer.code(s);break;case"table":t+=this.renderer.table(s);break;case"blockquote":t+=this.renderer.blockquote(s);break;case"list":t+=this.renderer.list(s);break;case"checkbox":t+=this.renderer.checkbox(s);break;case"html":t+=this.renderer.html(s);break;case"def":t+=this.renderer.def(s);break;case"paragraph":t+=this.renderer.paragraph(s);break;case"text":t+=this.renderer.text(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){let n="";for(let i=0;i<e.length;i++){let s=e[i];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=e||"";continue}}let r=s;switch(r.type){case"escape":case"text":n+=t.text(r);break;case"html":n+=t.html(r);break;case"link":n+=t.link(r);break;case"image":n+=t.image(r);break;case"checkbox":n+=t.checkbox(r);break;case"strong":n+=t.strong(r);break;case"em":n+=t.em(r);break;case"codespan":n+=t.codespan(r);break;case"br":n+=t.br(r);break;case"del":n+=t.del(r);break;default:{let e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},ft=class{options;block;constructor(e){this.options=e||re}static passThroughHooks=/* @__PURE__ */new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=/* @__PURE__ */new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?pt.lex:pt.lexInline}provideParser(){return this.block?mt.parse:mt.parseInline}},gt=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=mt;Renderer=ut;TextRenderer=dt;Lexer=pt;Tokenizer=ht;Hooks=ft;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let e=i;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let s=e[i].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new ut(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let i=n,s=e.renderer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ht(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let i=n,s=e.tokenizer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ft;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let i=n,s=e.hooks[i],r=t[i];ft.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async&&ft.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return r.call(t,n)})();let i=s.call(t,e);return r.call(t,i)}:t[i]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await r.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return pt.lex(e,t??this.defaults)}parser(e,t){return mt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},r=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===i.async)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return r(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,i=await(s.hooks?await s.hooks.provideLexer():e?pt.lex:pt.lexInline)(n,s),r=s.hooks?await s.hooks.processAllTokens(i):i;s.walkTokens&&await Promise.all(this.walkTokens(r,s.walkTokens));let o=await(s.hooks?await s.hooks.provideParser():e?mt.parse:mt.parseInline)(r,s);return s.hooks?await s.hooks.postprocess(o):o})().catch(r);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer():e?pt.lex:pt.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let i=(s.hooks?s.hooks.provideParser():e?mt.parse:mt.parseInline)(n,s);return s.hooks&&(i=s.hooks.postprocess(i)),i}catch(o){return r(o)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+rt(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function xt(e,t){return gt.parse(e,t)}xt.options=xt.setOptions=function(e){return gt.setOptions(e),xt.defaults=gt.defaults,oe(xt.defaults),xt},xt.getDefaults=se,xt.defaults=re,xt.use=function(...e){return gt.use(...e),xt.defaults=gt.defaults,oe(xt.defaults),xt},xt.walkTokens=function(e,t){return gt.walkTokens(e,t)},xt.parseInline=gt.parseInline,xt.Parser=mt,xt.parser=mt.parse,xt.Renderer=ut,xt.TextRenderer=dt,xt.Lexer=pt,xt.lexer=pt.lex,xt.Tokenizer=ht,xt.Hooks=ft,xt.parse=xt,xt.options,xt.setOptions,xt.use,xt.walkTokens,xt.parseInline,mt.parse,pt.lex;class bt{constructor(e,t,n,i){this.container=e,Object.assign(this.options,t),this.onStart=n.subscribe,this.onDispose=i.subscribe}onStart;onDispose;options={}}const kt={round:function(e,t){const n=10**t;return Math.round(e*n)/n},resizeCanvasForDPR:function(e,t,n){const i=window.devicePixelRatio||1,s=e.getContext("2d");if(!s)throw new Error("[JSONCanvasViewer] This error is unexpected, probably caused uncontrollable runtime errors. Please contact the developer and show how to reproduce.");e.width=Math.round(t*i),e.height=Math.round(n*i),s.setTransform(1,0,0,1,0,0),s.scale(i,i)},applyStyles:function(e,t){const n=document.createElement("style");n.innerHTML=t,e.appendChild(n)},drawRoundRect:function(e,t,n,i,s,r){e.beginPath(),e.moveTo(t+r,n),e.lineTo(t+i-r,n),e.quadraticCurveTo(t+i,n,t+i,n+r),e.lineTo(t+i,n+s-r),e.quadraticCurveTo(t+i,n+s,t+i-r,n+s),e.lineTo(t+r,n+s),e.quadraticCurveTo(t,n+s,t,n+s-r),e.lineTo(t,n+r),e.quadraticCurveTo(t,n,t+r,n),e.closePath()},getAnchorCoord:function(e,t){const n=e.x+e.width/2,i=e.y+e.height/2;switch(t){case"top":return[n,e.y];case"bottom":return[n,e.y+e.height];case"left":return[e.x,i];case"right":return[e.x+e.width,i];default:return[n,i]}},getColor:function(e="0"){let t=null;if(1===e.length)switch(e){case"1":t="rgba(255, 120, 129, ?)";break;case"2":t="rgba(251, 187, 131, ?)";break;case"3":t="rgba(255, 232, 139, ?)";break;case"4":t="rgba(124, 211, 124, ?)";break;case"5":t="rgba(134, 223, 226, ?)";break;case"6":t="rgba(203, 158, 255, ?)";break;default:t="rgba(140, 140, 140, ?)"}else{const n=function(e){const t=e.replace("#","");return{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16)}}(e);t=`rgba(${n.r}, ${n.g}, ${n.b}, ?)`}return{border:t.replace("?","0.75"),background:t.replace("?","0.1"),active:t.replace("?","1")}},makeHook:function(e=!1){const t=(...n)=>{if(e){Array.from(t.subs).reverse().forEach(e=>{e(...n)})}else t.subs.forEach(e=>{e(...n)})};return t.subs=/* @__PURE__ */new Set,t.subscribe=e=>{t.subs.add(e)},t.unsubscribe=e=>{t.subs.delete(e)},t}},wt=new Error("[JSONCanvasViewer] Resource hasn't been set up or has been disposed.");const vt=800;class yt extends bt{spatialGrid=null;onToggleFullscreen=kt.makeHook();data;constructor(...e){super(...e);const t=this.options.container;for(;t.firstElementChild;)t.firstElementChild.remove();t.innerHTML="";const n=this.options.noShadow||!1?t:t.attachShadow({mode:"open"});kt.applyStyles(n,".full,.click-layer,.link-iframe,.audio{top:0;left:0;width:100%;height:100%;position:absolute}.flex-center,.overlay-container.markdown-content{display:flex;justify-content:center;align-items:center}.container{--contentTransition: color .2s, opacity .2s, text-shadow .2s, fill .2s;--containerTransition: background .2s, opacity .2s, box-shadow .2s, border .2s, filter .2s, backdrop-filter .2s;color:#fff;fill:#fff;stroke:#fff;position:relative;width:100%;height:100%;overflow:hidden;background-color:#141414}.container.numb,.container.numb *{pointer-events:none!important}.main-canvas{width:100%;height:100%;transform-origin:top left}.overlays{position:absolute;top:0;left:0;width:10000px;height:10000px;transform-origin:top left;will-change:transform}.parsed-content-wrapper{font-family:sans-serif;box-sizing:border-box;max-width:100%;max-height:100%;padding:10px 6px;pointer-events:none;overflow:hidden;scrollbar-gutter:stable both-edges;display:flex;flex-direction:column;gap:12px}@supports not (scrollbar-gutter: stable both-edges){.parsed-content-wrapper{padding:10px}}.overlay-container{position:absolute;box-sizing:border-box;border-radius:12px;overflow:hidden;-webkit-user-select:none;user-select:none;contain:strict;content-visibility:auto}.overlay-container:hover{box-shadow:0 2px 12px #00000080}.overlay-container{transition:var(--containerTransition)}.overlay-container .overlay-border{box-sizing:border-box;pointer-events:none;position:absolute;top:0;left:0;width:100%;height:100%;border-width:2px;border-style:solid;border-radius:12px;transition:var(--containerTransition)}.overlay-container img{width:100%;height:100%;object-fit:cover;pointer-events:none}.overlay-container.active .overlay-border{border:6px solid var(--active-color)}.overlay-container.markdown-content{position:absolute;padding:0 7px}.overlay-container.markdown-content.active .parsed-content-wrapper{overflow:auto;-webkit-user-select:text;user-select:text;pointer-events:auto}.overlay-container.markdown-content.rtl{direction:rtl;text-align:right}.link-iframe,.audio{border:none;background:transparent}.click-layer{background:transparent;pointer-events:auto}.active .click-layer{pointer-events:none}::-webkit-scrollbar{width:4px}::-webkit-scrollbar-track{background-color:transparent}::-webkit-scrollbar-thumb{border-radius:2px;background:#ffffff40}::-webkit-scrollbar-thumb:hover{background:#1e1e1ebf}p{font-size:16px;line-height:21px}.parsed-content-wrapper img{width:100%;border-radius:8px}h1{font-size:25px}h2{font-size:23px}h3{font-size:22px}h4{font-size:20px}h5{font-size:19px}h6{font-size:17px}p,h1,h2,h3,h4,h5,h6,ol,ul{margin:0}h1,h2{font-weight:800}h3,h4{font-weight:700}h5,h6{font-weight:600}code{background:#ffffff1a;padding:2px 4px;border-radius:8px}pre code{display:block;box-sizing:border-box;width:100%}pre:has(code),table{margin:6px 0}strong{color:#fe8e7c}em{color:#5affb2}a{text-decoration:none;color:#6dadd0;font-weight:800;font-style:italic;cursor:pointer;transition:var(--contentTransition)}a:hover{color:#86d3fd}hr{height:1px;width:100%;background-color:#fff3;border:none}li{margin:5px 0}ul{padding-left:16px}ol{padding-left:15px;padding-right:7.5px}table{border-collapse:collapse;border-radius:8px;overflow:hidden;width:100%}table th,table td{border:1px solid rgba(255,255,255,.2);padding:6px 10px;background:#ffffff0f;text-align:left}table th{background:#ffffff1f;font-weight:700}"+this.options.extraCSS);const i=document.createElement("div");i.classList.add("container"),n.appendChild(i);const s=Object.assign({nodes:[],edges:[]},this.options.canvas);this.data={canvasData:s,nodeMap:{},canvasBaseDir:this.processBaseDir(this.options.attachmentDir),nodeBounds:this.calculateNodeBounds(s),offsetX:0,offsetY:0,scale:1,container:i},this.data.canvasData.nodes.forEach(e=>{if("file"===e.type&&!e.file.includes("http")){const t=e.file.split("/");e.file=t[t.length-1]}this.data.nodeMap[e.id]=e}),this.buildSpatialGrid(),this.resetView(),this.onDispose(this.dispose)}processBaseDir=e=>{if(!e)return"./";const t=e?.slice(-1);return"/"===t?e:`${e}/`};findNodeAt=e=>{const{x:t,y:n}=this.C2W(this.C2C({x:e.x,y:e.y}));let i=[];if(this.spatialGrid){const e=`${Math.floor(t/vt)},${Math.floor(n/vt)}`;i=this.spatialGrid[e]||[]}else i=this.data.canvasData.nodes;for(const s of i)if(!(t<s.x||t>s.x+s.width||n<s.y||n>s.y+s.height||"non-interactive"===this.judgeInteract(s)))return s;return null};judgeInteract=e=>{switch(e?.type){case"text":case"link":return"select";case"file":return e.file.match(/\.(md|wav|mp3)$/i)?"select":"non-interactive";default:return"non-interactive"}};calculateNodeBounds(e){let t=1/0,n=1/0,i=-1/0,s=-1/0;e.nodes.forEach(e=>{t=Math.min(t,e.x),n=Math.min(n,e.y),i=Math.max(i,e.x+e.width),s=Math.max(s,e.y+e.height)});const r=i-t,o=s-n;return{minX:t,minY:n,maxX:i,maxY:s,width:r,height:o,centerX:t+r/2,centerY:n+o/2}}buildSpatialGrid(){const e=this.data.canvasData;if(!(e.nodes.length<50)){this.spatialGrid={};for(const t of e.nodes){const e=Math.floor(t.x/vt),n=Math.floor((t.x+t.width)/vt),i=Math.floor(t.y/vt),s=Math.floor((t.y+t.height)/vt);for(let r=e;r<=n;r++)for(let e=i;e<=s;e++){const n=`${r},${e}`;this.spatialGrid[n]||(this.spatialGrid[n]=[]),this.spatialGrid[n].push(t)}}}}zoom=(e,t)=>{const n=this.data.scale*e;this.zoomToScale(n,t)};zoomToScale=(e,t)=>{const n=Math.max(Math.min(e,20),.05),i=this.data.scale;if(n===i)return;const s=this.C2C(t);this.data.offsetX=t.x-s.x*n/i,this.data.offsetY=t.y-s.y*n/i,this.data.scale=n};pan=({x:e,y:t})=>{this.data.offsetX=this.data.offsetX+e,this.data.offsetY=this.data.offsetY+t};panToCoords=({x:e,y:t})=>{this.data.offsetX=e,this.data.offsetY=t};shiftFullscreen=(e="toggle")=>{document.fullscreenElement||"toggle"!==e&&"enter"!==e?!document.fullscreenElement||"toggle"!==e&&"exit"!==e||(document.exitFullscreen(),this.onToggleFullscreen(!1)):(this.data.container.requestFullscreen(),this.onToggleFullscreen(!0))};resetView=()=>{const e=this.data.nodeBounds,t=this.data.container;if(!e||!t)return;const n=e.width+200,i=e.height+200,s=t.clientWidth,r=t.clientHeight,o=s/n,a=r/i,l=Math.round(1e3*Math.min(o,a))/1e3,c={scale:l,offsetX:s/2-e.centerX*l,offsetY:r/2-e.centerY*l};this.data.offsetX=c.offsetX,this.data.offsetY=c.offsetY,this.data.scale=c.scale};C2C=({x:e,y:t})=>({x:e-this.data.offsetX,y:t-this.data.offsetY});C2W=({x:e,y:t})=>({x:e/this.data.scale,y:t/this.data.scale});middleViewer=()=>{const e=this.data.container;return{x:e.clientWidth/2,y:e.clientHeight/2,width:e.clientWidth,height:e.clientHeight}};dispose=()=>this.data.container.remove()}class Tt extends bt{animationId=null;resizeAnimationId=null;DM;resizeObserver;perFrame={lastScale:1,lastOffsets:{x:0,y:0}};lastResizeCenter={x:null,y:null};hooks={onResize:kt.makeHook(),onRefresh:kt.makeHook()};constructor(...e){super(...e),this.onStart(this.start),this.onDispose(this.dispose),this.DM=this.container.get(yt),this.resizeObserver=new ResizeObserver(this.onResize)}start=()=>{this.resizeObserver.observe(this.DM.data.container),this.animationId=requestAnimationFrame(this.draw)};draw=()=>{this.perFrame.lastScale===this.DM.data.scale&&this.perFrame.lastOffsets.x===this.DM.data.offsetX&&this.perFrame.lastOffsets.y===this.DM.data.offsetY||this.refresh(),this.animationId=requestAnimationFrame(this.draw)};refresh=()=>{this.perFrame.lastScale=this.DM.data.scale,this.perFrame.lastOffsets={x:this.DM.data.offsetX,y:this.DM.data.offsetY},this.hooks.onRefresh()};onResize=()=>{this.resizeAnimationId=requestAnimationFrame(()=>{const e=this.DM.middleViewer();this.lastResizeCenter.x&&this.lastResizeCenter.y&&(this.DM.data.offsetX=this.DM.data.offsetX+e.x-this.lastResizeCenter.x,this.DM.data.offsetY=this.DM.data.offsetY+e.y-this.lastResizeCenter.y),this.lastResizeCenter.x=e.x,this.lastResizeCenter.y=e.y,this.hooks.onResize(e.width,e.height),this.refresh()})};dispose=()=>{this.animationId&&cancelAnimationFrame(this.animationId),this.resizeAnimationId&&cancelAnimationFrame(this.resizeAnimationId),this.resizeObserver.disconnect()}}const Ct='<svg viewBox="-5.28 -5.28 34.56 34.56" fill="none"><path d="M4 9V5.6c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C4.76 4 5.04 4 5.6 4H9M4 15v3.4c0 .56 0 .84.109 1.054a1 1 0 0 0 .437.437C4.76 20 5.04 20 5.6 20H9m6-16h3.4c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C20 4.76 20 5.04 20 5.6V9m0 6v3.4c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437C19.24 20 18.96 20 18.4 20H15" stroke-width="2.4" stroke-linecap="round"/></svg>';class St extends bt{_controlsPanel=null;_toggleCollapseBtn=null;_toggleFullscreenBtn=null;_zoomOutBtn=null;_zoomSlider=null;_zoomInBtn=null;_resetViewBtn=null;DM;collapsed;get controlsPanel(){if(null===this._controlsPanel)throw wt;return this._controlsPanel}get toggleCollapseBtn(){if(null===this._toggleCollapseBtn)throw wt;return this._toggleCollapseBtn}get toggleFullscreenBtn(){if(null===this._toggleFullscreenBtn)throw wt;return this._toggleFullscreenBtn}get zoomOutBtn(){if(null===this._zoomOutBtn)throw wt;return this._zoomOutBtn}get zoomSlider(){if(null===this._zoomSlider)throw wt;return this._zoomSlider}get zoomInBtn(){if(null===this._zoomInBtn)throw wt;return this._zoomInBtn}get resetViewBtn(){if(null===this._resetViewBtn)throw wt;return this._resetViewBtn}constructor(...e){super(...e),this.collapsed=this.options.controlsCollapsed||!1,this.DM=this.container.get(yt),this.DM.onToggleFullscreen.subscribe(this.updateFullscreenBtn),this.container.get(Tt).hooks.onRefresh.subscribe(this.updateSlider),this._controlsPanel=document.createElement("div"),this._controlsPanel.className="controls",this._controlsPanel.classList.toggle("collapsed",this.collapsed),kt.applyStyles(this._controlsPanel,".collapse-button{border-radius:8px;transition:transform .2s}.collapse-button:hover{background:#444c}button{cursor:pointer;font-size:18px;height:32px;border:none;transition:var(--containerTransition);text-align:center;background-color:#444;width:32px;padding:5px 0}button svg{width:100%;height:100%}.controls{position:absolute;top:10px;right:10px;display:flex;align-items:center;transition:transform .2s;border-radius:8px;gap:10px}.controls.collapsed{transform:translate(calc(100% - 32px))}.controls.collapsed .collapse-button{transform:rotate(180deg)}.controls .controls-content{display:flex;gap:1px;align-items:center;border-radius:8px;overflow:hidden;background:#333c}.controls button:hover{background:#555}.zoom-slider{width:100px;margin:0 10px}"),this._toggleCollapseBtn=document.createElement("button"),this._toggleCollapseBtn.className="collapse-button",this._toggleCollapseBtn.innerHTML='<svg viewBox="-3.6 -3.6 31.2 31.2" stroke-width=".4"><path d="M15.707 4.293a1 1 0 0 1 0 1.414L9.414 12l6.293 6.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z" /></svg>',this._controlsPanel.appendChild(this._toggleCollapseBtn);const t=document.createElement("div");t.className="controls-content",this._toggleFullscreenBtn=document.createElement("button"),this._toggleFullscreenBtn.innerHTML=Ct,t.appendChild(this._toggleFullscreenBtn),this._zoomOutBtn=document.createElement("button"),this._zoomOutBtn.innerHTML='<svg viewBox="-1.2 -1.2 26.4 26.4"><path d="M6 12h12" stroke-width="2" stroke-linecap="round" /></svg>',t.appendChild(this._zoomOutBtn),this._zoomSlider=document.createElement("input"),this._zoomSlider.type="range",this._zoomSlider.className="zoom-slider",this._zoomSlider.min="-30",this._zoomSlider.max="30",this._zoomSlider.value="0",t.appendChild(this._zoomSlider),this._zoomInBtn=document.createElement("button"),this._zoomInBtn.innerHTML='<svg viewBox="-1.2 -1.2 26.4 26.4"><path d="M6 12h12m-6-6v12" stroke-width="2" stroke-linecap="round" /></svg>',t.appendChild(this._zoomInBtn),this._resetViewBtn=document.createElement("button"),this._resetViewBtn.innerHTML='<svg viewBox="-6 -6 30 30" stroke-width=".08"><path d="m14.955 7.986.116.01a1 1 0 0 1 .85 1.13 8 8 0 0 1-13.374 4.728l-.84.84c-.63.63-1.707.184-1.707-.707V10h3.987c.89 0 1.337 1.077.707 1.707l-.731.731a6 6 0 0 0 8.347-.264 6 6 0 0 0 1.63-3.33 1 1 0 0 1 1.131-.848zM11.514.813a8 8 0 0 1 1.942 1.336l.837-.837c.63-.63 1.707-.184 1.707.707V6h-3.981c-.89 0-1.337-1.077-.707-1.707l.728-.729a6 6 0 0 0-9.98 3.591 1 1 0 1 1-1.98-.281A8 8 0 0 1 11.514.813Z" /></svg>',t.appendChild(this._resetViewBtn),this._controlsPanel.appendChild(t),this.DM.data.container.appendChild(this._controlsPanel),this._toggleCollapseBtn.addEventListener("click",this.toggleCollapse),this._zoomInBtn.addEventListener("click",this.zoomIn),this._zoomOutBtn.addEventListener("click",this.zoomOut),this._zoomSlider.addEventListener("input",this.slide),this._resetViewBtn.addEventListener("click",this.DM.resetView),this._toggleFullscreenBtn.addEventListener("click",this.toggleFullscreen),this.onDispose(this.dispose)}toggleCollapse=()=>{this.collapsed=!this.collapsed,this.controlsPanel.classList.toggle("collapsed",this.collapsed),this.collapsed||this.updateSlider()};zoomIn=()=>this.DM.zoom(1.1,this.DM.middleViewer());zoomOut=()=>this.DM.zoom(1/1.1,this.DM.middleViewer());slide=()=>this.DM.zoomToScale(1.1**Number(this.zoomSlider.value),this.DM.middleViewer());updateFullscreenBtn=e=>{this.toggleFullscreenBtn.innerHTML=e?'<svg viewBox="-40.32 -40.32 176.64 176.64"><path d="M30 60H6a6 6 0 0 0 0 12h18v18a6 6 0 0 0 12 0V66a5.997 5.997 0 0 0-6-6Zm60 0H66a5.997 5.997 0 0 0-6 6v24a6 6 0 0 0 12 0V72h18a6 6 0 0 0 0-12ZM66 36h24a6 6 0 0 0 0-12H72V6a6 6 0 0 0-12 0v24a5.997 5.997 0 0 0 6 6ZM30 0a5.997 5.997 0 0 0-6 6v18H6a6 6 0 0 0 0 12h24a5.997 5.997 0 0 0 6-6V6a5.997 5.997 0 0 0-6-6Z"/></svg>':Ct};toggleFullscreen=()=>this.DM.shiftFullscreen("toggle");updateSlider=()=>{this.collapsed||(this.zoomSlider.value=String(this.scaleToSlider(this.DM.data.scale)))};scaleToSlider=e=>Math.log(e)/Math.log(1.1);dispose=()=>{this.toggleCollapseBtn.removeEventListener("click",this.toggleCollapse),this.zoomInBtn.removeEventListener("click",this.zoomIn),this.zoomOutBtn.removeEventListener("click",this.zoomOut),this.zoomSlider.removeEventListener("input",this.slide),this.resetViewBtn.removeEventListener("click",this.DM.resetView),this.toggleFullscreenBtn.removeEventListener("click",this.toggleFullscreen),this.controlsPanel.remove(),this._controlsPanel=null,this._toggleCollapseBtn=null,this._zoomInBtn=null,this._zoomOutBtn=null,this._zoomSlider=null,this._resetViewBtn=null,this._toggleFullscreenBtn=null}}class Et extends bt{_debugPanel=null;DM;get debugPanel(){if(!this._debugPanel)throw wt;return this._debugPanel}constructor(...e){super(...e),this.DM=this.container.get(yt),this.container.get(Tt).hooks.onRefresh.subscribe(this.update),this._debugPanel=document.createElement("div"),this._debugPanel.className="debug-panel";const t=this.DM.data.container;kt.applyStyles(t,".debug-panel{position:absolute;bottom:12px;left:12px;background:#0006;border-radius:12px;padding:12px;-webkit-backdrop-filter:blur(8px) saturate(1.5);backdrop-filter:blur(8px) saturate(1.5);border:2px solid rgba(140,140,140,.75);color:#fff;font-size:calc(14px + .3vw);line-height:calc(17px + .3vw);pointer-events:none}"),t.appendChild(this._debugPanel),this.onDispose(this.dispose)}update=()=>{const e=kt.round,t=this.DM.data;this.debugPanel.innerHTML=`<p>Scale: ${e(t.scale,3)}</p><p>Offset: ${e(t.offsetX,1)}, ${e(t.offsetY,1)}</p>`};dispose=()=>{this.debugPanel.remove(),this._debugPanel=null}}class _t extends bt{_minimapCtx=null;_viewportRectangle=null;_minimap=null;_minimapContainer=null;_toggleMinimapBtn=null;minimapCache={scale:1,centerX:0,centerY:0};DM;collapsed;get minimap(){if(null===this._minimap)throw wt;return this._minimap}get minimapCtx(){if(null===this._minimapCtx)throw wt;return this._minimapCtx}get viewportRectangle(){if(null===this._viewportRectangle)throw wt;return this._viewportRectangle}get minimapContainer(){if(null===this._minimapContainer)throw wt;return this._minimapContainer}get toggleMinimapBtn(){if(null===this._toggleMinimapBtn)throw wt;return this._toggleMinimapBtn}constructor(...e){super(...e),this.collapsed=this.options.minimapCollapsed||!1,this.container.get(Tt).hooks.onRefresh.subscribe(this.updateViewportRectangle),this.DM=this.container.get(yt),this._minimapContainer=document.createElement("div"),this._minimapContainer.className="minimap-container",kt.applyStyles(this._minimapContainer,".collapse-button{border-radius:8px;transition:transform .2s}.collapse-button:hover{background:#444c}button{cursor:pointer;font-size:18px;height:32px;border:none;transition:var(--containerTransition);text-align:center;background-color:#444;width:32px;padding:5px 0}button svg{width:100%;height:100%}.minimap-container{position:absolute;bottom:10px;right:10px;display:flex;pointer-events:none;transition:transform .2s}.minimap-container.collapsed{transform:translate(calc(100% - 32px))}.toggle-minimap{margin:auto 10px 0 0;pointer-events:auto}.collapsed .toggle-minimap{transform:rotate(180deg)}.minimap{position:relative;width:200px;height:150px;overflow:hidden;border-radius:12px;background:#202020;-webkit-backdrop-filter:blur(8px) saturate(1.5);backdrop-filter:blur(8px) saturate(1.5);border:2px solid rgba(140,140,140,.75);transform-origin:0 0}.minimap .minimap-canvas{width:100%;height:100%}.minimap .viewport-rectangle{position:absolute;top:0;left:0;pointer-events:none;border:2px solid #fff;border-radius:6px;box-sizing:border-box;background:transparent}@container (max-width: 768px){.container .minimap{transform:scale(.6)}.container .toggle-minimap{transform:translateY(-60px)}.collapsed .container .toggle-minimap{transform:translateY(-60px) rotate(180deg)}.container .minimap-container{transform:translateY(60px) translate(80px)}.container .minimap-container.collapsed{transform:translateY(60px) translate(calc(100% - 32px))}}"),this._toggleMinimapBtn=document.createElement("button"),this._toggleMinimapBtn.className="toggle-minimap collapse-button",this._toggleMinimapBtn.innerHTML='<svg viewBox="-3.6 -3.6 31.2 31.2" stroke-width=".4"><path d="M15.707 4.293a1 1 0 0 1 0 1.414L9.414 12l6.293 6.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z" /></svg>',this._minimapContainer.appendChild(this._toggleMinimapBtn),this._minimap=document.createElement("div"),this._minimap.className="minimap";const t=document.createElement("canvas");t.className="minimap-canvas",t.width=200,t.height=150,this._minimap.appendChild(t),this._minimapCtx=t.getContext("2d"),this._viewportRectangle=document.createElement("div"),this._viewportRectangle.className="viewport-rectangle",this._minimap.appendChild(this._viewportRectangle),this._minimapContainer.appendChild(this._minimap),this.DM.data.container.appendChild(this._minimapContainer),this._minimapContainer.classList.toggle("collapsed",this.collapsed),this._toggleMinimapBtn.addEventListener("click",this.toggleCollapse),kt.resizeCanvasForDPR(t,t.width,t.height),this.onStart(this.start),this.onDispose(this.dispose)}toggleCollapse=()=>{this.collapsed=!this.collapsed,this.minimapContainer.classList.toggle("collapsed",this.collapsed),this.collapsed||this.updateViewportRectangle()};start=()=>{const e=this.DM.data.nodeBounds;if(!e)return;const t=this.minimap.clientWidth,n=this.minimap.clientHeight,i=t/e.width,s=n/e.height;this.minimapCache.scale=.9*Math.min(i,s),this.minimapCache.centerX=t/2,this.minimapCache.centerY=n/2,this.minimapCtx.clearRect(0,0,t,n),this.minimapCtx.save(),this.minimapCtx.translate(this.minimapCache.centerX,this.minimapCache.centerY),this.minimapCtx.scale(this.minimapCache.scale,this.minimapCache.scale),this.minimapCtx.translate(-e.centerX,-e.centerY);const r=this.DM.data.canvasData;for(const o of r.edges)this.drawMinimapEdge(o);for(const o of r.nodes)this.drawMinimapNode(o);this.minimapCtx.restore()};drawMinimapNode=e=>{const t=kt.getColor(e.color);this.minimapCtx.fillStyle=t.border,this.minimapCtx.globalAlpha=.3,kt.drawRoundRect(this.minimapCtx,e.x,e.y,e.width,e.height,25),this.minimapCtx.fill(),this.minimapCtx.globalAlpha=1};drawMinimapEdge=e=>{const t=this.DM.data.nodeMap,n=t[e.fromNode],i=t[e.toNode];if(!n||!i)return;const[s,r]=kt.getAnchorCoord(n,e.fromSide),[o,a]=kt.getAnchorCoord(i,e.toSide);this.minimapCtx.beginPath(),this.minimapCtx.moveTo(s,r),this.minimapCtx.lineTo(o,a),this.minimapCtx.strokeStyle="#555",this.minimapCtx.lineWidth=10,this.minimapCtx.stroke()};updateViewportRectangle=()=>{if(this.collapsed)return;const e=this.DM.data.nodeBounds,t=this.DM.data.container,n=this.DM.data.scale;if(!e)return;const i=t.clientWidth/n,s=t.clientHeight/n,r=-this.DM.data.offsetX/n+t.clientWidth/(2*n),o=-this.DM.data.offsetY/n+t.clientHeight/(2*n),a=this.minimapCache.centerX+(r-i/2-e.centerX)*this.minimapCache.scale,l=this.minimapCache.centerY+(o-s/2-e.centerY)*this.minimapCache.scale,c=i*this.minimapCache.scale,h=s*this.minimapCache.scale;this.viewportRectangle.style.left=`${a}px`,this.viewportRectangle.style.top=`${l}px`,this.viewportRectangle.style.width=`${c}px`,this.viewportRectangle.style.height=`${h}px`};dispose=()=>{this.toggleMinimapBtn.removeEventListener("click",this.toggleCollapse),this.minimapCtx.clearRect(0,0,this.minimap.clientWidth,this.minimap.clientHeight),this.minimapContainer.remove(),this._minimapContainer=null,this._toggleMinimapBtn=null,this._viewportRectangle=null,this._minimap=null}}class Mt extends bt{_preventionContainer=null;preventMt=!1;DM;preventMistouch={record:!1,lastX:0,lastY:0,initialX:0,initialY:0};get preventionContainer(){if(null===this._preventionContainer)throw wt;return this._preventionContainer}constructor(...e){super(...e);const t=Object.assign({preventAtStart:!0,labelText:"Click on to unlock."},this.options.mistouchPreventer||{}),n=document.createElement("div");n.className="prevention-banner",n.textContent=t.labelText,this.DM=this.container.get(yt),this._preventionContainer=document.createElement("div"),this._preventionContainer.className="prevention-container hidden",kt.applyStyles(this._preventionContainer,".full,.prevention-container{top:0;left:0;width:100%;height:100%;position:absolute}.flex-center,.prevention-container{display:flex;justify-content:center;align-items:center}.prevention-container{overflow:visible;transition:background .2s,opacity .2s,box-shadow .2s,border .2s,filter .2s,backdrop-filter .2s}.prevention-container.hidden{pointer-events:none;opacity:0}.prevention-container .prevention-banner{background:#0006;border-radius:12px;padding:12px;margin:12px;-webkit-backdrop-filter:blur(8px) saturate(1.5);backdrop-filter:blur(8px) saturate(1.5);border:2px solid rgba(140,140,140,.75);color:#fff;font-size:calc(14px + .3vw);line-height:calc(17px + .3vw);text-align:center}"),this._preventionContainer.appendChild(n),this.DM.data.container.appendChild(this._preventionContainer),t.preventAtStart&&this.startPrevention(),window.addEventListener("pointerdown",this.onPointerDown),window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),this.onDispose(this.dispose)}onPointerDown=e=>{const t=this.DM.data.container.getBoundingClientRect();e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom?this.preventMt||this.startPrevention():this.preventMt&&(this.preventMistouch.initialX=e.clientX,this.preventMistouch.initialY=e.clientY,this.preventMistouch.lastX=e.clientX,this.preventMistouch.lastY=e.clientY,this.preventMistouch.record=!0)};onPointerMove=e=>{this.preventMistouch.record&&(this.preventMistouch.lastX=e.clientX,this.preventMistouch.lastY=e.clientY)};onPointerUp=()=>{this.preventMistouch.record&&(this.preventMistouch.record=!1,Math.abs(this.preventMistouch.lastX-this.preventMistouch.initialX)+Math.abs(this.preventMistouch.lastY-this.preventMistouch.initialY)<5&&this.endPrevention())};startPrevention=()=>{this.preventionContainer.classList.remove("hidden"),this.DM.data.container.classList.add("numb"),this.preventMt=!0};endPrevention=()=>{this.preventMt=!1,this.preventionContainer.classList.add("hidden"),setTimeout(()=>this.DM.data.container.classList.remove("numb"),50)};dispose=()=>{window.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),this.preventionContainer.remove(),this._preventionContainer=null}}function zt(e){return"function"==typeof e}function Rt(e){const t=[];let n=e;for(;Object.getPrototypeOf(n).name;){const e=Object.getPrototypeOf(n);t.push(e),n=e}return t}function At(e){if(null==e)throw Error("Expected value to be not null or undefined");return e}function Dt(e,t){if(e.length>1)throw t();const n=e.at(0);if(void 0===n)throw t();return n}function Lt(e){return zt(e)}function It(e){return"provide"in e&&"useClass"in e}function Nt(e){return"provide"in e&&"useFactory"in e}function Ot(e){return Nt(e)&&!0===e.async}function Pt(e){return"provide"in e&&"useExisting"in e}function $t(e){return"provide"in e&&"multi"in e&&!0===e.multi}class Bt{description;options;constructor(e,t){this.description=e,this.options=t}toString(){return`InjectionToken "${String(this.description)}"`}}function Ft(e){return zt(e)}function Ht(e){return zt(e)?e.name:"symbol"==typeof e?e.description??String(e):e instanceof Bt?e.toString():e}function Yt(e){return Lt(e)?e:e.provide}const Ut=/* @__PURE__ */Symbol("injectable");class Xt{container;underConstruction=[];constructor(e){this.container=e}construct(e,t){if(Ot(e))throw new Vt(t);try{if(this.underConstruction.includes(e)){const t=[...this.underConstruction,e].map(Yt).map(Ht);throw new jt(t)}return this.underConstruction.push(e),this.doConstruct(e)}finally{this.underConstruction.pop()}}async constructAsync(e){try{if(this.underConstruction.includes(e)){const t=[...this.underConstruction,e].map(Yt).map(Ht);throw new jt(t)}if(this.underConstruction.push(e),Ot(e))return[await e.useFactory(this.container)];if(It(e)||Lt(e)){const t=Lt(e)?()=>[new e]:()=>[new e.useClass];return async function(e,t,n){for(;;)try{return await t()}catch(i){if(!(i instanceof e))throw i;await n(i)}}(Vt,async()=>t(),async e=>{await this.container.getAsync(e.token,{multi:!0,optional:!0})})}return this.doConstruct(e)}finally{this.underConstruction.pop()}}doConstruct(e){return Lt(e)?[new e]:It(e)?[new e.useClass]:function(e){return"provide"in e&&"useValue"in e}(e)?[e.useValue]:Nt(e)?[e.useFactory(this.container)]:Pt(e)?this.container.get(e.useExisting,{multi:!0}):function(){throw new Error("invalid state")}()}}class Vt extends Error{token;constructor(e){super(`Some providers for token ${Ht(e)} are async, please use injectAsync() or container.getAsync() instead`),this.token=e}}class jt extends Error{constructor(e){super(`Detected circular dependency: ${e.join(" -> ")}. Please change your dependency graph or use lazy injection instead.`)}}class qt{container;constructor(e){this.container=e}run(e){const t=Wt;try{return Wt=this,e(this.container)}finally{Wt=t}}async runAsync(e){const t=Wt;try{return Wt=this,await e(this.container)}finally{Wt=t}}}let Wt=new class{run(){throw new Zt}runAsync(){throw new Zt}};function Gt(e){return new qt(e)}class Zt extends Error{constructor(){super("You can only invoke inject() or injectAsync() within an injection context")}}class Qt{providers=/* @__PURE__ */new Map;singletons=/* @__PURE__ */new Map;parent;factory;constructor(e){this.parent=e,this.factory=new Xt(this),this.bind({provide:Qt,useValue:this})}bindAll(...e){return e.forEach(e=>this.bind(e)),this}bind(e){const t=Yt(e);if(Pt(e)&&e.provide===e.useExisting)throw Error(`The provider for token ${Ht(t)} with "useExisting" cannot refer to itself.`);if(!Pt(e)&&this.singletons.has(t))throw Error(`Cannot bind a new provider for ${Ht(t)}, since the existing provider was already constructed.`);if(Pt(e)&&$t(e)&&this.existingProviderAlreadyProvided(t,e.useExisting))return this;const n=this.providers.get(t)??[],i=$t(e);if(i&&n.some(e=>!$t(e)))throw Error(`Cannot bind ${Ht(t)} as multi-provider, since there is already a provider which is not a multi-provider.`);if(!i&&n.some(e=>$t(e))&&!n.every(Pt))throw Error(`Cannot bind ${Ht(t)} as provider, since there are already provider(s) that are multi-providers.`);return this.providers.set(t,i?[...n,e]:[e]),Ft(t)&&(It(e)||Lt(e))&&function(e,t=2){const n=[];return e.some((i,s)=>{if(s+t>e.length)return!0;n.push(e.slice(s,s+t))}),n}([t,...Rt(t)]).forEach(([e,t])=>{const n={provide:t,useExisting:e,multi:!0},i=this.providers.get(t)??[];this.existingProviderAlreadyProvided(t,e)||this.providers.set(t,[...i,n])}),this}unbind(e){const t=Yt(e);return this.providers.delete(t),this.singletons.delete(t),this}unbindAll(){return this.providers.clear(),this.singletons.clear(),this}get(e,t){if(t?.lazy??!1)return()=>this.get(e,{...t,lazy:!1});this.autoBindIfNeeded(e);const n=t?.optional??!1;if(!this.providers.has(e)){if(this.parent)return this.parent.get(e,{...t,lazy:!1});if(n)return;throw Error(`No provider(s) found for ${Ht(e)}`)}const i=At(this.providers.get(e));this.singletons.has(e)||Gt(this).run(()=>{const t=i.flatMap(t=>this.factory.construct(t,e));this.singletons.set(e,t)});const s=At(this.singletons.get(e));return t?.multi??!1?s:Dt(s,()=>Error(`Requesting a single value for ${Ht(e)}, but multiple values were provided. Consider passing "{ multi: true }" to inject all values, or adjust your bindings accordingly.`))}getAsync(e,t){return t?.lazy??!1?()=>this.getAsync(e,{...t,lazy:!1}):async function(e){return await new Promise(t=>t(e()))}(async()=>{this.autoBindIfNeeded(e);const n=t?.optional??!1;if(!this.providers.has(e)){if(n)return;throw Error(`No provider(s) found for ${Ht(e)}`)}const i=At(this.providers.get(e));this.singletons.has(e)||await Gt(this).runAsync(async()=>{const t=await Promise.all(i.map(e=>this.factory.constructAsync(e)));this.singletons.set(e,t.flat())});const s=At(this.singletons.get(e));return t?.multi??!1?s:Dt(s,()=>new Error(`Requesting a single value for ${Ht(e)}, but multiple values were provided. Consider passing "{ multi: true }" to inject all values, or adjust your bindings accordingly.`))})}createChild(){return new Qt(this)}has(e){return this.providers.has(e)||(this.parent?.has(e)??!1)}autoBindIfNeeded(e){if(!this.singletons.has(e))if(Ft(e)&&e.hasOwnProperty(Ut)){const t=function(e){return e[Ut]}(e);t.filter(e=>!this.providers.has(e)).forEach(e=>{this.bind({provide:e,useClass:e,multi:!0})})}else if(!this.providers.has(e)&&function(e){return e instanceof Bt}(e)&&e.options?.factory){const t=e.options.async;t?t&&this.bind({provide:e,async:!0,useFactory:e.options.factory}):this.bind({provide:e,async:!1,useFactory:e.options.factory})}}existingProviderAlreadyProvided(e,t){return(this.providers.get(e)??[]).some(n=>Pt(n)&&n.provide===e&&n.useExisting===t)}}class Kt{utils;window;pointers;monitoringElement;constructor(e,t,n,i){this.utils=e,this.window=t,this.pointers=n,this.monitoringElement=i}options;dispose;modifier;onPointerDown;onPointerMove;onPointerUp;onWheel;onStart;onStop}class Jt extends Kt{#e=-1/0;#t=0;options={clickPreserveTime:400,moveThreshold:5};onPointerDown=(e,t,n)=>{2===n.size&&(this.utils.getNthValue(0).interrupted=!0,t.interrupted=!0)};onPointerUp=(e,t)=>{if(t.interrupted)return;const n=this.options.moveThreshold;if(Math.abs(t.records[0].x-e.clientX)>=n||Math.abs(t.records[0].y-e.clientY)>=n)return;const i=this.utils.getLast(t.records).timestamp;i-this.#e<=this.options.clickPreserveTime?this.#t++:this.#t=1,this.#e=i;const s=this.utils.screenToTarget({x:e.clientX,y:e.clientY});this.utils.dispatch("trueClick",{...s,target:t.target,streak:this.#t})}}class en extends Kt{onPointerMove=(e,t,n)=>{const i=this.utils.getLast(t.records,1);if(1===n.size){const t=e.clientX-i.x,n=e.clientY-i.y;this.utils.dispatch("drag",{x:t,y:n,clientX:e.clientX,clientY:e.clientY})}}}class tn extends Kt{#n={lastDistance:0,lastMidpoint:{x:0,y:0}};#i(){const e=this.utils.getLast(this.utils.getNthValue(0).records),t=this.utils.getLast(this.utils.getNthValue(1).records),n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)}#s(){const e=this.utils.getLast(this.utils.getNthValue(0).records),t=this.utils.getLast(this.utils.getNthValue(1).records);return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}onPointerDown=(e,t,n)=>{2===n.size&&(this.#n.lastDistance=this.#i(),this.#n.lastMidpoint=this.utils.screenToTarget(this.#s()))};onPointerMove=(e,t,n)=>{if(2===n.size){const e=this.#i(),t=this.#s(),n=e/this.#n.lastDistance;this.#n.lastDistance=e;const i=this.utils.screenToTarget(t),s=i.x-this.#n.lastMidpoint.x,r=i.y-this.#n.lastMidpoint.y;this.#n.lastMidpoint=i,this.#r({x:s,y:r}),this.#o(n,i)}};#o(e,t){this.utils.dispatch("zoom",{x:t.x,y:t.y,factor:e})}#r(e){this.utils.dispatch("pan",e)}}class nn extends Kt{onWheel=e=>e.preventDefault();#a=e=>e.preventDefault();onStart=()=>{this.monitoringElement.style.touchAction="none",this.monitoringElement.addEventListener("gesturestart",this.#a,{passive:!1}),this.monitoringElement.addEventListener("gesturechange",this.#a,{passive:!1})};onStop=()=>{this.monitoringElement.style.touchAction="",this.monitoringElement.removeEventListener("gesturestart",this.#a),this.monitoringElement.removeEventListener("gesturechange",this.#a)};dispose=this.onStop}class sn extends Kt{options={proControlSchema:!1,zoomFactor:.1,lockControlSchema:!1};onWheel=e=>{const t=this.options;if(t.proControlSchema||t.lockControlSchema||!(e.ctrlKey||e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))||(t.proControlSchema=!0),t.proControlSchema)if(e.ctrlKey){const n=e.deltaY>0?1-t.zoomFactor:1+t.zoomFactor,i=this.utils.screenToTarget({x:e.clientX,y:e.clientY});this.#o(n,i)}else e.shiftKey&&Math.abs(e.deltaX)<=Math.abs(e.deltaY)?this.#r({x:-e.deltaY,y:-e.deltaX}):this.#r({x:-e.deltaX,y:-e.deltaY});else{const n=1-t.zoomFactor/50*e.deltaY,i=this.utils.screenToTarget({x:e.clientX,y:e.clientY});this.#o(n,i)}};#o(e,t){this.utils.dispatch("zoom",{x:t.x,y:t.y,factor:e})}#r(e){this.utils.dispatch("pan",e)}}class rn extends EventTarget{#l;#c=/* @__PURE__ */new Map;#h={};#p={};#u;options;get#d(){if(!this.#u)throw new Error("[Pointeract] Window is not defined.");return this.#u}constructor(e,t,n={}){super();const i=on(t||[]);this.#u=e.ownerDocument.defaultView,this.#l=e,this.options=n,this.#m({coordinateOutput:"relative"}),i.forEach(e=>{const t=new e(this.moduleUtils,this.#d,this.#c,this.#l);t.options&&this.#m(t.options),Object.assign(t,{options:n}),this.#h[e.name]=t})}#m=e=>{for(const[t,n]of Object.entries(e))t in this.options||(this.options[t]=n)};on=(e,t)=>(super.addEventListener(e,t),()=>this.off(e,t));off(e,t){super.removeEventListener(e,t)}moduleUtils={getNthValue:e=>{const t=new Error("[Pointeract] Invalid pointer index");if(e<0||e>=this.#c.size)throw t;let n=0;for(const i of this.#c.values()){if(n===e)return i;n++}throw t},screenToTarget:e=>{if("absolute"===this.options.coordinateOutput)return e;const t=this.#l.getBoundingClientRect();return e.x-=t.left,e.y-=t.top,"relative"===this.options.coordinateOutput||(e.x/=t.width,e.y/=t.height),e},dispatch:(e,t)=>{let n,i=!0;for(const s of Object.values(this.#h))if(s.modifier&&(i=s.modifier(e,t),!0!==i))break;!1!==i&&(n=!0===i?new CustomEvent(e,{detail:t}):new CustomEvent(i.name,{detail:i.detail}),this.dispatchEvent(n))},getLast:(e,t=0)=>e[e.length-1-t]};#f(e,...t){Object.values(this.#h).forEach(n=>{n[e]&&n[e](...t)})}#g=e=>{if(this.#c.size>=2)return;e.isPrimary&&this.#c.clear();const t={records:[{x:e.clientX,y:e.clientY,timestamp:Date.now()}],target:e.target};this.#c.set(e.pointerId,t),this.#f("onPointerDown",e,t,this.#c)};#x=e=>{const t=this.#c.get(e.pointerId);t&&(t.records.push({x:e.clientX,y:e.clientY,timestamp:Date.now()}),this.#f("onPointerMove",e,t,this.#c))};#b=e=>{const t=this.#c.get(e.pointerId);t&&(this.#c.delete(e.pointerId),this.#f("onPointerUp",e,t,this.#c))};#k=e=>this.#f("onWheel",e);stop=e=>{const t=e=>{if(!(e.name in this.#h))return;const t=this.#h[e.name];t.onStop&&t.onStop(),this.#p[e.name]=t,delete this.#h[e.name]};return e?on(e).forEach(e=>{t(e)}):(()=>{this.#l.removeEventListener("pointerdown",this.#g),this.#d.removeEventListener("pointermove",this.#x),this.#d.removeEventListener("pointerup",this.#b),this.#l.removeEventListener("wheel",this.#k),this.#f("onStop")})(),this};start=e=>{const t=e=>{if(!(e.name in this.#p))return;const t=this.#p[e.name];t.onStart&&t.onStart(),this.#h[e.name]=t,delete this.#p[e.name]};return e?on(e).forEach(e=>{t(e)}):(()=>{this.#l.addEventListener("pointerdown",this.#g),this.#d.addEventListener("pointermove",this.#x),this.#d.addEventListener("pointerup",this.#b),this.#l.addEventListener("wheel",this.#k),this.#f("onStart")})(),this};dispose=()=>{this.stop(),this.#u=null,this.#f("dispose")}}const on=e=>Array.isArray(e)?e:[e];class an extends bt{_overlaysLayer=document.createElement("div");overlays={};selectedId=null;eventListeners={};DM;IH;parse;get overlaysLayer(){if(!this._overlaysLayer)throw wt;return this._overlaysLayer}hooks={onInteractionStart:kt.makeHook(),onInteractionEnd:kt.makeHook()};constructor(...e){super(...e),this.parse=this.options.markdownParser||(e=>e),this.DM=this.container.get(yt),this.IH=this.container.get(ln,{lazy:!0});this.container.get(Tt).hooks.onRefresh.subscribe(this.updateOverlays),this._overlaysLayer=document.createElement("div"),this._overlaysLayer.className="overlays",this.DM.data.container.appendChild(this.overlaysLayer),this.onStart(this.start),this.onDispose(this.dispose)}start=()=>{this.IH().onClick.subscribe(this.select);const e=this.DM.data.canvasBaseDir,t=async t=>{switch(t.type){case"text":this.updateOverlay(t,t.text,"text");break;case"file":t.file.match(/\.md$/i)?this.loadMarkdownForNode(t):t.file.match(/\.(png|jpg|jpeg|gif|svg|webp)$/i)?this.updateOverlay(t,e+t.file,"image"):t.file.match(/\.(mp3|wav)$/i)&&this.updateOverlay(t,e+t.file,"audio");break;case"link":this.updateOverlay(t,t.url,"link")}};Object.values(this.DM.data.nodeMap).forEach(e=>{t(e)})};select=e=>{const t=this.selectedId?this.overlays[this.selectedId]:null,n=e?this.overlays[e]:null;t&&t.classList.remove("active"),n?(n.classList.add("active"),this.hooks.onInteractionStart()):this.hooks.onInteractionEnd(),this.selectedId=e};loadMarkdownForNode=async e=>{let t;this.updateOverlay(e,"Loading...","text");try{const n=await fetch(this.DM.data.canvasBaseDir+e.file),i=await n.text(),s=i.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);t=s?await this.parse(s[2]):await this.parse(i)}catch(n){console.error("[JSONCanvasViewer] Failed to load markdown:",n),t="Failed to load content."}this.updateOverlay(e,t,"text")};updateOverlays=()=>{const e=this.DM.data;this.overlaysLayer.style.transform=`translate(${e.offsetX}px, ${e.offsetY}px) scale(${e.scale})`};async updateOverlay(e,t,n){let i=this.overlays[e.id];if(i){if("text"===n){i.getElementsByClassName("parsed-content-wrapper")[0].innerHTML=t}}else i=await this.constructOverlay(e,t,n),this.overlaysLayer.appendChild(i),this.overlays[e.id]=i,i.style.left=`${e.x}px`,i.style.top=`${e.y}px`,i.style.width=`${e.width}px`,i.style.height=`${e.height}px`}async constructOverlay(e,t,n){const i=kt.getColor(e.color),s=document.createElement("div");switch(s.classList.add("overlay-container"),s.id=e.id,s.style.backgroundColor=i.background,s.style.setProperty("--active-color",i.active),n){case"text":{s.classList.add("markdown-content");const e=document.createElement("div");e.innerHTML=await this.parse(t||""),e.classList.add("parsed-content-wrapper"),s.appendChild(e);break}case"link":{const e=document.createElement("iframe");e.src=t,e.sandbox="allow-scripts allow-same-origin",e.className="link-iframe",e.loading="lazy",s.appendChild(e);break}case"audio":{const e=document.createElement("audio");e.className="audio",e.src=t,e.controls=!0,s.appendChild(e);break}case"image":{const e=document.createElement("img");e.src=t,e.loading="lazy",s.appendChild(e)}}switch(n){case"link":case"audio":{const e=document.createElement("div");e.className="click-layer",s.appendChild(e)}}const r=document.createElement("div");r.className="overlay-border",r.style.borderColor=i.border,s.appendChild(r);const o=()=>{e.id===this.selectedId&&this.hooks.onInteractionStart()},a=()=>{e.id===this.selectedId&&this.hooks.onInteractionEnd()};return s.addEventListener("pointerenter",o),s.addEventListener("pointerleave",a),s.addEventListener("touchstart",o),s.addEventListener("touchend",a),this.eventListeners[e.id]=[o,a],s}dispose=()=>{for(;this.overlaysLayer.firstElementChild;){const e=this.overlaysLayer.firstElementChild;if(this.eventListeners[e.id]){const t=this.eventListeners[e.id][0],n=this.eventListeners[e.id][1];if(!t||!n)throw wt;e.removeEventListener("pointerenter",t),e.removeEventListener("pointerleave",n),e.removeEventListener("touchstart",t),e.removeEventListener("touchend",n),this.eventListeners[e.id][0]=null,this.eventListeners[e.id][1]=null}e.remove()}this.overlaysLayer.remove(),this._overlaysLayer=null}}class ln extends bt{pointeract;DM;onClick=kt.makeHook();stopInteraction;startInteraction;constructor(...e){super(...e),this.DM=this.container.get(yt);const t=Object.assign(this.options.pointeract||{},{coordinateOutput:"relative"});this.pointeract=new rn(this.DM.data.container,[Jt,en,sn,nn,tn],t),this.startInteraction=this.pointeract.start,this.stopInteraction=this.pointeract.stop;const n=this.container.get(an);n.hooks.onInteractionStart.subscribe(this.stopInteraction),n.hooks.onInteractionEnd.subscribe(this.startInteraction),this.onStart(this.start),this.onDispose(this.dispose)}start=()=>{this.pointeract.on("pan",this.onPan),this.pointeract.on("drag",this.onPan),this.pointeract.on("zoom",this.onZoom),this.pointeract.on("trueClick",this.onTrueClick),this.pointeract.start()};onPan=e=>{this.DM.pan(e.detail)};onZoom=e=>{const t=e.detail;this.DM.zoom(t.factor,{x:t.x,y:t.y})};onTrueClick=e=>{const t=e.detail;if((n=e.detail.target)&&(n.closest(".controls")||n.closest("button")||n.closest("input")))return;var n;const i=this.DM.findNodeAt({x:t.x,y:t.y});this.onClick(i?i.id:null)};dispose=()=>{this.pointeract.off("pan",this.onPan),this.pointeract.off("zoom",this.onZoom),this.pointeract.off("trueClick",this.onTrueClick),this.pointeract.dispose()}}const cn="#fff";class hn extends bt{_canvas;ctx;DM;zoomInOptimize={lastDrawnScale:0,lastDrawnViewport:{left:0,right:0,top:0,bottom:0},timeout:null,lastCallTime:0};get canvas(){if(null===this._canvas)throw wt;return this._canvas}constructor(...e){super(...e);const t=this.container.get(Tt);t.hooks.onRefresh.subscribe(this.redraw),t.hooks.onResize.subscribe(this.optimizeDPR),this.DM=this.container.get(yt),this._canvas=document.createElement("canvas"),this._canvas.className="main-canvas",this.ctx=this._canvas.getContext("2d"),this.DM.data.container.appendChild(this._canvas),this.onDispose(this.dispose)}optimizeDPR=()=>{const e=this.DM.data.container;kt.resizeCanvasForDPR(this.canvas,e.offsetWidth,e.offsetHeight)};redraw=()=>{this.zoomInOptimize.timeout&&(clearTimeout(this.zoomInOptimize.timeout),this.zoomInOptimize.timeout=null);const e=Date.now(),t=this.DM.data.offsetX,n=this.DM.data.offsetY,i=this.DM.data.scale,s=this.getCurrentViewport(t,n,i);if(this.isViewportInside(s,this.zoomInOptimize.lastDrawnViewport)&&i!==this.zoomInOptimize.lastDrawnScale){if(e-this.zoomInOptimize.lastCallTime<500)return this.zoomInOptimize.timeout=setTimeout(()=>{this.trueRedraw(t,n,i,s),this.zoomInOptimize.lastCallTime=e,this.zoomInOptimize.timeout=null},60),void this.fakeRedraw(s,i)}this.zoomInOptimize.lastCallTime=e,this.trueRedraw(t,n,i,s)};trueRedraw(e,t,n,i){this.zoomInOptimize.lastDrawnViewport=i,this.zoomInOptimize.lastDrawnScale=n,this.canvas.style.transform="",this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(e,t),this.ctx.scale(n,n);const s=this.DM.data.canvasData;s.nodes.forEach(e=>{switch(e.type){case"group":this.drawGroup(e,n);break;case"file":this.drawFileNode(e)}}),s.edges.forEach(e=>{this.drawEdge(e)}),this.ctx.restore()}fakeRedraw(e,t){const n=t/this.zoomInOptimize.lastDrawnScale,i=(this.zoomInOptimize.lastDrawnViewport.left-e.left)*t,s=(this.zoomInOptimize.lastDrawnViewport.top-e.top)*t;this.canvas.style.transform=`translate(${i}px, ${s}px) scale(${n})`}isViewportInside=(e,t)=>e.left>t.left&&e.top>t.top&&e.right<t.right&&e.bottom<t.bottom;getCurrentViewport=(e,t,n)=>{const i=-e/n,s=-t/n,r=this.DM.data.container;return{left:i,top:s,right:i+r.clientWidth/n,bottom:s+r.clientHeight/n}};drawLabelBar=(e,t,n,i,s)=>{const r=30*s,o=6*s,a=8*s,l=16*s,c=6*s;this.ctx.save(),this.ctx.translate(e,t),this.ctx.scale(1/s,1/s),this.ctx.font=`${l}px 'Inter', sans-serif`;const h=this.ctx.measureText(n).width+2*c;this.ctx.translate(0,-r-a),this.ctx.fillStyle=i,this.ctx.beginPath(),this.ctx.moveTo(o,0),this.ctx.lineTo(h-o,0),this.ctx.quadraticCurveTo(h,0,h,o),this.ctx.lineTo(h,r-o),this.ctx.quadraticCurveTo(h,r,h-o,r),this.ctx.lineTo(o,r),this.ctx.quadraticCurveTo(0,r,0,r-o),this.ctx.lineTo(0,o),this.ctx.quadraticCurveTo(0,0,o,0),this.ctx.closePath(),this.ctx.fill(),this.ctx.fillStyle=cn,this.ctx.fillText(n,c,.65*r),this.ctx.restore()};drawNodeBackground=e=>{const t=kt.getColor(e.color);this.ctx.globalAlpha=1,this.ctx.fillStyle=t.background,kt.drawRoundRect(this.ctx,e.x+1,e.y+1,e.width-2,e.height-2,12),this.ctx.fill(),this.ctx.strokeStyle=t.border,this.ctx.lineWidth=2,kt.drawRoundRect(this.ctx,e.x,e.y,e.width,e.height,12),this.ctx.stroke()};drawGroup=(e,t)=>{this.drawNodeBackground(e),e.label&&this.drawLabelBar(e.x,e.y,e.label,kt.getColor(e.color).active,t)};drawFileNode=e=>{this.ctx.fillStyle=cn,this.ctx.font="16px sans-serif",this.ctx.fillText(e.file,e.x+5,e.y-10)};drawEdge=e=>{const{fromNode:t,toNode:n}=this.getEdgeNodes(e),i=kt.getAnchorCoord,[s,r]=i(t,e.fromSide),[o,a]=i(n,e.toSide),{active:l}=kt.getColor(e.color);let[c,h,p,u]=[0,0,0,0];if(e.controlPoints?[c,h,p,u]=e.controlPoints:([c,h,p,u]=this.getControlPoints(s,r,o,a,e.fromSide,e.toSide),e.controlPoints=[c,h,p,u]),this.drawCurvedPath(s,r,o,a,c,h,p,u,l),this.drawArrowhead(o,a,p,u,l),e.label){const t=.5,n=(1-t)**3*s+3*(1-t)**2*t*c+3*(1-t)*t*t*p+t**3*o,i=(1-t)**3*r+3*(1-t)**2*t*h+3*(1-t)*t*t*u+t**3*a;this.ctx.font="18px sans-serif";const l=8,d=this.ctx.measureText(e.label).width+2*l,m=20;this.ctx.fillStyle="#222",this.ctx.beginPath(),kt.drawRoundRect(this.ctx,n-d/2,i-m/2-2,d,m,4),this.ctx.fill(),this.ctx.fillStyle="#ccc",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(e.label,n,i-2),this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic"}};getEdgeNodes=e=>({fromNode:this.DM.data.nodeMap[e.fromNode],toNode:this.DM.data.nodeMap[e.toNode]});getControlPoints=(e,t,n,i,s,r)=>{const o=n-e,a=i-t,l=Math.min(Math.abs(o),Math.abs(a))+.3*Math.max(Math.abs(o),Math.abs(a)),c=(h=.5*l,p=60,u=300,Math.max(p,Math.min(u,h)));var h,p,u;let d=e,m=t,f=n,g=i;switch(s){case"top":m=t-c;break;case"bottom":m=t+c;break;case"left":d=e-c;break;case"right":d=e+c}switch(r){case"top":g=i-c;break;case"bottom":g=i+c;break;case"left":f=n-c;break;case"right":f=n+c}return[d,m,f,g]};drawCurvedPath=(e,t,n,i,s,r,o,a,l)=>{this.ctx.beginPath(),this.ctx.moveTo(e,t),this.ctx.bezierCurveTo(s,r,o,a,n,i),this.ctx.strokeStyle=l,this.ctx.lineWidth=2,this.ctx.stroke()};drawArrowhead=(e,t,n,i,s)=>{const r=e-n,o=t-i,a=Math.sqrt(r*r+o*o);if(0===a)return;const l=r/a,c=o/a,h=e-12*l-7*c,p=t-12*c+7*l,u=e-12*l+7*c,d=t-12*c-7*l;this.ctx.beginPath(),this.ctx.fillStyle=s,this.ctx.moveTo(e,t),this.ctx.lineTo(h,p),this.ctx.lineTo(u,d),this.ctx.closePath(),this.ctx.fill()};dispose=()=>{this.zoomInOptimize.timeout&&(clearTimeout(this.zoomInOptimize.timeout),this.zoomInOptimize.timeout=null),this.canvas.remove(),this._canvas=null}}class pn{options;allModules;IO=null;onStart=kt.makeHook();onDispose=kt.makeHook(!0);container;constructor(e,t){this.container=new Qt,this.options=e;this.allModules=[yt,Tt,an,ln,hn,...t||[]],this.allModules.forEach(e=>{this.container.bind({provide:e,useFactory:()=>new e(this.container,this.options,this.onStart,this.onDispose)})}),this.options.lazyLoading?(this.IO=new IntersectionObserver(this.onVisibilityCheck,{root:null,rootMargin:"50px",threshold:0}),this.IO.observe(this.options.container)):this.load()}load=()=>{this.allModules.forEach(e=>{this.container.get(e)}),this.onStart()};onVisibilityCheck=e=>{e.forEach(e=>{if(e.isIntersecting)return this.load(),this.IO?.disconnect(),void(this.IO=null)})};dispose=()=>{this.IO?.disconnect(),this.IO=null;const e=this.options.container;for(;e.firstChild;)e.firstChild.remove();this.onDispose(),this.container.unbindAll()}}const un=async e=>ie.sanitize(await xt(e));async function dn(e){return await fetch(e).then(e=>e.json())}export{St as Controls,Et as DebugPanel,pn as JSONCanvasViewer,_t as Minimap,Mt as MistouchPreventer,dn as fetchCanvas,un as parser};
@@ -0,0 +1,2 @@
1
+ "use strict";class t{constructor(t,e,s,i){this.container=t,Object.assign(this.options,e),this.onStart=s.subscribe,this.onDispose=i.subscribe}onStart;onDispose;options={}}const e={round:function(t,e){const s=10**e;return Math.round(t*s)/s},resizeCanvasForDPR:function(t,e,s){const i=window.devicePixelRatio||1,o=t.getContext("2d");if(!o)throw new Error("[JSONCanvasViewer] This error is unexpected, probably caused uncontrollable runtime errors. Please contact the developer and show how to reproduce.");t.width=Math.round(e*i),t.height=Math.round(s*i),o.setTransform(1,0,0,1,0,0),o.scale(i,i)},applyStyles:function(t,e){const s=document.createElement("style");s.innerHTML=e,t.appendChild(s)},drawRoundRect:function(t,e,s,i,o,a){t.beginPath(),t.moveTo(e+a,s),t.lineTo(e+i-a,s),t.quadraticCurveTo(e+i,s,e+i,s+a),t.lineTo(e+i,s+o-a),t.quadraticCurveTo(e+i,s+o,e+i-a,s+o),t.lineTo(e+a,s+o),t.quadraticCurveTo(e,s+o,e,s+o-a),t.lineTo(e,s+a),t.quadraticCurveTo(e,s,e+a,s),t.closePath()},getAnchorCoord:function(t,e){const s=t.x+t.width/2,i=t.y+t.height/2;switch(e){case"top":return[s,t.y];case"bottom":return[s,t.y+t.height];case"left":return[t.x,i];case"right":return[t.x+t.width,i];default:return[s,i]}},getColor:function(t="0"){let e=null;if(1===t.length)switch(t){case"1":e="rgba(255, 120, 129, ?)";break;case"2":e="rgba(251, 187, 131, ?)";break;case"3":e="rgba(255, 232, 139, ?)";break;case"4":e="rgba(124, 211, 124, ?)";break;case"5":e="rgba(134, 223, 226, ?)";break;case"6":e="rgba(203, 158, 255, ?)";break;default:e="rgba(140, 140, 140, ?)"}else{const s=function(t){const e=t.replace("#","");return{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16)}}(t);e=`rgba(${s.r}, ${s.g}, ${s.b}, ?)`}return{border:e.replace("?","0.75"),background:e.replace("?","0.1"),active:e.replace("?","1")}},makeHook:function(t=!1){const e=(...s)=>{if(t){Array.from(e.subs).reverse().forEach(t=>{t(...s)})}else e.subs.forEach(t=>{t(...s)})};return e.subs=new Set,e.subscribe=t=>{e.subs.add(t)},e.unsubscribe=t=>{e.subs.delete(t)},e}},s=new Error("[JSONCanvasViewer] Resource hasn't been set up or has been disposed.");const i=800;class o extends t{spatialGrid=null;onToggleFullscreen=e.makeHook();data;constructor(...t){super(...t);const s=this.options.container;for(;s.firstElementChild;)s.firstElementChild.remove();s.innerHTML="";const i=this.options.noShadow||!1?s:s.attachShadow({mode:"open"});e.applyStyles(i,".full,.click-layer,.link-iframe,.audio{top:0;left:0;width:100%;height:100%;position:absolute}.flex-center,.overlay-container.markdown-content{display:flex;justify-content:center;align-items:center}.container{--contentTransition: color .2s, opacity .2s, text-shadow .2s, fill .2s;--containerTransition: background .2s, opacity .2s, box-shadow .2s, border .2s, filter .2s, backdrop-filter .2s;color:#fff;fill:#fff;stroke:#fff;position:relative;width:100%;height:100%;overflow:hidden;background-color:#141414}.container.numb,.container.numb *{pointer-events:none!important}.main-canvas{width:100%;height:100%;transform-origin:top left}.overlays{position:absolute;top:0;left:0;width:10000px;height:10000px;transform-origin:top left;will-change:transform}.parsed-content-wrapper{font-family:sans-serif;box-sizing:border-box;max-width:100%;max-height:100%;padding:10px 6px;pointer-events:none;overflow:hidden;scrollbar-gutter:stable both-edges;display:flex;flex-direction:column;gap:12px}@supports not (scrollbar-gutter: stable both-edges){.parsed-content-wrapper{padding:10px}}.overlay-container{position:absolute;box-sizing:border-box;border-radius:12px;overflow:hidden;-webkit-user-select:none;user-select:none;contain:strict;content-visibility:auto}.overlay-container:hover{box-shadow:0 2px 12px #00000080}.overlay-container{transition:var(--containerTransition)}.overlay-container .overlay-border{box-sizing:border-box;pointer-events:none;position:absolute;top:0;left:0;width:100%;height:100%;border-width:2px;border-style:solid;border-radius:12px;transition:var(--containerTransition)}.overlay-container img{width:100%;height:100%;object-fit:cover;pointer-events:none}.overlay-container.active .overlay-border{border:6px solid var(--active-color)}.overlay-container.markdown-content{position:absolute;padding:0 7px}.overlay-container.markdown-content.active .parsed-content-wrapper{overflow:auto;-webkit-user-select:text;user-select:text;pointer-events:auto}.overlay-container.markdown-content.rtl{direction:rtl;text-align:right}.link-iframe,.audio{border:none;background:transparent}.click-layer{background:transparent;pointer-events:auto}.active .click-layer{pointer-events:none}::-webkit-scrollbar{width:4px}::-webkit-scrollbar-track{background-color:transparent}::-webkit-scrollbar-thumb{border-radius:2px;background:#ffffff40}::-webkit-scrollbar-thumb:hover{background:#1e1e1ebf}p{font-size:16px;line-height:21px}.parsed-content-wrapper img{width:100%;border-radius:8px}h1{font-size:25px}h2{font-size:23px}h3{font-size:22px}h4{font-size:20px}h5{font-size:19px}h6{font-size:17px}p,h1,h2,h3,h4,h5,h6,ol,ul{margin:0}h1,h2{font-weight:800}h3,h4{font-weight:700}h5,h6{font-weight:600}code{background:#ffffff1a;padding:2px 4px;border-radius:8px}pre code{display:block;box-sizing:border-box;width:100%}pre:has(code),table{margin:6px 0}strong{color:#fe8e7c}em{color:#5affb2}a{text-decoration:none;color:#6dadd0;font-weight:800;font-style:italic;cursor:pointer;transition:var(--contentTransition)}a:hover{color:#86d3fd}hr{height:1px;width:100%;background-color:#fff3;border:none}li{margin:5px 0}ul{padding-left:16px}ol{padding-left:15px;padding-right:7.5px}table{border-collapse:collapse;border-radius:8px;overflow:hidden;width:100%}table th,table td{border:1px solid rgba(255,255,255,.2);padding:6px 10px;background:#ffffff0f;text-align:left}table th{background:#ffffff1f;font-weight:700}"+this.options.extraCSS);const o=document.createElement("div");o.classList.add("container"),i.appendChild(o);const a=Object.assign({nodes:[],edges:[]},this.options.canvas);this.data={canvasData:a,nodeMap:{},canvasBaseDir:this.processBaseDir(this.options.attachmentDir),nodeBounds:this.calculateNodeBounds(a),offsetX:0,offsetY:0,scale:1,container:o},this.data.canvasData.nodes.forEach(t=>{if("file"===t.type&&!t.file.includes("http")){const e=t.file.split("/");t.file=e[e.length-1]}this.data.nodeMap[t.id]=t}),this.buildSpatialGrid(),this.resetView(),this.onDispose(this.dispose)}processBaseDir=t=>{if(!t)return"./";const e=t?.slice(-1);return"/"===e?t:`${t}/`};findNodeAt=t=>{const{x:e,y:s}=this.C2W(this.C2C({x:t.x,y:t.y}));let o=[];if(this.spatialGrid){const t=`${Math.floor(e/i)},${Math.floor(s/i)}`;o=this.spatialGrid[t]||[]}else o=this.data.canvasData.nodes;for(const i of o)if(!(e<i.x||e>i.x+i.width||s<i.y||s>i.y+i.height||"non-interactive"===this.judgeInteract(i)))return i;return null};judgeInteract=t=>{switch(t?.type){case"text":case"link":return"select";case"file":return t.file.match(/\.(md|wav|mp3)$/i)?"select":"non-interactive";default:return"non-interactive"}};calculateNodeBounds(t){let e=1/0,s=1/0,i=-1/0,o=-1/0;t.nodes.forEach(t=>{e=Math.min(e,t.x),s=Math.min(s,t.y),i=Math.max(i,t.x+t.width),o=Math.max(o,t.y+t.height)});const a=i-e,r=o-s;return{minX:e,minY:s,maxX:i,maxY:o,width:a,height:r,centerX:e+a/2,centerY:s+r/2}}buildSpatialGrid(){const t=this.data.canvasData;if(!(t.nodes.length<50)){this.spatialGrid={};for(const e of t.nodes){const t=Math.floor(e.x/i),s=Math.floor((e.x+e.width)/i),o=Math.floor(e.y/i),a=Math.floor((e.y+e.height)/i);for(let i=t;i<=s;i++)for(let t=o;t<=a;t++){const s=`${i},${t}`;this.spatialGrid[s]||(this.spatialGrid[s]=[]),this.spatialGrid[s].push(e)}}}}zoom=(t,e)=>{const s=this.data.scale*t;this.zoomToScale(s,e)};zoomToScale=(t,e)=>{const s=Math.max(Math.min(t,20),.05),i=this.data.scale;if(s===i)return;const o=this.C2C(e);this.data.offsetX=e.x-o.x*s/i,this.data.offsetY=e.y-o.y*s/i,this.data.scale=s};pan=({x:t,y:e})=>{this.data.offsetX=this.data.offsetX+t,this.data.offsetY=this.data.offsetY+e};panToCoords=({x:t,y:e})=>{this.data.offsetX=t,this.data.offsetY=e};shiftFullscreen=(t="toggle")=>{document.fullscreenElement||"toggle"!==t&&"enter"!==t?!document.fullscreenElement||"toggle"!==t&&"exit"!==t||(document.exitFullscreen(),this.onToggleFullscreen(!1)):(this.data.container.requestFullscreen(),this.onToggleFullscreen(!0))};resetView=()=>{const t=this.data.nodeBounds,e=this.data.container;if(!t||!e)return;const s=t.width+200,i=t.height+200,o=e.clientWidth,a=e.clientHeight,r=o/s,n=a/i,l=Math.round(1e3*Math.min(r,n))/1e3,c={scale:l,offsetX:o/2-t.centerX*l,offsetY:a/2-t.centerY*l};this.data.offsetX=c.offsetX,this.data.offsetY=c.offsetY,this.data.scale=c.scale};C2C=({x:t,y:e})=>({x:t-this.data.offsetX,y:e-this.data.offsetY});C2W=({x:t,y:e})=>({x:t/this.data.scale,y:e/this.data.scale});middleViewer=()=>{const t=this.data.container;return{x:t.clientWidth/2,y:t.clientHeight/2,width:t.clientWidth,height:t.clientHeight}};dispose=()=>this.data.container.remove()}exports.BaseModule=t,exports.Controller=class extends t{animationId=null;resizeAnimationId=null;DM;resizeObserver;perFrame={lastScale:1,lastOffsets:{x:0,y:0}};lastResizeCenter={x:null,y:null};hooks={onResize:e.makeHook(),onRefresh:e.makeHook()};constructor(...t){super(...t),this.onStart(this.start),this.onDispose(this.dispose),this.DM=this.container.get(o),this.resizeObserver=new ResizeObserver(this.onResize)}start=()=>{this.resizeObserver.observe(this.DM.data.container),this.animationId=requestAnimationFrame(this.draw)};draw=()=>{this.perFrame.lastScale===this.DM.data.scale&&this.perFrame.lastOffsets.x===this.DM.data.offsetX&&this.perFrame.lastOffsets.y===this.DM.data.offsetY||this.refresh(),this.animationId=requestAnimationFrame(this.draw)};refresh=()=>{this.perFrame.lastScale=this.DM.data.scale,this.perFrame.lastOffsets={x:this.DM.data.offsetX,y:this.DM.data.offsetY},this.hooks.onRefresh()};onResize=()=>{this.resizeAnimationId=requestAnimationFrame(()=>{const t=this.DM.middleViewer();this.lastResizeCenter.x&&this.lastResizeCenter.y&&(this.DM.data.offsetX=this.DM.data.offsetX+t.x-this.lastResizeCenter.x,this.DM.data.offsetY=this.DM.data.offsetY+t.y-this.lastResizeCenter.y),this.lastResizeCenter.x=t.x,this.lastResizeCenter.y=t.y,this.hooks.onResize(t.width,t.height),this.refresh()})};dispose=()=>{this.animationId&&cancelAnimationFrame(this.animationId),this.resizeAnimationId&&cancelAnimationFrame(this.resizeAnimationId),this.resizeObserver.disconnect()}},exports.DataManager=o,exports.destroyError=s,exports.utilities=e;
2
+ //# sourceMappingURL=controller--Q72jFEw.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller--Q72jFEw.cjs","sources":["../src/core/baseModule.ts","../src/core/utilities.ts","../src/core/dataManager.ts","../src/core/controller.ts"],"sourcesContent":["import type { Container } from '@needle-di/core';\nimport type { DefaultOptions, Empty, GeneralFunction, GeneralObject } from '$/declarations';\nimport type utilities from '$/utilities';\n\ntype Hook = ReturnType<typeof utilities.makeHook>;\n\nexport type BaseArgs = [Container, GeneralObject, Hook, Hook];\n\nexport type GeneralModuleCtor = typeof BaseModule<GeneralObject>;\nexport type GeneralModule = BaseModule<GeneralObject>;\n\nexport class BaseModule<O extends GeneralObject = Empty> {\n\tonStart: (callback: GeneralFunction) => void;\n\tonDispose: (callback: GeneralFunction) => void;\n\tconstructor(\n\t\tprotected container: Container,\n\t\toptions: GeneralObject,\n\t\tonStart: Hook,\n\t\tonDispose: Hook,\n\t) {\n\t\tObject.assign(this.options, options);\n\t\tthis.onStart = onStart.subscribe;\n\t\tthis.onDispose = onDispose.subscribe;\n\t}\n\toptions = {} as DefaultOptions & O;\n}\n","import type { GeneralArguments } from '$/declarations';\n\nexport default {\n\tround,\n\tresizeCanvasForDPR,\n\tapplyStyles,\n\tdrawRoundRect,\n\tgetAnchorCoord,\n\tgetColor,\n\tmakeHook,\n};\n\nexport const destroyError = new Error(\"[JSONCanvasViewer] Resource hasn't been set up or has been disposed.\");\n\nfunction applyStyles(container: HTMLElement | ShadowRoot, styleString: string) {\n\tconst style = document.createElement('style');\n\tstyle.innerHTML = styleString;\n\tcontainer.appendChild(style);\n}\n\nfunction drawRoundRect(\n\tctx: CanvasRenderingContext2D,\n\tx: number,\n\ty: number,\n\twidth: number,\n\theight: number,\n\tradius: number,\n) {\n\tctx.beginPath();\n\tctx.moveTo(x + radius, y);\n\tctx.lineTo(x + width - radius, y);\n\tctx.quadraticCurveTo(x + width, y, x + width, y + radius);\n\tctx.lineTo(x + width, y + height - radius);\n\tctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);\n\tctx.lineTo(x + radius, y + height);\n\tctx.quadraticCurveTo(x, y + height, x, y + height - radius);\n\tctx.lineTo(x, y + radius);\n\tctx.quadraticCurveTo(x, y, x + radius, y);\n\tctx.closePath();\n}\n\nfunction getAnchorCoord(node: JSONCanvasNode, side: 'top' | 'bottom' | 'left' | 'right') {\n\tconst midX = node.x + node.width / 2;\n\tconst midY = node.y + node.height / 2;\n\tswitch (side) {\n\t\tcase 'top':\n\t\t\treturn [midX, node.y];\n\t\tcase 'bottom':\n\t\t\treturn [midX, node.y + node.height];\n\t\tcase 'left':\n\t\t\treturn [node.x, midY];\n\t\tcase 'right':\n\t\t\treturn [node.x + node.width, midY];\n\t\tdefault:\n\t\t\treturn [midX, midY];\n\t}\n}\n\nfunction getColor(colorIndex: string = '0') {\n\tlet themeColor = null;\n\n\tfunction hexToRgb(hex: string) {\n\t\tconst cleanHex = hex.replace('#', '');\n\t\tconst r = parseInt(cleanHex.substring(0, 2), 16);\n\t\tconst g = parseInt(cleanHex.substring(2, 4), 16);\n\t\tconst b = parseInt(cleanHex.substring(4, 6), 16);\n\t\treturn { r, g, b };\n\t}\n\n\tif (colorIndex.length === 1) {\n\t\tswitch (colorIndex) {\n\t\t\tcase '1':\n\t\t\t\tthemeColor = 'rgba(255, 120, 129, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '2':\n\t\t\t\tthemeColor = 'rgba(251, 187, 131, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '3':\n\t\t\t\tthemeColor = 'rgba(255, 232, 139, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '4':\n\t\t\t\tthemeColor = 'rgba(124, 211, 124, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '5':\n\t\t\t\tthemeColor = 'rgba(134, 223, 226, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '6':\n\t\t\t\tthemeColor = 'rgba(203, 158, 255, ?)';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthemeColor = 'rgba(140, 140, 140, ?)';\n\t\t}\n\t} else {\n\t\tconst rgb = hexToRgb(colorIndex);\n\t\tthemeColor = `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ?)`;\n\t}\n\treturn {\n\t\tborder: themeColor.replace('?', '0.75'),\n\t\tbackground: themeColor.replace('?', '0.1'),\n\t\tactive: themeColor.replace('?', '1'),\n\t};\n}\n\nfunction resizeCanvasForDPR(canvas: HTMLCanvasElement, width: number, height: number) {\n\tconst dpr = window.devicePixelRatio || 1;\n\tconst ctx = canvas.getContext('2d');\n\tif (!ctx)\n\t\tthrow new Error(\n\t\t\t'[JSONCanvasViewer] This error is unexpected, probably caused uncontrollable runtime errors. Please contact the developer and show how to reproduce.',\n\t\t);\n\tcanvas.width = Math.round(width * dpr);\n\tcanvas.height = Math.round(height * dpr);\n\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\tctx.scale(dpr, dpr);\n}\n\nfunction round(roundedNum: number, digits: number) {\n\tconst factor = 10 ** digits;\n\treturn Math.round(roundedNum * factor) / factor;\n}\n\nfunction makeHook<Args extends GeneralArguments = []>(reverse: boolean = false) {\n\ttype MatchingFunc = (...args: Args) => unknown;\n\ttype Hook = {\n\t\t(...args: Args): void;\n\t\tsubs: Set<MatchingFunc>;\n\t\tsubscribe(callback: MatchingFunc): void;\n\t\tunsubscribe(callback: MatchingFunc): void;\n\t};\n\tconst result: Hook = (...args: Args) => {\n\t\tif (reverse) {\n\t\t\tconst items = Array.from(result.subs).reverse();\n\t\t\titems.forEach(callback => {\n\t\t\t\tcallback(...args);\n\t\t\t});\n\t\t} else\n\t\t\tresult.subs.forEach(callback => {\n\t\t\t\tcallback(...args);\n\t\t\t});\n\t};\n\tresult.subs = new Set();\n\tresult.subscribe = (callback: MatchingFunc) => {\n\t\tresult.subs.add(callback);\n\t};\n\tresult.unsubscribe = (callback: MatchingFunc) => {\n\t\tresult.subs.delete(callback);\n\t};\n\treturn result;\n}\n","import { type BaseArgs, BaseModule } from '$/baseModule';\nimport type { Coordinates, NodeBounds } from '$/declarations';\nimport style from '$/styles.scss?inline';\nimport utilities from '$/utilities';\n\nconst GRID_CELL_SIZE = 800;\nconst INITIAL_VIEWPORT_PADDING = 100;\n\ntype Options = {\n\tnoShadow?: boolean;\n\tcanvas: JSONCanvas;\n\tattachmentDir?: string;\n\textraCSS?: string;\n};\n\nexport default class DataManager extends BaseModule<Options> {\n\tprivate spatialGrid: Record<string, Array<JSONCanvasNode>> | null = null;\n\tonToggleFullscreen = utilities.makeHook<[boolean]>();\n\n\tdata: {\n\t\tcanvasData: Required<JSONCanvas>;\n\t\tnodeMap: Record<string, JSONCanvasNode>;\n\t\tcanvasBaseDir: string;\n\t\tnodeBounds: NodeBounds;\n\t\toffsetX: number;\n\t\toffsetY: number;\n\t\tscale: number;\n\t\tcontainer: HTMLDivElement;\n\t};\n\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tconst parentContainer = this.options.container;\n\t\twhile (parentContainer.firstElementChild) parentContainer.firstElementChild.remove();\n\t\tparentContainer.innerHTML = '';\n\n\t\tconst noShadow = this.options.noShadow || false;\n\t\tconst realContainer = noShadow ? parentContainer : parentContainer.attachShadow({ mode: 'open' });\n\n\t\tutilities.applyStyles(realContainer, style + this.options.extraCSS);\n\n\t\tconst HTMLContainer = document.createElement('div');\n\t\tHTMLContainer.classList.add('container');\n\t\trealContainer.appendChild(HTMLContainer);\n\t\tconst canvasData = Object.assign(\n\t\t\t{\n\t\t\t\tnodes: [],\n\t\t\t\tedges: [],\n\t\t\t},\n\t\t\tthis.options.canvas,\n\t\t);\n\n\t\tthis.data = {\n\t\t\tcanvasData: canvasData,\n\t\t\tnodeMap: {},\n\t\t\tcanvasBaseDir: this.processBaseDir(this.options.attachmentDir),\n\t\t\tnodeBounds: this.calculateNodeBounds(canvasData),\n\t\t\toffsetX: 0,\n\t\t\toffsetY: 0,\n\t\t\tscale: 1,\n\t\t\tcontainer: HTMLContainer,\n\t\t};\n\n\t\tthis.data.canvasData.nodes.forEach(node => {\n\t\t\tif (node.type === 'file' && !node.file.includes('http')) {\n\t\t\t\tconst file = node.file.split('/');\n\t\t\t\tnode.file = file[file.length - 1];\n\t\t\t}\n\t\t\tthis.data.nodeMap[node.id] = node;\n\t\t});\n\n\t\tthis.buildSpatialGrid();\n\t\tthis.resetView();\n\t\tthis.onDispose(this.dispose);\n\t}\n\n\tprivate processBaseDir = (baseDir: string | undefined) => {\n\t\tif (!baseDir) return './';\n\t\tconst lastChar = baseDir?.slice(-1);\n\t\tif (lastChar === '/') return baseDir;\n\t\treturn `${baseDir}/`;\n\t};\n\n\tfindNodeAt = (screenCoords: Coordinates) => {\n\t\tconst { x, y } = this.C2W(this.C2C({ x: screenCoords.x, y: screenCoords.y }));\n\t\tlet candidates: Array<JSONCanvasNode> = [];\n\t\tif (!this.spatialGrid) candidates = this.data.canvasData.nodes;\n\t\telse {\n\t\t\tconst col = Math.floor(x / GRID_CELL_SIZE);\n\t\t\tconst row = Math.floor(y / GRID_CELL_SIZE);\n\t\t\tconst key = `${col},${row}`;\n\t\t\tcandidates = this.spatialGrid[key] || [];\n\t\t}\n\t\tfor (const node of candidates) {\n\t\t\tif (\n\t\t\t\tx < node.x ||\n\t\t\t\tx > node.x + node.width ||\n\t\t\t\ty < node.y ||\n\t\t\t\ty > node.y + node.height ||\n\t\t\t\tthis.judgeInteract(node) === 'non-interactive'\n\t\t\t)\n\t\t\t\tcontinue;\n\t\t\treturn node;\n\t\t}\n\t\treturn null;\n\t};\n\n\t// how should the app handle node interactions\n\tprivate judgeInteract = (node: JSONCanvasNode | null) => {\n\t\tswitch (node?.type) {\n\t\t\tcase 'text':\n\t\t\tcase 'link':\n\t\t\t\treturn 'select';\n\t\t\tcase 'file': {\n\t\t\t\tif (node.file.match(/\\.(md|wav|mp3)$/i)) return 'select';\n\t\t\t\telse return 'non-interactive';\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn 'non-interactive';\n\t\t}\n\t};\n\n\tprivate calculateNodeBounds(canvasData: Required<JSONCanvas>) {\n\t\tlet minX = Infinity,\n\t\t\tminY = Infinity,\n\t\t\tmaxX = -Infinity,\n\t\t\tmaxY = -Infinity;\n\t\tcanvasData.nodes.forEach(node => {\n\t\t\tminX = Math.min(minX, node.x);\n\t\t\tminY = Math.min(minY, node.y);\n\t\t\tmaxX = Math.max(maxX, node.x + node.width);\n\t\t\tmaxY = Math.max(maxY, node.y + node.height);\n\t\t});\n\t\tconst width = maxX - minX;\n\t\tconst height = maxY - minY;\n\t\tconst centerX = minX + width / 2;\n\t\tconst centerY = minY + height / 2;\n\t\treturn { minX, minY, maxX, maxY, width, height, centerX, centerY };\n\t}\n\n\tprivate buildSpatialGrid() {\n\t\tconst canvasData = this.data.canvasData;\n\t\tif (canvasData.nodes.length < 50) return;\n\t\tthis.spatialGrid = {};\n\t\tfor (const node of canvasData.nodes) {\n\t\t\tconst minCol = Math.floor(node.x / GRID_CELL_SIZE);\n\t\t\tconst maxCol = Math.floor((node.x + node.width) / GRID_CELL_SIZE);\n\t\t\tconst minRow = Math.floor(node.y / GRID_CELL_SIZE);\n\t\t\tconst maxRow = Math.floor((node.y + node.height) / GRID_CELL_SIZE);\n\t\t\tfor (let col = minCol; col <= maxCol; col++) {\n\t\t\t\tfor (let row = minRow; row <= maxRow; row++) {\n\t\t\t\t\tconst key = `${col},${row}`;\n\t\t\t\t\tif (!this.spatialGrid[key]) this.spatialGrid[key] = [];\n\t\t\t\t\tthis.spatialGrid[key].push(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tzoom = (factor: number, origin: Coordinates) => {\n\t\tconst newScale = this.data.scale * factor;\n\t\tthis.zoomToScale(newScale, origin);\n\t};\n\tzoomToScale = (newScale: number, origin: Coordinates) => {\n\t\tconst validNewScale = Math.max(Math.min(newScale, 20), 0.05);\n\t\tconst scale = this.data.scale;\n\t\tif (validNewScale === scale) return;\n\t\tconst canvasCoords = this.C2C(origin);\n\t\tthis.data.offsetX = origin.x - (canvasCoords.x * validNewScale) / scale;\n\t\tthis.data.offsetY = origin.y - (canvasCoords.y * validNewScale) / scale;\n\t\tthis.data.scale = validNewScale;\n\t};\n\tpan = ({ x, y }: Coordinates) => {\n\t\tthis.data.offsetX = this.data.offsetX + x;\n\t\tthis.data.offsetY = this.data.offsetY + y;\n\t};\n\tpanToCoords = ({ x, y }: Coordinates) => {\n\t\tthis.data.offsetX = x;\n\t\tthis.data.offsetY = y;\n\t};\n\tshiftFullscreen = (option: string = 'toggle') => {\n\t\tif (!document.fullscreenElement && (option === 'toggle' || option === 'enter')) {\n\t\t\tthis.data.container.requestFullscreen();\n\t\t\tthis.onToggleFullscreen(true);\n\t\t} else if (document.fullscreenElement && (option === 'toggle' || option === 'exit')) {\n\t\t\tdocument.exitFullscreen();\n\t\t\tthis.onToggleFullscreen(false);\n\t\t}\n\t};\n\tresetView = () => {\n\t\tconst bounds = this.data.nodeBounds;\n\t\tconst container = this.data.container;\n\t\tif (!bounds || !container) return;\n\t\tconst contentWidth = bounds.width + INITIAL_VIEWPORT_PADDING * 2;\n\t\tconst contentHeight = bounds.height + INITIAL_VIEWPORT_PADDING * 2;\n\t\t// Use logical dimensions for scaling calculations\n\t\tconst viewWidth = container.clientWidth;\n\t\tconst viewHeight = container.clientHeight;\n\t\tconst scaleX = viewWidth / contentWidth;\n\t\tconst scaleY = viewHeight / contentHeight;\n\t\tconst newScale = Math.round(Math.min(scaleX, scaleY) * 1000) / 1000;\n\t\tconst contentCenterX = bounds.centerX;\n\t\tconst contentCenterY = bounds.centerY;\n\t\tconst initialView = {\n\t\t\tscale: newScale,\n\t\t\toffsetX: viewWidth / 2 - contentCenterX * newScale,\n\t\t\toffsetY: viewHeight / 2 - contentCenterY * newScale,\n\t\t};\n\t\tthis.data.offsetX = initialView.offsetX;\n\t\tthis.data.offsetY = initialView.offsetY;\n\t\tthis.data.scale = initialView.scale;\n\t};\n\n\t// Container to Canvas\n\tprivate C2C = ({ x: containerX, y: containerY }: Coordinates) => ({\n\t\tx: containerX - this.data.offsetX,\n\t\ty: containerY - this.data.offsetY,\n\t});\n\t// Canvas to World\n\tprivate C2W = ({ x: canvasX, y: canvasY }: Coordinates) => ({\n\t\tx: canvasX / this.data.scale,\n\t\ty: canvasY / this.data.scale,\n\t});\n\n\tmiddleViewer = () => {\n\t\tconst container = this.data.container;\n\t\treturn {\n\t\t\tx: container.clientWidth / 2,\n\t\t\ty: container.clientHeight / 2,\n\t\t\twidth: container.clientWidth,\n\t\t\theight: container.clientHeight,\n\t\t};\n\t};\n\n\tprivate dispose = () => this.data.container.remove();\n}\n","import { type BaseArgs, BaseModule } from '$/baseModule';\nimport DataManager from '$/dataManager';\nimport utilities from '$/utilities';\n\nexport default class Controller extends BaseModule {\n\tprivate animationId: null | number = null;\n\tprivate resizeAnimationId: null | number = null;\n\tprivate DM: DataManager;\n\tprivate resizeObserver: ResizeObserver;\n\tprivate perFrame = {\n\t\tlastScale: 1,\n\t\tlastOffsets: { x: 0, y: 0 },\n\t};\n\tprivate lastResizeCenter: {\n\t\tx: null | number;\n\t\ty: null | number;\n\t} = {\n\t\tx: null,\n\t\ty: null,\n\t};\n\n\thooks = {\n\t\tonResize: utilities.makeHook<[number, number]>(),\n\t\tonRefresh: utilities.makeHook(),\n\t};\n\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tthis.onStart(this.start);\n\t\tthis.onDispose(this.dispose);\n\t\tthis.DM = this.container.get(DataManager);\n\t\tthis.resizeObserver = new ResizeObserver(this.onResize);\n\t}\n\n\tprivate start = () => {\n\t\tthis.resizeObserver.observe(this.DM.data.container);\n\t\tthis.animationId = requestAnimationFrame(this.draw);\n\t};\n\n\tprivate draw = () => {\n\t\tif (\n\t\t\tthis.perFrame.lastScale !== this.DM.data.scale ||\n\t\t\tthis.perFrame.lastOffsets.x !== this.DM.data.offsetX ||\n\t\t\tthis.perFrame.lastOffsets.y !== this.DM.data.offsetY\n\t\t)\n\t\t\tthis.refresh();\n\t\tthis.animationId = requestAnimationFrame(this.draw);\n\t};\n\n\trefresh = () => {\n\t\tthis.perFrame.lastScale = this.DM.data.scale;\n\t\tthis.perFrame.lastOffsets = {\n\t\t\tx: this.DM.data.offsetX,\n\t\t\ty: this.DM.data.offsetY,\n\t\t};\n\t\tthis.hooks.onRefresh();\n\t};\n\n\tprivate onResize = () => {\n\t\tthis.resizeAnimationId = requestAnimationFrame(() => {\n\t\t\tconst center = this.DM.middleViewer();\n\t\t\tif (this.lastResizeCenter.x && this.lastResizeCenter.y) {\n\t\t\t\tthis.DM.data.offsetX = this.DM.data.offsetX + center.x - this.lastResizeCenter.x;\n\t\t\t\tthis.DM.data.offsetY = this.DM.data.offsetY + center.y - this.lastResizeCenter.y;\n\t\t\t}\n\t\t\tthis.lastResizeCenter.x = center.x;\n\t\t\tthis.lastResizeCenter.y = center.y;\n\t\t\tthis.hooks.onResize(center.width, center.height);\n\t\t\tthis.refresh();\n\t\t});\n\t};\n\n\tprivate dispose = () => {\n\t\tif (this.animationId) cancelAnimationFrame(this.animationId);\n\t\tif (this.resizeAnimationId) cancelAnimationFrame(this.resizeAnimationId);\n\t\tthis.resizeObserver.disconnect();\n\t};\n}\n"],"names":["BaseModule","constructor","container","options","onStart","onDispose","this","Object","assign","subscribe","utilities","round","roundedNum","digits","factor","Math","resizeCanvasForDPR","canvas","width","height","dpr","window","devicePixelRatio","ctx","getContext","Error","setTransform","scale","applyStyles","styleString","style","document","createElement","innerHTML","appendChild","drawRoundRect","x","y","radius","beginPath","moveTo","lineTo","quadraticCurveTo","closePath","getAnchorCoord","node","side","midX","midY","getColor","colorIndex","themeColor","length","rgb","hex","cleanHex","replace","r","parseInt","substring","g","b","hexToRgb","border","background","active","makeHook","reverse","result","args","Array","from","subs","forEach","callback","Set","add","unsubscribe","delete","destroyError","GRID_CELL_SIZE","DataManager","spatialGrid","onToggleFullscreen","data","super","parentContainer","firstElementChild","remove","realContainer","noShadow","attachShadow","mode","extraCSS","HTMLContainer","classList","canvasData","nodes","edges","nodeMap","canvasBaseDir","processBaseDir","attachmentDir","nodeBounds","calculateNodeBounds","offsetX","offsetY","type","file","includes","split","id","buildSpatialGrid","resetView","dispose","baseDir","lastChar","slice","findNodeAt","screenCoords","C2W","C2C","candidates","key","floor","judgeInteract","match","minX","Infinity","minY","maxX","maxY","min","max","centerX","centerY","minCol","maxCol","minRow","maxRow","col","row","push","zoom","origin","newScale","zoomToScale","validNewScale","canvasCoords","pan","panToCoords","shiftFullscreen","option","fullscreenElement","exitFullscreen","requestFullscreen","bounds","contentWidth","INITIAL_VIEWPORT_PADDING","contentHeight","viewWidth","clientWidth","viewHeight","clientHeight","scaleX","scaleY","initialView","containerX","containerY","canvasX","canvasY","middleViewer","animationId","resizeAnimationId","DM","resizeObserver","perFrame","lastScale","lastOffsets","lastResizeCenter","hooks","onResize","onRefresh","start","get","ResizeObserver","observe","requestAnimationFrame","draw","refresh","center","cancelAnimationFrame","disconnect"],"mappings":"aAWO,MAAMA,EAGZ,WAAAC,CACWC,EACVC,EACAC,EACAC,GAHUC,KAAAJ,UAAAA,EAKVK,OAAOC,OAAOF,KAAKH,QAASA,GAC5BG,KAAKF,QAAUA,EAAQK,UACvBH,KAAKD,UAAYA,EAAUI,SAC5B,CAXAL,QACAC,UAWAF,QAAU,CAAA,QCtBXO,EAAe,CACdC,MAiHD,SAAeC,EAAoBC,GAClC,MAAMC,EAAS,IAAMD,EACrB,OAAOE,KAAKJ,MAAMC,EAAaE,GAAUA,CAC1C,EAnHCE,mBAmGD,SAA4BC,EAA2BC,EAAeC,GACrE,MAAMC,EAAMC,OAAOC,kBAAoB,EACjCC,EAAMN,EAAOO,WAAW,MAC9B,IAAKD,EACJ,MAAM,IAAIE,MACT,uJAEFR,EAAOC,MAAQH,KAAKJ,MAAMO,EAAQE,GAClCH,EAAOE,OAASJ,KAAKJ,MAAMQ,EAASC,GACpCG,EAAIG,aAAa,EAAG,EAAG,EAAG,EAAG,EAAG,GAChCH,EAAII,MAAMP,EAAKA,EAChB,EA7GCQ,YASD,SAAqB1B,EAAqC2B,GACzD,MAAMC,EAAQC,SAASC,cAAc,SACrCF,EAAMG,UAAYJ,EAClB3B,EAAUgC,YAAYJ,EACvB,EAZCK,cAcD,SACCZ,EACAa,EACAC,EACAnB,EACAC,EACAmB,GAEAf,EAAIgB,YACJhB,EAAIiB,OAAOJ,EA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AAIyJ,EAAOzJ,EACjC/B,KAAK8K,MAAMC,SAASS,EAAO5K,MAAO4K,EAAO3K,QACzCb,KAAKuL,aAIC3E,QAAU,KACb5G,KAAKsK,aAAamB,qBAAqBzL,KAAKsK,aAC5CtK,KAAKuK,mBAAmBkB,qBAAqBzL,KAAKuK,mBACtDvK,KAAKyK,eAAeiB"}
@@ -0,0 +1,2 @@
1
+ class t{constructor(t,e,s,i){this.container=t,Object.assign(this.options,e),this.onStart=s.subscribe,this.onDispose=i.subscribe}onStart;onDispose;options={}}const e={round:function(t,e){const s=10**e;return Math.round(t*s)/s},resizeCanvasForDPR:function(t,e,s){const i=window.devicePixelRatio||1,o=t.getContext("2d");if(!o)throw new Error("[JSONCanvasViewer] This error is unexpected, probably caused uncontrollable runtime errors. Please contact the developer and show how to reproduce.");t.width=Math.round(e*i),t.height=Math.round(s*i),o.setTransform(1,0,0,1,0,0),o.scale(i,i)},applyStyles:function(t,e){const s=document.createElement("style");s.innerHTML=e,t.appendChild(s)},drawRoundRect:function(t,e,s,i,o,a){t.beginPath(),t.moveTo(e+a,s),t.lineTo(e+i-a,s),t.quadraticCurveTo(e+i,s,e+i,s+a),t.lineTo(e+i,s+o-a),t.quadraticCurveTo(e+i,s+o,e+i-a,s+o),t.lineTo(e+a,s+o),t.quadraticCurveTo(e,s+o,e,s+o-a),t.lineTo(e,s+a),t.quadraticCurveTo(e,s,e+a,s),t.closePath()},getAnchorCoord:function(t,e){const s=t.x+t.width/2,i=t.y+t.height/2;switch(e){case"top":return[s,t.y];case"bottom":return[s,t.y+t.height];case"left":return[t.x,i];case"right":return[t.x+t.width,i];default:return[s,i]}},getColor:function(t="0"){let e=null;if(1===t.length)switch(t){case"1":e="rgba(255, 120, 129, ?)";break;case"2":e="rgba(251, 187, 131, ?)";break;case"3":e="rgba(255, 232, 139, ?)";break;case"4":e="rgba(124, 211, 124, ?)";break;case"5":e="rgba(134, 223, 226, ?)";break;case"6":e="rgba(203, 158, 255, ?)";break;default:e="rgba(140, 140, 140, ?)"}else{const s=function(t){const e=t.replace("#","");return{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16)}}(t);e=`rgba(${s.r}, ${s.g}, ${s.b}, ?)`}return{border:e.replace("?","0.75"),background:e.replace("?","0.1"),active:e.replace("?","1")}},makeHook:function(t=!1){const e=(...s)=>{if(t){Array.from(e.subs).reverse().forEach(t=>{t(...s)})}else e.subs.forEach(t=>{t(...s)})};return e.subs=/* @__PURE__ */new Set,e.subscribe=t=>{e.subs.add(t)},e.unsubscribe=t=>{e.subs.delete(t)},e}},s=new Error("[JSONCanvasViewer] Resource hasn't been set up or has been disposed.");const i=800;class o extends t{spatialGrid=null;onToggleFullscreen=e.makeHook();data;constructor(...t){super(...t);const s=this.options.container;for(;s.firstElementChild;)s.firstElementChild.remove();s.innerHTML="";const i=this.options.noShadow||!1?s:s.attachShadow({mode:"open"});e.applyStyles(i,".full,.click-layer,.link-iframe,.audio{top:0;left:0;width:100%;height:100%;position:absolute}.flex-center,.overlay-container.markdown-content{display:flex;justify-content:center;align-items:center}.container{--contentTransition: color .2s, opacity .2s, text-shadow .2s, fill .2s;--containerTransition: background .2s, opacity .2s, box-shadow .2s, border .2s, filter .2s, backdrop-filter .2s;color:#fff;fill:#fff;stroke:#fff;position:relative;width:100%;height:100%;overflow:hidden;background-color:#141414}.container.numb,.container.numb *{pointer-events:none!important}.main-canvas{width:100%;height:100%;transform-origin:top left}.overlays{position:absolute;top:0;left:0;width:10000px;height:10000px;transform-origin:top left;will-change:transform}.parsed-content-wrapper{font-family:sans-serif;box-sizing:border-box;max-width:100%;max-height:100%;padding:10px 6px;pointer-events:none;overflow:hidden;scrollbar-gutter:stable both-edges;display:flex;flex-direction:column;gap:12px}@supports not (scrollbar-gutter: stable both-edges){.parsed-content-wrapper{padding:10px}}.overlay-container{position:absolute;box-sizing:border-box;border-radius:12px;overflow:hidden;-webkit-user-select:none;user-select:none;contain:strict;content-visibility:auto}.overlay-container:hover{box-shadow:0 2px 12px #00000080}.overlay-container{transition:var(--containerTransition)}.overlay-container .overlay-border{box-sizing:border-box;pointer-events:none;position:absolute;top:0;left:0;width:100%;height:100%;border-width:2px;border-style:solid;border-radius:12px;transition:var(--containerTransition)}.overlay-container img{width:100%;height:100%;object-fit:cover;pointer-events:none}.overlay-container.active .overlay-border{border:6px solid var(--active-color)}.overlay-container.markdown-content{position:absolute;padding:0 7px}.overlay-container.markdown-content.active .parsed-content-wrapper{overflow:auto;-webkit-user-select:text;user-select:text;pointer-events:auto}.overlay-container.markdown-content.rtl{direction:rtl;text-align:right}.link-iframe,.audio{border:none;background:transparent}.click-layer{background:transparent;pointer-events:auto}.active .click-layer{pointer-events:none}::-webkit-scrollbar{width:4px}::-webkit-scrollbar-track{background-color:transparent}::-webkit-scrollbar-thumb{border-radius:2px;background:#ffffff40}::-webkit-scrollbar-thumb:hover{background:#1e1e1ebf}p{font-size:16px;line-height:21px}.parsed-content-wrapper img{width:100%;border-radius:8px}h1{font-size:25px}h2{font-size:23px}h3{font-size:22px}h4{font-size:20px}h5{font-size:19px}h6{font-size:17px}p,h1,h2,h3,h4,h5,h6,ol,ul{margin:0}h1,h2{font-weight:800}h3,h4{font-weight:700}h5,h6{font-weight:600}code{background:#ffffff1a;padding:2px 4px;border-radius:8px}pre code{display:block;box-sizing:border-box;width:100%}pre:has(code),table{margin:6px 0}strong{color:#fe8e7c}em{color:#5affb2}a{text-decoration:none;color:#6dadd0;font-weight:800;font-style:italic;cursor:pointer;transition:var(--contentTransition)}a:hover{color:#86d3fd}hr{height:1px;width:100%;background-color:#fff3;border:none}li{margin:5px 0}ul{padding-left:16px}ol{padding-left:15px;padding-right:7.5px}table{border-collapse:collapse;border-radius:8px;overflow:hidden;width:100%}table th,table td{border:1px solid rgba(255,255,255,.2);padding:6px 10px;background:#ffffff0f;text-align:left}table th{background:#ffffff1f;font-weight:700}"+this.options.extraCSS);const o=document.createElement("div");o.classList.add("container"),i.appendChild(o);const a=Object.assign({nodes:[],edges:[]},this.options.canvas);this.data={canvasData:a,nodeMap:{},canvasBaseDir:this.processBaseDir(this.options.attachmentDir),nodeBounds:this.calculateNodeBounds(a),offsetX:0,offsetY:0,scale:1,container:o},this.data.canvasData.nodes.forEach(t=>{if("file"===t.type&&!t.file.includes("http")){const e=t.file.split("/");t.file=e[e.length-1]}this.data.nodeMap[t.id]=t}),this.buildSpatialGrid(),this.resetView(),this.onDispose(this.dispose)}processBaseDir=t=>{if(!t)return"./";const e=t?.slice(-1);return"/"===e?t:`${t}/`};findNodeAt=t=>{const{x:e,y:s}=this.C2W(this.C2C({x:t.x,y:t.y}));let o=[];if(this.spatialGrid){const t=`${Math.floor(e/i)},${Math.floor(s/i)}`;o=this.spatialGrid[t]||[]}else o=this.data.canvasData.nodes;for(const i of o)if(!(e<i.x||e>i.x+i.width||s<i.y||s>i.y+i.height||"non-interactive"===this.judgeInteract(i)))return i;return null};judgeInteract=t=>{switch(t?.type){case"text":case"link":return"select";case"file":return t.file.match(/\.(md|wav|mp3)$/i)?"select":"non-interactive";default:return"non-interactive"}};calculateNodeBounds(t){let e=1/0,s=1/0,i=-1/0,o=-1/0;t.nodes.forEach(t=>{e=Math.min(e,t.x),s=Math.min(s,t.y),i=Math.max(i,t.x+t.width),o=Math.max(o,t.y+t.height)});const a=i-e,n=o-s;return{minX:e,minY:s,maxX:i,maxY:o,width:a,height:n,centerX:e+a/2,centerY:s+n/2}}buildSpatialGrid(){const t=this.data.canvasData;if(!(t.nodes.length<50)){this.spatialGrid={};for(const e of t.nodes){const t=Math.floor(e.x/i),s=Math.floor((e.x+e.width)/i),o=Math.floor(e.y/i),a=Math.floor((e.y+e.height)/i);for(let i=t;i<=s;i++)for(let t=o;t<=a;t++){const s=`${i},${t}`;this.spatialGrid[s]||(this.spatialGrid[s]=[]),this.spatialGrid[s].push(e)}}}}zoom=(t,e)=>{const s=this.data.scale*t;this.zoomToScale(s,e)};zoomToScale=(t,e)=>{const s=Math.max(Math.min(t,20),.05),i=this.data.scale;if(s===i)return;const o=this.C2C(e);this.data.offsetX=e.x-o.x*s/i,this.data.offsetY=e.y-o.y*s/i,this.data.scale=s};pan=({x:t,y:e})=>{this.data.offsetX=this.data.offsetX+t,this.data.offsetY=this.data.offsetY+e};panToCoords=({x:t,y:e})=>{this.data.offsetX=t,this.data.offsetY=e};shiftFullscreen=(t="toggle")=>{document.fullscreenElement||"toggle"!==t&&"enter"!==t?!document.fullscreenElement||"toggle"!==t&&"exit"!==t||(document.exitFullscreen(),this.onToggleFullscreen(!1)):(this.data.container.requestFullscreen(),this.onToggleFullscreen(!0))};resetView=()=>{const t=this.data.nodeBounds,e=this.data.container;if(!t||!e)return;const s=t.width+200,i=t.height+200,o=e.clientWidth,a=e.clientHeight,n=o/s,r=a/i,l=Math.round(1e3*Math.min(n,r))/1e3,c={scale:l,offsetX:o/2-t.centerX*l,offsetY:a/2-t.centerY*l};this.data.offsetX=c.offsetX,this.data.offsetY=c.offsetY,this.data.scale=c.scale};C2C=({x:t,y:e})=>({x:t-this.data.offsetX,y:e-this.data.offsetY});C2W=({x:t,y:e})=>({x:t/this.data.scale,y:e/this.data.scale});middleViewer=()=>{const t=this.data.container;return{x:t.clientWidth/2,y:t.clientHeight/2,width:t.clientWidth,height:t.clientHeight}};dispose=()=>this.data.container.remove()}class a extends t{animationId=null;resizeAnimationId=null;DM;resizeObserver;perFrame={lastScale:1,lastOffsets:{x:0,y:0}};lastResizeCenter={x:null,y:null};hooks={onResize:e.makeHook(),onRefresh:e.makeHook()};constructor(...t){super(...t),this.onStart(this.start),this.onDispose(this.dispose),this.DM=this.container.get(o),this.resizeObserver=new ResizeObserver(this.onResize)}start=()=>{this.resizeObserver.observe(this.DM.data.container),this.animationId=requestAnimationFrame(this.draw)};draw=()=>{this.perFrame.lastScale===this.DM.data.scale&&this.perFrame.lastOffsets.x===this.DM.data.offsetX&&this.perFrame.lastOffsets.y===this.DM.data.offsetY||this.refresh(),this.animationId=requestAnimationFrame(this.draw)};refresh=()=>{this.perFrame.lastScale=this.DM.data.scale,this.perFrame.lastOffsets={x:this.DM.data.offsetX,y:this.DM.data.offsetY},this.hooks.onRefresh()};onResize=()=>{this.resizeAnimationId=requestAnimationFrame(()=>{const t=this.DM.middleViewer();this.lastResizeCenter.x&&this.lastResizeCenter.y&&(this.DM.data.offsetX=this.DM.data.offsetX+t.x-this.lastResizeCenter.x,this.DM.data.offsetY=this.DM.data.offsetY+t.y-this.lastResizeCenter.y),this.lastResizeCenter.x=t.x,this.lastResizeCenter.y=t.y,this.hooks.onResize(t.width,t.height),this.refresh()})};dispose=()=>{this.animationId&&cancelAnimationFrame(this.animationId),this.resizeAnimationId&&cancelAnimationFrame(this.resizeAnimationId),this.resizeObserver.disconnect()}}export{t as B,a as C,o as D,s as d,e as u};
2
+ //# sourceMappingURL=controller-siZ5v-SD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller-siZ5v-SD.js","sources":["../src/core/baseModule.ts","../src/core/utilities.ts","../src/core/dataManager.ts","../src/core/controller.ts"],"sourcesContent":["import type { Container } from '@needle-di/core';\nimport type { DefaultOptions, Empty, GeneralFunction, GeneralObject } from '$/declarations';\nimport type utilities from '$/utilities';\n\ntype Hook = ReturnType<typeof utilities.makeHook>;\n\nexport type BaseArgs = [Container, GeneralObject, Hook, Hook];\n\nexport type GeneralModuleCtor = typeof BaseModule<GeneralObject>;\nexport type GeneralModule = BaseModule<GeneralObject>;\n\nexport class BaseModule<O extends GeneralObject = Empty> {\n\tonStart: (callback: GeneralFunction) => void;\n\tonDispose: (callback: GeneralFunction) => void;\n\tconstructor(\n\t\tprotected container: Container,\n\t\toptions: GeneralObject,\n\t\tonStart: Hook,\n\t\tonDispose: Hook,\n\t) {\n\t\tObject.assign(this.options, options);\n\t\tthis.onStart = onStart.subscribe;\n\t\tthis.onDispose = onDispose.subscribe;\n\t}\n\toptions = {} as DefaultOptions & O;\n}\n","import type { GeneralArguments } from '$/declarations';\n\nexport default {\n\tround,\n\tresizeCanvasForDPR,\n\tapplyStyles,\n\tdrawRoundRect,\n\tgetAnchorCoord,\n\tgetColor,\n\tmakeHook,\n};\n\nexport const destroyError = new Error(\"[JSONCanvasViewer] Resource hasn't been set up or has been disposed.\");\n\nfunction applyStyles(container: HTMLElement | ShadowRoot, styleString: string) {\n\tconst style = document.createElement('style');\n\tstyle.innerHTML = styleString;\n\tcontainer.appendChild(style);\n}\n\nfunction drawRoundRect(\n\tctx: CanvasRenderingContext2D,\n\tx: number,\n\ty: number,\n\twidth: number,\n\theight: number,\n\tradius: number,\n) {\n\tctx.beginPath();\n\tctx.moveTo(x + radius, y);\n\tctx.lineTo(x + width - radius, y);\n\tctx.quadraticCurveTo(x + width, y, x + width, y + radius);\n\tctx.lineTo(x + width, y + height - radius);\n\tctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);\n\tctx.lineTo(x + radius, y + height);\n\tctx.quadraticCurveTo(x, y + height, x, y + height - radius);\n\tctx.lineTo(x, y + radius);\n\tctx.quadraticCurveTo(x, y, x + radius, y);\n\tctx.closePath();\n}\n\nfunction getAnchorCoord(node: JSONCanvasNode, side: 'top' | 'bottom' | 'left' | 'right') {\n\tconst midX = node.x + node.width / 2;\n\tconst midY = node.y + node.height / 2;\n\tswitch (side) {\n\t\tcase 'top':\n\t\t\treturn [midX, node.y];\n\t\tcase 'bottom':\n\t\t\treturn [midX, node.y + node.height];\n\t\tcase 'left':\n\t\t\treturn [node.x, midY];\n\t\tcase 'right':\n\t\t\treturn [node.x + node.width, midY];\n\t\tdefault:\n\t\t\treturn [midX, midY];\n\t}\n}\n\nfunction getColor(colorIndex: string = '0') {\n\tlet themeColor = null;\n\n\tfunction hexToRgb(hex: string) {\n\t\tconst cleanHex = hex.replace('#', '');\n\t\tconst r = parseInt(cleanHex.substring(0, 2), 16);\n\t\tconst g = parseInt(cleanHex.substring(2, 4), 16);\n\t\tconst b = parseInt(cleanHex.substring(4, 6), 16);\n\t\treturn { r, g, b };\n\t}\n\n\tif (colorIndex.length === 1) {\n\t\tswitch (colorIndex) {\n\t\t\tcase '1':\n\t\t\t\tthemeColor = 'rgba(255, 120, 129, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '2':\n\t\t\t\tthemeColor = 'rgba(251, 187, 131, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '3':\n\t\t\t\tthemeColor = 'rgba(255, 232, 139, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '4':\n\t\t\t\tthemeColor = 'rgba(124, 211, 124, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '5':\n\t\t\t\tthemeColor = 'rgba(134, 223, 226, ?)';\n\t\t\t\tbreak;\n\t\t\tcase '6':\n\t\t\t\tthemeColor = 'rgba(203, 158, 255, ?)';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthemeColor = 'rgba(140, 140, 140, ?)';\n\t\t}\n\t} else {\n\t\tconst rgb = hexToRgb(colorIndex);\n\t\tthemeColor = `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ?)`;\n\t}\n\treturn {\n\t\tborder: themeColor.replace('?', '0.75'),\n\t\tbackground: themeColor.replace('?', '0.1'),\n\t\tactive: themeColor.replace('?', '1'),\n\t};\n}\n\nfunction resizeCanvasForDPR(canvas: HTMLCanvasElement, width: number, height: number) {\n\tconst dpr = window.devicePixelRatio || 1;\n\tconst ctx = canvas.getContext('2d');\n\tif (!ctx)\n\t\tthrow new Error(\n\t\t\t'[JSONCanvasViewer] This error is unexpected, probably caused uncontrollable runtime errors. Please contact the developer and show how to reproduce.',\n\t\t);\n\tcanvas.width = Math.round(width * dpr);\n\tcanvas.height = Math.round(height * dpr);\n\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\tctx.scale(dpr, dpr);\n}\n\nfunction round(roundedNum: number, digits: number) {\n\tconst factor = 10 ** digits;\n\treturn Math.round(roundedNum * factor) / factor;\n}\n\nfunction makeHook<Args extends GeneralArguments = []>(reverse: boolean = false) {\n\ttype MatchingFunc = (...args: Args) => unknown;\n\ttype Hook = {\n\t\t(...args: Args): void;\n\t\tsubs: Set<MatchingFunc>;\n\t\tsubscribe(callback: MatchingFunc): void;\n\t\tunsubscribe(callback: MatchingFunc): void;\n\t};\n\tconst result: Hook = (...args: Args) => {\n\t\tif (reverse) {\n\t\t\tconst items = Array.from(result.subs).reverse();\n\t\t\titems.forEach(callback => {\n\t\t\t\tcallback(...args);\n\t\t\t});\n\t\t} else\n\t\t\tresult.subs.forEach(callback => {\n\t\t\t\tcallback(...args);\n\t\t\t});\n\t};\n\tresult.subs = new Set();\n\tresult.subscribe = (callback: MatchingFunc) => {\n\t\tresult.subs.add(callback);\n\t};\n\tresult.unsubscribe = (callback: MatchingFunc) => {\n\t\tresult.subs.delete(callback);\n\t};\n\treturn result;\n}\n","import { type BaseArgs, BaseModule } from '$/baseModule';\nimport type { Coordinates, NodeBounds } from '$/declarations';\nimport style from '$/styles.scss?inline';\nimport utilities from '$/utilities';\n\nconst GRID_CELL_SIZE = 800;\nconst INITIAL_VIEWPORT_PADDING = 100;\n\ntype Options = {\n\tnoShadow?: boolean;\n\tcanvas: JSONCanvas;\n\tattachmentDir?: string;\n\textraCSS?: string;\n};\n\nexport default class DataManager extends BaseModule<Options> {\n\tprivate spatialGrid: Record<string, Array<JSONCanvasNode>> | null = null;\n\tonToggleFullscreen = utilities.makeHook<[boolean]>();\n\n\tdata: {\n\t\tcanvasData: Required<JSONCanvas>;\n\t\tnodeMap: Record<string, JSONCanvasNode>;\n\t\tcanvasBaseDir: string;\n\t\tnodeBounds: NodeBounds;\n\t\toffsetX: number;\n\t\toffsetY: number;\n\t\tscale: number;\n\t\tcontainer: HTMLDivElement;\n\t};\n\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tconst parentContainer = this.options.container;\n\t\twhile (parentContainer.firstElementChild) parentContainer.firstElementChild.remove();\n\t\tparentContainer.innerHTML = '';\n\n\t\tconst noShadow = this.options.noShadow || false;\n\t\tconst realContainer = noShadow ? parentContainer : parentContainer.attachShadow({ mode: 'open' });\n\n\t\tutilities.applyStyles(realContainer, style + this.options.extraCSS);\n\n\t\tconst HTMLContainer = document.createElement('div');\n\t\tHTMLContainer.classList.add('container');\n\t\trealContainer.appendChild(HTMLContainer);\n\t\tconst canvasData = Object.assign(\n\t\t\t{\n\t\t\t\tnodes: [],\n\t\t\t\tedges: [],\n\t\t\t},\n\t\t\tthis.options.canvas,\n\t\t);\n\n\t\tthis.data = {\n\t\t\tcanvasData: canvasData,\n\t\t\tnodeMap: {},\n\t\t\tcanvasBaseDir: this.processBaseDir(this.options.attachmentDir),\n\t\t\tnodeBounds: this.calculateNodeBounds(canvasData),\n\t\t\toffsetX: 0,\n\t\t\toffsetY: 0,\n\t\t\tscale: 1,\n\t\t\tcontainer: HTMLContainer,\n\t\t};\n\n\t\tthis.data.canvasData.nodes.forEach(node => {\n\t\t\tif (node.type === 'file' && !node.file.includes('http')) {\n\t\t\t\tconst file = node.file.split('/');\n\t\t\t\tnode.file = file[file.length - 1];\n\t\t\t}\n\t\t\tthis.data.nodeMap[node.id] = node;\n\t\t});\n\n\t\tthis.buildSpatialGrid();\n\t\tthis.resetView();\n\t\tthis.onDispose(this.dispose);\n\t}\n\n\tprivate processBaseDir = (baseDir: string | undefined) => {\n\t\tif (!baseDir) return './';\n\t\tconst lastChar = baseDir?.slice(-1);\n\t\tif (lastChar === '/') return baseDir;\n\t\treturn `${baseDir}/`;\n\t};\n\n\tfindNodeAt = (screenCoords: Coordinates) => {\n\t\tconst { x, y } = this.C2W(this.C2C({ x: screenCoords.x, y: screenCoords.y }));\n\t\tlet candidates: Array<JSONCanvasNode> = [];\n\t\tif (!this.spatialGrid) candidates = this.data.canvasData.nodes;\n\t\telse {\n\t\t\tconst col = Math.floor(x / GRID_CELL_SIZE);\n\t\t\tconst row = Math.floor(y / GRID_CELL_SIZE);\n\t\t\tconst key = `${col},${row}`;\n\t\t\tcandidates = this.spatialGrid[key] || [];\n\t\t}\n\t\tfor (const node of candidates) {\n\t\t\tif (\n\t\t\t\tx < node.x ||\n\t\t\t\tx > node.x + node.width ||\n\t\t\t\ty < node.y ||\n\t\t\t\ty > node.y + node.height ||\n\t\t\t\tthis.judgeInteract(node) === 'non-interactive'\n\t\t\t)\n\t\t\t\tcontinue;\n\t\t\treturn node;\n\t\t}\n\t\treturn null;\n\t};\n\n\t// how should the app handle node interactions\n\tprivate judgeInteract = (node: JSONCanvasNode | null) => {\n\t\tswitch (node?.type) {\n\t\t\tcase 'text':\n\t\t\tcase 'link':\n\t\t\t\treturn 'select';\n\t\t\tcase 'file': {\n\t\t\t\tif (node.file.match(/\\.(md|wav|mp3)$/i)) return 'select';\n\t\t\t\telse return 'non-interactive';\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn 'non-interactive';\n\t\t}\n\t};\n\n\tprivate calculateNodeBounds(canvasData: Required<JSONCanvas>) {\n\t\tlet minX = Infinity,\n\t\t\tminY = Infinity,\n\t\t\tmaxX = -Infinity,\n\t\t\tmaxY = -Infinity;\n\t\tcanvasData.nodes.forEach(node => {\n\t\t\tminX = Math.min(minX, node.x);\n\t\t\tminY = Math.min(minY, node.y);\n\t\t\tmaxX = Math.max(maxX, node.x + node.width);\n\t\t\tmaxY = Math.max(maxY, node.y + node.height);\n\t\t});\n\t\tconst width = maxX - minX;\n\t\tconst height = maxY - minY;\n\t\tconst centerX = minX + width / 2;\n\t\tconst centerY = minY + height / 2;\n\t\treturn { minX, minY, maxX, maxY, width, height, centerX, centerY };\n\t}\n\n\tprivate buildSpatialGrid() {\n\t\tconst canvasData = this.data.canvasData;\n\t\tif (canvasData.nodes.length < 50) return;\n\t\tthis.spatialGrid = {};\n\t\tfor (const node of canvasData.nodes) {\n\t\t\tconst minCol = Math.floor(node.x / GRID_CELL_SIZE);\n\t\t\tconst maxCol = Math.floor((node.x + node.width) / GRID_CELL_SIZE);\n\t\t\tconst minRow = Math.floor(node.y / GRID_CELL_SIZE);\n\t\t\tconst maxRow = Math.floor((node.y + node.height) / GRID_CELL_SIZE);\n\t\t\tfor (let col = minCol; col <= maxCol; col++) {\n\t\t\t\tfor (let row = minRow; row <= maxRow; row++) {\n\t\t\t\t\tconst key = `${col},${row}`;\n\t\t\t\t\tif (!this.spatialGrid[key]) this.spatialGrid[key] = [];\n\t\t\t\t\tthis.spatialGrid[key].push(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tzoom = (factor: number, origin: Coordinates) => {\n\t\tconst newScale = this.data.scale * factor;\n\t\tthis.zoomToScale(newScale, origin);\n\t};\n\tzoomToScale = (newScale: number, origin: Coordinates) => {\n\t\tconst validNewScale = Math.max(Math.min(newScale, 20), 0.05);\n\t\tconst scale = this.data.scale;\n\t\tif (validNewScale === scale) return;\n\t\tconst canvasCoords = this.C2C(origin);\n\t\tthis.data.offsetX = origin.x - (canvasCoords.x * validNewScale) / scale;\n\t\tthis.data.offsetY = origin.y - (canvasCoords.y * validNewScale) / scale;\n\t\tthis.data.scale = validNewScale;\n\t};\n\tpan = ({ x, y }: Coordinates) => {\n\t\tthis.data.offsetX = this.data.offsetX + x;\n\t\tthis.data.offsetY = this.data.offsetY + y;\n\t};\n\tpanToCoords = ({ x, y }: Coordinates) => {\n\t\tthis.data.offsetX = x;\n\t\tthis.data.offsetY = y;\n\t};\n\tshiftFullscreen = (option: string = 'toggle') => {\n\t\tif (!document.fullscreenElement && (option === 'toggle' || option === 'enter')) {\n\t\t\tthis.data.container.requestFullscreen();\n\t\t\tthis.onToggleFullscreen(true);\n\t\t} else if (document.fullscreenElement && (option === 'toggle' || option === 'exit')) {\n\t\t\tdocument.exitFullscreen();\n\t\t\tthis.onToggleFullscreen(false);\n\t\t}\n\t};\n\tresetView = () => {\n\t\tconst bounds = this.data.nodeBounds;\n\t\tconst container = this.data.container;\n\t\tif (!bounds || !container) return;\n\t\tconst contentWidth = bounds.width + INITIAL_VIEWPORT_PADDING * 2;\n\t\tconst contentHeight = bounds.height + INITIAL_VIEWPORT_PADDING * 2;\n\t\t// Use logical dimensions for scaling calculations\n\t\tconst viewWidth = container.clientWidth;\n\t\tconst viewHeight = container.clientHeight;\n\t\tconst scaleX = viewWidth / contentWidth;\n\t\tconst scaleY = viewHeight / contentHeight;\n\t\tconst newScale = Math.round(Math.min(scaleX, scaleY) * 1000) / 1000;\n\t\tconst contentCenterX = bounds.centerX;\n\t\tconst contentCenterY = bounds.centerY;\n\t\tconst initialView = {\n\t\t\tscale: newScale,\n\t\t\toffsetX: viewWidth / 2 - contentCenterX * newScale,\n\t\t\toffsetY: viewHeight / 2 - contentCenterY * newScale,\n\t\t};\n\t\tthis.data.offsetX = initialView.offsetX;\n\t\tthis.data.offsetY = initialView.offsetY;\n\t\tthis.data.scale = initialView.scale;\n\t};\n\n\t// Container to Canvas\n\tprivate C2C = ({ x: containerX, y: containerY }: Coordinates) => ({\n\t\tx: containerX - this.data.offsetX,\n\t\ty: containerY - this.data.offsetY,\n\t});\n\t// Canvas to World\n\tprivate C2W = ({ x: canvasX, y: canvasY }: Coordinates) => ({\n\t\tx: canvasX / this.data.scale,\n\t\ty: canvasY / this.data.scale,\n\t});\n\n\tmiddleViewer = () => {\n\t\tconst container = this.data.container;\n\t\treturn {\n\t\t\tx: container.clientWidth / 2,\n\t\t\ty: container.clientHeight / 2,\n\t\t\twidth: container.clientWidth,\n\t\t\theight: container.clientHeight,\n\t\t};\n\t};\n\n\tprivate dispose = () => this.data.container.remove();\n}\n","import { type BaseArgs, BaseModule } from '$/baseModule';\nimport DataManager from '$/dataManager';\nimport utilities from '$/utilities';\n\nexport default class Controller extends BaseModule {\n\tprivate animationId: null | number = null;\n\tprivate resizeAnimationId: null | number = null;\n\tprivate DM: DataManager;\n\tprivate resizeObserver: ResizeObserver;\n\tprivate perFrame = {\n\t\tlastScale: 1,\n\t\tlastOffsets: { x: 0, y: 0 },\n\t};\n\tprivate lastResizeCenter: {\n\t\tx: null | number;\n\t\ty: null | number;\n\t} = {\n\t\tx: null,\n\t\ty: null,\n\t};\n\n\thooks = {\n\t\tonResize: utilities.makeHook<[number, number]>(),\n\t\tonRefresh: utilities.makeHook(),\n\t};\n\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tthis.onStart(this.start);\n\t\tthis.onDispose(this.dispose);\n\t\tthis.DM = this.container.get(DataManager);\n\t\tthis.resizeObserver = new ResizeObserver(this.onResize);\n\t}\n\n\tprivate start = () => {\n\t\tthis.resizeObserver.observe(this.DM.data.container);\n\t\tthis.animationId = requestAnimationFrame(this.draw);\n\t};\n\n\tprivate draw = () => {\n\t\tif (\n\t\t\tthis.perFrame.lastScale !== this.DM.data.scale ||\n\t\t\tthis.perFrame.lastOffsets.x !== this.DM.data.offsetX ||\n\t\t\tthis.perFrame.lastOffsets.y !== this.DM.data.offsetY\n\t\t)\n\t\t\tthis.refresh();\n\t\tthis.animationId = requestAnimationFrame(this.draw);\n\t};\n\n\trefresh = () => {\n\t\tthis.perFrame.lastScale = this.DM.data.scale;\n\t\tthis.perFrame.lastOffsets = {\n\t\t\tx: this.DM.data.offsetX,\n\t\t\ty: this.DM.data.offsetY,\n\t\t};\n\t\tthis.hooks.onRefresh();\n\t};\n\n\tprivate onResize = () => {\n\t\tthis.resizeAnimationId = requestAnimationFrame(() => {\n\t\t\tconst center = this.DM.middleViewer();\n\t\t\tif (this.lastResizeCenter.x && this.lastResizeCenter.y) {\n\t\t\t\tthis.DM.data.offsetX = this.DM.data.offsetX + center.x - this.lastResizeCenter.x;\n\t\t\t\tthis.DM.data.offsetY = this.DM.data.offsetY + center.y - this.lastResizeCenter.y;\n\t\t\t}\n\t\t\tthis.lastResizeCenter.x = center.x;\n\t\t\tthis.lastResizeCenter.y = center.y;\n\t\t\tthis.hooks.onResize(center.width, center.height);\n\t\t\tthis.refresh();\n\t\t});\n\t};\n\n\tprivate dispose = () => {\n\t\tif (this.animationId) cancelAnimationFrame(this.animationId);\n\t\tif (this.resizeAnimationId) cancelAnimationFrame(this.resizeAnimationId);\n\t\tthis.resizeObserver.disconnect();\n\t};\n}\n"],"names":["BaseModule","constructor","container","options","onStart","onDispose","this","Object","assign","subscribe","utilities","round","roundedNum","digits","factor","Math","resizeCanvasForDPR","canvas","width","height","dpr","window","devicePixelRatio","ctx","getContext","Error","setTransform","scale","applyStyles","styleString","style","document","createElement","innerHTML","appendChild","drawRoundRect","x","y","radius","beginPath","moveTo","lineTo","quadraticCurveTo","closePath","getAnchorCoord","node","side","midX","midY","getColor","colorIndex","themeColor","length","rgb","hex","cleanHex","replace","r","parseInt","substring","g","b","hexToRgb","border","background","active","makeHook","reverse","result","args","Array","from","subs","forEach","callback","Set","add","unsubscribe","delete","destroyError","GRID_CELL_SIZE","DataManager","spatialGrid","onToggleFullscreen","data","super","parentContainer","firstElementChild","remove","realContainer","noShadow","attachShadow","mode","extraCSS","HTMLContainer","classList","canvasData","nodes","edges","nodeMap","canvasBaseDir","processBaseDir","attachmentDir","nodeBounds","calculateNodeBounds","offsetX","offsetY","type","file","includes","split","id","buildSpatialGrid","resetView","dispose","baseDir","lastChar","slice","findNodeAt","screenCoords","C2W","C2C","candidates","key","floor","judgeInteract","match","minX","Infinity","minY","maxX","maxY","min","max","centerX","centerY","minCol","maxCol","minRow","maxRow","col","row","push","zoom","origin","newScale","zoomToScale","validNewScale","canvasCoords","pan","panToCoords","shiftFullscreen","option","fullscreenElement","exitFullscreen","requestFullscreen","bounds","contentWidth","INITIAL_VIEWPORT_PADDING","contentHeight","viewWidth","clientWidth","viewHeight","clientHeight","scaleX","scaleY","initialView","containerX","containerY","canvasX","canvasY","middleViewer","Controller","animationId","resizeAnimationId","DM","resizeObserver","perFrame","lastScale","lastOffsets","lastResizeCenter","hooks","onResize","onRefresh","start","get","ResizeObserver","observe","requestAnimationFrame","draw","refresh","center","cancelAnimationFrame","disconnect"],"mappings":"AAWO,MAAMA,EAGZ,WAAAC,CACWC,EACVC,EACAC,EACAC,GAHUC,KAAAJ,UAAAA,EAKVK,OAAOC,OAAOF,KAAKH,QAASA,GAC5BG,KAAKF,QAAUA,EAAQK,UACvB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,GAAG3F,KAAKsB,SAE7CpG,KAAKwL,UACNxL,KAAKuK,YAAce,sBAAsBtL,KAAKuL,OAG/CC,QAAU,KACTxL,KAAK2K,SAASC,UAAY5K,KAAKyK,GAAG3F,KAAKzD,MACvCrB,KAAK2K,SAASE,YAAc,CAC3B/I,EAAG9B,KAAKyK,GAAG3F,KAAKqB,QAChBpE,EAAG/B,KAAKyK,GAAG3F,KAAKsB,SAEjBpG,KAAK+K,MAAME,aAGJD,SAAW,KAClBhL,KAAKwK,kBAAoBc,sBAAsB,KAC9C,MAAMG,EAASzL,KAAKyK,GAAGJ,eACnBrK,KAAK8K,iBAAiBhJ,GAAK9B,KAAK8K,iBAAiB/I,IACpD/B,KAAKyK,GAAG3F,KAAKqB,QAAUnG,KAAKyK,GAAG3F,KAAKqB,QAAUsF,EAAO3J,EAAI9B,KAAK8K,iBAAiBhJ,EAC/E9B,KAAKyK,GAAG3F,KAAKsB,QAAUpG,KAAKyK,GAAG3F,KAAKsB,QAAUqF,EAAO1J,EAAI/B,KAAK8K,iBAAiB/I,GAEhF/B,KAAK8K,iBAAiBhJ,EAAI2J,EAAO3J,EACjC9B,KAAK8K,iBAAiB/I,EAAI0J,EAAO1J,EACjC/B,KAAK+K,MAAMC,SAASS,EAAO7K,MAAO6K,EAAO5K,QACzCb,KAAKwL,aAIC5E,QAAU,KACb5G,KAAKuK,aAAamB,qBAAqB1L,KAAKuK,aAC5CvK,KAAKwK,mBAAmBkB,qBAAqB1L,KAAKwK,mBACtDxK,KAAK0K,eAAeiB"}
package/dist/dev.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./controller--Q72jFEw.cjs"),r=require("./renderer-D9iInH9_.cjs");exports.BaseModule=e.BaseModule,exports.Controller=e.Controller,exports.DataManager=e.DataManager,exports.canvasUtils=e.utilities,exports.InteractionHandler=r.InteractionHandler,exports.OverlayManager=r.OverlayManager,exports.Renderer=r.Renderer;
2
+ //# sourceMappingURL=dev.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/dev.js ADDED
@@ -0,0 +1,2 @@
1
+ import{B as a,C as r,D as e,u as s}from"./controller-siZ5v-SD.js";import{I as o,O as n,R as t}from"./renderer-CZ85ZN6O.js";export{a as BaseModule,r as Controller,e as DataManager,o as InteractionHandler,n as OverlayManager,t as Renderer,s as canvasUtils};
2
+ //# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";const i=require("@needle-di/core"),t=require("./controller--Q72jFEw.cjs"),o=require("./renderer-D9iInH9_.cjs");exports.JSONCanvasViewer=class{options;allModules;IO=null;onStart=t.utilities.makeHook();onDispose=t.utilities.makeHook(!0);container;constructor(e,s){this.container=new i.Container,this.options=e;this.allModules=[t.DataManager,t.Controller,o.OverlayManager,o.InteractionHandler,o.Renderer,...s||[]],this.allModules.forEach(i=>{this.container.bind({provide:i,useFactory:()=>new i(this.container,this.options,this.onStart,this.onDispose)})}),this.options.lazyLoading?(this.IO=new IntersectionObserver(this.onVisibilityCheck,{root:null,rootMargin:"50px",threshold:0}),this.IO.observe(this.options.container)):this.load()}load=()=>{this.allModules.forEach(i=>{this.container.get(i)}),this.onStart()};onVisibilityCheck=i=>{i.forEach(i=>{if(i.isIntersecting)return this.load(),this.IO?.disconnect(),void(this.IO=null)})};dispose=()=>{this.IO?.disconnect(),this.IO=null;const i=this.options.container;for(;i.firstChild;)i.firstChild.remove();this.onDispose(),this.container.unbindAll()}};
2
+ //# sourceMappingURL=index-BSkMdAcV.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BSkMdAcV.cjs","sources":["../src/core/index.ts"],"sourcesContent":["import { Container } from '@needle-di/core';\nimport type { GeneralModuleCtor } from '$/baseModule';\nimport Controller from '$/controller';\nimport DataManager from '$/dataManager';\nimport type { ModuleInputCtor, UserOptions } from '$/declarations';\nimport InteractionHandler from '$/interactionHandler';\nimport OverlayManager from '$/overlayManager';\nimport Renderer from '$/renderer';\nimport utilities from '$/utilities';\n\nexport default class JSONCanvasViewer<M extends ModuleInputCtor = []> {\n\tprivate options: UserOptions<M>;\n\tprivate allModules: ModuleInputCtor;\n\tprivate IO: IntersectionObserver | null = null;\n\tprivate onStart = utilities.makeHook();\n\tprivate onDispose = utilities.makeHook(true);\n\tcontainer: Container;\n\n\tconstructor(options: UserOptions<M>, modules?: M) {\n\t\tthis.container = new Container();\n\t\tthis.options = options;\n\t\tconst bind = (Class: GeneralModuleCtor) => {\n\t\t\tthis.container.bind({\n\t\t\t\tprovide: Class,\n\t\t\t\tuseFactory: () => new Class(this.container, this.options, this.onStart, this.onDispose),\n\t\t\t});\n\t\t};\n\t\tthis.allModules = [\n\t\t\tDataManager,\n\t\t\tController,\n\t\t\tOverlayManager,\n\t\t\tInteractionHandler,\n\t\t\tRenderer,\n\t\t\t...(modules || []),\n\t\t];\n\n\t\tthis.allModules.forEach(bind);\n\t\tif (this.options.lazyLoading) {\n\t\t\tthis.IO = new IntersectionObserver(this.onVisibilityCheck, {\n\t\t\t\troot: null,\n\t\t\t\trootMargin: '50px',\n\t\t\t\tthreshold: 0,\n\t\t\t});\n\t\t\tthis.IO.observe(this.options.container);\n\t\t} else this.load();\n\t}\n\n\tprivate load = () => {\n\t\tthis.allModules.forEach(Module => {\n\t\t\tthis.container.get(Module);\n\t\t});\n\t\tthis.onStart();\n\t};\n\n\tprivate onVisibilityCheck = (entries: Array<IntersectionObserverEntry>) => {\n\t\tentries.forEach(entry => {\n\t\t\tif (entry.isIntersecting) {\n\t\t\t\tthis.load();\n\t\t\t\tthis.IO?.disconnect();\n\t\t\t\tthis.IO = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t});\n\t};\n\n\tdispose = () => {\n\t\tthis.IO?.disconnect();\n\t\tthis.IO = null;\n\t\tconst container = this.options.container;\n\t\twhile (container.firstChild) container.firstChild.remove();\n\t\tthis.onDispose();\n\t\tthis.container.unbindAll();\n\t};\n}\n"],"names":["options","allModules","IO","onStart","utilities","makeHook","onDispose","container","constructor","modules","this","Container","DataManager","Controller","OverlayManager","InteractionHandler","Renderer","forEach","Class","bind","provide","useFactory","lazyLoading","IntersectionObserver","onVisibilityCheck","root","rootMargin","threshold","observe","load","Module","get","entries","entry","isIntersecting","disconnect","dispose","firstChild","remove","unbindAll"],"mappings":"qJAUA,MACSA,QACAC,WACAC,GAAkC,KAClCC,QAAUC,EAAAA,UAAUC,WACpBC,UAAYF,EAAAA,UAAUC,UAAS,GACvCE,UAEA,WAAAC,CAAYR,EAAyBS,GACpCC,KAAKH,UAAY,IAAII,YACrBD,KAAKV,QAAUA,EAOfU,KAAKT,WAAa,CACjBW,EAAAA,YACAC,EAAAA,WACAC,EAAAA,eACAC,EAAAA,mBACAC,EAAAA,YACIP,GAAW,IAGhBC,KAAKT,WAAWgB,QAfFC,IACbR,KAAKH,UAAUY,KAAK,CACnBC,QAASF,EACTG,WAAY,IAAM,IAAIH,EAAMR,KAAKH,UAAWG,KAAKV,QAASU,KAAKP,QAASO,KAAKJ,eAa3EI,KAAKV,QAAQsB,aAChBZ,KAAKR,GAAK,IAAIqB,qBAAqBb,KAAKc,kBAAmB,CAC1DC,KAAM,KACNC,WAAY,OACZC,UAAW,IAEZjB,KAAKR,GAAG0B,QAAQlB,KAAKV,QAAQO,iBAClBsB,MACb,CAEQA,KAAO,KACdnB,KAAKT,WAAWgB,QAAQa,IACvBpB,KAAKH,UAAUwB,IAAID,KAEpBpB,KAAKP,WAGEqB,kBAAqBQ,IAC5BA,EAAQf,QAAQgB,IACf,GAAIA,EAAMC,eAIT,OAHAxB,KAAKmB,OACLnB,KAAKR,IAAIiC,kBACTzB,KAAKR,GAAK,SAMbkC,QAAU,KACT1B,KAAKR,IAAIiC,aACTzB,KAAKR,GAAK,KACV,MAAMK,EAAYG,KAAKV,QAAQO,UAC/B,KAAOA,EAAU8B,YAAY9B,EAAU8B,WAAWC,SAClD5B,KAAKJ,YACLI,KAAKH,UAAUgC"}
@@ -0,0 +1,2 @@
1
+ import{Container as o}from"@needle-di/core";import{u as i,D as s,C as t}from"./controller-siZ5v-SD.js";import{O as n,I as e,R as r}from"./renderer-CZ85ZN6O.js";class a{options;allModules;IO=null;onStart=i.makeHook();onDispose=i.makeHook(!0);container;constructor(i,a){this.container=new o,this.options=i;this.allModules=[s,t,n,e,r,...a||[]],this.allModules.forEach(o=>{this.container.bind({provide:o,useFactory:()=>new o(this.container,this.options,this.onStart,this.onDispose)})}),this.options.lazyLoading?(this.IO=new IntersectionObserver(this.onVisibilityCheck,{root:null,rootMargin:"50px",threshold:0}),this.IO.observe(this.options.container)):this.load()}load=()=>{this.allModules.forEach(o=>{this.container.get(o)}),this.onStart()};onVisibilityCheck=o=>{o.forEach(o=>{if(o.isIntersecting)return this.load(),this.IO?.disconnect(),void(this.IO=null)})};dispose=()=>{this.IO?.disconnect(),this.IO=null;const o=this.options.container;for(;o.firstChild;)o.firstChild.remove();this.onDispose(),this.container.unbindAll()}}export{a as J};
2
+ //# sourceMappingURL=index-u8PUIMyl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-u8PUIMyl.js","sources":["../src/core/index.ts"],"sourcesContent":["import { Container } from '@needle-di/core';\nimport type { GeneralModuleCtor } from '$/baseModule';\nimport Controller from '$/controller';\nimport DataManager from '$/dataManager';\nimport type { ModuleInputCtor, UserOptions } from '$/declarations';\nimport InteractionHandler from '$/interactionHandler';\nimport OverlayManager from '$/overlayManager';\nimport Renderer from '$/renderer';\nimport utilities from '$/utilities';\n\nexport default class JSONCanvasViewer<M extends ModuleInputCtor = []> {\n\tprivate options: UserOptions<M>;\n\tprivate allModules: ModuleInputCtor;\n\tprivate IO: IntersectionObserver | null = null;\n\tprivate onStart = utilities.makeHook();\n\tprivate onDispose = utilities.makeHook(true);\n\tcontainer: Container;\n\n\tconstructor(options: UserOptions<M>, modules?: M) {\n\t\tthis.container = new Container();\n\t\tthis.options = options;\n\t\tconst bind = (Class: GeneralModuleCtor) => {\n\t\t\tthis.container.bind({\n\t\t\t\tprovide: Class,\n\t\t\t\tuseFactory: () => new Class(this.container, this.options, this.onStart, this.onDispose),\n\t\t\t});\n\t\t};\n\t\tthis.allModules = [\n\t\t\tDataManager,\n\t\t\tController,\n\t\t\tOverlayManager,\n\t\t\tInteractionHandler,\n\t\t\tRenderer,\n\t\t\t...(modules || []),\n\t\t];\n\n\t\tthis.allModules.forEach(bind);\n\t\tif (this.options.lazyLoading) {\n\t\t\tthis.IO = new IntersectionObserver(this.onVisibilityCheck, {\n\t\t\t\troot: null,\n\t\t\t\trootMargin: '50px',\n\t\t\t\tthreshold: 0,\n\t\t\t});\n\t\t\tthis.IO.observe(this.options.container);\n\t\t} else this.load();\n\t}\n\n\tprivate load = () => {\n\t\tthis.allModules.forEach(Module => {\n\t\t\tthis.container.get(Module);\n\t\t});\n\t\tthis.onStart();\n\t};\n\n\tprivate onVisibilityCheck = (entries: Array<IntersectionObserverEntry>) => {\n\t\tentries.forEach(entry => {\n\t\t\tif (entry.isIntersecting) {\n\t\t\t\tthis.load();\n\t\t\t\tthis.IO?.disconnect();\n\t\t\t\tthis.IO = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t});\n\t};\n\n\tdispose = () => {\n\t\tthis.IO?.disconnect();\n\t\tthis.IO = null;\n\t\tconst container = this.options.container;\n\t\twhile (container.firstChild) container.firstChild.remove();\n\t\tthis.onDispose();\n\t\tthis.container.unbindAll();\n\t};\n}\n"],"names":["JSONCanvasViewer","options","allModules","IO","onStart","utilities","makeHook","onDispose","container","constructor","modules","this","Container","DataManager","Controller","OverlayManager","InteractionHandler","Renderer","forEach","Class","bind","provide","useFactory","lazyLoading","IntersectionObserver","onVisibilityCheck","root","rootMargin","threshold","observe","load","Module","get","entries","entry","isIntersecting","disconnect","dispose","firstChild","remove","unbindAll"],"mappings":"gKAUA,MAAqBA,EACZC,QACAC,WACAC,GAAkC,KAClCC,QAAUC,EAAUC,WACpBC,UAAYF,EAAUC,UAAS,GACvCE,UAEA,WAAAC,CAAYR,EAAyBS,GACpCC,KAAKH,UAAY,IAAII,EACrBD,KAAKV,QAAUA,EAOfU,KAAKT,WAAa,CACjBW,EACAC,EACAC,EACAC,EACAC,KACIP,GAAW,IAGhBC,KAAKT,WAAWgB,QAfFC,IACbR,KAAKH,UAAUY,KAAK,CACnBC,QAASF,EACTG,WAAY,IAAM,IAAIH,EAAMR,KAAKH,UAAWG,KAAKV,QAASU,KAAKP,QAASO,KAAKJ,eAa3EI,KAAKV,QAAQsB,aAChBZ,KAAKR,GAAK,IAAIqB,qBAAqBb,KAAKc,kBAAmB,CAC1DC,KAAM,KACNC,WAAY,OACZC,UAAW,IAEZjB,KAAKR,GAAG0B,QAAQlB,KAAKV,QAAQO,iBAClBsB,MACb,CAEQA,KAAO,KACdnB,KAAKT,WAAWgB,QAAQa,IACvBpB,KAAKH,UAAUwB,IAAID,KAEpBpB,KAAKP,WAGEqB,kBAAqBQ,IAC5BA,EAAQf,QAAQgB,IACf,GAAIA,EAAMC,eAIT,OAHAxB,KAAKmB,OACLnB,KAAKR,IAAIiC,kBACTzB,KAAKR,GAAK,SAMbkC,QAAU,KACT1B,KAAKR,IAAIiC,aACTzB,KAAKR,GAAK,KACV,MAAMK,EAAYG,KAAKV,QAAQO,UAC/B,KAAOA,EAAU8B,YAAY9B,EAAU8B,WAAWC,SAClD5B,KAAKJ,YACLI,KAAKH,UAAUgC"}