eidosmd 0.3.0 → 0.3.1

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.
@@ -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 b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(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 S(t,s,i,a,null)}function S(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 C(e){return e.children}function ee(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(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`?w(e):null}function T(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??w(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&&E(o)}}function E(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}),E(e)}function te(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!D.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(D)}function D(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=D.__r=0}}function O(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,b=t.length;for(c=ne(n,t,y,c,b),d=0;d<b;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=re(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 ne(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]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(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=w(s)),pe(s,s));return r}function re(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=re(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ie(e,t){return t||=[],e==null||typeof e==`boolean`||(v(e)?e.some(function(e){ie(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 ae(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function A(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||ae(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ae(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,_,x,S,T,E,te,D,ne,re,ie,k,ae=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 ae==`function`){f=s.length;try{if(T=n.props,E=ae.prototype&&ae.prototype.render,te=(d=ae.contextType)&&i[d.__c],D=d?te?te.props.value:d.__:i,r.__c?S=(p=n.__c=r.__c).__=p.__E:(E?n.__c=p=new ae(T,D):(n.__c=p=new ee(T,D),p.constructor=ae,p.render=me),te&&te.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),E&&p.__s==null&&(p.__s=p.state),E&&ae.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,ae.getDerivedStateFromProps(T,p.__s))),h=p.props,_=p.state,p.__v=n,m)E&&ae.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),E&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(E&&ae.getDerivedStateFromProps==null&&T!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(T,D),n.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(T,p.__s,D)){n.__v!=r.__v&&(p.props=T,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=w(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(T,p.__s,D),E&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,x)})}if(p.context=D,p.props=T,p.__P=e,p.__e=!1,ne=t.__r,re=0,E)p.state=p.__s,p.__d=!1,ne&&ne(n),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,ne&&ne(n),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++re<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),E&&!m&&p.getSnapshotBeforeUpdate!=null&&(x=p.getSnapshotBeforeUpdate(h,_)),ie=d!=null&&d.type===C&&d.key==null?ue(d.props.children):d,c=O(e,v(ie)?ie:[ie],n,r,i,a,o,s,c,l,u),p.base=n.__e,n.__u&=-161,p.__h.length&&s.push(p),S&&(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--;)b(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,x=i.props||h,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`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==!!C&&(C?g.localName==C:g.nodeType==3)){n=g,s[d]=null;break}}if(n==null){if(C==null)return document.createTextNode(S);n=document.createElementNS(o,C,S.is&&S),l&&=(t.__m&&t.__m(r,s),!1),s=null}if(C==null)x===S||l&&n.data==S||(n.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&e.call(n.childNodes),!l&&s!=null)for(x={},d=0;d<n.attributes.length;d++)x[(g=n.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||A(n,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||A(n,d,g,x[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=``),O(r.type==`template`?n.content:n,v(m)?m:[m],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&w(i,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&_==null?n.removeAttribute(`value`):_!=null&&(_!==n[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&A(n,d,_,x[d],o),d=`checked`,y!=null&&y!=n[d]&&A(n,d,y,x[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||b(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=x(C,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,te(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,ee.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),te(this))},ee.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),te(this))},ee.prototype.render=C,r=[],a=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,o=function(e,t){return e.__v.__b-t.__v.__b},D.__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,De=Se.unmount,Oe=Se.__;function M(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(ze,e)}function ke(e,t,n){var r=M(_e++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ze(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=M(_e++,3);!Se.__s&&Re(n.__H,t)&&(n.__=e,n.u=t,j.__H.__h.push(n))}function Ae(e,t){var n=M(_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=M(_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=M(_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),Oe&&Oe(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){De&&De(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 ze(e,t){return typeof t==`function`?t(e):t}function Be(e,t){for(var n in t)e[n]=t[n];return e}function L(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 ee).isPureReactComponent=!0,Ve.prototype.shouldComponentUpdate=function(e,t){return L(this.props,e)||L(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=Be({},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 ee).__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&&x(C,null,e.fallback);return i&&(i.__u&=-33),[x(C,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]}};function Ze(e){return this.getChildContext=function(){return e.context},e.children}function Qe(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){he(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(e,n){this.childNodes.push(e),t.h.insertBefore(e,n)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.h.removeChild(e)}}}he(x(Ze,{context:t.context},e.__v),t.v)}function $e(e,t){var n=x(Qe,{__v:e,h:t});return n.containerInfo=t,n}(Ye.prototype=new ee).__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=ie(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 et=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,tt=/^(?: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]/,nt=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,R=/[A-Z0-9]/g,rt=typeof document<`u`,it=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};function at(e,t,n){return t.__k??(t.textContent=``),he(e,t),typeof n==`function`&&n(),e?e.__c:null}ee.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(ee.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var z=t.event;t.event=function(e){return z&&(e=z(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var B={configurable:!0,get:function(){return this.class}},V=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||rt&&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`||it(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:nt.test(a)&&(a=s):s=a=`oninput`:i&&tt.test(a)?a=a.replace(R,`-$&`).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=ie(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=ie(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",B)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=et,V&&V(e)};var ot=t.__r;t.__r=function(e){ot&&ot(e),e.__c};var st=t.diffed;t.diffed=function(e){st&&st(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 ct(e){return!!e.__k&&(he(null,e),!0)}function lt(e){return{render:function(t){at(t,e)},unmount:function(){ct(e)}}}function H(e){let t={};for(let[n,r]of Object.entries(e?.styles??{}))r.color&&(t[n]=r.color);return t}var U=e=>e.type===`collection`,ut=e=>e.folders.filter(U);function W(e){return e===`darwin`?`Finder`:e===`win32`?`Explorer`:`Files`}var G=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function dt(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 G(r.status,i.error??r.statusText);return i}var ft=e=>e.split(`/`).map(encodeURIComponent).join(`/`),pt=e=>dt(`GET`,e),mt=(e,t)=>dt(`POST`,e,t??{}),ht=(e,t)=>dt(`PUT`,e,t??{}),gt=(e,t)=>dt(`DELETE`,e,t),_t=(e,t)=>e.email!==null&&t.email!==null&&e.email.toLowerCase()===t.email.toLowerCase()||e.name.toLowerCase()===t.name.toLowerCase();function vt(){let e=new URL(window.location.href);return{path:e.pathname,segments:e.pathname.split(`/`).filter(e=>e!==``).map(decodeURIComponent),query:e.searchParams}}var yt=new Set,bt=null;function xt(e){bt=e}function St(e,t){t?window.history.replaceState(null,``,e):window.history.pushState(null,``,e);for(let e of yt)e()}function Ct(e,t={}){if(!bt){St(e,t.replace===!0);return}bt(e).then(n=>n&&St(e,t.replace===!0))}function wt(){let[e,t]=N(vt);return P(()=>{let e=()=>t(vt());return yt.add(e),window.addEventListener(`popstate`,e),()=>{yt.delete(e),window.removeEventListener(`popstate`,e)}},[]),e}var Tt=e=>e.map(encodeURIComponent).join(`/`),Et=(e,t)=>`/c/${encodeURIComponent(e)}${t?`?open=${encodeURIComponent(t)}`:``}`,Dt=e=>`/b/${Tt(e.split(`/`))}`,Ot=(e,t)=>`/canvas/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`,K=e=>`/doc/${Tt(e.split(`/`))}`;function kt(){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(),Ct(n))},[])}var q=0;Array.isArray;function J(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:--q,__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}var At=6,jt=8;function Mt(e){let[t,n]=N({position:`fixed`,top:0,left:0,visibility:`hidden`}),r=I(()=>{let t=e.anchor.current,r=e.menuRef.current;if(!t||!r)return;let i=t.getBoundingClientRect(),a=Math.max(r.offsetWidth,e.matchWidth?i.width:0),o=r.offsetHeight,s=i.bottom+At;s+o>window.innerHeight-jt&&i.top-At-o>=jt&&(s=i.top-At-o),s=Math.max(jt,Math.min(s,window.innerHeight-jt-o));let c=Math.max(jt,Math.min(i.left,window.innerWidth-jt-a));n({position:`fixed`,top:s,left:c,visibility:`visible`,...e.matchWidth?{minWidth:i.width}:{}})},[e.anchor,e.menuRef,e.matchWidth]);return Ae(()=>(r(),window.addEventListener(`scroll`,r,!0),window.addEventListener(`resize`,r),()=>{window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`resize`,r)}),[r]),Ae(()=>{let t=e.menuRef.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>r());return n.observe(t),()=>n.disconnect()},[r,e.menuRef]),$e(J(`div`,{ref:e.menuRef,className:`floating ${e.className}`,style:t,onMouseDown:e.onMouseDown,children:e.children}),document.body)}var Nt=(e,...t)=>t.some(t=>t.current?.contains(e.target)===!0);function Y(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]),J(`div`,{className:`backdrop${e.center?` center`:``}`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:J(`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)&&J(`div`,{className:`modal__head`,children:[e.title!==void 0&&J(`h2`,{children:e.title}),e.head,J(`button`,{className:`quiet icon`,onClick:t,"data-tip":`Close (Esc)`,"data-tip-pos":`bottom`,"aria-label":`Close`,children:J(dn,{})})]}),J(`div`,{className:`modal__body`,children:e.children}),e.foot&&J(`div`,{className:`modal__foot`,children:e.foot})]})})}var Pt=ge(()=>void 0);function Ft(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 J(Pt.Provider,{value:i,children:[e.children,t&&J(`div`,{className:`toast${t.kind===`error`?` error`:``}`,children:t.message})]})}var It=()=>Me(Pt);function Lt(){let e=It();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 Rt=ge({confirm:async()=>!1,prompt:async()=>null,choose:async()=>null});function zt(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 J(Rt.Provider,{value:a,children:[e.children,t&&J(Y,{title:t.options.title,size:`sm`,center:!0,onClose:()=>o(t.kind!==`confirm`&&null),children:J(`div`,{style:{padding:`4px 18px 16px`},children:[t.options.body&&J(`div`,{className:`muted`,style:{marginBottom:12},children:t.options.body}),t.kind===`prompt`&&J(`div`,{className:`form`,style:{gridTemplateColumns:t.options.label?`110px 1fr`:`1fr`,margin:0},children:[t.options.label&&J(`label`,{children:t.options.label}),J(`input`,{ref:On,value:r,placeholder:t.options.placeholder,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r.trim()!==``&&o(r.trim())}})]}),J(`div`,{className:`actions`,children:[t.kind===`choose`?t.options.options.map((e,n)=>J(`button`,{className:e.kind===`primary`?`primary`:e.kind===`danger`?`danger`:``,ref:n===t.options.options.length-1?On:void 0,onClick:()=>o(e.value),children:e.label},e.value)):J(`button`,{onClick:()=>o(t.kind!==`confirm`&&null),children:`Cancel`}),t.kind===`choose`?null:t.kind===`confirm`?J(`button`,{className:t.options.danger?`primary danger-fill`:`primary`,ref:On,onClick:()=>o(!0),children:t.options.confirm??`OK`}):J(`button`,{className:`primary`,disabled:r.trim()===``,onClick:()=>o(r.trim()),children:t.options.confirm??`OK`})]})]})})]})}var Bt=()=>Me(Rt);function Vt(e){return J(`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):Ct(Dt(a)))},dangerouslySetInnerHTML:{__html:e.html}})}var Ht=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),Ut=e=>e.metaKey||e.ctrlKey,Wt=Ht?{}:{"⌘":`Ctrl`,"⌥":`Alt`,"⇧":`Shift`,"⌃":`Ctrl`};function Gt(e){return J(`span`,{className:`keys`,children:e.combo.split(/\s+\/\s+|\s*·\s*/).map((e,t)=>J(`span`,{className:`keys__alt`,children:[t>0&&J(`span`,{className:`keys__or`,children:`or`}),(e.match(/[⇧⌘⌥⌃]|[^⇧⌘⌥⌃]+/g)??[e]).map((e,t)=>J(`kbd`,{className:/^[⇧⌘⌥⌃]$/.test(e)?`mod`:``,children:Wt[e]??e},t))]},t))})}var Kt=new Map,qt=new Set,Jt=()=>qt.forEach(e=>e());function Yt(e,t){let n=F(Symbol(e)),r=JSON.stringify(t);P(()=>{let t=n.current;return Kt.set(t,{where:e,entries:JSON.parse(r)}),Jt(),()=>{Kt.delete(t),Jt()}},[e,r])}function Xt(){let[,e]=N(0);return P(()=>{let t=()=>e(e=>e+1);return qt.add(t),()=>{qt.delete(t)}},[]),[...Kt.values()]}function Zt(e){let t=Xt();return J(Y,{title:`Keyboard shortcuts`,size:`sm`,center:!0,onClose:e.onClose,children:J(`div`,{style:{padding:`4px 18px 16px`},children:t.map(e=>J(`div`,{children:[J(`h3`,{className:`settings__h`,children:e.where}),J(`table`,{className:`mini`,children:J(`tbody`,{children:e.entries.map(e=>J(`tr`,{children:[J(`td`,{style:{whiteSpace:`nowrap`},children:J(Gt,{combo:e.keys})}),J(`td`,{className:`muted`,children:e.what})]},e.keys))})})]},e.where))})})}var Qt=`eidosmd:dropdown-open`;function $t(e){window.dispatchEvent(new CustomEvent(Qt,{detail:e}))}function en(e,t){P(()=>{let n=n=>{n.detail!==e&&t()};return window.addEventListener(Qt,n),()=>window.removeEventListener(Qt,n)},[e,t])}function tn(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===C&&n(r.props.children)};return n(e),t}function X(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=F(null),m=I(()=>u(!1),[]);en(d.current,m),P(()=>{if(!l)return;let e=e=>{Nt(e,f,p)||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[h,g]=N(!1),_=tn(r),v=String(t??``),y=_.find(e=>e.value===v)??_[0],b=e=>{u(!1),g(!0),e!==v&&n?.({target:{value:e}})},x={};for(let[e,t]of Object.entries(c))(e.startsWith(`data-`)||e.startsWith(`aria-`))&&typeof t==`string`&&(x[e]=t);return J(`div`,{ref:f,className:`select${l?` open`:``}${s?` ${s}`:``}`,style:o,title:a,...x,...h?{"data-tip-off":``}:{},onMouseLeave:()=>g(!1),children:[J(`button`,{type:`button`,className:`select__btn`,disabled:i,"aria-haspopup":`listbox`,"aria-expanded":l,onClick:()=>{l||$t(d.current),g(!0),u(!l)},children:[J(`span`,{className:`select__val`,children:y?.label??``}),J(`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:J(`path`,{d:`M4 6l4 4 4-4`})})]}),l&&J(Mt,{anchor:f,menuRef:p,className:`popover select__menu`,matchWidth:!0,children:J(`div`,{role:`listbox`,children:_.map(e=>J(`button`,{type:`button`,role:`option`,"aria-selected":e.value===v,className:e.value===v?`on`:``,disabled:e.disabled,onClick:()=>b(e.value),children:e.label},e.value))})})]})}function nn(e){let[t,n]=N(!1),[r,i]=N(0),[a,o]=N(!1),s=F({}),c=F(null),l=F(null),u=F(null),d=I(()=>n(!1),[]);en(s.current,d);let f=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),[f.length,e.value]),P(()=>{e.autoFocus&&c.current?.focus()},[e.autoFocus]);let p=t=>{n(!1),e.onChange(t),e.onCommit?.(t)},m=t&&f.length>0;return J(`div`,{ref:l,className:`suggest${m?` open`:``}${e.className?` ${e.className}`:``}`,style:e.style,children:[J(`input`,{ref:c,value:e.value,placeholder:e.placeholder,onChange:t=>{e.onChange(t.target.value),o(!0),n(!0)},onFocus:e=>{$t(s.current),o(!1),n(!0),e.target.select()},onBlur:()=>{n(!1),e.onCommit?.(e.value)},onKeyDown:t=>{if(t.key===`ArrowDown`&&f.length>0)t.preventDefault(),n(!0),i(e=>Math.min(f.length-1,e+1));else if(t.key===`ArrowUp`&&f.length>0)t.preventDefault(),i(e=>Math.max(0,e-1));else if(t.key===`Enter`){t.preventDefault();let e=f[r];m&&e!==void 0?p(e):c.current?.blur()}else t.key===`Escape`&&(n(!1),e.onCancel?.())}}),m&&J(Mt,{anchor:l,menuRef:u,className:`popover select__menu suggest__menu`,matchWidth:!0,onMouseDown:e=>e.preventDefault(),children:J(`div`,{role:`listbox`,children:f.map((t,n)=>J(`button`,{type:`button`,role:`option`,"aria-selected":n===r,className:`${n===r?`on`:``}${t===e.value?` held`:``}`,onMouseEnter:()=>i(n),onClick:()=>p(t),children:t},t))})})]})}var rn=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],an=e=>String(e).padStart(2,`0`),on=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 sn(e){let[t,n]=N(!1),[r,i]=N(e.value);P(()=>i(e.value),[e.value]);let a=new Date,o=on(e.value),[s,c]=N({y:o?.y??a.getFullYear(),m:o?.m??a.getMonth()+1}),l=F({}),u=F(null),d=F(null),f=I(()=>n(!1),[]);en(l.current,f),P(()=>{if(!t)return;let r=on(e.value);c({y:r?.y??a.getFullYear(),m:r?.m??a.getMonth()+1});let i=e=>{Nt(e,u,d)||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 p=()=>{t||$t(l.current),n(!t)},m=()=>{let t=r.trim();if(t===``){e.value!==``&&e.onChange(null);return}on(t)?t!==e.value&&e.onChange(t):i(e.value)},h=(t,r,i)=>{let a=`${t}-${an(r)}-${an(i)}`;e.onChange(e.time?`${a}T${o?.time||`09:00`}`:a),n(!1)},g=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}-${an(n.m)}-${an(n.d)}T${t}`)},_=e=>{let t=s.y*12+(s.m-1)+e;c({y:Math.floor(t/12),m:t%12+1})},v=new Date(s.y,s.m-1,1),y=new Date(s.y,s.m-1,1-v.getDay()),b=Array.from({length:42},(e,t)=>new Date(y.getFullYear(),y.getMonth(),y.getDate()+t)),x=e=>o!==null&&e.getFullYear()===o.y&&e.getMonth()+1===o.m&&e.getDate()===o.d,S=e=>e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()&&e.getDate()===a.getDate();return J(`div`,{ref:u,className:`datepick${t?` open`:``}${e.className?` ${e.className}`:``}`,children:[J(`input`,{value:r,placeholder:e.time?`YYYY-MM-DDTHH:MM`:`YYYY-MM-DD`,onChange:e=>i(e.target.value),onBlur:m,onKeyDown:t=>{t.key===`Enter`?t.target.blur():t.key===`Escape`&&i(e.value)}}),J(`button`,{type:`button`,className:`datepick__btn`,onClick:p,"aria-label":`Pick a date`,"aria-expanded":t,children:J(Cn,{})}),t&&J(Mt,{anchor:u,menuRef:d,className:`popover datepick__menu`,onMouseDown:e=>e.preventDefault(),children:[J(`div`,{className:`datepick__head`,children:[J(`button`,{type:`button`,onClick:()=>_(-1),"aria-label":`Previous month`,children:`‹`}),J(`strong`,{children:[rn[s.m-1],` `,s.y]}),J(`button`,{type:`button`,onClick:()=>_(1),"aria-label":`Next month`,children:`›`})]}),J(`div`,{className:`datepick__grid`,children:[[`S`,`M`,`T`,`W`,`T`,`F`,`S`].map((e,t)=>J(`span`,{children:e},t)),b.map(e=>J(`button`,{type:`button`,className:`${x(e)?`on`:``}${S(e)?` today`:``}${e.getMonth()===s.m-1?``:` faint`}`,onClick:()=>h(e.getFullYear(),e.getMonth()+1,e.getDate()),children:e.getDate()},e.toISOString()))]}),e.time&&J(`label`,{className:`datepick__time`,children:[`Time`,J(`input`,{defaultValue:o?.time??``,placeholder:`HH:MM`,onBlur:e=>g(e.target.value.trim()),onKeyDown:e=>e.key===`Enter`&&e.target.blur()})]}),J(`div`,{className:`datepick__foot`,children:[J(`button`,{type:`button`,onClick:()=>(e.onChange(null),n(!1)),children:`Clear`}),J(`button`,{type:`button`,onClick:()=>h(a.getFullYear(),a.getMonth()+1,a.getDate()),children:`Today`})]})]})]})}var cn={viewBox:`0 0 16 16`,width:14,height:14,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`};function ln(){return J(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,children:J(`path`,{d:`M11.5 2.5l2 2L5 13H3v-2l8.5-8.5z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinejoin:`round`})})}function un(){return J(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,children:J(`path`,{d:`M9.5 2.5h4v4M13.5 2.5L9 7M6.5 13.5h-4v-4M2.5 13.5L7 9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Z(){return J(`svg`,{...cn,"aria-hidden":`true`,children:J(`path`,{d:`M2.5 4.5h11M6 4.5V3h4v1.5M4 4.5l.7 8.5h6.6l.7-8.5M6.7 7v4M9.3 7v4`})})}function dn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:J(`path`,{d:`M4 4l8 8M12 4l-8 8`})})}var fn=(()=>{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 pn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:[J(`path`,{d:fn,strokeLinejoin:`round`}),J(`circle`,{cx:`8`,cy:`8`,r:`2`})]})}function mn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:J(`path`,{d:`M7 3H3.5v9.5H13V9M9.5 2.5H13.5v4M13.5 2.5L7.5 8.5`})})}function hn(e){return J(`svg`,{...cn,"aria-hidden":`true`,style:{transform:e.direction===`down`?`rotate(180deg)`:`none`},children:J(`path`,{d:`M8 13V3M3.5 7.5L8 3l4.5 4.5`})})}function gn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:[J(`circle`,{cx:`3.5`,cy:`8`,r:`0.9`,fill:`currentColor`}),J(`circle`,{cx:`8`,cy:`8`,r:`0.9`,fill:`currentColor`}),J(`circle`,{cx:`12.5`,cy:`8`,r:`0.9`,fill:`currentColor`})]})}function _n(){return J(`svg`,{...cn,"aria-hidden":`true`,children:[J(`circle`,{cx:`8`,cy:`8`,r:`6.2`}),J(`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 vn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:[J(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),J(`path`,{d:`M4.5 6l2 2-2 2M8 10h3`})]})}function yn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:J(`path`,{d:`M2.5 4.5h11M2.5 8h11M2.5 11.5h11`})})}function bn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:J(`path`,{d:`M8 3v10M3 8h10`})})}function xn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:[J(`path`,{d:`M3.5 3.5A1.5 1.5 0 015 2h8v10.5H5a1.5 1.5 0 00-1.5 1.5z`}),J(`path`,{d:`M3.5 12.5A1.5 1.5 0 015 11h8v3H5a1.5 1.5 0 01-1.5-1.5M6 5h4`})]})}function Sn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:[J(`path`,{d:`M9 2H4.5A1 1 0 003.5 3v10a1 1 0 001 1h7a1 1 0 001-1V6zM9 2v4h3.5`}),J(`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 Cn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:[J(`rect`,{x:`2.5`,y:`3.5`,width:`11`,height:`10`,rx:`1.5`}),J(`path`,{d:`M2.5 6.5h11M5.5 2v3M10.5 2v3`})]})}function wn(){return J(`svg`,{...cn,"aria-hidden":`true`,children:[J(`rect`,{x:`3.5`,y:`7`,width:`9`,height:`6.5`,rx:`1.5`}),J(`path`,{d:`M5.5 7V5a2.5 2.5 0 015 0v2`})]})}function Tn(e){return J(`svg`,{...cn,"aria-hidden":`true`,style:{transform:e.open?`rotate(90deg)`:`none`,transition:`transform 0.12s`},children:J(`path`,{d:`M6 3.5l4.5 4.5L6 12.5`})})}function En(e){let t=e.type.toLowerCase();return t===`list`?J(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[J(`path`,{d:`M5 4h8M5 8h8M5 12h8`}),J(`circle`,{cx:`2.5`,cy:`4`,r:`0.6`,fill:`currentColor`}),J(`circle`,{cx:`2.5`,cy:`8`,r:`0.6`,fill:`currentColor`}),J(`circle`,{cx:`2.5`,cy:`12`,r:`0.6`,fill:`currentColor`})]}):t===`number`?J(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:J(`path`,{d:`M6 2 4 14M12 2l-2 12M3 6h11M2 10h11`})}):t===`checkbox`?J(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[J(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`2`}),J(`path`,{d:`m5 8 2 2 4-4`})]}):t.startsWith(`date`)?J(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[J(`rect`,{x:`2.5`,y:`3.5`,width:`11`,height:`10`,rx:`2`}),J(`path`,{d:`M2.5 7h11M5.5 2v3M10.5 2v3`})]}):J(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:J(`path`,{d:`M3 4h10M8 4v9M5.5 13h5`})})}function Dn(){return J(`div`,{className:`empty`,children:`Loading…`})}function On(e){e?.focus()}function kn(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 An=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function jn(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}var Mn=null;function Nn(e={}){return Mn||(e.includeStyleProperties?(Mn=e.includeStyleProperties,Mn):(Mn=jn(window.getComputedStyle(document.documentElement)),Mn))}function Pn(e,t){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace(`px`,``)):0}function Fn(e){let t=Pn(e,`border-left-width`),n=Pn(e,`border-right-width`);return e.clientWidth+t+n}function In(e){let t=Pn(e,`border-top-width`),n=Pn(e,`border-bottom-width`);return e.clientHeight+t+n}function Ln(e,t={}){return{width:t.width||Fn(e),height:t.height||In(e)}}function Rn(){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 zn=16384;function Bn(e){(e.width>zn||e.height>zn)&&(e.width>zn&&e.height>zn?e.width>e.height?(e.height*=zn/e.width,e.width=zn):(e.width*=zn/e.height,e.height=zn):e.width>zn?(e.height*=zn/e.width,e.width=zn):(e.width*=zn/e.height,e.height=zn))}function Vn(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 Hn(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function Un(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),Hn(i)}var Wn=(e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Wn(n,t)};function Gn(e){let t=e.getPropertyValue(`content`);return`${e.cssText} content: '${t.replace(/'|"/g,``)}';`}function Kn(e,t){return Nn(t).map(t=>`${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t)?` !important`:``};`).join(` `)}function qn(e,t,n,r){let i=`.${e}:${t}`,a=n.cssText?Gn(n):Kn(n,r);return document.createTextNode(`${i}{${a}}`)}function Jn(e,t,n,r){let i=window.getComputedStyle(e,n),a=i.getPropertyValue(`content`);if(a===``||a===`none`)return;let o=An();try{t.className=`${t.className} ${o}`}catch{return}let s=document.createElement(`style`);s.appendChild(qn(o,n,i,r)),t.appendChild(s)}function Yn(e,t,n){Jn(e,t,`:before`,n),Jn(e,t,`:after`,n)}var Xn=`application/font-woff`,Zn=`image/jpeg`,Qn={woff:Xn,woff2:Xn,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 $n(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:``}function er(e){return Qn[$n(e).toLowerCase()]||``}function tr(e){return e.split(/,/)[1]}function nr(e){return e.search(/^(data:)/)!==-1}function rr(e,t){return`data:${t};base64,${e}`}async function ir(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 ar={};function or(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 sr(e,t,n){let r=or(e,t,n.includeQueryParams);if(ar[r]!=null)return ar[r];n.cacheBust&&(e+=(/\?/.test(e)?`&`:`?`)+new Date().getTime());let i;try{i=rr(await ir(e,n.fetchRequestInit,({res:e,result:n})=>(t||=e.headers.get(`Content-Type`)||``,tr(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 ar[r]=i,i}async function cr(e){let t=e.toDataURL();return t===`data:,`?e.cloneNode(!1):Vn(t)}async function lr(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),Vn(t.toDataURL())}let n=e.poster;return Vn(await sr(n,er(n),t))}async function ur(e,t){try{if(e?.contentDocument?.body)return await br(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function dr(e,t){return Wn(e,HTMLCanvasElement)?cr(e):Wn(e,HTMLVideoElement)?lr(e,t):Wn(e,HTMLIFrameElement)?ur(e,t):e.cloneNode(pr(e))}var fr=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SLOT`,pr=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SVG`;async function mr(e,t,n){if(pr(t))return t;let r=[];return r=fr(e)&&e.assignedNodes?jn(e.assignedNodes()):Wn(e,HTMLIFrameElement)&&e.contentDocument?.body?jn(e.contentDocument.body.childNodes):jn((e.shadowRoot??e).childNodes),r.length===0||Wn(e,HTMLVideoElement)||await r.reduce((e,r)=>e.then(()=>br(r,n)).then(e=>{e&&t.appendChild(e)}),Promise.resolve()),t}function hr(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):Nn(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`),Wn(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 gr(e,t){Wn(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Wn(e,HTMLInputElement)&&t.setAttribute(`value`,e.value)}function _r(e,t){if(Wn(e,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(t=>e.value===t.getAttribute(`value`));r&&r.setAttribute(`selected`,``)}}function vr(e,t,n){return Wn(t,Element)&&(hr(e,t,n),Yn(e,t,n),gr(e,t),_r(e,t)),t}async function yr(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 br(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 br(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(e=>dr(e,t)).then(n=>mr(e,n,t)).then(n=>vr(e,n,t)).then(e=>yr(e,t))}var xr=/url\((['"]?)([^'"]+?)\1\)/g,Sr=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Cr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function wr(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}function Tr(e){let t=[];return e.replace(xr,(e,n,r)=>(t.push(r),e)),t.filter(e=>!nr(e))}async function Er(e,t,n,r,i){try{let a=n?kn(t,n):t,o=er(t),s;return s=i?rr(await i(a),o):await sr(a,o,r),e.replace(wr(t),`$1${s}$3`)}catch{}return e}function Dr(e,{preferredFontFormat:t}){return t?e.replace(Cr,e=>{for(;;){let[n,,r]=Sr.exec(e)||[];if(!r)return``;if(r===t)return`src: ${n};`}}):e}function Or(e){return e.search(xr)!==-1}async function kr(e,t,n){if(!Or(e))return e;let r=Dr(e,n);return Tr(r).reduce((e,r)=>e.then(e=>Er(e,r,t,n)),Promise.resolve(r))}async function Ar(e,t,n){let r=t.style?.getPropertyValue(e);if(r){let i=await kr(r,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function jr(e,t){await Ar(`background`,e,t)||await Ar(`background-image`,e,t),await Ar(`mask`,e,t)||await Ar(`-webkit-mask`,e,t)||await Ar(`mask-image`,e,t)||await Ar(`-webkit-mask-image`,e,t)}async function Mr(e,t){let n=Wn(e,HTMLImageElement);if(!(n&&!nr(e.src))&&!(Wn(e,SVGImageElement)&&!nr(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,i=await sr(r,er(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 Nr(e,t){let n=jn(e.childNodes).map(e=>Pr(e,t));await Promise.all(n).then(()=>e)}async function Pr(e,t){Wn(e,Element)&&(await jr(e,t),await Mr(e,t),await Nr(e,t))}function Fr(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 Ir={};async function Lr(e){let t=Ir[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},Ir[e]=t,t)}async function Rr(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),ir(a,t.fetchRequestInit,({result:e})=>(n=n.replace(i,`url(${e})`),[i,e]))});return Promise.all(i).then(()=>n)}function zr(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 Br(e,t){let n=[],r=[];return e.forEach(n=>{if(`cssRules`in n)try{jn(n.cssRules||[]).forEach((e,i)=>{if(e.type===CSSRule.IMPORT_RULE){let a=i+1,o=e.href,s=Lr(o).then(e=>Rr(e,t)).then(e=>zr(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(Lr(n.href).then(e=>Rr(e,t)).then(e=>zr(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{jn(e.cssRules||[]).forEach(e=>{n.push(e)})}catch(t){console.error(`Error while reading CSS rules from ${e.href}`,t)}}),n))}function Vr(e){return e.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>Or(e.style.getPropertyValue(`src`)))}async function Hr(e,t){if(e.ownerDocument==null)throw Error(`Provided element is not within a Document`);return Vr(await Br(jn(e.ownerDocument.styleSheets),t))}function Ur(e){return e.trim().replace(/["']/g,``)}function Wr(e){let t=new Set;function n(e){(e.style.fontFamily||getComputedStyle(e).fontFamily).split(`,`).forEach(e=>{t.add(Ur(e))}),Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&n(e)})}return n(e),t}async function Gr(e,t){let n=await Hr(e,t),r=Wr(e);return(await Promise.all(n.filter(e=>r.has(Ur(e.style.fontFamily))).map(e=>{let n=e.parentStyleSheet?e.parentStyleSheet.href:null;return kr(e.cssText,n,t)}))).join(`
2
+ `)}async function Kr(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await Gr(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 qr(e,t={}){let{width:n,height:r}=Ln(e,t),i=await br(e,t,!0);return await Kr(i,t),await Pr(i,t),Fr(i,t),await Un(i,n,r)}async function Jr(e,t={}){let{width:n,height:r}=Ln(e,t),i=await Vn(await qr(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||Rn(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||Bn(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 Yr(e,t={}){return(await Jr(e,t)).toDataURL()}var Xr=ge({settings:null,save:async()=>null,platform:``}),Zr=()=>Me(Xr),Qr=/^\[([^\]]*)\]\(([^)]+)\)$/;function $r(e){return Object.entries(e).map(([e,t])=>({key:e,value:t}))}function ei(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 ti=(e,t)=>{let n=t.find(t=>t.name===e)?.owner;return n&&n!==`eidos`&&n!==`custom`?n:null};function ni(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 ri(e){let{value:t}=e;if(t==null||t===``)return J(`span`,{className:`faint`,children:`—`});if(typeof t==`boolean`)return J(`span`,{children:t?`Yes`:`No`});if(typeof t==`string`){let n=Qr.exec(t.trim());if(n){let t=ni(e.base,n[2]??``);return t?J(`a`,{className:`link`,href:Dt(t),onClick:n=>{e.onOpen&&(n.preventDefault(),n.stopPropagation(),e.onOpen(t))},children:n[1]}):J(`a`,{className:`link`,href:n[2],target:`_blank`,rel:`noreferrer`,children:n[1]})}return/^https?:\/\//.test(t)?J(`a`,{className:`link`,href:t,target:`_blank`,rel:`noreferrer`,children:t}):J(`span`,{children:[e.color&&J(`i`,{className:`swatch`,style:{background:e.color}}),t]})}return Array.isArray(t)?J(`span`,{className:`list`,children:t.map((t,n)=>J(`span`,{className:`chip`,children:J(ri,{value:t,base:e.base,onOpen:e.onOpen})},n))}):J(`code`,{children:JSON.stringify(t)})}function ii(e,t,n){let r=H(n.find(t=>t.name===e)?.canvas);if(typeof t!=`string`)return;let i=Object.keys(r).find(e=>e.toLowerCase()===t.toLowerCase());return i?r[i]:void 0}function ai(e){let t=e.value!==``&&!e.options.includes(e.value);return J(X,{value:e.value,onChange:t=>e.onChange(t.target.value),title:t?`"${e.value}" is not one of the options`:void 0,children:[J(`option`,{value:``,children:`—`}),e.options.map(e=>J(`option`,{value:e,children:e},e)),t&&J(`option`,{value:e.value,children:[e.value,` (not an option)`]})]})}function oi(e){let[t,n]=N(``),r=()=>{let r=t.trim();r!==``&&(e.onChange([...e.value,r]),n(``))},i=(e.options??[]).filter(t=>!e.value.includes(t));return J(`span`,{className:`list`,children:[e.value.map((t,n)=>J(`span`,{className:`chip`,title:e.options&&typeof t==`string`&&!e.options.includes(t)?`"${t}" is not one of the options`:void 0,children:[typeof t==`string`?t.replace(Qr,`$1`):String(t),J(`button`,{type:`button`,onClick:()=>e.onChange(e.value.filter((e,t)=>t!==n)),"aria-label":`Remove`,children:J(Z,{})})]},n)),e.options?i.length>0&&J(X,{value:``,onChange:t=>e.onChange([...e.value,t.target.value]),children:[J(`option`,{value:``,children:`add…`}),i.map(e=>J(`option`,{value:e,children:e},e))]}):J(`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 si(e){let t=e.type.toLowerCase();return t===`list`?J(oi,{value:Array.isArray(e.value)?e.value:e.value===null||e.value===void 0||e.value===``?[]:[e.value],options:e.declared,onChange:e.onChange}):t===`text`&&e.declared?J(ai,{value:e.value===null||e.value===void 0?``:String(e.value),options:e.declared,onChange:t=>e.onChange(t===``?null:t)}):t===`checkbox`?J(`input`,{type:`checkbox`,checked:e.value===!0,onChange:t=>e.onChange(t.target.checked)}):t===`number`?J(`input`,{type:`number`,value:typeof e.value==`number`?e.value:``,onChange:t=>e.onChange(t.target.value===``?null:Number(t.target.value))}):t===`date`?J(sn,{value:typeof e.value==`string`?e.value:``,onChange:t=>e.onChange(t)}):t===`date & time`?J(sn,{time:!0,value:typeof e.value==`string`?e.value:``,onChange:t=>e.onChange(t)}):J(nn,{value:e.value===null||e.value===void 0?``:String(e.value),options:e.options,onChange:t=>e.onChange(t===``?null:t)})}function ci(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=ei(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)&&!ti(t.name,e.schema)&&t.name!==`title`&&t.name!==`summary`);return J(`div`,{className:`props`,children:[e.entries.map((t,n)=>{let d=ei(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=e.schema.find(e=>e.name===t.key)?.options??null,h=ti(t.key,e.schema),g=o&&!h,_=!o&&r?.key===t.key,v=!o&&!h&&e.onCommit!==void 0&&!_;return J(`div`,{className:`prop${g?` prop--edit`:``}${v?` prop--hot`:``}${_?` prop--inline`:``}`,ref:_?a:void 0,title:h?`${p??``}\nWritten by ${h}; not edited here.`.trim():p??(f?void 0:`Not in the schema`),onKeyDown:e=>{_&&(e.key===`Escape`?(l.current=null,i(null)):e.key===`Enter`&&e.target.tagName!==`TEXTAREA`&&!e.target.closest(`.list`)&&c())},children:[J(`span`,{className:`prop__icon`,children:h&&(o||e.onCommit)?J(wn,{}):J(En,{type:d})}),J(`span`,{className:`prop__name${f?``:` unknown`}`,children:t.key}),J(`span`,{className:`prop__value`,onClick:e=>{!v||e.target.closest(`a`)||i({key:t.key,value:t.value})},children:g?J(si,{type:d,value:t.value,options:e.known[t.key]??[],declared:m,onChange:e=>s(n,e)}):_&&r?J(si,{type:d,value:r.value,options:e.known[t.key]??[],declared:m,onChange:e=>i({key:t.key,value:e})}):J(ri,{value:t.value,base:e.base,color:ii(t.key,t.value,e.schema),onOpen:e.onOpen})}),g&&J(`button`,{type:`button`,className:`prop__remove`,onClick:()=>u(n),"aria-label":`Remove property`,"data-tip":`Remove`,"data-tip-pos":`left`,children:J(Z,{})})]},t.key)}),o&&J(`div`,{className:`prop--add`,children:[J(`span`,{children:`+`}),J(X,{value:``,onChange:e=>{d(e.target.value)},children:[J(`option`,{value:``,children:`Add property…`}),f.map(e=>J(`option`,{value:e.name,children:[e.name,` (`,e.type,e.required?`, required`:``,`)`]},e.name))]}),J(`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(``))}})]})]})}var li=ge({seq:0,paths:[]}),ui=(e,t)=>e.length===0||e.some(e=>e===t||t.startsWith(`${e}/`)||e.startsWith(`${t}/`));function di(e,t,n){let r=Me(li),[i,a]=N(!1),o=F(r.seq),s=F(n);return s.current=n,P(()=>{r.seq!==o.current&&(o.current=r.seq,!(!e||!ui(r.paths,e))&&(t?a(!0):s.current?.()))},[r.seq,r.paths,e,t]),P(()=>{t||a(!1)},[t]),{stale:i,dismiss:()=>a(!1)}}function fi(e){return J(`div`,{className:`stale`,role:`status`,children:[J(`span`,{children:e.missing?`${e.what} was deleted on disk.`:`${e.what} changed on disk while you were editing.`}),J(`button`,{className:`small primary`,onClick:e.onRefresh,children:`Refresh`}),!e.missing&&J(`button`,{className:`small quiet`,onClick:e.onKeep,children:`Keep mine`})]})}function pi(e){return e.findings.length===0?null:J(`ul`,{className:`findings`,children:e.findings.map((e,t)=>J(`li`,{className:e.level,children:[J(`code`,{children:e.code}),e.message]},t))})}var mi=e=>({kind:`blueprint`,path:e.path,title:e.title,summary:e.summary,html:e.html,raw:e.raw,body:e.body,properties:e.properties,schema:e.schema,known_values:e.known_values,findings:e.findings,frontmatter_error:e.frontmatter_error,collection:e.collection,group:e.group,variant:e.variant,git:null,history:[]}),hi=e=>({kind:`doc`,path:e.path,title:e.title,summary:e.description||null,html:e.html,raw:e.raw,body:e.raw,properties:{},schema:[],known_values:{},findings:[],frontmatter_error:null,collection:null,group:null,variant:null,git:e.git,history:e.history});function gi(e,t,n,r){let[i,a]=N(null),[o,s]=N(null),[c,l]=N(!1),[u,d]=N(0),f=F(r);return f.current=r,P(()=>{let n=!0;return(e===`doc`?pt(`/api/docs/${ft(t)}`).then(hi):pt(`/api/blueprints/${ft(t)}`).then(mi)).then(e=>n&&(a(e),s(null),l(!1))).catch(e=>n&&(f.current&&i?l(!0):s(e.message))),()=>{n=!1}},[e,t,n,u]),{detail:i,error:o,missing:c,reload:()=>d(e=>e+1)}}var _i=new Set([`title`,`summary`]);function vi(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(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/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 yi(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}var bi=5;function xi(e){let t=Lt(),[n,r]=N(bi);if(e.history.length===0)return e.git?J(`div`,{className:`history`,children:[J(`div`,{className:`history__h`,children:J(`span`,{children:`History`})}),J(`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 J(`div`,{className:`history`,children:[J(`div`,{className:`history__h`,children:[J(`span`,{children:`History`}),J(`span`,{className:`faint`,children:[e.history.length,` commit`,e.history.length===1?``:`s`]})]}),i.map(n=>J(`div`,{className:`history__row`,title:n.subject,children:[J(`code`,{children:n.short}),J(`span`,{className:`history__who`,children:n.author}),J(`span`,{className:`faint`,children:yi(n.date)}),e.diffable===!0&&J(`button`,{className:`small quiet`,onClick:()=>void t(()=>mt(`/api/blueprints/${ft(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&&J(`button`,{className:`small quiet`,onClick:()=>r(e=>e+bi),children:[`Show `,Math.min(bi,e.history.length-n),` more`]})]})}function Si(e){return J(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`View`,children:[J(`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`}),J(`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 Ci(e){return J(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Width`,children:[J(`button`,{className:e.fixed?`on`:``,role:`radio`,"aria-checked":e.fixed,onClick:()=>e.onChange(!0),"data-tip":`Every page held to about 1200px (a preference)`,"data-tip-pos":`bottom`,children:`Fixed`}),J(`button`,{className:e.fixed?``:`on`,role:`radio`,"aria-checked":!e.fixed,onClick:()=>e.onChange(!1),"data-tip":`Every page the whole window wide (a preference)`,"data-tip-pos":`bottom`,children:`Fluid`})]})}function wi(e){let t=e.kind??`blueprint`,n=t===`doc`,[r,i]=N(!1),{detail:a,error:o,missing:s,reload:c}=gi(t,e.path,e.tick,r),l=di(e.path,r),{settings:u,save:d,platform:f}=Zr(),p=u?.local.source_mode??!1,m=e=>void d({local:{source_mode:e}}),h=n||p,g=u?.local.reader_width!==`fluid`,_=e=>void d({local:{reader_width:e?`fixed`:`fluid`}}),[v,y]=N([]),[b,x]=N(``),[S,ee]=N(``),[w,T]=N(``),[E,te]=N(``),[D,O]=N(!1),[ne,re]=N([]),[ie,k]=N(!1),ae=F(null),A=Lt(),oe=Bt();P(()=>{if(n)return;let t=!0;return pt(`/api/blueprints/${ft(e.path)}/history`).then(e=>t&&(k(e.git),re(e.git?e.history:[]))).catch(()=>t&&(k(!1),re([]))),()=>{t=!1}},[n,e.path,e.tick]);let se=n?a?.history??[]:ne,ce=n?a?.git===!0:ie,le=je(()=>a?vi(a.html):{html:``,toc:[]},[a]),ue=()=>{a&&(y($r(a.properties).filter(e=>!_i.has(e.key))),x(a.title),ee(a.summary??``),T(a.body.replace(/^\n/,``)),te(a.raw),i(!0))},de=()=>i(!1),fe=I((e,t,n)=>{if(!a)return e;let r=Object.keys(a.properties),i=[],o=[...e],s=new Set;for(let e of r){if(e===`title`)i.push({key:e,value:t.trim()});else if(e===`summary`)i.push({key:e,value:n.trim()});else{let t=o.find(t=>t.key===e);t&&i.push(t)}s.add(e)}s.has(`title`)||i.splice(r.indexOf(`id`)+1,0,{key:`title`,value:t.trim()}),s.has(`summary`)||i.splice(i.findIndex(e=>e.key===`title`)+1,0,{key:`summary`,value:n.trim()});for(let e of o)i.some(t=>t.key===e.key)||i.push(e);return i},[a]),pe=I(async()=>{if(!a)return;O(!0);let t=h?{text:E}:{properties:fe(v,b,S).map(e=>[e.key,e.value]),body:`
3
+ `+w},r=await A(()=>ht(n?`/api/docs/${ft(a.path)}`:`/api/blueprints/${ft(a.path)}`,t));O(!1),r&&(i(!1),c(),e.onSaved?.())},[a,h,n,E,v,b,S,w,fe,A,c,e]),me=I(async t=>{if(!a)return;let n={properties:fe(t,a.title,a.summary??``).map(e=>[e.key,e.value]),body:a.body.startsWith(`
4
+ `)?a.body:`
5
+ `+a.body};await A(()=>ht(`/api/blueprints/${ft(a.path)}`,n),`Saved`)&&(c(),e.onSaved?.())},[a,fe,A,c,e]);P(()=>{let e=e=>{Ut(e)&&e.key===`s`&&r&&(e.preventDefault(),pe())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,pe]),Yt(n?`Document`:`Blueprint`,[{keys:`⌘S`,what:`Save what is being edited`},{keys:`Esc`,what:e.layout===`modal`?`Back to the table`:`Leave a field`}]);let he=async()=>{a&&await oe.confirm({title:`Delete ${a.title}?`,body:n?`${a.path} is removed from disk and from the framework's top_level list. Git keeps what was in it.`:`${a.path} is removed from disk. Nothing else changes.`,confirm:n?`Delete document`:`Delete blueprint`,danger:!0})&&await A(()=>gt(n?`/api/docs/${ft(a.path)}`:`/api/blueprints/${ft(a.path)}`),`Deleted`)&&(e.onSaved?.(),Ct(a.collection?Et(a.collection):`/`))},ge=e=>{(ae.current?.querySelector(`#${CSS.escape(e)}`))?.scrollIntoView({behavior:`smooth`,block:`start`})},_e=W(f),j=a?J(`span`,{className:`title__tools`,children:[u?.local.editor&&J(C,{children:[J(`button`,{className:`small quiet title__editor`,onClick:()=>void A(()=>mt(`/api/open`,{path:a.path}),`Opened in your editor`),"data-tip":`Open the file in the external editor set under Preferences`,"data-tip-pos":`bottom`,children:[J(mn,{}),` Editor`]}),J(`span`,{className:`title__sep`,"aria-hidden":`true`})]}),J(`button`,{className:`small quiet title__editor`,onClick:()=>void A(()=>mt(`/api/reveal`,{path:a.path}),`Shown in ${_e}`),"data-tip":`Show the file in ${_e}`,"data-tip-pos":`bottom`,children:[J(mn,{}),` `,_e]})]}):null,ve=a?J(C,{children:[(l.stale||s&&r)&&J(fi,{what:a.title,missing:s,onRefresh:()=>{l.dismiss(),i(!1),c()},onKeep:l.dismiss}),r?J(C,{children:[J(`button`,{className:`small primary`,onClick:()=>void pe(),disabled:D,children:D?`Saving…`:`Save`}),J(`button`,{className:`small quiet`,onClick:de,children:`Cancel`})]}):J(C,{children:[e.layout===`page`&&J(Ci,{fixed:g,onChange:_}),J(Si,{source:p,onChange:m}),J(`button`,{className:`small`,onClick:ue,"data-tip":h?`Edit the file as text`:`Edit the properties and the body`,"data-tip-pos":`bottom`,children:[J(ln,{}),` Edit`]}),J(`button`,{className:`small danger`,onClick:()=>void he(),"data-tip":`Remove the file from disk`,"data-tip-pos":`bottom`,children:[J(Z,{}),` Delete`]})]}),e.layout===`modal`&&J(`button`,{className:`small`,onClick:()=>Ct(Dt(a.path)),"data-tip":`Open as its own page`,"data-tip-pos":`bottom`,children:[J(un,{}),` Expand`]})]}):null,ye=le.toc.length>0?J(`nav`,{className:`toc`,children:[J(`div`,{className:`history__h`,children:J(`span`,{children:`Contents`})}),le.toc.map(e=>J(`a`,{href:`#${e.id}`,className:`toc__${e.level}`,onClick:t=>(t.preventDefault(),t.stopPropagation(),ge(e.id)),children:e.text},e.id))]}):null,be=o?J(`div`,{className:`empty`,children:o}):a?p||n&&r?J(`div`,{style:{padding:18},children:[J(`p`,{className:`faint mono`,style:{margin:`0 0 8px`},children:a.path}),r?J(`textarea`,{className:`editor`,value:E,onChange:e=>te(e.target.value),spellCheck:!1}):J(`pre`,{className:`source`,children:a.raw})]}):J(`div`,{className:`reader${e.layout===`page`?` reader--stack`:``}${n?` reader--doc`:``}`,children:[J(`aside`,{className:`reader__props`,children:[!n&&J(`div`,{className:`reader__meta`,children:[J(`span`,{className:`badge`,children:a.collection}),a.group&&J(`span`,{className:`badge`,children:a.group}),a.variant&&J(`span`,{className:`badge accent`,children:a.variant}),a.findings.length>0&&J(`span`,{className:`badge ${a.findings.some(e=>e.level===`error`)?`error`:`warn`}`,children:[a.findings.length,` finding`,a.findings.length>1?`s`:``]})]}),J(`p`,{className:`mono faint`,style:{margin:`0 0 12px`,wordBreak:`break-all`},children:a.path}),a.frontmatter_error&&J(`p`,{className:`prop__hint`,children:[`Frontmatter read leniently: `,a.frontmatter_error]}),!n&&J(ci,{entries:r?v:$r(a.properties).filter(e=>!_i.has(e.key)),schema:a.schema,known:a.known_values,base:a.path,editable:r,onChange:y,onCommit:r?void 0:e=>void me(e),onOpen:e.onOpenLink}),!r&&J(`div`,{style:{marginTop:n?0:18},children:[J(pi,{findings:a.findings}),e.layout===`modal`&&ye,J(xi,{path:a.path,history:se,git:ce,diffable:!n&&!!u?.local.diff_viewer})]})]}),J(`div`,{className:`reader__content`,ref:ae,children:r?J(C,{children:[J(`div`,{className:`reader__fields`,children:[J(`label`,{children:[J(`span`,{children:`Title`}),J(`input`,{value:b,onChange:e=>x(e.target.value)})]}),J(`label`,{children:[J(`span`,{children:`Summary`}),J(`textarea`,{rows:2,value:S,placeholder:`one plain line: what this blueprint is, the source for the collection index`,onChange:e=>ee(e.target.value)})]})]}),J(`textarea`,{className:`editor`,value:w,onChange:e=>T(e.target.value),spellCheck:!1})]}):J(C,{children:[a.summary&&e.layout===`modal`&&J(`p`,{className:`reader__summary`,children:a.summary}),J(Vt,{html:le.html,base:a.path,onOpen:e.onOpenLink})]})})]}):J(Dn,{});return e.layout===`modal`?J(Y,{title:J(`span`,{className:`title-row`,children:[J(`span`,{children:a?.title??`…`}),j]}),head:ve,size:`lg`,onClose:e.onClose??(()=>void 0),children:be}):J(`div`,{className:`page`,children:J(`div`,{children:[J(`div`,{className:`page__head`,children:[J(`div`,{className:`grow`,children:[a?.collection&&J(`a`,{className:`page__back`,href:Et(a.collection,a.path),children:[`← `,a.collection]}),J(`div`,{className:`title-row`,children:[J(`h1`,{children:a?.title??`…`}),j]}),a?.summary&&J(`p`,{children:a.summary})]}),J(`div`,{className:`toolbar`,children:ve})]}),J(`div`,{className:`doc${ye&&!r?` doc--rail`:``}`,children:[J(`div`,{className:`doc__body table-wrap`,style:{overflow:`visible`},children:be}),ye&&!r&&J(`aside`,{className:`doc__rail`,children:ye})]})]})})}var Ti=[{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 Ei(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 J(`svg`,{...t,children:J(`path`,{d:`M5 3l11 7-5 1.5L8.5 17z`})});case`hand`:return J(`svg`,{...t,children:J(`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 J(`svg`,{...t,children:[J(`rect`,{x:`3`,y:`5`,width:`14`,height:`10`,rx:`2`}),J(`path`,{d:`M6 9h8M6 12h5`})]});case`sticky`:return J(`svg`,{...t,children:[J(`path`,{d:`M4 4h12v8l-4 4H4z`}),J(`path`,{d:`M12 16v-4h4`})]});case`annotation`:return J(`svg`,{...t,children:[J(`rect`,{x:`3`,y:`3`,width:`10`,height:`7`,rx:`2`}),J(`path`,{d:`M8 10v3l3-3M11 13l6 4`}),J(`circle`,{cx:`17`,cy:`17`,r:`1.2`})]});case`text`:return J(`svg`,{...t,children:J(`path`,{d:`M4 5h12M10 5v11M7 16h6`})});case`blueprint`:return J(`svg`,{...t,children:[J(`path`,{d:`M5 3h7l4 4v10H5z`}),J(`path`,{d:`M12 3v4h4M8 11h5M8 14h5`})]});case`frame`:return J(`svg`,{...t,children:J(`path`,{d:`M6 2v16M14 2v16M2 6h16M2 14h16`})});case`connect`:return J(`svg`,{...t,children:[J(`circle`,{cx:`4.5`,cy:`5`,r:`2`}),J(`circle`,{cx:`15.5`,cy:`15`,r:`2`}),J(`path`,{d:`M6.5 5H11v10h2.5`})]});case`comment`:return J(`svg`,{...t,children:J(`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 J(`svg`,{...t,children:[J(`path`,{d:`M7 7L3 10l4 3`}),J(`path`,{d:`M3 10h8a4 4 0 010 8h-3`})]});case`redo`:return J(`svg`,{...t,children:[J(`path`,{d:`M13 7l4 3-4 3`}),J(`path`,{d:`M17 10H9a4 4 0 000 8h3`})]});case`export`:return J(`svg`,{...t,children:J(`path`,{d:`M10 3v10M6 9l4 4 4-4M4 16h12`})});case`image`:return J(`svg`,{...t,children:[J(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`2`}),J(`circle`,{cx:`7.5`,cy:`8.5`,r:`1.5`}),J(`path`,{d:`M3 14l4-4 3 3 3-3 4 4`})]})}}function Di(e){return J(`div`,{className:`cv__toolbar`,role:`toolbar`,children:Ti.map((t,n)=>J(`span`,{style:{display:`contents`},children:[(n===2||n===8)&&J(`i`,{className:`cv__toolbar-sep`}),J(`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:[J(Ei,{tool:t.tool}),J(`kbd`,{children:t.key})]})]},t.tool))})}function Oi(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?J(`input`,{ref:On,className:`${n} editing`,value:r.value??t,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()}):J(`span`,{className:n,onDoubleClick:()=>i({id:e,value:t}),title:`Double-click to rename`,children:t});return J(`div`,{ref:s,className:`cv__pages`,onPointerDown:e=>e.stopPropagation(),children:[J(`div`,{className:`cv__pages-head`,children:[J(`button`,{className:`quiet icon`,onClick:()=>n(e=>!e),"data-tip":t?`Collapse pages`:`Pages`,"data-tip-pos":`right`,"aria-label":`Pages`,children:J(Tn,{open:t})}),d(`canvas`,e.canvasTitle,`cv__pages-title`),J(`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`&&J(`div`,{className:`cv__menu`,style:l,children:[J(`button`,{onClick:()=>(o(null),i({id:`canvas`,value:e.canvasTitle})),children:J(`span`,{children:`Rename canvas`})}),J(`i`,{}),J(`button`,{className:`danger`,onClick:()=>(o(null),e.onDeleteCanvas()),children:J(`span`,{children:`Delete canvas…`})})]})]}),t&&J(`div`,{className:`cv__pages-list`,children:[J(`div`,{className:`cv__pages-label`,children:[J(`span`,{children:`Pages`}),J(`button`,{className:`quiet icon`,onClick:()=>void e.onAddPage().then(e=>{e&&i({id:e,value:null})}),title:`Add a page`,"aria-label":`Add a page`,children:J(bn,{})})]}),e.pages.map(t=>J(`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`),J(`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&&J(`div`,{className:`cv__menu`,style:l,onClick:e=>e.stopPropagation(),children:[J(`button`,{onClick:()=>(o(null),i({id:t.id,value:t.title})),children:J(`span`,{children:`Rename`})}),J(`i`,{}),J(`button`,{className:`danger`,disabled:e.pages.length<2,onClick:()=>(o(null),e.onDeletePage(t.id)),children:[J(`span`,{children:`Delete page…`}),J(Z,{})]})]})]},t.id))]})]})}function ki(e){return J(`div`,{className:`cv__top cv__top--right`,children:[J(`div`,{className:`group`,children:[J(`button`,{onClick:e.onUndo,disabled:!e.canUndo,"data-tip":`Undo ⌘Z`,"data-tip-pos":`bottom`,"aria-label":`Undo`,children:J(Ei,{tool:`undo`})}),J(`button`,{onClick:e.onRedo,disabled:!e.canRedo,"data-tip":`Redo ⇧⌘Z`,"data-tip-pos":`bottom`,"aria-label":`Redo`,children:J(Ei,{tool:`redo`})})]}),J(`div`,{className:`group`,children:[J(`button`,{className:e.showComments?`on`:``,onClick:e.onToggleComments,"data-tip":e.pinsHidden?`Comments ⇧C (pins hidden)`:`Comments ⇧C`,"data-tip-pos":`bottom`,children:[J(Ei,{tool:`comment`}),e.commentsOpen>0&&J(`span`,{className:`count`,children:e.commentsOpen})]}),e.children]})]})}function Ai(e){return J(`div`,{className:`cv__zoom`,children:[J(`button`,{onClick:()=>e.onZoom(1/1.2),"data-tip":`Zoom out −`,"aria-label":`Zoom out`,children:`−`}),J(`button`,{onClick:e.onFit,"data-tip":`Fit ⇧1
7
+ Double-click for 100% ⇧0`,onDoubleClick:e.onReset,children:[Math.round(e.scale*100),`%`]}),J(`button`,{onClick:()=>e.onZoom(1.2),"data-tip":`Zoom in +`,"aria-label":`Zoom in`,children:`+`})]})}function ji(e){return J(`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?J(`i`,{},n):J(`button`,{className:t.danger?`danger`:``,disabled:t.disabled,onClick:()=>{e.onClose(),t.onSelect?.()},children:[J(`span`,{children:t.label}),t.hint&&J(Gt,{combo:t.hint}),t.icon]},n))})}var Mi=`https://eidosmd.com/docs/cli/canvas`,Ni=[{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 Pi(e){return J(`div`,{className:`backdrop center`,onMouseDown:t=>t.target===t.currentTarget&&e.onClose(),children:J(`div`,{className:`modal`,style:{maxWidth:720},children:[J(`div`,{className:`modal__head`,children:[J(`h2`,{children:`Working the canvas`}),J(`a`,{className:`btn`,href:Mi,target:`_blank`,rel:`noreferrer`,children:`Navigating the canvas ↗`}),J(`button`,{className:`quiet`,onClick:e.onClose,children:`Close`})]}),J(`div`,{className:`modal__body`,style:{padding:`6px 18px 16px`},children:[J(`h3`,{className:`cv__sheet-h`,children:`Tools`}),J(`table`,{className:`mini`,children:J(`tbody`,{children:e.tools.map(e=>J(`tr`,{children:[J(`td`,{style:{whiteSpace:`nowrap`,width:120},children:J(`span`,{style:{display:`inline-flex`,gap:8,alignItems:`center`},children:[J(Ei,{tool:e.tool}),` `,J(`b`,{children:e.label})]})}),J(`td`,{style:{width:40},children:J(Gt,{combo:e.key})}),J(`td`,{className:`muted`,children:e.hint})]},e.tool))})}),J(`h3`,{className:`cv__sheet-h`,children:`Essentials`}),J(`table`,{className:`mini`,children:J(`tbody`,{children:Ni.map(e=>J(`tr`,{children:[J(`td`,{style:{whiteSpace:`nowrap`},children:J(Gt,{combo:e.keys})}),J(`td`,{className:`muted`,children:e.what})]},e.keys))})}),J(`p`,{className:`faint`,style:{fontSize:12,margin:`12px 0 0`},children:[`Everything else, with pictures: `,J(`a`,{href:Mi,target:`_blank`,rel:`noreferrer`,children:`eidosmd.com/docs/cli/canvas`}),`.`]})]})]})})}function Fi(e){return J(`button`,{className:`cv__help`,onClick:e.onOpen,"data-tip":`Tools and shortcuts ?`,"data-tip-pos":`right`,"aria-label":`Help`,children:J(_n,{})})}function Ii(e){let t=(t,n,r)=>J(`label`,{className:`cv__pref`,children:[J(`input`,{type:`checkbox`,checked:e.prefs[t],onChange:n=>e.onChange({...e.prefs,[t]:n.target.checked})}),J(`span`,{children:[J(`b`,{children:n}),J(`small`,{children:r})]})]});return J(`div`,{className:`cv__prefs`,onPointerDown:e=>e.stopPropagation(),children:[J(`div`,{className:`cv__prefs-head`,children:[J(`strong`,{children:`Canvas preferences`}),J(`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.`),J(`div`,{className:`cv__prefs-foot`,children:J(`a`,{href:`/settings/properties`,onClick:t=>(t.preventDefault(),e.onClose(),Ct(`/settings/properties`)),children:`Configure default styles →`})})]})}function Li(e){return J(`div`,{className:`cv__legend-wrap`,onPointerDown:e=>e.stopPropagation(),children:[e.open&&J(`div`,{className:`cv__legend`,children:e.entries.map(([e,t])=>J(`span`,{children:[J(`i`,{className:`swatch`,style:{background:t}}),e]},e))}),J(`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:[J(`i`,{className:`swatch`,style:{background:e.entries[0]?.[1]??`var(--text-faint)`,margin:0}}),`Legend`]})]})}var Ri=`frame:`,zi=e=>e.startsWith(Ri),Bi=e=>e.slice(6),Vi={w:200,h:72},Hi=[{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`}],Ui={small:{w:180,h:84},medium:{w:220,h:112},large:{w:280,h:148}},Wi={small:128,medium:176,large:240},Gi=.15,Ki=[`yellow`,`pink`,`blue`,`green`,`purple`,`orange`],qi=[`none`,`sand`,`sky`,`mint`,`rose`,`lilac`],Q=e=>Math.round(e/8)*8;function Ji(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]??{...Vi}:{...Ui[e.style.size]}}function Yi(e,t,n={}){return{...t[e.id]??e.position,...Ji(e,n)}}function Xi(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 Zi=(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,Qi=(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,$i=(e,t)=>t.x>=e.x&&t.x<=e.x+e.w&&t.y>=e.y&&t.y<=e.y+e.h,ea=e=>({x:e.x+e.w/2,y:e.y+e.h/2}),ta=(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)}),na=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}},ra=[`top-left`,`top`,`top-right`,`right`,`bottom-right`,`bottom`,`bottom-left`,`left`],ia=[`top`,`right`,`bottom`,`left`];function aa(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 oa(e,t,n=ra){let r=n[0]??`right`,i=1/0;for(let a of n){let n=aa(e,a),o=Math.hypot(n.x-t.x,n.y-t.y);o<i&&(i=o,r=a)}return r}function sa(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 ca=(e,t,n)=>({x:e.x+(t===`right`?n:t===`left`?-n:0),y:e.y+(t===`down`?n:t===`up`?-n:0)}),la=e=>e===`left`||e===`right`;function ua(e,t,n,r){return n&&r?{from:n,to:r}:n?{from:n,to:oa(t,aa(e,n),ia)}:r?{from:oa(e,aa(t,r),ia),to:r}:t.x>=e.x+e.w+da?{from:`right`,to:`left`}:e.x>=t.x+t.w+da?{from:`left`,to:`right`}:ea(t).y>=ea(e).y?{from:`bottom`,to:`top`}:{from:`top`,to:`bottom`}}var da=24,fa=4;function pa(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 ma(e,t,n={}){let r=ua(e,t,n.from,n.to),i=aa(e,r.from),a=aa(t,r.to),o=sa(r.from,i,a),s=sa(r.to,a,i),c=ca(i,o,fa),l=ca(a,s,fa),u=ca(c,o,da),d=ca(l,s,da),f,p=null,m=null;la(o)&&la(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`):!la(o)&&!la(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=la(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:pa(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 ha(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)),pa(r,10)}var ga=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 _a(e,t){let n=ga(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 va(e,t){let n=ga(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 ya=[`none`,`arrow`,`triangle`,`triangle-open`,`circle`,`diamond`,`bar`],ba={none:`None`,arrow:`Arrow`,triangle:`Triangle`,"triangle-open":`Open triangle`,circle:`Circle`,diamond:`Diamond`,bar:`Bar`},xa=e=>e===`none`?0:e===`arrow`||e===`bar`?1:e===`circle`?9:e===`diamond`?16:10;function Sa(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 Ca(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}`,wa=e=>`f:${e}`,Ta=e=>`e:${e.from}|${e.to}`,Ea=e=>e.startsWith(`n:`),Da=e=>e.startsWith(`f:`),Oa=e=>e.startsWith(`e:`),ka=e=>e.slice(2),Aa=e=>{let[t=``,n=``]=e.slice(2).split(`|`);return{from:t,to:n}},ja=e=>JSON.parse(JSON.stringify(e));function Ma(e=60){let t=F([]),n=F([]),[,r]=N(0),i=()=>r(e=>e+1),a=I(r=>{t.current.push(ja(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(ja(e)),i(),r):null},[]),s=I(e=>{let r=n.current.pop();return r?(t.current.push(ja(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 Na=ja,Pa=[`box`,`pill`,`parallelogram`],Fa=[`small`,`medium`,`large`];function Ia(e,t,n=[],r){let[i,a]=N({x:0,y:0}),[o,s]=N(0);return Ae(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>s(e=>e+1));return n.observe(e),()=>n.disconnect()},[]),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,o,...n]),{x:e.x+i.x,y:e.y+i.y}}function La(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 Ra(e){let t=F(null),n=Ia(e.at,t);return P(()=>{t.current?.querySelector(`input, select, textarea`)?.focus()},[]),J(`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:La,children:[J(`div`,{className:`cv__pop-head`,children:[J(`span`,{className:`badge`,children:e.kind}),J(`strong`,{children:e.title}),J(`button`,{className:`quiet small`,onClick:e.onClose,"data-tip":`Close Esc`,"data-tip-pos":`bottom`,children:`Close`})]}),J(`div`,{className:`cv__pop-body`,children:e.children})]})}function za(e){return J(`div`,{className:`cv__pop-sec`,children:[J(`div`,{className:`cv__pop-sec-h`,children:[J(`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?J(`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?On:void 0}):J(nn,{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 Va(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 J(za,{title:`Placement`,children:J(`div`,{className:`cv__pop-grid`,children:[J(`label`,{children:`Attached to frame`}),J(X,{value:t.frame??``,onChange:t=>e.onUpdate({frame:t.target.value||null}),children:[J(`option`,{value:``,children:`none`}),r?.frames.map(e=>J(`option`,{value:e.id,children:e.title},e.id))]}),J(`label`,{children:`Opens`}),J(X,{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:[J(`option`,{value:``,children:`nothing`}),n.canvas.pages.filter(e=>e.id!==r?.id).map(e=>J(`option`,{value:`page:${e.id}`,children:[`page: `,e.title]},e.id))]})]})})}function Ha(e){let t=Bt();return async()=>{let n=e.override;if(!n||Object.keys(n).length===0)return{};let r={style:{shape:null,color:null,fill:null,fill_color:null,size:null}};return 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`})?r:{}:r}}function Ua(e){let{node:t,data:n}=e,[r,i]=N(!1),a=Ha(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=J(`div`,{className:`cv__pop-foot`,children:[t.kind===`blueprint`&&t.path&&J(`a`,{className:`btn`,href:Dt(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`&&J(`button`,{onClick:()=>i(e=>!e),children:`Promote to blueprint…`}),J(`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:J(Z,{})})]});return J(Ra,{at:e.at,kind:t.kind,title:c,onClose:e.onClose,children:[t.kind===`sketch`&&J(C,{children:[J(za,{title:`Text`,children:J(`div`,{className:`cv__pop-grid`,children:[J(`label`,{children:`Title`}),J(Ba,{value:t.label,placeholder:`Title`,onCommit:t=>e.onUpdate({sketch:{label:t.trim()}})}),J(`label`,{children:`Description`}),J(Ba,{value:t.summary??``,rows:3,placeholder:`Description`,onCommit:t=>e.onUpdate({sketch:{note:t.trim()||null}})})]})}),J(za,{title:`Properties`,children:o.length===0?J(`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.`}):J(`div`,{className:`cv__pop-grid`,children:o.map(e=>J(Wa,{property:e,value:t.values[e.name]??``,options:e.values,onCommit:t=>void s(e.name,t)},e.name))})}),J(Va,{node:t,data:n,onUpdate:e.onUpdate}),l,r&&J(Ga,{data:n,label:t.label,onPromote:e.onPromote,onClose:()=>i(!1)})]}),t.kind===`blueprint`&&J(C,{children:[t.missing?J(`p`,{className:`findings`,children:J(`span`,{className:`error`,children:[`No blueprint with the id “`,t.blueprint,`”.`]})}):t.path&&J(Ka,{path:t.path,shown:n.palette.filter(e=>e.show).map(e=>e.property),restyle:a,onRestyle:e.onUpdate,onSaved:e.onBlueprintSaved}),J(Va,{node:t,data:n,onUpdate:e.onUpdate}),l]}),t.kind===`sticky`&&J(C,{children:[J(za,{title:`Text`,children:J(Ba,{value:t.label,rows:4,placeholder:`Write…`,onCommit:t=>e.onUpdate({sticky:{text:t}})})}),J(Va,{node:t,data:n,onUpdate:e.onUpdate}),l]}),t.kind===`annotation`&&J(C,{children:[J(za,{title:`Annotation`,children:[J(Ba,{value:t.label,rows:3,placeholder:`What to note about what it points at`,onCommit:t=>e.onUpdate({annotation:{text:t}})}),J(`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.`})]}),J(Va,{node:t,data:n,onUpdate:e.onUpdate}),l]}),t.kind===`text`&&J(C,{children:[J(za,{title:`Text`,children:J(Ba,{value:t.label,rows:3,onCommit:t=>e.onUpdate({text:{text:t}})})}),J(Va,{node:t,data:n,onUpdate:e.onUpdate}),l]})]})}function Wa(e){let t=e.property.options;return J(C,{children:[J(`label`,{title:e.property.meaning,children:e.property.name}),e.property.type===`Text`&&t?J(X,{value:e.value,onChange:t=>e.onCommit(t.target.value),title:e.value!==``&&!t.includes(e.value)?`"${e.value}" is not one of the options`:void 0,children:[J(`option`,{value:``,children:`—`}),t.map(e=>J(`option`,{value:e,children:e},e)),e.value!==``&&!t.includes(e.value)&&J(`option`,{value:e.value,children:[e.value,` (not an option)`]})]}):e.property.type===`Checkbox`?J(`input`,{type:`checkbox`,checked:e.value===`true`,onChange:t=>e.onCommit(t.target.checked?`true`:``),style:{width:`auto`}}):e.property.type===`Date`?J(sn,{value:e.value,onChange:t=>e.onCommit(t??``)}):J(Ba,{value:e.value,list:e.options,placeholder:e.property.type===`List`?`comma-separated`:`—`,onCommit:e.onCommit})]})}function Ga(e){let{data:t}=e,[n,r]=N(``),[i,a]=N(``),[o,s]=N(``),c=t.collections.find(e=>e.name===n),l=(c?.groups.length??0)>0,u=c!==void 0&&(!l||i!==``)&&o!==``,d=e=>{let n=t.collections.find(t=>t.name===e);r(e),a(``),s(n?.variants.find(e=>e.default)?.name??n?.variants[0]?.name??``)};return J(Y,{title:`Promote “${e.label||`Untitled`}” to a blueprint`,size:`sm`,center:!0,onClose:e.onClose,foot:J(C,{children:[J(`button`,{className:`small quiet`,onClick:e.onClose,children:`Cancel`}),J(`button`,{className:`small primary`,disabled:!u,onClick:()=>(e.onPromote({collection:n,group:i||null,variant:o}),e.onClose()),children:`Create blueprint`})]}),children:J(`div`,{className:`stack`,children:[J(`p`,{className:`muted`,style:{margin:0,fontSize:12},children:[`Scaffolds a blueprint from this sketch (the same as `,J(`code`,{children:`eidos new`}),`), carries its properties over, and points the node at it.`]}),J(`div`,{className:`promote__where`,children:[J(`label`,{children:[J(`span`,{children:`Collection`}),J(X,{value:n,onChange:e=>d(e.target.value),children:[J(`option`,{value:``,disabled:!0,children:`Choose…`}),t.collections.map(e=>J(`option`,{value:e.name,children:e.name},e.name))]})]}),J(`span`,{className:`promote__arrow`,"aria-hidden":`true`,children:`→`}),J(`label`,{children:[J(`span`,{children:`Group`}),J(X,{value:i,disabled:!l,onChange:e=>a(e.target.value),children:[J(`option`,{value:``,disabled:!0,children:c?l?`Choose…`:`No groups`:``}),c?.groups.map(e=>J(`option`,{value:e,children:e},e))]})]}),J(`span`,{className:`promote__arrow`,"aria-hidden":`true`,children:`→`}),J(`label`,{children:[J(`span`,{children:`Variant`}),J(X,{value:o,disabled:!c,onChange:e=>s(e.target.value),children:[!c&&J(`option`,{value:``,disabled:!0}),c?.variants.map(e=>J(`option`,{value:e.name,children:[e.name,e.default?` (default)`:``]},e.name))]})]})]})]})})}function Ka(e){let[t,n]=N(null),r=Lt(),i=()=>{pt(`/api/blueprints/${ft(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(()=>ht(`/api/blueprints/${ft(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 J(C,{children:[J(za,{title:`File`,aside:J(`code`,{className:`faint`,style:{fontSize:11},children:e.path}),children:J(`div`,{className:`cv__pop-grid`,children:[J(`label`,{children:`Title`}),J(Ba,{value:t?.title??``,onCommit:e=>e.trim()!==``&&void a({title:e.trim()},!1)}),J(`label`,{children:`Summary`}),J(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&&J(za,{title:`Properties`,children:J(`div`,{className:`cv__pop-grid`,children:o.map(e=>J(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 qa(e){return J(Ra,{at:e.at,kind:`flow`,title:`${e.from} → ${e.to}`,onClose:e.onClose,children:[J(za,{title:`Label`,children:J(Ba,{value:e.edge.label??``,placeholder:`optional`,onCommit:t=>e.onUpdate({label:t.trim()===``?null:t.trim()}),autoFocus:!0})}),J(za,{title:`Route`,aside:J(`span`,{className:`faint`,style:{fontSize:11},children:[e.edge.from_anchor??`auto`,` → `,e.edge.to_anchor??`auto`]}),children:[J(`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.`}),J(`div`,{className:`cv__pop-foot`,children:[e.edge.bend!==void 0&&J(`button`,{className:`small`,onClick:()=>e.onUpdate({bend:null}),children:`Recentre bend`}),(e.edge.from_anchor||e.edge.to_anchor)&&J(`button`,{className:`small`,onClick:()=>e.onUpdate({from_anchor:null,to_anchor:null}),children:`Auto anchors`}),J(`button`,{className:`quiet icon danger`,onClick:e.onRemove,style:{marginLeft:`auto`},"data-tip":`Remove the flow`,"data-tip-pos":`left`,"aria-label":`Remove`,children:J(Z,{})})]})]})]})}function Ja(e){return J(Ra,{at:e.at,kind:`frame`,title:e.frame.title,onClose:e.onClose,children:[J(za,{title:`Frame`,children:J(`div`,{className:`cv__pop-grid`,children:[J(`label`,{children:`Title`}),J(Ba,{value:e.frame.title,onCommit:t=>t.trim()!==``&&e.onUpdate({title:t.trim()})}),J(`label`,{children:`Color`}),J(`div`,{className:`swatches`,children:qi.map(t=>J(`button`,{className:`swatch-btn frame-${t}${(e.frame.color??`none`)===t?` on`:``}`,onClick:()=>e.onUpdate({color:t===`none`?null:t}),"data-tip":t},t))})]})}),J(za,{title:`Attached`,aside:J(`span`,{className:`faint`,style:{fontSize:11},children:[e.members,` node`,e.members===1?``:`s`]}),children:[J(`div`,{className:`cv__pop-foot`,children:J(`button`,{className:`small`,onClick:e.onSelectMembers,disabled:e.members===0,children:`Select attached`})}),J(`div`,{className:`cv__pop-foot`,children:[J(`button`,{className:`quiet danger small`,onClick:()=>e.onRemove(!1),children:`Delete Frame Only`}),J(`button`,{className:`quiet danger small`,onClick:()=>e.onRemove(!0),disabled:e.members===0,children:`Delete Frame & Contents`})]})]})]})}function Ya(e){let t=Sa({x:30,y:8},{x:1,y:0},e.cap);return J(`svg`,{viewBox:`0 0 34 16`,className:`cap-icon`,style:e.flip?{transform:`scaleX(-1)`}:void 0,"aria-hidden":`true`,children:[J(`path`,{d:`M3,8 L${30-xa(e.cap)},8`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`}),t&&J(`path`,{d:t.d,fill:t.filled?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinejoin:`round`})]})}function Xa(e){let[t,n]=N(!1);return J(`span`,{className:`cap-picker`,children:[J(`button`,{onClick:()=>n(e=>!e),"data-tip":`${e.label}: ${ba[e.value]}`,"data-tip-pos":`bottom`,"aria-label":e.label,children:[J(Ya,{cap:e.value,flip:e.flip}),J(Tn,{open:t})]}),t&&J(`span`,{className:`cap-menu`,onMouseLeave:()=>n(!1),children:ya.map(t=>J(`button`,{className:t===e.value?`on`:``,onClick:()=>(e.onChange(t),n(!1)),title:ba[t],children:J(Ya,{cap:t,flip:e.flip})},t))})]})}function Za(e){let t=F(null),n=Ia(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 J(`div`,{ref:t,className:`cv__selbar`,style:{left:n.x,top:n.y},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[J(`button`,{className:`quiet cv__selbar-style${e.styleOpen?` on`:``}`,onClick:e.onToggleStyle,"data-tip":`Style`,"data-tip-pos":`bottom`,children:[J(`i`,{className:`swatch`,style:{background:a}}),`Style`,J(`span`,{className:`cv__chev${e.styleOpen?` open`:``}`,children:J(Tn,{open:e.styleOpen})})]}),e.children,J(`i`,{className:`cv__selbar-sep`}),r&&J(C,{children:[J(`button`,{className:`quiet small`,onClick:e.onWrap,children:`Wrap in frame`}),J(`button`,{className:`quiet small`,onClick:e.onDuplicate,"data-tip":`Duplicate ⌘D`,"data-tip-pos":`bottom`,children:`Duplicate`}),J(`i`,{className:`cv__selbar-sep`})]}),J(`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:J(wn,{})}),i&&!r&&J(`button`,{className:`quiet icon`,onClick:e.onComment,"data-tip":`Comment on this`,"data-tip-pos":`bottom`,"aria-label":`Comment`,children:J(Ei,{tool:`comment`})}),e.onOpen&&J(`button`,{className:`quiet small`,onClick:e.onOpen,"data-tip":`Open the blueprint over the canvas`,"data-tip-pos":`bottom`,children:`Open`}),!r&&J(`button`,{className:`quiet icon`,onClick:e.onDetails,"data-tip":`Details ⏎`,"data-tip-pos":`bottom`,"aria-label":`Details`,children:J(gn,{})}),J(`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:J(Z,{})})]})}var Qa=e=>typeof e==`string`&&/^#[0-9a-f]{6}$/i.test(e)?e:`#888888`;function $a(e){let{current:t,onPick:n}=e;return J(`span`,{className:`colors`,children:[Hi.map(e=>J(`button`,{type:`button`,className:`colors__swatch${typeof t==`string`&&t.toLowerCase()===e.hex?` on`:``}`,style:{background:e.hex},onClick:()=>n(e.hex),"data-tip":e.name,"data-tip-pos":`top`,"aria-label":e.name},e.hex)),J(`label`,{className:`colors__pick`,"data-tip":typeof t==`string`&&t!==``?t:`Any color`,"data-tip-pos":`top`,children:[J(`i`,{className:`swatch`,style:{background:Qa(t)}}),J(`input`,{type:`color`,value:Qa(t),onChange:e=>n(e.target.value)})]}),J(`button`,{type:`button`,className:`quiet small`,onClick:()=>n(null),"data-tip":e.auto,"data-tip-pos":`top`,children:t===`mixed`?`mixed`:t?`auto`:`· auto`})]})}function eo(e){let{shape:t,fill:n,fillColor:r,color:i,size:a}=e,o=(t,n)=>e.clearable&&t===n?null:n;return J(C,{children:[J(`label`,{children:`Shape`}),J(X,{value:t===`mixed`?``:t??``,onChange:t=>e.onChange({shape:t.target.value||null}),children:[J(`option`,{value:``,children:t===`mixed`?`Mixed`:`Auto (property driven)`}),Pa.map(e=>J(`option`,{value:e,children:e},e))]}),J(`label`,{children:`Fill`}),J(`span`,{className:`seg`,children:[J(`button`,{type:`button`,className:n===`solid`?`on`:``,onClick:()=>e.onChange({fill:o(n,`solid`)}),"data-tip":`A solid box`,"data-tip-pos":`bottom`,children:`Fill`}),J(`button`,{type:`button`,className:n===`tint`?`on`:``,onClick:()=>e.onChange({fill:o(n,`tint`)}),"data-tip":`A tint of the fill color`,"data-tip-pos":`bottom`,children:`Transparent`}),J(`button`,{type:`button`,className:n===`none`?`on`:``,onClick:()=>e.onChange({fill:o(n,`none`)}),"data-tip":`No fill, just the outline`,"data-tip-pos":`bottom`,children:`No fill`})]}),n!==`none`&&J(C,{children:[J(`label`,{children:`Fill color`}),J($a,{current:r,onPick:t=>e.onChange({fill_color:t}),auto:`The page's own surface`})]}),J(`label`,{title:`The bar and border on a card`,children:`Highlight color`}),J($a,{current:i,onPick:t=>e.onChange({color:t}),auto:`Back to the property's color`}),a!==void 0&&J(C,{children:[J(`label`,{children:`Size`}),J(`span`,{className:`seg`,children:Fa.map(t=>J(`button`,{type:`button`,className:a===t?`on`:``,onClick:()=>e.onChange({size:o(a,t)}),children:t[0]?.toUpperCase()},t))})]})]})}function to(e){let t=F(null),n=Ia(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=>Pa.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??Ji(e),_=e.nodes.some(e=>e.override),{edge:v}=e,y=(e,t,n)=>J($a,{current:e,onPick:t,auto:n});return J(`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:[J(`div`,{className:`cv__pop-sec-h`,style:{marginBottom:8},children:[J(`span`,{children:[`Style`,e.nodes.length>1?` · ${e.nodes.length} selected`:``]}),J(`button`,{className:`quiet small`,onClick:e.onClose,children:`Close`})]}),J(`div`,{className:`cv__pop-grid`,children:[r.length>0&&J(eo,{shape:c,fill:u,fillColor:d,color:l,onChange:e.onNodeStyle}),r.length===0&&i.length>0&&J(C,{children:[J(`label`,{title:`The text itself`,children:`Text color`}),y(l,t=>e.onNodeStyle({color:t}),`Back to the property's color`)]}),i.length>0&&J(C,{children:[J(`label`,{children:`Text size`}),J(`span`,{style:{display:`flex`,gap:6,alignItems:`center`},children:[J(`span`,{className:`seg`,children:Fa.map(t=>J(`button`,{className:p===0&&f===t?`on`:``,onClick:()=>e.onTextSize({size:t,font:null}),children:t[0]?.toUpperCase()},t))}),J(`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&&J(C,{children:[J(`label`,{title:`The note and the lines it points with`,children:`Annotation color`}),y(s(o.map(e=>e.style.color??``)),t=>e.onAnnotationColor(t),`Ink, the page's text color`)]}),a.length>0&&J(C,{children:[J(`label`,{children:`Sticky color`}),J(`span`,{className:`swatches`,children:Ki.map(t=>J(`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`)&&J(C,{children:[J(`label`,{children:`Size`}),J(`span`,{className:`seg`,children:Fa.map(t=>J(`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&&J(C,{children:[J(`label`,{title:`An exact size; drag a selected node's corners for the same`,children:`Box`}),J(`span`,{style:{display:`flex`,gap:6,alignItems:`center`},children:[J(`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})}),J(`span`,{className:`faint`,children:`×`}),J(`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)})}),J(`button`,{className:`quiet small`,onClick:()=>e.onBox(null),disabled:!h,children:h?`auto`:`· auto`})]})]}),e.frame&&J(C,{children:[J(`label`,{children:`Frame color`}),J(`span`,{className:`swatches`,children:qi.map(t=>J(`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&&J(C,{children:[J(`label`,{children:`Line color`}),y(v.color??``,t=>e.onEdge({color:t}),`The page's line color`),J(`label`,{children:`Line`}),J(`span`,{className:`seg`,children:[J(`button`,{className:v.style===`dashed`?``:`on`,onClick:()=>e.onEdge({style:null}),children:`Solid`}),J(`button`,{className:v.style===`dashed`?`on`:``,onClick:()=>e.onEdge({style:`dashed`}),children:`Dashed`})]}),J(`label`,{children:`Start`}),J(Xa,{value:v.start??`none`,flip:!0,onChange:t=>e.onEdge({start:t===`none`?null:t}),label:`Start of the line`}),J(`label`,{children:`End`}),J(Xa,{value:v.end??`triangle`,onChange:t=>e.onEdge({end:t}),label:`End of the line`}),v.label&&J(C,{children:[J(`label`,{children:`Label at`}),J(`span`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[J(`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})}),J(`span`,{className:`faint`,style:{fontSize:12,width:34},children:[Math.round((v.label_at??.5)*100),`%`]})]})]})]})]}),J(`div`,{className:`cv__pop-foot`,style:{marginTop:10},children:[(_||v)&&J(`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&&J(C,{children:[J(`button`,{className:`small`,onClick:e.onCopyStyle,"data-tip":`Copy this look ⌥⌘C`,"data-tip-pos":`bottom`,style:{marginLeft:`auto`},children:`Copy style`}),J(`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 no(e){let[t,n]=N([]),[r,i]=N(``);P(()=>{pt(`/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 J(Y,{title:`Which blueprint goes here?`,size:`sm`,onClose:e.onClose,children:J(`div`,{style:{padding:12},children:[J(`input`,{ref:On,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)}}),J(`div`,{className:`palette__list`,style:{maxHeight:`50vh`,padding:`6px 0`},children:[o.length===0&&J(`div`,{className:`palette__empty`,children:`Every blueprint is already on this page.`}),o.map(t=>J(`div`,{className:`palette__hit`,onClick:()=>e.onPick(t),children:[J(`span`,{className:`t`,children:t.title}),J(`span`,{className:`w`,children:[t.collection,t.group?` / ${t.group}`:``]}),t.summary&&J(`span`,{className:`s`,children:t.summary})]},t.path))]})]})})}function ro(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 io(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 ao(e){return J(`span`,{className:`thread__avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:ro(e.name)})}var oo=/(@[\w.-]+)/g;function so(e){return J(C,{children:e.text.split(oo).map((t,n)=>{if(!t.startsWith(`@`))return J(`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?J(`b`,{className:`mention`,title:`${r.name}${r.role?` · ${r.role}`:``}`,children:t},n):J(`span`,{children:t},n)})})}function co(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 J(`span`,{className:`thread__field`,children:[J(`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&&J(`div`,{className:`thread__suggest`,children:i.map(e=>J(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(e),children:[J(`b`,{children:[`@`,e.alias]}),` `,J(`span`,{className:`faint`,children:e.name})]},e.alias))})]})}function lo(e){let t=e.comment.messages[0];return J(`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:J(`span`,{children:t?ro(t.author):e.index})})}function uo(e){let[t,n]=N(``),r=F(null),i=Ia(e.at,r),a=()=>{t.trim()!==``&&e.onPost(t.trim())};return J(`div`,{ref:r,className:`thread composer`,style:{left:i.x,top:i.y},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[J(`div`,{className:`thread__row`,children:[J(ao,{name:e.author.name,role:e.author.role}),J(co,{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})]}),J(`div`,{className:`thread__actions`,children:[J(`span`,{className:`faint`,children:[e.anchored?`Pinned to the object`:`Pinned here`,` · as `,e.author.name]}),J(`button`,{className:`small quiet`,onClick:e.onCancel,children:`Cancel`}),J(`button`,{className:`small primary`,disabled:t.trim()===``,onClick:a,children:`Post`})]})]})}function fo(e){let[t,n]=N(``),[r,i]=N(null),a=F(null),o=Ia(e.at,a,[e.comment.messages.length,r?.index]),{comment:s}=e;return J(`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:[J(`div`,{className:`thread__head`,children:[J(`strong`,{children:s.resolved?`Resolved`:`Thread`}),J(`button`,{className:`small quiet`,onClick:()=>e.onResolve(!s.resolved),title:s.resolved?`Reopen`:`Resolve (grays the pin)`,children:s.resolved?`Reopen`:`✓ Resolve`}),J(`button`,{className:`small quiet icon danger`,onClick:e.onDelete,"data-tip":`Delete the thread`,"data-tip-pos":`bottom`,"aria-label":`Delete the thread`,children:J(Z,{})}),J(`button`,{className:`small quiet`,onClick:e.onClose,"data-tip":`Close Esc`,"data-tip-pos":`bottom`,children:`Close`})]}),J(`div`,{className:`thread__list`,children:s.messages.map((t,n)=>J(`div`,{className:`thread__row`,children:[J(ao,{name:t.author,role:t.role}),J(`div`,{className:`thread__msg`,children:[J(`div`,{className:`thread__meta`,children:[J(`b`,{children:t.author}),J(`span`,{className:`faint`,children:io(t.at)}),r?.index!==n&&J(`span`,{className:`thread__tools`,children:[J(`button`,{className:`quiet icon`,onClick:()=>i({index:n,text:t.text}),title:`Edit`,"aria-label":`Edit message`,children:J(ln,{})}),J(`button`,{className:`quiet icon danger`,onClick:()=>e.onDeleteMessage(n),title:`Delete`,"aria-label":`Delete message`,children:J(Z,{})})]})]}),r?.index===n?J(C,{children:[J(co,{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)}),J(`div`,{className:`thread__actions`,children:J(`span`,{className:`faint`,children:`Enter saves · Esc cancels`})})]}):J(`div`,{children:J(so,{text:t.text,users:e.users})})]})]},n))}),J(`div`,{className:`thread__row`,children:[J(ao,{name:e.author.name,role:e.author.role}),J(co,{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 po(e){let t=e.comments.filter(e=>!e.resolved),n=e.comments.filter(e=>e.resolved),r=e.hideResolved?t:e.comments;return J(`div`,{className:`cv__panel cv__panel--comments`,children:[J(`div`,{className:`head`,children:[J(`strong`,{children:`Comments`}),J(`span`,{className:`faint`,children:[t.length,` open`,n.length>0?` · ${n.length} resolved`:``]}),J(`button`,{className:`quiet small`,onClick:e.onClose,children:`Close`})]}),J(`div`,{className:`body`,children:[J(`label`,{className:`cv__toggle`,children:[J(`input`,{type:`checkbox`,checked:e.hideResolved,onChange:e.onToggleHide}),`Hide resolved`]}),J(`label`,{className:`cv__toggle`,children:[J(`input`,{type:`checkbox`,checked:e.pinsHidden,onChange:e.onTogglePins}),`Hide the pins on the page`]}),r.length===0&&J(`div`,{className:`empty`,children:`No comments yet. Press C and click anywhere.`}),r.map(t=>{let n=t.messages[0];return J(`div`,{className:`thread__card${t.resolved?` resolved`:``}`,onClick:()=>e.onOpen(t.id),children:J(`div`,{className:`thread__row`,children:[n?J(ao,{name:n.author,role:n.role}):J(`span`,{className:`thread__avatar`,children:`?`}),J(`div`,{className:`thread__msg`,children:[J(`div`,{className:`thread__meta`,children:[J(`b`,{children:n?.author}),` `,J(`span`,{className:`faint`,children:n?io(n.at):``}),t.resolved&&J(`span`,{className:`badge ok`,children:`resolved`})]}),J(`div`,{className:`thread__text`,children:n?J(so,{text:n.text,users:e.users}):null}),t.messages.length>1&&J(`div`,{className:`faint`,children:[t.messages.length-1,` repl`,t.messages.length===2?`y`:`ies`]})]})]})},t.id)})]})]})}var mo=null,ho=null,go=900,_o=Math.cos(50*Math.PI/180),vo=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},yo=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)},bo=e=>{let t=yo(e);if(t===null)return`dark`;let n=1.05/(t+.05),r=(t+.05)/.061;return n*1.25>=r?`light`:`dark`};function xo(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 So=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}),Co=360,wo=400,To=460,Eo=(e,t,n)=>Math.min(n,Math.max(t,e)),Do={sketch:{w:220,h:112,label:`Sketch`},sticky:{w:176,h:176,label:`Sticky`},text:{w:160,h:32,label:`Text`},annotation:{w:Vi.w,h:Vi.h,label:`Annotation: place, then point`},blueprint:{w:220,h:112,label:`Blueprint: click, then pick`}};function Oo(e){for(let t=e;t;t=t.parentElement){let e=getComputedStyle(t).backgroundColor;if(e&&e!==`transparent`&&!/rgba\(\s*\d+,\s*\d+,\s*\d+,\s*0\)/.test(e))return e}return`#ffffff`}function ko(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function Ao(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({}),[b,x]=N({}),[S,ee]=N({}),[w,T]=N(null),[E,te]=N(null),[D,O]=N(null),[ne,re]=N(null),[ie,k]=N(null),[ae,A]=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(!1),[xe,Se]=N(()=>So(e.settings)),[Ce,we]=N(!1),[Te,Ee]=N(null),[De,Oe]=N(null),[M,ke]=N(null),Me=F(null),Ne=F(null),Pe=F(new Set),Fe=F(new Set),Ie=F(!1),Le=F(!1),Re=F(null),[ze,Be]=N(null),[L,Ve]=N(null),[He,Ue]=N(null),[We,Ge]=N(null),Ke=F(null),qe=F(null),Je=F(null);P(()=>()=>{Je.current&&window.clearTimeout(Je.current),Re.current!==null&&window.clearTimeout(Re.current)},[]);let Ye=F(null),Xe=Lt(),Ze=It(),Qe=Bt(),$e=Ma(),et=t?.page?.id??null,tt=et?`/api/canvas/${encodeURIComponent(e.id)}/pages/${encodeURIComponent(et)}`:null,nt=t?.page?.raw??null,R=m?`hand`:s,rt=F(0),it=I(()=>{let t=e.page?`/api/canvas/${encodeURIComponent(e.id)}/pages/${encodeURIComponent(e.page)}`:`/api/canvas/${encodeURIComponent(e.id)}`,r=++rt.current;pt(t).then(e=>{r===rt.current&&(n(e),i(null))}).catch(e=>r===rt.current&&i(e.message))},[e.id,e.page]);P(()=>()=>void(rt.current+=1),[]),P(it,[it,e.tick]),P(()=>{$e.reset(),_(new Set),k(null),re(null),O(null),Ee(null)},[e.id,et]),P(()=>Se(So(e.settings)),[e.settings]),P(()=>{t&&(y(Object.fromEntries(t.nodes.map(e=>[e.id,{x:e.position.x,y:e.position.y}]))),x({}),ee(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.nodes.find(t=>t.id===e)?.box))))},[t]);let at=t=>{Se(t),Xe(()=>ht(`/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(!tt)return;r&&nt&&$e.push(nt);let i=e===`POST`?mt:e===`PUT`?ht:gt;return Xe(()=>i(`${tt}${t}`,n))},[tt,nt,$e,Xe]),V=I((e,t=!0)=>B(`PUT`,``,{page:e},t).then(e=>(z(e),e)),[B,z]),ot=F(null);P(()=>{if(!t||!et||ot.current===`${e.id}/${et}`)return;let n=t.nodes.filter(e=>e.position.computed);n.length!==0&&(ot.current=`${e.id}/${et}`,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,et,e.id,B,z]);let st=I(()=>{if(!nt)return;let e=$e.undo(nt);e&&V(e,!1)},[nt,$e,V]),ct=I(()=>{if(!nt)return;let e=$e.redo(nt);e&&V(e,!1)},[nt,$e,V]),lt=je(()=>t?.nodes??[],[t]),H=je(()=>new Map(lt.map(e=>[e.id,e])),[lt]),U=I(e=>Yi(e,v,S),[v,S]),ut=je(()=>{let e=t?.page;return e?e.frames.map(e=>({frame:e,rect:Xi(e,lt,U,b[e.id])})).filter(e=>e.rect!==null):[]},[t,lt,U,b]),W=je(()=>new Map(ut.map(e=>[e.frame.id,e])),[ut]),G=I(e=>{if(zi(e))return W.get(Bi(e))?.rect??null;let t=H.get(e);return t?U(t):null},[H,W,U]),dt=I(e=>{let t=[e];for(let e=0;e<t.length;e+=1)for(let n of ut)n.frame.frame===t[e]&&!t.includes(n.frame.id)&&t.push(n.frame.id);return t},[ut]),_t=I((e,t)=>{let n=Ke.current?.getBoundingClientRect()??{left:0,top:0};return{x:(e-n.left-a.x)/a.scale,y:(t-n.top-a.y)/a.scale}},[a]),vt=I(e=>({x:e.x*a.scale+a.x,y:e.y*a.scale+a.y}),[a]),yt=I(e=>[...lt].reverse().find(t=>$i(U(t),e))??null,[lt,U]),bt=I(e=>[...ut].reverse().find(t=>$i(t.rect,e))?.frame??null,[ut]),xt=I(e=>{let t=dt(e),n=[];for(let e of t){let t=W.get(e);if(t)for(let r of lt)(r.frame===e||$i(t.rect,ea(U(r))))&&!n.includes(r.id)&&n.push(r.id)}return n},[W,dt,lt,U]),St=je(()=>na([...lt.map(U),...ut.map(e=>e.rect)]),[lt,ut,U]),wt=I((e,t=60)=>{let n=Ke.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=Eo(Math.min(n.width/(e.w+t*2),n.height/(e.h+t*2),1.2),Gi,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},[]),Tt=I(()=>wt(St),[wt,St]);Ae(()=>{t&&et&&He!==`${e.id}/${et}`&&Tt()&&Ue(`${e.id}/${et}`)},[t,et,He,Tt,e.id]);let Et=I((e,t,n)=>{let r=Ke.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=Eo(t.scale*e,Gi,3),r=n/t.scale;return{x:i-(i-t.x)*r,y:a-(a-t.y)*r,scale:n}})},[]),Dt=I(e=>{let t=Ke.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}})},[]),K=je(()=>[...g].filter(Ea).map(ka).filter(e=>H.has(e)),[g,H]),kt=je(()=>[...g].filter(Da).map(ka).filter(e=>W.has(e)),[g,W]),q=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),Ve(null),re(null),pe(null),de(null),e!==`select`&&O(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(()=>{Ee(null),p(!1)},[a.x,a.y,a.scale]),P(()=>{L||(ke(null),te(null))},[L]);let Y=I(e=>{if(!nt)return null;let t=Na(nt);return e(t),t},[nt]),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=[...ut].reverse().find(e=>e.frame.x!==void 0&&$i(b[e.frame.id]??e.rect,ea(i)));a&&(t.frame=a.frame.id)}},Ft=(e,t)=>{let n=Y(n=>{let r={};for(let t of e){let e=v[t],i=H.get(t);!e||!i||(n.layout[t]={x:Math.round(e.x),y:Math.round(e.y)},r[t]=Yi(i,v,S))}for(let e of t){let t=b[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=>xt(t).includes(e))),r)});n&&V(n)},Rt=I(()=>{if(g.size===0)return;let e=Y(e=>{let t=new Set(K),n=new Set(kt),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(Ta(e))&&!(zi(e.from)&&n.has(Bi(e.from)))&&!(zi(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,K,kt,Y,V,At]),zt=I((e,t)=>{At(),B(`DELETE`,`/frames/${encodeURIComponent(e)}${t?`?contents=delete`:``}`).then(z)},[At,B,z]),Vt=I(()=>{let e=[],t=Y(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 K){let i=t.nodes.find(e=>e.id===n),a=v[n];if(!i||i.blueprint||!a)continue;let o={...Na(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(()=>q(e.map($)))},[K,v,Y,V,q]),Ht=I(()=>{if(!nt||K.length===0)return;let e=new Set(K);mo={nodes:nt.nodes.filter(t=>e.has(t.id)).map(Na),positions:Object.fromEntries(K.map(e=>[e,v[e]??{x:0,y:0}])),box:na(K.map(e=>H.get(e)).filter(e=>e!==void 0).map(U)),edges:nt.edges.filter(t=>e.has(t.from)&&e.has(t.to)).map(Na)},Ze(`Copied ${K.length} node${K.length===1?``:`s`}; ⌘V pastes under the pointer`)},[nt,K,v,H,U,Ze]),Ut=I(e=>{let t=mo;if(!t||t.nodes.length===0)return;let n=Ke.current?.getBoundingClientRect(),r=e??Me.current??(n?_t(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=Y(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={...Na(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({...Na(n),from:t,to:r})}});l&&s.length>0&&V(l).then(()=>q(s.map($))),c>0&&Ze(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`)},[Y,V,q,_t,Ze]),Wt=I(e=>{let t=Y(t=>{for(let n of t.nodes){if(!K.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)},[K,Y,V]),Gt=I(e=>{let t=Y(t=>{for(let n of t.nodes)n.sticky&&K.includes(n.id)&&(n.sticky.color=e)});t&&V(t)},[K,Y,V]),Kt=I(()=>{let e=Y(e=>{for(let t of e.nodes)K.includes(t.id)&&(delete t.style,delete t.styled)});e&&V(e)},[K,Y,V]),qt=I(()=>{let e=K.map(e=>H.get(e)).find(e=>e!==void 0);e&&(ho={shape:e.style.shape,...e.style.color?{color:e.style.color}:{},size:e.style.size},Ze(`Style copied; ⌥⌘V lays it onto a selection`))},[K,H,Ze]),Jt=I(()=>{ho&&Wt({shape:ho.shape??null,color:ho.color??null,size:ho.size??null})},[Wt]),Yt=I(e=>{let t=Y(t=>{for(let n of t.nodes)K.includes(n.id)&&(e?n.locked=!0:delete n.locked);for(let n of t.frames)kt.includes(n.id)&&(e?n.locked=!0:delete n.locked)});t&&V(t)},[K,kt,Y,V]),Xt=g.size>0&&K.every(e=>H.get(e)?.locked)&&kt.every(e=>W.get(e)?.frame.locked),Zt=I((e,t)=>{if(K.length===0||!nt)return;Ye.current||=($e.push(nt),Na(nt));let n=Ye.current;y(r=>{let i={...r};for(let r of K){let a=i[r];!a||H.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}),Je.current&&window.clearTimeout(Je.current),Je.current=window.setTimeout(()=>{let e=Ye.current;Ye.current=null,e&&V(e,!1)},350)},[K,nt,$e,H,V]),Qt=I(e=>{let t=na(e.map(e=>H.get(e)).filter(e=>e!==void 0).map(U));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&&(q([wa(e.frame.id)]),O({kind:`frame`,id:e.frame.id,field:`label`,value:e.frame.title}))})},[H,U,B,z,q]),$t=I((e,t,n)=>{B(`POST`,`/nodes`,{...e,x:Q(t.x),y:Q(t.y)}).then(e=>{z(e),e?.node&&(q([$(e.node.id)]),n&&O({kind:n,id:e.node.id,field:`label`,value:e.node.label}))})},[B,z,q]),en=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=Ne.current===e;B(`POST`,`/edges`,a).then(t=>{z(t),t&&(o?(Ne.current=null,q([$(e)]),O({kind:`annotation`,id:e,field:`label`,value:H.get(e)?.label??``}),Nt(`annotation`,i)):R===`connect`&&Nt(`connect`,i))})},[B,z,R,Nt,H,q]),tn=I(()=>{let e=Ne.current;Ne.current=null,e&&B(`DELETE`,`/nodes/${encodeURIComponent(e)}`,void 0,!1).then(z)},[B,z]),X=F(null);X.current=D;let nn=I(()=>{let t=X.current;if(!t)return;X.current=null,O(null);let n=t.value;if(t.kind===`edge`){let{from:e,to:r}=Aa(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===W.get(t.id)?.frame.title)return;B(`PUT`,`/frames/${encodeURIComponent(t.id)}`,{title:n.trim()}).then(z);return}let r=H.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;Xe(async()=>{let e=await pt(`/api/blueprints/${ft(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 ht(`/api/blueprints/${ft(i)}`,{properties:a,body:e.body})}).then(()=>(it(),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)}},[H,W,B,z,Xe,it,e]),rn=I(t=>Ct(`${Ot(e.id,et)}?open=${encodeURIComponent(t)}`),[e.id,et]),an=I((e,t)=>{e.locked||(Ee(null),O({kind:e.kind,id:e.id,field:t,value:t===`summary`?e.summary??``:e.label}))},[]),on=I(e=>{O(null),_(new Set([e])),p(!1),Ee(e)},[]),sn=async(e,n=`png`)=>{let r=qe.current;if(!r||!t?.page)return;let i=null,a=K,o=kt;e&&(o=[...new Set(kt.flatMap(e=>dt(e)))],a=[...new Set([...K,...kt.flatMap(e=>xt(e))])],i=new Set([...a.map($),...o.map(wa)]));let s=na(e?[...a.map(e=>H.get(e)).filter(e=>e!==void 0).map(U),...o.map(e=>W.get(e)?.rect).filter(e=>e!==void 0)]:[...lt.map(U),...ut.map(e=>e.rect)]);if(!s){Ze(e?`Select something to export first.`:`Nothing on this page to export.`,`error`);return}let c=Math.ceil(s.w+80),l=Math.ceil(s.h+80),u={width:c,height:l,backgroundColor:Oo(r),style:{transform:`translate(${40-s.x}px, ${40-s.y}px)`,transformOrigin:`0 0`,width:`${c}px`,height:`${l}px`},filter:e=>{let t=e,n=t.classList;if(n&&[`cv__edit`,`frame__grip`,`frame__handle`,`node__handle`,`node__more`,`node__open`,`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(wa(r.frame));if(r.edgeGroup){let{from:e,to:t}=Aa(r.edgeGroup),n=e=>zi(e)?wa(Bi(e)):$(e);return i.has(n(e))&&i.has(n(t))}return!0}};_e(!0),r.classList.add(`exporting`),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())));try{let i=await Xe(()=>n===`svg`?qr(r,u):Yr(r,{...u,pixelRatio:2}));i&&ko(i,`${t.canvas.id}-${t.page.id}${e?`-selection`:``}.${n}`)}finally{r.classList.remove(`exporting`),_e(!1)}},cn=`.backdrop, .modal, .cv__pop, .cv__panel, .cv__stylepop, .thread, .cv__menu, .cv__prefs, .cv__pages-list, .cv__legend`,ln=e=>{if(e.target.closest(cn))return;if(e.preventDefault(),e.ctrlKey||e.metaKey){Et(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(xe.wheelZoom&&!e.shiftKey&&!t){Et(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=Ke.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 un=e=>e.kind===`text`||e.kind===`annotation`||xe.resizeAll,Z=e=>e.shiftKey||e.metaKey||e.ctrlKey&&!xe.ctrlClickMenu,dn=e=>e.button===2||xe.ctrlClickMenu&&e.ctrlKey&&e.button===0,fn=(e,t,n,r,i,a=null)=>{let o=[...new Set(i.flatMap(dt))],s=new Set(o.flatMap(xt)),c=[...new Set([...r,...s])].filter(e=>!H.get(e)?.locked);T({kind:`move`,ids:c,frames:o.filter(e=>!W.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,W.get(e)?.rect??{x:0,y:0,w:0,h:0}])),moved:!1,primary:t,primaryIsFrame:n,field:a})},hn=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),be(!1),we(!1),Ee(null),D&&nn(),e.currentTarget.setPointerCapture(e.pointerId);let r=_t(e.clientX,e.clientY);if(dn(e)){e.button===2&&xe.rightDragPan?T({kind:`pan`,startX:e.clientX,startY:e.clientY,originX:a.x,originY:a.y,moved:!1,button:2}):bn(e.clientX,e.clientY,r);return}if(e.button===1||R===`hand`){T({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){rn(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`?T({kind:`pin`,id:n,startX:e.clientX,startY:e.clientY,origin:r.at,moved:!1}):r&&(re(null),k(e=>e===n?null:n));return}let d=n.closest(`[data-edge-label]`);if(d){let t=d.dataset.edgeLabel??``;q([t]),T({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??``;q([t]),T({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){T({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`){q([m.dataset.edge??``],Z(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=H.get(t);n&&!n.locked&&T({kind:`nodesize`,id:t,corner:y.dataset.corner,origin:U(n),startX:e.clientX,startY:e.clientY});return}let b=n.closest(`[data-grip]`),x=n.closest(`[data-frame]`);if(R===`comment`){let e=_?H.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),re({x:r.x,y:r.y,node:e?.id??null,offset:t});return}if(R===`annotation`){let e={x:r.x-Vi.w/2,y:r.y-Vi.h/2};B(`POST`,`/nodes`,{annotation:{text:``},x:Q(e.x),y:Q(e.y)}).then(e=>{z(e),e?.node&&(Ne.current=e.node.id,c(`connect`),Ve({id:e.node.id,anchor:null}),q([$(e.node.id)]))});return}if(R===`sketch`||R===`sticky`||R===`text`){let t=Do[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`?$t({sketch:{label:``}},n,i?null:`sketch`):R===`sticky`?$t({sticky:{text:``,color:`yellow`}},n,i?null:`sticky`):$t({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`){T({kind:`draw`,start:r,current:r,startX:e.clientX,startY:e.clientY});return}if(R===`connect`){let t=h&&zi(h.dataset.handle??``)?h:null;if(_||t){let n=t?t.dataset.handle??``:_?.dataset.node??``,i=h?.dataset.anchor??null;L&&L.id!==n?(en(L.id,n,L.anchor,i,e.altKey),Ve(null)):T({kind:`connect`,from:n,anchor:i,point:r,moved:!1,startX:e.clientX,startY:e.clientY})}else if(L&&x){let t=x.dataset.frame??``,n=W.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||Ne.current===L.id?en(L.id,`${Ri}${t}`,L.anchor,oa(n.rect,r),e.altKey):B(`PUT`,`/nodes/${encodeURIComponent(L.id)}`,{frame:t}).then(z)),Ve(null)}else Ne.current||Ve(null);return}if(h){T({kind:`connect`,from:h.dataset.handle??``,anchor:h.dataset.anchor??null,point:r,moved:!1,startX:e.clientX,startY:e.clientY});return}if(b&&x){let t=x.dataset.frame??``,n=W.get(t);n&&!n.frame.locked&&T({kind:`resize`,frame:t,corner:b.dataset.grip,origin:n.rect,startX:e.clientX,startY:e.clientY});return}if(_){let t=_.dataset.node??``,r=H.get(t);if(!r)return;let i=$(t);if(Z(e)){q([i],!0);return}let a=K,o=kt,s=g.has(i);if(s||(q([i]),a=[t],o=[]),r.locked)return;let c=s?n.closest(`[data-field]`):null;fn(e,t,!1,a,o,c?.dataset.field??null);return}if(x){let t=x.dataset.frame??``,r=W.get(t);if(!r)return;let i=wa(t);if(Z(e)){q([i],!0);return}let a=kt,o=K,s=g.has(i);if(s||(q([i]),a=[t],o=[]),r.frame.locked)return;fn(e,t,!0,o,a,s&&n.closest(`.frame__title`)?`label`:null);return}T({kind:`marquee`,start:r,current:r,additive:Z(e),startX:e.clientX,startY:e.clientY}),Z(e)||At(),k(null)},_n=e=>{let n=_t(e.clientX,e.clientY);if(Me.current=n,Do[R]&&!ue?te(n):E&&!L&&te(null),!w){let t=e.target.closest(`[data-frame]`)?.dataset.frame??null;if(t!==De&&Oe(t),L){te(n);let e=yt(n),t=e&&e.id!==L.id?{kind:`node`,id:e.id,anchor:oa(U(e),n)}:null;if(!t){let e=bt(n),r=e?W.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||Ne.current===L.id?{kind:`frame-border`,id:e.id,anchor:oa(r.rect,n)}:{kind:`frame`,id:e.id})}JSON.stringify(t)!==JSON.stringify(M)&&ke(t)}return}let r=e.clientX-w.startX,i=e.clientY-w.startY,s=Math.abs(r)>3||Math.abs(i)>3;switch(w.kind){case`pan`:o(e=>({...e,x:w.originX+r,y:w.originY+i})),s!==w.moved&&T({...w,moved:s});return;case`move`:{let e=r/a.scale,t=i/a.scale;y(n=>{let r={...n};for(let n of w.ids){let i=w.origins[n];i&&(r[n]={x:Q(i.x+e),y:Q(i.y+t)})}return r}),w.frames.length>0&&x(n=>{let r={...n};for(let n of w.frames){let i=w.frameOrigins[n];i&&(r[n]={...i,x:Q(i.x+e),y:Q(i.y+t)})}return r}),s!==w.moved&&T({...w,moved:s});return}case`marquee`:case`draw`:T({...w,current:n});return;case`connect`:case`endpoint`:{let e=yt(n),t=w.kind===`connect`?w.from:null,r=e&&e.id!==t?{kind:`node`,id:e.id,anchor:oa(U(e),n)}:null;if(!r&&w.kind===`connect`){let e=bt(n),t=e?W.get(e.id):void 0;if(e&&t&&`frame:${e.id}`!==w.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=H.get(w.from)?.kind===`annotation`,o=zi(w.from)?W.get(Bi(w.from))?.frame.frame===e.id:H.get(w.from)?.frame===e.id;r=i<=18||a?{kind:`frame-border`,id:e.id,anchor:oa(t.rect,n)}:o?null:{kind:`frame`,id:e.id}}}JSON.stringify(r)!==JSON.stringify(M)&&ke(r),T(w.kind===`connect`?{...w,point:n,moved:s}:{...w,point:n});return}case`resize`:{let e=r/a.scale,t=i/a.scale,n=w.origin,{x:o,y:s,w:c,h:l}=n;w.corner.includes(`e`)&&(c=Math.max(60,n.w+e)),w.corner.includes(`s`)&&(l=Math.max(60,n.h+t)),w.corner.includes(`w`)&&(c=Math.max(60,n.w-e),o=n.x+n.w-c),w.corner.includes(`n`)&&(l=Math.max(60,n.h-t),s=n.y+n.h-l),x(e=>({...e,[w.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=w.origin,{x:o,y:s,w:c,h:l}=n;w.corner.includes(`e`)&&(c=Math.max(40,n.w+e)),w.corner.includes(`s`)&&(l=Math.max(24,n.h+t)),w.corner.includes(`w`)&&(c=Math.max(40,n.w-e),o=n.x+n.w-c),w.corner.includes(`n`)&&(l=Math.max(24,n.h-t),s=n.y+n.h-l),ee(e=>({...e,[w.id]:{w:Q(c),h:Q(l)}})),y(e=>({...e,[w.id]:{x:Q(o),y:Q(s)}}));return}case`bend`:T({...w,value:Q(w.origin+(w.axis===`x`?r:i)/a.scale)});return;case`label`:{let{from:e,to:r}=Aa(w.key),i=t?.page?.edges.find(t=>t.from===e&&t.to===r),a=G(e),o=G(r);if(!i||!a||!o)return;let s=ma(a,o,{bend:i.bend,from:i.from_anchor,to:i.to_anchor});T({...w,t:va(s.points,n)});return}case`pin`:T({...w,moved:s}),Ge(w.moved||s?{id:w.id,at:{x:w.origin.x+r/a.scale,y:w.origin.y+i/a.scale}}:null);return}},vn=e=>{if(!w)return;T(null);let n=_t(e.clientX,e.clientY);switch(w.kind){case`pan`:!w.moved&&w.button===2?bn(e.clientX,e.clientY,n):!w.moved&&R===`hand`&&At();return;case`move`:{let t=w.primaryIsFrame?wa(w.primary):$(w.primary);if(w.moved)Ft(w.ids,w.frames);else if(w.field&&R===`select`){if(w.primaryIsFrame){let e=W.get(w.primary);e&&!e.frame.locked&&O({kind:`frame`,id:e.frame.id,field:`label`,value:e.frame.title})}else{let e=H.get(w.primary);e&&an(e,w.field)}}else Z(e)||q([t]);return}case`marquee`:{let e=ta(w.start,w.current);if(e.w<4&&e.h<4)return;let t=lt.filter(t=>!t.locked&&Zi(U(t),e)).map(e=>$(e.id)),n=ut.filter(t=>!t.frame.locked&&Qi(e,t.rect)).map(e=>wa(e.frame.id));w.additive?_(e=>new Set([...e,...t,...n])):q([...t,...n]);return}case`draw`:{let t=ta(w.start,w.current);if(t.w<20||t.h<20){K.length>0&&Qt(K);return}let n=lt.filter(e=>Qi(t,U(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&&(q([wa(e.frame.id)]),O({kind:`frame`,id:e.frame.id,field:`label`,value:e.frame.title}))});return}case`connect`:{let t=M;if(ke(null),t?.kind===`node`&&H.get(t.id)&&t.id!==w.from)en(w.from,t.id,w.anchor,t.anchor,e.altKey);else if(t?.kind===`frame-border`)en(w.from,`${Ri}${t.id}`,w.anchor,t.anchor,e.altKey);else if(t?.kind===`frame`){let e=W.get(t.id)?.frame.title??t.id;zi(w.from)?B(`PUT`,`/frames/${encodeURIComponent(Bi(w.from))}`,{frame:t.id}).then(t=>(z(t),Ze(`Attached to ${e}; they move together`))):B(`PUT`,`/nodes/${encodeURIComponent(w.from)}`,{frame:t.id}).then(t=>(z(t),Ze(`Attached to ${e}`)))}else!w.moved&&R===`connect`&&Ve({id:w.from,anchor:w.anchor});return}case`endpoint`:{let{from:e,to:t}=Aa(w.key),n=M;if(ke(null),n?.kind!==`node`)return;let r=n.id;if(!H.get(r))return;let i=n.anchor;if(r===(w.end===`from`?e:t)){B(`PUT`,`/edges`,{from:e,to:t,[w.end===`from`?`from_anchor`:`to_anchor`]:i}).then(z);return}if(r===(w.end===`from`?t:e))return;let a=Y(n=>{let a=n.edges.find(n=>n.from===e&&n.to===t);a&&(w.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(()=>q([Ta({from:w.end===`from`?r:e,to:w.end===`to`?r:t})]));return}case`resize`:{let e=b[w.frame];if(e){let t=Y(t=>{let n=t.frames.find(e=>e.id===w.frame);n&&Object.assign(n,{x:e.x,y:e.y,w:e.w,h:e.h});let r=lt.filter(t=>$i(e,ea(U(t)))).map(e=>e.id);for(let e of t.nodes)r.includes(e.id)?e.frame=w.frame:e.frame===w.frame&&delete e.frame});t&&V(t)}return}case`nodesize`:{let e=S[w.id],t=v[w.id];if(!e)return;let n=Y(n=>{let r=n.nodes.find(e=>e.id===w.id);r&&(r.box={w:Math.round(e.w),h:Math.round(e.h)},t&&(n.layout[w.id]={x:Math.round(t.x),y:Math.round(t.y)}))});n&&V(n);return}case`bend`:{let{from:e,to:t}=Aa(w.key);w.value!==w.origin&&B(`PUT`,`/edges`,{from:e,to:t,bend:w.value}).then(z);return}case`label`:{let{from:n,to:r}=Aa(w.key);if(Math.abs(e.clientX-w.startX)>3||Math.abs(e.clientY-w.startY)>3)B(`PUT`,`/edges`,{from:n,to:r,label_at:w.t}).then(z);else{let e=t?.page?.edges.find(e=>e.from===n&&e.to===r);O({kind:`edge`,id:w.key,field:`label`,value:e?.label??``})}return}case`pin`:{let e=We?.at;if(Ge(null),w.moved&&e){let t=yt(e);B(`PUT`,`/comments/${encodeURIComponent(w.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===w.id?null:w.id),re(null);return}}},yn=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}=Aa(t),a=An?.edges.find(e=>e.from===r&&e.to===i),o=G(r),s=G(i),c=_t(e.clientX,e.clientY),l=a&&o&&s?va(ma(o,s,{bend:a.bend,from:a.from_anchor,to:a.to_anchor}).points,c):void 0;q([t]),O({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=W.get(r.dataset.frame??``);e&&!e.frame.locked&&O({kind:`frame`,id:e.frame.id,field:`label`,value:e.frame.title})}},bn=(e,t,n)=>{if(xe.contextMenu)return Cn(e,t,n);let r=yt(n),i=r?null:bt(n),a=r?$(r.id):i?wa(i.id):null;a&&(g.has(a)||q([a]),on(a))},Cn=(e,t,n)=>{let r=Ke.current?.getBoundingClientRect()??{left:0,top:0},i={x:e-r.left,y:t-r.top},a=yt(n),o=a?null:bt(n),s=[];if(a){g.has($(a.id))||q([$(a.id)]);let e=K.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:()=>rn(a.path??``)}),s.push({label:`Copy`,hint:`⌘C`,onSelect:()=>Ht()}),s.push({label:`Attach comment`,onSelect:()=>re({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:()=>Qt(e?K:[a.id])}),s.push({label:`Duplicate`,hint:`⌘D`,disabled:a.kind===`blueprint`&&!e,onSelect:()=>Vt()}),s.push({label:`Copy style`,hint:`⌥⌘C`,onSelect:()=>qt()}),s.push({label:`Paste style`,hint:`⌥⌘V`,disabled:ho===null,onSelect:()=>Jt()}),s.push({label:a.locked?`Unlock`:`Lock`,hint:`L`,onSelect:()=>Yt(!a.locked)}),s.push({separator:!0,label:``}),s.push({label:a.kind===`blueprint`?`Remove from canvas`:`Delete`,hint:`⌫`,danger:!0,onSelect:()=>Rt()})}else o?(g.has(wa(o.id))||q([wa(o.id)]),s.push({label:`Details…`,hint:`⏎`,onSelect:()=>on(wa(o.id))}),s.push({label:`Rename`,onSelect:()=>O({kind:`frame`,id:o.id,field:`label`,value:o.title})}),s.push({label:`Select attached`,onSelect:()=>q(xt(o.id).map($))}),s.push({label:o.locked?`Unlock`:`Lock`,hint:`L`,onSelect:()=>Yt(!o.locked)}),s.push({separator:!0,label:``}),s.push({label:`Delete Frame Only`,danger:!0,onSelect:()=>zt(o.id,!1)}),s.push({label:`Delete Frame & Contents`,danger:!0,disabled:xt(o.id).length===0,onSelect:()=>zt(o.id,!0)})):(s.push({label:`Insert sketch`,hint:`R`,onSelect:()=>$t({sketch:{label:``}},{x:n.x-110,y:n.y-56},`sketch`)}),s.push({label:`Insert sticky`,hint:`S`,onSelect:()=>$t({sticky:{text:``,color:`yellow`}},{x:n.x-88,y:n.y-88},`sticky`)}),s.push({label:`Insert text`,hint:`T`,onSelect:()=>$t({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:()=>re({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:mo===null,onSelect:()=>Ut(n)}),s.push({label:`Select all`,hint:`⌘A`,onSelect:()=>q(lt.filter(e=>!e.locked).map(e=>$(e.id)))}),s.push({label:`Fit to view`,hint:`⇧1`,onSelect:()=>void Tt()}));pe({at:i,items:s})},Tn=I(()=>{let e=new Set([...Pe.current,...Fe.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}},[]),En=I(()=>{let[e]=[...g];if(!e)return null;let t=Ea(e)?G(ka(e)):Da(e)?W.get(ka(e))?.rect??null:null;return t?ea(t):null},[g,G,W]),Dn=I(e=>{let[n]=[...g],r=En();if(!n||!r||Pe.current.size===0&&Fe.current.size===0)return;let i=Tn();Fe.current.clear();let a=[];if(e&&Ea(n)){let e=ka(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=G(t);r&&a.push({key:zi(t)?wa(Bi(t)):$(t),rect:r})}}else{for(let e of lt)$(e.id)!==n&&a.push({key:$(e.id),rect:U(e)});for(let e of ut)wa(e.frame.id)!==n&&a.push({key:wa(e.frame.id),rect:e.rect})}let s=null;for(let t of a){if(!e&&$i(t.rect,r))continue;let n=ea(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:_o)||!e&&c>go)continue;let u=c*(2-l);(!s||u<s.score)&&(s={key:t.key,score:u})}if(!s)return;q([s.key]);let c=Da(s.key)?W.get(ka(s.key))?.rect:G(ka(s.key)),l=Ke.current?.getBoundingClientRect();if(c&&l){let e=vt({x:c.x,y:c.y}),t=vt({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=ea(c);o(t=>({...t,x:l.width/2-e.x*t.scale,y:l.height/2-e.y*t.scale}))}}},[g,En,Tn,t,G,lt,ut,U,q,W,vt]);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||ye||Ce?(pe(null),he(!1),be(!1),we(!1)):Te?Ee(null):ne?re(null):ie?k(null):ue?de(null):j?ve(!1):L?(Ve(null),Ne.current&&(tn(),jt(`select`))):l?(u(null),jt(`select`)):s===`select`?At():jt(`select`);return}if(r&&t.key.toLowerCase()===`z`){t.preventDefault(),t.shiftKey?ct():st();return}if(r&&t.key.toLowerCase()===`a`){t.preventDefault(),q(lt.filter(e=>!e.locked).map(e=>$(e.id)));return}if(r&&t.key.toLowerCase()===`d`){t.preventDefault(),Vt();return}if(r&&t.altKey&&(t.key.toLowerCase()===`c`||t.code===`KeyC`)){if(K.length===0)return;t.preventDefault(),qt();return}if(r&&t.altKey&&(t.key.toLowerCase()===`v`||t.code===`KeyV`)){if(!ho||K.length===0)return;t.preventDefault(),Jt();return}if(r&&t.key.toLowerCase()===`c`){if(K.length===0)return;t.preventDefault(),Ht();return}if(r&&t.key.toLowerCase()===`v`){if(!mo)return;t.preventDefault(),Ut();return}if(r&&t.shiftKey&&t.key.toLowerCase()===`l`){t.preventDefault(),Yt(!Xt);return}if(r&&t.key===`0`){t.preventDefault(),Dt(1);return}if(r)return;if(t.key===`Delete`||t.key===`Backspace`){t.preventDefault(),Rt();return}if(t.key.startsWith(`Arrow`)){if(t.preventDefault(),t.altKey||g.size!==1){let e=t.shiftKey?10:1;Zt(t.key===`ArrowLeft`?-e:t.key===`ArrowRight`?e:0,t.key===`ArrowUp`?-e:t.key===`ArrowDown`?e:0);return}if(t.repeat&&Pe.current.has(t.key))return;if(Pe.current.add(t.key),Le.current){let e=En();e&&Be({from:e,dir:Tn()});return}Fe.current.add(t.key),Ie.current=t.shiftKey;let e=t.shiftKey;Re.current===null&&!e&&(Re.current=window.setTimeout(()=>{Re.current=null;let e=En();e&&Pe.current.size>0&&(Le.current=!0,Fe.current.clear(),Be({from:e,dir:Tn()}))},450));return}if(t.key.toLowerCase()===`l`&&!t.shiftKey&&g.size>0){Yt(!Xt);return}if(t.key===`?`){ve(e=>!e);return}if(t.key===`+`||t.key===`=`)return void Et(1.2);if(t.key===`-`)return void Et(1/1.2);if(t.shiftKey){let e=t.key.toLowerCase();if(t.key===`!`||e===`1`)return void Tt();if(t.key===`@`||e===`2`){let e=[...K.map(e=>H.get(e)).filter(e=>e!==void 0).map(U),...kt.map(e=>W.get(e)?.rect).filter(e=>e!==void 0)];wt(na(e),80);return}if(t.key===`)`||e===`0`)return void Dt(1);if(e===`c`||t.code===`KeyC`)return void le(e=>!e);if(t.key===`Enter`){g.size>0&&(Ee(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`&&K.length>0&&s===`select`?Qt(K):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`)&&(Pe.current.delete(e.key),Pe.current.size===0&&(Re.current!==null&&window.clearTimeout(Re.current),Re.current=null,Le.current=!1,Be(null),Fe.current.size>0&&Dn(Ie.current)))};return window.addEventListener(`keydown`,t),window.addEventListener(`keyup`,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`keyup`,n)}},[e.open,fe,me,ye,Ce,Te,ne,ie,ue,j,L,s,l,jt,At,ct,st,q,g,lt,Vt,Ht,Ut,qt,Jt,Yt,Xt,Dt,Rt,Zt,Et,Tt,K,kt,H,W,U,wt,Qt,on,tn,Dn,En,Tn,Mt]);let kn=I((e,t)=>{if(!t||H.get(e)?.box||w?.kind===`nodesize`)return;let n={w:t.offsetWidth,h:t.offsetHeight};ee(t=>t[e]?.w===n.w&&t[e]?.h===n.h?t:{...t,[e]:n})},[H,w]);if(r)return J(`div`,{className:`page empty`,children:r});if(!t)return J(`div`,{className:`page empty`,children:`Loading…`});let An=t.page;if(!An)return J(`div`,{className:`page empty`,children:`This canvas has no page yet.`});let jn=w?.kind===`marquee`?ta(w.start,w.current):null,Mn=w?.kind===`draw`?ta(w.start,w.current):null,Nn=t.comments.filter(e=>ae&&(!oe||!e.resolved||ie===e.id)),Pn=e.settings.shared.users,Fn=ie?t.comments.find(e=>e.id===ie):null,In=t.palette.find(e=>e.color)?.color??null,Ln=g.size===1,Rn=Ln&&kt[0]?W.get(kt[0]):void 0,zn=e=>{let t=Ke.current?.getBoundingClientRect()??{width:800,height:600},n=vt({x:e.x+e.w,y:e.y}),r=vt({x:e.x,y:e.y});return{x:Eo(n.x+14+Co<=t.width?n.x+14:Math.max(8,r.x-Co-14),8,Math.max(8,t.width-Co-8)),y:Eo(n.y,8,Math.max(8,t.height-To-8))}},Bn=e=>{let t=Ke.current?.getBoundingClientRect()??{width:800,height:600},n=vt({x:e.x,y:e.y}),r=vt({x:e.x,y:e.y+e.h});return{x:Eo(n.x,8,Math.max(8,t.width-wo-8)),y:r.y+14}},Vn=Te&&Ea(Te)?H.get(ka(Te)):void 0,Hn=Te&&Da(Te)?W.get(ka(Te)):void 0,Un=Te&&Oa(Te)?An.edges.find(e=>Ta(e)===Te):void 0,Wn=De??(Rn?Rn.frame.id:null),Gn=Wn?W.get(Wn)?.rect??null:null,Kn=e=>e.node&&v[e.node]?{x:v[e.node].x+e.x,y:v[e.node].y+e.y}:e.at,qn={faint:xo(`--text-faint`,`#6f7680`),muted:xo(`--text-muted`,`#575c65`),accent:xo(`--accent`,`#e08a63`),text:xo(`--text`,`#191b1f`),bg:xo(`--bg`,`#faf8f4`),font:getComputedStyle(document.body).fontFamily},Jn=g.size>1?na([...K.map(e=>H.get(e)).filter(e=>e!==void 0).map(U),...kt.map(e=>W.get(e)?.rect).filter(e=>e!==void 0)]):null,Yn=Jn??(K[0]&&H.get(K[0])?U(H.get(K[0])):kt[0]?W.get(kt[0])?.rect??null:null),Xn=(e,t,n)=>{let r=Ke.current?.getBoundingClientRect()??{width:800,height:600};return{x:Eo(e.x,8,Math.max(8,r.width-t-8)),y:Eo(e.y,8,Math.max(8,r.height-n-8))}},Zn=D?D.kind===`frame`?W.get(D.id)?.rect??null:H.get(D.id)?U(H.get(D.id)):null:null,Qn=(()=>{if(!Zn||!D||D.kind!==`sketch`&&D.kind!==`blueprint`)return null;let e=qe.current?.querySelector(`[data-node="${D.id}"]`),t=e?.querySelector(`[data-field="${D.field}"]`),n=qe.current?.getBoundingClientRect();if(!e||!t||!n)return D.field===`label`?{x:Zn.x+9,y:Zn.y+6,w:Zn.w-18,h:26}:{x:Zn.x+9,y:Zn.y+30,w:Zn.w-18,h:Zn.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`)-(H.get(D.id)?.shown.length?28:10);return{x:s,y:c,w:Math.max(l,60),h:D.field===`label`?Math.max(24,i.height/a.scale):Math.max(40,u-c)}})(),$n=Ln?An.edges.find(e=>g.has(Ta(e))):void 0,er=(()=>{if(g.size===0||D||w)return null;let e=na([...K.map(e=>H.get(e)).filter(e=>e!==void 0).map(U),...kt.map(e=>W.get(e)?.rect).filter(e=>e!==void 0)]);if(!e&&$n&&G($n.from)&&G($n.to)){let t=ma(G($n.from),G($n.to),{bend:$n.bend,from:$n.from_anchor,to:$n.to_anchor});e={x:t.label.x,y:t.label.y-10,w:0,h:0}}if(!e)return null;let t=vt({x:e.x+e.w/2,y:e.y});return{x:t.x,y:t.y-12}})(),tr=er!==null&&er.y-44>=260,nr=Ln&&K[0]?H.get(K[0]):void 0,rr=Do[R],ir=ue??(rr&&E&&!L?{x:Q(E.x-rr.w/2),y:Q(E.y-rr.h/2)}:null),ar=e=>`sticky-${e.style.color??`yellow`}`,or=e=>`text-${e.style.size}`,sr=Ke.current?.getBoundingClientRect(),cr=er&&f?J(to,{anchored:tr,at:tr?{x:0,y:-8}:Yn?Bn(Yn):{x:er.x-wo/2,y:er.y+40},nodes:K.map(e=>H.get(e)).filter(e=>e!==void 0),resizable:K.every(e=>{let t=H.get(e);return t!==void 0&&un(t)}),frame:Rn?.frame,edge:$n,onNodeStyle:Wt,onTextSize:e=>{let t=Y(t=>{for(let n of t.nodes)!n.text||!K.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=Y(t=>{for(let n of t.nodes)K.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:Gt,onAnnotationColor:e=>{let t=Y(t=>{for(let n of t.nodes)!n.annotation||!K.includes(n.id)||(e?n.annotation.color=e:delete n.annotation.color)});t&&V(t)},onFrameColor:e=>Rn&&void B(`PUT`,`/frames/${encodeURIComponent(Rn.frame.id)}`,{color:e}).then(z),onEdge:e=>$n&&void B(`PUT`,`/edges`,{from:$n.from,to:$n.to,...e}).then(z),onReset:()=>$n?void B(`PUT`,`/edges`,{from:$n.from,to:$n.to,color:null,style:null,start:null,end:null,label_at:null}).then(z):Kt(),onCopyStyle:qt,onPasteStyle:Jt,canPaste:ho!==null,onClose:()=>p(!1)}):null;return J(`div`,{ref:Ke,className:`cv${w?.kind===`pan`&&w.moved?` panning`:``}${w?` dragging`:``}`,"data-tool":R,onWheel:ln,onPointerDown:hn,onPointerMove:_n,onPointerUp:vn,onPointerCancel:()=>{w?.kind===`move`&&(y(e=>({...e,...w.origins})),x(e=>({...e,...w.frameOrigins}))),ke(null),Ge(null),T(null)},onPointerLeave:()=>te(null),onDoubleClick:yn,onContextMenu:e=>e.preventDefault(),children:[J(`div`,{ref:qe,className:`cv__world`,style:{transform:`translate(${a.x}px, ${a.y}px) scale(${a.scale})`},children:[ut.map(({frame:e,rect:t})=>J(`div`,{className:`frame${e.color?` frame-${e.color}`:``}${g.has(wa(e.id))?` selected`:``}${e.locked?` locked`:``}${De===e.id&&!w?` 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:[J(`span`,{className:`frame__title${g.has(wa(e.id))&&!e.locked?` hot`:``}`,"data-field":`label`,children:[e.title,e.locked&&J(`span`,{className:`lock`,"data-lock":e.id,"data-lock-kind":`frame`,title:`Locked; click to unlock`,children:J(wn,{})})]}),[`nw`,`ne`,`sw`,`se`,`n`,`e`,`s`,`w`].map(e=>J(`i`,{className:`frame__grip ${e}`,"data-grip":e},e)),ia.map(t=>J(`span`,{className:`frame__handle frame__handle--${t}`,"data-handle":`${Ri}${e.id}`,"data-anchor":t},t))]},e.id)),J(`svg`,{className:`cv__svg`,width:`1`,height:`1`,children:[ze&&(()=>{let e=Math.atan2(ze.dir.y,ze.dir.x),t=e-50*Math.PI/180,n=e+50*Math.PI/180,r=ze.from;return J(`path`,{className:`navrange`,d:`M${r.x},${r.y} L${r.x+Math.cos(t)*go},${r.y+Math.sin(t)*go} A${go},${go} 0 0 1 ${r.x+Math.cos(n)*go},${r.y+Math.sin(n)*go} Z`})})(),An.edges.map(e=>{let t=G(e.from),n=G(e.to);if(!t||!n)return null;let r=Ta(e),i=w?.kind===`bend`&&w.key===r?w.value:e.bend,a=g.has(r);if(w?.kind===`endpoint`&&w.key===r){let i=w.end===`from`?n:t,a={x:w.point.x,y:w.point.y,w:1,h:1};return J(`path`,{className:`temp`,d:(w.end===`from`?ma(a,i,{to:e.to_anchor}):ma(i,a,{from:e.from_anchor})).d,fill:`none`},r)}let o=ma(t,n,{bend:i,from:e.from_anchor,to:e.to_anchor}),s=H.get(e.from),c=s?.kind===`annotation`,l=c?s?.style.color??qn.text:e.color??(a?qn.accent:qn.faint),u=a?2.2:1.6,d=c?`none`:e.start??`none`,f=c?`arrow`:e.end??`triangle`,p=[Sa(o.start,Ca(o.points,`start`),d),Sa(o.end,Ca(o.points,`end`),f)],m=w?.kind===`label`&&w.key===r?w.t:e.label_at??.5,h=_a(o.points,m),_=D?.kind===`edge`&&D.id===r;return J(`g`,{"data-edge-group":r,children:[J(`path`,{className:`hit`,d:o.d,"data-edge":r,fill:`none`}),J(`path`,{className:`edge${a?` selected`:``}`,d:ha(o.points,xa(d),xa(f)),fill:`none`,style:{fill:`none`,stroke:l,strokeWidth:u,strokeDasharray:!c&&e.style===`dashed`?`7 5`:void 0}}),p.map((e,t)=>e&&J(`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&&!_&&J(C,{children:[!ge&&J(`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}),J(`text`,{x:h.x,y:h.y-8,textAnchor:`middle`,style:{fill:e.color??qn.muted,fontSize:11,fontFamily:qn.font,paintOrder:`stroke`,stroke:qn.bg,strokeWidth:3,strokeLinejoin:`round`},children:e.label})]}),a&&!ge&&o.handle&&o.mid!==null&&J(`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&&!ge&&J(`circle`,{className:`endpoint`,cx:o.start.x,cy:o.start.y,r:5,"data-endpoint":`from`,"data-edge":r}),a&&!ge&&J(`circle`,{className:`endpoint`,cx:o.end.x,cy:o.end.y,r:5,"data-endpoint":`to`,"data-edge":r})]},r)}),w?.kind===`connect`&&G(w.from)&&(()=>{let e=M?.kind===`node`?G(M.id):M?.kind===`frame-border`?W.get(M.id)?.rect??null:null,t=e&&(M?.kind===`node`||M?.kind===`frame-border`)?aa(e,M.anchor):w.point;return J(`path`,{className:`temp`,fill:`none`,d:ma(G(w.from),{x:t.x,y:t.y,w:1,h:1},{from:w.anchor??void 0,to:M?.kind===`node`||M?.kind===`frame-border`?M.anchor:void 0}).d})})(),L&&!w&&E&&G(L.id)&&(()=>{let e=M?.kind===`node`?G(M.id):M?.kind===`frame-border`?W.get(M.id)?.rect??null:null,t=e&&(M?.kind===`node`||M?.kind===`frame-border`)?aa(e,M.anchor):E;return J(`path`,{className:`temp`,fill:`none`,d:ma(G(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`&&H.get(M.id)&&(()=>{let e=U(H.get(M.id)),t=aa(e,M.anchor);return J(`g`,{className:`snap`,children:[J(`rect`,{className:`group-box`,x:e.x-3,y:e.y-3,width:e.w+6,height:e.h+6,rx:8}),J(`circle`,{className:`snap`,cx:t.x,cy:t.y,r:7})]})})(),L&&!ge&&H.get(L.id)&&(()=>{let e=U(H.get(L.id));return J(`rect`,{className:`group-box`,x:e.x-4,y:e.y-4,width:e.w+8,height:e.h+8,rx:8})})(),jn&&!ge&&J(`rect`,{className:`marquee`,x:jn.x,y:jn.y,width:jn.w,height:jn.h}),Mn&&!ge&&J(`rect`,{className:`drawing`,x:Mn.x,y:Mn.y,width:Mn.w,height:Mn.h,rx:12}),Jn&&!ge&&J(`rect`,{className:`group-box`,x:Jn.x-6,y:Jn.y-6,width:Jn.w+12,height:Jn.h+12,rx:8})]}),lt.map(t=>{let n=v[t.id]??t.position,r=g.has($(t.id)),i=D?.id===t.id&&D.kind!==`frame`&&(t.kind===`sticky`||t.kind===`text`||t.kind===`annotation`),a=D?.id===t.id?D.field:null,o=Wn!==null&&t.frame===Wn&&!(Gn&&$i(Gn,ea(U(t)))),s=r&&!t.locked&&R===`select`,c=ia.map(e=>J(`span`,{className:`node__handle node__handle--${e}`,"data-handle":t.id,"data-anchor":e},e)),l=r&&!t.locked&&R===`select`&&un(t)?[`nw`,`ne`,`sw`,`se`].map(e=>J(`i`,{className:`node__grip ${e}`,"data-node-grip":t.id,"data-corner":e},e)):null,u=t.box!==null||w?.kind===`nodesize`&&w.id===t.id,d=u?Ji(t,S):null,f=t.locked&&J(`span`,{className:`node__lock`,"data-lock":t.id,title:`Locked; click to unlock`,children:J(wn,{})}),p=J(`span`,{className:`node__more`,"data-details":t.id,title:`Details ⏎`,children:J(gn,{})});if(t.kind===`text`)return J(`div`,{ref:e=>kn(t.id,e),"data-node":t.id,"data-field":`label`,className:`text-el ${or(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:[J(`div`,{className:`text-el__body`,children:t.label||J(`span`,{style:{opacity:.45},children:`Text`})}),c,l]},t.id);if(t.kind===`annotation`)return J(`div`,{ref:e=>kn(t.id,e),"data-node":t.id,"data-field":`label`,className:`node annotation${r?` selected`:``}${t.locked?` locked`:``}${o?` attached`:``}${s?` hot`:``}${Ne.current===t.id?` pending`:``}${t.style.color&&vo(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,J(`div`,{className:`node__lbl`,children:t.label||J(`span`,{style:{opacity:.55},children:Ne.current===t.id?`Now click what this points at`:`Annotation`})}),c,l]},t.id);if(t.kind===`sticky`){let e=Ji(t,S);return J(`div`,{"data-node":t.id,"data-field":`label`,className:`node sticky ${ar(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,J(`div`,{className:`node__lbl`,children:t.label||J(`span`,{style:{opacity:.45},children:`Note`})}),c,l]},t.id)}return J(`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-${bo(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&&J(`i`,{className:`node__bar`}),f,t.kind===`blueprint`&&t.path&&J(`span`,{className:`node__open`,"data-open":t.path,title:`Open the blueprint`,children:J(mn,{})}),p,J(`div`,{className:`node__lbl`,"data-field":`label`,title:t.label,style:a===`label`?{visibility:`hidden`}:void 0,children:[J(`span`,{className:`node__kind`,title:t.kind===`blueprint`?`Blueprint`:`Sketch`,children:t.kind===`blueprint`?J(xn,{}):J(Sn,{})}),t.link?J(`a`,{href:t.link.canvas?Ot(t.link.canvas):Ot(e.id,t.link.page),onPointerDown:e=>e.stopPropagation(),onClick:n=>{n.preventDefault(),Ct(t.link?.canvas?Ot(t.link.canvas):Ot(e.id,t.link?.page))},children:[t.label,` ↗`]}):t.label||J(`span`,{className:`node__ph`,children:`Untitled`})]}),J(`div`,{className:`node__sum`,"data-field":`summary`,title:t.summary??void 0,style:a===`summary`?{visibility:`hidden`}:void 0,children:t.summary??(s?J(`span`,{className:`node__ph`,children:t.kind===`blueprint`?`no summary yet`:`Description`}):``)}),t.shown.length>0&&J(`div`,{className:`node__tags`,children:t.shown.map(e=>J(`span`,{children:e.value},e.property))}),c,l]},t.id)}),rr&&ir&&J(`div`,{className:`ghost${R===`sticky`?` ghost--sticky`:R===`text`?` ghost--text`:``}`,style:{left:ir.x,top:ir.y,width:rr.w,height:rr.h},children:J(`span`,{children:ue?`Pick the blueprint…`:rr.label})}),D?.kind===`edge`&&(()=>{let{from:e,to:t}=Aa(D.id),n=An.edges.find(n=>n.from===e&&n.to===t),r=G(e),i=G(t);if(!n||!r||!i)return null;let a=_a(ma(r,i,{bend:n.bend,from:n.from_anchor,to:n.to_anchor}).points,D.t??n.label_at??.5);return J(`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:J(`input`,{ref:On,value:D.value,placeholder:`label`,style:{width:`100%`},onChange:e=>O({...D,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?nn():e.key===`Escape`&&O(null)},onBlur:nn,onFocus:e=>e.target.select()})})})(),D&&D.kind!==`edge`&&Zn&&J(`div`,{className:`cv__edit ${D.kind}${D.kind===`sticky`?` ${ar(H.get(D.id))}`:D.kind===`text`?` ${or(H.get(D.id))}`:``}${Qn?` cv__edit--field field-${D.field}`:``}`,style:D.kind===`frame`?{left:Zn.x+10,top:Zn.y-13}:D.kind===`text`?{left:Zn.x,top:Zn.y,width:Math.max(200,Zn.w+20),height:Math.max(40,Zn.h+8)}:Qn?{left:Qn.x,top:Qn.y,width:Qn.w,height:Qn.h}:{left:Zn.x,top:Zn.y,width:Zn.w,height:Zn.h},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:D.kind===`frame`?J(`input`,{ref:On,value:D.value,onChange:e=>O({...D,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?nn():e.key===`Escape`&&O(null)},onBlur:nn,onFocus:e=>e.target.select()}):J(`textarea`,{ref:On,value:D.value,onChange:e=>O({...D,value:e.target.value}),onKeyDown:e=>{if(e.key!==`Enter`){e.key===`Escape`&&O(null);return}(D.field===`label`&&(D.kind===`sketch`||D.kind===`blueprint`)||e.metaKey||e.ctrlKey||xe.enterCommits&&!e.shiftKey)&&(e.preventDefault(),nn())},onBlur:nn,onFocus:e=>e.target.select()})})]}),M?.kind===`frame`&&w?.kind===`connect`&&(()=>{let e=vt(w.point);return J(`div`,{className:`cv__droplabel`,style:{left:e.x,top:e.y},children:[`Attach to `,W.get(M.id)?.frame.title??M.id]})})(),!tr&&cr,er&&J(Za,{at:er,nodes:K.map(e=>H.get(e)).filter(e=>e!==void 0),frame:Rn?.frame,edge:$n,count:g.size,locked:Xt,styleOpen:f,onToggleStyle:()=>(Ee(null),p(e=>!e)),onLock:Yt,onComment:()=>{if(!nr)return;let e=U(nr);k(null),re({x:e.x+e.w,y:e.y,node:nr.id,offset:{x:e.w,y:0}})},onDetails:()=>{let[e]=[...g];e&&on(e)},onOpen:nr?.kind===`blueprint`&&nr.path?()=>rn(nr.path??``):void 0,onWrap:()=>Qt(K),onDuplicate:Vt,onDelete:Rt,children:tr?cr:null}),J(`div`,{className:`cv__overlay`,style:{position:`absolute`,inset:0,pointerEvents:`none`},children:Nn.map((e,t)=>{let n=We?.id===e.id?We.at:Kn(e),r=vt(n);return J(`div`,{style:{position:`absolute`,left:r.x,top:r.y,pointerEvents:`auto`},children:J(lo,{comment:{...e,at:{x:0,y:0}},index:t+1,open:ie===e.id,onOpen:()=>void 0,onPointerDown:()=>void 0})},e.id)})}),Fn&&(()=>{let e=Xn({x:vt(Kn(Fn)).x+18,y:vt(Kn(Fn)).y-8},360,320);return J(fo,{comment:Fn,at:e,author:t.author,users:Pn,onReply:e=>void B(`POST`,`/comments/${encodeURIComponent(Fn.id)}/replies`,{text:e}).then(z),onResolve:e=>void B(`PUT`,`/comments/${encodeURIComponent(Fn.id)}`,{resolved:e}).then(t=>(z(t),e&&k(null))),onEditMessage:(e,t)=>void B(`PUT`,`/comments/${encodeURIComponent(Fn.id)}/messages/${e}`,{text:t}).then(z),onDeleteMessage:e=>void B(`DELETE`,`/comments/${encodeURIComponent(Fn.id)}/messages/${e}`).then(e=>{z(e),e&&!e.comments.some(e=>e.id===Fn.id)&&k(null)}),onDelete:()=>void B(`DELETE`,`/comments/${encodeURIComponent(Fn.id)}`).then(e=>(z(e),k(null))),onClose:()=>k(null)})})(),ne&&(()=>{let e=Xn({x:vt(ne).x+18,y:vt(ne).y-8},300,120);return J(C,{children:[J(`div`,{className:`pin open`,style:{left:vt(ne).x,top:vt(ne).y,position:`absolute`},children:J(`span`,{children:`+`})}),J(uo,{at:e,author:t.author,users:Pn,anchored:ne.node!==null,onPost:e=>{let t=ne.node?{text:e,node:ne.node,x:Math.round(ne.offset.x),y:Math.round(ne.offset.y)}:{text:e,x:Math.round(ne.x),y:Math.round(ne.y)};B(`POST`,`/comments`,t).then(e=>{z(e),re(null),A(!0),e?.comment&&k(e.comment.id),Nt(`comment`,!1)})},onCancel:()=>(re(null),Nt(`comment`,!1))})]})})(),J(Oi,{canvasTitle:t.canvas.title,pages:t.canvas.pages,current:An.id,onPage:t=>Ct(Ot(e.id,t)),onRenamePage:(t,n)=>void Xe(()=>ht(`/api/canvas/${encodeURIComponent(e.id)}/pages/${encodeURIComponent(t)}`,{title:n})).then(t=>t&&(it(),e.onChanged())),onAddPage:async()=>{let n=`Page ${t.canvas.pages.length+1}`,r=await Xe(()=>mt(`/api/canvas/${encodeURIComponent(e.id)}/pages`,{title:n}));if(!r)return null;let i=r.pages[r.pages.length-1]?.id??null;return e.onChanged(),Ct(Ot(e.id,i??void 0)),i},onDeletePage:n=>{let r=t.canvas.pages.find(e=>e.id===n);Qe.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&&Xe(()=>gt(`/api/canvas/${encodeURIComponent(e.id)}/pages/${encodeURIComponent(n)}`)).then(t=>t&&(e.onChanged(),Ct(Ot(e.id,n===An.id?void 0:An.id))))})},onRenameCanvas:t=>void Xe(()=>ht(`/api/canvas/${encodeURIComponent(e.id)}`,{title:t})).then(t=>t&&(it(),e.onChanged())),onDeleteCanvas:()=>void Qe.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&&Xe(()=>gt(`/api/canvas/${encodeURIComponent(e.id)}`)).then(t=>t&&(e.onChanged(),Ct(`/`)))})}),J(ki,{canUndo:$e.canUndo,canRedo:$e.canRedo,onUndo:st,onRedo:ct,commentsOpen:t.comments.filter(e=>!e.resolved).length,showComments:ce,pinsHidden:!ae,onToggleComments:()=>le(e=>!e),children:J(`button`,{className:me?`on`:``,onClick:()=>he(e=>!e),"data-tip":`Export`,"data-tip-pos":`bottom`,children:[J(Ei,{tool:`export`}),`Export`]})}),me&&J(ji,{anchor:`right`,at:{x:14,y:52},onClose:()=>he(!1),items:[{label:`Image of this page (PNG)`,icon:J(Ei,{tool:`image`}),onSelect:()=>void sn(!1)},{label:`Image of the selection (PNG)`,icon:J(Ei,{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:()=>ko(`/api/canvas/${encodeURIComponent(e.id)}/export/${encodeURIComponent(An.id)}`,`${t.canvas.id}-${An.id}.canvas`)}]}),J(Di,{tool:s,locked:l,temporary:m?`hand`:null,onTool:jt,onLock:Mt}),J(`div`,{className:`cv__br`,children:[J(Ai,{scale:a.scale,onZoom:e=>Et(e),onFit:()=>void Tt(),onReset:()=>Dt(1)}),J(`button`,{className:`cv__help${ye?` on`:``}`,onClick:()=>be(e=>!e),"data-tip":`Canvas preferences`,"data-tip-pos":`top`,"aria-label":`Preferences`,children:J(pn,{})}),J(Fi,{onOpen:()=>ve(!0)})]}),In&&J(`div`,{className:`cv__corner`,children:J(Li,{entries:Object.entries(In),open:Ce,onToggle:()=>we(e=>!e)})}),ye&&J(Ii,{prefs:xe,onChange:at,onClose:()=>be(!1)}),L&&J(`div`,{className:`cv__hint`,children:Ne.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&&J(ji,{at:fe.at,items:fe.items,onClose:()=>pe(null)}),j&&J(Pi,{tools:Ti,onClose:()=>ve(!1)}),ce&&J(po,{comments:t.comments,users:Pn,hideResolved:oe,onToggleHide:()=>se(e=>!e),onOpen:e=>{let n=t.comments.find(t=>t.id===e);n&&sr&&(A(!0),k(e),o(e=>({...e,x:sr.width/2-n.at.x*e.scale,y:sr.height/2-n.at.y*e.scale})))},onClose:()=>le(!1),pinsHidden:!ae,onTogglePins:()=>A(e=>!e)}),Vn&&J(Ua,{at:zn(U(Vn)),node:Vn,data:t,onUpdate:e=>void B(`PUT`,`/nodes/${encodeURIComponent(Vn.id)}`,e).then(z),onPromote:e=>void B(`POST`,`/nodes/${encodeURIComponent(Vn.id)}/promote`,e).then(z),onOpen:rn,onBlueprintSaved:()=>(it(),e.onChanged()),onRemove:()=>(Ee(null),Rt()),onClose:()=>Ee(null)},Vn.id),Hn&&J(Ja,{at:zn(Hn.rect),frame:Hn.frame,members:lt.filter(e=>e.frame===Hn.frame.id).length,onUpdate:e=>void B(`PUT`,`/frames/${encodeURIComponent(Hn.frame.id)}`,e).then(z),onSelectMembers:()=>(Ee(null),q(lt.filter(e=>e.frame===Hn.frame.id).map(e=>$(e.id)))),onRemove:e=>(Ee(null),zt(Hn.frame.id,e)),onClose:()=>Ee(null)},Hn.frame.id),Un&&G(Un.from)&&G(Un.to)&&(()=>{let e=ma(G(Un.from),G(Un.to),{bend:Un.bend,from:Un.from_anchor,to:Un.to_anchor});return J(qa,{at:zn({x:e.label.x,y:e.label.y,w:0,h:0}),edge:Un,from:zi(Un.from)?W.get(Bi(Un.from))?.frame.title??Un.from:H.get(Un.from)?.label??Un.from,to:zi(Un.to)?W.get(Bi(Un.to))?.frame.title??Un.to:H.get(Un.to)?.label??Un.to,onUpdate:e=>void B(`PUT`,`/edges`,{from:Un.from,to:Un.to,...e}).then(z),onRemove:()=>(Ee(null),Rt()),onClose:()=>Ee(null)})})(),ue&&J(no,{onClose:()=>{de(null),Nt(`blueprint`,!1)},taken:new Set(lt.map(e=>e.blueprint??``)),onPick:e=>{let t=ue;de(null),Nt(`blueprint`,!1),$t({blueprint:e.id},t,null)}}),e.open&&J(wi,{path:e.open,tick:e.tick,layout:`modal`,onClose:()=>Ct(Ot(e.id,et)),onSaved:()=>(it(),e.onChanged()),onOpenLink:rn})]})}var jo=new Set([`title`]),Mo=``;function No(e){return e==null?``:Array.isArray(e)?e.map(e=>No(e)).join(`, `):typeof e==`string`?e.replace(/^\[([^\]]*)\]\([^)]*\)$/,`$1`):String(e)}function Po(e,t,n){if(n===`Number`)return(typeof e==`number`?e:NaN)-(typeof t==`number`?t:NaN)||0;let r=No(e),i=No(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 J(`span`,{className:`faint`,children:`—`});if(Array.isArray(t))return J(C,{children:t.map((e,t)=>J(`span`,{className:`chip`,children:No(e)},t))});if(typeof t==`boolean`)return J(`span`,{children:t?`✓`:`—`});let n=H(e.column.property?.canvas),r=typeof t==`string`?n[Object.keys(n).find(e=>e.toLowerCase()===t.toLowerCase())??``]:void 0;return J(`span`,{title:No(t),children:[r&&J(`i`,{className:`value-swatch`,style:{background:r}}),No(t)]})}function Io(e){let[t,n]=N(!1),r=F({}),i=I(()=>n(!1),[]);en(r.current,i);let a=()=>{t||$t(r.current),n(!t)},o=e.selected.size;return J(`div`,{className:`relative`,children:[J(`button`,{className:o>0?`on-filter`:``,onClick:a,children:[e.label,o>0?`: ${o===1?[...e.selected][0]:`${o} chosen`}`:``,` `,J(Tn,{open:t})]}),t&&J(`div`,{className:`popover popover--left`,onMouseLeave:()=>n(!1),children:[e.options.length===0&&J(`span`,{className:`faint`,style:{fontSize:12,padding:4},children:`No values yet.`}),e.options.map(t=>J(`label`,{title:t.hint,children:[J(`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&&J(`button`,{className:`small quiet`,style:{marginTop:4,width:`100%`},onClick:()=>e.onChange(new Set),children:`Clear`})]})]})}var Lo=e=>{let t=e.property?.tools.eidosmd;return typeof t==`object`&&!!t&&t.filter===!0};function Ro(e){let[t,n]=N(null),r=t!==null&&t.collection.missing_templates.includes(t.collection.variants.find(e=>e.default)?.name??t.collection.variants[0]?.name??``),[i,a]=N(null),[o,s]=N({key:`title`,dir:`asc`}),[c,l]=N(new Set),[u,d]=N({}),[f,p]=N(``),m=F(null),[h,g]=N(!1),_=F({}),v=I(()=>g(!1),[]);en(_.current,v);let[y,b]=N(new Set),[x,S]=N(0),[C,ee]=N(null),w=Lt(),T=Bt(),E=e.settings.local.tables.page_size;P(()=>{let t=!0;return pt(`/api/collections/${encodeURIComponent(e.name)}`).then(e=>{t&&(n(e),a(null))}).catch(e=>t&&a(e.message)),()=>{t=!1}},[e.name,e.tick]),P(()=>{l(new Set),d({}),p(``),S(0),b(new Set),ee(null)},[e.name]);let te=je(()=>{if(!t)return[];let e=[];for(let n of t.columns)jo.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)&&!jo.has(t)&&(n.add(t),e.push({key:t,label:t,type:`Text`,property:null}));return e},[t]),D=e.settings.local.tables.columns[e.name],O=je(()=>new Set(D??[`id`,...te.filter(e=>e.type===`List`).map(e=>e.key)]),[D,te]),ne=t=>{w(()=>ht(`/api/settings`,{local:t})).then(t=>t&&e.onSettingsSaved())},re=je(()=>te.filter(Lo),[te]),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(No(e));else t!=null&&t!==``&&n.add(No(t))}let r=e.property?.options??[],i=[...n].filter(e=>!r.includes(e)).sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`}));return[...r,...i]},k=je(()=>{if(!t)return[];let e=f.trim().toLowerCase(),n=t.rows.filter(t=>{if(c.size>0&&!c.has(t.group??Mo))return!1;for(let[e,n]of Object.entries(u)){if(n.size===0)continue;let r=t.properties[e];if(!(Array.isArray(r)?r.map(No):[No(r)]).some(e=>n.has(e)))return!1}return e===``||`${t.title}\n${t.summary??``}\n${t.id??``}\n${Object.values(t.properties).map(No).join(`
9
+ `)}`.toLowerCase().includes(e)}),r=te.find(e=>e.key===o.key),i=e=>o.key===`title`?e.title:o.key===`__group`?e.group:e.properties[o.key];return n.sort((e,t)=>Po(i(e),i(t),r?.type??`Text`)*(o.dir===`asc`?1:-1)),n},[t,te,c,u,f,o]),ae=Math.max(1,Math.ceil(k.length/E)),A=Math.min(x,ae-1);P(()=>{if(e.open)return;let t=t=>{let n=t.target;if(Ut(t)&&!t.altKey&&!t.shiftKey&&t.key.toLowerCase()===`f`){t.preventDefault(),m.current?.focus(),m.current?.select();return}n.closest(`input, textarea, select, [contenteditable]`)||t.metaKey||t.ctrlKey||t.altKey||(t.key.toLowerCase()===`n`&&!t.shiftKey?(t.preventDefault(),r||e.onNew(e.name)):t.key===`ArrowLeft`&&A>0?S(A-1):t.key===`ArrowRight`&&A<ae-1&&S(A+1))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open,e.name,e.onNew,A,ae]),Yt(`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 oe=k.slice(A*E,(A+1)*E),se=t?.collection.grouping??null,ce=se!==null,le=je(()=>{if(!ce)return[{group:Mo,rows:oe}];let e=se?.groups.map(e=>e.name)??[];return[...e,...[...new Set(oe.map(e=>e.group??Mo))].filter(t=>t!==Mo&&!e.includes(t)).sort(),Mo].map(e=>({group:e,rows:oe.filter(t=>(t.group??Mo)===e)})).filter(e=>e.rows.length>0)},[ce,se,oe]),ue=t=>{let n=new Set(O);n.has(t)?n.delete(t):n.add(t),ne({tables:{columns:{[e.name]:[...n]}}})},de=e=>s(t=>({key:e,dir:t.key===e&&t.dir===`asc`?`desc`:`asc`})),fe=te.filter(e=>!O.has(e.key)),{platform:pe}=Zr(),me=W(pe),he=t=>[{label:`Open`,onSelect:()=>Ct(Et(e.name,t.path))},{label:`Open as a page`,onSelect:()=>Ct(Dt(t.path))},{label:`Copy path`,onSelect:()=>void navigator.clipboard?.writeText(t.path).catch(()=>void 0)},{separator:!0,label:``},...e.settings.local.editor?[{label:`Open in editor`,onSelect:()=>void w(()=>mt(`/api/open`,{path:t.path}),`Opened in your editor`)}]:[],{label:`Show in ${me}`,onSelect:()=>void w(()=>mt(`/api/reveal`,{path:t.path}),`Shown in ${me}`)},{separator:!0,label:``},{label:`Delete…`,danger:!0,onSelect:()=>void T.confirm({title:`Delete ${t.title}?`,body:`${t.path} is removed from disk. Nothing else changes.`,confirm:`Delete blueprint`,danger:!0}).then(n=>{n&&w(()=>gt(`/api/blueprints/${ft(t.path)}`),`Deleted`).then(t=>t&&e.onChanged())})}],ge=(e,t,n)=>ee({row:e,x:t,y:n});if(i)return J(`div`,{className:`page empty`,children:i});if(!t)return J(Dn,{});let _e=k.length===0?0:A*E+1,j=Math.min(k.length,(A+1)*E);return J(`div`,{className:`page`,onClick:()=>C&&ee(null),children:[J(`div`,{className:`page__head`,children:[J(`div`,{className:`grow`,children:[J(`h1`,{children:t.collection.name}),t.collection.description&&J(`p`,{children:t.collection.description})]}),J(`button`,{className:`primary`,onClick:()=>e.onNew(t.collection.name),disabled:r,"data-tip":r?`No template to scaffold from yet`:`New blueprint N`,"data-tip-pos":`left`,children:[`+ New `,t.collection.unit??`blueprint`]})]}),t.collection.missing_templates.length>0&&J(`div`,{className:`notice${r?` notice--error`:``}`,children:[r?`Nothing to scaffold a new blueprint from: `:`A variant has no template yet: `,t.collection.missing_templates.map(e=>J(`code`,{children:e},e)),r?` has no template file. `:` points at a file that does not exist. `,J(`a`,{href:`/settings/templates`,children:`Write it under Framework Settings → Templates`}),`.`]}),J(`div`,{className:`toolbar`,style:{marginBottom:12},children:[J(`input`,{ref:m,value:f,onChange:e=>(p(e.target.value),S(0)),onKeyDown:e=>e.key===`Escape`&&e.currentTarget.blur(),placeholder:`Find ${t.collection.unit??t.collection.name}`,style:{width:220}}),J(`div`,{className:`relative`,children:[J(`button`,{className:`icon`,onClick:()=>{h||$t(_.current),g(!h)},"data-tip":`Columns`,"data-tip-pos":`bottom`,"aria-label":`Columns`,children:J(pn,{})}),h&&J(`div`,{className:`popover popover--left`,onMouseLeave:()=>g(!1),children:[te.map(e=>J(`label`,{children:[J(`input`,{type:`checkbox`,checked:!O.has(e.key),onChange:()=>ue(e.key)}),e.label,J(`span`,{className:`faint`,style:{marginLeft:`auto`,fontSize:11},children:e.type})]},e.key)),J(`span`,{className:`faint`,style:{fontSize:11,padding:`4px 6px 0`},children:`Filters: flag a property under Framework Settings → Properties.`})]})]}),se&&se.groups.length>0&&J(Io,{label:se.label,options:[...se.groups.map(e=>({value:e.name,label:e.name,hint:e.description})),{value:Mo,label:`(ungrouped)`}],selected:c,onChange:e=>(l(e),S(0))}),re.map(e=>J(Io,{label:e.label,options:ie(e).map(e=>({value:e,label:e})),selected:u[e.key]??new Set,onChange:t=>(d(n=>({...n,[e.key]:t})),S(0))},e.key)),J(`div`,{className:`grow`}),J(`span`,{className:`pager`,children:[J(X,{value:String(E),onChange:e=>{ne({tables:{page_size:Number(e.target.value)}}),S(0)},"data-tip":`Rows per page`,"data-tip-pos":`bottom`,children:[25,50,100,250].map(e=>J(`option`,{value:String(e),children:[e,` / page`]},e))}),J(`button`,{className:`icon`,disabled:A===0,onClick:()=>S(A-1),"aria-label":`Previous page`,"data-tip":`Previous page ←`,"data-tip-pos":`bottom`,children:`‹`}),J(`span`,{className:`pager__count`,children:[k.length===0?`No rows`:`${_e}–${j} of ${k.length}`,k.length===t.rows.length?``:` (${t.rows.length} in all)`]}),J(`button`,{className:`icon`,disabled:A>=ae-1,onClick:()=>S(A+1),"aria-label":`Next page`,"data-tip":`Next page →`,"data-tip-pos":`bottom`,children:`›`})]})]}),t.rows.length===0?J(`div`,{className:`empty`,children:`Nothing here yet. Start with “+ New”.`}):J(`div`,{className:`table-wrap`,children:J(`table`,{className:`grid`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{onClick:()=>de(`title`),children:[`title`,o.key===`title`&&J(`span`,{className:`dir`,children:o.dir===`asc`?`▲`:`▼`})]}),fe.map(e=>J(`th`,{onClick:()=>de(e.key),title:e.property?.meaning,children:[e.label,o.key===e.key&&J(`span`,{className:`dir`,children:o.dir===`asc`?`▲`:`▼`})]},e.key)),J(`th`,{})]})}),J(`tbody`,{children:le.map(t=>J(zo,{nested:ce,group:t.group,label:t.group===Mo?ce?`ungrouped`:``:t.group,rows:t.rows,collapsed:y.has(t.group),onToggle:()=>b(e=>{let n=new Set(e);return n.has(t.group)?n.delete(t.group):n.add(t.group),n}),visible:fe,open:e.open,collection:e.name,span:fe.length+2,onMenu:ge},t.group))})]})}),C&&J(`div`,{style:{position:`fixed`,left:C.x,top:C.y,zIndex:30},onClick:e=>e.stopPropagation(),children:J(ji,{at:{x:0,y:0},items:he(C.row),onClose:()=>ee(null)})}),e.open&&J(wi,{path:e.open,tick:e.tick,layout:`modal`,onClose:()=>Ct(Et(e.name)),onSaved:e.onChanged})]})}function zo(e){return J(C,{children:[e.nested&&J(`tr`,{className:`group-row`,onClick:e.onToggle,children:J(`td`,{colSpan:e.span,children:[J(Tn,{open:!e.collapsed}),J(`span`,{className:`mono`,children:[e.label,`/`]}),J(`span`,{className:`faint`,children:e.rows.length})]})}),!e.collapsed&&e.rows.map(t=>J(`tr`,{className:`${e.open===t.path?`selected`:``}${e.nested?` nested`:``}`,onClick:()=>Ct(Et(e.collection,t.path)),onContextMenu:n=>{n.preventDefault(),e.onMenu(t,n.clientX,n.clientY)},children:[J(`td`,{className:`title`,children:[t.title,J(`span`,{className:`id`,children:t.id??t.path})]}),e.visible.map(e=>J(`td`,{className:e.key===`summary`?`summary`:``,children:J(Fo,{column:e,row:t})},e.key)),J(`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?J(`span`,{className:`dot error`}):t.findings.warnings>0?J(`span`,{className:`dot`}):null,J(`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:J(gn,{})})]})]},t.path))]})}var Bo=e=>e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),Vo=(e,t)=>`templates/${Bo(e)}.${Bo(t)}.md`;function Ho(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=Bo(e.name);return t.endsWith(`ies`)?`${t.slice(0,-3)}y`:t.endsWith(`s`)?t.slice(0,-1):t}function Uo(e){return J(Y,{title:e.title,size:`sm`,center:!0,onClose:e.onClose,foot:J(C,{children:[e.extra,J(`span`,{style:{flex:1}}),J(`button`,{className:`small quiet`,onClick:e.onClose,children:`Cancel`}),J(`button`,{className:`small primary`,disabled:!e.canSave,onClick:e.onSave,children:e.saveLabel??`Save`})]}),children:J(`form`,{className:`stack`,onSubmit:t=>{t.preventDefault(),e.canSave&&e.onSave()},children:e.children})})}function Wo(e){let[t,n]=N(e.collection?.name??``),[r,i]=N(e.collection?Ho(e.collection):``),[a,o]=N(e.collection?.description??``),[s,c]=N(e.collection!==null);P(()=>{s||i(Ho({name:t,type:`collection`,variants:[]}))},[t,s]);let l=e.taken.some(n=>n.toLowerCase()===t.trim().toLowerCase()&&n!==e.collection?.name);return J(Uo,{title:e.collection?`Edit ${e.collection.name}`:`Add a collection`,onClose:e.onClose,canSave:t.trim()!==``&&Bo(r)!==``&&!l,onSave:()=>e.onSave({name:t.trim(),unit:Bo(r),description:a.trim()}),children:[J(`label`,{children:[J(`span`,{children:`Name`}),J(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`Specs`,autoFocus:!0}),J(`span`,{className:`field__hint`,children:l?`A collection already has this name.`:`The folder at the root, in the naming convention; renaming moves the folder.`})]}),J(`label`,{children:[J(`span`,{children:`Unit`}),J(`input`,{value:r,onChange:e=>(c(!0),i(e.target.value)),placeholder:`spec`}),J(`span`,{className:`field__hint`,children:[`The word for one of its blueprints; its template files are named `,J(`code`,{children:[`templates/`,Bo(r)||`<unit>`,`.<variant>.md`]}),`. Changing it renames them.`]})]}),J(`label`,{children:[J(`span`,{children:`Description`}),J(`textarea`,{rows:3,value:a,onChange:e=>o(e.target.value),placeholder:`One line on what this collection holds.`})]})]})}function Go(e){let[t,n]=N([]);return P(()=>{pt(`/api/blueprints`).then(n).catch(()=>n([]))},[]),[...(e.top_level??[]).map(e=>({value:e.path,label:`${e.title} (${e.path.replace(/^\.\.\//,``)})`})),...t.map(e=>({value:`../${e.path}`,label:`${e.title} (${e.path})`}))]}function Ko(e){let[t,n]=N(e.name),[r,i]=N(e.description),a=e.taken.some(n=>n.toLowerCase()===t.trim().toLowerCase()&&n!==e.name);return J(Uo,{title:e.title,onClose:e.onClose,canSave:t.trim()!==``&&!a,onSave:()=>e.onSave({name:t.trim(),description:r.trim()}),children:[J(`label`,{children:[J(`span`,{children:e.nameLabel}),J(`input`,{value:t,onChange:e=>n(e.target.value),autoFocus:!0}),J(`span`,{className:`field__hint`,children:a?`That name is already taken.`:e.nameHint})]}),J(`label`,{children:[J(`span`,{children:`Description`}),J(`textarea`,{rows:3,value:r,onChange:e=>i(e.target.value),placeholder:`One line on what this is for.`})]})]})}var qo=[`Text`,`List`,`Number`,`Checkbox`,`Date`,`Date & time`];function Jo(e){let[t,n]=N(``),r=()=>{let r=t.trim();n(``),!(r===``||e.options.includes(r))&&e.onChange([...e.options,r])},i=(t,n)=>{let r=[...e.options],[i]=r.splice(t,1);i!==void 0&&(r.splice(t+n,0,i),e.onChange(r))};return J(`div`,{className:`options`,children:[e.options.length>0&&J(`div`,{className:`rows rows--plain options__rows`,children:e.options.map((t,n)=>J(`div`,{className:`row`,children:J(`div`,{className:`row__main`,children:[J(`span`,{className:`options__order`,children:n+1}),J(`span`,{className:`options__value`,children:t}),J(`button`,{type:`button`,className:`quiet icon`,disabled:n===0,onClick:()=>i(n,-1),"aria-label":`Move ${t} earlier`,title:`Earlier`,children:J(hn,{direction:`up`})}),J(`button`,{type:`button`,className:`quiet icon`,disabled:n===e.options.length-1,onClick:()=>i(n,1),"aria-label":`Move ${t} later`,title:`Later`,children:J(hn,{direction:`down`})}),J(`button`,{type:`button`,className:`quiet icon danger`,onClick:()=>e.onChange(e.options.filter((e,t)=>t!==n)),"aria-label":`Remove ${t}`,title:`Remove`,children:J(Z,{})})]})},t))}),J(`div`,{className:`options__add`,children:[J(`input`,{value:t,placeholder:e.options.length===0?`Type a value and press Enter`:`Add another value…`,onChange:e=>n(e.target.value),onKeyDown:e=>{(e.key===`Enter`||e.key===`,`)&&(e.preventDefault(),r())}}),J(`button`,{type:`button`,className:`small`,disabled:t.trim()===``||e.options.includes(t.trim()),onClick:r,children:`Add`})]})]})}function Yo(e){let[t,n]=N(e.property?.name??``),[r,i]=N(e.property?.type??`Text`),a=e.property?.applies_to,[o,s]=N(a===void 0||a===`all`),[c,l]=N(Array.isArray(a)?a:[]),[u,d]=N(e.property?.required===!0),[f,p]=N(e.property?.options??[]),[m,h]=N(e.property?.meaning??``),g=e.taken.some(n=>n===t.trim()&&n!==e.property?.name),_=/^[A-Za-z_][A-Za-z0-9_-]*$/.test(t.trim()),v=r===`Text`||r===`List`,y=v?f:[],b=(e,t)=>l(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e));return J(Uo,{title:e.property?`Edit ${e.property.name}`:`Add a property`,onClose:e.onClose,canSave:t.trim()!==``&&_&&!g&&(o||c.length>0),onSave:()=>e.onSave({name:t.trim(),type:r,applies_to:o?`all`:e.collections.filter(e=>c.includes(e)),required:u,options:y.length>0?y:null,meaning:m.trim()}),children:[J(`label`,{children:[J(`span`,{children:`Name`}),J(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`owner`,autoFocus:!0}),J(`span`,{className:`field__hint`,children:g?`A property already has this name.`:!_&&t.trim()!==``?`A frontmatter key: letters, digits, _ and -, no spaces.`:`The frontmatter key every blueprint it applies to carries.`})]}),J(`label`,{children:[J(`span`,{children:`Type`}),J(X,{value:r,onChange:e=>i(e.target.value),style:{alignSelf:`start`},children:qo.map(e=>J(`option`,{value:e,children:e},e))})]}),J(`div`,{children:[J(`span`,{className:`field__label`,children:`Applies to`}),J(`div`,{className:`checks`,children:[J(`label`,{className:`check`,children:[J(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),J(`span`,{children:`All collections`})]}),!o&&e.collections.map(e=>J(`label`,{className:`check`,children:[J(`input`,{type:`checkbox`,checked:c.includes(e),onChange:t=>b(e,t.target.checked)}),J(`span`,{children:e})]},e))]}),!o&&c.length===0&&J(`span`,{className:`field__hint`,children:`Pick at least one collection.`})]}),J(`div`,{children:[J(`span`,{className:`field__label`,children:`Required`}),J(`div`,{className:`checks`,children:J(`label`,{className:`check`,children:[J(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),J(`span`,{children:`Every blueprint it applies to carries it`})]})}),J(`span`,{className:`field__hint`,children:u?`Generated into every new blueprint, and the check notes one that lacks it. Existing blueprints need backfilling.`:`Optional: written when it has a value, left out otherwise, and never a gap the check notes.`})]}),v&&J(`label`,{children:[J(`span`,{children:`Options`}),J(Jo,{options:f,onChange:p}),J(`span`,{className:`field__hint`,children:y.length>0?`A closed set, ${y.length} value${y.length===1?``:`s`} in this order: the editor offers a dropdown, and the check notes a value off the list (exact, case included), never refuses it. Narrowing the list retires values.`:`None: any value is valid. Add one at a time (Enter adds) when ${r===`List`?`an item`:`the value`} is one of a set you control, a lifecycle or a tier, in the order the values run.`})]}),J(`label`,{children:[J(`span`,{children:`Meaning`}),J(`textarea`,{rows:3,value:m,onChange:e=>h(e.target.value),placeholder:y.length>0?`What the property is for; the options carry the values.`:`What the value says.`})]})]})}function Xo(e){let[t,n]=N(e.term.term),[r,i]=N(e.term.means),[a,o]=N(e.term.not.join(`
10
+ `)),[s,c]=N(e.term.see??``),l=e.taken.some(n=>n.toLowerCase()===t.trim().toLowerCase()&&n!==e.term.term),u=s===``||e.see.some(e=>e.value===s);return J(Uo,{title:e.term.term?`Edit “${e.term.term}”`:`Add a term`,onClose:e.onClose,canSave:t.trim()!==``&&!l,onSave:()=>{let n={term:t.trim(),means:r.trim(),not:a.split(/\r?\n|;/).map(e=>e.trim()).filter(e=>e!==``)};s.trim()!==``&&(n.see=s.trim()),e.onSave(n)},children:[J(`label`,{children:[J(`span`,{children:`Term`}),J(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`team member`,autoFocus:!0}),J(`span`,{className:`field__hint`,children:l?`That term is already declared.`:`The word, as the product uses it. Health Check warns where a blueprint says a near-miss instead.`})]}),J(`label`,{children:[J(`span`,{children:`Means`}),J(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`One line`})]}),J(`label`,{children:[J(`span`,{children:`Not`}),J(`textarea`,{rows:3,value:a,onChange:e=>o(e.target.value),placeholder:`The near-misses, one per line, each with why it is a different thing.`})]}),J(`label`,{children:[J(`span`,{children:`See`}),J(X,{value:u?s:`__other`,onChange:e=>c(e.target.value===`__other`?s:e.target.value),style:{alignSelf:`start`,maxWidth:`100%`},children:[J(`option`,{value:``,children:`None`}),e.see.map(e=>J(`option`,{value:e.value,children:e.label},e.value)),!u&&J(`option`,{value:`__other`,children:s})]}),J(`span`,{className:`field__hint`,children:`The blueprint or top-level doc that defines the term in full.`})]})]})}var Zo=[{tab:`general`,label:`Root`,blurb:`The root itself: its naming and its top-level documents.`},{tab:`collections`,label:`Folders`,blurb:`Every folder at the root: each collection, its variants, and how it groups its blueprints; an assets or other folder, described.`},{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.`}],Qo=[{tab:`check`,label:`Health Check`,blurb:`What the check finds in the root: errors, warnings, and the fixes it offers.`,href:`/check`},{tab:`versions`,label:`Versions`,blurb:`The root's own versions: snapshots recorded on purpose, each a commit and a tag.`,href:`/versions`},{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`}],$o=`https://eidosmd.com/docs/cli/browser#framework-settings`,es=[`kebab-case`,`TitleCase`,`Title Case`],ts=e=>JSON.parse(JSON.stringify(e));function ns(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}function rs(e){return J(`div`,{className:`page__head page__head--sticky`,children:[J(`div`,{className:`page__head__row`,children:[J(`div`,{className:`grow`,children:[J(`h1`,{children:e.title}),J(`p`,{children:e.blurb})]}),e.actions&&J(`div`,{className:`toolbar`,children:e.actions})]}),J(`nav`,{className:`tabs`,children:Qo.map(t=>J(`a`,{href:t.href,className:e.current===t.href?`on`:``,"data-tip":t.blurb,"data-tip-pos":`bottom`,children:t.label},t.tab))})]})}var is=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`System`}];function as(e){let[t,n]=N(null),[r,i]=N(null),[a,o]=N(!1),s=Lt(),c=Bt(),l=()=>({folders:{},templates:{},docs:{}}),u=F(l()),d=F({docs:[]}),f=(e,t,n)=>{if(t===n)return;let r=u.current[e],i=Object.keys(r).find(e=>r[e]===t)??t;i===n?delete r[i]:r[i]=n},p=e=>{let t=u.current.docs,n=Object.keys(t).find(n=>t[n]===e)??e;delete t[n],d.current.docs.includes(n)||d.current.docs.push(n)},m=()=>{pt(`/api/framework`).then(e=>{n(e),i(ts(e.document)),o(!1),u.current=l(),d.current={docs:[]}}).catch(()=>void 0)};P(m,[]);let h=di(`.eidos`,a,m),g=e=>{if(!r)return;let t=ts(r);e(t),i(t),o(!0)},_=async()=>{if(!r)return;let t=await s(()=>ht(`/api/framework`,{document:r,renames:u.current,deletes:d.current}),`Framework saved`);t&&(n(t),i(ts(t.document)),o(!1),u.current=l(),d.current={docs:[]},e.onSaved())},v={draft:r,dirty:a,save:_,discard:()=>{t&&i(ts(t.document)),o(!1),u.current=l(),d.current={docs:[]}}},y=N({current:v})[0];y.current=v,P(()=>{if(!a){xt(null);return}return xt(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 y.current.save(),!0):n===`discard`&&(y.current.discard(),!0)}),()=>xt(null)},[a,c,t,y]);let b=Zo.find(t=>t.tab===e.tab)??Zo[0],x=e.tab!==`templates`&&e.tab!==`roles`&&e.tab!==`me`;return J(`div`,{className:`page page--narrow`,children:[J(`div`,{className:`page__head page__head--sticky`,children:[J(`div`,{className:`page__head__row`,children:[J(`div`,{className:`grow`,children:[J(`h1`,{children:`Framework Settings`}),J(`p`,{children:b.blurb})]}),J(`div`,{className:`toolbar`,children:x&&J(C,{children:[h.stale&&J(fi,{what:`The framework`,onRefresh:()=>{h.dismiss(),m()},onKeep:h.dismiss}),a&&J(`span`,{className:`dirty`,children:`Unsaved changes`}),t&&t.problems.length>0&&J(`span`,{className:`badge warn`,title:t.problems.join(`
11
+ `),children:[t.problems.length,` problem(s)`]}),J(`button`,{onClick:m,disabled:!a,children:`Discard`}),J(`button`,{className:`primary`,onClick:()=>void _(),disabled:!a,children:`Save to Framework`})]})})]}),J(`nav`,{className:`tabs`,children:Zo.map(t=>J(`a`,{href:`/settings/${t.tab}`,className:e.tab===t.tab?`on`:``,children:t.label},t.tab))})]}),!r||!t?J(`div`,{className:`empty`,children:`Loading…`}):e.tab===`general`?J(ls,{draft:r,edit:g,file:t.file,rename:f,removeDoc:p,dialog:c}):e.tab===`collections`?J(us,{draft:r,edit:g,templates:t.templates,rename:f}):e.tab===`properties`?J(ds,{draft:r,edit:g}):e.tab===`vocabulary`?J(Ds,{draft:r,edit:g}):e.tab===`templates`?J(Os,{templates:t.templates,onSaved:()=>(m(),e.onSaved())}):e.tab===`roles`?J(Ms,{onSaved:e.onSaved}):J(Ps,{})]})}function os(e){let[t,n]=N([]),[r,i]=N(0),a=Bt(),o=Lt(),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(()=>mt(`/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(()=>{pt(`/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 J(X,{value:e.value,onChange:t=>{let n=t.target.value;if(n===`__create__`){s();return}e.onChange(n)},children:[!l&&J(`option`,{value:e.value,children:e.value||`— choose a file —`}),c.map(e=>J(`option`,{value:e.value,children:e.label},e.value)),e.create&&J(`option`,{value:`__create__`,children:`+ New file at the root…`})]})}function ss(e,t){let n=e.trim();return t===`TitleCase`?`${n.split(/\s+/).join(``)}.md`:t===`Title Case`?`${n}.md`:`${Bo(n)}.md`}var cs=e=>/^\.\.\/([^/]+\.md)$/i.exec(e)?.[1]??null;function ls(e){let{draft:t,edit:n}=e,r=t.naming??`kebab-case`,i=(i,a)=>{let o=t.top_level?.[i];if(!o)return;let s=cs(o.path),c=s!==null,l=c&&a.trim()!==``?ss(a,r):s;c&&l&&l!==s&&e.rename(`docs`,s,l),n(e=>{let t=e.top_level[i];t.title=a,c&&l&&l!==s&&(t.path=`../${l}`)})},a=async r=>{let i=t.top_level?.[r];if(!i)return;let a=cs(i.path);if(a){if(!await e.dialog.confirm({title:`Remove ${i.title||a}?`,body:`${a} is deleted from the root when you save; git keeps what was in it.`,confirm:`Remove and delete`,danger:!0}))return;e.removeDoc(a)}n(e=>e.top_level.splice(r,1))};return J(C,{children:[J(`h3`,{className:`settings__h`,children:`Root`}),J(`div`,{className:`field`,children:[J(`span`,{children:`Framework file`}),J(`code`,{children:e.file}),J(`span`,{children:`Eidos version`}),J(`code`,{children:t.eidos_version??`—`}),J(`span`,{children:`Naming`}),J(X,{value:t.naming??`kebab-case`,onChange:e=>n(t=>t.naming=e.target.value),children:es.map(e=>J(`option`,{children:e},e))})]}),J(`p`,{className:`faint`,style:{fontSize:12},children:`Naming is settled once; changing it renames nothing on disk.`}),J(`h3`,{className:`settings__h`,children:`Top-level documents`}),J(`table`,{className:`mini`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Title`}),J(`th`,{children:`File (at the root)`}),J(`th`,{children:`Description`}),J(`th`,{})]})}),J(`tbody`,{children:(t.top_level??[]).map((e,t)=>J(`tr`,{children:[J(`td`,{children:J(`input`,{value:e.title,onChange:e=>i(t,e.target.value)})}),J(`td`,{children:cs(e.path)?J(`code`,{title:`Named for the title; renamed on save when the title changes`,children:cs(e.path)}):J(os,{dir:``,ext:`md`,value:e.path,toValue:e=>`../${e.path}`,onChange:e=>n(n=>n.top_level[t].path=e),create:!0})}),J(`td`,{children:J(`input`,{value:e.description??``,placeholder:`What ${e.title||`this document`} is, in a line`,onChange:e=>n(n=>n.top_level[t].description=e.target.value)})}),J(`td`,{className:`x`,children:J(`button`,{className:`quiet icon danger`,onClick:()=>void a(t),"data-tip":`Remove, and delete the file on save`,"data-tip-pos":`left`,"aria-label":`Remove`,children:J(Z,{})})})]},t))})]}),J(`p`,{className:`faint`,style:{fontSize:12},children:`Listed in the order they are read: the browser lands on the first. A document's file is named for its title, so retitling one renames the file on save, and every link to it follows.`}),J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>n(e=>e.top_level=[...e.top_level??[],{title:`New doc`,path:``,description:``}]),children:`+ Add document`})})]})}function us(e){let{draft:t,edit:n}=e,r=(e,t)=>e.folders[t],i=t.folders.map((e,t)=>({folder:e,fi:t})),a=i.filter(e=>U(e.folder)),o=i.filter(e=>!U(e.folder)),[s,c]=N(null),[l,u]=N(null),[d,f]=N(null),[p,m]=N(null),h=(t,n,i,a)=>{let o=r(t,n),s=o.variants[i];s.name=a;let c=Vo(ns(o),a);c!==s.template&&e.rename(`templates`,s.template,c),s.template=c};return J(C,{children:[J(`p`,{className:`faint`,style:{fontSize:12},children:[`A template file follows the convention, `,J(`code`,{children:`templates/<unit>.<variant>.md`}),`, the unit being the word for one of the collection's blueprints; write it under Templates.`]}),a.map(({folder:t,fi:i})=>J(`div`,{className:`card`,children:[J(`div`,{className:`card__head`,children:[J(`strong`,{children:t.name||`untitled`}),J(`span`,{className:`badge`,title:`The unit: the word for one of its blueprints`,children:ns(t)}),J(`button`,{className:`quiet icon`,onClick:()=>c(i),"data-tip":`Edit the name, unit, and description`,"data-tip-pos":`left`,"aria-label":`Edit collection`,children:J(ln,{})}),J(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>e.folders.splice(i,1)),"data-tip":`Remove the collection from the framework (its folder stays)`,"data-tip-pos":`left`,"aria-label":`Remove collection`,children:J(Z,{})})]}),J(`input`,{className:`card__desc`,value:t.description??``,placeholder:`One line on what this collection holds.`,onChange:e=>n(t=>r(t,i).description=e.target.value)}),J(`h3`,{className:`settings__h`,children:`Variants`}),J(`div`,{className:`rows`,children:t.variants.map((a,o)=>{let s=e.templates.find(e=>e.collection===t.name&&e.variant===a.name);return J(`div`,{className:`row`,children:[J(`div`,{className:`row__main`,children:[J(`input`,{className:`row__name`,value:a.name,placeholder:`name`,onChange:e=>n(t=>h(t,i,o,e.target.value))}),J(`input`,{className:`row__desc`,value:a.description??``,placeholder:`one line on what this variant is for`,onChange:e=>n(t=>r(t,i).variants[o].description=e.target.value)}),J(`label`,{className:`row__check`,"data-tip":`What a new blueprint follows when no variant is named`,"data-tip-pos":`left`,children:[J(`input`,{type:`radio`,name:`default-${i}`,checked:a.default===!0,onChange:()=>n(e=>r(e,i).variants.forEach((e,t)=>t===o?e.default=!0:delete e.default))}),`Default`]}),J(`button`,{className:`quiet icon`,onClick:()=>u({ci:i,fi:o}),"data-tip":`Edit the name and description`,"data-tip-pos":`left`,"aria-label":`Edit variant`,children:J(ln,{})}),J(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>r(e,i).variants.splice(o,1)),"data-tip":`Remove variant`,"data-tip-pos":`left`,"aria-label":`Remove variant`,children:J(Z,{})})]}),J(`div`,{className:`row__sub`,children:[J(`span`,{className:`faint`,children:`Template file`}),J(`code`,{className:`faint`,children:a.template}),s&&!s.exists&&J(`span`,{className:`badge warn`,title:`No file at this path yet; create it under Templates`,children:`missing`})]})]},o)})}),J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>n(e=>{let t=r(e,i),n=t.variants.some(e=>e.name==="default")?`new`:`default`;t.variants.push({name:n,template:Vo(ns(t),n),description:``,...t.variants.length===0?{default:!0}:{}})}),children:`+ Add variant`})}),J(`h3`,{className:`settings__h`,children:`Grouping`}),t.grouping?J(C,{children:[J(`div`,{className:`field`,children:[J(`span`,{children:`Label`}),J(`input`,{value:t.grouping.label,onChange:e=>n(t=>r(t,i).grouping.label=e.target.value)}),J(`span`,{children:`Property`}),J(`input`,{placeholder:`the custom property carrying the group, e.g. domain`,value:t.grouping.property??``,onChange:e=>n(t=>r(t,i).grouping.property=e.target.value||null)})]}),J(`div`,{className:`rows`,style:{marginTop:8},children:(t.grouping.groups??[]).map((e,t)=>J(`div`,{className:`row`,children:J(`div`,{className:`row__main`,children:[J(`input`,{className:`row__name`,value:e.name,placeholder:`group`,onChange:e=>n(n=>r(n,i).grouping.groups[t].name=e.target.value)}),J(`input`,{className:`row__desc`,value:e.description??``,placeholder:`one line on what belongs in this group`,onChange:e=>n(n=>r(n,i).grouping.groups[t].description=e.target.value)}),J(`button`,{className:`quiet icon`,onClick:()=>f({ci:i,gi:t}),"data-tip":`Edit the group and its description`,"data-tip-pos":`left`,"aria-label":`Edit group`,children:J(ln,{})}),J(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>r(e,i).grouping.groups.splice(t,1)),"data-tip":`Remove group`,"data-tip-pos":`left`,"aria-label":`Remove group`,children:J(Z,{})})]})},t))}),J(`div`,{className:`rowbtn`,children:[J(`button`,{className:`small`,onClick:()=>n(e=>r(e,i).grouping.groups=[...r(e,i).grouping.groups??[],{name:`new-group`,description:``}]),children:`+ Add group`}),J(`button`,{className:`small quiet`,onClick:()=>n(e=>delete r(e,i).grouping),children:`Remove grouping`})]})]}):J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>n(e=>r(e,i).grouping={label:`Groups`,property:null,groups:[]}),children:`+ Group this collection`})})]},i)),J(`div`,{className:`rowbtn`,children:J(`button`,{onClick:()=>c(-1),children:`+ Add collection`})}),J(`h3`,{className:`settings__h`,children:`Other folders`}),J(`p`,{className:`faint`,style:{fontSize:12},children:[`Every folder at the root is declared with a type. An `,J(`b`,{children:`assets`}),` folder holds files that are not markdown (the images, diagrams, and documents the blueprints link to); an `,J(`b`,{children:`other`}),` folder is whatever its description says. Nothing inside either is read. Renaming one moves the folder on save.`]}),J(`div`,{className:`rows`,children:o.map(({folder:e,fi:t})=>J(`div`,{className:`row`,children:J(`div`,{className:`row__main`,children:[J(`strong`,{className:`row__name`,children:e.name||`untitled`}),J(X,{value:e.type,onChange:e=>n(n=>n.folders[t].type=e.target.value===`other`?`other`:`assets`),children:[J(`option`,{value:`assets`,children:`assets`}),J(`option`,{value:`other`,children:`other`})]}),J(`input`,{className:`row__desc`,value:e.description??``,placeholder:`one line on what the folder holds`,onChange:e=>n(n=>n.folders[t].description=e.target.value)}),J(`button`,{className:`quiet icon`,onClick:()=>m(t),"data-tip":`Edit the name and description`,"data-tip-pos":`left`,"aria-label":`Edit folder`,children:J(ln,{})}),J(`button`,{className:`quiet icon danger`,onClick:()=>n(e=>e.folders.splice(t,1)),"data-tip":`Remove the folder from the framework (the folder stays)`,"data-tip-pos":`left`,"aria-label":`Remove folder`,children:J(Z,{})})]})},t))}),J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>n(e=>e.folders.push({name:e.folders.some(e=>e.name===`assets`)?`new-folder`:`assets`,type:`assets`,description:``})),children:`+ Add folder`})}),l&&r(t,l.ci)?.variants[l.fi]&&J(Ko,{title:`Edit the ${r(t,l.ci).variants[l.fi].name} variant`,nameLabel:`Variant`,nameHint:J(C,{children:[`Its template file is named for it: `,J(`code`,{children:[`templates/`,ns(r(t,l.ci)),`.<variant>.md`]}),`.`]}),name:r(t,l.ci).variants[l.fi].name,description:r(t,l.ci).variants[l.fi].description??``,taken:r(t,l.ci).variants.map(e=>e.name),onClose:()=>u(null),onSave:e=>{n(t=>{h(t,l.ci,l.fi,e.name),r(t,l.ci).variants[l.fi].description=e.description}),u(null)}}),d&&r(t,d.ci)?.grouping?.groups?.[d.gi]&&J(Ko,{title:`Edit the ${r(t,d.ci).grouping.groups[d.gi].name} group`,nameLabel:`Group`,nameHint:`The sub-folder under the collection, in the naming convention; renaming moves nothing on disk.`,name:r(t,d.ci).grouping.groups[d.gi].name,description:r(t,d.ci).grouping.groups[d.gi].description??``,taken:(r(t,d.ci).grouping.groups??[]).map(e=>e.name),onClose:()=>f(null),onSave:e=>{n(t=>{let n=r(t,d.ci).grouping.groups[d.gi];n.name=e.name,n.description=e.description}),f(null)}}),p!==null&&t.folders[p]&&!U(t.folders[p])&&J(Ko,{title:`Edit the ${t.folders[p].name} folder`,nameLabel:`Folder`,nameHint:`The folder at the root, in the naming convention; renaming moves the folder on save.`,name:t.folders[p].name,description:t.folders[p].description??``,taken:t.folders.map(e=>e.name),onClose:()=>m(null),onSave:t=>{n(n=>{let r=n.folders[p];r.name!==t.name&&e.rename(`folders`,r.name,t.name),r.name=t.name,r.description=t.description}),m(null)}}),s!==null&&J(Wo,{collection:s===-1?null:r(t,s)??null,taken:t.folders.map(e=>e.name),onClose:()=>c(null),onSave:t=>{n(n=>{if(s===-1){n.folders.push({name:t.name,type:`collection`,description:t.description,variants:[{name:`default`,template:Vo(t.unit,`default`),description:``,default:!0}]});return}let i=r(n,s),a=i.name;if(a!==t.name){e.rename(`folders`,a,t.name);for(let e of n.properties?.custom??[])Array.isArray(e.applies_to)&&(e.applies_to=e.applies_to.map(e=>e===a?t.name:e))}i.name=t.name,i.description=t.description;for(let n of i.variants){let r=Vo(t.unit,n.name);r!==n.template&&(e.rename(`templates`,n.template,r),n.template=r)}}),c(null)}})]})}function ds(e){let{draft:t,edit:n}=e,[r,i]=N(null),[a,o]=N(null),s=t.properties?.custom??[],c=ut(t).map(e=>e.name),l=(e,t)=>n(n=>{n.properties=n.properties??{},n.properties.custom=n.properties.custom??[],t(n.properties.custom[e])}),u=e=>e.applies_to===void 0||e.applies_to===`all`?`all collections`:e.applies_to.join(`, `),d=e=>Object.keys(e.eidosmd?.canvas?.styles??{}).length>0;return J(C,{children:[J(`h3`,{className:`settings__h`,children:`Eidos core (the standard's)`}),J(`div`,{className:`rows rows--plain`,children:(t.properties?.core??[]).map(e=>J(`div`,{className:`row`,children:[J(`div`,{className:`row__main`,children:[J(`code`,{className:`row__key`,children:e.name}),J(`span`,{className:`badge`,children:e.type}),e.required===!0&&J(`span`,{className:`badge`,children:`required`}),J(`span`,{className:`muted row__text`,children:e.meaning})]}),J(fs,{options:e.options})]},e.name))}),J(`h3`,{className:`settings__h`,children:`Custom (yours)`}),J(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:[`A custom property is frontmatter a blueprint in the collections it applies to may carry. `,J(`b`,{children:`Required`}),` puts it on every new blueprint and the check notes one that lacks it; otherwise it is there when it has a value. `,J(`b`,{children:`Options`}),` close the value to a list, in order: the editor offers a dropdown and the check notes a value off it. `,J(`b`,{children:`Filter`}),` offers it as a dropdown over the collection's table. `,J(`b`,{children:`On node`}),` prints its value on a canvas card and lets you edit it there. `,J(`b`,{children:`Default style`}),` gives a canvas node its shape and color by value; when two properties both name a value, the higher `,J(`b`,{children:`style priority`}),` wins.`,` `,J(`a`,{href:$o,target:`_blank`,rel:`noreferrer`,children:`More in the docs ↗`})]}),J(`div`,{className:`pdefs`,children:s.map((e,t)=>J(`div`,{className:`pdef${r===t?` pdef--open`:``}`,children:[J(`div`,{className:`pdef__head`,children:[J(`code`,{className:`pdef__name`,children:e.name||`unnamed`}),J(`span`,{className:`badge`,children:e.type}),e.required===!0&&J(`span`,{className:`badge`,children:`required`}),J(`span`,{className:`faint pdef__applies`,children:[`applies to `,u(e)]}),J(`span`,{className:`grow`}),J(`button`,{className:`quiet icon`,onClick:()=>o(t),"data-tip":`Edit the name, type, what it applies to, whether it is required, its options, and meaning`,"data-tip-pos":`left`,"aria-label":`Edit property`,children:J(ln,{})}),J(`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:J(Z,{})})]}),J(`input`,{className:`pdef__meaning`,value:e.meaning??``,placeholder:`What this property means, in a line.`,onChange:e=>l(t,t=>t.meaning=e.target.value)}),J(fs,{options:e.options}),J(`div`,{className:`pdef__foot`,children:[J(`label`,{className:`row__check`,"data-tip":`A dropdown over the collection's table`,"data-tip-pos":`bottom`,children:[J(`input`,{type:`checkbox`,checked:e.eidosmd?.filter===!0,onChange:e=>l(t,t=>ps(t,`filter`,e.target.checked))}),`Filter`]}),J(`label`,{className:`row__check`,"data-tip":`Printed on the canvas card, and edited there`,"data-tip-pos":`bottom`,children:[J(`input`,{type:`checkbox`,checked:e.eidosmd?.canvas?.show===!0,onChange:e=>l(t,t=>ms(t,e.target.checked))}),`On node`]}),J(`span`,{className:`grow`}),J(`span`,{className:`pdef__style`,children:[J(`span`,{className:`faint`,children:`Default style`}),J(`button`,{className:`small${d(e)?` primary`:``}`,onClick:()=>i(r===t?null:t),children:r===t?`Close`:d(e)?`Edit style`:`Set style`}),J(`span`,{className:`faint`,style:{marginLeft:6},children:`Style priority`}),J(`span`,{className:`seg`,role:`group`,"aria-label":`Style priority`,children:[J(`button`,{disabled:t===0,onClick:()=>(n(e=>hs(e.properties.custom,t,-1)),i(r===t?t-1:r)),"data-tip":`Higher: wins over the rows below`,"data-tip-pos":`bottom`,"aria-label":`Higher priority`,children:J(hn,{direction:`up`})}),J(`button`,{disabled:t===s.length-1,onClick:()=>(n(e=>hs(e.properties.custom,t,1)),i(r===t?t+1:r)),"data-tip":`Lower: yields to the rows above`,"data-tip-pos":`bottom`,"aria-label":`Lower priority`,children:J(hn,{direction:`down`})})]})]})]}),r===t&&J(gs,{property:e,onChange:e=>l(t,e),onClose:()=>i(null)})]},t))}),J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>o(-1),children:`+ Add property`})}),a!==null&&J(Yo,{property:a===-1?null:s[a]??null,collections:c,taken:s.map(e=>e.name),onClose:()=>o(null),onSave:e=>{n(t=>{if(t.properties=t.properties??{},t.properties.custom=t.properties.custom??[],a===-1){t.properties.custom.push({name:e.name,type:e.type,applies_to:e.applies_to,...e.required?{required:!0}:{},...e.options?{options:e.options}:{},meaning:e.meaning});return}let{name:n,type:r,applies_to:i,required:o,options:s,meaning:c,...l}=t.properties.custom[a];t.properties.custom[a]={name:e.name,type:e.type,applies_to:e.applies_to,...e.required?{required:!0}:{},...e.options?{options:e.options}:{},meaning:e.meaning,...l}}),o(null)}}),Object.entries(t.properties?.tools??{}).map(([e,t])=>J(`div`,{children:[J(`h3`,{className:`settings__h`,children:[J(wn,{}),` `,e,` (the tool's own block)`]}),J(`div`,{className:`rows rows--plain`,children:t.map(e=>J(`div`,{className:`row`,children:[J(`div`,{className:`row__main`,children:[J(`code`,{className:`row__key`,children:e.name}),J(`span`,{className:`badge`,children:e.type}),e.required===!0&&J(`span`,{className:`badge`,children:`required`}),J(`span`,{className:`faint`,children:e.applies_to===void 0||e.applies_to===`all`?`all collections`:e.applies_to.join(`, `)}),J(`span`,{className:`muted row__text`,children:e.meaning})]}),J(fs,{options:e.options})]},e.name))}),J(`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 fs(e){return!e.options||e.options.length===0?null:J(`div`,{className:`row__sub pdef__options`,title:`The closed set of values, in the order they run`,children:[J(`span`,{className:`faint`,children:`options`}),e.options.map(e=>J(`span`,{className:`chip`,children:e},e))]})}function ps(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 ms(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 hs(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 gs(e){let t=e.property.eidosmd?.canvas??{},n=Object.entries(t.styles??{}),[r,i]=N(null),a=t=>e.onChange(e=>{let n={...e.eidosmd?.canvas?.styles??{}};t(n);let r={...e.eidosmd?.canvas??{}};Object.keys(n).length===0?delete r.styles:r.styles=n,e.eidosmd={...e.eidosmd??{},canvas:r}}),o=()=>{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()},s=(e,t)=>a(n=>{let r=Object.entries(n).map(([n,r])=>[n===e?t:n,r]);for(let e of Object.keys(n))delete n[e];for(let[e,t]of r)n[e]=t});return J(`div`,{className:`pdef__hint`,children:[J(`div`,{className:`card__head`,children:[J(`strong`,{children:[`Default style for “`,e.property.name,`”`]}),J(`button`,{className:`quiet small danger`,onClick:o,children:`Clear style`})]}),J(`p`,{className:`faint`,style:{fontSize:12,margin:`-4px 0 10px`},children:[`A node whose “`,e.property.name,`” has one of these values looks like this on a canvas unless styled by hand. Each value's style is the canvas's own: shape, fill, colors, size; a field left auto falls through to the next property in priority.`]}),J(`div`,{className:`rows`,children:n.map(([e,t])=>J(`div`,{className:`row`,children:J(`div`,{className:`row__main`,children:[J(`input`,{className:`row__name`,value:e,onChange:t=>s(e,t.target.value)}),J(_s,{style:t}),J(`span`,{className:`grow`}),J(`button`,{className:`quiet icon`,onClick:()=>i(e),"data-tip":`Edit the style`,"data-tip-pos":`left`,"aria-label":`Edit style`,children:J(ln,{})}),J(`button`,{className:`quiet icon danger`,onClick:()=>a(t=>delete t[e]),"data-tip":`Remove`,"data-tip-pos":`left`,"aria-label":`Remove`,children:J(Z,{})})]})},e))}),J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>{let e=n.length+1;for(;t.styles?.[`value-${e}`];)e+=1;let r=`value-${e}`;a(e=>e[r]={color:Hi[n.length%Hi.length].hex}),i(r)},children:`+ Value`})}),r!==null&&t.styles?.[r]&&J(vs,{property:e.property.name,value:r,style:t.styles[r],onChange:e=>a(t=>t[r]=e),onClose:()=>i(null)})]})}function _s(e){let{style:t}=e,n=[t.shape,t.fill,t.size].filter(e=>!!e),r=t.fill??`solid`,i=r===`none`?`transparent`:r===`tint`?`color-mix(in srgb, ${t.fill_color??t.color??`var(--text-faint)`} 18%, transparent)`:t.fill_color??`var(--bg-raised)`;return J(`span`,{className:`stylechip`,children:[J(`i`,{className:`stylechip__card ${t.shape??`box`}`,style:{background:i,borderColor:t.color??`var(--border-strong)`},children:t.color&&J(`b`,{style:{background:t.color}})}),J(`span`,{className:`faint`,children:n.length>0?n.join(` · `):`color only`})]})}function vs(e){let[t,n]=N(e.style);return J(Y,{title:`${e.property} = ${e.value}`,size:`sm`,center:!0,onClose:e.onClose,foot:J(C,{children:[J(`button`,{className:`small quiet`,onClick:e.onClose,children:`Cancel`}),J(`button`,{className:`small primary`,onClick:()=>(e.onChange(t),e.onClose()),children:`Save`})]}),children:J(`div`,{className:`stack`,children:[J(`p`,{className:`muted`,style:{margin:0,fontSize:12},children:`How a node with this value looks by default. Auto leaves the field to the next property in priority, or the canvas's own default.`}),J(`div`,{className:`cv__pop-grid`,children:J(eo,{shape:t.shape??null,fill:t.fill??null,fillColor:t.fill_color??null,color:t.color??null,size:t.size??null,clearable:!0,onChange:e=>n(t=>{let n={...t};for(let[t,r]of Object.entries(e))r==null?delete n[t]:n[t]=r;return n})})})]})})}var ys=e=>{let[t=`blueprint`,n=`default`]=e.split(`.`);return`# {{title}}
12
+
13
+ _What a ${t} of the ${n} variant is for, in a line or two. Delete these prompts as the sections fill in._
14
+
15
+ ## Intent
16
+
17
+ _Why this exists, in a paragraph._
18
+
19
+ ## Non-Goals
20
+
21
+ _What this deliberately does not do._
22
+ `};function bs(e){let t=e.trim(),n=t.search(/\n[ \t]*\n/),r=n<0?t:t.slice(0,n),i=n<0?``:t.slice(n).trim();return r.length>=2&&r.startsWith(`_`)&&r.endsWith(`_`)&&!/^_+$/.test(r)?{lead:r.slice(1,-1),rest:i}:{lead:``,rest:t}}var xs=(e,t)=>[e.trim()===``?``:`_${e.trim()}_`,t.trim()].filter(e=>e!==``).join(`
23
+
24
+ `);function Ss(e){let t=e.replace(/\r\n?/g,`
25
+ `).replace(/^\s*<!--[\s\S]*?-->\s*/,``).split(`
26
+ `),n={title:``,motivation:``,intro:``,sections:[]},r=!1,i=!1,a=[],o=null,s=()=>{let{lead:e,rest:t}=bs(a.join(`
27
+ `));o?(o.intent=e,o.body=t):(n.motivation=e,n.intro=t),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]??``,intent:``,body:``},n.sections.push(o);continue}a.push(e)}return s(),n}function Cs(e){let t=[`# ${e.title.trim()}`],n=xs(e.motivation,e.intro);n!==``&&t.push(n);for(let n of e.sections){t.push(`${`#`.repeat(n.level)} ${n.title.trim()}`);let e=xs(n.intent,n.body);e!==``&&t.push(e)}return t.join(`
28
+
29
+ `)+`
30
+ `}var ws=e=>({...Ss(e),title:`{{title}}`}),Ts=e=>Cs({...e,title:`{{title}}`});function Es(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 J(C,{children:[J(`h3`,{className:`settings__h`,children:`Sections`}),e.sections.length===0&&J(`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)=>J(`div`,{className:`tpl-sec`,children:[J(X,{value:String(r.level),onChange:e=>t(i,{level:Number(e.target.value)}),title:`Heading level`,children:[J(`option`,{value:`2`,children:`H2`}),J(`option`,{value:`3`,children:`H3`}),J(`option`,{value:`4`,children:`H4`})]}),J(`input`,{value:r.title,placeholder:`Section heading`,onChange:e=>t(i,{title:e.target.value})}),J(`span`,{className:`tpl-sec__tools`,children:[J(`button`,{className:`quiet icon`,disabled:i===0,onClick:()=>n(i,-1),"aria-label":`Move up`,title:`Move up`,children:J(hn,{direction:`up`})}),J(`button`,{className:`quiet icon`,disabled:i===e.sections.length-1,onClick:()=>n(i,1),"aria-label":`Move down`,title:`Move down`,children:J(hn,{direction:`down`})}),J(`button`,{className:`quiet icon danger`,onClick:()=>e.onChange(e.sections.filter((e,t)=>t!==i)),"aria-label":`Remove section`,title:`Remove section`,children:J(Z,{})})]}),J(`div`,{className:`tpl-sec__fields`,children:[J(`label`,{children:[J(`span`,{children:`Intent`}),J(`textarea`,{rows:2,value:r.intent,placeholder:e.intentHint,onChange:e=>t(i,{intent:e.target.value}),spellCheck:!1}),J(`small`,{className:`faint`,children:`Written in italics under the heading: what goes in this section, deleted as it fills in.`})]}),J(`label`,{children:[J(`span`,{children:`Default content`}),J(`textarea`,{value:r.body,placeholder:e.bodyHint,onChange:e=>t(i,{body:e.target.value}),spellCheck:!1}),J(`small`,{className:`faint`,children:`Plain markdown every new blueprint starts with, as written: a list, a table, a first line.`})]})]})]},i)),J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>e.onChange([...e.sections,{level:2,title:``,intent:``,body:``}]),children:`+ Add section`})})]})}function Ds(e){let{draft:t,edit:n}=e,r=t.vocabulary??[],i=Go(t),[a,o]=N(null),s=(e,t)=>n(n=>{n.vocabulary=n.vocabulary??[],t(n.vocabulary[e])}),c=e=>i.find(t=>t.value===e)?.label??e;return J(C,{children:[J(`h3`,{className:`settings__h`,children:`Terms`}),J(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:[`The words the product is described in, used on purpose: what each `,J(`b`,{children:`means`}),`, and what it is `,J(`b`,{children:`not`}),` (the near-misses, 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. `,J(`b`,{children:`See`}),` is the blueprint or top-level doc that defines the term in full.`,` `,J(`a`,{href:$o,target:`_blank`,rel:`noreferrer`,children:`More in the docs ↗`})]}),J(`div`,{className:`rows`,children:r.map((e,t)=>J(`div`,{className:`row`,children:[J(`div`,{className:`row__main`,children:[J(`input`,{className:`row__name`,value:e.term,placeholder:`term`,onChange:e=>s(t,t=>t.term=e.target.value)}),J(`input`,{className:`row__desc`,value:e.means,placeholder:`what it means, in a line`,onChange:e=>s(t,t=>t.means=e.target.value)}),J(`button`,{className:`quiet icon`,onClick:()=>o(t),"data-tip":`Edit the term, its meaning, its near-misses, and where it is defined`,"data-tip-pos":`left`,"aria-label":`Edit term`,children:J(ln,{})}),J(`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:J(Z,{})})]}),J(`div`,{className:`row__sub`,children:[J(`span`,{className:`faint`,children:`Not`}),e.not.length===0?J(`span`,{className:`faint`,children:`no near-misses yet`}):e.not.map((e,t)=>J(`span`,{className:`chip`,children:e},t)),e.see&&J(C,{children:[J(`span`,{className:`faint`,style:{marginLeft:8},children:`See`}),J(`span`,{className:`muted`,children:c(e.see)})]})]})]},t))}),J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>n(e=>{e.vocabulary=e.vocabulary??[],e.vocabulary.push({term:`new-term`,means:``,not:[]})}),children:`+ Add term`})}),a!==null&&r[a]&&J(Xo,{term:r[a],taken:r.map(e=>e.term),see:i,onClose:()=>o(null),onSave:e=>{n(t=>{t.vocabulary[a]=e}),o(null)}})]})}function Os(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}}`,motivation:``,intro:``,sections:[]}),d=Lt();P(()=>{t&&pt(`/api/templates/${ft(t)}`).then(e=>{let n=e.exists?e.text:ys(t.replace(/^templates\//,``).replace(/\.md$/,``));i(n),u(ws(n)),o(e.exists?e.text:``)}).catch(()=>void 0)},[t]);let f=async()=>{t&&await d(()=>ht(`/api/templates/${ft(t)}`,{text:r}),`Template saved`)&&(o(r),e.onSaved())},p=e=>{u(e),i(Ts(e))},m=e=>{e?u(ws(r)):i(Ts(l)),c(e)},h=e.templates.find(e=>e.path===t);return J(C,{children:[J(`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.`}),J(`div`,{className:`split`,style:{gridTemplateColumns:`240px 1fr`},children:[J(`div`,{children:e.templates.map(e=>J(`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&&J(`span`,{className:`badge warn`,style:{marginLeft:6},children:`missing`})]},`${e.collection}/${e.variant}`))}),J(`div`,{children:t?J(C,{children:[J(`div`,{className:`toolbar`,style:{marginBottom:8},children:[J(`code`,{children:[`.eidos/`,t]}),J(`div`,{className:`grow`}),J(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Editor`,children:[J(`button`,{className:s?`on`:``,role:`radio`,"aria-checked":s,onClick:()=>m(!0),children:`Builder`}),J(`button`,{className:s?``:`on`,role:`radio`,"aria-checked":!s,onClick:()=>m(!1),children:`Source`})]}),J(`button`,{className:`primary small`,onClick:()=>void f(),disabled:r===a,children:h?.exists?`Save`:`Create`})]}),s?J(C,{children:[J(`h3`,{className:`settings__h`,children:`Header`}),J(`div`,{className:`tpl-head`,children:[J(`code`,{className:`faint`,children:[`# `,`{{title}}`]}),J(`label`,{children:[J(`span`,{children:`Motivation`}),J(`textarea`,{rows:2,value:l.motivation,placeholder:`What a blueprint of this variant is for, in a line or two.`,onChange:e=>p({...l,motivation:e.target.value}),spellCheck:!1}),J(`small`,{className:`faint`,children:`Written in italics under the title, deleted as the blueprint is written.`})]}),J(`label`,{children:[J(`span`,{children:`Default content`}),J(`textarea`,{value:l.intro,placeholder:`Optional: anything before the first section that every new blueprint starts with.`,onChange:e=>p({...l,intro:e.target.value}),spellCheck:!1})]})]}),J(Es,{sections:l.sections,onChange:e=>p({...l,sections:e}),intentHint:`What goes here, deleted as it is filled in.`,bodyHint:`Optional.`})]}):J(`textarea`,{className:`editor`,style:{minHeight:`50vh`},value:r,onChange:e=>i(e.target.value),spellCheck:!1})]}):J(`div`,{className:`empty`,children:`No variants declare a template yet.`})})]})]})}var ks=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
+ `,As=e=>{let t=Ss(e);return{...t,motivation:``,intro:xs(t.motivation,t.intro)}},js=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Ms(e){let[t,n]=N([]),[r,i]=N(null),[a,o]=N(``),[s,c]=N(``),[l,u]=N(!0),[d,f]=N({title:``,motivation:``,intro:``,sections:[]}),p=Lt(),m=Bt(),h=I(async()=>{let e=await pt(`/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 pt(`/api/roles/${encodeURIComponent(r)}`).then(t=>{e&&(o(t.text),f(As(t.text)),c(t.text))}).catch(()=>void 0),()=>{e=!1}},[r]);let g=e=>{f(e),o(Cs(e))},_=e=>{e?f(As(a)):o(Cs(d)),u(e)},v=async()=>{r&&await p(()=>ht(`/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=js(n);if(r!==``){if(t.some(e=>e.name===r)){i(r);return}await p(()=>ht(`/api/roles/${encodeURIComponent(r)}`,{text:ks(n.trim())}),`Role ${n.trim()} created`)&&(await h(),i(r),e.onSaved())}},b=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(()=>gt(`/api/roles/${encodeURIComponent(n.name)}`),`Role deleted`)){let t=await h();i(t[0]?.name??null),e.onSaved()}},x=t.find(e=>e.name===r),[S,ee]=N(``);P(()=>ee(r??``),[r]);let w=async()=>{let n=js(S);if(!r||n===``||n===r){ee(r??``);return}if(t.some(e=>e.name===n)){await m.confirm({title:`That name is taken`,body:`A role named ${n} already exists; the name stays ${r}.`,confirm:`OK`}),ee(r);return}let a=await p(()=>ht(`/api/roles/${encodeURIComponent(r)}`,{rename:n}),`Role renamed to ${n}`);a?(await h(),i(a.name),e.onSaved()):ee(r)};return J(C,{children:[J(`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 `,J(`code`,{children:`me.md`}),` names the one in the seat. Committed with the root.`]}),J(`div`,{className:`split`,style:{gridTemplateColumns:`240px 1fr`},children:[J(`div`,{children:[t.map(e=>J(`button`,{className:`quiet${r===e.name?` primary`:``}`,style:{display:`block`,width:`100%`,textAlign:`left`,marginBottom:2},onClick:()=>i(e.name),children:[e.title,J(`span`,{className:`faint mono`,style:{marginLeft:6,fontSize:11},children:e.name})]},e.name)),J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>void y(),children:`+ New role`})})]}),J(`div`,{children:r&&x?J(C,{children:[J(`div`,{className:`toolbar`,style:{marginBottom:8},children:[J(`label`,{className:`field__inline`,"data-tip":`The role's name, and its file under .eidos/roles/; changing it renames the file`,"data-tip-pos":`bottom`,children:[J(`span`,{className:`faint`,children:`Name`}),J(`input`,{className:`mono`,value:S,style:{width:200},onChange:e=>ee(e.target.value),onBlur:()=>void w(),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())}})]}),J(`div`,{className:`grow`}),J(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Editor`,children:[J(`button`,{className:l?`on`:``,role:`radio`,"aria-checked":l,onClick:()=>_(!0),children:`Builder`}),J(`button`,{className:l?``:`on`,role:`radio`,"aria-checked":!l,onClick:()=>_(!1),children:`Source`})]}),J(`button`,{className:`quiet small danger`,onClick:()=>void b(),children:`Delete`}),J(`button`,{className:`primary small`,onClick:()=>void v(),disabled:a===s,children:`Save`})]}),l?J(C,{children:[J(`h3`,{className:`settings__h`,children:`Title`}),J(`input`,{value:d.title,placeholder:`Role title`,onChange:e=>g({...d,title:e.target.value}),style:{width:320}}),d.intro!==``&&J(`div`,{className:`tpl-head`,style:{marginTop:8},children:J(`textarea`,{value:d.intro,onChange:e=>g({...d,intro:e.target.value}),spellCheck:!1})}),J(Es,{sections:d.sections,onChange:e=>g({...d,sections:e}),intentHint:`What this section is about, in a line.`,bodyHint:`What to say here: who they are, how to respond, or how to calibrate.`})]}):J(`textarea`,{className:`editor`,style:{minHeight:`50vh`},value:a,onChange:e=>o(e.target.value),spellCheck:!1})]}):J(`div`,{className:`empty`,children:`No roles under .eidos/roles/ yet. Add one.`})})]})]})}var Ns=`__custom__`;function Ps(){let[e,t]=N(null),[n,r]=N(``),[i,a]=N(!0),[o,s]=N({role:``,custom:``,note:``,ownership:``,experience:``,capacity:``}),c=Lt(),l=I(()=>{pt(`/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?Ns:``,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 J(`div`,{className:`empty`,children:`Loading…`});let u=e=>s(t=>({...t,...e})),d=async()=>{let e=i?{role:o.role===Ns?o.custom:o.role,note:o.note,ownership:o.ownership,experience:o.experience,capacity:o.capacity}:{text:n};await c(()=>ht(`/api/me`,e),`Saved me.md`)&&l()};return J(C,{children:[J(`p`,{className:`faint`,style:{fontSize:12,margin:`0 0 12px`},children:[J(`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.`]}),J(`div`,{className:`toolbar`,style:{marginBottom:12},children:[J(`div`,{className:`grow`}),J(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Editor`,children:[J(`button`,{className:i?`on`:``,role:`radio`,"aria-checked":i,onClick:()=>a(!0),children:`Builder`}),J(`button`,{className:i?``:`on`,role:`radio`,"aria-checked":!i,onClick:()=>a(!1),children:`Source`})]}),J(`button`,{className:`primary small`,onClick:()=>void d(),disabled:!i&&n===e.text,children:`Save`})]}),i?J(C,{children:[J(`h3`,{className:`settings__h`,children:`Role`}),J(`div`,{className:`field`,children:[J(`span`,{children:`You are`}),J(X,{value:o.role,onChange:e=>u({role:e.target.value}),style:{width:280},children:[J(`option`,{value:``,children:`No role: full facilitation`}),e.roles.map(e=>J(`option`,{value:e.name,children:e.title},e.name)),J(`option`,{value:Ns,children:`A role of your own…`})]})]}),o.role===Ns&&J(`div`,{className:`field`,children:[J(`span`,{children:`Called`}),J(`input`,{value:o.custom,placeholder:`Auditor`,onChange:e=>u({custom:e.target.value}),style:{width:280}})]}),o.role!==``&&J(`div`,{className:`field`,style:{alignItems:`start`},children:[J(`span`,{children:`Note`}),J(`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})})]}),J(`h3`,{className:`settings__h`,children:`Calibration`}),J(`div`,{className:`field`,children:[J(`span`,{children:`Ownership`}),J(`input`,{value:o.ownership,placeholder:`What you own on this root, in your own words`,onChange:e=>u({ownership:e.target.value})})]}),J(`div`,{className:`field`,children:[J(`span`,{children:`Experience`}),J(nn,{value:o.experience,options:[`new`,`familiar`,`deep`],placeholder:`Your experience with the scope: new, familiar, deep`,onChange:e=>u({experience:e})})]}),J(`div`,{className:`field`,children:[J(`span`,{children:`Technical capacity`}),J(nn,{value:o.capacity,options:[`non-technical`,`some`,`fluent`],placeholder:`non-technical, some, fluent`,onChange:e=>u({capacity:e})})]})]}):J(`textarea`,{className:`editor`,style:{minHeight:`40vh`},value:n,onChange:e=>r(e.target.value),spellCheck:!1})]})}function Fs(e){let{settings:t}=e,n=Lt(),r=t=>{n(()=>ht(`/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)=>J(`label`,{className:`cv__pref`,children:[J(`input`,{type:`checkbox`,checked:i[e],onChange:t=>r({local:{canvas:{[e]:t.target.checked}}})}),J(`span`,{children:[J(`b`,{children:t}),J(`small`,{children:n})]})]});return J(`div`,{className:`page page--narrow`,children:[J(rs,{current:`/prefs`,title:`Preferences`,blurb:`How this browser behaves for you. Saved as you change them; nothing is kept in the browser itself.`}),J(`h3`,{className:`settings__h`,children:`Theme`}),J(`div`,{className:`field`,children:[J(`span`,{children:`Colors`}),J(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Theme`,children:is.map(e=>J(`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))})]}),J(`p`,{className:`faint`,style:{fontSize:12},children:`System follows the operating system and is what most people want; Light or Dark holds one.`}),J(`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.`),J(`p`,{className:`faint`,style:{fontSize:12},children:[`How a node looks by default is the framework's: `,J(`a`,{href:`/settings/properties`,children:`Framework Settings → Properties`}),`, the default style on each property.`]}),J(`h3`,{className:`settings__h`,children:`Reading`}),J(`div`,{className:`field`,children:[J(`span`,{children:`Page width`}),J(`span`,{className:`seg`,role:`radiogroup`,"aria-label":`Page width`,children:[J(`button`,{className:t.local.reader_width===`fluid`?``:`on`,role:`radio`,"aria-checked":t.local.reader_width!==`fluid`,onClick:()=>r({local:{reader_width:`fixed`}}),children:`Fixed`}),J(`button`,{className:t.local.reader_width===`fluid`?`on`:``,role:`radio`,"aria-checked":t.local.reader_width===`fluid`,onClick:()=>r({local:{reader_width:`fluid`}}),children:`Fluid`})]})]}),J(`p`,{className:`faint`,style:{fontSize:12},children:`Every page but the canvas: Fixed holds it to about 1200px, centred, so a wide screen does not stretch a line of prose or a table across it; Fluid fills the window. A blueprint's or a doc's page has the same switch beside Reading and Source.`}),J(`h3`,{className:`settings__h`,children:`Sidebar`}),J(`label`,{className:`cv__pref`,children:[J(`input`,{type:`checkbox`,checked:t.local.hide_overview,onChange:e=>r({local:{hide_overview:e.target.checked}})}),J(`span`,{children:[J(`b`,{children:`Hide Eidos Overview`}),J(`small`,{children:`Leaves the Eidos Overview link out of the sidebar once the standard is familiar; the standard and the agent guides stay a search away.`})]})]}),J(`h3`,{className:`settings__h`,children:`Tables`}),J(`div`,{className:`field`,children:[J(`span`,{children:`Rows per page`}),J(X,{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=>J(`option`,{value:String(e),children:e},e))})]}),J(`p`,{className:`faint`,style:{fontSize:12},children:`Which columns each table hides is remembered here too, from the table's own column cog.`}),J(`h3`,{className:`settings__h`,children:[`On save `,J(`span`,{className:`badge accent`,children:`shared with the root`})]}),J(`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 `,J(`code`,{children:t.files.shared}),`, so everyone in the root gets the same.`]}),o.length>0&&J(`table`,{className:`mini`,children:J(`tbody`,{children:o.map((e,t)=>J(`tr`,{children:[J(`td`,{children:J(X,{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)&&J(`option`,{value:e.property,children:e.property}),a.map(e=>J(`option`,{value:e.name,children:[e.name,` (`,e.type,`)`]},e.name))]})}),J(`td`,{children:J(X,{value:e.set,onChange:e=>s(o.map((n,r)=>r===t?{...n,set:e.target.value}:n)),children:[J(`option`,{value:`today`,children:`set to today (YYYY-MM-DD)`}),J(`option`,{value:`now`,children:`set to now (YYYY-MM-DDTHH:mm)`})]})}),J(`td`,{className:`x`,children:J(`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:J(Z,{})})})]},t))})}),J(`div`,{className:`rowbtn`,children:[J(`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&&J(`span`,{className:`faint`,style:{fontSize:12,alignSelf:`center`},children:`No Date property in the Properties table to set.`})]}),J(`h3`,{className:`settings__h`,children:`External editor`}),J(`div`,{className:`field`,children:[J(`span`,{children:`Command`}),J(`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}})}})]}),J(`p`,{className:`faint`,style:{fontSize:12},children:[`What `,J(`b`,{children:`Editor ↗`}),` on a blueprint or a document runs, with `,J(`code`,{children:`{file}`}),` the file's path. Blank opens the file with the system's default app for it.`]}),J(`h3`,{className:`settings__h`,children:`Files`}),J(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:[J(`code`,{children:t.files.local}),` is yours and ignored by git; `,J(`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 Is(e){let[t,n]=N(null),[r,i]=N(0),a=Lt();if(P(()=>{pt(`/api/check`).then(n).catch(()=>void 0)},[e.tick,r]),!t)return J(Dn,{});let o=new Map;for(let e of t.findings){let t=e.path??`(root)`;o.set(t,[...o.get(t)??[],e])}return J(`div`,{className:`page page--narrow`,children:[J(rs,{current:`/check`,title:`Health Check`,blurb:J(C,{children:[t.blueprints,` blueprints in `,t.collections,` collections · Eidos `,t.eidos_version??`?`,` · `,t.naming]}),actions:J(C,{children:[J(`span`,{className:`badge ${t.errors>0?`error`:`ok`}`,children:[t.errors,` errors`]}),J(`span`,{className:`badge ${t.warnings>0?t.strict?`error`:`warn`:`ok`}`,children:[t.warnings,` warnings`,t.strict?` (strict: they fail)`:``]}),J(`button`,{onClick:()=>i(e=>e+1),children:`Re-run`}),J(`button`,{onClick:()=>void a(()=>mt(`/api/index`),`Index rebuilt`).then(t=>{t&&(e.onChanged(),i(e=>e+1))}),children:`Rebuild index`})]})}),t.findings.length===0&&J(`div`,{className:`empty`,children:`No findings. The root reads clean.`}),[...o.entries()].map(([t,n])=>J(`div`,{style:{marginBottom:18},children:[J(`div`,{className:`mono`,style:{marginBottom:4},children:t.endsWith(`.md`)&&!t.startsWith(`.eidos`)?J(`a`,{href:Et(t.split(`/`)[0]??``,t),children:t}):t}),J(`ul`,{className:`findings`,children:n.map((t,n)=>J(`li`,{className:t.level,children:[J(`code`,{children:t.code}),t.message,t.fix&&J(`button`,{className:`small`,style:{marginLeft:10},onClick:()=>void a(()=>mt(`/api/fix`,{code:t.code,path:t.path}),`Fixed`).then(t=>{t&&(e.onChanged(),i(e=>e+1))}),children:t.fix})]},n))})]},t))]})}function Ls(e){let[t,n]=N(null),r=F(null);P(()=>{let t=!0;return pt(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:[]}:vi(t),[t]),a=e=>{r.current?.querySelector(`#${CSS.escape(e)}`)?.scrollIntoView({behavior:`smooth`,block:`start`})},o=i.toc.length>0;return J(`div`,{className:`page page--doc`,children:[J(`div`,{className:`page__head page__head--sticky`,children:[J(`div`,{className:`page__head__row`,children:J(`div`,{className:`grow`,children:J(`h1`,{children:e.title})})}),e.tabs&&J(`nav`,{className:`tabs`,children:e.tabs.map(e=>J(`a`,{href:e.href,className:e.active?`on`:``,"data-tip":e.summary,"data-tip-pos":`bottom`,children:e.name},e.name))})]}),t===null?J(Dn,{}):J(`div`,{className:`doc${o?` doc--rail`:``}`,children:[J(`div`,{className:`doc__body`,ref:r,children:J(Vt,{html:i.html})}),o&&J(`aside`,{className:`doc__rail`,children:J(`nav`,{className:`toc`,children:[J(`div`,{className:`history__h`,children:J(`span`,{children:`Contents`})}),i.toc.map(e=>J(`a`,{href:`#${e.id}`,className:`toc__${e.level}`,onClick:t=>(t.preventDefault(),t.stopPropagation(),a(e.id)),children:e.text},e.id))]})})]})]})}function Rs(e){let[t,n]=N(``),[r,i]=N(``),[a,o]=N(!1),s=Lt(),c=async()=>{o(!0);let n=await s(()=>mt(`/api/docs`,{title:t.trim(),description:r.trim()}),`${t.trim()} declared and written at the root`);o(!1),n&&(e.onCreated(),e.onClose(),Ct(K(n.path)))};return J(Y,{title:`New top-level doc`,size:`sm`,center:!0,onClose:e.onClose,foot:J(C,{children:[J(`button`,{onClick:e.onClose,children:`Cancel`}),J(`button`,{className:`primary`,onClick:()=>void c(),disabled:a||t.trim()===``,children:`Create`})]}),children:J(`div`,{style:{padding:`4px 18px 12px`},children:[J(`div`,{className:`form`,children:[J(`label`,{children:`Title`}),J(`input`,{ref:On,value:t,placeholder:`Roadmap`,onChange:e=>n(e.target.value),onKeyDown:e=>e.key===`Enter`&&t.trim()!==``&&void c()}),J(`label`,{children:`Description`}),J(`input`,{value:r,placeholder:`What the document is, in a line`,onChange:e=>i(e.target.value)})]}),J(`p`,{className:`faint`,style:{fontSize:12,margin:0},children:[`Declared under `,J(`code`,{children:`top_level`}),` and written at the root, named for its title, as `,J(`code`,{children:`eidos configure:doc add`}),` does.`]})]})})}function zs(e){let t=ut(e.root.framework),[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=Lt(),h=t.find(e=>e.name===n),g=h?.grouping?.groups??[],_=async()=>{p(!0);let t=await m(()=>mt(`/api/blueprints`,{collection:n,title:i,group:o||null,variant:c||null,summary:u||null}));p(!1),t&&(e.onCreated(),e.onClose(),Ct(Et(t.collection,t.path)))};return J(Y,{title:`New blueprint`,size:`sm`,center:!0,onClose:e.onClose,foot:J(C,{children:[J(`button`,{onClick:e.onClose,children:`Cancel`}),J(`button`,{className:`primary`,onClick:()=>void _(),disabled:f||i.trim()===``,children:`Create`})]}),children:J(`div`,{style:{padding:`4px 18px 12px`},children:[J(`div`,{className:`form`,children:[J(`label`,{children:`Collection`}),J(X,{value:n,onChange:e=>(r(e.target.value),s(``),l(``)),children:t.map(e=>J(`option`,{value:e.name,children:e.name},e.name))}),J(`label`,{children:`Title`}),J(`input`,{ref:On,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&i.trim()!==``&&void _()}),g.length>0&&J(C,{children:[J(`label`,{children:h?.grouping?.label??`Group`}),J(X,{value:o,onChange:e=>s(e.target.value),children:[J(`option`,{value:``,children:`—`}),g.map(e=>J(`option`,{value:e.name,children:e.name},e.name))]})]}),J(`label`,{children:`Variant`}),J(`span`,{children:[J(X,{value:c,onChange:e=>l(e.target.value),style:{width:`100%`},children:[J(`option`,{value:``,children:[`default`,h?` (${h.variants.find(e=>e.default)?.name??h.variants[0]?.name??``})`:``]}),h?.variants.map(e=>J(`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?J(`span`,{className:`field__hint`,children:e.description}):null})()]}),J(`label`,{children:`Summary`}),J(`input`,{value:u,placeholder:`one plain line`,onChange:e=>d(e.target.value)})]}),J(`p`,{className:`faint`,style:{fontSize:12,margin:0},children:[`Scaffolds the file from the variant's template, as `,J(`code`,{children:`eidos new`}),` does.`]})]})})}function Bs(e){let[t,n]=N([]),[r,i]=N(!1),a=Lt(),o=e.root.settings,s=o.shared.versions.tag_prefix,c=e.root.git_head,l=()=>{pt(`/api/versions`).then(e=>n(e.versions)).catch(()=>n([]))};P(l,[e.root]);let u=t=>{t!==s&&a(()=>ht(`/api/settings`,{shared:{versions:{tag_prefix:t}}}),`Tag prefix saved`).then(t=>t&&e.onSaved())};return J(`div`,{className:`page page--narrow`,children:[J(rs,{current:`/versions`,title:`Versions`,blurb:`Snapshots of the root taken on purpose: the root's own number, the commit that is the snapshot, and a git tag when one was made.`,actions:J(`button`,{className:`primary`,onClick:()=>i(!0),disabled:!c,"data-tip":c?void 0:`The root is not in a git repository; a version names a commit`,"data-tip-pos":`bottom`,children:`Record a version…`})}),J(`h3`,{className:`settings__h`,children:`Recorded`}),t.length===0?J(`p`,{className:`faint`,style:{fontSize:13,margin:0},children:`None yet, which is the normal state. Record one when a team needs a fixed point to hold the definition against.`}):J(`table`,{className:`mini`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Version`}),J(`th`,{children:`Commit`}),J(`th`,{children:`Tag`})]})}),J(`tbody`,{children:t.map(e=>J(`tr`,{children:[J(`td`,{children:e.version}),J(`td`,{children:J(`code`,{children:e.commit})}),J(`td`,{children:e.tag?J(`code`,{children:e.tag}):J(`span`,{className:`faint`,children:`no tag`})})]},e.version))})]}),J(`h3`,{className:`settings__h`,children:[`Tag prefix `,J(`span`,{className:`badge accent`,children:`shared with the root`})]}),J(`div`,{className:`field`,children:[J(`span`,{children:`Tags start with`}),J(`input`,{defaultValue:s,placeholder:`blueprints/`,style:{maxWidth:280},onBlur:e=>u(e.target.value.trim()),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})]}),J(`p`,{className:`faint`,style:{fontSize:12},children:[`A recorded version tagged from here or with `,J(`code`,{children:`eidos version record --tag`}),` is `,J(`code`,{children:[s||``,`<version>`]}),` on its commit. Kept in `,J(`code`,{children:o.files.shared}),`, so everyone in the root tags the same way. Blank tags the bare number.`]}),J(`h3`,{className:`settings__h`,children:`Where it lives`}),J(`p`,{className:`faint`,style:{fontSize:12,marginTop:0},children:[`The record is `,J(`code`,{children:`.eidos/plugins/eidosmd/versions.yaml`}),`, this CLI's own, since it needs git; the standard keeps none. The commit is the snapshot, nothing is copied, and the commit that adds the row is not the one it names, the way a tag follows the commit it marks. Not the product's release version.`]}),r&&J(Vs,{gitHead:c,prefix:s,onClose:()=>i(!1),onRecorded:()=>(l(),e.onSaved())})]})}function Vs(e){let[t,n]=N(``),[r,i]=N(``),[a,o]=N(!1),[s,c]=N(!1),l=Lt(),u=async()=>{c(!0);let n=await l(()=>mt(`/api/versions`,{version:t,commit:r||null,tag:a}),`Version recorded`);c(!1),n&&(e.onRecorded(),e.onClose())};return J(Y,{title:`Record a version of the root`,size:`sm`,center:!0,onClose:e.onClose,foot:J(C,{children:[J(`button`,{onClick:e.onClose,children:`Cancel`}),J(`button`,{className:`primary`,onClick:()=>void u(),disabled:s||t.trim()===``||!e.gitHead,children:`Record`})]}),children:J(`div`,{style:{padding:`4px 18px 12px`},children:[!e.gitHead&&J(`p`,{className:`findings`,children:J(`span`,{className:`error`,children:`This root is not in a git repository; a version names a commit.`})}),J(`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.`}),J(`div`,{className:`form`,children:[J(`label`,{children:`Version`}),J(`input`,{ref:On,value:t,placeholder:`the root's own number, e.g. 1.0.0`,onChange:e=>n(e.target.value)}),J(`label`,{children:`Commit`}),J(`input`,{value:r,placeholder:e.gitHead&&e.gitHead!==`HEAD`?`HEAD (${e.gitHead.slice(0,12)})`:`HEAD`,onChange:e=>i(e.target.value)}),J(`label`,{children:`Tag`}),J(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,color:`var(--text)`},children:[J(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),style:{width:`auto`}}),`create `,J(`code`,{children:[e.prefix,t.trim()||`<version>`]}),` on that commit`]})]})]})})}var Hs=e=>e.replace(/^@/,``).replace(/\s+/g,``);function Us(e){let{root:t}=e,n=t.settings,[r,i]=N(n.shared.users);P(()=>i(n.shared.users),[n.shared.users]);let a=Lt(),o=(t,n)=>{a(()=>ht(`/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=>_t(e,d)),p=(e,t)=>e!==``&&r.some((n,r)=>r!==t&&n.alias?.toLowerCase()===e.toLowerCase());return J(`div`,{className:`page page--narrow`,children:[J(rs,{current:`/users`,title:`Users`,blurb:J(C,{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.`]})}),n.shared.features.git&&d&&!f&&J(`div`,{className:`rowbtn`,children:[J(`button`,{className:`small`,onClick:()=>s([...r,{name:d.name,alias:Hs(d.name.split(/\s+/)[0]?.toLowerCase()??``)||null,role:u,email:d.email}]),children:[`+ Add `,d.name,` as a user`]}),J(`span`,{className:`faint`,style:{fontSize:12,alignSelf:`center`},children:[`with the role from your me.md`,u?` (${u})`:``]})]}),J(`h3`,{className:`settings__h`,children:`People`}),r.length===0?J(`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.`}):J(`table`,{className:`mini`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Display name`}),J(`th`,{children:`Alias`}),J(`th`,{children:`Role`}),J(`th`,{children:`Email`}),J(`th`,{})]})}),J(`tbody`,{children:r.map((e,t)=>J(`tr`,{children:[J(`td`,{children:J(`input`,{defaultValue:e.name,onBlur:n=>{let r=n.target.value.trim();r!==``&&r!==e.name&&c(t,{name:r})}})}),J(`td`,{children:J(`span`,{style:{display:`flex`,alignItems:`center`,gap:2},children:[J(`span`,{className:`faint`,children:`@`}),J(`input`,{defaultValue:e.alias??``,placeholder:`alias`,style:{width:110},onBlur:n=>{let r=Hs(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})}})]})}),J(`td`,{children:J(X,{value:e.role??``,onChange:e=>c(t,{role:e.target.value||null}),children:[J(`option`,{value:``,children:`none`}),!l.includes(e.role??``)&&e.role&&J(`option`,{value:e.role,children:e.role}),l.map(e=>J(`option`,{value:e,children:e},e))]})}),J(`td`,{children:J(`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})}})}),J(`td`,{className:`x`,children:J(`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:J(Z,{})})})]},t))})]}),J(`div`,{className:`rowbtn`,children:J(`button`,{className:`small`,onClick:()=>s([...r,{name:`Someone ${r.length+1}`,alias:null,role:null,email:null}]),children:`+ Add user`})}),J(`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 `,J(`code`,{children:`.eidos/roles/`}),`. Who this machine acts as is picked in the sidebar and kept in `,J(`code`,{children:n.files.local}),`: swap to a client during a call, annotate as them, swap back. Attribution, not authentication.`]})]})}function Ws(e){return J(`span`,{className:`s`,children:e.text.split(/(\[[^\]]*\])/g).map((e,t)=>e.startsWith(`[`)&&e.endsWith(`]`)&&e.length>2?J(`mark`,{children:e.slice(1,-1)},t):J(`span`,{children:e},t))})}function Gs(e){let t=[];for(let n of e.canvases)t.push({label:n.title,where:`Canvas map`,href:Ot(n.id)});for(let n of ut(e.framework))t.push({label:n.name,where:`Collection`,href:Et(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:K(e[1])})}t.push({label:`Health Check`,where:`Eidosmd CLI`,href:`/check`}),t.push({label:`Versions`,where:`Eidosmd CLI`,href:`/versions`}),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`,`Folders`],[`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 Ks=(e,t)=>t.every(t=>`${e.label} ${e.where}`.toLowerCase().includes(t));function qs(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(()=>Gs(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(()=>{pt(`/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=>Ks(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),ht(`/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(),Ct(t.kind===`place`?t.place.href:Et(t.hit.collection,t.hit.path))}},_=``,v=e=>e.kind===`recent`?`Recent searches`:e.kind===`place`?p===``?`Go to`:`Places`:`Blueprints`;return J(`div`,{className:`backdrop`,onMouseDown:t=>t.target===t.currentTarget&&e.onClose(),children:J(`div`,{className:`palette`,children:[J(`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])}}),J(`div`,{className:`palette__list`,children:[p!==``&&m.length===0&&J(`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 J(`div`,{children:[r&&J(`div`,{className:`palette__section`,children:r}),J(`div`,{className:`palette__hit${t===a?` active`:``}`,onMouseEnter:()=>o(t),onClick:()=>g(e),children:[e.kind===`recent`&&J(C,{children:[J(`span`,{className:`t muted`,children:e.query}),J(`span`,{className:`w`,children:`↵ to search again`})]}),e.kind===`place`&&J(C,{children:[J(`span`,{className:`t`,children:e.place.label}),J(`span`,{className:`w`,children:e.place.where})]}),e.kind===`hit`&&J(C,{children:[J(`span`,{className:`t`,children:e.hit.field===`title`?J(Ws,{text:e.hit.snippet}):e.hit.title}),J(`span`,{className:`w`,children:[e.hit.collection,e.hit.group?` / ${e.hit.group}`:``]}),e.hit.field!==`title`&&J(Ws,{text:e.hit.snippet}),e.hit.field===`title`&&e.hit.summary&&J(`span`,{className:`s`,children:e.hit.summary})]})]})]},i)})]}),J(`div`,{className:`palette__foot`,children:[J(`span`,{children:[J(`kbd`,{children:`↑`}),` `,J(`kbd`,{children:`↓`}),` move`]}),J(`span`,{children:[J(`kbd`,{children:`↵`}),` open`]}),J(`span`,{children:[J(`kbd`,{children:`>`}),` places · `,J(`kbd`,{children:`@`}),` blueprints`]}),J(`span`,{style:{marginLeft:`auto`},children:e.engine===`sqlite`?`SQLite full-text index`:`in-memory scan`})]})]})})}function Js(e){let{root:t}=e,n=t.settings,r=Lt(),i=(t,n)=>{r(()=>ht(`/api/settings`,t),n).then(t=>t&&e.onSaved())},a=t.git.user;return J(`div`,{className:`page page--narrow`,children:[J(rs,{current:`/plugins`,title:`Plugins`,blurb:J(C,{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,`.`]})}),J(`h3`,{className:`settings__h`,children:`Checks`}),J(`label`,{className:`cv__pref`,children:[J(`input`,{type:`checkbox`,checked:n.shared.check.strict,onChange:e=>i({shared:{check:{strict:e.target.checked}}},e.target.checked?`Strict checks on: a warning fails`:`Strict checks off`)}),J(`span`,{children:[J(`b`,{children:`Strict: a warning fails the check`}),J(`small`,{children:[`The framework owner's decision for this root, kept in `,n.files.shared," and committed, so CI, every machine, and every agent agree. `eidos check --strict` or `--no-strict` overrides one run."]})]})]}),J(`h3`,{className:`settings__h`,style:{marginTop:20},children:`Git`}),J(`label`,{className:`cv__pref`,children:[J(`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`)}),J(`span`,{children:[J(`b`,{children:`Read git for this root`}),J(`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&&J(`p`,{className:`faint`,style:{fontSize:12,margin:`4px 0 0 30px`},children:t.git.available?J(C,{children:[`This root is in a repository`,a?J(C,{children:[`; git says you are `,J(`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&&J(C,{children:[J(`div`,{className:`field`,style:{marginTop:16},children:[J(`span`,{children:[`Diff viewer `,J(`span`,{className:`badge`,children:`this machine`})]}),J(`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`)}})]}),J(`p`,{className:`faint`,style:{fontSize:12},children:[`Opened from a blueprint's history with `,J(`code`,{children:`{a}`}),` the file as it was and `,J(`code`,{children:`{b}`}),` the file now; nothing is shown in the page itself. Examples: `,J(`code`,{children:`code --diff {a} {b}`}),`, `,J(`code`,{children:`opendiff {a} {b}`}),`, `,J(`code`,{children:`meld {a} {b}`}),`. Yours alone, in `,n.files.local,`.`]})]})]})}var Ys=`https://eidosmd.com/docs/cli`;function Xs(e){e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}function Zs(){let[e,t]=N(null),[n,r]=N(null),[i,a]=N(0),[o,s]=N({seq:0,paths:[]}),c=I(()=>{pt(`/api/root`).then(e=>{t(e),r(null),a(e=>e+1)}).catch(e=>r(e.message))},[]);return P(c,[c]),P(()=>{e&&Xs(e.settings.local.theme)},[e]),P(()=>{let e=new EventSource(`/api/events`);return e.onmessage=e=>{let t=[];try{let n=JSON.parse(e.data);Array.isArray(n.paths)&&(t=n.paths.filter(e=>typeof e==`string`))}catch{t=[]}s(e=>({seq:e.seq+1,paths:t})),c()},()=>e.close()},[c]),{root:e,error:n,tick:i,reload:c,change:o}}function Qs(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}function $s(e){let{root:t}=e,n=Lt(),r=Bt(),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(()=>mt(`/api/canvas`,{title:t}));i&&(e.onChanged(),Ct(Ot(i.id)))},s=Qs(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=>_t(e,u)):void 0,p=l===``?f?d(f):``:l,m=t=>{let r=t===``||f!==void 0&&t.toLowerCase()===d(f).toLowerCase();n(()=>ht(`/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 J(`aside`,{className:`sidebar${e.open?` open`:``}`,children:[J(`div`,{className:`brand`,children:[J(`img`,{className:`brand__mark`,src:`/mark.svg`,alt:``}),J(`span`,{className:`brand__word`,children:`Eidos`})]}),J(`div`,{className:`brand__root`,title:t.root,children:t.name}),c.length>0&&J(`label`,{className:`sidebar__acting sidebar__acting--top`,children:[J(`span`,{"data-tip":`Comments and edits are signed by this user`,"data-tip-pos":`right`,children:`Acting as`}),J(X,{value:p,onChange:e=>m(e.target.value),children:[!f&&J(`option`,{value:``,children:h}),c.map(e=>J(`option`,{value:e.alias??e.name,children:[e.name,e.alias?` (@${e.alias})`:``]},e.alias??e.name))]})]}),J(`div`,{className:`sidebar__search`,onClick:e.onSearch,role:`button`,children:[J(`span`,{children:`Search…`}),J(`kbd`,{children:`/`})]}),J(`nav`,{className:`nav`,children:[J(`div`,{className:`nav__group`,children:[J(`span`,{children:`Top-Level Docs`}),J(`button`,{className:`quiet icon`,"data-tip":`New top-level doc`,"data-tip-pos":`left`,"aria-label":`New top-level doc`,onClick:e.onNewDoc,children:J(bn,{})})]}),s.length===0&&J(`div`,{className:`faint`,style:{padding:`2px 8px`,fontSize:12},children:`None declared.`}),s.map(e=>J(`a`,{href:K(e.path),className:i(K(e.path)),children:J(`span`,{children:e.title})},e.path)),J(`div`,{className:`nav__group`,children:[J(`span`,{children:`Collections`}),J(`button`,{className:`quiet icon`,"data-tip":`New blueprint`,"data-tip-pos":`left`,"aria-label":`New blueprint`,onClick:e.onNew,children:J(bn,{})})]}),ut(t.framework).map(e=>J(`a`,{href:Et(e.name),className:i(`/c/${encodeURIComponent(e.name)}`),children:[J(`span`,{children:e.name}),J(`span`,{className:`count`,children:a.get(e.name)??0})]},e.name)),J(`div`,{className:`nav__group`,children:[J(`span`,{children:`Canvas maps`}),J(`button`,{className:`quiet icon`,"data-tip":`New canvas`,"data-tip-pos":`left`,"aria-label":`New canvas`,onClick:()=>void o(),children:J(bn,{})})]}),t.canvases.length===0&&J(`div`,{className:`faint`,style:{padding:`2px 8px`,fontSize:12},children:`None yet.`}),t.canvases.map(e=>J(`a`,{href:Ot(e.id),className:i(Ot(e.id)),children:[J(`span`,{children:e.title}),J(`span`,{className:`count`,children:[e.pages,` page`,e.pages===1?``:`s`]})]},e.id)),J(`div`,{className:`nav__foot`,children:[J(`a`,{href:`/settings/general`,className:i(`/settings`),children:[J(pn,{}),J(`span`,{children:`Framework Settings`})]}),J(`a`,{href:`/check`,className:Qo.some(e=>i(e.href)!==``)?`active`:``,children:[J(vn,{}),J(`span`,{children:`Eidosmd CLI`}),t.check.errors+t.check.warnings>0&&J(`span`,{className:`badge ${t.check.errors>0||t.check.strict&&t.check.warnings>0?`error`:`warn`}`,children:t.check.errors+t.check.warnings})]}),!t.settings.local.hide_overview&&J(`a`,{href:`/learn/standard`,className:i(`/learn`),children:[J(xn,{}),J(`span`,{children:`Eidos Overview`})]}),J(`a`,{href:Ys,target:`_blank`,rel:`noreferrer`,children:[J(mn,{}),J(`span`,{children:`Docs`})]})]})]}),J(`div`,{className:`sidebar__foot`,children:J(`div`,{className:`sidebar__version`,children:[J(`span`,{children:[`eidosmd `,t.cli_version]}),J(`span`,{children:[`Eidos `,t.framework.eidos_version??t.standard_version]})]})})]})}var ec=!1;function tc(){let{root:e,error:t,tick:n,reload:r,change:i}=Zs(),a=wt(),o=kt(),s=Bt(),c=Lt(),[l,u]=N(!1),[d,f]=N(!1),[p,m]=N(!1);P(()=>m(!1),[a.path]);let[h,g]=N(!1),[_,v]=N(!1);P(()=>{!e||e.settings.configured||ec||(ec=!0,s.choose({title:`Set up eidosmd for this root`,body:J(C,{children:[J(`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.`:``]}),J(`p`,{className:`faint`,style:{margin:0,fontSize:12},children:[`Written to `,e.settings.files.shared,`. People and aliases for @mentions are added under Users; `,J(`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`)&&c(()=>ht(`/api/settings`,{shared:{features:{git:e===`on`}}})).then(e=>e&&r())}))},[e,s,c,r]);let y=I(e=>c(()=>ht(`/api/settings`,e)).then(e=>e?(r(),e):null),[c,r]);if(P(()=>{let e=e=>{e.target.closest(`input, textarea, select, [contenteditable]`)||(Ut(e)&&!e.altKey&&e.key.toLowerCase()===`o`?(e.preventDefault(),u(`@`)):Ut(e)&&!e.altKey&&e.key===`/`?(e.preventDefault(),u(`>`)):e.key===`/`&&!e.metaKey&&!e.ctrlKey&&!e.altKey?(e.preventDefault(),u(``)):e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!document.querySelector(`.cv`)&&(e.preventDefault(),f(e=>!e)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),Yt(`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||a.segments.length>0)return;let t=Qs(e)[0],n=ut(e.framework)[0],r=e.canvases[0];Ct(t?K(t.path):n?Et(n.name):r?Ot(r.id):`/check`,{replace:!0})},[e,a.segments.length]),t)return J(`div`,{className:`empty`,children:t});if(!e)return J(`div`,{className:`empty`,children:`Loading…`});let[b,...x]=a.segments,S;if(b===`canvas`&&x[0])S=J(Ao,{id:x[0],page:x[1]??null,open:a.query.get(`open`),tick:n,settings:e.settings,onChanged:r});else if(b===`c`&&x[0])S=J(Ro,{name:x[0],open:a.query.get(`open`),tick:n,settings:e.settings,onNew:e=>g(e),onSettingsSaved:r,onChanged:r});else if(b===`b`&&x.length>0)S=J(wi,{path:x.join(`/`),tick:n,layout:`page`,onSaved:r});else if(b===`doc`&&x.length>0)S=J(wi,{kind:`doc`,path:x.join(`/`),tick:n,layout:`page`,onSaved:r});else if(b===`check`)S=J(Is,{tick:n,onChanged:r});else if(b===`versions`)S=J(Bs,{root:e,onSaved:r});else if(b===`learn`){let t=x[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}))];S=J(Ls,{url:t===`standard`?`/api/standard`:`/api/instructions/${encodeURIComponent(t)}`,title:`Eidos Overview`,tabs:n})}else S=b===`prefs`?J(Fs,{settings:e.settings,properties:e.framework.properties,onSaved:r}):b===`plugins`?J(Js,{root:e,onSaved:r}):b===`users`?J(Us,{root:e,onSaved:r}):b===`settings`?J(as,{tab:Zo.find(e=>e.tab===x[0])?.tab??(x[0]===`me`?`me`:`general`),onSaved:r}):J(`div`,{className:`empty`,children:[`Nothing at `,a.path,`.`]});return J(Xr.Provider,{value:{settings:e.settings,save:y,platform:e.platform},children:J(li.Provider,{value:i,children:J(`div`,{className:`shell${p?` drawer-open`:``}`,onClick:o,children:[J(`button`,{className:`shell__menu`,onClick:()=>m(e=>!e),"aria-label":`Menu`,"aria-expanded":p,children:J(yn,{})}),J(`div`,{className:`shell__scrim`,onClick:()=>m(!1)}),J($s,{root:e,path:a.path,open:p,onSearch:()=>u(``),onNew:()=>g(null),onNewDoc:()=>v(!0),onChanged:r}),J(`main`,{className:`main${e.settings.local.reader_width===`fluid`?``:` main--fixed`}`,children:S}),l!==!1&&J(qs,{root:e,prefix:l,onClose:()=>u(!1),engine:e.search_engine,onSettingsSaved:r}),d&&J(Zt,{onClose:()=>f(!1)}),h!==!1&&J(zs,{root:e,collection:h,onClose:()=>g(!1),onCreated:r}),_&&J(Rs,{onClose:()=>v(!1),onCreated:r})]})})})}function nc(){return J(Ft,{children:J(zt,{children:J(tc,{})})})}var rc=8,ic=8;function ac(){let e=document.createElement(`div`);e.className=`tip`,e.setAttribute(`role`,`tooltip`),document.body.appendChild(e);let t=null,n=()=>{t=null,e.style.visibility=`hidden`},r=t=>{let n=t.getBoundingClientRect(),r=e.offsetWidth,i=e.offsetHeight,a=t.getAttribute(`data-tip-pos`)??`top`,o={top:n.top-rc-i>=ic,bottom:n.bottom+rc+i<=window.innerHeight-ic,left:n.left-rc-r>=ic,right:n.right+rc+r<=window.innerWidth-ic},s={top:`bottom`,bottom:`top`,left:`right`,right:`left`},c=o[a]||!o[s[a]]?a:s[a],l,u;c===`left`||c===`right`?(l=n.top+n.height/2-i/2,u=c===`left`?n.left-rc-r:n.right+rc):(l=c===`top`?n.top-rc-i:n.bottom+rc,u=n.left+n.width/2-r/2),e.style.top=`${Math.max(ic,Math.min(l,window.innerHeight-ic-i))}px`,e.style.left=`${Math.max(ic,Math.min(u,window.innerWidth-ic-r))}px`},i=i=>{let a=i.getAttribute(`data-tip`)??``;if(a===``||i.hasAttribute(`data-tip-off`)){n();return}t=i,e.textContent=a,e.style.visibility=`hidden`,e.style.display=`block`,r(i),e.style.visibility=`visible`},a=e=>e instanceof Element?e.closest(`[data-tip]`):null;document.addEventListener(`mouseover`,e=>{let r=a(e.target);r!==t&&(r?i(r):n())}),document.addEventListener(`mouseout`,e=>{t&&!t.contains(e.relatedTarget)&&n()}),document.addEventListener(`focusin`,e=>{let t=a(e.target);t&&t.matches(`:focus-visible`)&&i(t)}),document.addEventListener(`focusout`,()=>n()),document.addEventListener(`pointerdown`,()=>n(),!0),window.addEventListener(`scroll`,()=>n(),!0),window.addEventListener(`resize`,()=>n()),new MutationObserver(()=>{t&&t.hasAttribute(`data-tip-off`)&&n()}).observe(document.body,{subtree:!0,attributes:!0,attributeFilter:[`data-tip-off`]})}var oc=document.getElementById(`app`);oc&&(ac(),lt(oc).render(J(nc,{})));