eidosmd 0.1.0 → 0.2.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.
- package/README.md +50 -29
- package/browser/dist/assets/index-C2NMN_D4.css +1 -0
- package/browser/dist/assets/index-C65k1ihb.js +46 -0
- package/browser/dist/favicon.svg +5 -0
- package/browser/dist/index.html +15 -0
- package/browser/dist/mark.svg +4 -0
- package/dist/src/cli.js +7 -0
- package/dist/src/commands/agents.js +1 -1
- package/dist/src/commands/canvas.js +77 -0
- package/dist/src/commands/check.js +1 -1
- package/dist/src/commands/framework.js +24 -5
- package/dist/src/commands/index.js +4 -4
- package/dist/src/commands/init.js +1 -0
- package/dist/src/commands/instructions.js +1 -1
- package/dist/src/commands/list.js +8 -8
- package/dist/src/commands/migrate.js +32 -0
- package/dist/src/commands/new.js +3 -3
- package/dist/src/commands/seeds.js +5 -5
- package/dist/src/commands/setup.js +119 -0
- package/dist/src/commands/version.js +44 -0
- package/dist/src/commands/whoami.js +4 -4
- package/dist/src/context.js +5 -5
- package/dist/src/core/blueprint.js +16 -11
- package/dist/src/core/canvas-schema.js +148 -0
- package/dist/src/core/canvas.js +722 -0
- package/dist/src/core/check.js +127 -51
- package/dist/src/core/convert.js +7 -6
- package/dist/src/core/framework-markdown.js +113 -34
- package/dist/src/core/framework-model.js +27 -10
- package/dist/src/core/framework-structured.js +132 -33
- package/dist/src/core/framework.js +13 -13
- package/dist/src/core/git.js +59 -0
- package/dist/src/core/index-leaf.js +2 -2
- package/dist/src/core/me.js +16 -8
- package/dist/src/core/migrate.js +243 -0
- package/dist/src/core/naming.js +1 -1
- package/dist/src/core/root.js +2 -2
- package/dist/src/core/scaffold.js +19 -19
- package/dist/src/core/seed.js +151 -60
- package/dist/src/core/server.js +1236 -52
- package/dist/src/core/settings.js +181 -0
- package/dist/src/core/store.js +259 -0
- package/dist/src/core/template.js +32 -0
- package/dist/src/core/versions.js +79 -0
- package/dist/src/output.js +4 -1
- package/dist/src/program.js +134 -39
- package/instructions/authoring.md +13 -12
- package/instructions/configuring.md +65 -34
- package/instructions/init-required.md +4 -4
- package/instructions/overview.md +17 -7
- package/instructions/validating.md +5 -4
- package/package.json +21 -12
- package/standard/EIDOS.md +129 -188
- package/standard/seeds/README.md +6 -6
- package/standard/seeds/book/Framework.yaml +81 -0
- package/standard/seeds/book/README.md +9 -5
- package/standard/seeds/book/_gitignore +3 -3
- package/standard/seeds/book/me.md +1 -1
- package/standard/seeds/book/roles/README.md +3 -3
- package/standard/seeds/book/roles/framework-owner.md +2 -2
- package/standard/seeds/book/{shapes → templates}/chapter.full.md +0 -8
- package/standard/seeds/book/{shapes → templates}/chapter.sketch.md +0 -7
- package/standard/seeds/book/{shapes → templates}/frame.market.md +0 -6
- package/standard/seeds/book/templates/frame.premise.md +17 -0
- package/standard/seeds/book/{shapes → templates}/frame.reader.md +0 -6
- package/standard/seeds/book/{shapes → templates}/frame.voice.md +0 -7
- package/standard/seeds/research/Framework.yaml +81 -0
- package/standard/seeds/research/README.md +9 -5
- package/standard/seeds/research/_gitignore +3 -3
- package/standard/seeds/research/me.md +1 -1
- package/standard/seeds/research/roles/README.md +3 -3
- package/standard/seeds/research/roles/framework-owner.md +2 -2
- package/standard/seeds/research/{shapes → templates}/frame.ethics.md +0 -6
- package/standard/seeds/research/{shapes → templates}/frame.method.md +0 -7
- package/standard/seeds/research/{shapes → templates}/frame.prior-work.md +0 -6
- package/standard/seeds/research/{shapes → templates}/frame.question.md +0 -7
- package/standard/seeds/research/{shapes → templates}/investigation.full.md +0 -8
- package/standard/seeds/research/{shapes → templates}/investigation.note.md +0 -7
- package/standard/seeds/software/Framework.yaml +82 -0
- package/standard/seeds/software/README.md +5 -5
- package/standard/seeds/software/_gitignore +3 -3
- package/standard/seeds/software/me.md +1 -1
- package/standard/seeds/software/roles/README.md +3 -3
- package/standard/seeds/software/roles/framework-owner.md +2 -2
- package/standard/seeds/software/roles/project-manager.md +2 -2
- package/standard/seeds/software/roles/stakeholder.md +1 -1
- package/standard/seeds/software/{shapes → templates}/frame.architecture.md +0 -7
- package/standard/seeds/software/{shapes → templates}/frame.audience.md +1 -8
- package/standard/seeds/software/{shapes → templates}/frame.criteria.md +0 -8
- package/standard/seeds/software/{shapes → templates}/frame.market.md +0 -8
- package/standard/seeds/software/{shapes → templates}/spec.full.md +0 -8
- package/standard/seeds/software/{shapes → templates}/spec.micro.md +0 -9
- package/browser/index.html +0 -268
- package/dist/src/commands/convert.js +0 -30
- package/dist/src/core/shape.js +0 -26
- package/standard/seeds/book/Framework.md +0 -87
- package/standard/seeds/book/shapes/frame.premise.md +0 -24
- package/standard/seeds/research/Framework.md +0 -88
- package/standard/seeds/software/Framework.md +0 -88
- /package/standard/seeds/software/{shapes → templates}/.gitkeep +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function ee(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function te(e,t){this.props=e,this.context=t}function C(e,t){if(t==null)return e.__?C(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?C(e):null}function w(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=y({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),se(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??C(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,le(i,o,a),n.__e=n.__=null,o.__e!=r&&T(o)}}function T(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),T(e)}function ne(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!E.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(E)}function E(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,w(e)}finally{r.length=E.__r=0}}function D(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,ee=t.length;for(c=re(n,t,y,c,ee),d=0;d<ee;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=se(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&fe(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=ie(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function re(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):v(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=k(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=C(s)),pe(s,s));return r}function ie(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=ie(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=C(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function O(e,t){return t||=[],e==null||typeof e==`boolean`||(v(e)?e.some(function(e){O(e,t)}):t.push(e)),t}function k(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function A(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function ae(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||A(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||A(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function oe(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[c]==null)n[c]=d++;else if(n[c]<r[l])return;return r(t.event?t.event(n):n)}}}function se(e,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,b,x,w,T,ne,E,re,ie,O,k,A=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=n.__e=r.__e]),(d=t.__b)&&d(n);n:if(typeof A==`function`){f=s.length;try{if(w=n.props,T=A.prototype&&A.prototype.render,ne=(d=A.contextType)&&i[d.__c],E=d?ne?ne.props.value:d.__:i,r.__c?x=(p=n.__c=r.__c).__=p.__E:(T?n.__c=p=new A(w,E):(n.__c=p=new te(w,E),p.constructor=A,p.render=me),ne&&ne.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),T&&p.__s==null&&(p.__s=p.state),T&&A.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,A.getDerivedStateFromProps(w,p.__s))),h=p.props,_=p.state,p.__v=n,m)T&&A.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),T&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(T&&A.getDerivedStateFromProps==null&&w!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(w,E),n.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(w,p.__s,E)){n.__v!=r.__v&&(p.props=w,p.state=p.__s,p.__d=!1),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),g.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=C(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(w,p.__s,E),T&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,b)})}if(p.context=E,p.props=w,p.__P=e,p.__e=!1,re=t.__r,ie=0,T)p.state=p.__s,p.__d=!1,re&&re(n),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,re&&re(n),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++ie<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),T&&!m&&p.getSnapshotBeforeUpdate!=null&&(b=p.getSnapshotBeforeUpdate(h,_)),O=d!=null&&d.type===S&&d.key==null?ue(d.props.children):d,c=D(e,v(O)?O:[O],n,r,i,a,o,s,c,l,u),p.base=n.__e,n.__u&=-161,p.__h.length&&s.push(p),x&&(p.__E=p.__=null)}catch(e){if(s.length=f,n.__v=null,l||o!=null){if(e.then){for(n.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),n.__e=c}else if(o!=null)for(k=o.length;k--;)ee(o[k])}else n.__e=r.__e;n.__k??=r.__k||[],e.then||ce(n),t.__e(e,n,r)}}else o==null&&n.__v==r.__v?(n.__k=r.__k,n.__e=r.__e):c=n.__e=de(r.__e,n,r,i,a,o,s,l,u);return(d=t.diffed)&&d(n),128&n.__u?void 0:c}function ce(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ce))}function le(e,n,r){for(var i=0;i<r.length;i++)fe(r[i],r[++i],r[++i]);t.__c&&t.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){t.__e(e,n.__v)}})}function ue(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(ue):e.constructor===void 0?y({},e):null}function de(n,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,b=i.props||h,x=r.props,S=r.type;if(S==`svg`?o=`http://www.w3.org/2000/svg`:S==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!S&&(S?g.localName==S:g.nodeType==3)){n=g,s[d]=null;break}}if(n==null){if(S==null)return document.createTextNode(x);n=document.createElementNS(o,S,x.is&&x),l&&=(t.__m&&t.__m(r,s),!1),s=null}if(S==null)b===x||l&&n.data==x||(n.data=x);else{if(s=S==`textarea`&&x.defaultValue!=null?null:s&&e.call(n.childNodes),!l&&s!=null)for(b={},d=0;d<n.attributes.length;d++)b[(g=n.attributes[d]).name]=g.value;for(d in b)g=b[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in x||d==`value`&&`defaultValue`in x||d==`checked`&&`defaultChecked`in x||ae(n,d,null,g,o);for(d in x)g=x[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||b[d]===g||ae(n,d,g,b[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==n.innerHTML)||(n.innerHTML=f.__html),r.__k=[];else if(p&&(n.innerHTML=``),D(r.type==`template`?n.content:n,v(m)?m:[m],r,i,a,S==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&C(i,0),l,u),s!=null)for(d=s.length;d--;)ee(s[d]);l&&S!=`textarea`||(d=`value`,S==`progress`&&_==null?n.removeAttribute(`value`):_!=null&&(_!==n[d]||S==`progress`&&!_||S==`option`&&_!=b[d])&&ae(n,d,_,b[d],o),d=`checked`,y!=null&&y!=n[d]&&ae(n,d,y,b[d],o))}return n}function fe(e,n,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&n==null||(e.__u=e(n))}else e.current=n}catch(e){t.__e(e,r)}}function pe(e,n,r){var i,a;if(t.unmount&&t.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||fe(i,null,n)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){t.__e(e,n)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&pe(i[a],n,r||typeof e.type!=`function`);r||ee(e.__e),e.__c=e.__=e.__e=void 0}function me(e,t,n){return this.constructor(e,n)}function he(n,r,i){var a,o,s,c;r==document&&(r=document.documentElement),t.__&&t.__(n,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],se(r,n=(!a&&i||r).__k=b(S,null,[n]),o||h,h,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?e.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),le(s,n,c),n.props.children=null}function ge(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,ne(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+m++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}e=g.slice,t={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},n=0,te.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),ne(this))},te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ne(this))},te.prototype.render=S,r=[],a=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,o=function(e,t){return e.__v.__b-t.__v.__b},E.__r=0,s=Math.random().toString(8),c=`__d`+s,l=`__a`+s,u=/(PointerCapture)$|Capture$/i,d=0,f=oe(!1),p=oe(!0),m=0;var _e,j,ve,ye,be=0,xe=[],Se=t,Ce=Se.__b,we=Se.__r,Te=Se.diffed,Ee=Se.__c,M=Se.unmount,De=Se.__;function Oe(e,t){Se.__h&&Se.__h(j,e,be||t),be=0;var n=j.__H||(j.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function N(e){return be=1,ke(L,e)}function ke(e,t,n){var r=Oe(_e++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):L(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=j,!j.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};j.__f=!0;var a=j.shouldComponentUpdate,o=j.componentWillUpdate;j.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},j.shouldComponentUpdate=i}return r.__N||r.__}function P(e,t){var n=Oe(_e++,3);!Se.__s&&Re(n.__H,t)&&(n.__=e,n.u=t,j.__H.__h.push(n))}function Ae(e,t){var n=Oe(_e++,4);!Se.__s&&Re(n.__H,t)&&(n.__=e,n.u=t,j.__h.push(n))}function F(e){return be=5,je(function(){return{current:e}},[])}function je(e,t){var n=Oe(_e++,7);return Re(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function I(e,t){return be=8,je(function(){return e},t)}function Me(e){var t=j.context[e.__c],n=Oe(_e++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(j)),t.props.value):e.__}function Ne(){for(var e;e=xe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ie),t.__h.some(Le),t.__h=[]}catch(n){t.__h=[],Se.__e(n,e.__v)}}}Se.__b=function(e){j=null,Ce&&Ce(e)},Se.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),De&&De(e,t)},Se.__r=function(e){we&&we(e),_e=0;var t=(j=e.__c).__H;t&&(ve===j?(t.__h=[],j.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Ie),t.__h.some(Le),t.__h=[],_e=0)),ve=j},Se.diffed=function(e){Te&&Te(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xe.push(t)!==1&&ye===Se.requestAnimationFrame||((ye=Se.requestAnimationFrame)||Fe)(Ne)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ve=j=null},Se.__c=function(e,t){t.some(function(e){try{e.__h.some(Ie),e.__h=e.__h.filter(function(e){return!e.__||Le(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],Se.__e(n,e.__v)}}),Ee&&Ee(e,t)},Se.unmount=function(e){M&&M(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Ie(e)}catch(e){t=e}}),n.__H=void 0,t&&Se.__e(t,n.__v))};var Pe=typeof requestAnimationFrame==`function`;function Fe(e){var t,n=function(){clearTimeout(r),Pe&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Pe&&(t=requestAnimationFrame(n))}function Ie(e){var t=j,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),j=t}function Le(e){var t=j;e.__c=e.__(),j=t}function Re(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function L(e,t){return typeof t==`function`?t(e):t}function ze(e,t){for(var n in t)e[n]=t[n];return e}function Be(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function Ve(e,t){this.props=e,this.context=t}(Ve.prototype=new te).isPureReactComponent=!0,Ve.prototype.shouldComponentUpdate=function(e,t){return Be(this.props,e)||Be(this.state,t)};var He=t.__b;t.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),He&&He(e)},typeof Symbol<`u`&&Symbol.for;var Ue=t.__e;t.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k||[]),i.__c(e,t)}Ue(e,t,n,r)};var We=t.unmount;function Ge(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=ze({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Ge(e,t,n)})),e}function Ke(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Ke(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function qe(){this.__u=0,this.o=null,this.__b=null}function Je(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function Ye(){this.i=null,this.l=null}t.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),We&&We(e)},(qe.prototype=new te).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=Je(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Ke(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},qe.prototype.componentWillUnmount=function(){this.o=[]},qe.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=Ge(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&b(S,null,e.fallback);return i&&(i.__u&=-33),[b(S,null,t.__a?null:e.children),i]};var Xe=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(Ye.prototype=new te).__a=function(e){var t=this,n=Je(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Xe(t,e,r)):i()};n?n(a):a()}},Ye.prototype.render=function(e){this.i=null,this.l=new Map;var t=O(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},Ye.prototype.componentDidUpdate=Ye.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Xe(e,n,t)})};var Ze=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,Qe=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,$e=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,et=/[A-Z0-9]/g,R=typeof document<`u`,tt=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};function nt(e,t,n){return t.__k??(t.textContent=``),he(e,t),typeof n==`function`&&n(),e?e.__c:null}te.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(te.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var rt=t.event;t.event=function(e){return rt&&(e=rt(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var z={configurable:!0,get:function(){return this.class}},B=t.vnode;t.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||R&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||tt(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:$e.test(a)&&(a=s):s=a=`oninput`:i&&Qe.test(a)?a=a.replace(et,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=O(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=O(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",z)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=Ze,B&&B(e)};var V=t.__r;t.__r=function(e){V&&V(e),e.__c};var it=t.diffed;t.diffed=function(e){it&&it(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};function at(e){return!!e.__k&&(he(null,e),!0)}function ot(e){return{render:function(t){nt(t,e)},unmount:function(){at(e)}}}var H=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function U(e,t,n){let r=await fetch(t,{method:e,headers:n===void 0?{}:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>({}));if(!r.ok)throw new H(r.status,i.error??r.statusText);return i}var st=e=>e.split(`/`).map(encodeURIComponent).join(`/`),ct=e=>U(`GET`,e),lt=(e,t)=>U(`POST`,e,t??{}),ut=(e,t)=>U(`PUT`,e,t??{}),dt=(e,t)=>U(`DELETE`,e,t),W=(e,t)=>e.email!==null&&t.email!==null&&e.email.toLowerCase()===t.email.toLowerCase()||e.name.toLowerCase()===t.name.toLowerCase();function ft(){let e=new URL(window.location.href);return{path:e.pathname,segments:e.pathname.split(`/`).filter(e=>e!==``).map(decodeURIComponent),query:e.searchParams}}var G=new Set,K=null;function pt(e){K=e}function mt(e,t){t?window.history.replaceState(null,``,e):window.history.pushState(null,``,e);for(let e of G)e()}function ht(e,t={}){if(!K){mt(e,t.replace===!0);return}K(e).then(n=>n&&mt(e,t.replace===!0))}function gt(){let[e,t]=N(ft);return P(()=>{let e=()=>t(ft());return G.add(e),window.addEventListener(`popstate`,e),()=>{G.delete(e),window.removeEventListener(`popstate`,e)}},[]),e}var _t=e=>e.map(encodeURIComponent).join(`/`),vt=(e,t)=>`/c/${encodeURIComponent(e)}${t?`?open=${encodeURIComponent(t)}`:``}`,yt=e=>`/b/${_t(e.split(`/`))}`,bt=(e,t)=>`/canvas/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`,xt=e=>`/doc/${_t(e.split(`/`))}`;function St(){return I(e=>{let t=e.target.closest(`a`);if(!t||e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;let n=t.getAttribute(`href`)??``;!n.startsWith(`/`)||t.target===`_blank`||t.hasAttribute(`download`)||(e.preventDefault(),ht(n))},[])}var Ct=0;Array.isArray;function q(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ct,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}function wt(e){let{onClose:t}=e;return P(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t]),q(`div`,{className:`backdrop${e.center?` center`:``}`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:q(`div`,{className:`modal${e.size===`sm`?` modal--sm`:e.size===`lg`?` modal--lg`:e.size===`xl`?` modal--xl`:``}`,role:`dialog`,"aria-modal":`true`,children:[(e.title!==void 0||e.head)&&q(`div`,{className:`modal__head`,children:[e.title!==void 0&&q(`h2`,{children:e.title}),e.head,q(`button`,{className:`quiet icon`,onClick:t,"data-tip":`Close (Esc)`,"data-tip-pos":`bottom`,"aria-label":`Close`,children:q(Qt,{})})]}),q(`div`,{className:`modal__body`,children:e.children}),e.foot&&q(`div`,{className:`modal__foot`,children:e.foot})]})})}var Tt=ge(()=>void 0);function J(e){let[t,n]=N(null),r=F(null),i=I((e,t=`info`)=>{n({message:e,kind:t}),r.current&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>n(null),t===`error`?6e3:3500)},[]);return q(Tt.Provider,{value:i,children:[e.children,t&&q(`div`,{className:`toast${t.kind===`error`?` error`:``}`,children:t.message})]})}var Et=()=>Me(Tt);function Dt(){let e=Et();return I(async(t,n)=>{try{let r=await t();return n&&e(n),r}catch(t){e(t instanceof Error?t.message:String(t),`error`);return}},[e])}var Ot=ge({confirm:async()=>!1,prompt:async()=>null,choose:async()=>null});function Y(e){let[t,n]=N(null),[r,i]=N(``),a={confirm:e=>new Promise(t=>{n({kind:`confirm`,options:e,resolve:t})}),prompt:e=>new Promise(t=>{i(e.initial??``),n({kind:`prompt`,options:e,resolve:t})}),choose:e=>new Promise(t=>{n({kind:`choose`,options:e,resolve:t})})},o=e=>{t&&(n(null),t.kind===`confirm`?t.resolve(e===!0):t.resolve(typeof e==`string`?e:null))};return q(Ot.Provider,{value:a,children:[e.children,t&&q(wt,{title:t.options.title,size:`sm`,center:!0,onClose:()=>o(t.kind!==`confirm`&&null),children:q(`div`,{style:{padding:`4px 18px 16px`},children:[t.options.body&&q(`div`,{className:`muted`,style:{marginBottom:12},children:t.options.body}),t.kind===`prompt`&&q(`div`,{className:`form`,style:{gridTemplateColumns:t.options.label?`110px 1fr`:`1fr`,margin:0},children:[t.options.label&&q(`label`,{children:t.options.label}),q(`input`,{ref:gn,value:r,placeholder:t.options.placeholder,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r.trim()!==``&&o(r.trim())}})]}),q(`div`,{className:`actions`,children:[t.kind===`choose`?t.options.options.map((e,n)=>q(`button`,{className:e.kind===`primary`?`primary`:e.kind===`danger`?`danger`:``,ref:n===t.options.options.length-1?gn:void 0,onClick:()=>o(e.value),children:e.label},e.value)):q(`button`,{onClick:()=>o(t.kind!==`confirm`&&null),children:`Cancel`}),t.kind===`choose`?null:t.kind===`confirm`?q(`button`,{className:t.options.danger?`primary danger-fill`:`primary`,ref:gn,onClick:()=>o(!0),children:t.options.confirm??`OK`}):q(`button`,{className:`primary`,disabled:r.trim()===``,onClick:()=>o(r.trim()),children:t.options.confirm??`OK`})]})]})})]})}var kt=()=>Me(Ot);function At(e){return q(`div`,{className:`md${e.className?` ${e.className}`:``}`,onClick:t=>{let n=t.target.closest(`a`);if(!n)return;let r=n.getAttribute(`href`)??``;if(r===``||r.startsWith(`#`))return;if(t.preventDefault(),t.stopPropagation(),/^[a-z]+:/i.test(r)){window.open(r,`_blank`,`noopener`);return}let i=new URL(r,`http://eidos/${e.base??``}`),a=decodeURIComponent(i.pathname.replace(/^\//,``));a.endsWith(`.md`)&&(e.onOpen?e.onOpen(a):ht(yt(a)))},dangerouslySetInnerHTML:{__html:e.html}})}var jt=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),Mt=e=>e.metaKey||e.ctrlKey,Nt=jt?{}:{"⌘":`Ctrl`,"⌥":`Alt`,"⇧":`Shift`,"⌃":`Ctrl`};function X(e){return q(`span`,{className:`keys`,children:e.combo.split(/\s+\/\s+|\s*·\s*/).map((e,t)=>q(`span`,{className:`keys__alt`,children:[t>0&&q(`span`,{className:`keys__or`,children:`or`}),(e.match(/[⇧⌘⌥⌃]|[^⇧⌘⌥⌃]+/g)??[e]).map((e,t)=>q(`kbd`,{className:/^[⇧⌘⌥⌃]$/.test(e)?`mod`:``,children:Nt[e]??e},t))]},t))})}var Pt=new Map,Ft=new Set,It=()=>Ft.forEach(e=>e());function Lt(e,t){let n=F(Symbol(e)),r=JSON.stringify(t);P(()=>{let t=n.current;return Pt.set(t,{where:e,entries:JSON.parse(r)}),It(),()=>{Pt.delete(t),It()}},[e,r])}function Rt(){let[,e]=N(0);return P(()=>{let t=()=>e(e=>e+1);return Ft.add(t),()=>{Ft.delete(t)}},[]),[...Pt.values()]}function zt(e){let t=Rt();return q(wt,{title:`Keyboard shortcuts`,size:`sm`,center:!0,onClose:e.onClose,children:q(`div`,{style:{padding:`4px 18px 16px`},children:t.map(e=>q(`div`,{children:[q(`h3`,{className:`settings__h`,children:e.where}),q(`table`,{className:`mini`,children:q(`tbody`,{children:e.entries.map(e=>q(`tr`,{children:[q(`td`,{style:{whiteSpace:`nowrap`},children:q(X,{combo:e.keys})}),q(`td`,{className:`muted`,children:e.what})]},e.keys))})})]},e.where))})})}var Bt=`eidosmd:dropdown-open`;function Vt(e){window.dispatchEvent(new CustomEvent(Bt,{detail:e}))}function Ht(e,t){P(()=>{let n=n=>{n.detail!==e&&t()};return window.addEventListener(Bt,n),()=>window.removeEventListener(Bt,n)},[e,t])}function Ut(e){let t=[],n=e=>{if(Array.isArray(e)){e.forEach(n);return}if(!e||typeof e!=`object`||!(`props`in e))return;let r=e;r.type===`option`?t.push({value:String(r.props.value??``),label:r.props.children??String(r.props.value??``),disabled:r.props.disabled===!0}):r.type===S&&n(r.props.children)};return n(e),t}function Z(e){let{value:t,onChange:n,children:r,disabled:i,title:a,style:o,className:s,...c}=e,[l,u]=N(!1),d=F({}),f=F(null),p=I(()=>u(!1),[]);Ht(d.current,p),P(()=>{if(!l)return;let e=e=>{f.current?.contains(e.target)||u(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),u(!1))};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t,!0)}},[l]);let[m,h]=N(!1),g=Ut(r),_=String(t??``),v=g.find(e=>e.value===_)??g[0],y=e=>{u(!1),h(!0),e!==_&&n?.({target:{value:e}})},ee={};for(let[e,t]of Object.entries(c))(e.startsWith(`data-`)||e.startsWith(`aria-`))&&typeof t==`string`&&(ee[e]=t);return q(`div`,{ref:f,className:`select${l?` open`:``}${s?` ${s}`:``}`,style:o,title:a,...ee,...m?{"data-tip-off":``}:{},onMouseLeave:()=>h(!1),children:[q(`button`,{type:`button`,className:`select__btn`,disabled:i,"aria-haspopup":`listbox`,"aria-expanded":l,onClick:()=>{l||Vt(d.current),h(!0),u(!l)},children:[q(`span`,{className:`select__val`,children:v?.label??``}),q(`svg`,{className:`select__chev`,viewBox:`0 0 16 16`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:q(`path`,{d:`M4 6l4 4 4-4`})})]}),l&&q(`div`,{className:`popover popover--left select__menu`,role:`listbox`,children:g.map(e=>q(`button`,{type:`button`,role:`option`,"aria-selected":e.value===_,className:e.value===_?`on`:``,disabled:e.disabled,onClick:()=>y(e.value),children:e.label},e.value))})]})}function Wt(e){let[t,n]=N(!1),[r,i]=N(0),[a,o]=N(!1),s=F({}),c=F(null),l=I(()=>n(!1),[]);Ht(s.current,l);let u=je(()=>{let t=e.value.trim().toLowerCase();return(!a||t===``?e.options:e.options.filter(e=>e.toLowerCase().includes(t))).slice(0,40)},[e.value,e.options,a]);P(()=>i(0),[u.length,e.value]),P(()=>{e.autoFocus&&c.current?.focus()},[e.autoFocus]);let d=t=>{n(!1),e.onChange(t),e.onCommit?.(t)},f=t&&u.length>0;return q(`div`,{className:`suggest${f?` open`:``}${e.className?` ${e.className}`:``}`,style:e.style,children:[q(`input`,{ref:c,value:e.value,placeholder:e.placeholder,onChange:t=>{e.onChange(t.target.value),o(!0),n(!0)},onFocus:e=>{Vt(s.current),o(!1),n(!0),e.target.select()},onBlur:()=>{n(!1),e.onCommit?.(e.value)},onKeyDown:t=>{if(t.key===`ArrowDown`&&u.length>0)t.preventDefault(),n(!0),i(e=>Math.min(u.length-1,e+1));else if(t.key===`ArrowUp`&&u.length>0)t.preventDefault(),i(e=>Math.max(0,e-1));else if(t.key===`Enter`){t.preventDefault();let e=u[r];f&&e!==void 0?d(e):c.current?.blur()}else t.key===`Escape`&&(n(!1),e.onCancel?.())}}),f&&q(`div`,{className:`popover popover--left select__menu suggest__menu`,role:`listbox`,onMouseDown:e=>e.preventDefault(),children:u.map((t,n)=>q(`button`,{type:`button`,role:`option`,"aria-selected":n===r,className:`${n===r?`on`:``}${t===e.value?` held`:``}`,onMouseEnter:()=>i(n),onClick:()=>d(t),children:t},t))})]})}function Gt(e){let[t,n]=N(!1),[r,i]=N(e.value),a=()=>{e.onChange(r),n(!1)};return q(`div`,{className:`longtext`,children:[q(`div`,{className:`longtext__text`,children:e.value||q(`span`,{className:`faint`,children:e.placeholder??`Nothing yet`})}),q(`button`,{type:`button`,className:`small quiet`,onClick:()=>{i(e.value),n(!0)},children:`Edit`}),t&&q(wt,{title:e.label,size:`sm`,center:!0,onClose:()=>n(!1),foot:q(S,{children:[q(`button`,{onClick:()=>n(!1),children:`Cancel`}),q(`button`,{className:`primary`,onClick:a,children:`Done`})]}),children:q(`div`,{style:{padding:`4px 18px 12px`},children:q(`textarea`,{ref:gn,className:`longtext__editor`,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&a()}})})})]})}var Kt=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],qt=e=>String(e).padStart(2,`0`),Jt=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}:\d{2}))?/.exec(e.trim());return t?{y:Number(t[1]),m:Number(t[2]),d:Number(t[3]),time:t[4]??``}:null};function Yt(e){let[t,n]=N(!1),[r,i]=N(e.value);P(()=>i(e.value),[e.value]);let a=new Date,o=Jt(e.value),[s,c]=N({y:o?.y??a.getFullYear(),m:o?.m??a.getMonth()+1}),l=F({}),u=F(null),d=I(()=>n(!1),[]);Ht(l.current,d),P(()=>{if(!t)return;let r=Jt(e.value);c({y:r?.y??a.getFullYear(),m:r?.m??a.getMonth()+1});let i=e=>{u.current?.contains(e.target)||n(!1)},o=e=>{e.key===`Escape`&&(e.stopPropagation(),n(!1))};return window.addEventListener(`pointerdown`,i,!0),window.addEventListener(`keydown`,o,!0),()=>{window.removeEventListener(`pointerdown`,i,!0),window.removeEventListener(`keydown`,o,!0)}},[t]);let f=()=>{t||Vt(l.current),n(!t)},p=()=>{let t=r.trim();if(t===``){e.value!==``&&e.onChange(null);return}Jt(t)?t!==e.value&&e.onChange(t):i(e.value)},m=(t,r,i)=>{let a=`${t}-${qt(r)}-${qt(i)}`;e.onChange(e.time?`${a}T${o?.time||`09:00`}`:a),n(!1)},h=t=>{if(!/^\d{2}:\d{2}$/.test(t))return;let n=o??{y:a.getFullYear(),m:a.getMonth()+1,d:a.getDate(),time:``};e.onChange(`${n.y}-${qt(n.m)}-${qt(n.d)}T${t}`)},g=e=>{let t=s.y*12+(s.m-1)+e;c({y:Math.floor(t/12),m:t%12+1})},_=new Date(s.y,s.m-1,1),v=new Date(s.y,s.m-1,1-_.getDay()),y=Array.from({length:42},(e,t)=>new Date(v.getFullYear(),v.getMonth(),v.getDate()+t)),ee=e=>o!==null&&e.getFullYear()===o.y&&e.getMonth()+1===o.m&&e.getDate()===o.d,b=e=>e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()&&e.getDate()===a.getDate();return q(`div`,{ref:u,className:`datepick${t?` open`:``}${e.className?` ${e.className}`:``}`,children:[q(`input`,{value:r,placeholder:e.time?`YYYY-MM-DDTHH:MM`:`YYYY-MM-DD`,onChange:e=>i(e.target.value),onBlur:p,onKeyDown:t=>{t.key===`Enter`?t.target.blur():t.key===`Escape`&&i(e.value)}}),q(`button`,{type:`button`,className:`datepick__btn`,onClick:f,"aria-label":`Pick a date`,"aria-expanded":t,children:q(dn,{})}),t&&q(`div`,{className:`popover popover--left datepick__menu`,onMouseDown:e=>e.preventDefault(),children:[q(`div`,{className:`datepick__head`,children:[q(`button`,{type:`button`,onClick:()=>g(-1),"aria-label":`Previous month`,children:`‹`}),q(`strong`,{children:[Kt[s.m-1],` `,s.y]}),q(`button`,{type:`button`,onClick:()=>g(1),"aria-label":`Next month`,children:`›`})]}),q(`div`,{className:`datepick__grid`,children:[[`S`,`M`,`T`,`W`,`T`,`F`,`S`].map((e,t)=>q(`span`,{children:e},t)),y.map(e=>q(`button`,{type:`button`,className:`${ee(e)?`on`:``}${b(e)?` today`:``}${e.getMonth()===s.m-1?``:` faint`}`,onClick:()=>m(e.getFullYear(),e.getMonth()+1,e.getDate()),children:e.getDate()},e.toISOString()))]}),e.time&&q(`label`,{className:`datepick__time`,children:[`Time`,q(`input`,{defaultValue:o?.time??``,placeholder:`HH:MM`,onBlur:e=>h(e.target.value.trim()),onKeyDown:e=>e.key===`Enter`&&e.target.blur()})]}),q(`div`,{className:`datepick__foot`,children:[q(`button`,{type:`button`,onClick:()=>(e.onChange(null),n(!1)),children:`Clear`}),q(`button`,{type:`button`,onClick:()=>m(a.getFullYear(),a.getMonth()+1,a.getDate()),children:`Today`})]})]})]})}var Xt={viewBox:`0 0 16 16`,width:14,height:14,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`};function Zt(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:q(`path`,{d:`M2.5 4.5h11M6 4.5V3h4v1.5M4 4.5l.7 8.5h6.6l.7-8.5M6.7 7v4M9.3 7v4`})})}function Qt(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:q(`path`,{d:`M4 4l8 8M12 4l-8 8`})})}var $t=(()=>{let e=6.9,t=5.3,n=[];for(let r=0;r<8;r+=1){let i=r/8*Math.PI*2,a=Math.PI*2/8;for(let[r,o]of[[t,-a*.28],[e,-a*.16],[e,a*.16],[t,a*.28]])n.push(`${(8+Math.cos(i+o)*r).toFixed(2)} ${(8+Math.sin(i+o)*r).toFixed(2)}`)}return`M${n.join(`L`)}Z`})();function en(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:[q(`path`,{d:$t,strokeLinejoin:`round`}),q(`circle`,{cx:`8`,cy:`8`,r:`2`})]})}function tn(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:q(`path`,{d:`M7 3H3.5v9.5H13V9M9.5 2.5H13.5v4M13.5 2.5L7.5 8.5`})})}function nn(e){return q(`svg`,{...Xt,"aria-hidden":`true`,style:{transform:e.direction===`down`?`rotate(180deg)`:`none`},children:q(`path`,{d:`M8 13V3M3.5 7.5L8 3l4.5 4.5`})})}function rn(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:[q(`circle`,{cx:`3.5`,cy:`8`,r:`0.9`,fill:`currentColor`}),q(`circle`,{cx:`8`,cy:`8`,r:`0.9`,fill:`currentColor`}),q(`circle`,{cx:`12.5`,cy:`8`,r:`0.9`,fill:`currentColor`})]})}function an(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:[q(`circle`,{cx:`8`,cy:`8`,r:`6.2`}),q(`path`,{d:`M6.2 6.3a1.9 1.9 0 013.7.5c0 1.2-1.9 1.4-1.9 2.6M8 11.6h.01`})]})}function on(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:[q(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),q(`path`,{d:`M4.5 6l2 2-2 2M8 10h3`})]})}function sn(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:q(`path`,{d:`M2.5 4.5h11M2.5 8h11M2.5 11.5h11`})})}function cn(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:q(`path`,{d:`M8 3v10M3 8h10`})})}function ln(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:[q(`path`,{d:`M3.5 3.5A1.5 1.5 0 015 2h8v10.5H5a1.5 1.5 0 00-1.5 1.5z`}),q(`path`,{d:`M3.5 12.5A1.5 1.5 0 015 11h8v3H5a1.5 1.5 0 01-1.5-1.5M6 5h4`})]})}function un(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:[q(`path`,{d:`M9 2H4.5A1 1 0 003.5 3v10a1 1 0 001 1h7a1 1 0 001-1V6zM9 2v4h3.5`}),q(`path`,{d:`M6 11.5l.6-1.9 4.1-4.1 1.3 1.3-4.1 4.1z`,fill:`currentColor`,stroke:`none`})]})}function dn(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:[q(`rect`,{x:`2.5`,y:`3.5`,width:`11`,height:`10`,rx:`1.5`}),q(`path`,{d:`M2.5 6.5h11M5.5 2v3M10.5 2v3`})]})}function fn(){return q(`svg`,{...Xt,"aria-hidden":`true`,children:[q(`rect`,{x:`3.5`,y:`7`,width:`9`,height:`6.5`,rx:`1.5`}),q(`path`,{d:`M5.5 7V5a2.5 2.5 0 015 0v2`})]})}function pn(e){return q(`svg`,{...Xt,"aria-hidden":`true`,style:{transform:e.open?`rotate(90deg)`:`none`,transition:`transform 0.12s`},children:q(`path`,{d:`M6 3.5l4.5 4.5L6 12.5`})})}function mn(e){let t=e.type.toLowerCase();return t===`list`?q(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[q(`path`,{d:`M5 4h8M5 8h8M5 12h8`}),q(`circle`,{cx:`2.5`,cy:`4`,r:`0.6`,fill:`currentColor`}),q(`circle`,{cx:`2.5`,cy:`8`,r:`0.6`,fill:`currentColor`}),q(`circle`,{cx:`2.5`,cy:`12`,r:`0.6`,fill:`currentColor`})]}):t===`number`?q(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:q(`path`,{d:`M6 2 4 14M12 2l-2 12M3 6h11M2 10h11`})}):t===`checkbox`?q(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[q(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`2`}),q(`path`,{d:`m5 8 2 2 4-4`})]}):t.startsWith(`date`)?q(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[q(`rect`,{x:`2.5`,y:`3.5`,width:`11`,height:`10`,rx:`2`}),q(`path`,{d:`M2.5 7h11M5.5 2v3M10.5 2v3`})]}):q(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:q(`path`,{d:`M3 4h10M8 4v9M5.5 13h5`})})}function hn(){return q(`div`,{className:`empty`,children:`Loading…`})}function gn(e){e?.focus()}function _n(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let n=document.implementation.createHTMLDocument(),r=n.createElement(`base`),i=n.createElement(`a`);return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}var vn=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function yn(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}var bn=null;function xn(e={}){return bn||(e.includeStyleProperties?(bn=e.includeStyleProperties,bn):(bn=yn(window.getComputedStyle(document.documentElement)),bn))}function Sn(e,t){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace(`px`,``)):0}function Cn(e){let t=Sn(e,`border-left-width`),n=Sn(e,`border-right-width`);return e.clientWidth+t+n}function wn(e){let t=Sn(e,`border-top-width`),n=Sn(e,`border-bottom-width`);return e.clientHeight+t+n}function Tn(e,t={}){return{width:t.width||Cn(e),height:t.height||wn(e)}}function En(){let e,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}var Dn=16384;function On(e){(e.width>Dn||e.height>Dn)&&(e.width>Dn&&e.height>Dn?e.width>e.height?(e.height*=Dn/e.width,e.width=Dn):(e.width*=Dn/e.height,e.height=Dn):e.width>Dn?(e.height*=Dn/e.width,e.width=Dn):(e.width*=Dn/e.height,e.height=Dn))}function kn(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin=`anonymous`,r.decoding=`async`,r.src=e})}async function An(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function jn(e,t,n){let r=`http://www.w3.org/2000/svg`,i=document.createElementNS(r,`svg`),a=document.createElementNS(r,`foreignObject`);return i.setAttribute(`width`,`${t}`),i.setAttribute(`height`,`${n}`),i.setAttribute(`viewBox`,`0 0 ${t} ${n}`),a.setAttribute(`width`,`100%`),a.setAttribute(`height`,`100%`),a.setAttribute(`x`,`0`),a.setAttribute(`y`,`0`),a.setAttribute(`externalResourcesRequired`,`true`),i.appendChild(a),a.appendChild(e),An(i)}var Mn=(e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Mn(n,t)};function Nn(e){let t=e.getPropertyValue(`content`);return`${e.cssText} content: '${t.replace(/'|"/g,``)}';`}function Pn(e,t){return xn(t).map(t=>`${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t)?` !important`:``};`).join(` `)}function Fn(e,t,n,r){let i=`.${e}:${t}`,a=n.cssText?Nn(n):Pn(n,r);return document.createTextNode(`${i}{${a}}`)}function In(e,t,n,r){let i=window.getComputedStyle(e,n),a=i.getPropertyValue(`content`);if(a===``||a===`none`)return;let o=vn();try{t.className=`${t.className} ${o}`}catch{return}let s=document.createElement(`style`);s.appendChild(Fn(o,n,i,r)),t.appendChild(s)}function Ln(e,t,n){In(e,t,`:before`,n),In(e,t,`:after`,n)}var Rn=`application/font-woff`,zn=`image/jpeg`,Bn={woff:Rn,woff2:Rn,ttf:`application/font-truetype`,eot:`application/vnd.ms-fontobject`,png:`image/png`,jpg:zn,jpeg:zn,gif:`image/gif`,tiff:`image/tiff`,svg:`image/svg+xml`,webp:`image/webp`};function Vn(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:``}function Hn(e){return Bn[Vn(e).toLowerCase()]||``}function Un(e){return e.split(/,/)[1]}function Wn(e){return e.search(/^(data:)/)!==-1}function Gn(e,t){return`data:${t};base64,${e}`}async function Kn(e,t,n){let r=await fetch(e,t);if(r.status===404)throw Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((e,t)=>{let a=new FileReader;a.onerror=t,a.onloadend=()=>{try{e(n({res:r,result:a.result}))}catch(e){t(e)}},a.readAsDataURL(i)})}var qn={};function Jn(e,t,n){let r=e.replace(/\?.*/,``);return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,``)),t?`[${t}]${r}`:r}async function Yn(e,t,n){let r=Jn(e,t,n.includeQueryParams);if(qn[r]!=null)return qn[r];n.cacheBust&&(e+=(/\?/.test(e)?`&`:`?`)+new Date().getTime());let i;try{i=Gn(await Kn(e,n.fetchRequestInit,({res:e,result:n})=>(t||=e.headers.get(`Content-Type`)||``,Un(n))),t)}catch(t){i=n.imagePlaceholder||``;let r=`Failed to fetch resource: ${e}`;t&&(r=typeof t==`string`?t:t.message),r&&console.warn(r)}return qn[r]=i,i}async function Xn(e){let t=e.toDataURL();return t===`data:,`?e.cloneNode(!1):kn(t)}async function Zn(e,t){if(e.currentSrc){let t=document.createElement(`canvas`),n=t.getContext(`2d`);return t.width=e.clientWidth,t.height=e.clientHeight,n?.drawImage(e,0,0,t.width,t.height),kn(t.toDataURL())}let n=e.poster;return kn(await Yn(n,Hn(n),t))}async function Qn(e,t){try{if(e?.contentDocument?.body)return await cr(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function $n(e,t){return Mn(e,HTMLCanvasElement)?Xn(e):Mn(e,HTMLVideoElement)?Zn(e,t):Mn(e,HTMLIFrameElement)?Qn(e,t):e.cloneNode(tr(e))}var er=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SLOT`,tr=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SVG`;async function nr(e,t,n){if(tr(t))return t;let r=[];return r=er(e)&&e.assignedNodes?yn(e.assignedNodes()):Mn(e,HTMLIFrameElement)&&e.contentDocument?.body?yn(e.contentDocument.body.childNodes):yn((e.shadowRoot??e).childNodes),r.length===0||Mn(e,HTMLVideoElement)||await r.reduce((e,r)=>e.then(()=>cr(r,n)).then(e=>{e&&t.appendChild(e)}),Promise.resolve()),t}function rr(e,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):xn(n).forEach(n=>{let a=i.getPropertyValue(n);n===`font-size`&&a.endsWith(`px`)&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),Mn(e,HTMLIFrameElement)&&n===`display`&&a===`inline`&&(a=`block`),n===`d`&&t.getAttribute(`d`)&&(a=`path(${t.getAttribute(`d`)})`),r.setProperty(n,a,i.getPropertyPriority(n))})}function ir(e,t){Mn(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Mn(e,HTMLInputElement)&&t.setAttribute(`value`,e.value)}function ar(e,t){if(Mn(e,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(t=>e.value===t.getAttribute(`value`));r&&r.setAttribute(`selected`,``)}}function or(e,t,n){return Mn(t,Element)&&(rr(e,t,n),Ln(e,t,n),ir(e,t),ar(e,t)),t}async function sr(e,t){let n=e.querySelectorAll?e.querySelectorAll(`use`):[];if(n.length===0)return e;let r={};for(let i=0;i<n.length;i++){let a=n[i].getAttribute(`xlink:href`);if(a){let n=e.querySelector(a),i=document.querySelector(a);!n&&i&&!r[a]&&(r[a]=await cr(i,t,!0))}}let i=Object.values(r);if(i.length){let t=`http://www.w3.org/1999/xhtml`,n=document.createElementNS(t,`svg`);n.setAttribute(`xmlns`,t),n.style.position=`absolute`,n.style.width=`0`,n.style.height=`0`,n.style.overflow=`hidden`,n.style.display=`none`;let r=document.createElementNS(t,`defs`);n.appendChild(r);for(let e=0;e<i.length;e++)r.appendChild(i[e]);e.appendChild(n)}return e}async function cr(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(e=>$n(e,t)).then(n=>nr(e,n,t)).then(n=>or(e,n,t)).then(e=>sr(e,t))}var lr=/url\((['"]?)([^'"]+?)\1\)/g,ur=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,dr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function fr(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}function pr(e){let t=[];return e.replace(lr,(e,n,r)=>(t.push(r),e)),t.filter(e=>!Wn(e))}async function mr(e,t,n,r,i){try{let a=n?_n(t,n):t,o=Hn(t),s;return s=i?Gn(await i(a),o):await Yn(a,o,r),e.replace(fr(t),`$1${s}$3`)}catch{}return e}function hr(e,{preferredFontFormat:t}){return t?e.replace(dr,e=>{for(;;){let[n,,r]=ur.exec(e)||[];if(!r)return``;if(r===t)return`src: ${n};`}}):e}function gr(e){return e.search(lr)!==-1}async function _r(e,t,n){if(!gr(e))return e;let r=hr(e,n);return pr(r).reduce((e,r)=>e.then(e=>mr(e,r,t,n)),Promise.resolve(r))}async function vr(e,t,n){let r=t.style?.getPropertyValue(e);if(r){let i=await _r(r,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function yr(e,t){await vr(`background`,e,t)||await vr(`background-image`,e,t),await vr(`mask`,e,t)||await vr(`-webkit-mask`,e,t)||await vr(`mask-image`,e,t)||await vr(`-webkit-mask-image`,e,t)}async function br(e,t){let n=Mn(e,HTMLImageElement);if(!(n&&!Wn(e.src))&&!(Mn(e,SVGImageElement)&&!Wn(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,i=await Yn(r,Hn(r),t);await new Promise((r,a)=>{e.onload=r,e.onerror=t.onImageErrorHandler?(...e)=>{try{r(t.onImageErrorHandler(...e))}catch(e){a(e)}}:a;let o=e;o.decode&&=r,o.loading===`lazy`&&(o.loading=`eager`),n?(e.srcset=``,e.src=i):e.href.baseVal=i})}async function xr(e,t){let n=yn(e.childNodes).map(e=>Sr(e,t));await Promise.all(n).then(()=>e)}async function Sr(e,t){Mn(e,Element)&&(await yr(e,t),await br(e,t),await xr(e,t))}function Cr(e,t){let{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(e=>{n[e]=r[e]}),e}var wr={};async function Tr(e){let t=wr[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},wr[e]=t,t)}async function Er(e,t){let n=e.cssText,r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let a=i.replace(r,`$1`);return a.startsWith(`https://`)||(a=new URL(a,e.url).href),Kn(a,t.fetchRequestInit,({result:e})=>(n=n.replace(i,`url(${e})`),[i,e]))});return Promise.all(i).then(()=>n)}function Dr(e){if(e==null)return[];let t=[],n=e.replace(/(\/\*[\s\S]*?\*\/)/gi,``),r=RegExp(`((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})`,`gi`);for(;;){let e=r.exec(n);if(e===null)break;t.push(e[0])}n=n.replace(r,``);let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=RegExp(`((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})`,`gi`);for(;;){let e=i.exec(n);if(e===null){if(e=a.exec(n),e===null)break;i.lastIndex=a.lastIndex}else a.lastIndex=i.lastIndex;t.push(e[0])}return t}async function Or(e,t){let n=[],r=[];return e.forEach(n=>{if(`cssRules`in n)try{yn(n.cssRules||[]).forEach((e,i)=>{if(e.type===CSSRule.IMPORT_RULE){let a=i+1,o=e.href,s=Tr(o).then(e=>Er(e,t)).then(e=>Dr(e).forEach(e=>{try{n.insertRule(e,e.startsWith(`@import`)?a+=1:n.cssRules.length)}catch(t){console.error(`Error inserting rule from remote css`,{rule:e,error:t})}})).catch(e=>{console.error(`Error loading remote css`,e.toString())});r.push(s)}})}catch(i){let a=e.find(e=>e.href==null)||document.styleSheets[0];n.href!=null&&r.push(Tr(n.href).then(e=>Er(e,t)).then(e=>Dr(e).forEach(e=>{a.insertRule(e,a.cssRules.length)})).catch(e=>{console.error(`Error loading remote stylesheet`,e)})),console.error(`Error inlining remote css file`,i)}}),Promise.all(r).then(()=>(e.forEach(e=>{if(`cssRules`in e)try{yn(e.cssRules||[]).forEach(e=>{n.push(e)})}catch(t){console.error(`Error while reading CSS rules from ${e.href}`,t)}}),n))}function kr(e){return e.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>gr(e.style.getPropertyValue(`src`)))}async function Ar(e,t){if(e.ownerDocument==null)throw Error(`Provided element is not within a Document`);return kr(await Or(yn(e.ownerDocument.styleSheets),t))}function jr(e){return e.trim().replace(/["']/g,``)}function Mr(e){let t=new Set;function n(e){(e.style.fontFamily||getComputedStyle(e).fontFamily).split(`,`).forEach(e=>{t.add(jr(e))}),Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&n(e)})}return n(e),t}async function Nr(e,t){let n=await Ar(e,t),r=Mr(e);return(await Promise.all(n.filter(e=>r.has(jr(e.style.fontFamily))).map(e=>{let n=e.parentStyleSheet?e.parentStyleSheet.href:null;return _r(e.cssText,n,t)}))).join(`
|
|
2
|
+
`)}async function Pr(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await Nr(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function Fr(e,t={}){let{width:n,height:r}=Tn(e,t),i=await cr(e,t,!0);return await Pr(i,t),await Sr(i,t),Cr(i,t),await jn(i,n,r)}async function Ir(e,t={}){let{width:n,height:r}=Tn(e,t),i=await kn(await Fr(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||En(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||On(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}async function Lr(e,t={}){return(await Ir(e,t)).toDataURL()}var Rr=ge({settings:null,save:async()=>null}),zr=()=>Me(Rr),Br=/^\[([^\]]*)\]\(([^)]+)\)$/;function Vr(e){return Object.entries(e).map(([e,t])=>({key:e,value:t}))}function Hr(e,t,n){return n.find(t=>t.name===e)?.type||(Array.isArray(t)?`List`:typeof t==`number`?`Number`:typeof t==`boolean`?`Checkbox`:typeof t==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(t)?`Date`:`Text`)}var Ur=(e,t)=>{let n=t.find(t=>t.name===e)?.owner;return n&&n!==`eidos`&&n!==`custom`?n:null};function Wr(e,t){if(/^[a-z]+:/i.test(t))return null;let n=new URL(t,`http://eidos/${e}`),r=decodeURIComponent(n.pathname.replace(/^\//,``));return r.endsWith(`.md`)?r:null}function Gr(e){let{value:t}=e;if(t==null||t===``)return q(`span`,{className:`faint`,children:`—`});if(typeof t==`boolean`)return q(`span`,{children:t?`Yes`:`No`});if(typeof t==`string`){let n=Br.exec(t.trim());if(n){let t=Wr(e.base,n[2]??``);return t?q(`a`,{className:`link`,href:yt(t),onClick:n=>{e.onOpen&&(n.preventDefault(),n.stopPropagation(),e.onOpen(t))},children:n[1]}):q(`a`,{className:`link`,href:n[2],target:`_blank`,rel:`noreferrer`,children:n[1]})}return/^https?:\/\//.test(t)?q(`a`,{className:`link`,href:t,target:`_blank`,rel:`noreferrer`,children:t}):q(`span`,{children:[e.color&&q(`i`,{className:`swatch`,style:{background:e.color}}),t]})}return Array.isArray(t)?q(`span`,{className:`list`,children:t.map((t,n)=>q(`span`,{className:`chip`,children:q(Gr,{value:t,base:e.base,onOpen:e.onOpen})},n))}):q(`code`,{children:JSON.stringify(t)})}function Kr(e,t,n){let r=n.find(t=>t.name===e)?.canvas?.color;if(!r||typeof t!=`string`)return;let i=Object.keys(r).find(e=>e.toLowerCase()===t.toLowerCase());return i?r[i]:void 0}function qr(e){let[t,n]=N(``),r=()=>{let r=t.trim();r!==``&&(e.onChange([...e.value,r]),n(``))};return q(`span`,{className:`list`,children:[e.value.map((t,n)=>q(`span`,{className:`chip`,children:[typeof t==`string`?t.replace(Br,`$1`):String(t),q(`button`,{type:`button`,onClick:()=>e.onChange(e.value.filter((e,t)=>t!==n)),"aria-label":`Remove`,children:q(Zt,{})})]},n)),q(`input`,{value:t,placeholder:`add…`,onChange:e=>n(e.target.value),onBlur:r,onKeyDown:n=>{n.key===`Enter`||n.key===`,`?(n.preventDefault(),r()):n.key===`Backspace`&&t===``&&e.value.length>0&&e.onChange(e.value.slice(0,-1))}})]})}function Jr(e){let t=e.type.toLowerCase();return t===`list`?q(qr,{value:Array.isArray(e.value)?e.value:e.value===null||e.value===void 0||e.value===``?[]:[e.value],onChange:e.onChange}):t===`checkbox`?q(`input`,{type:`checkbox`,checked:e.value===!0,onChange:t=>e.onChange(t.target.checked)}):t===`number`?q(`input`,{type:`number`,value:typeof e.value==`number`?e.value:``,onChange:t=>e.onChange(t.target.value===``?null:Number(t.target.value))}):t===`date`?q(Yt,{value:typeof e.value==`string`?e.value:``,onChange:t=>e.onChange(t)}):t===`date & time`?q(Yt,{time:!0,value:typeof e.value==`string`?e.value:``,onChange:t=>e.onChange(t)}):q(Wt,{value:e.value===null||e.value===void 0?``:String(e.value),options:e.options,onChange:t=>e.onChange(t===``?null:t)})}function Yr(e){let[t,n]=N(``),[r,i]=N(null),a=F(null),o=e.editable===!0&&e.onChange!==void 0,s=(t,n)=>e.onChange?.(e.entries.map((e,r)=>r===t?{...e,value:n}:e));P(()=>{if(!r)return;let e=a.current;if(!e)return;e.querySelector(`input, select, textarea`)?.focus();let t=t=>{let n=t.relatedTarget;n&&e.contains(n)||window.setTimeout(()=>{e.contains(document.activeElement)||c()},0)};return e.addEventListener(`focusout`,t),()=>e.removeEventListener(`focusout`,t)},[r?.key]);let c=()=>{let t=l.current;if(!t)return;l.current=null,i(null);let n=e.entries.find(e=>e.key===t.key);!n||JSON.stringify(n.value)===JSON.stringify(t.value)||e.onCommit?.(e.entries.map(e=>e.key===t.key?{...e,value:t.value}:e))},l=F(r);l.current=r;let u=t=>e.onChange?.(e.entries.filter((e,n)=>n!==t)),d=t=>{if(t===``||e.entries.some(e=>e.key===t))return;let n=Hr(t,null,e.schema).toLowerCase();e.onChange?.([...e.entries,{key:t,value:n===`list`?[]:n!==`checkbox`&&null}])},f=e.schema.filter(t=>!e.entries.some(e=>e.key===t.name)&&!Ur(t.name,e.schema)&&t.name!==`title`&&t.name!==`summary`);return q(`div`,{className:`props`,children:[e.entries.map((t,n)=>{let d=Hr(t.key,t.value,e.schema),f=e.schema.some(e=>e.name===t.key),p=e.schema.find(e=>e.name===t.key)?.meaning,m=Ur(t.key,e.schema),h=o&&!m,g=!o&&r?.key===t.key,_=!o&&!m&&e.onCommit!==void 0&&!g;return q(`div`,{className:`prop${h?` prop--edit`:``}${_?` prop--hot`:``}${g?` prop--inline`:``}`,ref:g?a:void 0,title:m?`${p??``}\nWritten by ${m}; not edited here.`.trim():p??(f?void 0:`Not in the schema`),onKeyDown:e=>{g&&(e.key===`Escape`?(l.current=null,i(null)):e.key===`Enter`&&e.target.tagName!==`TEXTAREA`&&!e.target.closest(`.list`)&&c())},children:[q(`span`,{className:`prop__icon`,children:m&&(o||e.onCommit)?q(fn,{}):q(mn,{type:d})}),q(`span`,{className:`prop__name${f?``:` unknown`}`,children:t.key}),q(`span`,{className:`prop__value`,onClick:e=>{!_||e.target.closest(`a`)||i({key:t.key,value:t.value})},children:h?q(Jr,{type:d,value:t.value,options:e.known[t.key]??[],onChange:e=>s(n,e)}):g&&r?q(Jr,{type:d,value:r.value,options:e.known[t.key]??[],onChange:e=>i({key:t.key,value:e})}):q(Gr,{value:t.value,base:e.base,color:Kr(t.key,t.value,e.schema),onOpen:e.onOpen})}),h&&q(`button`,{type:`button`,className:`prop__remove`,onClick:()=>u(n),"aria-label":`Remove property`,"data-tip":`Remove`,"data-tip-pos":`left`,children:q(Zt,{})})]},t.key)}),o&&q(`div`,{className:`prop--add`,children:[q(`span`,{children:`+`}),q(Z,{value:``,onChange:e=>{d(e.target.value)},children:[q(`option`,{value:``,children:`Add property…`}),f.map(e=>q(`option`,{value:e.name,children:[e.name,` (`,e.type,`)`]},e.name))]}),q(`input`,{value:t,placeholder:`or a custom name`,style:{width:140},onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(d(t.trim().replace(/\s+/g,`_`)),n(``))}})]})]})}function Xr(e){return e.findings.length===0?null:q(`ul`,{className:`findings`,children:e.findings.map((e,t)=>q(`li`,{className:e.level,children:[q(`code`,{children:e.code}),e.message]},t))})}function Zr(e,t){let[n,r]=N(null),[i,a]=N(null),[o,s]=N(0);return P(()=>{let t=!0;return ct(`/api/blueprints/${st(e)}`).then(e=>t&&(r(e),a(null))).catch(e=>t&&a(e.message)),()=>{t=!1}},[e,t,o]),{detail:n,error:i,reload:()=>s(e=>e+1)}}var Qr=new Set([`title`,`summary`]);function $r(e){let t=[],n=new Map;return{html:e.replace(/<h([23])([^>]*)>([\s\S]*?)<\/h\1>/gi,(e,r,i,a)=>{let o=a.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).trim(),s=o.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)||`section`,c=n.get(s)??0;return n.set(s,c+1),c>0&&(s=`${s}-${c+1}`),t.push({id:s,text:o,level:Number(r)}),`<h${r}${i.replace(/\s*id="[^"]*"/,``)} id="${s}">${a}</h${r}>`}),toc:t}}function ei(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}var ti=5;function ni(e){let t=Dt(),[n,r]=N(ti);if(e.history.length===0)return e.git?q(`div`,{className:`history`,children:[q(`div`,{className:`history__h`,children:q(`span`,{children:`History`})}),q(`p`,{className:`faint`,style:{fontSize:12,margin:`0 6px`},children:`Nothing committed yet for this file; commits that touch it will list here.`})]}):null;let i=e.history.slice(0,n);return q(`div`,{className:`history`,children:[q(`div`,{className:`history__h`,children:[q(`span`,{children:`History`}),q(`span`,{className:`faint`,children:[e.history.length,` commit`,e.history.length===1?``:`s`]})]}),i.map(n=>q(`div`,{className:`history__row`,title:n.subject,children:[q(`code`,{children:n.short}),q(`span`,{className:`history__who`,children:n.author}),q(`span`,{className:`faint`,children:ei(n.date)}),e.diffable===!0&&q(`button`,{className:`small quiet`,onClick:()=>void t(()=>lt(`/api/blueprints/${st(e.path)}/diff`,{sha:n.sha}),`Diff viewer opened`),"data-tip":`Open the diff viewer set under Preferences`,"data-tip-pos":`left`,children:`Diff`})]},n.sha)),e.history.length>n&&q(`button`,{className:`small quiet`,onClick:()=>r(e=>e+ti),children:[`Show `,Math.min(ti,e.history.length-n),` more`]})]})}function ri(e){return q(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`View`,children:[q(`button`,{className:e.source?``:`on`,role:`radio`,"aria-checked":!e.source,onClick:()=>e.onChange(!1),"data-tip":`The rendered page`,"data-tip-pos":`bottom`,children:`Reading`}),q(`button`,{className:e.source?`on`:``,role:`radio`,"aria-checked":e.source,onClick:()=>e.onChange(!0),"data-tip":`The file as text`,"data-tip-pos":`bottom`,children:`Source`})]})}function ii(e){let{detail:t,error:n,reload:r}=Zr(e.path,e.tick),[i,a]=N(!1),{settings:o,save:s}=zr(),c=o?.local.source_mode??!1,l=e=>void s({local:{source_mode:e}}),[u,d]=N([]),[f,p]=N(``),[m,h]=N(``),[g,_]=N(``),[v,y]=N(``),[ee,b]=N(!1),[x,te]=N([]),[C,w]=N(!1),T=F(null),ne=Dt(),E=kt();P(()=>{let t=!0;return ct(`/api/blueprints/${st(e.path)}/history`).then(e=>t&&(w(e.git),te(e.git?e.history:[]))).catch(()=>t&&(w(!1),te([]))),()=>{t=!1}},[e.path,e.tick]);let D=je(()=>t?$r(t.html):{html:``,toc:[]},[t]),re=()=>{t&&(d(Vr(t.properties).filter(e=>!Qr.has(e.key))),p(t.title),h(t.summary??``),_(t.body.replace(/^\n/,``)),y(t.raw),a(!0))},ie=()=>a(!1),O=I((e,n,r)=>{if(!t)return e;let i=Object.keys(t.properties),a=[],o=[...e],s=new Set;for(let e of i){if(e===`title`)a.push({key:e,value:n.trim()});else if(e===`summary`)a.push({key:e,value:r.trim()});else{let t=o.find(t=>t.key===e);t&&a.push(t)}s.add(e)}s.has(`title`)||a.splice(i.indexOf(`id`)+1,0,{key:`title`,value:n.trim()}),s.has(`summary`)||a.splice(a.findIndex(e=>e.key===`title`)+1,0,{key:`summary`,value:r.trim()});for(let e of o)a.some(t=>t.key===e.key)||a.push(e);return a},[t]),k=I(async()=>{if(!t)return;b(!0);let n=c?{text:v}:{properties:O(u,f,m).map(e=>[e.key,e.value]),body:`
|
|
3
|
+
`+g},i=await ne(()=>ut(`/api/blueprints/${st(t.path)}`,n));b(!1),i&&(a(!1),r(),e.onSaved?.())},[t,c,v,u,f,m,g,O,ne,r,e]),A=I(async n=>{if(!t)return;let i={properties:O(n,t.title,t.summary??``).map(e=>[e.key,e.value]),body:t.body.startsWith(`
|
|
4
|
+
`)?t.body:`
|
|
5
|
+
`+t.body};await ne(()=>ut(`/api/blueprints/${st(t.path)}`,i),`Saved`)&&(r(),e.onSaved?.())},[t,O,ne,r,e]);P(()=>{let e=e=>{Mt(e)&&e.key===`s`&&i&&(e.preventDefault(),k())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,k]),Lt(`Blueprint`,[{keys:`⌘S`,what:`Save what is being edited`},{keys:`Esc`,what:e.layout===`modal`?`Back to the table`:`Leave a field`}]);let ae=async()=>{t&&await E.confirm({title:`Delete ${t.title}?`,body:`${t.path} is removed from disk. Nothing else changes.`,confirm:`Delete blueprint`,danger:!0})&&await ne(()=>dt(`/api/blueprints/${st(t.path)}`),`Deleted`)&&(e.onSaved?.(),ht(vt(t.collection)))},oe=e=>{(T.current?.querySelector(`#${CSS.escape(e)}`))?.scrollIntoView({behavior:`smooth`,block:`start`})},se=t?q(S,{children:[i?q(S,{children:[q(`button`,{className:`small primary`,onClick:()=>void k(),disabled:ee,children:ee?`Saving…`:`Save`}),q(`button`,{className:`small quiet`,onClick:ie,children:`Cancel`})]}):q(S,{children:[q(ri,{source:c,onChange:l}),q(`button`,{className:`small`,onClick:re,"data-tip":c?`Edit the file as text`:`Edit the properties and the body`,"data-tip-pos":`bottom`,children:`Edit`}),q(`button`,{className:`small quiet`,onClick:()=>void ne(()=>lt(`/api/open`,{path:t.path}),`Opened in your editor`),"data-tip":`Open the file in the external editor set under Preferences`,"data-tip-pos":`bottom`,children:`Editor ↗`}),q(`button`,{className:`small quiet danger`,onClick:()=>void ae(),"data-tip":`Remove the file from disk`,"data-tip-pos":`bottom`,children:`Delete`})]}),e.layout===`modal`&&q(`button`,{className:`small quiet`,onClick:()=>ht(yt(t.path)),"data-tip":`Open as its own page`,"data-tip-pos":`bottom`,children:`Expand`})]}):null,ce=D.toc.length>0?q(`nav`,{className:`toc`,children:[q(`div`,{className:`history__h`,children:q(`span`,{children:`Contents`})}),D.toc.map(e=>q(`a`,{href:`#${e.id}`,className:`toc__${e.level}`,onClick:t=>(t.preventDefault(),t.stopPropagation(),oe(e.id)),children:e.text},e.id))]}):null,le=n?q(`div`,{className:`empty`,children:n}):t?c?q(`div`,{style:{padding:18},children:[q(`p`,{className:`faint mono`,style:{margin:`0 0 8px`},children:t.path}),i?q(`textarea`,{className:`editor`,value:v,onChange:e=>y(e.target.value),spellCheck:!1}):q(`pre`,{className:`source`,children:t.raw})]}):q(`div`,{className:`reader${e.layout===`page`?` reader--stack`:``}`,children:[q(`aside`,{className:`reader__props`,children:[q(`div`,{className:`reader__meta`,children:[q(`span`,{className:`badge`,children:t.collection}),t.group&&q(`span`,{className:`badge`,children:t.group}),t.variant&&q(`span`,{className:`badge accent`,children:t.variant}),t.findings.length>0&&q(`span`,{className:`badge ${t.findings.some(e=>e.level===`error`)?`error`:`warn`}`,children:[t.findings.length,` finding`,t.findings.length>1?`s`:``]})]}),q(`p`,{className:`mono faint`,style:{margin:`0 0 12px`,wordBreak:`break-all`},children:t.path}),t.frontmatter_error&&q(`p`,{className:`prop__hint`,children:[`Frontmatter read leniently: `,t.frontmatter_error]}),q(Yr,{entries:i?u:Vr(t.properties).filter(e=>!Qr.has(e.key)),schema:t.schema,known:t.known_values,base:t.path,editable:i,onChange:d,onCommit:i?void 0:e=>void A(e),onOpen:e.onOpenLink}),!i&&q(`div`,{style:{marginTop:18},children:[q(Xr,{findings:t.findings}),e.layout===`modal`&&ce,q(ni,{path:t.path,history:x,git:C,diffable:!!o?.local.diff_viewer})]})]}),q(`div`,{className:`reader__content`,ref:T,children:i?q(S,{children:[q(`div`,{className:`reader__fields`,children:[q(`label`,{children:[q(`span`,{children:`Title`}),q(`input`,{value:f,onChange:e=>p(e.target.value)})]}),q(`label`,{children:[q(`span`,{children:`Summary`}),q(`textarea`,{rows:2,value:m,placeholder:`one plain line: what this blueprint is, the source for the collection index`,onChange:e=>h(e.target.value)})]})]}),q(`textarea`,{className:`editor`,value:g,onChange:e=>_(e.target.value),spellCheck:!1})]}):q(S,{children:[t.summary&&e.layout===`modal`&&q(`p`,{className:`reader__summary`,children:t.summary}),q(At,{html:D.html,base:t.path,onOpen:e.onOpenLink})]})})]}):q(hn,{});return e.layout===`modal`?q(wt,{title:t?.title??`…`,head:se,size:`lg`,onClose:e.onClose??(()=>void 0),children:le}):q(`div`,{className:`page`,children:[q(`div`,{className:`page__head`,children:[q(`div`,{className:`grow`,children:[t&&q(`a`,{className:`page__back`,href:vt(t.collection,t.path),children:[`← `,t.collection]}),q(`h1`,{children:t?.title??`…`}),t?.summary&&q(`p`,{children:t.summary})]}),q(`div`,{className:`toolbar`,children:se})]}),q(`div`,{className:`doc${ce&&!i?` doc--rail`:``}`,children:[q(`div`,{className:`doc__body table-wrap`,style:{overflow:`visible`},children:le}),ce&&!i&&q(`aside`,{className:`doc__rail`,children:ce})]})]})}var ai=[{tool:`select`,label:`Select`,key:`V`,hint:`Click to select, drag on empty space for a marquee, ⇧ or ⌘ click to add`},{tool:`hand`,label:`Hand`,key:`H`,hint:`Drag to pan. The right mouse button and Space pan in every tool`},{tool:`sketch`,label:`Sketch`,key:`R`,hint:`Click to place a sketch, a node that is not a blueprint yet`},{tool:`sticky`,label:`Sticky`,key:`S`,hint:`Click to place a sticky note`},{tool:`text`,label:`Text`,key:`T`,hint:`Click to place free text: a heading over a region, a note in the margin`},{tool:`annotation`,label:`Annotation`,key:`A`,hint:`Click to place a note, then click what it points at; it lives only while it points at something`},{tool:`blueprint`,label:`Blueprint`,key:`B`,hint:`Click where it goes, then pick the blueprint`},{tool:`frame`,label:`Frame`,key:`F`,hint:`Drag to draw a frame around a region; with a selection, F wraps it`},{tool:`connect`,label:`Connect`,key:`X`,hint:`Click a node, then the node it flows to`},{tool:`comment`,label:`Comment`,key:`C`,hint:`Click anywhere, or on an object, to start a thread`}];function oi(e){let t={viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,width:18,height:18};switch(e.tool){case`select`:return q(`svg`,{...t,children:q(`path`,{d:`M5 3l11 7-5 1.5L8.5 17z`})});case`hand`:return q(`svg`,{...t,children:q(`path`,{d:`M7 10V4.5a1.5 1.5 0 013 0V9M10 9V3.5a1.5 1.5 0 013 0V9M13 9V5.5a1.5 1.5 0 013 0V12a5 5 0 01-5 5h-1.5a5 5 0 01-4-2l-2.3-3a1.4 1.4 0 012.1-1.8L7 12v-2`})});case`sketch`:return q(`svg`,{...t,children:[q(`rect`,{x:`3`,y:`5`,width:`14`,height:`10`,rx:`2`}),q(`path`,{d:`M6 9h8M6 12h5`})]});case`sticky`:return q(`svg`,{...t,children:[q(`path`,{d:`M4 4h12v8l-4 4H4z`}),q(`path`,{d:`M12 16v-4h4`})]});case`annotation`:return q(`svg`,{...t,children:[q(`rect`,{x:`3`,y:`3`,width:`10`,height:`7`,rx:`2`}),q(`path`,{d:`M8 10v3l3-3M11 13l6 4`}),q(`circle`,{cx:`17`,cy:`17`,r:`1.2`})]});case`text`:return q(`svg`,{...t,children:q(`path`,{d:`M4 5h12M10 5v11M7 16h6`})});case`blueprint`:return q(`svg`,{...t,children:[q(`path`,{d:`M5 3h7l4 4v10H5z`}),q(`path`,{d:`M12 3v4h4M8 11h5M8 14h5`})]});case`frame`:return q(`svg`,{...t,children:q(`path`,{d:`M6 2v16M14 2v16M2 6h16M2 14h16`})});case`connect`:return q(`svg`,{...t,children:[q(`circle`,{cx:`4.5`,cy:`5`,r:`2`}),q(`circle`,{cx:`15.5`,cy:`15`,r:`2`}),q(`path`,{d:`M6.5 5H11v10h2.5`})]});case`comment`:return q(`svg`,{...t,children:q(`path`,{d:`M3 5a2 2 0 012-2h10a2 2 0 012 2v7a2 2 0 01-2 2H9l-4 3v-3H5a2 2 0 01-2-2z`})});case`undo`:return q(`svg`,{...t,children:[q(`path`,{d:`M7 7L3 10l4 3`}),q(`path`,{d:`M3 10h8a4 4 0 010 8h-3`})]});case`redo`:return q(`svg`,{...t,children:[q(`path`,{d:`M13 7l4 3-4 3`}),q(`path`,{d:`M17 10H9a4 4 0 000 8h3`})]});case`export`:return q(`svg`,{...t,children:q(`path`,{d:`M10 3v10M6 9l4 4 4-4M4 16h12`})});case`image`:return q(`svg`,{...t,children:[q(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`2`}),q(`circle`,{cx:`7.5`,cy:`8.5`,r:`1.5`}),q(`path`,{d:`M3 14l4-4 3 3 3-3 4 4`})]})}}function si(e){return q(`div`,{className:`cv__toolbar`,role:`toolbar`,children:ai.map((t,n)=>q(`span`,{style:{display:`contents`},children:[(n===2||n===8)&&q(`i`,{className:`cv__toolbar-sep`}),q(`button`,{className:`${e.tool===t.tool?`on`:e.temporary===t.tool?`temp`:``}${e.locked===t.tool?` locked`:``}`,onClick:()=>e.onTool(t.tool),onDoubleClick:()=>e.onLock(t.tool),"data-tip":`${t.label} ${t.key}\n${t.hint}${t.tool===`select`||t.tool===`hand`?``:`
|
|
6
|
+
Double-click to keep the tool`}`,"aria-label":t.label,children:[q(oi,{tool:t.tool}),q(`kbd`,{children:t.key})]})]},t.tool))})}function ci(e){let[t,n]=N(!0),[r,i]=N(null),[a,o]=N(null),s=F(null),c=(e,t)=>{if(a?.id===e){o(null);return}let n=t.getBoundingClientRect();o({id:e,x:n.left,y:n.bottom+4})},l=a?{position:`fixed`,left:a.x,top:a.y}:void 0;P(()=>{if(!a)return;let e=e=>{s.current?.contains(e.target)||o(null)};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},[a]);let u=()=>{if(!r)return;let t=r.value.trim();if(i(null),t!==``){if(r.id===`canvas`)t!==e.canvasTitle&&e.onRenameCanvas(t);else{let n=e.pages.find(e=>e.id===r.id);n&&t!==n.title&&e.onRenamePage(r.id,t)}}},d=(e,t,n)=>r?.id===e?q(`input`,{ref:gn,className:`${n} editing`,value:r.value,onChange:t=>i({id:e,value:t.target.value}),onBlur:u,onKeyDown:e=>{e.key===`Enter`?u():e.key===`Escape`&&i(null)},onFocus:e=>e.target.select()}):q(`span`,{className:n,onDoubleClick:()=>i({id:e,value:t}),title:`Double-click to rename`,children:t});return q(`div`,{ref:s,className:`cv__pages`,onPointerDown:e=>e.stopPropagation(),children:[q(`div`,{className:`cv__pages-head`,children:[q(`button`,{className:`quiet icon`,onClick:()=>n(e=>!e),"data-tip":t?`Collapse pages`:`Pages`,"data-tip-pos":`right`,"aria-label":`Pages`,children:q(pn,{open:t})}),d(`canvas`,e.canvasTitle,`cv__pages-title`),q(`button`,{className:`quiet icon`,onClick:e=>c(`canvas`,e.currentTarget),"data-tip":`Canvas menu`,"data-tip-pos":`bottom`,"aria-label":`Canvas menu`,children:`⋯`}),a?.id===`canvas`&&q(`div`,{className:`cv__menu`,style:l,children:[q(`button`,{onClick:()=>(o(null),i({id:`canvas`,value:e.canvasTitle})),children:q(`span`,{children:`Rename canvas`})}),q(`i`,{}),q(`button`,{className:`danger`,onClick:()=>(o(null),e.onDeleteCanvas()),children:q(`span`,{children:`Delete canvas…`})})]})]}),t&&q(`div`,{className:`cv__pages-list`,children:[q(`div`,{className:`cv__pages-label`,children:[q(`span`,{children:`Pages`}),q(`button`,{className:`quiet icon`,onClick:e.onAddPage,title:`Add a page`,"aria-label":`Add a page`,children:q(cn,{})})]}),e.pages.map(t=>q(`div`,{className:`cv__page${t.id===e.current?` on`:``}`,onClick:()=>t.id!==e.current&&e.onPage(t.id),children:[d(t.id,t.title,`cv__page-title`),q(`button`,{className:`quiet icon cv__page-more`,onClick:e=>{e.stopPropagation(),c(t.id,e.currentTarget)},"aria-label":`Page menu`,children:`⋯`}),a?.id===t.id&&q(`div`,{className:`cv__menu`,style:l,onClick:e=>e.stopPropagation(),children:[q(`button`,{onClick:()=>(o(null),i({id:t.id,value:t.title})),children:q(`span`,{children:`Rename`})}),q(`i`,{}),q(`button`,{className:`danger`,disabled:e.pages.length<2,onClick:()=>(o(null),e.onDeletePage(t.id)),children:[q(`span`,{children:`Delete page…`}),q(Zt,{})]})]})]},t.id))]})]})}function li(e){return q(`div`,{className:`cv__top cv__top--right`,children:[q(`div`,{className:`group`,children:[q(`button`,{onClick:e.onUndo,disabled:!e.canUndo,"data-tip":`Undo ⌘Z`,"data-tip-pos":`bottom`,"aria-label":`Undo`,children:q(oi,{tool:`undo`})}),q(`button`,{onClick:e.onRedo,disabled:!e.canRedo,"data-tip":`Redo ⇧⌘Z`,"data-tip-pos":`bottom`,"aria-label":`Redo`,children:q(oi,{tool:`redo`})})]}),q(`div`,{className:`group`,children:[q(`button`,{className:e.showComments?`on`:``,onClick:e.onToggleComments,"data-tip":e.pinsHidden?`Comments ⇧C (pins hidden)`:`Comments ⇧C`,"data-tip-pos":`bottom`,children:[q(oi,{tool:`comment`}),e.commentsOpen>0&&q(`span`,{className:`count`,children:e.commentsOpen})]}),e.children]})]})}function ui(e){return q(`div`,{className:`cv__zoom`,children:[q(`button`,{onClick:()=>e.onZoom(1/1.2),"data-tip":`Zoom out −`,"aria-label":`Zoom out`,children:`−`}),q(`button`,{onClick:e.onFit,"data-tip":`Fit ⇧1
|
|
7
|
+
Double-click for 100% ⇧0`,onDoubleClick:e.onReset,children:[Math.round(e.scale*100),`%`]}),q(`button`,{onClick:()=>e.onZoom(1.2),"data-tip":`Zoom in +`,"aria-label":`Zoom in`,children:`+`})]})}function di(e){return q(`div`,{className:`cv__menu`,style:e.anchor===`right`?{right:e.at.x,top:e.at.y}:{left:e.at.x,top:e.at.y},onPointerDown:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:e.items.map((t,n)=>t.separator?q(`i`,{},n):q(`button`,{className:t.danger?`danger`:``,disabled:t.disabled,onClick:()=>{e.onClose(),t.onSelect?.()},children:[q(`span`,{children:t.label}),t.hint&&q(X,{combo:t.hint}),t.icon]},n))})}var fi=`https://eidosmd.com/docs/cli/canvas`,pi=[{keys:`Space drag · right drag`,what:`Pan; ⌘ scroll or pinch zooms`},{keys:`⇧1 · ⇧2 · ⇧0`,what:`Fit the page · zoom to the selection · 100%`},{keys:`⌥ click`,what:`Place with a tool and keep it; double-click a tool, or tap its key twice, to lock it`},{keys:`⌘A · ⌘D · ⌫`,what:`Select all · duplicate · delete`},{keys:`⌘C · ⌘V`,what:`Copy · paste under the pointer`},{keys:`⌥⌘C · ⌥⌘V`,what:`Copy a style · paste it onto the selection`},{keys:`⌘Z · ⇧⌘Z`,what:`Undo · redo`},{keys:`⏎ · ⇧⏎`,what:`Details of the selection · its style`},{keys:`Arrows · ⇧ arrows · ⌥ arrows`,what:`Move to the next thing that way · along a connector · nudge`},{keys:`L · ⇧C · Esc`,what:`Lock · the comments sidebar · back to Select`}];function mi(e){return q(`div`,{className:`backdrop center`,onMouseDown:t=>t.target===t.currentTarget&&e.onClose(),children:q(`div`,{className:`modal`,style:{maxWidth:720},children:[q(`div`,{className:`modal__head`,children:[q(`h2`,{children:`Working the canvas`}),q(`a`,{className:`btn`,href:fi,target:`_blank`,rel:`noreferrer`,children:`Navigating the canvas ↗`}),q(`button`,{className:`quiet`,onClick:e.onClose,children:`Close`})]}),q(`div`,{className:`modal__body`,style:{padding:`6px 18px 16px`},children:[q(`h3`,{className:`cv__sheet-h`,children:`Tools`}),q(`table`,{className:`mini`,children:q(`tbody`,{children:e.tools.map(e=>q(`tr`,{children:[q(`td`,{style:{whiteSpace:`nowrap`,width:120},children:q(`span`,{style:{display:`inline-flex`,gap:8,alignItems:`center`},children:[q(oi,{tool:e.tool}),` `,q(`b`,{children:e.label})]})}),q(`td`,{style:{width:40},children:q(X,{combo:e.key})}),q(`td`,{className:`muted`,children:e.hint})]},e.tool))})}),q(`h3`,{className:`cv__sheet-h`,children:`Essentials`}),q(`table`,{className:`mini`,children:q(`tbody`,{children:pi.map(e=>q(`tr`,{children:[q(`td`,{style:{whiteSpace:`nowrap`},children:q(X,{combo:e.keys})}),q(`td`,{className:`muted`,children:e.what})]},e.keys))})}),q(`p`,{className:`faint`,style:{fontSize:12,margin:`12px 0 0`},children:[`Everything else, with pictures: `,q(`a`,{href:fi,target:`_blank`,rel:`noreferrer`,children:`eidosmd.com/docs/cli/canvas`}),`.`]})]})]})})}function hi(e){return q(`button`,{className:`cv__help`,onClick:e.onOpen,"data-tip":`Tools and shortcuts ?`,"data-tip-pos":`right`,"aria-label":`Help`,children:q(an,{})})}function gi(e){let t=(t,n,r)=>q(`label`,{className:`cv__pref`,children:[q(`input`,{type:`checkbox`,checked:e.prefs[t],onChange:n=>e.onChange({...e.prefs,[t]:n.target.checked})}),q(`span`,{children:[q(`b`,{children:n}),q(`small`,{children:r})]})]});return q(`div`,{className:`cv__prefs`,onPointerDown:e=>e.stopPropagation(),children:[q(`div`,{className:`cv__prefs-head`,children:[q(`strong`,{children:`Canvas preferences`}),q(`button`,{className:`quiet small`,onClick:e.onClose,children:`Close`})]}),t(`wheelZoom`,`Scroll wheel zooms`,`On: the wheel zooms, ⇧ wheel pans sideways, a trackpad still pans. Off: the wheel pans, ⌘ wheel zooms.`),t(`rightDragPan`,`Right-drag pans`,`On: hold the right button to pan; a plain right click still opens the menu. Off: the right button only opens the menu.`),t(`ctrlClickMenu`,`Ctrl-click opens the menu`,`On: Ctrl + click opens the context menu, as in Figma. Off: Ctrl + click adds to the selection.`),t(`enterCommits`,`Enter finishes an edit`,`On: Enter finishes typing in a sticky, text, or description, ⇧ Enter breaks a line. Off: Enter breaks a line, ⌘ Enter finishes.`),t(`contextMenu`,`Right-click opens the menu`,`On: a right click opens the context menu. Off: a right click on an object opens its details instead; everything the menu offers has a shortcut.`),t(`resizeAll`,`Resize all objects`,`On: every node shows corner grips and takes an exact box. Off: only text elements resize; frames always do.`),q(`div`,{className:`cv__prefs-foot`,children:q(`a`,{href:`/settings/properties`,onClick:t=>(t.preventDefault(),e.onClose(),ht(`/settings/properties`)),children:`Configure default styles →`})})]})}function _i(e){return q(`div`,{className:`cv__legend-wrap`,onPointerDown:e=>e.stopPropagation(),children:[e.open&&q(`div`,{className:`cv__legend`,children:e.entries.map(([e,t])=>q(`span`,{children:[q(`i`,{className:`swatch`,style:{background:t}}),e]},e))}),q(`button`,{className:`cv__help${e.open?` on`:``}`,onClick:e.onToggle,"data-tip":e.open?`Hide the legend`:`Legend`,"data-tip-pos":`right`,"aria-label":`Legend`,style:{width:`auto`,padding:`0 10px`,gap:6},children:[q(`i`,{className:`swatch`,style:{background:e.entries[0]?.[1]??`var(--text-faint)`,margin:0}}),`Legend`]})]})}var vi=`frame:`,yi=e=>e.startsWith(vi),bi=e=>e.slice(6),xi={w:200,h:72},Si=[{name:`Terracotta`,hex:`#e08a63`},{name:`Ochre`,hex:`#d3a53c`},{name:`Olive`,hex:`#7fae6c`},{name:`Teal`,hex:`#4aa39f`},{name:`Slate`,hex:`#5f80cf`},{name:`Plum`,hex:`#9a74bd`},{name:`Rose`,hex:`#cf7b8f`},{name:`Stone`,hex:`#8b9099`}],Ci={small:{w:180,h:84},medium:{w:220,h:112},large:{w:280,h:148}},wi={small:128,medium:176,large:240},Ti=.15,Ei=[`yellow`,`pink`,`blue`,`green`,`purple`,`orange`],Di=[`none`,`sand`,`sky`,`mint`,`rose`,`lilac`],Q=e=>Math.round(e/8)*8;function Oi(e,t={}){if(t[e.id]&&(e.box||e.kind===`text`||e.kind===`annotation`))return t[e.id];if(e.box)return{...e.box};if(e.kind===`sticky`){let t=wi[e.style.size];return{w:t,h:t}}return e.kind===`text`?t[e.id]??{w:160,h:32}:e.kind===`annotation`?t[e.id]??{...xi}:{...Ci[e.style.size]}}function ki(e,t,n={}){return{...t[e.id]??e.position,...Oi(e,n)}}function Ai(e,t,n,r){if(r)return r;if(e.x!==void 0&&e.y!==void 0&&e.w!==void 0&&e.h!==void 0)return{x:e.x,y:e.y,w:e.w,h:e.h};let i=t.filter(t=>t.frame===e.id).map(n);if(i.length===0)return null;let a=Math.min(...i.map(e=>e.x))-24,o=Math.min(...i.map(e=>e.y))-34,s=Math.max(...i.map(e=>e.x+e.w))+24,c=Math.max(...i.map(e=>e.y+e.h))+24;return{x:a,y:o,w:s-a,h:c-o}}var ji=(e,t)=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y,Mi=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.w<=e.x+e.w&&t.y+t.h<=e.y+e.h,Ni=(e,t)=>t.x>=e.x&&t.x<=e.x+e.w&&t.y>=e.y&&t.y<=e.y+e.h,Pi=e=>({x:e.x+e.w/2,y:e.y+e.h/2}),Fi=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}),Ii=e=>{if(e.length===0)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,w:Math.max(...e.map(e=>e.x+e.w))-t,h:Math.max(...e.map(e=>e.y+e.h))-n}},Li=[`top-left`,`top`,`top-right`,`right`,`bottom-right`,`bottom`,`bottom-left`,`left`],Ri=[`top`,`right`,`bottom`,`left`];function zi(e,t){return{x:t.endsWith(`left`)?e.x:t.endsWith(`right`)?e.x+e.w:e.x+e.w/2,y:t.startsWith(`top`)?e.y:t.startsWith(`bottom`)?e.y+e.h:e.y+e.h/2}}function Bi(e,t,n=Li){let r=n[0]??`right`,i=1/0;for(let a of n){let n=zi(e,a),o=Math.hypot(n.x-t.x,n.y-t.y);o<i&&(i=o,r=a)}return r}function Vi(e,t,n){return e===`top`?`up`:e===`bottom`?`down`:e===`left`?`left`:e===`right`?`right`:Math.abs(n.x-t.x)>=Math.abs(n.y-t.y)?e.endsWith(`left`)?`left`:`right`:e.startsWith(`top`)?`up`:`down`}var Hi=(e,t,n)=>({x:e.x+(t===`right`?n:t===`left`?-n:0),y:e.y+(t===`down`?n:t===`up`?-n:0)}),Ui=e=>e===`left`||e===`right`;function Wi(e,t,n,r){return n&&r?{from:n,to:r}:n?{from:n,to:Bi(t,zi(e,n),Ri)}:r?{from:Bi(e,zi(t,r),Ri),to:r}:t.x>=e.x+e.w+Gi?{from:`right`,to:`left`}:e.x>=t.x+t.w+Gi?{from:`left`,to:`right`}:Pi(t).y>=Pi(e).y?{from:`bottom`,to:`top`}:{from:`top`,to:`bottom`}}var Gi=24,Ki=4;function qi(e,t){if(e.length<2)return``;let n=`M${e[0]?.x},${e[0]?.y}`;for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r],o=e[r+1],s=Math.hypot(a.x-i.x,a.y-i.y),c=Math.hypot(o.x-a.x,o.y-a.y),l=Math.min(t,s/2,c/2);if(l<1){n+=` L${a.x},${a.y}`;continue}let u=a.x-(a.x-i.x)/s*l,d=a.y-(a.y-i.y)/s*l,f=a.x+(o.x-a.x)/c*l,p=a.y+(o.y-a.y)/c*l;n+=` L${u},${d} Q${a.x},${a.y} ${f},${p}`}let r=e[e.length-1];return`${n} L${r.x},${r.y}`}function Ji(e,t,n={}){let r=Wi(e,t,n.from,n.to),i=zi(e,r.from),a=zi(t,r.to),o=Vi(r.from,i,a),s=Vi(r.to,a,i),c=Hi(i,o,Ki),l=Hi(a,s,Ki),u=Hi(c,o,Gi),d=Hi(l,s,Gi),f,p=null,m=null;Ui(o)&&Ui(s)?(m=n.bend??Math.round((u.x+d.x)/2),f=[c,u,{x:m,y:u.y},{x:m,y:d.y},d,l],p=`x`):!Ui(o)&&!Ui(s)?(m=n.bend??Math.round((u.y+d.y)/2),f=[c,u,{x:u.x,y:m},{x:d.x,y:m},d,l],p=`y`):f=Ui(o)?[c,u,{x:d.x,y:u.y},d,l]:[c,u,{x:u.x,y:d.y},d,l];let h=f[2],g=f[3],_=p?{x:(h.x+g.x)/2,y:(h.y+g.y)/2}:null,v=_??h;return{d:qi(f,10),points:f,start:c,end:l,handle:_,axis:p,label:{x:v.x,y:v.y-8},mid:m,from:r.from,to:r.to}}function Yi(e,t,n){let r=e.map(e=>({...e})),i=(e,t,n)=>{let r=Math.hypot(t.x-e.x,t.y-e.y);if(r===0||n<=0)return e;let i=Math.min(n,r-1)/r;return{x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}},a=r[0],o=r[1],s=r[r.length-1],c=r[r.length-2];return a&&o&&(r[0]=i(a,o,t)),s&&c&&(r[r.length-1]=i(s,c,n)),qi(r,10)}var Xi=e=>e.reduce((t,n,r)=>r===0?0:t+Math.hypot(n.x-e[r-1].x,n.y-e[r-1].y),0);function Zi(e,t){let n=Xi(e),r=Math.min(1,Math.max(0,t))*n;for(let t=1;t<e.length;t+=1){let n=e[t-1],i=e[t],a=Math.hypot(i.x-n.x,i.y-n.y);if(r<=a||t===e.length-1){let e=a===0?0:Math.min(1,r/a);return{x:n.x+(i.x-n.x)*e,y:n.y+(i.y-n.y)*e}}r-=a}return e[0]??{x:0,y:0}}function Qi(e,t){let n=Xi(e);if(n===0)return .5;let r={distance:1/0,t:.5},i=0;for(let a=1;a<e.length;a+=1){let o=e[a-1],s=e[a],c=s.x-o.x,l=s.y-o.y,u=Math.hypot(c,l),d=u===0?0:Math.min(1,Math.max(0,((t.x-o.x)*c+(t.y-o.y)*l)/(u*u))),f=Math.hypot(o.x+c*d-t.x,o.y+l*d-t.y);f<r.distance&&(r={distance:f,t:(i+u*d)/n}),i+=u}return Math.round(r.t*100)/100}var $i=[`none`,`arrow`,`triangle`,`triangle-open`,`circle`,`diamond`,`bar`],ea={none:`None`,arrow:`Arrow`,triangle:`Triangle`,"triangle-open":`Open triangle`,circle:`Circle`,diamond:`Diamond`,bar:`Bar`},ta=e=>e===`none`?0:e===`arrow`||e===`bar`?1:e===`circle`?9:e===`diamond`?16:10;function na(e,t,n){if(n===`none`)return null;let r={x:-t.x,y:-t.y},i={x:-t.y,y:t.x},a=(t,n)=>`${(e.x+r.x*t+i.x*n).toFixed(1)},${(e.y+r.y*t+i.y*n).toFixed(1)}`;switch(n){case`arrow`:return{d:`M${a(9,-5)} L${a(0,0)} L${a(9,5)}`,filled:!1};case`triangle`:return{d:`M${a(0,0)} L${a(11,-5.5)} L${a(11,5.5)} Z`,filled:!0};case`triangle-open`:return{d:`M${a(0,0)} L${a(11,-5.5)} L${a(11,5.5)} Z`,filled:!1};case`circle`:{let t={x:e.x+r.x*5,y:e.y+r.y*5};return{d:`M${(t.x-5).toFixed(1)},${t.y.toFixed(1)} a5,5 0 1,0 10,0 a5,5 0 1,0 -10,0`,filled:!1}}case`diamond`:return{d:`M${a(0,0)} L${a(8,-5)} L${a(16,0)} L${a(8,5)} Z`,filled:!1};case`bar`:return{d:`M${a(0,-6)} L${a(0,6)}`,filled:!1}}}function ra(e,t){let[n,r]=t===`end`?[e[e.length-2],e[e.length-1]]:[e[1],e[0]];if(!n||!r)return{x:1,y:0};let i=Math.hypot(r.x-n.x,r.y-n.y)||1;return{x:(r.x-n.x)/i,y:(r.y-n.y)/i}}var $=e=>`n:${e}`,ia=e=>`f:${e}`,aa=e=>`e:${e.from}|${e.to}`,oa=e=>e.startsWith(`n:`),sa=e=>e.startsWith(`f:`),ca=e=>e.startsWith(`e:`),la=e=>e.slice(2),ua=e=>{let[t=``,n=``]=e.slice(2).split(`|`);return{from:t,to:n}},da=e=>JSON.parse(JSON.stringify(e));function fa(e=60){let t=F([]),n=F([]),[,r]=N(0),i=()=>r(e=>e+1),a=I(r=>{t.current.push(da(r)),t.current.length>e&&t.current.shift(),n.current=[],i()},[e]),o=I(e=>{let r=t.current.pop();return r?(n.current.push(da(e)),i(),r):null},[]),s=I(e=>{let r=n.current.pop();return r?(t.current.push(da(e)),i(),r):null},[]),c=I(()=>{t.current=[],n.current=[],i()},[]);return{push:a,undo:o,redo:s,canUndo:t.current.length>0,canRedo:n.current.length>0,reset:c}}var pa=da,ma=[`box`,`pill`,`parallelogram`],ha=[`small`,`medium`,`large`];function ga(e,t,n=[],r){let[i,a]=N({x:0,y:0});return Ae(()=>{let e=t.current,n=e?r?e.closest(r):e.offsetParent:null;if(!e||!n)return;let o=n.getBoundingClientRect(),s=e.getBoundingClientRect(),c=s.left-i.x,l=s.top-i.y,u=0,d=0;c+s.width>o.right-8&&(u=o.right-8-(c+s.width)),c+u<o.left+8&&(u=o.left+8-c),l+s.height>o.bottom-8&&(d=o.bottom-8-(l+s.height)),l+d<o.top+8&&(d=o.top+8-l),(Math.round(u)!==i.x||Math.round(d)!==i.y)&&a({x:Math.round(u),y:Math.round(d)})},[e.x,e.y,...n]),{x:e.x+i.x,y:e.y+i.y}}function _a(e){if(e.key!==`Tab`)return;let t=[...e.currentTarget.querySelectorAll(`input, select, textarea, button, a[href], [tabindex]:not([tabindex="-1"])`)].filter(e=>!e.hasAttribute(`disabled`));if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||!e.currentTarget.contains(i))?(e.preventDefault(),r.focus()):!e.shiftKey&&(i===r||!e.currentTarget.contains(i))&&(e.preventDefault(),n.focus())}function va(e){let t=F(null),n=ga(e.at,t);return P(()=>{t.current?.querySelector(`input, select, textarea`)?.focus()},[]),q(`div`,{ref:t,className:`cv__pop${e.wide?` cv__pop--wide`:``}`,style:{left:n.x,top:n.y},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onKeyDown:_a,children:[q(`div`,{className:`cv__pop-head`,children:[q(`span`,{className:`badge`,children:e.kind}),q(`strong`,{children:e.title}),q(`button`,{className:`quiet small`,onClick:e.onClose,"data-tip":`Close Esc`,"data-tip-pos":`bottom`,children:`Close`})]}),q(`div`,{className:`cv__pop-body`,children:e.children})]})}function ya(e){return q(`div`,{className:`cv__pop-sec`,children:[q(`div`,{className:`cv__pop-sec-h`,children:[q(`span`,{children:e.title}),e.aside]}),e.children]})}function ba(e){let[t,n]=N(e.value);return P(()=>n(e.value),[e.value]),e.rows&&e.rows>1?q(`textarea`,{rows:e.rows,value:t,placeholder:e.placeholder,onChange:e=>n(e.target.value),onBlur:()=>{t!==e.value&&e.onCommit(t)},onKeyDown:t=>t.key===`Escape`&&n(e.value),ref:e.autoFocus?gn:void 0}):q(Wt,{value:t,options:e.list??[],placeholder:e.placeholder,autoFocus:e.autoFocus,onChange:n,onCommit:t=>{t!==e.value&&e.onCommit(t)},onCancel:()=>n(e.value)})}function xa(e){let{node:t,data:n}=e,r=n.page,i=t.link?.page?`page:${t.link.page}`:t.link?.canvas?`canvas:${t.link.canvas}`:``;return q(ya,{title:`Placement`,children:q(`div`,{className:`cv__pop-grid`,children:[q(`label`,{children:`Attached to frame`}),q(Z,{value:t.frame??``,onChange:t=>e.onUpdate({frame:t.target.value||null}),children:[q(`option`,{value:``,children:`none`}),r?.frames.map(e=>q(`option`,{value:e.id,children:e.title},e.id))]}),q(`label`,{children:`Opens`}),q(Z,{value:i,onChange:t=>{let n=t.target.value;e.onUpdate({link:n.startsWith(`page:`)?{page:n.slice(5)}:n.startsWith(`canvas:`)?{canvas:n.slice(7)}:null})},children:[q(`option`,{value:``,children:`nothing`}),n.canvas.pages.filter(e=>e.id!==r?.id).map(e=>q(`option`,{value:`page:${e.id}`,children:[`page: `,e.title]},e.id))]})]})})}function Sa(e){let t=kt();return async()=>{let n=e.override;return!n||!n.shape&&!n.color?{}:e.styled?await t.confirm({title:`Apply the default style?`,body:`This property gives the node a style of its own, and you styled this one by hand. Apply the default and drop yours?`,confirm:`Apply default`})?{style:{shape:null,color:null}}:{}:{style:{shape:null,color:null}}}}function Ca(e){let{node:t,data:n}=e,[r,i]=N(!1),a=Sa(t),o=n.sketch_properties.filter(e=>e.canvas?.show),s=async(t,n)=>{e.onUpdate({sketch:{properties:{[t]:n===``?null:n}},...await a()})},c=t.kind===`sticky`||t.kind===`text`?t.label.split(`
|
|
8
|
+
`)[0]||t.kind:t.label,l=q(`div`,{className:`cv__pop-foot`,children:[t.kind===`blueprint`&&t.path&&q(`a`,{className:`btn`,href:yt(t.path),title:`Open here; ⌘-click for its own page`,onClick:n=>{n.metaKey||n.ctrlKey||n.shiftKey||(n.preventDefault(),e.onOpen(t.path??``))},children:`Open blueprint`}),t.kind===`sketch`&&q(`button`,{onClick:()=>i(e=>!e),children:`Promote to blueprint…`}),q(`button`,{className:`quiet icon danger`,onClick:e.onRemove,style:{marginLeft:`auto`},"data-tip":t.kind===`blueprint`?`Remove from the canvas (the file stays)`:`Delete`,"data-tip-pos":`left`,"aria-label":`Delete`,children:q(Zt,{})})]});return q(va,{at:e.at,kind:t.kind,title:c,onClose:e.onClose,children:[t.kind===`sketch`&&q(S,{children:[q(ya,{title:`Text`,children:q(`div`,{className:`cv__pop-grid`,children:[q(`label`,{children:`Title`}),q(ba,{value:t.label,placeholder:`Title`,onCommit:t=>e.onUpdate({sketch:{label:t.trim()}})}),q(`label`,{children:`Description`}),q(ba,{value:t.summary??``,rows:3,placeholder:`Description`,onCommit:t=>e.onUpdate({sketch:{note:t.trim()||null}})})]})}),q(ya,{title:`Properties`,children:o.length===0?q(`p`,{className:`faint`,style:{fontSize:12,margin:0},children:`None flagged. Under Framework Settings → Schema, tick “Show on the canvas node” on a property that applies to all collections.`}):q(`div`,{className:`cv__pop-grid`,children:o.map(e=>q(wa,{property:e,value:t.values[e.name]??``,options:e.values,onCommit:t=>void s(e.name,t)},e.name))})}),q(xa,{node:t,data:n,onUpdate:e.onUpdate}),l,r&&q(Ta,{data:n,onPromote:e.onPromote})]}),t.kind===`blueprint`&&q(S,{children:[t.missing?q(`p`,{className:`findings`,children:q(`span`,{className:`error`,children:[`No blueprint with the id “`,t.blueprint,`”.`]})}):t.path&&q(Ea,{path:t.path,shown:n.palette.filter(e=>e.show).map(e=>e.property),restyle:a,onRestyle:e.onUpdate,onSaved:e.onBlueprintSaved}),q(xa,{node:t,data:n,onUpdate:e.onUpdate}),l]}),t.kind===`sticky`&&q(S,{children:[q(ya,{title:`Text`,children:q(ba,{value:t.label,rows:4,placeholder:`Write…`,onCommit:t=>e.onUpdate({sticky:{text:t}})})}),q(xa,{node:t,data:n,onUpdate:e.onUpdate}),l]}),t.kind===`annotation`&&q(S,{children:[q(ya,{title:`Annotation`,children:[q(ba,{value:t.label,rows:3,placeholder:`What to note about what it points at`,onCommit:t=>e.onUpdate({annotation:{text:t}})}),q(`p`,{className:`faint`,style:{fontSize:11,margin:`6px 0 0`},children:`Points at one thing or more; drag from its sides to point at another. It goes when nothing is left to point at.`})]}),q(xa,{node:t,data:n,onUpdate:e.onUpdate}),l]}),t.kind===`text`&&q(S,{children:[q(ya,{title:`Text`,children:q(ba,{value:t.label,rows:3,onCommit:t=>e.onUpdate({text:{text:t}})})}),q(xa,{node:t,data:n,onUpdate:e.onUpdate}),l]})]})}function wa(e){return q(S,{children:[q(`label`,{title:e.property.meaning,children:e.property.name}),e.property.type===`Checkbox`?q(`input`,{type:`checkbox`,checked:e.value===`true`,onChange:t=>e.onCommit(t.target.checked?`true`:``),style:{width:`auto`}}):e.property.type===`Date`?q(Yt,{value:e.value,onChange:t=>e.onCommit(t??``)}):q(ba,{value:e.value,list:e.options,placeholder:e.property.type===`List`?`comma-separated`:`—`,onCommit:e.onCommit})]})}function Ta(e){let{data:t}=e,[n,r]=N(t.collections.find(e=>e.groups.length>0)?.name??t.collections[0]?.name??``),[i,a]=N(``),[o,s]=N(``),c=t.collections.find(e=>e.name===n);return q(`div`,{className:`card`,style:{margin:`10px 0 0`},children:[q(`p`,{className:`muted`,style:{margin:`0 0 8px`,fontSize:12},children:[`Scaffolds a blueprint from this sketch (the same as `,q(`code`,{children:`eidos new`}),`), carries its properties over, and points the node at it.`]}),q(`div`,{className:`cv__pop-grid`,children:[q(`label`,{children:`Collection`}),q(Z,{value:n,onChange:e=>(r(e.target.value),a(``),s(``)),children:t.collections.map(e=>q(`option`,{value:e.name,children:e.name},e.name))}),c&&c.groups.length>0&&q(S,{children:[q(`label`,{children:`Group`}),q(Z,{value:i,onChange:e=>a(e.target.value),children:[q(`option`,{value:``,children:`—`}),c.groups.map(e=>q(`option`,{value:e,children:e},e))]})]}),q(`label`,{children:`Variant`}),q(Z,{value:o,onChange:e=>s(e.target.value),children:[q(`option`,{value:``,children:`default`}),c?.variants.map(e=>q(`option`,{value:e.name,children:e.name},e.name))]})]}),q(`div`,{className:`actions`,style:{marginTop:10},children:q(`button`,{className:`primary small`,onClick:()=>e.onPromote({collection:n,group:i||null,variant:o||null}),children:`Create blueprint`})})]})}function Ea(e){let[t,n]=N(null),r=Dt(),i=()=>{ct(`/api/blueprints/${st(e.path)}`).then(n).catch(()=>void 0)};P(i,[e.path]);let a=async(n,a)=>{if(!t)return;let o=Object.entries(t.properties).map(([e,t])=>[e,e in n?n[e]:t]);for(let[e,t]of Object.entries(n))o.some(([t])=>t===e)||o.push([e,t]);let s=a?await e.restyle():{};await r(()=>ut(`/api/blueprints/${st(e.path)}`,{properties:o,body:t.body}),`Saved to file`)&&(Object.keys(s).length>0&&e.onRestyle(s),i(),e.onSaved())},o=t?t.schema.filter(t=>e.shown.includes(t.name)&&t.owner===`custom`):[],s=e=>e==null?``:Array.isArray(e)?e.map(String).join(`, `):String(e),c=(e,t)=>t.trim()===``?null:e.type===`List`?t.split(`,`).map(e=>e.trim()).filter(e=>e!==``):e.type===`Number`?Number(t):e.type===`Checkbox`?t===`true`:t.trim();return q(S,{children:[q(ya,{title:`File`,aside:q(`code`,{className:`faint`,style:{fontSize:11},children:e.path}),children:q(`div`,{className:`cv__pop-grid`,children:[q(`label`,{children:`Title`}),q(ba,{value:t?.title??``,onCommit:e=>e.trim()!==``&&void a({title:e.trim()},!1)}),q(`label`,{children:`Summary`}),q(ba,{value:t?.summary??``,rows:3,placeholder:`one plain line: what this blueprint is`,onCommit:e=>void a({summary:e.trim()},!1)})]})}),t&&o.length>0&&q(ya,{title:`Properties`,children:q(`div`,{className:`cv__pop-grid`,children:o.map(e=>q(wa,{property:e,value:s(t.properties[e.name]),options:t.known_values[e.name]??[],onCommit:t=>void a({[e.name]:c(e,t)},!0)},e.name))})})]})}function Da(e){return q(va,{at:e.at,kind:`flow`,title:`${e.from} → ${e.to}`,onClose:e.onClose,children:[q(ya,{title:`Label`,children:q(ba,{value:e.edge.label??``,placeholder:`optional`,onCommit:t=>e.onUpdate({label:t.trim()===``?null:t.trim()}),autoFocus:!0})}),q(ya,{title:`Route`,aside:q(`span`,{className:`faint`,style:{fontSize:11},children:[e.edge.from_anchor??`auto`,` → `,e.edge.to_anchor??`auto`]}),children:[q(`p`,{className:`faint`,style:{fontSize:12,margin:0},children:`The line turns along the grid. Drag the dot on its middle segment to move the bend (double-click it to recentre); drag either end to another anchor, or another node.`}),q(`div`,{className:`cv__pop-foot`,children:[e.edge.bend!==void 0&&q(`button`,{className:`small`,onClick:()=>e.onUpdate({bend:null}),children:`Recentre bend`}),(e.edge.from_anchor||e.edge.to_anchor)&&q(`button`,{className:`small`,onClick:()=>e.onUpdate({from_anchor:null,to_anchor:null}),children:`Auto anchors`}),q(`button`,{className:`quiet icon danger`,onClick:e.onRemove,style:{marginLeft:`auto`},"data-tip":`Remove the flow`,"data-tip-pos":`left`,"aria-label":`Remove`,children:q(Zt,{})})]})]})]})}function Oa(e){return q(va,{at:e.at,kind:`frame`,title:e.frame.title,onClose:e.onClose,children:[q(ya,{title:`Frame`,children:q(`div`,{className:`cv__pop-grid`,children:[q(`label`,{children:`Title`}),q(ba,{value:e.frame.title,onCommit:t=>t.trim()!==``&&e.onUpdate({title:t.trim()})}),q(`label`,{children:`Color`}),q(`div`,{className:`swatches`,children:Di.map(t=>q(`button`,{className:`swatch-btn frame-${t}${(e.frame.color??`none`)===t?` on`:``}`,onClick:()=>e.onUpdate({color:t===`none`?null:t}),"data-tip":t},t))})]})}),q(ya,{title:`Attached`,aside:q(`span`,{className:`faint`,style:{fontSize:11},children:[e.members,` node`,e.members===1?``:`s`]}),children:[q(`div`,{className:`cv__pop-foot`,children:q(`button`,{className:`small`,onClick:e.onSelectMembers,disabled:e.members===0,children:`Select attached`})}),q(`div`,{className:`cv__pop-foot`,children:[q(`button`,{className:`quiet danger small`,onClick:()=>e.onRemove(!1),children:`Delete Frame Only`}),q(`button`,{className:`quiet danger small`,onClick:()=>e.onRemove(!0),disabled:e.members===0,children:`Delete Frame & Contents`})]})]})]})}function ka(e){let t=na({x:30,y:8},{x:1,y:0},e.cap);return q(`svg`,{viewBox:`0 0 34 16`,className:`cap-icon`,style:e.flip?{transform:`scaleX(-1)`}:void 0,"aria-hidden":`true`,children:[q(`path`,{d:`M3,8 L${30-ta(e.cap)},8`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`}),t&&q(`path`,{d:t.d,fill:t.filled?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinejoin:`round`})]})}function Aa(e){let[t,n]=N(!1);return q(`span`,{className:`cap-picker`,children:[q(`button`,{onClick:()=>n(e=>!e),"data-tip":`${e.label}: ${ea[e.value]}`,"data-tip-pos":`bottom`,"aria-label":e.label,children:[q(ka,{cap:e.value,flip:e.flip}),q(pn,{open:t})]}),t&&q(`span`,{className:`cap-menu`,onMouseLeave:()=>n(!1),children:$i.map(t=>q(`button`,{className:t===e.value?`on`:``,onClick:()=>(e.onChange(t),n(!1)),title:ea[t],children:q(ka,{cap:t,flip:e.flip})},t))})]})}function ja(e){let t=F(null),n=ga(e.at,t),r=e.count>1,i=e.nodes[0],a=e.edge?e.edge.color??`var(--text-faint)`:e.frame?`var(--frame-${e.frame.color??`none`}, transparent)`:i?.style.color??`transparent`;return q(`div`,{ref:t,className:`cv__selbar`,style:{left:n.x,top:n.y},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[q(`button`,{className:`quiet cv__selbar-style${e.styleOpen?` on`:``}`,onClick:e.onToggleStyle,"data-tip":`Style`,"data-tip-pos":`bottom`,children:[q(`i`,{className:`swatch`,style:{background:a}}),`Style`,q(`span`,{className:`cv__chev${e.styleOpen?` open`:``}`,children:q(pn,{open:e.styleOpen})})]}),e.children,q(`i`,{className:`cv__selbar-sep`}),r&&q(S,{children:[q(`button`,{className:`quiet small`,onClick:e.onWrap,children:`Wrap in frame`}),q(`button`,{className:`quiet small`,onClick:e.onDuplicate,"data-tip":`Duplicate ⌘D`,"data-tip-pos":`bottom`,children:`Duplicate`}),q(`i`,{className:`cv__selbar-sep`})]}),q(`button`,{className:`quiet icon${e.locked?` on`:``}`,onClick:()=>e.onLock(!e.locked),"data-tip":e.locked?`Unlock ⇧⌘L`:`Lock ⇧⌘L`,"data-tip-pos":`bottom`,"aria-label":`Lock`,children:q(fn,{})}),i&&!r&&q(`button`,{className:`quiet icon`,onClick:e.onComment,"data-tip":`Comment on this`,"data-tip-pos":`bottom`,"aria-label":`Comment`,children:q(oi,{tool:`comment`})}),e.onOpen&&q(`button`,{className:`quiet small`,onClick:e.onOpen,"data-tip":`Open the blueprint over the canvas`,"data-tip-pos":`bottom`,children:`Open`}),!r&&q(`button`,{className:`quiet icon`,onClick:e.onDetails,"data-tip":`Details ⏎`,"data-tip-pos":`bottom`,"aria-label":`Details`,children:q(rn,{})}),q(`button`,{className:`quiet icon danger`,onClick:e.onDelete,"data-tip":i?.kind===`blueprint`&&!r?`Remove from the canvas ⌫`:`Delete ⌫`,"data-tip-pos":`bottom`,"aria-label":`Delete`,children:q(Zt,{})})]})}function Ma(e){let t=F(null),n=ga(e.at,t,[],`.cv`),r=e.nodes.filter(e=>e.kind===`sketch`||e.kind===`blueprint`),i=e.nodes.filter(e=>e.kind===`text`),a=e.nodes.filter(e=>e.kind===`sticky`),o=e.nodes.filter(e=>e.kind===`annotation`),s=e=>e.length===0?null:e.every(t=>t===e[0])?e[0]:`mixed`,c=s(r.map(e=>ma.includes(e.override?.shape??``)?e.override?.shape:``)),l=s([...r,...i].map(e=>e.style.color??``)),u=s(r.map(e=>e.style.fill)),d=s(r.map(e=>e.style.fill_color??``)),f=s(e.nodes.map(e=>e.style.size)),p=s(i.map(e=>e.font??0)),m=s(e.nodes.map(e=>e.box?`${e.box.w}x${e.box.h}`:``))===`mixed`?`mixed`:e.nodes[0]?.box??null,h=e.nodes.some(e=>e.box),g=e=>e.box??Oi(e),_=e.nodes.some(e=>e.override),{edge:v}=e,y=e=>typeof e==`string`&&/^#[0-9a-f]{6}$/i.test(e)?e:`#888888`,ee=(e,t,n)=>q(`span`,{className:`colors`,children:[Si.map(n=>q(`button`,{className:`colors__swatch${typeof e==`string`&&e.toLowerCase()===n.hex?` on`:``}`,style:{background:n.hex},onClick:()=>t(n.hex),"data-tip":n.name,"data-tip-pos":`top`,"aria-label":n.name},n.hex)),q(`label`,{className:`colors__pick`,"data-tip":typeof e==`string`&&e!==``?e:`Any color`,"data-tip-pos":`top`,children:[q(`i`,{className:`swatch`,style:{background:y(e)}}),q(`input`,{type:`color`,value:y(e),onChange:e=>t(e.target.value)})]}),q(`button`,{className:`quiet small`,onClick:()=>t(null),"data-tip":n,"data-tip-pos":`top`,children:e===`mixed`?`mixed`:e?`auto`:`· auto`})]});return q(`div`,{ref:t,className:`cv__stylepop${e.anchored?` cv__stylepop--anchored`:``}`,style:{left:n.x,top:n.y},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[q(`div`,{className:`cv__pop-sec-h`,style:{marginBottom:8},children:[q(`span`,{children:[`Style`,e.nodes.length>1?` · ${e.nodes.length} selected`:``]}),q(`button`,{className:`quiet small`,onClick:e.onClose,children:`Close`})]}),q(`div`,{className:`cv__pop-grid`,children:[r.length>0&&q(S,{children:[q(`label`,{children:`Shape`}),q(Z,{value:c===`mixed`?``:c??``,onChange:t=>e.onNodeStyle({shape:t.target.value||null}),children:[q(`option`,{value:``,children:c===`mixed`?`Mixed`:`Auto (property driven)`}),ma.map(e=>q(`option`,{value:e,children:e},e))]})]}),r.length>0&&q(S,{children:[q(`label`,{children:`Fill`}),q(`span`,{className:`seg`,children:[q(`button`,{className:u===`solid`?`on`:``,onClick:()=>e.onNodeStyle({fill:`solid`}),"data-tip":`A solid box`,"data-tip-pos":`bottom`,children:`Fill`}),q(`button`,{className:u===`tint`?`on`:``,onClick:()=>e.onNodeStyle({fill:`tint`}),"data-tip":`A tint of the fill color`,"data-tip-pos":`bottom`,children:`Transparent`}),q(`button`,{className:u===`none`?`on`:``,onClick:()=>e.onNodeStyle({fill:`none`}),"data-tip":`No fill, just the outline`,"data-tip-pos":`bottom`,children:`No fill`})]}),u!==`none`&&q(S,{children:[q(`label`,{children:`Fill color`}),ee(d,t=>e.onNodeStyle({fill_color:t}),`The page's own surface`)]})]}),(r.length>0||i.length>0)&&q(S,{children:[q(`label`,{title:`The bar and border on a card; the text itself on a text element`,children:r.length>0?`Highlight color`:`Text color`}),ee(l,t=>e.onNodeStyle({color:t}),`Back to the property's color`)]}),i.length>0&&q(S,{children:[q(`label`,{children:`Text size`}),q(`span`,{style:{display:`flex`,gap:6,alignItems:`center`},children:[q(`span`,{className:`seg`,children:ha.map(t=>q(`button`,{className:p===0&&f===t?`on`:``,onClick:()=>e.onTextSize({size:t,font:null}),children:t[0]?.toUpperCase()},t))}),q(`input`,{type:`number`,min:8,max:64,step:8,value:typeof p==`number`&&p>0?p:``,placeholder:`px`,style:{width:64},onChange:t=>e.onTextSize({font:t.target.value===``?null:Math.min(64,Math.max(8,Number(t.target.value)))})})]})]}),o.length>0&&q(S,{children:[q(`label`,{title:`The note and the lines it points with`,children:`Annotation color`}),ee(s(o.map(e=>e.style.color??``)),t=>e.onAnnotationColor(t),`Ink, the page's text color`)]}),a.length>0&&q(S,{children:[q(`label`,{children:`Sticky color`}),q(`span`,{className:`swatches`,children:Ei.map(t=>q(`button`,{className:`swatch-btn sticky-${t}${a.every(e=>(e.style.color??`yellow`)===t)?` on`:``}`,onClick:()=>e.onStickyColor(t),"data-tip":t,"data-tip-pos":`bottom`},t))})]}),e.nodes.some(e=>e.kind!==`text`)&&q(S,{children:[q(`label`,{children:`Size`}),q(`span`,{className:`seg`,children:ha.map(t=>q(`button`,{className:f===t&&!h?`on`:``,onClick:()=>(e.onBox(null),e.onNodeStyle({size:t})),children:t[0]?.toUpperCase()},t))})]}),e.nodes.length>0&&e.resizable&&q(S,{children:[q(`label`,{title:`An exact size; drag a selected node's corners for the same`,children:`Box`}),q(`span`,{style:{display:`flex`,gap:6,alignItems:`center`},children:[q(`input`,{type:`number`,min:40,step:8,value:m===`mixed`||!m?``:m.w,placeholder:`W`,style:{width:62},onChange:t=>t.target.value!==``&&e.onBox({w:Number(t.target.value),h:m&&m!==`mixed`?m.h:e.nodes[0]?g(e.nodes[0]).h:112})}),q(`span`,{className:`faint`,children:`×`}),q(`input`,{type:`number`,min:24,step:8,value:m===`mixed`||!m?``:m.h,placeholder:`H`,style:{width:62},onChange:t=>t.target.value!==``&&e.onBox({w:m&&m!==`mixed`?m.w:e.nodes[0]?g(e.nodes[0]).w:220,h:Number(t.target.value)})}),q(`button`,{className:`quiet small`,onClick:()=>e.onBox(null),disabled:!h,children:h?`auto`:`· auto`})]})]}),e.frame&&q(S,{children:[q(`label`,{children:`Frame color`}),q(`span`,{className:`swatches`,children:Di.map(t=>q(`button`,{className:`swatch-btn frame-${t}${(e.frame?.color??`none`)===t?` on`:``}`,onClick:()=>e.onFrameColor(t===`none`?null:t),"data-tip":t,"data-tip-pos":`bottom`},t))})]}),v&&q(S,{children:[q(`label`,{children:`Line color`}),ee(v.color??``,t=>e.onEdge({color:t}),`The page's line color`),q(`label`,{children:`Line`}),q(`span`,{className:`seg`,children:[q(`button`,{className:v.style===`dashed`?``:`on`,onClick:()=>e.onEdge({style:null}),children:`Solid`}),q(`button`,{className:v.style===`dashed`?`on`:``,onClick:()=>e.onEdge({style:`dashed`}),children:`Dashed`})]}),q(`label`,{children:`Start`}),q(Aa,{value:v.start??`none`,flip:!0,onChange:t=>e.onEdge({start:t===`none`?null:t}),label:`Start of the line`}),q(`label`,{children:`End`}),q(Aa,{value:v.end??`triangle`,onChange:t=>e.onEdge({end:t}),label:`End of the line`}),v.label&&q(S,{children:[q(`label`,{children:`Label at`}),q(`span`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[q(`input`,{type:`range`,min:0,max:100,value:Math.round((v.label_at??.5)*100),onChange:t=>e.onEdge({label_at:Number(t.target.value)/100})}),q(`span`,{className:`faint`,style:{fontSize:12,width:34},children:[Math.round((v.label_at??.5)*100),`%`]})]})]})]})]}),q(`div`,{className:`cv__pop-foot`,style:{marginTop:10},children:[(_||v)&&q(`button`,{className:`quiet small`,onClick:e.onReset,"data-tip":v?`Plain line, arrow at the end`:`Back to what the properties say`,"data-tip-pos":`bottom`,children:`Reset`}),e.nodes.length>0&&q(S,{children:[q(`button`,{className:`small`,onClick:e.onCopyStyle,"data-tip":`Copy this look ⌥⌘C`,"data-tip-pos":`bottom`,style:{marginLeft:`auto`},children:`Copy style`}),q(`button`,{className:`small`,onClick:e.onPasteStyle,disabled:!e.canPaste,"data-tip":`Lay the copied look onto the selection ⌥⌘V`,"data-tip-pos":`bottom`,children:`Paste style`})]})]})]})}function Na(e){let[t,n]=N([]),[r,i]=N(``);P(()=>{ct(`/api/blueprints`).then(n).catch(()=>void 0)},[]);let a=r.toLowerCase(),o=t.filter(t=>t.id&&!e.taken.has(t.id)&&(a===``||`${t.title} ${t.id} ${t.collection} ${t.group??``}`.toLowerCase().includes(a)));return q(wt,{title:`Which blueprint goes here?`,size:`sm`,onClose:e.onClose,children:q(`div`,{style:{padding:12},children:[q(`input`,{ref:gn,value:r,placeholder:`Filter by title, id, collection…`,onChange:e=>i(e.target.value),onKeyDown:t=>{let n=o[0];t.key===`Enter`&&n&&e.onPick(n)}}),q(`div`,{className:`palette__list`,style:{maxHeight:`50vh`,padding:`6px 0`},children:[o.length===0&&q(`div`,{className:`palette__empty`,children:`Every blueprint is already on this page.`}),o.map(t=>q(`div`,{className:`palette__hit`,onClick:()=>e.onPick(t),children:[q(`span`,{className:`t`,children:t.title}),q(`span`,{className:`w`,children:[t.collection,t.group?` / ${t.group}`:``]}),t.summary&&q(`span`,{className:`s`,children:t.summary})]},t.path))]})]})})}function Pa(){return q(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:q(`path`,{d:`M11.5 2.5l2 2L5 13H3v-2z`})})}function Fa(e){let t=e.trim().split(/\s+/).filter(e=>e!==``);return(t.length>=2?`${t[0]?.[0]??``}${t[1]?.[0]??``}`:(t[0]??`me`).slice(0,2)).toUpperCase()}function Ia(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.round(n/6e4)}m ago`:n<864e5?`${Math.round(n/36e5)}h ago`:t.toLocaleDateString()}function La(e){return q(`span`,{className:`thread__avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:Fa(e.name)})}var Ra=/(@[\w.-]+)/g;function za(e){return q(S,{children:e.text.split(Ra).map((t,n)=>{if(!t.startsWith(`@`))return q(`span`,{children:t},n);let r=e.users.find(e=>e.alias?.toLowerCase()===t.slice(1).toLowerCase()||e.name.toLowerCase()===t.slice(1).toLowerCase());return r?q(`b`,{className:`mention`,title:`${r.name}${r.role?` · ${r.role}`:``}`,children:t},n):q(`span`,{children:t},n)})})}function Ba(e){let t=F(null);P(()=>{e.focus&&t.current?.focus()},[e.focus]);let n=/(^|\s)@([\w.-]*)$/.exec(e.value),r=n?.[2]?.toLowerCase()??null,i=r===null?[]:e.users.filter(e=>e.alias&&(e.alias.toLowerCase().startsWith(r)||e.name.toLowerCase().startsWith(r))).slice(0,5),a=r=>{!n||!r.alias||(e.onChange(`${e.value.slice(0,e.value.length-n[0].length)}${n[1]}@${r.alias} `),t.current?.focus())};return q(`span`,{className:`thread__field`,children:[q(`textarea`,{ref:t,rows:e.rows,value:e.value,placeholder:e.placeholder,onChange:t=>e.onChange(t.target.value),onKeyDown:t=>{t.key===`Escape`?e.onCancel():t.key===`Tab`&&i[0]?(t.preventDefault(),a(i[0])):t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),i[0]&&r!==null&&r!==``&&i.length===1?a(i[0]):e.onSubmit())}}),i.length>0&&q(`div`,{className:`thread__suggest`,children:i.map(e=>q(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(e),children:[q(`b`,{children:[`@`,e.alias]}),` `,q(`span`,{className:`faint`,children:e.name})]},e.alias))})]})}function Va(e){let t=e.comment.messages[0];return q(`div`,{className:`pin${e.open?` open`:``}${e.comment.resolved?` resolved`:``}`,style:{left:e.comment.at.x,top:e.comment.at.y},"data-comment":e.comment.id,title:t?`${t.author}: ${t.text}${e.comment.resolved?` (resolved)`:``}`:``,onPointerDown:e.onPointerDown,onClick:t=>{t.stopPropagation(),e.onOpen()},children:q(`span`,{children:t?Fa(t.author):e.index})})}function Ha(e){let[t,n]=N(``),r=F(null),i=ga(e.at,r),a=()=>{t.trim()!==``&&e.onPost(t.trim())};return q(`div`,{ref:r,className:`thread composer`,style:{left:i.x,top:i.y},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[q(`div`,{className:`thread__row`,children:[q(La,{name:e.author.name,role:e.author.role}),q(Ba,{value:t,users:e.users,rows:2,placeholder:e.anchored?`Comment on this…`:`Add a comment…`,onChange:n,onSubmit:a,onCancel:e.onCancel,focus:!0})]}),q(`div`,{className:`thread__actions`,children:[q(`span`,{className:`faint`,children:[e.anchored?`Pinned to the object`:`Pinned here`,` · as `,e.author.name]}),q(`button`,{className:`small quiet`,onClick:e.onCancel,children:`Cancel`}),q(`button`,{className:`small primary`,disabled:t.trim()===``,onClick:a,children:`Post`})]})]})}function Ua(e){let[t,n]=N(``),[r,i]=N(null),a=F(null),o=ga(e.at,a,[e.comment.messages.length,r?.index]),{comment:s}=e;return q(`div`,{ref:a,className:`thread${s.resolved?` thread--resolved`:``}`,style:{left:o.x,top:o.y},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[q(`div`,{className:`thread__head`,children:[q(`strong`,{children:s.resolved?`Resolved`:`Thread`}),q(`button`,{className:`small quiet`,onClick:()=>e.onResolve(!s.resolved),title:s.resolved?`Reopen`:`Resolve (grays the pin)`,children:s.resolved?`Reopen`:`✓ Resolve`}),q(`button`,{className:`small quiet icon danger`,onClick:e.onDelete,"data-tip":`Delete the thread`,"data-tip-pos":`bottom`,"aria-label":`Delete the thread`,children:q(Zt,{})}),q(`button`,{className:`small quiet`,onClick:e.onClose,"data-tip":`Close Esc`,"data-tip-pos":`bottom`,children:`Close`})]}),q(`div`,{className:`thread__list`,children:s.messages.map((t,n)=>q(`div`,{className:`thread__row`,children:[q(La,{name:t.author,role:t.role}),q(`div`,{className:`thread__msg`,children:[q(`div`,{className:`thread__meta`,children:[q(`b`,{children:t.author}),q(`span`,{className:`faint`,children:Ia(t.at)}),r?.index!==n&&q(`span`,{className:`thread__tools`,children:[q(`button`,{className:`quiet icon`,onClick:()=>i({index:n,text:t.text}),title:`Edit`,"aria-label":`Edit message`,children:q(Pa,{})}),q(`button`,{className:`quiet icon danger`,onClick:()=>e.onDeleteMessage(n),title:`Delete`,"aria-label":`Delete message`,children:q(Zt,{})})]})]}),r?.index===n?q(S,{children:[q(Ba,{value:r.text,users:e.users,rows:2,placeholder:`Say it again…`,focus:!0,onChange:e=>i({index:n,text:e}),onSubmit:()=>{r.text.trim()!==``&&e.onEditMessage(n,r.text.trim()),i(null)},onCancel:()=>i(null)}),q(`div`,{className:`thread__actions`,children:q(`span`,{className:`faint`,children:`Enter saves · Esc cancels`})})]}):q(`div`,{children:q(za,{text:t.text,users:e.users})})]})]},n))}),q(`div`,{className:`thread__row`,children:[q(La,{name:e.author.name,role:e.author.role}),q(Ba,{value:t,users:e.users,rows:1,placeholder:`Reply as ${e.author.name}…`,onChange:n,onSubmit:()=>{t.trim()!==``&&(e.onReply(t.trim()),n(``))},onCancel:e.onClose})]})]})}function Wa(e){let t=e.comments.filter(e=>!e.resolved),n=e.comments.filter(e=>e.resolved),r=e.hideResolved?t:e.comments;return q(`div`,{className:`cv__panel cv__panel--comments`,children:[q(`div`,{className:`head`,children:[q(`strong`,{children:`Comments`}),q(`span`,{className:`faint`,children:[t.length,` open`,n.length>0?` · ${n.length} resolved`:``]}),q(`button`,{className:`quiet small`,onClick:e.onClose,children:`Close`})]}),q(`div`,{className:`body`,children:[q(`label`,{className:`cv__toggle`,children:[q(`input`,{type:`checkbox`,checked:e.hideResolved,onChange:e.onToggleHide}),`Hide resolved`]}),q(`label`,{className:`cv__toggle`,children:[q(`input`,{type:`checkbox`,checked:e.pinsHidden,onChange:e.onTogglePins}),`Hide the pins on the page`]}),r.length===0&&q(`div`,{className:`empty`,children:`No comments yet. Press C and click anywhere.`}),r.map(t=>{let n=t.messages[0];return q(`div`,{className:`thread__card${t.resolved?` resolved`:``}`,onClick:()=>e.onOpen(t.id),children:q(`div`,{className:`thread__row`,children:[n?q(La,{name:n.author,role:n.role}):q(`span`,{className:`thread__avatar`,children:`?`}),q(`div`,{className:`thread__msg`,children:[q(`div`,{className:`thread__meta`,children:[q(`b`,{children:n?.author}),` `,q(`span`,{className:`faint`,children:n?Ia(n.at):``}),t.resolved&&q(`span`,{className:`badge ok`,children:`resolved`})]}),q(`div`,{className:`thread__text`,children:n?q(za,{text:n.text,users:e.users}):null}),t.messages.length>1&&q(`div`,{className:`faint`,children:[t.messages.length-1,` repl`,t.messages.length===2?`y`:`ies`]})]})]})},t.id)})]})]})}var Ga=null,Ka=null,qa=900,Ja=Math.cos(50*Math.PI/180),Ya=e=>{let t=/^#([0-9a-f]{6})$/i.exec(e);if(!t)return 1;let n=Number.parseInt(t[1]??``,16);return(.2126*(n>>16&255)+.7152*(n>>8&255)+.0722*(n&255))/255},Xa=e=>{let t=/^#([0-9a-f]{6})$/i.exec(e);if(!t)return null;let n=Number.parseInt(t[1]??``,16),r=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(n>>16&255)+.7152*r(n>>8&255)+.0722*r(n&255)},Za=e=>{let t=Xa(e);if(t===null)return`dark`;let n=1.05/(t+.05),r=(t+.05)/.061;return n*1.25>=r?`light`:`dark`};function Qa(e,t){let n=document.createElement(`span`);n.style.color=`var(${e})`,n.style.position=`absolute`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=getComputedStyle(n).color;return n.remove(),r&&r!==``?r:t}var $a=e=>({wheelZoom:e.local.canvas.wheel_zoom,rightDragPan:e.local.canvas.right_drag_pan,ctrlClickMenu:e.local.canvas.ctrl_click_menu,enterCommits:e.local.canvas.enter_commits,contextMenu:e.local.canvas.context_menu,resizeAll:e.local.canvas.resize_all}),eo=360,to=400,no=460,ro=(e,t,n)=>Math.min(n,Math.max(t,e)),io={sketch:{w:220,h:112,label:`Sketch`},sticky:{w:176,h:176,label:`Sticky`},text:{w:160,h:32,label:`Text`},annotation:{w:xi.w,h:xi.h,label:`Annotation: place, then point`},blueprint:{w:220,h:112,label:`Blueprint: click, then pick`}};function ao(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function oo(e){let[t,n]=N(null),[r,i]=N(null),[a,o]=N({x:40,y:40,scale:1}),[s,c]=N(`select`),[l,u]=N(null),d=F(null),[f,p]=N(!1),[m,h]=N(!1),[g,_]=N(new Set),[v,y]=N({}),[ee,b]=N({}),[x,te]=N({}),[C,w]=N(null),[T,ne]=N(null),[E,D]=N(null),[re,ie]=N(null),[O,k]=N(null),[A,ae]=N(!0),[oe,se]=N(!1),[ce,le]=N(!1),[ue,de]=N(null),[fe,pe]=N(null),[me,he]=N(!1),[ge,_e]=N(!1),[j,ve]=N(!1),[ye,be]=N(()=>$a(e.settings)),[xe,Se]=N(!1),[Ce,we]=N(null),[Te,Ee]=N(null),[M,De]=N(null),Oe=F(null),ke=F(null),Me=F(new Set),Ne=F(new Set),Pe=F(!1),Fe=F(!1),Ie=F(null),[Le,Re]=N(null),[L,ze]=N(null),[Be,Ve]=N(null),[He,Ue]=N(null),We=F(null),Ge=F(null),Ke=F(null);P(()=>()=>{Ke.current&&window.clearTimeout(Ke.current),Ie.current!==null&&window.clearTimeout(Ie.current)},[]);let qe=F(null),Je=Dt(),Ye=Et(),Xe=kt(),Ze=fa(),Qe=t?.page?.id??null,$e=Qe?`/api/canvas/${encodeURIComponent(e.id)}/pages/${encodeURIComponent(Qe)}`:null,et=t?.page?.raw??null,R=m?`hand`:s,tt=F(0),nt=I(()=>{let t=e.page?`/api/canvas/${encodeURIComponent(e.id)}/pages/${encodeURIComponent(e.page)}`:`/api/canvas/${encodeURIComponent(e.id)}`,r=++tt.current;ct(t).then(e=>{r===tt.current&&(n(e),i(null))}).catch(e=>r===tt.current&&i(e.message))},[e.id,e.page]);P(()=>()=>void(tt.current+=1),[]),P(nt,[nt,e.tick]),P(()=>{Ze.reset(),_(new Set),k(null),ie(null),D(null),we(null)},[e.id,Qe]),P(()=>be($a(e.settings)),[e.settings]),P(()=>{t&&(y(Object.fromEntries(t.nodes.map(e=>[e.id,{x:e.position.x,y:e.position.y}]))),b({}),te(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.nodes.find(t=>t.id===e)?.box))))},[t]);let rt=t=>{be(t),Je(()=>ut(`/api/settings`,{local:{canvas:{wheel_zoom:t.wheelZoom,right_drag_pan:t.rightDragPan,ctrl_click_menu:t.ctrlClickMenu,enter_commits:t.enterCommits,context_menu:t.contextMenu,resize_all:t.resizeAll}}})).then(t=>t&&e.onChanged())},z=I(t=>{t&&(n(t),e.onChanged())},[e.onChanged]),B=I(async(e,t,n,r=!0)=>{if(!$e)return;r&&et&&Ze.push(et);let i=e===`POST`?lt:e===`PUT`?ut:dt;return Je(()=>i(`${$e}${t}`,n))},[$e,et,Ze,Je]),V=I((e,t=!0)=>B(`PUT`,``,{page:e},t).then(e=>(z(e),e)),[B,z]),it=F(null);P(()=>{if(!t||!Qe||it.current===`${e.id}/${Qe}`)return;let n=t.nodes.filter(e=>e.position.computed);n.length!==0&&(it.current=`${e.id}/${Qe}`,B(`PUT`,`/layout`,{positions:Object.fromEntries(n.map(e=>[e.id,{x:Math.round(e.position.x),y:Math.round(e.position.y)}]))},!1).then(z))},[t,Qe,e.id,B,z]);let at=I(()=>{if(!et)return;let e=Ze.undo(et);e&&V(e,!1)},[et,Ze,V]),ot=I(()=>{if(!et)return;let e=Ze.redo(et);e&&V(e,!1)},[et,Ze,V]),H=je(()=>t?.nodes??[],[t]),U=je(()=>new Map(H.map(e=>[e.id,e])),[H]),W=I(e=>ki(e,v,x),[v,x]),ft=je(()=>{let e=t?.page;return e?e.frames.map(e=>({frame:e,rect:Ai(e,H,W,ee[e.id])})).filter(e=>e.rect!==null):[]},[t,H,W,ee]),G=je(()=>new Map(ft.map(e=>[e.frame.id,e])),[ft]),K=I(e=>{if(yi(e))return G.get(bi(e))?.rect??null;let t=U.get(e);return t?W(t):null},[U,G,W]),pt=I(e=>{let t=[e];for(let e=0;e<t.length;e+=1)for(let n of ft)n.frame.frame===t[e]&&!t.includes(n.frame.id)&&t.push(n.frame.id);return t},[ft]),mt=I((e,t)=>{let n=We.current?.getBoundingClientRect()??{left:0,top:0};return{x:(e-n.left-a.x)/a.scale,y:(t-n.top-a.y)/a.scale}},[a]),gt=I(e=>({x:e.x*a.scale+a.x,y:e.y*a.scale+a.y}),[a]),_t=I(e=>[...H].reverse().find(t=>Ni(W(t),e))??null,[H,W]),vt=I(e=>[...ft].reverse().find(t=>Ni(t.rect,e))?.frame??null,[ft]),yt=I(e=>{let t=pt(e),n=[];for(let e of t){let t=G.get(e);if(t)for(let r of H)(r.frame===e||Ni(t.rect,Pi(W(r))))&&!n.includes(r.id)&&n.push(r.id)}return n},[G,pt,H,W]),xt=je(()=>Ii([...H.map(W),...ft.map(e=>e.rect)]),[H,ft,W]),St=I((e,t=60)=>{let n=We.current?.getBoundingClientRect();if(!n||n.width===0||n.height===0)return!1;if(!e)return o({x:40,y:40,scale:1}),!0;let r=ro(Math.min(n.width/(e.w+t*2),n.height/(e.h+t*2),1.2),Ti,3);return o({x:(n.width-e.w*r)/2-e.x*r,y:(n.height-e.h*r)/2-e.y*r,scale:r}),!0},[]),Ct=I(()=>St(xt),[St,xt]);Ae(()=>{t&&Qe&&Be!==`${e.id}/${Qe}`&&Ct()&&Ve(`${e.id}/${Qe}`)},[t,Qe,Be,Ct,e.id]);let wt=I((e,t,n)=>{let r=We.current?.getBoundingClientRect();if(!r)return;let i=t===void 0?r.width/2:t-r.left,a=n===void 0?r.height/2:n-r.top;o(t=>{let n=ro(t.scale*e,Ti,3),r=n/t.scale;return{x:i-(i-t.x)*r,y:a-(a-t.y)*r,scale:n}})},[]),Tt=I(e=>{let t=We.current?.getBoundingClientRect();t&&o(n=>{let r=e/n.scale;return{x:t.width/2-(t.width/2-n.x)*r,y:t.height/2-(t.height/2-n.y)*r,scale:e}})},[]),J=je(()=>[...g].filter(oa).map(la).filter(e=>U.has(e)),[g,U]),Ot=je(()=>[...g].filter(sa).map(la).filter(e=>G.has(e)),[g,G]),Y=I((e,t=!1)=>{_(n=>{if(!t)return new Set(e);let r=new Set(n);for(let t of e)r.has(t)?r.delete(t):r.add(t);return r})},[]),At=I(()=>_(new Set),[]),jt=I(e=>{c(e),u(t=>t===e?t:null),ze(null),ie(null),pe(null),de(null),e!==`select`&&D(null)},[]),Mt=I(e=>{e!==`select`&&e!==`hand`&&(c(e),u(e))},[]),Nt=I((e,t)=>{!t&&l!==e&&jt(`select`)},[l,jt]);P(()=>p(!1),[g]),P(()=>{we(null),p(!1)},[a.x,a.y,a.scale]),P(()=>{L||(De(null),ne(null))},[L]);let X=I(e=>{if(!et)return null;let t=pa(et);return e(t),t},[et]),Pt=(e,t,n)=>{for(let r of t){let t=e.nodes.find(e=>e.id===r),i=n[r];if(!t||!i)continue;let a=[...ft].reverse().find(e=>e.frame.x!==void 0&&Ni(ee[e.frame.id]??e.rect,Pi(i)));a&&(t.frame=a.frame.id)}},Ft=(e,t)=>{let n=X(n=>{let r={};for(let t of e){let e=v[t],i=U.get(t);!e||!i||(n.layout[t]={x:Math.round(e.x),y:Math.round(e.y)},r[t]=ki(i,v,x))}for(let e of t){let t=ee[e],r=n.frames.find(t=>t.id===e);t&&r&&Object.assign(r,{x:Math.round(t.x),y:Math.round(t.y),w:Math.round(t.w),h:Math.round(t.h)})}Pt(n,e.filter(e=>!t.some(t=>yt(t).includes(e))),r)});n&&V(n)},It=I(()=>{if(g.size===0)return;let e=X(e=>{let t=new Set(J),n=new Set(Ot),r=t=>{e.nodes=e.nodes.filter(e=>!t.has(e.id)),e.edges=e.edges.filter(e=>!t.has(e.from)&&!t.has(e.to)),e.comments=e.comments.filter(e=>!e.node||!t.has(e.node));for(let n of t)delete e.layout[n]};r(t),e.edges=e.edges.filter(e=>!g.has(aa(e))&&!(yi(e.from)&&n.has(bi(e.from)))&&!(yi(e.to)&&n.has(bi(e.to)))),e.frames=e.frames.filter(e=>!n.has(e.id));for(let t of e.nodes)t.frame&&n.has(t.frame)&&delete t.frame;for(let t of e.frames)t.frame&&n.has(t.frame)&&delete t.frame;let i=new Set(e.nodes.filter(t=>t.annotation&&!e.edges.some(e=>e.from===t.id)).map(e=>e.id));for(;i.size>0;)r(i),i=new Set(e.nodes.filter(t=>t.annotation&&!e.edges.some(e=>e.from===t.id)).map(e=>e.id))});At(),e&&V(e)},[g,J,Ot,X,V,At]),Lt=I((e,t)=>{At(),B(`DELETE`,`/frames/${encodeURIComponent(e)}${t?`?contents=delete`:``}`).then(z)},[At,B,z]),Rt=I(()=>{let e=[],t=X(t=>{let n=t.nodes.length,r=()=>{for(n+=1;t.nodes.some(e=>e.id===`n${n}`);)n+=1;return`n${n}`};for(let n of J){let i=t.nodes.find(e=>e.id===n),a=v[n];if(!i||i.blueprint||!a)continue;let o={...pa(i),id:r()};delete o.locked,t.nodes.push(o),t.layout[o.id]={x:Math.round(a.x+24),y:Math.round(a.y+24)},e.push(o.id)}});t&&e.length>0&&V(t).then(()=>Y(e.map($)))},[J,v,X,V,Y]),zt=I(()=>{if(!et||J.length===0)return;let e=new Set(J);Ga={nodes:et.nodes.filter(t=>e.has(t.id)).map(pa),positions:Object.fromEntries(J.map(e=>[e,v[e]??{x:0,y:0}])),box:Ii(J.map(e=>U.get(e)).filter(e=>e!==void 0).map(W)),edges:et.edges.filter(t=>e.has(t.from)&&e.has(t.to)).map(pa)},Ye(`Copied ${J.length} node${J.length===1?``:`s`}; ⌘V pastes under the pointer`)},[et,J,v,U,W,Ye]),Bt=I(e=>{let t=Ga;if(!t||t.nodes.length===0)return;let n=We.current?.getBoundingClientRect(),r=e??Oe.current??(n?mt(n.left+n.width/2,n.top+n.height/2):{x:0,y:0}),i=t.box??{x:0,y:0,w:0,h:0},a=Q(r.x-(i.x+i.w/2)),o=Q(r.y-(i.y+i.h/2)),s=[],c=0,l=X(e=>{let n=e.nodes.length,r=()=>{for(n+=1;e.nodes.some(e=>e.id===`n${n}`);)n+=1;return`n${n}`},i=new Map;for(let n of t.nodes){if(n.blueprint&&e.nodes.some(e=>e.blueprint===n.blueprint)){c+=1;continue}let l={...pa(n),id:r()};delete l.locked,delete l.styled,delete l.frame,i.set(n.id,l.id),e.nodes.push(l);let u=t.positions[n.id]??{x:0,y:0};e.layout[l.id]={x:Math.round(u.x+a),y:Math.round(u.y+o)},s.push(l.id)}for(let n of t.edges){let t=i.get(n.from),r=i.get(n.to);t&&r&&e.edges.push({...pa(n),from:t,to:r})}});l&&s.length>0&&V(l).then(()=>Y(s.map($))),c>0&&Ye(s.length===0?`Those blueprints are already on this page.`:`${c} blueprint${c===1?` is`:`s are`} already on this page and stayed put.`,s.length===0?`error`:`info`)},[X,V,Y,mt,Ye]),Vt=I(e=>{let t=X(t=>{for(let n of t.nodes){if(!J.includes(n.id))continue;let t={...n.style??{}};for(let[r,i]of Object.entries(e))i!==void 0&&(n.sticky&&r!==`size`||n.text&&r===`shape`||(i===null?delete t[r]:t[r]=i));Object.keys(t).length>0?n.style=t:delete n.style,n.styled=!0}});t&&V(t)},[J,X,V]),Ht=I(e=>{let t=X(t=>{for(let n of t.nodes)n.sticky&&J.includes(n.id)&&(n.sticky.color=e)});t&&V(t)},[J,X,V]),Ut=I(()=>{let e=X(e=>{for(let t of e.nodes)J.includes(t.id)&&(delete t.style,delete t.styled)});e&&V(e)},[J,X,V]),Z=I(()=>{let e=J.map(e=>U.get(e)).find(e=>e!==void 0);e&&(Ka={shape:e.style.shape,...e.style.color?{color:e.style.color}:{},size:e.style.size},Ye(`Style copied; ⌥⌘V lays it onto a selection`))},[J,U,Ye]),Wt=I(()=>{Ka&&Vt({shape:Ka.shape??null,color:Ka.color??null,size:Ka.size??null})},[Vt]),Gt=I(e=>{let t=X(t=>{for(let n of t.nodes)J.includes(n.id)&&(e?n.locked=!0:delete n.locked);for(let n of t.frames)Ot.includes(n.id)&&(e?n.locked=!0:delete n.locked)});t&&V(t)},[J,Ot,X,V]),Kt=g.size>0&&J.every(e=>U.get(e)?.locked)&&Ot.every(e=>G.get(e)?.frame.locked),qt=I((e,t)=>{if(J.length===0||!et)return;qe.current||=(Ze.push(et),pa(et));let n=qe.current;y(r=>{let i={...r};for(let r of J){let a=i[r];!a||U.get(r)?.locked||(i[r]={x:a.x+e,y:a.y+t},n.layout[r]={x:Math.round(a.x+e),y:Math.round(a.y+t)})}return i}),Ke.current&&window.clearTimeout(Ke.current),Ke.current=window.setTimeout(()=>{let e=qe.current;qe.current=null,e&&V(e,!1)},350)},[J,et,Ze,U,V]),Jt=I(e=>{let t=Ii(e.map(e=>U.get(e)).filter(e=>e!==void 0).map(W));t&&B(`POST`,`/frames`,{x:Q(t.x-24),y:Q(t.y-34),w:Q(t.w+48),h:Q(t.h+24+34),members:e}).then(e=>{z(e),e?.frame&&(Y([ia(e.frame.id)]),D({kind:`frame`,id:e.frame.id,field:`label`,value:e.frame.title}))})},[U,W,B,z,Y]),Yt=I((e,t,n)=>{B(`POST`,`/nodes`,{...e,x:Q(t.x),y:Q(t.y)}).then(e=>{z(e),e?.node&&(Y([$(e.node.id)]),n&&D({kind:n,id:e.node.id,field:`label`,value:e.node.label}))})},[B,z,Y]),Xt=I((e,t,n,r,i=!1)=>{if(e===t)return;let a={from:e,to:t};n&&(a.from_anchor=n),r&&(a.to_anchor=r);let o=ke.current===e;B(`POST`,`/edges`,a).then(t=>{z(t),t&&(o?(ke.current=null,Y([$(e)]),D({kind:`annotation`,id:e,field:`label`,value:U.get(e)?.label??``}),Nt(`annotation`,i)):R===`connect`&&Nt(`connect`,i))})},[B,z,R,Nt,U,Y]),Zt=I(()=>{let e=ke.current;ke.current=null,e&&B(`DELETE`,`/nodes/${encodeURIComponent(e)}`,void 0,!1).then(z)},[B,z]),Qt=F(null);Qt.current=E;let $t=I(()=>{let t=Qt.current;if(!t)return;Qt.current=null,D(null);let n=t.value;if(t.kind===`edge`){let{from:e,to:r}=ua(t.id);B(`PUT`,`/edges`,{from:e,to:r,label:n.trim()===``?null:n.trim(),...t.t===void 0?{}:{label_at:t.t}}).then(z);return}if(t.kind===`frame`){if(n.trim()===``||n===G.get(t.id)?.frame.title)return;B(`PUT`,`/frames/${encodeURIComponent(t.id)}`,{title:n.trim()}).then(z);return}let r=U.get(t.id);if(n!==(t.field===`summary`?r?.summary??``:r?.label??``)){if(t.kind===`blueprint`){if(!r?.path||t.field===`label`&&n.trim()===``)return;let i=r.path;Je(async()=>{let e=await ct(`/api/blueprints/${st(i)}`),r=t.field===`label`?`title`:`summary`,a=Object.entries(e.properties).map(([e,t])=>[e,e===r?n.trim():t]);a.some(([e])=>e===r)||a.push([r,n.trim()]),await ut(`/api/blueprints/${st(i)}`,{properties:a,body:e.body})}).then(()=>(nt(),e.onChanged()));return}if(t.kind===`annotation`){B(`PUT`,`/nodes/${encodeURIComponent(t.id)}`,{annotation:{text:n}}).then(z);return}if(t.kind===`sketch`){if(t.field===`summary`){B(`PUT`,`/nodes/${encodeURIComponent(t.id)}`,{sketch:{note:n.trim()||null}}).then(z);return}if(n.trim()===``)return;B(`PUT`,`/nodes/${encodeURIComponent(t.id)}`,{sketch:{label:n.trim()}}).then(z)}else t.kind===`sticky`?B(`PUT`,`/nodes/${encodeURIComponent(t.id)}`,{sticky:{text:n}}).then(z):B(`PUT`,`/nodes/${encodeURIComponent(t.id)}`,{text:{text:n}}).then(z)}},[U,G,B,z,Je,nt,e]),nn=I(t=>ht(`${bt(e.id,Qe)}?open=${encodeURIComponent(t)}`),[e.id,Qe]),an=I((e,t)=>{e.locked||(we(null),D({kind:e.kind,id:e.id,field:t,value:t===`summary`?e.summary??``:e.label}))},[]),on=I(e=>{D(null),_(new Set([e])),p(!1),we(e)},[]),sn=async(e,n=`png`)=>{let r=Ge.current;if(!r||!t?.page)return;let i=e?g:null,a=Ii(e?[...J.map(e=>U.get(e)).filter(e=>e!==void 0).map(W),...Ot.map(e=>G.get(e)?.rect).filter(e=>e!==void 0)]:[...H.map(W),...ft.map(e=>e.rect)]);if(!a){Ye(e?`Select something to export first.`:`Nothing on this page to export.`,`error`);return}let o=Math.ceil(a.w+80),s=Math.ceil(a.h+80),c={width:o,height:s,backgroundColor:getComputedStyle(document.body).backgroundColor,style:{transform:`translate(${40-a.x}px, ${40-a.y}px)`,transformOrigin:`0 0`,width:`${o}px`,height:`${s}px`},filter:e=>{let t=e,n=t.classList;if(n&&[`cv__edit`,`frame__grip`,`node__handle`,`hit`,`group-box`,`marquee`,`drawing`,`ghost`,`endpoint`,`bend`,`snap`].some(e=>n.contains(e)))return!1;let r=t.dataset;if(!i||!r)return!0;if(r.node)return i.has($(r.node));if(r.frame)return i.has(ia(r.frame));if(r.edgeGroup){let{from:e,to:t}=ua(r.edgeGroup),n=e=>yi(e)?ia(bi(e)):$(e);return i.has(n(e))&&i.has(n(t))}return!0}},l=await Je(()=>n===`svg`?Fr(r,c):Lr(r,{...c,pixelRatio:2}));l&&ao(l,`${t.canvas.id}-${t.page.id}${e?`-selection`:``}.${n}`)},cn=`.backdrop, .modal, .cv__pop, .cv__panel, .cv__stylepop, .thread, .cv__menu, .cv__prefs, .cv__pages-list, .cv__legend`,dn=e=>{if(e.target.closest(cn))return;if(e.preventDefault(),e.ctrlKey||e.metaKey){wt(Math.exp(-e.deltaY*.01),e.clientX,e.clientY);return}let t=e.deltaX!==0||e.deltaMode===0&&Math.abs(e.deltaY)<20&&!Number.isInteger(e.deltaY);if(ye.wheelZoom&&!e.shiftKey&&!t){wt(Math.exp(-e.deltaY*.0025),e.clientX,e.clientY);return}e.shiftKey&&e.deltaX===0?o(t=>({...t,x:t.x-e.deltaY})):o(t=>({...t,x:t.x-e.deltaX,y:t.y-e.deltaY}))};P(()=>{let e=We.current;if(!e)return;let t=e=>{e.target.closest(cn)||e.preventDefault()};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]);let pn=e=>e.kind===`text`||e.kind===`annotation`||ye.resizeAll,mn=e=>e.shiftKey||e.metaKey||e.ctrlKey&&!ye.ctrlClickMenu,hn=e=>e.button===2||ye.ctrlClickMenu&&e.ctrlKey&&e.button===0,_n=(e,t,n,r,i,a=null)=>{let o=[...new Set(i.flatMap(pt))],s=new Set(o.flatMap(yt)),c=[...new Set([...r,...s])].filter(e=>!U.get(e)?.locked);w({kind:`move`,ids:c,frames:o.filter(e=>!G.get(e)?.frame.locked),startX:e.clientX,startY:e.clientY,origins:Object.fromEntries(c.map(e=>[e,v[e]??{x:0,y:0}])),frameOrigins:Object.fromEntries(o.map(e=>[e,G.get(e)?.rect??{x:0,y:0,w:0,h:0}])),moved:!1,primary:t,primaryIsFrame:n,field:a})},vn=e=>{let n=e.target;if(n.closest(`.cv__toolbar, .cv__top, .cv__pages, .cv__zoom, .cv__panel, .cv__pop, .cv__menu, .cv__edit, .cv__prefs, .cv__corner, .cv__br, .cv__legend-wrap, .thread, .backdrop, input, textarea, select, button, a`))return;pe(null),he(!1),ve(!1),Se(!1),we(null),E&&$t(),e.currentTarget.setPointerCapture(e.pointerId);let r=mt(e.clientX,e.clientY);if(hn(e)){e.button===2&&ye.rightDragPan?w({kind:`pan`,startX:e.clientX,startY:e.clientY,originX:a.x,originY:a.y,moved:!1,button:2}):Sn(e.clientX,e.clientY,r);return}if(e.button===1||R===`hand`){w({kind:`pan`,startX:e.clientX,startY:e.clientY,originX:a.x,originY:a.y,moved:!1,button:e.button});return}if(e.button!==0)return;let i=n.closest(`[data-details]`);if(i){on($(i.dataset.details??``));return}let o=n.closest(`[data-open]`);if(o){nn(o.dataset.open??``);return}let s=n.closest(`[data-lock]`);if(s){let e=s.dataset.lock??``;s.dataset.lockKind===`frame`?B(`PUT`,`/frames/${encodeURIComponent(e)}`,{locked:!1}).then(z):B(`PUT`,`/nodes/${encodeURIComponent(e)}`,{locked:!1}).then(z);return}let u=n.closest(`[data-comment]`);if(u){let n=u.dataset.comment??``,r=t?.comments.find(e=>e.id===n);r&&R===`select`?w({kind:`pin`,id:n,startX:e.clientX,startY:e.clientY,origin:r.at,moved:!1}):r&&(ie(null),k(e=>e===n?null:n));return}let d=n.closest(`[data-edge-label]`);if(d){let t=d.dataset.edgeLabel??``;Y([t]),w({kind:`label`,key:t,t:Number(d.dataset.t??.5),startX:e.clientX,startY:e.clientY});return}let f=n.closest(`[data-bend]`);if(f){let t=f.dataset.bend??``;Y([t]),w({kind:`bend`,key:t,axis:f.dataset.axis??`x`,startX:e.clientX,startY:e.clientY,origin:Number(f.dataset.mid??0),value:Number(f.dataset.mid??0)});return}let p=n.closest(`[data-endpoint]`);if(p){w({kind:`endpoint`,key:p.dataset.edge??``,end:p.dataset.endpoint??`to`,point:r,startX:e.clientX,startY:e.clientY});return}let m=n.closest(`[data-edge]`);if(m&&R===`select`){Y([m.dataset.edge??``],mn(e));return}let h=n.closest(`[data-handle]`),_=n.closest(`[data-node]`),y=n.closest(`[data-node-grip]`);if(y){let t=y.dataset.nodeGrip??``,n=U.get(t);n&&!n.locked&&w({kind:`nodesize`,id:t,corner:y.dataset.corner,origin:W(n),startX:e.clientX,startY:e.clientY});return}let ee=n.closest(`[data-grip]`),b=n.closest(`[data-frame]`);if(R===`comment`){let e=_?U.get(_.dataset.node??``):null,t=e?{x:r.x-(v[e.id]?.x??e.position.x),y:r.y-(v[e.id]?.y??e.position.y)}:{x:0,y:0};k(null),ie({x:r.x,y:r.y,node:e?.id??null,offset:t});return}if(R===`annotation`){let e={x:r.x-xi.w/2,y:r.y-xi.h/2};B(`POST`,`/nodes`,{annotation:{text:``},x:Q(e.x),y:Q(e.y)}).then(e=>{z(e),e?.node&&(ke.current=e.node.id,c(`connect`),ze({id:e.node.id,anchor:null}),Y([$(e.node.id)]))});return}if(R===`sketch`||R===`sticky`||R===`text`){let t=io[R]??{w:220,h:112,label:``},n={x:r.x-t.w/2,y:r.y-t.h/2},i=e.altKey||l===R;R===`sketch`?Yt({sketch:{label:``}},n,i?null:`sketch`):R===`sticky`?Yt({sticky:{text:``,color:`yellow`}},n,i?null:`sticky`):Yt({text:{text:`Text`}},n,i?null:`text`),Nt(R,i);return}if(R===`blueprint`){de({x:Q(r.x-110),y:Q(r.y-56)});return}if(R===`frame`){w({kind:`draw`,start:r,current:r,startX:e.clientX,startY:e.clientY});return}if(R===`connect`){let t=h&&yi(h.dataset.handle??``)?h:null;if(_||t){let n=t?t.dataset.handle??``:_?.dataset.node??``,i=h?.dataset.anchor??null;L&&L.id!==n?(Xt(L.id,n,L.anchor,i,e.altKey),ze(null)):w({kind:`connect`,from:n,anchor:i,point:r,moved:!1,startX:e.clientX,startY:e.clientY})}else if(L&&b){let t=b.dataset.frame??``,n=G.get(t);n&&L.id!==`frame:${t}`&&(Math.min(r.x-n.rect.x,n.rect.x+n.rect.w-r.x,r.y-n.rect.y,n.rect.y+n.rect.h-r.y)<=18||ke.current===L.id?Xt(L.id,`${vi}${t}`,L.anchor,Bi(n.rect,r),e.altKey):B(`PUT`,`/nodes/${encodeURIComponent(L.id)}`,{frame:t}).then(z)),ze(null)}else ke.current||ze(null);return}if(h){w({kind:`connect`,from:h.dataset.handle??``,anchor:h.dataset.anchor??null,point:r,moved:!1,startX:e.clientX,startY:e.clientY});return}if(ee&&b){let t=b.dataset.frame??``,n=G.get(t);n&&!n.frame.locked&&w({kind:`resize`,frame:t,corner:ee.dataset.grip,origin:n.rect,startX:e.clientX,startY:e.clientY});return}if(_){let t=_.dataset.node??``,r=U.get(t);if(!r)return;let i=$(t);if(mn(e)){Y([i],!0);return}let a=J,o=Ot,s=g.has(i);if(s||(Y([i]),a=[t],o=[]),r.locked)return;let c=s?n.closest(`[data-field]`):null;_n(e,t,!1,a,o,c?.dataset.field??null);return}if(b){let t=b.dataset.frame??``,r=G.get(t);if(!r)return;let i=ia(t);if(mn(e)){Y([i],!0);return}let a=Ot,o=J,s=g.has(i);if(s||(Y([i]),a=[t],o=[]),r.frame.locked)return;_n(e,t,!0,o,a,s&&n.closest(`.frame__title`)?`label`:null);return}w({kind:`marquee`,start:r,current:r,additive:mn(e),startX:e.clientX,startY:e.clientY}),mn(e)||At(),k(null)},yn=e=>{let n=mt(e.clientX,e.clientY);if(Oe.current=n,io[R]&&!ue?ne(n):T&&!L&&ne(null),!C){let t=e.target.closest(`[data-frame]`)?.dataset.frame??null;if(t!==Te&&Ee(t),L){ne(n);let e=_t(n),t=e&&e.id!==L.id?{kind:`node`,id:e.id,anchor:Bi(W(e),n)}:null;if(!t){let e=vt(n),r=e?G.get(e.id):void 0;e&&r&&`frame:${e.id}`!==L.id&&(t=Math.min(n.x-r.rect.x,r.rect.x+r.rect.w-n.x,n.y-r.rect.y,r.rect.y+r.rect.h-n.y)<=18||ke.current===L.id?{kind:`frame-border`,id:e.id,anchor:Bi(r.rect,n)}:{kind:`frame`,id:e.id})}JSON.stringify(t)!==JSON.stringify(M)&&De(t)}return}let r=e.clientX-C.startX,i=e.clientY-C.startY,s=Math.abs(r)>3||Math.abs(i)>3;switch(C.kind){case`pan`:o(e=>({...e,x:C.originX+r,y:C.originY+i})),s!==C.moved&&w({...C,moved:s});return;case`move`:{let e=r/a.scale,t=i/a.scale;y(n=>{let r={...n};for(let n of C.ids){let i=C.origins[n];i&&(r[n]={x:Q(i.x+e),y:Q(i.y+t)})}return r}),C.frames.length>0&&b(n=>{let r={...n};for(let n of C.frames){let i=C.frameOrigins[n];i&&(r[n]={...i,x:Q(i.x+e),y:Q(i.y+t)})}return r}),s!==C.moved&&w({...C,moved:s});return}case`marquee`:case`draw`:w({...C,current:n});return;case`connect`:case`endpoint`:{let e=_t(n),t=C.kind===`connect`?C.from:null,r=e&&e.id!==t?{kind:`node`,id:e.id,anchor:Bi(W(e),n)}:null;if(!r&&C.kind===`connect`){let e=vt(n),t=e?G.get(e.id):void 0;if(e&&t&&`frame:${e.id}`!==C.from){let i=Math.min(n.x-t.rect.x,t.rect.x+t.rect.w-n.x,n.y-t.rect.y,t.rect.y+t.rect.h-n.y),a=U.get(C.from)?.kind===`annotation`,o=yi(C.from)?G.get(bi(C.from))?.frame.frame===e.id:U.get(C.from)?.frame===e.id;r=i<=18||a?{kind:`frame-border`,id:e.id,anchor:Bi(t.rect,n)}:o?null:{kind:`frame`,id:e.id}}}JSON.stringify(r)!==JSON.stringify(M)&&De(r),w(C.kind===`connect`?{...C,point:n,moved:s}:{...C,point:n});return}case`resize`:{let e=r/a.scale,t=i/a.scale,n=C.origin,{x:o,y:s,w:c,h:l}=n;C.corner.includes(`e`)&&(c=Math.max(60,n.w+e)),C.corner.includes(`s`)&&(l=Math.max(60,n.h+t)),C.corner.includes(`w`)&&(c=Math.max(60,n.w-e),o=n.x+n.w-c),C.corner.includes(`n`)&&(l=Math.max(60,n.h-t),s=n.y+n.h-l),b(e=>({...e,[C.frame]:{x:Q(o),y:Q(s),w:Q(c),h:Q(l)}}));return}case`nodesize`:{let e=r/a.scale,t=i/a.scale,n=C.origin,{x:o,y:s,w:c,h:l}=n;C.corner.includes(`e`)&&(c=Math.max(40,n.w+e)),C.corner.includes(`s`)&&(l=Math.max(24,n.h+t)),C.corner.includes(`w`)&&(c=Math.max(40,n.w-e),o=n.x+n.w-c),C.corner.includes(`n`)&&(l=Math.max(24,n.h-t),s=n.y+n.h-l),te(e=>({...e,[C.id]:{w:Q(c),h:Q(l)}})),y(e=>({...e,[C.id]:{x:Q(o),y:Q(s)}}));return}case`bend`:w({...C,value:Q(C.origin+(C.axis===`x`?r:i)/a.scale)});return;case`label`:{let{from:e,to:r}=ua(C.key),i=t?.page?.edges.find(t=>t.from===e&&t.to===r),a=K(e),o=K(r);if(!i||!a||!o)return;let s=Ji(a,o,{bend:i.bend,from:i.from_anchor,to:i.to_anchor});w({...C,t:Qi(s.points,n)});return}case`pin`:w({...C,moved:s}),Ue(C.moved||s?{id:C.id,at:{x:C.origin.x+r/a.scale,y:C.origin.y+i/a.scale}}:null);return}},bn=e=>{if(!C)return;w(null);let n=mt(e.clientX,e.clientY);switch(C.kind){case`pan`:!C.moved&&C.button===2?Sn(e.clientX,e.clientY,n):!C.moved&&R===`hand`&&At();return;case`move`:{let t=C.primaryIsFrame?ia(C.primary):$(C.primary);if(C.moved)Ft(C.ids,C.frames);else if(C.field&&R===`select`){if(C.primaryIsFrame){let e=G.get(C.primary);e&&!e.frame.locked&&D({kind:`frame`,id:e.frame.id,field:`label`,value:e.frame.title})}else{let e=U.get(C.primary);e&&an(e,C.field)}}else mn(e)||Y([t]);return}case`marquee`:{let e=Fi(C.start,C.current);if(e.w<4&&e.h<4)return;let t=H.filter(t=>!t.locked&&ji(W(t),e)).map(e=>$(e.id)),n=ft.filter(t=>!t.frame.locked&&Mi(e,t.rect)).map(e=>ia(e.frame.id));C.additive?_(e=>new Set([...e,...t,...n])):Y([...t,...n]);return}case`draw`:{let t=Fi(C.start,C.current);if(t.w<20||t.h<20){J.length>0&&Jt(J);return}let n=H.filter(e=>Mi(t,W(e))).map(e=>e.id),r=e.altKey||l===`frame`;B(`POST`,`/frames`,{x:Q(t.x),y:Q(t.y),w:Q(t.w),h:Q(t.h),members:n}).then(e=>{z(e),Nt(`frame`,r),e?.frame&&!r&&(Y([ia(e.frame.id)]),D({kind:`frame`,id:e.frame.id,field:`label`,value:e.frame.title}))});return}case`connect`:{let t=M;if(De(null),t?.kind===`node`&&U.get(t.id)&&t.id!==C.from)Xt(C.from,t.id,C.anchor,t.anchor,e.altKey);else if(t?.kind===`frame-border`)Xt(C.from,`${vi}${t.id}`,C.anchor,t.anchor,e.altKey);else if(t?.kind===`frame`){let e=G.get(t.id)?.frame.title??t.id;yi(C.from)?B(`PUT`,`/frames/${encodeURIComponent(bi(C.from))}`,{frame:t.id}).then(t=>(z(t),Ye(`Attached to ${e}; they move together`))):B(`PUT`,`/nodes/${encodeURIComponent(C.from)}`,{frame:t.id}).then(t=>(z(t),Ye(`Attached to ${e}`)))}else!C.moved&&R===`connect`&&ze({id:C.from,anchor:C.anchor});return}case`endpoint`:{let{from:e,to:t}=ua(C.key),n=M;if(De(null),n?.kind!==`node`)return;let r=n.id;if(!U.get(r))return;let i=n.anchor;if(r===(C.end===`from`?e:t)){B(`PUT`,`/edges`,{from:e,to:t,[C.end===`from`?`from_anchor`:`to_anchor`]:i}).then(z);return}if(r===(C.end===`from`?t:e))return;let a=X(n=>{let a=n.edges.find(n=>n.from===e&&n.to===t);a&&(C.end===`from`?(a.from=r,a.from_anchor=i):(a.to=r,a.to_anchor=i),n.edges=n.edges.filter((e,t,n)=>n.findIndex(t=>t.from===e.from&&t.to===e.to)===t))});a&&V(a).then(()=>Y([aa({from:C.end===`from`?r:e,to:C.end===`to`?r:t})]));return}case`resize`:{let e=ee[C.frame];if(e){let t=X(t=>{let n=t.frames.find(e=>e.id===C.frame);n&&Object.assign(n,{x:e.x,y:e.y,w:e.w,h:e.h});let r=H.filter(t=>Ni(e,Pi(W(t)))).map(e=>e.id);for(let e of t.nodes)r.includes(e.id)?e.frame=C.frame:e.frame===C.frame&&delete e.frame});t&&V(t)}return}case`nodesize`:{let e=x[C.id],t=v[C.id];if(!e)return;let n=X(n=>{let r=n.nodes.find(e=>e.id===C.id);r&&(r.box={w:Math.round(e.w),h:Math.round(e.h)},t&&(n.layout[C.id]={x:Math.round(t.x),y:Math.round(t.y)}))});n&&V(n);return}case`bend`:{let{from:e,to:t}=ua(C.key);C.value!==C.origin&&B(`PUT`,`/edges`,{from:e,to:t,bend:C.value}).then(z);return}case`label`:{let{from:n,to:r}=ua(C.key);if(Math.abs(e.clientX-C.startX)>3||Math.abs(e.clientY-C.startY)>3)B(`PUT`,`/edges`,{from:n,to:r,label_at:C.t}).then(z);else{let e=t?.page?.edges.find(e=>e.from===n&&e.to===r);D({kind:`edge`,id:C.key,field:`label`,value:e?.label??``})}return}case`pin`:{let e=He?.at;if(Ue(null),C.moved&&e){let t=_t(e);B(`PUT`,`/comments/${encodeURIComponent(C.id)}`,t?{node:t.id,x:Math.round(e.x-(v[t.id]?.x??0)),y:Math.round(e.y-(v[t.id]?.y??0))}:{node:null,x:Math.round(e.x),y:Math.round(e.y)}).then(z)}else k(e=>e===C.id?null:C.id),ie(null);return}}},xn=e=>{if(R!==`select`)return;let t=e.target;if(t.closest(`.cv__toolbar, .cv__top, .cv__pages, .cv__zoom, .cv__panel, .cv__pop, .cv__selbar, .cv__menu, .cv__edit, .thread, .pin, [data-bend], [data-endpoint]`)||t.closest(`[data-node]`))return;let n=t.closest(`[data-edge]`);if(n){let t=n.dataset.edge??``,{from:r,to:i}=ua(t),a=On?.edges.find(e=>e.from===r&&e.to===i),o=K(r),s=K(i),c=mt(e.clientX,e.clientY),l=a&&o&&s?Qi(Ji(o,s,{bend:a.bend,from:a.from_anchor,to:a.to_anchor}).points,c):void 0;Y([t]),D({kind:`edge`,id:t,field:`label`,value:a?.label??``,...l===void 0?{}:{t:l}});return}let r=t.closest(`[data-frame]`);if(r){let e=G.get(r.dataset.frame??``);e&&!e.frame.locked&&D({kind:`frame`,id:e.frame.id,field:`label`,value:e.frame.title})}},Sn=(e,t,n)=>{if(ye.contextMenu)return Cn(e,t,n);let r=_t(n),i=r?null:vt(n),a=r?$(r.id):i?ia(i.id):null;a&&(g.has(a)||Y([a]),on(a))},Cn=(e,t,n)=>{let r=We.current?.getBoundingClientRect()??{left:0,top:0},i={x:e-r.left,y:t-r.top},a=_t(n),o=a?null:vt(n),s=[];if(a){g.has($(a.id))||Y([$(a.id)]);let e=J.length>1&&g.has($(a.id));e||s.push({label:`Details…`,hint:`⏎`,onSelect:()=>on($(a.id))}),a.kind===`blueprint`&&a.path&&s.push({label:`Open blueprint`,onSelect:()=>nn(a.path??``)}),s.push({label:`Copy`,hint:`⌘C`,onSelect:()=>zt()}),s.push({label:`Attach comment`,onSelect:()=>ie({x:n.x,y:n.y,node:a.id,offset:{x:n.x-(v[a.id]?.x??0),y:n.y-(v[a.id]?.y??0)}})}),s.push({label:`Wrap in a frame`,hint:`F`,onSelect:()=>Jt(e?J:[a.id])}),s.push({label:`Duplicate`,hint:`⌘D`,disabled:a.kind===`blueprint`&&!e,onSelect:()=>Rt()}),s.push({label:`Copy style`,hint:`⌥⌘C`,onSelect:()=>Z()}),s.push({label:`Paste style`,hint:`⌥⌘V`,disabled:Ka===null,onSelect:()=>Wt()}),s.push({label:a.locked?`Unlock`:`Lock`,hint:`L`,onSelect:()=>Gt(!a.locked)}),s.push({separator:!0,label:``}),s.push({label:a.kind===`blueprint`?`Remove from canvas`:`Delete`,hint:`⌫`,danger:!0,onSelect:()=>It()})}else o?(g.has(ia(o.id))||Y([ia(o.id)]),s.push({label:`Details…`,hint:`⏎`,onSelect:()=>on(ia(o.id))}),s.push({label:`Rename`,onSelect:()=>D({kind:`frame`,id:o.id,field:`label`,value:o.title})}),s.push({label:`Select attached`,onSelect:()=>Y(yt(o.id).map($))}),s.push({label:o.locked?`Unlock`:`Lock`,hint:`L`,onSelect:()=>Gt(!o.locked)}),s.push({separator:!0,label:``}),s.push({label:`Delete Frame Only`,danger:!0,onSelect:()=>Lt(o.id,!1)}),s.push({label:`Delete Frame & Contents`,danger:!0,disabled:yt(o.id).length===0,onSelect:()=>Lt(o.id,!0)})):(s.push({label:`Insert sketch`,hint:`R`,onSelect:()=>Yt({sketch:{label:``}},{x:n.x-110,y:n.y-56},`sketch`)}),s.push({label:`Insert sticky`,hint:`S`,onSelect:()=>Yt({sticky:{text:``,color:`yellow`}},{x:n.x-88,y:n.y-88},`sticky`)}),s.push({label:`Insert text`,hint:`T`,onSelect:()=>Yt({text:{text:`Text`}},{x:n.x,y:n.y-16},`text`)}),s.push({label:`Insert blueprint…`,hint:`B`,onSelect:()=>de({x:Q(n.x-110),y:Q(n.y-56)})}),s.push({label:`Insert comment`,onSelect:()=>ie({x:n.x,y:n.y,node:null,offset:{x:0,y:0}})}),s.push({separator:!0,label:``}),s.push({label:`Paste here`,hint:`⌘V`,disabled:Ga===null,onSelect:()=>Bt(n)}),s.push({label:`Select all`,hint:`⌘A`,onSelect:()=>Y(H.filter(e=>!e.locked).map(e=>$(e.id)))}),s.push({label:`Fit to view`,hint:`⇧1`,onSelect:()=>void Ct()}));pe({at:i,items:s})},wn=I(()=>{let e=new Set([...Me.current,...Ne.current]),t=+!!e.has(`ArrowRight`)-!!e.has(`ArrowLeft`),n=+!!e.has(`ArrowDown`)-!!e.has(`ArrowUp`),r=Math.hypot(t,n)||1;return{x:t/r,y:n/r}},[]),Tn=I(()=>{let[e]=[...g];if(!e)return null;let t=oa(e)?K(la(e)):sa(e)?G.get(la(e))?.rect??null:null;return t?Pi(t):null},[g,K,G]),En=I(e=>{let[n]=[...g],r=Tn();if(!n||!r||Me.current.size===0&&Ne.current.size===0)return;let i=wn();Ne.current.clear();let a=[];if(e&&oa(n)){let e=la(n);for(let n of t?.page?.edges??[]){let t=n.from===e?n.to:n.to===e?n.from:null;if(!t)continue;let r=K(t);r&&a.push({key:yi(t)?ia(bi(t)):$(t),rect:r})}}else{for(let e of H)$(e.id)!==n&&a.push({key:$(e.id),rect:W(e)});for(let e of ft)ia(e.frame.id)!==n&&a.push({key:ia(e.frame.id),rect:e.rect})}let s=null;for(let t of a){if(!e&&Ni(t.rect,r))continue;let n=Pi(t.rect),a=n.x-r.x,o=n.y-r.y,c=Math.hypot(a,o);if(c===0)continue;let l=(a*i.x+o*i.y)/c;if(l<(e?0:Ja)||!e&&c>qa)continue;let u=c*(2-l);(!s||u<s.score)&&(s={key:t.key,score:u})}if(!s)return;Y([s.key]);let c=sa(s.key)?G.get(la(s.key))?.rect:K(la(s.key)),l=We.current?.getBoundingClientRect();if(c&&l){let e=gt({x:c.x,y:c.y}),t=gt({x:c.x+c.w,y:c.y+c.h});if(e.x<0||e.y<0||t.x>l.width||t.y>l.height){let e=Pi(c);o(t=>({...t,x:l.width/2-e.x*t.scale,y:l.height/2-e.y*t.scale}))}}},[g,Tn,wn,t,K,H,ft,W,Y,G,gt]);P(()=>{let t=t=>{let n=t.target.closest(`input, textarea, select, [contenteditable]`),r=t.metaKey||t.ctrlKey;if(n){t.key===`Escape`&&t.target.blur();return}if(e.open)return;if(t.key===` `&&!t.repeat){t.preventDefault(),h(!0);return}if(t.key===`Escape`){fe||me||j||xe?(pe(null),he(!1),ve(!1),Se(!1)):Ce?we(null):re?ie(null):O?k(null):ue?de(null):ge?_e(!1):L?(ze(null),ke.current&&(Zt(),jt(`select`))):l?(u(null),jt(`select`)):s===`select`?At():jt(`select`);return}if(r&&t.key.toLowerCase()===`z`){t.preventDefault(),t.shiftKey?ot():at();return}if(r&&t.key.toLowerCase()===`a`){t.preventDefault(),Y(H.filter(e=>!e.locked).map(e=>$(e.id)));return}if(r&&t.key.toLowerCase()===`d`){t.preventDefault(),Rt();return}if(r&&t.altKey&&(t.key.toLowerCase()===`c`||t.code===`KeyC`)){if(J.length===0)return;t.preventDefault(),Z();return}if(r&&t.altKey&&(t.key.toLowerCase()===`v`||t.code===`KeyV`)){if(!Ka||J.length===0)return;t.preventDefault(),Wt();return}if(r&&t.key.toLowerCase()===`c`){if(J.length===0)return;t.preventDefault(),zt();return}if(r&&t.key.toLowerCase()===`v`){if(!Ga)return;t.preventDefault(),Bt();return}if(r&&t.shiftKey&&t.key.toLowerCase()===`l`){t.preventDefault(),Gt(!Kt);return}if(r&&t.key===`0`){t.preventDefault(),Tt(1);return}if(r)return;if(t.key===`Delete`||t.key===`Backspace`){t.preventDefault(),It();return}if(t.key.startsWith(`Arrow`)){if(t.preventDefault(),t.altKey||g.size!==1){let e=t.shiftKey?10:1;qt(t.key===`ArrowLeft`?-e:t.key===`ArrowRight`?e:0,t.key===`ArrowUp`?-e:t.key===`ArrowDown`?e:0);return}if(t.repeat&&Me.current.has(t.key))return;if(Me.current.add(t.key),Fe.current){let e=Tn();e&&Re({from:e,dir:wn()});return}Ne.current.add(t.key),Pe.current=t.shiftKey;let e=t.shiftKey;Ie.current===null&&!e&&(Ie.current=window.setTimeout(()=>{Ie.current=null;let e=Tn();e&&Me.current.size>0&&(Fe.current=!0,Ne.current.clear(),Re({from:e,dir:wn()}))},450));return}if(t.key.toLowerCase()===`l`&&!t.shiftKey&&g.size>0){Gt(!Kt);return}if(t.key===`?`){_e(e=>!e);return}if(t.key===`+`||t.key===`=`)return void wt(1.2);if(t.key===`-`)return void wt(1/1.2);if(t.shiftKey){let e=t.key.toLowerCase();if(t.key===`!`||e===`1`)return void Ct();if(t.key===`@`||e===`2`){let e=[...J.map(e=>U.get(e)).filter(e=>e!==void 0).map(W),...Ot.map(e=>G.get(e)?.rect).filter(e=>e!==void 0)];St(Ii(e),80);return}if(t.key===`)`||e===`0`)return void Tt(1);if(e===`c`||t.code===`KeyC`)return void le(e=>!e);if(t.key===`Enter`){g.size>0&&(we(null),p(!0));return}return}let i={v:`select`,h:`hand`,r:`sketch`,s:`sticky`,t:`text`,a:`annotation`,b:`blueprint`,f:`frame`,x:`connect`,c:`comment`}[t.key.toLowerCase()];if(i){if(t.repeat)return;let e=performance.now(),n=d.current?.tool===i&&e-d.current.at<400;d.current={tool:i,at:e},n?Mt(i):i===`frame`&&J.length>0&&s===`select`?Jt(J):jt(i);return}if(t.key===`Enter`&&g.size===1){let[e]=[...g];e&&on(e)}},n=e=>{e.key===` `&&h(!1),e.key.startsWith(`Arrow`)&&(Me.current.delete(e.key),Me.current.size===0&&(Ie.current!==null&&window.clearTimeout(Ie.current),Ie.current=null,Fe.current=!1,Re(null),Ne.current.size>0&&En(Pe.current)))};return window.addEventListener(`keydown`,t),window.addEventListener(`keyup`,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`keyup`,n)}},[e.open,fe,me,j,xe,Ce,re,O,ue,ge,L,s,l,jt,At,ot,at,Y,g,H,Rt,zt,Bt,Z,Wt,Gt,Kt,Tt,It,qt,wt,Ct,J,Ot,U,G,W,St,Jt,on,Zt,En,Tn,wn,Mt]);let Dn=I((e,t)=>{if(!t||U.get(e)?.box||C?.kind===`nodesize`)return;let n={w:t.offsetWidth,h:t.offsetHeight};te(t=>t[e]?.w===n.w&&t[e]?.h===n.h?t:{...t,[e]:n})},[U,C]);if(r)return q(`div`,{className:`page empty`,children:r});if(!t)return q(`div`,{className:`page empty`,children:`Loading…`});let On=t.page;if(!On)return q(`div`,{className:`page empty`,children:`This canvas has no page yet.`});let kn=C?.kind===`marquee`?Fi(C.start,C.current):null,An=C?.kind===`draw`?Fi(C.start,C.current):null,jn=t.comments.filter(e=>A&&(!oe||!e.resolved||O===e.id)),Mn=e.settings.shared.users,Nn=O?t.comments.find(e=>e.id===O):null,Pn=t.palette.find(e=>e.color)?.color??null,Fn=g.size===1,In=Fn&&Ot[0]?G.get(Ot[0]):void 0,Ln=e=>{let t=We.current?.getBoundingClientRect()??{width:800,height:600},n=gt({x:e.x+e.w,y:e.y}),r=gt({x:e.x,y:e.y});return{x:ro(n.x+14+eo<=t.width?n.x+14:Math.max(8,r.x-eo-14),8,Math.max(8,t.width-eo-8)),y:ro(n.y,8,Math.max(8,t.height-no-8))}},Rn=e=>{let t=We.current?.getBoundingClientRect()??{width:800,height:600},n=gt({x:e.x,y:e.y}),r=gt({x:e.x,y:e.y+e.h});return{x:ro(n.x,8,Math.max(8,t.width-to-8)),y:r.y+14}},zn=Ce&&oa(Ce)?U.get(la(Ce)):void 0,Bn=Ce&&sa(Ce)?G.get(la(Ce)):void 0,Vn=Ce&&ca(Ce)?On.edges.find(e=>aa(e)===Ce):void 0,Hn=Te??(In?In.frame.id:null),Un=Hn?G.get(Hn)?.rect??null:null,Wn=e=>e.node&&v[e.node]?{x:v[e.node].x+e.x,y:v[e.node].y+e.y}:e.at,Gn={faint:Qa(`--text-faint`,`#6f7680`),accent:Qa(`--accent`,`#e08a63`),text:Qa(`--text`,`#191b1f`)},Kn=g.size>1?Ii([...J.map(e=>U.get(e)).filter(e=>e!==void 0).map(W),...Ot.map(e=>G.get(e)?.rect).filter(e=>e!==void 0)]):null,qn=Kn??(J[0]&&U.get(J[0])?W(U.get(J[0])):Ot[0]?G.get(Ot[0])?.rect??null:null),Jn=(e,t,n)=>{let r=We.current?.getBoundingClientRect()??{width:800,height:600};return{x:ro(e.x,8,Math.max(8,r.width-t-8)),y:ro(e.y,8,Math.max(8,r.height-n-8))}},Yn=E?E.kind===`frame`?G.get(E.id)?.rect??null:U.get(E.id)?W(U.get(E.id)):null:null,Xn=(()=>{if(!Yn||!E||E.kind!==`sketch`&&E.kind!==`blueprint`)return null;let e=Ge.current?.querySelector(`[data-node="${E.id}"]`),t=e?.querySelector(`[data-field="${E.field}"]`),n=Ge.current?.getBoundingClientRect();if(!e||!t||!n)return E.field===`label`?{x:Yn.x+9,y:Yn.y+6,w:Yn.w-18,h:26}:{x:Yn.x+9,y:Yn.y+30,w:Yn.w-18,h:Yn.h-60};let r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),o=(e,t)=>(e-(t===`x`?n.left:n.top))/a.scale,s=o(i.left,`x`),c=o(i.top,`y`),l=i.width/a.scale,u=o(r.bottom,`y`)-(U.get(E.id)?.shown.length?28:10);return{x:s,y:c,w:Math.max(l,60),h:E.field===`label`?Math.max(24,i.height/a.scale):Math.max(40,u-c)}})(),Zn=Fn?On.edges.find(e=>g.has(aa(e))):void 0,Qn=(()=>{if(g.size===0||E||C)return null;let e=Ii([...J.map(e=>U.get(e)).filter(e=>e!==void 0).map(W),...Ot.map(e=>G.get(e)?.rect).filter(e=>e!==void 0)]);if(!e&&Zn&&K(Zn.from)&&K(Zn.to)){let t=Ji(K(Zn.from),K(Zn.to),{bend:Zn.bend,from:Zn.from_anchor,to:Zn.to_anchor});e={x:t.label.x,y:t.label.y-10,w:0,h:0}}if(!e)return null;let t=gt({x:e.x+e.w/2,y:e.y});return{x:t.x,y:t.y-12}})(),$n=Qn!==null&&Qn.y-44>=260,er=Fn&&J[0]?U.get(J[0]):void 0,tr=io[R],nr=ue??(tr&&T&&!L?{x:Q(T.x-tr.w/2),y:Q(T.y-tr.h/2)}:null),rr=e=>`sticky-${e.style.color??`yellow`}`,ir=e=>`text-${e.style.size}`,ar=We.current?.getBoundingClientRect(),or=Qn&&f?q(Ma,{anchored:$n,at:$n?{x:0,y:-8}:qn?Rn(qn):{x:Qn.x-to/2,y:Qn.y+40},nodes:J.map(e=>U.get(e)).filter(e=>e!==void 0),resizable:J.every(e=>{let t=U.get(e);return t!==void 0&&pn(t)}),frame:In?.frame,edge:Zn,onNodeStyle:Vt,onTextSize:e=>{let t=X(t=>{for(let n of t.nodes)!n.text||!J.includes(n.id)||(e.size!==void 0&&(n.text.size=e.size),e.font===null?delete n.text.font:typeof e.font==`number`&&e.font>=8&&e.font<=64&&(n.text.font=Math.round(e.font)))});t&&V(t)},onBox:e=>{let t=X(t=>{for(let n of t.nodes)J.includes(n.id)&&(e?n.box={w:Math.max(40,Math.round(e.w)),h:Math.max(24,Math.round(e.h))}:delete n.box)});t&&V(t)},onStickyColor:Ht,onAnnotationColor:e=>{let t=X(t=>{for(let n of t.nodes)!n.annotation||!J.includes(n.id)||(e?n.annotation.color=e:delete n.annotation.color)});t&&V(t)},onFrameColor:e=>In&&void B(`PUT`,`/frames/${encodeURIComponent(In.frame.id)}`,{color:e}).then(z),onEdge:e=>Zn&&void B(`PUT`,`/edges`,{from:Zn.from,to:Zn.to,...e}).then(z),onReset:()=>Zn?void B(`PUT`,`/edges`,{from:Zn.from,to:Zn.to,color:null,style:null,start:null,end:null,label_at:null}).then(z):Ut(),onCopyStyle:Z,onPasteStyle:Wt,canPaste:Ka!==null,onClose:()=>p(!1)}):null;return q(`div`,{ref:We,className:`cv${C?.kind===`pan`&&C.moved?` panning`:``}${C?` dragging`:``}`,"data-tool":R,onWheel:dn,onPointerDown:vn,onPointerMove:yn,onPointerUp:bn,onPointerCancel:()=>{C?.kind===`move`&&(y(e=>({...e,...C.origins})),b(e=>({...e,...C.frameOrigins}))),De(null),Ue(null),w(null)},onPointerLeave:()=>ne(null),onDoubleClick:xn,onContextMenu:e=>e.preventDefault(),children:[q(`div`,{ref:Ge,className:`cv__world`,style:{transform:`translate(${a.x}px, ${a.y}px) scale(${a.scale})`},children:[ft.map(({frame:e,rect:t})=>q(`div`,{className:`frame${e.color?` frame-${e.color}`:``}${g.has(ia(e.id))?` selected`:``}${e.locked?` locked`:``}${Te===e.id&&!C?` hover`:``}${M?.kind===`frame`&&M.id===e.id?` drop`:``}${M?.kind===`frame-border`&&M.id===e.id?` drop-border`:``}`,"data-frame":e.id,style:{left:t.x,top:t.y,width:t.w,height:t.h},children:[q(`span`,{className:`frame__title${g.has(ia(e.id))&&!e.locked?` hot`:``}`,"data-field":`label`,children:[e.title,e.locked&&q(`span`,{className:`lock`,"data-lock":e.id,"data-lock-kind":`frame`,title:`Locked; click to unlock`,children:q(fn,{})})]}),[`nw`,`ne`,`sw`,`se`,`n`,`e`,`s`,`w`].map(e=>q(`i`,{className:`frame__grip ${e}`,"data-grip":e},e)),Ri.map(t=>q(`span`,{className:`frame__handle frame__handle--${t}`,"data-handle":`${vi}${e.id}`,"data-anchor":t},t))]},e.id)),q(`svg`,{className:`cv__svg`,width:`1`,height:`1`,children:[Le&&(()=>{let e=Math.atan2(Le.dir.y,Le.dir.x),t=e-50*Math.PI/180,n=e+50*Math.PI/180,r=Le.from;return q(`path`,{className:`navrange`,d:`M${r.x},${r.y} L${r.x+Math.cos(t)*qa},${r.y+Math.sin(t)*qa} A${qa},${qa} 0 0 1 ${r.x+Math.cos(n)*qa},${r.y+Math.sin(n)*qa} Z`})})(),On.edges.map(e=>{let t=K(e.from),n=K(e.to);if(!t||!n)return null;let r=aa(e),i=C?.kind===`bend`&&C.key===r?C.value:e.bend,a=g.has(r);if(C?.kind===`endpoint`&&C.key===r){let i=C.end===`from`?n:t,a={x:C.point.x,y:C.point.y,w:1,h:1};return q(`path`,{className:`temp`,d:(C.end===`from`?Ji(a,i,{to:e.to_anchor}):Ji(i,a,{from:e.from_anchor})).d,fill:`none`},r)}let o=Ji(t,n,{bend:i,from:e.from_anchor,to:e.to_anchor}),s=U.get(e.from),c=s?.kind===`annotation`,l=c?s?.style.color??Gn.text:e.color??(a?Gn.accent:Gn.faint),u=a?2.2:1.6,d=c?`none`:e.start??`none`,f=c?`arrow`:e.end??`triangle`,p=[na(o.start,ra(o.points,`start`),d),na(o.end,ra(o.points,`end`),f)],m=C?.kind===`label`&&C.key===r?C.t:e.label_at??.5,h=Zi(o.points,m),_=E?.kind===`edge`&&E.id===r;return q(`g`,{"data-edge-group":r,children:[q(`path`,{className:`hit`,d:o.d,"data-edge":r,fill:`none`}),q(`path`,{className:`edge${a?` selected`:``}`,d:Yi(o.points,ta(d),ta(f)),fill:`none`,style:{fill:`none`,stroke:l,strokeWidth:u,strokeDasharray:!c&&e.style===`dashed`?`7 5`:void 0}}),p.map((e,t)=>e&&q(`path`,{className:`cap`,d:e.d,fill:e.filled?l:`none`,style:{fill:e.filled?l:`none`,stroke:l,strokeWidth:u,strokeLinejoin:`round`,strokeLinecap:`round`}},t)),e.label&&!_&&q(S,{children:[q(`rect`,{className:`labelhit`,x:h.x-Math.max(30,e.label.length*3.6),y:h.y-22,width:Math.max(60,e.label.length*7.2),height:28,"data-edge-label":r,"data-t":m}),q(`text`,{x:h.x,y:h.y-8,textAnchor:`middle`,style:e.color?{fill:e.color}:void 0,children:e.label})]}),a&&o.handle&&o.mid!==null&&q(`circle`,{className:`bend`,cx:o.handle.x,cy:o.handle.y,r:5,"data-bend":r,"data-axis":o.axis??`x`,"data-mid":o.mid,onDoubleClick:()=>void B(`PUT`,`/edges`,{from:e.from,to:e.to,bend:null}).then(z)}),a&&q(`circle`,{className:`endpoint`,cx:o.start.x,cy:o.start.y,r:5,"data-endpoint":`from`,"data-edge":r}),a&&q(`circle`,{className:`endpoint`,cx:o.end.x,cy:o.end.y,r:5,"data-endpoint":`to`,"data-edge":r})]},r)}),C?.kind===`connect`&&K(C.from)&&(()=>{let e=M?.kind===`node`?K(M.id):M?.kind===`frame-border`?G.get(M.id)?.rect??null:null,t=e&&(M?.kind===`node`||M?.kind===`frame-border`)?zi(e,M.anchor):C.point;return q(`path`,{className:`temp`,fill:`none`,d:Ji(K(C.from),{x:t.x,y:t.y,w:1,h:1},{from:C.anchor??void 0,to:M?.kind===`node`||M?.kind===`frame-border`?M.anchor:void 0}).d})})(),L&&!C&&T&&K(L.id)&&(()=>{let e=M?.kind===`node`?K(M.id):M?.kind===`frame-border`?G.get(M.id)?.rect??null:null,t=e&&(M?.kind===`node`||M?.kind===`frame-border`)?zi(e,M.anchor):T;return q(`path`,{className:`temp`,fill:`none`,d:Ji(K(L.id),{x:t.x,y:t.y,w:1,h:1},{from:L.anchor??void 0,to:M?.kind===`node`||M?.kind===`frame-border`?M.anchor:void 0}).d})})(),M?.kind===`node`&&U.get(M.id)&&(()=>{let e=W(U.get(M.id)),t=zi(e,M.anchor);return q(`g`,{className:`snap`,children:[q(`rect`,{className:`group-box`,x:e.x-3,y:e.y-3,width:e.w+6,height:e.h+6,rx:8}),q(`circle`,{className:`snap`,cx:t.x,cy:t.y,r:7})]})})(),L&&U.get(L.id)&&(()=>{let e=W(U.get(L.id));return q(`rect`,{className:`group-box`,x:e.x-4,y:e.y-4,width:e.w+8,height:e.h+8,rx:8})})(),kn&&q(`rect`,{className:`marquee`,x:kn.x,y:kn.y,width:kn.w,height:kn.h}),An&&q(`rect`,{className:`drawing`,x:An.x,y:An.y,width:An.w,height:An.h,rx:12}),Kn&&q(`rect`,{className:`group-box`,x:Kn.x-6,y:Kn.y-6,width:Kn.w+12,height:Kn.h+12,rx:8})]}),H.map(t=>{let n=v[t.id]??t.position,r=g.has($(t.id)),i=E?.id===t.id&&E.kind!==`frame`&&(t.kind===`sticky`||t.kind===`text`||t.kind===`annotation`),a=E?.id===t.id?E.field:null,o=Hn!==null&&t.frame===Hn&&!(Un&&Ni(Un,Pi(W(t)))),s=r&&!t.locked&&R===`select`,c=Ri.map(e=>q(`span`,{className:`node__handle node__handle--${e}`,"data-handle":t.id,"data-anchor":e},e)),l=r&&!t.locked&&R===`select`&&pn(t)?[`nw`,`ne`,`sw`,`se`].map(e=>q(`i`,{className:`node__grip ${e}`,"data-node-grip":t.id,"data-corner":e},e)):null,u=t.box!==null||C?.kind===`nodesize`&&C.id===t.id,d=u?Oi(t,x):null,f=t.locked&&q(`span`,{className:`node__lock`,"data-lock":t.id,title:`Locked; click to unlock`,children:q(fn,{})}),p=q(`span`,{className:`node__more`,"data-details":t.id,title:`Details ⏎`,children:q(rn,{})});if(t.kind===`text`)return q(`div`,{ref:e=>Dn(t.id,e),"data-node":t.id,"data-field":`label`,className:`text-el ${ir(t)}${r?` selected`:``}${t.locked?` locked`:``}${o?` attached`:``}${s?` hot`:``}${u?` boxed`:``}`,style:{left:n.x,top:n.y,visibility:i?`hidden`:`visible`,...t.style.color?{color:t.style.color}:{},...t.font?{fontSize:t.font}:{},...d?{width:d.w,height:d.h}:{}},children:[q(`div`,{className:`text-el__body`,children:t.label||q(`span`,{style:{opacity:.45},children:`Text`})}),c,l]},t.id);if(t.kind===`annotation`)return q(`div`,{ref:e=>Dn(t.id,e),"data-node":t.id,"data-field":`label`,className:`node annotation${r?` selected`:``}${t.locked?` locked`:``}${o?` attached`:``}${s?` hot`:``}${ke.current===t.id?` pending`:``}${t.style.color&&Ya(t.style.color)>.6?` ink-dark`:``}${u?` boxed`:``}`,style:{left:n.x,top:n.y,visibility:i?`hidden`:`visible`,...t.style.color?{"--ann":t.style.color}:{},...d?{width:d.w,height:d.h}:{}},children:[f,p,q(`div`,{className:`node__lbl`,children:t.label||q(`span`,{style:{opacity:.55},children:ke.current===t.id?`Now click what this points at`:`Annotation`})}),c,l]},t.id);if(t.kind===`sticky`){let e=Oi(t,x);return q(`div`,{"data-node":t.id,"data-field":`label`,className:`node sticky ${rr(t)}${r?` selected`:``}${t.locked?` locked`:``}${o?` attached`:``}${s?` hot`:``}${u?` boxed`:``}`,style:{left:n.x,top:n.y,width:e.w,height:e.h,visibility:i?`hidden`:`visible`},children:[f,p,q(`div`,{className:`node__lbl`,children:t.label||q(`span`,{style:{opacity:.45},children:`Note`})}),c,l]},t.id)}return q(`div`,{"data-node":t.id,className:`node ${t.style.shape} size-${t.style.size} fill-${t.style.fill}${t.style.color?` highlighted`:``}${t.style.fill===`solid`&&t.style.fill_color?` ink-${Za(t.style.fill_color)}`:``}${r?` selected`:``}${t.missing?` missing`:``}${t.kind===`sketch`?` sketch`:``}${t.locked?` locked`:``}${o?` attached`:``}${s?` hot`:``}${u?` boxed`:``}`,style:{left:n.x,top:n.y,...t.style.color?{"--node-color":t.style.color,borderColor:t.style.color}:{},...t.style.fill_color?{"--node-fill":t.style.fill_color}:{},...d?{width:d.w,height:d.h}:{}},children:[t.style.color&&q(`i`,{className:`node__bar`}),f,t.kind===`blueprint`&&t.path&&q(`span`,{className:`node__open`,"data-open":t.path,title:`Open the blueprint`,children:q(tn,{})}),p,q(`div`,{className:`node__lbl`,"data-field":`label`,title:t.label,style:a===`label`?{visibility:`hidden`}:void 0,children:[q(`span`,{className:`node__kind`,title:t.kind===`blueprint`?`Blueprint`:`Sketch`,children:t.kind===`blueprint`?q(ln,{}):q(un,{})}),t.link?q(`a`,{href:t.link.canvas?bt(t.link.canvas):bt(e.id,t.link.page),onPointerDown:e=>e.stopPropagation(),onClick:n=>{n.preventDefault(),ht(t.link?.canvas?bt(t.link.canvas):bt(e.id,t.link?.page))},children:[t.label,` ↗`]}):t.label||q(`span`,{className:`node__ph`,children:`Untitled`})]}),q(`div`,{className:`node__sum`,"data-field":`summary`,title:t.summary??void 0,style:a===`summary`?{visibility:`hidden`}:void 0,children:t.summary??(s?q(`span`,{className:`node__ph`,children:t.kind===`blueprint`?`no summary yet`:`Description`}):``)}),t.shown.length>0&&q(`div`,{className:`node__tags`,children:t.shown.map(e=>q(`span`,{children:e.value},e.property))}),c,l]},t.id)}),tr&&nr&&q(`div`,{className:`ghost${R===`sticky`?` ghost--sticky`:R===`text`?` ghost--text`:``}`,style:{left:nr.x,top:nr.y,width:tr.w,height:tr.h},children:q(`span`,{children:ue?`Pick the blueprint…`:tr.label})}),E?.kind===`edge`&&(()=>{let{from:e,to:t}=ua(E.id),n=On.edges.find(n=>n.from===e&&n.to===t),r=K(e),i=K(t);if(!n||!r||!i)return null;let a=Zi(Ji(r,i,{bend:n.bend,from:n.from_anchor,to:n.to_anchor}).points,E.t??n.label_at??.5);return q(`div`,{className:`cv__edit edge`,style:{left:a.x-70,top:a.y-22,width:140},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:q(`input`,{ref:gn,value:E.value,placeholder:`label`,style:{width:`100%`},onChange:e=>D({...E,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?$t():e.key===`Escape`&&D(null)},onBlur:$t,onFocus:e=>e.target.select()})})})(),E&&E.kind!==`edge`&&Yn&&q(`div`,{className:`cv__edit ${E.kind}${E.kind===`sticky`?` ${rr(U.get(E.id))}`:E.kind===`text`?` ${ir(U.get(E.id))}`:``}${Xn?` field field-${E.field}`:``}`,style:E.kind===`frame`?{left:Yn.x+10,top:Yn.y-13}:E.kind===`text`?{left:Yn.x,top:Yn.y,width:Math.max(200,Yn.w+20),height:Math.max(40,Yn.h+8)}:Xn?{left:Xn.x,top:Xn.y,width:Xn.w,height:Xn.h}:{left:Yn.x,top:Yn.y,width:Yn.w,height:Yn.h},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:E.kind===`frame`?q(`input`,{ref:gn,value:E.value,onChange:e=>D({...E,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?$t():e.key===`Escape`&&D(null)},onBlur:$t,onFocus:e=>e.target.select()}):q(`textarea`,{ref:gn,value:E.value,onChange:e=>D({...E,value:e.target.value}),onKeyDown:e=>{if(e.key!==`Enter`){e.key===`Escape`&&D(null);return}(E.field===`label`&&(E.kind===`sketch`||E.kind===`blueprint`)||e.metaKey||e.ctrlKey||ye.enterCommits&&!e.shiftKey)&&(e.preventDefault(),$t())},onBlur:$t,onFocus:e=>e.target.select()})})]}),M?.kind===`frame`&&C?.kind===`connect`&&(()=>{let e=gt(C.point);return q(`div`,{className:`cv__droplabel`,style:{left:e.x,top:e.y},children:[`Attach to `,G.get(M.id)?.frame.title??M.id]})})(),!$n&&or,Qn&&q(ja,{at:Qn,nodes:J.map(e=>U.get(e)).filter(e=>e!==void 0),frame:In?.frame,edge:Zn,count:g.size,locked:Kt,styleOpen:f,onToggleStyle:()=>(we(null),p(e=>!e)),onLock:Gt,onComment:()=>{if(!er)return;let e=W(er);k(null),ie({x:e.x+e.w,y:e.y,node:er.id,offset:{x:e.w,y:0}})},onDetails:()=>{let[e]=[...g];e&&on(e)},onOpen:er?.kind===`blueprint`&&er.path?()=>nn(er.path??``):void 0,onWrap:()=>Jt(J),onDuplicate:Rt,onDelete:It,children:$n?or:null}),q(`div`,{className:`cv__overlay`,style:{position:`absolute`,inset:0,pointerEvents:`none`},children:jn.map((e,t)=>{let n=He?.id===e.id?He.at:Wn(e),r=gt(n);return q(`div`,{style:{position:`absolute`,left:r.x,top:r.y,pointerEvents:`auto`},children:q(Va,{comment:{...e,at:{x:0,y:0}},index:t+1,open:O===e.id,onOpen:()=>void 0,onPointerDown:()=>void 0})},e.id)})}),Nn&&(()=>{let e=Jn({x:gt(Wn(Nn)).x+18,y:gt(Wn(Nn)).y-8},360,320);return q(Ua,{comment:Nn,at:e,author:t.author,users:Mn,onReply:e=>void B(`POST`,`/comments/${encodeURIComponent(Nn.id)}/replies`,{text:e}).then(z),onResolve:e=>void B(`PUT`,`/comments/${encodeURIComponent(Nn.id)}`,{resolved:e}).then(t=>(z(t),e&&k(null))),onEditMessage:(e,t)=>void B(`PUT`,`/comments/${encodeURIComponent(Nn.id)}/messages/${e}`,{text:t}).then(z),onDeleteMessage:e=>void B(`DELETE`,`/comments/${encodeURIComponent(Nn.id)}/messages/${e}`).then(e=>{z(e),e&&!e.comments.some(e=>e.id===Nn.id)&&k(null)}),onDelete:()=>void B(`DELETE`,`/comments/${encodeURIComponent(Nn.id)}`).then(e=>(z(e),k(null))),onClose:()=>k(null)})})(),re&&(()=>{let e=Jn({x:gt(re).x+18,y:gt(re).y-8},300,120);return q(S,{children:[q(`div`,{className:`pin open`,style:{left:gt(re).x,top:gt(re).y,position:`absolute`},children:q(`span`,{children:`+`})}),q(Ha,{at:e,author:t.author,users:Mn,anchored:re.node!==null,onPost:e=>{let t=re.node?{text:e,node:re.node,x:Math.round(re.offset.x),y:Math.round(re.offset.y)}:{text:e,x:Math.round(re.x),y:Math.round(re.y)};B(`POST`,`/comments`,t).then(e=>{z(e),ie(null),ae(!0),e?.comment&&k(e.comment.id),Nt(`comment`,!1)})},onCancel:()=>(ie(null),Nt(`comment`,!1))})]})})(),q(ci,{canvasTitle:t.canvas.title,pages:t.canvas.pages,current:On.id,onPage:t=>ht(bt(e.id,t)),onRenamePage:(t,n)=>void Je(()=>ut(`/api/canvas/${encodeURIComponent(e.id)}/pages/${encodeURIComponent(t)}`,{title:n})).then(t=>t&&(nt(),e.onChanged())),onAddPage:()=>{let n=`Page ${t.canvas.pages.length+1}`;Je(()=>lt(`/api/canvas/${encodeURIComponent(e.id)}/pages`,{title:n})).then(t=>{t&&(e.onChanged(),ht(bt(e.id,t.pages[t.pages.length-1]?.id)))})},onDeletePage:n=>{let r=t.canvas.pages.find(e=>e.id===n);Xe.confirm({title:`Delete the page “${r?.title??n}”?`,body:`Everything on it goes with it. Undo does not reach across pages.`,confirm:`Delete page`,danger:!0}).then(t=>{t&&Je(()=>dt(`/api/canvas/${encodeURIComponent(e.id)}/pages/${encodeURIComponent(n)}`)).then(t=>t&&(e.onChanged(),ht(bt(e.id,n===On.id?void 0:On.id))))})},onRenameCanvas:t=>void Je(()=>ut(`/api/canvas/${encodeURIComponent(e.id)}`,{title:t})).then(t=>t&&(nt(),e.onChanged())),onDeleteCanvas:()=>void Xe.confirm({title:`Delete the canvas “${t.canvas.title}”?`,body:`The file under .eidos/plugins/eidosmd/maps/ is removed. The blueprints it pointed at stay.`,confirm:`Delete canvas`,danger:!0}).then(t=>{t&&Je(()=>dt(`/api/canvas/${encodeURIComponent(e.id)}`)).then(t=>t&&(e.onChanged(),ht(`/`)))})}),q(li,{canUndo:Ze.canUndo,canRedo:Ze.canRedo,onUndo:at,onRedo:ot,commentsOpen:t.comments.filter(e=>!e.resolved).length,showComments:ce,pinsHidden:!A,onToggleComments:()=>le(e=>!e),children:q(`button`,{className:me?`on`:``,onClick:()=>he(e=>!e),"data-tip":`Export`,"data-tip-pos":`bottom`,children:[q(oi,{tool:`export`}),`Export`]})}),me&&q(di,{anchor:`right`,at:{x:14,y:52},onClose:()=>he(!1),items:[{label:`Image of this page (PNG)`,icon:q(oi,{tool:`image`}),onSelect:()=>void sn(!1)},{label:`Image of the selection (PNG)`,icon:q(oi,{tool:`image`}),disabled:g.size===0,onSelect:()=>void sn(!0)},{label:`Vector of this page (SVG)`,onSelect:()=>void sn(!1,`svg`)},{label:`Vector of the selection (SVG)`,disabled:g.size===0,onSelect:()=>void sn(!0,`svg`)},{separator:!0,label:``},{label:`JSON Canvas (Obsidian)`,onSelect:()=>ao(`/api/canvas/${encodeURIComponent(e.id)}/export/${encodeURIComponent(On.id)}`,`${t.canvas.id}-${On.id}.canvas`)}]}),q(si,{tool:s,locked:l,temporary:m?`hand`:null,onTool:jt,onLock:Mt}),q(`div`,{className:`cv__br`,children:[q(ui,{scale:a.scale,onZoom:e=>wt(e),onFit:()=>void Ct(),onReset:()=>Tt(1)}),q(`button`,{className:`cv__help${j?` on`:``}`,onClick:()=>ve(e=>!e),"data-tip":`Canvas preferences`,"data-tip-pos":`top`,"aria-label":`Preferences`,children:q(en,{})}),q(hi,{onOpen:()=>_e(!0)})]}),Pn&&q(`div`,{className:`cv__corner`,children:q(_i,{entries:Object.entries(Pn),open:xe,onToggle:()=>Se(e=>!e)})}),j&&q(gi,{prefs:ye,onChange:rt,onClose:()=>ve(!1)}),L&&q(`div`,{className:`cv__hint`,children:ke.current?`Click the node or frame this annotation points at · Esc takes it back`:`Now click the node, or a frame's border, it flows to · Esc to stop`}),fe&&q(di,{at:fe.at,items:fe.items,onClose:()=>pe(null)}),ge&&q(mi,{tools:ai,onClose:()=>_e(!1)}),ce&&q(Wa,{comments:t.comments,users:Mn,hideResolved:oe,onToggleHide:()=>se(e=>!e),onOpen:e=>{let n=t.comments.find(t=>t.id===e);n&&ar&&(ae(!0),k(e),o(e=>({...e,x:ar.width/2-n.at.x*e.scale,y:ar.height/2-n.at.y*e.scale})))},onClose:()=>le(!1),pinsHidden:!A,onTogglePins:()=>ae(e=>!e)}),zn&&q(Ca,{at:Ln(W(zn)),node:zn,data:t,onUpdate:e=>void B(`PUT`,`/nodes/${encodeURIComponent(zn.id)}`,e).then(z),onPromote:e=>void B(`POST`,`/nodes/${encodeURIComponent(zn.id)}/promote`,e).then(z),onOpen:nn,onBlueprintSaved:()=>(nt(),e.onChanged()),onRemove:()=>(we(null),It()),onClose:()=>we(null)},zn.id),Bn&&q(Oa,{at:Ln(Bn.rect),frame:Bn.frame,members:H.filter(e=>e.frame===Bn.frame.id).length,onUpdate:e=>void B(`PUT`,`/frames/${encodeURIComponent(Bn.frame.id)}`,e).then(z),onSelectMembers:()=>(we(null),Y(H.filter(e=>e.frame===Bn.frame.id).map(e=>$(e.id)))),onRemove:e=>(we(null),Lt(Bn.frame.id,e)),onClose:()=>we(null)},Bn.frame.id),Vn&&K(Vn.from)&&K(Vn.to)&&(()=>{let e=Ji(K(Vn.from),K(Vn.to),{bend:Vn.bend,from:Vn.from_anchor,to:Vn.to_anchor});return q(Da,{at:Ln({x:e.label.x,y:e.label.y,w:0,h:0}),edge:Vn,from:yi(Vn.from)?G.get(bi(Vn.from))?.frame.title??Vn.from:U.get(Vn.from)?.label??Vn.from,to:yi(Vn.to)?G.get(bi(Vn.to))?.frame.title??Vn.to:U.get(Vn.to)?.label??Vn.to,onUpdate:e=>void B(`PUT`,`/edges`,{from:Vn.from,to:Vn.to,...e}).then(z),onRemove:()=>(we(null),It()),onClose:()=>we(null)})})(),ue&&q(Na,{onClose:()=>{de(null),Nt(`blueprint`,!1)},taken:new Set(H.map(e=>e.blueprint??``)),onPick:e=>{let t=ue;de(null),Nt(`blueprint`,!1),Yt({blueprint:e.id},t,null)}}),e.open&&q(ii,{path:e.open,tick:e.tick,layout:`modal`,onClose:()=>ht(bt(e.id,Qe)),onSaved:()=>(nt(),e.onChanged()),onOpenLink:nn})]})}var so=new Set([`title`]),co=``;function lo(e){return e==null?``:Array.isArray(e)?e.map(e=>lo(e)).join(`, `):typeof e==`string`?e.replace(/^\[([^\]]*)\]\([^)]*\)$/,`$1`):String(e)}function uo(e,t,n){if(n===`Number`)return(typeof e==`number`?e:NaN)-(typeof t==`number`?t:NaN)||0;let r=lo(e),i=lo(t);return r===``&&i!==``?1:i===``&&r!==``?-1:r.localeCompare(i,void 0,{numeric:!0,sensitivity:`base`})}function fo(e){let t=e.column.key===`__group`?e.row.group:e.row.properties[e.column.key];if(t==null||t===``)return q(`span`,{className:`faint`,children:`—`});if(Array.isArray(t))return q(S,{children:t.map((e,t)=>q(`span`,{className:`chip`,children:lo(e)},t))});if(typeof t==`boolean`)return q(`span`,{children:t?`✓`:`—`});let n=e.column.property?.canvas?.color,r=n&&typeof t==`string`?n[Object.keys(n).find(e=>e.toLowerCase()===t.toLowerCase())??``]:void 0;return q(`span`,{title:lo(t),children:[r&&q(`i`,{className:`value-swatch`,style:{background:r}}),lo(t)]})}function po(e){let[t,n]=N(!1),r=F({}),i=I(()=>n(!1),[]);Ht(r.current,i);let a=()=>{t||Vt(r.current),n(!t)},o=e.selected.size;return q(`div`,{className:`relative`,children:[q(`button`,{className:o>0?`on-filter`:``,onClick:a,children:[e.label,o>0?`: ${o===1?[...e.selected][0]:`${o} chosen`}`:``,` `,q(pn,{open:t})]}),t&&q(`div`,{className:`popover popover--left`,onMouseLeave:()=>n(!1),children:[e.options.length===0&&q(`span`,{className:`faint`,style:{fontSize:12,padding:4},children:`No values yet.`}),e.options.map(t=>q(`label`,{title:t.hint,children:[q(`input`,{type:`checkbox`,checked:e.selected.has(t.value),onChange:()=>{let n=new Set(e.selected);n.has(t.value)?n.delete(t.value):n.add(t.value),e.onChange(n)}}),t.label]},t.value)),o>0&&q(`button`,{className:`small quiet`,style:{marginTop:4,width:`100%`},onClick:()=>e.onChange(new Set),children:`Clear`})]})]})}var mo=e=>{let t=e.property?.tools.eidosmd;return typeof t==`object`&&!!t&&t.filter===!0};function ho(e){let[t,n]=N(null),[r,i]=N(null),[a,o]=N({key:`title`,dir:`asc`}),[s,c]=N(new Set),[l,u]=N({}),[d,f]=N(``),p=F(null),[m,h]=N(!1),g=F({}),_=I(()=>h(!1),[]);Ht(g.current,_);let[v,y]=N(new Set),[ee,b]=N(0),[x,S]=N(null),te=Dt(),C=kt(),w=e.settings.local.tables.page_size;P(()=>{let t=!0;return ct(`/api/collections/${encodeURIComponent(e.name)}`).then(e=>{t&&(n(e),i(null))}).catch(e=>t&&i(e.message)),()=>{t=!1}},[e.name,e.tick]),P(()=>{c(new Set),u({}),f(``),b(0),y(new Set),S(null)},[e.name]);let T=je(()=>{if(!t)return[];let e=[];for(let n of t.columns)so.has(n.name)||e.push({key:n.name,label:n.name,type:n.type,property:n});let n=new Set(e.map(e=>e.key));for(let r of t.rows)for(let t of Object.keys(r.properties))!n.has(t)&&!so.has(t)&&(n.add(t),e.push({key:t,label:t,type:`Text`,property:null}));return e},[t]),ne=e.settings.local.tables.columns[e.name],E=je(()=>new Set(ne??[`id`,...T.filter(e=>e.type===`List`).map(e=>e.key)]),[ne,T]),D=t=>{te(()=>ut(`/api/settings`,{local:t})).then(t=>t&&e.onSettingsSaved())},re=je(()=>T.filter(mo),[T]),ie=e=>{let n=new Set(t?.known_values[e.key]??[]);for(let r of t?.rows??[]){let t=r.properties[e.key];if(Array.isArray(t))for(let e of t)n.add(lo(e));else t!=null&&t!==``&&n.add(lo(t))}return[...n].sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`}))},O=je(()=>{if(!t)return[];let e=d.trim().toLowerCase(),n=t.rows.filter(t=>{if(s.size>0&&!s.has(t.group??co))return!1;for(let[e,n]of Object.entries(l)){if(n.size===0)continue;let r=t.properties[e];if(!(Array.isArray(r)?r.map(lo):[lo(r)]).some(e=>n.has(e)))return!1}return e===``||`${t.title}\n${t.summary??``}\n${t.id??``}\n${Object.values(t.properties).map(lo).join(`
|
|
9
|
+
`)}`.toLowerCase().includes(e)}),r=T.find(e=>e.key===a.key),i=e=>a.key===`title`?e.title:a.key===`__group`?e.group:e.properties[a.key];return n.sort((e,t)=>uo(i(e),i(t),r?.type??`Text`)*(a.dir===`asc`?1:-1)),n},[t,T,s,l,d,a]),k=Math.max(1,Math.ceil(O.length/w)),A=Math.min(ee,k-1);P(()=>{if(e.open)return;let t=t=>{let n=t.target;if(Mt(t)&&!t.altKey&&!t.shiftKey&&t.key.toLowerCase()===`f`){t.preventDefault(),p.current?.focus(),p.current?.select();return}n.closest(`input, textarea, select, [contenteditable]`)||t.metaKey||t.ctrlKey||t.altKey||(t.key.toLowerCase()===`n`&&!t.shiftKey?(t.preventDefault(),e.onNew(e.name)):t.key===`ArrowLeft`&&A>0?b(A-1):t.key===`ArrowRight`&&A<k-1&&b(A+1))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open,e.name,e.onNew,A,k]),Lt(`Collection table`,[{keys:`N`,what:`New blueprint in this collection`},{keys:`⌘F`,what:`Find in the table (Esc leaves the box)`},{keys:`← · →`,what:`Previous page · next page`}]);let ae=O.slice(A*w,(A+1)*w),oe=t?.collection.grouping??null,se=oe!==null,ce=je(()=>{if(!se)return[{group:co,rows:ae}];let e=oe?.groups.map(e=>e.name)??[];return[...e,...[...new Set(ae.map(e=>e.group??co))].filter(t=>t!==co&&!e.includes(t)).sort(),co].map(e=>({group:e,rows:ae.filter(t=>(t.group??co)===e)})).filter(e=>e.rows.length>0)},[se,oe,ae]),le=t=>{let n=new Set(E);n.has(t)?n.delete(t):n.add(t),D({tables:{columns:{[e.name]:[...n]}}})},ue=e=>o(t=>({key:e,dir:t.key===e&&t.dir===`asc`?`desc`:`asc`})),de=T.filter(e=>!E.has(e.key)),fe=t=>[{label:`Open`,onSelect:()=>ht(vt(e.name,t.path))},{label:`Open as a page`,onSelect:()=>ht(yt(t.path))},{label:`Copy path`,onSelect:()=>void navigator.clipboard?.writeText(t.path).catch(()=>void 0)},{separator:!0,label:``},{label:`Delete…`,danger:!0,onSelect:()=>void C.confirm({title:`Delete ${t.title}?`,body:`${t.path} is removed from disk. Nothing else changes.`,confirm:`Delete blueprint`,danger:!0}).then(n=>{n&&te(()=>dt(`/api/blueprints/${st(t.path)}`),`Deleted`).then(t=>t&&e.onChanged())})}],pe=(e,t,n)=>S({row:e,x:t,y:n});if(r)return q(`div`,{className:`page empty`,children:r});if(!t)return q(hn,{});let me=O.length===0?0:A*w+1,he=Math.min(O.length,(A+1)*w);return q(`div`,{className:`page`,onClick:()=>x&&S(null),children:[q(`div`,{className:`page__head`,children:[q(`div`,{className:`grow`,children:[q(`h1`,{children:t.collection.name}),t.collection.description&&q(`p`,{children:t.collection.description})]}),q(`button`,{className:`primary`,onClick:()=>e.onNew(t.collection.name),"data-tip":`New blueprint N`,"data-tip-pos":`left`,children:[`+ New `,t.collection.unit??`blueprint`]})]}),q(`div`,{className:`toolbar`,style:{marginBottom:12},children:[q(`input`,{ref:p,value:d,onChange:e=>(f(e.target.value),b(0)),onKeyDown:e=>e.key===`Escape`&&e.currentTarget.blur(),placeholder:`Find ${t.collection.unit??t.collection.name}`,style:{width:220}}),q(`div`,{className:`relative`,children:[q(`button`,{className:`icon`,onClick:()=>{m||Vt(g.current),h(!m)},"data-tip":`Columns`,"data-tip-pos":`bottom`,"aria-label":`Columns`,children:q(en,{})}),m&&q(`div`,{className:`popover popover--left`,onMouseLeave:()=>h(!1),children:[T.map(e=>q(`label`,{children:[q(`input`,{type:`checkbox`,checked:!E.has(e.key),onChange:()=>le(e.key)}),e.label,q(`span`,{className:`faint`,style:{marginLeft:`auto`,fontSize:11},children:e.type})]},e.key)),q(`span`,{className:`faint`,style:{fontSize:11,padding:`4px 6px 0`},children:`Filters: flag a property under Framework Settings → Properties.`})]})]}),oe&&oe.groups.length>0&&q(po,{label:oe.label,options:[...oe.groups.map(e=>({value:e.name,label:e.name,hint:e.description})),{value:co,label:`(ungrouped)`}],selected:s,onChange:e=>(c(e),b(0))}),re.map(e=>q(po,{label:e.label,options:ie(e).map(e=>({value:e,label:e})),selected:l[e.key]??new Set,onChange:t=>(u(n=>({...n,[e.key]:t})),b(0))},e.key)),q(`div`,{className:`grow`}),q(`span`,{className:`pager`,children:[q(Z,{value:String(w),onChange:e=>{D({tables:{page_size:Number(e.target.value)}}),b(0)},"data-tip":`Rows per page`,"data-tip-pos":`bottom`,children:[25,50,100,250].map(e=>q(`option`,{value:String(e),children:[e,` / page`]},e))}),q(`button`,{className:`icon`,disabled:A===0,onClick:()=>b(A-1),"aria-label":`Previous page`,"data-tip":`Previous page ←`,"data-tip-pos":`bottom`,children:`‹`}),q(`span`,{className:`pager__count`,children:[O.length===0?`No rows`:`${me}–${he} of ${O.length}`,O.length===t.rows.length?``:` (${t.rows.length} in all)`]}),q(`button`,{className:`icon`,disabled:A>=k-1,onClick:()=>b(A+1),"aria-label":`Next page`,"data-tip":`Next page →`,"data-tip-pos":`bottom`,children:`›`})]})]}),t.rows.length===0?q(`div`,{className:`empty`,children:`Nothing here yet. Start with “+ New”.`}):q(`div`,{className:`table-wrap`,children:q(`table`,{className:`grid`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{onClick:()=>ue(`title`),children:[`title`,a.key===`title`&&q(`span`,{className:`dir`,children:a.dir===`asc`?`▲`:`▼`})]}),de.map(e=>q(`th`,{onClick:()=>ue(e.key),title:e.property?.meaning,children:[e.label,a.key===e.key&&q(`span`,{className:`dir`,children:a.dir===`asc`?`▲`:`▼`})]},e.key)),q(`th`,{})]})}),q(`tbody`,{children:ce.map(t=>q(go,{nested:se,group:t.group,label:t.group===co?se?`ungrouped`:``:t.group,rows:t.rows,collapsed:v.has(t.group),onToggle:()=>y(e=>{let n=new Set(e);return n.has(t.group)?n.delete(t.group):n.add(t.group),n}),visible:de,open:e.open,collection:e.name,span:de.length+2,onMenu:pe},t.group))})]})}),x&&q(`div`,{style:{position:`fixed`,left:x.x,top:x.y,zIndex:30},onClick:e=>e.stopPropagation(),children:q(di,{at:{x:0,y:0},items:fe(x.row),onClose:()=>S(null)})}),e.open&&q(ii,{path:e.open,tick:e.tick,layout:`modal`,onClose:()=>ht(vt(e.name)),onSaved:e.onChanged})]})}function go(e){return q(S,{children:[e.nested&&q(`tr`,{className:`group-row`,onClick:e.onToggle,children:q(`td`,{colSpan:e.span,children:[q(pn,{open:!e.collapsed}),q(`span`,{className:`mono`,children:[e.label,`/`]}),q(`span`,{className:`faint`,children:e.rows.length})]})}),!e.collapsed&&e.rows.map(t=>q(`tr`,{className:`${e.open===t.path?`selected`:``}${e.nested?` nested`:``}`,onClick:()=>ht(vt(e.collection,t.path)),onContextMenu:n=>{n.preventDefault(),e.onMenu(t,n.clientX,n.clientY)},children:[q(`td`,{className:`title`,children:[t.title,q(`span`,{className:`id`,children:t.id??t.path})]}),e.visible.map(e=>q(`td`,{className:e.key===`summary`?`summary`:``,children:q(fo,{column:e,row:t})},e.key)),q(`td`,{className:`flags`,title:t.findings.errors+t.findings.warnings>0?`${t.findings.errors} error(s), ${t.findings.warnings} warning(s)`:void 0,children:[t.findings.errors>0?q(`span`,{className:`dot error`}):t.findings.warnings>0?q(`span`,{className:`dot`}):null,q(`button`,{className:`quiet icon row-more`,"aria-label":`Actions`,onClick:n=>{n.stopPropagation();let r=n.currentTarget.getBoundingClientRect();e.onMenu(t,r.right-200,r.bottom+4)},children:q(rn,{})})]})]},t.path))]})}var _o=[{tab:`general`,label:`Root`,blurb:`The root itself: its naming, its top-level documents, and its versions.`},{tab:`collections`,label:`Collections`,blurb:`Each collection, its variants, and how it groups its blueprints.`},{tab:`properties`,label:`Properties`,blurb:`The property contract: the standard's block, yours, and each tool's. The order of yours is the styling precedence.`},{tab:`vocabulary`,label:`Vocabulary`,blurb:`The root's own terms: what each means, and what it is not.`},{tab:`templates`,label:`Templates`,blurb:`The body each variant starts from: its sections, in order, with a note on what goes there.`},{tab:`roles`,label:`Roles`,blurb:`The response contracts under .eidos/roles/: who each kind of person is, and how an agent talks to them.`},{tab:`me`,label:`Me`,blurb:`Who you are to this root: your role and calibration, personal and gitignored, read by an agent before it acts.`}],vo=[{tab:`check`,label:`Health Check`,blurb:`What the check finds in the root: errors, warnings, and the fixes it offers.`,href:`/check`},{tab:`prefs`,label:`Preferences`,blurb:`How this browser behaves for you, and what every save does to a blueprint.`,href:`/prefs`},{tab:`plugins`,label:`Plugins`,blurb:`What the browser can switch on for this root: git, and its settings.`,href:`/plugins`},{tab:`users`,label:`Users`,blurb:`The people who work in this root, their @aliases and roles.`,href:`/users`}],yo=`https://eidosmd.com/docs/cli/browser#framework-settings`,bo=[`Text`,`List`,`Number`,`Checkbox`,`Date`,`Date & time`],xo=[`box`,`pill`,`dark`,`accent`,`parallelogram`,`text`],So=[`kebab-case`,`TitleCase`,`Title Case`],Co=e=>JSON.parse(JSON.stringify(e));function wo(e){for(let t of e.variants){let e=t.template.split(`/`).pop()?.replace(/\.md$/i,``)??``,n=e.indexOf(`.`);if(n>0)return e.slice(0,n)}let t=e.name.trim().toLowerCase().replace(/\s+/g,`-`);return t.endsWith(`ies`)?`${t.slice(0,-3)}y`:t.endsWith(`s`)?t.slice(0,-1):t}var To=(e,t)=>`templates/${wo(e)}.${t.trim().toLowerCase().replace(/\s+/g,`-`)}.md`;function Eo(e){return q(`nav`,{className:`tabs`,children:vo.map(t=>q(`a`,{href:t.href,className:e.current===t.href?`on`:``,"data-tip":t.blurb,"data-tip-pos":`bottom`,children:t.label},t.tab))})}var Do=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`System`}];function Oo(e){let[t,n]=N(null),[r,i]=N(null),[a,o]=N(!1),s=Dt(),c=kt(),l=()=>{ct(`/api/framework`).then(e=>{n(e),i(Co(e.document)),o(!1)}).catch(()=>void 0)};P(l,[]);let u=e=>{if(!r)return;let t=Co(r);e(t),i(t),o(!0)},d=async()=>{if(!r)return;let t=await s(()=>ut(`/api/framework`,{document:r}),`Framework saved`);t&&(n(t),i(Co(t.document)),o(!1),e.onSaved())},f={draft:r,dirty:a,save:d,discard:()=>{t&&i(Co(t.document)),o(!1)}},p=N({current:f})[0];p.current=f,P(()=>{if(!a){pt(null);return}return pt(async e=>{if(e.startsWith(`/settings/`))return!0;let n=await c.choose({title:`Unsaved framework changes`,body:`The framework document has edits that are not in ${t?.file??`Framework.yaml`} yet.`,options:[{value:`stay`,label:`Keep editing`},{value:`discard`,label:`Discard`,kind:`danger`},{value:`save`,label:`Save and go`,kind:`primary`}]});return n===`save`?(await p.current.save(),!0):n===`discard`&&(p.current.discard(),!0)}),()=>pt(null)},[a,c,t,p]);let m=_o.find(t=>t.tab===e.tab)??_o[0],h=e.tab!==`templates`&&e.tab!==`roles`&&e.tab!==`me`;return q(`div`,{className:`page page--narrow`,children:[q(`div`,{className:`page__head`,children:[q(`div`,{className:`grow`,children:[q(`h1`,{children:`Framework Settings`}),q(`nav`,{className:`tabs`,style:{marginBottom:8},children:_o.map(t=>q(`a`,{href:`/settings/${t.tab}`,className:e.tab===t.tab?`on`:``,children:t.label},t.tab))}),q(`p`,{children:m.blurb})]}),h&&q(`div`,{className:`toolbar`,children:[a&&q(`span`,{className:`dirty`,children:`Unsaved changes`}),t&&t.problems.length>0&&q(`span`,{className:`badge warn`,title:t.problems.join(`
|
|
10
|
+
`),children:[t.problems.length,` problem(s)`]}),q(`button`,{onClick:l,disabled:!a,children:`Discard`}),q(`button`,{className:`primary`,onClick:()=>void d(),disabled:!a,children:`Save to Framework`})]})]}),!r||!t?q(`div`,{className:`empty`,children:`Loading…`}):e.tab===`general`?q(Ao,{draft:r,edit:u,file:t.file,gitHead:e.gitHead,onRecorded:()=>(l(),e.onSaved())}):e.tab===`collections`?q(jo,{draft:r,edit:u,templates:t.templates}):e.tab===`properties`?q(Mo,{draft:r,edit:u}):e.tab===`vocabulary`?q(Ko,{draft:r,edit:u}):e.tab===`templates`?q(qo,{templates:t.templates,onSaved:()=>(l(),e.onSaved())}):e.tab===`roles`?q(Xo,{onSaved:e.onSaved}):q(Qo,{})]})}function ko(e){let[t,n]=N([]),[r,i]=N(0),a=kt(),o=Dt(),s=async()=>{let t=await a.prompt({title:`New top-level document`,label:`Title`,placeholder:`Roadmap`,confirm:`Create`});if(!t)return;let n=`${t.trim().replace(/[\\/:*?"<>|]+/g,``).replace(/\s+/g,`-`)}.md`,r=await o(()=>lt(`/api/docs`,{path:n,title:t.trim()}),`${n} created at the root`);r&&(i(e=>e+1),e.onChange(e.toValue({name:r.path,path:r.path,kind:`file`})))};P(()=>{ct(`/api/files?dir=${encodeURIComponent(e.dir)}${e.ext?`&ext=${e.ext}`:``}`).then(e=>n(e.entries.filter(e=>e.kind===`file`))).catch(()=>n([]))},[e.dir,e.ext,r]);let c=t.map(t=>({value:e.toValue(t),label:t.name})),l=c.some(t=>t.value===e.value);return q(Z,{value:e.value,onChange:t=>{let n=t.target.value;if(n===`__create__`){s();return}e.onChange(n)},children:[!l&&q(`option`,{value:e.value,children:e.value||`— choose a file —`}),c.map(e=>q(`option`,{value:e.value,children:e.label},e.value)),e.create&&q(`option`,{value:`__create__`,children:`+ New file at the root…`})]})}function Ao(e){let{draft:t,edit:n}=e,[r,i]=N(!1),[a,o]=N([]);return P(()=>{ct(`/api/versions`).then(e=>o(e.versions)).catch(()=>o([]))},[r]),q(S,{children:[q(`h3`,{className:`settings__h`,children:`Root`}),q(`div`,{className:`field`,children:[q(`span`,{children:`Framework file`}),q(`code`,{children:e.file}),q(`span`,{children:`Eidos version`}),q(`code`,{children:t.eidos_version??`—`}),q(`span`,{children:`Naming`}),q(Z,{value:t.naming??`kebab-case`,onChange:e=>n(t=>t.naming=e.target.value),children:So.map(e=>q(`option`,{children:e},e))})]}),q(`p`,{className:`faint`,style:{fontSize:12},children:`Naming is settled once; changing it renames nothing on disk.`}),q(`h3`,{className:`settings__h`,children:`Top-level documents`}),q(`table`,{className:`mini`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Title`}),q(`th`,{children:`File (at the root)`}),q(`th`,{children:`Description`}),q(`th`,{})]})}),q(`tbody`,{children:(t.top_level??[]).map((e,t)=>q(`tr`,{children:[q(`td`,{children:q(`input`,{value:e.title,onChange:e=>n(n=>n.top_level[t].title=e.target.value)})}),q(`td`,{children:q(ko,{dir:``,ext:`md`,value:e.path,toValue:e=>`../${e.path}`,onChange:e=>n(n=>n.top_level[t].path=e),create:!0})}),q(`td`,{children:q(Gt,{value:e.description??``,label:`What ${e.title} is`,onChange:e=>n(n=>n.top_level[t].description=e)})}),q(`td`,{className:`x`,children:q(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>e.top_level.splice(t,1)),"data-tip":`Remove`,"data-tip-pos":`left`,"aria-label":`Remove`,children:q(Zt,{})})})]},t))})]}),q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>n(e=>e.top_level=[...e.top_level??[],{title:`New doc`,path:``,description:``}]),children:`+ Add document`})}),q(`h3`,{className:`settings__h`,children:`Versions of the root`}),q(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:[`Snapshots taken on purpose, newest first: the root's own number, the commit that is the snapshot, the tag if one was made. This CLI's own record, kept under `,q(`code`,{children:`.eidos/plugins/eidosmd/versions.yaml`}),`, since it needs git; the standard keeps none. Empty is the normal state.`]}),a.length>0&&q(`table`,{className:`mini`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Version`}),q(`th`,{children:`Commit`}),q(`th`,{children:`Tag`})]})}),q(`tbody`,{children:a.map(e=>q(`tr`,{children:[q(`td`,{children:e.version}),q(`td`,{children:q(`code`,{children:e.commit})}),q(`td`,{children:e.tag?q(`code`,{children:e.tag}):q(`span`,{className:`faint`,children:`—`})})]},e.version))})]}),q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>i(!0),children:`Record a version…`})}),r&&q(is,{gitHead:e.gitHead,onClose:()=>i(!1),onRecorded:e.onRecorded})]})}function jo(e){let{draft:t,edit:n}=e;return q(S,{children:[q(`p`,{className:`faint`,style:{fontSize:12},children:[`A template file follows the convention, `,q(`code`,{children:`templates/<unit>.<variant>.md`}),`, the unit being the word for one of the collection's blueprints; write it under Templates.`]}),t.collections.map((t,r)=>q(`div`,{className:`card`,children:[q(`div`,{className:`card__head`,children:[q(`strong`,{children:t.name||`untitled`}),wo(t)===`frame`&&q(`span`,{className:`badge accent`,children:`framing`}),q(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>e.collections.splice(r,1)),"data-tip":`Remove the collection from the framework (its folder stays)`,"data-tip-pos":`left`,"aria-label":`Remove collection`,children:q(Zt,{})})]}),q(`div`,{className:`field`,children:[q(`span`,{children:`Unit`}),q(`span`,{children:[q(`code`,{children:wo(t)}),` `,q(`span`,{className:`field__hint`,children:`The word for one of its blueprints, read off its template files.`})]})]}),q(`h3`,{className:`settings__h`,children:`Variants`}),q(`table`,{className:`mini`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Name`}),q(`th`,{children:`Description`}),q(`th`,{children:`Template file`}),q(`th`,{children:`Default`}),q(`th`,{})]})}),q(`tbody`,{children:t.variants.map((i,a)=>{let o=e.templates.find(e=>e.collection===t.name&&e.variant===i.name);return q(`tr`,{children:[q(`td`,{children:q(`input`,{value:i.name,onChange:e=>n(t=>{let n=t.collections[r],i=n.variants[a];i.name=e.target.value,i.template=To(n,e.target.value)})})}),q(`td`,{children:q(Gt,{value:i.description??``,label:`The ${i.name} variant`,onChange:e=>n(t=>t.collections[r].variants[a].description=e)})}),q(`td`,{children:q(`span`,{style:{display:`flex`,gap:6,alignItems:`center`},children:[q(`code`,{className:`faint`,children:i.template}),o&&!o.exists&&q(`span`,{className:`badge warn`,title:`No file at this path yet; create it under Templates`,children:`missing`})]})}),q(`td`,{children:q(`input`,{type:`radio`,name:`default-${r}`,checked:i.default===!0,onChange:()=>n(e=>e.collections[r].variants.forEach((e,t)=>t===a?e.default=!0:delete e.default))})}),q(`td`,{className:`x`,children:q(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>e.collections[r].variants.splice(a,1)),"data-tip":`Remove variant`,"data-tip-pos":`left`,"aria-label":`Remove variant`,children:q(Zt,{})})})]},a)})})]}),q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>n(e=>{let t=e.collections[r];t.variants.push({name:`new`,template:To(t,`new`),description:``,...t.variants.length===0?{default:!0}:{}})}),children:`+ Add variant`})}),q(`h3`,{className:`settings__h`,children:`Grouping`}),t.grouping?q(S,{children:[q(`div`,{className:`field`,children:[q(`span`,{children:`Label`}),q(`input`,{value:t.grouping.label,onChange:e=>n(t=>t.collections[r].grouping.label=e.target.value)}),q(`span`,{children:`Property`}),q(`input`,{placeholder:`the custom property carrying the group, e.g. domain`,value:t.grouping.property??``,onChange:e=>n(t=>t.collections[r].grouping.property=e.target.value||null)})]}),q(`table`,{className:`mini`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Group`}),q(`th`,{children:`Description`}),q(`th`,{})]})}),q(`tbody`,{children:(t.grouping.groups??[]).map((e,t)=>q(`tr`,{children:[q(`td`,{children:q(`input`,{value:e.name,onChange:e=>n(n=>n.collections[r].grouping.groups[t].name=e.target.value)})}),q(`td`,{children:q(Gt,{value:e.description??``,label:`The ${e.name} group`,onChange:e=>n(n=>n.collections[r].grouping.groups[t].description=e)})}),q(`td`,{className:`x`,children:q(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>e.collections[r].grouping.groups.splice(t,1)),"data-tip":`Remove group`,"data-tip-pos":`left`,"aria-label":`Remove group`,children:q(Zt,{})})})]},t))})]}),q(`div`,{className:`rowbtn`,children:[q(`button`,{className:`small`,onClick:()=>n(e=>e.collections[r].grouping.groups=[...e.collections[r].grouping.groups??[],{name:`new-group`,description:``}]),children:`+ Add group`}),q(`button`,{className:`small quiet`,onClick:()=>n(e=>delete e.collections[r].grouping),children:`Remove grouping`})]})]}):q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>n(e=>e.collections[r].grouping={label:`Groups`,property:null,groups:[]}),children:`+ Group this collection`})})]},r)),q(`div`,{className:`rowbtn`,children:q(`button`,{onClick:()=>n(e=>e.collections.push({name:`new-collection`,description:``,variants:[{name:`default`,template:`templates/new-collection.default.md`,default:!0}]})),children:`+ Add collection`})})]})}function Mo(e){let{draft:t,edit:n}=e,[r,i]=N(null),a=t.properties?.custom??[],o=t.collections.map(e=>e.name),s=(e,t)=>n(n=>{n.properties=n.properties??{},n.properties.custom=n.properties.custom??[],t(n.properties.custom[e])}),c=e=>e.applies_to===void 0||e.applies_to===`all`?`all`:e.applies_to.join(`, `);return q(S,{children:[q(`h3`,{className:`settings__h`,children:`Eidos core (the standard's)`}),q(`table`,{className:`mini`,children:q(`tbody`,{children:(t.properties?.core??[]).map(e=>q(`tr`,{children:[q(`td`,{children:q(`code`,{children:e.name})}),q(`td`,{className:`faint`,children:e.type}),q(`td`,{className:`muted`,children:e.meaning})]},e.name))})}),q(`h3`,{className:`settings__h`,children:`Custom (yours)`}),q(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:[`A custom property is frontmatter every blueprint in the collections it applies to may carry. `,q(`b`,{children:`Filter`}),` offers it as a dropdown over the collection's table. `,q(`b`,{children:`On node`}),` prints its value on a canvas card and lets you edit it there. `,q(`b`,{children:`Default style`}),` gives a canvas node its shape and color by value; the order of the rows is the precedence (the top-most property that names a value wins) and the arrows move a row.`,` `,q(`a`,{href:yo,target:`_blank`,rel:`noreferrer`,children:`More in the docs ↗`})]}),q(`table`,{className:`mini`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{}),q(`th`,{children:`Name`}),q(`th`,{children:`Type`}),q(`th`,{children:`Applies to`}),q(`th`,{children:`Meaning`}),q(`th`,{title:`Offer this property as a filter over the collection table`,children:`Filter`}),q(`th`,{title:`Print the value on the canvas node, and edit it there`,children:`On node`}),q(`th`,{children:`Default style`}),q(`th`,{})]})}),q(`tbody`,{children:a.map((e,t)=>q(`tr`,{children:[q(`td`,{className:`x`,style:{whiteSpace:`nowrap`,width:52},children:[q(`button`,{className:`quiet icon`,disabled:t===0,onClick:()=>n(e=>Fo(e.properties.custom,t,-1)),"data-tip":`Higher precedence`,"data-tip-pos":`right`,"aria-label":`Move up`,children:q(nn,{direction:`up`})}),q(`button`,{className:`quiet icon`,disabled:t===a.length-1,onClick:()=>n(e=>Fo(e.properties.custom,t,1)),"data-tip":`Lower precedence`,"data-tip-pos":`right`,"aria-label":`Move down`,children:q(nn,{direction:`down`})})]}),q(`td`,{children:q(`input`,{value:e.name,onChange:e=>s(t,t=>t.name=e.target.value),style:{width:130}})}),q(`td`,{children:q(Z,{value:e.type,onChange:e=>s(t,t=>t.type=e.target.value),children:bo.map(e=>q(`option`,{value:e,children:e},e))})}),q(`td`,{children:q(Wt,{value:c(e),options:[`all`,...o],style:{width:130},onChange:e=>s(t,t=>{let n=e.trim();t.applies_to=n===``||n===`all`?`all`:n.split(`,`).map(e=>e.trim()).filter(e=>e!==``)})})}),q(`td`,{children:q(Gt,{value:e.meaning??``,label:`What ${e.name} means`,onChange:e=>s(t,t=>t.meaning=e)})}),q(`td`,{style:{textAlign:`center`},children:q(`input`,{type:`checkbox`,checked:e.eidosmd?.filter===!0,onChange:e=>s(t,t=>No(t,`filter`,e.target.checked))})}),q(`td`,{style:{textAlign:`center`},children:q(`input`,{type:`checkbox`,checked:e.eidosmd?.canvas?.show===!0,onChange:e=>s(t,t=>Po(t,e.target.checked))})}),q(`td`,{children:q(`button`,{className:`small${e.eidosmd?.canvas?.shape||e.eidosmd?.canvas?.color?` primary`:``}`,onClick:()=>i(r===t?null:t),children:r===t?`Close`:e.eidosmd?.canvas?.shape||e.eidosmd?.canvas?.color?`Edit style`:`Set style`})}),q(`td`,{className:`x`,children:q(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>e.properties.custom.splice(t,1)),"data-tip":`Remove property`,"data-tip-pos":`left`,"aria-label":`Remove property`,children:q(Zt,{})})})]},t))})]}),q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>n(e=>{e.properties=e.properties??{},e.properties.custom=[...e.properties.custom??[],{name:`new_property`,type:`Text`,applies_to:`all`,meaning:``}]}),children:`+ Add property`})}),r!==null&&a[r]&&q(Io,{property:a[r],onChange:e=>s(r,e),onClose:()=>i(null)}),Object.entries(t.properties?.tools??{}).map(([e,t])=>q(`div`,{children:[q(`h3`,{className:`settings__h`,children:[q(fn,{}),` `,e,` (the tool's own block)`]}),q(`table`,{className:`mini`,children:q(`tbody`,{children:t.map(e=>q(`tr`,{children:[q(`td`,{children:q(`code`,{children:e.name})}),q(`td`,{className:`faint`,children:e.type}),q(`td`,{className:`faint`,children:e.applies_to===void 0||e.applies_to===`all`?`all`:e.applies_to.join(`, `)}),q(`td`,{className:`muted`,children:e.meaning})]},e.name))})}),q(`p`,{className:`faint`,style:{fontSize:12},children:[`Declared and written by `,e,` alone; generated into frontmatter and checked like any other property. Not edited here.`]})]},e))]})}function No(e,t,n){let r={...e.eidosmd??{}};n?r[t]=!0:delete r[t],Object.keys(r).length===0?delete e.eidosmd:e.eidosmd=r}function Po(e,t){let n={...e.eidosmd?.canvas??{}};t?n.show=!0:delete n.show;let r={...e.eidosmd??{}};Object.keys(n).length===0?delete r.canvas:r.canvas=n,Object.keys(r).length===0?delete e.eidosmd:e.eidosmd=r}function Fo(e,t,n){let r=t+n;if(r<0||r>=e.length)return;let[i]=e.splice(t,1);i!==void 0&&e.splice(r,0,i)}function Io(e){let t=e.property.eidosmd?.canvas??{},n=Object.entries(t.shape??{}),r=Object.entries(t.color??{}),i=t=>e.onChange(e=>{let n={...e.eidosmd?.canvas??{}};t(n),e.eidosmd={...e.eidosmd??{},canvas:n}}),a=()=>{e.onChange(e=>{if(!e.eidosmd)return;let{canvas:t,...n}=e.eidosmd;Object.keys(n).length===0?delete e.eidosmd:e.eidosmd=n}),e.onClose()},o=(e,t,n)=>{let r=Object.entries(e);return r[t]=[n,r[t]?.[1]??``],Object.fromEntries(r)},s=(e,t)=>{let n={...e};return delete n[t],n};return q(`div`,{className:`card`,style:{marginTop:14},children:[q(`div`,{className:`card__head`,children:[q(`strong`,{children:[`Default style for “`,e.property.name,`”`]}),q(`button`,{className:`quiet small danger`,onClick:a,children:`Clear style`})]}),q(`p`,{className:`faint`,style:{fontSize:12,margin:`-4px 0 10px`},children:`A node with this value looks like this on a canvas unless styled by hand.`}),q(`div`,{className:`split`,children:[q(`div`,{children:[q(`h3`,{className:`settings__h`,children:`Value → shape`}),q(`table`,{className:`mini`,children:q(`tbody`,{children:n.map(([e,t],n)=>q(`tr`,{children:[q(`td`,{children:q(`input`,{value:e,onChange:e=>i(t=>t.shape=o(t.shape??{},n,e.target.value))})}),q(`td`,{children:q(Z,{value:t,onChange:t=>i(n=>n.shape={...n.shape??{},[e]:t.target.value}),children:xo.map(e=>q(`option`,{value:e,children:e},e))})}),q(`td`,{className:`x`,children:q(`button`,{className:`quiet icon danger`,onClick:()=>i(t=>t.shape=s(t.shape??{},e)),"aria-label":`Remove`,children:q(Zt,{})})})]},n))})}),q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>i(e=>e.shape={...e.shape??{},[`value-${n.length+1}`]:`box`}),children:`+ Value`})})]}),q(`div`,{children:[q(`h3`,{className:`settings__h`,children:`Value → color`}),q(`table`,{className:`mini`,children:q(`tbody`,{children:r.map(([e,t],n)=>q(`tr`,{children:[q(`td`,{children:q(`input`,{value:e,onChange:e=>i(t=>t.color=o(t.color??{},n,e.target.value))})}),q(`td`,{style:{width:40},children:q(`input`,{type:`color`,value:/^#[0-9a-f]{6}$/i.test(t)?t:`#888888`,onChange:t=>i(n=>n.color={...n.color??{},[e]:t.target.value})})}),q(`td`,{className:`x`,children:q(`button`,{className:`quiet icon danger`,onClick:()=>i(t=>t.color=s(t.color??{},e)),"aria-label":`Remove`,children:q(Zt,{})})})]},n))})}),q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>i(e=>e.color={...e.color??{},[`value-${r.length+1}`]:`#2f6fd0`}),children:`+ Value`})})]})]})]})}var Lo=e=>{let[t=`blueprint`,n=`default`]=e.split(`.`);return`# {{title}}
|
|
11
|
+
|
|
12
|
+
_What a ${t} of the ${n} variant is for, in a line or two. Delete these prompts as the sections fill in._
|
|
13
|
+
|
|
14
|
+
## Intent
|
|
15
|
+
|
|
16
|
+
_Why this exists, in a paragraph._
|
|
17
|
+
|
|
18
|
+
## Non-Goals
|
|
19
|
+
|
|
20
|
+
_What this deliberately does not do._
|
|
21
|
+
`};function Ro(e){let t=e.replace(/\r\n?/g,`
|
|
22
|
+
`).replace(/^\s*<!--[\s\S]*?-->\s*/,``).split(`
|
|
23
|
+
`),n={title:``,intro:``,sections:[]},r=!1,i=!1,a=[],o=null,s=()=>{let e=a.join(`
|
|
24
|
+
`).trim();o?o.body=e:n.intro=e,a=[]};for(let e of t){/^```/.test(e)&&(r=!r);let t=r?null:/^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(e);if(t&&t[1]?.length===1&&!i){i=!0,n.title=t[2]??``;continue}if(t){s(),o={level:Math.min(4,Math.max(2,t[1]?.length??2)),title:t[2]??``,body:``},n.sections.push(o);continue}a.push(e)}return s(),n}function zo(e){let t=[`# ${e.title.trim()}`];e.intro.trim()!==``&&t.push(e.intro.trim());for(let n of e.sections)t.push(`${`#`.repeat(n.level)} ${n.title.trim()}`),n.body.trim()!==``&&t.push(n.body.trim());return t.join(`
|
|
25
|
+
|
|
26
|
+
`)+`
|
|
27
|
+
`}var Bo=e=>({...Ro(e),title:`{{title}}`}),Vo=e=>zo({...e,title:`{{title}}`}),Ho=e=>{let t=/^_([\s\S]+?)_(?:\s*\n\s*\n([\s\S]*))?\s*$/.exec(e.trim());return t?{motivation:(t[1]??``).trim(),body:(t[2]??``).trim()}:{motivation:``,body:e.trim()}},Uo=(e,t)=>[e.trim()===``?``:`_${e.trim()}_`,t.trim()].filter(e=>e!==``).join(`
|
|
28
|
+
|
|
29
|
+
`);function Wo(e){let t=(t,n)=>e.onChange(e.sections.map((e,r)=>r===t?{...e,...n}:e)),n=(t,n)=>{let r=[...e.sections],[i]=r.splice(t,1);i&&(r.splice(t+n,0,i),e.onChange(r))};return q(S,{children:[q(`h3`,{className:`settings__h`,children:`Sections`}),e.sections.length===0&&q(`p`,{className:`faint`,style:{fontSize:12},children:`No sections yet. An H2 is a section; H3 and deeper nest under the one above.`}),e.sections.map((r,i)=>q(`div`,{className:`tpl-sec`,children:[q(Z,{value:String(r.level),onChange:e=>t(i,{level:Number(e.target.value)}),title:`Heading level`,children:[q(`option`,{value:`2`,children:`H2`}),q(`option`,{value:`3`,children:`H3`}),q(`option`,{value:`4`,children:`H4`})]}),q(`input`,{value:r.title,placeholder:`Section heading`,onChange:e=>t(i,{title:e.target.value})}),q(`span`,{className:`tpl-sec__tools`,children:[q(`button`,{className:`quiet icon`,disabled:i===0,onClick:()=>n(i,-1),"aria-label":`Move up`,title:`Move up`,children:q(nn,{direction:`up`})}),q(`button`,{className:`quiet icon`,disabled:i===e.sections.length-1,onClick:()=>n(i,1),"aria-label":`Move down`,title:`Move down`,children:q(nn,{direction:`down`})}),q(`button`,{className:`quiet icon danger`,onClick:()=>e.onChange(e.sections.filter((e,t)=>t!==i)),"aria-label":`Remove section`,title:`Remove section`,children:q(Zt,{})})]}),q(`textarea`,{value:r.body,placeholder:e.guidance,onChange:e=>t(i,{body:e.target.value}),spellCheck:!1})]},i)),q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>e.onChange([...e.sections,{level:2,title:``,body:``}]),children:`+ Add section`})})]})}var Go=e=>e.split(/\r?\n|;/).map(e=>e.trim()).filter(e=>e!==``);function Ko(e){let{draft:t,edit:n}=e,r=t.vocabulary??[],i=(e,t)=>n(n=>{n.vocabulary=n.vocabulary??[],t(n.vocabulary[e])});return q(S,{children:[q(`h3`,{className:`settings__h`,children:`Terms`}),q(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:[`The words the product is described in, used on purpose: what each `,q(`b`,{children:`means`}),`, and what it is `,q(`b`,{children:`not`}),` (the near-misses, one per line, each with why it is a different thing). A declared term is the word: Health Check warns where a blueprint says a near-miss instead. `,q(`b`,{children:`See`}),` points at the blueprint or top-level doc that defines the term in full, as a path from `,q(`code`,{children:`.eidos/`}),`.`,` `,q(`a`,{href:yo,target:`_blank`,rel:`noreferrer`,children:`More in the docs ↗`})]}),q(`table`,{className:`mini`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Term`}),q(`th`,{children:`Means`}),q(`th`,{children:`Not`}),q(`th`,{children:`See`}),q(`th`,{})]})}),q(`tbody`,{children:r.map((e,t)=>q(`tr`,{children:[q(`td`,{children:q(`input`,{value:e.term,placeholder:`team member`,onChange:e=>i(t,t=>t.term=e.target.value),style:{width:150}})}),q(`td`,{children:q(Gt,{value:e.means,label:`What ${e.term||`the term`} means`,placeholder:`One line`,onChange:e=>i(t,t=>t.means=e.trim())})}),q(`td`,{children:q(Gt,{value:e.not.join(`
|
|
30
|
+
`),label:`What ${e.term||`the term`} is not`,placeholder:`Near-misses, one per line`,onChange:e=>i(t,t=>t.not=Go(e))})}),q(`td`,{children:q(`input`,{value:e.see??``,placeholder:`../Specs/team-member.md`,onChange:e=>i(t,t=>{let n=e.target.value.trim();n===``?delete t.see:t.see=n}),style:{width:200}})}),q(`td`,{className:`x`,children:q(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>e.vocabulary.splice(t,1)),"data-tip":`Remove term`,"data-tip-pos":`left`,"aria-label":`Remove term`,children:q(Zt,{})})})]},t))})]}),q(`button`,{onClick:()=>n(e=>{e.vocabulary=e.vocabulary??[],e.vocabulary.push({term:``,means:``,not:[]})}),children:`+ Add term`})]})}function qo(e){let[t,n]=N(e.templates[0]?.path??null),[r,i]=N(``),[a,o]=N(``),[s,c]=N(!0),[l,u]=N({title:`{{title}}`,intro:``,sections:[]}),d=Dt();P(()=>{t&&ct(`/api/templates/${st(t)}`).then(e=>{let n=e.exists?e.text:Lo(t.replace(/^templates\//,``).replace(/\.md$/,``));i(n),u(Bo(n)),o(e.exists?e.text:``)}).catch(()=>void 0)},[t]);let f=async()=>{t&&await d(()=>ut(`/api/templates/${st(t)}`,{text:r}),`Template saved`)&&(o(r),e.onSaved())},p=e=>{u(e),i(Vo(e))},m=e=>{e?u(Bo(r)):i(Vo(l)),c(e)},h=e.templates.find(e=>e.path===t);return q(S,{children:[q(`p`,{className:`faint`,style:{fontSize:12,margin:`0 0 12px`},children:`A template is the body a new blueprint starts from; its H2 headings are the sections a check expects. Body only: a frontmatter block in a template is an error, the frontmatter is generated from the Properties table.`}),q(`div`,{className:`split`,style:{gridTemplateColumns:`240px 1fr`},children:[q(`div`,{children:e.templates.map(e=>q(`button`,{className:`quiet${t===e.path?` primary`:``}`,style:{display:`block`,width:`100%`,textAlign:`left`,marginBottom:2},onClick:()=>n(e.path),children:[e.collection,` · `,e.variant,!e.exists&&q(`span`,{className:`badge warn`,style:{marginLeft:6},children:`missing`})]},`${e.collection}/${e.variant}`))}),q(`div`,{children:t?q(S,{children:[q(`div`,{className:`toolbar`,style:{marginBottom:8},children:[q(`code`,{children:[`.eidos/`,t]}),q(`div`,{className:`grow`}),q(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Editor`,children:[q(`button`,{className:s?`on`:``,role:`radio`,"aria-checked":s,onClick:()=>m(!0),children:`Builder`}),q(`button`,{className:s?``:`on`,role:`radio`,"aria-checked":!s,onClick:()=>m(!1),children:`Source`})]}),q(`button`,{className:`primary small`,onClick:()=>void f(),disabled:r===a,children:h?.exists?`Save`:`Create`})]}),s?q(S,{children:[q(`h3`,{className:`settings__h`,children:`Header`}),q(`div`,{className:`tpl-head`,children:[q(`code`,{className:`faint`,children:[`# `,`{{title}}`]}),q(`label`,{children:`Motivation, written in italics under the title`}),q(`textarea`,{rows:2,value:Ho(l.intro).motivation,placeholder:`What a blueprint of this variant is for, in a line or two.`,onChange:e=>p({...l,intro:Uo(e.target.value,Ho(l.intro).body)}),spellCheck:!1}),q(`label`,{children:`Anything else before the first section`}),q(`textarea`,{value:Ho(l.intro).body,placeholder:`Optional: guidance that applies to the whole blueprint.`,onChange:e=>p({...l,intro:Uo(Ho(l.intro).motivation,e.target.value)}),spellCheck:!1})]}),q(Wo,{sections:l.sections,onChange:e=>p({...l,sections:e}),guidance:`_Guidance for this section: what goes here, deleted as it is filled in._`})]}):q(`textarea`,{className:`editor`,style:{minHeight:`50vh`},value:r,onChange:e=>i(e.target.value),spellCheck:!1})]}):q(`div`,{className:`empty`,children:`No variants declare a template yet.`})})]})]})}var Jo=e=>`# ${e}
|
|
31
|
+
|
|
32
|
+
## Who they are
|
|
33
|
+
|
|
34
|
+
_Who this person is to the product, in a line or two: what they hold, what they want to know._
|
|
35
|
+
|
|
36
|
+
## How to respond
|
|
37
|
+
|
|
38
|
+
- **Vocabulary & depth:** _the terms they use, and how deep to go._
|
|
39
|
+
- **Decisions:** _which calls are theirs, and which are not._
|
|
40
|
+
- **Surface / hide:** _what to bring forward, what to fold away._
|
|
41
|
+
- **Focus:** _what they look for in a blueprint._
|
|
42
|
+
|
|
43
|
+
## Calibration
|
|
44
|
+
|
|
45
|
+
_The usual technical capacity and experience with the scope, as a starting point; me.md tunes it per person._
|
|
46
|
+
`,Yo=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Xo(e){let[t,n]=N([]),[r,i]=N(null),[a,o]=N(``),[s,c]=N(``),[l,u]=N(!0),[d,f]=N({title:``,intro:``,sections:[]}),p=Dt(),m=kt(),h=I(async()=>{let e=await ct(`/api/roles`);return n(e),e},[]);P(()=>{h().then(e=>i(t=>t??e[0]?.name??null)).catch(()=>void 0)},[h]),P(()=>{if(!r)return;let e=!0;return ct(`/api/roles/${encodeURIComponent(r)}`).then(t=>{e&&(o(t.text),f(Ro(t.text)),c(t.text))}).catch(()=>void 0),()=>{e=!1}},[r]);let g=e=>{f(e),o(zo(e))},_=e=>{e?f(Ro(a)):o(zo(d)),u(e)},v=async()=>{r&&await p(()=>ut(`/api/roles/${encodeURIComponent(r)}`,{text:a}),`Role saved`)&&(c(a),await h(),e.onSaved())},y=async()=>{let n=await m.prompt({title:`New role`,label:`Title`,placeholder:`Reviewer`,confirm:`Create`});if(!n)return;let r=Yo(n);if(r!==``){if(t.some(e=>e.name===r)){i(r);return}await p(()=>ut(`/api/roles/${encodeURIComponent(r)}`,{text:Jo(n.trim())}),`Role ${n.trim()} created`)&&(await h(),i(r),e.onSaved())}},ee=async()=>{let n=t.find(e=>e.name===r);if(n&&await m.confirm({title:`Delete ${n.title}?`,body:`${n.path} is removed from disk. A user or a me.md naming this role keeps the name until it is changed.`,confirm:`Delete role`,danger:!0})&&await p(()=>dt(`/api/roles/${encodeURIComponent(n.name)}`),`Role deleted`)){let t=await h();i(t[0]?.name??null),e.onSaved()}},b=t.find(e=>e.name===r);return q(S,{children:[q(`p`,{className:`faint`,style:{fontSize:12,margin:`0 0 12px`},children:[`A role is a response contract: who one kind of person is, and how an agent talks to them. Which roles exist is the framework's call; a user holds one, and `,q(`code`,{children:`me.md`}),` names the one in the seat. Committed with the root.`]}),q(`div`,{className:`split`,style:{gridTemplateColumns:`240px 1fr`},children:[q(`div`,{children:[t.map(e=>q(`button`,{className:`quiet${r===e.name?` primary`:``}`,style:{display:`block`,width:`100%`,textAlign:`left`,marginBottom:2},onClick:()=>i(e.name),children:[e.title,q(`span`,{className:`faint mono`,style:{marginLeft:6,fontSize:11},children:e.name})]},e.name)),q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>void y(),children:`+ New role`})})]}),q(`div`,{children:r&&b?q(S,{children:[q(`div`,{className:`toolbar`,style:{marginBottom:8},children:[q(`code`,{children:b.path}),q(`div`,{className:`grow`}),q(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Editor`,children:[q(`button`,{className:l?`on`:``,role:`radio`,"aria-checked":l,onClick:()=>_(!0),children:`Builder`}),q(`button`,{className:l?``:`on`,role:`radio`,"aria-checked":!l,onClick:()=>_(!1),children:`Source`})]}),q(`button`,{className:`quiet small danger`,onClick:()=>void ee(),children:`Delete`}),q(`button`,{className:`primary small`,onClick:()=>void v(),disabled:a===s,children:`Save`})]}),l?q(S,{children:[q(`h3`,{className:`settings__h`,children:`Title`}),q(`input`,{value:d.title,placeholder:`Role title`,onChange:e=>g({...d,title:e.target.value}),style:{width:320}}),d.intro!==``&&q(`div`,{className:`tpl-head`,style:{marginTop:8},children:q(`textarea`,{value:d.intro,onChange:e=>g({...d,intro:e.target.value}),spellCheck:!1})}),q(Wo,{sections:d.sections,onChange:e=>g({...d,sections:e}),guidance:`_What to say here: who they are, how to respond, or how to calibrate._`})]}):q(`textarea`,{className:`editor`,style:{minHeight:`50vh`},value:a,onChange:e=>o(e.target.value),spellCheck:!1})]}):q(`div`,{className:`empty`,children:`No roles under .eidos/roles/ yet. Add one.`})})]})]})}var Zo=`__custom__`;function Qo(){let[e,t]=N(null),[n,r]=N(``),[i,a]=N(!0),[o,s]=N({role:``,custom:``,note:``,ownership:``,experience:``,capacity:``}),c=Dt(),l=I(()=>{ct(`/api/me`).then(e=>{t(e),r(e.text);let n=e.actor.role??``,i=e.roles.find(e=>e.title===n||e.name===n),a=n!==``&&!i;s({role:i?i.name:a?Zo:``,custom:a?n:``,note:a&&e.actor.note===`A custom role: describe how you want to be helped here.`?``:e.actor.note??``,ownership:e.actor.ownership??``,experience:e.actor.experience??``,capacity:e.actor.capacity??``})}).catch(()=>void 0)},[]);if(P(l,[l]),!e)return q(`div`,{className:`empty`,children:`Loading…`});let u=e=>s(t=>({...t,...e})),d=async()=>{let e=i?{role:o.role===Zo?o.custom:o.role,note:o.note,ownership:o.ownership,experience:o.experience,capacity:o.capacity}:{text:n};await c(()=>ut(`/api/me`,e),`Saved me.md`)&&l()};return q(S,{children:[q(`p`,{className:`faint`,style:{fontSize:12,margin:`0 0 12px`},children:[q(`code`,{children:e.path}),` is yours alone (gitignored): the role you hold and how to calibrate it, so an agent knows who it is helping. Blank is fine: full facilitation.`]}),q(`div`,{className:`toolbar`,style:{marginBottom:12},children:[q(`div`,{className:`grow`}),q(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Editor`,children:[q(`button`,{className:i?`on`:``,role:`radio`,"aria-checked":i,onClick:()=>a(!0),children:`Builder`}),q(`button`,{className:i?``:`on`,role:`radio`,"aria-checked":!i,onClick:()=>a(!1),children:`Source`})]}),q(`button`,{className:`primary small`,onClick:()=>void d(),disabled:!i&&n===e.text,children:`Save`})]}),i?q(S,{children:[q(`h3`,{className:`settings__h`,children:`Role`}),q(`div`,{className:`field`,children:[q(`span`,{children:`You are`}),q(Z,{value:o.role,onChange:e=>u({role:e.target.value}),style:{width:280},children:[q(`option`,{value:``,children:`No role: full facilitation`}),e.roles.map(e=>q(`option`,{value:e.name,children:e.title},e.name)),q(`option`,{value:Zo,children:`A role of your own…`})]})]}),o.role===Zo&&q(`div`,{className:`field`,children:[q(`span`,{children:`Called`}),q(`input`,{value:o.custom,placeholder:`Auditor`,onChange:e=>u({custom:e.target.value}),style:{width:280}})]}),o.role!==``&&q(`div`,{className:`field`,style:{alignItems:`start`},children:[q(`span`,{children:`Note`}),q(`textarea`,{rows:3,value:o.note,placeholder:`Anything about how you want to be helped, in your own words.`,onChange:e=>u({note:e.target.value})})]}),q(`h3`,{className:`settings__h`,children:`Calibration`}),q(`div`,{className:`field`,children:[q(`span`,{children:`Ownership`}),q(`input`,{value:o.ownership,placeholder:`What you own on this root, in your own words`,onChange:e=>u({ownership:e.target.value})})]}),q(`div`,{className:`field`,children:[q(`span`,{children:`Experience`}),q(Wt,{value:o.experience,options:[`new`,`familiar`,`deep`],placeholder:`Your experience with the scope: new, familiar, deep`,onChange:e=>u({experience:e})})]}),q(`div`,{className:`field`,children:[q(`span`,{children:`Technical capacity`}),q(Wt,{value:o.capacity,options:[`non-technical`,`some`,`fluent`],placeholder:`non-technical, some, fluent`,onChange:e=>u({capacity:e})})]})]}):q(`textarea`,{className:`editor`,style:{minHeight:`40vh`},value:n,onChange:e=>r(e.target.value),spellCheck:!1})]})}function $o(e){let{settings:t}=e,n=Dt(),r=t=>{n(()=>ut(`/api/settings`,t),`Preferences saved`).then(t=>t&&e.onSaved())},i=t.local.canvas,a=(e.properties?.custom??[]).filter(e=>e.type===`Date`||e.type===`Date & time`),o=t.shared.on_save,s=e=>r({shared:{on_save:e}}),c=(e,t,n)=>q(`label`,{className:`cv__pref`,children:[q(`input`,{type:`checkbox`,checked:i[e],onChange:t=>r({local:{canvas:{[e]:t.target.checked}}})}),q(`span`,{children:[q(`b`,{children:t}),q(`small`,{children:n})]})]});return q(`div`,{className:`page page--narrow`,children:[q(`div`,{className:`page__head`,children:q(`div`,{className:`grow`,children:[q(`h1`,{children:`Preferences`}),q(`p`,{children:`How this browser behaves for you. Saved as you change them; nothing is kept in the browser itself.`})]})}),q(Eo,{current:`/prefs`}),q(`h3`,{className:`settings__h`,children:`Theme`}),q(`div`,{className:`field`,children:[q(`span`,{children:`Colors`}),q(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Theme`,children:Do.map(e=>q(`button`,{className:t.local.theme===e.value?`on`:``,role:`radio`,"aria-checked":t.local.theme===e.value,onClick:()=>r({local:{theme:e.value}}),children:e.label},e.value))})]}),q(`p`,{className:`faint`,style:{fontSize:12},children:`System follows the operating system and is what most people want; Light or Dark holds one.`}),q(`h3`,{className:`settings__h`,children:`Canvas`}),c(`wheel_zoom`,`Scroll wheel zooms`,`On: the wheel zooms, ⇧ wheel pans sideways, a trackpad still pans. Off: the wheel pans, ⌘ wheel zooms.`),c(`right_drag_pan`,`Right-drag pans`,`On: hold the right button to pan; a plain right click still opens the menu. Off: the right button only opens the menu.`),c(`ctrl_click_menu`,`Ctrl-click opens the menu`,`On: Ctrl + click opens the context menu, as in Figma. Off: Ctrl + click adds to the selection.`),c(`enter_commits`,`Enter finishes an edit`,`On: Enter finishes typing in a sticky, text, or description, ⇧ Enter breaks a line. Off: Enter breaks a line, ⌘ Enter finishes.`),c(`context_menu`,`Right-click opens the menu`,`On: a right click opens the context menu. Off: a right click on an object opens its details instead; everything the menu offers has a shortcut.`),c(`resize_all`,`Resize all objects`,`On: every node shows corner grips and takes an exact box. Off: only text elements resize; frames always do.`),q(`p`,{className:`faint`,style:{fontSize:12},children:[`How a node looks by default is the framework's: `,q(`a`,{href:`/settings/properties`,children:`Framework Settings → Properties`}),`, the default style on each property.`]}),q(`h3`,{className:`settings__h`,children:`Tables`}),q(`div`,{className:`field`,children:[q(`span`,{children:`Rows per page`}),q(Z,{value:String(t.local.tables.page_size),onChange:e=>r({local:{tables:{page_size:Number(e.target.value)}}}),children:[25,50,100,250].map(e=>q(`option`,{value:String(e),children:e},e))})]}),q(`p`,{className:`faint`,style:{fontSize:12},children:`Which columns each table hides is remembered here too, from the table's own column cog.`}),q(`h3`,{className:`settings__h`,children:[`On save `,q(`span`,{className:`badge accent`,children:`shared with the root`})]}),q(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:[`Applied to a blueprint's frontmatter whenever the browser saves it: the property named takes today's date, or the time. Kept in `,q(`code`,{children:t.files.shared}),`, so everyone in the root gets the same.`]}),o.length>0&&q(`table`,{className:`mini`,children:q(`tbody`,{children:o.map((e,t)=>q(`tr`,{children:[q(`td`,{children:q(Z,{value:e.property,onChange:e=>s(o.map((n,r)=>r===t?{...n,property:e.target.value}:n)),children:[!a.some(t=>t.name===e.property)&&q(`option`,{value:e.property,children:e.property}),a.map(e=>q(`option`,{value:e.name,children:[e.name,` (`,e.type,`)`]},e.name))]})}),q(`td`,{children:q(Z,{value:e.set,onChange:e=>s(o.map((n,r)=>r===t?{...n,set:e.target.value}:n)),children:[q(`option`,{value:`today`,children:`set to today (YYYY-MM-DD)`}),q(`option`,{value:`now`,children:`set to now (YYYY-MM-DDTHH:mm)`})]})}),q(`td`,{className:`x`,children:q(`button`,{className:`quiet icon danger`,onClick:()=>s(o.filter((e,n)=>n!==t)),"data-tip":`Remove rule`,"data-tip-pos":`left`,"aria-label":`Remove rule`,children:q(Zt,{})})})]},t))})}),q(`div`,{className:`rowbtn`,children:[q(`button`,{className:`small`,disabled:a.length===0,onClick:()=>s([...o,{property:a.find(e=>!o.some(t=>t.property===e.name))?.name??a[0].name,set:`today`}]),children:`+ Add rule`}),a.length===0&&q(`span`,{className:`faint`,style:{fontSize:12,alignSelf:`center`},children:`No Date property in the Properties table to set.`})]}),q(`h3`,{className:`settings__h`,children:`External editor`}),q(`div`,{className:`field`,children:[q(`span`,{children:`Command`}),q(`input`,{defaultValue:t.local.editor??``,placeholder:`code {file}`,onBlur:e=>{let n=e.target.value.trim();n!==(t.local.editor??``)&&r({local:{editor:n===``?null:n}})}})]}),q(`p`,{className:`faint`,style:{fontSize:12},children:[`What `,q(`b`,{children:`Editor ↗`}),` on a blueprint or a document runs, with `,q(`code`,{children:`{file}`}),` the file's path. Blank opens the file with the system's default app for it.`]}),q(`h3`,{className:`settings__h`,children:`Files`}),q(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:[q(`code`,{children:t.files.local}),` is yours and ignored by git; `,q(`code`,{children:t.files.shared}),` travels with the root. Both are plain YAML, editable by hand. Git and its diff viewer are under Plugins.`]})]})}function es(e){let[t,n]=N(null),[r,i]=N(0),a=Dt();if(P(()=>{ct(`/api/check`).then(n).catch(()=>void 0)},[e.tick,r]),!t)return q(hn,{});let o=new Map;for(let e of t.findings){let t=e.path??`(root)`;o.set(t,[...o.get(t)??[],e])}return q(`div`,{className:`page page--narrow`,children:[q(`div`,{className:`page__head`,children:[q(`div`,{className:`grow`,children:[q(`h1`,{children:`Health Check`}),q(`p`,{children:[t.blueprints,` blueprints in `,t.collections,` collections · Eidos `,t.eidos_version??`?`,` · `,t.naming]})]}),q(`div`,{className:`toolbar`,children:[q(`span`,{className:`badge ${t.errors>0?`error`:`ok`}`,children:[t.errors,` errors`]}),q(`span`,{className:`badge ${t.warnings>0?`warn`:`ok`}`,children:[t.warnings,` warnings`]}),q(`button`,{onClick:()=>i(e=>e+1),children:`Re-run`}),q(`button`,{onClick:()=>void a(()=>lt(`/api/index`),`Index rebuilt`).then(t=>{t&&(e.onChanged(),i(e=>e+1))}),children:`Rebuild index`})]})]}),q(Eo,{current:`/check`}),t.findings.length===0&&q(`div`,{className:`empty`,children:`No findings. The root reads clean.`}),[...o.entries()].map(([t,n])=>q(`div`,{style:{marginBottom:18},children:[q(`div`,{className:`mono`,style:{marginBottom:4},children:t.endsWith(`.md`)&&!t.startsWith(`.eidos`)?q(`a`,{href:vt(t.split(`/`)[0]??``,t),children:t}):t}),q(`ul`,{className:`findings`,children:n.map((t,n)=>q(`li`,{className:t.level,children:[q(`code`,{children:t.code}),t.message,t.fix&&q(`button`,{className:`small`,style:{marginLeft:10},onClick:()=>void a(()=>lt(`/api/fix`,{code:t.code,path:t.path}),`Fixed`).then(t=>{t&&(e.onChanged(),i(e=>e+1))}),children:t.fix})]},n))})]},t))]})}function ts(e){let[t,n]=N(null),r=F(null);P(()=>{let t=!0;return ct(e.url).then(e=>t&&n(e.html)).catch(e=>t&&n(`<p>${e.message}</p>`)),()=>{t=!1}},[e.url]);let i=je(()=>t===null?{html:``,toc:[]}:$r(t),[t]),a=e=>{r.current?.querySelector(`#${CSS.escape(e)}`)?.scrollIntoView({behavior:`smooth`,block:`start`})},o=i.toc.length>0;return q(`div`,{className:`page page--doc`,children:[q(`div`,{className:`page__head`,children:q(`div`,{className:`grow`,children:q(`h1`,{children:e.title})})}),e.tabs&&q(`nav`,{className:`tabs`,children:e.tabs.map(e=>q(`a`,{href:e.href,className:e.active?`on`:``,"data-tip":e.summary,"data-tip-pos":`bottom`,children:e.name},e.name))}),t===null?q(hn,{}):q(`div`,{className:`doc${o?` doc--rail`:``}`,children:[q(`div`,{className:`doc__body`,ref:r,children:q(At,{html:i.html})}),o&&q(`aside`,{className:`doc__rail`,children:q(`nav`,{className:`toc`,children:[q(`div`,{className:`history__h`,children:q(`span`,{children:`Contents`})}),i.toc.map(e=>q(`a`,{href:`#${e.id}`,className:`toc__${e.level}`,onClick:t=>(t.preventDefault(),t.stopPropagation(),a(e.id)),children:e.text},e.id))]})})]})]})}function ns(e){let[t,n]=N(null),[r,i]=N(null),[a,o]=N(!1),[s,c]=N(``),l=F(null),u=Dt(),{settings:d,save:f}=zr(),p=d?.local.source_mode??!1;P(()=>{let t=!0;return ct(`/api/docs/${st(e.path)}`).then(e=>t&&(n(e),i(null))).catch(e=>t&&i(e.message)),()=>{t=!1}},[e.path,e.tick]);let m=je(()=>t?$r(t.html):{html:``,toc:[]},[t]),h=e=>{l.current?.querySelector(`#${CSS.escape(e)}`)?.scrollIntoView({behavior:`smooth`,block:`start`})},g=async()=>{let t=await u(()=>ut(`/api/docs/${st(e.path)}`,{text:s}),`Saved`);t&&(n(t),o(!1),e.onSaved())};if(r)return q(`div`,{className:`page empty`,children:r});if(!t)return q(hn,{});let _=!a&&(!p&&m.toc.length>0||t.history.length>0);return q(`div`,{className:`page page--doc`,children:[q(`div`,{className:`page__head`,children:[q(`div`,{className:`grow`,children:[q(`h1`,{children:t.title}),q(`p`,{className:`mono faint`,children:t.path})]}),q(`div`,{className:`toolbar`,children:a?q(S,{children:[q(`button`,{className:`small primary`,onClick:()=>void g(),children:`Save`}),q(`button`,{className:`small quiet`,onClick:()=>o(!1),children:`Cancel`})]}):q(S,{children:[q(ri,{source:p,onChange:e=>void f({local:{source_mode:e}})}),q(`button`,{className:`small`,onClick:()=>(c(t.raw),o(!0)),children:`Edit`}),q(`button`,{className:`small quiet`,onClick:()=>void u(()=>lt(`/api/open`,{path:t.path}),`Opened in your editor`),"data-tip":`Open the file in the external editor set under Preferences`,"data-tip-pos":`bottom`,children:`Editor ↗`})]})})]}),a?q(`textarea`,{className:`editor`,value:s,onChange:e=>c(e.target.value),spellCheck:!1}):q(`div`,{className:`doc${_?` doc--rail`:``}`,children:[q(`div`,{className:`doc__body`,ref:l,children:p?q(`pre`,{className:`source`,children:t.raw}):q(At,{html:m.html,base:t.path})}),_&&q(`aside`,{className:`doc__rail`,children:[!p&&m.toc.length>0&&q(`nav`,{className:`toc`,children:[q(`div`,{className:`history__h`,children:q(`span`,{children:`Contents`})}),m.toc.map(e=>q(`a`,{href:`#${e.id}`,className:`toc__${e.level}`,onClick:t=>(t.preventDefault(),t.stopPropagation(),h(e.id)),children:e.text},e.id))]}),t.history.length>0&&q(ni,{path:t.path,history:t.history,diffable:!1})]})]})]})}function rs(e){let t=e.root.framework.collections,[n,r]=N(e.collection??t[0]?.name??``),[i,a]=N(``),[o,s]=N(``),[c,l]=N(``),[u,d]=N(``),[f,p]=N(!1),m=Dt(),h=t.find(e=>e.name===n),g=h?.grouping?.groups??[],_=async()=>{p(!0);let t=await m(()=>lt(`/api/blueprints`,{collection:n,title:i,group:o||null,variant:c||null,summary:u||null}));p(!1),t&&(e.onCreated(),e.onClose(),ht(vt(t.collection,t.path)))};return q(wt,{title:`New blueprint`,size:`sm`,center:!0,onClose:e.onClose,foot:q(S,{children:[q(`button`,{onClick:e.onClose,children:`Cancel`}),q(`button`,{className:`primary`,onClick:()=>void _(),disabled:f||i.trim()===``,children:`Create`})]}),children:q(`div`,{style:{padding:`4px 18px 12px`},children:[q(`div`,{className:`form`,children:[q(`label`,{children:`Collection`}),q(Z,{value:n,onChange:e=>(r(e.target.value),s(``),l(``)),children:t.map(e=>q(`option`,{value:e.name,children:e.name},e.name))}),q(`label`,{children:`Title`}),q(`input`,{ref:gn,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&i.trim()!==``&&void _()}),g.length>0&&q(S,{children:[q(`label`,{children:h?.grouping?.label??`Group`}),q(Z,{value:o,onChange:e=>s(e.target.value),children:[q(`option`,{value:``,children:`—`}),g.map(e=>q(`option`,{value:e.name,children:e.name},e.name))]})]}),q(`label`,{children:`Variant`}),q(`span`,{children:[q(Z,{value:c,onChange:e=>l(e.target.value),style:{width:`100%`},children:[q(`option`,{value:``,children:[`default`,h?` (${h.variants.find(e=>e.default)?.name??h.variants[0]?.name??``})`:``]}),h?.variants.map(e=>q(`option`,{value:e.name,children:e.name},e.name))]}),(()=>{let e=h?.variants.find(e=>e.name===(c||(h?.variants.find(e=>e.default)?.name??h?.variants[0]?.name)));return e?.description?q(`span`,{className:`field__hint`,children:e.description}):null})()]}),q(`label`,{children:`Summary`}),q(`input`,{value:u,placeholder:`one plain line`,onChange:e=>d(e.target.value)})]}),q(`p`,{className:`faint`,style:{fontSize:12,margin:0},children:[`Scaffolds the file from the variant's template, as `,q(`code`,{children:`eidos new`}),` does.`]})]})})}function is(e){let[t,n]=N(``),[r,i]=N(``),[a,o]=N(!1),[s,c]=N(!1),l=Dt(),u=async()=>{c(!0);let n=await l(()=>lt(`/api/versions`,{version:t,commit:r||null,tag:a}),`Version recorded`);c(!1),n&&(e.onRecorded(),e.onClose())};return q(wt,{title:`Record a version of the root`,size:`sm`,center:!0,onClose:e.onClose,foot:q(S,{children:[q(`button`,{onClick:e.onClose,children:`Cancel`}),q(`button`,{className:`primary`,onClick:()=>void u(),disabled:s||t.trim()===``||!e.gitHead,children:`Record`})]}),children:q(`div`,{style:{padding:`4px 18px 12px`},children:[!e.gitHead&&q(`p`,{className:`findings`,children:q(`span`,{className:`error`,children:`This root is not in a git repository; a version names a commit.`})}),q(`p`,{className:`muted`,style:{margin:`0 0 10px`,fontSize:13},children:`A fixed point a team holds the definition against later. The commit is the snapshot; nothing is copied. Not the product's release version.`}),q(`div`,{className:`form`,children:[q(`label`,{children:`Version`}),q(`input`,{ref:gn,value:t,placeholder:`the root's own number, e.g. 1.0.0`,onChange:e=>n(e.target.value)}),q(`label`,{children:`Commit`}),q(`input`,{value:r,placeholder:e.gitHead&&e.gitHead!==`HEAD`?`HEAD (${e.gitHead.slice(0,12)})`:`HEAD`,onChange:e=>i(e.target.value)}),q(`label`,{children:`Tag`}),q(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,color:`var(--text)`},children:[q(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),style:{width:`auto`}}),`create `,q(`code`,{children:[`blueprints/`,t.trim()||`<version>`]}),` on that commit`]})]})]})})}var as=e=>e.replace(/^@/,``).replace(/\s+/g,``);function os(e){let{root:t}=e,n=t.settings,[r,i]=N(n.shared.users);P(()=>i(n.shared.users),[n.shared.users]);let a=Dt(),o=(t,n)=>{a(()=>ut(`/api/settings`,t),n).then(t=>t&&e.onSaved())},s=e=>{i(e),o({shared:{users:e}},`Users saved`)},c=(e,t)=>s(r.map((n,r)=>r===e?{...n,...t}:n)),l=t.roles.map(e=>e.name),u=t.roles.find(e=>e.name===t.actor.role||e.title===t.actor.role)?.name??t.actor.role,d=t.git.user,f=!d||r.some(e=>W(e,d)),p=(e,t)=>e!==``&&r.some((n,r)=>r!==t&&n.alias?.toLowerCase()===e.toLowerCase());return q(`div`,{className:`page page--narrow`,children:[q(`div`,{className:`page__head`,children:q(`div`,{className:`grow`,children:[q(`h1`,{children:`Users`}),q(`p`,{children:[`The people who work in this root. Comments are signed by whoever this machine acts as; @alias in a comment mentions a listed user. Kept in `,n.files.shared,`, shared with the root.`]})]})}),q(Eo,{current:`/users`}),n.shared.features.git&&d&&!f&&q(`div`,{className:`rowbtn`,children:[q(`button`,{className:`small`,onClick:()=>s([...r,{name:d.name,alias:as(d.name.split(/\s+/)[0]?.toLowerCase()??``)||null,role:u,email:d.email}]),children:[`+ Add `,d.name,` as a user`]}),q(`span`,{className:`faint`,style:{fontSize:12,alignSelf:`center`},children:[`with the role from your me.md`,u?` (${u})`:``]})]}),q(`h3`,{className:`settings__h`,children:`People`}),r.length===0?q(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:`No users yet. Without any, a comment is signed by the git identity, or by the role in me.md.`}):q(`table`,{className:`mini`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Display name`}),q(`th`,{children:`Alias`}),q(`th`,{children:`Role`}),q(`th`,{children:`Email`}),q(`th`,{})]})}),q(`tbody`,{children:r.map((e,t)=>q(`tr`,{children:[q(`td`,{children:q(`input`,{defaultValue:e.name,onBlur:n=>{let r=n.target.value.trim();r!==``&&r!==e.name&&c(t,{name:r})}})}),q(`td`,{children:q(`span`,{style:{display:`flex`,alignItems:`center`,gap:2},children:[q(`span`,{className:`faint`,children:`@`}),q(`input`,{defaultValue:e.alias??``,placeholder:`alias`,style:{width:110},onBlur:n=>{let r=as(n.target.value);if(n.target.value=r,p(r,t)){n.target.value=e.alias??``;return}(r||null)!==e.alias&&c(t,{alias:r||null})}})]})}),q(`td`,{children:q(Z,{value:e.role??``,onChange:e=>c(t,{role:e.target.value||null}),children:[q(`option`,{value:``,children:`none`}),!l.includes(e.role??``)&&e.role&&q(`option`,{value:e.role,children:e.role}),l.map(e=>q(`option`,{value:e,children:e},e))]})}),q(`td`,{children:q(`input`,{defaultValue:e.email??``,placeholder:`ties to git`,onBlur:n=>{let r=n.target.value.trim();(r||null)!==e.email&&c(t,{email:r||null})}})}),q(`td`,{className:`x`,children:q(`button`,{className:`quiet icon danger`,onClick:()=>s(r.filter((e,n)=>n!==t)),"data-tip":`Remove`,"data-tip-pos":`left`,"aria-label":`Remove user`,children:q(Zt,{})})})]},t))})]}),q(`div`,{className:`rowbtn`,children:q(`button`,{className:`small`,onClick:()=>s([...r,{name:`Someone ${r.length+1}`,alias:null,role:null,email:null}]),children:`+ Add user`})}),q(`p`,{className:`faint`,style:{fontSize:12},children:[`An alias has no spaces and is what an @mention types. A user's role is one of the framework's, from `,q(`code`,{children:`.eidos/roles/`}),`. Who this machine acts as is picked in the sidebar and kept in `,q(`code`,{children:n.files.local}),`: swap to a client during a call, annotate as them, swap back. Attribution, not authentication.`]})]})}function ss(e){return q(`span`,{className:`s`,children:e.text.split(/(\[[^\]]*\])/g).map((e,t)=>e.startsWith(`[`)&&e.endsWith(`]`)&&e.length>2?q(`mark`,{children:e.slice(1,-1)},t):q(`span`,{children:e},t))})}function cs(e){let t=[];for(let n of e.canvases)t.push({label:n.title,where:`Canvas map`,href:bt(n.id)});for(let n of e.framework.collections)t.push({label:n.name,where:`Collection`,href:vt(n.name)});for(let n of e.framework.top_level??[]){let e=/^\.\.\/([^/].*\.md)$/.exec(n.path);e?.[1]&&t.push({label:n.title||e[1],where:`Document`,href:xt(e[1])})}t.push({label:`Health Check`,where:`Eidosmd CLI`,href:`/check`}),t.push({label:`The standard`,where:`Eidos Overview`,href:`/learn/standard`});for(let n of e.guides)t.push({label:`Agent instructions: ${n.name}`,where:n.summary,href:`/learn/${n.name}`});for(let[e,n]of[[`general`,`Root`],[`collections`,`Collections`],[`properties`,`Properties`],[`vocabulary`,`Vocabulary`],[`templates`,`Templates`],[`roles`,`Roles`]])t.push({label:n,where:`Framework Settings`,href:`/settings/${e}`});return t.push({label:`Preferences`,where:`Eidosmd CLI`,href:`/prefs`}),t.push({label:`Users`,where:`Eidosmd CLI`,href:`/users`}),t.push({label:`Me`,where:`Eidosmd CLI`,href:`/settings/me`}),t}var ls=(e,t)=>t.every(t=>`${e.label} ${e.where}`.toLowerCase().includes(t));function us(e){let[t,n]=N(e.prefix??``),[r,i]=N([]),[a,o]=N(0),[s,c]=N(()=>e.root.settings.local.recent_searches.slice(0,3)),l=F(null),u=F(0),d=je(()=>cs(e.root),[e.root]);P(()=>{l.current?.focus()},[]);let f=t.startsWith(`>`)?`places`:t.startsWith(`@`)?`blueprints`:`all`,p=(f===`all`?t:t.slice(1)).trim();P(()=>{let e=u.current+=1;if(p===``||f===`places`){i([]);return}let t=window.setTimeout(()=>{ct(`/api/search?q=${encodeURIComponent(p)}&limit=30`).then(t=>{u.current===e&&i(t.hits)}).catch(()=>void 0)},60);return()=>window.clearTimeout(t)},[p,f]);let m=je(()=>{if(p===``)return f===`places`?d.map(e=>({kind:`place`,place:e})):f===`blueprints`?[]:[...s.map(e=>({kind:`recent`,query:e})),...d.slice(0,8).map(e=>({kind:`place`,place:e}))];let e=p.toLowerCase().split(/\s+/).filter(e=>e!==``);return[...(f===`blueprints`?[]:d.filter(t=>ls(t,e)).slice(0,f===`places`?30:4)).map(e=>({kind:`place`,place:e})),...f===`places`?[]:r.map(e=>({kind:`hit`,hit:e}))]},[p,f,d,s,r]);P(()=>o(0),[m.length,p]);let h=()=>{if(p===``)return;let n=[t,...s.filter(e=>e!==t)].slice(0,3);c(n),ut(`/api/settings`,{local:{recent_searches:n}}).then(()=>e.onSettingsSaved()).catch(()=>void 0)},g=t=>{if(t){if(t.kind===`recent`){n(t.query);return}h(),e.onClose(),ht(t.kind===`place`?t.place.href:vt(t.hit.collection,t.hit.path))}},_=``,v=e=>e.kind===`recent`?`Recent searches`:e.kind===`place`?p===``?`Go to`:`Places`:`Blueprints`;return q(`div`,{className:`backdrop`,onMouseDown:t=>t.target===t.currentTarget&&e.onClose(),children:q(`div`,{className:`palette`,children:[q(`input`,{ref:l,value:t,placeholder:`Search blueprints and places… (> places, @ blueprints)`,onChange:e=>n(e.target.value),onKeyDown:t=>{t.key===`Escape`?e.onClose():t.key===`ArrowDown`?(t.preventDefault(),o(e=>Math.min(m.length-1,e+1))):t.key===`ArrowUp`?(t.preventDefault(),o(e=>Math.max(0,e-1))):t.key===`Enter`&&g(m[a])}}),q(`div`,{className:`palette__list`,children:[p!==``&&m.length===0&&q(`div`,{className:`palette__empty`,children:`Nothing matches.`}),m.map((e,t)=>{let n=v(e),r=n===_?null:n;_=n;let i=e.kind===`hit`?`h:${e.hit.path}`:e.kind===`place`?`p:${e.place.href}`:`r:${e.query}`;return q(`div`,{children:[r&&q(`div`,{className:`palette__section`,children:r}),q(`div`,{className:`palette__hit${t===a?` active`:``}`,onMouseEnter:()=>o(t),onClick:()=>g(e),children:[e.kind===`recent`&&q(S,{children:[q(`span`,{className:`t muted`,children:e.query}),q(`span`,{className:`w`,children:`↵ to search again`})]}),e.kind===`place`&&q(S,{children:[q(`span`,{className:`t`,children:e.place.label}),q(`span`,{className:`w`,children:e.place.where})]}),e.kind===`hit`&&q(S,{children:[q(`span`,{className:`t`,children:e.hit.field===`title`?q(ss,{text:e.hit.snippet}):e.hit.title}),q(`span`,{className:`w`,children:[e.hit.collection,e.hit.group?` / ${e.hit.group}`:``]}),e.hit.field!==`title`&&q(ss,{text:e.hit.snippet}),e.hit.field===`title`&&e.hit.summary&&q(`span`,{className:`s`,children:e.hit.summary})]})]})]},i)})]}),q(`div`,{className:`palette__foot`,children:[q(`span`,{children:[q(`kbd`,{children:`↑`}),` `,q(`kbd`,{children:`↓`}),` move`]}),q(`span`,{children:[q(`kbd`,{children:`↵`}),` open`]}),q(`span`,{children:[q(`kbd`,{children:`>`}),` places · `,q(`kbd`,{children:`@`}),` blueprints`]}),q(`span`,{style:{marginLeft:`auto`},children:e.engine===`sqlite`?`SQLite full-text index`:`in-memory scan`})]})]})})}function ds(e){let{root:t}=e,n=t.settings,r=Dt(),i=(t,n)=>{r(()=>ut(`/api/settings`,t),n).then(t=>t&&e.onSaved())},a=t.git.user;return q(`div`,{className:`page page--narrow`,children:[q(`div`,{className:`page__head`,children:q(`div`,{className:`grow`,children:[q(`h1`,{children:`Plugins`}),q(`p`,{children:[`What this browser can switch on for the root. A switch is kept in `,n.files.shared,`, shared with everyone in the root; a setting that only applies to this machine is marked and kept in `,n.files.local,`.`]})]})}),q(Eo,{current:`/plugins`}),q(`h3`,{className:`settings__h`,children:`Git`}),q(`label`,{className:`cv__pref`,children:[q(`input`,{type:`checkbox`,checked:n.shared.features.git,onChange:e=>i({shared:{features:{git:e.target.checked}}},e.target.checked?`Git plugin on`:`Git plugin off`)}),q(`span`,{children:[q(`b`,{children:`Read git for this root`}),q(`small`,{children:`A blueprint's history and the diff viewer, who signs a comment when nobody is acting as a user, and the versions of the root. Off, the browser never runs git.`})]})]}),n.shared.features.git&&q(`p`,{className:`faint`,style:{fontSize:12,margin:`4px 0 0 30px`},children:t.git.available?q(S,{children:[`This root is in a repository`,a?q(S,{children:[`; git says you are `,q(`b`,{children:a.name}),a.email?` <${a.email}>`:``]}):`, but git has no user.name set`,`.`]}):`This root is not in a git repository, so nothing is read yet.`}),n.shared.features.git&&q(S,{children:[q(`div`,{className:`field`,style:{marginTop:16},children:[q(`span`,{children:[`Diff viewer `,q(`span`,{className:`badge`,children:`this machine`})]}),q(`input`,{defaultValue:n.local.diff_viewer??``,placeholder:`code --diff {a} {b}`,onBlur:e=>{let t=e.target.value.trim();t!==(n.local.diff_viewer??``)&&i({local:{diff_viewer:t===``?null:t}},`Diff viewer saved`)}})]}),q(`p`,{className:`faint`,style:{fontSize:12},children:[`Opened from a blueprint's history with `,q(`code`,{children:`{a}`}),` the file as it was and `,q(`code`,{children:`{b}`}),` the file now; nothing is shown in the page itself. Examples: `,q(`code`,{children:`code --diff {a} {b}`}),`, `,q(`code`,{children:`opendiff {a} {b}`}),`, `,q(`code`,{children:`meld {a} {b}`}),`. Yours alone, in `,n.files.local,`.`]})]})]})}var fs=`https://eidosmd.com/docs/cli`;function ps(e){e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}function ms(){let[e,t]=N(null),[n,r]=N(null),[i,a]=N(0),o=I(()=>{ct(`/api/root`).then(e=>{t(e),r(null),a(e=>e+1)}).catch(e=>r(e.message))},[]);return P(o,[o]),P(()=>{e&&ps(e.settings.local.theme)},[e]),P(()=>{let e=new EventSource(`/api/events`);return e.onmessage=()=>o(),()=>e.close()},[o]),{root:e,error:n,tick:i,reload:o}}function hs(e){let t=[];for(let n of e.framework.top_level??[]){let e=/^\.\.\/([^/].*\.md)$/.exec(n.path);e?.[1]&&t.push({title:n.title||e[1],path:e[1]})}return t.some(e=>e.path===`README.md`)||t.unshift({title:`README`,path:`README.md`}),t}function gs(e){let{root:t}=e,n=Dt(),r=kt(),i=t=>e.path===t||e.path.startsWith(t+`/`)?`active`:``,a=new Map;for(let e of t.blueprints)a.set(e.collection,(a.get(e.collection)??0)+1);let o=async()=>{let t=await r.prompt({title:`New canvas`,label:`Title`,placeholder:`Product map`,confirm:`Create`});if(!t)return;let i=await n(()=>lt(`/api/canvas`,{title:t}));i&&(e.onChanged(),ht(bt(i.id)))},s=hs(t),c=t.settings.shared.users,l=t.settings.local.user??``,u=t.git.available?t.git.user:null,d=e=>e.alias??e.name,f=u?c.find(e=>W(e,u)):void 0,p=l===``?f?d(f):``:l,m=t=>{let r=t===``||f!==void 0&&t.toLowerCase()===d(f).toLowerCase();n(()=>ut(`/api/settings`,{local:{user:r?null:t}})).then(t=>t&&e.onChanged())},h=t.git.available&&t.git.user?`${t.git.user.name} (git)`:t.actor.role?`${t.actor.role} (me.md)`:`me`;return q(`aside`,{className:`sidebar${e.open?` open`:``}`,children:[q(`div`,{className:`brand`,children:[q(`img`,{className:`brand__mark`,src:`/mark.svg`,alt:``}),q(`span`,{className:`brand__word`,children:`Eidos`})]}),q(`div`,{className:`brand__root`,title:t.root,children:t.name}),c.length>0&&q(`label`,{className:`sidebar__acting sidebar__acting--top`,children:[q(`span`,{children:`Acting as`}),q(Z,{value:p,onChange:e=>m(e.target.value),"data-tip":`Comments and edits are signed by this user`,"data-tip-pos":`bottom`,children:[!f&&q(`option`,{value:``,children:h}),c.map(e=>q(`option`,{value:e.alias??e.name,children:[e.name,e.alias?` (@${e.alias})`:``]},e.alias??e.name))]})]}),q(`div`,{className:`sidebar__search`,onClick:e.onSearch,role:`button`,children:[q(`span`,{children:`Search…`}),q(`kbd`,{children:`/`})]}),q(`nav`,{className:`nav`,children:[q(`div`,{className:`nav__group`,children:[q(`span`,{children:`Canvas maps`}),q(`button`,{className:`quiet icon`,"data-tip":`New canvas`,"data-tip-pos":`left`,"aria-label":`New canvas`,onClick:()=>void o(),children:q(cn,{})})]}),t.canvases.length===0&&q(`div`,{className:`faint`,style:{padding:`2px 8px`,fontSize:12},children:`None yet.`}),t.canvases.map(e=>q(`a`,{href:bt(e.id),className:i(bt(e.id)),children:[q(`span`,{children:e.title}),q(`span`,{className:`count`,children:[e.pages,` page`,e.pages===1?``:`s`]})]},e.id)),q(`div`,{className:`nav__group`,children:[q(`span`,{children:`Collections`}),q(`button`,{className:`quiet icon`,"data-tip":`New blueprint`,"data-tip-pos":`left`,"aria-label":`New blueprint`,onClick:e.onNew,children:q(cn,{})})]}),t.framework.collections.map(e=>q(`a`,{href:vt(e.name),className:i(`/c/${encodeURIComponent(e.name)}`),children:[q(`span`,{children:e.name}),q(`span`,{className:`count`,children:a.get(e.name)??0})]},e.name)),q(`div`,{className:`nav__group`,children:q(`span`,{children:`Top-Level Docs`})}),s.map(e=>q(`a`,{href:xt(e.path),className:i(xt(e.path)),children:q(`span`,{children:e.title})},e.path)),q(`div`,{className:`nav__foot`,children:[q(`a`,{href:`/settings/general`,className:i(`/settings`),children:[q(en,{}),q(`span`,{children:`Framework Settings`})]}),q(`a`,{href:`/check`,className:vo.some(e=>i(e.href)!==``)?`active`:``,children:[q(on,{}),q(`span`,{children:`Eidosmd CLI`}),t.check.errors+t.check.warnings>0&&q(`span`,{className:`badge ${t.check.errors>0?`error`:`warn`}`,children:t.check.errors+t.check.warnings})]}),q(`a`,{href:`/learn/standard`,className:i(`/learn`),children:[q(ln,{}),q(`span`,{children:`Eidos Overview`})]}),q(`a`,{href:fs,target:`_blank`,rel:`noreferrer`,children:[q(tn,{}),q(`span`,{children:`Docs`})]})]})]}),q(`div`,{className:`sidebar__foot`,children:q(`div`,{className:`sidebar__version`,children:[q(`span`,{children:[`eidosmd `,t.cli_version]}),q(`span`,{children:[`Eidos `,t.framework.eidos_version??t.standard_version]})]})})]})}var _s=!1;function vs(){let{root:e,error:t,tick:n,reload:r}=ms(),i=gt(),a=St(),o=kt(),s=Dt(),[c,l]=N(!1),[u,d]=N(!1),[f,p]=N(!1);P(()=>p(!1),[i.path]);let[m,h]=N(!1);P(()=>{!e||e.settings.configured||_s||(_s=!0,o.choose({title:`Set up eidosmd for this root`,body:q(S,{children:[q(`p`,{style:{margin:`0 0 8px`},children:[`Nothing is configured for this root yet. Should the browser read git (a blueprint's history, who wrote a comment, the versions of the root)?`,e.git.head===null?` The root is not in a git repository right now, so this only matters once it is.`:``]}),q(`p`,{className:`faint`,style:{margin:0,fontSize:12},children:[`Written to `,e.settings.files.shared,`. People and aliases for @mentions are added under Users; `,q(`code`,{children:`eidos setup`}),` does the same from the terminal.`]})]}),options:[{value:`later`,label:`Later`},{value:`off`,label:`Without git`},{value:`on`,label:`Use git`,kind:`primary`}]}).then(e=>{(e===`on`||e===`off`)&&s(()=>ut(`/api/settings`,{shared:{features:{git:e===`on`}}})).then(e=>e&&r())}))},[e,o,s,r]);let g=I(e=>s(()=>ut(`/api/settings`,e)).then(e=>e?(r(),e):null),[s,r]);if(P(()=>{let e=e=>{e.target.closest(`input, textarea, select, [contenteditable]`)||(Mt(e)&&!e.altKey&&e.key.toLowerCase()===`o`?(e.preventDefault(),l(`@`)):Mt(e)&&!e.altKey&&e.key===`/`?(e.preventDefault(),l(`>`)):e.key===`/`&&!e.metaKey&&!e.ctrlKey&&!e.altKey?(e.preventDefault(),l(``)):e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!document.querySelector(`.cv`)&&(e.preventDefault(),d(e=>!e)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),Lt(`Anywhere`,[{keys:`/`,what:`Search blueprints and places`},{keys:`⌘O`,what:`Open a blueprint`},{keys:`⌘/`,what:`Go to a place`},{keys:`?`,what:`These shortcuts`}]),P(()=>{if(!e||i.segments.length>0)return;let t=e.canvases[0];ht(t?bt(t.id):e.framework.collections[0]?vt(e.framework.collections[0].name):`/check`,{replace:!0})},[e,i.segments.length]),t)return q(`div`,{className:`empty`,children:t});if(!e)return q(`div`,{className:`empty`,children:`Loading…`});let[_,...v]=i.segments,y;if(_===`canvas`&&v[0])y=q(oo,{id:v[0],page:v[1]??null,open:i.query.get(`open`),tick:n,settings:e.settings,onChanged:r});else if(_===`c`&&v[0])y=q(ho,{name:v[0],open:i.query.get(`open`),tick:n,settings:e.settings,onNew:e=>h(e),onSettingsSaved:r,onChanged:r});else if(_===`b`&&v.length>0)y=q(ii,{path:v.join(`/`),tick:n,layout:`page`,onSaved:r});else if(_===`doc`&&v.length>0)y=q(ns,{path:v.join(`/`),tick:n,onSaved:r});else if(_===`check`)y=q(es,{tick:n,onChanged:r});else if(_===`learn`){let t=v[0]??`standard`,n=[{name:`The standard`,summary:`Eidos ${e.standard_version}`,href:`/learn/standard`,active:t===`standard`},...e.guides.map(e=>({name:`${e.name.slice(0,1).toUpperCase()}${e.name.slice(1)}`,summary:e.summary,href:`/learn/${e.name}`,active:e.name===t}))];y=q(ts,{url:t===`standard`?`/api/standard`:`/api/instructions/${encodeURIComponent(t)}`,title:`Eidos Overview`,tabs:n})}else y=_===`prefs`?q($o,{settings:e.settings,properties:e.framework.properties,onSaved:r}):_===`plugins`?q(ds,{root:e,onSaved:r}):_===`users`?q(os,{root:e,onSaved:r}):_===`settings`?q(Oo,{tab:_o.find(e=>e.tab===v[0])?.tab??(v[0]===`me`?`me`:`general`),gitHead:e.git_head,onSaved:r}):q(`div`,{className:`empty`,children:[`Nothing at `,i.path,`.`]});return q(Rr.Provider,{value:{settings:e.settings,save:g},children:q(`div`,{className:`shell${f?` drawer-open`:``}`,onClick:a,children:[q(`button`,{className:`shell__menu`,onClick:()=>p(e=>!e),"aria-label":`Menu`,"aria-expanded":f,children:q(sn,{})}),q(`div`,{className:`shell__scrim`,onClick:()=>p(!1)}),q(gs,{root:e,path:i.path,open:f,onSearch:()=>l(``),onNew:()=>h(null),onChanged:r}),q(`main`,{className:`main`,children:y}),c!==!1&&q(us,{root:e,prefix:c,onClose:()=>l(!1),engine:e.search_engine,onSettingsSaved:r}),u&&q(zt,{onClose:()=>d(!1)}),m!==!1&&q(rs,{root:e,collection:m,onClose:()=>h(!1),onCreated:r})]})})}function ys(){return q(J,{children:q(Y,{children:q(vs,{})})})}var bs=document.getElementById(`app`);bs&&ot(bs).render(q(ys,{}));
|