const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/VisualEditor-CVNb9YbH.js","assets/VisualEditor-ptHiDCW_.css"])))=>i.map(i=>d[i]); var e=Object.defineProperty,t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function ee(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function te(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,te(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ee(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),te(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u{t.exports=r()})),a=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),o=t(((e,t)=>{t.exports=a()})),s=t((e=>{var t=i();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=t((e=>{var t=o(),n=i(),r=c();function a(e){var t=`https://react.dev/errors/`+e;if(1_e||(e.current=ge[_e],ge[_e]=null,_e--)}function R(e,t){_e++,ge[_e]=e.current,e.current=t}var be=ve(null),xe=ve(null),Se=ve(null),Ce=ve(null);function we(e,t){switch(R(Se,t),R(xe,e),R(be,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ye(be),R(be,e)}function Te(){ye(be),ye(xe),ye(Se)}function Ee(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,R(Ce,e)),t=be.current;var n=dp(t,e.type);t!==n&&(R(xe,e),R(be,n))}function De(e){xe.current===e&&(ye(be),ye(xe)),Ce.current===e&&(ye(Ce),sh._currentValue=he)}var Oe,ke;function Ae(e){if(Oe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Oe=t&&t[1]||``,ke=-1)`:-1i||c[r]!==l[i]){var u=` `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{je=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Ae(n):``}function Ne(e,t){switch(e.tag){case 26:case 27:case 5:return Ae(e.type);case 16:return Ae(`Lazy`);case 13:return e.child!==t&&t!==null?Ae(`Suspense Fallback`):Ae(`Suspense`);case 19:return Ae(`SuspenseList`);case 0:case 15:return Me(e.type,!1);case 11:return Me(e.type.render,!1);case 1:return Me(e.type,!0);case 31:return Ae(`Activity`);case 30:return Ae(`ViewTransition`);default:return``}}function Pe(e){try{var t=``,n=null;do t+=Ne(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}var Fe=Object.prototype.hasOwnProperty,Ie=t.unstable_scheduleCallback,Le=t.unstable_cancelCallback,Re=t.unstable_shouldYield,ze=t.unstable_requestPaint,Be=t.unstable_now,Ve=t.unstable_getCurrentPriorityLevel,He=t.unstable_ImmediatePriority,Ue=t.unstable_UserBlockingPriority,We=t.unstable_NormalPriority,Ge=t.unstable_LowPriority,Ke=t.unstable_IdlePriority,qe=t.log,Je=t.unstable_setDisableYieldValue,Ye=null,Xe=null;function Ze(e){if(typeof qe==`function`&&Je(e),Xe&&typeof Xe.setStrictMode==`function`)try{Xe.setStrictMode(Ye,e)}catch{}}var Qe=Math.clz32?Math.clz32:tt,$e=Math.log,et=Math.LN2;function tt(e){return e>>>=0,e===0?32:31-($e(e)/et|0)|0}var nt=256,rt=262144,it=4194304;function at(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ot(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=at(n))):i=at(o):i=at(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=at(n))):i=at(o)):i=at(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function st(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ct(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function ft(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function pt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=fr),hr=` `,gr=!1;function _r(e,t){switch(e){case`keyup`:return ur.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function vr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var yr=!1;function br(e,t){switch(e){case`compositionend`:return vr(t);case`keypress`:return t.which===32?(gr=!0,hr):null;case`textInput`:return e=t.data,e===hr&&gr?null:e;default:return null}}function xr(e,t){if(yr)return e===`compositionend`||!dr&&_r(e,t)?(e=Nn(),Mn=jn=An=null,yr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Wr(n)}}function Kr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Kr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ur(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ur(e.document)}return t}function Jr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Yr=Dn&&`documentMode`in document&&11>=document.documentMode,Xr=null,Zr=null,Qr=null,$r=!1;function ei(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$r||Xr==null||Xr!==Ur(r)||(r=Xr,`selectionStart`in r&&Jr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Qr&&Hr(Qr,r)||(Qr=r,r=Jf(Zr,`onSelect`),0>=o,i-=o,Xi=1<<32-Qe(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),V&&Qi(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),V&&Qi(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return V&&Qi(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),V&&Qi(i,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===j&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case k:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===j){if(r.tag===7){n(e,r.sibling),c=i(r,o.props.children),so(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===ae&&eo(l)===r.type){n(e,r.sibling),c=i(r,o.props),so(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===j?(c=Li(o.props.children,e.mode,c,o.key),so(c,o),c.return=e,e=c):(c=Ii(o.type,o.key,o.props,null,e.mode,c),so(c,o),c.return=e,e=c)}return s(e);case A:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=i(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Bi(o,e.mode,c),c.return=e,e=c}return s(e);case ae:return o=eo(o),_(e,r,o,c)}if(me(o))return h(e,r,o,c);if(de(o)){if(l=de(o),typeof l!=`function`)throw Error(a(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,oo(o),c);if(o.$$typeof===N)return _(e,r,Ta(e,o),c);co(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,o),c.return=e,e=c):(n(e,r),c=Ri(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ao=0;var i=_(e,t,n,r);return io=null,i}catch(t){if(t===Ja||t===Xa)throw t;var a=Mi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var uo=lo(!0),fo=lo(!1),po=!1;function mo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ho(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function go(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function _o(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,K&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ki(e),Oi(e,null,n),t}return Ti(e,r,t,n),ki(e)}function vo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ht(e,n)}}function yo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var bo=!1;function xo(){if(bo){var e=za;if(e!==null)throw e}}function So(e,t,n,r){bo=!1;var i=e.updateQueue;po=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Y&f)===f:(r&f)===f){f!==0&&f===Ra&&(bo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=D({},d,f);break a;case 2:po=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),od|=o,e.lanes=o,e.memoizedState=d}}function Co(e,t){if(typeof e!=`function`)throw Error(a(191,e));e.call(t)}function wo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=I.T,s={};s.types=o===null?null:o.types,I.T=s,uc(e,!1,t,n);try{var c=i(),l=I.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?lc(e,t,Ha(c,r),jd(e)):lc(e,t,r,jd(e))}catch(n){lc(e,t,{then:function(){},status:`rejected`,reason:n},jd())}finally{L.p=a,o!==null&&s.types!==null&&(o.types=s.types),I.T=o}}function $s(){}function ec(e,t,n,r){if(e.tag!==5)throw Error(a(476));var i=tc(e).queue;Qs(e,i,t,he,n===null?$s:function(){return nc(e),n(r)})}function tc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:he,baseState:he,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ds,lastRenderedState:he},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ds,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function nc(e){var t=tc(e);t.next===null&&(t=e.alternate.memoizedState),lc(e,t.next.queue,{},jd())}function rc(){return wa(sh)}function ic(){return os().memoizedState}function ac(){return os().memoizedState}function oc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=jd();e=go(n);var r=_o(t,e,n);r!==null&&(Pd(r,t,n),vo(r,t,n)),t={cache:ja()},e.payload=t;return}t=t.return}}function sc(e,t,n){var r=jd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},dc(e)?fc(t,n):(n=Ei(e,t,n,r),n!==null&&(Pd(n,e,r),pc(n,t,r)))}function cc(e,t,n){lc(e,t,n,jd())}function lc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(dc(e))fc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Vr(s,o))return Ti(e,t,i,0),q===null&&wi(),!1}catch{}if(n=Ei(e,t,i,r),n!==null)return Pd(n,e,r),pc(n,t,r),!0}return!1}function uc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},dc(e)){if(t)throw Error(a(479))}else t=Ei(e,n,r,2),t!==null&&Pd(t,e,2)}function dc(e){var t=e.alternate;return e===H||t!==null&&t===H}function fc(e,t){Wo=Uo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function pc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ht(e,n)}}var mc={readContext:wa,use:ls,useCallback:Xo,useContext:Xo,useEffect:Xo,useImperativeHandle:Xo,useLayoutEffect:Xo,useInsertionEffect:Xo,useMemo:Xo,useReducer:Xo,useRef:Xo,useState:Xo,useDebugValue:Xo,useDeferredValue:Xo,useTransition:Xo,useSyncExternalStore:Xo,useId:Xo,useHostTransitionStatus:Xo,useFormState:Xo,useActionState:Xo,useOptimistic:Xo,useMemoCache:Xo,useCacheRefresh:Xo,useEffectEvent:Xo},hc={readContext:wa,use:ls,useCallback:function(e,t){return as().memoizedState=[e,t===void 0?null:t],e},useContext:wa,useEffect:zs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Ls(4194308,4,Gs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ls(4194308,4,e,t)},useInsertionEffect:function(e,t){Ls(4,2,e,t)},useMemo:function(e,t){var n=as();t=t===void 0?null:t;var r=e();if(Go){Ze(!0);try{e()}finally{Ze(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=as();if(n!==void 0){var i=n(t);if(Go){Ze(!0);try{n(t)}finally{Ze(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=sc.bind(null,H,e),[r.memoizedState,e]},useRef:function(e){var t=as();return e={current:e},t.memoizedState=e},useState:function(e){e=xs(e);var t=e.queue,n=cc.bind(null,H,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:qs,useDeferredValue:function(e,t){return Xs(as(),e,t)},useTransition:function(){var e=xs(!1);return e=Qs.bind(null,H,e.queue,!0,!1),as().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=H,i=as();if(V){if(n===void 0)throw Error(a(407));n=n()}else{if(n=t(),q===null)throw Error(a(349));Y&127||gs(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,zs(vs.bind(null,r,o,e),[e]),r.flags|=2048,Fs(9,{destroy:void 0},_s.bind(null,r,o,n,t),null),n},useId:function(){var e=as(),t=q.identifierPrefix;if(V){var n=Zi,r=Xi;n=(r&~(1<<32-Qe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Ko++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}o[St]=t,o[Ct]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&pl(t)}}return W(t),t.subtreeFlags&=-33554433,ml(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&pl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(a(166));if(e=Se.current,ua(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=ra,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[St]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||ep(e.nodeValue,n)),e||sa(t,!0)}else e=lp(e).createTextNode(r),e[St]=t,t.stateNode=e}return W(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ua(t),n!==null){if(e===null){if(!r)throw Error(a(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(557));e[St]=t}else da(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;W(t),e=!1}else n=fa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Io(t),t):(Io(t),null);if(t.flags&128)throw Error(a(558))}return W(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=ua(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(a(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(a(317));i[St]=t}else da(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;W(t),i=!1}else i=fa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Io(t),t):(Io(t),null)}return Io(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),gl(t,t.updateQueue),W(t),null);case 4:return Te(),e===null&&Wf(t.stateNode.containerInfo),t.flags|=67108864,W(t),null;case 10:return va(t.type),W(t),null;case 19:if(zo(t),r=t.memoizedState,r===null)return W(t),null;if(i=!!(t.flags&128),o=r.rendering,o===null){if(i)_l(r,!1);else{if(ad!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Bo(e),o!==null){for(t.flags|=128,_l(r,!1),e=o.updateQueue,t.updateQueue=e,gl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Fi(n,e),n=n.sibling;return Ro(t,Lo.current&1|2),V&&Qi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Be()>gd&&(t.flags|=128,i=!0,_l(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Bo(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,gl(t,e),_l(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!V)return W(t),null}else 2*Be()-r.renderingStartTime>gd&&n!==536870912&&(t.flags|=128,i=!0,_l(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Be(),e.sibling=null,o=Lo.current,o=i?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||V?Ro(t,o):(n=o,R(Ao,t),R(Lo,n),jo===null&&(jo=t)),V&&Qi(t,r.treeForkCount),e}return W(t),null;case 22:case 23:return Io(t),ko(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(W(t),t.subtreeFlags&6&&(t.flags|=8192)):W(t),n=t.updateQueue,n!==null&&gl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ye(Wa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),va(Aa),W(t),null;case 25:return null;case 30:return t.flags|=33554432,W(t),null}throw Error(a(156,t.tag))}function yl(e,t){switch(ta(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return va(Aa),Te(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return De(t),null;case 31:if(t.memoizedState!==null){if(Io(t),t.alternate===null)throw Error(a(340));da()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));da()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return zo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Te(),null;case 10:return va(t.type),null;case 22:case 23:return Io(t),ko(),e!==null&&ye(Wa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return va(Aa),null;case 25:return null;default:return null}}function bl(e,t){switch(ta(t),t.tag){case 3:va(Aa),Te();break;case 26:case 27:case 5:De(t);break;case 4:Te();break;case 31:t.memoizedState!==null&&Io(t);break;case 13:Io(t);break;case 19:zo(t);break;case 10:va(t.type);break;case 22:case 23:Io(t),ko(),e!==null&&ye(Wa);break;case 24:va(Aa)}}function xl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Sl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function Cl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{wo(t,n)}catch(t){Z(e,e.return,t)}}}function wl(e,t,n){n.props=Sc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function Tl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=_i(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);h(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function El(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}}function Dl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[St]=e,It(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,i).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Gr(s,h),v=Gr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,I.T=null,n=wd,wd=null;var o=bd,s=Sd;if(yd=0,xd=bd=null,Sd=0,K&6)throw Error(a(331));var c=K;if(K|=4,Yu(o.current),Vu(o,o.current,s,n),K=c,Df(0,!1),Xe&&typeof Xe.onPostCommitFiberRoot==`function`)try{Xe.onPostCommitFiberRoot(Ye,o)}catch{}return!0}finally{L.p=i,I.T=r,uf(e,t)}}function pf(e,t,n){t=Hi(n,t),t=Oc(e.stateNode,t,2),e=_o(e,t,2),e!==null&&(ft(e,2),Ef(e))}function Z(e,t,n){if(e.tag===3)pf(e,e,n);else for(;t!==null;){if(t.tag===3){pf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(vd===null||!vd.has(r))){e=Hi(n,e),n=kc(2),r=_o(t,n,2),r!==null&&(Ac(n,r,t,e),ft(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new $u;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(rd=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,q===e&&(Y&n)===n&&(ad===4||ad===3&&(Y&62914560)===Y&&300>Be()-md?K&2?cd|=n:Vd(e,0):cd|=n,ud===Y&&(ud=0)),Ef(e)}function gf(e,t){t===0&&(t=ut()),e=Di(e,t),e!==null&&(ft(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(a(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return Ie(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Qe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=Y,a=ot(r,r===q?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||st(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&hp()&&(e=Tf);for(var t=Be(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}yd!==0&&yd!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=nn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),It(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+nn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+nn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+nn(n.imageSizes)+`"]`)):i+=`[href="`+nn(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[At]=!0,o.onload=o.onerror=function(){Lt(o)}),It(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+nn(r)+`"][href="`+nn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=D({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),It(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Ft(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);It(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Ft(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=D({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),It(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Ft(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),It(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var i=(i=Se.current)?bm(i):null;if(!i)throw Error(a(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Ft(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Ft(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(i,e,o,s.state))),t&&r===null)throw Error(a(528,``));return s}if(t&&r!==null)throw Error(a(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Ft(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Pm(e){return`href="`+nn(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[At]){r.loading=1;return}}else t=e.createElement(`link`),t[At]=!0,t.onload=t.onerror=Lt.bind(null,t),np(t,`link`,n),It(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+nn(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+nn(n.href)+`"]`);if(r)return t.instance=r,It(r),r;var i=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),It(r),np(r,`style`,i),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Pm(n.href);var o=e.querySelector(Fm(i));if(o)return t.state.loading|=4,t.instance=o,It(o),o;r=Im(n),(i=vm.get(i))&&Hm(r,i),o=(e.ownerDocument||e).createElement(`link`),It(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(i=e.querySelector(zm(o)))?(t.instance=i,It(i),i):(r=n,(i=vm.get(o))&&(r=D({},n),Um(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),It(i),np(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(a(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,It(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),It(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=l()})),d=i(),f=u(),p=class extends Error{},m=class extends Error{},h=class extends Error{problems;constructor(e,t){super(e),this.problems=t}};async function g(e){let t=await fetch(e,{credentials:`same-origin`,headers:{Accept:`application/json`}});if(t.status===401)throw new p(`Sign in to continue.`);let n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`The editor answered ${t.status}.`);return n}async function _(e,t){let n=await fetch(e,{method:`POST`,credentials:`same-origin`,headers:{"Content-Type":`application/json`,Accept:`application/json`,"X-HotDog":`1`},body:JSON.stringify(t)});if(n.status===401)throw new p(`Your sign-in has ended. Sign in again.`);let r=await n.json().catch(()=>({}));if(n.status===409&&r.problems)throw new h(r.error,r.problems);if(n.status===409)throw new m(r.error||`This changed since you opened it.`);if(!n.ok)throw Error(r.error||`The editor answered ${n.status}.`);return r}async function v(e,t,n){let r=new FormData;for(let[e,t]of Object.entries(n))r.set(e,t);r.set(`file`,t);let i=await fetch(x(e,`media`),{method:`POST`,credentials:`same-origin`,headers:{Accept:`application/json`,"X-HotDog":`1`},body:r});if(i.status===401)throw new p(`Your sign-in has ended. Sign in again.`);let a=await i.json().catch(()=>({}));if(i.status===409)throw new m(a.error||`This changed since you opened it.`);if(!i.ok)throw Error(a.error||`The editor answered ${i.status}.`);return a}function y(e){try{return localStorage.getItem(`hotdog-as:${e}`)||void 0}catch{return}}function b(e,t){try{localStorage.setItem(`hotdog-as:${e}`,t)}catch{}}function x(e,t=``,n={}){let r=new URLSearchParams;for(let[e,t]of Object.entries(n))t&&r.set(e,t);let i=y(e);return i&&r.set(`as`,i),`/api/sites/${encodeURIComponent(e)}${t?`/${t}`:``}${r.size?`?${r}`:``}`}var S=(e,t)=>x(e,t),C={quickInfo:e=>g(x(e,`quick`)),quick:(e,t)=>_(S(e,`quick`),t),save:(e,t)=>_(S(e,`save`),t),newPage:(e,t)=>_(S(e,`new`),t),live:(e,t)=>_(S(e,`live`),t),review:(e,t)=>_(S(e,`review`),t),people:e=>g(x(e,`people`)),revert:(e,t)=>_(S(e,`revert`),{sha:t}),publish:(e,t)=>_(S(e,`publish`),t),upload:(e,t,n)=>v(e,t,n),look:(e,t)=>g(x(e,`look`,{branch:t})),lookLive:(e,t)=>_(S(e,`look-live`),t),lookSave:(e,t)=>_(S(e,`look-save`),t),files:(e,t)=>g(x(e,`files`,{branch:t})),file:(e,t,n)=>g(x(e,`file`,{path:t,branch:n})),fileSave:(e,t)=>_(S(e,`file-save`),t),fileDiff:(e,t)=>_(S(e,`file-diff`),t),compare:(e,t)=>g(x(e,`compare`,{branch:t})),log:(e,t,n,r=30)=>g(x(e,`log`,{branch:t,path:n,n:String(r)})),redirects:(e,t)=>g(x(e,`redirects`,{branch:t})),redirectsSave:(e,t)=>_(S(e,`redirects-save`),t),move:(e,t)=>_(S(e,`move`),t),privacy:(e,t)=>g(x(e,`privacy`,{branch:t})),privacySave:(e,t)=>_(S(e,`privacy-save`),t),search:(e,t)=>g(x(e,`search`,{branch:t})),searchSave:(e,t)=>_(S(e,`search-save`),t),forms:(e,t)=>g(x(e,`forms`,{branch:t})),formLive:(e,t)=>_(S(e,`form-live`),t),formSave:(e,t)=>_(S(e,`form-save`),t),submissions:(e,t,n=0)=>g(x(e,`submissions`,{form:t,offset:String(n),limit:`50`})),sections:(e,t)=>g(x(e,`sections`,{branch:t})),media:(e,t)=>g(x(e,`media`,{branch:t})),mediaFile:(e,t,n)=>x(e,`media-file`,{url:t,branch:n}),session:()=>g(`/api/session`),about:()=>g(`/api/about`),sites:()=>g(`/api/sites`),site:(e,t)=>g(x(e,``,{branch:t})),page:(e,t,n)=>g(x(e,`page`,{source:t,branch:n})),logout:e=>fetch(`/auth/logout${e?`?account=${encodeURIComponent(e)}`:``}`,{method:`POST`,credentials:`same-origin`,headers:{"X-HotDog":`1`}})};function w(e,t,n=!1){return`/auth/login?forge=${encodeURIComponent(e)}&return=${encodeURIComponent(t)}${n?`&select=1`:``}`}function T(e){let t=e.pathname.split(`/`).filter(Boolean).map(decodeURIComponent),n=new URLSearchParams(e.search),r=n.get(`branch`)||void 0;return t[0]===`sites`&&t[1]?t[2]===`page`&&n.get(`source`)?{view:`page`,id:t[1],source:n.get(`source`),branch:r}:t[2]===`media`?{view:`media`,id:t[1],branch:r}:t[2]===`look`?{view:`look`,id:t[1],branch:r}:t[2]===`redirects`?{view:`redirects`,id:t[1],branch:r}:t[2]===`privacy`?{view:`privacy`,id:t[1],branch:r}:t[2]===`search`?{view:`search`,id:t[1],branch:r}:t[2]===`history`?{view:`history`,id:t[1]}:t[2]===`quick`?{view:`quick`,id:t[1],kind:n.get(`kind`)||void 0}:t[2]===`forms`?{view:`forms`,id:t[1],branch:r,form:n.get(`form`)||void 0}:t[2]===`files`?{view:`files`,id:t[1],branch:r,path:n.get(`path`)||void 0}:t[2]===`present`&&n.get(`url`)?{view:`present`,id:t[1],url:n.get(`url`),branch:r}:{view:`site`,id:t[1],branch:r}:{view:`sites`}}function E(e){let t=new URLSearchParams;switch(`branch`in e&&e.branch&&t.set(`branch`,e.branch),e.view){case`sites`:return`/`;case`site`:return`/sites/${encodeURIComponent(e.id)}${t.size?`?${t}`:``}`;case`page`:return t.set(`source`,e.source),`/sites/${encodeURIComponent(e.id)}/page?${t}`;case`files`:return e.path&&t.set(`path`,e.path),`/sites/${encodeURIComponent(e.id)}/files${t.size?`?${t}`:``}`;case`history`:return`/sites/${encodeURIComponent(e.id)}/history`;case`quick`:return e.kind&&t.set(`kind`,e.kind),`/sites/${encodeURIComponent(e.id)}/quick${t.size?`?${t}`:``}`;case`forms`:return e.form&&t.set(`form`,e.form),`/sites/${encodeURIComponent(e.id)}/forms${t.size?`?${t}`:``}`;case`search`:return`/sites/${encodeURIComponent(e.id)}/search${t.size?`?${t}`:``}`;case`privacy`:return`/sites/${encodeURIComponent(e.id)}/privacy${t.size?`?${t}`:``}`;case`redirects`:return`/sites/${encodeURIComponent(e.id)}/redirects${t.size?`?${t}`:``}`;case`look`:return`/sites/${encodeURIComponent(e.id)}/look${t.size?`?${t}`:``}`;case`media`:return`/sites/${encodeURIComponent(e.id)}/media${t.size?`?${t}`:``}`;case`present`:return t.set(`url`,e.url),`/sites/${encodeURIComponent(e.id)}/present?${t}`}}function D(e){history.pushState(null,``,E(e)),dispatchEvent(new PopStateEvent(`popstate`))}function O(){let[e,t]=(0,d.useState)(()=>T(location));return(0,d.useEffect)(()=>{let e=()=>t(T(location));return addEventListener(`popstate`,e),()=>removeEventListener(`popstate`,e)},[]),e}var k=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),A=t(((e,t)=>{t.exports=k()})),j=A();function ee(e){return e>1<<20?`${(e/(1<<20)).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function M({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)();return(0,d.useEffect)(()=>{C.media(e,t).then(r,e=>a(e.message))},[e,t]),(0,j.jsxs)(`section`,{className:`pad`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Pictures`}),(0,j.jsxs)(`p`,{className:`muted`,children:[`Everything in `,(0,j.jsx)(`span`,{className:`mono`,children:`static/media/`}),t?(0,j.jsxs)(j.Fragment,{children:[` on `,(0,j.jsx)(`span`,{className:`mono`,children:t})]}):null,`. Pictures are added from a page, with Insert picture; each is re-encoded on the way in, with its location and camera details removed.`]}),i&&(0,j.jsx)(`p`,{className:`notice bad`,role:`alert`,children:i}),!n&&!i&&(0,j.jsx)(`p`,{className:`muted`,children:`Looking through the site…`}),n&&n.length===0&&(0,j.jsx)(`p`,{className:`muted`,children:`No pictures yet.`}),(0,j.jsx)(`ul`,{className:`media-grid`,children:n?.map(n=>(0,j.jsxs)(`li`,{className:`media-card`,children:[(0,j.jsx)(`img`,{src:C.mediaFile(e,n.thumb,t),alt:n.alt,width:n.width,height:n.height,loading:`lazy`}),(0,j.jsxs)(`div`,{className:`media-meta`,children:[(0,j.jsx)(`span`,{className:`mono small`,children:n.url}),(0,j.jsxs)(`span`,{className:`muted small`,children:[n.width,`×`,n.height,` · `,n.files,` files · `,ee(n.bytes)]}),n.usedBy.length>0?(0,j.jsxs)(`span`,{className:`small`,children:[`Used in `,n.usedBy.map(e=>(0,j.jsxs)(`span`,{className:`mono`,children:[` `,e]},e))]}):(0,j.jsx)(`span`,{className:`pill warn`,children:`Not used`})]})]},n.url))})]})}function te({id:e,branch:t,baseCommit:n,source:r,onDraft:i,file:a,onUploaded:o,onInsert:s,onClose:c}){let l=(0,d.useRef)(null),[u,f]=(0,d.useState)(`upload`),[p,m]=(0,d.useState)(a),[h,g]=(0,d.useState)(),[_,v]=(0,d.useState)(),[y,b]=(0,d.useState)(),[x,S]=(0,d.useState)(``),[w,T]=(0,d.useState)(!1),[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)();(0,d.useEffect)(()=>{l.current?.showModal()},[]),(0,d.useEffect)(()=>{if(!p)return g(void 0);let e=URL.createObjectURL(p);return g(e),()=>URL.revokeObjectURL(e)},[p]),(0,d.useEffect)(()=>{u===`library`&&!y&&C.media(e,t).then(b,e=>k(e.message))},[u]);let A=(w||x.trim()!==``)&&(u===`upload`?!!p:!!_)&&!E,M=e=>`![${w?``:x.trim().replace(/[[\]\n]/g,` `)}](${e})`;return(0,j.jsxs)(`dialog`,{ref:l,className:`picture-dialog form`,"aria-labelledby":`pic-title`,onClose:c,onCancel:e=>E&&e.preventDefault(),children:[(0,j.jsx)(`h2`,{id:`pic-title`,children:`Insert picture`}),(0,j.jsxs)(`div`,{className:`seg`,role:`tablist`,"aria-label":`Where the picture comes from`,children:[(0,j.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":u===`upload`,"aria-pressed":u===`upload`,onClick:()=>f(`upload`),children:`Upload`}),(0,j.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":u===`library`,"aria-pressed":u===`library`,onClick:()=>f(`library`),children:`From the library`})]}),u===`upload`&&(0,j.jsxs)(`div`,{className:`drop ${p?`has`:``}`,onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault();let t=e.dataTransfer.files[0];t&&m(t)},children:[h?(0,j.jsx)(`img`,{src:h,alt:``}):(0,j.jsx)(`p`,{className:`muted`,children:`Drop a picture here, or choose one.`}),(0,j.jsxs)(`label`,{className:`button small`,children:[p?`Choose another`:`Choose a picture`,(0,j.jsx)(`input`,{type:`file`,accept:`image/jpeg,image/png,image/gif,image/webp`,className:`visually-hidden`,onChange:e=>e.target.files?.[0]&&m(e.target.files[0])})]}),p&&(0,j.jsxs)(`span`,{className:`muted small`,children:[p.name,` · `,ee(p.size)]})]}),u===`library`&&(0,j.jsxs)(`div`,{className:`library-pick`,children:[!y&&!O&&(0,j.jsx)(`p`,{className:`muted`,children:`Loading the library…`}),y&&y.length===0&&(0,j.jsx)(`p`,{className:`muted`,children:`No pictures in this site yet.`}),(0,j.jsx)(`ul`,{className:`media-grid small`,children:y?.map(n=>(0,j.jsx)(`li`,{children:(0,j.jsx)(`button`,{type:`button`,className:`media-pick ${_?.url===n.url?`on`:``}`,"aria-pressed":_?.url===n.url,onClick:()=>{v(n),!x&&n.alt&&S(n.alt)},children:(0,j.jsx)(`img`,{src:C.mediaFile(e,n.thumb,t),alt:n.alt||n.url,loading:`lazy`})})},n.url))})]}),(0,j.jsxs)(`label`,{className:`alt-field`,children:[`Alt text `,(0,j.jsx)(`span`,{className:`muted small`,children:`what the picture shows, for people who can't see it`}),(0,j.jsx)(`input`,{value:x,disabled:w,onChange:e=>S(e.target.value),placeholder:`e.g. The harbor at dawn, boats tied up along the dock`})]}),(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked)}),` Decorative: it adds nothing the text doesn't say`]}),!w&&!x.trim()&&(0,j.jsx)(`p`,{className:`muted small`,children:`A picture needs alt text, or to be marked decorative.`}),u===`upload`&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`It's re-encoded on the way in: its location and camera details are removed, and it's resized for the web. It's committed to `,i?`this draft`:`a new draft; the published site is unchanged`,`.`]}),O&&(0,j.jsx)(`p`,{className:`notice bad`,role:`alert`,children:O}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!A,onClick:async()=>{if(k(void 0),u===`library`&&_)s(M(_.url));else if(p){D(!0);try{let i=await C.upload(e,p,{branch:t,baseCommit:n,source:r});o(i),s(M(i.url))}catch(e){k(e.message),D(!1)}}},children:E?`Uploading…`:`Insert`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,disabled:E,onClick:()=>l.current?.close(),children:`Cancel`})]})]})}var N=0,ne=()=>`s${N++}`;function re(e){if(Array.isArray(e))return e.map(e=>{if(e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===1){let[t,n]=Object.entries(e)[0];return{key:ne(),type:t,data:n&&typeof n==`object`&&!Array.isArray(n)?n:{}}}return{key:ne(),type:``,data:{},raw:e}})}function P(e){return e.map(e=>e.raw===void 0?{[e.type]:e.data}:e.raw)}function ie(e){let t={};for(let n of e)n.default!==void 0&&n.default!==null&&n.default!==``&&(t[n.name]=n.type===`number`?Number(n.default):n.default);return t}function ae(e,t,n){if(n===void 0||n===``||n===!1||Array.isArray(n)&&n.length===0||n&&typeof n==`object`&&!Array.isArray(n)&&Object.keys(n).length===0){let{[t]:n,...r}=e;return r}return t in e?Object.fromEntries(Object.entries(e).map(([e,r])=>[e,e===t?n:r])):{...e,[t]:n}}function F(e,t,n){if(n<0||n>=e.length||t===n)return e;let r=e.slice(),[i]=r.splice(t,1);return r.splice(n,0,i),r}function oe(e){for(let t of[`heading`,`title`,`eyebrow`,`text`,`body`])if(typeof e[t]==`string`&&e[t])return String(e[t]).split(` `)[0].slice(0,80);return``}function se({id:e,branch:t,value:n,onChange:r,disabled:i,upload:a}){let[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)();(0,d.useEffect)(()=>{C.sections(e,t).then(s,e=>l(e.message))},[e,t]);let _=e=>o?.sections.find(t=>t.name===e),v=(e,t)=>r(n.map((n,r)=>r===e?t:n));return(0,j.jsxs)(`div`,{className:`sections`,children:[c&&(0,j.jsx)(`p`,{className:`notice bad small`,children:c}),(0,j.jsx)(`ol`,{className:`section-list`,children:n.map((s,c)=>{let l=_(s.type),d=u===s.key,p=l?Object.keys(s.data).filter(e=>!l.fields.some(t=>t.name===e)):[];return(0,j.jsxs)(`li`,{className:`section-card ${h===c?`dragging`:``}`,onDragOver:e=>h!==void 0&&e.preventDefault(),onDrop:e=>{e.preventDefault(),h!==void 0&&r(F(n,h,c)),g(void 0)},children:[(0,j.jsxs)(`div`,{className:`section-head`,draggable:!i,onDragStart:()=>g(c),onDragEnd:()=>g(void 0),children:[(0,j.jsx)(`span`,{className:`grip`,"aria-hidden":`true`,title:`Drag to move`,children:`⋮⋮`}),(0,j.jsxs)(`button`,{type:`button`,className:`section-title`,"aria-expanded":d,onClick:()=>f(d?void 0:s.key),children:[(0,j.jsx)(`strong`,{children:s.raw===void 0?l?.label||s.type:`Not a section`}),(0,j.jsxs)(`span`,{className:`muted small`,children:[` `,oe(s.data)]})]}),(0,j.jsxs)(`span`,{className:`section-tools`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:i||c===0,onClick:()=>r(F(n,c,c-1)),"aria-label":`Move ${l?.label||s.type} up`,children:`↑`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:i||c===n.length-1,onClick:()=>r(F(n,c,c+1)),"aria-label":`Move ${l?.label||s.type} down`,children:`↓`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:i,onClick:()=>r([...n.slice(0,c+1),{...s,key:ne(),data:structuredClone(s.data)},...n.slice(c+1)]),"aria-label":`Duplicate ${l?.label||s.type}`,children:`Duplicate`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:i,onClick:()=>r(n.filter((e,t)=>t!==c)),"aria-label":`Remove ${l?.label||s.type}`,children:`Remove`})]})]}),d&&(0,j.jsxs)(`div`,{className:`section-body`,children:[s.raw!==void 0&&(0,j.jsx)(`p`,{className:`muted small`,children:`This entry isn't a section the form can edit; change it in the YAML view.`}),s.raw===void 0&&o&&!l&&(0,j.jsxs)(`p`,{className:`notice bad small`,children:[`This site has no `,(0,j.jsxs)(`span`,{className:`mono`,children:[`sections/`,s.type,`.html`]}),`, so the page won't build until it's removed or added.`]}),l?.problem&&(0,j.jsxs)(`p`,{className:`notice warn small`,children:[`The section's field list couldn't be read (`,l.problem,`); its fields were worked out from the template instead.`]}),l&&o&&(0,j.jsx)(ce,{fields:l.fields,value:s.data,onChange:e=>v(c,{...s,data:e}),ctx:{id:e,branch:t,lib:o,upload:a},disabled:i}),p.length>0&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`Also has `,p.join(`, `),`; edit `,p.length===1?`it`:`them`,` in the YAML view.`]})]})]},s.key)})}),!i&&!p&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>m(!0),children:`Add a section`}),p&&o&&(0,j.jsxs)(`div`,{className:`section-library`,role:`group`,"aria-label":`Section library`,children:[(0,j.jsxs)(`div`,{className:`library-head`,children:[(0,j.jsx)(`strong`,{children:`Add a section`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>m(!1),children:`Cancel`})]}),(0,j.jsx)(`ul`,{children:o.sections.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(`button`,{type:`button`,className:`library-card`,onClick:()=>{let t={key:ne(),type:e.name,data:ie(e.fields)};r([...n,t]),f(t.key),m(!1)},children:[(0,j.jsx)(`strong`,{children:e.label}),e.about&&(0,j.jsx)(`span`,{className:`muted small`,children:e.about}),e.pack&&(0,j.jsxs)(`span`,{className:`muted small`,children:[`From the `,e.pack,` pack`]})]})},e.name))})]})]})}function ce({fields:e,value:t,onChange:n,ctx:r,disabled:i}){return(0,j.jsx)(`div`,{className:`fields`,children:e.map(e=>(0,j.jsx)(le,{field:e,value:t[e.name],onChange:r=>n(ae(t,e.name,r)),ctx:r,disabled:i},e.name))})}function le({field:e,value:t,onChange:n,ctx:r,disabled:i}){let a=(0,j.jsxs)(`span`,{className:`field-label`,children:[e.label||e.name,e.required&&(0,j.jsx)(`span`,{className:`req`,"aria-hidden":`true`,children:` *`})]}),o=e.help&&(0,j.jsx)(`span`,{className:`muted small`,children:e.help}),s=e.required&&(t===void 0||t===``)&&(0,j.jsx)(`span`,{className:`field-warn small`,children:`Needed`}),c=typeof t==`string`||typeof t==`number`?String(t):``;switch(e.type){case`bool`:return(0,j.jsxs)(`label`,{className:`check field`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:i,onChange:e=>n(e.target.checked)}),` `,e.label||e.name,o]});case`textarea`:case`markdown`:return(0,j.jsxs)(`label`,{className:`field`,children:[a,(0,j.jsx)(`textarea`,{className:e.type===`markdown`?`code`:``,rows:e.type===`markdown`?4:3,value:c,disabled:i,required:e.required,onChange:e=>n(e.target.value)}),o,s]});case`number`:return(0,j.jsxs)(`label`,{className:`field`,children:[a,(0,j.jsx)(`input`,{type:`number`,value:c,disabled:i,onChange:e=>n(e.target.value===``?void 0:Number(e.target.value))}),o]});case`select`:case`data`:case`collection`:{let t=e.type===`select`?e.options||[]:e.type===`data`?r.lib.data:r.lib.collections;return(0,j.jsxs)(`label`,{className:`field`,children:[a,(0,j.jsxs)(`select`,{value:c,disabled:i,onChange:e=>n(e.target.value||void 0),children:[(0,j.jsx)(`option`,{value:``,children:e.default===void 0?`—`:`Default (${String(e.default)})`}),t.map(e=>(0,j.jsx)(`option`,{value:e,children:e},e)),c&&!t.includes(c)&&(0,j.jsxs)(`option`,{value:c,children:[c,` (not found)`]})]}),o,s]})}case`image`:return(0,j.jsx)(ue,{f:e,label:a,help:o,value:c,onChange:n,ctx:r,disabled:i});case`group`:{let a=t&&typeof t==`object`&&!Array.isArray(t)?t:{};return(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:e.label||e.name}),o,(0,j.jsx)(ce,{fields:e.fields||[],value:a,onChange:n,ctx:r,disabled:i})]})}case`list`:{let a=Array.isArray(t)?t:[],s=!e.fields||e.fields.length===0;return(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:e.label||e.name}),o,(0,j.jsx)(`ol`,{className:`list-items`,children:a.map((t,o)=>(0,j.jsxs)(`li`,{className:`list-item`,children:[s?(0,j.jsx)(`input`,{value:typeof t==`string`?t:JSON.stringify(t),disabled:i,onChange:e=>n(a.map((t,n)=>n===o?e.target.value:t)),"aria-label":`${e.label||e.name} ${o+1}`}):(0,j.jsx)(ce,{fields:e.fields,value:t&&typeof t==`object`?t:{},onChange:e=>n(a.map((t,n)=>n===o?e:t)),ctx:r,disabled:i}),(0,j.jsxs)(`span`,{className:`list-tools`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:i||o===0,onClick:()=>n(F(a,o,o-1)),"aria-label":`Move up`,children:`↑`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:i||o===a.length-1,onClick:()=>n(F(a,o,o+1)),"aria-label":`Move down`,children:`↓`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:i,onClick:()=>n(a.filter((e,t)=>t!==o)),children:`Remove`})]})]},o))}),!i&&(0,j.jsxs)(`button`,{type:`button`,className:`ghost small`,onClick:()=>n([...a,s?``:ie(e.fields)]),children:[`Add `,s?`a line`:`an item`]})]})}case`link`:return(0,j.jsxs)(`label`,{className:`field`,children:[a,(0,j.jsx)(`input`,{value:c,disabled:i,placeholder:`/about/ or https://…`,onChange:e=>n(e.target.value)}),o,s]});default:return(0,j.jsxs)(`label`,{className:`field`,children:[a,(0,j.jsx)(`input`,{value:c,disabled:i,required:e.required,onChange:e=>n(e.target.value)}),o,s]})}}function ue({f:e,label:t,help:n,value:r,onChange:i,ctx:a,disabled:o}){let[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(),[f,p]=(0,d.useState)(!1),m=(0,d.useRef)(null),[h,g]=(0,d.useState)(),_=async e=>{if(e&&a.upload){p(!0),g(void 0);try{i(await a.upload(e)),c(!1)}catch(e){g(e.message)}finally{p(!1)}}};return(0,d.useEffect)(()=>{s&&!l&&C.media(a.id,a.branch).then(u,()=>u([]))},[s]),(0,j.jsxs)(`div`,{className:`field`,children:[(0,j.jsxs)(`label`,{className:`field`,children:[t,(0,j.jsxs)(`span`,{className:`image-row`,children:[(0,j.jsx)(`input`,{value:r,disabled:o,placeholder:`/media/…`,onChange:e=>i(e.target.value)}),!o&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>c(!s),children:s?`Close`:`Choose`}),!o&&a.upload&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:f,onClick:()=>m.current?.click(),children:f?`Uploading…`:`Upload`})]})]}),a.upload&&(0,j.jsx)(`input`,{ref:m,type:`file`,accept:`image/jpeg,image/png,image/gif,image/webp`,className:`visually-hidden`,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{_(e.target.files?.[0]),e.target.value=``}}),h&&(0,j.jsx)(`span`,{className:`field-warn small`,children:h}),n,s&&(0,j.jsxs)(`ul`,{className:`media-grid small`,children:[l?.length===0&&(0,j.jsxs)(`li`,{className:`muted small`,children:[`No pictures yet`,a.upload?`; upload one.`:`; add one from the body with Insert picture.`]}),l?.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsx)(`button`,{type:`button`,className:`media-pick ${r===e.url?`on`:``}`,onClick:()=>{i(e.url),c(!1)},children:(0,j.jsx)(`img`,{src:C.mediaFile(a.id,e.thumb,a.branch),alt:e.alt||e.url})})},e.url))]}),e.required&&!r&&(0,j.jsx)(`span`,{className:`field-warn small`,children:`Needed`})]})}var de=[{kind:`banner`,label:`Banner or alert`,about:`A line across the top of the site: hours, a closure, an offer.`},{kind:`post`,label:`News post`,about:`A short announcement, dated today.`},{kind:`event`,label:`Event`,about:`Something happening on a date, added to the calendar.`},{kind:`home`,label:`Front page`,about:`Change the words and buttons on the home page.`}];function fe(e,t){let n=new Date(`${e}T00:00:00Z`);return n.setUTCDate(n.getUTCDate()+t),n.toISOString().slice(0,10)}function pe({id:e,kind:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(),o=de.filter(e=>e.kind!==`event`||(n?.calendars.length??0)>0),s=o.find(e=>e.kind===t)?.kind||`banner`,[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(),[p,m]=(0,d.useState)(!1),g=()=>C.quickInfo(e).then(r,e=>a(e.message));(0,d.useEffect)(()=>{g()},[e]);let _=async(t,n)=>{m(!0),l(void 0),f(void 0);try{let r=await C.quick(e,{...t,publish:n});return l(r),f(r.problems||void 0),g(),!0}catch(e){return e instanceof h&&f(e.problems),a(e.message),!1}finally{m(!1)}},v={info:n,busy:p,send:(e,t)=>(a(void 0),_(e,t))};return(0,j.jsxs)(`section`,{className:`pad quick`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:t=>{t.preventDefault(),D({view:`site`,id:e})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Quick post`}),(0,j.jsx)(`div`,{className:`quick-kinds`,role:`tablist`,"aria-label":`What to post`,children:o.map(t=>(0,j.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t.kind===s,className:`quick-kind ${t.kind===s?`on`:``}`,onClick:()=>{l(void 0),a(void 0),D({view:`quick`,id:e,kind:t.kind})},children:[(0,j.jsx)(`strong`,{children:t.label}),(0,j.jsx)(`span`,{className:`muted small`,children:t.about})]},t.kind))}),i&&(0,j.jsx)(`p`,{className:`notice bad`,role:`alert`,children:i}),c&&(0,j.jsxs)(`div`,{className:`notice ${c.published?`good`:u?.length?`bad`:`info`}`,role:`status`,children:[(0,j.jsx)(`p`,{children:c.message}),(0,j.jsxs)(`p`,{className:`small`,children:[c.review&&(0,j.jsxs)(`a`,{href:c.review.url,target:`_blank`,rel:`noopener noreferrer`,children:[`Review #`,c.review.number,` ↗`]}),c.preview&&(0,j.jsxs)(j.Fragment,{children:[` · `,(0,j.jsx)(`a`,{href:c.preview,target:`_blank`,rel:`noopener noreferrer`,children:`Preview ↗`})]})]})]}),u&&u.length>0&&(0,j.jsx)(`ul`,{className:`problems`,children:u.filter(e=>e.Level===`error`).map((e,t)=>(0,j.jsxs)(`li`,{className:`error`,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,(0,j.jsx)(`span`,{className:`mono small`,children:e.File}),` `,e.What,e.Fix&&(0,j.jsx)(`span`,{className:`fix`,children:e.Fix})]},t))}),!n&&!i&&(0,j.jsx)(`p`,{className:`muted`,children:`Reading the site…`}),n&&s===`banner`&&(0,j.jsx)(I,{...v}),n&&s===`post`&&(0,j.jsx)(L,{...v}),n&&s===`event`&&(0,j.jsx)(he,{...v}),n&&s===`home`&&(0,j.jsx)(ge,{id:e,...v})]})}function me({busy:e,ready:t,onSend:n}){return(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:e||!t,onClick:()=>n(!0),children:e?`Posting…`:`Post now`}),(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:e||!t,onClick:()=>n(!1),children:`Send for review`}),(0,j.jsx)(`span`,{className:`muted small`,children:`Post now runs the checks and publishes, if the platform lets you. Otherwise it waits in review.`})]})}function I({info:e,busy:t,send:n}){let[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(`info`),[f,p]=(0,d.useState)(`all`),[m,h]=(0,d.useState)(`now`),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(`today`),[b,x]=(0,d.useState)(``),S=e.now.slice(0,10),C={none:``,today:`${fe(S,1)} 00:00`,tomorrow:`${fe(S,2)} 00:00`,week:`${fe(S,7)} ${e.now.slice(11)}`,pick:b.replace(`T`,` `)}[v]??``,w=m===`later`?g.replace(`T`,` `):``;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`form quick-form`,children:[(0,j.jsxs)(`label`,{children:[`What it says`,(0,j.jsx)(`input`,{value:r,maxLength:280,onChange:e=>i(e.target.value),placeholder:`Closed Monday for the holiday.`})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Link (optional)`,(0,j.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`/news/holiday-hours/ or https://…`})]}),(0,j.jsxs)(`label`,{children:[`Link text`,(0,j.jsx)(`input`,{value:s,disabled:!a,onChange:e=>c(e.target.value),placeholder:`More`})]})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Kind`,(0,j.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),children:[(0,j.jsx)(`option`,{value:`info`,children:`Announcement`}),(0,j.jsx)(`option`,{value:`alert`,children:`Alert (stands out)`})]})]}),(0,j.jsxs)(`label`,{children:[`Where`,(0,j.jsxs)(`select`,{value:f,onChange:e=>p(e.target.value),children:[(0,j.jsx)(`option`,{value:`all`,children:`Every page`}),(0,j.jsx)(`option`,{value:`home`,children:`The home page only`})]})]})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Starts`,(0,j.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),children:[(0,j.jsx)(`option`,{value:`now`,children:`As soon as it's published`}),(0,j.jsx)(`option`,{value:`later`,children:`At a date and time…`})]}),m===`later`&&(0,j.jsx)(`input`,{type:`datetime-local`,value:g,onChange:e=>_(e.target.value),"aria-label":`Starts at`})]}),(0,j.jsxs)(`label`,{children:[`Comes down`,(0,j.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),children:[(0,j.jsx)(`option`,{value:`today`,children:`At the end of today`}),(0,j.jsx)(`option`,{value:`tomorrow`,children:`At the end of tomorrow`}),(0,j.jsx)(`option`,{value:`week`,children:`In a week`}),(0,j.jsx)(`option`,{value:`pick`,children:`At a date and time…`}),(0,j.jsx)(`option`,{value:`none`,children:`When I take it down`})]}),v===`pick`&&(0,j.jsx)(`input`,{type:`datetime-local`,value:b,onChange:e=>x(e.target.value),"aria-label":`Comes down at`})]})]}),(0,j.jsxs)(`p`,{className:`muted small`,children:[`Times are in the site's time zone, `,e.timezone,`. A scheduled banner appears and comes down when the site is next rebuilt after that time.`]}),r.trim()&&(0,j.jsxs)(`div`,{className:`banner-preview ${l===`alert`?`alert`:``}`,"aria-label":`Preview`,children:[l===`alert`?(0,j.jsx)(`strong`,{children:r}):r,a&&(0,j.jsxs)(j.Fragment,{children:[` `,(0,j.jsx)(`u`,{children:s||`More`})]})]})]}),(0,j.jsx)(me,{busy:t,ready:!!r.trim()&&(m!==`later`||!!g)&&(v!==`pick`||!!b),onSend:async e=>{await n({kind:`banner`,text:r,link:a,linkText:s,tone:l,show:f,from:w,until:C},e)&&(i(``),o(``),c(``))}}),(0,j.jsx)(`h2`,{children:`On the site`}),e.banners.length===0&&(0,j.jsx)(`p`,{className:`muted`,children:`No banners.`}),(0,j.jsx)(`ul`,{className:`quick-banners`,children:e.banners.map((e,r)=>(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`span`,{className:`pill ${e.showing?`good`:e.expired?``:`warn`}`,children:e.showing?`showing`:e.expired?`over`:`scheduled`}),e.tone===`alert`&&(0,j.jsx)(`span`,{className:`pill`,children:`alert`}),(0,j.jsx)(`span`,{children:e.text}),(0,j.jsx)(`span`,{className:`muted small`,children:[e.show===`home`?`home page`:``,e.from?`from ${e.from}`:``,e.until?`until ${e.until}`:``].filter(Boolean).join(` · `)}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:t,onClick:()=>n({kind:`banner-remove`,index:r,text:e.text},!0),children:`Take down`})]},r))})]})}function L({info:e,busy:t,send:n}){let[r,i]=(0,d.useState)(e.collections.find(e=>e.name===`news`)?.name||e.collections[0]?.name||``),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(``);return e.collections.length===0?(0,j.jsx)(`p`,{className:`muted`,children:`This site has no collection for posts yet (a folder in content/, like news/).`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`form quick-form`,children:[(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Title`,(0,j.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`New winter hours`})]}),(0,j.jsxs)(`label`,{children:[`Goes in`,(0,j.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),children:e.collections.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.title},e.name))})]})]}),(0,j.jsxs)(`label`,{children:[`Summary (for lists and link previews)`,(0,j.jsx)(`input`,{value:s,onChange:e=>c(e.target.value)})]}),(0,j.jsxs)(`label`,{children:[`Text (Markdown)`,(0,j.jsx)(`textarea`,{rows:8,value:l,onChange:e=>u(e.target.value)})]})]}),(0,j.jsx)(me,{busy:t,ready:!!a.trim(),onSend:async e=>{await n({kind:`post`,collection:r,title:a,summary:s,body:l},e)&&(o(``),c(``),u(``))}})]})}function he({info:e,busy:t,send:n}){let[r,i]=(0,d.useState)(e.calendars[0]?.name||``),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(e.now.slice(0,10)),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(`18:00`),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(``),[S,C]=(0,d.useState)(``);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`form quick-form`,children:[(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`What`,(0,j.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`Spring open house`})]}),e.calendars.length>1?(0,j.jsxs)(`label`,{children:[`Calendar`,(0,j.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),children:e.calendars.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.title},e.name))})]}):(0,j.jsx)(`span`,{})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Date`,(0,j.jsx)(`input`,{type:`date`,value:s,onChange:e=>c(e.target.value)})]}),(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),` All day`]})]}),l?(0,j.jsxs)(`label`,{children:[`Last day, if it runs over several (optional)`,(0,j.jsx)(`input`,{type:`date`,value:g,min:s,onChange:e=>_(e.target.value)})]}):(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Starts`,(0,j.jsx)(`input`,{type:`time`,value:f,onChange:e=>p(e.target.value)})]}),(0,j.jsxs)(`label`,{children:[`Ends (optional)`,(0,j.jsx)(`input`,{type:`time`,value:m,onChange:e=>h(e.target.value)})]})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Where (optional)`,(0,j.jsx)(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`The Grange Hall, 12 Main St`})]}),(0,j.jsxs)(`label`,{children:[`Tickets or sign-up link (optional)`,(0,j.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:`https://…`})]})]}),(0,j.jsxs)(`label`,{children:[`About it (Markdown, optional)`,(0,j.jsx)(`textarea`,{rows:6,value:S,onChange:e=>C(e.target.value)})]}),(0,j.jsxs)(`p`,{className:`muted small`,children:[`Times are in the site's time zone, `,e.timezone,`. The event appears in the calendar feed, so subscribers see it in their calendar app.`]})]}),(0,j.jsx)(me,{busy:t,ready:!!a.trim()&&!!s&&(l||!!f),onSend:async e=>{await n({kind:`event`,collection:r,title:a,date:s,start:l?``:f,end:l?``:m,endDate:l?g:``,location:v,eventLink:b,body:S},e)&&(o(``),C(``))}})]})}function ge({id:e,busy:t,send:n}){let[r,i]=(0,d.useState)(),[a,o]=(0,d.useState)(),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(),f=()=>C.page(e,`content/index.md`).then(e=>{i(e),o(re(e.frontMatter.sections)),c(e.body)},e=>u(e.message));if((0,d.useEffect)(()=>{f()},[e]),l)return(0,j.jsx)(`p`,{className:`notice bad`,children:l});if(!r)return(0,j.jsx)(`p`,{className:`muted`,children:`Reading the home page…`});let p=a&&JSON.stringify(P(a))!==JSON.stringify(r.frontMatter.sections)||s!==r.body;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`form quick-form`,children:a?(0,j.jsx)(se,{id:e,branch:r.branch,value:a,onChange:o}):(0,j.jsxs)(`label`,{children:[`The home page (Markdown)`,(0,j.jsx)(`textarea`,{rows:14,value:s,onChange:e=>c(e.target.value)})]})}),(0,j.jsx)(me,{busy:t,ready:!!p,onSend:async e=>{await n({kind:`home`,edit:a?{set:{sections:P(a)},body:s}:{body:s},baseCommit:r.commit},e)&&f()}})]})}var _e;function ve(){let[e,t]=(0,d.useState)();(0,d.useEffect)(()=>{_e??=C.about(),_e.then(t,()=>_e=void 0)},[]);let n=e=>e.replace(/^https?:\/\//,``).replace(/\/$/,``),r=e?`${e.version}${e.revision?` · ${e.revision.slice(0,7)}`:``}${e.modified?` (modified)`:``}`:``;return(0,j.jsxs)(`footer`,{className:`bottom`,children:[(0,j.jsxs)(`span`,{children:[e?.copyright||`© 2026 Coffey Labs LLC`,` ·`,` `,(0,j.jsx)(`a`,{href:e?.companyURL||`https://coffeylabs.org`,target:`_blank`,rel:`noopener noreferrer`,children:n(e?.companyURL||`https://coffeylabs.org`)})]}),e&&(0,j.jsxs)(`span`,{className:`bottom-links`,children:[(0,j.jsxs)(`span`,{title:e.revision?`Built from ${e.revision}`:void 0,children:[e.name,` `,r]}),(0,j.jsx)(`a`,{href:e.source,target:`_blank`,rel:`noopener noreferrer`,children:`Source code`}),(0,j.jsx)(`a`,{href:e.licenseURL,target:`_blank`,rel:`noopener noreferrer`,title:`GNU Affero General Public License, version 3 or later`,children:e.license}),e.links?.map(e=>(0,j.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:e.name},e.url))]})]})}var ye=`/assets/logo-header-dark-Uv8TV887.svg`,R=`/assets/logo-header-light-MgsFviuG.svg`;function be(e){return{gitea:`Gitea`,forgejo:`Forgejo`,github:`GitHub`,gitlab:`GitLab`,bitbucket:`Bitbucket`}[e]||e}function xe({session:e,onChanged:t}){let n=(0,d.useRef)(null),r=location.pathname+location.search,i=e.accounts,a=i[0];(0,d.useEffect)(()=>{let e=e=>{n.current?.open&&!n.current.contains(e.target)&&(n.current.open=!1)},t=e=>{e.key===`Escape`&&n.current?.open&&(n.current.open=!1,n.current.querySelector(`summary`)?.focus())};return document.addEventListener(`click`,e),document.addEventListener(`focusin`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`focusin`,e),document.removeEventListener(`keydown`,t)}},[]);let o=e=>C.logout(e).then(t);return(0,j.jsxs)(`details`,{className:`accounts`,ref:n,children:[(0,j.jsx)(`summary`,{children:i.length===1?(0,j.jsxs)(j.Fragment,{children:[a.name||a.login,` `,(0,j.jsxs)(`span`,{className:`muted`,children:[`@`,a.login]})]}):(0,j.jsxs)(j.Fragment,{children:[i.length,` accounts`]})}),(0,j.jsxs)(`div`,{className:`accounts-panel`,role:`group`,"aria-label":`Accounts`,children:[(0,j.jsx)(`ul`,{children:i.map(e=>(0,j.jsxs)(`li`,{children:[(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:e.name||e.login}),(0,j.jsxs)(`span`,{className:`muted small`,children:[` @`,e.login,` · `,e.forge]})]}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>o(e.id),children:`Sign out`})]},e.id))}),(0,j.jsx)(`h3`,{className:`side-label`,children:`Add an account`}),e.forges.map(e=>{let t=i.some(t=>t.forge.toLowerCase()===e.host.toLowerCase());return(0,j.jsxs)(`div`,{className:`add-account`,children:[(0,j.jsxs)(`a`,{className:`button small`,href:w(e.host,r,t),children:[be(e.kind),` `,(0,j.jsxs)(`span`,{className:`muted-on`,children:[`· `,e.host]})]}),t&&e.kind!==`github`&&(0,j.jsxs)(`p`,{className:`muted small`,children:[e.host,` signs in whoever is signed in there. To add a different account, switch accounts on `,e.host,` first.`]})]},e.host)}),i.length>1&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small signout-all`,onClick:()=>o(),children:`Sign out of all`})]})]})}var Se=new Map;function Ce(e){let t=(0,d.useRef)(e);t.current=e,(0,d.useEffect)(()=>{let e=Symbol();return Se.set(e,t),()=>{Se.delete(e)}},[])}function we(){let e=new Set,t=[];for(let n of Se.values())for(let r of n.current())e.has(r.id)||(e.add(r.id),t.push(r));return t}function Te(e,t){let n=e.toLowerCase().trim();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);if(i>=0)return 1e3-i;let a=0,o=0,s=-1;for(let e of n){if(e===` `)continue;let t=r.indexOf(e,a);if(t<0)return-1;s>=0&&(o+=t-s-1),s=t,a=t+1}return 500-o}function Ee(e,t,n=!0){let r=(0,d.useRef)(t);r.current=t,(0,d.useEffect)(()=>{if(!n)return;let[t,i]=e.includes(`+`)?e.split(`+`):[``,e],a=e=>{(t===`mod`?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey)&&e.key.toLowerCase()===i.toLowerCase()&&(e.preventDefault(),r.current(e))};return window.addEventListener(`keydown`,a),()=>window.removeEventListener(`keydown`,a)},[e,n])}var De=()=>void 0,Oe=()=>De(),ke=`Commands (the site and branch are the ones on screen): sites the sites you can open open open a site status site, branch, account, checks pages [collection] list pages edit open a page or any file (content/about.md, site.yaml) files [text] list files, optionally only those containing text cat print a text file new "Title" start a draft with a new page (- for top level) check the branch's check results laptop: hotdog-cms check drafts open drafts and reviews branch [name] switch to a draft, or back to the published branch diff what publishing this draft would change log [file] history of the branch, or of one file review "Title" ["Notes"] open a review for this draft publish merge this draft's review, if it passes the checks pictures | look | files open those views as work on this site as another of your accounts theme light|dark|auto the editor's colors clear clear the console It never runs shell commands: the editor host is not a shell.`;function Ae(e){let t=[],n=/"([^"]*)"|'([^']*)'|(\S+)/g,r;for(;r=n.exec(e);)t.push(r[1]??r[2]??r[3]);return t}function je(){let e=O(),[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)([{kind:`hint`,text:`Type help for the commands. Esc returns to the page.`}]),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)(-1),[f,p]=(0,d.useState)(!1),m=(0,d.useRef)(null),h=(0,d.useRef)(null);De=()=>n(e=>!e),Ee("mod+`",()=>n(e=>!e)),Ce(()=>[{id:`console`,title:t?`Close the console`:`Open the console`,group:`Editor`,keys:"Ctrl+`",run:()=>n(!t)}]),(0,d.useEffect)(()=>{t&&h.current?.focus()},[t]),(0,d.useEffect)(()=>{m.current?.scrollTo(0,m.current.scrollHeight)},[r]);let g=`id`in e?e.id:void 0,_=`branch`in e?e.branch:void 0,v=(e,t=`out`)=>i(n=>[...n,{kind:t,text:e}]),y=()=>{if(!g)throw Error(`Open a site first: sites, then open .`);return g},x=async()=>C.site(y(),_),S=async t=>{let[n,...r]=Ae(t);if(n)switch(n){case`help`:return v(ke);case`clear`:return i([]);case`sites`:{let e=await C.sites();return v(e.length?e.map(e=>`${e.id.padEnd(28)} ${e.name}${e.canWrite?``:` (read only)`}`).join(` `):`No sites open to your accounts.`)}case`open`:if(!r[0])throw Error(`open `);return D({view:`site`,id:r[0]});case`status`:{let e=await x();return v(`${e.name} (${e.id})\nbranch ${e.branch}${e.branch===e.publishBranch?` (published)`:` (draft)`} at ${e.commit.slice(0,10)}\nas ${e.as}${e.canWrite?``:` (read only)`}\nchecks ${e.build.failed?`doesn't build: ${e.build.failed}`:`${e.build.errors} error(s), ${e.build.warnings} warning(s), ${e.build.pages} pages`}`)}case`pages`:{let e=((await x()).pages||[]).filter(e=>e.source&&(!r[0]||e.collection===r[0]||r[0]===`-`&&!e.collection));return v(e.map(e=>`${(e.source||``).padEnd(40)} ${e.title}`).join(` `)||`No pages.`)}case`edit`:{let e=r[0];if(!e)throw Error(`edit `);let t=y();return/^content\/.+\.md$/.test(e)?D({view:`page`,id:t,source:e,branch:_}):D({view:`files`,id:t,branch:_,path:e})}case`files`:{let e=(await C.files(y(),_)).files.filter(e=>!r[0]||e.path.includes(r[0]));return v(e.map(e=>`${e.path}${e.text?``:` (not text)`}`).join(` `)||`No files match.`)}case`cat`:{if(!r[0])throw Error(`cat `);let e=await C.file(y(),r[0],_);return v(e.exists?e.content:`No ${r[0]} on this branch.`)}case`new`:{if(r.length<2)throw Error(`new "Title" (- for a top-level page)`);let e=await C.newPage(y(),{collection:r[0]===`-`?``:r[0],title:r.slice(1).join(` `)});return v(`Started ${e.source} on ${e.branch}.`),v(`laptop: create the file under content/, then commit it to a branch`,`hint`),D({view:`page`,id:y(),source:e.source,branch:e.branch})}case`check`:{let e=await x();if(e.build.failed)return v(`This branch doesn't build: ${e.build.failed}`,`err`);let t=e.build.problems||[];return v(t.length?t.map(e=>`${e.Level.padEnd(8)} ${e.Rule.padEnd(24)} ${e.File} ${e.What}`).join(` `):`Passes every check.`),v(`${e.build.errors} error(s), ${e.build.warnings} warning(s).${e.build.errors?` Errors block publishing.`:``}`,e.build.errors?`err`:`hint`)}case`drafts`:{let e=await x(),t=(e.drafts||[]).map(t=>`${t.branch}${(e.reviews||[]).some(e=>e.branch===t.branch)?` (in review)`:``}`);return v(t.join(` `)||`No drafts.`)}case`branch`:{let t=y();if(!r[0]){let e=await x();return v(`${e.branch}${e.branch===e.publishBranch?` (published)`:` (draft)`}`)}let n=e.view===`page`||e.view===`files`||e.view===`look`||e.view===`media`?e.view:`site`,i=r[0];return n===`page`&&e.view===`page`?D({view:`page`,id:t,source:e.source,branch:i}):n===`files`&&e.view===`files`?D({view:`files`,id:t,branch:i,path:e.path}):D(n===`look`?{view:`look`,id:t,branch:i}:n===`media`?{view:`media`,id:t,branch:i}:{view:`site`,id:t,branch:i})}case`diff`:{if(!_)throw Error(`This is the published branch; switch to a draft first (branch ).`);let e=await C.compare(y(),_);return v(e.diff?`${e.stat}\n\n${e.diff}`:`Nothing differs from the published branch.`)}case`log`:{let e=await C.log(y(),_,r[0],20),t=e=>new Date(e).toLocaleString(void 0,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,timeZoneName:`short`});return v(e.commits.map(e=>`${e.sha.slice(0,8)} ${t(e.when).padEnd(24)} ${e.author.padEnd(18)} ${e.subject}`).join(` `)||`No history.`)}case`review`:{if(!_)throw Error(`Reviews are for drafts; switch to one first.`);if(!r[0])throw Error(`review "Title" ["What changed"]`);let e=await C.review(y(),{branch:_,title:r[0],description:r[1]||``});return v(`Opened review #${e.number}: ${e.url}`)}case`publish`:if(!_)throw Error(`Publishing merges a draft; switch to one first.`);return await C.publish(y(),{branch:_}),v(`Published: merged. The live site updates when its publishing pipeline runs.`),D({view:`site`,id:y()});case`pictures`:return D({view:`media`,id:y(),branch:_});case`look`:return D({view:`look`,id:y(),branch:_});case`as`:{let e=await x(),t=e.accounts.find(e=>e.login===r[0]||e.id===r[0]);if(!t)throw Error(`Not signed in as ${r[0]||`?`} with access to this site. Accounts here: ${e.accounts.map(e=>e.login).join(`, `)}`);return b(e.id,t.id),v(`Working on ${e.name} as @${t.login}.`),D({view:`site`,id:e.id,branch:_})}case`theme`:{let e=r[0];if(e!==`light`&&e!==`dark`&&e!==`auto`)throw Error(`theme light|dark|auto`);try{e===`auto`?localStorage.removeItem(`hotdog-theme`):localStorage.setItem(`hotdog-theme`,e)}catch{}return e===`auto`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e,v(`Theme: ${e}.`)}default:throw Error(`No command ${n}. Type help.`)}},w=async()=>{let e=a.trim();if(e&&!f){o(``),u(-1),c(t=>[e,...t.filter(t=>t!==e)].slice(0,50)),v(`${g?`${g}${_?`@${_}`:``}`:`~`} $ ${e}`,`in`),p(!0);try{await S(e)}catch(e){v(e.message,`err`)}finally{p(!1)}}};return t?(0,j.jsxs)(`section`,{className:`console`,"aria-label":`Console`,children:[(0,j.jsxs)(`div`,{className:`console-head`,children:[(0,j.jsx)(`strong`,{children:`Console`}),(0,j.jsxs)(`span`,{className:`muted small`,children:[g?`${g}${_?` @ ${_}`:``}`:`no site open`,` · help for commands`]}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>n(!1),"aria-label":`Close the console`,children:`Close`})]}),(0,j.jsxs)(`div`,{className:`console-out`,ref:m,role:`log`,"aria-live":`polite`,children:[r.map((e,t)=>(0,j.jsx)(`pre`,{className:`console-line ${e.kind}`,children:e.text},t)),f&&(0,j.jsx)(`pre`,{className:`console-line hint`,children:`…`})]}),(0,j.jsxs)(`form`,{className:`console-in`,onSubmit:e=>{e.preventDefault(),w()},children:[(0,j.jsx)(`span`,{"aria-hidden":`true`,children:`$`}),(0,j.jsx)(`input`,{ref:h,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`ArrowUp`){e.preventDefault();let t=Math.min(l+1,s.length-1);t>=0&&(u(t),o(s[t]))}else if(e.key===`ArrowDown`){e.preventDefault();let t=l-1;u(Math.max(t,-1)),o(t>=0?s[t]:``)}else e.key===`Escape`&&n(!1)},spellCheck:!1,autoComplete:`off`,"aria-label":`Command`})]})]}):null}function Me({diff:e,empty:t=`No changes.`}){return e.trim()?(0,j.jsx)(`pre`,{className:`diff`,"aria-label":`Changes`,children:e.split(` `).map((e,t)=>{let n=e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`h`:e.startsWith(`@@`)?`at`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:``;return(0,j.jsx)(`span`,{className:n,children:e+` `},t)})}):(0,j.jsx)(`p`,{className:`muted small`,children:t})}function Ne(e){return e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function Pe({id:e,branch:t,path:n}){let[r,i]=(0,d.useState)(),[a,o]=(0,d.useState)(),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(),[f,p]=(0,d.useState)(),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(`edit`),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(``),[S,w]=(0,d.useState)(),[T,E]=(0,d.useState)(),[O,k]=(0,d.useState)(!1),[A,ee]=(0,d.useState)(),[M,te]=(0,d.useState)(),N=(0,d.useRef)(!1),ne=()=>C.files(e,t).then(e=>i(e.files),e=>o(e.message));(0,d.useEffect)(()=>{ne(),C.site(e,t).then(u,()=>void 0)},[e,t]),(0,d.useEffect)(()=>{_(`edit`),N.current||E(void 0),N.current=!1,p(void 0),n&&C.file(e,n,t).then(e=>{p(e),h(e.content)},e=>E({kind:`bad`,text:e.message}))},[e,t,n]);let re=t||l?.publishBranch||``,P=l?re!==l.publishBranch:!1,ie=f!==void 0&&(m!==f.content||!f.exists),ae=!!l?.canWrite,F=(0,d.useMemo)(()=>(r||[]).filter(e=>!s||e.path.toLowerCase().includes(s.toLowerCase())),[r,s]),oe=r=>{if(ie&&r!==n)return ee(r);D({view:`files`,id:e,branch:t,path:r})},se=async()=>{if(n&&ie){k(!0);try{let t=await C.fileDiff(e,{branch:re,path:n,content:m});y(t.diff),x(f?.exists?`Edit ${n}`:`Add ${n}`),_(`review`)}catch(e){E({kind:`bad`,text:e.message})}finally{k(!1)}}},ce=async(r=!1)=>{if(n&&f){k(!0),E({kind:`info`,text:r?`Deleting…`:`Saving…`});try{let i=await C.fileSave(e,{branch:re,baseCommit:f.commit,path:n,content:r?void 0:m,delete:r,message:b});if(E({kind:`good`,text:`${r?`Deleted`:`Saved`} on ${i.created?`a new draft, ${i.branch}`:i.branch}.`}),i.created||i.branch!==t)N.current=!0,D({view:`files`,id:e,branch:i.branch,path:r?void 0:n});else if(r)N.current=!0,D({view:`files`,id:e,branch:t,path:void 0});else{let t=await C.file(e,n,i.branch);p(t),h(t.content),_(`edit`)}ne()}catch(e){E({kind:`bad`,text:e.message})}finally{k(!1)}}},le=async()=>{n&&(_(`history`),w(void 0),C.log(e,re,n).then(e=>w(e.commits),e=>E({kind:`bad`,text:e.message})))},ue=async()=>{_(`compare`),y(``),C.compare(e,re).then(e=>y(e.stat?`${e.stat}\n\n${e.diff}`:e.diff),e=>E({kind:`bad`,text:e.message}))};return Ee(`mod+s`,()=>g===`review`?ce():se(),!!n),Ce(()=>[...n&&ae?[{id:`files-review`,title:`Review changes and save`,group:`File`,keys:`Ctrl+S`,run:se}]:[],...n?[{id:`files-history`,title:`History of ${n}`,group:`File`,run:le}]:[],...n&&ae?[{id:`files-delete`,title:`Delete ${n}`,group:`File`,run:()=>_(`delete`)}]:[],...P?[{id:`files-compare`,title:`Compare ${re} with ${l?.publishBranch}`,group:`Draft`,run:ue}]:[],...ae?[{id:`files-new`,title:`New file…`,group:`File`,run:()=>te(``)}]:[],...(r||[]).filter(e=>e.text).map(e=>({id:`file:${e.path}`,title:e.path,group:`Open file`,run:()=>oe(e.path)}))]),a?(0,j.jsx)(`p`,{className:`pad notice bad`,role:`alert`,children:a}):(0,j.jsxs)(`div`,{className:`split files-view`,children:[(0,j.jsxs)(`aside`,{className:`side`,"aria-label":`Files`,children:[(0,j.jsxs)(`div`,{className:`side-head`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Files`}),(0,j.jsx)(`p`,{className:`muted mono small`,children:P?`${re} · draft`:`${re} · published branch`})]}),(0,j.jsx)(`input`,{className:`file-filter`,placeholder:`Filter files`,value:s,onChange:e=>c(e.target.value),"aria-label":`Filter files`}),ae&&M===void 0&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small file-new`,onClick:()=>te(``),children:`New file`}),M!==void 0&&(0,j.jsxs)(`form`,{className:`file-new-form`,onSubmit:e=>{e.preventDefault(),M.trim()&&(te(void 0),oe(M.trim()))},children:[(0,j.jsx)(`input`,{autoFocus:!0,placeholder:`data/team.yaml`,value:M,onChange:e=>te(e.target.value),"aria-label":`New file's path`}),(0,j.jsx)(`button`,{type:`submit`,className:`ghost small`,children:`Create`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>te(void 0),children:`Cancel`})]}),P&&(0,j.jsxs)(`button`,{type:`button`,className:`ghost small file-new`,onClick:ue,children:[`Compare with `,l?.publishBranch]}),!r&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:`Listing files…`}),(0,j.jsx)(`ul`,{className:`file-list`,children:F.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${e.path===n?`on`:``}`,disabled:!e.text,title:e.text?``:`Not text: change it through git`,onClick:()=>oe(e.path),children:[(0,j.jsx)(`span`,{className:`mono`,children:e.path}),` `,(0,j.jsx)(`span`,{children:Ne(e.size)})]})},e.path))})]}),(0,j.jsxs)(`section`,{className:`content file-pane`,children:[A&&(0,j.jsxs)(`div`,{className:`notice warn`,role:`alert`,children:[(0,j.jsxs)(`strong`,{children:[n,` has unsaved changes.`]}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>ee(void 0),children:`Keep editing`}),(0,j.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:()=>{let n=A;ee(void 0),p(void 0),D({view:`files`,id:e,branch:t,path:n})},children:[`Discard them and open `,A]})]})]}),T&&(0,j.jsx)(`p`,{className:`notice ${T.kind}`,role:`status`,children:T.text}),g===`compare`&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`toolbar`,children:[(0,j.jsxs)(`h2`,{children:[re,` compared with `,l?.publishBranch]}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>_(`edit`),children:`Close`})]}),(0,j.jsx)(`p`,{className:`muted small`,children:`What publishing this draft would change.`}),(0,j.jsx)(Me,{diff:v,empty:`Nothing differs from the published branch.`})]}),g!==`compare`&&!n&&(0,j.jsx)(`p`,{className:`muted`,children:`Choose a file to edit, or start a new one. Saving shows the changes first, and goes to a draft.`}),g!==`compare`&&n&&f&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`toolbar`,children:[(0,j.jsxs)(`h2`,{className:`mono`,children:[n,!f.exists&&(0,j.jsx)(`span`,{className:`pill warn`,children:`new`})]}),(0,j.jsxs)(`span`,{className:`toolbar-actions`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`button primary`,disabled:!ie||O||!ae,onClick:se,children:[`Review changes `,(0,j.jsx)(`kbd`,{children:`Ctrl+S`})]}),f.exists&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:le,children:`History`}),f.exists&&ae&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>_(`delete`),children:`Delete`})]})]}),g===`review`&&(0,j.jsxs)(`div`,{className:`review-box`,children:[(0,j.jsx)(Me,{diff:v}),(0,j.jsxs)(`label`,{className:`field`,children:[`Commit message`,(0,j.jsx)(`input`,{value:b,onChange:e=>x(e.target.value)})]}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`button primary`,disabled:O,onClick:()=>ce(),children:[P?`Save`:`Save as draft`,` `,(0,j.jsx)(`kbd`,{children:`Ctrl+S`})]}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>_(`edit`),children:`Back to editing`}),!P&&(0,j.jsx)(`span`,{className:`muted small`,children:`Starts a draft; the published site is unchanged.`})]})]}),g===`delete`&&(0,j.jsxs)(`div`,{className:`notice warn`,children:[(0,j.jsxs)(`strong`,{children:[`Delete `,n,`?`]}),` It's removed on `,P?`this draft`:`a new draft`,`, so it's back in one revert if it was a mistake.`,(0,j.jsxs)(`label`,{className:`field`,children:[`Commit message`,(0,j.jsx)(`input`,{value:b||`Delete ${n}`,onChange:e=>x(e.target.value)})]}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:O,onClick:()=>ce(!0),children:`Delete it`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>_(`edit`),children:`Cancel`})]})]}),g===`history`&&(0,j.jsxs)(`div`,{className:`history`,children:[(0,j.jsxs)(`div`,{className:`toolbar`,children:[(0,j.jsx)(`h3`,{children:`History`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>_(`edit`),children:`Close`})]}),!S&&(0,j.jsx)(`p`,{className:`muted small`,children:`Reading the history…`}),(0,j.jsx)(`ol`,{className:`commits`,children:S?.map(e=>(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`span`,{className:`mono small`,children:e.sha.slice(0,8)}),` `,e.subject,` `,(0,j.jsxs)(`span`,{className:`muted small`,children:[`· `,e.author,` · `,new Date(e.when).toLocaleString()]})]},e.sha))})]}),(0,j.jsx)(`textarea`,{className:`code file-edit`,value:m,spellCheck:!1,readOnly:!ae||g===`review`,onChange:e=>h(e.target.value),onKeyDown:e=>{if(e.key===`Tab`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault();let t=e.currentTarget,n=t.selectionStart;h(m.slice(0,n)+` `+m.slice(t.selectionEnd)),requestAnimationFrame(()=>t.setSelectionRange(n+2,n+2))}else e.key===`Escape`&&e.currentTarget.blur()},"aria-label":`Contents of ${n}`})]})]})]})}var Fe=`hotdog-split`,Ie=44,Le=25,Re=75,ze=e=>Math.min(Re,Math.max(Le,Math.round(e*10)/10));function Be(){try{let e=Number(localStorage.getItem(Fe));if(e>=Le&&e<=Re)return e}catch{}return Ie}function Ve({left:e,right:t}){let[n,r]=(0,d.useState)(Be),[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null),s=e=>{try{localStorage.setItem(Fe,String(e))}catch{}},c=e=>{let t=ze(e);r(t),s(t)},l=e=>{let t=o.current?.getBoundingClientRect();t&&t.width>0&&r(ze((e.clientX-t.left)/t.width*100))};return(0,j.jsxs)(`div`,{className:`pageview${i?` resizing`:``}`,ref:o,style:{"--split":`${n}%`},children:[e,(0,j.jsx)(`div`,{className:`divider`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the editor and preview`,"aria-valuemin":Le,"aria-valuemax":Re,"aria-valuenow":Math.round(n),tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),a(!0)},onPointerMove:e=>i&&l(e),onPointerUp:e=>{e.currentTarget.releasePointerCapture(e.pointerId),a(!1),s(n)},onPointerCancel:()=>a(!1),onDoubleClick:()=>c(Ie),onKeyDown:e=>{let t=e.shiftKey?10:2,r={ArrowLeft:n-t,ArrowRight:n+t,Home:Le,End:Re}[e.key];r!==void 0&&(e.preventDefault(),c(r))}}),t]})}var He={desktop:{w:1280,h:800,label:`Desktop`},tablet:{w:768,h:1024,label:`Tablet`},mobile:{w:390,h:844,label:`Mobile`}};function Ue(){let[e,t]=(0,d.useState)(()=>{try{let e=localStorage.getItem(`hotdog-device`);if(e===`desktop`||e===`tablet`||e===`mobile`)return e}catch{}return`desktop`});return[e,e=>{t(e);try{localStorage.setItem(`hotdog-device`,e)}catch{}}]}function We({device:e,onChange:t}){return(0,j.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`Preview size`,children:Object.keys(He).map(n=>(0,j.jsx)(`button`,{type:`button`,"aria-pressed":e===n,onClick:()=>t(n),title:`${He[n].label}, ${He[n].w}×${He[n].h}`,children:He[n].label},n))})}function Ge({src:e,device:t,title:n,reloadKey:r}){let i=(0,d.useRef)(null),[a,o]=(0,d.useState)({w:800,h:600});(0,d.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(([e])=>o({w:e.contentRect.width,h:e.contentRect.height}));return t.observe(e),()=>t.disconnect()},[]);let s=He[t],c=Math.max(100,a.w-48),l=Math.max(100,a.h-48),u=t===`desktop`?Math.min(1,c/s.w):Math.min(1,c/s.w,l/s.h),f=t===`desktop`?l/u:s.h;return(0,j.jsxs)(`div`,{className:`frame-box ${t}`,ref:i,children:[e?(0,j.jsx)(`div`,{className:`device`,style:{width:s.w*u,height:f*u},children:(0,j.jsx)(`iframe`,{title:n,src:e,sandbox:`allow-same-origin allow-scripts allow-popups allow-forms`,style:{width:s.w,height:f,transform:`scale(${u})`}},r)}):(0,j.jsx)(`p`,{className:`muted pad`,children:`No preview yet.`}),(0,j.jsxs)(`span`,{className:`frame-size muted small`,children:[s.label,` · `,s.w,`px`,u<1?` · shown at ${Math.round(u*100)}%`:``]})]})}var Ke=[`text`,`email`,`url`,`tel`,`textarea`,`select`,`checkbox`];function qe(e,t,n){if(n<0||n>=e.length)return e;let r=e.slice(),[i]=r.splice(t,1);return r.splice(n,0,i),r}function Je({id:e,branch:t,form:n}){let[r,i]=(0,d.useState)(),[a,o]=(0,d.useState)(),[s,c]=(0,d.useState)(),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(`build`),[m,h]=(0,d.useState)(),[g,_]=(0,d.useState)(),[v,y]=(0,d.useState)(),[b,x]=(0,d.useState)(0),[S,w]=Ue(),[T,E]=(0,d.useState)(!1),[O,k]=(0,d.useState)(),[A,ee]=(0,d.useState)(),[M,te]=(0,d.useState)(0),N=()=>C.forms(e,t).then(e=>{i(e.forms),o({commit:e.commit,branch:e.branch,canWrite:e.canWrite,submissions:e.submissions})},e=>h({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{N()},[e,t]),(0,d.useEffect)(()=>{let e=r?.find(e=>e.name===n);e?(c(structuredClone(e.form)),u(JSON.stringify(e.form))):n&&r?(c({to:``,fields:[{name:`email`,type:`email`,label:`Email`,required:!0}]}),u(``)):c(void 0),p(`build`),ee(void 0),te(0)},[n,r]);let ne=(0,d.useRef)(0);(0,d.useEffect)(()=>{if(s&&n&&a)return window.clearTimeout(ne.current),ne.current=window.setTimeout(()=>{C.formLive(e,{branch:a.branch,name:n,form:s}).then(e=>{if(e.error)return y(e.error);y(void 0),e.url===g?x(e=>e+1):_(e.url)},e=>y(e.message))},400),()=>window.clearTimeout(ne.current)},[s,n,a]),(0,d.useEffect)(()=>{f===`submissions`&&n&&C.submissions(e,n,M).then(ee,e=>h({kind:`bad`,text:e.message}))},[f,n,M]);let re=!!s&&JSON.stringify(s)!==l,P=e=>c(t=>({...t,...e})),ie=(e,t)=>c(n=>({...n,fields:n.fields.map((n,r)=>r===e?{...n,...t}:n)})),ae=async(r=!1)=>{if(a&&n){E(!0),h({kind:`info`,text:r?`Deleting…`:`Saving…`});try{let i=await C.formSave(e,{branch:a.branch,baseCommit:a.commit,name:n,form:r?void 0:s,delete:r});h({kind:`good`,text:`${r?`Deleted`:`Saved`} on ${i.created?`a new draft, ${i.branch}`:i.branch}.`}),D({view:`forms`,id:e,branch:i.branch,form:r?void 0:n}),!i.created&&i.branch===t&&N()}catch(e){h({kind:`bad`,text:e.message})}finally{E(!1)}}},F=!!a?.canWrite,oe=r?.find(e=>e.name===n)?.usedBy||[],se=(s?.fields||[]).filter(e=>e.type===`email`);return(0,j.jsx)(Ve,{left:(0,j.jsxs)(`section`,{className:`editor-pane forms-view`,children:[(0,j.jsx)(`div`,{className:`pane-head`,children:(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`})}),(0,j.jsx)(`h1`,{children:`Forms`}),m&&(0,j.jsx)(`p`,{className:`notice ${m.kind}`,role:`status`,children:m.text}),(0,j.jsxs)(`div`,{className:`form-list`,children:[r?.map(r=>(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r.name===n?`on`:``}`,onClick:()=>D({view:`forms`,id:e,branch:t,form:r.name}),children:[(0,j.jsx)(`span`,{children:r.form.title||r.name}),` `,(0,j.jsx)(`span`,{className:`muted small mono`,children:r.name})]},r.name)),r&&r.length===0&&(0,j.jsx)(`p`,{className:`muted small`,children:`No forms yet.`}),F&&O===void 0&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>k(``),children:`New form`}),O!==void 0&&(0,j.jsxs)(`form`,{className:`file-new-form`,onSubmit:n=>{n.preventDefault();let r=O.trim();/^[a-z][a-z0-9_]*$/.test(r)&&(k(void 0),D({view:`forms`,id:e,branch:t,form:r}))},children:[(0,j.jsx)(`input`,{autoFocus:!0,placeholder:`newsletter`,value:O,onChange:e=>k(e.target.value.toLowerCase()),"aria-label":`New form's name`}),(0,j.jsx)(`button`,{type:`submit`,className:`ghost small`,children:`Create`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>k(void 0),children:`Cancel`})]})]}),s&&n&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`toolbar`,children:[(0,j.jsx)(`h2`,{className:`mono`,children:n}),a?.submissions&&(0,j.jsxs)(`div`,{className:`seg small`,role:`tablist`,children:[(0,j.jsx)(`button`,{type:`button`,"aria-pressed":f===`build`,onClick:()=>p(`build`),children:`Form`}),(0,j.jsx)(`button`,{type:`button`,"aria-pressed":f===`submissions`,onClick:()=>p(`submissions`),children:`Submissions`})]})]}),f===`build`&&(0,j.jsxs)(`div`,{className:`form builder`,children:[oe.length===0&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`No page shows this form yet: add `,(0,j.jsxs)(`span`,{className:`mono`,children:[`form: `,n]}),` to a page's front matter.`]}),oe.length>0&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`Shown on `,oe.join(`, `),`.`]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Title`,(0,j.jsx)(`input`,{value:s.title||``,disabled:!F,onChange:e=>P({title:e.target.value})})]}),(0,j.jsxs)(`label`,{children:[`Send submissions to`,(0,j.jsx)(`input`,{value:s.to||``,disabled:!F,placeholder:`hello@example.org`,onChange:e=>P({to:e.target.value})})]})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Email subject`,(0,j.jsx)(`input`,{value:s.subject||``,disabled:!F,placeholder:`Contact from {{ .name }}`,onChange:e=>P({subject:e.target.value})})]}),(0,j.jsxs)(`label`,{children:[`Reply to`,(0,j.jsxs)(`select`,{value:s.reply_to||``,disabled:!F,onChange:e=>P({reply_to:e.target.value||void 0}),children:[(0,j.jsx)(`option`,{value:``,children:`—`}),se.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Button`,(0,j.jsx)(`input`,{value:s.submit||``,disabled:!F,placeholder:`Send`,onChange:e=>P({submit:e.target.value})})]}),(0,j.jsxs)(`label`,{children:[`After sending, go to`,(0,j.jsx)(`input`,{value:s.success||``,disabled:!F,placeholder:`/thanks/`,onChange:e=>P({success:e.target.value})})]})]}),(0,j.jsxs)(`label`,{children:[`Address shown without JavaScript`,(0,j.jsx)(`input`,{value:s.mailto||``,disabled:!F,placeholder:`hello@example.org`,onChange:e=>P({mailto:e.target.value})})]}),(0,j.jsxs)(`label`,{children:[`Cloudflare Turnstile site key`,(0,j.jsx)(`input`,{value:s.turnstile_sitekey||``,disabled:!F,placeholder:`Optional`,onChange:e=>P({turnstile_sitekey:e.target.value})})]}),(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:!!s.store,disabled:!F,onChange:e=>P({store:e.target.checked||void 0})}),` Also keep submissions on the server (readable here, if the editor is set up for it)`]}),(0,j.jsx)(`h3`,{className:`side-label`,children:`Fields`}),(0,j.jsx)(`ol`,{className:`list-items`,children:s.fields.map((e,t)=>(0,j.jsxs)(`li`,{className:`list-item field-card`,children:[(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Label`,(0,j.jsx)(`input`,{value:e.label||``,disabled:!F,onChange:e=>ie(t,{label:e.target.value})})]}),(0,j.jsxs)(`label`,{children:[`Name`,(0,j.jsx)(`input`,{value:e.name,disabled:!F,className:`mono`,onChange:e=>ie(t,{name:e.target.value.toLowerCase().replace(/[^a-z0-9_]/g,`_`)})})]})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Kind`,(0,j.jsx)(`select`,{value:e.type||`text`,disabled:!F,onChange:e=>ie(t,{type:e.target.value===`text`?void 0:e.target.value}),children:Ke.map(e=>(0,j.jsx)(`option`,{value:e,children:e},e))})]}),(0,j.jsxs)(`label`,{children:[`Placeholder`,(0,j.jsx)(`input`,{value:e.placeholder||``,disabled:!F,onChange:e=>ie(t,{placeholder:e.target.value})})]})]}),e.type===`select`&&(0,j.jsxs)(`label`,{children:[`Choices, one per line`,(0,j.jsx)(`textarea`,{rows:3,value:(e.options||[]).join(` `),disabled:!F,onChange:e=>ie(t,{options:e.target.value.split(` `).map(e=>e.trim()).filter(Boolean)})})]}),(0,j.jsxs)(`label`,{children:[`Help`,(0,j.jsx)(`input`,{value:e.help||``,disabled:!F,onChange:e=>ie(t,{help:e.target.value})})]}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:!!e.required,disabled:!F,onChange:e=>ie(t,{required:e.target.checked||void 0})}),` Required`]}),(0,j.jsxs)(`label`,{className:`inline`,children:[`Most characters`,(0,j.jsx)(`input`,{type:`number`,min:1,value:e.max||``,disabled:!F,onChange:e=>ie(t,{max:e.target.value?Number(e.target.value):void 0})})]}),F&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:t===0,onClick:()=>P({fields:qe(s.fields,t,t-1)}),"aria-label":`Move up`,children:`↑`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:t===s.fields.length-1,onClick:()=>P({fields:qe(s.fields,t,t+1)}),"aria-label":`Move down`,children:`↓`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>P({fields:s.fields.filter((e,n)=>n!==t)}),children:`Remove`})]})]})]},t))}),F&&(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>P({fields:[...s.fields,{name:`field_${s.fields.length+1}`,label:`New field`}]}),children:`Add a field`}),(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!re||T,onClick:()=>ae(),children:a?.branch===t?`Save`:`Save as draft`}),l&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:T,onClick:()=>ae(!0),children:`Delete form`})]})]}),f===`submissions`&&(0,j.jsxs)(`div`,{className:`subs`,children:[!A&&(0,j.jsx)(`p`,{className:`muted`,children:`Reading submissions…`}),A&&A.total===0&&(0,j.jsx)(`p`,{className:`muted`,children:`No submissions kept for this form.`}),A&&A.submissions.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`p`,{className:`muted small`,children:[A.total,` kept, newest first. Read from the endpoint's private viewer; the public site can't show them.`]}),(0,j.jsx)(`div`,{className:`table-wrap`,children:(0,j.jsxs)(`table`,{className:`pages`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`When`}),(A.fields||[]).map(e=>(0,j.jsx)(`th`,{children:e.label||e.name},e.name))]})}),(0,j.jsx)(`tbody`,{children:A.submissions.map((e,t)=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{className:`small`,children:new Date(e.time).toLocaleString()}),(A.fields||[]).map(t=>(0,j.jsx)(`td`,{className:`small sub-cell`,children:e.values[t.name]},t.name))]},t))})]})}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:M===0,onClick:()=>te(Math.max(0,M-50)),children:`Newer`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:M+50>=A.total,onClick:()=>te(M+50),children:`Older`})]})]})]})]}),!n&&r&&r.length>0&&(0,j.jsx)(`p`,{className:`muted`,children:`Choose a form to change it.`})]}),right:(0,j.jsxs)(`section`,{className:`preview-pane`,"aria-label":`Preview`,children:[(0,j.jsx)(`div`,{className:`preview-bar`,children:(0,j.jsx)(We,{device:S,onChange:w})}),v&&(0,j.jsx)(`p`,{className:`notice warn small preview-note`,children:v}),(0,j.jsx)(Ge,{src:g,device:S,title:`Preview of the form`,reloadKey:b})]})})}function Ye({id:e}){let[t,n]=(0,d.useState)(),[r,i]=(0,d.useState)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)();(0,d.useEffect)(()=>{C.site(e).then(e=>o(e.canWrite),()=>void 0),C.log(e,void 0,void 0,50).then(e=>n(e.commits),e=>i({kind:`bad`,text:e.message}))},[e]);let l=async t=>{c(t.sha),i({kind:`info`,text:`Undoing "${t.subject}"…`});try{let n=await C.revert(e,t.sha);i({kind:`good`,text:`"${t.subject}" is undone on a new draft, ${n.branch}. Look it over, then submit it for review and publish.`,branch:n.branch})}catch(e){i({kind:`bad`,text:e.message})}finally{c(void 0)}};return(0,j.jsxs)(`section`,{className:`pad history`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:t=>{t.preventDefault(),D({view:`site`,id:e})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`History`}),(0,j.jsx)(`p`,{className:`muted`,children:`Every change that reached the published site, newest first. Undoing one makes a draft that reverses it; nothing changes until that's published.`}),r&&(0,j.jsxs)(`p`,{className:`notice ${r.kind}`,role:`status`,children:[r.text,r.branch&&(0,j.jsxs)(j.Fragment,{children:[` `,(0,j.jsx)(`a`,{href:`#`,onClick:t=>{t.preventDefault(),D({view:`site`,id:e,branch:r.branch})},children:`Open the draft`})]})]}),!t&&!r&&(0,j.jsx)(`p`,{className:`muted`,children:`Reading the history…`}),(0,j.jsx)(`ol`,{className:`commit-list`,children:t?.map(e=>(0,j.jsxs)(`li`,{children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`strong`,{children:e.subject}),(0,j.jsxs)(`span`,{className:`muted small`,children:[` `,e.author,` · `,new Date(e.when).toLocaleString(),` · `,(0,j.jsx)(`span`,{className:`mono`,children:e.sha.slice(0,8)})]})]}),a&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:!!s,onClick:()=>l(e),children:s===e.sha?`Undoing…`:`Undo on a draft`})]},e.sha))})]})}function Xe({id:e,url:t,branch:n}){let[r,i]=Ue(),[a,o]=(0,d.useState)(0);return(0,d.useEffect)(()=>{let e=Ze();if(e)return e.onmessage=e=>{e.data?.url===t&&o(e=>e+1)},()=>e.close()},[t]),(0,j.jsxs)(`div`,{className:`present`,children:[(0,j.jsxs)(`div`,{className:`preview-bar`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>window.opener?window.close():history.length>1?history.back():D({view:`site`,id:e,branch:n}),children:`← Back to editing`}),(0,j.jsx)(`span`,{className:`spacer`}),(0,j.jsx)(We,{device:r,onChange:i}),(0,j.jsx)(`span`,{className:`spacer`}),(0,j.jsx)(`a`,{className:`ghost small linkbtn`,href:t,target:`_blank`,rel:`noopener noreferrer`,children:`Open ↗`})]}),(0,j.jsx)(Ge,{src:t,device:r,title:`Presentation preview`,reloadKey:a})]})}function Ze(){return typeof BroadcastChannel>`u`?void 0:new BroadcastChannel(`hotdog-live`)}var Qe=60,$e=160;function et({id:e,branch:t,seo:n,siteURL:r,path:i}){let a=r.replace(/\/$/,``)+i,o=n.image,s=o&&o.startsWith(`/media/`),c=[];return n.title?n.title.length>Qe&&c.push(`The title is ${n.title.length} characters; search results show about ${Qe}, so the end may be cut.`):c.push(`No title.`),n.description?n.description.length>$e&&c.push(`The description is ${n.description.length} characters; results show about ${$e}.`):c.push(`No description: search engines will pick some text from the page. Add a summary.`),o?n.imageAlt||c.push(`The preview picture has no description (image_alt).`):c.push(`No picture for link previews: set image in the front matter.`),(0,j.jsxs)(`details`,{className:`seo`,children:[(0,j.jsxs)(`summary`,{children:[(0,j.jsx)(`strong`,{children:`Search and social`}),(0,j.jsxs)(`span`,{className:`muted small`,children:[` `,n.noindex?`hidden from search engines`:c.length?`${c.length} thing${c.length===1?``:`s`} to look at`:`looks good`]})]}),n.noindex&&(0,j.jsx)(`p`,{className:`notice warn small`,children:`This page asks search engines not to list it (noindex).`}),(0,j.jsxs)(`div`,{className:`serp`,"aria-label":`As a search result`,children:[(0,j.jsx)(`span`,{className:`serp-url`,children:a}),(0,j.jsx)(`span`,{className:`serp-title`,children:n.title.length>Qe?n.title.slice(0,59)+`…`:n.title||`(no title)`}),(0,j.jsx)(`span`,{className:`serp-desc`,children:n.description?n.description.length>$e?n.description.slice(0,159)+`…`:n.description:(0,j.jsx)(`em`,{className:`muted`,children:`No description`})})]}),(0,j.jsxs)(`div`,{className:`card-preview`,"aria-label":`As a link preview`,children:[(0,j.jsx)(`div`,{className:`card-img`,children:s?(0,j.jsx)(`img`,{src:C.mediaFile(e,o,t),alt:``}):o?(0,j.jsx)(`span`,{className:`muted small mono`,children:o}):(0,j.jsx)(`span`,{className:`muted small`,children:`No picture`})}),(0,j.jsxs)(`div`,{className:`card-text`,children:[(0,j.jsx)(`span`,{className:`muted small`,children:new URL(a).host}),(0,j.jsx)(`strong`,{children:n.title||`(no title)`}),n.description&&(0,j.jsx)(`span`,{className:`small`,children:n.description})]})]}),(0,j.jsx)(`p`,{className:`muted small`,children:`Mastodon, LinkedIn and Bluesky show the picture above the title like this; a picture 1200×630 suits them all.`}),c.length>0&&(0,j.jsx)(`ul`,{className:`seo-notes`,children:c.map(e=>(0,j.jsx)(`li`,{children:e},e))})]})}function tt(e,t,n){return[e.trim(),t.trim(),n].filter(Boolean).join(` `)}function nt(e){let t=e.trim().toLowerCase().replace(/^https?:\/\//,``).replace(/\/.*$/,``);return t.includes(`@`)&&(t=t.slice(t.lastIndexOf(`@`)+1)),/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}(?::\d{1,5})?$/.test(t)?t:``}function rt(e,t){return`https://${e}/share?text=${encodeURIComponent(t)}`}function it(e){return`https://bsky.app/intent/compose?text=${encodeURIComponent(e)}`}function at(e){return`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(e)}`}function ot(e){if(typeof Intl<`u`&&`Segmenter`in Intl){let t=0;for(let n of new Intl.Segmenter(void 0,{granularity:`grapheme`}).segment(e))t++;return t}return[...e].length}var st=`hotdog-mastodon`;function ct(){try{return localStorage.getItem(st)||``}catch{return``}}function lt({title:e,summary:t,url:n,onClose:r}){let[i,a]=(0,d.useState)(()=>tt(e,t,n)),[o,s]=(0,d.useState)(ct),[c,l]=(0,d.useState)(!1),u=nt(o),f=ot(i),p=e=>window.open(e,`_blank`,`noopener,noreferrer`);return(0,j.jsxs)(`div`,{className:`share-panel form`,role:`group`,"aria-label":`Share this page`,children:[(0,j.jsxs)(`div`,{className:`library-head`,children:[(0,j.jsx)(`strong`,{children:`Share`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:r,children:`Close`})]}),(0,j.jsx)(`p`,{className:`muted small`,children:`Each button opens the network's own share page with this filled in; you post it from your account there. Share once the live site shows the change.`}),(0,j.jsxs)(`label`,{children:[`Post`,(0,j.jsx)(`textarea`,{rows:5,value:i,onChange:e=>a(e.target.value)})]}),(0,j.jsxs)(`p`,{className:`small ${f>300?`bad-text`:`muted`}`,children:[f,` characters`,f>300?`: Bluesky allows 300`:``]}),(0,j.jsxs)(`div`,{className:`share-row`,children:[(0,j.jsxs)(`label`,{className:`share-server`,children:[`Mastodon server`,(0,j.jsx)(`input`,{value:o,placeholder:`mastodon.social`,onChange:e=>s(e.target.value),spellCheck:!1})]}),(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:!u||!i.trim(),onClick:()=>{try{localStorage.setItem(st,u)}catch{}p(rt(u,i))},children:`Mastodon ↗`})]}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:!i.trim()||f>300,onClick:()=>p(it(i)),children:`Bluesky ↗`}),(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>p(at(n)),title:`LinkedIn takes the link and reads the title and picture from the page; copy the text to add it`,children:`LinkedIn ↗`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:async()=>{try{await navigator.clipboard.writeText(i),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},children:c?`Copied`:`Copy text`})]})]})}var ut=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),dt=function(e){return`/`+e},ft={},pt=function(e){return e.pathname.endsWith(`.css`)},mt=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ht=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=dt(t,n);let r=s(t),i=pt(r);return mt(ft,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ut,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},gt=(0,d.lazy)(()=>ht(()=>import(`./VisualEditor-CVNb9YbH.js`).then(e=>({default:e.VisualEditor})),__vite__mapDeps([0,1]))),_t=[`title`,`summary`,`date`,`tags`,`image`,`image_alt`,`draft`,`publish_at`];function vt(e){return e==null?``:typeof e==`string`?e:String(e)}function yt(e){let t=vt(e);return/^\d{4}-\d{2}-\d{2}/.test(t)?t.slice(0,10):t}function bt(e){let t=vt(e);if(!t)return``;let n=new Date(t);if(isNaN(n.getTime()))return``;let r=e=>String(e).padStart(2,`0`);return`${n.getFullYear()}-${r(n.getMonth()+1)}-${r(n.getDate())}T${r(n.getHours())}:${r(n.getMinutes())}`}function xt(e){let t=Array.isArray(e.tags)?e.tags.map(vt).join(`, `):vt(e.tags);return{title:vt(e.title),summary:vt(e.summary),date:yt(e.date),tags:t,image:vt(e.image),image_alt:vt(e.image_alt),draft:e.draft===!0,publish_at:bt(e.publish_at)}}function St(e,t,n){let r={};for(let i of _t){if(e[i]===t[i])continue;let a=t[i];i===`draft`?r.draft=a?!0:null:i===`tags`?r.tags=a.trim()?a.split(`,`).map(e=>e.trim()).filter(Boolean):null:i===`publish_at`?r.publish_at=a?new Date(a).toISOString().replace(`.000Z`,`Z`):null:r[i]=a.trim()?a:i in n?null:void 0}for(let e of Object.keys(r))r[e]===void 0&&delete r[e];return r}function Ct({id:e,source:t,branch:n,site:r,onSiteChanged:i}){let[a,o]=(0,d.useState)(),[s,c]=(0,d.useState)(),[l,u]=(0,d.useState)(),[f,p]=(0,d.useState)(``),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(),[S,w]=(0,d.useState)(!1),[T,O]=(0,d.useState)(!1),[k,A]=(0,d.useState)(),[ee,M]=(0,d.useState)(),[N,ne]=(0,d.useState)(0),[ie,ae]=Ue(),[F,oe]=(0,d.useState)(!1),[ce,le]=(0,d.useState)(),[ue,de]=(0,d.useState)(),[fe,pe]=(0,d.useState)(),[me,I]=(0,d.useState)(()=>{try{return localStorage.getItem(`hotdog-body-mode`)===`visual`?`visual`:`markdown`}catch{return`markdown`}}),L=e=>{I(e);try{localStorage.setItem(`hotdog-body-mode`,e)}catch{}},he=(0,d.useRef)(null),[ge,_e]=(0,d.useState)(!1),[ve,ye]=(0,d.useState)(),[R,be]=(0,d.useState)(),xe=(0,d.useRef)(null),Se=(0,d.useRef)(void 0),we=(0,d.useRef)(void 0),Te=n||r?.publishBranch||``;(0,d.useEffect)(()=>{o(void 0),C.page(e,t,n).then(e=>{o(e);let t=Se.current;Se.current=void 0,u(t?t.fields:xt(e.frontMatter)),p(t?t.body:e.body),y(t?t.yaml:e.frontMatterRaw),_(t?t.yamlMode:!1),pe(t?t.secs:re(e.frontMatter.sections))},e=>c(e.message))},[e,t,n]);let De=(0,d.useMemo)(()=>a?xt(a.frontMatter):void 0,[a]),Oe=(0,d.useMemo)(()=>{if(!a||!l||!De)return null;if(g)return v===a.frontMatterRaw&&f===a.body?null:{frontMatter:v,body:f};let e=St(De,l,a.frontMatter);if(fe){let t=P(fe);JSON.stringify(t)!==JSON.stringify(a.frontMatter.sections??null)&&(e.sections=t.length?t:null)}return Object.keys(e).length===0&&f===a.body?null:{set:e,body:f}},[a,l,De,f,v,g,fe]),ke=Oe!==null,Ae=(0,d.useRef)(0),je=(0,d.useRef)(void 0);(0,d.useEffect)(()=>(je.current=Ze(),()=>je.current?.close()),[]);let Me=(0,d.useCallback)(n=>{a&&C.live(e,{source:t,branch:Te,edit:n}).then(e=>{e.error?M(`The preview shows the last version that rendered. ${e.error}`):(M(void 0),e.seo&&e.siteURL&&e.path&&be({seo:e.seo,siteURL:e.siteURL,path:e.path}),e.url===k?ne(e=>e+1):A(e.url),je.current?.postMessage({url:e.url}))},e=>M(e.message))},[e,t,Te,a,k]);(0,d.useEffect)(()=>{if(a)return window.clearTimeout(Ae.current),Ae.current=window.setTimeout(()=>Me(Oe),Oe?600:0),()=>window.clearTimeout(Ae.current)},[Oe,a]),(0,d.useEffect)(()=>{let e=e=>{ke&&e.preventDefault()};return addEventListener(`beforeunload`,e),()=>removeEventListener(`beforeunload`,e)},[ke]);let Ne=r?.pages?.find(e=>e.source===t)?.path,Pe=Ne?Ne.endsWith(`/`)?`public${Ne}index.html`:`public${Ne}`:``,Fe=(r?.build.problems||[]).filter(e=>e.File===Pe||e.File.startsWith(t)),Ie=r?.reviews?.find(e=>e.branch===Te),Le=r?Te!==r.publishBranch:!1,Re=r?.canWrite,ze=r?.siteURL&&Ne?r.siteURL.replace(/\/+$/,``)+Ne:``,Be=!Le&&!!l&&!l.draft&&!!ze,He=async()=>{if(a&&Oe){O(!0),x({kind:`info`,text:`Saving…`});try{let r=await C.save(e,{source:t,branch:Te,baseCommit:a.commit,edit:Oe});if(x({kind:`good`,text:r.created?`Saved. Your change is on a new draft, ${r.branch}; the published site is unchanged.`:`Saved to ${r.branch}.`}),i(),r.created||r.branch!==n)D({view:`page`,id:e,source:t,branch:r.branch});else{let n=await C.page(e,t,r.branch);o(n),u(xt(n.frontMatter)),p(n.body),y(n.frontMatterRaw),pe(re(n.frontMatter.sections))}}catch(e){x({kind:`bad`,text:e instanceof m?e.message:`Not saved: ${e.message}`})}finally{O(!1)}}},Ke=n=>{let r,s=me===`visual`&&he.current,c=/^!\[([^\]]*)\]\(([^)]+)\)$/.exec(n);if(s&&c)r=he.current.insertImage(c[2],c[1]);else{let e=xe.current,t=e?e.selectionStart:f.length,i=f.slice(0,t),a=f.slice(t),o=i===``||i.endsWith(` `)?``:i.endsWith(` `)?` `:` `,s=a.startsWith(` `)?``:a.startsWith(` `)||a===``?` `:` `;r=i+o+n+s+a}p(r),de(void 0);let u=we.current;if(we.current=void 0,!u)return;let d=(u.notes||[]).join(` `);x({kind:`good`,text:`Added ${u.url}${u.created?` on a new draft, ${u.branch}`:``}. ${d} Save to keep it in the page.`.trim()}),i(),u.created||u.branch!==Te?(l&&(Se.current={fields:l,body:r,yaml:v,yamlMode:g,secs:fe}),D({view:`page`,id:e,source:t,branch:u.branch})):a&&o({...a,commit:u.commit})},qe=(0,d.useRef)(void 0),Je=async n=>{let r=await C.upload(e,n,{branch:Te,baseCommit:a?.commit||``,source:t});return qe.current=r,r.url};(0,d.useEffect)(()=>{let n=qe.current;if(!n)return;qe.current=void 0;let r=(n.notes||[]).join(` `);x({kind:`good`,text:`Added ${n.url}${n.created?` on a new draft, ${n.branch}`:``}. ${r} Save to keep it in the page.`.trim()}),i(),n.created||n.branch!==Te?(l&&(Se.current={fields:l,body:f,yaml:v,yamlMode:g,secs:fe}),D({view:`page`,id:e,source:t,branch:n.branch})):a&&o({...a,commit:n.commit})},[fe]);let Ye=async()=>{O(!0),x({kind:`info`,text:`Checking the draft and publishing…`}),le(void 0);try{await C.publish(e,{branch:Te}),x({kind:`good`,text:`Published: the change is merged. The live site updates when its publishing pipeline runs.`}),w(!0),r&&D({view:`page`,id:e,source:t,branch:r.publishBranch}),i()}catch(e){e instanceof h&&le(e.problems),x({kind:`bad`,text:e.message})}finally{O(!1)}},Xe=k?new URL(k).origin:``,Qe=e=>{let t=document.querySelector(`.preview-pane iframe`);t?.contentWindow&&Xe&&t.contentWindow.postMessage({type:`hotdog:point`,on:e},Xe)};if((0,d.useEffect)(()=>{let e=e=>{if(!Xe||e.origin!==Xe||!e.data||typeof e.data!=`object`||(e.data.type===`hotdog:ready`&&Qe(ge),e.data.type!==`hotdog:jump`||typeof e.data.text!=`string`))return;let t=e.data.text.slice(0,200);if(me===`visual`&&he.current){he.current.jumpTo(t)||x({kind:`info`,text:`"${t.slice(0,60)}" isn't in the body; it comes from the front matter, a section or the template.`});return}let n=xe.current;if(!n)return;let r=f.toLowerCase(),i=t.toLowerCase().split(` `),a=-1;for(let e of[t.toLowerCase().slice(0,40),i.slice(0,4).join(` `),i.slice(0,2).join(` `)])if(e.length>=3&&(a=r.indexOf(e))>=0)break;if(a<0){x({kind:`info`,text:`"${t.slice(0,60)}" isn't in the body; it comes from the front matter, a section or the template.`});return}n.focus(),n.setSelectionRange(a,a+Math.min(t.length,f.length-a));let o=f.slice(0,a).split(` `).length;n.scrollTop=Math.max(0,(o-3)*parseFloat(getComputedStyle(n).lineHeight||`20`))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[Xe,ge,me,f]),(0,d.useEffect)(()=>Qe(ge),[ge,k]),Ee(`mod+s`,()=>ke&&!T&&Re&&He(),!!a),Ce(()=>a?[...Re&&ke?[{id:`page-save`,title:Le?`Save`:`Save as draft`,group:`Page`,keys:`Ctrl+S`,run:He}]:[],...Re?[{id:`page-picture`,title:`Insert picture`,group:`Page`,run:()=>de({})}]:[],{id:`page-mode`,title:me===`visual`?`Edit the body as Markdown`:`Edit the body visually`,group:`Page`,run:()=>L(me===`visual`?`markdown`:`visual`)},...k?[{id:`page-point`,title:ge?`Stop pointing in the preview`:`Point and edit: click text in the preview`,group:`Page`,run:()=>_e(!ge)}]:[],{id:`page-yaml`,title:g?`Edit front matter as fields`:`Edit front matter as YAML`,group:`Page`,run:()=>_(!g)},...Le&&!Ie&&Re&&!ke?[{id:`page-review`,title:`Submit for review`,group:`Page`,run:()=>oe(!0)}]:[],...Le&&Ie&&Re&&!ke?[{id:`page-publish`,title:`Publish`,group:`Page`,run:Ye}]:[],...Be&&!ke?[{id:`page-share`,title:`Share this page`,group:`Page`,run:()=>w(!0)}]:[],...k?[{id:`page-present`,title:`Present in a new tab`,group:`Page`,run:()=>window.open(E({view:`present`,id:e,url:k,branch:n}),`_blank`,`noopener`)}]:[],{id:`page-file`,title:`Edit ${t} as a raw file`,group:`Page`,run:()=>D({view:`files`,id:e,branch:n,path:t})}]:[]),s)return(0,j.jsx)(`div`,{className:`pad notice bad`,role:`alert`,children:s});if(!a||!l)return(0,j.jsx)(`p`,{className:`pad muted`,children:`Loading the page…`});let $e=Object.keys(a.frontMatter).filter(e=>!_t.includes(e)&&!(e===`sections`&&fe)),tt=e=>t=>u({...l,[e]:t.target.type===`checkbox`?!!t.target.checked:t.target.value});return(0,j.jsx)(Ve,{left:(0,j.jsxs)(`section`,{className:`editor-pane`,children:[(0,j.jsxs)(`div`,{className:`pane-head`,children:[(0,j.jsxs)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}${n?`?branch=${encodeURIComponent(n)}`:``}`,onClick:t=>{t.preventDefault(),D({view:`site`,id:e,branch:n})},children:[`← `,r?.name||`Site`]}),(0,j.jsxs)(`span`,{className:`pane-pills`,children:[r&&r.accounts.length>1&&(0,j.jsxs)(`span`,{className:`pill`,title:`Change it in the site view`,children:[`as @`,r.as.split(`/`).pop()]}),(0,j.jsx)(`span`,{className:`pill ${Le?`warn`:``}`,children:Le?`draft: ${Te}`:`${Te} · published`})]})]}),(0,j.jsx)(`h1`,{children:l.title||t}),(0,j.jsxs)(`p`,{className:`muted mono small`,children:[t,Ne?` → ${Ne}`:``,Re&&ve===void 0&&t!==`content/index.md`&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small move-btn`,onClick:()=>ye(Ne||``),children:`Move…`})]}),ve!==void 0&&(0,j.jsx)(Tt,{id:e,source:t,branch:Te,baseCommit:a.commit,current:Ne||``,value:ve,dirty:ke,onChange:ye,onDone:t=>{ye(void 0),x({kind:`good`,text:`Moved to ${t.to}${t.redirected?`; ${t.from} now redirects there`:``}.${t.created?` On a new draft, ${t.branch}.`:``}`}),i(),D({view:`page`,id:e,source:t.source,branch:t.branch})}}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!ke||T||!Re,onClick:He,children:Le?`Save`:`Save as draft`}),Le&&!Ie&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:T||ke||!Re,onClick:()=>oe(!F),children:`Submit for review`}),Le&&Ie&&(0,j.jsxs)(`a`,{className:`button`,href:Ie.url,target:`_blank`,rel:`noopener noreferrer`,children:[`Review #`,Ie.number,` ↗`]}),Le&&Ie&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:T||ke||!Re,onClick:Ye,title:`Merges the review, if the draft passes the checks`,children:`Publish`}),Be&&!S&&(0,j.jsx)(`button`,{type:`button`,className:`ghost`,disabled:ke,onClick:()=>w(!0),title:`Post a link to this page on Mastodon, Bluesky or LinkedIn`,children:`Share…`}),!Re&&(0,j.jsx)(`span`,{className:`muted small`,children:`Read only: the platform doesn't let you change this site.`}),ke&&(0,j.jsx)(`span`,{className:`muted small`,children:`Unsaved changes`})]}),b&&(0,j.jsx)(`p`,{className:`notice ${b.kind}`,role:`status`,children:b.text}),ce&&ce.length>0&&(0,j.jsx)(`ul`,{className:`problems`,children:ce.filter(e=>e.Level===`error`).map((e,t)=>(0,j.jsxs)(`li`,{className:`error`,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,(0,j.jsx)(`span`,{className:`mono small`,children:e.File}),` `,e.What]},t))}),S&&Be&&(0,j.jsx)(lt,{title:t===`content/index.md`&&r?.siteName||l.title,summary:l.summary,url:ze,onClose:()=>w(!1)}),F&&(0,j.jsx)(wt,{id:e,branch:Te,title:l.title,onDone:e=>{oe(!1),x({kind:`good`,text:e}),i()},onError:e=>x({kind:`bad`,text:e})}),Fe.length>0&&(0,j.jsxs)(`div`,{className:`notice warn`,children:[(0,j.jsx)(`strong`,{children:`Checks on this page`}),(0,j.jsx)(`ul`,{className:`problems`,children:Fe.map((e,t)=>(0,j.jsxs)(`li`,{className:e.Level,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,e.What,e.Fix&&(0,j.jsx)(`span`,{className:`fix`,children:e.Fix})]},t))})]}),R&&(0,j.jsx)(et,{id:e,branch:Te,seo:R.seo,siteURL:R.siteURL,path:R.path}),(0,j.jsxs)(`div`,{className:`fm-head`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Front matter`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>_(!g),children:g?`Edit as fields`:`Edit as YAML`})]}),g?(0,j.jsx)(`textarea`,{className:`code`,rows:10,value:v,onChange:e=>y(e.target.value),spellCheck:!1,"aria-label":`Front matter as YAML`}):(0,j.jsxs)(`div`,{className:`form`,children:[(0,j.jsxs)(`label`,{children:[`Title`,(0,j.jsx)(`input`,{value:l.title,onChange:tt(`title`)})]}),(0,j.jsxs)(`label`,{children:[`Summary`,(0,j.jsx)(`textarea`,{rows:2,value:l.summary,onChange:tt(`summary`)})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Date`,(0,j.jsx)(`input`,{type:`date`,value:l.date,onChange:tt(`date`)})]}),(0,j.jsxs)(`label`,{children:[`Publish at`,(0,j.jsx)(`input`,{type:`datetime-local`,value:l.publish_at,onChange:tt(`publish_at`)})]})]}),(0,j.jsxs)(`label`,{children:[`Tags `,(0,j.jsx)(`span`,{className:`muted small`,children:`comma-separated`}),(0,j.jsx)(`input`,{value:l.tags,onChange:tt(`tags`)})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Image`,(0,j.jsx)(`input`,{value:l.image,onChange:tt(`image`),placeholder:`/img/…`})]}),(0,j.jsxs)(`label`,{children:[`Image alt text`,(0,j.jsx)(`input`,{value:l.image_alt,onChange:tt(`image_alt`)})]})]}),(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:l.draft,onChange:tt(`draft`)}),` Keep out of the published site (draft)`]}),$e.length>0&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`Other fields (`,$e.join(`, `),`) are kept as they are; edit them as YAML.`]})]}),fe&&!g&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`h2`,{className:`side-label`,children:[`Sections `,(0,j.jsx)(`span`,{className:`muted small`,children:`the page, top to bottom`})]}),(0,j.jsx)(se,{id:e,branch:Te,value:fe,onChange:pe,disabled:!Re,upload:Je})]}),(0,j.jsxs)(`div`,{className:`body-head`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Body`}),(0,j.jsxs)(`div`,{className:`seg small`,role:`group`,"aria-label":`Edit the body as`,children:[(0,j.jsx)(`button`,{type:`button`,"aria-pressed":me===`markdown`,onClick:()=>L(`markdown`),children:`Markdown`}),(0,j.jsx)(`button`,{type:`button`,"aria-pressed":me===`visual`,onClick:()=>L(`visual`),children:`Visual`})]}),Re&&me===`markdown`&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>de({}),children:`Insert picture`})]}),me===`visual`&&(0,j.jsx)(d.Suspense,{fallback:(0,j.jsx)(`p`,{className:`muted small`,children:`Loading the visual editor…`}),children:(0,j.jsx)(gt,{ref:he,value:f,onChange:p,onPicture:e=>de({file:e}),disabled:!Re})}),me===`markdown`&&(0,j.jsx)(`textarea`,{ref:xe,className:`code body-edit`,value:f,onChange:e=>p(e.target.value),onDragOver:e=>Re&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault(),onDrop:e=>{let t=Array.from(e.dataTransfer.files).find(e=>`image/jpeg,image/png,image/gif,image/webp`.split(`,`).includes(e.type));t&&Re&&(e.preventDefault(),de({file:t}))},onPaste:e=>{let t=Array.from(e.clipboardData.files).find(e=>`image/jpeg,image/png,image/gif,image/webp`.split(`,`).includes(e.type));t&&Re&&(e.preventDefault(),de({file:t}))},spellCheck:!0,"aria-label":`Page body, Markdown`}),ue&&(0,j.jsx)(te,{id:e,branch:Te,baseCommit:a.commit,source:t,onDraft:Le,file:ue.file,onUploaded:e=>we.current=e,onInsert:Ke,onClose:()=>de(void 0)})]}),right:(0,j.jsxs)(`section`,{className:`preview-pane`,"aria-label":`Preview`,children:[(0,j.jsxs)(`div`,{className:`preview-bar`,children:[(0,j.jsx)(We,{device:ie,onChange:ae}),(0,j.jsx)(`span`,{className:`spacer`}),k&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,"aria-pressed":ge,onClick:()=>_e(!ge),title:`Click text in the preview to put the cursor there`,children:`Point & edit`}),k&&(0,j.jsx)(`a`,{className:`ghost small linkbtn`,href:E({view:`present`,id:e,url:k,branch:n}),target:`_blank`,rel:`noopener`,children:`Present ↗`}),k&&(0,j.jsx)(`a`,{className:`ghost small linkbtn`,href:k,target:`_blank`,rel:`noopener noreferrer`,children:`Open ↗`})]}),ee&&(0,j.jsx)(`p`,{className:`notice warn small preview-note`,children:ee}),(0,j.jsx)(Ge,{src:k,device:ie,title:`Preview of ${l.title}`,reloadKey:N})]})})}function wt({id:e,branch:t,title:n,onDone:r,onError:i}){let[a,o]=(0,d.useState)(`Update ${n}`),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(),[m,h]=(0,d.useState)([]);return(0,d.useEffect)(()=>{C.people(e).then(e=>p(e.people),()=>p([]))},[e]),(0,j.jsxs)(`div`,{className:`form review-form`,children:[(0,j.jsxs)(`label`,{children:[`Review title`,(0,j.jsx)(`input`,{value:a,onChange:e=>o(e.target.value)})]}),(0,j.jsxs)(`label`,{children:[`What changed, for the reviewer`,(0,j.jsx)(`textarea`,{rows:3,value:s,onChange:e=>c(e.target.value)})]}),f&&f.length>0&&(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Ask for a review from`}),(0,j.jsx)(`div`,{className:`reviewer-pick`,children:f.map(e=>(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:m.includes(e.login),onChange:t=>h(t.target.checked?[...m,e.login]:m.filter(t=>t!==e.login))}),e.name||e.login,` `,(0,j.jsxs)(`span`,{className:`muted small`,children:[`@`,e.login]})]},e.login))})]}),(0,j.jsx)(`div`,{className:`actions`,children:(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:l||!a.trim(),onClick:async()=>{u(!0);try{let n=await C.review(e,{branch:t,title:a,description:s,reviewers:m}),i=n.reviewers?.length?` ${n.reviewers.map(e=>`@`+e).join(`, `)} ${n.reviewers.length===1?`was`:`were`} asked to review; the platform lets them know.`:``;r(`Submitted for review as #${n.number}.${n.preview?` The review links to this draft's preview.`:``}${i}${n.reviewersError?` `+n.reviewersError:``}`)}catch(e){i(e.message)}finally{u(!1)}},children:`Open the review`})})]})}function Tt({id:e,source:t,branch:n,baseCommit:r,current:i,value:a,dirty:o,onChange:s,onDone:c}){let[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(),m=`/`+a.trim().replace(/^\/+|\/+$/g,``)+`/`,h=m===`//`?``:`content${m.slice(0,-1)}.md`,g=async()=>{u(!0),p(void 0);try{c(await C.move(e,{branch:n,baseCommit:r,source:t,to:h}))}catch(e){p(e.message)}finally{u(!1)}};return(0,j.jsxs)(`form`,{className:`form move-form`,onSubmit:e=>{e.preventDefault(),h&&!o&&g()},children:[(0,j.jsxs)(`label`,{children:[`New address`,(0,j.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>s(e.target.value),placeholder:`/about-us/`})]}),h&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`Renames `,(0,j.jsx)(`span`,{className:`mono`,children:t}),` to `,(0,j.jsx)(`span`,{className:`mono`,children:h}),i&&m!==i?(0,j.jsxs)(j.Fragment,{children:[`, and `,(0,j.jsx)(`span`,{className:`mono`,children:i}),` will redirect to `,(0,j.jsx)(`span`,{className:`mono`,children:m})]}):``,`.`]}),o&&(0,j.jsx)(`p`,{className:`notice warn small`,children:`Save your changes first; the move is its own commit.`}),f&&(0,j.jsx)(`p`,{className:`notice bad small`,children:f}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`submit`,className:`button`,disabled:l||!h||o||m===i,children:`Move`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>s(void 0),children:`Cancel`})]})]})}function Et(e){let t=e.replace(`#`,``);if(t.length===3&&(t=t.split(``).map(e=>e+e).join(``)),t.length!==6)return 0;let n=[0,2,4].map(e=>{let n=parseInt(t.slice(e,e+2),16)/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4});return .2126*n[0]+.7152*n[1]+.0722*n[2]}function Dt(e,t){let[n,r]=[Et(e),Et(t)].sort((e,t)=>t-e);return Math.round((n+.05)/(r+.05)*100)/100}var Ot=e=>(typeof e==`string`?e:e?.light)||``,kt=e=>(typeof e==`object`&&e?e.dark:``)||``;function At(e,t,n,r){let i=e.tokens.find(e=>e.name===n),a=t[n];return r===`dark`?kt(a)||i.dark||Ot(a)||i.default||`#000000`:Ot(a)||i.default||`#000000`}function jt({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(),[o,s]=(0,d.useState)({}),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(),[h,g]=(0,d.useState)(),[_,v]=(0,d.useState)(0),[y,b]=Ue(),[x,S]=(0,d.useState)(),[w,T]=(0,d.useState)(!1),E=(0,d.useRef)(void 0),O=(0,d.useRef)(void 0),k=async r=>{let i=await C.upload(e,r,{branch:t||n?.branch||``,baseCommit:n?.commit||``,source:`look.md`});return E.current=i,i.url},A=()=>C.look(e,t).then(e=>{r(e);let t=O.current;O.current=void 0,s(t||e.values||{})},e=>a(e.message));(0,d.useEffect)(()=>{A(),C.site(e,t).then(S,()=>void 0)},[e,t]);let ee=t||n?.branch||``,M=x?ee!==x.publishBranch:!1,te=x?.reviews?.find(e=>e.branch===ee),N=n?JSON.stringify(o)!==JSON.stringify(n.values||{}):!1;(0,d.useEffect)(()=>{let t=E.current;t&&(E.current=void 0,l({kind:`good`,text:`Added ${t.url}${t.created?` on a new draft, ${t.branch}`:``}. Save to keep it in the look.`}),t.created||t.branch!==ee?(O.current=o,D({view:`look`,id:e,branch:t.branch})):n&&r({...n,commit:t.commit}))},[o]);let ne=(0,d.useRef)(0);(0,d.useEffect)(()=>{if(n?.look)return window.clearTimeout(ne.current),ne.current=window.setTimeout(()=>{C.lookLive(e,{branch:ee,look:o}).then(e=>{if(e.error)return g(e.error);g(void 0),e.url===p?v(e=>e+1):m(e.url)},e=>g(e.message))},350),()=>window.clearTimeout(ne.current)},[o,n]);let re=(0,d.useMemo)(()=>n?.look?(n.look.contrast||[]).map(([e,t])=>({fg:e,bg:t,light:Dt(At(n.look,o,e,`light`),At(n.look,o,t,`light`)),dark:Dt(At(n.look,o,e,`dark`),At(n.look,o,t,`dark`))})):[],[n,o]),P=re.filter(e=>e.light<(n?.minContrast||4.5)||e.dark<(n?.minContrast||4.5)).length,ie=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t===void 0||t===``?i:{...i,[e]:t}}),ae=async()=>{if(n){f(!0),l({kind:`info`,text:`Saving…`});try{let r=await C.lookSave(e,{branch:ee,baseCommit:n.commit,look:o});l({kind:`good`,text:r.created?`Saved. The new look is on a draft, ${r.branch}; the published site is unchanged.`:`Saved to ${r.branch}.`}),r.created||r.branch!==t?D({view:`look`,id:e,branch:r.branch}):A()}catch(e){l({kind:`bad`,text:`Not saved: ${e.message}`})}finally{f(!1)}}},F=async()=>{f(!0),l({kind:`info`,text:`Checking the draft and publishing…`});try{await C.publish(e,{branch:ee}),l({kind:`good`,text:`Published: the change is merged. The live site updates when its publishing pipeline runs.`}),x&&D({view:`look`,id:e,branch:x.publishBranch})}catch(e){l({kind:`bad`,text:e.message})}finally{f(!1)}};if(Ee(`mod+s`,()=>N&&!u&&n?.canWrite&&ae(),!!n),i)return(0,j.jsx)(`p`,{className:`pad notice bad`,role:`alert`,children:i});if(!n)return(0,j.jsx)(`p`,{className:`pad muted`,children:`Loading the look…`});let oe=(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`});if(!n.look)return(0,j.jsxs)(`section`,{className:`pad`,children:[oe,(0,j.jsx)(`h1`,{children:`Look`}),(0,j.jsxs)(`p`,{className:`muted`,children:[`This site's theme doesn't say what can be changed: it has no `,(0,j.jsx)(`span`,{className:`mono`,children:`look.yaml`}),`. A developer adds one to offer colors, fonts and a logo here.`]})]});let se=n.canWrite;return(0,j.jsx)(Ve,{left:(0,j.jsxs)(`section`,{className:`editor-pane`,children:[(0,j.jsxs)(`div`,{className:`pane-head`,children:[oe,(0,j.jsx)(`span`,{className:`pill ${M?`warn`:``}`,children:M?`draft: ${ee}`:`${ee} · published`})]}),(0,j.jsx)(`h1`,{children:`Look`}),(0,j.jsx)(`p`,{className:`muted small`,children:`What this site's theme lets change. The preview shows the home page as you pick.`}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!N||u||!se,onClick:ae,children:M?`Save`:`Save as draft`}),M&&!te&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:u||N||!se,onClick:()=>T(!w),children:`Submit for review`}),M&&te&&(0,j.jsxs)(`a`,{className:`button`,href:te.url,target:`_blank`,rel:`noopener noreferrer`,children:[`Review #`,te.number,` ↗`]}),M&&te&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:u||N||!se,onClick:F,children:`Publish`}),N&&(0,j.jsx)(`span`,{className:`muted small`,children:`Unsaved changes`}),!se&&(0,j.jsx)(`span`,{className:`muted small`,children:`Read only: the platform doesn't let you change this site.`})]}),c&&(0,j.jsx)(`p`,{className:`notice ${c.kind}`,role:`status`,children:c.text}),w&&(0,j.jsx)(wt,{id:e,branch:ee,title:`the look`,onDone:n=>{T(!1),l({kind:`good`,text:n}),C.site(e,t).then(S)},onError:e=>l({kind:`bad`,text:e})}),(0,j.jsxs)(`div`,{className:`notice ${P?`bad`:`good`}`,children:[(0,j.jsx)(`strong`,{children:P?`${P} pair${P===1?``:`s`} too hard to read: this can't be published until fixed.`:`Every pair is readable.`}),(0,j.jsxs)(`table`,{className:`contrast`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Text`}),(0,j.jsx)(`th`,{children:`On`}),(0,j.jsx)(`th`,{children:`Light`}),(0,j.jsx)(`th`,{children:`Dark`})]})}),(0,j.jsx)(`tbody`,{children:re.map(e=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{children:Mt(n.look,e.fg)}),(0,j.jsx)(`td`,{children:Mt(n.look,e.bg)}),[e.light,e.dark].map((e,t)=>(0,j.jsxs)(`td`,{className:e(0,j.jsx)(Nt,{t,value:o[t.name],onChange:e=>ie(t.name,e),id:e,branch:ee,disabled:!se,upload:k},t.name))})]}),right:(0,j.jsxs)(`section`,{className:`preview-pane`,"aria-label":`Preview`,children:[(0,j.jsx)(`div`,{className:`preview-bar`,children:(0,j.jsx)(We,{device:y,onChange:b})}),h&&(0,j.jsx)(`p`,{className:`notice warn small preview-note`,children:h}),(0,j.jsx)(Ge,{src:p,device:y,title:`Preview of the look`,reloadKey:_})]})})}function Mt(e,t){return e.tokens.find(e=>e.name===t)?.label||t}function Nt({t:e,value:t,onChange:n,id:r,branch:i,disabled:a,upload:o}){let s=t!==void 0&&!a&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>n(void 0),children:`Use the theme's`}),c=e.help&&(0,j.jsx)(`span`,{className:`muted small`,children:e.help});switch(e.type){case`color`:{let r=Ot(t),i=kt(t),o=(t,r)=>n(r?{light:t||e.default,dark:r}:t||void 0);return(0,j.jsxs)(`fieldset`,{className:`field group token`,children:[(0,j.jsxs)(`legend`,{children:[e.label||e.name,` `,s]}),c,(0,j.jsxs)(`div`,{className:`color-row`,children:[(0,j.jsxs)(`label`,{className:`color-pick`,children:[(0,j.jsx)(`input`,{type:`color`,value:r||e.default,disabled:a,onChange:e=>o(e.target.value,i),"aria-label":`${e.label}, light`}),(0,j.jsx)(`span`,{className:`mono small`,children:r||`${e.default} (theme)`})]}),(0,j.jsxs)(`label`,{className:`check small`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:!!i,disabled:a,onChange:t=>o(r,t.target.checked?e.dark||r||e.default||`#000000`:``)}),` Different in dark mode`]}),i&&(0,j.jsxs)(`label`,{className:`color-pick`,children:[(0,j.jsx)(`input`,{type:`color`,value:i,disabled:a,onChange:e=>o(r,e.target.value),"aria-label":`${e.label}, dark`}),(0,j.jsxs)(`span`,{className:`mono small`,children:[i,` (dark)`]})]}),!i&&e.dark&&(0,j.jsxs)(`span`,{className:`muted small`,children:[`Dark mode: `,e.dark,` (theme)`]})]})]})}case`font`:case`select`:return(0,j.jsxs)(`label`,{className:`field token`,children:[(0,j.jsxs)(`span`,{className:`field-label`,children:[e.label||e.name,` `,s]}),(0,j.jsxs)(`select`,{value:Ot(t),disabled:a,onChange:e=>n(e.target.value||void 0),children:[(0,j.jsxs)(`option`,{value:``,children:[`The theme's (`,e.default,`)`]}),(e.options||[]).map(t=>(0,j.jsx)(`option`,{value:t.name,style:e.type===`font`?{fontFamily:t.value}:void 0,children:t.name},t.name))]}),c]});case`image`:return(0,j.jsx)(ue,{f:{name:e.name,label:e.label,type:`image`},label:(0,j.jsxs)(`span`,{className:`field-label`,children:[e.label||e.name,` `,s]}),help:c,value:Ot(t),onChange:e=>n(e||void 0),ctx:{id:r,branch:i,lib:{sections:[],data:[],collections:[]},upload:o},disabled:a})}}var Pt=()=>void 0,Ft=()=>Pt();function It(){let[e,t]=(0,d.useState)(!1),[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)(0),[o,s]=(0,d.useState)([]),c=(0,d.useRef)(null),l=(0,d.useRef)(null),u=()=>{s(we()),r(``),a(0),t(!0)};Pt=u,Ee(`mod+k`,()=>e?t(!1):u()),(0,d.useEffect)(()=>{e?c.current?.showModal():c.current?.open&&c.current.close()},[e]);let f=(0,d.useMemo)(()=>{let e=o.map(e=>({c:e,s:Math.max(Te(n,e.title),Te(n,`${e.group} ${e.title}`)-50)})).filter(e=>e.s>=0);return n.trim()&&e.sort((e,t)=>t.s-e.s),e.slice(0,60).map(e=>e.c)},[o,n]);(0,d.useEffect)(()=>{l.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[i]);let p=e=>{t(!1),setTimeout(e.run,0)};return(0,j.jsx)(`dialog`,{ref:c,className:`palette`,"aria-label":`Command palette`,onClose:()=>t(!1),children:e&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`input`,{autoFocus:!0,className:`palette-input`,placeholder:`Type a command or a page…`,value:n,role:`combobox`,"aria-expanded":`true`,"aria-controls":`palette-list`,"aria-activedescendant":f[i]?`cmd-${i}`:void 0,onChange:e=>{r(e.target.value),a(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),a(e=>Math.min(e+1,f.length-1))):e.key===`ArrowUp`?(e.preventDefault(),a(e=>Math.max(e-1,0))):e.key===`Enter`&&f[i]&&(e.preventDefault(),p(f[i]))}}),(0,j.jsxs)(`ul`,{id:`palette-list`,role:`listbox`,ref:l,className:`palette-list`,children:[f.length===0&&(0,j.jsx)(`li`,{className:`muted small palette-empty`,children:`Nothing matches.`}),f.map((e,t)=>(0,j.jsxs)(`li`,{id:`cmd-${t}`,role:`option`,"aria-selected":t===i,className:t===i?`on`:``,onMouseMove:()=>a(t),onClick:()=>p(e),children:[(0,j.jsx)(`span`,{className:`muted small palette-group`,children:e.group}),(0,j.jsx)(`span`,{className:`palette-title`,children:e.title}),e.keys&&(0,j.jsx)(`kbd`,{children:e.keys})]},e.id))]}),(0,j.jsx)(`p`,{className:`palette-foot muted small`,children:"↑↓ to move · Enter to run · Esc to close · Ctrl+` opens the console"})]})})}var Lt=[{id:``,label:`None`,about:`No visit statistics.`},{id:`plausible`,label:`Plausible`,about:`Counts visits without cookies; hosted or self-hosted.`},{id:`matomo`,label:`Matomo`,about:`Self-hosted statistics.`},{id:`ga4`,label:`Google Analytics`,about:`Google Analytics 4. Visitors’ data goes to Google.`}];function Rt({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)({}),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(!1),p=()=>C.privacy(e,t).then(e=>{a(e.analytics),s(e.privacy),r({commit:e.commit,branch:e.branch,canWrite:e.canWrite,start:JSON.stringify([e.analytics,e.privacy])})},e=>l({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{p()},[e,t]);let m=!!n&&JSON.stringify([i,o])!==n.start,h=!i||i.gated!==!1,g=(e,t,r,o)=>(0,j.jsxs)(`label`,{className:`field`,children:[t,(0,j.jsx)(`input`,{value:i?.[e]||``,placeholder:r,disabled:!n?.canWrite,onChange:t=>a({...i,[e]:t.target.value})}),o&&(0,j.jsx)(`span`,{className:`muted small`,children:o})]});return(0,j.jsxs)(`section`,{className:`pad privacy-view`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Privacy and statistics`}),(0,j.jsx)(`p`,{className:`muted`,children:`What the site counts, and who answers for visitors' data. The privacy notice at /privacy/ is written from these settings every time the site is built.`}),c&&(0,j.jsx)(`p`,{className:`notice ${c.kind}`,role:`status`,children:c.text}),n&&(0,j.jsxs)(`div`,{className:`form wizard`,children:[(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Visit statistics`}),(0,j.jsx)(`div`,{className:`provider-pick`,role:`radiogroup`,"aria-label":`Statistics`,children:Lt.map(e=>(0,j.jsxs)(`label`,{className:`provider ${(i?.provider||``)===e.id?`on`:``}`,children:[(0,j.jsx)(`input`,{type:`radio`,name:`provider`,checked:(i?.provider||``)===e.id,disabled:!n.canWrite,onChange:()=>a(e.id?{provider:e.id,gated:i?.gated}:null)}),(0,j.jsx)(`strong`,{children:e.label}),(0,j.jsx)(`span`,{className:`muted small`,children:e.about})]},e.id))}),i?.provider===`plausible`&&(0,j.jsxs)(j.Fragment,{children:[g(`domain`,`Site domain in Plausible`,`example.org`),g(`src`,`Script address (if self-hosted)`,`https://plausible.io/js/script.js`,`Leave empty for plausible.io.`)]}),i?.provider===`matomo`&&(0,j.jsxs)(j.Fragment,{children:[g(`url`,`Matomo address`,`https://matomo.example.org/`),g(`siteId`,`Site ID`,`1`)]}),i?.provider===`ga4`&&g(`id`,`Measurement ID`,`G-XXXXXXX`),i&&(0,j.jsxs)(`label`,{className:`check field`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:h,disabled:!n.canWrite,onChange:e=>a({...i,gated:e.target.checked?void 0:!1})}),`Ask visitors first (recommended)`]}),i&&h&&(0,j.jsx)(`p`,{className:`muted small`,children:`A banner asks on the first visit, with Decline first and as prominent as Accept. Nothing is counted until someone accepts; declining later removes the counter's cookies.`}),i&&!h&&(0,j.jsx)(`p`,{className:`notice warn small`,children:`Statistics will start on page view, without asking. That's recorded in site.yaml (gated: false), the privacy notice says so, and every check warns about it. In much of the world, counting with cookies needs consent.`})]}),(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Who answers for visitors' data`}),(0,j.jsxs)(`label`,{className:`field`,children:[`Person or organization`,(0,j.jsx)(`input`,{value:o.controller||``,disabled:!n.canWrite,placeholder:`Your name, or your company`,onChange:e=>s({...o,controller:e.target.value})})]}),(0,j.jsxs)(`label`,{className:`field`,children:[`Email to write to`,(0,j.jsx)(`input`,{value:o.contact||``,disabled:!n.canWrite,placeholder:`privacy@example.org`,onChange:e=>s({...o,contact:e.target.value})})]}),(0,j.jsxs)(`label`,{className:`field`,children:[`Last changed`,(0,j.jsx)(`input`,{value:o.updated||``,disabled:!n.canWrite,placeholder:`10 October 2026`,onChange:e=>s({...o,updated:e.target.value})})]})]}),n.canWrite&&(0,j.jsx)(`div`,{className:`actions-row`,children:(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!m||u,onClick:async()=>{if(n){f(!0),l({kind:`info`,text:`Saving…`});try{let r=await C.privacySave(e,{branch:n.branch,baseCommit:n.commit,analytics:i,privacy:o});l({kind:`good`,text:`Saved on ${r.created?`a new draft, ${r.branch}`:r.branch}. Its preview's /privacy/ page shows the new list.`}),r.created||r.branch!==t?D({view:`privacy`,id:e,branch:r.branch}):p()}catch(e){l({kind:`bad`,text:e.message})}finally{f(!1)}}},children:n.branch===t?`Save`:`Save as draft`})})]})]})}function zt({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(),[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(!1),u=()=>C.redirects(e,t).then(e=>{a({rows:e.redirects,commit:e.commit,branch:e.branch,canWrite:e.canWrite}),r(e.redirects.map(e=>({...e})))},e=>s({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{u()},[e,t]);let f=!!i&&JSON.stringify(n)!==JSON.stringify(i.rows),p=(e,t,n)=>r(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r));return(0,j.jsxs)(`section`,{className:`pad redirects`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Redirects`}),(0,j.jsx)(`p`,{className:`muted`,children:`Old addresses that should keep working. Moving a page adds its redirect by itself; add others here, for a page that's gone or a link printed somewhere.`}),o&&(0,j.jsx)(`p`,{className:`notice ${o.kind}`,role:`status`,children:o.text}),!n&&!o&&(0,j.jsx)(`p`,{className:`muted`,children:`Reading site.yaml…`}),n&&(0,j.jsxs)(`div`,{className:`form`,children:[(0,j.jsxs)(`table`,{className:`pages redirect-table`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Old address`}),(0,j.jsx)(`th`,{children:`Goes to`}),(0,j.jsx)(`th`,{})]})}),(0,j.jsxs)(`tbody`,{children:[n.map((e,t)=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{children:(0,j.jsx)(`input`,{value:e.from,placeholder:`/old-page/`,disabled:!i?.canWrite,onChange:e=>p(t,`from`,e.target.value),"aria-label":`Old address ${t+1}`})}),(0,j.jsx)(`td`,{children:(0,j.jsx)(`input`,{value:e.to,placeholder:`/new-page/ or https://…`,disabled:!i?.canWrite,onChange:e=>p(t,`to`,e.target.value),"aria-label":`Goes to ${t+1}`})}),(0,j.jsx)(`td`,{children:i?.canWrite&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>r(n.filter((e,n)=>n!==t)),children:`Remove`})})]},t)),n.length===0&&(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:3,className:`muted small`,children:`No redirects.`})})]})]}),i?.canWrite&&(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>r([...n,{from:``,to:``}]),children:`Add a redirect`}),(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!f||c,onClick:async()=>{if(i&&n){l(!0),s({kind:`info`,text:`Saving…`});try{let r=await C.redirectsSave(e,{branch:i.branch,baseCommit:i.commit,redirects:n.filter(e=>e.from.trim()||e.to.trim())});s({kind:`good`,text:`Saved on ${r.created?`a new draft, ${r.branch}`:r.branch}.`}),r.created||r.branch!==t?D({view:`redirects`,id:e,branch:r.branch}):u()}catch(e){s({kind:`bad`,text:e.message})}finally{l(!1)}}},children:i.branch===t?`Save`:`Save as draft`})]})]})]})}var Bt=[{k:`google`,name:`Google Search Console`,where:`Add a property for the site, choose "HTML tag", and copy the content="…" value (or the whole tag; the code is taken out of it).`},{k:`bing`,name:`Bing Webmaster Tools`,where:`Add the site, choose "HTML Meta Tag", and copy the content value of msvalidate.01.`},{k:`yandex`,name:`Yandex Webmaster`,where:`Add the site, choose "Meta tag", and copy the content value.`}];function Vt(){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function Ht({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(!1),p=()=>C.search(e,t).then(e=>{let t={google:e.verify.google||``,bing:e.verify.bing||``,yandex:e.verify.yandex||``};a(t),s(e.indexnow||``),r({commit:e.commit,branch:e.branch,canWrite:e.canWrite,sitemap:e.sitemap,siteURL:e.siteURL,start:JSON.stringify([t,e.indexnow||``])})},e=>l({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{p()},[e,t]);let m=!!n&&JSON.stringify([i,o])!==n.start;return(0,j.jsxs)(`section`,{className:`pad search-view`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Search engines`}),(0,j.jsx)(`p`,{className:`muted`,children:`Show each search console the site is yours, and tell search engines what changed whenever it's published.`}),c&&(0,j.jsx)(`p`,{className:`notice ${c.kind}`,role:`status`,children:c.text}),n&&(0,j.jsxs)(`div`,{className:`form wizard`,children:[(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Verification`}),Bt.map(e=>(0,j.jsxs)(`label`,{className:`field`,children:[e.name,(0,j.jsx)(`input`,{value:i[e.k]||``,disabled:!n.canWrite,placeholder:`The code from the meta tag`,onChange:t=>a({...i,[e.k]:t.target.value})}),(0,j.jsx)(`span`,{className:`muted small`,children:e.where})]},e.k)),(0,j.jsxs)(`p`,{className:`muted small`,children:[`The codes become meta tags on the home page. The site's sitemap, to give each console: `,(0,j.jsx)(`span`,{className:`mono`,children:n.sitemap})]})]}),(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`IndexNow`}),(0,j.jsxs)(`p`,{className:`muted small`,children:[`IndexNow tells Bing, Yandex and the other search engines that share it which pages changed, each time the site is published. The key proves the message is the site's own; the build publishes it as `,(0,j.jsxs)(`span`,{className:`mono`,children:[`/`,o||`key`,`.txt`]}),`.`]}),(0,j.jsxs)(`div`,{className:`image-row`,children:[(0,j.jsx)(`input`,{value:o,disabled:!n.canWrite,placeholder:`No key: IndexNow is off`,onChange:e=>s(e.target.value),"aria-label":`IndexNow key`}),n.canWrite&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>s(Vt()),children:o?`New key`:`Make a key`})]}),(0,j.jsxs)(`p`,{className:`muted small`,children:[`Then, on the live site's publish target, set `,(0,j.jsx)(`span`,{className:`mono`,children:`indexnow: true`}),` in publish.yaml (or run the pull agent with `,(0,j.jsx)(`span`,{className:`mono`,children:`-indexnow`}),`). Only that target sends; staging never does.`]})]}),n.canWrite&&(0,j.jsx)(`div`,{className:`actions-row`,children:(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!m||u,onClick:async()=>{if(n){f(!0),l({kind:`info`,text:`Saving…`});try{let r=await C.searchSave(e,{branch:n.branch,baseCommit:n.commit,verify:i,indexnow:o});l({kind:`good`,text:`Saved on ${r.created?`a new draft, ${r.branch}`:r.branch}. Once it's published, press Verify in each console.`}),r.created||r.branch!==t?D({view:`search`,id:e,branch:r.branch}):p()}catch(e){l({kind:`bad`,text:e.message})}finally{f(!1)}}},children:n.branch===t?`Save`:`Save as draft`})})]})]})}var Ut=`hotdog-theme`;function Wt(){try{let e=localStorage.getItem(Ut);if(e===`light`||e===`dark`)return e}catch{}return`system`}function Gt(){let[e,t]=(0,d.useState)(Wt),n=e=>{t(e),e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e;try{e===`system`?localStorage.removeItem(Ut):localStorage.setItem(Ut,e)}catch{}},r={system:`Auto`,light:`Light`,dark:`Dark`};return(0,j.jsx)(`div`,{className:`seg theme-pick`,role:`group`,"aria-label":`Color theme`,children:Object.keys(r).map(t=>(0,j.jsx)(`button`,{type:`button`,"aria-pressed":e===t,title:t===`system`?`Follow the device setting`:`${r[t]} theme`,onClick:()=>n(t),children:r[t]},t))})}function z({to:e,children:t,className:n}){return(0,j.jsx)(`a`,{className:n,href:E(e),onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),D(e))},children:t})}function Kt(e,t){let[n,r]=(0,d.useState)({loading:!0}),i=(0,d.useCallback)(()=>{r(e=>({...e,loading:!0})),e().then(e=>r({data:e,loading:!1}),e=>r({error:e,loading:!1}))},t);return(0,d.useEffect)(i,[i]),{...n,reload:i}}function qt(){let e=O(),t=Kt(C.session,[]);if(t.loading&&!t.data)return(0,j.jsx)(Jt,{children:(0,j.jsx)(`p`,{className:`muted pad`,children:`Loading…`})});if(t.error)return(0,j.jsx)(Jt,{children:(0,j.jsx)(Yt,{error:t.error})});let n=t.data;return n.signedIn?(0,j.jsxs)(Jt,{session:n,onAccountsChanged:t.reload,children:[e.view===`sites`&&(0,j.jsx)(Zt,{}),e.view===`site`&&(0,j.jsx)(Qt,{id:e.id,branch:e.branch}),e.view===`page`&&(0,j.jsx)(en,{id:e.id,source:e.source,branch:e.branch}),e.view===`present`&&(0,j.jsx)(Xe,{id:e.id,url:e.url,branch:e.branch}),e.view===`media`&&(0,j.jsx)(M,{id:e.id,branch:e.branch}),e.view===`look`&&(0,j.jsx)(jt,{id:e.id,branch:e.branch}),e.view===`files`&&(0,j.jsx)(Pe,{id:e.id,branch:e.branch,path:e.path}),e.view===`redirects`&&(0,j.jsx)(zt,{id:e.id,branch:e.branch}),e.view===`privacy`&&(0,j.jsx)(Rt,{id:e.id,branch:e.branch}),e.view===`search`&&(0,j.jsx)(Ht,{id:e.id,branch:e.branch}),e.view===`forms`&&(0,j.jsx)(Je,{id:e.id,branch:e.branch,form:e.form}),e.view===`history`&&(0,j.jsx)(Ye,{id:e.id}),e.view===`quick`&&(0,j.jsx)(pe,{id:e.id,kind:e.kind})]}):(0,j.jsx)(Xt,{session:n})}function Jt({children:e,session:t,onAccountsChanged:n}){return(0,j.jsxs)(`div`,{className:`app`,children:[(0,j.jsxs)(`header`,{className:`top`,children:[(0,j.jsxs)(z,{to:{view:`sites`},className:`brand`,children:[(0,j.jsx)(`img`,{className:`logo only-light`,src:R,alt:`HotDog CMS`}),(0,j.jsx)(`img`,{className:`logo only-dark`,src:ye,alt:`HotDog CMS`}),(0,j.jsx)(`span`,{className:`brand-sub`,children:`Editor`})]}),(0,j.jsxs)(`div`,{className:`who`,children:[t?.signedIn&&(0,j.jsxs)(`button`,{type:`button`,className:`ghost small kbd-hint`,onClick:Ft,title:`Every action, by name`,children:[`Commands `,(0,j.jsx)(`kbd`,{children:`Ctrl K`})]}),(0,j.jsx)(Gt,{}),t?.signedIn&&n&&(0,j.jsx)(xe,{session:t,onChanged:n})]})]}),(0,j.jsx)(`main`,{id:`main`,children:e}),(0,j.jsx)(ve,{}),t?.signedIn&&(0,j.jsx)(nn,{session:t}),t?.signedIn&&(0,j.jsx)(It,{}),t?.signedIn&&(0,j.jsx)(je,{})]})}function Yt({error:e}){return e instanceof p?(0,j.jsxs)(`div`,{className:`pad`,children:[(0,j.jsx)(`p`,{children:e.message}),(0,j.jsx)(`p`,{children:(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>location.reload(),children:`Sign in again`})})]}):(0,j.jsx)(`div`,{className:`pad notice bad`,role:`alert`,children:e.message})}function Xt({session:e}){let t=location.pathname+location.search;return(0,j.jsxs)(`div`,{className:`app`,children:[(0,j.jsx)(`div`,{className:`signin`,children:(0,j.jsxs)(`div`,{className:`card`,children:[(0,j.jsx)(`img`,{className:`signin-logo only-light`,src:R,alt:`HotDog CMS`}),(0,j.jsx)(`img`,{className:`signin-logo only-dark`,src:ye,alt:`HotDog CMS`}),(0,j.jsx)(`h1`,{children:`Sign in`}),(0,j.jsx)(`p`,{className:`muted`,children:`With the git platform your sites live on. The editor keeps no accounts of its own: what you can open and change is what the platform already lets you, and every change is made as you.`}),(0,j.jsxs)(`div`,{className:`stack`,children:[e.forges.map(e=>(0,j.jsxs)(`a`,{className:`button primary`,href:w(e.host,t),children:[`Sign in with `,be(e.kind),` `,(0,j.jsxs)(`span`,{className:`muted-on`,children:[`· `,e.host]})]},e.host)),e.forges.length===0&&(0,j.jsx)(`p`,{className:`notice bad`,children:`No git platform is configured for this editor.`})]})]})}),(0,j.jsx)(ve,{})]})}function Zt(){let e=Kt(C.sites,[]);return(0,j.jsxs)(`section`,{className:`pad`,children:[(0,j.jsx)(`h1`,{children:`Your sites`}),e.loading&&!e.data&&(0,j.jsx)(`p`,{className:`muted`,children:`Asking the platform which sites you can open…`}),e.error&&(0,j.jsx)(Yt,{error:e.error}),e.data&&e.data.length===0&&(0,j.jsx)(`p`,{className:`muted`,children:`None of the sites this editor knows about are open to your account.`}),(0,j.jsx)(`ul`,{className:`tiles`,children:e.data?.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(z,{to:{view:`site`,id:e.id},className:`tile`,children:[(0,j.jsx)(`strong`,{children:e.name}),e.discovered&&(0,j.jsx)(`span`,{className:`muted small`,title:`Not listed in editor.yaml: found because it has a site.yaml`,children:`Found in your repositories`}),(0,j.jsx)(`span`,{className:`muted mono`,children:e.repo.replace(/^https?:\/\//,``).replace(/\.git$/,``)}),(0,j.jsx)(`span`,{className:`tile-accounts`,children:e.accounts.map(e=>(0,j.jsxs)(`span`,{className:`pill`,title:`${e.login} on ${e.forge}`,children:[`@`,e.login,` · `,e.canWrite?`can edit`:`read only`]},e.id))})]})},e.id))})]})}function Qt({id:e,branch:t}){let n=Kt(()=>C.site(e,t),[e,t]);Ce(()=>{let r=n.data;return r?[...(r.pages||[]).filter(e=>e.source).map(n=>({id:`page:${n.source}`,title:`${n.title} ${n.path}`,group:`Open page`,run:()=>D({view:`page`,id:e,source:n.source,branch:t})})),...(r.drafts||[]).map(t=>({id:`draft:${t.branch}`,title:t.branch,group:`Switch to draft`,run:()=>D({view:`site`,id:e,branch:t.branch})})),...t?[{id:`draft:back`,title:`Back to ${r.publishBranch}`,group:`Switch to draft`,run:()=>D({view:`site`,id:e})}]:[]]:[]});let[r,i]=(0,d.useState)(``),a=n.data,o=(0,d.useMemo)(()=>(a?.pages||[]).filter(e=>r===``?!0:r===`-`?!e.collection:e.collection===r),[a,r]);if(n.loading&&!a)return(0,j.jsx)(`p`,{className:`pad muted`,children:`Fetching the site with your account…`});if(n.error)return(0,j.jsx)(Yt,{error:n.error});if(!a)return null;let s=(a.pages||[]).filter(e=>!e.collection).length;return(0,j.jsxs)(`div`,{className:`split`,children:[(0,j.jsxs)(`aside`,{className:`side`,"aria-label":`Site`,children:[(0,j.jsxs)(`div`,{className:`side-head`,children:[(0,j.jsx)(z,{to:{view:`sites`},className:`back`,children:`← Sites`}),(0,j.jsx)(`h1`,{children:a.name}),(0,j.jsx)(`p`,{className:`muted mono small`,children:a.branch===a.publishBranch?`${a.branch} · published branch`:`${a.branch} · draft`}),a.role&&(0,j.jsx)(`p`,{className:`muted small role-line`,title:`From the platform's permissions`,children:{reader:`You can read this site.`,writer:`You can save drafts and open reviews; the platform decides who may publish.`,maintainer:`You maintain this site: drafts, reviews and publishing.`}[a.role]}),a.accounts.length>1&&(0,j.jsxs)(`label`,{className:`working-as`,children:[`Working as`,(0,j.jsx)(`select`,{value:a.as,onChange:t=>{b(e,t.target.value),n.reload()},children:a.accounts.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[`@`,e.login,` · `,e.forge,e.canWrite?``:` (read only)`]},e.id))})]})]}),(0,j.jsxs)(`nav`,{"aria-label":`Pages`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Pages`}),(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r===``?`on`:``}`,onClick:()=>i(``),children:[`All pages `,(0,j.jsx)(`span`,{children:(a.pages||[]).length})]}),s>0&&(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r===`-`?`on`:``}`,onClick:()=>i(`-`),children:[`Pages `,(0,j.jsx)(`span`,{children:s})]}),(a.collections||[]).map(e=>(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r===e.name?`on`:``}`,onClick:()=>i(e.name),children:[e.title,` `,(0,j.jsx)(`span`,{children:e.count})]},e.name))]}),(0,j.jsxs)(`nav`,{"aria-label":`Site files`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Files`}),(0,j.jsx)(z,{to:{view:`media`,id:e,branch:t},className:`side-item`,children:`Pictures`}),(0,j.jsx)(z,{to:{view:`forms`,id:e,branch:t},className:`side-item`,children:`Forms`}),(0,j.jsx)(z,{to:{view:`look`,id:e,branch:t},className:`side-item`,children:`Look`}),(0,j.jsx)(z,{to:{view:`files`,id:e,branch:t},className:`side-item`,children:`Files`}),(0,j.jsx)(z,{to:{view:`redirects`,id:e,branch:t},className:`side-item`,children:`Redirects`}),(0,j.jsx)(z,{to:{view:`history`,id:e},className:`side-item`,children:`History`}),(0,j.jsx)(z,{to:{view:`privacy`,id:e,branch:t},className:`side-item`,children:`Privacy & statistics`}),(0,j.jsx)(z,{to:{view:`search`,id:e,branch:t},className:`side-item`,children:`Search engines`})]}),(0,j.jsxs)(`nav`,{"aria-label":`Drafts`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Drafts`}),a.branch!==a.publishBranch&&(0,j.jsxs)(z,{to:{view:`site`,id:e},className:`side-item`,children:[`← Back to `,a.publishBranch]}),(a.drafts||[]).length===0&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:`No drafts.`}),(a.drafts||[]).map(t=>(0,j.jsx)(z,{to:{view:`site`,id:e,branch:t.branch},className:`side-item ${a.branch===t.branch?`on`:``}`,children:t.branch},t.branch))]}),(0,j.jsxs)(`nav`,{"aria-label":`Reviews`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`In review`}),(a.reviews||[]).length===0&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:`Nothing waiting for review.`}),(a.reviews||[]).map(e=>(0,j.jsxs)(`a`,{className:`side-item`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[`#`,e.number,` `,e.title]},e.number))]}),a.notYet&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:a.notYet})]}),(0,j.jsxs)(`section`,{className:`content`,children:[(0,j.jsx)($t,{build:a.build}),(0,j.jsxs)(`div`,{className:`toolbar`,children:[(0,j.jsx)(`h2`,{children:r===``?`All pages`:r===`-`?`Pages`:(a.collections||[]).find(e=>e.name===r)?.title}),(0,j.jsxs)(`span`,{className:`toolbar-actions`,children:[a.canWrite&&(0,j.jsx)(z,{to:{view:`quick`,id:e},className:`button primary`,children:`Quick post`}),a.canWrite&&(0,j.jsx)(tn,{id:e,collections:a.collections,branch:a.branch===a.publishBranch?void 0:a.branch}),a.preview&&(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>D({view:`present`,id:e,url:a.preview,branch:t}),children:`Present`}),a.preview&&(0,j.jsx)(`a`,{className:`button`,href:a.preview,target:`_blank`,rel:`noopener noreferrer`,children:`Open preview ↗`})]})]}),(0,j.jsxs)(`table`,{className:`pages`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Title`}),(0,j.jsx)(`th`,{children:`Address`}),(0,j.jsx)(`th`,{children:`Date`})]})}),(0,j.jsx)(`tbody`,{children:o.map(n=>(0,j.jsxs)(`tr`,{children:[(0,j.jsxs)(`td`,{children:[(0,j.jsx)(z,{to:{view:`page`,id:e,source:n.source,branch:t},children:n.title}),n.draft&&(0,j.jsx)(`span`,{className:`pill warn`,children:`draft`}),n.redirect&&(0,j.jsx)(`span`,{className:`pill`,children:`redirects`})]}),(0,j.jsx)(`td`,{className:`mono small`,children:n.path}),(0,j.jsx)(`td`,{className:`small`,children:n.date||``})]},n.source))})]})]})]})}function $t({build:e}){let[t,n]=(0,d.useState)(!1);if(e.failed)return(0,j.jsxs)(`div`,{className:`notice bad`,role:`alert`,children:[(0,j.jsx)(`strong`,{children:`This branch doesn't build.`}),` `,e.failed]});let r=e.problems||[];return(0,j.jsxs)(`div`,{className:`notice ${e.errors?`bad`:e.warnings?`warn`:`good`}`,children:[(0,j.jsxs)(`div`,{className:`notice-row`,children:[(0,j.jsxs)(`span`,{children:[e.errors?(0,j.jsxs)(`strong`,{children:[e.errors,` check error`,e.errors===1?``:`s`,`: this can't be published until they're fixed.`]}):(0,j.jsx)(`strong`,{children:`Passes the checks.`}),e.warnings>0&&(0,j.jsxs)(j.Fragment,{children:[` `,e.warnings,` warning`,e.warnings===1?``:`s`,`.`]}),(0,j.jsxs)(`span`,{className:`muted`,children:[` `,e.pages,` pages built from `,e.commit.slice(0,10),`.`]})]}),r.length>0&&(0,j.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":t,onClick:()=>n(!t),children:[t?`Hide`:`Show`,` details`]})]}),t&&(0,j.jsx)(`ul`,{className:`problems`,children:r.map((e,t)=>(0,j.jsxs)(`li`,{className:e.Level,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,(0,j.jsx)(`span`,{className:`mono small`,children:e.File}),` `,e.What,e.Fix&&(0,j.jsx)(`span`,{className:`fix`,children:e.Fix})]},t))})]})}function en({id:e,source:t,branch:n}){let r=Kt(()=>C.site(e,n),[e,n]);return(0,j.jsx)(Ct,{id:e,source:t,branch:n,site:r.data,onSiteChanged:r.reload})}function tn({id:e,collections:t,branch:n}){let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(t?.[0]?.name||``),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)();if(!r)return(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>i(!0),children:`New page`});let m=async()=>{u(!0),p(void 0);try{let t=await C.newPage(e,{collection:s,title:a,branch:n});D({view:`page`,id:e,source:t.source,branch:t.branch})}catch(e){p(e.message),u(!1)}};return(0,j.jsxs)(`div`,{className:`newpage form`,children:[(0,j.jsxs)(`label`,{children:[`In`,(0,j.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(t||[]).map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.title},e.name)),(0,j.jsx)(`option`,{value:``,children:`Pages (top level)`})]})]}),(0,j.jsxs)(`label`,{children:[`Title`,(0,j.jsx)(`input`,{value:a,autoFocus:!0,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Enter`&&a.trim()&&m()})]}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:l||!a.trim(),onClick:m,children:n?`Add the page`:`Start a draft`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>i(!1),children:`Cancel`})]}),f&&(0,j.jsx)(`p`,{className:`notice bad`,children:f})]})}function nn({session:e}){let t=O(),n=`id`in t?t.id:void 0,r=`branch`in t?t.branch:void 0,i=e=>()=>{try{e===`auto`?localStorage.removeItem(`hotdog-theme`):localStorage.setItem(`hotdog-theme`,e)}catch{}e===`auto`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e};return Ce(()=>[{id:`go-sites`,title:`All sites`,group:`Go to`,run:()=>D({view:`sites`})},...n?[{id:`go-site`,title:`This site's pages`,group:`Go to`,run:()=>D({view:`site`,id:n,branch:r})},{id:`go-files`,title:`Files`,group:`Go to`,run:()=>D({view:`files`,id:n,branch:r})},{id:`go-pictures`,title:`Pictures`,group:`Go to`,run:()=>D({view:`media`,id:n,branch:r})},{id:`go-look`,title:`Look`,group:`Go to`,run:()=>D({view:`look`,id:n,branch:r})},{id:`go-history`,title:`History (undo a published change)`,group:`Go to`,run:()=>D({view:`history`,id:n})},{id:`quick-banner`,title:`Quick post: banner or alert`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`banner`})},{id:`quick-post`,title:`Quick post: news post`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`post`})},{id:`quick-event`,title:`Quick post: event`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`event`})},{id:`quick-home`,title:`Quick post: front page`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`home`})},{id:`go-forms`,title:`Forms and submissions`,group:`Go to`,run:()=>D({view:`forms`,id:n,branch:r})},{id:`go-redirects`,title:`Redirects`,group:`Go to`,run:()=>D({view:`redirects`,id:n,branch:r})},{id:`go-search`,title:`Search engines (verification, IndexNow)`,group:`Go to`,run:()=>D({view:`search`,id:n,branch:r})},{id:`go-privacy`,title:`Privacy and statistics (analytics)`,group:`Go to`,run:()=>D({view:`privacy`,id:n,branch:r})}]:[],{id:`console-open`,title:`Open the console`,group:`Editor`,keys:"Ctrl+`",run:Oe},{id:`theme-light`,title:`Light theme`,group:`Editor`,run:i(`light`)},{id:`theme-dark`,title:`Dark theme`,group:`Editor`,run:i(`dark`)},{id:`theme-auto`,title:`Automatic theme`,group:`Editor`,run:i(`auto`)},...e.forges.map(t=>({id:`add-${t.host}`,title:`Add an account: ${be(t.kind)} · ${t.host}`,group:`Accounts`,run:()=>{location.href=w(t.host,location.pathname+location.search,e.accounts.some(e=>e.forge===t.host))}}))]),null}(0,f.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(d.StrictMode,{children:(0,j.jsx)(qt,{})}));export{i as n,n as r,A as t};