forked from kojibai/verify.kai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSealMomentModal-C7mxkSGB.js
More file actions
1 lines (1 loc) · 6.49 KB
/
Copy pathSealMomentModal-C7mxkSGB.js
File metadata and controls
1 lines (1 loc) · 6.49 KB
1
import{Tn as e,jn as t,tn as n,wn as r}from"./index-BlYU7j-M.js";var i=t(e(),1),a=t(r(),1),o=t(n(),1),s=`sigil:urls`;function c(e){if(!(typeof window>`u`))try{let t=window.localStorage.getItem(s),n=t?JSON.parse(t):[];n.includes(e)||(n.push(e),window.localStorage.setItem(s,JSON.stringify(n))),window.dispatchEvent(new CustomEvent(`sigil:url-registered`,{detail:{url:e}}))}catch{}}var l=({open:e,url:t,hash:n,onClose:r})=>{let s=(0,i.useRef)(null),l=(0,i.useRef)(null),m=(0,i.useRef)(null),[h,g]=(0,i.useState)(``),_=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!(!e||!t)&&_.current!==t){if(_.current=t,typeof window<`u`&&typeof window.__SIGIL__?.registerSigilUrl==`function`)try{window.__SIGIL__.registerSigilUrl(t)}catch{c(t)}else c(t);if(typeof window<`u`&&typeof window.__SIGIL__?.registerSend==`function`)try{window.__SIGIL__.registerSend({type:`sigil:mint`,url:t,hash:n})}catch{}}},[e,t,n]);let v=(0,i.useMemo)(()=>{if(typeof navigator>`u`)return!1;let e=navigator;return typeof e.share==`function`?t&&typeof e.canShare==`function`?e.canShare({url:t}):!0:!1},[t]),y=(0,i.useCallback)(e=>{let t=s.current;if(!t)return;let n=t.querySelectorAll([`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex='-1'])`].join(`,`));if(n.length===0)return;let r=n[0],i=n[n.length-1];!e.shiftKey&&document.activeElement===i?(e.preventDefault(),r.focus()):e.shiftKey&&document.activeElement===r&&(e.preventDefault(),i.focus())},[]);(0,i.useEffect)(()=>{if(!e)return;m.current=document.activeElement??null;let t=document.body.style.overflow;document.body.style.overflow=`hidden`;let n=window.setTimeout(()=>l.current?.focus({preventScroll:!0}),0),r=e=>{e.key===`Tab`&&y(e)};return document.addEventListener(`keydown`,r,!0),()=>{document.body.style.overflow=t,document.removeEventListener(`keydown`,r,!0),window.clearTimeout(n),m.current?.focus?.()}},[e,y]);let b=e=>{g(e),window.setTimeout(()=>g(``),900)},x=async(e,t)=>{try{if(typeof navigator>`u`)throw Error(`no navigator`);if(!navigator.clipboard?.writeText)throw Error(`no clipboard`);await navigator.clipboard.writeText(e),b(`${t} copied to clipboard`)}catch{b(`Could not copy ${t}`)}},S=async()=>{try{v&&typeof navigator<`u`?(await navigator.share?.({title:`Kairos Sigil-Glyph`,text:`Sealed Kairos Moment`,url:t}),b(`Share sheet opened`)):await x(t,`Link`)}catch{}},C=(0,i.useMemo)(()=>n?n.slice(0,16):`—`,[n]),w=e=>{e.preventDefault(),e.stopPropagation(),r?.()},T=e=>{e.target===e.currentTarget&&e.preventDefault()};return e?(0,a.createPortal)((0,o.jsxs)(`div`,{className:`seal-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`seal-title`,"aria-describedby":`seal-desc`,"data-state":`open`,onClick:e=>e.stopPropagation(),onPointerDown:T,children:[(0,o.jsx)(`div`,{className:`seal-veil`,"aria-hidden":`true`}),(0,o.jsxs)(`div`,{ref:s,className:`seal-card`,role:`document`,onClick:e=>e.stopPropagation(),children:[(0,o.jsx)(`div`,{className:`seal-ornament seal-ornament--tl`,"aria-hidden":`true`}),(0,o.jsx)(`div`,{className:`seal-ornament seal-ornament--tr`,"aria-hidden":`true`}),(0,o.jsx)(`div`,{className:`seal-ornament seal-ornament--bl`,"aria-hidden":`true`}),(0,o.jsx)(`div`,{className:`seal-ornament seal-ornament--br`,"aria-hidden":`true`}),(0,o.jsx)(`button`,{ref:l,className:`seal-close`,"aria-label":`Close`,onClick:w,type:`button`,children:(0,o.jsx)(u,{})}),(0,o.jsxs)(`header`,{className:`seal-header`,children:[(0,o.jsx)(`h3`,{id:`seal-title`,className:`seal-title`,children:`Moment Sealed`}),(0,o.jsx)(`p`,{id:`seal-desc`,className:`seal-subtitle`,children:`Your Kairos imprint is preserved. Proceed to the URL below to Inhale Claimed Ownership.`})]}),(0,o.jsxs)(`label`,{className:`field`,children:[(0,o.jsx)(`span`,{className:`field-label`,children:`Hash`}),(0,o.jsxs)(`div`,{className:`row`,children:[(0,o.jsx)(`code`,{className:`hash`,title:n||`—`,children:n?C:`—`}),(0,o.jsx)(`button`,{className:`icon-btn`,onClick:()=>x(n,`Hash`),disabled:!n,"aria-label":`Copy hash`,title:`Copy hash`,type:`button`,children:(0,o.jsx)(f,{})})]}),n&&(0,o.jsxs)(`p`,{className:`micro`,children:[`Full: `,(0,o.jsx)(`span`,{className:`mono`,children:n})]})]}),(0,o.jsxs)(`label`,{className:`field`,children:[(0,o.jsx)(`span`,{className:`field-label`,children:`URL`}),(0,o.jsxs)(`div`,{className:`row`,children:[(0,o.jsx)(`input`,{className:`url-input`,value:t,readOnly:!0,"aria-readonly":`true`,spellCheck:!1}),(0,o.jsx)(`button`,{className:`icon-btn`,onClick:()=>x(t,`Link`),disabled:!t,"aria-label":`Copy link`,title:`Copy link`,type:`button`,children:(0,o.jsx)(f,{})}),t&&(0,o.jsx)(`a`,{className:`open-link`,href:t,target:`_blank`,rel:`noopener`,"aria-label":`Open link in new tab`,title:`Open link`,children:(0,o.jsx)(p,{})})]})]}),(0,o.jsx)(`div`,{className:`cta-row`,children:(0,o.jsxs)(`button`,{className:`secondary cta`,onClick:S,type:`button`,children:[(0,o.jsx)(d,{}),(0,o.jsx)(`span`,{children:v?`Share`:`Remember Link`})]})}),(0,o.jsx)(`p`,{className:`fine`,children:`This moment is now sealed in time. Use the link above within the next 11 breaths to claim ownership & gain permanent access to this Kairos moment.`}),(0,o.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:h})]})]}),document.body):null},u=()=>(0,o.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":!0,className:`seal-close-ico`,children:[(0,o.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,opacity:`.35`}),(0,o.jsx)(`path`,{d:`M7 7l10 10M17 7L7 17`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})]}),d=()=>(0,o.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":!0,className:`ico`,children:[(0,o.jsx)(`path`,{d:`M15 8a3 3 0 100-6 3 3 0 000 6zM6 14a3 3 0 100-6 3 3 0 000 6zm9 12a3 3 0 100-6 3 3 0 000 6z`,fill:`currentColor`}),(0,o.jsx)(`path`,{d:`M8.6 9.7l6.8-3.4M8.6 12.3l6.8 3.4`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`})]}),f=()=>(0,o.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":!0,className:`ico`,children:[(0,o.jsx)(`rect`,{x:`9`,y:`9`,width:`10`,height:`10`,rx:`2`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`}),(0,o.jsx)(`rect`,{x:`5`,y:`5`,width:`10`,height:`10`,rx:`2`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,opacity:`.5`})]}),p=()=>(0,o.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":!0,className:`ico`,children:[(0,o.jsx)(`path`,{d:`M10 14a5 5 0 007.07 0l1.41-1.41a5 5 0 00-7.07-7.07L10 6`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`}),(0,o.jsx)(`path`,{d:`M14 10a5 5 0 00-7.07 0L5.5 11.43a5 5 0 007.07 7.07L14 18`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`})]}),m=l;export{m as t};