@deslop/auth 0.1.1259 → 0.1.1261

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
@@ -7,10 +7,4 @@ npm install --global @deslop/auth
7
7
  auth service install --url https://auth.mp281x.xyz --auth https://auth.mp281x.xyz --admins <github-id> --github-client-id <id>
8
8
  ```
9
9
 
10
- - **Secret**: `GITHUB_CLIENT_SECRET` in `~/.deslop/auth.env`.
11
- - **MCP** at `/mcp`: `answer_request` approves a sign-in by its code.
12
- - **Access tokens**: ten-minute Ed25519 JWTs, valid across Deslop apps; public keys at `/.well-known/jwks.json`.
13
- - **Commands**: a command without a browser signs in with RFC 8628's device code at `/api/auth/oauth2/device_authorization`; its code is approved like any other, in Auth or with `answer_request`.
14
- - **Web sign-in**: Auth keeps a host-only browser session and immediately authorizes Deslop web callbacks. Signing that browser out also ends the app sessions it started.
15
-
16
10
  Common flags and service commands: [Deslop app runtime](https://github.com/MP281X/deslop/blob/main/packages/runtime/README.md).
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{a as t,n,o as r}from"./react-COyt-gOi.js";import{H as i,I as a,K as o,L as s,R as c,U as l,i as u,z as d}from"./components-Ch6q3AXb.js";import{$a as f,Ba as p,L as m,La as h,Na as g,Qi as _,R as v,Ua as y,Va as b,_ as x,ba as S,ia as C,va as w,z as T}from"./effect-CarHrcH-.js";import{t as E}from"./Check.es-AeXSmS94.js";import{F as D,I as O,L as k,N as A,R as j,cr as M,d as N,ir as P,m as F,or as I,y as L}from"./utils-C0__Xx0_.js";import{t as R}from"./index-DhM_XKY3.js";var z=e(r(),1),B=new Map([[`bold`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H40a12,12,0,0,1,0-24H216A12,12,0,0,1,228,128Z`}))],[`duotone`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),z.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128Z`}))],[`fill`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H72a8,8,0,0,1,0-16H184a8,8,0,0,1,0,16Z`}))],[`light`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H40a6,6,0,0,1,0-12H216A6,6,0,0,1,222,128Z`}))],[`regular`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128Z`}))],[`thin`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H40a4,4,0,0,1,0-8H216A4,4,0,0,1,220,128Z`}))]]),V=z.forwardRef((e,t)=>z.createElement(M,{ref:t,...e,weights:B}));V.displayName=`MinusIcon`;var H=e=>{let t=U(z.useMemo(()=>ee(e.machine,e.path),[e.machine,e.path]));if(m(t))throw _(t.cause);return v(t)?e.pending??null:h(t.value)?e.children(t.value.value):e.inactive??null},ee=(e,t)=>O(e)?k(e,t):j(e,t),U=e=>te(z.useContext(o),e),te=(e,t)=>{let n=z.useMemo(()=>{let n,r,i=e=>T(e)?(n=e,e):v(e)&&n!==void 0?n:e;return{subscribe:n=>e.subscribe(t,n),snapshot:()=>i(e.get(t)),serverSnapshot:()=>r??=i(x(t,e))}},[e,t]);return z.useSyncExternalStore(n.subscribe,n.snapshot,n.serverSnapshot)},W=H,G=n(),ne=Object.defineProperty,re=Object.defineProperties,ie=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,Y=(e,t,n)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ae=(e,t)=>{for(var n in t||={})q.call(t,n)&&Y(e,n,t[n]);if(K)for(var n of K(t))J.call(t,n)&&Y(e,n,t[n]);return e},oe=(e,t)=>re(e,ie(t)),se=(e,t)=>{var n={};for(var r in e)q.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&K)for(var r of K(e))t.indexOf(r)<0&&J.call(e,r)&&(n[r]=e[r]);return n};function ce(e){return[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)]}function le(e){let t=z.useRef();return z.useEffect(()=>{t.current=e}),t.current}var ue=18,X=40,de=`${X}px`;function fe(e){let t=e.getBoundingClientRect().right,n=e;for(;n;){if(getComputedStyle(n).overflowX!==`visible`)return n.getBoundingClientRect().left+n.clientLeft+n.clientWidth-t;n=n.parentElement}return document.documentElement.clientWidth-t}var pe=`[data-lastpass-icon-root],com-1password-button,[data-dashlanecreated],[style$="2147483647 !important;"]`;function me({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:r}){let[i,a]=z.useState(!1),[o,s]=z.useState(!1),[c,l]=z.useState(!1),u=z.useMemo(()=>n!==`none`&&(n===`increase-width`||n===`experimental-no-flickering`)&&i&&o,[i,o,n]),d=z.useCallback(()=>{let r=e.current,i=t.current;if(!r||!i||c||n===`none`)return;let o=r,u=o.getBoundingClientRect().left+o.offsetWidth,d=o.getBoundingClientRect().top+o.offsetHeight/2,f=u-ue,p=d;document.querySelectorAll(pe).length===0&&document.elementFromPoint(f,p)===r||(s(fe(r)>=X),a(!0),l(!0))},[e,t,c,n]);return z.useEffect(()=>{let t=e.current;if(!t||n===`none`)return;function r(){s(fe(t)>=X)}r();let i=setInterval(r,1e3);return()=>{clearInterval(i)}},[e,n]),z.useEffect(()=>{let e=r||document.activeElement===t.current;if(n===`none`||!e)return;let i=setTimeout(d,0),a=setTimeout(d,2e3),o=setTimeout(d,5e3),s=setTimeout(()=>{l(!0)},6e3);return()=>{clearTimeout(i),clearTimeout(a),clearTimeout(o),clearTimeout(s)}},[t,r,n,d]),{hasPWMBadge:i,willPushPWMBadge:u,PWM_BADGE_SPACE_WIDTH:de}}var he=z.createContext({}),ge=z.forwardRef((e,t)=>{var n=e,{value:r,onChange:i,maxLength:a,textAlign:o=`left`,pattern:s,placeholder:c,inputMode:l=`numeric`,onComplete:u,pushPasswordManagerStrategy:d=`increase-width`,pasteTransformer:f,containerClassName:p,noScriptCSSFallback:m=_e,nonce:h,render:g,children:_}=n,v=se(n,[`value`,`onChange`,`maxLength`,`textAlign`,`pattern`,`placeholder`,`inputMode`,`onComplete`,`pushPasswordManagerStrategy`,`pasteTransformer`,`containerClassName`,`noScriptCSSFallback`,`nonce`,`render`,`children`]),y;let[b,x]=z.useState(typeof v.defaultValue==`string`?v.defaultValue:``),S=r??b,C=le(S),w=z.useCallback(e=>{i?.(e),x(e)},[i]),T=z.useMemo(()=>s?typeof s==`string`?new RegExp(s):s:null,[s]),E=z.useRef(null),D=z.useRef(null),O=z.useRef({value:S,onChange:w,isIOS:typeof window<`u`&&((y=window==null?void 0:window.CSS)?.supports)?.call(y,`-webkit-touch-callout`,`none`)}),k=z.useRef({prev:[E.current?.selectionStart,E.current?.selectionEnd,E.current?.selectionDirection]});z.useImperativeHandle(t,()=>E.current,[]),z.useEffect(()=>{let e=E.current,t=D.current;if(!e||!t)return;O.current.value!==e.value&&O.current.onChange(e.value),k.current.prev=[e.selectionStart,e.selectionEnd,e.selectionDirection];function n(){if(document.activeElement!==e){F(null),L(null);return}let t=e.selectionStart,n=e.selectionEnd,r=e.selectionDirection,i=e.maxLength,a=e.value,o=k.current.prev,s=-1,c=-1,l;if(a.length!==0&&t!==null&&n!==null){let r=t===n,u=t===a.length&&a.length<i;if(r&&!u){let e=t;if(e===0)s=0,c=1,l=`forward`;else if(e===i)s=e-1,c=e,l=`backward`;else if(i>1&&a.length>1){let t=0;if(o[0]!==null&&o[1]!==null){l=e<o[1]?`backward`:`forward`;let n=o[0]===o[1]&&o[0]<i;l===`backward`&&!n&&(t=-1)}s=t+e,c=t+e+1}}s!==-1&&c!==-1&&s!==c&&e.setSelectionRange(s,c,l)}let u=s===-1?t:s,d=c===-1?n:c,f=l??r;F(u),L(d),k.current.prev=[u,d,f]}if(document.addEventListener(`selectionchange`,n,{capture:!0}),n(),document.activeElement===e&&N(!0),!document.getElementById(`input-otp-style`)){let e=document.createElement(`style`);if(e.id=`input-otp-style`,h&&e.setAttribute(`nonce`,h),document.head.appendChild(e),e.sheet){let t=`background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;`;Z(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),Z(e.sheet,`[data-input-otp]:autofill { ${t} }`),Z(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),Z(e.sheet,`@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }`),Z(e.sheet,`[data-input-otp] + * { pointer-events: all !important; }`)}}let r=()=>{t&&t.style.setProperty(`--root-height`,`${e.clientHeight}px`)};r();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i?.observe(e),()=>{document.removeEventListener(`selectionchange`,n,{capture:!0}),i?.disconnect()}},[]);let[A,j]=z.useState(!1),[M,N]=z.useState(!1),[P,F]=z.useState(null),[I,L]=z.useState(null);z.useEffect(()=>{let e=ce(()=>{var e;(e=E.current)==null||e.dispatchEvent(new Event(`input`));let t=E.current?.selectionStart,n=E.current?.selectionEnd,r=E.current?.selectionDirection;t!==null&&n!==null&&(F(t),L(n),k.current.prev=[t,n,r])});return()=>{e.forEach(e=>clearTimeout(e))}},[S,M]),z.useEffect(()=>{C!==void 0&&S!==C&&C.length<a&&S.length===a&&u?.(S)},[a,u,C,S]);let R=me({containerRef:D,inputRef:E,pushPasswordManagerStrategy:d,isFocused:M}),B=z.useCallback(e=>{let t=e.currentTarget.value.slice(0,a);t.length>0&&T&&!T.test(t)?e.preventDefault():(typeof C==`string`&&t.length<C.length&&document.dispatchEvent(new Event(`selectionchange`)),w(t))},[a,w,C,T]),V=z.useCallback(()=>{var e;if(E.current){let t=Math.min(E.current.value.length,a-1),n=E.current.value.length;(e=E.current)==null||e.setSelectionRange(t,n),F(t),L(n)}N(!0)},[a]),H=z.useCallback(e=>{let t=E.current;if(!f&&(!O.current.isIOS||!e.clipboardData||!t))return;let n=e.clipboardData.getData(`text/plain`),r=f?f(n):n;e.preventDefault();let i=E.current?.selectionStart,o=E.current?.selectionEnd,s=(i===o?S.slice(0,i)+r+S.slice(i):S.slice(0,i)+r+S.slice(o)).slice(0,a);if(s.length>0&&T&&!T.test(s))return;t.value=s,w(s);let c=Math.min(s.length,a-1),l=s.length;t.setSelectionRange(c,l),F(c),L(l)},[a,w,f,T,S]),ee=z.useMemo(()=>({position:`relative`,cursor:v.disabled?`default`:`text`,userSelect:`none`,WebkitUserSelect:`none`,pointerEvents:`none`}),[v.disabled]),U=z.useMemo(()=>({position:`absolute`,inset:0,width:R.willPushPWMBadge?`calc(100% + ${R.PWM_BADGE_SPACE_WIDTH})`:`100%`,clipPath:R.willPushPWMBadge?`inset(0 ${R.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:`100%`,display:`flex`,textAlign:o,opacity:`1`,color:`transparent`,pointerEvents:`all`,background:`transparent`,caretColor:`transparent`,border:`0 solid transparent`,outline:`0 solid transparent`,boxShadow:`none`,lineHeight:`1`,letterSpacing:`-.5em`,fontSize:`var(--root-height, 16px)`,fontFamily:`monospace`,fontVariantNumeric:`tabular-nums`}),[R.PWM_BADGE_SPACE_WIDTH,R.willPushPWMBadge,o]),te=z.useMemo(()=>z.createElement(`input`,oe(ae({autoComplete:v.autoComplete||`one-time-code`},v),{"data-input-otp":!0,"data-input-otp-placeholder-shown":S.length===0||void 0,"data-input-otp-mss":P,"data-input-otp-mse":I,inputMode:l,pattern:T?.source,"aria-placeholder":c,style:U,maxLength:a,value:S,ref:E,spellCheck:v.spellCheck??!1,onPaste:e=>{var t;H(e),(t=v.onPaste)==null||t.call(v,e)},onChange:B,onMouseOver:e=>{var t;j(!0),(t=v.onMouseOver)==null||t.call(v,e)},onMouseLeave:e=>{var t;j(!1),(t=v.onMouseLeave)==null||t.call(v,e)},onFocus:e=>{var t;V(),(t=v.onFocus)==null||t.call(v,e)},onBlur:e=>{var t;N(!1),(t=v.onBlur)==null||t.call(v,e)}})),[B,V,H,l,U,a,I,P,c,v,T?.source,S]),W=z.useMemo(()=>({slots:Array.from({length:a}).map((e,t)=>{let n=M&&P!==null&&I!==null&&(P===I&&t===P||t>=P&&t<I),r=S[t]===void 0?null:S[t];return{char:r,placeholderChar:S[0]===void 0?c?.[t]??null:null,isActive:n,hasFakeCaret:n&&r===null}}),isFocused:M,isHovering:!v.disabled&&A}),[M,A,a,I,P,c,v.disabled,S]),G=z.useMemo(()=>g?g(W):z.createElement(he.Provider,{value:W},_),[_,W,g]);return z.createElement(z.Fragment,null,m!==null&&z.createElement(`noscript`,null,z.createElement(`style`,null,m)),z.createElement(`div`,{ref:D,"data-input-otp-container":!0,translate:`no`,style:ee,className:p},G,z.createElement(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`}},te)))});ge.displayName=`Input`;function Z(e,t){try{e.insertRule(t)}catch{console.warn(`input-otp could not insert CSS rule:`,t)}}var _e=`
1
+ import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{a as t,n,o as r}from"./react-COyt-gOi.js";import{H as i,I as a,K as o,L as s,R as c,U as l,i as u,z as d}from"./components-Dzgxr0NK.js";import{$a as f,Ba as p,L as m,La as h,Na as g,Qi as _,R as v,Ua as y,Va as b,_ as x,ba as S,ia as C,va as w,z as T}from"./effect-CarHrcH-.js";import{t as E}from"./Check.es-C9l513Ch.js";import{F as D,I as O,L as k,N as A,R as j,cr as M,d as N,ir as P,m as F,or as I,y as L}from"./utils-BepQ-yTS.js";import{t as R}from"./index-CW-CqO1U.js";var z=e(r(),1),B=new Map([[`bold`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H40a12,12,0,0,1,0-24H216A12,12,0,0,1,228,128Z`}))],[`duotone`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),z.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128Z`}))],[`fill`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H72a8,8,0,0,1,0-16H184a8,8,0,0,1,0,16Z`}))],[`light`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H40a6,6,0,0,1,0-12H216A6,6,0,0,1,222,128Z`}))],[`regular`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128Z`}))],[`thin`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H40a4,4,0,0,1,0-8H216A4,4,0,0,1,220,128Z`}))]]),V=z.forwardRef((e,t)=>z.createElement(M,{ref:t,...e,weights:B}));V.displayName=`MinusIcon`;var H=e=>{let t=U(z.useMemo(()=>ee(e.machine,e.path),[e.machine,e.path]));if(m(t))throw _(t.cause);return v(t)?e.pending??null:h(t.value)?e.children(t.value.value):e.inactive??null},ee=(e,t)=>O(e)?k(e,t):j(e,t),U=e=>te(z.useContext(o),e),te=(e,t)=>{let n=z.useMemo(()=>{let n,r,i=e=>T(e)?(n=e,e):v(e)&&n!==void 0?n:e;return{subscribe:n=>e.subscribe(t,n),snapshot:()=>i(e.get(t)),serverSnapshot:()=>r??=i(x(t,e))}},[e,t]);return z.useSyncExternalStore(n.subscribe,n.snapshot,n.serverSnapshot)},W=H,G=n(),ne=Object.defineProperty,re=Object.defineProperties,ie=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,Y=(e,t,n)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ae=(e,t)=>{for(var n in t||={})q.call(t,n)&&Y(e,n,t[n]);if(K)for(var n of K(t))J.call(t,n)&&Y(e,n,t[n]);return e},oe=(e,t)=>re(e,ie(t)),se=(e,t)=>{var n={};for(var r in e)q.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&K)for(var r of K(e))t.indexOf(r)<0&&J.call(e,r)&&(n[r]=e[r]);return n};function ce(e){return[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)]}function le(e){let t=z.useRef();return z.useEffect(()=>{t.current=e}),t.current}var ue=18,X=40,de=`${X}px`;function fe(e){let t=e.getBoundingClientRect().right,n=e;for(;n;){if(getComputedStyle(n).overflowX!==`visible`)return n.getBoundingClientRect().left+n.clientLeft+n.clientWidth-t;n=n.parentElement}return document.documentElement.clientWidth-t}var pe=`[data-lastpass-icon-root],com-1password-button,[data-dashlanecreated],[style$="2147483647 !important;"]`;function me({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:r}){let[i,a]=z.useState(!1),[o,s]=z.useState(!1),[c,l]=z.useState(!1),u=z.useMemo(()=>n!==`none`&&(n===`increase-width`||n===`experimental-no-flickering`)&&i&&o,[i,o,n]),d=z.useCallback(()=>{let r=e.current,i=t.current;if(!r||!i||c||n===`none`)return;let o=r,u=o.getBoundingClientRect().left+o.offsetWidth,d=o.getBoundingClientRect().top+o.offsetHeight/2,f=u-ue,p=d;document.querySelectorAll(pe).length===0&&document.elementFromPoint(f,p)===r||(s(fe(r)>=X),a(!0),l(!0))},[e,t,c,n]);return z.useEffect(()=>{let t=e.current;if(!t||n===`none`)return;function r(){s(fe(t)>=X)}r();let i=setInterval(r,1e3);return()=>{clearInterval(i)}},[e,n]),z.useEffect(()=>{let e=r||document.activeElement===t.current;if(n===`none`||!e)return;let i=setTimeout(d,0),a=setTimeout(d,2e3),o=setTimeout(d,5e3),s=setTimeout(()=>{l(!0)},6e3);return()=>{clearTimeout(i),clearTimeout(a),clearTimeout(o),clearTimeout(s)}},[t,r,n,d]),{hasPWMBadge:i,willPushPWMBadge:u,PWM_BADGE_SPACE_WIDTH:de}}var he=z.createContext({}),ge=z.forwardRef((e,t)=>{var n=e,{value:r,onChange:i,maxLength:a,textAlign:o=`left`,pattern:s,placeholder:c,inputMode:l=`numeric`,onComplete:u,pushPasswordManagerStrategy:d=`increase-width`,pasteTransformer:f,containerClassName:p,noScriptCSSFallback:m=_e,nonce:h,render:g,children:_}=n,v=se(n,[`value`,`onChange`,`maxLength`,`textAlign`,`pattern`,`placeholder`,`inputMode`,`onComplete`,`pushPasswordManagerStrategy`,`pasteTransformer`,`containerClassName`,`noScriptCSSFallback`,`nonce`,`render`,`children`]),y;let[b,x]=z.useState(typeof v.defaultValue==`string`?v.defaultValue:``),S=r??b,C=le(S),w=z.useCallback(e=>{i?.(e),x(e)},[i]),T=z.useMemo(()=>s?typeof s==`string`?new RegExp(s):s:null,[s]),E=z.useRef(null),D=z.useRef(null),O=z.useRef({value:S,onChange:w,isIOS:typeof window<`u`&&((y=window==null?void 0:window.CSS)?.supports)?.call(y,`-webkit-touch-callout`,`none`)}),k=z.useRef({prev:[E.current?.selectionStart,E.current?.selectionEnd,E.current?.selectionDirection]});z.useImperativeHandle(t,()=>E.current,[]),z.useEffect(()=>{let e=E.current,t=D.current;if(!e||!t)return;O.current.value!==e.value&&O.current.onChange(e.value),k.current.prev=[e.selectionStart,e.selectionEnd,e.selectionDirection];function n(){if(document.activeElement!==e){F(null),L(null);return}let t=e.selectionStart,n=e.selectionEnd,r=e.selectionDirection,i=e.maxLength,a=e.value,o=k.current.prev,s=-1,c=-1,l;if(a.length!==0&&t!==null&&n!==null){let r=t===n,u=t===a.length&&a.length<i;if(r&&!u){let e=t;if(e===0)s=0,c=1,l=`forward`;else if(e===i)s=e-1,c=e,l=`backward`;else if(i>1&&a.length>1){let t=0;if(o[0]!==null&&o[1]!==null){l=e<o[1]?`backward`:`forward`;let n=o[0]===o[1]&&o[0]<i;l===`backward`&&!n&&(t=-1)}s=t+e,c=t+e+1}}s!==-1&&c!==-1&&s!==c&&e.setSelectionRange(s,c,l)}let u=s===-1?t:s,d=c===-1?n:c,f=l??r;F(u),L(d),k.current.prev=[u,d,f]}if(document.addEventListener(`selectionchange`,n,{capture:!0}),n(),document.activeElement===e&&N(!0),!document.getElementById(`input-otp-style`)){let e=document.createElement(`style`);if(e.id=`input-otp-style`,h&&e.setAttribute(`nonce`,h),document.head.appendChild(e),e.sheet){let t=`background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;`;Z(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),Z(e.sheet,`[data-input-otp]:autofill { ${t} }`),Z(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),Z(e.sheet,`@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }`),Z(e.sheet,`[data-input-otp] + * { pointer-events: all !important; }`)}}let r=()=>{t&&t.style.setProperty(`--root-height`,`${e.clientHeight}px`)};r();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i?.observe(e),()=>{document.removeEventListener(`selectionchange`,n,{capture:!0}),i?.disconnect()}},[]);let[A,j]=z.useState(!1),[M,N]=z.useState(!1),[P,F]=z.useState(null),[I,L]=z.useState(null);z.useEffect(()=>{let e=ce(()=>{var e;(e=E.current)==null||e.dispatchEvent(new Event(`input`));let t=E.current?.selectionStart,n=E.current?.selectionEnd,r=E.current?.selectionDirection;t!==null&&n!==null&&(F(t),L(n),k.current.prev=[t,n,r])});return()=>{e.forEach(e=>clearTimeout(e))}},[S,M]),z.useEffect(()=>{C!==void 0&&S!==C&&C.length<a&&S.length===a&&u?.(S)},[a,u,C,S]);let R=me({containerRef:D,inputRef:E,pushPasswordManagerStrategy:d,isFocused:M}),B=z.useCallback(e=>{let t=e.currentTarget.value.slice(0,a);t.length>0&&T&&!T.test(t)?e.preventDefault():(typeof C==`string`&&t.length<C.length&&document.dispatchEvent(new Event(`selectionchange`)),w(t))},[a,w,C,T]),V=z.useCallback(()=>{var e;if(E.current){let t=Math.min(E.current.value.length,a-1),n=E.current.value.length;(e=E.current)==null||e.setSelectionRange(t,n),F(t),L(n)}N(!0)},[a]),H=z.useCallback(e=>{let t=E.current;if(!f&&(!O.current.isIOS||!e.clipboardData||!t))return;let n=e.clipboardData.getData(`text/plain`),r=f?f(n):n;e.preventDefault();let i=E.current?.selectionStart,o=E.current?.selectionEnd,s=(i===o?S.slice(0,i)+r+S.slice(i):S.slice(0,i)+r+S.slice(o)).slice(0,a);if(s.length>0&&T&&!T.test(s))return;t.value=s,w(s);let c=Math.min(s.length,a-1),l=s.length;t.setSelectionRange(c,l),F(c),L(l)},[a,w,f,T,S]),ee=z.useMemo(()=>({position:`relative`,cursor:v.disabled?`default`:`text`,userSelect:`none`,WebkitUserSelect:`none`,pointerEvents:`none`}),[v.disabled]),U=z.useMemo(()=>({position:`absolute`,inset:0,width:R.willPushPWMBadge?`calc(100% + ${R.PWM_BADGE_SPACE_WIDTH})`:`100%`,clipPath:R.willPushPWMBadge?`inset(0 ${R.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:`100%`,display:`flex`,textAlign:o,opacity:`1`,color:`transparent`,pointerEvents:`all`,background:`transparent`,caretColor:`transparent`,border:`0 solid transparent`,outline:`0 solid transparent`,boxShadow:`none`,lineHeight:`1`,letterSpacing:`-.5em`,fontSize:`var(--root-height, 16px)`,fontFamily:`monospace`,fontVariantNumeric:`tabular-nums`}),[R.PWM_BADGE_SPACE_WIDTH,R.willPushPWMBadge,o]),te=z.useMemo(()=>z.createElement(`input`,oe(ae({autoComplete:v.autoComplete||`one-time-code`},v),{"data-input-otp":!0,"data-input-otp-placeholder-shown":S.length===0||void 0,"data-input-otp-mss":P,"data-input-otp-mse":I,inputMode:l,pattern:T?.source,"aria-placeholder":c,style:U,maxLength:a,value:S,ref:E,spellCheck:v.spellCheck??!1,onPaste:e=>{var t;H(e),(t=v.onPaste)==null||t.call(v,e)},onChange:B,onMouseOver:e=>{var t;j(!0),(t=v.onMouseOver)==null||t.call(v,e)},onMouseLeave:e=>{var t;j(!1),(t=v.onMouseLeave)==null||t.call(v,e)},onFocus:e=>{var t;V(),(t=v.onFocus)==null||t.call(v,e)},onBlur:e=>{var t;N(!1),(t=v.onBlur)==null||t.call(v,e)}})),[B,V,H,l,U,a,I,P,c,v,T?.source,S]),W=z.useMemo(()=>({slots:Array.from({length:a}).map((e,t)=>{let n=M&&P!==null&&I!==null&&(P===I&&t===P||t>=P&&t<I),r=S[t]===void 0?null:S[t];return{char:r,placeholderChar:S[0]===void 0?c?.[t]??null:null,isActive:n,hasFakeCaret:n&&r===null}}),isFocused:M,isHovering:!v.disabled&&A}),[M,A,a,I,P,c,v.disabled,S]),G=z.useMemo(()=>g?g(W):z.createElement(he.Provider,{value:W},_),[_,W,g]);return z.createElement(z.Fragment,null,m!==null&&z.createElement(`noscript`,null,z.createElement(`style`,null,m)),z.createElement(`div`,{ref:D,"data-input-otp-container":!0,translate:`no`,style:ee,className:p},G,z.createElement(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`}},te)))});ge.displayName=`Input`;function Z(e,t){try{e.insertRule(t)}catch{console.warn(`input-otp could not insert CSS rule:`,t)}}var _e=`
2
2
  [data-input-otp] {
3
3
  --nojs-bg: white !important;
4
4
  --nojs-fg: black !important;
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{o as t}from"./react-COyt-gOi.js";import{cr as n}from"./utils-C0__Xx0_.js";var r=e(t(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M232,56V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M228.24,76.24l-128,128a6,6,0,0,1-8.48,0l-56-56a6,6,0,0,1,8.48-8.48L96,191.51,219.76,67.76a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M226.83,74.83l-128,128a4,4,0,0,1-5.66,0l-56-56a4,4,0,0,1,5.66-5.66L96,194.34,221.17,69.17a4,4,0,1,1,5.66,5.66Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`CheckIcon`;export{a as t};
1
+ import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{o as t}from"./react-COyt-gOi.js";import{cr as n}from"./utils-BepQ-yTS.js";var r=e(t(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M232,56V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M228.24,76.24l-128,128a6,6,0,0,1-8.48,0l-56-56a6,6,0,0,1,8.48-8.48L96,191.51,219.76,67.76a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M226.83,74.83l-128,128a4,4,0,0,1-5.66,0l-56-56a4,4,0,0,1,5.66-5.66L96,194.34,221.17,69.17a4,4,0,1,1,5.66,5.66Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`CheckIcon`;export{a as t};