livelocale 0.10.0-next.7 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -636,6 +636,10 @@ on the real page and a before/after table with the check results. Then turn it i
636
636
  replies "Waiting for a maintainer: comment `/livelocale apply`", and nothing is written until a
637
637
  maintainer posts that comment on the issue. Edits the translator saved with "Save anyway" are
638
638
  skipped as `needs --force`; comment `/livelocale apply --force` to include them.
639
+ - **Who can trigger it.** The Action trusts the issue author or the commenter when GitHub marks
640
+ them OWNER, MEMBER or COLLABORATOR on the repository, or when they have write access. In an
641
+ organization that means any member or invited collaborator, even one with read-only access, can
642
+ turn a link into a pull request, but only people with write access can merge it.
639
643
  - **Base branches.** By default every pull request targets the default branch. To let links made
640
644
  from other builds (for example a `staging` deployment) target their own branch, list the
641
645
  branches with `npx livelocale init --share --branches main,staging`. A link from any other
@@ -7,7 +7,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
7
7
  Error generating stack: `+e.message+`
8
8
  `+e.stack}return{value:e,source:t,stack:i,digest:null}}function Ds(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Os(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var ks=typeof WeakMap==`function`?WeakMap:Map;function As(e,t,n){n=ao(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){rl||(rl=!0,il=r),Os(e,t)},n}function js(e,t,n){n=ao(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Os(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){Os(e,t),typeof r!=`function`&&(al===null?al=new Set([this]):al.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function Ms(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new ks;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)||(i.add(n),e=zl.bind(null,e,t,n),t.then(e,e))}function Ns(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null?!0:t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Ps(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=ao(-1,1),t.tag=2,oo(n,t,1))),n.lanes|=1),e)}var Fs=C.ReactCurrentOwner,Is=!1;function Ls(e,t,n,r){t.child=e===null?Ha(t,null,n,r):Va(t,e.child,n,r)}function Rs(e,t,n,r,i){n=n.render;var a=t.ref;return Xa(t,i),r=No(e,t,n,r,a,i),n=Po(),e!==null&&!Is?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ic(e,t,i)):(U&&n&&Sa(t),t.flags|=1,Ls(e,t,r,i),t.child)}function zs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ql(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,Bs(e,t,a,r,i)):(e=Xl(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Mr:n,n(o,r)&&e.ref===t.ref)return ic(e,t,i)}return t.flags|=1,e=Yl(a,r),e.ref=t.ref,e.return=t,t.child=e}function Bs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Mr(a,r)&&e.ref===t.ref)if(Is=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Is=!0);else return t.lanes=e.lanes,ic(e,t,i)}return Us(e,t,n,r,i)}function Vs(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`)if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},H(qc,Kc),Kc|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,H(qc,Kc),Kc|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,H(qc,Kc),Kc|=r}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),H(qc,Kc),Kc|=r;return Ls(e,t,i,n),t.child}function Hs(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Us(e,t,n,r,i){var a=$i(n)?Zi:Yi.current;return a=Qi(t,a),Xa(t,i),n=No(e,t,n,r,a,i),r=Po(),e!==null&&!Is?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ic(e,t,i)):(U&&r&&Sa(t),t.flags|=1,Ls(e,t,n,i),t.child)}function Ws(e,t,n,r,i){if($i(n)){var a=!0;ra(t)}else a=!1;if(Xa(t,i),t.stateNode===null)rc(e,t),Cs(t,n,r),Ts(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=Za(l):(l=$i(n)?Zi:Yi.current,l=Qi(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&ws(t,o,r,l),no=!1;var f=t.memoizedState;o.state=f,lo(t,r,o,i),c=t.memoizedState,s!==r||f!==c||Xi.current||no?(typeof u==`function`&&(bs(t,n,u,r),c=t.memoizedState),(s=no||Ss(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,io(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:ys(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=Za(c):(c=$i(n)?Zi:Yi.current,c=Qi(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&ws(t,o,r,c),no=!1,f=t.memoizedState,o.state=f,lo(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||Xi.current||no?(typeof p==`function`&&(bs(t,n,p,r),m=t.memoizedState),(l=no||Ss(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Gs(e,t,n,r,a,i)}function Gs(e,t,n,r,i,a){Hs(e,t);var o=(t.flags&128)!=0;if(!r&&!o)return i&&ia(t,n,!1),ic(e,t,a);r=t.stateNode,Fs.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Va(t,e.child,null,a),t.child=Va(t,null,s,a)):Ls(e,t,s,a),t.memoizedState=r.state,i&&ia(t,n,!0),t.child}function Ks(e){var t=e.stateNode;t.pendingContext?ta(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ta(e,t.context,!1),_o(e,t.containerInfo)}function qs(e,t,n,r,i){return Pa(),Fa(i),t.flags|=256,Ls(e,t,n,r),t.child}var Js={dehydrated:null,treeContext:null,retryLane:0};function Ys(e){return{baseLanes:e,cachePool:null,transitions:null}}function Xs(e,t,n){var r=t.pendingProps,i=W.current,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(i&2)!=0),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),H(W,i&1),e===null)return Aa(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data===`$!`?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=Ql(o,r,0,null),e=Zl(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=Ys(n),t.memoizedState=Js,e):Zs(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return $s(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Yl(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=Zl(a,o,n,null),a.flags|=2):a=Yl(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?Ys(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=Js,r}return a=e.child,e=a.sibling,r=Yl(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Zs(e,t){return t=Ql({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function Qs(e,t,n,r){return r!==null&&Fa(r),Va(t,e.child,null,n),e=Zs(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function $s(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=Ds(Error(r(422))),Qs(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=Ql({mode:`visible`,children:i.children},a,0,null),o=Zl(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&Va(t,e.child,null,s),t.child.memoizedState=Ys(s),t.memoizedState=Js,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return Qs(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=Ds(o,i,void 0),Qs(e,t,s,i)}if(c=(s&e.childLanes)!==0,Is||c){if(i=X,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,to(e,a),hl(i,e,a,-1))}return kl(),i=Ds(Error(r(421))),Qs(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Vl.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,Ta=Mi(a.nextSibling),wa=t,U=!0,Ea=null,e!==null&&(ha[ga++]=va,ha[ga++]=ya,ha[ga++]=_a,va=e.id,ya=e.overflow,_a=t),t=Zs(t,i.children),t.flags|=4096,t)}function ec(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ya(e.return,t,n)}function tc(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function nc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(Ls(e,t,r.children,n),r=W.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ec(e,n,t);else if(e.tag===19)ec(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(H(W,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&xo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),tc(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&xo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}tc(t,!0,n,null,a);break;case`together`:tc(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function rc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ic(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Yc|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=Yl(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Yl(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function ac(e,t,n){switch(t.tag){case 3:Ks(t),Pa();break;case 5:yo(t);break;case 1:$i(t.type)&&ra(t);break;case 4:_o(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;H(Ua,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(H(W,W.current&1),e=ic(e,t,n),e===null?null:e.sibling):Xs(e,t,n):(H(W,W.current&1),t.flags|=128,null);H(W,W.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return nc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),H(W,W.current),r)break;return null;case 22:case 23:return t.lanes=0,Vs(e,t,n)}return ic(e,t,n)}var oc=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},sc=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,go(po.current);var o=null;switch(n){case`input`:i=_e(e,i),r=_e(e,r),o=[];break;case`select`:i=N({},i,{value:void 0}),r=N({},r,{value:void 0}),o=[];break;case`textarea`:i=Te(e,i),r=Te(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=Si)}Re(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null));for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null))if(u===`style`)if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l;else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&B(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},cc=function(e,t,n,r){n!==r&&(t.flags|=4)};function lc(e,t){if(!U)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function uc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function dc(e,t,n){var i=t.pendingProps;switch(Ca(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return uc(t),null;case 1:return $i(t.type)&&ea(),uc(t),null;case 3:return i=t.stateNode,vo(),V(Xi),V(Yi),Co(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Ma(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ea!==null&&(yl(Ea),Ea=null))),uc(t),null;case 5:bo(t);var o=go(ho.current);if(n=t.type,e!==null&&t.stateNode!=null)sc(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return uc(t),null}if(e=go(po.current),Ma(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[Fi]=t,i[Ii]=s,e=(t.mode&1)!=0,n){case`dialog`:B(`cancel`,i),B(`close`,i);break;case`iframe`:case`object`:case`embed`:B(`load`,i);break;case`video`:case`audio`:for(o=0;o<ai.length;o++)B(ai[o],i);break;case`source`:B(`error`,i);break;case`img`:case`image`:case`link`:B(`error`,i),B(`load`,i);break;case`details`:B(`toggle`,i);break;case`input`:ve(i,s),B(`invalid`,i);break;case`select`:i._wrapperState={wasMultiple:!!s.multiple},B(`invalid`,i);break;case`textarea`:Ee(i,s),B(`invalid`,i)}for(var c in Re(n,s),o=null,s)if(s.hasOwnProperty(c)){var l=s[c];c===`children`?typeof l==`string`?i.textContent!==l&&(!0!==s.suppressHydrationWarning&&xi(i.textContent,l,e),o=[`children`,l]):typeof l==`number`&&i.textContent!==``+l&&(!0!==s.suppressHydrationWarning&&xi(i.textContent,l,e),o=[`children`,``+l]):a.hasOwnProperty(c)&&l!=null&&c===`onScroll`&&B(`scroll`,i)}switch(n){case`input`:me(i),xe(i,s,!0);break;case`textarea`:me(i),De(i);break;case`select`:case`option`:break;default:typeof s.onClick==`function`&&(i.onclick=Si)}i=o,t.updateQueue=i,i!==null&&(t.flags|=4)}else{c=o.nodeType===9?o:o.ownerDocument,e===`http://www.w3.org/1999/xhtml`&&(e=Oe(n)),e===`http://www.w3.org/1999/xhtml`?n===`script`?(e=c.createElement(`div`),e.innerHTML=`<script><\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Fi]=t,e[Ii]=i,oc(e,t,!1,!1),t.stateNode=e;a:{switch(c=ze(n,i),n){case`dialog`:B(`cancel`,e),B(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:B(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;o<ai.length;o++)B(ai[o],e);o=i;break;case`source`:B(`error`,e),o=i;break;case`img`:case`image`:case`link`:B(`error`,e),B(`load`,e),o=i;break;case`details`:B(`toggle`,e),o=i;break;case`input`:ve(e,i),o=_e(e,i),B(`invalid`,e);break;case`option`:o=i;break;case`select`:e._wrapperState={wasMultiple:!!i.multiple},o=N({},i,{value:void 0}),B(`invalid`,e);break;case`textarea`:Ee(e,i),o=Te(e,i),B(`invalid`,e);break;default:o=i}for(s in Re(n,o),l=o,l)if(l.hasOwnProperty(s)){var u=l[s];s===`style`?Ie(e,u):s===`dangerouslySetInnerHTML`?(u=u?u.__html:void 0,u!=null&&je(e,u)):s===`children`?typeof u==`string`?(n!==`textarea`||u!==``)&&Me(e,u):typeof u==`number`&&Me(e,``+u):s!==`suppressContentEditableWarning`&&s!==`suppressHydrationWarning`&&s!==`autoFocus`&&(a.hasOwnProperty(s)?u!=null&&s===`onScroll`&&B(`scroll`,e):u!=null&&S(e,s,u,c))}switch(n){case`input`:me(e),xe(e,i,!1);break;case`textarea`:me(e),De(e);break;case`option`:i.value!=null&&e.setAttribute(`value`,``+de(i.value));break;case`select`:e.multiple=!!i.multiple,s=i.value,s==null?i.defaultValue!=null&&we(e,!!i.multiple,i.defaultValue,!0):we(e,!!i.multiple,s,!1);break;default:typeof o.onClick==`function`&&(e.onclick=Si)}switch(n){case`button`:case`input`:case`select`:case`textarea`:i=!!i.autoFocus;break a;case`img`:i=!0;break a;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return uc(t),null;case 6:if(e&&t.stateNode!=null)cc(e,t,e.memoizedProps,i);else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(n=go(ho.current),go(po.current),Ma(t)){if(i=t.stateNode,n=t.memoizedProps,i[Fi]=t,(s=i.nodeValue!==n)&&(e=wa,e!==null))switch(e.tag){case 3:xi(i.nodeValue,n,(e.mode&1)!=0);break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&xi(i.nodeValue,n,(e.mode&1)!=0)}s&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[Fi]=t,t.stateNode=i}return uc(t),null;case 13:if(V(W),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(U&&Ta!==null&&t.mode&1&&!(t.flags&128))Na(),Pa(),t.flags|=98560,s=!1;else if(s=Ma(t),i!==null&&i.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s===null?null:s.dehydrated,!s)throw Error(r(317));s[Fi]=t}else Pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;uc(t),s=!1}else Ea!==null&&(yl(Ea),Ea=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||W.current&1?Q===0&&(Q=3):kl())),t.updateQueue!==null&&(t.flags|=4),uc(t),null);case 4:return vo(),e===null&&di(t.stateNode.containerInfo),uc(t),null;case 10:return Ja(t.type._context),uc(t),null;case 17:return $i(t.type)&&ea(),uc(t),null;case 19:if(V(W),s=t.memoizedState,s===null)return uc(t),null;if(i=(t.flags&128)!=0,c=s.rendering,c===null)if(i)lc(s,!1);else{if(Q!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=xo(e),c!==null){for(t.flags|=128,lc(s,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)s=n,e=i,s.flags&=14680066,c=s.alternate,c===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return H(W,W.current&1|2),t.child}e=e.sibling}s.tail!==null&&R()>tl&&(t.flags|=128,i=!0,lc(s,!1),t.lanes=4194304)}else{if(!i)if(e=xo(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),lc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!U)return uc(t),null}else 2*R()-s.renderingStartTime>tl&&n!==1073741824&&(t.flags|=128,i=!0,lc(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(uc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=R(),t.sibling=null,n=W.current,H(W,i?n&1|2:n&1),t);case 22:case 23:return Tl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Kc&1073741824&&(uc(t),t.subtreeFlags&6&&(t.flags|=8192)):uc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function fc(e,t){switch(Ca(t),t.tag){case 1:return $i(t.type)&&ea(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vo(),V(Xi),V(Yi),Co(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return bo(t),null;case 13:if(V(W),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return V(W),null;case 4:return vo(),null;case 10:return Ja(t.type._context),null;case 22:case 23:return Tl(),null;case 24:return null;default:return null}}var pc=!1,mc=!1,hc=typeof WeakSet==`function`?WeakSet:Set,J=null;function gc(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){$(e,t,n)}else n.current=null}function _c(e,t,n){try{n()}catch(n){$(e,t,n)}}var vc=!1;function yc(e,t){if(Ci=hn,e=Ir(),Lr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(wi={focusedElem:e,selectionRange:n},hn=!1,J=t;J!==null;)if(t=J,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,J=e;else for(;J!==null;){t=J;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:ys(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){$(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,J=e;break}J=t.return}return h=vc,vc=!1,h}function bc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&_c(t,n,a)}i=i.next}while(i!==r)}}function xc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Sc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function Cc(e){var t=e.alternate;t!==null&&(e.alternate=null,Cc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Fi],delete t[Ii],delete t[Ri],delete t[zi],delete t[Bi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function wc(e){return e.tag===5||e.tag===3||e.tag===4}function Tc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||wc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ec(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Si));else if(r!==4&&(e=e.child,e!==null))for(Ec(e,t,n),e=e.sibling;e!==null;)Ec(e,t,n),e=e.sibling}function Dc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Dc(e,t,n),e=e.sibling;e!==null;)Dc(e,t,n),e=e.sibling}var Oc=null,kc=!1;function Ac(e,t,n){for(n=n.child;n!==null;)jc(e,t,n),n=n.sibling}function jc(e,t,n){if(Tt&&typeof Tt.onCommitFiberUnmount==`function`)try{Tt.onCommitFiberUnmount(wt,n)}catch{}switch(n.tag){case 5:mc||gc(n,t);case 6:var r=Oc,i=kc;Oc=null,Ac(e,t,n),Oc=r,kc=i,Oc!==null&&(kc?(e=Oc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Oc.removeChild(n.stateNode));break;case 18:Oc!==null&&(kc?(e=Oc,n=n.stateNode,e.nodeType===8?ji(e.parentNode,n):e.nodeType===1&&ji(e,n),pn(e)):ji(Oc,n.stateNode));break;case 4:r=Oc,i=kc,Oc=n.stateNode.containerInfo,kc=!0,Ac(e,t,n),Oc=r,kc=i;break;case 0:case 11:case 14:case 15:if(!mc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&_c(n,t,o),i=i.next}while(i!==r)}Ac(e,t,n);break;case 1:if(!mc&&(gc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){$(n,t,e)}Ac(e,t,n);break;case 21:Ac(e,t,n);break;case 22:n.mode&1?(mc=(r=mc)||n.memoizedState!==null,Ac(e,t,n),mc=r):Ac(e,t,n);break;default:Ac(e,t,n)}}function Mc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new hc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Nc(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i];try{var o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 5:Oc=c.stateNode,kc=!1;break a;case 3:Oc=c.stateNode.containerInfo,kc=!0;break a;case 4:Oc=c.stateNode.containerInfo,kc=!0;break a}c=c.return}if(Oc===null)throw Error(r(160));jc(o,s,a),Oc=null,kc=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(e){$(a,t,e)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Pc(t,e),t=t.sibling}function Pc(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Nc(t,e),Fc(e),i&4){try{bc(3,e,e.return),xc(3,e)}catch(t){$(e,e.return,t)}try{bc(5,e,e.return)}catch(t){$(e,e.return,t)}}break;case 1:Nc(t,e),Fc(e),i&512&&n!==null&&gc(n,n.return);break;case 5:if(Nc(t,e),Fc(e),i&512&&n!==null&&gc(n,n.return),e.flags&32){var a=e.stateNode;try{Me(a,``)}catch(t){$(e,e.return,t)}}if(i&4&&(a=e.stateNode,a!=null)){var o=e.memoizedProps,s=n===null?o:n.memoizedProps,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c===`input`&&o.type===`radio`&&o.name!=null&&ye(a,o),ze(c,s);var u=ze(c,o);for(s=0;s<l.length;s+=2){var d=l[s],f=l[s+1];d===`style`?Ie(a,f):d===`dangerouslySetInnerHTML`?je(a,f):d===`children`?Me(a,f):S(a,d,f,u)}switch(c){case`input`:be(a,o);break;case`textarea`:I(a,o);break;case`select`:var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m==null?p!==!!o.multiple&&(o.defaultValue==null?we(a,!!o.multiple,o.multiple?[]:``,!1):we(a,!!o.multiple,o.defaultValue,!0)):we(a,!!o.multiple,m,!1)}a[Ii]=o}catch(t){$(e,e.return,t)}}break;case 6:if(Nc(t,e),Fc(e),i&4){if(e.stateNode===null)throw Error(r(162));a=e.stateNode,o=e.memoizedProps;try{a.nodeValue=o}catch(t){$(e,e.return,t)}}break;case 3:if(Nc(t,e),Fc(e),i&4&&n!==null&&n.memoizedState.isDehydrated)try{pn(t.containerInfo)}catch(t){$(e,e.return,t)}break;case 4:Nc(t,e),Fc(e);break;case 13:Nc(t,e),Fc(e),a=e.child,a.flags&8192&&(o=a.memoizedState!==null,a.stateNode.isHidden=o,!o||a.alternate!==null&&a.alternate.memoizedState!==null||(el=R())),i&4&&Mc(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(mc=(u=mc)||d,Nc(t,e),mc=u):Nc(t,e),Fc(e),i&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(J=e,d=e.child;d!==null;){for(f=J=d;J!==null;){switch(p=J,m=p.child,p.tag){case 0:case 11:case 14:case 15:bc(4,p,p.return);break;case 1:gc(p,p.return);var h=p.stateNode;if(typeof h.componentWillUnmount==`function`){i=p,n=p.return;try{t=i,h.props=t.memoizedProps,h.state=t.memoizedState,h.componentWillUnmount()}catch(e){$(i,n,e)}}break;case 5:gc(p,p.return);break;case 22:if(p.memoizedState!==null){zc(f);continue}}m===null?zc(f):(m.return=p,J=m)}d=d.sibling}a:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{a=f.stateNode,u?(o=a.style,typeof o.setProperty==`function`?o.setProperty(`display`,`none`,`important`):o.display=`none`):(c=f.stateNode,l=f.memoizedProps.style,s=l!=null&&l.hasOwnProperty(`display`)?l.display:null,c.style.display=Fe(`display`,s))}catch(t){$(e,e.return,t)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?``:f.memoizedProps}catch(t){$(e,e.return,t)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break a;for(;f.sibling===null;){if(f.return===null||f.return===e)break a;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Nc(t,e),Fc(e),i&4&&Mc(e);break;case 21:break;default:Nc(t,e),Fc(e)}}function Fc(e){var t=e.flags;if(t&2){try{a:{for(var n=e.return;n!==null;){if(wc(n)){var i=n;break a}n=n.return}throw Error(r(160))}switch(i.tag){case 5:var a=i.stateNode;i.flags&32&&(Me(a,``),i.flags&=-33),Dc(e,Tc(e),a);break;case 3:case 4:var o=i.stateNode.containerInfo;Ec(e,Tc(e),o);break;default:throw Error(r(161))}}catch(t){$(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Ic(e,t,n){J=e,Lc(e,t,n)}function Lc(e,t,n){for(var r=(e.mode&1)!=0;J!==null;){var i=J,a=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||pc;if(!o){var s=i.alternate,c=s!==null&&s.memoizedState!==null||mc;s=pc;var l=mc;if(pc=o,(mc=c)&&!l)for(J=i;J!==null;)o=J,c=o.child,o.tag===22&&o.memoizedState!==null||c===null?Bc(i):(c.return=o,J=c);for(;a!==null;)J=a,Lc(a,t,n),a=a.sibling;J=i,pc=s,mc=l}Rc(e,t,n)}else i.subtreeFlags&8772&&a!==null?(a.return=i,J=a):Rc(e,t,n)}}function Rc(e){for(;J!==null;){var t=J;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:mc||xc(5,t);break;case 1:var i=t.stateNode;if(t.flags&4&&!mc)if(n===null)i.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:ys(t.type,n.memoizedProps);i.componentDidUpdate(a,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&uo(t,o,i);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}uo(t,s,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case`button`:case`input`:case`select`:case`textarea`:l.autoFocus&&n.focus();break;case`img`:l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&pn(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}mc||t.flags&512&&Sc(t)}catch(e){$(t,t.return,e)}}if(t===e){J=null;break}if(n=t.sibling,n!==null){n.return=t.return,J=n;break}J=t.return}}function zc(e){for(;J!==null;){var t=J;if(t===e){J=null;break}var n=t.sibling;if(n!==null){n.return=t.return,J=n;break}J=t.return}}function Bc(e){for(;J!==null;){var t=J;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{xc(4,t)}catch(e){$(t,n,e)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount==`function`){var i=t.return;try{r.componentDidMount()}catch(e){$(t,i,e)}}var a=t.return;try{Sc(t)}catch(e){$(t,a,e)}break;case 5:var o=t.return;try{Sc(t)}catch(e){$(t,o,e)}}}catch(e){$(t,t.return,e)}if(t===e){J=null;break}var s=t.sibling;if(s!==null){s.return=t.return,J=s;break}J=t.return}}var Vc=Math.ceil,Hc=C.ReactCurrentDispatcher,Uc=C.ReactCurrentOwner,Wc=C.ReactCurrentBatchConfig,Y=0,X=null,Z=null,Gc=0,Kc=0,qc=qi(0),Q=0,Jc=null,Yc=0,Xc=0,Zc=0,Qc=null,$c=null,el=0,tl=1/0,nl=null,rl=!1,il=null,al=null,ol=!1,sl=null,cl=0,ll=0,ul=null,dl=-1,fl=0;function pl(){return Y&6?R():dl===-1?dl=R():dl}function ml(e){return e.mode&1?Y&2&&Gc!==0?Gc&-Gc:Ia.transition===null?(e=z,e===0?(e=window.event,e=e===void 0?16:xn(e.type),e):e):(fl===0&&(fl=Rt()),fl):1}function hl(e,t,n,i){if(50<ll)throw ll=0,ul=null,Error(r(185));Bt(e,n,i),(!(Y&2)||e!==X)&&(e===X&&(!(Y&2)&&(Xc|=n),Q===4&&xl(e,Gc)),gl(e,i),n===1&&Y===0&&!(t.mode&1)&&(tl=R()+500,oa&&ua()))}function gl(e,t){var n=e.callbackNode;It(e,t);var r=Pt(e,e===X?Gc:0);if(r===0)n!==null&&ht(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&ht(n),t===1)e.tag===0?la(Sl.bind(null,e)):ca(Sl.bind(null,e)),ki(function(){!(Y&6)&&ua()}),n=null;else{switch(Ut(r)){case 1:n=yt;break;case 4:n=bt;break;case 16:n=xt;break;case 536870912:n=Ct;break;default:n=xt}n=Wl(n,_l.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function _l(e,t){if(dl=-1,fl=0,Y&6)throw Error(r(327));var n=e.callbackNode;if(Ll()&&e.callbackNode!==n)return null;var i=Pt(e,e===X?Gc:0);if(i===0)return null;if(i&30||(i&e.expiredLanes)!==0||t)t=Al(e,i);else{t=i;var a=Y;Y|=2;var o=Ol();(X!==e||Gc!==t)&&(nl=null,tl=R()+500,El(e,t));do try{Ml();break}catch(t){Dl(e,t)}while(1);qa(),Hc.current=o,Y=a,Z===null?(X=null,Gc=0,t=Q):t=0}if(t!==0){if(t===2&&(a=Lt(e),a!==0&&(i=a,t=vl(e,a))),t===1)throw n=Jc,El(e,0),xl(e,i),gl(e,R()),n;if(t===6)xl(e,i);else{if(a=e.current.alternate,!(i&30)&&!bl(a)&&(t=Al(e,i),t===2&&(o=Lt(e),o!==0&&(i=o,t=vl(e,o))),t===1))throw n=Jc,El(e,0),xl(e,i),gl(e,R()),n;switch(e.finishedWork=a,e.finishedLanes=i,t){case 0:case 1:throw Error(r(345));case 2:Fl(e,$c,nl);break;case 3:if(xl(e,i),(i&130023424)===i&&(t=el+500-R(),10<t)){if(Pt(e,0)!==0)break;if(a=e.suspendedLanes,(a&i)!==i){pl(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Ei(Fl.bind(null,e,$c,nl),t);break}Fl(e,$c,nl);break;case 4:if(xl(e,i),(i&4194240)===i)break;for(t=e.eventTimes,a=-1;0<i;){var s=31-Dt(i);o=1<<s,s=t[s],s>a&&(a=s),i&=~o}if(i=a,i=R()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Vc(i/1960))-i,10<i){e.timeoutHandle=Ei(Fl.bind(null,e,$c,nl),i);break}Fl(e,$c,nl);break;case 5:Fl(e,$c,nl);break;default:throw Error(r(329))}}}return gl(e,R()),e.callbackNode===n?_l.bind(null,e):null}function vl(e,t){var n=Qc;return e.current.memoizedState.isDehydrated&&(El(e,t).flags|=256),e=Al(e,t),e!==2&&(t=$c,$c=n,t!==null&&yl(t)),e}function yl(e){$c===null?$c=e:$c.push.apply($c,e)}function bl(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!jr(a(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function xl(e,t){for(t&=~Zc,t&=~Xc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Dt(t),r=1<<n;e[n]=-1,t&=~r}}function Sl(e){if(Y&6)throw Error(r(327));Ll();var t=Pt(e,0);if(!(t&1))return gl(e,R()),null;var n=Al(e,t);if(e.tag!==0&&n===2){var i=Lt(e);i!==0&&(t=i,n=vl(e,i))}if(n===1)throw n=Jc,El(e,0),xl(e,t),gl(e,R()),n;if(n===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Fl(e,$c,nl),gl(e,R()),null}function Cl(e,t){var n=Y;Y|=1;try{return e(t)}finally{Y=n,Y===0&&(tl=R()+500,oa&&ua())}}function wl(e){sl!==null&&sl.tag===0&&!(Y&6)&&Ll();var t=Y;Y|=1;var n=Wc.transition,r=z;try{if(Wc.transition=null,z=1,e)return e()}finally{z=r,Wc.transition=n,Y=t,!(Y&6)&&ua()}}function Tl(){Kc=qc.current,V(qc)}function El(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Di(n)),Z!==null)for(n=Z.return;n!==null;){var r=n;switch(Ca(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&ea();break;case 3:vo(),V(Xi),V(Yi),Co();break;case 5:bo(r);break;case 4:vo();break;case 13:V(W);break;case 19:V(W);break;case 10:Ja(r.type._context);break;case 22:case 23:Tl()}n=n.return}if(X=e,Z=e=Yl(e.current,null),Gc=Kc=t,Q=0,Jc=null,Zc=Xc=Yc=0,$c=Qc=null,Qa!==null){for(t=0;t<Qa.length;t++)if(n=Qa[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,a=n.pending;if(a!==null){var o=a.next;a.next=i,r.next=o}n.pending=r}Qa=null}return e}function Dl(e,t){do{var n=Z;try{if(qa(),wo.current=hs,Do){for(var i=G.memoizedState;i!==null;){var a=i.queue;a!==null&&(a.pending=null),i=i.next}Do=!1}if(Eo=0,q=K=G=null,Oo=!1,ko=0,Uc.current=null,n===null||n.return===null){Q=1,Jc=t,Z=null;break}a:{var o=e,s=n.return,c=n,l=t;if(t=Gc,c.flags|=32768,typeof l==`object`&&l&&typeof l.then==`function`){var u=l,d=c,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=Ns(s);if(m!==null){m.flags&=-257,Ps(m,s,c,o,t),m.mode&1&&Ms(o,u,t),t=m,l=u;var h=t.updateQueue;if(h===null){var g=new Set;g.add(l),t.updateQueue=g}else h.add(l);break a}else{if(!(t&1)){Ms(o,u,t),kl();break a}l=Error(r(426))}}else if(U&&c.mode&1){var _=Ns(s);if(_!==null){!(_.flags&65536)&&(_.flags|=256),Ps(_,s,c,o,t),Fa(Es(l,c));break a}}o=l=Es(l,c),Q!==4&&(Q=2),Qc===null?Qc=[o]:Qc.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=As(o,l,t);co(o,v);break a;case 1:c=l;var y=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof y.getDerivedStateFromError==`function`||b!==null&&typeof b.componentDidCatch==`function`&&(al===null||!al.has(b)))){o.flags|=65536,t&=-t,o.lanes|=t;var x=js(o,c,t);co(o,x);break a}}o=o.return}while(o!==null)}Pl(n)}catch(e){t=e,Z===n&&n!==null&&(Z=n=n.return);continue}break}while(1)}function Ol(){var e=Hc.current;return Hc.current=hs,e===null?hs:e}function kl(){(Q===0||Q===3||Q===2)&&(Q=4),X===null||!(Yc&268435455)&&!(Xc&268435455)||xl(X,Gc)}function Al(e,t){var n=Y;Y|=2;var i=Ol();(X!==e||Gc!==t)&&(nl=null,El(e,t));do try{jl();break}catch(t){Dl(e,t)}while(1);if(qa(),Y=n,Hc.current=i,Z!==null)throw Error(r(261));return X=null,Gc=0,Q}function jl(){for(;Z!==null;)Nl(Z)}function Ml(){for(;Z!==null&&!gt();)Nl(Z)}function Nl(e){var t=Ul(e.alternate,e,Kc);e.memoizedProps=e.pendingProps,t===null?Pl(e):Z=t,Uc.current=null}function Pl(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=fc(n,t),n!==null){n.flags&=32767,Z=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Q=6,Z=null;return}}else if(n=dc(n,t,Kc),n!==null){Z=n;return}if(t=t.sibling,t!==null){Z=t;return}Z=t=e}while(t!==null);Q===0&&(Q=5)}function Fl(e,t,n){var r=z,i=Wc.transition;try{Wc.transition=null,z=1,Il(e,t,n,r)}finally{Wc.transition=i,z=r}return null}function Il(e,t,n,i){do Ll();while(sl!==null);if(Y&6)throw Error(r(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(Vt(e,o),e===X&&(Z=X=null,Gc=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||ol||(ol=!0,Wl(xt,function(){return Ll(),null})),o=(n.flags&15990)!=0,n.subtreeFlags&15990||o){o=Wc.transition,Wc.transition=null;var s=z;z=1;var c=Y;Y|=4,Uc.current=null,yc(e,n),Pc(n,e),Rr(wi),hn=!!Ci,wi=Ci=null,e.current=n,Ic(n,e,a),_t(),Y=c,z=s,Wc.transition=o}else e.current=n;if(ol&&(ol=!1,sl=e,cl=a),o=e.pendingLanes,o===0&&(al=null),Et(n.stateNode,i),gl(e,R()),t!==null)for(i=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],i(a.value,{componentStack:a.stack,digest:a.digest});if(rl)throw rl=!1,e=il,il=null,e;return cl&1&&e.tag!==0&&Ll(),o=e.pendingLanes,o&1?e===ul?ll++:(ll=0,ul=e):ll=0,ua(),null}function Ll(){if(sl!==null){var e=Ut(cl),t=Wc.transition,n=z;try{if(Wc.transition=null,z=16>e?16:e,sl===null)var i=!1;else{if(e=sl,sl=null,cl=0,Y&6)throw Error(r(331));var a=Y;for(Y|=4,J=e.current;J!==null;){var o=J,s=o.child;if(J.flags&16){var c=o.deletions;if(c!==null){for(var l=0;l<c.length;l++){var u=c[l];for(J=u;J!==null;){var d=J;switch(d.tag){case 0:case 11:case 15:bc(8,d,o)}var f=d.child;if(f!==null)f.return=d,J=f;else for(;J!==null;){d=J;var p=d.sibling,m=d.return;if(Cc(d),d===u){J=null;break}if(p!==null){p.return=m,J=p;break}J=m}}}var h=o.alternate;if(h!==null){var g=h.child;if(g!==null){h.child=null;do{var _=g.sibling;g.sibling=null,g=_}while(g!==null)}}J=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,J=s;else b:for(;J!==null;){if(o=J,o.flags&2048)switch(o.tag){case 0:case 11:case 15:bc(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,J=v;break b}J=o.return}}var y=e.current;for(J=y;J!==null;){s=J;var b=s.child;if(s.subtreeFlags&2064&&b!==null)b.return=s,J=b;else b:for(s=y;J!==null;){if(c=J,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:xc(9,c)}}catch(e){$(c,c.return,e)}if(c===s){J=null;break b}var x=c.sibling;if(x!==null){x.return=c.return,J=x;break b}J=c.return}}if(Y=a,ua(),Tt&&typeof Tt.onPostCommitFiberRoot==`function`)try{Tt.onPostCommitFiberRoot(wt,e)}catch{}i=!0}return i}finally{z=n,Wc.transition=t}}return!1}function Rl(e,t,n){t=Es(n,t),t=As(e,t,1),e=oo(e,t,1),t=pl(),e!==null&&(Bt(e,1,t),gl(e,t))}function $(e,t,n){if(e.tag===3)Rl(e,e,n);else for(;t!==null;){if(t.tag===3){Rl(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(al===null||!al.has(r))){e=Es(n,e),e=js(t,e,1),t=oo(t,e,1),e=pl(),t!==null&&(Bt(t,1,e),gl(t,e));break}}t=t.return}}function zl(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=pl(),e.pingedLanes|=e.suspendedLanes&n,X===e&&(Gc&n)===n&&(Q===4||Q===3&&(Gc&130023424)===Gc&&500>R()-el?El(e,0):Zc|=n),gl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=Mt,Mt<<=1,!(Mt&130023424)&&(Mt=4194304)):t=1);var n=pl();e=to(e,t),e!==null&&(Bt(e,t,n),gl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Xi.current)Is=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Is=!1,ac(e,t,n);Is=!!(e.flags&131072)}else Is=!1,U&&t.flags&1048576&&xa(t,ma,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;rc(e,t),e=t.pendingProps;var a=Qi(t,Yi.current);Xa(t,n),a=No(null,t,i,e,a,n);var o=Po();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,$i(i)?(o=!0,ra(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,ro(t),a.updater=xs,t.stateNode=a,a._reactInternals=t,Ts(t,i,e,n),t=Gs(null,t,i,!0,o,n)):(t.tag=0,U&&o&&Sa(t),Ls(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(rc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=Jl(i),e=ys(i,e),a){case 0:t=Us(null,t,i,e,n);break a;case 1:t=Ws(null,t,i,e,n);break a;case 11:t=Rs(null,t,i,e,n);break a;case 14:t=zs(null,t,i,ys(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ys(i,a),Us(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ys(i,a),Ws(e,t,i,a,n);case 3:a:{if(Ks(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,io(e,t),lo(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Es(Error(r(423)),t),t=qs(e,t,i,n,a);break a}else if(i!==a){a=Es(Error(r(424)),t),t=qs(e,t,i,n,a);break a}else for(Ta=Mi(t.stateNode.containerInfo.firstChild),wa=t,U=!0,Ea=null,n=Ha(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Pa(),i===a){t=ic(e,t,n);break a}Ls(e,t,i,n)}t=t.child}return t;case 5:return yo(t),e===null&&Aa(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,Ti(i,a)?s=null:o!==null&&Ti(i,o)&&(t.flags|=32),Hs(e,t),Ls(e,t,s,n),t.child;case 6:return e===null&&Aa(t),null;case 13:return Xs(e,t,n);case 4:return _o(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Va(t,null,i,n):Ls(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ys(i,a),Rs(e,t,i,a,n);case 7:return Ls(e,t,t.pendingProps,n),t.child;case 8:return Ls(e,t,t.pendingProps.children,n),t.child;case 12:return Ls(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,H(Ua,i._currentValue),i._currentValue=s,o!==null)if(jr(o.value,s)){if(o.children===a.children&&!Xi.current){t=ic(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=ao(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Ya(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Ya(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Ls(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Xa(t,n),a=Za(a),i=i(a),t.flags|=1,Ls(e,t,i,n),t.child;case 14:return i=t.type,a=ys(i,t.pendingProps),a=ys(i.type,a),zs(e,t,i,a,n);case 15:return Bs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ys(i,a),rc(e,t),t.tag=1,$i(i)?(e=!0,ra(t)):e=!1,Xa(t,n),Cs(t,i,a),Ts(t,i,a,n),Gs(null,t,i,!0,e,n);case 19:return nc(e,t,n);case 22:return Vs(e,t,n)}throw Error(r(156,t.tag))};function Wl(e,t){return mt(e,t)}function Gl(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===A)return 11;if(e===M)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Xl(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return Zl(n.children,a,o,t);case D:s=8,a|=8;break;case O:return e=Kl(12,n,t,a|2),e.elementType=O,e.lanes=o,e;case j:return e=Kl(13,n,t,a),e.elementType=j,e.lanes=o,e;case te:return e=Kl(19,n,t,a),e.elementType=te,e.lanes=o,e;case re:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case k:s=10;break a;case ee:s=9;break a;case A:s=11;break a;case M:s=14;break a;case ne:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=re,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zt(0),this.expirationTimes=zt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ro(a),e}function ru(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:T,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}function iu(e){if(!e)return Ji;e=e._reactInternals;a:{if(ct(e)!==e||e.tag!==1)throw Error(r(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break a;case 1:if($i(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break a}}t=t.return}while(t!==null);throw Error(r(171))}if(e.tag===1){var n=e.type;if($i(n))return na(e,n,t)}return t}function au(e,t,n,r,i,a,o,s,c){return e=nu(n,r,!0,e,i,a,o,s,c),e.context=iu(null),n=e.current,r=pl(),i=ml(n),a=ao(r,i),a.callback=t??null,oo(n,a,i),e.current.lanes=i,Bt(e,i,r),gl(e,r),e}function ou(e,t,n,r){var i=t.current,a=pl(),o=ml(i);return n=iu(n),t.context===null?t.context=n:t.pendingContext=n,t=ao(a,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=oo(i,t,o),e!==null&&(hl(e,i,o,a),so(e,i,o)),o}function su(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function cu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function lu(e,t){cu(e,t),(e=e.alternate)&&cu(e,t)}function uu(){return null}var du=typeof reportError==`function`?reportError:function(e){console.error(e)};function fu(e){this._internalRoot=e}pu.prototype.render=fu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));ou(e,t,null,null)},pu.prototype.unmount=fu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;wl(function(){ou(null,e,null,null)}),t[Li]=null}};function pu(e){this._internalRoot=e}pu.prototype.unstable_scheduleHydration=function(e){if(e){var t=qt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<nn.length&&t!==0&&t<nn[n].priority;n++);nn.splice(n,0,e),n===0&&cn(e)}};function mu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function hu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==` react-mount-point-unstable `))}function gu(){}function _u(e,t,n,r,i){if(i){if(typeof r==`function`){var a=r;r=function(){var e=su(o);a.call(e)}}var o=au(t,r,e,0,null,!1,!1,``,gu);return e._reactRootContainer=o,e[Li]=o.current,di(e.nodeType===8?e.parentNode:e),wl(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r==`function`){var s=r;r=function(){var e=su(c);s.call(e)}}var c=nu(e,0,!1,null,null,!1,!1,``,gu);return e._reactRootContainer=c,e[Li]=c.current,di(e.nodeType===8?e.parentNode:e),wl(function(){ou(t,c,n,r)}),c}function vu(e,t,n,r,i){var a=n._reactRootContainer;if(a){var o=a;if(typeof i==`function`){var s=i;i=function(){var e=su(o);s.call(e)}}ou(t,o,e,i)}else o=_u(n,t,e,i,r);return su(o)}Wt=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Nt(t.pendingLanes);n!==0&&(Ht(t,n|1),gl(t,R()),!(Y&6)&&(tl=R()+500,ua()))}break;case 13:wl(function(){var t=to(e,1);t!==null&&hl(t,e,1,pl())}),lu(e,1)}},Gt=function(e){if(e.tag===13){var t=to(e,134217728);t!==null&&hl(t,e,134217728,pl()),lu(e,134217728)}},Kt=function(e){if(e.tag===13){var t=ml(e),n=to(e,t);n!==null&&hl(n,e,t,pl()),lu(e,t)}},qt=function(){return z},Jt=function(e,t){var n=z;try{return z=e,t()}finally{z=n}},He=function(e,t,n){switch(t){case`input`:if(be(e,n),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name=`+JSON.stringify(``+t)+`][type="radio"]`),t=0;t<n.length;t++){var i=n[t];if(i!==e&&i.form===e.form){var a=Wi(i);if(!a)throw Error(r(90));he(i),be(i,a)}}}break;case`textarea`:I(e,n);break;case`select`:t=n.value,t!=null&&we(e,!!n.multiple,t,!1)}},qe=Cl,Je=wl;var yu={usingClientEntryPoint:!1,Events:[Hi,Ui,Wi,Ge,Ke,Cl]},bu={findFiberByHostInstance:Vi,bundleType:0,version:`18.3.1`,rendererPackageName:`react-dom`},xu={bundleType:bu.bundleType,version:bu.version,rendererPackageName:bu.rendererPackageName,rendererConfig:bu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=ft(e),e===null?null:e.stateNode},findFiberByHostInstance:bu.findFiberByHostInstance||uu,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:`18.3.1-next-f1338f8080-20240426`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Su=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Su.isDisabled&&Su.supportsFiber)try{wt=Su.inject(xu),Tt=Su}catch{}}e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=yu,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!mu(t))throw Error(r(200));return ru(e,t,null,n)},e.createRoot=function(e,t){if(!mu(e))throw Error(r(299));var n=!1,i=``,a=du;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=nu(e,1,!1,null,null,n,!1,i,a),e[Li]=t.current,di(e.nodeType===8?e.parentNode:e),new fu(t)},e.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=ft(t),e=e===null?null:e.stateNode,e},e.flushSync=function(e){return wl(e)},e.hydrate=function(e,t,n){if(!hu(t))throw Error(r(200));return vu(null,e,t,!0,n)},e.hydrateRoot=function(e,t,n){if(!mu(e))throw Error(r(405));var i=n!=null&&n.hydratedSources||null,a=!1,o=``,s=du;if(n!=null&&(!0===n.unstable_strictMode&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=au(t,null,e,1,n??null,a,!1,o,s),e[Li]=t.current,di(e),i)for(e=0;e<i.length;e++)n=i[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new pu(t)},e.render=function(e,t,n){if(!hu(t))throw Error(r(200));return vu(null,e,t,!1,n)},e.unmountComponentAtNode=function(e){if(!hu(e))throw Error(r(40));return e._reactRootContainer?(wl(function(){vu(null,null,e,!1,function(){e._reactRootContainer=null,e[Li]=null})}),!0):!1},e.unstable_batchedUpdates=Cl,e.unstable_renderSubtreeIntoContainer=function(e,t,n,i){if(!hu(n))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return vu(e,t,n,!1,i)},e.version=`18.3.1-next-f1338f8080-20240426`})),m=o(((e,t)=>{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=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),g=c(u(),1),_=c(h(),1),v=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),y=o(((e,t)=>{t.exports=v()}))(),b=8e3,x=({iframeRef:e,appOrigin:t,appUrl:n,connectionStatus:r})=>{let[i,a]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{if(a(!1),r!==`connecting`)return;let e=setTimeout(()=>a(!0),b);return()=>clearTimeout(e)},[r]),(0,y.jsxs)(`div`,{className:`flex-1 flex flex-col h-full bg-slate-900 border border-slate-800 rounded-2xl overflow-hidden shadow-2xl relative`,children:[(0,y.jsxs)(`div`,{className:`h-14 bg-slate-950 border-b border-slate-800 flex items-center justify-between px-6 select-none shrink-0`,children:[(0,y.jsx)(`div`,{className:`flex items-center gap-3 w-1/3`,children:(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`w-3 h-3 rounded-full bg-rose-500/80`}),(0,y.jsx)(`span`,{className:`w-3 h-3 rounded-full bg-amber-500/80`}),(0,y.jsx)(`span`,{className:`w-3 h-3 rounded-full bg-emerald-500/80`})]})}),(0,y.jsxs)(`div`,{className:`flex items-center gap-4 w-1/3 justify-end`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[10px] font-semibold tracking-wider text-slate-500 uppercase`,children:`Status`}),(0,y.jsx)(`span`,{className:`px-2 py-0.5 rounded text-[10px] font-bold ${r===`connected`?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:r===`connecting`?`bg-amber-500/10 text-amber-400 border border-amber-500/20 animate-pulse`:`bg-rose-500/10 text-rose-400 border border-rose-500/20`}`,children:r===`connected`?`ACTIVE`:`CONNECTING`})]}),(0,y.jsx)(`button`,{onClick:()=>{e.current&&(e.current.src=e.current.src)},className:`p-1.5 hover:bg-slate-800 text-slate-400 hover:text-slate-200 rounded-lg transition duration-200 border border-transparent hover:border-slate-700`,title:`Reload Frame`,children:(0,y.jsxs)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,viewBox:`0 0 24 24`,children:[(0,y.jsx)(`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`}),(0,y.jsx)(`path`,{d:`M21 3v5h-5`})]})})]})]}),(0,y.jsxs)(`div`,{className:`flex-1 bg-slate-900 relative`,children:[(0,y.jsx)(`iframe`,{id:`app-preview-iframe`,ref:e,src:`${n}?livelocale-origin=${encodeURIComponent(window.location.origin)}`,className:`w-full h-full border-none bg-white`,sandbox:`allow-same-origin allow-scripts allow-forms allow-popups`}),r===`connecting`&&(0,y.jsxs)(`div`,{className:`absolute inset-0 bg-slate-950/80 backdrop-blur-sm flex flex-col items-center justify-center gap-4 transition duration-300`,children:[(0,y.jsxs)(`div`,{className:`relative w-12 h-12`,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-indigo-500/20`}),(0,y.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-t-indigo-500 animate-spin`})]}),(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h3`,{className:`text-slate-200 font-semibold tracking-wide font-outfit`,children:`Connecting to Project`}),(0,y.jsx)(`p`,{className:`text-xs text-slate-500 mt-1 font-mono`,children:`Waiting for client bridge initialization...`})]}),i&&(0,y.jsxs)(`div`,{role:`status`,"data-testid":`slow-connection-help`,className:`max-w-md mx-6 mt-2 rounded-xl border border-slate-800 bg-slate-900/90 p-4 text-left text-xs text-slate-300`,children:[(0,y.jsx)(`p`,{className:`font-semibold text-slate-100`,children:`Still connecting? Usual causes:`}),(0,y.jsxs)(`ul`,{className:`mt-2 space-y-1.5 list-disc pl-4`,children:[(0,y.jsxs)(`li`,{children:[`The app is not running at `,(0,y.jsx)(`span`,{className:`font-mono`,children:t}),`.`]}),(0,y.jsxs)(`li`,{children:[`The app blocks framing: its `,(0,y.jsx)(`span`,{className:`font-mono`,children:`frame-ancestors`}),` `,`or `,(0,y.jsx)(`span`,{className:`font-mono`,children:`X-Frame-Options`}),` header must allow`,` `,(0,y.jsx)(`span`,{className:`font-mono`,children:window.location.origin}),`.`]}),(0,y.jsxs)(`li`,{children:[(0,y.jsx)(`span`,{className:`font-mono`,children:`LiveLocaleProvider`}),` is not mounted, or LiveLocale is off in the app (preview builds need`,` `,(0,y.jsx)(`span`,{className:`font-mono`,children:`NEXT_PUBLIC_LIVELOCALE=preview`}),`).`]})]}),(0,y.jsxs)(`p`,{className:`mt-3 text-slate-400`,children:[`Run`,` `,(0,y.jsxs)(`span`,{className:`font-mono text-slate-200 select-all`,children:[`npx livelocale doctor --app `,t]}),` `,`to check.`]})]})]})]})]})},S=new Set([`plural`,`select`,`selectordinal`]);function C(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r!==`'`){t+=r,n+=1;continue}if(e[n+1]===`'`){t+=`'`,n+=2;continue}let i=e[n+1];if(i===`{`||i===`}`||i===`#`||i===`|`){let t=n+1;for(;t<e.length;){if(e[t]===`'`){if(e[t+1]===`'`){t+=2;continue}break}t+=1}n=t+1;continue}t+=r,n+=1}return t}function w(e){let t=new Set,n=0,r=null,i=e=>{r||=e},a=t=>{for(;n<e.length;){let r=e[n];if(r===`{`)n+=1,s(t+1);else if(r===`}`)if(t===0)i(`Unbalanced braces: unexpected "}"`),n+=1;else return;else n+=1}t>0&&i(`Unbalanced braces: missing "}"`)},o=t=>{let r=``;for(;n<e.length&&!t.includes(e[n]);)r+=e[n],n+=1;return r},s=r=>{let s=o([`,`,`}`]).trim();if(s&&!s.includes(`{`)&&t.add(s),n>=e.length){i(`Unbalanced braces: missing "}"`);return}if(e[n]===`}`){n+=1;return}n+=1;let c=o([`,`,`}`]).trim();if(n>=e.length){i(`Unbalanced braces: missing "}"`);return}if(e[n]===`}`){n+=1;return}if(n+=1,S.has(c)){let t=!1;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n+=1;if(e[n]===`}`){n+=1,t||i(`"${s}" (${c}) has no "other" branch`);return}let l=o([`{`,`}`,` `,` `,`
9
9
  `]).trim();for(;n<e.length&&/\s/.test(e[n]);)n+=1;if(e[n]!==`{`){i(`"${s}" (${c}): expected "{" after "${l}"`);return}l===`other`&&(t=!0),n+=1,a(r+1),e[n]===`}`&&(n+=1)}i(`Unbalanced braces: missing "}"`);return}let l=1;for(;n<e.length&&l>0;)e[n]===`{`?l+=1:e[n]===`}`&&--l,n+=1;l>0&&i(`Unbalanced braces: missing "}"`)};return a(0),{args:t,error:r}}var T=/\{\{\s*([^{}]*?)\s*\}\}/g,E=/\$t\([^)]*\)/g,D=/%(?:\d+\$)?[-+ 0#]*\d*(?:\.\d+)?[sdifgxXoc]/g,O=/<\/?([A-Za-z][\w-]*|\d+)\b[^<>]*>/g;function k(e){if(typeof e!=`string`||e===``)return[];let t=new Set,n=e.replace(T,(e,n)=>{let r=n.split(`,`)[0].trim();return r&&t.add(`{{${r}}}`),` `});for(let e of n.match(E)??[])t.add(e);for(let e of n.replace(/%%/g,``).match(D)??[])t.add(e);for(let e of n.matchAll(O))t.add(`<${e[1]}>`);let r=w(C(n.replace(O,` `)));for(let e of r.args)t.add(`{${e}}`);return Array.from(t).sort()}function ee(e,t){if(!e)return{ok:!0,missing:[],extra:[]};let n=new Set(k(e)),r=new Set(k(t)),i=Array.from(n).filter(e=>!r.has(e)),a=Array.from(r).filter(e=>!n.has(e));return{ok:i.length===0&&a.length===0,missing:i,extra:a}}function A(e){return typeof e==`string`?w(C(e.replace(T,` `).replace(O,` `))).error:null}var j=[`zero`,`one`,`two`,`few`,`many`,`other`];function te(e,t){if(e[t+1]===`'`)return t+2;let n=e[t+1];if(n!==`{`&&n!==`}`&&n!==`#`&&n!==`|`)return t+1;let r=t+1;for(;r<e.length;){if(e[r]===`'`){if(e[r+1]===`'`){r+=2;continue}return r+1}r+=1}return e.length}function M(e,t){let n=0,r=t;for(;r<e.length;){let t=e[r];if(t===`'`){r=te(e,r);continue}if(t===`{`)n+=1;else if(t===`}`&&(--n,n===0))return r;r+=1}return-1}function ne(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===`'`){n=te(e,n);continue}if(r===`}`)return null;if(r===`{`){let r=M(e,n);if(r===-1)return null;t.push({start:n,end:r}),n=r+1;continue}n+=1}return t}var re=/^\s*([\w.]+)\s*,\s*(plural|select|selectordinal)\s*,/;function ie(e){if(typeof e!=`string`)return null;let t=ne(e);if(!t)return null;let n=t.filter(t=>re.test(e.slice(t.start+1,t.end)));if(n.length!==1)return null;let{start:r,end:i}=n[0],a=e.slice(r+1,i),o=re.exec(a),s=o[1],c=o[2],l=o[0].length,u=null,d=[];for(;l<a.length;){for(;l<a.length&&/\s/.test(a[l]);)l+=1;if(l>=a.length)break;let e=``;for(;l<a.length&&!/[\s{]/.test(a[l]);)e+=a[l],l+=1;if(e.startsWith(`offset:`)){let t=e.slice(7);for(;l<a.length&&/\s/.test(a[l]);)l+=1;if(t===``)for(;l<a.length&&/\d/.test(a[l]);)t+=a[l],l+=1;u=t||null;continue}for(;l<a.length&&/\s/.test(a[l]);)l+=1;if(!e||a[l]!==`{`)return null;let t=M(a,l);if(t===-1)return null;d.push({selector:e,text:a.slice(l+1,t)}),l=t+1}return d.length===0?null:{variable:s,type:c,offset:u,prefix:e.slice(0,r),suffix:e.slice(i+1),branches:d}}function ae(e){let t=[];e.offset&&t.push(` offset:${e.offset}`);for(let n of e.branches)n.text===``&&n.selector!==`other`||t.push(` ${n.selector} {${n.text}}`);return`${e.prefix}{${e.variable}, ${e.type},${t.join(``)}}${e.suffix}`}function N(e,t=`plural`){if(t===`select`)return[];try{let n=new Intl.PluralRules(e,{type:t===`selectordinal`?`ordinal`:`cardinal`}),r=new Set(n.resolvedOptions().pluralCategories);return j.filter(e=>r.has(e))}catch{return[`one`,`other`]}}var oe={zero:`zero (e.g. 0)`,one:`one (singular)`,two:`two (dual)`,few:`few (small numbers)`,many:`many (large numbers)`,other:`other (default, required)`},se=({locale:e,value:t,onChange:n,disabled:r})=>{let i=(0,g.useMemo)(()=>ie(t),[t]),a=(0,g.useMemo)(()=>{if(!i)return[];let t=new Map(i.branches.map(e=>[e.selector,e.text])),n=N(e,i.type);return[...i.branches.map(e=>e.selector).filter(e=>!n.includes(e)),...n].map(e=>({selector:e,text:t.get(e)??``,required:n.includes(e)}))},[i,e]);if(!i)return null;let o=(e,t)=>{n(ae({...i,...e,branches:t??i.branches}))},s=(e,t)=>{o({},a.map(n=>({selector:n.selector,text:n.selector===e?t:n.text})))},c=`w-full bg-slate-950 border border-slate-800 hover:border-slate-750 focus:border-indigo-500 focus:outline-hidden focus:ring-1 focus:ring-indigo-500/50 rounded-lg px-3 py-2 text-xs text-slate-100 placeholder-slate-600 transition duration-150 disabled:opacity-60`;return(0,y.jsxs)(`div`,{className:`space-y-3`,"data-testid":`plural-editor`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsxs)(`span`,{className:`text-[10px] text-slate-500 font-mono`,children:[i.type,` on `,(0,y.jsx)(`span`,{className:`text-indigo-400`,children:i.variable}),i.offset?` · offset ${i.offset}`:``]}),(0,y.jsxs)(`span`,{className:`text-[10px] text-slate-600`,children:[(0,y.jsx)(`code`,{className:`font-mono`,children:`#`}),` = the number`]})]}),i.prefix!==``&&(0,y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,y.jsx)(`span`,{className:`text-[10px] font-semibold text-slate-500 uppercase tracking-wider`,children:`Before`}),(0,y.jsx)(`input`,{"data-testid":`plural-prefix`,dir:`auto`,value:i.prefix,disabled:r,onChange:e=>o({prefix:e.target.value}),className:c})]}),(0,y.jsx)(`div`,{className:`space-y-2`,children:a.map(t=>(0,y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,y.jsxs)(`span`,{className:`flex items-center gap-2 text-[10px] font-mono`,children:[(0,y.jsx)(`span`,{className:`text-slate-300`,children:t.selector}),(0,y.jsx)(`span`,{className:`text-slate-600`,children:oe[t.selector]??`explicit case`}),t.required&&t.text===``&&t.selector!==`other`&&(0,y.jsxs)(`span`,{className:`text-amber-400`,children:[`needed for `,e]})]}),(0,y.jsx)(`input`,{"data-testid":`plural-branch-${t.selector}`,dir:`auto`,value:t.text,disabled:r,onChange:e=>s(t.selector,e.target.value),className:c})]},t.selector))}),i.suffix!==``&&(0,y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,y.jsx)(`span`,{className:`text-[10px] font-semibold text-slate-500 uppercase tracking-wider`,children:`After`}),(0,y.jsx)(`input`,{"data-testid":`plural-suffix`,dir:`auto`,value:i.suffix,disabled:r,onChange:e=>o({suffix:e.target.value}),className:c})]})]})},ce={present:`bg-slate-800/80 border-slate-700 text-slate-300`,missing:`bg-rose-500/10 border-rose-500/40 text-rose-300 line-through`,extra:`bg-amber-500/10 border-amber-500/40 text-amber-300`},P={present:`Placeholder from the reference, present in your translation`,missing:`Placeholder from the reference is missing from your translation`,extra:`Placeholder not present in the reference`},le=({selected:e,inputValue:t,locale:n=`en`,isLoading:r,isSuccess:i,error:a,saveWarning:o,onInputChange:s,onSave:c,onForceSave:l,onDismissWarning:u,onClear:d})=>{let[f,p]=(0,g.useState)(!1),m=(0,g.useMemo)(()=>ie(t)!==null,[t]),h=m&&!f,_=!r&&t!==e.currentValue,v=e=>{e.key!==`Enter`||!(e.ctrlKey||e.metaKey)||(e.preventDefault(),_&&c())},b=(0,g.useMemo)(()=>{let n=new Set(k(e.fallbackValue||``)),r=new Set(k(t)),i=[];for(let e of n)i.push({token:e,state:r.has(e)?`present`:`missing`});for(let e of r)n.has(e)||i.push({token:e,state:`extra`});return i},[e.fallbackValue,t]);return(0,y.jsxs)(`div`,{className:`flex-1 flex flex-col p-6 overflow-y-auto space-y-6`,children:[(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`Translation Key`}),(0,y.jsx)(`button`,{onClick:d,className:`text-[10px] font-medium text-slate-500 hover:text-slate-300 transition duration-200`,children:`Clear Selection`})]}),(0,y.jsx)(`div`,{className:`bg-slate-950 border border-slate-800/80 rounded-xl px-4 py-3 font-mono text-xs text-indigo-400 select-all break-all shadow-inner leading-relaxed`,children:e.key})]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`Reference (Fallback Value)`}),(0,y.jsx)(`div`,{dir:`auto`,className:`bg-slate-950/40 border border-slate-850 rounded-xl px-4 py-3 text-sm text-slate-400 select-all leading-relaxed whitespace-pre-wrap`,children:e.fallbackValue||(0,y.jsx)(`span`,{className:`italic text-slate-600`,children:`None`})})]}),b.length>0&&(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`Placeholders`}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(({token:e,state:t})=>(0,y.jsx)(`span`,{"data-testid":`placeholder-${e}`,"data-state":t,title:P[t],className:`px-2 py-0.5 rounded-md border text-[10px] font-mono ${ce[t]}`,children:e},e))})]}),(0,y.jsxs)(`div`,{className:`space-y-2 flex-1 flex flex-col min-h-[180px]`,onKeyDown:v,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:h?`Plural forms`:`Translation Output`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[m&&(0,y.jsx)(`button`,{type:`button`,"data-testid":`plural-raw-toggle`,onClick:()=>p(e=>!e),className:`text-[10px] font-semibold text-slate-500 hover:text-slate-300 transition duration-150`,children:f?`Edit forms`:`Edit raw`}),(0,y.jsxs)(`span`,{className:`text-[10px] text-slate-500 font-mono`,children:[t.length,`/10000`]})]})]}),h?(0,y.jsx)(se,{locale:n,value:t,onChange:s,disabled:r}):(0,y.jsx)(`textarea`,{id:`studio-translation-input`,dir:`auto`,value:t,onChange:e=>s(e.target.value),disabled:r,placeholder:`Type your translation here...`,className:`w-full min-h-32 bg-slate-950 border border-slate-800 hover:border-slate-750 focus:border-indigo-500 focus:outline-hidden focus:ring-1 focus:ring-indigo-500/50 rounded-xl px-4 py-3 text-sm text-slate-100 placeholder-slate-600 font-sans resize-none transition duration-205 shadow-inner leading-relaxed`})]}),o&&(0,y.jsxs)(`div`,{"data-testid":`save-warning`,className:`bg-amber-500/10 border border-amber-500/30 rounded-xl p-3 space-y-3`,children:[(0,y.jsx)(`div`,{className:`text-xs text-amber-200 leading-relaxed`,children:o.message}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`button`,{onClick:l,disabled:r,className:`h-8 px-3 rounded-lg text-[11px] font-semibold text-white bg-amber-600 hover:bg-amber-500 active:bg-amber-700 transition duration-150`,children:`Save anyway`}),(0,y.jsx)(`button`,{onClick:u,className:`h-8 px-3 rounded-lg text-[11px] font-semibold text-slate-300 bg-slate-800 border border-slate-700 hover:border-slate-600 transition duration-150`,children:`Keep editing`})]})]}),a&&(0,y.jsxs)(`div`,{className:`bg-rose-500/10 border border-rose-500/20 rounded-xl p-3 flex items-start gap-[0.625rem] shadow-xs`,children:[(0,y.jsx)(`svg`,{className:`w-4 h-4 text-rose-500 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),(0,y.jsx)(`div`,{className:`text-xs text-rose-400 font-mono leading-normal break-all`,children:a})]}),(0,y.jsx)(`div`,{className:`flex items-center gap-3 pt-4 shrink-0`,children:(0,y.jsx)(`button`,{id:`studio-save-button`,onClick:c,disabled:!_,className:`flex-1 h-11 rounded-xl text-sm font-semibold tracking-wide flex items-center justify-center gap-2 shadow-sm transition duration-205 ${t===e.currentValue?`bg-slate-800 text-slate-500 cursor-not-allowed shadow-none border border-slate-850`:`bg-indigo-600 hover:bg-indigo-500 text-white active:bg-indigo-700`}`,children:r?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`svg`,{className:`animate-spin h-4 w-4 text-indigo-200`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,y.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,y.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),(0,y.jsx)(`span`,{children:`Saving...`})]}):i?(0,y.jsxs)(`span`,{"data-testid":`save-success`,className:`flex items-center gap-1 text-emerald-400 font-bold`,children:[(0,y.jsx)(`svg`,{className:`w-4 h-4 text-emerald-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 13l4 4L19 7`})}),(0,y.jsx)(`span`,{children:`Saved!`})]}):(0,y.jsx)(`span`,{children:`Save Changes`})})})]})},F=()=>(0,y.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-6 text-center select-none`,children:[(0,y.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-indigo-500/5 border border-indigo-500/10 flex items-center justify-center text-indigo-400 shadow-xs mb-6`,children:(0,y.jsx)(`svg`,{className:`w-8 h-8 text-indigo-500`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122`})})}),(0,y.jsx)(`h3`,{className:`text-slate-200 font-semibold tracking-wide font-outfit`,children:`Select an Element`}),(0,y.jsx)(`p`,{className:`text-xs text-slate-500 max-w-xs mt-2 leading-relaxed`,children:`Hover over elements in the live preview iframe and click to load them into the visual editing sidebar.`})]}),ue=/^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,4})?$/,de=/^[a-zA-Z0-9._-]+$/,fe=1e4,pe=new Set([`__proto__`,`constructor`,`prototype`]);function me(e){return typeof e==`string`?!e.split(`.`).some(e=>pe.has(e)):!1}function he(e){return typeof e==`string`&&e.length>=2&&e.length<=10&&ue.test(e)}function ge(e){return typeof e==`string`&&e.length>=1&&e.length<=200&&de.test(e)}function _e(e){return typeof e==`string`&&e.length<=1e4}function ve(e){return!(e.includes(`..`)||e.includes(`/`)||e.includes(`\\`)||e.includes(`%`)||e.includes(`\0`))}var ye=({code:e,isActive:t,isLoading:n,allLocales:r,onRename:i,onDelete:a})=>{let[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(e),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(null);return(0,y.jsx)(`div`,{className:`bg-slate-950/40 border border-slate-850 hover:border-slate-800/80 rounded-xl px-4 py-3 flex items-center justify-between gap-4 transition duration-200`,children:o?(0,y.jsxs)(`div`,{className:`flex-1 flex items-center gap-2`,children:[(0,y.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:n,className:`flex-1 bg-slate-950 border border-slate-800 rounded-lg px-2.5 py-1 text-xs font-mono text-slate-100 focus:outline-hidden focus:border-indigo-500`,autoFocus:!0}),(0,y.jsx)(`button`,{onClick:async()=>{p(null);let t=c.trim();if(!t||t===e){s(!1);return}if(!he(t)){p(`Invalid locale format.`);return}if(r.includes(t)&&t!==e){p(`Target locale already exists.`);return}try{await i(e,t),s(!1)}catch(e){p(e.message||`Failed to rename.`)}},disabled:n,className:`p-1 text-emerald-400 hover:text-emerald-300 transition duration-150`,title:`Save rename`,children:(0,y.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2.5,d:`M5 13l4 4L19 7`})})}),(0,y.jsx)(`button`,{onClick:()=>s(!1),disabled:n,className:`p-1 text-slate-500 hover:text-slate-400 transition duration-150`,title:`Cancel`,children:(0,y.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2.5,d:`M6 18L18 6M6 6l12 12`})})})]}):u?(0,y.jsxs)(`div`,{className:`flex-1 flex flex-col gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[10px] font-semibold text-rose-400`,children:`Confirm deletion? This deletes the translation file.`}),f&&(0,y.jsx)(`span`,{className:`text-[10px] text-rose-400 font-mono`,children:f}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,y.jsx)(`button`,{onClick:()=>d(!1),disabled:n,className:`px-2.5 py-1 text-[10px] font-semibold bg-slate-800 hover:bg-slate-750 text-slate-300 rounded-lg transition`,children:`Cancel`}),(0,y.jsx)(`button`,{onClick:async()=>{p(null);try{await a(e),d(!1)}catch(e){p(e.message||`Failed to delete.`)}},disabled:n,className:`px-2.5 py-1 text-[10px] font-semibold bg-rose-600 hover:bg-rose-500 text-white rounded-lg transition shadow-sm shadow-rose-600/10`,children:`Delete`})]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-slate-200 truncate`,children:e}),t&&(0,y.jsx)(`span`,{className:`text-[9px] text-indigo-400 font-bold tracking-wide mt-0.5`,children:`ACTIVE WORKSPACE`}),f&&(0,y.jsx)(`span`,{className:`text-[10px] text-rose-400 font-mono mt-0.5`,children:f})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,y.jsx)(`button`,{onClick:()=>{l(e),p(null),s(!0)},disabled:n,className:`p-1.5 text-slate-500 hover:text-slate-300 transition duration-150`,title:`Rename locale code`,children:(0,y.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z`})})}),(0,y.jsx)(`button`,{onClick:()=>{p(null),d(!0)},disabled:n,className:`p-1.5 text-slate-500 hover:text-rose-400 transition duration-150`,title:`Delete locale`,children:(0,y.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})})})]})]})})},be=({locale:e,locales:t,isLoading:n,error:r,onAddLocale:i,onRenameLocale:a,onDeleteLocale:o})=>{let[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(null);return(0,y.jsxs)(`div`,{className:`flex-1 flex flex-col p-6 overflow-y-auto space-y-6`,children:[(0,y.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),u(null);let n=s.trim();if(n){if(!he(n)){u(`Locale format must be 2-3 letters, optionally followed by a region (e.g., fr or es-MX).`);return}if(t.includes(n)){u(`Locale already exists.`);return}try{await i(n),c(``)}catch(e){u(e.message||`Failed to add locale.`)}}},className:`space-y-2.5`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`Add New Locale`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g. fr, es-MX`,disabled:n,className:`flex-1 min-w-0 bg-slate-950 border border-slate-800 hover:border-slate-750 focus:border-indigo-500 focus:outline-hidden focus:ring-1 focus:ring-indigo-500/50 rounded-xl px-4 py-2.5 text-xs text-slate-100 placeholder-slate-600 font-mono transition duration-155`}),(0,y.jsx)(`button`,{type:`submit`,disabled:n||!s.trim(),className:`h-10 px-4 bg-indigo-600 hover:bg-indigo-500 disabled:bg-slate-800 disabled:text-slate-500 text-white text-xs font-semibold rounded-xl transition duration-155 flex items-center justify-center gap-1.5 shrink-0`,children:`Add`})]})]}),(l||r)&&(0,y.jsxs)(`div`,{className:`bg-rose-500/10 border border-rose-500/20 rounded-xl p-3 flex items-start gap-[0.625rem] shadow-xs`,children:[(0,y.jsx)(`svg`,{className:`w-4 h-4 text-rose-500 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),(0,y.jsx)(`div`,{className:`text-xs text-rose-400 font-mono leading-normal break-all`,children:l||r})]}),(0,y.jsxs)(`div`,{className:`flex-1 flex flex-col space-y-2`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-1`,children:`Active Locales`}),(0,y.jsx)(`div`,{className:`flex-1 overflow-y-auto space-y-2 pr-1 select-none`,children:t.map(r=>(0,y.jsx)(ye,{code:r,isActive:r===e,isLoading:n,allLocales:t,onRename:a,onDelete:o},r))})]})]})},xe={en:`English`,ar:`Arabic`,es:`Spanish`,fr:`French`,de:`German`,zh:`Chinese`,ja:`Japanese`,pt:`Portuguese`,it:`Italian`,ru:`Russian`,hi:`Hindi`,tr:`Turkish`},Se=e=>`${xe[e.split(`-`)[0]?.toLowerCase()||e]||xe[e]||`Custom`} (${e})`,Ce=({selected:e,inputValue:t,locale:n,isLoading:r,isSuccess:i,error:a,saveWarning:o,onInputChange:s,onLocaleChange:c,onSave:l,onForceSave:u,onDismissWarning:d,onClear:f,locales:p,onAddLocale:m,onRenameLocale:h,onDeleteLocale:_,className:v=`w-[420px] shrink-0`})=>{let[b,x]=(0,g.useState)(!1);return(0,y.jsxs)(`div`,{"data-testid":`editor-panel`,className:`${v} bg-slate-900 border border-slate-800 rounded-2xl flex flex-col h-full shadow-2xl overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`h-14 bg-slate-950 border-b border-slate-800 flex items-center justify-between px-6 shrink-0 select-none`,children:[(0,y.jsx)(`h2`,{className:`text-sm font-bold tracking-wide font-outfit text-slate-200`,children:b?`Manage Languages`:`Translation Studio`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!b&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`label`,{className:`text-[10px] font-semibold text-slate-500 uppercase tracking-wider`,children:`Locale`}),(0,y.jsx)(`select`,{value:n,onChange:e=>c(e.target.value),className:`bg-slate-900 border border-slate-800 hover:border-slate-700 text-slate-300 text-xs rounded-lg px-2.5 py-1.5 focus:outline-hidden focus:ring-1 focus:ring-indigo-500/50 cursor-pointer font-mono`,children:p.map(e=>(0,y.jsx)(`option`,{value:e,children:Se(e)},e))})]}),(0,y.jsx)(`button`,{onClick:()=>x(!b),className:`p-1.5 rounded-lg border transition duration-200 ${b?`bg-indigo-600/20 border-indigo-500 text-indigo-400`:`bg-slate-900 border-slate-800 text-slate-400 hover:text-slate-200 hover:border-slate-700`}`,title:b?`Back to Editor`:`Manage Languages`,children:b?(0,y.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2.5,d:`M10 19l-7-7m0 0l7-7m-7 7h18`})}):(0,y.jsxs)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:[(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z`}),(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`})]})})]})]}),b?(0,y.jsx)(be,{locale:n,locales:p,isLoading:r,error:a,onAddLocale:m,onRenameLocale:h,onDeleteLocale:_}):e?(0,y.jsx)(le,{selected:e,inputValue:t,locale:n,isLoading:r,isSuccess:i,error:a,saveWarning:o,onInputChange:s,onSave:l,onForceSave:u,onDismissWarning:d,onClear:f}):(0,y.jsx)(F,{})]})};function we(e,t){if(typeof e!=`object`||!e)return t;if(typeof t!=`object`||!t)return e;let n={...e};for(let r of Object.keys(t))r in e?n[r]=we(e[r],t[r]):n[r]=t[r];return n}function Te(e,t,n){let r=t.split(`.`);if(r.length>30)throw Error(`[livelocale] Key depth limit exceeded. Maximum depth is 30 levels.`);if(r.some(e=>pe.has(e)))throw Error(`[livelocale] Forbidden key segment in path: "${t}". Segment names like __proto__, constructor, and prototype are not allowed.`);let i=e;for(let e=0;e<r.length;e++){let t=r[e];if(e===r.length-1){i[t]=n;return}(!(t in i)||i[t]===null||typeof i[t]!=`object`||Array.isArray(i[t]))&&(i[t]={}),i=i[t]}}function Ee(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function I(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function De(e,t){if(!Ee(e))return{state:`missing`};let n=t.split(`.`),r=n.length-1,i=e;for(let e=0;e<r;e++){if(I(i,n.slice(e).join(`.`)))return{state:`occupied`};let t=n[e];if(!I(i,t))return{state:`missing`};let r=i[t];if(!Ee(r))return{state:`occupied`};i=r}let a=n[r];if(!I(i,a))return{state:`missing`};let o=i[a];return typeof o==`string`?{state:`string`,value:o}:{state:`occupied`}}function Oe(e,t=``,n=new Set){if(!e||typeof e!=`object`)return n;for(let r of Object.keys(e)){let i=e[r],a=t?`${t}.${r}`:r;i&&typeof i==`object`&&!Array.isArray(i)?Oe(i,a,n):n.add(a)}return n}var ke=(e,t,n)=>({ok:!1,status:e,code:t,error:n});function Ae(e,t={}){let{locale:n,key:r,value:i}=e;if(!he(n))return ke(400,`INVALID_LOCALE_FORMAT`,`Invalid locale string parameter.`);if(!ge(r))return ke(400,`INVALID_KEY_FORMAT`,`Invalid key path. Must be 1-200 characters containing alphanumeric, dots, underscores, or hyphens.`);if(!me(r))return ke(400,`INVALID_KEY_FORMAT`,`Forbidden key path: segments like __proto__, constructor, or prototype are not allowed.`);if(!_e(i))return ke(400,`INVALID_VALUE_FORMAT`,`Invalid value. Must be a string less than 10000 characters.`);let a={ok:!0,locale:n,key:r,value:i};if(t.force===!0)return a;let o=A(a.value);if(o)return ke(422,`MESSAGE_SYNTAX`,`Message syntax: ${o}.`);let s=ee(t.reference,a.value);if(!s.ok){let e=[];return s.missing.length&&e.push(`missing ${s.missing.join(`, `)}`),s.extra.length&&e.push(`unexpected ${s.extra.join(`, `)}`),{...ke(422,`PLACEHOLDER_MISMATCH`,`Placeholders differ from the reference: ${e.join(`; `)}.`),details:{missing:s.missing,extra:s.extra}}}return a}function je(e,t){let n=De(t.source,e);return n.state===`string`?n.value:null}function Me(e,t,n){let{locale:r,key:i,value:a}=e,o={locale:r,key:i,value:a},s=Ae(o,{force:!0});return s.ok?De(r===t.sourceLocale?t.source:t.target??{},i).state===`occupied`?ke(409,`KEY_NOT_A_STRING`,`Cannot save "${i}" in ${r}: it would replace translations that are not a single text.`):Ae(o,{reference:je(i,t),force:n?.force===!0}):s}var Ne={markup:`Adds markup that the source text does not have.`,"javascript-url":`Adds a javascript:, vbscript: or data: link.`,"new-url":`Adds a web address that the source text does not have.`,"bidi-control":`Contains invisible text-direction control characters.`},Pe=/<\/?([A-Za-z][\w-]*)\b[^<>]*>/g,Fe=[/\b(?:javascript|vbscript)\s*:/i,/\bdata:[a-z]+\/[\w.+-]+/i],Ie=/\b(?:https?:\/\/|www\.)[^\s<>"')]+/gi,Le=/[\u202A-\u202E\u2066-\u2069]/g,Re=e=>Array.from(e.matchAll(Pe),e=>e[1].toLowerCase()),ze=(e,t)=>t.match(e)??[],Be=(e,t)=>{let n=new Set(e);return t.some(e=>!n.has(e))};function Ve(e,t){let n=e??``,r=[];return Be(Re(n),Re(t))&&r.push(`markup`),Fe.some(e=>e.test(t)&&!e.test(n))&&r.push(`javascript-url`),Be(ze(Ie,n),ze(Ie,t))&&r.push(`new-url`),Be(ze(Le,n),ze(Le,t))&&r.push(`bidi-control`),r}var He=`lc1.`,Ue="```livelocale",We="```",L=class extends Error{code;constructor(e,t){super(t),this.name=`ChangeLinkError`,this.code=e}},Ge=`This change link is damaged or incomplete. Ask the sender to send the file instead.`,Ke=`This change link was made by a newer LiveLocale. Update LiveLocale and try again.`,qe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,Je=32768;function Ye(e){let t=``;for(let n=0;n<e.length;n+=Je)t+=String.fromCharCode(...e.subarray(n,n+Je));return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Xe(e){if(!/^[A-Za-z0-9_-]*$/.test(e)||e.length%4==1)throw new L(`CORRUPT`,Ge);let t=e.length%4;if(t!==0){let n=t===2?15:3;if((qe.indexOf(e[e.length-1])&n)!==0)throw new L(`CORRUPT`,Ge)}let n=atob(e.replace(/-/g,`+`).replace(/_/g,`/`)+`=`.repeat(t===0?0:4-t)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function Ze(e){return`${Ue}\n${e}\n${We}\n`}function Qe(e){let t=RegExp(`${Ue}(?:\\r\\n|\\r|\\n)`).exec(e);if(!t)return null;let n=e.slice(t.index+t[0].length).split(/\r\n|\r|\n/),r=n.indexOf(We);return(r<0?n:n.slice(0,r)).join(``).replace(/\s+/g,``)}function $e(e){let t=(Qe(e)??e).replace(/%23/gi,`#`),n=new Set;for(let e of t.matchAll(/(?:^|[^A-Za-z0-9_-])lc1\.([A-Za-z0-9_-]+)/g))n.add(e[1]);if(n.size===1)return He+[...n][0];throw n.size>1?new L(`AMBIGUOUS`,`This text holds more than one change link. Paste one link at a time.`):/(?:^|[^A-Za-z0-9_-])lc(?:[2-9]|[1-9]\d+)\.[A-Za-z0-9_-]/.test(t)?new L(`UNSUPPORTED_VERSION`,Ke):new L(`NOT_FOUND`,`This is not a LiveLocale change link. A change link contains "lc1.".`)}function et(e){if(!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9._-]{1,100}$/.test(e))return!1;let t=e.slice(e.indexOf(`/`)+1);return t!==`.`&&t!==`..`}var tt=/^(?!-)(?!.*\.\.)[^\s\x00-\x1f\x7f]{1,255}$/;function nt(e){return tt.test(e)&&!ft(e)}var rt=2e3;function it(e){return{v:1,...e.repo===void 0?{}:{repo:e.repo},branch:e.branch,base:e.base,src:e.src,by:e.by,note:e.note,e:e.edits.map(({locale:e,key:t,from:n,to:r,force:i})=>i?[e,t,n,r,1]:[e,t,n,r])}}var at=/^(?:[0-9a-f]{40}|[0-9a-f]{64})?$/,ot=/[\x00-\x1f\x7f]/,st=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/,ct=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]/;function lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ut(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function dt(e){return new L(`INVALID`,e)}function ft(e){return typeof e==`string`&&ct.test(e)}function pt(e,t){let n=e=>dt(`edit ${t}: ${e}`);if(!Array.isArray(e)||e.length!==4&&e.length!==5)throw n(`is not a [locale, key, from, to] entry.`);let[r,i,a,o,s]=e;if(typeof r!=`string`||!he(r))throw n(`the locale is not a locale code.`);if(typeof i!=`string`||!ge(i)||!me(i))throw n(`the key is not a valid translation key.`);if(a!==null&&(typeof a!=`string`||!_e(a)))throw n(`the current text is not text of at most ${fe} characters.`);if(typeof o!=`string`||!_e(o))throw n(`the new text is not text of at most ${fe} characters.`);if(e.length===5&&s!==1)throw n(`the force flag must be 1.`);return{locale:r,key:i,from:a,to:o,force:e.length===5}}function mt(e){let t=new Map;e.forEach(({locale:e,key:n},r)=>{let i=t.get(e);if(i||t.set(e,i=new Set),i.has(n))throw dt(`edit ${r+1}: an earlier edit changes the same key.`);i.add(n)}),e.forEach(({locale:e,key:n},r)=>{let i=t.get(e);for(let e=n.indexOf(`.`);e>=0;e=n.indexOf(`.`,e+1))if(i.has(n.slice(0,e)))throw dt(`edit ${r+1}: another edit changes a key that contains this one.`)})}function ht(e){if(!lt(e))throw dt(`This change link does not hold a change set.`);if(ut(e,`v`)!==1)throw new L(`UNSUPPORTED_VERSION`,Ke);let t=ut(e,`repo`);if(t!==void 0&&(typeof t!=`string`||!et(t)))throw dt(`The repository is not an owner/name slug.`);let n=ut(e,`branch`);if(typeof n!=`string`||n!==``&&!nt(n))throw dt(`The branch is not a valid branch name.`);let r=ut(e,`base`);if(typeof r!=`string`||!at.test(r))throw dt(`The base is not a full commit id.`);let i=ut(e,`src`);if(typeof i!=`string`||!he(i))throw dt(`The source locale is not a locale code.`);let a=ut(e,`by`);if(typeof a!=`string`||a.length>100||ot.test(a))throw dt(`The name is not one line of at most 100 characters.`);let o=ut(e,`note`);if(typeof o!=`string`||o.length>2e3||st.test(o))throw dt(`The note is not plain text of at most ${rt} characters.`);let s=ut(e,`e`);if(!Array.isArray(s))throw dt(`This change link holds no list of edits.`);if(s.length>500)throw new L(`TOO_MANY_EDITS`,`A change link holds at most 500 edits. Send the rest in another link.`);if(s.length===0)throw dt(`This change link holds no edits.`);let c=Array.from(s,(e,t)=>pt(e,t+1));if(mt(c),[t,n,r,i,a,o].some(ft))throw dt(`This change link holds broken text.`);return c.forEach(({locale:e,key:t,from:n,to:r},i)=>{if([e,t,n,r].some(ft))throw dt(`edit ${i+1}: holds broken text.`)}),{...t===void 0?{}:{repo:t},branch:n,base:r,src:i,by:a,note:o,edits:c}}var gt=512*1024,_t=`A change link holds at most ${gt/1024} KB of text. Send the changes in smaller links.`,R=`This browser cannot create or read change links. Use a current Chrome, Edge or Firefox, or Safari 16.4 or later.`,vt=4096;async function yt(e,t,n){let r=new Uint8Array(t),i=e.writable.getWriter(),a=e.readable.getReader(),o=!1;(async()=>{for(let e=0;e<r.length;e+=vt){if(o)return;await i.write(r.subarray(e,e+vt))}o||await i.close()})().catch(()=>{});let s=[],c=0;try{for(;;){let{done:e,value:t}=await a.read();if(e)break;if(c+=t.length,c>n)throw new L(`TOO_LARGE`,_t);s.push(t)}}catch(e){throw o=!0,i.abort(e).catch(()=>{}),await a.cancel(e).catch(()=>{}),e}let l=new Uint8Array(c),u=0;for(let e of s)l.set(e,u),u+=e.length;return l}var bt=async e=>{if(typeof globalThis.CompressionStream!=`function`)throw new L(`UNSUPPORTED_ENVIRONMENT`,R);return yt(new CompressionStream(`deflate`),e,1/0)},xt=async(e,t)=>{if(typeof globalThis.DecompressionStream!=`function`)throw new L(`UNSUPPORTED_ENVIRONMENT`,R);try{return await yt(new DecompressionStream(`deflate`),e,t)}catch(e){throw e instanceof L?e:new L(`CORRUPT`,Ge)}};async function St(e,t=bt){let n=JSON.stringify(it(ht(it(e)))),r=new TextEncoder().encode(n);if(r.length>524288)throw new L(`TOO_LARGE`,_t);return He+Ye(await t(r))}async function Ct(e,t=xt){let n=$e(e);if(n.length>1e6)throw new L(`TOO_LARGE`,_t);try{let e=await t(Xe(n.slice(4)),gt),r=new TextDecoder(`utf-8`,{fatal:!0}).decode(e);return ht(JSON.parse(r))}catch(e){throw e instanceof L?e:new L(`CORRUPT`,Ge)}}var wt=`manifest.json`,Tt=/^[0-9a-f]{40}([0-9a-f]{24})?$/;function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Dt(e,t){if(!Array.isArray(e))return!1;for(let n=0;n<e.length;n++)if(!t(e[n]))return!1;return!0}function Ot(e){return typeof e==`string`}function kt(e){return typeof e==`string`&&ue.test(e)}function At(e,t){return e===null||typeof e==`string`&&t(e)}function jt(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Et(e,`repo`),n=Et(e,`layout`),r=Et(e,`locales`),i=Et(e,`sourceLocale`);return Et(e,`format`)===1&&(t===void 0||typeof t==`string`&&et(t))&&At(Et(e,`defaultBranch`),nt)&&At(Et(e,`branch`),nt)&&At(Et(e,`base`),e=>Tt.test(e))&&typeof Et(e,`localesPath`)==`string`&&(n===`flat`||n===`namespaced`)&&Dt(r,kt)&&typeof i==`string`&&r.includes(i)&&At(Et(e,`basePath`),e=>e.startsWith(`/`)&&e.endsWith(`/`))&&Dt(Et(e,`codeKeys`),Ot)}function Mt(e){return jt(e)?e:null}function Nt(e){if(typeof e!=`string`||e.trim()===``)return null;try{let t=new URL(e.trim());return t.protocol!==`http:`&&t.protocol!==`https:`?null:t.origin}catch{return null}}function Pt(e){let t=null;if(e.search)try{t=new URLSearchParams(e.search).get(`app`)}catch{t=null}return Nt(t)??Nt(e.injected)??Nt(e.buildTime)??`http://localhost:3000`}var Ft=`This Studio was opened from a website, but livelocale/manifest.json is missing or is not a LiveLocale manifest. Rebuild with share: true (or run livelocale pack) and upload the whole livelocale/ folder.`;function It(e){return new URL(`../`,e).href}var Lt=/\/livelocale\/(index\.html)?$/;async function Rt(e){try{let t=await e.fetch(new URL(wt,e.href).href,{cache:`no-store`,credentials:`same-origin`});if(!t.ok)return null;let n=await t.text(),r=Mt(JSON.parse(n));return r?{manifest:r,manifestText:n}:null}catch{return null}}async function zt(e){let t=t=>{let n=Pt(e);return{kind:`server`,appOrigin:n,appUrl:n,problems:t}};if(Nt(e.injected)!==null)return t([]);let n=await Rt(e);return n?{kind:`static`,appOrigin:new URL(e.href).origin,appUrl:It(e.href),...n}:t(Lt.test(new URL(e.href).pathname)?[Ft]:[])}var Bt=null;function Vt(e){Bt=e}function Ht(){if(Bt)return Bt;let e=typeof window<`u`,t=Pt({search:e?window.location.search:void 0,injected:e?window.__LIVELOCALE_CONFIG__?.appOrigin:void 0,buildTime:void 0});return{kind:`server`,appOrigin:t,appUrl:t,problems:[]}}function z(){return Ht().appOrigin}function Ut(){return Ht().appUrl}function Wt(){let e=Ht();return e.kind===`static`?e.transport:null}function Gt(){let e=Ht();if(e.kind!==`static`)return{};let{basePath:t,locales:n}=e.manifest;return{basePath:t??new URL(e.appUrl).pathname,locales:n}}function Kt(){let e=Ht();return e.kind===`server`&&e.problems.includes(`This Studio was opened from a website, but livelocale/manifest.json is missing or is not a LiveLocale manifest. Rebuild with share: true (or run livelocale pack) and upload the whole livelocale/ folder.`)}var qt=()=>`${z()}/api/livelocale`,Jt=`livelocale-token`,Yt=`livelocale:unauthorized`,Xt=`livelocale:token-changed`,Zt=class extends Error{code;details;constructor(e,t,n){super(e),this.name=`ValidationError`,this.code=t,this.details={missing:n?.missing??[],extra:n?.extra??[]}}},Qt=class extends Error{code=`UNAUTHORIZED`;constructor(e=`Unauthorized`){super(e),this.name=`UnauthorizedError`}},$t=null;function en(){try{return window.sessionStorage.getItem(`livelocale-token`)??$t}catch{return $t}}function tn(e){$t=e;try{e?window.sessionStorage.setItem(Jt,e):window.sessionStorage.removeItem(Jt)}catch{}typeof window<`u`&&window.dispatchEvent(new Event(Xt))}function nn(e={}){let t=en();return t?{...e,Authorization:`Bearer ${t}`}:e}async function rn(e){let t=null;try{t=await e.json()}catch{}if(e.status===401)throw typeof window<`u`&&window.dispatchEvent(new Event(Yt)),new Qt(t?.error||`Unauthorized`);if(e.status===422)throw new Zt(t?.error||`The translation was rejected.`,t?.code||`VALIDATION`,t?.details);if(!e.ok)throw Error(t?.error||`Server responded with status ${e.status}`);return t}function an(e=``){let t=`${qt()}${e}`;return(en()?fetch(t,{headers:nn()}):fetch(t)).then(e=>rn(e))}async function on(e){return rn(await fetch(qt(),{method:`POST`,headers:nn({"Content-Type":`application/json`}),body:JSON.stringify(e)}))}var sn={fetchInfo:()=>an(`?action=info`),fetchLocales:()=>an(),fetchKeysMetadata:()=>an(`?action=keys`),fetchLocaleDictionary:e=>an(`?locale=${encodeURIComponent(e)}`),fetchGitState:()=>an(`?action=git`),saveTranslation:(e,t,n,r={})=>on({locale:e,key:t,value:n,...r.reference===void 0?{}:{reference:r.reference},...r.force?{force:!0}:{}}),addLocaleRequest:e=>on({action:`addLocale`,locale:e}),renameLocaleRequest:(e,t)=>on({action:`renameLocale`,locale:e,newLocale:t}),deleteLocaleRequest:e=>on({action:`deleteLocale`,locale:e}),commitLocales:e=>on({action:`commit`,message:e}),discardLocales:()=>on({action:`discard`})},cn=sn;function ln(e){cn=e??sn}var un=()=>cn.fetchInfo(),dn=()=>cn.fetchLocales(),fn=()=>cn.fetchKeysMetadata(),pn=e=>cn.fetchLocaleDictionary(e),mn=()=>cn.fetchGitState(),hn=(e,t,n,r={})=>cn.saveTranslation(e,t,n,r),gn=e=>cn.addLocaleRequest(e),_n=(e,t)=>cn.renameLocaleRequest(e,t),vn=e=>cn.deleteLocaleRequest(e),yn=e=>cn.commitLocales(e),bn=()=>cn.discardLocales();function xn(e,t){return e.repo?e.repo:`path:`+new URL(t).pathname}function Sn(e,t,n){let r=e.layout===`namespaced`?`${t}/${n.split(`.`)[0]}.json`:`${t}.json`;return e.localesPath===`.`?r:`${e.localesPath}/${r}`}var Cn=(e,t)=>e<t?-1:+(e>t);function wn(e,t){let n=e.map(e=>({path:Sn(t,e.locale,e.key),draft:e})).sort((e,t)=>Cn(e.path,t.path)||Cn(e.draft.key,t.draft.key)),r=[],i=null;for(let{path:e,draft:t}of n)e!==i&&(r.push(`--- a/${e}`,`+++ b/${e}`),i=e),r.push(`@@ ${t.key} @@`),t.from!==null&&r.push(`-${JSON.stringify(t.from)}`),r.push(`+${JSON.stringify(t.to)}`);return r.join(`
10
- `)}function Tn(e,t){return t===e.to?`live`:(t??null)===e.from?`pending`:`conflict`}var En=`livelocale:drafts-changed`,Dn=`This browser cannot keep your changes after the tab closes (private window or blocked storage). Send them before you leave.`,On=`Adding, renaming or deleting languages is not available on a share link. Ask your developer.`,kn=`Use "Send to developer" to hand your changes over.`,An=(e,t)=>e.startsWith(t+`.`)||t.startsWith(e+`.`);async function jn(e){let{studioUrl:t,appUrl:n,store:r}=e,i=e.manifest,a=e.manifestText,o=e.fetch??((e,t)=>globalThis.fetch(e,t)),s=e.now??(()=>Date.now()),c=e.events??(typeof window<`u`?window:new EventTarget),l=()=>{c.dispatchEvent(new Event(En))},u=xn(i,n),d=new Map,f=e=>he(e)&&ve(e)&&i.locales.includes(e);async function p(e){let n=`locales/${e}.json`,r=await o(new URL(n,t).href,{cache:`no-cache`,credentials:`same-origin`});if(!r.ok)throw Error(`Could not load ${n} (${r.status}).`);return await r.json()}function m(e){if(!f(e))return Promise.reject(Error(`Unknown language "${e}".`));let t=d.get(e);return t||(t=p(e),d.set(e,t),t.catch(()=>{d.get(e)===t&&d.delete(e)})),t}async function h(e){return(await r.list(u)).filter(t=>t.locale===e).reverse()}async function g(){let e=await Promise.allSettled(i.locales.map(e=>m(e))),t=[];return e.forEach((e,n)=>{e.status===`fulfilled`&&t.push([i.locales[n],e.value])}),t}async function _(){let e=await r.list(u),t=[...new Set(e.map(e=>e.locale).filter(f))],n=await Promise.allSettled(t.map(e=>m(e))),i=new Map;n.forEach((e,n)=>{e.status===`fulfilled`&&i.set(t[n],e.value)});let a={live:[],conflicts:[]},o=!1;for(let t of e){let e=`conflict`;if(f(t.locale)){let n=i.get(t.locale);if(!n)continue;let r=De(n,t.key);e=Tn(t,r.state===`string`?r.value:void 0)}if(e===`live`)await r.delete(u,t.locale,t.key),a.live.push(t),o=!0;else if(e===`conflict`){let e=t.conflict?t:{...t,conflict:!0};t.conflict||(await r.put(e),o=!0),a.conflicts.push(e)}}return o&&l(),a}let v=s(),y=await _().catch(()=>({live:[],conflicts:[]}));async function b(){try{let e=await o(new URL(`manifest.json`,t).href,{cache:`no-store`,credentials:`same-origin`});return e.ok?await e.text():null}catch{return null}}return{get manifest(){return i},scope:u,initialReconcile:y,persistent:r.persistent,events:c,readBuiltLocale:m,async fetchInfo(){return{mode:`static`,authRequired:!1,git:!1,problems:r.persistent?[]:[Dn]}},async fetchLocales(){return[...i.locales]},async fetchLocaleDictionary(e){let t=await m(e),n={};for(let t of await h(e))Te(n,t.key,t.to);return we(t,n)},async fetchKeysMetadata(){let e=new Set(i.codeKeys);for(let[,t]of await g())Oe(t,``,e);for(let t of await r.list(u))e.add(t.key);return{allKeys:[...e].sort(),codeKeys:[...i.codeKeys]}},async textCandidates(){let e={};for(let[t,n]of await g()){let r={};for(let e of Oe(n)){let t=De(n,e);t.state===`string`&&(r[e]=[t.value])}for(let e of await h(t)){let t=r[e.key]??=[];t.includes(e.to)||t.push(e.to)}e[t]=r}return e},listDrafts(){return r.list(u)},async discardDraft(e,t){let n=await r.get(u,e,t);return n&&await r.delete(u,e,t),l(),n},async markDraftsSent(e){let t=s();for(let{locale:n,key:i}of e){let e=await r.get(u,n,i);e&&await r.put({...e,status:`sent`,sentAt:t})}l()},async restoreDrafts(e){let t=await r.list(u),n=0;for(let{locale:a,key:o,from:c,to:l,force:d}of e){let e=t.some(e=>e.locale===a&&(e.key===o||An(e.key,o)));if(!f(a)||e)continue;let p={scope:u,locale:a,key:o,from:c,to:l,force:d,base:i.base,branch:i.branch,status:`unsent`,conflict:!1,updatedAt:s(),sentAt:null};await r.put(p),t.push(p),n++}return n>0&&l(),{added:n,skipped:e.length-n}},async saveTranslation(e,t,n,a={}){let o=await m(e),c=De(o,t),d=c.state===`string`?c.value:null;if(n===d)return await r.delete(u,e,t),l(),{success:!0,key:t,locale:e};let f=a.force===!0,p=Me({locale:e,key:t,value:n},{sourceLocale:i.sourceLocale,source:await m(i.sourceLocale),target:o},{force:f});if(!p.ok&&p.status!==422)throw Error(p.error);if((await r.list(u)).filter(n=>n.locale===e&&n.key!==t).some(e=>An(e.key,t)))throw Error(`Cannot save "${t}" in ${e}: it would replace translations that are not a single text.`);if(!p.ok)throw new Zt(p.error,p.code,p.details);return await r.put({scope:u,locale:e,key:t,from:d,to:n,force:f,base:i.base,branch:i.branch,status:`unsent`,conflict:!1,updatedAt:s(),sentAt:null}),l(),{success:!0,key:t,locale:e}},async discardLocales(){for(let e of await r.list(u))e.status===`unsent`&&await r.delete(u,e.locale,e.key);return l(),{success:!0}},async fetchGitState(){let e=await r.list(u),t=new Set(e.map(e=>Sn(i,e.locale,e.key)));return{available:!0,isRepo:!0,branch:i.branch,mode:`static`,changes:[...t].sort().map(e=>({path:e,status:`modified`})),diff:wn(e,i),pullRequestUrl:null}},async refreshManifest(){if(s()-v<6e4)return null;v=s();let e=await b();if(e===null||e===a)return null;let t;try{t=Mt(JSON.parse(e))}catch{t=null}return t?(i=t,a=e,d.clear(),_()):null},addLocaleRequest:()=>Promise.reject(Error(On)),renameLocaleRequest:()=>Promise.reject(Error(On)),deleteLocaleRequest:()=>Promise.reject(Error(On)),commitLocales:()=>Promise.reject(Error(kn))}}function Mn(e){return e===1?`1 change not sent`:`${e} changes not sent`}function Nn(e){let[t,n]=(0,g.useState)([]),[r,i]=(0,g.useState)(()=>e?.initialReconcile?.live??[]),a=(0,g.useCallback)(e=>{e.live.length>0&&i(t=>[...t,...e.live])},[]),o=(0,g.useCallback)(()=>i([]),[]),s=(0,g.useCallback)(async()=>{e&&n(await e.listDrafts())},[e]);(0,g.useEffect)(()=>{if(!e)return;let t=!0,r=()=>{e.listDrafts().then(e=>{t&&n(e)}).catch(()=>{})};return r(),e.events.addEventListener(En,r),()=>{t=!1,e.events.removeEventListener(En,r)}},[e]);let c=(0,g.useCallback)(async t=>e?.discardDraft(t.locale,t.key),[e]),l=(0,g.useCallback)(async t=>{e&&await e.markDraftsSent(t.map(({locale:e,key:t})=>({locale:e,key:t})))},[e]),{unsentCount:u,sentCount:d}=(0,g.useMemo)(()=>{let e=t.filter(e=>e.status===`unsent`).length;return{unsentCount:e,sentCount:t.length-e}},[t]);return{drafts:t,unsentCount:u,sentCount:d,refresh:s,discard:c,markSent:l,liveNow:r,noteReconcile:a,dismissLiveNow:o}}var Pn=e=>e===1?`Reviewing 1 proposed change`:`Reviewing ${e} proposed changes`,Fn={content:`detected from page text`,url:`from the page address`,manual:`chosen by you`,remembered:`from your last visit`},In=({coveragePercentage:e,mode:t,changesCount:n,isChangesOpen:r,onToggleChanges:i,unsentCount:a=0,targetLocale:o=null,locales:s,onChooseLocale:c,canSend:l=!1,onSend:u,reviewCount:d=null,onCloseReview:f,onImport:p})=>{let m=d!==null,h=o?.mismatch&&(!s||s.includes(o.mismatch))?o.mismatch:null;return(0,y.jsxs)(`header`,{className:`h-16 bg-[#080b11]/90 backdrop-blur-md border-b border-slate-900/60 px-4 xl:px-8 flex items-center justify-between gap-4 shrink-0 select-none`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,y.jsx)(`div`,{className:`w-8 h-8 rounded-xl bg-linear-to-tr from-indigo-600 to-violet-500 flex items-center justify-center shadow-lg shadow-indigo-500/20`,children:(0,y.jsxs)(`svg`,{className:`w-4 h-4 text-white`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:[(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2.5,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`}),(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z`})]})}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h1`,{className:`text-base font-extrabold tracking-wide font-outfit bg-linear-to-r from-slate-100 to-slate-300 bg-clip-text text-transparent`,children:`LiveLocale`}),(0,y.jsx)(`p`,{className:`hidden xl:block text-[10px] text-slate-500 font-medium tracking-wider uppercase mt-0.5`,children:`Live Visual Translation Studio`})]})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-3 xl:gap-5 min-w-0`,children:[o&&(0,y.jsxs)(`div`,{"data-testid":`target-locale`,className:`flex items-center gap-2 select-none min-w-0 overflow-hidden`,children:[o.source===null?(0,y.jsx)(`span`,{className:`px-2.5 py-1 rounded-full bg-slate-900 border border-slate-800 text-[10px] font-semibold text-slate-400 whitespace-nowrap truncate min-w-0`,children:`Language: not chosen yet`}):(0,y.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-indigo-600/10 border border-indigo-500/30 text-[10px] whitespace-nowrap min-w-0`,children:[(0,y.jsx)(`span`,{className:`font-bold text-indigo-200`,children:`Editing: ${o.locale}`}),(0,y.jsx)(`span`,{className:`hidden xl:inline text-slate-400`,children:Fn[o.source]})]}),h&&(0,y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-amber-300 whitespace-nowrap shrink-0`,children:[(0,y.jsx)(`span`,{className:`hidden xl:inline`,children:`This text looks like ${h}.`}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>c?.(h),title:`This text looks like ${h}.`,className:`px-2 py-0.5 rounded-md bg-amber-500/10 border border-amber-500/30 font-semibold hover:bg-amber-500/20 transition duration-150`,children:`Switch to ${h}`})]})]}),(0,y.jsxs)(`div`,{className:`items-center gap-2.5 shrink-0 ${o?`hidden xl:flex`:`flex`}`,title:`${e}% of keys translated`,children:[(0,y.jsx)(`span`,{className:`text-[10px] text-slate-500 font-medium select-none whitespace-nowrap`,children:`Coverage`}),(0,y.jsx)(`div`,{className:`w-16 xl:w-28 h-1.5 bg-slate-800 rounded-full overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full transition-all duration-700 ease-out`,style:{width:`${e}%`,background:e>=80?`linear-gradient(90deg, #34d399, #059669)`:e>=40?`linear-gradient(90deg, #fbbf24, #f59e0b)`:`linear-gradient(90deg, #f87171, #ef4444)`}})}),(0,y.jsxs)(`span`,{className:`text-[10px] font-bold font-mono text-slate-400 select-none tabular-nums`,children:[e,`%`]})]}),t===`preview`&&(0,y.jsx)(`span`,{className:`px-2.5 py-1 rounded-full bg-amber-500/10 border border-amber-500/30 text-[10px] font-extrabold tracking-wider text-amber-300 select-none`,title:`Edits go to a git branch on the server; nothing is written locally.`,children:`PREVIEW`}),m&&(0,y.jsx)(`span`,{"data-testid":`review-chip`,className:`shrink-0 px-2.5 py-1 rounded-full bg-indigo-600/10 border border-indigo-500/30 text-[10px] font-semibold text-indigo-200 select-none whitespace-nowrap`,children:Pn(d)}),m&&f&&(0,y.jsx)(`button`,{id:`studio-close-review`,type:`button`,onClick:f,className:`shrink-0 px-3 py-1.5 rounded-xl border text-[11px] font-semibold bg-slate-900 border-slate-800 text-slate-300 hover:text-slate-100 hover:border-slate-700 transition duration-150 whitespace-nowrap`,children:`Close review`}),!m&&a>0&&(0,y.jsx)(`span`,{"data-testid":`unsent-counter`,className:`shrink-0 px-2.5 py-1 rounded-full bg-amber-500/10 border border-amber-500/30 text-[10px] font-semibold text-amber-300 select-none whitespace-nowrap`,title:`Saved in this browser only. Send them to your developer before you leave.`,children:Mn(a)}),!m&&u&&(0,y.jsx)(`button`,{id:`studio-send-button`,onClick:u,disabled:!l,className:`shrink-0 px-3 py-1.5 rounded-xl border text-[11px] font-semibold bg-indigo-600 border-indigo-500 text-indigo-50 hover:bg-indigo-500 disabled:opacity-40 disabled:cursor-not-allowed transition duration-150 whitespace-nowrap`,title:`Turn your changes into a link or file for your developer`,children:`Send to developer`}),t===`development`&&p&&(0,y.jsx)(`button`,{id:`studio-import-button`,type:`button`,onClick:p,className:`shrink-0 px-3 py-1.5 rounded-xl border text-[11px] font-semibold bg-slate-900 border-slate-800 text-slate-300 hover:text-slate-100 hover:border-slate-700 transition duration-150 whitespace-nowrap`,title:`Review a translator's change link and apply it to your local files`,children:`Import change link`}),(0,y.jsxs)(`button`,{id:`studio-changes-button`,onClick:i,className:`shrink-0 flex items-center gap-2 px-3 py-1.5 rounded-xl border text-[11px] font-semibold whitespace-nowrap transition duration-150 ${r?`bg-indigo-600/20 border-indigo-500 text-indigo-300`:`bg-slate-900 border-slate-800 text-slate-300 hover:text-slate-100 hover:border-slate-700`}`,title:`Review, commit, or undo locale changes`,children:[(0,y.jsxs)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,viewBox:`0 0 24 24`,children:[(0,y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,y.jsx)(`path`,{d:`M12 3v6M12 15v6`})]}),`Changes`,n>0&&(0,y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-md bg-amber-500/15 border border-amber-500/30 text-[10px] font-mono font-bold text-amber-300`,children:n})]}),(0,y.jsxs)(`span`,{className:`hidden xl:block px-3 py-1 rounded-full bg-slate-900 border border-slate-800 text-[10px] font-bold text-slate-400 select-none`,children:[`v`,`0.10.0-next.7`,` (BETA)`]})]})]})},Ln=({showConfirmModal:e,onConfirm:t,onCancel:n})=>e?(0,y.jsx)(`div`,{className:`fixed inset-0 z-50 bg-slate-950/80 backdrop-blur-sm flex items-center justify-center p-4`,children:(0,y.jsxs)(`div`,{className:`bg-slate-900 border border-slate-800 rounded-2xl w-full max-w-md p-6 shadow-2xl relative animate-in fade-in zoom-in-95 duration-200`,children:[(0,y.jsx)(`h3`,{className:`text-base font-bold text-slate-200 font-outfit`,children:`Unsaved Changes`}),(0,y.jsx)(`p`,{className:`text-xs text-slate-400 mt-2 leading-relaxed`,children:`You have unsaved edits in your translation. Selecting another element will discard these modifications. Do you want to discard your edits?`}),(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-6`,children:[(0,y.jsx)(`button`,{onClick:n,className:`px-4 py-2 text-xs font-semibold text-slate-400 hover:text-slate-200 bg-slate-800 hover:bg-slate-750 border border-slate-850 hover:border-slate-700 rounded-xl transition duration-150`,children:`Keep Editing`}),(0,y.jsx)(`button`,{onClick:t,className:`px-4 py-2 text-xs font-semibold text-white bg-rose-600 hover:bg-rose-500 rounded-xl shadow-lg shadow-rose-600/10 active:bg-rose-700 transition duration-150`,children:`Discard Edits`})]})]})}):null,Rn=({filteredKeys:e,selected:t,localeData:n,searchTerm:r,setSearchTerm:i,filterPageOnly:a,setFilterPageOnly:o,visibleKeys:s,selectKeyDirectly:c,className:l=`w-[300px] shrink-0`})=>(0,y.jsxs)(`div`,{"data-testid":`keys-directory`,className:`${l} bg-slate-900 border border-slate-800 rounded-2xl flex flex-col h-full shadow-2xl overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`h-14 bg-slate-950 border-b border-slate-800 flex items-center justify-between px-6 shrink-0 select-none`,children:[(0,y.jsx)(`h2`,{className:`text-sm font-bold tracking-wide font-outfit text-slate-200`,children:`Locale Directory`}),(0,y.jsxs)(`span`,{className:`text-[10px] font-bold font-mono px-2 py-0.5 rounded bg-slate-900 text-indigo-400 border border-slate-850`,children:[e.length,` keys`]})]}),(0,y.jsxs)(`div`,{className:`p-4 border-b border-slate-800/80 shrink-0 bg-slate-900/40 space-y-3`,children:[(0,y.jsxs)(`div`,{className:`relative`,children:[(0,y.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search keys or values...`,className:`w-full h-9 pl-9 pr-4 bg-slate-950 border border-slate-800 hover:border-slate-750 focus:border-indigo-500 focus:outline-hidden focus:ring-1 focus:ring-indigo-500/50 rounded-lg text-xs text-slate-200 placeholder-slate-600 transition duration-150`}),(0,y.jsx)(`svg`,{className:`w-3.5 h-3.5 text-slate-600 absolute left-3 top-2.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2.5,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-[10px] text-slate-500 font-semibold uppercase tracking-wider`,children:`Scope`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1 bg-slate-950 border border-slate-850 rounded-lg p-0.5 select-none shrink-0`,children:[(0,y.jsx)(`button`,{onClick:()=>o(!1),className:`px-2.5 py-1 text-[9px] font-bold rounded-md transition duration-150 ${a?`text-slate-500 hover:text-slate-300`:`bg-indigo-600 text-white shadow-sm`}`,children:`All Keys`}),(0,y.jsx)(`button`,{onClick:()=>o(!0),disabled:s===null,className:`px-2.5 py-1 text-[9px] font-bold rounded-md transition duration-150 ${a?`bg-indigo-600 text-white shadow-sm`:`text-slate-500 hover:text-slate-300 disabled:opacity-40 disabled:cursor-not-allowed`}`,title:s===null?`Waiting for preview connection...`:`Only show keys on the current page`,children:`Page Keys`})]})]})]}),(0,y.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-1 scrollbar-thin`,children:e.length>0?e.map(e=>{let r=t?.key===e,i=n[e]||``,a=n[e]===void 0;return(0,y.jsxs)(`button`,{onClick:()=>c(e),className:`w-full text-left p-3 rounded-xl border transition duration-150 flex flex-col gap-1.5 ${r?`bg-indigo-600/10 border-indigo-500 text-slate-100 shadow-sm`:`bg-slate-950/20 hover:bg-slate-950/50 border-transparent text-slate-300 hover:text-slate-200`}`,children:[(0,y.jsxs)(`div`,{className:`w-full flex items-center justify-between gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[11px] font-semibold font-mono break-all line-clamp-2 leading-relaxed text-indigo-400`,children:e}),a&&(0,y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-rose-500/10 text-[8px] font-extrabold text-rose-400 border border-rose-500/20 shrink-0 uppercase tracking-wider`,children:`Missing`})]}),(0,y.jsx)(`span`,{dir:`auto`,className:`text-[10px] text-slate-500 break-all line-clamp-1`,children:i||(0,y.jsx)(`span`,{className:`italic text-slate-750`,children:`Empty`})})]},e)}):(0,y.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center p-6 text-center text-slate-600 select-none`,children:[(0,y.jsx)(`svg`,{className:`w-8 h-8 text-slate-700 mb-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`})}),(0,y.jsx)(`span`,{className:`text-xs`,children:`No keys found`})]})})]}),zn={unsent:`Not sent`,sent:`Sent`,live:`Live now`,conflict:`Changed by someone else, please check`},Bn={unsent:`text-amber-400 border-amber-500/30 bg-amber-500/10`,sent:`text-sky-400 border-sky-500/30 bg-sky-500/10`,live:`text-emerald-400 border-emerald-500/30 bg-emerald-500/10`,conflict:`text-rose-400 border-rose-500/30 bg-rose-500/10`},Vn=`Removes it from this list. A link you already sent still carries it.`;function Hn(e){return e.conflict?`conflict`:e.status}var Un=e=>(0,y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[9px] font-extrabold uppercase tracking-wider border ${Bn[e]}`,children:zn[e]}),Wn=e=>(0,y.jsx)(`span`,{className:`text-[11px] font-mono text-indigo-400 break-all`,children:`${e.key} · ${e.locale}`}),Gn=({d:e})=>(0,y.jsxs)(`div`,{className:`text-[10px] leading-relaxed`,children:[e.from?(0,y.jsx)(`span`,{dir:`auto`,className:`text-rose-400/80 line-through break-all`,children:e.from}):(0,y.jsx)(`em`,{className:`text-rose-400/80 line-through`,children:`empty`}),(0,y.jsx)(`span`,{className:`text-slate-600`,children:` → `}),e.to?(0,y.jsx)(`span`,{dir:`auto`,className:`text-emerald-300 break-all`,children:e.to}):(0,y.jsx)(`em`,{className:`text-emerald-300`,children:`empty`})]}),Kn=`px-3 py-2 rounded-xl bg-slate-950/40 border border-slate-800/80 space-y-1`,qn=`h-9 px-3 rounded-xl text-xs font-semibold text-slate-300 hover:text-slate-100 bg-slate-800 hover:bg-slate-700 border border-slate-700 transition duration-150 cursor-pointer`,Jn=({drafts:e,onUndo:t,isUndoing:n,onDownloadBackup:r,onRestoreBackup:i,onReviewChange:a,liveNow:o=[],onDismissLiveNow:s})=>{let[c,l]=(0,g.useState)(null);return(0,y.jsxs)(`section`,{className:`space-y-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsx)(`h3`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`Your changes`}),(0,y.jsx)(`span`,{className:`text-[10px] font-bold font-mono px-2 py-0.5 rounded bg-slate-950 text-indigo-400 border border-slate-850`,children:e.length})]}),e.length===0&&o.length===0?(0,y.jsx)(`p`,{className:`text-xs text-slate-500`,children:`No changes yet. Alt+Click any text in the app to fix it.`}):(0,y.jsxs)(`ul`,{className:`space-y-1.5`,children:[e.map(e=>{let r=Hn(e),i=r===`sent`;return(0,y.jsxs)(`li`,{className:Kn,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[Wn(e),(0,y.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[Un(r),(0,y.jsx)(`button`,{onClick:()=>t(e),disabled:n,className:`text-[10px] font-semibold text-slate-400 hover:text-slate-100 px-2 py-0.5 rounded-md border border-slate-800 hover:border-slate-600 disabled:opacity-40 transition duration-150`,title:i?Vn:`Go back to the published text`,children:i?`Remove`:`Undo`})]})]}),(0,y.jsx)(Gn,{d:e})]},`${e.locale}/${e.key}`)}),o.map(e=>(0,y.jsxs)(`li`,{className:Kn,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[Wn(e),(0,y.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:Un(`live`)})]}),(0,y.jsx)(Gn,{d:e})]},`live:${e.locale}/${e.key}`))]}),o.length>0&&s&&(0,y.jsx)(`button`,{onClick:s,className:`text-[10px] font-semibold text-slate-500 hover:text-slate-300 transition duration-150`,children:`Dismiss live changes`}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-2`,children:[(0,y.jsx)(`button`,{onClick:async()=>{l(null);try{await r(),l(`Backup downloaded.`)}catch(e){l(e?.message||`Could not create the backup.`)}},className:qn,children:`Download backup`}),(0,y.jsxs)(`label`,{className:`${qn} inline-flex items-center`,children:[`Restore backup`,(0,y.jsx)(`input`,{type:`file`,accept:`.txt,text/plain`,onChange:async e=>{let t=e.currentTarget,n=t.files?.[0];if(n){l(null);try{l(await i(n))}catch(e){l(e?.message||`Could not restore the backup.`)}finally{t.value=``}}},className:`sr-only`})]}),a&&(0,y.jsx)(`button`,{onClick:a,className:qn,children:`Review a change link or file`})]}),c&&(0,y.jsx)(`p`,{role:`status`,className:`text-[11px] text-slate-400 break-words`,children:c})]})},Yn=async()=>{},Xn=async()=>``,Zn={modified:`text-amber-400 border-amber-500/30 bg-amber-500/10`,added:`text-emerald-400 border-emerald-500/30 bg-emerald-500/10`,deleted:`text-rose-400 border-rose-500/30 bg-rose-500/10`,renamed:`text-sky-400 border-sky-500/30 bg-sky-500/10`},Qn=e=>e.startsWith(`+++`)||e.startsWith(`---`)?`text-slate-500`:e.startsWith(`@@`)?`text-indigo-400`:e.startsWith(`diff `)||e.startsWith(`new file`)?`text-slate-600`:e.startsWith(`+`)?`text-emerald-300 bg-emerald-500/10`:e.startsWith(`-`)?`text-rose-300 bg-rose-500/10`:`text-slate-400`,$n=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),er=({isOpen:e,onClose:t,git:n,gitError:r,isGitLoading:i,lastCommit:a,onCommit:o,onDiscard:s,onRefresh:c,history:l,onUndo:u,isUndoing:d,drafts:f,onUndoDraft:p=Yn,onDownloadBackup:m=Yn,onRestoreBackup:h=Xn,onReviewChange:_,liveNow:v,onDismissLiveNow:b})=>{let[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1);if(!e)return null;let D=n?.changes??[],O=n?.mode===`github`,k=!!n?.isRepo&&D.length>0&&x.trim().length>0;return(0,y.jsxs)(`div`,{className:`fixed inset-0 top-16 z-40 flex justify-end`,"data-testid":`changes-panel`,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 bg-slate-950/60 backdrop-blur-[2px]`,onClick:t}),(0,y.jsxs)(`aside`,{className:`relative w-[520px] max-w-full h-full bg-slate-900 border-l border-slate-800 shadow-2xl flex flex-col animate-in slide-in-from-right duration-200`,children:[(0,y.jsxs)(`div`,{className:`h-14 bg-slate-950 border-b border-slate-800 flex items-center justify-between px-6 shrink-0 select-none`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`h2`,{className:`text-sm font-bold tracking-wide font-outfit text-slate-200`,children:`Changes`}),n?.isRepo&&n.branch&&(0,y.jsx)(`span`,{className:`px-2 py-0.5 rounded-md bg-slate-900 border border-slate-800 text-[10px] font-mono text-indigo-400`,children:n.branch})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`button`,{onClick:c,className:`p-1.5 rounded-lg text-slate-400 hover:text-slate-200 hover:bg-slate-800 border border-transparent hover:border-slate-700 transition duration-150`,title:`Refresh`,children:(0,y.jsxs)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,viewBox:`0 0 24 24`,children:[(0,y.jsx)(`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`}),(0,y.jsx)(`path`,{d:`M21 3v5h-5`})]})}),(0,y.jsx)(`button`,{onClick:t,className:`p-1.5 rounded-lg text-slate-400 hover:text-slate-200 hover:bg-slate-800 border border-transparent hover:border-slate-700 transition duration-150`,title:`Close`,children:(0,y.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{d:`M18 6L6 18M6 6l12 12`})})})]})]}),Array.isArray(f)?(0,y.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-6`,children:(0,y.jsx)(Jn,{drafts:f,onUndo:p,isUndoing:d,onDownloadBackup:m,onRestoreBackup:h,onReviewChange:_,liveNow:v,onDismissLiveNow:b})}):(0,y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-6`,children:[(0,y.jsxs)(`section`,{className:`space-y-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`Locale files`}),(0,y.jsxs)(`span`,{className:`text-[10px] font-bold font-mono px-2 py-0.5 rounded bg-slate-950 text-indigo-400 border border-slate-850`,children:[D.length,` changed`]})]}),n===null?(0,y.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Loading git status…`}):n.available?n.isRepo?D.length===0?(0,y.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Working tree is clean. Edits you save will show up here.`}):(0,y.jsx)(`ul`,{className:`space-y-1.5`,children:D.map(e=>(0,y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-3 py-2 rounded-xl bg-slate-950/40 border border-slate-800/80`,children:[(0,y.jsx)(`span`,{className:`text-[11px] font-mono text-slate-300 break-all`,children:e.path}),(0,y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[9px] font-extrabold uppercase tracking-wider border shrink-0 ${Zn[e.status]??Zn.modified}`,children:e.status})]},e.path))}):(0,y.jsxs)(`p`,{className:`text-xs text-slate-500 leading-relaxed`,children:[`The locales directory is not inside a git repository, or the`,` `,(0,y.jsx)(`code`,{className:`font-mono text-slate-400`,children:`git`}),` command is not on PATH.`]}):(0,y.jsxs)(`p`,{className:`text-xs text-slate-500 leading-relaxed`,children:[`Git integration is disabled for this handler. Enable it by removing`,` `,(0,y.jsx)(`code`,{className:`font-mono text-slate-400`,children:`git: false`}),` from the route configuration.`]}),n?.isRepo&&D.length>0&&(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`button`,{onClick:()=>E(e=>!e),className:`text-[10px] font-semibold text-slate-500 hover:text-slate-300 transition duration-150`,children:T?`Hide diff`:`Show diff`}),T&&(0,y.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-xl bg-slate-950 border border-slate-800 p-3 text-[10px] font-mono leading-relaxed whitespace-pre`,children:n.diff.split(`
10
+ `)}function Tn(e,t){return t===e.to?`live`:(t??null)===e.from?`pending`:`conflict`}var En=`livelocale:drafts-changed`,Dn=`This browser cannot keep your changes after the tab closes (private window or blocked storage). Send them before you leave.`,On=`Adding, renaming or deleting languages is not available on a share link. Ask your developer.`,kn=`Use "Send to developer" to hand your changes over.`,An=(e,t)=>e.startsWith(t+`.`)||t.startsWith(e+`.`);async function jn(e){let{studioUrl:t,appUrl:n,store:r}=e,i=e.manifest,a=e.manifestText,o=e.fetch??((e,t)=>globalThis.fetch(e,t)),s=e.now??(()=>Date.now()),c=e.events??(typeof window<`u`?window:new EventTarget),l=()=>{c.dispatchEvent(new Event(En))},u=xn(i,n),d=new Map,f=e=>he(e)&&ve(e)&&i.locales.includes(e);async function p(e){let n=`locales/${e}.json`,r=await o(new URL(n,t).href,{cache:`no-cache`,credentials:`same-origin`});if(!r.ok)throw Error(`Could not load ${n} (${r.status}).`);return await r.json()}function m(e){if(!f(e))return Promise.reject(Error(`Unknown language "${e}".`));let t=d.get(e);return t||(t=p(e),d.set(e,t),t.catch(()=>{d.get(e)===t&&d.delete(e)})),t}async function h(e){return(await r.list(u)).filter(t=>t.locale===e).reverse()}async function g(){let e=await Promise.allSettled(i.locales.map(e=>m(e))),t=[];return e.forEach((e,n)=>{e.status===`fulfilled`&&t.push([i.locales[n],e.value])}),t}async function _(){let e=await r.list(u),t=[...new Set(e.map(e=>e.locale).filter(f))],n=await Promise.allSettled(t.map(e=>m(e))),i=new Map;n.forEach((e,n)=>{e.status===`fulfilled`&&i.set(t[n],e.value)});let a={live:[],conflicts:[]},o=!1;for(let t of e){let e=`conflict`;if(f(t.locale)){let n=i.get(t.locale);if(!n)continue;let r=De(n,t.key);e=Tn(t,r.state===`string`?r.value:void 0)}if(e===`live`)await r.delete(u,t.locale,t.key),a.live.push(t),o=!0;else if(e===`conflict`){let e=t.conflict?t:{...t,conflict:!0};t.conflict||(await r.put(e),o=!0),a.conflicts.push(e)}}return o&&l(),a}let v=s(),y=await _().catch(()=>({live:[],conflicts:[]}));async function b(){try{let e=await o(new URL(`manifest.json`,t).href,{cache:`no-store`,credentials:`same-origin`});return e.ok?await e.text():null}catch{return null}}return{get manifest(){return i},scope:u,initialReconcile:y,persistent:r.persistent,events:c,readBuiltLocale:m,async fetchInfo(){return{mode:`static`,authRequired:!1,git:!1,problems:r.persistent?[]:[Dn]}},async fetchLocales(){return[...i.locales]},async fetchLocaleDictionary(e){let t=await m(e),n={};for(let t of await h(e))Te(n,t.key,t.to);return we(t,n)},async fetchKeysMetadata(){let e=new Set(i.codeKeys);for(let[,t]of await g())Oe(t,``,e);for(let t of await r.list(u))e.add(t.key);return{allKeys:[...e].sort(),codeKeys:[...i.codeKeys]}},async textCandidates(){let e={};for(let[t,n]of await g()){let r={};for(let e of Oe(n)){let t=De(n,e);t.state===`string`&&(r[e]=[t.value])}for(let e of await h(t)){let t=r[e.key]??=[];t.includes(e.to)||t.push(e.to)}e[t]=r}return e},listDrafts(){return r.list(u)},async discardDraft(e,t){let n=await r.get(u,e,t);return n&&await r.delete(u,e,t),l(),n},async markDraftsSent(e){let t=s();for(let{locale:n,key:i}of e){let e=await r.get(u,n,i);e&&await r.put({...e,status:`sent`,sentAt:t})}l()},async restoreDrafts(e){let t=await r.list(u),n=0;for(let{locale:a,key:o,from:c,to:l,force:d}of e){let e=t.some(e=>e.locale===a&&(e.key===o||An(e.key,o)));if(!f(a)||e)continue;let p={scope:u,locale:a,key:o,from:c,to:l,force:d,base:i.base,branch:i.branch,status:`unsent`,conflict:!1,updatedAt:s(),sentAt:null};await r.put(p),t.push(p),n++}return n>0&&l(),{added:n,skipped:e.length-n}},async saveTranslation(e,t,n,a={}){let o=await m(e),c=De(o,t),d=c.state===`string`?c.value:null;if(n===d)return await r.delete(u,e,t),l(),{success:!0,key:t,locale:e};let f=a.force===!0,p=Me({locale:e,key:t,value:n},{sourceLocale:i.sourceLocale,source:await m(i.sourceLocale),target:o},{force:f});if(!p.ok&&p.status!==422)throw Error(p.error);if((await r.list(u)).filter(n=>n.locale===e&&n.key!==t).some(e=>An(e.key,t)))throw Error(`Cannot save "${t}" in ${e}: it would replace translations that are not a single text.`);if(!p.ok)throw new Zt(p.error,p.code,p.details);return await r.put({scope:u,locale:e,key:t,from:d,to:n,force:f,base:i.base,branch:i.branch,status:`unsent`,conflict:!1,updatedAt:s(),sentAt:null}),l(),{success:!0,key:t,locale:e}},async discardLocales(){for(let e of await r.list(u))e.status===`unsent`&&await r.delete(u,e.locale,e.key);return l(),{success:!0}},async fetchGitState(){let e=await r.list(u),t=new Set(e.map(e=>Sn(i,e.locale,e.key)));return{available:!0,isRepo:!0,branch:i.branch,mode:`static`,changes:[...t].sort().map(e=>({path:e,status:`modified`})),diff:wn(e,i),pullRequestUrl:null}},async refreshManifest(){if(s()-v<6e4)return null;v=s();let e=await b();if(e===null||e===a)return null;let t;try{t=Mt(JSON.parse(e))}catch{t=null}return t?(i=t,a=e,d.clear(),_()):null},addLocaleRequest:()=>Promise.reject(Error(On)),renameLocaleRequest:()=>Promise.reject(Error(On)),deleteLocaleRequest:()=>Promise.reject(Error(On)),commitLocales:()=>Promise.reject(Error(kn))}}function Mn(e){return e===1?`1 change not sent`:`${e} changes not sent`}function Nn(e){let[t,n]=(0,g.useState)([]),[r,i]=(0,g.useState)(()=>e?.initialReconcile?.live??[]),a=(0,g.useCallback)(e=>{e.live.length>0&&i(t=>[...t,...e.live])},[]),o=(0,g.useCallback)(()=>i([]),[]),s=(0,g.useCallback)(async()=>{e&&n(await e.listDrafts())},[e]);(0,g.useEffect)(()=>{if(!e)return;let t=!0,r=()=>{e.listDrafts().then(e=>{t&&n(e)}).catch(()=>{})};return r(),e.events.addEventListener(En,r),()=>{t=!1,e.events.removeEventListener(En,r)}},[e]);let c=(0,g.useCallback)(async t=>e?.discardDraft(t.locale,t.key),[e]),l=(0,g.useCallback)(async t=>{e&&await e.markDraftsSent(t.map(({locale:e,key:t})=>({locale:e,key:t})))},[e]),{unsentCount:u,sentCount:d}=(0,g.useMemo)(()=>{let e=t.filter(e=>e.status===`unsent`).length;return{unsentCount:e,sentCount:t.length-e}},[t]);return{drafts:t,unsentCount:u,sentCount:d,refresh:s,discard:c,markSent:l,liveNow:r,noteReconcile:a,dismissLiveNow:o}}var Pn=e=>e===1?`Reviewing 1 proposed change`:`Reviewing ${e} proposed changes`,Fn={content:`detected from page text`,url:`from the page address`,manual:`chosen by you`,remembered:`from your last visit`},In=({coveragePercentage:e,mode:t,changesCount:n,isChangesOpen:r,onToggleChanges:i,unsentCount:a=0,targetLocale:o=null,locales:s,onChooseLocale:c,canSend:l=!1,onSend:u,reviewCount:d=null,onCloseReview:f,onImport:p})=>{let m=d!==null,h=o?.mismatch&&(!s||s.includes(o.mismatch))?o.mismatch:null;return(0,y.jsxs)(`header`,{className:`h-16 bg-[#080b11]/90 backdrop-blur-md border-b border-slate-900/60 px-4 xl:px-8 flex items-center justify-between gap-4 shrink-0 select-none`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,y.jsx)(`div`,{className:`w-8 h-8 rounded-xl bg-linear-to-tr from-indigo-600 to-violet-500 flex items-center justify-center shadow-lg shadow-indigo-500/20`,children:(0,y.jsxs)(`svg`,{className:`w-4 h-4 text-white`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:[(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2.5,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`}),(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z`})]})}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h1`,{className:`text-base font-extrabold tracking-wide font-outfit bg-linear-to-r from-slate-100 to-slate-300 bg-clip-text text-transparent`,children:`LiveLocale`}),(0,y.jsx)(`p`,{className:`hidden xl:block text-[10px] text-slate-500 font-medium tracking-wider uppercase mt-0.5`,children:`Live Visual Translation Studio`})]})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-3 xl:gap-5 min-w-0`,children:[o&&(0,y.jsxs)(`div`,{"data-testid":`target-locale`,className:`flex items-center gap-2 select-none min-w-0 overflow-hidden`,children:[o.source===null?(0,y.jsx)(`span`,{className:`px-2.5 py-1 rounded-full bg-slate-900 border border-slate-800 text-[10px] font-semibold text-slate-400 whitespace-nowrap truncate min-w-0`,children:`Language: not chosen yet`}):(0,y.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-indigo-600/10 border border-indigo-500/30 text-[10px] whitespace-nowrap min-w-0`,children:[(0,y.jsx)(`span`,{className:`font-bold text-indigo-200`,children:`Editing: ${o.locale}`}),(0,y.jsx)(`span`,{className:`hidden xl:inline text-slate-400`,children:Fn[o.source]})]}),h&&(0,y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-amber-300 whitespace-nowrap shrink-0`,children:[(0,y.jsx)(`span`,{className:`hidden xl:inline`,children:`This text looks like ${h}.`}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>c?.(h),title:`This text looks like ${h}.`,className:`px-2 py-0.5 rounded-md bg-amber-500/10 border border-amber-500/30 font-semibold hover:bg-amber-500/20 transition duration-150`,children:`Switch to ${h}`})]})]}),(0,y.jsxs)(`div`,{className:`items-center gap-2.5 shrink-0 ${o?`hidden xl:flex`:`flex`}`,title:`${e}% of keys translated`,children:[(0,y.jsx)(`span`,{className:`text-[10px] text-slate-500 font-medium select-none whitespace-nowrap`,children:`Coverage`}),(0,y.jsx)(`div`,{className:`w-16 xl:w-28 h-1.5 bg-slate-800 rounded-full overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full transition-all duration-700 ease-out`,style:{width:`${e}%`,background:e>=80?`linear-gradient(90deg, #34d399, #059669)`:e>=40?`linear-gradient(90deg, #fbbf24, #f59e0b)`:`linear-gradient(90deg, #f87171, #ef4444)`}})}),(0,y.jsxs)(`span`,{className:`text-[10px] font-bold font-mono text-slate-400 select-none tabular-nums`,children:[e,`%`]})]}),t===`preview`&&(0,y.jsx)(`span`,{className:`px-2.5 py-1 rounded-full bg-amber-500/10 border border-amber-500/30 text-[10px] font-extrabold tracking-wider text-amber-300 select-none`,title:`Edits go to a git branch on the server; nothing is written locally.`,children:`PREVIEW`}),m&&(0,y.jsx)(`span`,{"data-testid":`review-chip`,className:`shrink-0 px-2.5 py-1 rounded-full bg-indigo-600/10 border border-indigo-500/30 text-[10px] font-semibold text-indigo-200 select-none whitespace-nowrap`,children:Pn(d)}),m&&f&&(0,y.jsx)(`button`,{id:`studio-close-review`,type:`button`,onClick:f,className:`shrink-0 px-3 py-1.5 rounded-xl border text-[11px] font-semibold bg-slate-900 border-slate-800 text-slate-300 hover:text-slate-100 hover:border-slate-700 transition duration-150 whitespace-nowrap`,children:`Close review`}),!m&&a>0&&(0,y.jsx)(`span`,{"data-testid":`unsent-counter`,className:`shrink-0 px-2.5 py-1 rounded-full bg-amber-500/10 border border-amber-500/30 text-[10px] font-semibold text-amber-300 select-none whitespace-nowrap`,title:`Saved in this browser only. Send them to your developer before you leave.`,children:Mn(a)}),!m&&u&&(0,y.jsx)(`button`,{id:`studio-send-button`,onClick:u,disabled:!l,className:`shrink-0 px-3 py-1.5 rounded-xl border text-[11px] font-semibold bg-indigo-600 border-indigo-500 text-indigo-50 hover:bg-indigo-500 disabled:opacity-40 disabled:cursor-not-allowed transition duration-150 whitespace-nowrap`,title:`Turn your changes into a link or file for your developer`,children:`Send to developer`}),t===`development`&&p&&(0,y.jsx)(`button`,{id:`studio-import-button`,type:`button`,onClick:p,className:`shrink-0 px-3 py-1.5 rounded-xl border text-[11px] font-semibold bg-slate-900 border-slate-800 text-slate-300 hover:text-slate-100 hover:border-slate-700 transition duration-150 whitespace-nowrap`,title:`Review a translator's change link and apply it to your local files`,children:`Import change link`}),(0,y.jsxs)(`button`,{id:`studio-changes-button`,onClick:i,className:`shrink-0 flex items-center gap-2 px-3 py-1.5 rounded-xl border text-[11px] font-semibold whitespace-nowrap transition duration-150 ${r?`bg-indigo-600/20 border-indigo-500 text-indigo-300`:`bg-slate-900 border-slate-800 text-slate-300 hover:text-slate-100 hover:border-slate-700`}`,title:`Review, commit, or undo locale changes`,children:[(0,y.jsxs)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,viewBox:`0 0 24 24`,children:[(0,y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,y.jsx)(`path`,{d:`M12 3v6M12 15v6`})]}),`Changes`,n>0&&(0,y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-md bg-amber-500/15 border border-amber-500/30 text-[10px] font-mono font-bold text-amber-300`,children:n})]}),(0,y.jsxs)(`span`,{className:`hidden xl:block px-3 py-1 rounded-full bg-slate-900 border border-slate-800 text-[10px] font-bold text-slate-400 select-none`,children:[`v`,`0.10.0`,` (BETA)`]})]})]})},Ln=({showConfirmModal:e,onConfirm:t,onCancel:n})=>e?(0,y.jsx)(`div`,{className:`fixed inset-0 z-50 bg-slate-950/80 backdrop-blur-sm flex items-center justify-center p-4`,children:(0,y.jsxs)(`div`,{className:`bg-slate-900 border border-slate-800 rounded-2xl w-full max-w-md p-6 shadow-2xl relative animate-in fade-in zoom-in-95 duration-200`,children:[(0,y.jsx)(`h3`,{className:`text-base font-bold text-slate-200 font-outfit`,children:`Unsaved Changes`}),(0,y.jsx)(`p`,{className:`text-xs text-slate-400 mt-2 leading-relaxed`,children:`You have unsaved edits in your translation. Selecting another element will discard these modifications. Do you want to discard your edits?`}),(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-6`,children:[(0,y.jsx)(`button`,{onClick:n,className:`px-4 py-2 text-xs font-semibold text-slate-400 hover:text-slate-200 bg-slate-800 hover:bg-slate-750 border border-slate-850 hover:border-slate-700 rounded-xl transition duration-150`,children:`Keep Editing`}),(0,y.jsx)(`button`,{onClick:t,className:`px-4 py-2 text-xs font-semibold text-white bg-rose-600 hover:bg-rose-500 rounded-xl shadow-lg shadow-rose-600/10 active:bg-rose-700 transition duration-150`,children:`Discard Edits`})]})]})}):null,Rn=({filteredKeys:e,selected:t,localeData:n,searchTerm:r,setSearchTerm:i,filterPageOnly:a,setFilterPageOnly:o,visibleKeys:s,selectKeyDirectly:c,className:l=`w-[300px] shrink-0`})=>(0,y.jsxs)(`div`,{"data-testid":`keys-directory`,className:`${l} bg-slate-900 border border-slate-800 rounded-2xl flex flex-col h-full shadow-2xl overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`h-14 bg-slate-950 border-b border-slate-800 flex items-center justify-between px-6 shrink-0 select-none`,children:[(0,y.jsx)(`h2`,{className:`text-sm font-bold tracking-wide font-outfit text-slate-200`,children:`Locale Directory`}),(0,y.jsxs)(`span`,{className:`text-[10px] font-bold font-mono px-2 py-0.5 rounded bg-slate-900 text-indigo-400 border border-slate-850`,children:[e.length,` keys`]})]}),(0,y.jsxs)(`div`,{className:`p-4 border-b border-slate-800/80 shrink-0 bg-slate-900/40 space-y-3`,children:[(0,y.jsxs)(`div`,{className:`relative`,children:[(0,y.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search keys or values...`,className:`w-full h-9 pl-9 pr-4 bg-slate-950 border border-slate-800 hover:border-slate-750 focus:border-indigo-500 focus:outline-hidden focus:ring-1 focus:ring-indigo-500/50 rounded-lg text-xs text-slate-200 placeholder-slate-600 transition duration-150`}),(0,y.jsx)(`svg`,{className:`w-3.5 h-3.5 text-slate-600 absolute left-3 top-2.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2.5,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-[10px] text-slate-500 font-semibold uppercase tracking-wider`,children:`Scope`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1 bg-slate-950 border border-slate-850 rounded-lg p-0.5 select-none shrink-0`,children:[(0,y.jsx)(`button`,{onClick:()=>o(!1),className:`px-2.5 py-1 text-[9px] font-bold rounded-md transition duration-150 ${a?`text-slate-500 hover:text-slate-300`:`bg-indigo-600 text-white shadow-sm`}`,children:`All Keys`}),(0,y.jsx)(`button`,{onClick:()=>o(!0),disabled:s===null,className:`px-2.5 py-1 text-[9px] font-bold rounded-md transition duration-150 ${a?`bg-indigo-600 text-white shadow-sm`:`text-slate-500 hover:text-slate-300 disabled:opacity-40 disabled:cursor-not-allowed`}`,title:s===null?`Waiting for preview connection...`:`Only show keys on the current page`,children:`Page Keys`})]})]})]}),(0,y.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-1 scrollbar-thin`,children:e.length>0?e.map(e=>{let r=t?.key===e,i=n[e]||``,a=n[e]===void 0;return(0,y.jsxs)(`button`,{onClick:()=>c(e),className:`w-full text-left p-3 rounded-xl border transition duration-150 flex flex-col gap-1.5 ${r?`bg-indigo-600/10 border-indigo-500 text-slate-100 shadow-sm`:`bg-slate-950/20 hover:bg-slate-950/50 border-transparent text-slate-300 hover:text-slate-200`}`,children:[(0,y.jsxs)(`div`,{className:`w-full flex items-center justify-between gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[11px] font-semibold font-mono break-all line-clamp-2 leading-relaxed text-indigo-400`,children:e}),a&&(0,y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-rose-500/10 text-[8px] font-extrabold text-rose-400 border border-rose-500/20 shrink-0 uppercase tracking-wider`,children:`Missing`})]}),(0,y.jsx)(`span`,{dir:`auto`,className:`text-[10px] text-slate-500 break-all line-clamp-1`,children:i||(0,y.jsx)(`span`,{className:`italic text-slate-750`,children:`Empty`})})]},e)}):(0,y.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center p-6 text-center text-slate-600 select-none`,children:[(0,y.jsx)(`svg`,{className:`w-8 h-8 text-slate-700 mb-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`})}),(0,y.jsx)(`span`,{className:`text-xs`,children:`No keys found`})]})})]}),zn={unsent:`Not sent`,sent:`Sent`,live:`Live now`,conflict:`Changed by someone else, please check`},Bn={unsent:`text-amber-400 border-amber-500/30 bg-amber-500/10`,sent:`text-sky-400 border-sky-500/30 bg-sky-500/10`,live:`text-emerald-400 border-emerald-500/30 bg-emerald-500/10`,conflict:`text-rose-400 border-rose-500/30 bg-rose-500/10`},Vn=`Removes it from this list. A link you already sent still carries it.`;function Hn(e){return e.conflict?`conflict`:e.status}var Un=e=>(0,y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[9px] font-extrabold uppercase tracking-wider border ${Bn[e]}`,children:zn[e]}),Wn=e=>(0,y.jsx)(`span`,{className:`text-[11px] font-mono text-indigo-400 break-all`,children:`${e.key} · ${e.locale}`}),Gn=({d:e})=>(0,y.jsxs)(`div`,{className:`text-[10px] leading-relaxed`,children:[e.from?(0,y.jsx)(`span`,{dir:`auto`,className:`text-rose-400/80 line-through break-all`,children:e.from}):(0,y.jsx)(`em`,{className:`text-rose-400/80 line-through`,children:`empty`}),(0,y.jsx)(`span`,{className:`text-slate-600`,children:` → `}),e.to?(0,y.jsx)(`span`,{dir:`auto`,className:`text-emerald-300 break-all`,children:e.to}):(0,y.jsx)(`em`,{className:`text-emerald-300`,children:`empty`})]}),Kn=`px-3 py-2 rounded-xl bg-slate-950/40 border border-slate-800/80 space-y-1`,qn=`h-9 px-3 rounded-xl text-xs font-semibold text-slate-300 hover:text-slate-100 bg-slate-800 hover:bg-slate-700 border border-slate-700 transition duration-150 cursor-pointer`,Jn=({drafts:e,onUndo:t,isUndoing:n,onDownloadBackup:r,onRestoreBackup:i,onReviewChange:a,liveNow:o=[],onDismissLiveNow:s})=>{let[c,l]=(0,g.useState)(null);return(0,y.jsxs)(`section`,{className:`space-y-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsx)(`h3`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`Your changes`}),(0,y.jsx)(`span`,{className:`text-[10px] font-bold font-mono px-2 py-0.5 rounded bg-slate-950 text-indigo-400 border border-slate-850`,children:e.length})]}),e.length===0&&o.length===0?(0,y.jsx)(`p`,{className:`text-xs text-slate-500`,children:`No changes yet. Alt+Click any text in the app to fix it.`}):(0,y.jsxs)(`ul`,{className:`space-y-1.5`,children:[e.map(e=>{let r=Hn(e),i=r===`sent`;return(0,y.jsxs)(`li`,{className:Kn,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[Wn(e),(0,y.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[Un(r),(0,y.jsx)(`button`,{onClick:()=>t(e),disabled:n,className:`text-[10px] font-semibold text-slate-400 hover:text-slate-100 px-2 py-0.5 rounded-md border border-slate-800 hover:border-slate-600 disabled:opacity-40 transition duration-150`,title:i?Vn:`Go back to the published text`,children:i?`Remove`:`Undo`})]})]}),(0,y.jsx)(Gn,{d:e})]},`${e.locale}/${e.key}`)}),o.map(e=>(0,y.jsxs)(`li`,{className:Kn,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[Wn(e),(0,y.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:Un(`live`)})]}),(0,y.jsx)(Gn,{d:e})]},`live:${e.locale}/${e.key}`))]}),o.length>0&&s&&(0,y.jsx)(`button`,{onClick:s,className:`text-[10px] font-semibold text-slate-500 hover:text-slate-300 transition duration-150`,children:`Dismiss live changes`}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-2`,children:[(0,y.jsx)(`button`,{onClick:async()=>{l(null);try{await r(),l(`Backup downloaded.`)}catch(e){l(e?.message||`Could not create the backup.`)}},className:qn,children:`Download backup`}),(0,y.jsxs)(`label`,{className:`${qn} inline-flex items-center`,children:[`Restore backup`,(0,y.jsx)(`input`,{type:`file`,accept:`.txt,text/plain`,onChange:async e=>{let t=e.currentTarget,n=t.files?.[0];if(n){l(null);try{l(await i(n))}catch(e){l(e?.message||`Could not restore the backup.`)}finally{t.value=``}}},className:`sr-only`})]}),a&&(0,y.jsx)(`button`,{onClick:a,className:qn,children:`Review a change link or file`})]}),c&&(0,y.jsx)(`p`,{role:`status`,className:`text-[11px] text-slate-400 break-words`,children:c})]})},Yn=async()=>{},Xn=async()=>``,Zn={modified:`text-amber-400 border-amber-500/30 bg-amber-500/10`,added:`text-emerald-400 border-emerald-500/30 bg-emerald-500/10`,deleted:`text-rose-400 border-rose-500/30 bg-rose-500/10`,renamed:`text-sky-400 border-sky-500/30 bg-sky-500/10`},Qn=e=>e.startsWith(`+++`)||e.startsWith(`---`)?`text-slate-500`:e.startsWith(`@@`)?`text-indigo-400`:e.startsWith(`diff `)||e.startsWith(`new file`)?`text-slate-600`:e.startsWith(`+`)?`text-emerald-300 bg-emerald-500/10`:e.startsWith(`-`)?`text-rose-300 bg-rose-500/10`:`text-slate-400`,$n=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),er=({isOpen:e,onClose:t,git:n,gitError:r,isGitLoading:i,lastCommit:a,onCommit:o,onDiscard:s,onRefresh:c,history:l,onUndo:u,isUndoing:d,drafts:f,onUndoDraft:p=Yn,onDownloadBackup:m=Yn,onRestoreBackup:h=Xn,onReviewChange:_,liveNow:v,onDismissLiveNow:b})=>{let[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1);if(!e)return null;let D=n?.changes??[],O=n?.mode===`github`,k=!!n?.isRepo&&D.length>0&&x.trim().length>0;return(0,y.jsxs)(`div`,{className:`fixed inset-0 top-16 z-40 flex justify-end`,"data-testid":`changes-panel`,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 bg-slate-950/60 backdrop-blur-[2px]`,onClick:t}),(0,y.jsxs)(`aside`,{className:`relative w-[520px] max-w-full h-full bg-slate-900 border-l border-slate-800 shadow-2xl flex flex-col animate-in slide-in-from-right duration-200`,children:[(0,y.jsxs)(`div`,{className:`h-14 bg-slate-950 border-b border-slate-800 flex items-center justify-between px-6 shrink-0 select-none`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`h2`,{className:`text-sm font-bold tracking-wide font-outfit text-slate-200`,children:`Changes`}),n?.isRepo&&n.branch&&(0,y.jsx)(`span`,{className:`px-2 py-0.5 rounded-md bg-slate-900 border border-slate-800 text-[10px] font-mono text-indigo-400`,children:n.branch})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`button`,{onClick:c,className:`p-1.5 rounded-lg text-slate-400 hover:text-slate-200 hover:bg-slate-800 border border-transparent hover:border-slate-700 transition duration-150`,title:`Refresh`,children:(0,y.jsxs)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,viewBox:`0 0 24 24`,children:[(0,y.jsx)(`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`}),(0,y.jsx)(`path`,{d:`M21 3v5h-5`})]})}),(0,y.jsx)(`button`,{onClick:t,className:`p-1.5 rounded-lg text-slate-400 hover:text-slate-200 hover:bg-slate-800 border border-transparent hover:border-slate-700 transition duration-150`,title:`Close`,children:(0,y.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{d:`M18 6L6 18M6 6l12 12`})})})]})]}),Array.isArray(f)?(0,y.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-6`,children:(0,y.jsx)(Jn,{drafts:f,onUndo:p,isUndoing:d,onDownloadBackup:m,onRestoreBackup:h,onReviewChange:_,liveNow:v,onDismissLiveNow:b})}):(0,y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-6`,children:[(0,y.jsxs)(`section`,{className:`space-y-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`Locale files`}),(0,y.jsxs)(`span`,{className:`text-[10px] font-bold font-mono px-2 py-0.5 rounded bg-slate-950 text-indigo-400 border border-slate-850`,children:[D.length,` changed`]})]}),n===null?(0,y.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Loading git status…`}):n.available?n.isRepo?D.length===0?(0,y.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Working tree is clean. Edits you save will show up here.`}):(0,y.jsx)(`ul`,{className:`space-y-1.5`,children:D.map(e=>(0,y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-3 py-2 rounded-xl bg-slate-950/40 border border-slate-800/80`,children:[(0,y.jsx)(`span`,{className:`text-[11px] font-mono text-slate-300 break-all`,children:e.path}),(0,y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[9px] font-extrabold uppercase tracking-wider border shrink-0 ${Zn[e.status]??Zn.modified}`,children:e.status})]},e.path))}):(0,y.jsxs)(`p`,{className:`text-xs text-slate-500 leading-relaxed`,children:[`The locales directory is not inside a git repository, or the`,` `,(0,y.jsx)(`code`,{className:`font-mono text-slate-400`,children:`git`}),` command is not on PATH.`]}):(0,y.jsxs)(`p`,{className:`text-xs text-slate-500 leading-relaxed`,children:[`Git integration is disabled for this handler. Enable it by removing`,` `,(0,y.jsx)(`code`,{className:`font-mono text-slate-400`,children:`git: false`}),` from the route configuration.`]}),n?.isRepo&&D.length>0&&(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`button`,{onClick:()=>E(e=>!e),className:`text-[10px] font-semibold text-slate-500 hover:text-slate-300 transition duration-150`,children:T?`Hide diff`:`Show diff`}),T&&(0,y.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-xl bg-slate-950 border border-slate-800 p-3 text-[10px] font-mono leading-relaxed whitespace-pre`,children:n.diff.split(`
11
11
  `).map((e,t)=>(0,y.jsx)(`div`,{className:`px-1 ${Qn(e)}`,children:e||` `},t))})]})]}),n?.isRepo&&(0,y.jsxs)(`section`,{className:`space-y-3`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:O?`Propose`:`Commit`}),O&&n?.pullRequestUrl&&(0,y.jsx)(`a`,{href:n.pullRequestUrl,target:`_blank`,rel:`noreferrer`,className:`block text-[11px] text-indigo-400 hover:text-indigo-300 underline underline-offset-2`,children:`View the open pull request`}),(0,y.jsx)(`textarea`,{id:`studio-commit-message`,value:x,onChange:e=>S(e.target.value),disabled:i||D.length===0,placeholder:D.length===0?O?`No changes on the branch yet`:`Nothing to commit`:O?`Pull request title, e.g. "Update checkout copy"`:`i18n: describe the copy change…`,maxLength:500,className:`w-full min-h-20 bg-slate-950 border border-slate-800 hover:border-slate-750 focus:border-indigo-500 focus:outline-hidden focus:ring-1 focus:ring-indigo-500/50 rounded-xl px-4 py-3 text-xs text-slate-100 placeholder-slate-600 font-sans resize-none transition duration-150 disabled:opacity-60`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`button`,{id:`studio-commit-button`,onClick:async()=>{await o(x.trim())&&S(``)},disabled:!k||i,className:`flex-1 h-10 rounded-xl text-xs font-semibold tracking-wide bg-indigo-600 hover:bg-indigo-500 active:bg-indigo-700 text-white disabled:bg-slate-800 disabled:text-slate-500 disabled:cursor-not-allowed transition duration-150`,children:i?`Working…`:O?n?.pullRequestUrl?`Pull request is open`:`Open pull request`:`Commit locale changes`}),C?(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`button`,{onClick:async()=>{await s()&&w(!1)},disabled:i,className:`h-10 px-3 rounded-xl text-xs font-semibold text-white bg-rose-600 hover:bg-rose-500 active:bg-rose-700 transition duration-150`,children:O?`Reset to base`:`Discard all`}),(0,y.jsx)(`button`,{onClick:()=>w(!1),className:`h-10 px-3 rounded-xl text-xs font-semibold text-slate-400 hover:text-slate-200 bg-slate-800 border border-slate-850 transition duration-150`,children:`Keep`})]}):(0,y.jsx)(`button`,{onClick:()=>w(!0),disabled:D.length===0||i,className:`h-10 px-4 rounded-xl text-xs font-semibold text-rose-400 bg-rose-500/10 hover:bg-rose-500/20 border border-rose-500/20 disabled:opacity-40 disabled:cursor-not-allowed transition duration-150`,children:O?`Reset branch`:`Discard`})]}),a&&!r&&(0,y.jsx)(`p`,{className:`text-[11px] text-emerald-400 font-mono break-all`,children:O?(0,y.jsxs)(y.Fragment,{children:[`Pull request:`,` `,(0,y.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:`underline`,children:a})]}):(0,y.jsxs)(y.Fragment,{children:[`Committed as `,a,`. Push whenever you are ready.`]})}),r&&(0,y.jsx)(`div`,{className:`bg-rose-500/10 border border-rose-500/20 rounded-xl p-3 text-xs text-rose-400 font-mono break-all`,children:r})]}),(0,y.jsxs)(`section`,{className:`space-y-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsx)(`label`,{className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`This session`}),(0,y.jsxs)(`span`,{className:`text-[10px] font-bold font-mono px-2 py-0.5 rounded bg-slate-950 text-slate-400 border border-slate-850`,children:[l.length,` edits`]})]}),l.length===0?(0,y.jsx)(`p`,{className:`text-xs text-slate-500`,children:`No edits saved yet in this session.`}):(0,y.jsx)(`ul`,{className:`space-y-1.5`,children:l.map(e=>(0,y.jsxs)(`li`,{className:`px-3 py-2 rounded-xl bg-slate-950/40 border border-slate-800/80 space-y-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,y.jsxs)(`span`,{className:`text-[11px] font-mono text-indigo-400 break-all`,children:[e.key,(0,y.jsxs)(`span`,{className:`text-slate-600`,children:[` · `,e.locale]})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,y.jsx)(`span`,{className:`text-[9px] text-slate-600 font-mono`,children:$n(e.at)}),(0,y.jsx)(`button`,{onClick:()=>u(e),disabled:d,className:`text-[10px] font-semibold text-slate-400 hover:text-slate-100 px-2 py-0.5 rounded-md border border-slate-800 hover:border-slate-600 disabled:opacity-40 transition duration-150`,title:`Restore the previous value`,children:`Undo`})]})]}),(0,y.jsxs)(`div`,{className:`text-[10px] leading-relaxed`,children:[(0,y.jsx)(`span`,{className:`text-rose-400/80 line-through break-all`,children:e.previousValue||(0,y.jsx)(`em`,{children:`empty`})}),(0,y.jsx)(`span`,{className:`text-slate-600`,children:` → `}),(0,y.jsx)(`span`,{className:`text-emerald-300 break-all`,children:e.nextValue||(0,y.jsx)(`em`,{children:`empty`})})]})]},e.id))})]})]})]})]})},tr=({isOpen:e,onSubmit:t})=>{let[n,r]=(0,g.useState)(``);return e?(0,y.jsx)(`div`,{className:`fixed inset-0 z-50 bg-slate-950/80 backdrop-blur-sm flex items-center justify-center p-4`,children:(0,y.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&t(n.trim())},className:`bg-slate-900 border border-slate-800 rounded-2xl w-full max-w-md p-6 shadow-2xl animate-in fade-in zoom-in-95 duration-200 space-y-4`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h3`,{className:`text-base font-bold text-slate-200 font-outfit`,children:`Access token required`}),(0,y.jsxs)(`p`,{className:`text-xs text-slate-400 mt-2 leading-relaxed`,children:[`This app runs LiveLocale in preview mode. Paste the access token configured on the server (`,(0,y.jsx)(`code`,{className:`font-mono text-slate-300`,children:`LIVELOCALE_TOKEN`}),`) to edit translations. It is kept in this browser tab only.`]})]}),(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(`label`,{htmlFor:`studio-access-token`,className:`text-[11px] font-bold text-slate-500 uppercase tracking-wider`,children:`Access token`}),(0,y.jsx)(`input`,{id:`studio-access-token`,type:`password`,autoComplete:`off`,value:n,onChange:e=>r(e.target.value),className:`w-full bg-slate-950 border border-slate-800 hover:border-slate-750 focus:border-indigo-500 focus:outline-hidden focus:ring-1 focus:ring-indigo-500/50 rounded-xl px-4 py-2.5 text-sm text-slate-100 font-mono transition duration-150`})]}),(0,y.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,y.jsx)(`button`,{type:`submit`,disabled:!n.trim(),className:`px-4 py-2 text-xs font-semibold text-white bg-indigo-600 hover:bg-indigo-500 active:bg-indigo-700 disabled:bg-slate-800 disabled:text-slate-500 disabled:cursor-not-allowed rounded-xl transition duration-150`,children:`Connect`})})]})}):null},nr=`Saving will fail until the server setup is fixed:`,rr=({problems:e,title:t=nr})=>e.length===0?null:(0,y.jsxs)(`div`,{role:`alert`,"data-testid":`setup-problems`,className:`mx-6 mt-4 rounded-xl border border-rose-500/30 bg-rose-500/10 px-4 py-3 text-xs text-rose-200 select-text`,children:[(0,y.jsx)(`p`,{className:`font-semibold text-rose-100`,children:t}),(0,y.jsx)(`ul`,{className:`mt-1.5 space-y-1 list-disc pl-4`,children:e.map(e=>(0,y.jsx)(`li`,{children:e},e))})]}),ir=({candidates:e,onChoose:t,onCancel:n})=>e===null?null:(0,y.jsx)(`div`,{className:`fixed inset-0 z-50 bg-slate-950/80 backdrop-blur-sm flex items-center justify-center p-4`,children:(0,y.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`studio-locale-picker-title`,className:`bg-slate-900 border border-slate-800 rounded-2xl w-full max-w-md p-6 shadow-2xl relative animate-in fade-in zoom-in-95 duration-200`,children:[(0,y.jsx)(`h3`,{id:`studio-locale-picker-title`,className:`text-base font-bold text-slate-200 font-outfit`,children:`Which language are you editing?`}),(0,y.jsx)(`p`,{className:`text-xs text-slate-400 mt-2 leading-relaxed`,children:`LiveLocale could not tell from the page. Your fix will be saved to the language you pick.`}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-5`,children:e.map(e=>(0,y.jsx)(`button`,{onClick:()=>t(e),className:`px-4 py-2 text-xs font-mono font-semibold text-indigo-200 bg-indigo-600/20 hover:bg-indigo-600/30 border border-indigo-500/40 hover:border-indigo-400 rounded-xl transition duration-150`,children:e},e))}),(0,y.jsx)(`div`,{className:`flex items-center justify-end mt-6`,children:(0,y.jsx)(`button`,{onClick:n,className:`px-4 py-2 text-xs font-semibold text-slate-400 hover:text-slate-200 bg-slate-800 border border-slate-850 hover:border-slate-700 rounded-xl transition duration-150`,children:`Cancel`})})]})}),ar=new Map;function or(e){return`livelocale:${e}`}function sr(e){try{return localStorage.getItem(or(e))}catch{return ar.get(e)??null}}function cr(e,t){t===null?ar.delete(e):ar.set(e,t);try{t===null?localStorage.removeItem(or(e)):localStorage.setItem(or(e),t)}catch{}}function lr(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`;try{return document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}async function ur(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return lr(e)}function dr(e,t){let n=URL.createObjectURL(new Blob([t],{type:`text/plain;charset=utf-8`})),r=document.createElement(`a`);r.href=n,r.download=e,r.style.display=`none`;try{document.body.appendChild(r),r.click()}finally{r.remove(),URL.revokeObjectURL(n)}}var fr=[`Hold Alt/Option and click any text.`,`Type your fix. The page updates as you type, and your changes are kept in this browser.`,`When you are done, press Send to developer and paste the link to your developer.`];function pr(e){let[t,n]=(0,g.useState)(()=>sr(`tips-seen`)===`1`),[r,i]=(0,g.useState)(()=>sr(`translator-name`)??``);return{showTips:e&&!t,dismiss:()=>{cr(`tips-seen`,`1`),n(!0)},name:r,setName:e=>{i(e),cr(`translator-name`,e===``?null:e)}}}var mr=({open:e,name:t,onNameChange:n,onDismiss:r})=>e?(0,y.jsx)(`div`,{className:`fixed inset-0 z-50 bg-slate-950/80 backdrop-blur-sm flex items-center justify-center p-4`,children:(0,y.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`studio-tips-title`,className:`bg-slate-900 border border-slate-800 rounded-2xl w-full max-w-md p-6 shadow-2xl`,children:[(0,y.jsx)(`h3`,{id:`studio-tips-title`,className:`text-base font-bold text-slate-200 font-outfit`,children:`Welcome to LiveLocale`}),(0,y.jsx)(`ol`,{className:`mt-3 space-y-2 list-decimal list-inside text-xs text-slate-300 leading-relaxed`,children:fr.map(e=>(0,y.jsx)(`li`,{children:e},e))}),(0,y.jsx)(`label`,{htmlFor:`studio-tips-name`,className:`block mt-5 text-xs font-semibold text-slate-400`,children:`Your name (optional, credited in the pull request)`}),(0,y.jsx)(`input`,{id:`studio-tips-name`,type:`text`,maxLength:80,dir:`auto`,value:t,onChange:e=>n(e.target.value),className:`mt-1 w-full h-9 px-3 rounded-xl bg-slate-950 border border-slate-800 text-xs text-slate-200 focus:outline-none focus:border-indigo-500`}),(0,y.jsx)(`div`,{className:`flex items-center justify-end mt-6`,children:(0,y.jsx)(`button`,{onClick:r,className:`px-4 py-2 text-xs font-semibold text-white bg-indigo-600 hover:bg-indigo-500 rounded-xl transition duration-150`,children:`Start editing`})})]})}):null;function hr(e,t){let n=e.filter(e=>!e.conflict&&(e.status===`unsent`||t.includeSent)).sort((e,t)=>e.updatedAt-t.updatedAt);return{included:n.slice(0,500),overflow:Math.max(0,n.length-500)}}function gr(e){return e>=55296&&e<=56319}function _r(e){return e>=56320&&e<=57343}function vr(e){let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);gr(r)?n+1<e.length&&_r(e.charCodeAt(n+1))&&(t+=e.slice(n,n+2),n++):_r(r)||(t+=e.charAt(n))}return t}function yr(e,t){let n=vr(e).slice(0,t);return n.length>0&&gr(n.charCodeAt(n.length-1))?n.slice(0,-1):n}var br=/[\x00-\x1f\x7f]/g,xr=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;function Sr(e){return yr((e??``).replace(/\s+/g,` `).replace(br,``).trim(),80)}function Cr(e){return yr((e??``).replace(xr,``).trim(),500)}function wr(e,t){return e<t?-1:+(e>t)}function Tr(e){let{drafts:t,manifest:n}=e,r=t.map(({locale:e,key:t,from:n,to:r,force:i})=>({locale:e,key:t,from:n,to:r,force:i})).sort((e,t)=>wr(e.locale,t.locale)||wr(e.key,t.key));return{...typeof n.repo==`string`&&n.repo!==``?{repo:n.repo}:{},branch:n.branch??``,base:n.base??``,src:n.sourceLocale,by:Sr(e.by),note:Cr(e.note),edits:r}}function Er(e,t){let n=new URL(e),r=n.pathname.endsWith(`/`)?`${n.pathname}index.html`:n.pathname;return`${n.origin}${r}#${t}`}function Dr(e,t){return`livelocale-${e}-${t.toISOString().slice(0,10)}.txt`}var Or=`This change link is damaged or incomplete, which happens when an email or chat app breaks a long link. Ask the sender to send the file instead.`,kr=`This change link is larger than LiveLocale accepts (500 changes, 512 KB).`,Ar={NOT_FOUND:`This is not a LiveLocale change link. A change link contains "lc1.".`,AMBIGUOUS:`This text holds more than one change link. Paste one link at a time.`,CORRUPT:Or,INVALID:Or,TOO_LARGE:kr,TOO_MANY_EDITS:kr,UNSUPPORTED_VERSION:`This change link was made by a newer LiveLocale. Update the site and try again.`,UNSUPPORTED_ENVIRONMENT:`This browser cannot create or read change links. Use a current Chrome, Edge or Firefox, or Safari 16.4 or later.`};function jr(e){return e instanceof L&&Object.hasOwn(Ar,e.code)?Ar[e.code]:e instanceof Error&&e.message||`Could not read the change link.`}var Mr=`Paste here: your clipboard holds the LiveLocale change block (Ctrl+V, or Cmd+V on Mac).
12
12
  `,Nr=40;function Pr(e){let t=e.trim().replace(/^https:\/\/(?:www\.)?github\.com\//i,``).replace(/^git@github\.com:/i,``).replace(/\/+$/,``).replace(/\.git$/i,``);return et(t)?t:null}function Fr(e,t){return e??t}function Ir(e){let t=e.replace(/[\x00-\x1f\x7f-\x9f‪-‮⁦-⁩]/g,``).replace(/\s+/g,` `).trim().slice(0,Nr);return/[\ud800-\udbff]$/.test(t)?t.slice(0,-1):t}function Lr(e,t){let n=`LiveLocale: ${e} translation ${e===1?`change`:`changes`}`,r=t===void 0?``:Ir(t);return r===``?n:`${n} from ${r}`}function Rr(e,t,n){return`https://github.com/${e}/issues/new?title=${encodeURIComponent(t)}&body=${encodeURIComponent(n)}`}function zr(e,t,n,r){let i=Ze(t);if(i.length>65536)return{url:null,clipboard:null,tooLarge:!0};let a=Lr(n,r),o=Rr(e,a,i);return o.length<=8e3?{url:o,clipboard:null,tooLarge:!1}:{url:Rr(e,a,Mr),clipboard:i,tooLarge:!1}}var Br=`Too large for a GitHub issue. Run npx livelocale apply with this link instead.`,Vr=`Copy change block`,Hr=`Open GitHub and paste`,Ur=`Copying did not work. Copy the block below, then open GitHub and paste it.`,Wr=`inline-flex items-center h-8 px-3 rounded-xl text-[11px] font-semibold border transition duration-150 text-slate-300 hover:text-slate-100 bg-slate-800 hover:bg-slate-700 border-slate-700`;function Gr({repo:e,token:t,count:n,by:r,label:i,onOpened:a}){let[o,s]=(0,g.useState)(null),c=zr(e,t,n,r);if(c.tooLarge||c.url===null)return(0,y.jsx)(`p`,{className:`text-[11px] text-amber-300`,children:Br});let l=e=>(0,y.jsx)(`a`,{href:c.url??void 0,target:`_blank`,rel:`noopener noreferrer`,onClick:()=>a?.(),className:Wr,children:e}),u=c.clipboard;return u===null?l(i):(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:async()=>s(await ur(u)?`ok`:`failed`),className:Wr,children:Vr}),o!==null&&l(Hr)]}),o===`failed`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:`text-[11px] text-slate-400`,children:Ur}),(0,y.jsx)(`textarea`,{"data-testid":`manual-copy`,readOnly:!0,value:u,rows:4,onFocus:e=>e.currentTarget.select(),className:`w-full px-3 py-2 rounded-xl bg-slate-950 border border-slate-800 text-[11px] font-mono text-slate-300 resize-none`})]})]})}var Kr=`Link copied. Paste it to your developer in chat or email.`,qr=`Copy did not work in this browser. Select the link above, copy it, then press “I copied it”.`,Jr=`File saved. Send it to your developer.`,Yr=`This batch is too long for a chat message. Use Download file instead.`,Xr=`Press “Submit new issue” on GitHub. A pull-request link appears as a comment about a minute later.`,Zr=`There are no changes to send.`,Qr=e=>e===1?`1 change`:`${e} changes`,$r=`h-9 px-4 rounded-xl text-xs font-semibold border transition duration-150 disabled:opacity-40 disabled:cursor-not-allowed`,ei=({isOpen:e,onClose:t,drafts:n,manifest:r,studioHref:i,onMarkSent:a})=>{let[o,s]=(0,g.useState)(()=>sr(`translator-name`)??``),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(null),[_,v]=(0,g.useState)(!1),[b,x]=(0,g.useState)(null),[S,C]=(0,g.useState)(null),[w,T]=(0,g.useState)(null),E=(0,g.useRef)(0);(0,g.useEffect)(()=>{e&&(s(sr(`translator-name`)??``),l(``),d(!1),C(null),T(null))},[e]);let D=(0,g.useMemo)(()=>n.filter(e=>e.status===`sent`&&!e.conflict).length,[n]),{included:O,overflow:k}=(0,g.useMemo)(()=>hr(n,{includeSent:u}),[n,u]);if((0,g.useEffect)(()=>{if(!e||!r)return;let t=++E.current;if(p(null),h(null),x(null),O.length===0){v(!1);return}v(!0),St(Tr({drafts:O,manifest:r,by:o,note:c})).then(e=>{t===E.current&&(p(Er(i,e)),h(e))}).catch(e=>{t===E.current&&x(`Could not create the link: `+jr(e))}).finally(()=>{t===E.current&&v(!1)})},[e,r,O,o,c,i]),!e||!r)return null;let ee=f!==null&&f.length>6e3,A=!_&&f!==null&&!ee,j=!_&&f!==null,te=async(e,t)=>{try{await a(e),C(t)}catch(e){T(e?.message||`Could not mark the changes as sent.`)}},M=async()=>{if(!f)return;let e=O;T(null),await ur(f)?await te(e,`copied`):C(`copy-failed`)},ne=async()=>{if(!f)return;let e=O;T(null);try{dr(Dr(`changes`,new Date),f+`
13
13
  `)}catch(e){T(e?.message||`Could not save the file.`);return}await te(e,`downloaded`)},re=e=>{s(e),cr(`translator-name`,e===``?null:e)};return(0,y.jsx)(`div`,{className:`fixed inset-0 z-50 bg-slate-950/80 backdrop-blur-sm flex items-center justify-center p-4`,children:(0,y.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`studio-send-title`,className:`bg-slate-900 border border-slate-800 rounded-2xl w-full max-w-lg max-h-[90vh] overflow-y-auto p-6 shadow-2xl space-y-4`,children:[(0,y.jsx)(`h3`,{id:`studio-send-title`,className:`text-base font-bold text-slate-200 font-outfit`,children:`Send to developer`}),(0,y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,y.jsx)(`span`,{className:`text-[11px] font-semibold text-slate-400`,children:`Your name`}),(0,y.jsx)(`input`,{id:`studio-send-name`,type:`text`,dir:`auto`,maxLength:80,value:o,onChange:e=>re(e.target.value),className:`w-full h-9 px-3 rounded-xl bg-slate-950 border border-slate-800 text-xs text-slate-200 focus:outline-none focus:border-indigo-500`})]}),(0,y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,y.jsx)(`span`,{className:`text-[11px] font-semibold text-slate-400`,children:`Note for the developer (optional)`}),(0,y.jsx)(`textarea`,{id:`studio-send-note`,dir:`auto`,rows:2,maxLength:500,value:c,onChange:e=>l(e.target.value),className:`w-full px-3 py-2 rounded-xl bg-slate-950 border border-slate-800 text-xs text-slate-200 focus:outline-none focus:border-indigo-500 resize-none`})]}),D>0&&(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-slate-300`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),`Also include ${Qr(D)} already sent`]}),O.length===0?(0,y.jsx)(`p`,{className:`text-xs text-slate-500`,children:Zr}):(0,y.jsx)(`ul`,{"data-testid":`send-dialog-changes`,className:`max-h-48 overflow-y-auto space-y-1.5`,children:O.map(e=>(0,y.jsxs)(`li`,{className:`px-3 py-2 rounded-xl bg-slate-950/40 border border-slate-800/80 space-y-1`,children:[(0,y.jsx)(`span`,{className:`block text-[11px] font-mono text-indigo-400 break-all`,children:`${e.key} · ${e.locale}`}),(0,y.jsxs)(`div`,{className:`text-[10px] leading-relaxed`,children:[e.from?(0,y.jsx)(`span`,{dir:`auto`,className:`text-rose-400/80 line-through break-all`,children:e.from}):(0,y.jsx)(`em`,{className:`text-rose-400/80 line-through`,children:`empty`}),(0,y.jsx)(`span`,{className:`text-slate-600`,children:` → `}),e.to?(0,y.jsx)(`span`,{dir:`auto`,className:`text-emerald-300 break-all`,children:e.to}):(0,y.jsx)(`em`,{className:`text-emerald-300`,children:`empty`})]})]},`${e.locale}/${e.key}`))}),k>0&&(0,y.jsx)(`p`,{className:`text-xs text-amber-300`,children:`${O.length} of ${O.length+k} changes are in this link. Send again for the rest.`}),b&&(0,y.jsx)(`p`,{className:`text-xs text-rose-400 break-words`,children:b}),f!==null&&!ee&&(0,y.jsx)(`input`,{id:`studio-send-link`,"data-testid":`change-link`,type:`text`,readOnly:!0,value:f,onFocus:e=>e.currentTarget.select(),className:`w-full h-9 px-3 rounded-xl bg-slate-950 border border-slate-800 text-[11px] font-mono text-slate-300`}),ee&&(0,y.jsx)(`p`,{className:`text-xs text-amber-300`,children:Yr}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`button`,{id:`studio-send-copy`,onClick:M,disabled:!A,className:`${$r} text-indigo-100 bg-indigo-600 hover:bg-indigo-500 border-indigo-500`,children:`Copy link`}),(0,y.jsx)(`button`,{id:`studio-send-download`,onClick:ne,disabled:!j,className:`${$r} text-slate-300 hover:text-slate-100 bg-slate-800 hover:bg-slate-700 border-slate-700`,children:`Download file`}),(0,y.jsx)(`button`,{onClick:t,className:`${$r} ml-auto text-slate-400 hover:text-slate-200 bg-slate-800 border-slate-800 hover:border-slate-700`,children:`Close`})]}),r.repo&&m!==null&&!_&&(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(Gr,{repo:r.repo,token:m,count:O.length,by:o,label:`Open on GitHub`,onOpened:()=>void te(O,null)}),(0,y.jsx)(`p`,{className:`text-[11px] text-slate-400`,children:Xr})]}),S===`copied`&&(0,y.jsx)(`p`,{role:`status`,className:`text-xs text-emerald-300`,children:Kr}),S===`downloaded`&&(0,y.jsx)(`p`,{role:`status`,className:`text-xs text-emerald-300`,children:Jr}),S===`copy-failed`&&(0,y.jsxs)(`div`,{role:`status`,className:`space-y-2`,children:[(0,y.jsx)(`p`,{className:`text-xs text-amber-300`,children:qr}),(0,y.jsx)(`button`,{onClick:()=>te(O,`copied`),className:`${$r} text-slate-300 hover:text-slate-100 bg-slate-800 hover:bg-slate-700 border-slate-700`,children:`I copied it`})]}),w&&(0,y.jsx)(`p`,{className:`text-xs text-rose-400 break-words`,children:w})]})})},ti=`This file could not be read. Paste the link instead.`,ni=({isOpen:e,onClose:t,onSubmit:n,error:r})=>{let[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(!1);if((0,g.useEffect)(()=>{e&&(a(``),l(null),d(!1))},[e]),!e)return null;let f=async e=>{if(e){l(null);try{a(await e.text())}catch{l(ti)}}},p=async()=>{s(!0);try{let e=await n(i);d(!0),e&&t()}finally{s(!1)}},m=c??(u?r:null);return(0,y.jsx)(`div`,{className:`fixed inset-0 z-50 bg-slate-950/80 backdrop-blur-sm flex items-center justify-center p-4`,children:(0,y.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`studio-import-title`,className:`bg-slate-900 border border-slate-800 rounded-2xl w-full max-w-lg p-6 shadow-2xl relative animate-in fade-in zoom-in-95 duration-200 select-text`,children:[(0,y.jsx)(`h3`,{id:`studio-import-title`,className:`text-base font-bold text-slate-200 font-outfit`,children:`Import change link`}),(0,y.jsx)(`p`,{className:`text-xs text-slate-400 mt-2 leading-relaxed`,children:`Review a translator’s changes before they are written to your local files.`}),(0,y.jsx)(`label`,{htmlFor:`studio-import-text`,className:`block mt-5 text-xs font-semibold text-slate-300`,children:`Paste a change link`}),(0,y.jsx)(`textarea`,{id:`studio-import-text`,value:i,onChange:e=>a(e.target.value),rows:5,spellCheck:!1,className:`mt-2 w-full px-3 py-2 rounded-xl bg-slate-950 border border-slate-800 focus:border-indigo-500 outline-none text-[11px] font-mono text-slate-200 break-all resize-y`}),(0,y.jsx)(`label`,{htmlFor:`studio-import-file`,className:`block mt-4 text-xs font-semibold text-slate-300`,children:`or choose a file`}),(0,y.jsx)(`input`,{id:`studio-import-file`,type:`file`,accept:`.txt,text/plain`,onChange:e=>void f(e.target.files?.[0]),className:`mt-2 block w-full text-[11px] text-slate-400 file:mr-3 file:px-3 file:py-1.5 file:rounded-lg file:border-0 file:bg-slate-800 file:text-slate-200 file:text-[11px] file:font-semibold`}),m&&(0,y.jsx)(`p`,{role:`alert`,className:`mt-4 text-xs text-rose-300 break-words`,children:m}),(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 mt-6`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-2 text-xs font-semibold text-slate-400 hover:text-slate-200 bg-slate-800 border border-slate-850 hover:border-slate-700 rounded-xl transition duration-150`,children:`Cancel`}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>void p(),disabled:i.trim()===``||o,className:`px-4 py-2 text-xs font-semibold text-indigo-50 bg-indigo-600 border border-indigo-500 hover:bg-indigo-500 disabled:opacity-40 disabled:cursor-not-allowed rounded-xl transition duration-150`,children:`Review changes`})]})]})})},ri=/\u200C(?:[\u200B\u200D]{8})+\u200C/g;function ii(e){ri.lastIndex=0;let t=ri.test(e);return ri.lastIndex=0,t}var ai={...Ne,forced:`Saved with “Save anyway”.`,"new-key":`Adds a key the source locale does not have.`};function oi(e,t){let n=t.indexOf(`.`);if(n===-1)return!1;let r=t.slice(0,n);if(!Object.prototype.hasOwnProperty.call(e,r))return!1;let i=e[r];return typeof i==`object`&&!!i&&!Array.isArray(i)}function si(e,t,n){let{locale:r,key:i,from:a,to:o,force:s}=e,c={locale:r,key:i,from:a,to:o,force:s},l=(e,t)=>({...c,status:`invalid`,code:e,message:t,flags:[]}),u=t.targets.get(r);if(!u)return l(`UNKNOWN_LOCALE`,`No "${r}" locale file on the target.`);if(u.layout===`namespaced`&&!oi(u.dict,i))return l(`UNKNOWN_NAMESPACE`,`"${i}" is not in an existing namespace file of ${r}.`);if(ii(o))return l(`CONTAINS_WATERMARK`,`The new text contains LiveLocale watermark characters.`);let d={sourceLocale:t.sourceLocale,source:n,target:u.dict},f=je(i,d),p=[],m=e=>({...c,...e,flags:[...p,...Ve(f??a??void 0,o)]}),h=De(u.dict,i);if(h.state===`string`&&h.value===o)return m({status:`already`,current:h.value});let g=Me({locale:r,key:i,value:o},d,{force:!1});if(!g.ok){if(g.status!==422||!s)return l(g.code,g.error);if(!t.allowForce)return m({status:`needs-force`,code:g.code,message:g.error});p.push(`forced`)}let _=h.state===`string`?h.value:void 0;return _===void 0?a===null?(f===null&&p.push(`new-key`),m({status:`apply`})):m({status:`conflict`,code:`REMOVED_ON_TARGET`,message:`Removed on the target since the link was made.`}):m(_===a?{status:`apply`}:{status:`conflict`,code:`CHANGED_ON_TARGET`,message:`Changed on the target since the link was made.`,current:_})}function ci(e){let t=e.targets.get(e.sourceLocale);if(!t)throw Error(`Source locale "${e.sourceLocale}" has no locale file on the target.`);let n=e.edits.map(n=>si(n,e,t.dict)),r={apply:0,already:0,conflict:0,invalid:0,"needs-force":0};for(let e of n)r[e.status]+=1;return{edits:n,counts:r}}var B={apply:`Ready`,already:`Already applied`,conflict:`Changed since`,invalid:`Invalid`,"needs-force":`Saved with “Save anyway”`};function li(e){let t=[];e.status===`invalid`&&e.message&&t.push({level:`error`,message:e.message}),e.status===`needs-force`&&e.message&&t.push({level:`warning`,message:`${e.message} Saved with “Save anyway”.`});for(let n of e.flags)t.push({level:`warning`,message:ai[n]});return t}function ui(e){let{edits:t}=ci({edits:e.set.edits,sourceLocale:e.sourceLocale,targets:e.targets,allowForce:e.allowForce===!0});return t.map(e=>({...e,id:`${e.locale}\u0000${e.key}`,checks:li(e)}))}function di(e){let t={apply:0,already:0,conflict:0,invalid:0,"needs-force":0};for(let n of e)t[n.status]+=1;return t}var fi=`Which GitHub repository should get the pull request?`,pi=`Enter it as owner/repo, for example acme/website.`,mi=({initial:e=``,onSave:t})=>{let[n,r]=(0,g.useState)(e),[i,a]=(0,g.useState)(!1);return(0,y.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let r=Pr(n);a(r===null),r!==null&&t(r)},className:`space-y-2`,children:[(0,y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,y.jsx)(`span`,{className:`text-[11px] font-semibold text-slate-400`,children:fi}),(0,y.jsx)(`input`,{type:`text`,dir:`ltr`,placeholder:`owner/repo`,spellCheck:!1,autoComplete:`off`,value:n,onChange:e=>{r(e.target.value),a(!1)},"aria-invalid":i||void 0,className:`w-full h-9 px-3 rounded-xl bg-slate-950 border border-slate-800 text-xs font-mono text-slate-200 focus:outline-none focus:border-indigo-500`})]}),i&&(0,y.jsx)(`p`,{className:`text-[11px] text-rose-300`,children:pi}),(0,y.jsx)(`button`,{type:`submit`,className:`h-8 px-3 rounded-xl text-[11px] font-semibold border transition duration-150 text-indigo-100 bg-indigo-600 hover:bg-indigo-500 border-indigo-500`,children:`Save`})]})},hi=`npx livelocale apply --clipboard --pr`;function gi(e){let t=`npx livelocale apply "${e}" --pr`;return t.length>8e3?hi:t}var _i=`This change link cannot be opened:`,vi=`Run it in the repository. It opens a pull request with your git and gh, on any git host.`,yi=`Copied.`,bi=`Copy did not work in this browser. Select the text above and copy it.`,xi=`Then press Submit on GitHub. The pull request opens in about a minute.`,Si=`Issues turned off? Actions → LiveLocale → Run workflow, then paste the link.`,Ci=e=>e===1?`1 change`:`${e} changes`,wi={applied:`text-emerald-300`,skipped:`text-slate-400`,failed:`text-rose-300`},Ti=e=>e.state===`applied`?`Applied`:e.state===`failed`?`Failed: ${e.message}`:`Skipped: ${e.reason}`,Ei=[`apply`,`already`,`conflict`,`needs-force`,`invalid`],Di={apply:`text-emerald-300`,already:`text-slate-400`,conflict:`text-amber-300`,"needs-force":`text-amber-300`,invalid:`text-rose-300`},Oi=()=>{},ki=`h-8 px-3 rounded-xl text-[11px] font-semibold border transition duration-150 text-slate-300 hover:text-slate-100 bg-slate-800 hover:bg-slate-700 border-slate-700`,Ai=({value:e})=>e===null||e===``?(0,y.jsx)(`em`,{className:`text-slate-500`,children:`empty`}):(0,y.jsx)(`span`,{dir:`auto`,className:`break-all whitespace-pre-wrap`,children:e}),ji=({row:e})=>ie(e.to)===null?(0,y.jsx)(Ai,{value:e.to}):(0,y.jsx)(se,{disabled:!0,locale:e.locale,value:e.to,onChange:Oi}),Mi=({review:e,error:t,isLoading:n,focusKey:r,onSelectLocale:i,onClose:a,studioHref:o,repo:s,repoFromManifest:c,onRepoChange:l,onApplyLocal:u,applyResults:d={},isApplying:f=!1,actions:p,className:m=`w-[420px] shrink-0`})=>{let[h,_]=(0,g.useState)(null),[v,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(!1),C=(0,g.useRef)(null),w=(0,g.useMemo)(()=>e?Er(o,e.token):null,[e,o]),T=w===null?null:gi(w),E=(0,g.useMemo)(()=>e?di(e.rows):null,[e]),D=e?.rows.find(e=>e.key===r)?.id??null;(0,g.useEffect)(()=>_(null),[e]),(0,g.useEffect)(()=>S(!1),[e?.token]);let O=E?E.apply+(x?E[`needs-force`]:0):0;(0,g.useEffect)(()=>{C.current?.scrollIntoView?.({block:`nearest`})},[D]);let k=async e=>{_(await ur(e)?yi:bi)},ee=e=>{b(!1),l(e)},A=e?.set.by??``,j=e?.set.note??``;return(0,y.jsxs)(`section`,{"data-testid":`review-panel`,className:`${m} bg-slate-900 border border-slate-800 rounded-2xl flex flex-col h-full shadow-2xl overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`h-14 bg-slate-950 border-b border-slate-800 flex items-center justify-between px-6 shrink-0 select-none`,children:[(0,y.jsx)(`h2`,{className:`text-sm font-bold tracking-wide font-outfit text-slate-200`,children:`Review`}),(0,y.jsx)(`button`,{type:`button`,onClick:a,className:`text-[11px] font-semibold text-slate-400 hover:text-slate-100 transition duration-150`,children:`Close review`})]}),(0,y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4 select-text`,children:[t!==null&&(0,y.jsx)(rr,{title:_i,problems:[t]}),n&&e===null&&(0,y.jsx)(`p`,{className:`text-xs text-slate-400`,children:`Opening the change link…`}),e&&E&&w&&T&&(0,y.jsxs)(y.Fragment,{children:[(A!==``||j!==``)&&(0,y.jsx)(`p`,{"data-testid":`review-note`,dir:`auto`,className:`px-3 py-2 rounded-xl bg-slate-950/60 border border-slate-800 text-xs text-slate-300 whitespace-pre-wrap break-words`,children:`From ${A||`the translator`}${j===``?``:`: ${j}`}`}),(0,y.jsx)(`ul`,{"data-testid":`review-summary`,className:`flex flex-wrap gap-2 text-[11px]`,children:Ei.filter(e=>E[e]>0).map(e=>(0,y.jsx)(`li`,{className:`px-2.5 py-1 rounded-full bg-slate-950 border border-slate-800 ${Di[e]}`,children:`${E[e]} ${B[e]}`},e))}),e.target===`github`&&(0,y.jsx)(`div`,{className:`space-y-2 px-3 py-3 rounded-xl bg-slate-950/40 border border-slate-800`,children:s===null||v?(0,y.jsx)(mi,{initial:v?s??void 0:e.set.repo,onSave:ee}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(Gr,{repo:s,token:e.token,count:e.set.edits.length,by:e.set.by,label:`Create pull request`}),(0,y.jsx)(`span`,{className:`text-[11px] font-mono text-slate-400 break-all`,children:s}),!c&&(0,y.jsx)(`button`,{type:`button`,onClick:()=>b(!0),className:`text-[11px] font-semibold text-slate-400 hover:text-slate-100 underline-offset-2 hover:underline`,children:`Change`})]}),(0,y.jsx)(`p`,{className:`text-[11px] text-slate-400`,children:xi})]})}),e.target===`local`&&u&&(0,y.jsxs)(`div`,{className:`space-y-2 px-3 py-3 rounded-xl bg-slate-950/40 border border-slate-800`,children:[(0,y.jsx)(`button`,{id:`studio-apply-local`,type:`button`,disabled:O===0||f,onClick:()=>u({includeForced:x}),className:`h-8 px-3 rounded-xl text-[11px] font-semibold border transition duration-150 bg-indigo-600 border-indigo-500 text-indigo-50 hover:bg-indigo-500 disabled:opacity-40 disabled:cursor-not-allowed`,children:`Apply ${Ci(O)} to local files`}),E[`needs-force`]>0&&(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px] text-slate-300`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),`Include ${Ci(E[`needs-force`])} saved with “Save anyway”`]})]}),p,(0,y.jsxs)(`div`,{className:`space-y-2 px-3 py-3 rounded-xl bg-slate-950/40 border border-slate-800`,children:[(0,y.jsx)(`h3`,{className:`text-xs font-semibold text-slate-200`,children:`Apply with the command line`}),(0,y.jsx)(`code`,{"data-testid":`review-apply-command`,className:`block px-3 py-2 rounded-lg bg-slate-950 border border-slate-800 text-[11px] font-mono text-slate-300 break-all`,children:T}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:()=>k(T),className:ki,children:`Copy command`}),T===hi&&(0,y.jsx)(`button`,{type:`button`,onClick:()=>k(w),className:ki,children:`Copy link`}),h&&(0,y.jsx)(`span`,{className:`text-[11px] text-slate-400`,children:h})]}),(0,y.jsx)(`p`,{className:`text-[11px] text-slate-500`,children:vi})]}),e.target===`github`&&(0,y.jsx)(`p`,{className:`text-[11px] text-slate-500`,children:Si}),(0,y.jsxs)(`table`,{className:`w-full text-[11px] text-left border-collapse`,children:[(0,y.jsx)(`thead`,{className:`text-slate-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`py-1 pr-2 font-semibold`,children:`Language`}),(0,y.jsx)(`th`,{className:`py-1 pr-2 font-semibold`,children:`Key`}),(0,y.jsx)(`th`,{className:`py-1 pr-2 font-semibold`,children:`Before`}),(0,y.jsx)(`th`,{className:`py-1 pr-2 font-semibold`,children:`After`}),(0,y.jsx)(`th`,{className:`py-1 font-semibold`,children:`Check`})]})}),(0,y.jsx)(`tbody`,{className:`text-slate-300 align-top`,children:e.rows.map(e=>{let t=e.id===D;return(0,y.jsxs)(`tr`,{ref:t?C:void 0,"aria-current":t?`true`:void 0,className:`border-t border-slate-800 ${t?`bg-indigo-600/10`:``}`,children:[(0,y.jsx)(`td`,{className:`py-2 pr-2`,children:(0,y.jsx)(`button`,{type:`button`,onClick:()=>i(e.locale),title:`Show the page in ${e.locale}`,className:`font-mono text-indigo-300 hover:text-indigo-100 underline-offset-2 hover:underline`,children:e.locale})}),(0,y.jsx)(`td`,{className:`py-2 pr-2 font-mono text-indigo-400 break-all`,children:e.key}),(0,y.jsxs)(`td`,{className:`py-2 pr-2`,children:[(0,y.jsx)(Ai,{value:e.from}),e.status===`conflict`&&e.current!==void 0&&(0,y.jsxs)(`p`,{className:`mt-1 text-amber-300`,children:[`Now on the site: `,(0,y.jsx)(`span`,{dir:`auto`,className:`break-all whitespace-pre-wrap`,children:e.current})]})]}),(0,y.jsx)(`td`,{className:`py-2 pr-2`,children:(0,y.jsx)(ji,{row:e})}),(0,y.jsxs)(`td`,{className:`py-2`,children:[(0,y.jsx)(`span`,{className:`font-semibold ${Di[e.status]}`,children:B[e.status]}),d[e.id]&&(0,y.jsx)(`p`,{"data-testid":`apply-result`,className:`mt-1 inline-block px-2 py-0.5 rounded-full bg-slate-950 border border-slate-800 ${wi[d[e.id].state]}`,children:Ti(d[e.id])}),e.checks.length>0&&(0,y.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:e.checks.map(e=>(0,y.jsx)(`li`,{className:e.level===`error`?`text-rose-300`:`text-amber-300`,children:e.message},e.message))})]})]},e.id)})})]})]})]})]})},Ni=`studio-drawer-keys`,Pi=`studio-drawer-side`,Fi=`absolute inset-y-0 z-30 w-[min(400px,45vw)] p-2`,Ii=e=>`px-3 py-1.5 rounded-xl border text-[11px] font-semibold transition duration-150 ${e?`bg-indigo-600/20 border-indigo-500 text-indigo-300`:`bg-slate-900 border-slate-800 text-slate-300 hover:text-slate-100 hover:border-slate-700`}`,Li=({isWide:e,keys:t,viewer:n,side:r,sideLabel:i,openPanel:a,onOpenPanelChange:o,toolbar:s})=>{let c=e?null:a;(0,g.useEffect)(()=>{if(c===null)return;let e=e=>{e.key===`Escape`&&o(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[c,o]);let l=e=>o(a===e?null:e);return(0,y.jsxs)(`main`,{className:`flex-1 flex overflow-hidden min-h-0 bg-linear-to-b from-[#0b0f19] to-[#070a10] ${e?`gap-6 p-6`:`relative gap-0 p-2`}`,children:[(0,y.jsx)(`div`,{id:Ni,"data-testid":Ni,className:e?`h-full shrink-0`:`${Fi} left-0`,hidden:!e&&c!==`keys`,children:t}),(0,y.jsxs)(`div`,{className:`flex-1 min-w-0 h-full flex flex-col gap-2`,children:[!e&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 select-none`,children:[(0,y.jsx)(`button`,{type:`button`,"data-testid":`studio-toggle-keys`,"aria-expanded":c===`keys`,"aria-controls":Ni,onClick:()=>l(`keys`),className:Ii(c===`keys`),children:`Keys`}),(0,y.jsx)(`button`,{type:`button`,"data-testid":`studio-toggle-side`,"aria-expanded":c===`side`,"aria-controls":Pi,onClick:()=>l(`side`),className:Ii(c===`side`),children:i}),s]}),n]}),(0,y.jsx)(`div`,{id:Pi,"data-testid":Pi,className:e?`h-full shrink-0`:`${Fi} right-0`,hidden:!e&&c!==`side`,children:r})]})},Ri=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function zi(e,t={}){let n;try{n=new URL(e,`http://localhost`)}catch{return null}let r=n.searchParams.get(`locale`),{basePath:i,locales:a}=t;if(!a){if(r)return r;let e=n.pathname.split(`/`)[1];return e&&e.length===2?e:null}let o=e=>{if(!e)return null;let t=e.toLowerCase();return a.find(e=>e.toLowerCase()===t)??null},s=o(r);if(s)return s;let c=i??`/`;return n.pathname.startsWith(c)?o(n.pathname.slice(c.length).split(`/`)[0]):null}function Bi(e){return e.normalize(`NFC`).replace(/\s+/g,` `).trim().toLowerCase()}function Vi(e,t,n){let r=new Set(t.map(Bi).filter(e=>e!==``));if(r.size===0)return[];let i=[];for(let t of Object.keys(n)){let a=n[t];!a||!Ri(a,e)||(a[e]??[]).some(e=>r.has(Bi(e)))&&i.push(t)}return i.sort()}function Hi(e,t){let n=new Map;for(let{key:r,text:i}of e)for(let e of Vi(r,[i],t))n.set(e,(n.get(e)??0)+1);let r=Math.max(0,...n.values());return r===0?[]:[...n.keys()].filter(e=>n.get(e)===r).sort()}function Ui(e,t,n){let{locale:r,source:i}=t;return i===`manual`?{locale:r,source:i}:e.length===1?{locale:e[0],source:`content`}:e.length>1?i!==null&&e.includes(r)?{locale:r,source:i}:{pick:[...e]}:i===null?{pick:[...n]}:{locale:r,source:i}}function Wi(e,t){return t.source===`manual`||e===null?t:{locale:e,source:`url`}}function Gi(e,t){return t.source===`manual`?t:e.length===1?{locale:e[0],source:`content`}:t.source===`remembered`&&e.includes(t.locale)?{locale:t.locale,source:`content`}:t}function Ki(e,t){if(t.source!==`manual`||e.length!==1)return null;let n=e[0];return n===t.locale?null:n}function qi(e){return e.source===`content`||e.source===`url`||e.source===`manual`}function V(e){let t=[];for(let n of e){if(t.length>=100)break;if(!n||typeof n!=`object`)continue;let{key:e,text:r}=n;typeof e==`string`&&typeof r==`string`&&t.push({key:e,text:r})}return t}var H=e=>{let[t,n]=(0,g.useState)(`connecting`),[r,i]=(0,g.useState)(`/`),[a,o]=(0,g.useState)(null),s=(0,g.useRef)(null),c=(0,g.useRef)(e);return c.current=e,(0,g.useEffect)(()=>{let e=e=>{if(e.origin!==z()||e.data?.source!==`livelocale-client`)return;let{type:t,payload:r}=e.data;if(t===`READY`){n(`connected`),i(r.url||`/`),o(null);let e=zi(r.url||`/`,Gt());e&&c.current.onLocaleDetected(e)}else t===`ELEMENT_SELECTED`?c.current.onElementSelected(r):t===`ERROR`?c.current.onError(r.error||`Client-side error occurred.`):t===`VISIBLE_KEYS_CHANGED`?Array.isArray(r)&&o(r):t===`VISIBLE_TEXTS_CHANGED`&&Array.isArray(r)&&c.current.onVisibleTexts?.(V(r))};return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e)}},[]),{connectionStatus:t,currentPath:r,visibleKeys:a,iframeRef:s,sendToIframe:(0,g.useCallback)((e,t)=>{s.current&&s.current.contentWindow&&s.current.contentWindow.postMessage({source:`livelocale-studio`,type:e,payload:t},z())},[])}};function Ji(e,t=``){let n={};if(!e||typeof e!=`object`)return n;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let i=t?`${t}.${r}`:r;typeof e[r]==`object`&&e[r]!==null&&!Array.isArray(e[r])?Object.assign(n,Ji(e[r],i)):n[i]=String(e[r])}return n}var Yi=({connectionStatus:e,iframeRef:t,referenceLocale:n=`en`})=>{let[r,i]=(0,g.useState)(`en`),[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)([]),[l,u]=(0,g.useState)([]),[d,f]=(0,g.useState)({}),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)({}),v=(0,g.useCallback)(async e=>{try{let t=await dn();Array.isArray(t)&&(o(t),e&&t.length>0&&i(e=>t.includes(e)?e:t.includes(`en`)?`en`:t[0]||`en`))}catch(e){console.warn(`[livelocale] Failed to fetch locales list:`,e.message)}},[]),y=(0,g.useCallback)(async()=>{try{let e=await fn();e&&Array.isArray(e.allKeys)&&c(e.allKeys),e&&Array.isArray(e.codeKeys)&&u(e.codeKeys)}catch(e){console.warn(`[livelocale] Failed to fetch keys metadata:`,e.message)}},[]),b=(0,g.useCallback)(async e=>{try{f(Ji(await pn(e))),m(e)}catch(e){console.warn(`[livelocale] Failed to load full locale dictionary:`,e.message)}},[]);(0,g.useEffect)(()=>{e===`connected`&&(v(!0),y())},[e,v,y]),(0,g.useEffect)(()=>{e===`connected`&&r&&b(r)},[e,r,b]),(0,g.useEffect)(()=>{e===`connected`&&pn(n).then(e=>_(Ji(e))).catch(e=>console.warn(`[livelocale] Failed to load reference locale:`,e.message))},[e,n]),(0,g.useEffect)(()=>{r===n&&_(d)},[r,d,n]);let x=(0,g.useCallback)(e=>{if(i(e),t.current&&t.current.contentWindow)try{let n=new URL(t.current.src);n.searchParams.set(`locale`,e),t.current.src=n.toString()}catch{}},[t]),S=(0,g.useCallback)(async()=>{await v(),await y(),await b(r)},[v,y,b,r]),C=(0,g.useCallback)((e,t)=>{f(n=>({...n,[e]:t}))},[]),w=s.length,T=s.filter(e=>{let t=d[e];return t!==void 0&&t.trim()!==``}).length;return{locale:r,setLocale:i,locales:a,allKeys:s,codeKeys:l,localeData:d,dataLocale:p,enLocaleData:h,coveragePercentage:w>0?Math.round(T/w*100):100,handleLocaleChange:x,fetchLocales:v,fetchKeysMetadata:y,fetchLocaleData:b,refreshAll:S,updateLocaleDataCache:C}},Xi=({localeData:e,enLocaleData:t,sendToIframe:n,locale:r,refreshKeysMetadata:i,updateLocaleDataCache:a,setLoading:o,setError:s,onSaved:c})=>{let[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(null),[v,y]=(0,g.useState)(0),b=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);let[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(null),T=l!==null&&d!==l.currentValue,E=(0,g.useCallback)(e=>{f(e),_(null),n(`APPLY_PREVIEW`,{key:l?.key,value:e})},[n,l?.key]),D=(0,g.useCallback)(t=>{if(T){w(t),S(!0);return}let n=e[t.key]??t.currentValue;u({...t,currentValue:n}),y(e=>e+1),f(n),m(!1),_(null),s(null)},[T,e,s]),O=(0,g.useCallback)(()=>{if(C){let t=e[C.key]??C.currentValue;u({...C,currentValue:t}),y(e=>e+1),f(t)}else u(null),f(``),n(`CLEAR_SELECTION`);w(null),S(!1),m(!1),s(null)},[C,e,n,s]),k=(0,g.useCallback)(()=>{w(null),S(!1)},[]),ee=(0,g.useCallback)(t=>{let n=e[t]||``;D({key:t,fallbackValue:n,currentValue:n})},[e,D]);return(0,g.useEffect)(()=>{if(l){let n=e[l.key]||``,r=t[l.key]||l.fallbackValue||``;l.currentValue!==n&&(u(e=>e?{...e,currentValue:n,fallbackValue:r}:null),f(n))}},[e,t]),{selected:l,selectionCount:v,inputValue:d,isSuccess:p,showConfirmModal:x,hasUnsavedChanges:T,selectElement:D,confirmDiscard:O,cancelDiscard:k,selectKeyDirectly:ee,handleInputChange:E,handleSave:async(e={})=>{if(l){o(!0),m(!1),s(null);try{let o=l.currentValue,s=r===`en`?o:t[l.key]??l.fallbackValue;await hn(r,l.key,d,{reference:s||void 0,force:e.force}),_(null),m(!0),c?.({locale:r,key:l.key,previousValue:o,nextValue:d}),u(e=>e?{...e,currentValue:d}:null),a(l.key,d),i(),n(`COMMIT_PREVIEW`,{key:l.key,value:d}),n(`CLEAR_SELECTION`),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{m(!1),b.current=null},2e3)}catch(e){e instanceof Zt?_({code:e.code,message:e.message,missing:e.details.missing,extra:e.details.extra}):s(e.message||`Failed to save translation.`)}finally{o(!1)}}},handleClearSelection:(0,g.useCallback)(()=>{if(T){w(null),S(!0);return}u(null),f(``),n(`CLEAR_SELECTION`)},[T,n]),saveWarning:h,dismissSaveWarning:()=>_(null)}},Zi=({locale:e,locales:t,handleLocaleChange:n,refreshAll:r,handleClearSelection:i,setLoading:a,setError:o})=>({handleAddLocale:(0,g.useCallback)(async e=>{try{a(!0),o(null),await gn(e),await r(),n(e)}catch(e){o(e.message||`Failed to add locale.`)}finally{a(!1)}},[r,n,a,o]),handleRenameLocale:(0,g.useCallback)(async(t,i)=>{try{a(!0),o(null),await _n(t,i),await r(),e===t&&n(i)}catch(e){o(e.message||`Failed to rename locale.`)}finally{a(!1)}},[e,r,n,a,o]),handleDeleteLocale:(0,g.useCallback)(async s=>{try{a(!0),o(null),await vn(s);let c=t.filter(e=>e!==s),l=`en`;c.length>0&&(l=c.includes(`en`)?`en`:c[0]||`en`),await r(),e===s&&(n(l),i())}catch(e){o(e.message||`Failed to delete locale.`)}finally{a(!1)}},[t,e,r,n,i,a,o])}),Qi=({allKeys:e,visibleKeys:t,localeData:n})=>{let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(!1);return{searchTerm:r,setSearchTerm:i,filterPageOnly:a,setFilterPageOnly:o,filteredKeys:(0,g.useMemo)(()=>e.filter(e=>{if(a&&t!==null&&!t.includes(e))return!1;let i=n[e]||``;return e.toLowerCase().includes(r.toLowerCase())||i.toLowerCase().includes(r.toLowerCase())}),[e,t,n,r,a])}},$i=({connectionStatus:e,onAfterDiscard:t})=>{let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useCallback)(async()=>{try{r(await mn())}catch(e){s(e.message||`Failed to read git status.`)}},[]);return(0,g.useEffect)(()=>{e===`connected`&&u()},[e,u]),{git:n,isLoading:i,error:o,lastCommit:c,refresh:u,commit:(0,g.useCallback)(async e=>{a(!0),s(null);try{let t=await yn(e);return l(t.hash),await u(),t.hash}catch(e){s(e.message||`Commit failed.`);return}finally{a(!1)}},[u]),discard:(0,g.useCallback)(async()=>{a(!0),s(null);try{return await bn(),await t(),await u(),!0}catch(e){return s(e.message||`Discard failed.`),!1}finally{a(!1)}},[t,u]),clearError:()=>s(null)}},ea=200,ta=0,na=()=>{let[e,t]=(0,g.useState)([]);return{entries:e,record:(0,g.useCallback)(e=>{ta+=1;let n={...e,id:`${Date.now()}-${ta}`,at:Date.now()};t(e=>[n,...e].slice(0,ea))},[]),remove:(0,g.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),clear:(0,g.useCallback)(()=>t([]),[])}},ra=()=>{let[e,t]=(0,g.useState)(()=>en()),[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(0);return(0,g.useEffect)(()=>{let e=()=>r(!0);return window.addEventListener(Yt,e),()=>window.removeEventListener(Yt,e)},[]),{token:e,needsToken:n,tokenVersion:i,submitToken:(0,g.useCallback)(e=>{let n=e.trim();n&&(tn(n),t(n),r(!1),a(e=>e+1))},[]),clearToken:(0,g.useCallback)(()=>{tn(null),t(null),a(e=>e+1)},[])}};function ia(e){(0,g.useEffect)(()=>{if(!e)return;let t=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e])}function aa(e){let{mode:t,locale:n,localeConfirmed:r,history:i,drafts:a}=e,o=new Map;if(t===`preview`)for(let e of[...i].reverse())e.locale===n&&o.set(e.key,e.nextValue);else if(t===`static`&&r)for(let e of a)e.locale===n&&o.set(e.key,e.to);return o}var oa=`livelocale-target-locale:`;function sa(e){try{return localStorage.getItem(oa+e)}catch{return null}}function ca(e,t){try{localStorage.setItem(oa+e,t)}catch{}}var la=({enabled:e,scope:t,locale:n,setLocale:r,setMenuLocale:i=r,locales:a,getCandidates:o})=>{let[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(null),p=(0,g.useRef)(n);p.current=n;let m=(0,g.useRef)(s);m.current=s;let h=(0,g.useRef)(null),_=(0,g.useRef)(null),v=()=>({locale:p.current,source:m.current}),y=e=>{let n=v();e.locale===n.locale&&e.source===n.source||(p.current=e.locale,m.current=e.source,r(e.locale),c(e.source),t!==null&&qi(e)&&ca(t,e.locale))};(0,g.useEffect)(()=>{if(!e||t===null||_.current===t||m.current!==null)return;let n=sa(t);n===null||!a.includes(n)||(_.current=t,p.current=n,m.current=`remembered`,r(n),c(`remembered`))},[e,t,a]);let b=t=>{if(!e){r(t);return}y(Wi(t,v()))},x=async t=>{e&&y(Gi(Hi(t,await o()),v()))},S=async t=>{if(!e)return!0;let n=await o(),r=Vi(t.key,[t.currentValue],n),i=v();u(Ki(r,i));let s=Ui(r,i,a);return`pick`in s?s.pick.length===0?!0:(h.current=t,f(s.pick),!1):(y(s),!0)},C=t=>!e||m.current!==null||a.length===0?!0:(h.current=t,f([...a]),!1),w=e=>{p.current=e,m.current=`manual`,r(e),c(`manual`),t!==null&&ca(t,e),u(null),f(null);let n=h.current;return h.current=null,n},T=t=>{e?w(t):i(t)},E=(0,g.useCallback)(()=>{h.current=null,f(null)},[]);return{source:s,confirmed:qi({locale:n,source:s}),mismatch:l,pickerCandidates:d,onUrlLocale:b,onVisibleTexts:x,resolveForSelection:S,resolveForDirectPick:C,choose:w,onMenuLocale:T,cancelPick:E}},ua=`More than 500 changes: send some of them first, then download the backup.`,da=`No change link found in this file.`;async function fa(e){let{drafts:t,manifest:n,studioHref:r,by:i}=e;if(t.length>500)throw Error(ua);let a=await St(Tr({drafts:t,manifest:n,by:i}));return{fileName:Dr(`backup`,e.now??new Date),text:Er(r,a)+`
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <meta name="robots" content="noindex, nofollow" />
7
7
  <title>LiveLocale · Studio</title>
8
- <script type="module" crossorigin src="./assets/index-Dlvw1H47.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-yI6iF4xN.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="./assets/index-FFC_lDHv.css">
10
10
  </head>
11
11
  <body class="bg-background text-foreground antialiased overflow-hidden">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livelocale",
3
- "version": "0.10.0-next.7",
3
+ "version": "0.10.0",
4
4
  "description": "Click any text in your running React app to edit its translation. Edits stay as JSON in git, or arrive as a pull request from a deployed preview. Local-first, zero-dependency.",
5
5
  "license": "MIT",
6
6
  "author": "Araby99",